CN104113761A - Code rate control method for video encoding and encoder - Google Patents
Code rate control method for video encoding and encoder Download PDFInfo
- Publication number
- CN104113761A CN104113761A CN201310137132.4A CN201310137132A CN104113761A CN 104113761 A CN104113761 A CN 104113761A CN 201310137132 A CN201310137132 A CN 201310137132A CN 104113761 A CN104113761 A CN 104113761A
- Authority
- CN
- China
- Prior art keywords
- video image
- code rate
- target
- current video
- gradient value
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
- 238000000034 method Methods 0.000 title claims abstract description 70
- 238000013139 quantization Methods 0.000 claims description 15
- 238000004364 calculation method Methods 0.000 claims description 12
- 238000007781 pre-processing Methods 0.000 claims description 8
- 230000002596 correlated effect Effects 0.000 claims description 7
- 238000012545 processing Methods 0.000 abstract description 6
- 230000008569 process Effects 0.000 description 25
- 230000006870 function Effects 0.000 description 17
- 238000010586 diagram Methods 0.000 description 10
- 238000005516 engineering process Methods 0.000 description 7
- 230000000875 corresponding effect Effects 0.000 description 6
- 238000004590 computer program Methods 0.000 description 5
- 238000012986 modification Methods 0.000 description 5
- 230000004048 modification Effects 0.000 description 5
- 230000033001 locomotion Effects 0.000 description 4
- 230000009466 transformation Effects 0.000 description 3
- 230000005540 biological transmission Effects 0.000 description 2
- 230000001133 acceleration Effects 0.000 description 1
- 238000009825 accumulation Methods 0.000 description 1
- 238000004422 calculation algorithm Methods 0.000 description 1
- 230000008859 change Effects 0.000 description 1
- 238000004891 communication Methods 0.000 description 1
- 230000006835 compression Effects 0.000 description 1
- 238000007906 compression Methods 0.000 description 1
- 238000001914 filtration Methods 0.000 description 1
- 238000004519 manufacturing process Methods 0.000 description 1
- 238000012544 monitoring process Methods 0.000 description 1
- 238000011160 research Methods 0.000 description 1
Landscapes
- Compression Or Coding Systems Of Tv Signals (AREA)
Abstract
本发明涉及数据视频处理领域,公开了一种视频编码中的码率控制方法及编码器,用以提高码率控制方法的准确性,以及降低复杂度,该方法为:先确定当前视频图像的第一梯度值及前一视频图像的第二梯度值,再根据预设平均码率计算当前视频图像的目标码率,然后确定指定的至少一个已编码视频图像的性能参数,然后,在第一梯度值和/或第二梯度值不为0的情况下,根据目标码率、第一梯度值、第二梯度值及性能参数确定当前视频图像的QP;在为0的情况下,根据目标码率和性能参数确定当前视频图像的QP,最后,根据QP对当前视频图像进行编码,这样,提高了码率控制方法的准确性,同时还降低了复杂度。
The invention relates to the field of data and video processing, and discloses a code rate control method and an encoder in video coding, which are used to improve the accuracy of the code rate control method and reduce complexity. The method is as follows: first determine the current video image The first gradient value and the second gradient value of the previous video image, and then calculate the target bit rate of the current video image according to the preset average bit rate, then determine the specified performance parameters of at least one encoded video image, and then, in the first When the gradient value and/or the second gradient value are not 0, determine the QP of the current video image according to the target code rate, the first gradient value, the second gradient value and performance parameters; The QP of the current video image is determined according to the rate and performance parameters. Finally, the current video image is encoded according to the QP. In this way, the accuracy of the code rate control method is improved, and the complexity is also reduced.
Description
技术领域technical field
本发明涉及数据视频处理领域,特别涉及一种视频编码中的码率控制方法及编码器。The invention relates to the field of data and video processing, in particular to a code rate control method and an encoder in video encoding.
背景技术Background technique
为了节约传输带宽和存储空间,以及支持数字电视广播、远程监控、数字视频点播、无线多媒体通信等应用,视频编码已经成为国内外研究和工业应用的热点之一。目前的视频编码标准所涉及的编码技术主要包括:帧内预测、帧间预测、整数变换、重建图像、码率控制、量化和熵编码和反量化反变换去块效应滤波等,具体如图1所示。In order to save transmission bandwidth and storage space, and support applications such as digital TV broadcasting, remote monitoring, digital video on demand, and wireless multimedia communication, video coding has become one of the hot spots in research and industrial applications at home and abroad. The coding technologies involved in the current video coding standards mainly include: intra prediction, inter prediction, integer transformation, reconstructed image, bit rate control, quantization and entropy coding, inverse quantization and inverse transformation, deblocking filtering, etc., as shown in Figure 1 shown.
其中,码率控制是视频编码中必不可少的技术,任何标准离开码率控制,其应用都会受到限制,比如在带宽约束条件下的传输过程中,如果没有合适的码率控制方法,客户端缓冲区就有可能发生溢出,即码率控制的目的是保证在产生指定的目标码率的条件下,能够达到最优的图像质量,并保证编解码缓冲区不会发生溢出。码率控制的主要输出为QP(Quantization Parameter,量化参数),编码过程中利用该QP参数获取良好量化步长用于图像量化。Among them, bit rate control is an indispensable technology in video coding. Any standard without bit rate control will have its application limited. For example, in the transmission process under bandwidth constraints, if there is no suitable bit rate control method, the client The buffer may overflow, that is, the purpose of rate control is to ensure that the optimal image quality can be achieved under the condition of generating the specified target bit rate, and to ensure that the codec buffer will not overflow. The main output of rate control is QP (Quantization Parameter, quantization parameter), which is used in the encoding process to obtain a good quantization step size for image quantization.
目前,单一I帧编码技术由于具有以下优点而被广泛应用,例如:单一I帧编码技术只利用了帧内的相关性,在保证压缩效率的情况下,避免了GOP-based编码中产生的累积误差,有效提高了视频编码质量;又例如,单一I帧编码技术中的每一帧都是单独编码和解码,这种特性使得编码器可以方便地采用并行编解码、分布式编解码等加速技术,有效提高了编码速率。At present, single I-frame coding technology is widely used due to its following advantages. For example, single I-frame coding technology only utilizes the correlation within the frame, and avoids the accumulation of GOP-based coding while ensuring compression efficiency. error, effectively improving the quality of video coding; another example, each frame in a single I-frame coding technology is coded and decoded separately, this feature makes it easy for the encoder to adopt acceleration technologies such as parallel codec and distributed codec , effectively improving the encoding rate.
现有的H.264/AVC标准由于存在以下问题而不能对单一I帧编码模式下的输出码率进行较好地控制:The existing H.264/AVC standard cannot control the output code rate in a single I frame encoding mode well due to the following problems:
一、在H.264/AVC标准中,采用了宏块级的码率控制算法,该方法为:首先采用线性预测,得到当前宏块的MAD(Mean Absolute Difference,平均绝对误差),再采用二次方模型,计算相应的QP。此方法适用于帧间编码过程,不适用于帧内编码,对于单一I帧模式来说,由于QP还与帧内复杂度有关,因此,需要有一个新的统计量来衡量图像帧内的复杂度,从而给编码器增加了计算负荷,提高了计算的复杂度;1. In the H.264/AVC standard, a macroblock-level code rate control algorithm is adopted. The method is as follows: firstly, linear prediction is used to obtain the MAD (Mean Absolute Difference) of the current macroblock, and then two Power model, calculate the corresponding QP. This method is suitable for inter-frame coding process, not for intra-frame coding. For a single I-frame mode, since QP is also related to intra-frame complexity, a new statistic is needed to measure the complexity of the image frame degree, thus increasing the computational load to the encoder and increasing the computational complexity;
二、在现有的H.264/AVC标准中,码率控制是在宏块级进行的,通过前一视频图像对应位置宏块的MAD对当前视频图像对应位置宏块的MAD进行预测,这种方法适合于运动较少、场景变化小的视频图像,对于运动区域或者当镜头出现运动或伸缩时,当前视频图像对应位置宏块和前一视频图像对应位置宏块内容上可能会出现较大差异,这样的预测必然会导致极大的误差,从而导致码率分配的不合理,使视频质量恶化。由于单一I帧模式所处理的为运动较大或者镜头移动频繁的视频图像,因此,会造成明显的误差,降低确定出的QP的准确性,也就降低了码率控制的准确性。Two, in the existing H.264/AVC standard, the code rate control is carried out at the macroblock level, and the MAD of the macroblock at the corresponding position of the current video image is predicted by the MAD of the macroblock at the corresponding position of the previous video image. This method is suitable for video images with less motion and small scene changes. For motion areas or when the lens moves or zooms, there may be larger Such prediction will inevitably lead to huge errors, which will lead to unreasonable bit rate allocation and deteriorate video quality. Since the single I frame mode deals with video images with large motion or frequent camera movement, it will cause obvious errors, reduce the accuracy of the determined QP, and also reduce the accuracy of bit rate control.
现有技术中,为了提高码率控制的准确性,对变换量化后的DCT(DiscreteCosine Transformation,离散余弦变换)系数进行分析,建立起DCT系数和输出码率之间的关系,进而通过DCT系数确定输出码率,但是,这种方法不仅复杂度较高,而且所需要的时间较长,因此,目前尚未有一种针对于单一I帧视频编码中准确性较高、复杂度较低的码率控制方法。In the prior art, in order to improve the accuracy of bit rate control, the transformed and quantized DCT (DiscreteCosine Transformation, discrete cosine transform) coefficients are analyzed to establish the relationship between the DCT coefficients and the output bit rate, and then determined by the DCT coefficients Output code rate, but this method not only has higher complexity, but also takes a long time, so there is no bit rate control with higher accuracy and lower complexity for single I-frame video coding at present. method.
发明内容Contents of the invention
本发明实施例提供一种视频编码中的码率控制方法,用以解决现有技术中针对单一I帧视频编码的码率控制方法的准确性较差及复杂度较高的问题。An embodiment of the present invention provides a code rate control method in video coding, which is used to solve the problem of poor accuracy and high complexity of the code rate control method for single I-frame video coding in the prior art.
一种视频编码中的码率控制方法,用于对单一I帧的视频图像进行码率控制,包括:A bit rate control method in video coding, used to carry out bit rate control to the video image of single I frame, comprising:
确定当前视频图像的第一梯度值及前一视频图像的第二梯度值;determining the first gradient value of the current video image and the second gradient value of the previous video image;
根据预设平均码率计算所述当前视频图像的目标码率;Calculate the target bit rate of the current video image according to the preset average bit rate;
确定指定的至少一个已编码视频图像的性能参数;determining a performance parameter of the specified at least one encoded video image;
判断所述第一梯度值和/或所述第二梯度值是否为0,若是,根据所述目标码率和所述性能参数确定所述当前视频图像的量化参数QP,否则,根据所述目标码率、所述第一梯度值、所述第二梯度值及所述性能参数确定所述当前视频图像的QP;Judging whether the first gradient value and/or the second gradient value is 0, if so, determine the quantization parameter QP of the current video image according to the target code rate and the performance parameter, otherwise, determine the quantization parameter QP according to the target bit rate The code rate, the first gradient value, the second gradient value and the performance parameter determine the QP of the current video image;
根据所述QP对所述当前视频图像进行编码。Encode the current video image according to the QP.
一种编码器,用于对单一I帧的视频图像进行码率控制,包括:A kind of encoder, is used for carrying out code rate control to the video image of single I frame, comprises:
第一确定单元,用于确定当前视频图像的第一梯度值及前一视频图像的第二梯度值;The first determination unit is used to determine the first gradient value of the current video image and the second gradient value of the previous video image;
计算单元,用于根据预设平均码率计算所述当前视频图像的目标码率;A calculation unit, configured to calculate the target bit rate of the current video image according to a preset average bit rate;
第二确定单元,用于确定指定的至少一个已编码视频图像的性能参数;A second determining unit, configured to determine a specified performance parameter of at least one coded video image;
第三确定单元,用于判断所述第一梯度值和/或所述第二梯度值是否为0,若是,根据所述目标码率和所述性能参数确定所述当前视频图像的量化参数QP,否则,根据所述目标码率、所述第一梯度值、所述第二梯度值及所述性能参数确定所述当前视频图像的QP;A third determination unit, configured to determine whether the first gradient value and/or the second gradient value is 0, and if so, determine the quantization parameter QP of the current video image according to the target code rate and the performance parameter , otherwise, determine the QP of the current video image according to the target code rate, the first gradient value, the second gradient value and the performance parameter;
编码单元,用于根据所述QP对所述当前视频图像进行编码。A coding unit, configured to code the current video image according to the QP.
本发明实施例中,编码器在编码过程中,对每一视频图像进行码率控制时,先确定确定当前视频图像的第一梯度值及前一视频图像的第二梯度值,再根据预设平均码率计算所述当前视频图像的目标码率,然后,确定指定的至少一个已编码视频图像的性能参数,最后,在第一梯度值和/或第二梯度值为0的情况下,根据目标码率和性能参数确定当前视频图像的QP,在第一梯度值和/或第二梯度值不为0的情况下,根据目标码率、第一梯度值、第二梯度值及性能参数确定当前视频图像的QP,最后,根据QP对当前视频图像进行编码,由于梯度值是视频图像的固有属性之一,用于量化视频图像的复杂度,且QP衡量的也是视频图像的复杂度,通过梯度值计算得出的QP的准确度较高,而本发明中通过第一梯度值及第二梯度值来确定计算QP所具体采用的方法,并且在第一梯度值和第二梯度值不为0的情况下,根据目标码率、第一梯度值、第二梯度值及性能参数确定当前视频图像的QP,因此,采用本发明实施例提供的方案来计算QP,可以提高计算得出的QP的准确度,进而提高了针对单一I帧视频编码的码率控制方法的准确度,因此,解决了目前针对单一I帧视频编码中的码率控制方法的准确性较差的问题,同时,由于在确定QP的过程中不需要设置新的统计量来衡量图像帧内的复杂度,因此,降低了针对单一I帧视频编码中的码率控制方法的复杂度。In the embodiment of the present invention, the encoder first determines the first gradient value of the current video image and the second gradient value of the previous video image when performing bit rate control on each video image during the encoding process, and then according to the preset Calculate the target bit rate of the current video image at the average bit rate, then determine the specified performance parameter of at least one encoded video image, and finally, when the first gradient value and/or the second gradient value are 0, according to The target code rate and performance parameters determine the QP of the current video image, and if the first gradient value and/or the second gradient value are not 0, it is determined according to the target code rate, the first gradient value, the second gradient value and the performance parameters The QP of the current video image. Finally, the current video image is encoded according to the QP. Since the gradient value is one of the inherent attributes of the video image, it is used to quantify the complexity of the video image, and the QP measures the complexity of the video image. By The accuracy of the QP calculated by the gradient value is relatively high, but in the present invention, the specific method used to calculate the QP is determined by the first gradient value and the second gradient value, and the first gradient value and the second gradient value are not equal to In the case of 0, the QP of the current video image is determined according to the target code rate, the first gradient value, the second gradient value and performance parameters. Therefore, the scheme provided by the embodiments of the present invention is used to calculate the QP, which can improve the calculated QP accuracy, and then improve the accuracy of the bit rate control method for single I-frame video coding, therefore, solve the problem that the accuracy of the bit rate control method in the single I-frame video coding is poor at present, at the same time, due to In the process of determining the QP, there is no need to set a new statistic to measure the complexity of the image frame, so the complexity of the rate control method for single I-frame video coding is reduced.
附图说明Description of drawings
图1为现有技术中编码器的功能结构示意图;FIG. 1 is a schematic diagram of the functional structure of an encoder in the prior art;
图2为本发明实施例中码率控制的第一详细实施例;Fig. 2 is the first detailed embodiment of code rate control in the embodiment of the present invention;
图3为本发明实施例中码率控制的第二详细实施例;Fig. 3 is the second detailed embodiment of code rate control in the embodiment of the present invention;
图4为本发明实施例中码率控制的第三详细实施例;Fig. 4 is the third detailed embodiment of code rate control in the embodiment of the present invention;
图5为本发明实施例中编码器的逻辑功能结构示意图;FIG. 5 is a schematic diagram of a logic function structure of an encoder in an embodiment of the present invention;
图6A为本发明实施例中计算单元的逻辑功能结构示意图;FIG. 6A is a schematic diagram of a logic function structure of a computing unit in an embodiment of the present invention;
图6B为本发明实施例中第二确定单元的逻辑功能结构示意图。Fig. 6B is a schematic diagram of the logic function structure of the second determination unit in the embodiment of the present invention.
具体实施方式Detailed ways
为了解决现有技术中针对单一I帧视频编码中的码率控制方法的准确性较差及复杂度较高的问题,本发明实施例中,编码器在编码过程中,对每一视频图像进行码率控制时,先确定确定当前视频图像的第一梯度值及前一视频图像的第二梯度值,再根据预设平均码率计算所述当前视频图像的目标码率,然后,确定指定的至少一个已编码视频图像的性能参数,最后,在第一梯度值和/或第二梯度值为0的情况下,根据目标码率和性能参数确定当前视频图像的QP,在第一梯度值和/或第二梯度值不为0的情况下,根据目标码率、第一梯度值、第二梯度值及性能参数确定当前视频图像的QP,最后,根据QP对当前视频图像进行编码,由于梯度值是视频图像的固有属性之一,用于量化视频图像的复杂度,且QP衡量的也是视频图像的复杂度,通过梯度值计算得出的QP的准确度较高,而本发明中通过第一梯度值及第二梯度值来确定计算QP所具体采用的方法,并且在第一梯度值和第二梯度值不为0的情况下,根据目标码率、第一梯度值、第二梯度值及性能参数确定当前视频图像的QP,因此,采用本发明实施例提供的方案来计算QP,可以提高计算得出的QP的准确度,进而提高了针对单一I帧视频编码的码率控制方法的准确度,因此,解决了目前针对单一I帧视频编码中的码率控制方法的准确性较差的问题,同时,由于在确定QP的过程中不需要设置新的统计量来衡量图像帧内的复杂度,因此,降低了针对单一I帧视频编码中的码率控制方法的复杂度。In order to solve the problem of poor accuracy and high complexity of the bit rate control method in the single I-frame video encoding in the prior art, in the embodiment of the present invention, the encoder performs an encoding process on each video image during the encoding process. During code rate control, first determine the first gradient value of the current video image and the second gradient value of the previous video image, then calculate the target code rate of the current video image according to the preset average code rate, and then determine the specified At least one performance parameter of the coded video image, finally, in the case of the first gradient value and/or the second gradient value of 0, determine the QP of the current video image according to the target bit rate and the performance parameter, in the first gradient value and /or when the second gradient value is not 0, determine the QP of the current video image according to the target code rate, the first gradient value, the second gradient value and performance parameters, and finally, encode the current video image according to the QP, due to the gradient Value is one of the intrinsic properties of video images, which is used to quantify the complexity of video images, and what QP measures is also the complexity of video images. The accuracy of QP calculated by the gradient value is higher, and in the present invention, through the first A gradient value and a second gradient value are used to determine the specific method used to calculate QP, and when the first gradient value and the second gradient value are not 0, according to the target code rate, the first gradient value, and the second gradient value and performance parameters to determine the QP of the current video image, therefore, adopting the scheme provided by the embodiment of the present invention to calculate QP can improve the accuracy of the calculated QP, and then improve the efficiency of the bit rate control method for single I-frame video encoding Accuracy, therefore, solves the problem that the bit rate control method in the single I-frame video coding is poor in accuracy at present, at the same time, because there is no need to set a new statistic to measure the image frame in the process of determining the QP Therefore, the complexity of the rate control method for single I-frame video coding is reduced.
下面结合附图对本发明优选的实施方式进行详细说明。Preferred embodiments of the present invention will be described in detail below in conjunction with the accompanying drawings.
在本发明实施例中,具体实施流程为:In the embodiment of the present invention, the specific implementation process is as follows:
参阅图2所示,本发明实施例中,视频编码中的码率控制方法的详细流程如下:Referring to Fig. 2, in an embodiment of the present invention, the detailed flow of the code rate control method in video coding is as follows:
步骤200:确定当前视频图像的第一梯度值及前一视频图像的第二梯度值。Step 200: Determine the first gradient value of the current video image and the second gradient value of the previous video image.
本发明实施例中,确定当前视频图像的第一梯度值的方式有多种,较佳的,采用梯度函数确定当前视频图像的第一梯度值,其中,梯度函数至少包括像素参数与梯度参数,如公式一所示,且梯度参数为0或1。In the embodiment of the present invention, there are multiple ways to determine the first gradient value of the current video image. Preferably, a gradient function is used to determine the first gradient value of the current video image, wherein the gradient function includes at least a pixel parameter and a gradient parameter, As shown in Formula 1, and the gradient parameter is 0 or 1.
其中,Gradient为梯度值;M为当前视频图像的长度;N为当前视频图像的宽度;Ix,y为(x,y)位置的像素参数,x为像素点的横坐标,y为像素点的纵坐标;Sgn(x,y)为梯度参数。Wherein, Gradient is gradient value; M is the length of current video image; N is the width of current video image; I x, y is the pixel parameter of (x, y) position, and x is the abscissa of pixel point, and y is pixel point The ordinate; Sgn(x,y) is the gradient parameter.
公式一中的Sgn(x,y)的取值为0或者为1,在取值时根据预设的门限值进行确定,具体确定方式如公式二所示:The value of Sgn(x, y) in Formula 1 is 0 or 1, and it is determined according to the preset threshold value when taking the value. The specific determination method is shown in Formula 2:
其中,Threshold为预设的门限值。Wherein, Threshold is a preset threshold value.
本发明实施例中,为了得到合适的预设门限值,进而提高确定的梯度值的准确度,Threshold可以根据公式三进行计算:In the embodiment of the present invention, in order to obtain a suitable preset threshold value and further improve the accuracy of the determined gradient value, Threshold can be calculated according to formula three:
其中,a可以为任意数值,较佳的,a的取值为3.1;QStep与前一视频图像的QP具有对应关系,因此,QStep的具体取值根据前一视频图像的QP进行确定。Wherein, a can be any value, preferably, the value of a is 3.1; QStep has a corresponding relationship with the QP of the previous video image, therefore, the specific value of QStep is determined according to the QP of the previous video image.
本发明实施例中,在确定前一视频图像的第二梯度值时,所采用的方式有多种,较佳的,采用确定当前视频图像的第一梯度值时所使用的梯度函数,具体如公式一所示。In the embodiment of the present invention, when determining the second gradient value of the previous video image, there are many ways to be adopted. Preferably, the gradient function used when determining the first gradient value of the current video image is adopted, specifically as Formula 1 shows.
步骤210:根据预设平均码率计算当前视频图像的目标码率。Step 210: Calculate the target bit rate of the current video image according to the preset average bit rate.
本发明实施例中,计算当前视频图像的目标码率的方式有多种,较佳的,根据预设平均码率计算当前视频图像的目标码率,其中,整个编码过程中所有视频图像所使用的预设平均码率是相同的,不随着视频图像的变化而进行变换,且目标码率为对视频图像进行编码之前所预期达到的码率,而不是视频图像进行编码之后实际输出的码率。In the embodiment of the present invention, there are many ways to calculate the target code rate of the current video image. Preferably, the target code rate of the current video image is calculated according to the preset average code rate, wherein, all video images used in the entire encoding process The preset average bit rate is the same, does not change as the video image changes, and the target bit rate is the expected bit rate before encoding the video image, not the actual output bit rate after the video image is encoded .
本发明实施例中,根据预设平均码率计算当前视频图像的目标码率的方式有多种,例如,可以根据预设平均码率确定视频图像编码后的目标平均数据大小,并基于目标平均数据大小计算包括所述当前视频图像在内的N个视频图像的总目标数据大小,及将所述总的目标数据大小与所述N个视频图像中不包括所述当前视频图像在内的剩余视频图像的总的实际数据大小的差值作为所述当前视频图像的目标码率,其中,数据大小是指视频图像编码后输出的码流所占的内存大小,且编码过程中所有视频图像编码后的目标平均数据大小均相同。In the embodiment of the present invention, there are many ways to calculate the target bit rate of the current video image according to the preset average bit rate. For example, the target average data size of the encoded video image can be determined according to the preset average bit rate, and based on the target average The data size calculates the total target data size of N video images including the current video image, and compares the total target data size with the rest of the N video images not including the current video image. The difference between the total actual data size of the video image is used as the target code rate of the current video image, wherein the data size refers to the memory size occupied by the code stream output after the video image is encoded, and all video images are encoded in the encoding process The average data size of the subsequent targets is the same.
例如:在视频图像编码过程中的预设平均码率a为500kbps,预设帧率b为25帧/s,已编码的前三个视频图像的数据大小分别为:22kbit、21kbit、20kbit,则在确定待编码的第四帧视频图像(当前视频图像)的目标码率时,先根据预设平均码率a确定每一帧视频图像编码后的目标平均数据大小c:采用(公式四)进行计算,再确定前四个视频图像的总目标数据大小d:d=c×n(公式五)其中,n为特定视频图像的个数,即d=20kbit/帧*4帧=80kbit,则第四个视频图像的目标数据大小e按照公式六进行计算:e=d-指定视频图像总的大小(公式六),即因此,第四个视频图像的目标码率为17kbit/帧,即680bps。For example: the preset average bit rate a in the process of video image encoding is 500kbps, the preset frame rate b is 25 frames/s, and the data sizes of the first three encoded video images are respectively: 22kbit, 21kbit, and 20kbit, then When determining the target bit rate of the fourth frame of video image (current video image) to be encoded, first determine the target average data size c after encoding each frame of video image according to the preset average bit rate a: adopt (Formula 4) to calculate, Then determine the total target data size d of the first four video images: d=c×n (Formula 5) where n is the number of specific video images, that is, d=20kbit/frame*4 frames=80kbit, then the fourth The target data size e of the video image is calculated according to Formula 6: e=d-specify the total size of the video image (Formula 6), that is Therefore, the target bit rate of the fourth video image is 17kbit/frame, that is, 680bps.
进一步,为了提高确定出的视频图像的目标码率的平稳性,在根据预设平均码率确定视频图像编码后的目标平均数据大小后,基于目标平均数据大小计算包括所述当前视频图像在内的N个视频图像的总目标数据大小,及将所述总的目标数据大小与所述N个视频图像中不包括所述当前视频图像在内的剩余视频图像的总的实际数据大小的差值作为所述当前视频图像的预处理目标码率,根据预处理目标码率及指定的视频图像的权重值计算所述当前视频图像的目标码率。Further, in order to improve the stability of the determined target bit rate of the video image, after determining the target average data size of the encoded video image according to the preset average bit rate, calculate the current video image based on the target average data size The total target data size of the N video images, and the difference between the total target data size and the total actual data size of the remaining video images not including the current video image in the N video images As the preprocessing target code rate of the current video image, the target code rate of the current video image is calculated according to the preprocessing target code rate and the specified weight value of the video image.
例如:在视频图像编码过程中的预设平均码率a为500kbps,预设帧率b为25帧/s,已编码的前三个视频图像的总实际数据大小分别为:22kbit、21kbit、20kbit,第三视频图像与第四视频图像的权重值比例为2:1,根据上述实施例可知,第四视频图像的目标数据大小为17kbit,则第四视频图像的目标码率为即720bps。For example: in the process of video image encoding, the preset average bit rate a is 500kbps, the preset frame rate b is 25 frames/s, and the total actual data sizes of the first three encoded video images are: 22kbit, 21kbit, 20kbit , the weight value ratio of the third video image and the fourth video image is 2:1, according to the above-mentioned embodiment, it can be known that the target data size of the fourth video image is 17kbit, then the target code rate of the fourth video image is That is 720bps.
由于在计算梯度值时引入了梯度参数,该梯度参数可以将一些像素点去除掉,提高计算出的梯度值的准确性,梯度值表示的是视频图像的复杂度,可以进一步计算QP,因此,避免了确定出的QP的误差,提高了QP的准确性,从而提高了针对单一I帧视频编码的码率控制方法的准确性。Since the gradient parameter is introduced when calculating the gradient value, the gradient parameter can remove some pixels and improve the accuracy of the calculated gradient value. The gradient value represents the complexity of the video image, and the QP can be further calculated. Therefore, The error of the determined QP is avoided, and the accuracy of the QP is improved, thereby improving the accuracy of the code rate control method for single I-frame video encoding.
步骤220:确定指定的至少一个已编码视频图像的性能参数。Step 220: Determine the performance parameter of the specified at least one coded video image.
本发明实施例中,指定的至少一个已编码视频图像的性能参数至少包括以下参数:实际平均码率和实际平均QP。In the embodiment of the present invention, the designated performance parameters of at least one coded video image include at least the following parameters: actual average code rate and actual average QP.
本发明实施例中,在确定指定的至少一个已编码视频图像的实际平均码率时,先获取指定的至少一个已编码视频图像的实际码率,再根据实际码率确定实际平均码率即可,如公式七所示:In the embodiment of the present invention, when determining the actual average bit rate of the specified at least one encoded video image, first obtain the actual bit rate of the specified at least one encoded video image, and then determine the actual average bit rate according to the actual bit rate , as shown in Equation 7:
其中,Ratelast为指定的至少一个已编码视频图像的实际平均码率;Ratek为指定的至少一个已编码视频图像的实际码率;n为指定的已编码的视频图像的数量。Wherein, Rate last is the actual average code rate of at least one coded video image specified; Rate k is the actual code rate of at least one coded video image specified; n is the number of coded video images specified.
例如:前三个已编码的视频图像的实际码率分别为:12kbps、20kbps、24kbps,则前三个已编码视频图像的实际平均码率为前三个已编码的视频图像的实际码率的平均值18.67kbps。For example: the actual bit rates of the first three encoded video images are respectively: 12kbps, 20kbps, and 24kbps, then the actual average bit rate of the first three encoded video images is the actual bit rate of the first three encoded video images The average is 18.67kbps.
本发明实施例中,在确定指定的至少一个已编码视频图像的实际平均QP时,先获取指定的至少一个已编码视频图像的实际QP,再根据实际QP确定实际平均QP即可,如公式八所示:In the embodiment of the present invention, when determining the actual average QP of the specified at least one encoded video image, first obtain the actual QP of the specified at least one encoded video image, and then determine the actual average QP according to the actual QP, as shown in formula 8 Shown:
其中,QPlast为指定的至少一个已编码视频图像的实际平均QP;QPk为指定的至少一个已编码视频图像的实际QP;n为指定的已编码的视频图像的数量。Wherein, QP last is the actual average QP of the specified at least one coded video image; QP k is the actual QP of the specified at least one coded video image; n is the number of specified coded video images.
例如:前三个已编码的视频图像的实际QP分别为:12、20、24,则前三个已编码视频图像的实际平均QP为前三个已编码的视频图像的实际QP的平均值18.67,由于QP只能为整数,因此,计算出的平均QP为19。For example: the actual QP of the first three encoded video images are: 12, 20, 24 respectively, then the actual average QP of the first three encoded video images is the average value of the actual QP of the first three encoded video images 18.67 , since the QP can only be an integer, the calculated average QP is 19.
本发明实施例中,指定的已编码的视频图像可以为一个已编码的视频图像,也可以为N个已编码的视频图像,其中,N为大于1的正整数。无论为一个已编码的视频图像,还是N个已编码的视频图像,均为与当前视频图像距离最近的前一个或前N个已编码的视频图像,也就是说,获取的不是任意的已编码的视频图像。In this embodiment of the present invention, the specified encoded video image may be one encoded video image, or N encoded video images, where N is a positive integer greater than 1. Whether it is a coded video image or N coded video images, it is the previous or the previous N coded video images closest to the current video image, that is, it is not any coded video image obtained. video image.
例如:待编码的当前视频图像为第十二视频图像,即前面已编码的视频图像共有十一个,确定的性能参数为三个已编码的视频图像的性能参数,则三个已编码的视频图像为第十一视频图像、第十视频图像、第九视频图像,而不是从已编码的十一个视频图像中任意选取三个视频图像。For example: the current video image to be encoded is the twelfth video image, that is, there are eleven encoded video images in the front, and the determined performance parameters are the performance parameters of three encoded video images, then the three encoded video images The images are the eleventh video image, the tenth video image, and the ninth video image, instead of randomly selecting three video images from the encoded eleven video images.
步骤230:判断第一梯度值和/或第二梯度值是否为0,若是,则执行步骤240;否则,执行步骤250。Step 230: Determine whether the first gradient value and/or the second gradient value is 0, if yes, perform step 240; otherwise, perform step 250.
本发明实施例中,计算第一梯度值及第二梯度值时,采用公式一进行计算,因此,若梯度参数为0,则计算出的第一梯度值与第二梯度值为0。In the embodiment of the present invention, formula 1 is used to calculate the first gradient value and the second gradient value. Therefore, if the gradient parameter is 0, the calculated first gradient value and the second gradient value are 0.
步骤240:根据目标码率及性能参数确定当前视频图像的QP。Step 240: Determine the QP of the current video image according to the target code rate and performance parameters.
根据目标码率和性能参数确定当前视频图像的QP的方式有多种,较佳的,采用第一Q计算P函数确定当前视频图像的QP,其中,QP与目标码率呈正相关,与性能参数呈负相关,具体如公式九所示:There are multiple ways to determine the QP of the current video image according to the target code rate and performance parameters. Preferably, the first Q calculation P function is used to determine the QP of the current video image. It is negatively correlated, as shown in Formula 9:
其中,QPthis为当前视频图像的QP值;Ratethis为当前视频图像的目标码率;Ratelast为指定的至少一个已编码视频图像的实际平均码率;QPlast为指定的至少一个已编码视频图像的实际平均QP;λ的取值范围为[0.1,0.2]。Wherein, QP this is the QP value of the current video image; Rate this is the target bit rate of the current video image; Rate last is the actual average bit rate of at least one encoded video image specified; QP last is at least one encoded video specified The actual average QP of the image; the value range of λ is [0.1,0.2].
步骤250:根据目标码率、第一梯度值、第二梯度值及性能参数确定当前视频图像的QP。Step 250: Determine the QP of the current video image according to the target code rate, the first gradient value, the second gradient value and performance parameters.
本发明实施例中,根据目标码率、第一梯度值、第二梯度值及性能参数确定当前视频图像的QP的方式有多种,较佳的,采用第二QP计算函数确定当前视频图像的QP,其中,QP与目标码率及第二梯度值呈正相关,与第一梯度值及性能参数呈负相关,具体如公式十所示:In the embodiment of the present invention, there are many ways to determine the QP of the current video image according to the target code rate, the first gradient value, the second gradient value, and performance parameters. Preferably, the second QP calculation function is used to determine the QP of the current video image. QP, where QP is positively correlated with the target code rate and the second gradient value, and negatively correlated with the first gradient value and performance parameters, specifically as shown in Formula 10:
其中,QPthis为当前视频图像的QP值;Gradientthis为当前视频图像的第一梯度值;Ratethis为当前视频图像的目标码率;Ratelast为指定的至少一个已编码视频图像的实际平均码率;Gradientlast前一视频图像的第二梯度值;QPlast为指定的至少一个已编码视频图像的实际平均QP;λ的取值范围为[0.1,0.2]。Wherein, QP this is the QP value of the current video image; Gradient this is the first gradient value of the current video image; Rate this is the target code rate of the current video image; Rate last is the actual average code of at least one coded video image specified rate; Gradient last is the second gradient value of the previous video image; QP last is the actual average QP of at least one coded video image specified; the value range of λ is [0.1,0.2].
步骤260:根据QP对当前视频图像进行编码。Step 260: Encode the current video image according to the QP.
本发明实施例中,根据QP对当前视频图像进行编码的方式有多种,较佳的,采用MEPG-2标准根据QP对当前视频图像进行编码;或者,采用JVT-G012标准根据QP对当前视频图像进行编码。In the embodiment of the present invention, there are multiple ways to encode the current video image according to the QP. Preferably, the MEPG-2 standard is used to encode the current video image according to the QP; or, the JVT-G012 standard is used to encode the current video image according to the QP. The image is encoded.
为了更好地理解本发明实施例,以下给出具体应用场景,针对视频编码中的码率控制的过程,作出进一步详细描述:In order to better understand the embodiment of the present invention, a specific application scenario is given below, and a further detailed description is made for the process of bit rate control in video coding:
下面以确定第二视频图像的QP为例进行说明,具体执行过程如图3所示(其中,预设平均码率为2500kbps、第一视频图像的实际数据大小为98824bits(即实际码率为3952.96bps)、第一视频图像的QP为40、a为3.1、λ为0.12):The following takes determining the QP of the second video image as an example, and the specific execution process is shown in Figure 3 (wherein, the preset average bit rate is 2500kbps, and the actual data size of the first video image is 98824bits (that is, the actual bit rate is 3952.96 bps), the QP of the first video image is 40, a is 3.1, and λ is 0.12):
步骤300:确定第二视频图像的第一梯度值及第一视频图像的第二梯度值;Step 300: Determine the first gradient value of the second video image and the second gradient value of the first video image;
该步骤中,在计算第一梯度值时,先根据公式三确定Threshold,第一视频图像的QP为40,通过查阅标准文档得知,QP为40时对应的QStep为64,因此,可知Threshold为20.6,然后,再将Threshold为20.6带入公式二确定出梯度参数Sgn(x,y),最后,将确定出的梯度参数Sgn(x,y)带入公式一可得出第二视频图像的第一梯度值为566596。In this step, when calculating the first gradient value, the Threshold is first determined according to Formula 3. The QP of the first video image is 40. By consulting the standard document, the corresponding QStep is 64 when the QP is 40. Therefore, it can be seen that the Threshold is 20.6, and then, bring the Threshold of 20.6 into Formula 2 to determine the gradient parameter Sgn(x, y), and finally, bring the determined gradient parameter Sgn(x, y) into Formula 1 to obtain the second video image The first gradient value is 566596.
在计算第二梯度值时,与计算第一梯度值的过程一样,参照上述过程最后得出第二梯度值为567917。When calculating the second gradient value, the process of calculating the first gradient value is the same as the process of calculating the first gradient value. Referring to the above process, the second gradient value is finally obtained as 567917.
步骤310:根据预设平均码率2500kbps计算第二视频图像(即当前视频图像)的目标码率;Step 310: Calculate the target bit rate of the second video image (ie the current video image) according to the preset average bit rate of 2500kbps;
该实施例中,预设平均码率为2500kbps、视频帧率为25帧/s,根据公式四可知,每一视频图像的目标平均数据大小为100kbit,即100000bit,由于已编码的第一视频图像的实际数据大小为98824bits,则根据公式六可知,第二视频图像(即当前视频图像)的目标码率为101176bit/帧,即为4047.04bps。In this embodiment, the preset average code rate is 2500kbps, and the video frame rate is 25 frames/s. According to formula 4, the target average data size of each video image is 100kbit, that is, 100000bit. Since the encoded first video image The actual data size of is 98824bits, then according to Formula 6, the target bit rate of the second video image (that is, the current video image) is 101176bit/frame, which is 4047.04bps.
步骤320:确定第一视频图像的性能参数,其中,性能参数包括:实际平均码率、实际平均QP;Step 320: Determine the performance parameters of the first video image, wherein the performance parameters include: actual average code rate, actual average QP;
该步骤中,由于仅确定一个已编码的视频图像的性能参数,因此,实际平均码率与实际平均QP为第一视频图像的码率与QP,即实际平均码率为3952.96bps、实际平均QP为40。In this step, owing to only determining the performance parameter of an encoded video image, therefore, the actual average code rate and the actual average QP are the code rate and the QP of the first video image, that is, the actual average code rate is 3952.96bps, the actual average QP for 40.
步骤330:确定第一梯度值566596与第二梯度值567917均不为0,因此,根据目标码率、第一梯度值、第二梯度值及性能参数确定第二视频图像的QP;Step 330: Determine that both the first gradient value 566596 and the second gradient value 567917 are not 0, therefore, determine the QP of the second video image according to the target code rate, the first gradient value, the second gradient value and performance parameters;
该步骤中,根据目标码率、第一梯度值、第二梯度值及性能参数确定第二视频图像的QP时,可采用第二QP函数进行确定,其中,第二QP函数如公式十所示,将上述具体值带入公式十可得出:In this step, when determining the QP of the second video image according to the target code rate, the first gradient value, the second gradient value and the performance parameter, the second QP function can be used for determination, wherein the second QP function is as shown in formula ten , put the above specific values into Formula 10 to get:
步骤340:根据QP对第二视频图像进行编码,输出码流。Step 340: Encode the second video image according to the QP, and output a code stream.
下面以确定第三视频图像的QP为例进行说明,具体执行过程如图4所示(其中,预设平均码率为2500kbps、第一视频图像的实际数据大小为98824bits(即实际码率为3952.96bps)、第一视频图像的QP为40、a为3.1、λ为0.12):The following takes determining the QP of the third video image as an example, and the specific execution process is shown in Figure 4 (wherein, the preset average code rate is 2500kbps, the actual data size of the first video image is 98824bits (that is, the actual code rate is 3952.96 bps), the QP of the first video image is 40, a is 3.1, and λ is 0.12):
步骤400:确定第三视频图像的第一梯度值及第二视频图像的第二梯度值;Step 400: Determine the first gradient value of the third video image and the second gradient value of the second video image;
该步骤中,在计算第一梯度值时,先根据公式三确定Threshold,a为3.1,由于当前视频图像的QStep与指定的已编码的视频图像的实际平均QP相关,该实施例中,指定的已编码的视频图像为第一视频图像及第二视频图像,第一视频图像的QP为40,第二视频图像的QP为40(第二视频图像的实际QP为39.785,因为QP只能为整数,因此,将第二视频图像的QP优化为40),则实际平均QP为40,通过查阅标准文档可知,QP为40时对应的QStep为64,因此,可知Threshold为20.6,然后,再将Threshold为20.6带入公式二而确定出梯度参数Sgn(x,y),最后,将确定出的梯度参数Sgn(x,y)带入公式一可得出第三视频图像的第一梯度值为565791。In this step, when calculating the first gradient value, first determine Threshold according to formula three, a is 3.1, because the QStep of the current video image is related to the actual average QP of the specified encoded video image, in this embodiment, the specified The coded video images are the first video image and the second video image, the QP of the first video image is 40, and the QP of the second video image is 40 (the actual QP of the second video image is 39.785, because QP can only be an integer , therefore, the QP of the second video image is optimized to 40), then the actual average QP is 40. According to the standard document, when the QP is 40, the corresponding QStep is 64. Therefore, it can be seen that the Threshold is 20.6, and then Threshold Put the gradient parameter Sgn(x,y) into formula 2 for 20.6 to determine the gradient parameter Sgn(x,y), and finally, bring the determined gradient parameter Sgn(x,y) into formula 1 to get the first gradient value of the third video image 565791 .
在计算第二梯度值时,与计算第一梯度值的过程一样,参照上述过程最后得出第二梯度值为566596。When calculating the second gradient value, the process of calculating the first gradient value is the same as the process of calculating the first gradient value, referring to the above process to finally obtain the second gradient value of 566596.
步骤410:根据预设平均码率2500kbps计算第三视频图像(即当前视频图像)的目标码率;Step 410: Calculate the target bit rate of the third video image (ie the current video image) according to the preset average bit rate of 2500kbps;
该实施例中,预设平均码率为2500kbps、视频帧率为25帧/s,根据公式四可知,每一视频图像的目标平均数据大小为100kbit,即100000bit,由于已编码的第一视频图像的实际数据大小为98824bits,已编码的第二视频图像的实际数据大小为98176bits,则根据公式六可知,第三视频图像(即当前视频图像)的目标码率为103000bit/帧,即4120bps。In this embodiment, the preset average code rate is 2500kbps, and the video frame rate is 25 frames/s. According to formula 4, the target average data size of each video image is 100kbit, that is, 100000bit. Since the encoded first video image The actual data size of the encoded second video image is 98824bits, and the actual data size of the encoded second video image is 98176bits. According to formula 6, the target bit rate of the third video image (ie, the current video image) is 103000bit/frame, that is, 4120bps.
步骤420:确定第一视频图像及第二视频图像的性能参数,其中,性能参数包括:实际平均码率、实际平均QP;Step 420: Determine the performance parameters of the first video image and the second video image, wherein the performance parameters include: actual average code rate, actual average QP;
该步骤中,由于确定的是两个已编码的视频图像的性能参数,因此,实际平均码率为第一视频图像与第二视频图像的实际码率的平均值,实际平均QP为第一视频图像与第二视频图像的实际QP的平均值,即实际平均QP为40、实际平均码率为100912bit/帧,即4036.48bps。In this step, since it is determined the performance parameters of two encoded video images, the actual average code rate is the average value of the actual code rates of the first video image and the second video image, and the actual average QP is the first video image The average value of the actual QP of the image and the second video image, that is, the actual average QP is 40, and the actual average bit rate is 100912bit/frame, that is, 4036.48bps.
步骤430:确定第一梯度值565791与第二梯度值566596均不为0,因此,根据目标码率、第一梯度值、第二梯度值及性能参数确定第三视频图像的QP;Step 430: Determine that both the first gradient value 565791 and the second gradient value 566596 are not 0, therefore, determine the QP of the third video image according to the target code rate, the first gradient value, the second gradient value and performance parameters;
该步骤中,根据目标码率、第一梯度值、第二梯度参数及性能参数确定第三视频图像的QP时,可采用第二QP函数进行确定,其中,第二QP函数如公式十所示,λ的为0.12,将上述具体值带入公式十可得出:In this step, when determining the QP of the third video image according to the target code rate, the first gradient value, the second gradient parameter and the performance parameter, the second QP function can be used for determination, wherein the second QP function is as shown in formula ten , λ is 0.12, and the above specific value is brought into Formula 10 to get:
由于QP只能是整数,所以第三视频图像的实际QP为40,经过编码,第三视频图像的实际数据大小为99656bits。Since the QP can only be an integer, the actual QP of the third video image is 40. After encoding, the actual data size of the third video image is 99656 bits.
步骤440:根据QP对第三视频图像进行编码,输出码流。Step 440: Encode the third video image according to the QP, and output a code stream.
基于上述技术方案,参阅图5所示,本发明实施例中,编码器包括第一确定单元50、计算单元51、第二确定单元52、第三确定单元53及编码单元54,其中Based on the above technical solution, as shown in FIG. 5, in the embodiment of the present invention, the encoder includes a first determination unit 50, a calculation unit 51, a second determination unit 52, a third determination unit 53, and an encoding unit 54, wherein
第一确定单元50,用于确定当前视频图像的第一梯度值及前一视频图像的第二梯度值;The first determining unit 50 is used to determine the first gradient value of the current video image and the second gradient value of the previous video image;
计算单元51,用于根据预设平均码率计算当前视频图像的目标码率;Calculation unit 51, for calculating the target code rate of current video image according to preset average code rate;
第二确定单元52,用于确定指定的至少一个已编码视频图像的性能参数;The second determination unit 52 is configured to determine the specified performance parameter of at least one coded video image;
第三确定单元53,用于判断第一梯度值和/或第二梯度值是否为0,若是,根据目标码率和性能参数确定当前视频图像的量化参数QP,否则,根据目标码率、第一梯度值、第二梯度值及性能参数确定当前视频图像的QP;The third determining unit 53 is used to judge whether the first gradient value and/or the second gradient value are 0, if so, determine the quantization parameter QP of the current video image according to the target code rate and performance parameters, otherwise, according to the target code rate, the second gradient value A gradient value, a second gradient value and performance parameters determine the QP of the current video image;
编码单元54,用于根据QP对当前视频图像进行编码。The encoding unit 54 is configured to encode the current video image according to the QP.
第一确定单元50具体用于,根据梯度函数确定当前视频图像的第一梯度值,其中,梯度函数至少包括像素参数及梯度参数,且梯度参数为0或者1。The first determining unit 50 is specifically configured to determine a first gradient value of the current video image according to a gradient function, wherein the gradient function includes at least a pixel parameter and a gradient parameter, and the gradient parameter is 0 or 1.
本发明实施例中,计算单元51具体确定目标平均数据大小单元510、计算总目标数据大小单元5100及计算目标码率单元51000,参阅图6A所示,其中:In the embodiment of the present invention, the calculation unit 51 specifically determines the target average data size unit 510, the calculation total target data size unit 5100, and the calculation target code rate unit 51000, as shown in FIG. 6A, wherein:
确定目标平均数据大小单元510,用于根据预设平均码率确定视频图像编码后的目标平均数据大小;Determine the target average data size unit 510, which is used to determine the target average data size after video image encoding according to the preset average code rate;
计算总目标数据大小单元5100,用于基于目标平均数据大小计算包括当前视频图像在内的N个视频图像的总目标数据大小;Calculate the total target data size unit 5100, for calculating the total target data size of N video images including the current video image based on the target average data size;
计算目标码率单元51000,用于将总目标数据大小与N个视频图像中不包括当前视频图像在内的剩余视频图像的总的实际数据大小的差值作为当前视频图像的目标码率;或者,用于先将总的目标数据大小与N个视频图像中不包括当前视频图像在内的剩余视频图像的总的实际数据大小的差值作为当前视频图像的预处理目标码率,再根据预处理目标码率及指定的视频图像的权重值计算当前视频图像的目标码率。Calculating the target code rate unit 51000, which is used to use the difference between the total target data size and the total actual data size of the remaining video images not including the current video image in the N video images as the target code rate of the current video image; or , which is used to use the difference between the total target data size and the total actual data size of the remaining video images excluding the current video image in the N video images as the preprocessing target code rate of the current video image, and then according to the preprocessing Process the target bit rate and the weight value of the specified video image to calculate the target bit rate of the current video image.
本发明实施例中,第二确定单元52确定的指定的至少一个已编码视频图像的性能参数至少包括:实际平均码率及实际平均QP。In the embodiment of the present invention, the performance parameters of the specified at least one coded video image determined by the second determination unit 52 at least include: an actual average code rate and an actual average QP.
进一步的,第二确定单元52具体包括获取单元520及性能参数确定单元5200,参阅图6B所示,其中,获取单元520,用于获取指定的至少一个已编码视频图像的实际码率和实际QP;Further, the second determination unit 52 specifically includes an acquisition unit 520 and a performance parameter determination unit 5200, as shown in FIG. 6B, wherein the acquisition unit 520 is used to acquire the actual code rate and the actual QP of at least one specified encoded video image ;
性能参数确定单元5200,用于根据实际码率和实际QP分别确定实际平均码率和实际平均QP。The performance parameter determining unit 5200 is configured to respectively determine an actual average code rate and an actual average QP according to the actual code rate and the actual QP.
综上所述,本发明实施例中,编码器在编码过程中,对每一视频图像进行码率控制时,先确定确定当前视频图像的第一梯度值及前一视频图像的第二梯度值,再根据预设平均码率计算所述当前视频图像的目标码率,然后,确定指定的至少一个已编码视频图像的性能参数,最后,在第一梯度值和/或第二梯度值为0的情况下,根据目标码率和性能参数确定当前视频图像的QP,在第一梯度值和/或第二梯度值不为0的情况下,根据目标码率、第一梯度值、第二梯度值及性能参数确定当前视频图像的QP,最后,根据QP对当前视频图像进行编码,由于梯度值是视频图像的固有属性之一,用于量化视频图像的复杂度,且QP衡量的也是视频图像的复杂度,通过梯度值计算得出的QP的准确度较高,而本发明中通过第一梯度值及第二梯度值来确定计算QP所具体采用的方法,并且在第一梯度值和第二梯度值不为0的情况下,根据目标码率、第一梯度值、第二梯度值及性能参数确定当前视频图像的QP,因此,采用本发明实施例提供的方案来计算QP,可以提高计算得出的QP的准确度,进而提高了针对单一I帧视频编码的码率控制方法的准确度,因此,解决了目前针对单一I帧视频编码中的码率控制方法的准确性较差的问题,同时,由于在确定QP的过程中不需要设置新的统计量来衡量图像帧内的复杂度,因此,降低了针对单一I帧视频编码中的码率控制方法的复杂度。To sum up, in the embodiment of the present invention, the encoder first determines the first gradient value of the current video image and the second gradient value of the previous video image when performing rate control on each video image during the encoding process. , and then calculate the target bit rate of the current video image according to the preset average bit rate, then determine the specified performance parameter of at least one encoded video image, and finally, when the first gradient value and/or the second gradient value is 0 In the case of , determine the QP of the current video image according to the target code rate and performance parameters, and if the first gradient value and/or the second gradient value are not 0, determine The value and performance parameters determine the QP of the current video image. Finally, the current video image is encoded according to the QP. Since the gradient value is one of the inherent attributes of the video image, it is used to quantify the complexity of the video image, and QP also measures the video image. complexity, the accuracy of the QP calculated by the gradient value is relatively high, and in the present invention, the specific method used to calculate the QP is determined by the first gradient value and the second gradient value, and the first gradient value and the second gradient value When the second gradient value is not 0, determine the QP of the current video image according to the target code rate, the first gradient value, the second gradient value and performance parameters, therefore, adopt the scheme provided by the embodiments of the present invention to calculate QP, which can improve The accuracy of the calculated QP improves the accuracy of the bit rate control method for single I-frame video coding, and therefore solves the problem that the current accuracy of the bit rate control method for single I-frame video coding is poor. At the same time, since there is no need to set a new statistic to measure the complexity of the image frame in the process of determining the QP, the complexity of the rate control method for single I-frame video coding is reduced.
本发明是参照根据本发明实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中的功能的装置。The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It should be understood that each procedure and/or block in the flowchart and/or block diagram, and combinations of procedures and/or blocks in the flowchart and/or block diagram can be realized by computer program instructions. These computer program instructions may be provided to a general purpose computer, special purpose computer, embedded processor, or processor of other programmable data processing equipment to produce a machine such that the instructions executed by the processor of the computer or other programmable data processing equipment produce a A device for realizing the functions in one or more procedures of the flow chart and/or one or more blocks of the block diagram.
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中的功能。These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing apparatus to operate in a specific manner, such that the instructions stored in the computer-readable memory produce an article of manufacture comprising instruction means, the instructions The device implements the functions in one or more procedures of the flow chart and/or one or more blocks of the block diagram.
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中的功能的步骤。These computer program instructions can also be loaded onto a computer or other programmable data processing device, causing a series of operational steps to be performed on the computer or other programmable device to produce a computer-implemented process, thereby The instructions provide steps for implementing the functions in the flow chart or flow charts and/or the block diagram block or blocks.
尽管已描述了本发明的优选实施例,但本领域内的技术人员一旦得知了基本创造性概念,则可对这些实施例作出另外的变更和修改。所以,所附权利要求意欲解释为包括优选实施例以及落入本发明范围的所有变更和修改。While preferred embodiments of the invention have been described, additional changes and modifications to these embodiments can be made by those skilled in the art once the basic inventive concept is appreciated. Therefore, it is intended that the appended claims be construed to cover the preferred embodiment as well as all changes and modifications which fall within the scope of the invention.
显然,本领域的技术人员可以对本发明实施例进行各种改动和变型而不脱离本发明实施例的精神和范围。这样,倘若本发明实施例的这些修改和变型属于本发明权利要求及其等同技术的范围之内,则本发明也意图包含这些改动和变型在内。Apparently, those skilled in the art can make various changes and modifications to the embodiments of the present invention without departing from the spirit and scope of the embodiments of the present invention. In this way, if the modifications and variations of the embodiments of the present invention fall within the scope of the claims of the present invention and equivalent technologies, the present invention also intends to include these modifications and variations.
Claims (12)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201310137132.4A CN104113761B (en) | 2013-04-19 | 2013-04-19 | Bit rate control method and encoder in a kind of Video coding |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201310137132.4A CN104113761B (en) | 2013-04-19 | 2013-04-19 | Bit rate control method and encoder in a kind of Video coding |
Publications (2)
Publication Number | Publication Date |
---|---|
CN104113761A true CN104113761A (en) | 2014-10-22 |
CN104113761B CN104113761B (en) | 2018-05-01 |
Family
ID=51710376
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201310137132.4A Expired - Fee Related CN104113761B (en) | 2013-04-19 | 2013-04-19 | Bit rate control method and encoder in a kind of Video coding |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN104113761B (en) |
Cited By (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108989814A (en) * | 2018-08-06 | 2018-12-11 | 上海大学 | A kind of bit rate control method based on parallel encoding structure |
WO2019104635A1 (en) * | 2017-11-30 | 2019-06-06 | SZ DJI Technology Co., Ltd. | System and method for controlling video coding at frame level |
CN111050169A (en) * | 2018-10-15 | 2020-04-21 | 华为技术有限公司 | Method and device for generating quantization parameter in image coding and terminal |
WO2020107449A1 (en) * | 2018-11-30 | 2020-06-04 | Oppo广东移动通信有限公司 | Coding method, coder and computer storage medium |
US11134250B2 (en) | 2017-11-30 | 2021-09-28 | SZ DJI Technology Co., Ltd. | System and method for controlling video coding within image frame |
US11190775B2 (en) | 2017-11-30 | 2021-11-30 | SZ DJI Technology Co., Ltd. | System and method for reducing video coding fluctuation |
Citations (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1988659A (en) * | 2006-12-30 | 2007-06-27 | 清华大学 | Method for control video frequency coding rate |
CN101252689A (en) * | 2008-02-29 | 2008-08-27 | 杭州爱威芯科技有限公司 | Self-adapting code rate control method |
CN101668197A (en) * | 2009-09-18 | 2010-03-10 | 浙江大学 | Code rate control method in scalable video coding based on linear model |
CN101677398A (en) * | 2008-09-19 | 2010-03-24 | 三星电子株式会社 | Scene switching code rate control method |
CN101895759A (en) * | 2010-07-28 | 2010-11-24 | 南京信息工程大学 | H.264 code rate control method |
CN102123276A (en) * | 2009-12-15 | 2011-07-13 | 铜陵市维新投资咨询有限公司 | Code rate control method during scene change |
CN102355584A (en) * | 2011-10-31 | 2012-02-15 | 电子科技大学 | Code rate control method based on intra-frame predictive coding modes |
CN102932641A (en) * | 2012-11-13 | 2013-02-13 | 北京大学 | Constant quality code rate controlling method |
-
2013
- 2013-04-19 CN CN201310137132.4A patent/CN104113761B/en not_active Expired - Fee Related
Patent Citations (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1988659A (en) * | 2006-12-30 | 2007-06-27 | 清华大学 | Method for control video frequency coding rate |
CN101252689A (en) * | 2008-02-29 | 2008-08-27 | 杭州爱威芯科技有限公司 | Self-adapting code rate control method |
CN101677398A (en) * | 2008-09-19 | 2010-03-24 | 三星电子株式会社 | Scene switching code rate control method |
CN101668197A (en) * | 2009-09-18 | 2010-03-10 | 浙江大学 | Code rate control method in scalable video coding based on linear model |
CN102123276A (en) * | 2009-12-15 | 2011-07-13 | 铜陵市维新投资咨询有限公司 | Code rate control method during scene change |
CN101895759A (en) * | 2010-07-28 | 2010-11-24 | 南京信息工程大学 | H.264 code rate control method |
CN102355584A (en) * | 2011-10-31 | 2012-02-15 | 电子科技大学 | Code rate control method based on intra-frame predictive coding modes |
CN102932641A (en) * | 2012-11-13 | 2013-02-13 | 北京大学 | Constant quality code rate controlling method |
Cited By (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2019104635A1 (en) * | 2017-11-30 | 2019-06-06 | SZ DJI Technology Co., Ltd. | System and method for controlling video coding at frame level |
US11134250B2 (en) | 2017-11-30 | 2021-09-28 | SZ DJI Technology Co., Ltd. | System and method for controlling video coding within image frame |
US11190775B2 (en) | 2017-11-30 | 2021-11-30 | SZ DJI Technology Co., Ltd. | System and method for reducing video coding fluctuation |
US11356672B2 (en) | 2017-11-30 | 2022-06-07 | SZ DJI Technology Co., Ltd. | System and method for controlling video coding at frame level |
CN108989814A (en) * | 2018-08-06 | 2018-12-11 | 上海大学 | A kind of bit rate control method based on parallel encoding structure |
CN108989814B (en) * | 2018-08-06 | 2021-06-04 | 上海大学 | A Rate Control Method Based on Parallel Coding Structure |
CN111050169A (en) * | 2018-10-15 | 2020-04-21 | 华为技术有限公司 | Method and device for generating quantization parameter in image coding and terminal |
WO2020107449A1 (en) * | 2018-11-30 | 2020-06-04 | Oppo广东移动通信有限公司 | Coding method, coder and computer storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN104113761B (en) | 2018-05-01 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN104301724B (en) | Method for processing video frequency, encoding device and decoding device | |
CN101232619B (en) | Video encoding method of embedding intraframe coding block | |
CN103327325B (en) | The quick self-adapted system of selection of intra prediction mode based on HEVC standard | |
CN103813174B (en) | A kind of mixed-resolution decoding method and device | |
CN103533359B (en) | One is bit rate control method H.264 | |
CN101860748B (en) | System and method for generating side information based on distributed video coding | |
CN104113761B (en) | Bit rate control method and encoder in a kind of Video coding | |
JP5897218B2 (en) | Video encoding method and video encoding apparatus using this method | |
CN101321287A (en) | Video Coding Method Based on Moving Object Detection | |
CN103916675B (en) | A kind of low latency inner frame coding method divided based on band | |
CN102281446B (en) | Visual-perception-characteristic-based quantification method in distributed video coding | |
CN101835042A (en) | Wyner-Ziv Video Coding System and Method Based on No Feedback Rate Control | |
CN102158709A (en) | Derivable motion compensation prediction method of decoding terminal | |
CN103442228B (en) | Code-transferring method and transcoder thereof in from standard H.264/AVC to the fast frame of HEVC standard | |
CN110351552B (en) | A Fast Coding Method in Video Coding | |
CN104301730A (en) | Two-way video codec system and method based on video mobile device | |
CN102196272B (en) | P frame coding method and device | |
CN102595132A (en) | Distributed video encoding and decoding method applied to wireless sensor network | |
CN104702959A (en) | Intra-frame prediction method and system of video coding | |
CN108401185A (en) | Reference frame selection method, video transcoding method, electronic device and storage medium | |
CN101883275B (en) | Video coding method | |
CN108769689A (en) | skip macro block judging method, video transcoding method, electronic equipment and storage medium | |
CN102685497A (en) | Rapid interframe mode selection method and device for AVS (Advanced Audio Video Coding Standard) coder | |
CN101867818B (en) | Selection method and device of macroblock mode | |
CN104053009A (en) | Encoding method of monitoring video and device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant | ||
TR01 | Transfer of patent right | ||
TR01 | Transfer of patent right |
Effective date of registration: 20220623 Address after: 100871 No. 5, the Summer Palace Road, Beijing, Haidian District Patentee after: Peking University Patentee after: New founder holdings development Co.,Ltd. Patentee after: BEIJING FOUNDER ELECTRONICS Co.,Ltd. Address before: 100871 No. 5, the Summer Palace Road, Beijing, Haidian District Patentee before: Peking University Patentee before: PEKING UNIVERSITY FOUNDER GROUP Co.,Ltd. Patentee before: BEIJING FOUNDER ELECTRONICS Co.,Ltd. |
|
CF01 | Termination of patent right due to non-payment of annual fee | ||
CF01 | Termination of patent right due to non-payment of annual fee |
Granted publication date: 20180501 |