WO2019127136A1 - Bit rate control method and encoding device - Google Patents
Bit rate control method and encoding device Download PDFInfo
- Publication number
- WO2019127136A1 WO2019127136A1 PCT/CN2017/119111 CN2017119111W WO2019127136A1 WO 2019127136 A1 WO2019127136 A1 WO 2019127136A1 CN 2017119111 W CN2017119111 W CN 2017119111W WO 2019127136 A1 WO2019127136 A1 WO 2019127136A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- image
- encoded
- frame
- parameter
- complexity
- Prior art date
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/124—Quantisation
-
- 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/134—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the element, parameter or criterion affecting or controlling the adaptive coding
- H04N19/146—Data rate or code amount at the encoder output
-
- 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/134—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the element, parameter or criterion affecting or controlling the adaptive coding
- H04N19/157—Assigned coding mode, i.e. the coding mode being predefined or preselected to be further used for selection of another element or parameter
- H04N19/159—Prediction type, e.g. intra-frame, inter-frame or bidirectional frame prediction
-
- 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/50—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using predictive coding
-
- 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/61—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using transform coding in combination with predictive coding
-
- 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/90—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using coding techniques not provided for in groups H04N19/10-H04N19/85, e.g. fractals
- H04N19/91—Entropy coding, e.g. variable length coding [VLC] or arithmetic coding
Definitions
- Visual information is one of the most important sources for humans to obtain external information, but the uncompressed raw video data collected by the camera occupies a huge storage space with a resolution of 1920 ⁇ 1080, a frame rate of 30 frames per second, and a duration of 10
- storing the video without compression requires 104.28 Gbytes of storage space.
- the video coding process includes steps of prediction, transform, rate control, quantization, and entropy coding.
- the rate control plays a very important role in the video encoding process. Since the content and characteristics of different video sequences are different, if the same coding parameters are used for encoding, a very different output bit rate and different degrees of video distortion will be generated. To overcome this problem, rate control is proposed.
- the rate control algorithm adaptively adjusts the encoding parameters according to the characteristics of different video images.
- standards-based video encoders have great flexibility in the choice of encoding parameters, and the choice of encoding parameters can have a large impact on the code rate of the encoded video stream.
- the rate control algorithm may enable the encoder to select an appropriate coding parameter between a set of coding parameter sets to achieve the actual coded bits approximating the pre-assigned coded bits.
- the present application provides a code rate control method and apparatus, which can take into account the accuracy of the rate control and the computational complexity of the encoder in the rate control process.
- a method of rate control is provided, the method being applied to a video encoder, the method comprising: receiving image complexity of an image to be encoded, the image complexity being image processing connected to an encoder Obtaining a preset encoding bit of the image to be encoded; obtaining a quantization parameter of the image to be encoded according to the image complexity and the preset encoding bit; and according to the quantization parameter of the image to be encoded,
- the image to be encoded is encoded.
- an encoding apparatus comprising: a transceiver unit configured to receive an image complexity of an image to be encoded, the image complexity being acquired by an image processor connected to the encoder; And determining a preset coding bit of the image to be encoded; obtaining a quantization parameter of the image to be encoded according to the image complexity and the preset coding bit; and according to the quantization parameter of the image to be encoded,
- the image to be encoded is encoded.
- an encoding apparatus comprising a memory for storing instructions, the processor for executing the instructions stored by the memory, and instructions stored in the memory Execution of the processor causes the processor to perform the method provided by the first aspect.
- a chip comprising a processing module and a communication interface, the processing module is configured to control the communication interface to communicate with an external, and the processing module is further configured to implement the method provided by the first aspect.
- a fifth aspect a computer readable storage medium having stored thereon a computer program, the computer program being executed by a computer to cause the computer to implement the method of any of the first aspect or the first aspect .
- the computer may be the above-mentioned ** device.
- a computer program product comprising instructions, which when executed by a computer, causes the computer to implement the method provided by the first aspect.
- the embodiment of the present invention when the rate control is performed, the image complexity is acquired by the image processor external to the encoder, and a large amount of calculations that may occur may be performed by an image processor (such as an ISP) other than the encoder. Therefore, the calculation amount and implementation complexity of the encoder can be reduced, and the encoding delay caused by the secondary encoding of the encoder can be avoided.
- the embodiment of the present invention can obtain the quantization parameter according to the image complexity and the preset coding bit, so that the rate control precision can be guaranteed to a certain extent. Therefore, the solution of the embodiment of the present invention can reduce the calculation amount and implementation complexity of the encoder without sacrificing the accuracy of the rate control, thereby improving the coding efficiency.
- FIG. 1 is a schematic flow chart of a video encoding process.
- FIG. 2 is a schematic block diagram of an image processing system in accordance with an embodiment of the present invention.
- FIG. 3 is a schematic flowchart of a method for rate rate control according to an embodiment of the present invention.
- FIG. 4 is a schematic diagram of dividing an entire frame image into a plurality of image blocks in an embodiment of the present invention.
- FIG. 5 is a schematic diagram of a pixel block in an embodiment of the present invention.
- FIG. 6 is another schematic flowchart of a method for rate rate control according to an embodiment of the present invention.
- Fig. 7 is a schematic block diagram of an encoding apparatus according to an embodiment of the present invention.
- FIG. 8 is another schematic block diagram of an encoding apparatus according to an embodiment of the present invention.
- the video encoding process includes steps of prediction, transform, quantization, and entropy coding.
- the explanation of these steps is as follows.
- the purpose of the prediction is to use the prediction block information to remove redundant information of the current image block to be encoded.
- the prediction includes two types of intra prediction and inter prediction.
- Intra prediction is to obtain prediction block data using information of the current frame image.
- intra prediction uses spatial domain information of the current encoded frame to eliminate redundant information.
- Inter prediction uses the information of the reference frame to obtain prediction block data.
- inter prediction may use time domain frame information adjacent to the front and back of the current encoded frame for eliminating redundant information.
- the process of inter prediction includes: first, dividing an image block to be encoded into a plurality of sub image blocks; and then, for each sub image block, searching for a picture block that best matches the current sub image block as a prediction block in the reference frame; And subtracting the sub-image block from the corresponding pixel value of the prediction block to obtain a residual, and combining the obtained residuals corresponding to each sub-image block to obtain a residual of the image block to be encoded.
- a video frame using only the intra prediction mode is referred to as an I frame
- a video frame that can be inter-predicted using a forward reference frame is referred to as a P frame
- a video frame that can have a bidirectional reference frame is referred to as an B frame. frame.
- the purpose of the transformation is to remove redundant information from the image block.
- the transformation matrix can be used to remove the correlation of the residuals of the image blocks, i.e., remove redundant information of the image blocks in order to improve coding efficiency.
- the transformation of the data block in the image block usually adopts a two-dimensional transformation, that is, the residual information of the data block is respectively multiplied by a transformation matrix and its transposed matrix, and the multiplication is obtained after the multiplication.
- quantization is to obtain quantized coefficients based on the coefficient of variation. Specifically, the transform coefficients are quantized according to the quantization parameter to obtain corresponding quantized coefficients.
- the purpose of entropy coding is to obtain a bit stream by entropy coding the quantized coefficients.
- steps such as inverse quantization and inverse transform are also included.
- Anti-quantization refers to the process that is the opposite of the quantification process.
- Inverse transformation refers to the process that is the opposite of the transformation process.
- the encoding end After completing the image coding, stores or transmits the encoded bit stream obtained by entropy coding, such as intra prediction mode and motion vector information, to the decoding end.
- entropy coding such as intra prediction mode and motion vector information
- the decoding end after obtaining the entropy-encoded bit stream, first, entropy decoding the bit stream to obtain a corresponding residual; and then obtaining a predicted image block according to the decoded motion vector or intra-coding prediction mode information; The value of each pixel in the current sub-image block is obtained according to the residual of the predicted image block and the image block.
- rate control In the video coding process, in addition to the above steps of prediction, transformation, quantization and entropy coding, rate control also plays a very important role.
- rate control is to dynamically adjust the coding parameters to ensure that the compressed video stream can be transmitted in real time through a fixed bandwidth channel while ensuring a certain image quality, or to satisfy the stream code file after compression for a specific time. To be less than a specified size constraint.
- the rate control algorithm can be divided into the following two steps:
- the coded bits are pre-allocated before each coding level is encoded.
- the coding hierarchy is from high to low: group of pictures (GOP) level, single video frame level and basic sub-image block level.
- GOP group of pictures
- the coding parameters are adjusted such that the actual coded bits coincide with the coded bits pre-allocated in the first step.
- the coding parameters dynamically adjusted in the rate control process include: a direction mode of the intra prediction, a motion vector of the inter prediction, and a coding parameter such as a quantization parameter in the quantization process.
- the scaling of the transform coefficients is performed by the quantization parameters, the transform coefficients are input, and the quantized coefficients are output.
- the process is as follows:
- quantizedCoeff represents a quantized coefficient
- transformed Coeff represents a transform coefficient
- QP represents a quantization parameter
- f(QP) represents a quantization step size, which is a scalar determined by a quantization parameter QP.
- the quantized coefficients enter the entropy coder, they are further encoded into a binary code stream, and the bit quantity of the coded quantized coefficients is very high in the code stream encoded by the entire video, and the amplitude range of the quantized coefficients is controlled by the quantization step size.
- the quantization step size is directly determined by the quantization parameter, so the size of the quantization parameter determines the size of the output code rate after encoding the video frame. In the case where other coding parameters are fixed, a larger quantization parameter usually causes the encoder to output a smaller code rate when encoding the same video, whereas a smaller quantization parameter causes the encoder to output a larger code rate when encoding the same video. .
- one of the frequently used encoding parameters is a quantization parameter.
- the feature information of some images is obtained by preprocessing for rate control before the encoder starts encoding.
- the encoder performs the pre-processing process, which causes the encoding delay, which affects the running speed of the encoder, which is not conducive to real-time encoding.
- the present application proposes a method and an encoding apparatus for rate control, which can balance both the accuracy of the rate control and the computational complexity of the encoder.
- image complexity is introduced into a rate control algorithm.
- image complexity information of the image to be encoded is generated by an image processor external to the encoder, such as an image signal processor (ISP).
- ISP image signal processor
- the encoder Since the encoder is not required to perform image complexity calculations, it is possible to avoid introducing additional computational complexity and coding time-consuming for the encoder.
- the video signal is collected by the camera and then transmitted to the video encoder, it is first processed by an image processor (such as an ISP). Therefore, image complexity information generated by the image processor is not in the image processing system. Introduce additional components.
- the system includes an image processor 210 and an encoding device 220.
- the encoding device 220 includes a prediction module 221, a transform module 222, a code rate control module 223, a quantization module 224, and an entropy encoding module 225.
- the image processor 210 is configured to receive a sequence of images to be encoded, calculate its image complexity, and input the image complexity into the rate control module 223.
- the image processor 210 is an ISP.
- the prediction module 221 is configured to receive a sequence of images to be encoded, predict the same, and obtain a corresponding residual signal.
- the change module 222 is configured to receive the residual signal output by the prediction module 221, transform it, and obtain a corresponding transform parameter.
- the rate control module is configured to, 223, obtain a corresponding quantization parameter according to the preset coded bits and the image complexity acquired from the image processor 210.
- the quantization module 224 is configured to receive the transformation parameters of the variation module 222 and the quantization parameters output by the rate control module 223, and quantize the variation parameters by using the quantization parameters to obtain corresponding quantization coefficients.
- the entropy encoding module 225 is configured to receive the quantized coefficients output by the quantization module 224, and entropy encode the quantized coefficients to obtain an encoded bit stream.
- the system further includes an inverse transform module and an inverse quantization module.
- the function of the inverse transform module is opposite to that of the transform module.
- the function of the inverse quantization module is opposite to that of the quantization module.
- the image complexity is calculated by an image processor external to the encoder, and the image complexity is used to perform rate control in the image encoding process.
- the accuracy of the rate control is guaranteed to a certain extent; on the other hand, a large amount of calculations that may occur are performed by an image processor external to the encoder, which can reduce the computation and implementation complexity of the encoder.
- FIG. 3 is a schematic flowchart of a method for rate rate control according to an embodiment of the present invention.
- the method can be performed by a video encoder, such as by encoding device 220 shown in FIG.
- the method includes the following steps.
- Receive image complexity of an image to be encoded the image complexity being acquired by an image processor connected to the encoder.
- the image processor acquires the image complexity of the image to be encoded, and then the encoder receives the image complexity of the image to be encoded from the image processor.
- the image processor is located external to the encoder.
- the image processor is an ISP.
- the image complexity of the image to be encoded is obtained according to the texture information of the image to be encoded. It should be understood that the image complexity obtained by calculating the texture information of an image can characterize the amount of information of the image.
- the image complexity of the image to be encoded is determined according to the degree of fluctuation of the pixels in the image to be encoded, that is, the image complexity of the image to be encoded indicates the degree of fluctuation of the pixels in the region to be encoded.
- the preset coded bits refer to pre-assigned coded bits before image coding.
- the image complexity may represent the amount of information of the image before encoding
- the preset coded bits represent the amount of information of the encoded compressed image, so it is reasonable and effective to calculate the quantization parameter by combining the image complexity and the preset encoding bit.
- steps 310 to 330 belong to the rate control process. Specifically, steps 310 through 330 may be performed by a code rate control module internal to the encoder, and step 340 may be performed by an encoding module internal to the encoder (eg, a module that implements entropy encoding).
- a code rate control module internal to the encoder
- step 340 may be performed by an encoding module internal to the encoder (eg, a module that implements entropy encoding).
- the image complexity is acquired by the image processor external to the encoder, and a large amount of calculations that may occur may be performed by an image processor (such as an ISP) other than the encoder, which may reduce the encoder.
- the computational complexity and implementation complexity can avoid the encoder's encoding delay affecting the running speed of the encoder, which in turn facilitates real-time encoding.
- the embodiment of the present invention can obtain the quantization parameter according to the image complexity and the preset coding bit, so that the rate control precision can be guaranteed to a certain extent. Therefore, the solution of the embodiment of the present invention can reduce the calculation amount and implementation complexity of the encoder without sacrificing the accuracy of the rate control, thereby improving the coding efficiency.
- the image to be encoded is one image block in an image frame.
- the encoder when encoding an image of one frame, the encoder first divides the entire frame image into a plurality of 64 ⁇ 64 image blocks, as shown in FIG. 4, and divides one frame image into 128 image blocks, in FIG. Each block represents an image block of size 64 x 64. The encoder then encodes each image block in sequence.
- the image to be encoded may also be directly a frame image.
- the image to be encoded is an image block in the image frame, but the embodiment of the present invention does not limit this.
- the image frame in which the image to be encoded is located is an I frame.
- a video frame using only the intra prediction mode is referred to as an I frame.
- the residual signal of the I-frame image at the time of encoding is generated by intra-frame image signal prediction, it is advantageous to use the complexity information of the intra-frame image for the rate control algorithm.
- the image frame in which the image to be encoded is located is a P frame.
- a video frame that performs inter prediction using a forward reference frame is referred to as a P frame.
- step 330 specifically includes: calculating the quantization parameter by using a first function model, where the exponential operation is not included in the first function model, and the independent variable of the first function model includes the image complexity and The preset coded bit.
- the first function model only includes a logarithm operation, a multiplication operation, an addition operation, and/or a subtraction operation, and the independent variable of the first function model includes the image complexity and the preset coding bit.
- the logarithmic operation mentioned in the embodiment of the present invention may be a logarithmic operation of various forms, for example, an e-based logarithm operation, a base 10 logarithm operation, or other values.
- the logarithmic operation of the base number is not limited in this embodiment of the present invention.
- the coefficients in the first function model include at least one of: a first parameter for multiplication, a second parameter for multiplication, and a third for addition and/or subtraction.
- the parameter, the first parameter, the second parameter and the third parameter are all parameters used for rate control.
- the first parameter, the second parameter, and the third parameter are code rate control parameters owned by the code rate control module inside the encoder.
- calculating the quantization parameter of the encoded image by using the first function model includes: calculating a quantization parameter of the encoded image according to the following formula:
- QP represents the quantization parameter
- complexity represents the image complexity
- targetBits represents the preset coded bit
- A1 represents the first parameter
- A2 represents the second parameter
- B represents the third parameter
- Log() represents a logarithm operation.
- the absolute values of the first parameter A1 and the second parameter A2 are the same.
- the image complexity of the image to be encoded is derived from texture information of the image to be encoded.
- an image processor eg, an ISP
- the image to be encoded includes M pixel blocks, the size of the pixel block is N ⁇ N, and both M and N are positive integers, and the image complexity of the image to be encoded is SAD j is the sum of the absolute values of the pixel differences of the jth pixel block in the M pixel blocks, and Ave j is the pixel average of the jth pixel block, and Represents pixels in the jth pixel block.
- a complete image (denoted as an image frame) is divided into a number of image blocks of size 64 x 64. Taking an image frame with a resolution of 1920 ⁇ 1080 as an example, it can be divided into 510 (30 ⁇ 17) image blocks.
- a pixel block having a size of 2 ⁇ 2 is used as a minimum unit for calculating image complexity, and a pixel block composed of four pixels x0, x1, x2, and x3 as shown in FIG. It should be understood that 1024 pixel blocks are included in one image block.
- xi represents the pixel value of the ith pixel in the pixel block.
- SAD 2x2i represents the sum of the absolute values of the pixel differences of the i-th pixel block in the image block.
- the image complexity of the image block is obtained by adding the sum of the absolute values of the pixel differences of all the pixel blocks in the same image block, SAD 2 ⁇ 2 .
- the image complexity of an image frame can be obtained by adding the image complexity of all image blocks within the image frame.
- the image complexity of an image block can be referred to as block level image complexity.
- the image complexity of an image frame can be referred to as frame level image complexity.
- the image complexity of the image to be encoded represents the degree of volatility of pixels in the region of the image to be encoded.
- the image complexity of the image to be encoded is obtained by a frequency domain calculation method.
- the image processor determines the image complexity of the image to be encoded by counting the discrete (positive) cosine transform of the image to be encoded or the transform coefficients of the Hadamard transform.
- the image complexity of the image to be encoded is obtained by a pixel domain calculation method.
- the image processor determines the image complexity of the image to be encoded by calculating the variance or standard deviation of the pixels within the image to be encoded.
- the image to be encoded is one image block in the image frame
- the step 320 specifically includes: preset the encoding bit according to the frame level, the frame level image complexity, and the image complexity of the image to be encoded, Determining a preset encoding bit of the image to be encoded, wherein the frame level preset encoding bit represents a preset encoding bit of the image frame, and the frame level image complexity refers to a sum of image complexity of all image blocks in the image frame. .
- the image to be encoded is the i-th image block in the image frame
- the preset encoding bit targetBits i of the image to be encoded is calculated according to the following formula:
- the preset stage TargetBits represents a frame encoded bits
- the complexity of the image Complexity image i represents the i-th frame image block (i.e., the image to be encoded) is
- ⁇ j complexity j denotes the frame complexity level image, i.e. image frame
- the sum of the images of all image blocks is complex.
- the image frame in this embodiment is an I frame.
- preset coded bits may be assigned to each image block in the image frame in advance before encoding begins.
- the image to be encoded is an image block in an image frame
- the image frame is a P frame
- the step 320 specifically includes: a product of a frame-level preset bit and the first coefficient according to the P frame. Determining a preset bit of the image to be encoded, wherein the first coefficient is determined according to at least one of: an overall image complexity of the P frame, a sum of weights of all image blocks in the P frame, the image to be encoded Image complexity, weight of the image to be encoded, and frame level preset bits of the P frame, wherein the weight is determined by a code rate control parameter of the P frame.
- the first coefficient is a product of a ratio of an image complexity of the image to be encoded to a total image complexity of the P frame and a second coefficient
- a weight of the image to be encoded accounts for all image blocks in the P frame.
- the ratio of the sum of the weights is determined by the sum of the products of the third coefficients, wherein the second coefficient and the third coefficient are both greater than 0, and the sum of the second coefficient and the third coefficient is equal to one.
- the preset encoding bit targetBits i of the image to be encoded is calculated according to the following formula:
- targetBits represents a frame-level preset encoding bit
- complexity i represents an image complexity of an i-th image block (ie, the image to be encoded) in the image frame
- ⁇ j complexity j represents a frame-level image complexity, that is, the image The sum of the image complexity of all image blocks in the frame
- weight i represents the weight of the i-th image block (ie, the image to be encoded) in the image frame
- ⁇ j weight j represents the sum of the weights of all image blocks in the image frame
- C1 represents the second coefficient
- C2 represents the third coefficient.
- the second coefficient C1 is 1/4 and the third coefficient C2 is 3/4.
- the weight of the image block is the weight determined according to the code rate control parameter of the P frame.
- preset coded bits may be assigned to each image block in the image frame in advance before encoding begins.
- the method of determining the preset coded bits is different for the I frame and the P frame.
- the rate control strategy used in the I frame encoding is different from the rate control strategy used in the P frame encoding, which is advantageous for improving the accuracy of the rate control for the following reasons.
- the residual information obtained when the I frame is encoded represents the difference between a certain coded subblock and its spatially adjacent image.
- the residual information obtained when encoding the P frame more indicates the difference between the current encoded frame and the reference frame in the time domain.
- the residual information obtained at the time of I frame coding and P frame coding is different, and correspondingly, the code rate control strategy for the I frame and the P frame should be different in the case of rate control.
- the same rate control strategy as the P frame is used in the I frame coding, which leads to inaccurate rate control, which affects the quality of the encoded video.
- the present application can improve the rate control accuracy by processing the I frame coding and the P frame coding by using different rate control strategies.
- the image to be encoded is an image block in an image frame in which the image to be encoded is located
- the method further includes: according to a frame level image complexity and a frame level preset of the image frame.
- the step 340 specifically includes: determining, according to the size relationship between the quantization parameter of the image to be encoded and the quantization parameter of the image frame, a quantization parameter used to encode the image to be encoded, and then using the finally determined quantization parameter to the image to be encoded. Encode.
- the quantization parameter of the image to be encoded is within a range of the quantization parameter of the image frame, and the step 340 specifically includes: encoding the image to be encoded according to the quantization parameter of the image to be encoded. .
- the quantization parameter of the image to be encoded is not in the range of the quantization parameter of the image frame, and the step 340 specifically includes: cutting the quantization parameter of the image to be encoded to the quantization parameter of the image frame.
- the image to be encoded is encoded according to the quantization parameter of the image to be encoded after the cropping.
- the image to be encoded represents an image block in an entire frame of image.
- the encoding of the entire frame image is performed with the image block as the minimum coding unit.
- the entire frame image is first divided into a plurality of image blocks, and then each image block is sequentially encoded in steps 310 to 340 in sequence, and when the encoding of all image blocks in the image frame is completed, the entire frame image is completed. coding.
- the method further includes: updating the first according to the frame-level actual coding bit and the frame-level preset coding bit of the image frame.
- the three parameters, the frame-level actual coded bits represent actual coded bits of the image frame, and the frame-level preset coded bits represent frame-level preset coded bits of the image frame.
- the updated third parameter is obtained, where the argument of the second function model includes the frame-level actual coded bit, the frame-level preset coded bit, and the third parameter before the update,
- the second function model includes at least one of the following operations: a logarithmic operation, a multiplication operation, an addition, and/or a subtraction operation.
- the updated third parameter B new is obtained according to the following formula:
- the third parameter before the update represents the first parameter
- k represents the update rate, for example, may be taken as the empirical value 2
- actualBits represents the actual coded bit at the frame level.
- targetBits represents frame-level preset encoding bits.
- the code rate control parameter A1 ie, the first parameter
- the code rate control parameter B ie, the third parameter
- the code rate control parameter B adaptively iteratively updates according to the difference between the frame-level actual coded bits and the frame-level preset coded bits.
- the code rate control parameter is iteratively updated, so that the code rate control module in the encoder can be more adapted to the characteristics of different video images, thereby improving the accuracy of the rate control.
- FIG. 6 is another schematic flowchart of an image encoding method according to an embodiment of the present invention, which is performed by an encoder.
- the image complexity, the preset coding bits, the actual coding bits, and the quantization parameters of the image block are respectively recorded as: block-level image complexity, block-level preset coding bits, block-level actual coding bits, Block level quantization parameters.
- the image complexity, preset coding bits, actual coding bits, and quantization parameters of the entire frame image are respectively recorded as: frame-level image complexity, frame-level preset coding bits, frame-level actual coding bits, and frame-level quantization parameters.
- the method includes the following steps.
- step 6003 the block-level image complexity determined according to step 6001 and the block-level preset coding bit determined in step 6002, and combined with the code rate control parameter (such as the first parameter, the second parameter, and the third parameter in the foregoing embodiment), Calculate block level quantization parameters.
- the code rate control parameter such as the first parameter, the second parameter, and the third parameter in the foregoing embodiment
- step 6006 according to the frame-level image complexity determined in step 6004 and the frame-level preset coding bits determined in step 6005, and combined with the code rate control parameters (such as the first parameter, the second parameter, and the third parameter in the foregoing embodiments), Calculate frame level quantization parameters.
- code rate control parameters such as the first parameter, the second parameter, and the third parameter in the foregoing embodiments
- step 6007. Determine whether the block-level quantization parameter obtained in step 6003 is within the range of the frame-level quantization parameter obtained in step 6006. If yes, go to step 6008, and if no, go to step 6009.
- step 6003 The block-level quantization parameter obtained in step 6003 is clipped to a certain range of the frame-level quantization parameter obtained in step 6006, and the process proceeds to step 6009.
- step 6007 determines whether the block-level quantization parameter obtained in step 6003 is input into the quantization module; if the determination result in step 6007 is negative, the block-level quantization parameter after the clipping in step 6008 is input. Quantization module.
- step 6010 Determine whether the encoding of the current one frame complete image is completed. If yes, go to step 6011, and if no, go to step 6012.
- step 6011 Update the code rate control parameter used in step 6006 according to the frame-level actual coding bit and the frame-level preset coding bit of the currently completed encoded image frame. Go to step 6006.
- the preset coded bits may be allocated to the next image block to be encoded according to the difference between the actual coded bits of the image block and the preset coded bits.
- step 6001, step 6002, step 6004, and step 6005 in the above process.
- the embodiment of the present invention when the rate control is performed, the image complexity is acquired by the image processor external to the encoder, and a large amount of calculations that may occur may be performed by an image processor (such as an ISP) other than the encoder. Therefore, the calculation amount and implementation complexity of the encoder can be reduced, and the encoding delay caused by the secondary encoding of the encoder can be avoided.
- the embodiment of the present invention can obtain the quantization parameter according to the image complexity and the preset coding bit, so that the rate control precision can be guaranteed to a certain extent. Therefore, the solution of the embodiment of the present invention can reduce the calculation amount and implementation complexity of the encoder without sacrificing the accuracy of the rate control, thereby improving the coding efficiency.
- FIG. 7 is a schematic block diagram of an encoding apparatus 700 according to an embodiment of the present invention.
- the encoding apparatus 700 includes:
- the transceiver unit 710 is configured to receive image complexity of the image to be encoded, where the image complexity is acquired by an image processor connected to the encoder;
- the processing unit 720 is configured to determine a preset encoding bit of the image to be encoded, obtain a quantization parameter of the image to be encoded according to the image complexity and the preset encoding bit, and obtain the quantization parameter according to the quantization parameter of the image to be encoded.
- the encoded image is encoded.
- the processing unit 720 is specifically configured to calculate the quantization parameter by using a first function model, where the first function model only includes a logarithm operation, a multiplication operation, an addition, and/or a subtraction operation, where The argument of the first function model includes the image complexity and the preset coded bits.
- the coefficients in the first function model include at least one of: a first parameter for multiplication, a second parameter for multiplication, and a third for addition and/or subtraction.
- the parameter, the first parameter, the second parameter and the third parameter are all parameters used for rate control.
- the first function model is: a product of a logarithm operation value of the image complexity and the first parameter, a logarithm operation value of the preset coded bit, and a third parameter The sum of the product and the second parameter.
- the absolute values of the first parameter and the second parameter are the same.
- the processing unit 720 is further configured to: according to the frame-level actual encoding bit and the frame-level preset encoding bit of the image frame, Updating the third parameter, the frame-level actual coded bits represent actual coded bits of the image frame, the frame-level preset coded bits representing frame-level preset coded bits of the image frame.
- the processing unit 720 is specifically configured to obtain, according to the second function model, an updated third parameter, where the argument of the second function model includes the frame-level actual coded bit, the frame The level preset coded bits, and the third parameter before the update, the second function model includes at least one of the following operations: a logarithmic operation, a multiplication operation, an addition, and/or a subtraction operation.
- the second function model is: a difference between a logarithm operation value of the frame-level actual coded bit and a logarithm operation value of the frame-level preset coded bit, and an update rate value and the first The product of a parameter, the sum of the third parameter before the update.
- the image to be encoded is an image block in an image frame in which the image to be encoded is located; the processing unit 720 is specifically configured to: preset a coding bit according to a frame level of the image frame, The frame-level image complexity of the image frame and the image complexity of the image to be encoded determine a preset encoded bit of the image to be encoded.
- the processing unit 720 is configured to: according to a ratio of image complexity of the image to be encoded to a frame-level image complexity of the image frame, and a frame-level preset encoding of the image frame.
- the product of the bits determines the preset coded bits of the image to be encoded.
- the image to be encoded is one image block in an image frame in which the image to be encoded is located; the processing unit 720 is further configured to preset according to image complexity and frame level of the image frame. Encoding a bit, obtaining a quantization parameter of the image frame; when encoding the image to be encoded, the processing unit 720 is specifically configured to: when the quantization parameter of the image to be encoded is within a range of the quantization parameter of the image frame, according to The quantization parameter of the image to be encoded is encoded by the image to be encoded.
- the processing unit 720 when the image to be encoded is encoded, is specifically configured to: when the quantization parameter of the image to be encoded is not within the range of the quantization parameter of the image frame, The quantization parameter of the image to be encoded is clipped to the range of the quantization parameter of the image frame, and the image to be encoded is encoded according to the quantization parameter of the image to be encoded after the clipping.
- the image frame in which the image to be encoded is located is an I frame.
- the image frame in which the image to be encoded is located is a P frame
- the image to be encoded is an image block in the P frame
- the processing unit 720 is specifically configured to: according to the frame of the P frame The product of the preset bits and the first coefficient determines a preset bit of the image to be encoded, wherein the first coefficient is determined according to at least one of: an overall image complexity of the P frame, all images in the P frame The sum of the weights of the blocks, the image complexity of the image to be encoded, the weight of the image to be encoded, and the frame level preset bits of the P frame, wherein the weight is determined by the code rate control parameter of the P frame.
- the processing unit 720 is specifically configured to: the first coefficient is a product of a ratio of an image complexity of the image to be encoded to a total image complexity of the P frame and a second coefficient, Determining, by the sum of the ratio of the weight of the image to be encoded to the sum of the weights of all image blocks in the P frame and the product of the third coefficient, wherein the second coefficient and the third coefficient are both greater than 0, and the second The sum of the coefficient and the third coefficient is equal to one.
- the image complexity of the image to be encoded is obtained according to texture information of the image to be encoded.
- the image complexity of the image to be encoded indicates the degree of fluctuation of the pixels in the area of the image to be encoded.
- the image complexity of the image to be encoded is obtained by counting the discrete positive/cosine transform of the image to be encoded or the transform coefficient of the Hadamard transform.
- the image complexity of the image to be encoded is obtained by calculating a variance or a standard deviation of pixels within the image to be encoded.
- the image processor is an image signal processor ISP.
- the processing unit 710 in this embodiment specifically includes: a code rate control unit, a prediction unit, a transform unit, an inverse transform unit, a quantization unit, an inverse quantization unit, and an entropy coding unit.
- the code rate control unit is configured to implement rate control and provide quantization parameters for the quantization unit.
- the code rate control unit is configured to receive image complexity from the image processor, and then calculate the quantization parameter according to the image complexity and the preset coded bits.
- an embodiment of the present invention further provides an encoding apparatus 800, a processor 810 and a memory 820.
- the memory 820 is configured to store an instruction
- the processor 810 is configured to execute an instruction stored by the memory 820, and Execution of the instructions stored in memory 820 is such that processor 810 is operative to perform the methods of the above method embodiments.
- the encoding device 800 further includes a transceiver 830 for receiving image complexity information from an external image processor (eg, an ISP).
- an external image processor eg, an ISP
- Embodiments of the present invention also provide a computer storage medium having stored thereon a computer program that, when executed by a computer, causes the computer to perform the method of the above method embodiments.
- Embodiments of the present invention also provide a computer program product comprising instructions, wherein the instructions, when executed by a computer, cause a computer to perform the method of the above method embodiments.
- the computer program product includes one or more computer instructions.
- the computer can be a general purpose computer, a special purpose computer, a computer network, or other programmable device.
- the computer instructions can be stored in a computer readable storage medium or transferred from one computer readable storage medium to another computer readable storage medium, for example, the computer instructions can be from a website site, computer, server or data center Transmission to another website site, computer, server or data center via wired (eg coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (eg infrared, wireless, microwave, etc.).
- the computer readable storage medium can be any available media that can be accessed by a computer or a data storage device such as a server, data center, or the like that includes one or more available media.
- the usable medium may be a magnetic medium (for example, a floppy disk, a hard disk, a magnetic tape), an optical medium (such as a digital video disc (DVD)), or a semiconductor medium (such as a solid state disk (SSD)).
- a magnetic medium for example, a floppy disk, a hard disk, a magnetic tape
- an optical medium such as a digital video disc (DVD)
- a semiconductor medium such as a solid state disk (SSD)
- the disclosed systems, devices, and methods may be implemented in other manners.
- the coding device embodiment described above is only illustrative.
- the division of the unit is only a logical function division, and the actual implementation may have another division manner, for example, multiple units or components may be combined. Or it can be integrated into another system, or some features can be ignored or not executed.
- the mutual coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interface, device or unit, and may be in an electrical, mechanical or other form.
- the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, may be located in one place, or may be distributed to multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of the embodiment.
- each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
Landscapes
- Engineering & Computer Science (AREA)
- Multimedia (AREA)
- Signal Processing (AREA)
- Compression Or Coding Systems Of Tv Signals (AREA)
Abstract
Provided are an image processing method and device. The method comprises: receiving the image complexity of an image to be encoded, the image complexity being obtained by an image processor connected to an encoder; determining a preset coded bit of the image to be encoded; obtaining, according to the image complexity and the preset coded bit, a quantified parameter of the image to be encoded; and encoding, according to the quantified parameter of the image to be encoded, the image to be encoded. The method can take both the bit rate control accuracy and the computational complexity of the encoder into consideration.
Description
版权申明Copyright statement
本专利文件披露的内容包含受版权保护的材料。该版权为版权所有人所有。版权所有人不反对任何人复制专利与商标局的官方记录和档案中所存在的该专利文件或者该专利披露。The disclosure of this patent document contains material that is subject to copyright protection. This copyright is the property of the copyright holder. The copyright owner has no objection to the reproduction of the patent document or the patent disclosure in the official records and files of the Patent and Trademark Office.
本申请涉及视频编解码领域,并且更为具体地,涉及一种码率控制的方法与编码装置。The present application relates to the field of video codec and, more particularly, to a method and an encoding apparatus for rate control.
视觉信息是人类获取外界信息的最重要来源之一,但是摄像头采集所得未经压缩的原始视频数据占用的存储空间非常巨大,以分辨率为1920×1080、帧率为30帧每秒、时长10分钟的视频为例,在无压缩的情况下存储该视频需要占用104.28G字节的存储空间。为了减少视频存储和传输所占用的带宽,需要对视频数据进行编码压缩处理。Visual information is one of the most important sources for humans to obtain external information, but the uncompressed raw video data collected by the camera occupies a huge storage space with a resolution of 1920×1080, a frame rate of 30 frames per second, and a duration of 10 For example, in the case of a minute video, storing the video without compression requires 104.28 Gbytes of storage space. In order to reduce the bandwidth occupied by video storage and transmission, it is necessary to encode and compress the video data.
视频编码过程包括预测、变换、码率控制、量化和熵编码等步骤。其中,码率控制在视频编码过程中扮演着非常重要的角色。由于不同视频序列的内容和特征都各不相同,若使用同样的编码参数进行编码就会产生差别很大的输出码率及不同程度的视频失真,为了克服这个问题,就提出了码率控制。The video coding process includes steps of prediction, transform, rate control, quantization, and entropy coding. Among them, the rate control plays a very important role in the video encoding process. Since the content and characteristics of different video sequences are different, if the same coding parameters are used for encoding, a very different output bit rate and different degrees of video distortion will be generated. To overcome this problem, rate control is proposed.
码率控制算法是根据不同视频图像的特征自适应地调整编码参数。通常,基于标准的视频编码器在编码参数的选择方面具有很大的灵活性,编码参数的选择可能对编码后视频码流的码率有很大的影响。码率控制算法可以使得,编码器可以在一系列编码参数集合之间选择合适的编码参数,以实现实际编码比特逼近预先分配的编码比特。The rate control algorithm adaptively adjusts the encoding parameters according to the characteristics of different video images. In general, standards-based video encoders have great flexibility in the choice of encoding parameters, and the choice of encoding parameters can have a large impact on the code rate of the encoded video stream. The rate control algorithm may enable the encoder to select an appropriate coding parameter between a set of coding parameter sets to achieve the actual coded bits approximating the pre-assigned coded bits.
在业界现有的码率控制算法中,有些算法会导致码率控制不准确,有些算法在解决码率控制不准确的同时又会增加编码器的计算复杂度。In the existing rate control algorithms in the industry, some algorithms may result in inaccurate rate control. Some algorithms may improve the computational complexity of the encoder while solving the inaccurate rate control.
因此,需要提出一种可以兼容码率控制准确度与编码器的计算复杂度的编码方法。Therefore, it is necessary to propose an encoding method that is compatible with the accuracy of the rate control and the computational complexity of the encoder.
发明内容Summary of the invention
本申请提供一种码率控制方法与装置,能够在码率控制过程中兼顾码率控制准确度与编码器的计算复杂度。The present application provides a code rate control method and apparatus, which can take into account the accuracy of the rate control and the computational complexity of the encoder in the rate control process.
第一方面,提供一种码率控制的方法,所述方法应用于视频编码器,所述方法包括:接收待编码图像的图像复杂度,所述图像复杂度是由与编码器相连的图像处理器获取的;确定所述待编码图像的预设编码比特;根据所述图像复杂度与所述预设编码比特,获得所述待编码图像的量化参数;根据所述待编码图像的量化参数,对所述待编码图像进行编码。In a first aspect, a method of rate control is provided, the method being applied to a video encoder, the method comprising: receiving image complexity of an image to be encoded, the image complexity being image processing connected to an encoder Obtaining a preset encoding bit of the image to be encoded; obtaining a quantization parameter of the image to be encoded according to the image complexity and the preset encoding bit; and according to the quantization parameter of the image to be encoded, The image to be encoded is encoded.
第二方面,提供一种编码装置,所述编码装置包括:收发单元,用于接收待编码图像的图像复杂度,所述图像复杂度是由与编码器相连的图像处理器获取的;处理单元,用于确定所述待编码图像的预设编码比特;根据所述图像复杂度与所述预设编码比特,获得所述待编码图像的量化参数;根据所述待编码图像的量化参数,对所述待编码图像进行编码。In a second aspect, an encoding apparatus is provided, the encoding apparatus comprising: a transceiver unit configured to receive an image complexity of an image to be encoded, the image complexity being acquired by an image processor connected to the encoder; And determining a preset coding bit of the image to be encoded; obtaining a quantization parameter of the image to be encoded according to the image complexity and the preset coding bit; and according to the quantization parameter of the image to be encoded, The image to be encoded is encoded.
第三方面,提供一种编码装置,所述编码装置包括存储器和处理器,所述存储器用于存储指令,所述处理器用于执行所述存储器存储的指令,并且对所述存储器中存储的指令的执行使得所述处理器执行第一方面提供的方法。In a third aspect, an encoding apparatus is provided, the encoding apparatus comprising a memory for storing instructions, the processor for executing the instructions stored by the memory, and instructions stored in the memory Execution of the processor causes the processor to perform the method provided by the first aspect.
第四方面,提供一种芯片,所述芯片包括处理模块与通信接口,所述处理模块用于控制所述通信接口与外部进行通信,所述处理模块还用于实现第一方面提供的方法。In a fourth aspect, a chip is provided, the chip comprising a processing module and a communication interface, the processing module is configured to control the communication interface to communicate with an external, and the processing module is further configured to implement the method provided by the first aspect.
第五方面,提供一种计算机可读存储介质,其上存储有计算机程序,所述计算机程序被计算机执行时使得所述计算机实现第一方面或第一方面的任一可能的实现方式中的方法。具体地,所述计算机可以为上述**设备。A fifth aspect, a computer readable storage medium having stored thereon a computer program, the computer program being executed by a computer to cause the computer to implement the method of any of the first aspect or the first aspect . Specifically, the computer may be the above-mentioned ** device.
第六方面,提供一种包含指令的计算机程序产品,所述指令被计算机执行时使得所述计算机实现第一方面提供的方法。In a sixth aspect, a computer program product comprising instructions, which when executed by a computer, causes the computer to implement the method provided by the first aspect.
综上所述,本发明实施例在进行码率控制时,通过编码器外部的图像处理器获取图像复杂度,可以将可能出现的大量计算由编码器之外的图像处理器(例如ISP)完成,从而可以降低编码器的计算量和实现复杂度,进而可以避免编码器进行二次编码带来的编码延迟。同时,本发明实施例通过根据图像复杂度与预设编码比特获取量化参数,从而可以在一定程度上保证码率控制精度。因此,本发明实施例的方案可以在不牺牲码率控制精度的前提下,可以降低编码器的计算量和实现复杂度,从而可以提高编码 效率。In summary, in the embodiment of the present invention, when the rate control is performed, the image complexity is acquired by the image processor external to the encoder, and a large amount of calculations that may occur may be performed by an image processor (such as an ISP) other than the encoder. Therefore, the calculation amount and implementation complexity of the encoder can be reduced, and the encoding delay caused by the secondary encoding of the encoder can be avoided. In the meantime, the embodiment of the present invention can obtain the quantization parameter according to the image complexity and the preset coding bit, so that the rate control precision can be guaranteed to a certain extent. Therefore, the solution of the embodiment of the present invention can reduce the calculation amount and implementation complexity of the encoder without sacrificing the accuracy of the rate control, thereby improving the coding efficiency.
图1是视频编码过程的示意性流程图。1 is a schematic flow chart of a video encoding process.
图2是本发明实施例的图像处理系统的示意性框图。2 is a schematic block diagram of an image processing system in accordance with an embodiment of the present invention.
图3是本发明实施例的码率控制的方法的示意性流程图。FIG. 3 is a schematic flowchart of a method for rate rate control according to an embodiment of the present invention.
图4是本发明实施例中将整帧图像分为若干个图像块的示意图。4 is a schematic diagram of dividing an entire frame image into a plurality of image blocks in an embodiment of the present invention.
图5是本发明实施例中的像素块的示意图。FIG. 5 is a schematic diagram of a pixel block in an embodiment of the present invention.
图6是本发明实施例的码率控制的方法的另一示意性流程图。FIG. 6 is another schematic flowchart of a method for rate rate control according to an embodiment of the present invention.
图7是本发明实施例的编码装置的示意性框图。Fig. 7 is a schematic block diagram of an encoding apparatus according to an embodiment of the present invention.
图8是本发明实施例的编码装置的另一示意性框图。FIG. 8 is another schematic block diagram of an encoding apparatus according to an embodiment of the present invention.
为了便于理解与描述本申请的方案,下面首先结合图1描述视频编码的过程。In order to facilitate understanding and description of the solution of the present application, the process of video encoding will be described below first with reference to FIG.
如图1所示,视频编码过程包括预测、变换、量化和熵编码等步骤。这些步骤的解释如下。As shown in FIG. 1, the video encoding process includes steps of prediction, transform, quantization, and entropy coding. The explanation of these steps is as follows.
预测的其目的在于,利用预测块信息去除当前待编码图像块的冗余信息。预测包括帧内预测和帧间预测两种类型。帧内预测是利用本帧图像的信息获得预测块数据。例如,帧内预测使用当前编码帧的空域信息用于消除冗余信息。帧间预测利用参考帧的信息获得预测块数据。例如,帧间预测可以使用与当前编码帧前后相邻的时域帧信息用于消除冗余信息。帧间预测的过程包括:首先,将待编码图像块划分成若干个子图像块;然后,针对每个子图像块,在参考帧中搜索与当前子图像块最匹配的图像块作为预测块;其后,将该子图像块与该预测块的相应像素值相减得到残差,并将得到的各子图像块对应的残差组合在一起,得到待编码图像块的残差。The purpose of the prediction is to use the prediction block information to remove redundant information of the current image block to be encoded. The prediction includes two types of intra prediction and inter prediction. Intra prediction is to obtain prediction block data using information of the current frame image. For example, intra prediction uses spatial domain information of the current encoded frame to eliminate redundant information. Inter prediction uses the information of the reference frame to obtain prediction block data. For example, inter prediction may use time domain frame information adjacent to the front and back of the current encoded frame for eliminating redundant information. The process of inter prediction includes: first, dividing an image block to be encoded into a plurality of sub image blocks; and then, for each sub image block, searching for a picture block that best matches the current sub image block as a prediction block in the reference frame; And subtracting the sub-image block from the corresponding pixel value of the prediction block to obtain a residual, and combining the obtained residuals corresponding to each sub-image block to obtain a residual of the image block to be encoded.
在视频编码处理时,仅使用帧内预测模式的视频帧被称为I帧;可以使用前向参考帧进行帧间预测的视频帧称为P帧;可以拥有双向参考帧的视频帧称为B帧。At the time of video encoding processing, a video frame using only the intra prediction mode is referred to as an I frame; a video frame that can be inter-predicted using a forward reference frame is referred to as a P frame; a video frame that can have a bidirectional reference frame is referred to as an B frame. frame.
变换的目的在于去除图像块的冗余信息。具体地,可以使用变换矩阵去除图像块的残差的相关性,即去除图像块的冗余信息,以便提高编码效 率。图像块中数据块的变换通常采用二维变换,即将数据块的残差信息分别与一个变换矩阵及其转置矩阵相乘,相乘之后得到的是变换系数。The purpose of the transformation is to remove redundant information from the image block. Specifically, the transformation matrix can be used to remove the correlation of the residuals of the image blocks, i.e., remove redundant information of the image blocks in order to improve coding efficiency. The transformation of the data block in the image block usually adopts a two-dimensional transformation, that is, the residual information of the data block is respectively multiplied by a transformation matrix and its transposed matrix, and the multiplication is obtained after the multiplication.
量化的目的在于,根据变化系数得到量化系数。具体地,根据量化参数对变换系数进行量化,得到对应的量化系数。The purpose of quantization is to obtain quantized coefficients based on the coefficient of variation. Specifically, the transform coefficients are quantized according to the quantization parameter to obtain corresponding quantized coefficients.
熵编码的目的在于,通过对量化系数进行熵编码,得到比特流。The purpose of entropy coding is to obtain a bit stream by entropy coding the quantized coefficients.
如图1所示,在编码过程中,还会包括反量化和反变换等步骤。反量化指的就是与量化过程相反的过程。反变换指的就是与变换过程相反的过程。As shown in FIG. 1, in the encoding process, steps such as inverse quantization and inverse transform are also included. Anti-quantization refers to the process that is the opposite of the quantification process. Inverse transformation refers to the process that is the opposite of the transformation process.
编码端在完成图像编码后,会将熵编码得到的比特流及进行编码后的编码模式信息,如帧内预测模式、运动矢量信息等,进行存储或发送到解码端。After completing the image coding, the encoding end stores or transmits the encoded bit stream obtained by entropy coding, such as intra prediction mode and motion vector information, to the decoding end.
在解码端,获得熵编码比特流之后,首先,对该比特流进行熵解码,得到相应的残差;然后,根据解码得到的运动矢量或帧内预测等编码模式信息,获得预测图像块;最后,根据预测图像块与图像块的残差得到当前子图像块中各像素点的值。At the decoding end, after obtaining the entropy-encoded bit stream, first, entropy decoding the bit stream to obtain a corresponding residual; and then obtaining a predicted image block according to the decoded motion vector or intra-coding prediction mode information; The value of each pixel in the current sub-image block is obtained according to the residual of the predicted image block and the image block.
在视频编码过程中,除了上述的预测、变换、量化与熵编码等步骤外,码率控制也扮演着非常重要的角色。In the video coding process, in addition to the above steps of prediction, transformation, quantization and entropy coding, rate control also plays a very important role.
不同的视频序列其内容和特征都各不相同。若使用同样的编码参数对不同的视频序列进行编码,会产生差别很大的输出码率以及不同程度的视频失真。为了克服这个问题,需要根据不同视频图像的特征自适应地调整编码参数,这个调整编码参数的过程就称为码率控制。Different video sequences have different content and characteristics. If the same encoding parameters are used to encode different video sequences, a very different output bit rate and varying degrees of video distortion will result. In order to overcome this problem, it is necessary to adaptively adjust the encoding parameters according to the characteristics of different video images. This process of adjusting the encoding parameters is called rate control.
码率控制的目的是,通过动态地调整编码参数,在保证一定图像质量的前提下使压缩后的视频码流能通过固定带宽的信道实时传输,或是满足特定时间内压缩后码流文件必须要小于某个规定尺寸的约束。The purpose of rate control is to dynamically adjust the coding parameters to ensure that the compressed video stream can be transmitted in real time through a fixed bandwidth channel while ensuring a certain image quality, or to satisfy the stream code file after compression for a specific time. To be less than a specified size constraint.
通常,码率控制算法可分为以下两步实现:In general, the rate control algorithm can be divided into the following two steps:
第一步,在各个编码层次编码前预先分配编码比特。In the first step, the coded bits are pre-allocated before each coding level is encoded.
编码层次从高到底依次为:图片组(group of pictures,GOP)级、单视频帧级及基本子图像块级。The coding hierarchy is from high to low: group of pictures (GOP) level, single video frame level and basic sub-image block level.
在这一步中,也会考虑编码器缓冲区的占满程度。In this step, the full extent of the encoder buffer is also considered.
第二步,在每个编码层次的编码过程中,通过调整编码参数,以使得实际编码比特与第一步预先分配的编码比特相吻合。In the second step, in the encoding process of each coding level, the coding parameters are adjusted such that the actual coded bits coincide with the coded bits pre-allocated in the first step.
码率控制过程中动态调整的编码参数包括:帧内预测的方向模式,帧间预测的运动矢量,量化过程中的量化参数等编码参数。The coding parameters dynamically adjusted in the rate control process include: a direction mode of the intra prediction, a motion vector of the inter prediction, and a coding parameter such as a quantization parameter in the quantization process.
在量化过程中,通过量化参数实现变换系数的缩放,输入变换系数,输出量化系数,该过程如下公式所示:In the quantization process, the scaling of the transform coefficients is performed by the quantization parameters, the transform coefficients are input, and the quantized coefficients are output. The process is as follows:
其中,quantizedCoeff表示量化系数;transformedCoeff表示变换系数;QP表示量化参数;f(QP)表示量化步长,是由量化参数QP决定的标量。Wherein, quantizedCoeff represents a quantized coefficient; transformed Coeff represents a transform coefficient; QP represents a quantization parameter; and f(QP) represents a quantization step size, which is a scalar determined by a quantization parameter QP.
由于量化系数进入熵编码器中会进一步编码成二进制码流,且编码量化系数的比特量在整个视频编码成的码流中占比非常高,而量化系数的幅值范围受控于量化步长,量化步长由量化参数直接确定,因此量化参数的大小将决定视频帧编码后输出码率的大小。在其他编码参数固定的情况下,较大的量化参数通常会导致编码器编码相同视频时输出较小的码率,反之较小的量化参数会导致编码器编码相同视频时输出较大的码率。Since the quantized coefficients enter the entropy coder, they are further encoded into a binary code stream, and the bit quantity of the coded quantized coefficients is very high in the code stream encoded by the entire video, and the amplitude range of the quantized coefficients is controlled by the quantization step size. The quantization step size is directly determined by the quantization parameter, so the size of the quantization parameter determines the size of the output code rate after encoding the video frame. In the case where other coding parameters are fixed, a larger quantization parameter usually causes the encoder to output a smaller code rate when encoding the same video, whereas a smaller quantization parameter causes the encoder to output a larger code rate when encoding the same video. .
因此,在码率控制过程中,频繁使用的编码参数之一是量化参数。Therefore, in the rate control process, one of the frequently used encoding parameters is a quantization parameter.
在业界现有的码率控制算法中,为了提高码率控制的准确性,在编码器开始编码之前,通过预处理获得一些图像的特征信息用于码率控制。但是,在编码前,编码器执行预处理的过程会带来编码延迟,从而影响编码器的运行速度,不利于实时编码实现。In the existing rate control algorithm in the industry, in order to improve the accuracy of the rate control, the feature information of some images is obtained by preprocessing for rate control before the encoder starts encoding. However, before the encoding, the encoder performs the pre-processing process, which causes the encoding delay, which affects the running speed of the encoder, which is not conducive to real-time encoding.
针对上述问题,本申请提出一种码率控制的方法与编码装置,可以兼顾码率控制准确度与编码器的计算复杂度。In view of the above problems, the present application proposes a method and an encoding apparatus for rate control, which can balance both the accuracy of the rate control and the computational complexity of the encoder.
在本申请中,首先,将图像复杂度引入码率控制算法。其次,由编码器外部的图像处理器,例如图像信号处理器(image signal processor,ISP)生成待编码图像的图像复杂度信息。In the present application, first, image complexity is introduced into a rate control algorithm. Secondly, image complexity information of the image to be encoded is generated by an image processor external to the encoder, such as an image signal processor (ISP).
由于无需编码器执行图像复杂度的计算,因此,可以避免为编码器引入额外的计算复杂度和编码耗时。同时,由于视频信号在经摄像头采集后,再传输到视频编码器之前,会首先经过图像处理器(例如ISP)的处理,因此,由图像处理器生成图像复杂度信息,不会在图像处理系统中引入额外的部件。Since the encoder is not required to perform image complexity calculations, it is possible to avoid introducing additional computational complexity and coding time-consuming for the encoder. At the same time, since the video signal is collected by the camera and then transmitted to the video encoder, it is first processed by an image processor (such as an ISP). Therefore, image complexity information generated by the image processor is not in the image processing system. Introduce additional components.
图2是本发明实施例的图像处理系统的架构示意图。该系统包括图像 处理器210和编码装置220。编码装置220包括预测模块221、变换模块222、码率控制模块223、量化模块224与熵编码模块225。2 is a schematic structural diagram of an image processing system according to an embodiment of the present invention. The system includes an image processor 210 and an encoding device 220. The encoding device 220 includes a prediction module 221, a transform module 222, a code rate control module 223, a quantization module 224, and an entropy encoding module 225.
图像处理器210用于,接收待编码的图像序列,计算其图像复杂度,并将图像复杂度输入到码率控制模块223中。The image processor 210 is configured to receive a sequence of images to be encoded, calculate its image complexity, and input the image complexity into the rate control module 223.
具体地,图像处理器210为ISP。Specifically, the image processor 210 is an ISP.
预测模块221用于,接收待编码的图像序列,对其进行预测,获得对应的残差信号。The prediction module 221 is configured to receive a sequence of images to be encoded, predict the same, and obtain a corresponding residual signal.
变化模块222用于,接收预测模块221输出的残差信号,对其进行变换,获得对应的变换参数。The change module 222 is configured to receive the residual signal output by the prediction module 221, transform it, and obtain a corresponding transform parameter.
码率控制模块用于,223根据预设编码比特与从图像处理器210获取的图像复杂度,获得对应的量化参数。The rate control module is configured to, 223, obtain a corresponding quantization parameter according to the preset coded bits and the image complexity acquired from the image processor 210.
量化模块224用于,接收变化模块222的变换参数以及码率控制模块223输出的量化参数,并利用量化参数对变化参数进行量化,获得对应的量化系数。The quantization module 224 is configured to receive the transformation parameters of the variation module 222 and the quantization parameters output by the rate control module 223, and quantize the variation parameters by using the quantization parameters to obtain corresponding quantization coefficients.
熵编码模块225用于,接收量化模块224输出的量化系数,并对量化系数进行熵编码,获得编码比特流。The entropy encoding module 225 is configured to receive the quantized coefficients output by the quantization module 224, and entropy encode the quantized coefficients to obtain an encoded bit stream.
如图2所示,系统中还包括反变换模块和反量化模块。反变换模块的功能与变换模块的功能相反。反量化模块的功能与量化模块的功能相反。As shown in FIG. 2, the system further includes an inverse transform module and an inverse quantization module. The function of the inverse transform module is opposite to that of the transform module. The function of the inverse quantization module is opposite to that of the quantization module.
在本发明实施例中,通过编码器外部的图像处理器计算图像复杂度,在图像编码过程中,利用该图像复杂度进行码率控制。一方面,在一定程度上保证码率控制精度;另一方面,将可能出现的大量计算由编码器外部的图像处理器完成,可以降低编码器的计算和实现复杂度。In the embodiment of the present invention, the image complexity is calculated by an image processor external to the encoder, and the image complexity is used to perform rate control in the image encoding process. On the one hand, the accuracy of the rate control is guaranteed to a certain extent; on the other hand, a large amount of calculations that may occur are performed by an image processor external to the encoder, which can reduce the computation and implementation complexity of the encoder.
图3是本发明实施例的码率控制的方法的示意性流程图。该方法可以由视频编码器执行,例如由图2中所示的编码装置220执行。如图3所示,该方法包括如下步骤。FIG. 3 is a schematic flowchart of a method for rate rate control according to an embodiment of the present invention. The method can be performed by a video encoder, such as by encoding device 220 shown in FIG. As shown in FIG. 3, the method includes the following steps.
310,接收待编码图像的图像复杂度,该图像复杂度是由与编码器相连的图像处理器获取的。310. Receive image complexity of an image to be encoded, the image complexity being acquired by an image processor connected to the encoder.
具体地,图像处理器获取待编码图像的图像复杂度,然后,编码器从图像处理器接收待编码图像的图像复杂度。该图像处理器位于编码器的外部。例如,该图像处理器为ISP。Specifically, the image processor acquires the image complexity of the image to be encoded, and then the encoder receives the image complexity of the image to be encoded from the image processor. The image processor is located external to the encoder. For example, the image processor is an ISP.
具体地,该待编码图像的图像复杂度是根据该待编码图像的纹理信息得 到的。应理解,通过计算图像的纹理信息得到的图像复杂度可以表征该图像的信息量。或者,该待编码图像的图像复杂度是根据该待编码图像内区域像素的波动剧烈程度确定的,即该待编码图像的图像复杂度表示该待编码图像内区域像素的波动剧烈程度。Specifically, the image complexity of the image to be encoded is obtained according to the texture information of the image to be encoded. It should be understood that the image complexity obtained by calculating the texture information of an image can characterize the amount of information of the image. Alternatively, the image complexity of the image to be encoded is determined according to the degree of fluctuation of the pixels in the image to be encoded, that is, the image complexity of the image to be encoded indicates the degree of fluctuation of the pixels in the region to be encoded.
320,确定该待编码图像的预设编码比特。320. Determine a preset coded bit of the image to be encoded.
具体地,预设编码比特指,在图像编码之前,预先分配的编码比特。Specifically, the preset coded bits refer to pre-assigned coded bits before image coding.
330,根据该图像复杂度与该预设编码比特,获得该待编码图像的量化参数。330. Obtain a quantization parameter of the image to be encoded according to the image complexity and the preset coding bit.
应理解,图像复杂度可以表征编码前图像的信息量,而预设编码比特表示经编码压缩后图像的信息量,因此通过结合图像复杂度及预设编码比特的方法计算量化参数是合理有效的。It should be understood that the image complexity may represent the amount of information of the image before encoding, and the preset coded bits represent the amount of information of the encoded compressed image, so it is reasonable and effective to calculate the quantization parameter by combining the image complexity and the preset encoding bit. .
340,根据该待编码图像的量化参数,对该待编码图像进行编码。340. Encode the image to be encoded according to the quantization parameter of the image to be encoded.
应理解,上述步骤310至步骤330属于码率控制过程。具体地,步骤310至步骤330可以由编码器内部的码率控制模块执行,步骤340可以由编码器内部的编码模块(例如,实现熵编码的模块)执行。It should be understood that the above steps 310 to 330 belong to the rate control process. Specifically, steps 310 through 330 may be performed by a code rate control module internal to the encoder, and step 340 may be performed by an encoding module internal to the encoder (eg, a module that implements entropy encoding).
本发明实施例在进行码率控制时,通过编码器外部的图像处理器获取图像复杂度,可以将可能出现的大量计算由编码器之外的图像处理器(例如ISP)完成,可以降低编码器的计算量和实现复杂度,从而可以避免编码器的编码延迟影响编码器的运行速度,进而有利于实现实时编码。同时,本发明实施例通过根据图像复杂度与预设编码比特获取量化参数,从而可以在一定程度上保证码率控制精度。因此,本发明实施例的方案可以在不牺牲码率控制精度的前提下,可以降低编码器的计算量和实现复杂度,从而可以提高编码效率。In the embodiment of the present invention, when the code rate control is performed, the image complexity is acquired by the image processor external to the encoder, and a large amount of calculations that may occur may be performed by an image processor (such as an ISP) other than the encoder, which may reduce the encoder. The computational complexity and implementation complexity can avoid the encoder's encoding delay affecting the running speed of the encoder, which in turn facilitates real-time encoding. In the meantime, the embodiment of the present invention can obtain the quantization parameter according to the image complexity and the preset coding bit, so that the rate control precision can be guaranteed to a certain extent. Therefore, the solution of the embodiment of the present invention can reduce the calculation amount and implementation complexity of the encoder without sacrificing the accuracy of the rate control, thereby improving the coding efficiency.
可选地,在一些实施例中,待编码图像为图像帧中的一个图像块。Optionally, in some embodiments, the image to be encoded is one image block in an image frame.
具体地,编码器在对一帧图像进行编码时,首先将整帧图像分为若干个64×64的图像块,如图4所示,将一帧图像划分为128个图像块,图4中每个块表示一个大小为64×64的图像块。然后,编码器按顺序依次对每个图像块进行编码。Specifically, when encoding an image of one frame, the encoder first divides the entire frame image into a plurality of 64×64 image blocks, as shown in FIG. 4, and divides one frame image into 128 image blocks, in FIG. Each block represents an image block of size 64 x 64. The encoder then encodes each image block in sequence.
可选地,在一些实施例中,待编码图像也可以直接是一帧图像。Optionally, in some embodiments, the image to be encoded may also be directly a frame image.
为了便于描述与理解,下文以待编码图像为图像帧中的一个图像块为例进行描述,但本发明实施例对此不作限定。For the convenience of description and understanding, the following is an example in which the image to be encoded is an image block in the image frame, but the embodiment of the present invention does not limit this.
可选地,在一些实施例中,该待编码图像所在的图像帧为I帧。Optionally, in some embodiments, the image frame in which the image to be encoded is located is an I frame.
具体地,在视频编码处理时,仅使用帧内预测模式的视频帧被称为I帧。Specifically, at the time of video encoding processing, a video frame using only the intra prediction mode is referred to as an I frame.
由于编码时I帧图像的残差信号是由帧内图像信号预测产生的,因此通过获取帧内图像的复杂度信息用于码率控制算法是有益的。Since the residual signal of the I-frame image at the time of encoding is generated by intra-frame image signal prediction, it is advantageous to use the complexity information of the intra-frame image for the rate control algorithm.
可选地,在一些实施例中,该待编码图像所在的图像帧为P帧。Optionally, in some embodiments, the image frame in which the image to be encoded is located is a P frame.
具体地,在视频编码处理时,使用前向参考帧进行帧间预测的视频帧称为P帧。Specifically, at the time of video encoding processing, a video frame that performs inter prediction using a forward reference frame is referred to as a P frame.
可选地,在一些实施例中,步骤330具体包括:利用第一函数模型计算该量化参数,该第一函数模型中不包括指数运算,该第一函数模型的自变量包括该图像复杂度与该预设编码比特。Optionally, in some embodiments, step 330 specifically includes: calculating the quantization parameter by using a first function model, where the exponential operation is not included in the first function model, and the independent variable of the first function model includes the image complexity and The preset coded bit.
可选地,在一些实施例中,该第一函数模型只包括对数运算、乘法运算、加法和/或减法运算,该第一函数模型的自变量包括该图像复杂度与该预设编码比特。Optionally, in some embodiments, the first function model only includes a logarithm operation, a multiplication operation, an addition operation, and/or a subtraction operation, and the independent variable of the first function model includes the image complexity and the preset coding bit. .
具体地,本发明实施例中提及的对数运算可以为各种形式的对数运算,例如,以e为底的对数运算,以10为底的对数运算,或者,是以其他数值为底数的对数运算,本发明实施例对此不作限定。Specifically, the logarithmic operation mentioned in the embodiment of the present invention may be a logarithmic operation of various forms, for example, an e-based logarithm operation, a base 10 logarithm operation, or other values. The logarithmic operation of the base number is not limited in this embodiment of the present invention.
可选地,在一些实施例中,该第一函数模型中的系数包括以下至少一个参数:作乘法运算的第一参数、作乘法运算的第二参数以及作加法和/或减法运算的第三参数,该第一参数、该第二参数与该第三参数均为用于码率控制的参数。Optionally, in some embodiments, the coefficients in the first function model include at least one of: a first parameter for multiplication, a second parameter for multiplication, and a third for addition and/or subtraction. The parameter, the first parameter, the second parameter and the third parameter are all parameters used for rate control.
具体地,该第一参数、该第二参数与该第三参数为编码器内部的码率控制模块自有的码率控制参数。Specifically, the first parameter, the second parameter, and the third parameter are code rate control parameters owned by the code rate control module inside the encoder.
具体地,利用第一函数模型计算该编码图像的量化参数,包括:根据如下公式计算该编码图像的量化参数:Specifically, calculating the quantization parameter of the encoded image by using the first function model includes: calculating a quantization parameter of the encoded image according to the following formula:
QP=A1·log(complexity)+A2·log(targetBits)+B (2)QP=A1·log(complexity)+A2·log(targetBits)+B (2)
其中,QP表示所述量化参数,complexity表示所述图像复杂度,targetBits表示所述预设编码比特,A1表示所述第一参数,A2表示所述第二参数,B表示所述第三参数,log()表示对数运算。Wherein QP represents the quantization parameter, complexity represents the image complexity, targetBits represents the preset coded bit, A1 represents the first parameter, A2 represents the second parameter, and B represents the third parameter, Log() represents a logarithm operation.
可选地,在一些实施例中,第一参数A1和第二参数A2的绝对值相同。Optionally, in some embodiments, the absolute values of the first parameter A1 and the second parameter A2 are the same.
可选地,在一些实施例中,待编码图像的图像复杂度是根据该待编码 图像的纹理信息得到的。换句话说,编码器外部的图像处理器(例如ISP)根据图像的纹理信息计算图像复杂度。Optionally, in some embodiments, the image complexity of the image to be encoded is derived from texture information of the image to be encoded. In other words, an image processor (eg, an ISP) external to the encoder calculates image complexity from the texture information of the image.
具体地,假设该待编码图像包括M个像素块,该像素块的大小为N×N,M与N均为正整数,该待编码图像的图像复杂度为
SAD
j为M个像素块中第j个像素块的像素差绝对值之和,且
Ave
j为该第j个像素块的像素平均值,且
表示该第j个像素块中的像素。
Specifically, it is assumed that the image to be encoded includes M pixel blocks, the size of the pixel block is N×N, and both M and N are positive integers, and the image complexity of the image to be encoded is SAD j is the sum of the absolute values of the pixel differences of the jth pixel block in the M pixel blocks, and Ave j is the pixel average of the jth pixel block, and Represents pixels in the jth pixel block.
作为一个示例,一幅完整图像(记为图像帧)划分为若干个大小为64×64的图像块。以分辨率为1920×1080的图像帧为例,可划分为510(30×17)个图像块。以大小为2×2的像素块作为计算图像复杂度的最小单位,如图5中所示的由四个像素x0、x1、x2、x3组成的像素块。应理解,一个图像块中包括1024个像素块。As an example, a complete image (denoted as an image frame) is divided into a number of image blocks of size 64 x 64. Taking an image frame with a resolution of 1920×1080 as an example, it can be divided into 510 (30×17) image blocks. A pixel block having a size of 2 × 2 is used as a minimum unit for calculating image complexity, and a pixel block composed of four pixels x0, x1, x2, and x3 as shown in FIG. It should be understood that 1024 pixel blocks are included in one image block.
首先,根据如下公式计算一个像素块的像素平均值average
2×2:
First, calculate the pixel average of the pixel block average 2×2 according to the following formula:
average
2×2=(x0+x1+x2+x3)/4 (3)
Average 2×2 =(x0+x1+x2+x3)/4 (3)
其次,根据如下公式计算该像素块的像素差绝对值之和SAD
2×2:
Next, the sum of the absolute values of the pixel differences of the pixel block is calculated according to the following formula: SAD 2 × 2 :
其中,xi表示该像素块中第i个像素的像素值。Where xi represents the pixel value of the ith pixel in the pixel block.
然后,根据如下公式计算一个图像块的图像复杂度complexity
64×64:
Then, calculate the image complexity of an image block according to the following formula: Complexity 64×64 :
其中,SAD
2x2i表示该图像块中的第i个像素块的像素差绝对值之和。
Wherein, SAD 2x2i represents the sum of the absolute values of the pixel differences of the i-th pixel block in the image block.
换句话说,通过将同一个图像块中所有像素块的像素差绝对值之和SAD
2×2相加,获得该图像块的图像复杂度。
In other words, the image complexity of the image block is obtained by adding the sum of the absolute values of the pixel differences of all the pixel blocks in the same image block, SAD 2 × 2 .
图像帧的图像复杂度可由该图像帧内的所有图像块的图像复杂度相加获得。The image complexity of an image frame can be obtained by adding the image complexity of all image blocks within the image frame.
图像块的图像复杂度可称为块级图像复杂度。图像帧的图像复杂度可称为帧级图像复杂度。The image complexity of an image block can be referred to as block level image complexity. The image complexity of an image frame can be referred to as frame level image complexity.
应理解,上述结合图5的描述仅为示例而非限定。实际应用中,可以根据具体情况确定用于计算图像复杂度的最小单位。It should be understood that the above description in connection with FIG. 5 is merely an example and not a limitation. In practical applications, the minimum unit for calculating image complexity can be determined on a case-by-case basis.
可选地,在一些实施例中,待编码图像的图像复杂度表示待编码图像内 区域像素的波动剧烈程度。Alternatively, in some embodiments, the image complexity of the image to be encoded represents the degree of volatility of pixels in the region of the image to be encoded.
作为一种可选实现方式,待编码图像的图像复杂度是通过频域计算方法获得。As an alternative implementation, the image complexity of the image to be encoded is obtained by a frequency domain calculation method.
例如,图像处理器通过统计待编码图像的离散(正)余弦变换或哈达玛变换的变换系数,确定待编码图像的图像复杂度。For example, the image processor determines the image complexity of the image to be encoded by counting the discrete (positive) cosine transform of the image to be encoded or the transform coefficients of the Hadamard transform.
作为另一种可选实现方式,待编码图像的图像复杂度是通过像素域计算方法获得。As another alternative implementation, the image complexity of the image to be encoded is obtained by a pixel domain calculation method.
例如,图像处理器通过计算待编码图像内像素的方差或标准差,确定待编码图像的图像复杂度。For example, the image processor determines the image complexity of the image to be encoded by calculating the variance or standard deviation of the pixels within the image to be encoded.
可选地,在一些实施例中,待编码图像为图像帧中的一个图像块,步骤320具体包括:根据帧级预设编码比特、帧级图像复杂度以及该待编码图像的图像复杂度,确定该待编码图像的预设编码比特,其中,帧级预设编码比特表示该图像帧的预设编码比特,帧级图像复杂度指的是该图像帧内所有图像块的图像复杂度之和。Optionally, in some embodiments, the image to be encoded is one image block in the image frame, and the step 320 specifically includes: preset the encoding bit according to the frame level, the frame level image complexity, and the image complexity of the image to be encoded, Determining a preset encoding bit of the image to be encoded, wherein the frame level preset encoding bit represents a preset encoding bit of the image frame, and the frame level image complexity refers to a sum of image complexity of all image blocks in the image frame. .
具体地,假设该待编码图像为图像帧中的第i个图像块,根据如下公式计算该待编码图像的预设编码比特targetBits
i:
Specifically, it is assumed that the image to be encoded is the i-th image block in the image frame, and the preset encoding bit targetBits i of the image to be encoded is calculated according to the following formula:
其中,targetBits表示帧级预设编码比特,complexity
i表示图像帧中的第i个图像块(即该待编码图像)的图像复杂度,∑
jcomplexity
j表示帧级图像复杂度,即图像帧内所有图像块的图像复杂之和。
Wherein, the preset stage TargetBits represents a frame encoded bits, the complexity of the image Complexity image i represents the i-th frame image block (i.e., the image to be encoded) is, Σ j complexity j denotes the frame complexity level image, i.e. image frame The sum of the images of all image blocks is complex.
具体地,计算图像复杂度的过程请参见结合图5的描述,这里不再赘述。Specifically, for the process of calculating image complexity, please refer to the description in conjunction with FIG. 5, and details are not described herein again.
具体地,本实施例中的图像帧为I帧。Specifically, the image frame in this embodiment is an I frame.
可选地,可以在编码开始之前,预先为图像帧中的每个图像块分配预设编码比特。Alternatively, preset coded bits may be assigned to each image block in the image frame in advance before encoding begins.
可选地,在一些实施例中,待编码图像为图像帧中的一个图像块,该图像帧为P帧,步骤320具体包括:根据该P帧的帧级预设比特与第一系数的乘积确定该待编码图像的预设比特,其中,该第一系数是根据以下至少一项确定的:该P帧的总体图像复杂度、该P帧内所有图像块的权重之和、该待编码图像的图像复杂度、该待编码图像的权重以及该P帧的帧级预设比特,其中,该权重由该P帧的码率控制参数确定。Optionally, in some embodiments, the image to be encoded is an image block in an image frame, and the image frame is a P frame, and the step 320 specifically includes: a product of a frame-level preset bit and the first coefficient according to the P frame. Determining a preset bit of the image to be encoded, wherein the first coefficient is determined according to at least one of: an overall image complexity of the P frame, a sum of weights of all image blocks in the P frame, the image to be encoded Image complexity, weight of the image to be encoded, and frame level preset bits of the P frame, wherein the weight is determined by a code rate control parameter of the P frame.
具体地,该第一系数是根据该待编码图像的图像复杂度占该P帧的总体图像复杂度的比例与第二系数的乘积,与该待编码图像的权重占该P帧内所有图像块的权重之和的比例与第三系数的乘积之和确定的,其中,该第二系数和该第三系数均大于0,且第二系数和第三系数的和等于1。Specifically, the first coefficient is a product of a ratio of an image complexity of the image to be encoded to a total image complexity of the P frame and a second coefficient, and a weight of the image to be encoded accounts for all image blocks in the P frame. The ratio of the sum of the weights is determined by the sum of the products of the third coefficients, wherein the second coefficient and the third coefficient are both greater than 0, and the sum of the second coefficient and the third coefficient is equal to one.
作为一个示例,假设该待编码图像为图像帧中的第i个图像块,根据如下公式计算该待编码图像的预设编码比特targetBits
i:
As an example, assuming that the image to be encoded is the i-th image block in the image frame, the preset encoding bit targetBits i of the image to be encoded is calculated according to the following formula:
其中,targetBits表示帧级预设编码比特;complexity
i表示该图像帧中的第i个图像块(即该待编码图像)的图像复杂度;∑
jcomplexity
j表示帧级图像复杂度,即该图像帧内所有图像块的图像复杂度之和;weight
i表示图像帧中第i个图像块(即该待编码图像)的权重,∑
jweight
j表示该图像帧内所有图像块的权重之和;C1表示第二系数,C2表示第三系数。例如,第二系数C1为1/4,第三系数C2为3/4。本示例中,图像块的权重是按照P帧的码率控制参数确定的权重。
Wherein, targetBits represents a frame-level preset encoding bit; complexity i represents an image complexity of an i-th image block (ie, the image to be encoded) in the image frame; ∑ j complexity j represents a frame-level image complexity, that is, the image The sum of the image complexity of all image blocks in the frame; weight i represents the weight of the i-th image block (ie, the image to be encoded) in the image frame, and ∑ j weight j represents the sum of the weights of all image blocks in the image frame; C1 represents the second coefficient and C2 represents the third coefficient. For example, the second coefficient C1 is 1/4 and the third coefficient C2 is 3/4. In this example, the weight of the image block is the weight determined according to the code rate control parameter of the P frame.
具体地,计算图像复杂度的过程请参见结合图5的描述,这里不再赘述。Specifically, for the process of calculating image complexity, please refer to the description in conjunction with FIG. 5, and details are not described herein again.
可选地,可以在编码开始之前,预先为图像帧中的每个图像块分配预设编码比特。Alternatively, preset coded bits may be assigned to each image block in the image frame in advance before encoding begins.
从公式(6)和公式(7)可知,在本申请提供的方案中,针对I帧与P帧,确定预设编码比特的方法不同。换句话说,在I帧编码时使用的码率控制策略与在P帧编码时使用的码率控制策略不同,这样有利于提高码率控制的准确度,理由如下。It can be seen from the formula (6) and the formula (7) that, in the solution provided by the present application, the method of determining the preset coded bits is different for the I frame and the P frame. In other words, the rate control strategy used in the I frame encoding is different from the rate control strategy used in the P frame encoding, which is advantageous for improving the accuracy of the rate control for the following reasons.
由于I帧不依赖时域的参考信息来产生预测残差,因此在编码I帧时得到的残差信息表示的是某编码子块与与其空间相邻图像间的差异。而编码P帧时得到的残差信息更多地表示当前编码帧与参考帧在时域上的差异。换句话说,在I帧编码和P帧编码时得到的残差信息不同,对应地,在码率控制时,针对I帧与P帧的码率控制策略也应该相应不同。在业界现有的一些码率控制算法中,在I帧编码时使用的是与P帧相同的码率控制策略,这种做法会导致码率控制不准确,从而影响编码后视频的质量。Since the I frame does not depend on the reference information of the time domain to generate the prediction residual, the residual information obtained when the I frame is encoded represents the difference between a certain coded subblock and its spatially adjacent image. The residual information obtained when encoding the P frame more indicates the difference between the current encoded frame and the reference frame in the time domain. In other words, the residual information obtained at the time of I frame coding and P frame coding is different, and correspondingly, the code rate control strategy for the I frame and the P frame should be different in the case of rate control. In some existing rate control algorithms in the industry, the same rate control strategy as the P frame is used in the I frame coding, which leads to inaccurate rate control, which affects the quality of the encoded video.
因此,本申请通过采用不同的码率控制策略处理I帧编码与P帧编码,从而可以提高码率控制准确性。Therefore, the present application can improve the rate control accuracy by processing the I frame coding and the P frame coding by using different rate control strategies.
可选地,在某些实施例中,该待编码图像为该待编码图像所在的图像帧中的一个图像块,该方法还包括:根据该图像帧的帧级图像复杂度与帧级预设编码比特,获取该图像帧的量化参数。步骤340具体包括:根据该待编码图像的量化参数与该图像帧的量化参数的大小关系,确定用于对该待编码图像进行编码的量化参数,然后利用最终确定的量化参数对该待编码图像进行编码。Optionally, in some embodiments, the image to be encoded is an image block in an image frame in which the image to be encoded is located, and the method further includes: according to a frame level image complexity and a frame level preset of the image frame. Encoding bits to obtain quantization parameters for the image frame. The step 340 specifically includes: determining, according to the size relationship between the quantization parameter of the image to be encoded and the quantization parameter of the image frame, a quantization parameter used to encode the image to be encoded, and then using the finally determined quantization parameter to the image to be encoded. Encode.
可选地,在某些实施例中,该待编码图像的量化参数在该图像帧的量化参数的范围内,步骤340具体包括:根据该待编码图像的量化参数,对该待编码图像进行编码。Optionally, in some embodiments, the quantization parameter of the image to be encoded is within a range of the quantization parameter of the image frame, and the step 340 specifically includes: encoding the image to be encoded according to the quantization parameter of the image to be encoded. .
可选地,在某些实施例中,该待编码图像的量化参数不在该图像帧的量化参数的范围内,步骤340具体包括:将该待编码图像的量化参数剪裁至该图像帧的量化参数的范围内,根据该剪裁之后的该待编码图像的量化参数对该待编码图像进行编码。Optionally, in some embodiments, the quantization parameter of the image to be encoded is not in the range of the quantization parameter of the image frame, and the step 340 specifically includes: cutting the quantization parameter of the image to be encoded to the quantization parameter of the image frame. The image to be encoded is encoded according to the quantization parameter of the image to be encoded after the cropping.
可选地,在一些实施例中,该待编码图像表示整帧图像中的图像块。换句话说,以图像块为最小编码单位进行整帧图像的编码。Optionally, in some embodiments, the image to be encoded represents an image block in an entire frame of image. In other words, the encoding of the entire frame image is performed with the image block as the minimum coding unit.
具体地,先将整帧图像划分为若干个图像块,然后按顺序依次对每个图像块按照步骤310至步骤340进行编码,当完成图像帧内所有图像块的编码时,完成整帧图像的编码。Specifically, the entire frame image is first divided into a plurality of image blocks, and then each image block is sequentially encoded in steps 310 to 340 in sequence, and when the encoding of all image blocks in the image frame is completed, the entire frame image is completed. coding.
可选地,在一些实施例中,在完成该待编码图像所在的图像帧的编码后,该方法还包括:根据该图像帧的帧级实际编码比特与帧级预设编码比特,更新该第三参数,该帧级实际编码比特表示该图像帧的实际编码比特,该帧级预设编码比特表示该图像帧的帧级预设编码比特。Optionally, in some embodiments, after the encoding of the image frame where the image to be encoded is completed, the method further includes: updating the first according to the frame-level actual coding bit and the frame-level preset coding bit of the image frame. The three parameters, the frame-level actual coded bits represent actual coded bits of the image frame, and the frame-level preset coded bits represent frame-level preset coded bits of the image frame.
具体地,根据第二函数模型,获得更新后的第三参数,该第二函数模型的自变量包括该帧级实际编码比特、该帧级预设编码比特、以及更新之前的第三参数,该第二函数模型包括以下至少一种运算:对数运算、乘法运算、加法和/或减法运算。Specifically, according to the second function model, the updated third parameter is obtained, where the argument of the second function model includes the frame-level actual coded bit, the frame-level preset coded bit, and the third parameter before the update, The second function model includes at least one of the following operations: a logarithmic operation, a multiplication operation, an addition, and/or a subtraction operation.
作为一个示例,根据如下公式获得更新的第三参数B
new:
As an example, the updated third parameter B new is obtained according to the following formula:
B
new=B
old+k·A1·(log(actualBits)-log(targetBits)) (8)
B new =B old +k·A1·(log(actualBits)-log(targetBits)) (8)
其中,表示更新之前的第三参数,即上一个完成编码的图像帧所采用的第三参数;表示第一参数;k表示更新速率,例如可以取为经验值2;actualBits表示帧级实际编码比特;targetBits表示帧级预设编码比特。Wherein, the third parameter before the update is indicated, that is, the third parameter adopted by the image frame of the last completed encoding; represents the first parameter; k represents the update rate, for example, may be taken as the empirical value 2; and actualBits represents the actual coded bit at the frame level. ; targetBits represents frame-level preset encoding bits.
应理解,码率控制参数A1(即第一参数)、码率控制参数B(即第三参数)为编码器内部码率控制模块自有的参数,为使码率控制模块更适应不同视频图像的特点,在编码过程中,每完成一帧图像的编码后,码率控制参数B会根据帧级实际编码比特与帧级预设编码比特的差距进行自适应迭代更新。It should be understood that the code rate control parameter A1 (ie, the first parameter) and the code rate control parameter B (ie, the third parameter) are parameters of the encoder internal code rate control module, so that the code rate control module is more suitable for different video images. In the encoding process, after encoding one frame of image, the code rate control parameter B adaptively iteratively updates according to the difference between the frame-level actual coded bits and the frame-level preset coded bits.
本实施例,通过在完成一帧图像的编码后,迭代更新码率控制参数,从而可以使得编码器内的码率控制模块更适应不同视频图像的特点,这样可以提高码率控制的准确性。In this embodiment, after the encoding of one frame of image is completed, the code rate control parameter is iteratively updated, so that the code rate control module in the encoder can be more adapted to the characteristics of different video images, thereby improving the accuracy of the rate control.
应理解,本文中描述的各个公式仅为示例而非限定。例如,公式中的参数或系数可以根据实际需求确定。It should be understood that the various formulas described herein are merely exemplary and not limiting. For example, the parameters or coefficients in the formula can be determined based on actual needs.
图6是本发明实施例的图像编码方法的另一示意性流程图,该方法由编码器执行。在本实施例的描述中,将图像块的图像复杂度、预设编码比特、实际编码比特、量化参数分别记为:块级图像复杂度、块级预设编码比特、块级实际编码比特、块级量化参数。将整帧图像的图像复杂度、预设编码比特、实际编码比特、量化参数分别记为:帧级图像复杂度、帧级预设编码比特、帧级实际编码比特、帧级量化参数。如图6所示,该方法包括如下步骤。FIG. 6 is another schematic flowchart of an image encoding method according to an embodiment of the present invention, which is performed by an encoder. In the description of the embodiment, the image complexity, the preset coding bits, the actual coding bits, and the quantization parameters of the image block are respectively recorded as: block-level image complexity, block-level preset coding bits, block-level actual coding bits, Block level quantization parameters. The image complexity, preset coding bits, actual coding bits, and quantization parameters of the entire frame image are respectively recorded as: frame-level image complexity, frame-level preset coding bits, frame-level actual coding bits, and frame-level quantization parameters. As shown in FIG. 6, the method includes the following steps.
6001,从图像处理器获取块级图像复杂度,该图像处理器位于编码器的外部。6001, obtaining block level image complexity from an image processor that is external to the encoder.
6002,确定块级预设编码比特。6002. Determine block level preset coding bits.
6003,根据步骤6001确定的块级图像复杂度与步骤6002确定的块级预设编码比特,并结合码率控制参数(如上文实施例中的第一参数、第二参数与第三参数),计算块级量化参数。6003, the block-level image complexity determined according to step 6001 and the block-level preset coding bit determined in step 6002, and combined with the code rate control parameter (such as the first parameter, the second parameter, and the third parameter in the foregoing embodiment), Calculate block level quantization parameters.
6004,从图像处理器获取帧级图像复杂度。6004, obtaining frame level image complexity from the image processor.
6005,确定帧级预设编码比特。6005, determining frame level preset coding bits.
6006,根据步骤6004确定的帧级图像复杂度与步骤6005确定的帧级预设编码比特,并结合码率控制参数(如上文实施例中的第一参数、第二参数与第三参数),计算帧级量化参数。6006, according to the frame-level image complexity determined in step 6004 and the frame-level preset coding bits determined in step 6005, and combined with the code rate control parameters (such as the first parameter, the second parameter, and the third parameter in the foregoing embodiments), Calculate frame level quantization parameters.
6007,判断步骤6003得到的块级量化参数是否在步骤6006得到的帧级量化参数的范围内,若是,转到步骤6008,若否,转到步骤6009。6007. Determine whether the block-level quantization parameter obtained in step 6003 is within the range of the frame-level quantization parameter obtained in step 6006. If yes, go to step 6008, and if no, go to step 6009.
6008,将步骤6003得到的块级量化参数剪裁至步骤6006得到的帧级量化参数的一定范围内,转到步骤6009。6008. The block-level quantization parameter obtained in step 6003 is clipped to a certain range of the frame-level quantization parameter obtained in step 6006, and the process proceeds to step 6009.
6009,将最终得到的块级量化参数输入量化模块中进行图像块的编码。6009. Input the block-level quantization parameter finally obtained into the quantization module to perform coding of the image block.
具体地,若步骤6007的判断结果为是,则将步骤6003得到的块级量化参数输入量化模块中;若步骤6007的判断结果为否,则将步骤6008中经过剪裁之后的块级量化参数输入量化模块中。Specifically, if the determination result of step 6007 is YES, the block-level quantization parameter obtained in step 6003 is input into the quantization module; if the determination result in step 6007 is negative, the block-level quantization parameter after the clipping in step 6008 is input. Quantization module.
6010,判断是否完成当前一帧完整图像的编码,若是,转到步骤6011,若否,转到步骤6012。6010. Determine whether the encoding of the current one frame complete image is completed. If yes, go to step 6011, and if no, go to step 6012.
6011,根据当前完成编码的图像帧的帧级实际编码比特与帧级预设编码比特,更新步骤6006中采用的码率控制参数。转到步骤6006。6011: Update the code rate control parameter used in step 6006 according to the frame-level actual coding bit and the frame-level preset coding bit of the currently completed encoded image frame. Go to step 6006.
具体地,更新如上文实施例中描述的第三参数,详见上文相关描述,这里不再赘述。Specifically, the third parameter as described in the foregoing embodiment is updated. For details, refer to the related description above, and details are not described herein again.
6012,根据当前完成编码的图像块的块级实际编码比特与块级预设编码比特,为下一个待编码的图像块分配块级预设编码比特。转到步骤6002。6012. Allocate block-level preset coding bits for the next image block to be encoded according to the block-level actual coding bits and the block-level preset coding bits of the currently completed coded image block. Go to step 6002.
具体地,在一个图像块编码完成后,可以根据该图像块的实际编码比特与预设编码比特的差值,为下一个待编码的图像块分配预设编码比特。Specifically, after the encoding of one image block is completed, the preset coded bits may be allocated to the next image block to be encoded according to the difference between the actual coded bits of the image block and the preset coded bits.
应理解,通过设置帧级量化参数与块级量化参数,可以在保证码率控制精度的同时使得一帧内的图像质量稳定。It should be understood that by setting the frame-level quantization parameter and the block-level quantization parameter, the image quality within one frame can be stabilized while ensuring the accuracy of the code rate control.
还应理解,上述过程中的步骤6001、步骤6002、步骤6004、步骤6005之间没有严格的顺序关系。It should also be understood that there is no strict order relationship between step 6001, step 6002, step 6004, and step 6005 in the above process.
综上所述,本发明实施例在进行码率控制时,通过编码器外部的图像处理器获取图像复杂度,可以将可能出现的大量计算由编码器之外的图像处理器(例如ISP)完成,从而可以降低编码器的计算量和实现复杂度,进而可以避免编码器进行二次编码带来的编码延迟。同时,本发明实施例通过根据图像复杂度与预设编码比特获取量化参数,从而可以在一定程度上保证码率控制精度。因此,本发明实施例的方案可以在不牺牲码率控制精度的前提下,可以降低编码器的计算量和实现复杂度,从而可以提高编码效率。In summary, in the embodiment of the present invention, when the rate control is performed, the image complexity is acquired by the image processor external to the encoder, and a large amount of calculations that may occur may be performed by an image processor (such as an ISP) other than the encoder. Therefore, the calculation amount and implementation complexity of the encoder can be reduced, and the encoding delay caused by the secondary encoding of the encoder can be avoided. In the meantime, the embodiment of the present invention can obtain the quantization parameter according to the image complexity and the preset coding bit, so that the rate control precision can be guaranteed to a certain extent. Therefore, the solution of the embodiment of the present invention can reduce the calculation amount and implementation complexity of the encoder without sacrificing the accuracy of the rate control, thereby improving the coding efficiency.
上文描述了本申请的方法实施例,下文将描述本申请的装置实施例。应理解,装置实施例的描述与方法实施例的描述相互对应,因此,未详细描述的内容可以参见前面方法实施例,为了简洁,这里不再赘述。The method embodiments of the present application have been described above, and the device embodiments of the present application will be described below. It should be understood that the description of the device embodiments and the description of the method embodiments correspond to each other. Therefore, for the details that are not described in detail, reference may be made to the foregoing method embodiments, and for brevity, no further details are provided herein.
图7为本发明实施例提供的编码装置700的示意性框图,该编码装置700包括:FIG. 7 is a schematic block diagram of an encoding apparatus 700 according to an embodiment of the present invention. The encoding apparatus 700 includes:
收发单元710,用于接收待编码图像的图像复杂度,该图像复杂度是由 与编码器相连的图像处理器获取的;The transceiver unit 710 is configured to receive image complexity of the image to be encoded, where the image complexity is acquired by an image processor connected to the encoder;
处理单元720,用于确定该待编码图像的预设编码比特;根据该图像复杂度与该预设编码比特,获得该待编码图像的量化参数;根据该待编码图像的量化参数,对该待编码图像进行编码。The processing unit 720 is configured to determine a preset encoding bit of the image to be encoded, obtain a quantization parameter of the image to be encoded according to the image complexity and the preset encoding bit, and obtain the quantization parameter according to the quantization parameter of the image to be encoded. The encoded image is encoded.
可选地,在一些实施例中,该处理单元720具体用于,利用第一函数模型计算该量化参数,该第一函数模型只包括对数运算、乘法运算、加法和/或减法运算,该第一函数模型的自变量包括该图像复杂度与该预设编码比特。Optionally, in some embodiments, the processing unit 720 is specifically configured to calculate the quantization parameter by using a first function model, where the first function model only includes a logarithm operation, a multiplication operation, an addition, and/or a subtraction operation, where The argument of the first function model includes the image complexity and the preset coded bits.
可选地,在一些实施例中,该第一函数模型中的系数包括以下至少一个参数:作乘法运算的第一参数、作乘法运算的第二参数以及作加法和/或减法运算的第三参数,该第一参数、该第二参数与该第三参数均为用于码率控制的参数。Optionally, in some embodiments, the coefficients in the first function model include at least one of: a first parameter for multiplication, a second parameter for multiplication, and a third for addition and/or subtraction. The parameter, the first parameter, the second parameter and the third parameter are all parameters used for rate control.
可选地,在一些实施例中,该第一函数模型为:该图像复杂度的对数运算值与该第一参数的乘积、该预设编码比特的对数运算值与该第三参数的乘积、与该第二参数的和。Optionally, in some embodiments, the first function model is: a product of a logarithm operation value of the image complexity and the first parameter, a logarithm operation value of the preset coded bit, and a third parameter The sum of the product and the second parameter.
可选地,在一些实施例中,该第一参数和该第二参数的绝对值相同。Optionally, in some embodiments, the absolute values of the first parameter and the second parameter are the same.
可选地,在一些实施例中,在完成该待编码图像所在的图像帧的编码后,该处理单元720还用于:根据该图像帧的帧级实际编码比特与帧级预设编码比特,更新该第三参数,该帧级实际编码比特表示该图像帧的实际编码比特,该帧级预设编码比特表示该图像帧的帧级预设编码比特。Optionally, in some embodiments, after the encoding of the image frame in which the image to be encoded is completed, the processing unit 720 is further configured to: according to the frame-level actual encoding bit and the frame-level preset encoding bit of the image frame, Updating the third parameter, the frame-level actual coded bits represent actual coded bits of the image frame, the frame-level preset coded bits representing frame-level preset coded bits of the image frame.
可选地,在一些实施例中,该处理单元720具体用于,根据第二函数模型,获得更新后的第三参数,该第二函数模型的自变量包括该帧级实际编码比特、该帧级预设编码比特、以及更新之前的第三参数,该第二函数模型包括以下至少一种运算:对数运算、乘法运算、加法和/或减法运算。Optionally, in some embodiments, the processing unit 720 is specifically configured to obtain, according to the second function model, an updated third parameter, where the argument of the second function model includes the frame-level actual coded bit, the frame The level preset coded bits, and the third parameter before the update, the second function model includes at least one of the following operations: a logarithmic operation, a multiplication operation, an addition, and/or a subtraction operation.
可选地,在一些实施例中,该第二函数模型为:该帧级实际编码比特的对数运算值与该帧级预设编码比特的对数运算值之差与更新速率值以及该第一参数的乘积,与更新之前的第三参数的和。Optionally, in some embodiments, the second function model is: a difference between a logarithm operation value of the frame-level actual coded bit and a logarithm operation value of the frame-level preset coded bit, and an update rate value and the first The product of a parameter, the sum of the third parameter before the update.
可选地,在一些实施例中,该待编码图像为该待编码图像所在的图像帧中的一个图像块;该处理单元720具体用于,根据该图像帧的帧级预设编码比特、该图像帧的帧级图像复杂度以及该待编码图像的图像复杂度,确定该待编码图像的预设编码比特。Optionally, in some embodiments, the image to be encoded is an image block in an image frame in which the image to be encoded is located; the processing unit 720 is specifically configured to: preset a coding bit according to a frame level of the image frame, The frame-level image complexity of the image frame and the image complexity of the image to be encoded determine a preset encoded bit of the image to be encoded.
可选地,在一些实施例中,该处理单元720具体用于,根据该待编码图 像的图像复杂度占该图像帧的帧级图像复杂度的比例,与该图像帧的帧级预设编码比特的乘积,确定该待编码图像的预设编码比特。Optionally, in some embodiments, the processing unit 720 is configured to: according to a ratio of image complexity of the image to be encoded to a frame-level image complexity of the image frame, and a frame-level preset encoding of the image frame. The product of the bits determines the preset coded bits of the image to be encoded.
可选地,在一些实施例中,该待编码图像为该待编码图像所在的图像帧中的一个图像块;该处理单元720还用于,根据该图像帧的图像复杂度与帧级预设编码比特,获取该图像帧的量化参数;在对该待编码图像进行编码时,该处理单元720具体用于,当该待编码图像的量化参数在该图像帧的量化参数的范围内时,根据该待编码图像的量化参数,对该待编码图像进行编码。Optionally, in some embodiments, the image to be encoded is one image block in an image frame in which the image to be encoded is located; the processing unit 720 is further configured to preset according to image complexity and frame level of the image frame. Encoding a bit, obtaining a quantization parameter of the image frame; when encoding the image to be encoded, the processing unit 720 is specifically configured to: when the quantization parameter of the image to be encoded is within a range of the quantization parameter of the image frame, according to The quantization parameter of the image to be encoded is encoded by the image to be encoded.
可选地,在一些实施例中,在对该待编码图像进行编码时,该处理单元720具体用于,当该待编码图像的量化参数不在该图像帧的量化参数的范围内时,将该待编码图像的量化参数剪裁至该图像帧的量化参数的范围内,根据该剪裁之后的该待编码图像的量化参数对该待编码图像进行编码。Optionally, in some embodiments, when the image to be encoded is encoded, the processing unit 720 is specifically configured to: when the quantization parameter of the image to be encoded is not within the range of the quantization parameter of the image frame, The quantization parameter of the image to be encoded is clipped to the range of the quantization parameter of the image frame, and the image to be encoded is encoded according to the quantization parameter of the image to be encoded after the clipping.
可选地,在一些实施例中,该待编码图像所在的图像帧为I帧。Optionally, in some embodiments, the image frame in which the image to be encoded is located is an I frame.
可选地,在一些实施例中,该待编码图像所在的图像帧为P帧,该待编码图像为该P帧中的一个图像块;该处理单元720具体用于,根据该P帧的帧级预设比特与第一系数的乘积确定该待编码图像的预设比特,其中,该第一系数是根据以下至少一项确定的:该P帧的总体图像复杂度、该P帧内所有图像块的权重之和、该待编码图像的图像复杂度、该待编码图像的权重以及该P帧的帧级预设比特,其中,该权重由该P帧的码率控制参数确定。Optionally, in some embodiments, the image frame in which the image to be encoded is located is a P frame, and the image to be encoded is an image block in the P frame; the processing unit 720 is specifically configured to: according to the frame of the P frame The product of the preset bits and the first coefficient determines a preset bit of the image to be encoded, wherein the first coefficient is determined according to at least one of: an overall image complexity of the P frame, all images in the P frame The sum of the weights of the blocks, the image complexity of the image to be encoded, the weight of the image to be encoded, and the frame level preset bits of the P frame, wherein the weight is determined by the code rate control parameter of the P frame.
可选地,在一些实施例中,该处理单元720具体用于,该第一系数是根据该待编码图像的图像复杂度占该P帧的总体图像复杂度的比例与第二系数的乘积,与该待编码图像的权重占该P帧内所有图像块的权重之和的比例与第三系数的乘积之和确定的,其中,该第二系数和该第三系数均大于0,且第二系数和第三系数的和等于1。Optionally, in some embodiments, the processing unit 720 is specifically configured to: the first coefficient is a product of a ratio of an image complexity of the image to be encoded to a total image complexity of the P frame and a second coefficient, Determining, by the sum of the ratio of the weight of the image to be encoded to the sum of the weights of all image blocks in the P frame and the product of the third coefficient, wherein the second coefficient and the third coefficient are both greater than 0, and the second The sum of the coefficient and the third coefficient is equal to one.
可选地,在一些实施例中,该待编码图像的图像复杂度是根据该待编码图像的纹理信息得到的。Optionally, in some embodiments, the image complexity of the image to be encoded is obtained according to texture information of the image to be encoded.
可选地,在一些实施例中,该待编码图像的图像复杂度表示该待编码图像内区域像素的波动剧烈程度。Optionally, in some embodiments, the image complexity of the image to be encoded indicates the degree of fluctuation of the pixels in the area of the image to be encoded.
可选地,在一些实施例中,该待编码图像的图像复杂度是通过统计该待编码图像的离散正/余弦变换或哈达玛变换的变换系数获得的。Optionally, in some embodiments, the image complexity of the image to be encoded is obtained by counting the discrete positive/cosine transform of the image to be encoded or the transform coefficient of the Hadamard transform.
可选地,在一些实施例中,该待编码图像的图像复杂度是通过计算该待编码图像内的像素的方差或标准差获得的。Optionally, in some embodiments, the image complexity of the image to be encoded is obtained by calculating a variance or a standard deviation of pixels within the image to be encoded.
可选地,在一些实施例中,该图像处理器为图像信号处理器ISP。Optionally, in some embodiments, the image processor is an image signal processor ISP.
本实施例中的处理单元710具体包括:码率控制单元、预测单元,变换单元,反变换单元,量化单元,反量化单元,熵编码单元。其中,码率控制单元用于实现码率控制,为量化单元提供量化参数。具体地,码率控制单元用于从图像处理器接收图像复杂度,然后根据图像复杂度与预设编码比特,计算量化参数。The processing unit 710 in this embodiment specifically includes: a code rate control unit, a prediction unit, a transform unit, an inverse transform unit, a quantization unit, an inverse quantization unit, and an entropy coding unit. The code rate control unit is configured to implement rate control and provide quantization parameters for the quantization unit. Specifically, the code rate control unit is configured to receive image complexity from the image processor, and then calculate the quantization parameter according to the image complexity and the preset coded bits.
如图8所示,本发明实施例还提供一种编码装置800,处理器810与存储器820,该存储器820用于存储指令,该处理器810用于执行该存储器820存储的指令,并且对该存储器820中存储的指令的执行使得,该处理器810用于执行上文方法实施例的方法。As shown in FIG. 8, an embodiment of the present invention further provides an encoding apparatus 800, a processor 810 and a memory 820. The memory 820 is configured to store an instruction, and the processor 810 is configured to execute an instruction stored by the memory 820, and Execution of the instructions stored in memory 820 is such that processor 810 is operative to perform the methods of the above method embodiments.
具体地,该编码装置800还包括收发器830,用于从外部的图像处理器(例如ISP)接收图像复杂度信息。Specifically, the encoding device 800 further includes a transceiver 830 for receiving image complexity information from an external image processor (eg, an ISP).
本发明实施例还提供一种计算机存储介质,其上存储有计算机程序,该计算机程序被计算机执行时使得,该计算机执行上文方法实施例的方法。Embodiments of the present invention also provide a computer storage medium having stored thereon a computer program that, when executed by a computer, causes the computer to perform the method of the above method embodiments.
本发明实施例还提供一种包含指令的计算机程序产品,其特征在于,该指令被计算机执行时使得计算机执行上文方法实施例的方法。Embodiments of the present invention also provide a computer program product comprising instructions, wherein the instructions, when executed by a computer, cause a computer to perform the method of the above method embodiments.
在上述实施例中,可以全部或部分地通过软件、硬件、固件或者其他任意组合来实现。当使用软件实现时,可以全部或部分地以计算机程序产品的形式实现。所述计算机程序产品包括一个或多个计算机指令。在计算机上加载和执行所述计算机程序指令时,全部或部分地产生按照本发明实施例所述的流程或功能。所述计算机可以是通用计算机、专用计算机、计算机网络、或者其他可编程装置。所述计算机指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一个计算机可读存储介质传输,例如,所述计算机指令可以从一个网站站点、计算机、服务器或数据中心通过有线(例如同轴电缆、光纤、数字用户线(digital subscriber line,DSL))或无线(例如红外、无线、微波等)方式向另一个网站站点、计算机、服务器或数据中心进行传输。所述计算机可读存储介质可以是计算机能够存取的任何可用介质或者是包含一个或多个可用介质集成的服务器、数据中心等数据存储设备。所述可用介质可以是磁性介质(例如,软盘、硬盘、磁带)、光介质(例如数字视频光盘(digital video disc,DVD))、或者半导体介质(例如固态硬盘(solid state disk,SSD))等。In the above embodiments, it may be implemented in whole or in part by software, hardware, firmware or any other combination. When implemented in software, it may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions described in accordance with embodiments of the present invention are generated in whole or in part. The computer can be a general purpose computer, a special purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer readable storage medium or transferred from one computer readable storage medium to another computer readable storage medium, for example, the computer instructions can be from a website site, computer, server or data center Transmission to another website site, computer, server or data center via wired (eg coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (eg infrared, wireless, microwave, etc.). The computer readable storage medium can be any available media that can be accessed by a computer or a data storage device such as a server, data center, or the like that includes one or more available media. The usable medium may be a magnetic medium (for example, a floppy disk, a hard disk, a magnetic tape), an optical medium (such as a digital video disc (DVD)), or a semiconductor medium (such as a solid state disk (SSD)). .
本领域普通技术人员可以意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、或者计算机软件和电子硬件的结合来实现。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。Those of ordinary skill in the art will appreciate that the elements and algorithm steps of the various examples described in connection with the embodiments disclosed herein can be implemented in electronic hardware or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the solution. A person skilled in the art can use different methods to implement the described functions for each particular application, but such implementation should not be considered to be beyond the scope of the present application.
在本申请所提供的几个实施例中,应该理解到,所揭露的系统、装置和方法,可以通过其它的方式实现。例如,以上所描述的编码装置实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。In the several embodiments provided by the present application, it should be understood that the disclosed systems, devices, and methods may be implemented in other manners. For example, the coding device embodiment described above is only illustrative. For example, the division of the unit is only a logical function division, and the actual implementation may have another division manner, for example, multiple units or components may be combined. Or it can be integrated into another system, or some features can be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interface, device or unit, and may be in an electrical, mechanical or other form.
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, may be located in one place, or may be distributed to multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of the embodiment.
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
以上所述,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以所述权利要求的保护范围为准。The foregoing is only a specific embodiment of the present application, but the scope of protection of the present application is not limited thereto, and any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed in the present application. It should be covered by the scope of protection of this application. Therefore, the scope of protection of the present application should be determined by the scope of the claims.
Claims (43)
- 一种码率控制的方法,其特征在于,所述方法应用于视频编码器,所述方法包括:A method of rate control, characterized in that the method is applied to a video encoder, the method comprising:接收待编码图像的图像复杂度,所述图像复杂度是由与编码器相连的图像处理器获取的;Receiving image complexity of the image to be encoded, the image complexity being acquired by an image processor connected to the encoder;确定所述待编码图像的预设编码比特;Determining a preset encoding bit of the image to be encoded;根据所述图像复杂度与所述预设编码比特,获得所述待编码图像的量化参数;Obtaining a quantization parameter of the image to be encoded according to the image complexity and the preset coding bit;根据所述待编码图像的量化参数,对所述待编码图像进行编码。And encoding the image to be encoded according to the quantization parameter of the image to be encoded.
- 根据权利要求1所述的方法,其特征在于,所述根据所述图像复杂度与所述预设编码比特,获得所述待编码图像的量化参数,包括:The method according to claim 1, wherein the obtaining the quantization parameter of the image to be encoded according to the image complexity and the preset coding bit comprises:利用第一函数模型计算所述量化参数,所述第一函数模型只包括对数运算、乘法运算、加法和/或减法运算,所述第一函数模型的自变量包括所述图像复杂度与所述预设编码比特。Calculating the quantization parameter using a first function model, the first function model only including a logarithm operation, a multiplication operation, an addition operation, and/or a subtraction operation, the independent variable of the first function model including the image complexity and the Preset coded bits.
- 根据权利要求2所述的方法,其特征在于,所述第一函数模型中的系数包括以下至少一个参数:作乘法运算的第一参数、作乘法运算的第二参数以及作加法和/或减法运算的第三参数,所述第一参数、所述第二参数与所述第三参数均为用于码率控制的参数。The method of claim 2 wherein the coefficients in the first function model comprise at least one of: a first parameter for multiplication, a second parameter for multiplication, and addition and/or subtraction. The third parameter of the operation, the first parameter, the second parameter and the third parameter are all parameters for rate control.
- 根据权利要求3所述的方法,其特征在于,所述第一函数模型包括:所述图像复杂度的对数运算值与所述第一参数的乘积、所述预设编码比特的对数运算值与所述第三参数的乘积、与所述第二参数的和。The method according to claim 3, wherein the first function model comprises: a product of a logarithm operation value of the image complexity and the first parameter, and a logarithm operation of the preset coded bit The sum of the value and the third parameter, and the sum of the second parameter.
- 根据权利要求3或4所述的方法,其特征在于,所述第一参数和所述第二参数的绝对值相同。The method according to claim 3 or 4, wherein the absolute values of the first parameter and the second parameter are the same.
- 根据权利要求3至5中任一项所述的方法,其特征在于,在完成所述待编码图像所在的图像帧的编码后,所述方法还包括:The method according to any one of claims 3 to 5, wherein after the encoding of the image frame in which the image to be encoded is to be completed, the method further comprises:根据所述图像帧的帧级实际编码比特与帧级预设编码比特,更新所述第三参数,所述帧级实际编码比特表示所述图像帧的实际编码比特,所述帧级预设编码比特表示所述图像帧的帧级预设编码比特。Updating the third parameter according to a frame-level actual coded bit of the image frame and a frame-level preset coded bit, where the frame-level actual coded bit represents an actual coded bit of the image frame, the frame-level preset code The bits represent the frame level preset coded bits of the image frame.
- 根据权利要求6所述的方法,其特征在于,所述根据所述图像帧的帧级实际编码比特与帧级预设编码比特,更新所述第三参数,包括:The method according to claim 6, wherein the updating the third parameter according to the frame-level actual coding bit and the frame-level preset coding bit of the image frame comprises:根据第二函数模型,获得更新后的第三参数,所述第二函数模型的自变 量包括所述帧级实际编码比特、所述帧级预设编码比特、以及更新之前的第三参数,所述第二函数模型包括以下至少一种运算:对数运算、乘法运算、加法和/或减法运算。Obtaining, according to the second function model, an updated third parameter, where the argument of the second function model includes the frame-level actual coded bit, the frame-level preset coded bit, and a third parameter before updating, The second function model includes at least one of the following operations: a logarithmic operation, a multiplication operation, an addition, and/or a subtraction operation.
- 根据权利要求7所述的方法,其特征在于,所述第二函数模型包括:所述帧级实际编码比特的对数运算值与所述帧级预设编码比特的对数运算值之差与更新速率值以及所述第一参数的乘积,与更新之前的第三参数的和。The method according to claim 7, wherein the second function model comprises: a difference between a logarithmic operation value of the frame-level actual coded bit and a logarithm operation value of the frame-level preset coded bit The sum of the rate value and the first parameter, and the third parameter before the update.
- 根据权利要求1至5中任一项所述的方法,其特征在于,所述待编码图像为所述待编码图像所在的图像帧中的一个图像块;The method according to any one of claims 1 to 5, wherein the image to be encoded is one image block in an image frame in which the image to be encoded is located;所述确定所述待编码图像的预设编码比特,包括:Determining the preset coded bits of the image to be encoded, including:根据所述图像帧的帧级预设编码比特、所述图像帧的帧级图像复杂度以及所述待编码图像的图像复杂度,确定所述待编码图像的预设编码比特。Determining, according to a frame-level preset encoding bit of the image frame, a frame-level image complexity of the image frame, and an image complexity of the image to be encoded, determining a preset encoding bit of the image to be encoded.
- 根据权利要求9所述的方法,其特征在于,所述确定所述待编码图像的预设编码比特,具体包括:The method according to claim 9, wherein the determining the preset encoding bit of the image to be encoded comprises:根据所述待编码图像的图像复杂度占所述图像帧的帧级图像复杂度的比例,与所述图像帧的帧级预设编码比特的乘积,确定所述待编码图像的预设编码比特。Determining, according to a ratio of image complexity of the image to be encoded to a frame-level image complexity of the image frame, a product of a frame-level preset encoding bit of the image frame, determining a preset encoding bit of the image to be encoded. .
- 根据权利要求1至5、9或10中任一项所述的方法,其特征在于,所述待编码图像为所述待编码图像所在的图像帧中的一个图像块;The method according to any one of claims 1 to 5, 9 or 10, wherein the image to be encoded is one image block in an image frame in which the image to be encoded is located;所述方法还包括:The method further includes:根据所述图像帧的图像复杂度与帧级预设编码比特,获取所述图像帧的量化参数;Obtaining a quantization parameter of the image frame according to an image complexity of the image frame and a frame-level preset encoding bit;所述根据所述待编码图像的量化参数,对所述待编码图像进行编码,包括:And encoding, according to the quantization parameter of the image to be encoded, the image to be encoded, including:当所述待编码图像的量化参数在所述图像帧的量化参数的范围内时,根据所述待编码图像的量化参数,对所述待编码图像进行编码。When the quantization parameter of the image to be encoded is within the range of the quantization parameter of the image frame, the image to be encoded is encoded according to the quantization parameter of the image to be encoded.
- 根据权利要求11所述的方法,其特征在于,所述根据所述待编码图像的量化参数,对所述待编码图像进行编码,还包括:The method according to claim 11, wherein the encoding the image to be encoded according to the quantization parameter of the image to be encoded further comprises:当所述待编码图像的量化参数不在所述图像帧的量化参数的范围内时,将所述待编码图像的量化参数剪裁至所述图像帧的量化参数的范围内,根据所述剪裁之后的所述待编码图像的量化参数对所述待编码图像进行编码。When the quantization parameter of the image to be encoded is not within the range of the quantization parameter of the image frame, trimming the quantization parameter of the image to be encoded into a range of quantization parameters of the image frame, according to the clipping The quantization parameter of the image to be encoded encodes the image to be encoded.
- 根据权利要求1至12中任一项所述的方法,其特征在于,所述待 编码图像所在的图像帧为I帧。The method according to any one of claims 1 to 12, wherein the image frame in which the image to be encoded is located is an I frame.
- 根据权利要求1所述的方法,其特征在于,所述待编码图像所在的图像帧为P帧,所述待编码图像为所述P帧中的一个图像块;The method according to claim 1, wherein the image frame in which the image to be encoded is located is a P frame, and the image to be encoded is one image block in the P frame;所述确定所述待编码图像的预设编码比特,包括:Determining the preset coded bits of the image to be encoded, including:根据所述P帧的帧级预设比特与第一系数的乘积确定所述待编码图像的预设比特,其中,所述第一系数是根据以下至少一项确定的:所述P帧的总体图像复杂度、所述P帧内所有图像块的权重之和、所述待编码图像的图像复杂度、所述待编码图像的权重以及所述P帧的帧级预设比特,其中,所述权重由所述P帧的码率控制参数确定。Determining a preset bit of the image to be encoded according to a product of a frame level preset bit of the P frame and a first coefficient, wherein the first coefficient is determined according to at least one of: a totality of the P frame Image complexity, sum of weights of all image blocks in the P frame, image complexity of the image to be encoded, weight of the image to be encoded, and frame level preset bits of the P frame, wherein The weight is determined by the rate control parameter of the P frame.
- 根据权利要求14所述的方法,其特征在于,所述第一系数是根据所述待编码图像的图像复杂度占所述P帧的总体图像复杂度的比例与第二系数的乘积,与所述待编码图像的权重占所述P帧内所有图像块的权重之和的比例与第三系数的乘积之和确定的,其中,所述第二系数和所述第三系数均大于0,且所述第二系数和第三系数的和等于1。The method according to claim 14, wherein the first coefficient is a product of a ratio of an image complexity of the image to be encoded to an overall image complexity of the P frame and a second coefficient, Determining, by the sum of the ratio of the weight of the encoded image to the sum of the weights of all the image blocks in the P frame and the product of the third coefficient, wherein the second coefficient and the third coefficient are both greater than 0, and The sum of the second coefficient and the third coefficient is equal to one.
- 根据权利要求1至15中任一项所述的方法,其特征在于,所述待编码图像的图像复杂度是根据所述待编码图像的纹理信息得到的。The method according to any one of claims 1 to 15, wherein the image complexity of the image to be encoded is obtained based on texture information of the image to be encoded.
- 根据权利要求1至15中任一项所述的方法,其特征在于,所述待编码图像的图像复杂度表示所述待编码图像内区域像素的波动剧烈程度。The method according to any one of claims 1 to 15, wherein the image complexity of the image to be encoded represents the degree of fluctuation of the pixels in the area of the image to be encoded.
- 根据权利要求17所述的方法,其特征在于,所述待编码图像的图像复杂度是通过统计所述待编码图像的离散正/余弦变换或哈达玛变换的变换系数获得的。The method according to claim 17, wherein the image complexity of the image to be encoded is obtained by counting the discrete positive/cosine transform of the image to be encoded or the transform coefficient of the Hadamard transform.
- 根据权利要求17所述的方法,其特征在于,所述待编码图像的图像复杂度是通过计算所述待编码图像内的像素的方差或标准差获得的。The method according to claim 17, wherein the image complexity of the image to be encoded is obtained by calculating a variance or a standard deviation of pixels within the image to be encoded.
- 根据权利要求1至19中任一项所述的方法,其特征在于,所述图像处理器为图像信号处理器ISP。The method according to any one of claims 1 to 19, wherein the image processor is an image signal processor ISP.
- 一种编码装置,其特征在于,包括:An encoding device, comprising:收发单元,用于接收待编码图像的图像复杂度,所述图像复杂度是由与编码器相连的图像处理器获取的;a transceiver unit, configured to receive image complexity of an image to be encoded, the image complexity being acquired by an image processor connected to the encoder;处理单元,用于确定所述待编码图像的预设编码比特;根据所述图像复杂度与所述预设编码比特,获得所述待编码图像的量化参数;根据所述待编码图像的量化参数,对所述待编码图像进行编码。a processing unit, configured to determine a preset encoding bit of the image to be encoded; obtain a quantization parameter of the image to be encoded according to the image complexity and the preset encoding bit; and perform quantization parameter according to the image to be encoded Encoding the image to be encoded.
- 根据权利要求21所述的编码装置,其特征在于,所述处理单元具体用于,利用第一函数模型计算所述量化参数,所述第一函数模型只包括对数运算、乘法运算、加法和/或减法运算,所述第一函数模型的自变量包括所述图像复杂度与所述预设编码比特。The encoding apparatus according to claim 21, wherein the processing unit is specifically configured to calculate the quantization parameter by using a first function model, the first function model only including a logarithm operation, a multiplication operation, an addition, and / or subtraction, the argument of the first function model includes the image complexity and the preset coded bits.
- 根据权利要求22所述的编码装置,其特征在于,所述第一函数模型中的系数包括以下至少一个参数:作乘法运算的第一参数、作乘法运算的第二参数以及作加法和/或减法运算的第三参数,所述第一参数、所述第二参数与所述第三参数均为用于码率控制的参数。The encoding apparatus according to claim 22, wherein the coefficients in said first function model comprise at least one of: a first parameter for multiplication, a second parameter for multiplication, and addition and/or a third parameter of the subtraction operation, wherein the first parameter, the second parameter, and the third parameter are parameters for rate control.
- 根据权利要求23所述的编码装置,其特征在于,所述第一函数模型包括:所述图像复杂度的对数运算值与所述第一参数的乘积、所述预设编码比特的对数运算值与所述第三参数的乘积、与所述第二参数的和。The encoding apparatus according to claim 23, wherein said first function model comprises: a product of a logarithmically operated value of said image complexity and said first parameter, and a logarithm of said preset encoded bit The sum of the calculated value and the third parameter, and the sum of the second parameter.
- 根据权利要求23或24所述的编码装置,其特征在于,所述第一参数和所述第二参数的绝对值相同。The encoding device according to claim 23 or 24, characterized in that the absolute values of the first parameter and the second parameter are the same.
- 根据权利要求22至25中任一项所述的编码装置,其特征在于,在完成所述待编码图像所在的图像帧的编码后,所述处理单元还用于:The encoding apparatus according to any one of claims 22 to 25, wherein after the encoding of the image frame in which the image to be encoded is to be completed, the processing unit is further configured to:根据所述图像帧的帧级实际编码比特与帧级预设编码比特,更新所述第三参数,所述帧级实际编码比特表示所述图像帧的实际编码比特,所述帧级预设编码比特表示所述图像帧的帧级预设编码比特。Updating the third parameter according to a frame-level actual coded bit of the image frame and a frame-level preset coded bit, where the frame-level actual coded bit represents an actual coded bit of the image frame, the frame-level preset code The bits represent the frame level preset coded bits of the image frame.
- 根据权利要求26所述的编码装置,其特征在于,所述处理单元具体用于,根据第二函数模型,获得更新后的第三参数,所述第二函数模型的自变量包括所述帧级实际编码比特、所述帧级预设编码比特、以及更新之前的第三参数,所述第二函数模型包括以下至少一种运算:对数运算、乘法运算、加法和/或减法运算。The encoding apparatus according to claim 26, wherein the processing unit is configured to obtain an updated third parameter according to a second function model, wherein an argument of the second function model includes the frame level The actual coded bits, the frame-level preset coded bits, and the third parameter before the update, the second function model includes at least one of the following operations: a logarithmic operation, a multiplication operation, an addition, and/or a subtraction operation.
- 根据权利要求27所述的编码装置,其特征在于,所述第二函数模型包括:所述帧级实际编码比特的对数运算值与所述帧级预设编码比特的对数运算值之差与更新速率值以及所述第一参数的乘积,与更新之前的第三参数的和。The encoding apparatus according to claim 27, wherein said second function model comprises: a difference between a logarithmic operation value of said frame-level actual coded bits and a logarithm operation value of said frame-level preset coded bits The sum of the product of the update rate value and the first parameter, and the third parameter before the update.
- 根据权利要求21至25中任一项所述的编码装置,其特征在于,所述待编码图像为所述待编码图像所在的图像帧中的一个图像块;The encoding device according to any one of claims 21 to 25, wherein the image to be encoded is one image block in an image frame in which the image to be encoded is located;所述处理单元具体用于,根据所述图像帧的帧级预设编码比特、所述图像帧的帧级图像复杂度以及所述待编码图像的图像复杂度,确定所述待编码 图像的预设编码比特。The processing unit is configured to determine, according to a frame-level preset encoding bit of the image frame, a frame-level image complexity of the image frame, and an image complexity of the image to be encoded, Set the coded bits.
- 根据权利要求29所述的编码装置,其特征在于,所述处理单元具体用于,根据所述待编码图像的图像复杂度占所述图像帧的帧级图像复杂度的比例,与所述图像帧的帧级预设编码比特的乘积,确定所述待编码图像的预设编码比特。The encoding apparatus according to claim 29, wherein the processing unit is configured to: according to a ratio of image complexity of the image to be encoded to a frame-level image complexity of the image frame, and the image A product of frame-level preset coded bits of the frame determines a preset coded bit of the image to be encoded.
- 根据权利要求21至25、29或30中任一项所述的编码装置,其特征在于,所述待编码图像为所述待编码图像所在的图像帧中的一个图像块;The encoding device according to any one of claims 21 to 25, 29 or 30, wherein the image to be encoded is one image block in an image frame in which the image to be encoded is located;所述处理单元还用于,根据所述图像帧的图像复杂度与帧级预设编码比特,获取所述图像帧的量化参数;The processing unit is further configured to acquire, according to an image complexity of the image frame and a frame-level preset encoding bit, a quantization parameter of the image frame;在对所述待编码图像进行编码时,所述处理单元具体用于,当所述待编码图像的量化参数在所述图像帧的量化参数的范围内时,根据所述待编码图像的量化参数,对所述待编码图像进行编码。When the image to be encoded is encoded, the processing unit is specifically configured to: when the quantization parameter of the image to be encoded is within a range of the quantization parameter of the image frame, according to the quantization parameter of the image to be encoded Encoding the image to be encoded.
- 根据权利要求31所述的编码装置,其特征在于,在对所述待编码图像进行编码时,所述处理单元具体用于,当所述待编码图像的量化参数不在所述图像帧的量化参数的范围内时,将所述待编码图像的量化参数剪裁至所述图像帧的量化参数的范围内,根据所述剪裁之后的所述待编码图像的量化参数对所述待编码图像进行编码。The encoding apparatus according to claim 31, wherein, when encoding the image to be encoded, the processing unit is specifically configured to: when a quantization parameter of the image to be encoded is not a quantization parameter of the image frame The quantization parameter of the image to be encoded is clipped to the range of the quantization parameter of the image frame, and the image to be encoded is encoded according to the quantization parameter of the image to be encoded after the clipping.
- 根据权利要求21至32中任一项所述的编码装置,其特征在于,所述待编码图像所在的图像帧为I帧。The encoding device according to any one of claims 21 to 32, wherein the image frame in which the image to be encoded is located is an I frame.
- 根据权利要求21所述的编码装置,其特征在于,所述待编码图像所在的图像帧为P帧,所述待编码图像为所述P帧中的一个图像块;The encoding device according to claim 21, wherein the image frame in which the image to be encoded is located is a P frame, and the image to be encoded is one image block in the P frame;所述处理单元具体用于,根据所述P帧的帧级预设比特与第一系数的乘积确定所述待编码图像的预设比特,其中,所述第一系数是根据以下至少一项确定的:所述P帧的总体图像复杂度、所述P帧内所有图像块的权重之和、所述待编码图像的图像复杂度、所述待编码图像的权重以及所述P帧的帧级预设比特,其中,所述权重由所述P帧的码率控制参数确定。The processing unit is configured to determine, according to a product of a frame-level preset bit of the P frame and a first coefficient, a preset bit of the image to be encoded, where the first coefficient is determined according to at least one of the following: The overall image complexity of the P frame, the sum of the weights of all image blocks in the P frame, the image complexity of the image to be encoded, the weight of the image to be encoded, and the frame level of the P frame. a preset bit, wherein the weight is determined by a code rate control parameter of the P frame.
- 根据权利要求34所述的编码装置,其特征在于,所述第一系数是根据所述待编码图像的图像复杂度占所述P帧的总体图像复杂度的比例与第二系数的乘积,与所述待编码图像的权重占所述P帧内所有图像块的权重之和的比例与第三系数的乘积之和确定的,其中,所述第二系数和所述第三系数均大于0,且所述第二系数和第三系数的和等于1。The encoding apparatus according to claim 34, wherein the first coefficient is a product of a ratio of an image complexity of the image to be encoded to an overall image complexity of the P frame and a second coefficient, and Determining, by the sum of the weight of the image to be encoded, the sum of the weights of all the image blocks in the P frame and the product of the third coefficient, wherein the second coefficient and the third coefficient are both greater than 0, And the sum of the second coefficient and the third coefficient is equal to one.
- 根据权利要求21至35中任一项所述的编码装置,其特征在于,所述待编码图像的图像复杂度是根据所述待编码图像的纹理信息得到的。The encoding apparatus according to any one of claims 21 to 35, wherein the image complexity of the image to be encoded is obtained based on texture information of the image to be encoded.
- 根据权利要求21至36中任一项所述的编码装置,其特征在于,所述待编码图像的图像复杂度表示所述待编码图像内区域像素的波动剧烈程度。The encoding apparatus according to any one of claims 21 to 36, characterized in that the image complexity of the image to be encoded represents the degree of fluctuation of the pixels of the area in the image to be encoded.
- 根据权利要求37所述的编码装置,其特征在于,所述待编码图像的图像复杂度是通过统计所述待编码图像的离散正/余弦变换或哈达玛变换的变换系数获得的。The encoding apparatus according to claim 37, wherein the image complexity of the image to be encoded is obtained by counting the discrete positive/cosine transform of the image to be encoded or the transform coefficient of the Hadamard transform.
- 根据权利要求37所述的编码装置,其特征在于,所述待编码图像的图像复杂度是通过计算所述待编码图像内的像素的方差或标准差获得的。The encoding apparatus according to claim 37, wherein the image complexity of the image to be encoded is obtained by calculating a variance or a standard deviation of pixels within the image to be encoded.
- 根据权利要求21至39中任一项所述的编码装置,其特征在于,所述图像处理器为图像信号处理器ISP。The encoding device according to any one of claims 21 to 39, wherein the image processor is an image signal processor ISP.
- 一种编码装置,其特征在于,包括:存储器与处理器,所述存储器用于存储指令,所述处理器用于执行所述存储器存储的指令,并且对所述存储器中存储的指令的执行使得,所述处理器用于执行如权利要求1至20中任一项所述的方法。An encoding apparatus, comprising: a memory for storing instructions, said processor for executing instructions stored in said memory, and performing execution of instructions stored in said memory such that The processor is operative to perform the method of any one of claims 1 to 20.
- 一种计算机存储介质,其特征在于,其上存储有计算机程序,所述计算机程序被计算机执行时使得,所述计算机执行如权利要求1至20中任一项所述的方法。A computer storage medium, characterized in that a computer program is stored thereon, the computer program being executed by a computer such that the computer performs the method of any one of claims 1 to 20.
- 一种包含指令的计算机程序产品,其特征在于,所述指令被计算机执行时使得计算机执行如权利要求1至20中任一项所述的方法。A computer program product comprising instructions, wherein the instructions, when executed by a computer, cause a computer to perform the method of any one of claims 1 to 20.
Priority Applications (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
PCT/CN2017/119111 WO2019127136A1 (en) | 2017-12-27 | 2017-12-27 | Bit rate control method and encoding device |
CN201780018104.7A CN109076212A (en) | 2017-12-27 | 2017-12-27 | The method and code device of code rate control |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
PCT/CN2017/119111 WO2019127136A1 (en) | 2017-12-27 | 2017-12-27 | Bit rate control method and encoding device |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2019127136A1 true WO2019127136A1 (en) | 2019-07-04 |
Family
ID=64812361
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2017/119111 WO2019127136A1 (en) | 2017-12-27 | 2017-12-27 | Bit rate control method and encoding device |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN109076212A (en) |
WO (1) | WO2019127136A1 (en) |
Families Citing this family (17)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2020150994A1 (en) * | 2019-01-25 | 2020-07-30 | 深圳市大疆创新科技有限公司 | Method and device for determining quantity of image information |
CN111279697A (en) * | 2019-01-25 | 2020-06-12 | 深圳市大疆创新科技有限公司 | Code rate allocation method and device |
WO2020168520A1 (en) * | 2019-02-21 | 2020-08-27 | 深圳市大疆创新科技有限公司 | Encoder, encoding system, and encoding method |
CN110536168B (en) * | 2019-09-11 | 2021-09-17 | 北京达佳互联信息技术有限公司 | Video uploading method and device, electronic equipment and storage medium |
CN110740324B (en) * | 2019-09-11 | 2023-03-31 | 浙江大华技术股份有限公司 | Coding control method and related device |
CN113453001A (en) * | 2020-03-24 | 2021-09-28 | 合肥君正科技有限公司 | Method for improving H264 coding efficiency by using ISP information to adaptively allocate QP |
CN111447446B (en) * | 2020-05-15 | 2022-08-23 | 西北民族大学 | HEVC (high efficiency video coding) rate control method based on human eye visual region importance analysis |
CN114979640A (en) * | 2020-07-17 | 2022-08-30 | Oppo广东移动通信有限公司 | Encoding method, encoder and computer readable storage medium |
CN112218083B (en) * | 2020-10-16 | 2021-09-17 | 西安邮电大学 | Method for estimating intra-frame image code rate of high-efficiency video coding standard |
CN112492305B (en) * | 2020-11-18 | 2022-02-11 | 腾讯科技(深圳)有限公司 | Data processing method and device and computer readable storage medium |
US11523117B2 (en) * | 2021-03-22 | 2022-12-06 | Realtek Semiconductor Corp. | Encoder using coding tree unit level adaptive quantization mode to adjust frame level quantization parameter and associated signal processing method |
WO2022252222A1 (en) * | 2021-06-04 | 2022-12-08 | 深圳市大疆创新科技有限公司 | Encoding method and encoding device |
CN113438488B (en) * | 2021-06-18 | 2023-01-31 | 北京锐马视讯科技有限公司 | Low-bit-rate video optimization coding method, device, equipment and storage medium |
CN113612999B (en) * | 2021-08-20 | 2024-03-22 | 北京市商汤科技开发有限公司 | Video processing method and device, electronic equipment and storage medium |
CN113784126A (en) * | 2021-09-17 | 2021-12-10 | Oppo广东移动通信有限公司 | Image encoding method, apparatus, device and storage medium |
CN117221564A (en) * | 2022-01-21 | 2023-12-12 | 杭州海康威视数字技术股份有限公司 | Video decoding method, device and storage medium |
CN117676143A (en) * | 2022-09-08 | 2024-03-08 | 华为技术有限公司 | Encoding and decoding method and device |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20040120404A1 (en) * | 2002-11-27 | 2004-06-24 | Takayuki Sugahara | Variable length data encoding method, variable length data encoding apparatus, variable length encoded data decoding method, and variable length encoded data decoding apparatus |
US20100118937A1 (en) * | 2007-03-14 | 2010-05-13 | Nippon Telegraph And Telephone Corporation | Encoding bit-rate control method and apparatus, program therefor, and storage medium which stores the program |
CN102036062A (en) * | 2009-09-29 | 2011-04-27 | 华为技术有限公司 | Video coding method and device and electronic equipment |
US20150229941A1 (en) * | 2012-09-26 | 2015-08-13 | Panasonic Intellectual Property Management Co., Ltd. | Image encoding device, captured image recording system, imaging device, method of encoding image, and image encoding program |
CN105208390A (en) * | 2014-06-30 | 2015-12-30 | 杭州海康威视数字技术股份有限公司 | Code rate control method of video coding and system thereof |
Family Cites Families (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN100562118C (en) * | 2007-07-03 | 2009-11-18 | 上海富瀚微电子有限公司 | Code rate control method for video coding |
CN101127909B (en) * | 2007-09-29 | 2010-07-07 | 华为技术有限公司 | A control method and device for image code rate |
EP2286595A1 (en) * | 2008-06-16 | 2011-02-23 | Dolby Laboratories Licensing Corporation | Rate control model adaptation based on slice dependencies for video coding |
CN101754003B (en) * | 2008-12-11 | 2011-09-14 | 北京威速科技有限公司 | Code rate control method for stabilizing video quality |
EP2579593A1 (en) * | 2011-10-04 | 2013-04-10 | Thomson Licensing | Adaptive quantisation for intra-encoded image blocks |
CN102938840A (en) * | 2012-11-26 | 2013-02-20 | 南京邮电大学 | Key frame quantization parameter selecting method applied to multi-viewpoint video coding system |
CN104754335B (en) * | 2015-03-09 | 2016-03-02 | 湖南国科微电子股份有限公司 | A kind of code rate controlling method for video coding |
-
2017
- 2017-12-27 CN CN201780018104.7A patent/CN109076212A/en active Pending
- 2017-12-27 WO PCT/CN2017/119111 patent/WO2019127136A1/en active Application Filing
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20040120404A1 (en) * | 2002-11-27 | 2004-06-24 | Takayuki Sugahara | Variable length data encoding method, variable length data encoding apparatus, variable length encoded data decoding method, and variable length encoded data decoding apparatus |
US20100118937A1 (en) * | 2007-03-14 | 2010-05-13 | Nippon Telegraph And Telephone Corporation | Encoding bit-rate control method and apparatus, program therefor, and storage medium which stores the program |
CN102036062A (en) * | 2009-09-29 | 2011-04-27 | 华为技术有限公司 | Video coding method and device and electronic equipment |
US20150229941A1 (en) * | 2012-09-26 | 2015-08-13 | Panasonic Intellectual Property Management Co., Ltd. | Image encoding device, captured image recording system, imaging device, method of encoding image, and image encoding program |
CN105208390A (en) * | 2014-06-30 | 2015-12-30 | 杭州海康威视数字技术股份有限公司 | Code rate control method of video coding and system thereof |
Also Published As
Publication number | Publication date |
---|---|
CN109076212A (en) | 2018-12-21 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2019127136A1 (en) | Bit rate control method and encoding device | |
KR101644208B1 (en) | Video encoding using previously calculated motion information | |
KR101744654B1 (en) | Motion based dynamic resolution multiple bit rate video encoding | |
CN104885455A (en) | Content adaptive bitrate and quality control by using frame-level sensitive quantization for efficient next generation video coding | |
KR20030070231A (en) | Method for encoding motion image having fixed computational complexity and apparatus thereof | |
WO2021135715A1 (en) | Image compression method and apparatus | |
JP2020520197A (en) | Video encoding method, computer device, and storage medium | |
TW201215155A (en) | Optimized deblocking filters | |
KR20200089635A (en) | Systems and methods for image compression at multiple, different bitrates | |
WO2023077707A1 (en) | Video encoding method, model training method, device, and storage medium | |
WO2022021422A1 (en) | Video coding method and system, coder, and computer storage medium | |
US20240129473A1 (en) | Probability estimation in multi-symbol entropy coding | |
TWI510050B (en) | Quantization control method and apparatus, and quantization control program | |
JP2019083492A (en) | Quantization parameter correction device, quantization parameter correction method, and quantization parameter correction program | |
JP2019083491A (en) | Code amount estimation device and code amount estimation program | |
TWI405467B (en) | Bit rate control circuit and method for image compression | |
CN116600121A (en) | Video coding method and device, electronic equipment and storage medium | |
KR20210022117A (en) | Spatial layer rate allocation | |
WO2022198465A1 (en) | Coding method and apparatus | |
RU2587412C2 (en) | Video rate control based on transform-coefficients histogram | |
CN115550650A (en) | Method and device for effectively adjusting compression rate of reference frame image and electronic equipment | |
JP5809574B2 (en) | Encoding method, decoding method, encoding device, decoding device, encoding program, and decoding program | |
KR101035746B1 (en) | Method of distributed motion estimation for video encoder and video decoder | |
US11825088B2 (en) | Adaptively encoding video frames based on complexity | |
TW201801529A (en) | Complexity control of video codec |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 17936128 Country of ref document: EP Kind code of ref document: A1 |
|
NENP | Non-entry into the national phase |
Ref country code: DE |
|
122 | Ep: pct application non-entry in european phase |
Ref document number: 17936128 Country of ref document: EP Kind code of ref document: A1 |