Encoder and signal processing method applied to same
By quantizing and optimizing the encoder design, the problem of maintaining video quality and reducing the size of encoded data was solved, achieving effective control of the number of data bits after encoding and reducing the complexity of hardware circuits.
Patent Information
- Application Number
- CN202411201776.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Priority Date
- 2024-08-07
- Filing Date
- 2024-08-29
- Publication Date
- 2026-02-10
AI Technical Summary
How to design an encoder that maintains video quality while minimizing the size of the output encoded data.
The video frame data is quantized and adjusted using a quantization circuit and a post-quantization data adjustment circuit. Combined with an optimization level calculation circuit, the quantization parameters and coefficients are dynamically adjusted to control the number of bits in the encoded data.
Effectively control the number of bits in the encoded data, reduce hardware circuit complexity, and maintain video quality.
Smart Images

Figure CN121509652A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to a video encoder. Background Technology
[0002] In video encoders, bitrate control results in higher video quality but also larger encoded data outputs. Conversely, lower bitrates lead to lower video quality but smaller encoded data outputs. Therefore, designing an encoder that maintains video quality while minimizing output data size is a crucial challenge. Summary of the Invention
[0003] Therefore, one of the objectives of this invention is to provide an encoder and a related signal processing method to solve the problems described in the prior art.
[0004] In one embodiment of the present invention, an encoder is disclosed, comprising a quantization circuit, a quantized data adjustment circuit, and an encoding circuit. The quantization circuit sequentially quantizes multiple blocks in a current frame of data to generate multiple quantized data corresponding to the multiple blocks. For each block in the current frame of data, the quantized data adjustment circuit adjusts multiple coefficients in the quantized data corresponding to that block according to an optimization level of that block to generate adjusted quantized data. The encoding circuit encodes the adjusted quantized data of each block to generate encoded data.
[0005] In one embodiment of the present invention, a signal processing method for an encoder is disclosed, comprising the following steps: sequentially quantizing multiple blocks in a current frame of data to generate multiple quantized data corresponding to the multiple blocks respectively; for each block in the current frame of data, adjusting multiple coefficients in the quantized data corresponding to the block according to an optimization level of the block to generate adjusted quantized data; and encoding the adjusted quantized data of each block to generate encoded data. Attached Figure Description
[0006] Figure 1 This is a schematic diagram of an encoder according to an embodiment of the present invention.
[0007] Figure 2 This is a flowchart illustrating the operation of a quantization parameter calculation circuit according to an embodiment of the present invention.
[0008] Figure 3 This is a schematic diagram of multiple blocks of frame data.
[0009] Figure 4 This is a flowchart illustrating the operation of an optimization level calculation circuit according to an embodiment of the present invention.
[0010] Figure 5 This is a schematic diagram of a block group according to an embodiment of the present invention.
[0011] Figure 6 This is a flowchart illustrating the operation of a quantized data adjustment circuit according to an embodiment of the present invention. Detailed Implementation
[0012] Figure 1 This is a schematic diagram of an encoder 100 according to an embodiment of the present invention. Figure 1 As shown, encoder 100 includes a transformation circuit 110, a quantization circuit 120, a quantized data adjustment circuit 130, an encoding circuit 140, an optimization level calculation circuit 150, and a quantization parameter calculation circuit 160. In this embodiment, encoder 100 supports the AV1 video encoding format defined by the Open Media Consortium (AOMedia), but the present invention is not limited thereto.
[0013] In the main operation of encoder 100, conversion circuit 110 performs Discrete Cosine Transform (DCT) on image data, such as a frame, to convert the image data into frequency domain data. Next, quantization circuit 120 quantizes the frequency domain data generated by conversion circuit 110 according to a quantization parameter provided by quantization parameter calculation circuit 160 to generate quantized data. Each frame's quantization operation corresponds to a quantization parameter, and the quantized data contains multiple sets of coefficients from multiple blocks in the image data. Then, quantized data adjustment circuit 130 adjusts a set of coefficients for each block according to the optimization level provided by optimization level calculation circuit 150 to generate adjusted quantized data. Encoding circuit 140, which may be a Variable-Length Code (VLC) encoder, encodes the adjusted quantized data to generate encoded data, which is then transmitted to a decoder (not shown) via a back-end channel. In addition, the encoded data is provided to the optimization level calculation circuit 150 to determine the optimization level of each block, and to the quantization parameter calculation circuit 160 to calculate the quantization parameters of the next image data (i.e., the next frame data).
[0014] It should be noted that the main operations of the conversion circuit 110, quantization circuit 120, and encoding circuit 140 in encoder 100 are well known to those skilled in the art, and the focus of this invention is on the quantized data adjustment circuit 130, the optimization level calculation circuit 150, and / or the quantization parameter calculation circuit 160. Therefore, the following description mainly focuses on the contents of the quantized data adjustment circuit 130, the optimization level calculation circuit 150, and the quantization parameter calculation circuit 160.
[0015] Regarding the operation of the quantization parameter calculation circuit 160, please refer to... Figure 2 In the flowchart described above, at step 200, the process begins, encoder 100 receives current frame data and begins processing, and encoder 100 has already completed the processing of the previous frame data to generate encoded data of the previous frame data. At step 202, quantization parameter calculation circuit 160 obtains the target number of bits for the current frame data and the encoding and / or quantization information of the previous frame data. In this embodiment, the target number of bits for the current frame data refers to the expected number of bits after the current frame data completes the encoding operation. For example, assuming encoder 100 is applied to 4K resolution, frame rate (frames per second, FPS) is 60, and transmission rate is 800 Mbps (megabits per second), then the target number of bits for the current frame data can be calculated as follows: 800 * 3840 * 2160 / 60 = 110592000 bits. Furthermore, since encoder 100 processes frame data as follows... Figure 3 The frame data 300 is divided into multiple blocks (represented by "MB"). Assuming each block is 16*16 pixels in size, the target number of bits for each block can be calculated as follows: 110592000 / [(3840 / 16)*(2160 / 16)] ~ 3413 bits. In one embodiment, the encoding and / or quantization information of the previous frame data may include at least the quantization parameters of the previous frame data, the number of encoded bits for each block of the previous frame data, and the optimization level for each block. The details of the optimization level for each block will be explained later in the specification.
[0016] In step 204, the quantization parameter calculation circuit 160 determines the quantization parameters of the current frame data based on the target number of bits in the current frame data and the encoding and / or quantization information of the previous frame data. In one embodiment, assuming that the encoding and / or quantization information of the previous frame data includes the quantization parameters of the previous frame data, the number of encoded bits in each block of the previous frame data, and the optimization level of each block, the quantization parameter calculation circuit 160 can first accumulate the number of encoded bits in each block of the previous frame data to obtain the number of bits in the encoded data of the previous frame data, then accumulate the optimization levels of each block to obtain a sum of optimization levels, and then divide the sum of optimization levels by the number of blocks in the previous frame data to obtain a block average optimization level. In addition, the quantization parameter calculation circuit 160 calculates a critical value for quantization parameter adjustment based on the target number of bits in the current frame data, wherein the critical value can be generated by a lookup table method, or by multiplying an adjustment parameter determined by a lookup table method by the target number of bits in the current frame data. Next, the quantization parameter calculation circuit 160 determines whether the number of bits in the encoded data of the previous frame is greater than the threshold value, and / or determines the relationship between the sum of optimization levels and multiple adjustment parameters, in order to decide whether to increase or decrease the quantization parameters of the previous frame to obtain the quantization parameters of the current frame. For example, assuming that the number of bits in the encoded data of the previous frame is greater than the threshold value, or the sum of optimization levels exceeds the smallest adjustment parameter among the multiple adjustment parameters, the quantization parameter calculation circuit 160 increases the quantization parameters of the previous frame to obtain the quantization parameters of the current frame, so that the encoded data generated by the encoder 140 after processing of the current frame will have fewer bits. The adjustment amount of the quantization parameters can be determined based on which of the multiple intervals the number of bits in the encoded data of the previous frame falls into, or based on which of the multiple intervals the sum of optimization levels falls into. That is, the higher the number of bits in the encoded data of the previous frame, or the higher the sum of optimization levels, the higher the adjustment amount of the quantization parameters. Furthermore, assuming that the number of bits in the encoded data of the previous frame is less than the threshold, the quantization parameter calculation circuit 160 will reduce the quantization parameter of the previous frame to obtain the quantization parameter of the current frame, so that the encoded data generated by the encoder 140 after processing of the current frame will have a higher number of bits. The adjustment amount of the quantization parameter can be determined according to which of the multiple intervals the number of bits in the encoded data of the previous frame falls into. That is, the lower the number of bits in the encoded data of the previous frame, the higher the adjustment amount of the quantization parameter.
[0017] It should be noted that the detailed calculation method of the quantization parameter calculation circuit 160 described above is only an example and not a limitation of the present invention.
[0018] After determining the quantization parameters of the current frame data, the quantization parameter calculation circuit 160, and the quantization circuit 120, based on these parameters, perform quantization operations on the frequency domain data generated by the conversion circuit 110 to produce quantized data. The quantization circuit 120 performs the quantization operation sequentially on blocks within the current frame data, for example, sequentially from... Figure 3 Starting from the first row of the frame data 300 shown, each block is quantized from left to right to generate quantized data corresponding to each block, where the quantized data of each block contains a matrix with multiple coefficients. Then, the quantized data of each block of the current frame data is sequentially processed by the quantized data adjustment circuit 130 and the encoding circuit 140 to generate the corresponding encoded data.
[0019] Since the quantization parameters used in each block of the current frame data are the same, in order to ensure that the encoded data generated by the encoding circuit 140 is lower than the target number of bits of the current frame data, the present invention further proposes an optimization level calculation circuit 150 and a quantized data adjustment circuit 130 to further adjust the quantized data of each block according to the information of each block.
[0020] In the operation of the optimization level calculation circuit 150, it is used to calculate the optimization level of each block. The optimization level reflects the degree to which the quantized data of the block needs adjustment. For example, a higher optimization level means that the quantized data of the block needs to be adjusted more significantly to greatly reduce the number of bits in the corresponding encoded data, while a lower optimization level means that the quantized data of the block needs to be adjusted less significantly, or not adjusted at all, to slightly reduce the number of bits in the corresponding encoded data. In one embodiment, the optimization level calculation circuit 150 can estimate the number of bits in the encoded data of the current unencoded block and its optimization level by using the number of bits in the encoded data of some already encoded blocks and their optimization levels, for operation by the quantized data adjustment circuit 130.
[0021] Figure 4 This is a flowchart illustrating the operation of an optimization level calculation circuit 150 according to an embodiment of the present invention. At step 400, the process begins. At step 402, the optimization level calculation circuit 150 groups multiple blocks in the current frame data to generate multiple block groups. Figure 5 Taking an example, the optimization level calculation circuit 150 groups multiple blocks, such as four blocks, to generate multiple block groups 510_1, 510_2, 510_3, ..., where multiple block groups 510_1, 510_2, and 510_3 are located in the same column. It should be noted that... Figure 5The number of blocks contained in each block group is merely an illustrative example and not a limitation of the invention.
[0022] In step 404, the optimization level calculation circuit 150 selects the block group that has not yet been encoded. In step 406, the optimization level calculation circuit 150 refers to the encoding information of the already encoded blocks to determine the optimization level of the current block group, wherein the encoding information of the already encoded blocks may include the number of bits of the encoded data of the already encoded blocks, the optimization level, etc. For example, assuming the selected unencoded block group is 510_3, and the blocks in the first column of block groups 510_1 and 510_2 have been encoded and generated corresponding encoded data and optimization levels, the optimization level calculation circuit 150 can first predict the number of bits of encoded data of the block in the upper left corner of block group 510_3 based on the number of bits of encoded data of the block in the upper left corner of block group 510_1 and the number of bits of encoded data of the block in the upper left corner of block group 510_2. The predicted number of bits of encoded data of the block in the upper left corner of block group 510_3 can be calculated using a weighted average or other suitable methods. Next, since the target number of bits for each block in the current frame data is known, the optimization level calculation circuit 150 can determine a total number of available bits based on the difference between the number of bits of the encoded data and the target number of the blocks in the first column of block group 510_1, and the difference between the number of bits of the encoded data and the target number of the blocks in the first column of block group 520_1. In this embodiment, the total number of available bits is the sum of the target number of the already encoded blocks minus the sum of the number of bits of the encoded data. That is, if the total number of available bits is a positive value, it indicates that there are more extra bits available for subsequent encoded blocks. Next, the optimization level calculation circuit 150 can determine the total number of available bits based on the target number of the block in the upper left corner of block group 510_3, the predicted number of bits of the encoded data, the total number of available bits, and the optimization level of the blocks in block groups 510_1 and 510_2. In one example, if the number of bits of the predicted encoded data of the top-left block of block group 510_3 is greater than the target number of bits, and / or the total number of available bits is less than a threshold, then the optimization level calculation circuit 150 can increase the optimization level of block group 510_2, or obtain the optimization level of block group 510_3 based on the optimization levels of block groups 510_1 and 510_2.
[0023] In the above embodiments, the blocks in each block group are set to have the same optimization level. Therefore, the optimization level calculation circuit 150 only needs to process one block in each block group, such as the upper left block in each block group in the above embodiments, without needing to judge the optimization level of each block.
[0024] It should be noted that, in Figure 4 and Figure 5 In this embodiment, only the encoding information of blocks in block groups 510_1 and 510_2 is referenced in the process of calculating the optimization level of block group 510_3, but the present invention is not limited thereto. In other embodiments, the number of other blocks' encoding information referenced in the process of calculating the optimization level of block groups can vary depending on the designer's considerations.
[0025] In the operation of the quantized data adjustment circuit 130, it is used to adjust the coefficients in the quantized data according to the optimization level of each block, so as to further control the number of bits of the encoded data generated by the block after processing by the encoding circuit 140.
[0026] Figure 6 This is a flowchart illustrating the operation of a quantized data adjustment circuit 130 according to an embodiment of the present invention. At step 600, the process begins. At step 602, the quantized data adjustment circuit 130 sequentially obtains the quantized data of each block of the current frame data from the quantization circuit 120. At step 604, the quantized data adjustment circuit 130 selects a block that has not yet been processed. At step 606, the quantized data adjustment circuit 130 determines whether the optimization level of the block is greater than a threshold value; if not, the process proceeds to step 608; if yes, the process proceeds to step 610.
[0027] In step 608, the quantized data adjustment circuit 130 uses a first mode to adjust the quantized data of the block. The first mode is to slightly reduce or not adjust multiple coefficients in the quantized data to generate an adjusted quantized data of the block. The number of bits of the encoded data generated after the adjusted quantized data is processed by the encoding circuit 140 is slightly lower than or the same as the number of bits of the encoded data generated after the quantized data is processed by the encoding circuit 140. For example, suppose the quantized data of the block is an 8x8 matrix, meaning the quantized data contains 64 coefficients (with index values from 0 to 63), and the optimization level of the block is between 1 and this threshold. The quantized data adjustment circuit 130 can first select a subset of these 64 coefficients, such as coefficients with index values below another threshold or coefficients in the lower right corner of the 8x8 matrix. It then subtracts a fixed value from the coefficients with positive values in this subset and adds the fixed value to the coefficients with negative values to generate adjusted quantized data. This fixed value can be 1, 2, 3, 4, etc. Furthermore, if the optimization level of the block is zero, the quantized data adjustment circuit 130 will not adjust any of the coefficients in the quantized data; that is, the adjusted quantized data will be equal to the quantized data.
[0028] In step 610, the quantized data adjustment circuit 130 uses a second mode to adjust the quantized data of the block. The second mode significantly reduces multiple coefficients in the quantized data to generate adjusted quantized data for the block. The number of bits in the encoded data generated after processing by the encoding circuit 140 is significantly lower than the number of bits in the encoded data generated after processing by the encoding circuit 140. In other words, the adjustment amount of the second mode on the multiple coefficients in the quantized data is greater than the adjustment amount of the first mode on the multiple coefficients in the quantized data. For example, the quantized data adjustment circuit 130 can first use the first mode to adjust multiple coefficients in the quantized data to generate a temporary adjusted quantized data, and then significantly adjust the coefficients in the temporary quantized data whose values are greater than another threshold value, for example, by setting them directly to "0" or shifting them one bit to the right (i.e., dividing by "2"), to generate the adjusted quantized data.
[0029] Next, the process returns to step 604 to continue processing the next block.
[0030] In summary, in the encoder and related operations of this invention, by dynamically adjusting the quantization parameters of each frame of data and / or calculating the optimization level of each block in the frame of data to adjust multiple coefficients of the quantized data of the block, the complexity of the hardware circuitry can be significantly reduced, and the number of bits of the encoded data generated by the encoder can be effectively controlled. As used herein, the term "and / or" includes any combination of one or more of the listed related items.
[0031] The above description is only a preferred embodiment of the present invention. All equivalent changes and modifications made in accordance with the claims of the present invention shall fall within the scope of the present invention.
[0032] [Symbol Explanation]
[0033] 100: Encoder
[0034] 110: Conversion circuit
[0035] 120: Quantization circuit
[0036] 130: Quantized data adjustment circuit
[0037] 140: Encoding circuit
[0038] 150: Optimization level calculation circuit
[0039] 160: Quantization parameter calculation circuit
[0040] 200~204: Steps
[0041] 300: Frame data
[0042] 400~406: Steps
[0043] 510_1 ~ 510_3: Block Groups
[0044] 600~610: Steps
[0045] MB: Block.
Claims
1. An encoder comprising: A quantization circuit is used to sequentially quantize multiple blocks in a current frame of data to generate multiple quantized data corresponding to the multiple blocks respectively. A quantized data adjustment circuit, wherein, For each block in the current frame data, the quantized data adjustment circuit adjusts multiple coefficients in the quantized data corresponding to the block according to an optimization level of the block, so as to generate an adjusted quantized data. as well as An encoding circuit is used to encode the adjusted quantized data of each block to produce encoded data.
2. The encoder as claimed in claim 1, further comprising: An optimization level calculation circuit, wherein, For a current block that has not yet been encoded by the encoding circuit, the optimization level calculation circuit refers to the encoding information of at least one block that has been encoded to determine the optimization level of the current block.
3. The encoder as described in claim 2, wherein, The encoding information of the at least one block that has been encoded includes the number of bits of the encoded data corresponding to the at least one block and the optimization level.
4. The encoder as claimed in claim 3, wherein, The optimization level calculation circuit calculates the number of bits of a predicted encoded data for the current block based on the number of bits of the encoded data for the at least one block that has already been encoded. The optimization level calculation circuit determines the optimization level of the current block based on the number of bits of the predicted encoded data of the current block, the sum of a target number of bits and a borrowable number of bits of the current block, and the optimization level of the at least one block.
5. The encoder as claimed in claim 1, wherein, If the optimization level of the block is not higher than a critical value, the quantized data adjustment circuit uses a first mode to adjust the multiple coefficients in the quantized data corresponding to the block to generate the adjusted quantized data. If the optimization level of the block is higher than the threshold, the quantized data adjustment circuit uses a second mode, different from the first mode, to adjust the multiple coefficients in the quantized data corresponding to the block, so as to generate the adjusted quantized data.
6. The encoder as claimed in claim 5, wherein, The adjustment amount of the second mode for the multiple coefficients in the quantized data of the block is greater than the adjustment amount of the first mode for the multiple coefficients in the quantized data of the block.
7. The encoder as claimed in claim 6, wherein, If the optimization level of the block is not higher than the critical value, the quantized data adjustment circuit uses the first mode to reduce the multiple coefficients in the quantized data of the block, or not to adjust the multiple coefficients in the quantized data, so as to generate the adjusted quantized data of the block. And if the optimization level of the block is higher than the threshold, the quantized data adjustment circuit uses the second mode to reduce the multiple coefficients in the quantized data of the block to generate the adjusted quantized data of the block.
8. The encoder of claim 1, further comprising: A quantization parameter calculation circuit is used to determine a quantization parameter of the current frame data based on a target number of bits of the current frame data and the encoding and / or quantization information of a previous frame data, so that the quantization circuit can sequentially quantize the multiple blocks in the current frame data.
9. A signal processing method applied to an encoder, comprising: Multiple blocks in a current frame of data are sequentially quantized to generate multiple quantized data corresponding to those blocks. For each block in the current frame data, multiple coefficients in the quantized data corresponding to that block are adjusted according to an optimization level of that block to produce adjusted quantized data; as well as The adjusted quantized data for each block is encoded to produce encoded data.
10. The signal processing method as described in claim 9, further comprising: If the optimization level of the block is not higher than a critical value, a first mode is used to adjust the multiple coefficients in the quantized data corresponding to the block to produce the adjusted quantized data; and If the optimization level of the block is higher than the threshold, a second mode, different from the first mode, is used to adjust the multiple coefficients in the quantized data corresponding to the block to generate the adjusted quantized data.