CN113014921A - Method, device and equipment for scheduling encoder - Google Patents
Method, device and equipment for scheduling encoder Download PDFInfo
- Publication number
- CN113014921A CN113014921A CN202110148303.8A CN202110148303A CN113014921A CN 113014921 A CN113014921 A CN 113014921A CN 202110148303 A CN202110148303 A CN 202110148303A CN 113014921 A CN113014921 A CN 113014921A
- Authority
- CN
- China
- Prior art keywords
- encoder
- type
- time
- encoding
- total
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N19/00—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
- H04N19/10—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
- H04N19/102—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the element, parameter or selection affected or controlled by the adaptive coding
- H04N19/13—Adaptive entropy coding, e.g. adaptive variable length coding [AVLC] or context adaptive binary arithmetic coding [CABAC]
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N19/00—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
- H04N19/10—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
- H04N19/102—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the element, parameter or selection affected or controlled by the adaptive coding
- H04N19/103—Selection of coding mode or of prediction mode
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N19/00—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
- H04N19/10—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
- H04N19/169—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding
- H04N19/17—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding the unit being an image region, e.g. an object
- H04N19/176—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding the unit being an image region, e.g. an object the region being a block, e.g. a macroblock
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N19/00—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
- H04N19/60—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using transform coding
- H04N19/625—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using transform coding using discrete cosine transform [DCT]
Landscapes
- Engineering & Computer Science (AREA)
- Multimedia (AREA)
- Signal Processing (AREA)
- Physics & Mathematics (AREA)
- Discrete Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Compression Or Coding Systems Of Tv Signals (AREA)
Abstract
The application provides a method, a device and equipment for scheduling an encoder, relates to the field of image processing, and can solve the problem of low encoding efficiency in the image encoding process. The specific technical scheme is as follows: acquiring unit coding time of each type of coder; counting the number of each type of macro blocks in the current frame image; determining the thread number of each type of encoder according to the unit encoding time of each type of encoder and the number of each type of macro block in the current frame image; and starting the corresponding encoder according to the number of the threads of each type of encoder. The invention is used for scheduling of the encoder.
Description
Technical Field
The present application relates to the field of image processing, and in particular, to a method, an apparatus, and a device for scheduling an encoder.
Background
In the process of image coding, it is usually necessary to perform segmentation processing on each frame of image, for example, it may be: firstly, transversely cutting an image into a plurality of strips, wherein each strip is called a slice; each slice is then sliced longitudinally into blocks, each block being called a macroblock. A macroblock is a basic unit of image compression, and features of an image are easier to generalize within the macroblock, for example, a macroblock may be composed of 16 × 16 or 256 pixels. The macro blocks can be classified into text blocks, picture blocks, video blocks, and the like by an image recognition algorithm, and further, there are macro blocks identical to a certain block of the previous frame image or a certain block of the present frame image. After the macro block identification classification is completed, targeted coding is carried out on different macro block types. For example, text blocks are huffman coded, picture blocks are jpeg or png coded, video blocks are 264 coded, etc.
In the specific implementation process of image coding, different encoders are usually implemented according to the adopted coding algorithms, after macro block division and identification are completed, the corresponding encoders are called according to different macro block types for coding, and then code streams obtained by coding of the encoders are spliced, so that coding of one frame of image is completed.
At present, a mainstream CPU mostly has multiple cores, and an operating system can also support multiple tasks, in order to improve coding efficiency, when a software coding program is implemented, all encoders can be simultaneously operated in a multi-task manner, and coding operations of different macro blocks are implemented in parallel. However, this method has the following limitations:
firstly, since images are very different, after the images are divided into macro blocks, the distribution of the number of each type of macro block in the total number of the macro blocks is also very different, even the whole frame of image only contains one type of macro block, for example, all the macro blocks are video blocks when the video is played on the full screen, and no text or picture macro blocks exist; for another example, when a screen displays a text file, there are almost only text blocks, and almost no picture blocks or video blocks. Thus, the workload of each encoder is dynamically variable, and thus, the respective time consumption of each encoder must also be dynamically variable for the complete encoding of a frame of an image.
Second, the complexity of each encoder algorithm is different, and thus the time required for each encoder to calculate a macroblock is different. For example, binary arithmetic coding (CABAC) is more complex than adaptive variable length coding (CAVLC), and accordingly takes longer than the latter.
In an actual coding design, the code stream of one frame of image can be spliced only after all the encoders complete coding, but due to the above limitations, the situation that some encoders complete coding and other encoders still perform coding occurs in the coding process, and the encoders cannot complete coding basically and synchronously, so that the multi-core and multi-task capability is wasted, and the coding efficiency is low.
Disclosure of Invention
The embodiment of the application provides a method, a device and equipment for scheduling an encoder, which can solve the problem of low encoding efficiency in the image encoding process. The technical scheme is as follows:
according to a first aspect of embodiments of the present application, there is provided a method of scheduling an encoder, the method including:
acquiring unit coding time of each type of encoder, wherein the unit coding time is the time for coding a macro block in an image;
counting the number of each type of macro blocks in the current frame image;
determining the thread number of each type of encoder according to the unit encoding time of each type of encoder and the number of each type of macro block in the current frame image;
and starting the corresponding encoder according to the thread number of each type of encoder.
The method for scheduling the encoders can determine the thread number of each type of encoder according to the unit encoding time of each type of encoder and the number of each type of macro block in the current frame image, and schedules each encoder.
In one embodiment, the determining the number of threads started by each type of encoder according to the unit encoding time of each type of encoder and the number of each type of macroblock in the current frame image includes:
calculating the total operation amount of each type of encoder according to the number of each type of macro block and the unit encoding time of each type of encoder;
sequencing the total operation amount of each type of encoder to obtain a sequencing result of the total operation amount;
and determining the thread quantity of each type of encoder according to a preset rule based on the sequencing result of the total operand.
In one embodiment, the determining, according to a preset rule, the number of threads of each type of encoder based on the sorting result of the total operand includes:
determining the number of threads of the encoder with the minimum total operand as R1 according to the sorting result of the total operand, wherein R1 is the preset minimum number of threads, and R1 is a positive integer;
determining the number of threads of the corresponding type of encoders by using a first formula aiming at other total operation quantities except the minimum total operation quantity;
the first formula is: ri=[Ti/Tmin]*R1;
Wherein R isiRepresenting the number of threads of the encoder corresponding to the ith total operand in the other total operands, TiA value representing the ith of said other total operands, TminRepresents the minimum total operand, [ T ]i/Tmin]Representative pair Ti/TminThe value of (c) is rounded.
In one embodiment, after starting the corresponding encoder according to the number of threads of each type of encoder, the method further includes:
monitoring the started encoder;
when it is monitored that any one encoder completes encoding and other encoders are still executing encoding tasks, the thread occupied by the encoder which completes encoding is distributed to the encoder which has the highest total operation amount in the encoders which are currently executing the encoding tasks.
In the process of image coding, by monitoring the started encoders, the threads occupied by the encoders which have completed coding can be distributed to the encoders with the highest total computation amount in the encoders which are currently executing coding tasks to complete the remaining coding tasks, so that the occupancy rate of a processor and the efficiency of image coding are further improved.
In one embodiment, before the obtaining of the unit encoding time of each type of encoder, the method further includes:
calculating unit coding time of each type of coder;
and saving the unit coding time of each type of coder.
In one embodiment, the unit encoding time of each type of encoder is expressed in a time complexity manner; the calculating the unit encoding time of each type of encoder comprises:
counting the calculation time of a reference type encoder and the calculation time of other encoders except the reference type encoder by taking a macro block as a calculation unit;
taking the time complexity of the reference type encoder as m, and calculating the time complexity of other encoders except the reference type encoder by using a second formula;
the second formula is: m ox=tx/tb;
Wherein o isxRepresenting the temporal complexity of an x-type encoder, said x-type encoder being any one of the other types of encoders than said reference type encoder, txRepresenting the computation time, t, of said x-type encoderbRepresenting the computation time of the reference type encoder.
The time complexity of each type of encoder is obtained by normalizing the calculation time of each type of encoder, and the total calculation amount of each type of macro block can be conveniently sequenced and compared.
According to a second aspect of embodiments of the present application, there is provided an apparatus for scheduling an encoder, including:
the device comprises an acquisition module, a decoding module and a decoding module, wherein the acquisition module is used for acquiring unit coding time of each type of encoder, and the unit coding time is time for coding a macro block in an image;
the statistic module is used for counting the number of each type of macro blocks in the current frame image;
the scheduling module is used for determining the thread number of each type of encoder according to the unit encoding time of each type of encoder and the number of each type of macro block in the current frame image;
and the starting module is used for starting the corresponding encoder according to the thread number of each type of encoder.
The device for scheduling the encoders can determine the thread number of each type of encoder according to the unit encoding time of each type of encoder and the number of each type of macro block in the current frame image, and schedules each encoder.
In one embodiment, the scheduling module comprises:
the calculation unit of the computation amount, is used for calculating the total computation amount of each type of coder according to the unit code time of said each type of coder and the quantity of said each type of macroblock;
the sorting unit is used for sorting the total operand of each type of encoder to obtain a sorting result of the total operand;
and the thread determining unit is used for determining the thread quantity of each type of encoder according to a preset rule based on the sequencing result of the total operand.
In one embodiment, the apparatus further comprises:
the monitoring module is used for monitoring the started encoder;
and the distribution module is used for distributing the thread occupied by the encoder which finishes the encoding to the encoder with the highest total computation amount in the encoders which are currently executing the encoding task when monitoring that any one encoder finishes the encoding and other encoders are still executing the encoding task.
The device for scheduling the encoders provided by the embodiment of the application can distribute the threads occupied by the encoders which have completed encoding to the encoders with the highest total computation in the encoders which are currently executing the encoding tasks to complete the remaining encoding tasks by monitoring the started encoders, thereby further improving the occupancy rate of the processor and the efficiency of image encoding.
According to a third aspect of embodiments of the present application, there is provided an apparatus for scheduling an encoder, the apparatus comprising a processor and a memory, the memory storing therein at least one computer instruction, the instruction being loaded and executed by the processor to implement the steps performed in the method for scheduling an encoder described above.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the application.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and together with the description, serve to explain the principles of the application.
Fig. 1 is a flowchart of a method for scheduling encoders according to an embodiment of the present application;
fig. 2 is a flowchart of another method for scheduling encoders according to an embodiment of the present application;
fig. 3 is a schematic structural diagram of an apparatus for scheduling encoders according to an embodiment of the present application;
fig. 4 is a schematic structural diagram of another apparatus for scheduling an encoder according to an embodiment of the present application;
fig. 5 is a schematic structural diagram of another apparatus for scheduling encoders according to an embodiment of the present application;
fig. 6 is a schematic structural diagram of an apparatus for scheduling an encoder according to an embodiment of the present application;
fig. 7 is a schematic structural diagram of an apparatus for scheduling an encoder according to an embodiment of the present application.
Detailed Description
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present application, as detailed in the appended claims.
An embodiment of the present application provides a method for scheduling an encoder, and as shown in fig. 1, the method for scheduling an encoder includes the following steps:
step 101: the unit encoding time of each type of encoder is acquired.
And acquiring unit coding time of each type of coder provided by the current coding platform, wherein the unit coding time is the time for coding one macro block in the image.
In one embodiment, the unit encoding time of each type of encoder may be calculated in advance, the calculated unit encoding time of each type of encoder may be stored, and the unit encoding time of each type of encoder may be used directly when encoding an image.
Step 102: and counting the number of each type of macro block in the current frame image.
When a frame of image is coded, the number of each type of macro block in the current frame of image is counted. For the current frame image, the macro blocks into which it is divided may include at least one of various types, such as text macro blocks, video macro blocks, image macro blocks, and the like. Each type of macroblock may be encoded using at least one type of encoder, such as a text macroblock encoded using a type a encoder, a video macroblock encoded using a type B encoder, an image macroblock encoded using a type C encoder, and so on.
Specifically, the percentage of the statistics on the number of each type of macro blocks may be directly calculated according to the ratio of the count of each type of macro blocks to the total number of macro blocks in the whole frame picture, so as to obtain the statistics value of the number of each type of macro blocks, which may be respectively recorded as: p is a radical oftxt(statistics of the number of macroblocks of text), ppct(statistics of the number of macroblocks in a picture), pmov(statistics of the number of video macroblocks) and the like.
Step 103: the number of threads for each type of encoder is determined.
And after the number of each type of macro block in the current frame image is determined, determining the thread number of each type of encoder according to the unit encoding time of each type of encoder and the number of each type of macro block in the current frame image.
Specifically, the total computation of each type of encoder may be calculated according to the number of each type of macroblock and the unit encoding time of each type of encoder, then the total computation of each type of encoder is sorted to obtain a sorting result of the total computation, and then the number of threads of each type of encoder is determined according to a preset rule based on the sorting result of the total computation.
The method for determining the number of threads of each type of encoder according to the preset rule may be: determining the number of threads of the encoder with the minimum total operand as R1, wherein R1 is a positive integer and represents a preset minimum number of threads, and can be 1, for example; for the total calculation amount except the minimum total calculation amount, the first formula R is usedi=[Ti/Tmin]R1 determines the number of threads of the encoder of the corresponding type; wherein R isiRepresents the number of threads of the encoder corresponding to the ith (i is an integer) total operand in other total operands, TiA value representing the ith of the other total operands, TminRepresents the minimum total operand, [ Ti/Tmin]Representative pair Ti/TminThe value of (c) is rounded.
In this step, the number of threads of each type of encoder used in encoding the current frame image is usually determined, and the encoder used in encoding the current frame image may be determined according to each type of macroblock in the current frame image.
Step 104: and starting the corresponding encoder according to the number of the threads of each type of encoder.
And after the thread number of each type of encoder is determined, starting the corresponding encoder according to the thread number of each type of encoder. For example, the current frame image includes text macroblocks and image macroblocks, the text macroblocks are encoded by an a-type encoder, the image macroblocks are encoded by a C-type encoder, the number of threads of the a-type encoder is determined to be M1 and the number of threads of the C-type encoder is determined to be M2 according to the unit encoding time of each type of encoder and the number of each type of macroblock in the current frame image, then an M1-way a-type encoder is started to encode the text macroblocks, and an M2-way C-type encoder is started to encode the image macroblocks.
The method for scheduling the encoders can determine the thread number of each type of encoder according to the unit encoding time of each type of encoder and the number of each type of macro block in the current frame image, and schedules each encoder.
Based on the method for scheduling an encoder provided in the embodiment corresponding to fig. 1, another embodiment of the present application provides a method for scheduling an encoder, which can be applied to an image encoding platform such as an image encoding apparatus and an image encoding device. Referring to fig. 2, the method for scheduling an encoder according to the present embodiment may include the following steps:
step 201: the unit encoding time of each type of encoder is calculated.
Before the thread number of each type of encoder is determined, the unit encoding time of each type of encoder provided by the current encoding platform can be determined, and the unit encoding time of each type of encoder can be measured once at first and then directly used. The unit encoding time is a time for encoding one macroblock in an image.
Specifically, the unit encoding time of each type of encoder may be represented in a time complexity manner, and may be calculated by the following method: firstly, taking a macro block as a calculating unit, and counting the calculating time of a reference type encoder and the calculating time of other encoders except the reference type encoder; then, taking the time complexity of the reference type encoder as m, for example, m may be taken as 1, and using a second formula m × ox=tx/tbCalculating the time complexity of encoders of various types other than the reference type encoder, wherein oxRepresenting the temporal complexity of an x-type encoder, which is any of the other types of encoders than the reference type encoder, txRepresenting the computation time, t, of the x-type encoderbRepresenting the computation time of the reference type encoder.
In order to facilitate the sequencing comparison, one encoder may be selected from various encoders provided by the current encoding platform as a reference type encoder, for example, the current encoding platform is provided with a huffman encoder, an adaptive variable length coder (CAVLC), a Discrete Cosine Transform (DCT) encoder, an Inverse Discrete Cosine Transform (iDCT) encoder, a binary arithmetic coding (CABAC) encoder, and the like, and the time complexity of the encoders such as the CAVLC, the iDCT, and the CABAC may be obtained by normalization processing with the computation time of the huffman encoder as a reference.
Specifically, in this step, the normalization is performed based on the calculation time of the huffman encoder, and the normalization process may include the following steps a1 to d 1:
step a 1: taking macro block as computing unit, counting the computing time of Huffman coder, and recording as tb;
Step b 1: respectively recording the time of completing one macro block calculated by other encoder algorithms (such as CAVLC, DCT, iDCT, CABAC and the like) except the Huffman encoder, taking DCT as an example and recording tDCT;
Step c 1: taking the time complexity of the huffman coder as 1, the time complexity of the DCT coder can be calculated as: oDCT=tDCT/tb;
Step d 1: the complexity of the encoder algorithms such as iDCT, CAVLC and CABAC is respectively calculated in the same way as the DCT encoder, and o is respectively obtainediDCT、oCAVLCAnd oCABAC。
Step 202: the unit encoding time of each type of encoder is saved.
After the unit coding time of each type of encoder is obtained through calculation, the unit coding time of each type of encoder can be stored, and the unit coding time can be directly used when the thread number of each type of encoder is determined subsequently.
Step 203: the unit encoding time of each type of encoder is acquired.
When the number of threads of each type of encoder is determined, the unit encoding time of each type of encoder is acquired. Specifically, the unit encoding time of each type of encoder that is saved may be read from the memory.
Step 204: and counting the number of each type of macro block in the current frame image.
Before determining the thread number of each type of encoder for the current frame image, counting the number of each type of macro block in the current frame image. Specifically, the percentage of the statistics on the number of each type of macro blocks can be directly calculated according to the ratio of the count of each type of macro blocks to the total number of macro blocks of the whole frame picture, so as to obtain the statistical value of the number of each type of macro blocks.
Generally, one type of encoder may correspond to at least one type of macroblock, for example, a type a encoder may be used for text macroblock encoding as well as for image macroblock encoding; as another example, an image macroblock may be encoded using an a-type encoder or a B-type encoder. In practical application, after the number of each type of macro block in the current frame image is counted, a proper encoder can be selected for each type of macro block according to the counting result, so as to further improve the encoding efficiency.
For example, a minimum number X of macroblocks may be preset, and when the number of macroblocks of a certain type is counted to be smaller than the minimum number X of macroblocks, if the macroblock of the certain type can be encoded by more than one type of encoder, the encoder with the highest encoding speed may be selected to encode the macroblock of the certain type. For example, an image macroblock may be encoded using an a-type encoder or a B-type encoder, and a text macroblock may be encoded using a C-type encoder; when a current frame image is coded, counting that the current frame image comprises X1 image macro blocks and X2 character macro blocks, and assuming that a type A coder has a higher coding speed than a type B coder, the type B coder is a default coder for coding the image macro blocks; if X1 is greater than the preset minimum macroblock number X, encoding the image macroblock by using a default B-type encoder; if X1 is less than the predetermined minimum number of macroblocks X, the encoder for the image macroblock can be adjusted to be a type a encoder.
Step 205: the total amount of operations for each type of encoder is calculated.
After the number of each type of macroblock in the current frame image is determined, the total operation amount of each type of encoder may be calculated according to the number of each type of macroblock and the unit encoding time of each type of encoder, where the number of each type of macroblock may be represented in the manner of the statistical value described in step 102. Specifically, the total computation amount of each type of encoder may be calculated by weighting the unit encoding time of each type of encoder.
Specifically, taking the DCT coder as an example, the DCT coder is respectively used in jpeg encoding and H264 encoding, where jpeg encoding is mainly for picture macro blocks and H264 encoding is mainly for video macro blocks, so that the total computation T of the DCT coder isDCTCan be calculated by the following formula:
TDCT=oDCT×(ppct+pmov);
wherein o isDCTRepresenting the temporal complexity, p, of a DCT coderpctStatistics value p representing the number of picture macroblocksmovA statistic value representing the number of video macroblocks.
Similarly, the total computation of other encoders, such as the total computation T of the iDCT encoder, can be determined in a similar manneriDCTTotal operation quantity T of CAVLC coderCAVLCAnd the total operation amount T of CABAC encoderCABACAnd the like.
Step 206: the total amount of operations for each type of encoder is ordered.
And after the total computation of each type of encoder is obtained through calculation, sequencing the total computation of each type of encoder to obtain a sequencing result of the total computation. For example, the sorting may be performed in a descending order or in a descending order.
Step 207: the number of threads for each type of encoder is determined.
And after the sequencing result of the total operand of each type of encoder is obtained, determining the thread number of each type of encoder according to a preset rule based on the sequencing result of the total operand. Specifically, the determination may be performed as follows: when encoding is started, the number of threads of the encoder with the minimum total operand is determined as R1, R1 is a preset minimum number of threads, for example, R1 may be taken as 1; aiming at other total operation quantity, the first formula R is utilizedi=[Ti/Tmin]R1 determines the number of threads of the corresponding type of encoder, wherein RiRepresenting the number of threads, T, of the encoder corresponding to the ith total operand among the other total operandsiA value representing the ith of the other total operands, TminRepresents the minimum total operand, [ Ti/Tmin]Representative pair Ti/TminIs rounded, i.e. does not exceed Ti/TminIs the largest integer of (a).
In practical application, the total number of threads created for all encoders should be limited, so that a processor (such as a central processing unit CPU) is prevented from being frequently in a thread switching state, and encoding efficiency is reduced. Typically, the number of bus threads should not exceed 3 times the number of current processor cores. In the case that the thread limit has been reached, the encoder of the type corresponding to the maximum total operand only starts path R1.
In practical applications, the current encoding platform may provide multiple types of encoders, and the current frame image to be encoded may only need a part of the encoders, and at this time, only the unit encoding time of the part of encoders may be acquired, and the number of threads of the encoders may be determined by the above method.
Step 208: and starting the corresponding encoder according to the number of the threads of each type of encoder.
Step 209: the activated encoder is monitored.
Step 210: and when monitoring that any one encoder finishes encoding and other encoders are still executing encoding tasks, adjusting the encoder thread according to a preset allocation rule.
Specifically, in the encoding process, the states of the started encoders can be monitored, and when it is monitored that any one encoder has completed encoding and other encoders are still executing encoding tasks, the thread occupied by the encoder which has completed encoding is allocated to the encoder which has the highest total computation amount in the encoders currently executing the encoding tasks to complete the remaining encoding tasks, so that the occupancy rate of the processor and the image encoding efficiency are improved.
In the above scheme, on one hand, the distribution of each type of macro block is considered, and for the type with a small number of macro blocks, because the number of the macro blocks is small, the influence on the size of the code stream is small, and a faster encoder algorithm can be adopted to improve the encoding efficiency. On the other hand, because the picture content of each frame of image is different, the image statistics can be performed once every N (N is a positive integer) frames of images, and the distribution of the encoder is adjusted based on the statistical result; for example, dynamic statistics may be performed for each frame of image and the encoder allocation may be adjusted based on the statistics.
According to the method for scheduling the encoders, the number of macro blocks of each type in a current frame image is counted by obtaining the unit encoding time of each type of encoder, the thread number of each type of encoder is determined according to the unit encoding time of each type of encoder and the number of macro blocks of each type in the current frame image, the corresponding encoder is started according to the thread number of each type of encoder, the calculation time of each type of encoder and the distribution number of macro blocks of different types in the current frame image are comprehensively considered, so that each encoder can complete work as simultaneously as possible, and the image encoding time is shortened from the counting angle of a complete frame; moreover, a proper encoder algorithm can be selected according to the distribution condition of each macro block in the current frame image, so that the conflict between the code stream size and the encoding time is balanced. .
Based on the methods for scheduling encoders described in the above embodiments, the following are embodiments of the apparatus of the present application, and may be used to implement embodiments of the method of the present application.
An embodiment of the present application provides an apparatus for scheduling an encoder, as shown in fig. 3, the apparatus 30 for scheduling an encoder includes: an acquisition module 301, a statistic module 302, a scheduling module 303 and a starting module 304;
the obtaining module 301 is configured to obtain a unit encoding time of each type of encoder, where the unit encoding time is a time for encoding a macroblock in an image;
the counting module 302 is configured to count the number of each type of macro block in the current frame image;
the scheduling module 303 is configured to determine the number of threads of each type of encoder according to the unit encoding time of each type of encoder and the number of each type of macro block in the current frame image;
the starting module 304 is configured to start the corresponding encoder according to the number of threads of each type of encoder.
As shown in fig. 4, the scheduling module 303 may include an operand calculation unit 3031, a sorting unit 3032, and a thread determination unit 3033;
the operand calculation unit 3031 is configured to calculate the total operand of each type of encoder according to the number of each type of macroblock and the unit encoding time of each type of encoder;
the sorting unit 3032 is configured to sort the total operand of each type of encoder to obtain a sorting result of the total operand;
the thread determining unit 3033 determines the thread number of each type of encoder according to a preset rule based on the sorting result of the total operand obtained by the sorting unit 3032. Specifically, the thread determining unit 3033 determines, according to the sorting result of the total operand obtained by the sorting unit 3032, the number of threads of the encoder having the smallest total operand as R1(R1 is a positive integer), where R1 is a preset minimum number of threads; for the total calculation amount except the minimum total calculation amount, the first formula R is usedi=[Ti/Tmin]R1 determines the number of threads of the encoder of the corresponding type; wherein R isiRepresenting the number of threads, T, of the encoder corresponding to the ith total operand among the other total operandsiA value representing the ith of the other total operands, TminRepresents the minimum total operand, [ Ti/Tmin]Representative pair Ti/TminThe value of (c) is rounded.
In one embodiment, as shown in fig. 5, the apparatus 30 for scheduling encoders further comprises a monitoring module 305 and an allocation module 306.
Wherein, the monitoring module 305 is configured to monitor the started encoder;
the allocation module 306 is configured to, when it is monitored that any one of the encoders has completed encoding and still has other encoders executing an encoding task, allocate a thread occupied by the encoder that has completed encoding to an encoder that has the highest total computation amount among the encoders currently executing the encoding task.
In one embodiment, as shown in fig. 6, the apparatus 30 for scheduling encoders further comprises a calculation module 307 and a storage module 308.
Wherein, the calculating module 307 is used for calculating the unit encoding time of each type of encoder;
the storage module 308 is used for storing the unit encoding time of each type of encoder calculated by the calculation module 307.
Specifically, the unit encoding time of each type of encoder may be expressed in a time complexity manner, and the calculation module 307 may include a statistics unit 3071 and a time complexity calculation unit 3072.
The statistic unit 3071 is configured to count the calculation time of the reference type encoder and the calculation time of each type of encoder other than the reference type encoder, using the macro block as the calculation unit;
the time complexity calculating unit 3072 is configured to take the time complexity of the reference type encoder as m, and calculate the time complexity of each type of encoder other than the reference type encoder by using a second formula; the second formula is: m ox=tx/tb(ii) a Wherein o isxRepresenting the temporal complexity of an x-type encoder, which is any of the other types of encoders than the reference type encoder, txRepresenting the computation time, t, of an x-type encoderbRepresenting the computation time of a reference-type encoder。
The device for scheduling the encoders can determine the thread number of each type of encoder according to the unit encoding time of each type of encoder and the number of each type of macro block in the current frame image, and schedules each encoder.
Referring to fig. 7, an embodiment of the present application further provides an apparatus 70 for scheduling an encoder, where the apparatus includes a processor 701 and a memory 702, where the memory 702 stores at least one computer instruction, and the computer instruction is loaded and executed by the processor 701 to implement the method for scheduling an encoder described in the corresponding embodiment of fig. 1 or fig. 2.
Based on the method for scheduling encoders described in the embodiments corresponding to fig. 1 and fig. 2, embodiments of the present application further provide a computer-readable storage medium, for example, the non-transitory computer-readable storage medium may be a Read Only Memory (ROM), a Random Access Memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, and the like. The storage medium stores computer instructions for executing the method for scheduling encoders described in the embodiments corresponding to fig. 1 and fig. 2, which is not described herein again.
Other embodiments of the present application will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure disclosed herein. This application is intended to cover any variations, uses, or adaptations of the invention following, in general, the principles of the application and including such departures from the present disclosure as come within known or customary practice within the art to which the invention pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the application being indicated by the following claims.
It will be understood that the present application is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the application is limited only by the appended claims.
Claims (10)
1. A method of scheduling an encoder, the method comprising:
acquiring unit coding time of each type of encoder, wherein the unit coding time is the time for coding a macro block in an image;
counting the number of each type of macro blocks in the current frame image;
determining the thread number of each type of encoder according to the unit encoding time of each type of encoder and the number of each type of macro block in the current frame image;
and starting the corresponding encoder according to the thread number of each type of encoder.
2. The method of claim 1, wherein the determining the number of threads started by each type of encoder according to the unit encoding time of each type of encoder and the number of each type of macroblock in the current frame image comprises:
calculating the total operation amount of each type of encoder according to the number of each type of macro block and the unit encoding time of each type of encoder;
sequencing the total operation amount of each type of encoder to obtain a sequencing result of the total operation amount;
and determining the thread quantity of each type of encoder according to a preset rule based on the sequencing result of the total operand.
3. The method according to claim 2, wherein the determining the number of threads of each type of encoder according to a preset rule based on the sorting result of the total operand comprises:
determining the number of threads of the encoder with the minimum total operand as R1 according to the sorting result of the total operand, wherein R1 is the preset minimum number of threads, and R1 is a positive integer;
determining the number of threads of the corresponding type of encoders by using a first formula aiming at other total operation quantities except the minimum total operation quantity;
the first formula is: ri=[Ti/Tmin]*R1;
Wherein R isiRepresenting the number of threads of the encoder corresponding to the ith total operand in the other total operands, TiA value representing the ith of said other total operands, TminRepresents the minimum total operand, [ T ]i/Tmin]Representative pair Ti/TminThe value of (c) is rounded.
4. The method of claim 2, wherein after starting the corresponding encoder according to the number of threads of each type of encoder, the method further comprises:
monitoring the started encoder;
when it is monitored that any one encoder completes encoding and other encoders are still executing encoding tasks, the thread occupied by the encoder which completes encoding is distributed to the encoder which has the highest total operation amount in the encoders which are currently executing the encoding tasks.
5. The method of claim 1, wherein prior to said obtaining the unit encoding time of each type of encoder, the method further comprises:
calculating unit coding time of each type of coder;
and saving the unit coding time of each type of coder.
6. The method according to claim 5, wherein the unit encoding time of each type of encoder is expressed in a time-complexity manner; the calculating the unit encoding time of each type of encoder comprises:
counting the calculation time of a reference type encoder and the calculation time of other encoders except the reference type encoder by taking a macro block as a calculation unit;
taking the time complexity of the reference type encoder as m, and calculating the time complexity of other encoders except the reference type encoder by using a second formula;
the second formula is: m ox=tx/tb;
Wherein o isxRepresenting the temporal complexity of an x-type encoder, said x-type encoder being any one of the other types of encoders than said reference type encoder, txRepresenting the computation time, t, of said x-type encoderbRepresenting the computation time of the reference type encoder.
7. An apparatus for scheduling an encoder, comprising:
the device comprises an acquisition module, a decoding module and a decoding module, wherein the acquisition module is used for acquiring unit coding time of each type of encoder, and the unit coding time is time for coding a macro block in an image;
the statistic module is used for counting the number of each type of macro blocks in the current frame image;
the scheduling module is used for determining the thread number of each type of encoder according to the unit encoding time of each type of encoder and the number of each type of macro block in the current frame image;
and the starting module is used for starting the corresponding encoder according to the thread number of each type of encoder.
8. The apparatus of claim 7, wherein the scheduling module comprises:
the calculation unit of the computation amount, is used for calculating the total computation amount of each type of coder according to the unit code time of said each type of coder and the quantity of said each type of macroblock;
the sorting unit is used for sorting the total operand of each type of encoder to obtain a sorting result of the total operand;
and the thread determining unit is used for determining the thread quantity of each type of encoder according to a preset rule based on the sequencing result of the total operand.
9. The apparatus of claim 8, further comprising:
the monitoring module is used for monitoring the started encoder;
and the distribution module is used for distributing the thread occupied by the encoder which finishes the encoding to the encoder with the highest total computation amount in the encoders which are currently executing the encoding task when monitoring that any one encoder finishes the encoding and other encoders are still executing the encoding task.
10. An apparatus for scheduling an encoder, comprising a processor and a memory, the memory having stored therein at least one computer instruction, the instruction being loaded and executed by the processor to perform the steps performed in the method of scheduling an encoder according to any one of claims 1 to 6.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110148303.8A CN113014921B (en) | 2021-02-03 | 2021-02-03 | Method, device and equipment for scheduling encoder |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110148303.8A CN113014921B (en) | 2021-02-03 | 2021-02-03 | Method, device and equipment for scheduling encoder |
Publications (2)
Publication Number | Publication Date |
---|---|
CN113014921A true CN113014921A (en) | 2021-06-22 |
CN113014921B CN113014921B (en) | 2025-06-13 |
Family
ID=76384996
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202110148303.8A Active CN113014921B (en) | 2021-02-03 | 2021-02-03 | Method, device and equipment for scheduling encoder |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN113014921B (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN117615141A (en) * | 2023-11-23 | 2024-02-27 | 镕铭微电子(济南)有限公司 | Video coding method, system, equipment and medium |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20130198753A1 (en) * | 2012-01-30 | 2013-08-01 | International Business Machines Corporation | Full exploitation of parallel processors for data processing |
CN107566842A (en) * | 2017-08-31 | 2018-01-09 | 西安万像电子科技有限公司 | The methods, devices and systems of image coding and decoding compression |
WO2021004126A1 (en) * | 2019-07-09 | 2021-01-14 | 西安万像电子科技有限公司 | Image coding method and apparatus |
-
2021
- 2021-02-03 CN CN202110148303.8A patent/CN113014921B/en active Active
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20130198753A1 (en) * | 2012-01-30 | 2013-08-01 | International Business Machines Corporation | Full exploitation of parallel processors for data processing |
CN107566842A (en) * | 2017-08-31 | 2018-01-09 | 西安万像电子科技有限公司 | The methods, devices and systems of image coding and decoding compression |
WO2021004126A1 (en) * | 2019-07-09 | 2021-01-14 | 西安万像电子科技有限公司 | Image coding method and apparatus |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN117615141A (en) * | 2023-11-23 | 2024-02-27 | 镕铭微电子(济南)有限公司 | Video coding method, system, equipment and medium |
Also Published As
Publication number | Publication date |
---|---|
CN113014921B (en) | 2025-06-13 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
KR100801630B1 (en) | Distributed decoding processing apparatus and method using a multicore processor | |
US8036474B2 (en) | Information processing apparatus enabling an efficient parallel processing | |
US20100195733A1 (en) | Video scene change detection and encoding complexity reduction in a video encoder system having multiple processing devices | |
JP5545288B2 (en) | Task allocation device, task allocation method, and task allocation program | |
CN103188521B (en) | Transcoding distribution method and device, code-transferring method and equipment | |
WO2008079041A1 (en) | Methods and apparatus to decode and encode video information | |
US20110072439A1 (en) | Decoding device, recording medium, and decoding method for coded data | |
CN105451020A (en) | Video compression method and device | |
US20140072029A1 (en) | Adaptive scaler switching | |
CN113473148A (en) | Computing system for video coding and video coding method | |
CN1299511C (en) | Scalable MPEG-2 video decoder with selective motion compensation | |
CN113014921B (en) | Method, device and equipment for scheduling encoder | |
US20150208072A1 (en) | Adaptive video compression based on motion | |
Zhao et al. | A dynamic slice control scheme for slice-parallel video encoding | |
US10791332B2 (en) | Video data processing system | |
KR101050188B1 (en) | Video decoding apparatus using multiprocessor and video decoding method in same apparatus | |
US11997275B2 (en) | Benefit-based bitrate distribution for video encoding | |
WO2014209366A1 (en) | Frame division into subframes | |
KR20180108315A (en) | Parallel encoding method and apparatus | |
Hsiao et al. | Balanced parallel scheduling for video encoding with adaptive gop structure | |
CN110933442B (en) | 16x4 level reference frame compression method and device | |
CN112437308A (en) | WebP coding method and device | |
JP5236386B2 (en) | Image decoding apparatus and image decoding method | |
CN119697369B (en) | Video stream encoding and decoding acceleration method and system based on microcomputer host | |
CN113347432B (en) | Video encoding and decoding method and device, computer equipment and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |