WO2020107449A1 - Coding method, coder and computer storage medium - Google Patents

Coding method, coder and computer storage medium Download PDF

Info

Publication number
WO2020107449A1
WO2020107449A1 PCT/CN2018/118701 CN2018118701W WO2020107449A1 WO 2020107449 A1 WO2020107449 A1 WO 2020107449A1 CN 2018118701 W CN2018118701 W CN 2018118701W WO 2020107449 A1 WO2020107449 A1 WO 2020107449A1
Authority
WO
WIPO (PCT)
Prior art keywords
encoder
bit rate
image frame
previous time
virtual buffer
Prior art date
Application number
PCT/CN2018/118701
Other languages
French (fr)
Chinese (zh)
Inventor
周益民
程学理
Original Assignee
Oppo广东移动通信有限公司
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Oppo广东移动通信有限公司 filed Critical Oppo广东移动通信有限公司
Priority to PCT/CN2018/118701 priority Critical patent/WO2020107449A1/en
Priority to CN201880097326.7A priority patent/CN112655207A/en
Publication of WO2020107449A1 publication Critical patent/WO2020107449A1/en

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/102Methods 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/124Quantisation

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Compression Or Coding Systems Of Tv Signals (AREA)

Abstract

Provided are a coding method, a coder and a computer storage medium. The method is applied to a coder, and the method comprises: acquiring a performance parameter of a coder at the last moment and a QP value of an image frame to be coded at the last moment (S101); determining, according to a target performance parameter of the coder, variations in performance parameters of the coder at the current moment and the last moment (S102); determining, according to the variations in the performance parameters, the performance parameter of the coder at the last moment, and the QP value of said image frame at the last moment, a QP value of said image frame at the current moment (S103); and coding, according to the QP value of said image frame at the current moment, said image frame at the current moment (S104).

Description

编码方法、编码器以及计算机存储介质Encoding method, encoder and computer storage medium 技术领域Technical field
本申请实施例涉及视频编码中的码率控制技术领域,尤其涉及一种编码方法、编码器以及计算机存储介质。The embodiments of the present application relate to the technical field of bit rate control in video encoding, and in particular, to an encoding method, an encoder, and a computer storage medium.
背景技术Background technique
视频编码又称视频压缩,通过量化、变换、熵编码等技术对存在大量时域与空域冗余的原始视频信源进行压缩,以尽可能的降低存储或传输所需的空间或带宽。随着互联网的飞速发展,人们对高清、超高清视频的追求与受限的网络带宽之间的矛盾日益凸显,如果能在尽可能保证视频质量的同时,满足有限的带宽传输需求,这样将会给人们的生活带来极大的便利。Video coding, also known as video compression, compresses original video sources with a large amount of time and space redundancy through techniques such as quantization, transformation, and entropy coding to minimize the space or bandwidth required for storage or transmission. With the rapid development of the Internet, the contradiction between people's pursuit of high-definition and ultra-high-definition video and limited network bandwidth has become increasingly prominent. If the quality of video can be guaranteed as much as possible while meeting the demand for limited bandwidth transmission, this will Bring great convenience to people's lives.
其中,码率控制是通过调节编码参数来改变编码器输出的码率,以达到用户设定的码率需求。长期以来,码率控制都是视频编码领域最重要的技术领域;码率控制的核心问题是建立码率与编码参数之间的关系模型,即,如何根据目标码率确定编码参数以使得在保证一定视频质量前提下控制平稳且误差足够小。Among them, the code rate control is to change the code rate output by the encoder by adjusting the coding parameters, so as to meet the code rate requirements set by the user. For a long time, rate control is the most important technical field in the field of video coding; the core problem of rate control is to establish the relationship model between the rate and the encoding parameters, that is, how to determine the encoding parameters according to the target rate to ensure that the Under certain video quality, the control is stable and the error is small enough.
在视频编码过程中,若不进行码率控制,那么通常视频编码将以预设定的编码参数进行编码。每帧图像输出比特数起伏波动,不受控制。在实际应用中,信源视频中包含大量的时域冗余与空域冗余,编码的目的就是尽可能消除这些冗余,但通常在各种视频序列中这些冗余分布十分不均匀甚至毫无规律,造成编码器输出比特波动较大。还有,编码器普遍采用变长编码方式进行系数编码以节省码字,变长编码根据符号出现的概率来设计码字。出现概率越大,其码字越短,反之,出现概率越小,则码字越长。另外,由于信号出现和变化的概率具有随机性,这也会引起编码器输出比特率的变化。正是由于视频信源内容的这些不确定性,编码时不可能保证每一帧图像的实际输出码率平稳,更不能保证输出码率与目标码率完全一致。所以,在视频编码中进行码率控制尤为重要。In the video encoding process, if the code rate control is not performed, then usually the video encoding will be encoded with preset encoding parameters. The number of output bits of each frame of image fluctuates and is not controlled. In practical applications, the source video contains a lot of time and space redundancy. The purpose of encoding is to eliminate these redundancy as much as possible, but usually these redundancy distributions in various video sequences are very uneven or even no. The regularity causes the encoder output bit to fluctuate greatly. In addition, encoders generally use variable-length coding to encode coefficients to save codewords, and variable-length coding designs codewords based on the probability of symbol appearance. The greater the probability of occurrence, the shorter the codeword. Conversely, the smaller the probability of occurrence, the longer the codeword. In addition, since the probability of signal occurrence and change is random, it will also cause the output bit rate of the encoder to change. Because of these uncertainties in the content of the video source, it is impossible to ensure that the actual output bit rate of each frame of image is stable during encoding, nor can it be guaranteed that the output bit rate is completely consistent with the target bit rate. Therefore, bit rate control is particularly important in video coding.
目前,现有的码率控制技术中,为了保证输出码率与目标码率的一致性,在H.264中,采用了图像组级、帧级和宏块级三级码率控制。当对码率控制精度要求较高时,采用宏块级的码率控制,码率控制算法会根据每个宏块的内容特性,为每一个宏块计算一组编码参数,从而获得比较精确的控制效果;反之,采用图像组级或者帧级的码率控制,在图像组级的码率控制情况下,主要思想为:计算每个图像组的总比特需求和剩余未编码帧的比特分配,并确定每一个图像组的实际量化参数。帧级的码率控制稍微复杂一些,主要是对I、P、B三种不同类型的帧采取不同的量化参数计算策略,B帧不被其它帧参考,其量化参数通过相邻帧的量化参数插值得到,P帧会被后面多帧参考,影响较大,因此需要对其进行精确计算。H.264中采用了线性跟踪理论为当前帧计算了2组目标比特,再对其求加权平均得到分配给当前帧的比特数,再利用线性模型预测当前帧的MAD复杂度,并带入二次率失真模型,得到当前帧的量化参数。对于宏块级的码率控制,其主要思想与帧级的码率控制类似,先预测分配的比特数,再预测MAD,最后带入二次率失真模型计算得到当前宏块的量化参数。At present, in the existing code rate control technology, in order to ensure the consistency of the output code rate and the target code rate, in H.264, three levels of code rate control at the group level, frame level, and macroblock level are used. When the precision of rate control is high, the rate control at the macroblock level is adopted. The rate control algorithm calculates a set of coding parameters for each macroblock according to the content characteristics of each macroblock, thereby obtaining a more accurate Control effect; on the contrary, the use of image group level or frame level code rate control, in the case of image group level code rate control, the main idea is: calculate the total bit demand of each image group and the bit allocation of the remaining uncoded frames, And determine the actual quantization parameters of each image group. Frame-level bit rate control is a bit more complicated. It mainly adopts different quantization parameter calculation strategies for three different types of frames: I, P, and B. Frame B is not referenced by other frames, and its quantization parameters pass the quantization parameters of adjacent frames. After interpolation, the P frame will be referenced by multiple frames in the future, which has a greater impact, so it needs to be accurately calculated. In H.264, the linear tracking theory is used to calculate two sets of target bits for the current frame, and then the weighted average is calculated to obtain the number of bits allocated to the current frame, and then the linear model is used to predict the MAD complexity of the current frame and bring into the two The second-rate distortion model obtains the quantization parameters of the current frame. For the rate control at the macroblock level, the main idea is similar to the rate control at the frame level. First, the number of allocated bits is predicted, then the MAD is predicted, and finally the quantization parameter of the current macroblock is calculated by the second rate distortion model.
在高效视频编码标准(HEVC,High Efficiency Video Coding)中,也采用了与H.264相似的三级码率控制机制。其核心内容是创新性地提出了R-λ关系模型,用于计算拉格 朗日乘子λ,而后直接将拉格朗日乘子λ带入一个经验公式计算量化参数。In the high-efficiency video coding standard (HEVC, High Efficiency Video Coding), a three-level rate control mechanism similar to H.264 is also adopted. The core content is to innovatively propose the R-λ relation model, which is used to calculate the Lagrangian multiplier λ, and then directly bring the Lagrangian multiplier λ into an empirical formula to calculate the quantitative parameters.
在第二代信源编码标准(AVS2,Audio Video coding Standard 2)中,采用了基于模糊逻辑的控制理论,预先建立好模糊控制查询表。在码率控制过程中,建立缓冲区状态,直接查表得到量化参数的变化量,进而得到下一帧编码所使用的量化参数。In the second-generation source coding standard (AVS2, Audio, Video, and Standard 2), a fuzzy logic-based control theory is adopted, and a fuzzy control lookup table is established in advance. In the rate control process, the buffer state is established, and the table is directly looked up to obtain the change of the quantization parameter, and then the quantization parameter used for encoding the next frame is obtained.
以上三种码率控制算法仅仅考虑当前已编码帧的状态,且确定编码参数的方法单一固定,导致编码控制精度不佳,编码器输出的性能不稳定;由此可以看出,现有的编码器的编码方法由于编码控制精度不佳导致编码性能不佳。The above three rate control algorithms only consider the current state of the encoded frame, and the method of determining the encoding parameters is single and fixed, resulting in poor encoding control accuracy and unstable performance of the encoder output; it can be seen that the existing encoding The encoder's coding method results in poor coding performance due to poor coding control accuracy.
发明内容Summary of the invention
有鉴于此,本申请实施例期望提供一种编码方法、编码器以及计算机存储介质,能够提高编码器在编码时的编码性能。In view of this, the embodiments of the present application desire to provide an encoding method, an encoder, and a computer storage medium, which can improve the encoding performance of the encoder when encoding.
本申请实施例的技术方案可以如下实现:The technical solutions of the embodiments of the present application may be implemented as follows:
第一方面,本申请实施例提供了一种电容编码方法,所述方法应用于一编码器中,所述方法包括:In a first aspect, an embodiment of the present application provides a capacitive encoding method, which is applied to an encoder, and the method includes:
获取所述编码器在上一时刻的性能参数和待编码图像帧在上一时刻的量化参数QP值;Obtain the performance parameter of the encoder at the last moment and the quantization parameter QP value of the image frame to be encoded at the last moment;
根据所述编码器的目标性能参数,确定所述编码器在当前时刻与上一时刻性能参数的变化量;According to the target performance parameter of the encoder, determine the change amount of the performance parameter of the encoder at the current time and the previous time;
根据所述性能参数的变化量、所述编码器在上一时刻的性能参数和所述待编码图像帧在上一时刻的QP值,确定所述待编码图像帧在当前时刻的QP值;Determine the QP value of the image frame to be encoded at the current time according to the change amount of the performance parameter, the performance parameter of the encoder at the previous time and the QP value of the image frame to be encoded at the previous time;
根据所述待编码图像帧在当前时刻的QP值,对当前时刻的所述待编码图像帧进行编码。According to the QP value of the image frame to be encoded at the current moment, encode the image frame to be encoded at the current moment.
第二方面,本申请实施例提供了一种编码器,所述编码器包括:In a second aspect, an embodiment of the present application provides an encoder. The encoder includes:
第一获取单元,用于获取所述编码器在上一时刻的性能参数和待编码图像帧在上一时刻的量化参数QP值;A first acquiring unit, configured to acquire the performance parameter of the encoder at the last moment and the quantization parameter QP value of the image frame to be encoded at the last moment;
第一确定单元,用于根据所述编码器的目标性能参数,确定所述编码器在当前时刻与上一时刻性能参数的变化量;A first determining unit, configured to determine the change amount of the performance parameter of the encoder at the current time and the previous time according to the target performance parameter of the encoder;
第二确定单元,用于根据所述性能参数的变化量、所述编码器在上一时刻的性能参数和所述待编码图像帧在上一时刻的QP值,确定所述待编码图像帧在当前时刻的QP值;The second determining unit is configured to determine that the image frame to be encoded is based on the change amount of the performance parameter, the performance parameter of the encoder at the previous time, and the QP value of the image frame to be encoded at the previous time QP value at the current moment;
编码单元,用于根据所述待编码图像帧在当前时刻的QP值,对当前时刻的所述待编码图像帧进行编码。The encoding unit is configured to encode the image frame to be encoded at the current time according to the QP value of the image frame to be encoded at the current time.
第三方面,本申请实施例提供了一种编码器,所述编码器包括:In a third aspect, an embodiment of the present application provides an encoder. The encoder includes:
处理器以及存储有所述处理器可执行指令的存储介质,所述存储介质通过通信总线依赖所述处理器执行操作,当所述指令被所述处理器执行时,执行上述第一方面所述的编码方法。A processor and a storage medium storing instructions executable by the processor, the storage medium relies on the processor to perform operations through a communication bus, and when the instructions are executed by the processor, the first aspect described above is performed Encoding method.
第四方面,本申请实施例提供了一种计算机存储介质,存储有可执行指令,当所述可执行指令被一个或多个处理器执行的时候,所述处理器执行所述第一方面所述的编码方法。According to a fourth aspect, an embodiment of the present application provides a computer storage medium that stores executable instructions. When the executable instructions are executed by one or more processors, the processor executes the first aspect. The encoding method described.
本申请实施例提供了一种编码方法、编码器以及计算机存储介质,该方法应用于一编码器中,该方法包括:首先,获取编码器在上一时刻的性能参数和待编码图像帧在上一时刻的QP值,根据编码器的目标性能参数,确定编码器在当前时刻与上一时刻性能参数的变化量,这样,便可以得知当前时刻与上一时刻性能参数的变化量,再根据性能 参数的变化量、编码器在上一时刻的性能参数和待编码图像帧在上一时刻的QP值,确定待编码图像帧在当前时刻的QP值,即,用性能参数的变化量、编码器在上一时刻的性能参数和待编码图像帧在上一时刻的QP值来确定待编码图像帧在当前时刻的QP值,也就是说,在本申请实施例中,在确定待编码图像帧在当前时刻的QP值考虑到了上一时刻性能参数的变化量,如此,结合性能参数的历史情况,得到的编码图像帧在当前时刻待的QP值更加精确,最后,根据待编码图像帧在当前时刻的QP值,对待编码图像帧在当前时刻进行编码;使得编码过程中不仅仅只是用预先设定的编码参数,还考虑到了编码器性能参数的变化量,这样,有利于提高编码过程中性能参数的控制精度,从而提高了编码过程中的编码性能。An embodiment of the present application provides an encoding method, an encoder, and a computer storage medium. The method is applied to an encoder. The method includes: first, acquiring the performance parameters of the encoder at the previous moment and the image frame to be encoded are on the The QP value at a moment, according to the target performance parameter of the encoder, determines the amount of change in the performance parameter of the encoder at the current time and the previous time, so that you can know the amount of change in the performance parameter at the current time and the previous time, and then according to The amount of change in performance parameters, the performance parameter of the encoder at the previous time, and the QP value of the image frame to be encoded at the previous time, determine the QP value of the image frame to be encoded at the current time, that is, the amount of change in the performance parameter, encoding The performance parameter of the device at the previous moment and the QP value of the image frame to be encoded at the previous moment determine the QP value of the image frame to be encoded at the current moment, that is to say, in the embodiment of the present application, the image frame to be encoded is determined The QP value at the current time takes into account the amount of change in the performance parameter at the previous time. Thus, combined with the historical situation of the performance parameter, the QP value of the resulting encoded image frame at the current time is more accurate. Finally, according to the current image frame to be encoded The QP value at the moment, the image frame to be encoded is encoded at the current moment; making the encoding process not only uses the preset encoding parameters, but also considers the amount of change in the encoder performance parameters, which is conducive to improving the performance of the encoding process The control precision of the parameters, thereby improving the encoding performance in the encoding process.
附图说明BRIEF DESCRIPTION
图1为本申请实施例提供的一种可选的编码方法的流程示意图;1 is a schematic flowchart of an optional encoding method provided by an embodiment of this application;
图2为本申请实施例提供的另一种可选的编码方法的流程示意图;2 is a schematic flowchart of another optional encoding method provided by an embodiment of the present application;
图3为本申请实施例提供的又一种可选的编码方法的流程示意图;FIG. 3 is a schematic flowchart of another alternative encoding method provided by an embodiment of the present application;
图4为本申请实施例提供的再一种可选的连接方法的流程示意图;4 is a schematic flowchart of still another optional connection method provided by an embodiment of the present application;
图5为本申请实施例提供的编码方法的一种可选的实例的流程示意图;5 is a schematic flowchart of an alternative example of an encoding method provided by an embodiment of this application;
图6为本申请实施例提供的编码方法的另一种可选的实例的流程示意图;6 is a schematic flowchart of another optional example of the encoding method provided by the embodiment of the present application;
图7为本申请实施例提供的编码方法的又一种可选的实例的流程示意图;7 is a schematic flowchart of another optional example of the encoding method provided by the embodiment of the present application;
图8为本申请实施例提供的AI编码结构下虚拟缓冲区的充盈程度的仿真图;8 is a simulation diagram of the filling degree of the virtual buffer zone under the AI coding structure provided by the embodiment of the present application;
图9为本申请实施例提供的LD编码结构下虚拟缓冲区的充盈程度的仿真图;9 is a simulation diagram of the filling degree of the virtual buffer under the LD coding structure provided by the embodiment of the present application;
图10为本申请实施例提供的RA编码结构下虚拟缓冲区的充盈程度的仿真图;10 is a simulation diagram of the filling degree of the virtual buffer under the RA coding structure provided by the embodiment of the present application;
图11为本申请实施例提供的一种编码器的结构示意图一;11 is a schematic structural diagram 1 of an encoder provided by an embodiment of the present application;
图12为本申请实施例提供的一种编码器的结构示意图二。FIG. 12 is a second structural diagram of an encoder provided by an embodiment of the present application.
具体实施方式detailed description
为了能够更加详尽地了解本申请实施例的特点与技术内容,下面结合附图对本申请实施例的实现进行详细阐述,所附附图仅供参考说明之用,并非用来限定本申请实施例。In order to understand the features and technical contents of the embodiments of the present application in more detail, the implementation of the embodiments of the present application will be described in detail below with reference to the drawings. The accompanying drawings are for reference only and are not intended to limit the embodiments of the present application.
本申请实施例提供了一种编码方法,该方法应用于一编码器中,图1为本申请实施例提供的一种可选的编码方法的流程示意图,参考图1所示,该编码方法可以包括:An embodiment of the present application provides an encoding method, which is applied to an encoder. FIG. 1 is a schematic flowchart of an optional encoding method provided by an embodiment of the present application. Referring to FIG. 1, the encoding method may include:
S101:获取编码器在上一时刻的性能参数和待编码图像帧在上一时刻的QP值;S101: Obtain the performance parameter of the encoder at the last moment and the QP value of the image frame to be encoded at the last moment;
其中,性能参数包括以下任意一项:图像帧的输出速率参数,图像帧的输出质量参数或者图像帧的输出时间参数。Among them, the performance parameter includes any one of the following: the output rate parameter of the image frame, the output quality parameter of the image frame, or the output time parameter of the image frame.
举例来说,当性能参数为图像帧的输出速率参数时,且图像帧的输出速率参数为输出比特率时,对应地,目标性能参数为目标输出比特率;For example, when the performance parameter is the output rate parameter of the image frame, and the output rate parameter of the image frame is the output bit rate, correspondingly, the target performance parameter is the target output bit rate;
在S101之前,获取编码器的目标输出比特率,例如,接收到用户设置的编码器的目标输出比特率,这里需要说明的是,目标输出比特率还可以称为目标码率;Before S101, the target output bit rate of the encoder is obtained, for example, the target output bit rate of the encoder set by the user is received. It should be noted here that the target output bit rate may also be referred to as the target code rate;
其中,上述编码器的目标码率是由用户预先设定的,用户可以根据自身的需求来设置编码器的目标码率(TBR,Target Bit Rate)。Among them, the target bit rate of the encoder is preset by the user, and the user can set the target bit rate (TBR, Target, BitRate) of the encoder according to their own needs.
这里,需要说明的是,TBR的单位是比特每秒(bps,bit per second),为了一般化编码序列的运算过程,本申请实施例可以以比特每像素(bpp,bit per pixel)为单位进行比特率的刻画,从而可以将目标码率转化为目标比特每像素(T bpp,Target bit per pixel),目标码率的转化方法可以通过以下公式进行计算: Here, it should be noted that the unit of TBR is bits per second (bps, bit per second). In order to generalize the operation process of the coding sequence, the embodiments of the present application may be performed in units of bit per pixel (bpp, bit per pixel) Characterization of the bit rate, so that the target bit rate can be converted into a target bit per pixel (T bpp , Target bit per pixel), the conversion method of the target bit rate can be calculated by the following formula:
Figure PCTCN2018118701-appb-000001
Figure PCTCN2018118701-appb-000001
其中,FPS为原始视频的帧率,W和H分别为原始视频的宽和高。Among them, FPS is the frame rate of the original video, and W and H are the width and height of the original video, respectively.
这样,便可以将目标码率转化为目标比特每像素,在本申请实施例中所指的目标码率均由目标比特每像素来表示。In this way, the target code rate can be converted into the target bit per pixel, and the target code rate referred to in the embodiments of the present application is expressed by the target bit per pixel.
在S101中,在编码完成上一时刻图像帧之后,由于每一帧编码完毕后会产生实际输出比特数(RB,Real Bits),第t帧产生的比特数为RB t,将其转化为以bpp为单位的比特率,用R t表示,可以通过以下公式计算: In S101, after the image frame at the last moment after the encoding is completed, since the actual output bits (RB, Real Bits) are generated after the encoding of each frame, the number of bits generated in the t-th frame is RB t , which is converted into The bit rate in bpp, expressed in R t , can be calculated by the following formula:
Figure PCTCN2018118701-appb-000002
Figure PCTCN2018118701-appb-000002
其中,t表示时刻,上述上一时刻编码器输出比特率可以用上述公式(2)表示出来;进而可以通过以下公式计算编码器在t时刻的输出误差e:Where t represents the time, and the output bit rate of the encoder at the previous time can be expressed by the above formula (2); further, the output error e of the encoder at time t can be calculated by the following formula:
e t=R t-T bpp   (3) e t = R t -T bpp (3)
其中,R为编码器输出比特率,T bpp为目标码率; Among them, R is the encoder output bit rate, T bpp is the target code rate;
也就是说,除了获取当前时刻待编码图像帧,还需要获取上一时刻编码器输出比特率R t-1和上一时刻待编码图像帧的QP值。 In other words, in addition to acquiring the image frame to be encoded at the current time, it is also necessary to acquire the output bit rate R t-1 of the encoder at the previous time and the QP value of the image frame to be encoded at the previous time.
S102:根据编码器的目标性能参数,确定编码器在当前时刻与上一时刻性能参数的变化量;S102: According to the target performance parameter of the encoder, determine the change amount of the performance parameter of the encoder at the current time and the previous time;
S102可以包括:根据编码器的目标输出比特率,确定编码器在当前时刻与上一时刻输出比特率的变化量。S102 may include: determining the change amount of the output bit rate of the encoder at the current time and the previous time according to the target output bit rate of the encoder.
在接收到编码器的目标码率之后,可以根据目标码率来确定编码器在当前时刻与上一时刻输出比特率的变化量ΔR,那么,为了确定出编码器在当前时刻与上一时刻输出比特率的变化量ΔR,在一种可选的实施例中,图2为本申请实施例提供的另一种可选的编码方法的流程示意图,参考图2所示,S102可以包括:After receiving the target code rate of the encoder, the output bit rate change ΔR of the encoder at the current time and the previous time can be determined according to the target code rate, then, in order to determine the output of the encoder at the current time and the previous time The amount of change in bit rate ΔR. In an alternative embodiment, FIG. 2 is a schematic flowchart of another alternative encoding method provided by an embodiment of the present application. Referring to FIG. 2, S102 may include:
S201:获取上一时刻虚拟缓冲区的目标线;S201: Obtain the target line of the virtual buffer at the previous moment;
S202:获取当前时刻虚拟缓冲区的目标线;S202: Obtain the target line of the virtual buffer at the current moment;
S203:根据上一时刻虚拟缓冲区的目标线和当前时刻虚拟缓冲区的目标线,确定编码器在当前时刻与上一时刻输出比特率的变化量;S203: According to the target line of the virtual buffer at the previous time and the target line of the virtual buffer at the current time, determine the amount of change in the output bit rate of the encoder between the current time and the previous time;
其中,虚拟缓冲区用于记录编码器的输出比特率超过目标输出比特率的值。Among them, the virtual buffer is used to record the value of the encoder's output bit rate exceeding the target output bit rate.
在一种可选的实施例中,S202可以包括:In an optional embodiment, S202 may include:
确定待编码图像帧在当前时刻的编码结构类型;Determine the encoding structure type of the image frame to be encoded at the current moment;
根据待编码图像帧在当前时刻的编码结构类型和编码器的目标输出比特率,确定当前时刻虚拟缓冲区的目标线。The target line of the virtual buffer at the current moment is determined according to the encoding structure type of the image frame to be encoded at the current moment and the target output bit rate of the encoder.
具体来说,图像帧的编码结构大致可以分为三种,分别为全帧内(AI,All Intra)的编码结构、低延时(LD,Low Delay)的编码结构和随机访问(RA,Random Access)的编码结构。Specifically, the coding structure of the image frame can be roughly divided into three types, which are the coding structure in the full frame (AI, All Intra), the coding structure in low latency (LD, Low Delay), and the random access (RA, Random) Access) coding structure.
在S201中确定出的当前时刻待编码图像帧的编码结构之后,针对不同的编码结构来确定上一时刻虚拟缓冲区的目标线和当前时刻虚拟缓冲区的目标线。After the coding structure of the image frame to be coded at the current time determined in S201, the target line of the virtual buffer at the previous time and the target line of the virtual buffer at the current time are determined for different coding structures.
为了模拟在编码器和信道之间的缓冲器,本申请实施例引入了虚拟缓冲区,假设流入虚拟缓冲区的流量为编码器实时输出的比特率,流出虚拟缓冲区的流量为目标码率,那么,在这个过程中,假设虚拟缓冲区会保持动态变化,其中,虚拟缓冲区的剩余流量叫做当前虚拟缓冲区的充盈程度(CBF,Current Buffer Fullness);或者,由于每一帧输出都可能存在e t,导致编码器输出的比特超过目标码率而滞留在编码端(滞留数可以为 负值,说明编码器输出的码率小于目标码率),本申请实施例将这个滞留数称作当前虚拟缓冲区的充盈程度。其中,可以通过下述公式计算虚拟缓冲区的充盈程度: In order to simulate the buffer between the encoder and the channel, the embodiment of the present application introduces a virtual buffer, assuming that the traffic flowing into the virtual buffer is the bit rate output by the encoder in real time, and the traffic flowing out of the virtual buffer is the target code rate, So, in this process, it is assumed that the virtual buffer will keep changing dynamically, where the remaining flow of the virtual buffer is called the current virtual buffer fullness (CBF, Current Buffer Fullness); or, because each frame output may exist e t , causing the bits output by the encoder to exceed the target code rate and stay at the encoding end (the retention number can be a negative value, indicating that the output bit rate of the encoder is less than the target code rate). The filling level of the virtual buffer. Among them, the filling degree of the virtual buffer can be calculated by the following formula:
Figure PCTCN2018118701-appb-000003
Figure PCTCN2018118701-appb-000003
其中,t表示时刻,由于不同的编码结构,CBF的动态变化过程具有较大的差异,通常编码I帧所需比特数最多,P帧次之,B帧所需比特数最少。Among them, t represents the moment, because of the different coding structure, the dynamic change process of CBF has a big difference, usually the number of bits required to encode I frame is the most, P frame is next, and B frame is the least bit.
那么,为了确定出上一时刻虚拟缓冲区的目标线和当前时刻虚拟缓冲区的目标线,在一种可选的实施例中,根据待编码图像帧在当前时刻的编码结构类型和编码器的目标码率,确定当前时刻虚拟缓冲区的目标线,可以包括:Then, in order to determine the target line of the virtual buffer at the previous moment and the target line of the virtual buffer at the current moment, in an optional embodiment, according to the encoding structure type of the image frame to be encoded at the current moment and the encoder’s The target code rate, which determines the target line of the virtual buffer at the current moment, may include:
若待编码图像帧在当前时刻的编码结构类型为AI结构时,确定当前时刻虚拟缓冲区的目标线均为零;If the coding structure type of the image frame to be coded at the current moment is the AI structure, determine that the target lines of the virtual buffer at the current moment are all zero;
若待编码图像帧在当前时刻的编码结构类型为LD结构时,基于目标输出比特率,调用第一预设公式,确定当前时刻虚拟缓冲区的目标线;If the coding structure type of the image frame to be coded at the current moment is the LD structure, based on the target output bit rate, the first preset formula is called to determine the target line of the virtual buffer at the current moment;
若待编码图像帧在当前时刻的编码结构类型为RA结构时,基于目标输出比特率,调用第二预设公式,确定当前时刻虚拟缓冲区的目标线。If the coding structure type of the image frame to be coded at the current moment is the RA structure, the second preset formula is called based on the target output bit rate to determine the target line of the virtual buffer at the current moment.
具体来说,在AI结构下,由于所有帧都是I帧,输出的比特率相对平稳,和目标比特率比较接近,因此,在此编码结构下,码率控制的理想目标是让CBF在更新过程中,尽可能地接近0,所以,在AI结构线,虚拟缓冲区的目标线恒为0,可以用下述公式来表示虚拟缓冲区的目标线(TBL,Target Bit Line):Specifically, in the AI structure, since all frames are I frames, the output bit rate is relatively stable, and is close to the target bit rate. Therefore, in this coding structure, the ideal goal of rate control is to let the CBF update In the process, it is as close to 0 as possible, so in the AI structure line, the target line of the virtual buffer is always 0, and the target line of the virtual buffer (TBL, Target BitLine) can be expressed by the following formula:
TBL t=0   (5) TBL t = 0 (5)
若当前时刻待编码图像帧的编码结构类型为LD结构时,通过公式(3)计算编码器的输出误差e:If the coding structure type of the image frame to be coded at the current moment is the LD structure, the output error e of the encoder is calculated by formula (3):
通过下述公式计算上一时刻虚拟缓冲区的目标线和当前时刻虚拟缓冲区的目标线:Use the following formula to calculate the target line of the virtual buffer at the previous moment and the target line of the virtual buffer at the current moment:
Figure PCTCN2018118701-appb-000004
Figure PCTCN2018118701-appb-000004
其中,TBL表示虚拟缓冲区的目标线,TFs表示总的编码帧数,即,上述公式(3)和公式(6)为第一预设公式。Wherein, TBL represents the target line of the virtual buffer, and TFs represents the total number of encoded frames, that is, the above formula (3) and formula (6) are the first preset formulas.
具体来说,对于LD的编码结构,首帧是I帧,其输出的比特率往往是目标比特率的几倍甚至几十倍,导致编码完首I帧后,CBF会冲高很多,而随后的P帧不可能马上将这个冲高拉回到0,即使可以这样,也会导致随后的P帧编码质量很差,在其被参考的时候,这种误差会进一步放大,导致整个序列严重失真。这种情况下,首I帧的冲高缓缓下降到0,可以使得后续P帧的失真不至于太大;其中,首I帧为一个序列的起始帧。Specifically, for the LD coding structure, the first frame is an I frame, and the output bit rate is often several times or even tens of times the target bit rate, resulting in the CBF will be much higher after encoding the first I frame, and then It is impossible for the P frame to pull this high back to 0 immediately. Even if it can, it will cause the subsequent P frame to be of poor coding quality. When it is referenced, this error will be further amplified, resulting in serious distortion of the entire sequence . In this case, the height of the first I frame slowly drops to 0, which can make the distortion of the subsequent P frame not too large; where the first I frame is the starting frame of a sequence.
其中,上述公式(6)表示在LD结构下,首I-帧无增量反馈,便无法加以控制,其目标线即为首I帧的比特率误差,其后缓缓减少这个冲高,直至最后一帧归零。Among them, the above formula (6) shows that under the LD structure, the first I-frame can not be controlled without incremental feedback, and its target line is the bit rate error of the first I-frame, and then this decrease is slowly reduced until the end One frame is zeroed.
若当前时刻待编码图像帧的编码结构类型为RA结构时,通过上述公式(3)计算编码器的输出误差e。If the coding structure type of the image frame to be coded at the current moment is the RA structure, the output error e of the encoder is calculated by the above formula (3).
通过上述公式(4)计算虚拟缓冲区的充盈程度CBF。The filling degree CBF of the virtual buffer is calculated by the above formula (4).
通过下述公式计算上一时刻虚拟缓冲区的目标线和当前时刻虚拟缓冲区的目标线:Use the following formula to calculate the target line of the virtual buffer at the previous moment and the target line of the virtual buffer at the current moment:
Figure PCTCN2018118701-appb-000005
Figure PCTCN2018118701-appb-000005
其中,TBL表示虚拟缓冲区的目标线,IP表示每一个I帧周期内包含的帧数,下标I表示当前I帧周期中I帧的编码序,I-Picture表示I帧,Others表示非I帧,即,上述公式(3)、公式(4)和公式(7)为第二预设公式。Among them, TBL represents the target line of the virtual buffer, IP represents the number of frames contained in each I frame period, subscript I represents the coding sequence of I frames in the current I frame period, I-Picture represents I frames, and Others represents non-I Frame, that is, the above formula (3), formula (4) and formula (7) are the second preset formula.
对于RA结构,其编码结构和参考结构较LD都稍显复杂,I-帧会周期性的出现,序列的播放顺序与编码顺序不一致,参考时,就存在后向参考的情况,并且某些帧会出现不被参考的情况。但是忽略这些复杂的情况,我们可以将相邻I帧之间的情况简单地看作是一个LD结构。For the RA structure, the coding structure and the reference structure are slightly more complicated than the LD. I-frames will appear periodically. The sequence of the sequence is inconsistent with the coding order. When referring, there is a backward reference, and some frames There will be cases where it is not referenced. But ignoring these complicated situations, we can simply treat the situation between adjacent I frames as an LD structure.
其中,公式(7)表示每一个I帧周期内与LD结构类似,在I帧周期内就让冲高缓缓下降到0。但是,几乎很难做到恰好归零,因此,后续周期(非第一个周期)的I帧TBL需要加上前一个周期结束时存在的误差,上述CBF t-1表示上一个IP编码结束时虚拟缓冲区的充盈程度,因此编码首个IP时,CBF t-1=0。 Among them, the formula (7) indicates that each I frame period is similar to the LD structure, and in the I frame period, the height is slowly reduced to 0. However, it is difficult to achieve almost exactly zero, therefore, the following cycle (non-first cycle) required TBL I frame errors occurring when the end of a cycle before adding, when said CBF t-1 represents the end of an encoded IP The degree of filling of the virtual buffer, so when encoding the first IP, CBF t-1 = 0.
在一种可选的实施例中,图3为本申请实施例提供的又一种可选的编码方法的流程示意图,参考图3所示,S203可以包括:In an alternative embodiment, FIG. 3 is a schematic flowchart of another alternative encoding method provided by an embodiment of the present application. Referring to FIG. 3, S203 may include:
S301:获取当前时刻虚拟缓冲区的充盈程度;S301: Obtain the filling degree of the virtual buffer at the current moment;
S302:根据当前时刻虚拟缓冲区的充盈程度和上一时刻虚拟缓冲区的目标线,确定上一时刻虚拟缓冲区的误差;S302: Determine the error of the virtual buffer at the previous time according to the filling level of the virtual buffer at the current time and the target line of the virtual buffer at the previous time;
S303:根据编码器在上一时刻输出比特率和目标输出比特率,确定编码器在上一时刻的输出误差;S303: Determine the output error of the encoder at the previous time according to the output bit rate of the encoder at the previous time and the target output bit rate;
S304:根据上一时刻虚拟缓冲区的误差、编码器在上一时刻的输出误差、上一时刻虚拟缓冲区的目标线和当前时刻虚拟缓冲区的目标线,确定编码器在当前时刻与上一时刻输出比特率的变化量;S304: According to the error of the virtual buffer at the last moment, the output error of the encoder at the last moment, the target line of the virtual buffer at the last moment, and the target line of the virtual buffer at the current moment, determine the current moment The output bit rate change at any time;
S305:调用第三预设公式更新当前时刻虚拟缓冲区的充盈程度。S305: Call the third preset formula to update the filling level of the virtual buffer at the current moment.
在一种可选的实施例中,S304可以包括:In an optional embodiment, S304 may include:
用当前时刻虚拟缓冲区的目标线,减去上一时刻虚拟缓冲区的目标线,减去上一时刻虚拟缓冲区的误差,减去编码器在上一时刻的输出误差得到的值,确定为编码器在当前时刻与上一时刻输出比特率的变化量。Using the target line of the virtual buffer at the current time, subtract the target line of the virtual buffer at the previous time, subtract the error of the virtual buffer at the previous time, and subtract the output error of the encoder at the previous time, and determine as The encoder outputs the amount of change in the bit rate between the current time and the previous time.
这里,与上述公式(3)类似,有了虚拟缓冲区的目标线和虚拟缓冲区的充盈程度之后,可以定义虚拟缓冲区的误差E,可以通过以下公式计算虚拟缓冲区的误差E:Here, similar to the above formula (3), after having the target line of the virtual buffer and the filling degree of the virtual buffer, the error E of the virtual buffer can be defined, and the error E of the virtual buffer can be calculated by the following formula:
E t=CBF t-TBL t   (8) E t =CBF t -TBL t (8)
这样,便可以得到编码器下一帧输出比特率R t+1,这个比特率用于消除之前存在的误差并且需要达到虚拟缓冲区的目标线。其推演过程如下公式所示: In this way, the output bit rate R t+1 of the next frame of the encoder can be obtained. This bit rate is used to eliminate the previous error and needs to reach the target line of the virtual buffer. The derivation process is as follows:
Figure PCTCN2018118701-appb-000006
Figure PCTCN2018118701-appb-000006
根据上述公式(3)、(8)和(9)可以得到相邻两个时刻间输出比特率的变化量ΔR:According to the above formulas (3), (8) and (9), the change amount ΔR of the output bit rate between two adjacent moments can be obtained:
Figure PCTCN2018118701-appb-000007
Figure PCTCN2018118701-appb-000007
计算出ΔR之后,调用第三预设公式即公式(4)更新当前虚拟缓冲区的充盈程度。After calculating ΔR, the third preset formula, formula (4), is called to update the filling level of the current virtual buffer.
由于视频编码的过程是一个不可预知的过程,公式(10)并未考虑过去一段时间的变化过程,因此,本技术方案在理论公式上加上了过去一段时间的误差累积量和过去两帧的误差变化量,且其赋予其一定的权值。如下公式所示:Since the process of video encoding is an unpredictable process, formula (10) does not take into account the changes in the past period of time. Therefore, this technical solution adds the cumulative amount of errors in the past period and the past two frames to the theoretical formula. The amount of error change, and it is given a certain weight. As shown in the following formula:
Figure PCTCN2018118701-appb-000008
Figure PCTCN2018118701-appb-000008
其中,上述a、b和c为经验权重参数。Among them, the above-mentioned a, b and c are empirical weight parameters.
至此,便可以通过上述公式(10)或者公式(11)确定出编码器在上一时刻与当前时刻输出比特率的变化量ΔR。So far, the amount of change ΔR in the output bit rate of the encoder at the previous time and the current time can be determined by the above formula (10) or formula (11).
S103:根据性能参数的变化量、编码器在上一时刻的性能参数和待编码图像帧在上一时刻的QP值,确定待编码图像帧在当前时刻的QP值;S103: Determine the QP value of the image frame to be encoded at the current time according to the amount of change in the performance parameter, the performance parameter of the encoder at the previous time, and the QP value of the image frame to be encoded at the previous time;
具体来说,QP值可以用Q来表示,需要通过ΔR反馈计算拉格朗日乘子和量化参数。计算二者的关键在于找到连接比特率、拉格朗日乘子和量化参数之间的关系。实际上,R和λ,R和Q,λ和Q之间,都存在若干种经验公式,很容易将ΔR代入反馈计算得到λ和Q。Specifically, the QP value can be represented by Q, and the Lagrangian multiplier and quantization parameter need to be calculated through ΔR feedback. The key to calculating both is to find the relationship between the connection bit rate, Lagrangian multiplier and quantization parameter. In fact, there are several empirical formulas between R and λ, R and Q, and λ and Q. It is easy to substitute ΔR into the feedback calculation to obtain λ and Q.
为了确定出当前时刻待编码图像帧的QP值,在一种可选的实施例中,图4为本申请实施例提供的再一种可选的编码方法的流程示意图,参考图4所示,S104可以包括:In order to determine the QP value of the image frame to be encoded at the current moment, in an alternative embodiment, FIG. 4 is a schematic flowchart of yet another alternative encoding method provided by an embodiment of the present application. Referring to FIG. 4, S104 may include:
S401:根据输出比特率的变化量和编码器在上一时刻输出比特率,确定当前时刻的拉格朗日乘子与上一时刻的拉格朗日乘子的比值;S401: Determine the ratio of the Lagrangian multiplier at the current time to the Lagrangian multiplier at the previous time according to the change in the output bit rate and the output bit rate of the encoder at the previous time;
S402:根据当前时刻的拉格朗日乘子与上一时刻的拉格朗日乘子的比值,以及待编码图像帧在上一时刻的QP值,确定当前时刻待编码图像帧的QP值。S402: Determine the QP value of the image frame to be encoded at the current time according to the ratio of the Lagrange multiplier at the current time to the Lagrange multiplier at the previous time and the QP value of the image frame to be encoded at the previous time.
具体来说,R-λ模型可以通过下述公式表示:Specifically, the R-λ model can be expressed by the following formula:
R=α·λ β   (12) R=α·λ β (12)
其中,上述α和β为常数。Among them, the above α and β are constants.
基于上述公式(12),可以得到相邻时刻编码器的输出比特率:Based on the above formula (12), the output bit rate of the encoder at the adjacent time can be obtained:
Figure PCTCN2018118701-appb-000009
Figure PCTCN2018118701-appb-000009
将上述公式(13)中的两个表达式相除可以得到下列公式:Divide the two expressions in the above formula (13) to get the following formula:
Figure PCTCN2018118701-appb-000010
Figure PCTCN2018118701-appb-000010
Figure PCTCN2018118701-appb-000011
Figure PCTCN2018118701-appb-000011
在一种可选的实施例中,S401可以包括:In an optional embodiment, S401 may include:
通过下面公式(16)计算当前时刻的拉格朗日乘子与上一时刻的拉格朗日乘子的比值;Calculate the ratio of the Lagrange multiplier at the current moment to the Lagrange multiplier at the previous moment by the following formula (16);
若定义两个λ的比值为η λ,则η λ可以用下列公式表示: If the ratio of two λs is defined as η λ , then η λ can be expressed by the following formula:
Figure PCTCN2018118701-appb-000012
Figure PCTCN2018118701-appb-000012
其中,t表示时刻,λ为拉格朗日乘子,R为编码器输出比特率,ΔR为比特率的变 化量,β为系数。Where t represents the time, λ is the Lagrangian multiplier, R is the encoder output bit rate, ΔR is the amount of bit rate change, and β is the coefficient.
那么,下一时刻的λ t+1拉格朗日乘子可以由下列公式计算得到: Then, the λ t+1 Lagrange multiplier at the next moment can be calculated by the following formula:
Figure PCTCN2018118701-appb-000013
Figure PCTCN2018118701-appb-000013
在一种可选的实施例中,S402可以包括:与求解λ的过程类似,Q-λ模型可以通过下述公式表示:In an optional embodiment, S402 may include: similar to the process of solving λ, the Q-λ model may be expressed by the following formula:
Q=a·lnλ+b   (18)Q=a·lnλ+b (18)
其中,Q表示QP值,a,b为常数。Among them, Q represents QP value, a, b are constants.
Figure PCTCN2018118701-appb-000014
Figure PCTCN2018118701-appb-000014
将公式(19)中的两个表示相减,可以得到如下公式:Subtract the two expressions in formula (19) to obtain the following formula:
Figure PCTCN2018118701-appb-000015
Figure PCTCN2018118701-appb-000015
对公式(20)稍作变形,便可以得到最终量化参数QP的计算公式,如下所示:By slightly modifying equation (20), the calculation formula of the final quantization parameter QP can be obtained as follows:
Figure PCTCN2018118701-appb-000016
Figure PCTCN2018118701-appb-000016
通过公式(21)计算当前时刻待编码图像帧的QP值;Calculate the QP value of the image frame to be encoded at the current moment by formula (21);
另外,对拉格朗日乘子和量化参数的表示方法,还可以有多种,例如,下面的表示方法及解析过程:In addition, there can be multiple methods for representing Lagrange multipliers and quantization parameters. For example, the following representation methods and analysis processes:
首先,通过大量统计分析,可以得到R-Q指数模型:First, through a lot of statistical analysis, the R-Q index model can be obtained:
R=α·e -βQ   (22) R=α·e -βQ (22)
对公式(22)两边同时对Q求导可得如下公式:Differentiating Q from both sides of formula (22) gives the following formula:
Figure PCTCN2018118701-appb-000017
Figure PCTCN2018118701-appb-000017
在较小的QP值变化范围内,将△R≈dR,△Q≈dQ,带入上述公式(23)后可得:Within a small variation range of QP value, △R≈dR and △Q≈dQ can be taken into the above formula (23) to obtain:
Figure PCTCN2018118701-appb-000018
Figure PCTCN2018118701-appb-000018
那么,下一时刻所使用的QP可以表达为:Then, the QP used at the next moment can be expressed as:
Q t+1=Q t+△Q   (25) Q t+1 =Q t +△Q (25)
由上述公式(20)可以得到如下公式:The following formula can be obtained from the above formula (20):
Figure PCTCN2018118701-appb-000019
Figure PCTCN2018118701-appb-000019
根据公式(25)和公式(26)可以得到上述公式(21),从而可以计算出当前时刻待编码图像帧的QP值。The above formula (21) can be obtained according to formula (25) and formula (26), so that the QP value of the image frame to be encoded at the current moment can be calculated.
S104:根据待编码图像帧在当前时刻的QP值,对当前时刻的待编码图像帧进行编码。S104: According to the QP value of the image frame to be encoded at the current moment, encode the image frame to be encoded at the current moment.
这样,采用基于缓冲区增量反馈的方法,将当前缓冲区充盈程度反馈到比特率的变化量,再通过编码器输出的比特率R与拉格朗日乘子λ、比特率与量化参数QP或者拉格朗日乘子与量化参数之间的关系调节编码参数(拉格朗日乘子和量化参数),将调节后的参数用于当前图像编码,进而达到码率控制的目的。In this way, the method based on buffer incremental feedback is used to feed back the current buffer filling degree to the change in bit rate, and then output the bit rate R and Lagrange multiplier λ, bit rate and quantization parameter QP through the encoder. Or, the relationship between the Lagrangian multiplier and the quantization parameter adjusts the encoding parameters (the Lagrangian multiplier and the quantization parameter), and the adjusted parameter is used in the current image encoding, thereby achieving the purpose of code rate control.
下面举实例来对上述一个或多个实施例所述的编码方法进行说明。The following provides an example to describe the encoding method described in the above one or more embodiments.
图5为本申请实施例提供的编码方法的一种可选的实例的流程示意图,参考图5所示,该方法可以包括:FIG. 5 is a schematic flowchart of an alternative example of an encoding method provided by an embodiment of the present application. Referring to FIG. 5, the method may include:
S501:获取1帧图像;S501: Acquire 1 frame of image;
S502:确定该图像的编码结构类型和系统分配给该图像的QP值;S502: Determine the coding structure type of the image and the QP value assigned by the system to the image;
S503:进入虚拟缓冲区增量反馈计算QP值的子流程,得到1帧图像的QP值;S503: Enter the sub-process of calculating the QP value in the incremental feedback of the virtual buffer to obtain the QP value of one frame of image;
S504:用1帧图像的QP值编码1帧图像;S504: encode one frame of image with the QP value of one frame of image;
S505:更新虚拟缓冲区状态;S505: Update the state of the virtual buffer;
S506:判断是否全部编码完成;若为是,结束编码;若为否,转入S401。S506: Determine whether all encoding is completed; if yes, end encoding; if no, go to S401.
图6为本申请实施例提供的编码方法的另一种可选的实例的流程示意图,参考图6所示,确定QP值的方法可以包括:FIG. 6 is a schematic flowchart of another optional example of the encoding method provided by the embodiment of the present application. Referring to FIG. 6, the method for determining the QP value may include:
S601:根据上述公式(5)、公式(6)和公式(7)确定上一时刻虚拟缓冲区的目标线和当前时刻虚拟缓冲区的目标线;S601: Determine the target line of the virtual buffer at the previous moment and the target line of the virtual buffer at the current moment according to the above formula (5), formula (6) and formula (7);
S602:根据公式(8)计算前一帧(上一时刻)虚拟缓冲区的误差;S602: Calculate the error of the virtual buffer in the previous frame (last time) according to formula (8);
S603:根据公式(11)计算编码器在当前时刻与上一时刻输出比特率的变化量;S603: Calculate the amount of change in the output bit rate of the encoder at the current time and the previous time according to formula (11);
S604:根据公式(20)计算QP值的变化量;S604: Calculate the change in QP value according to formula (20);
S605:根据公式(21)计算当前时刻待编码图像帧的QP值。S605: Calculate the QP value of the image frame to be encoded at the current moment according to formula (21).
图7为本申请实施例提供的编码方法的又一种可选的实例的流程示意图,参考图7所示,确定虚拟缓冲区的充盈程度的方法(虚拟缓冲区状态更新的子流程)可以包括:FIG. 7 is a schematic flowchart of still another optional example of the encoding method provided by the embodiment of the present application. Referring to FIG. 7, the method for determining the filling degree of the virtual buffer (sub-process of virtual buffer status update) may include :
S701:根据公式(3)确定当前帧(当前时刻)编码器的输出误差;S701: Determine the output error of the encoder of the current frame (the current moment) according to formula (3);
S702:根据公式(4)更新当前虚拟缓冲区的充盈程度。S702: Update the filling level of the current virtual buffer according to formula (4).
在本申请实施例中,通过输出比特率的误差累计,利用虚拟缓冲区构建控制系统,反馈调节QP以达到调节码率的目的。同样的,如果将质量误差相关的各项统计指标构建模型,使用失真虚拟缓冲区构建反馈系统,将误差模型作为输入调节QP,能够达到控制图像质量稳定的目的;如果将时间误差相关的各项统计指标构建模型,建立时间误差统计与图像质量的关系,结合质量反馈调节系统进行QP调节,能够达到控制速率稳定的目的。In the embodiment of the present application, by accumulating the error of the output bit rate, a virtual buffer is used to construct a control system, and the QP is fed back to adjust the bit rate. Similarly, if the statistical indicators related to the quality error are used to construct a model, the distortion virtual buffer is used to construct a feedback system, and the error model is used as an input to adjust the QP, the purpose of controlling the image quality can be achieved. The statistical index builds a model, establishes the relationship between time error statistics and image quality, and performs QP adjustment in combination with the quality feedback adjustment system, which can achieve the purpose of stable control rate.
图8为本申请实施例提供的AI编码结构下虚拟缓冲区的充盈程度的仿真图,参考图8所示,图8中的(a)、(b)、(c)和(d)分别为图像的编码格式为AI编码结构下四种不同视频在不同目标码率下虚拟缓冲区的充盈程度线,其中,图8-(a)的视频名称为City_1280×720_60,图8-(b)的视频名称为vidyo1_1280×720_60,图8-(c)的视频名称为beach_1920×1080_25,图8-(d)的视频名称为pku_girls_3840×2160_50;在图8中的(a)、(b)、(c)和(d)中的每个子图中,有四种不同的目标码率,分别为T1、T2、T3和T4;上述图8的横坐标为编码序列(coding order),纵坐标为虚拟缓冲区的充盈程度。FIG. 8 is a simulation diagram of the filling degree of the virtual buffer under the AI coding structure provided by the embodiment of the present application. Referring to FIG. 8, (a), (b), (c), and (d) in FIG. 8 are: The encoding format of the image is the filling level line of the virtual buffer of the four different videos under different target bit rates under the AI encoding structure. Among them, the video name in Figure 8-(a) is City_1280×720_60, and that in Figure 8-(b) The video name is vidyo1_1280×720_60, the video name in Figure 8-(c) is beach_1920×1080_25, and the video name in Figure 8-(d) is pku_girls_3840×2160_50; (a), (b), (c in Figure 8 ) And (d) in each sub-picture, there are four different target code rates, namely T1, T2, T3 and T4; the abscissa of the above Figure 8 is the coding sequence (coding order), the ordinate is the virtual buffer The filling degree of the district.
图9为本申请实施例提供的LD编码结构下虚拟缓冲区的充盈程度的仿真图,参考 图9所示,图9中的(a)、(b)、(c)和(d)分别为图像的编码格式为LD编码结构下四种不同视频在不同目标码率下虚拟缓冲区的充盈程度线,其中,图9-(a)的视频名称为City_1280×720_60,图9-(b)的视频名称为vidyo1_1280×720_60,图9-(c)的视频名称为beach_1920×1080_25,图9-(d)的视频名称为pku_girls_3840×2160_50;在图9中的(a)、(b)、(c)和(d)中的每个子图中,有四种不同的目标码率,分别为T1、T2、T3和T4;上述图9的横坐标为编码序列(coding order),纵坐标为虚拟缓冲区的充盈程度。9 is a simulation diagram of the filling degree of the virtual buffer under the LD coding structure provided by the embodiment of the present application. Referring to FIG. 9, (a), (b), (c) and (d) in FIG. 9 are: The encoding format of the image is the filling level line of the virtual buffer of the four different videos under different target bit rates under the LD encoding structure. Among them, the video name in Figure 9-(a) is City_1280×720_60, and that in Figure 9-(b) The video name is vidyo1_1280×720_60, the video name in Figure 9-(c) is beach_1920×1080_25, and the video name in Figure 9-(d) is pku_girls_3840×2160_50; (a), (b), (c in Figure 9 ) And (d) in each sub-picture, there are four different target code rates, respectively T1, T2, T3 and T4; the abscissa of the above Figure 9 is the coding sequence (coding order), the ordinate is the virtual buffer The filling degree of the district.
图10为本申请实施例提供的RA编码结构下虚拟缓冲区的充盈程度的仿真图,参考图10所示,图10中的(a)、(b)、(c)和(d)分别为图像的编码格式为RA编码结构下四种不同视频在不同目标码率下虚拟缓冲区的充盈程度线,其中,图10-(a)的视频名称为City_1280×720_60,图10-(b)的视频名称为vidyo1_1280×720_60,图10-(c)的视频名称为beach_1920×1080_25,图10-(d)的视频名称为pku_girls_3840×2160_50;在图8中的(a)、(b)、(c)和(d)中的每个子图中,有四种不同的目标码率,分别为T1、T2、T3和T4;上述图10的横坐标为编码序列(coding order),纵坐标为虚拟缓冲区的充盈程度。FIG. 10 is a simulation diagram of the filling degree of the virtual buffer under the RA coding structure provided by the embodiment of the present application. Referring to FIG. 10, (a), (b), (c), and (d) in FIG. 10 are: The encoding format of the image is the filling level line of the virtual buffer of the four different videos under different target bit rates under the RA encoding structure. Among them, the video name in Figure 10-(a) is City_1280×720_60, and that in Figure 10-(b) The video name is vidyo1_1280×720_60, the video name in Figure 10-(c) is beach_1920×1080_25, and the video name in Figure 10-(d) is pku_girls_3840×2160_50; (a), (b), (c in Figure 8 ) And (d) in each sub-picture, there are four different target bit rates, respectively T1, T2, T3 and T4; the abscissa of the above Figure 10 is the coding sequence (coding order), the ordinate is the virtual buffer The filling degree of the district.
下面表1为AI编码结构下,针对YUV颜色编码下,不同的视频源的控制误差,其中,视频源包括:UHD、1080P、WVGA、WQVGA和720p。Table 1 below is the control error of different video sources under the AI coding structure for YUV color coding. Among them, the video sources include: UHD, 1080P, WVGA, WQVGA and 720p.
Figure PCTCN2018118701-appb-000020
Figure PCTCN2018118701-appb-000020
表1Table 1
下面表2为LD编码结构下,针对YUV颜色编码下,不同的视频源的控制误差,其中,视频源包括:UHD、1080P、WVGA、WQVGA和720p。Table 2 below shows the control errors of different video sources under the LD coding structure for YUV color coding. Among them, the video sources include: UHD, 1080P, WVGA, WQVGA, and 720p.
Figure PCTCN2018118701-appb-000021
Figure PCTCN2018118701-appb-000021
表2Table 2
下面表3为RA编码结构下,针对YUV颜色编码下,不同的视频源的控制误差, 其中,视频源包括:UHD、1080P、WVGA、WQVGA和720p。Table 3 below shows the control errors of different video sources under the RA coding structure for YUV color coding, where the video sources include: UHD, 1080P, WVGA, WQVGA, and 720p.
Figure PCTCN2018118701-appb-000022
Figure PCTCN2018118701-appb-000022
表3table 3
本申请实施例提供了一种编码方法,该方法应用于一编码器中,该方法包括:在确定待编码图像帧在当前时刻的QP值考虑到了上一时刻性能参数的变化量,如此,结合性能参数的历史情况,得到的编码图像帧在当前时刻待的QP值更加精确,最后,根据待编码图像帧在当前时刻的QP值,对待编码图像帧在当前时刻进行编码;使得编码过程中不仅仅只是用预先设定的编码参数,还考虑到了编码器性能参数的变化量,这样,有利于提高编码过程中性能参数的控制精度,从而提高了编码过程中的编码性能。An embodiment of the present application provides an encoding method, which is applied to an encoder. The method includes: determining the QP value of the image frame to be encoded at the current time taking into account the amount of change in the performance parameter at the previous time, thus, combining The historical situation of the performance parameters, the QP value of the obtained encoded image frame at the current time is more accurate, and finally, according to the QP value of the image frame to be encoded at the current time, the image frame to be encoded is encoded at the current time; making the encoding process not only Only the preset encoding parameters are used, and the variation of the encoder performance parameters is also taken into consideration. This helps to improve the control accuracy of the performance parameters during the encoding process, thereby improving the encoding performance during the encoding process.
基于前述实施例相同的发明构思,图11为本申请实施例提供的一种编码器的结构示意图一,参见图11,编码器110可以包括:Based on the same inventive concept of the foregoing embodiment, FIG. 11 is a schematic structural diagram 1 of an encoder provided by an embodiment of the present application. Referring to FIG. 11, the encoder 110 may include:
第一获取单元111,用于获取编码器在上一时刻的性能参数和待编码图像帧在上一时刻的QP值;The first acquiring unit 111 is configured to acquire the performance parameter of the encoder at the last moment and the QP value of the image frame to be encoded at the last moment;
第一确定单元112,用于根据编码器的目标性能参数,确定编码器在当前时刻与上一时刻性能参数的变化量;The first determining unit 112 is configured to determine the change amount of the performance parameter of the encoder at the current time and the previous time according to the target performance parameter of the encoder;
第二确定单元113,用于根据性能参数的变化量、编码器在上一时刻的性能参数和待编码图像帧在上一时刻的QP值,确定待编码图像帧在当前时刻的QP值;The second determining unit 113 is configured to determine the QP value of the image frame to be encoded at the current time according to the change amount of the performance parameter, the performance parameter of the encoder at the previous time, and the QP value of the image frame to be encoded at the previous time;
编码单元114,用于根据待编码图像帧在当前时刻的QP值,对当前时刻的待编码图像帧进行编码。The encoding unit 114 is configured to encode the image frame to be encoded at the current time according to the QP value of the image frame to be encoded at the current time.
在上述方案中,性能参数包括以下任意一项:图像帧的输出速率参数,图像帧的输出质量参数或者图像帧的输出时间参数。In the above solution, the performance parameter includes any one of the following: the output rate parameter of the image frame, the output quality parameter of the image frame, or the output time parameter of the image frame.
在上述方案中,当性能参数为图像帧的输出速率参数时,且图像帧的输出速率参数为输出比特率时,对应地,目标性能参数为目标输出比特率;In the above solution, when the performance parameter is the output rate parameter of the image frame, and the output rate parameter of the image frame is the output bit rate, correspondingly, the target performance parameter is the target output bit rate;
第一确定单元112,具体用于:根据编码器的目标输出比特率,确定编码器在当前时刻与上一时刻输出比特率的变化量。The first determining unit 112 is specifically configured to: according to the target output bit rate of the encoder, determine the amount of change in the output bit rate of the encoder at the current time and the previous time.
在上述方案中,第一确定单元112,包括:In the above solution, the first determining unit 112 includes:
第一获取子单元,用于获取上一时刻虚拟缓冲区的目标线;The first obtaining subunit is used to obtain the target line of the virtual buffer at the previous moment;
第二获取子单元,用于获取当前时刻虚拟缓冲区的目标线;The second obtaining subunit is used to obtain the target line of the virtual buffer at the current moment;
第一确定子单元,用于根据上一时刻虚拟缓冲区的目标线和当前时刻虚拟缓冲区的目标线,确定编码器在当前时刻与上一时刻输出比特率的变化量;The first determining subunit is used to determine the amount of change in the output bit rate of the encoder between the current time and the previous time according to the target line of the virtual buffer at the previous time and the target line of the virtual buffer at the current time;
其中,虚拟缓冲区用于记录编码器的输出比特率超过目标输出比特率的值。Among them, the virtual buffer is used to record the value of the encoder's output bit rate exceeding the target output bit rate.
在上述方案中,第二获取子单元,包括:In the above solution, the second acquisition subunit includes:
第二确定子单元,用于确定待编码图像帧在当前时刻的编码结构类型;The second determining subunit is used to determine the encoding structure type of the image frame to be encoded at the current moment;
第三确定子单元,用于根据待编码图像帧在当前时刻的编码结构类型和编码器的目 标输出比特率,确定当前时刻虚拟缓冲区的目标线。The third determining subunit is used to determine the target line of the virtual buffer at the current time according to the encoding structure type of the image frame to be encoded at the current time and the target output bit rate of the encoder.
在上述方案中,第三确定子单元,具体用于:In the above solution, the third determining subunit is specifically used for:
若待编码图像帧在当前时刻的编码结构类型为全帧内AI结构时,确定当前时刻虚拟缓冲区的目标线均为零;If the coding structure type of the image frame to be coded at the current moment is the AI structure within the full frame, determine that the target line of the virtual buffer at the current moment is all zero;
若待编码图像帧在当前时刻的编码结构类型为低延时LD结构时,基于目标输出比特率,调用第一预设公式,确定当前时刻虚拟缓冲区的目标线;If the encoding structure type of the image frame to be encoded at the current moment is a low-latency LD structure, based on the target output bit rate, the first preset formula is called to determine the target line of the virtual buffer at the current moment;
若待编码图像帧在当前时刻的编码结构类型为随机访问RA结构时,基于目标输出比特率,调用第二预设公式,确定当前时刻虚拟缓冲区的目标线。If the coding structure type of the image frame to be coded at the current moment is a random access RA structure, the second preset formula is called based on the target output bit rate to determine the target line of the virtual buffer at the current moment.
在上述方案中,第一确定子单元,包括:In the above solution, the first determining subunit includes:
第三获取子单元,用于获取当前时刻虚拟缓冲区的充盈程度;The third obtaining subunit is used to obtain the filling degree of the virtual buffer at the current moment;
第四确定子单元,用于根据当前时刻虚拟缓冲区的充盈程度和上一时刻虚拟缓冲区的目标线,确定上一时刻虚拟缓冲区的误差;The fourth determining subunit is used to determine the error of the virtual buffer at the previous time according to the filling level of the virtual buffer at the current time and the target line of the virtual buffer at the previous time;
第五确定子单元,用于根据编码器在上一时刻的输出比特率和目标输出比特率,确定编码器在上一时刻的输出误差;The fifth determining subunit is used to determine the output error of the encoder at the last moment according to the output bit rate of the encoder at the last moment and the target output bit rate;
第六确定子单元,用于根据上一时刻虚拟缓冲区的误差、编码器在上一时刻的输出误差、上一时刻虚拟缓冲区的目标线和当前时刻虚拟缓冲区的目标线,确定编码器在当前时刻与上一时刻输出比特率的变化量;The sixth determining subunit is used to determine the encoder based on the error of the virtual buffer at the previous time, the output error of the encoder at the previous time, the target line of the virtual buffer at the previous time and the target line of the virtual buffer at the current time Output the amount of change in bit rate between the current time and the previous time;
更新子单元,用于调用第三预设公式更新当前时刻虚拟缓冲区的充盈程度。The update subunit is used to call the third preset formula to update the filling degree of the virtual buffer at the current moment.
在上述方案中,第六确定子单元,具体用于:In the above solution, the sixth determining subunit is specifically used for:
用当前时刻虚拟缓冲区的目标线,减去上一时刻虚拟缓冲区的目标线,减去上一时刻虚拟缓冲区的误差,减去编码器在上一时刻的输出误差得到的值,确定为编码器在当前时刻与上一时刻输出比特率的变化量。Using the target line of the virtual buffer at the current time, subtract the target line of the virtual buffer at the previous time, subtract the error of the virtual buffer at the previous time, and subtract the output error of the encoder at the previous time, and determine as The encoder outputs the amount of change in the bit rate between the current time and the previous time.
在上述方案中,当性能参数为图像帧的输出参数时,且该图像帧的输出速率参数为输出比特率时,对应地,目标性能参数为目标输出比特率;In the above solution, when the performance parameter is the output parameter of the image frame, and the output rate parameter of the image frame is the output bit rate, correspondingly, the target performance parameter is the target output bit rate;
第二确定单元113,具体用于:The second determining unit 113 is specifically used for:
根据输出比特率的变化量、编码器在上一时刻的输出比特率和待编码图像帧在上一时刻的QP值,确定待编码图像帧在当前时刻的QP值。The QP value of the image frame to be encoded at the current time is determined according to the change amount of the output bit rate, the output bit rate of the encoder at the previous time, and the QP value of the image frame to be encoded at the previous time.
在上述方案中,第二确定单元113,包括:In the above solution, the second determining unit 113 includes:
第七确定子单元,用于根据输出比特率的变化量和编码器在上一时刻的输出比特率,确定当前时刻的拉格朗日乘子与上一时刻的拉格朗日乘子的比值;The seventh determining subunit is used to determine the ratio of the Lagrangian multiplier at the current time to the Lagrangian multiplier at the previous time according to the output bit rate change and the output bit rate of the encoder at the previous time ;
第八确定子单元,用于根据当前时刻的拉格朗日乘子与上一时刻的拉格朗日乘子的比值,以及待编码图像帧在上一时刻的QP值,确定待编码图像帧在当前时刻的QP值。The eighth determination subunit is used to determine the image frame to be encoded based on the ratio of the Lagrange multiplier at the current time to the Lagrange multiplier at the previous time and the QP value of the image frame to be encoded at the previous time QP value at the current moment.
在上述方案中,第七确定子单元,具体用于:In the above solution, the seventh determining subunit is specifically used for:
通过下述公式计算当前时刻的拉格朗日乘子与上一时刻的拉格朗日乘子的比值:Calculate the ratio of the Lagrange multiplier at the current moment to the Lagrange multiplier at the previous moment by the following formula:
Figure PCTCN2018118701-appb-000023
Figure PCTCN2018118701-appb-000023
其中,t表示时刻,λ为拉格朗日乘子,R为编码器输出比特率,ΔR为输出比特率的变化量,β为系数。Where t represents the time, λ is the Lagrangian multiplier, R is the encoder output bit rate, ΔR is the change in output bit rate, and β is the coefficient.
在上述方案中,第八确定子单元,具体用于:In the above solution, the eighth determining subunit is specifically used for:
通过下述公式计算待编码图像帧在当前时刻的QP值:Calculate the QP value of the image frame to be encoded at the current moment by the following formula:
Figure PCTCN2018118701-appb-000024
Figure PCTCN2018118701-appb-000024
其中,t表示时刻,Q表示QP值,λ为拉格朗日乘子,a为常数。Among them, t represents time, Q represents QP value, λ is Lagrange multiplier, a is constant.
可以理解地,在本实施例中,“单元”可以是部分电路、部分处理器、部分程序或软件等等,当然也可以是模块,还可以是非模块化的。Understandably, in this embodiment, the "unit" may be a part of a circuit, a part of a processor, a part of a program or software, etc. Of course, it may also be a module or non-modular.
另外,在本实施例中的各组成单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能模块的形式实现。In addition, each component unit in this embodiment may be integrated into one processing unit, or each unit may exist alone physically, or two or more units may be integrated into one unit. The above integrated unit can be implemented in the form of hardware or software function module.
所述集成的单元如果以软件功能模块的形式实现并非作为独立的产品进行销售或使用时,可以存储在一个计算机可读取存储介质中,基于这样的理解,本实施例的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)或processor(处理器)执行本实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(Read Only Memory,ROM)、随机存取存储器(Random Access Memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。If the integrated unit is implemented in the form of a software function module and is not sold or used as an independent product, it may be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this embodiment essentially or It is said that part of the contribution to the existing technology or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions to make a computer device (may It is a personal computer, a server, or a network device, etc.) or a processor (processor) that performs all or part of the steps of the method described in this embodiment. The foregoing storage media include various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (Read Only Memory, ROM), a random access memory (Random Access Memory, RAM), a magnetic disk, or an optical disk.
图12为本申请实施例提供的一种编码器的结构示意图二,如图12所示,本申请实施例提供了一种编码器120,FIG. 12 is a second structural diagram of an encoder provided by an embodiment of the present application. As shown in FIG. 12, an encoder 120 is provided by an embodiment of the present application.
包括处理器121以及存储有处理器121可执行指令的存储介质122,存储介质122通过通信总线123依赖处理器121执行操作,当指令被处理器121执行时,执行上述实施例一的编码方法。It includes a processor 121 and a storage medium 122 that stores instructions executable by the processor 121. The storage medium 122 relies on the processor 121 to perform operations through the communication bus 123. When the instructions are executed by the processor 121, the encoding method of Embodiment 1 above is performed.
需要说明的是,实际应用时,终端中的各个组件通过通信总线123耦合在一起。可理解,通信总线123用于实现这些组件之间的连接通信。通信总线123除包括数据总线之外,还包括电源总线、控制总线和状态信号总线。但是为了清楚说明起见,在图12中将各种总线都标为通信总线123。It should be noted that, in actual application, various components in the terminal are coupled together through the communication bus 123. It can be understood that the communication bus 123 is used to implement connection communication between these components. The communication bus 123 includes a power bus, a control bus, and a status signal bus in addition to the data bus. However, for the sake of clarity, various buses are marked as communication buses 123 in FIG. 12.
本申请实施例提供了一种计算机存储介质,存储有可执行指令,当所述可执行指令被一个或多个处理器执行的时候,所述处理器执行上述一个或多个实施例所述的编码方法。An embodiment of the present application provides a computer storage medium that stores executable instructions, and when the executable instructions are executed by one or more processors, the processor executes the one or more embodiments described above Encoding method.
可以理解,本申请实施例中的存储器可以是易失性存储器或非易失性存储器,或可包括易失性和非易失性存储器两者。其中,非易失性存储器可以是只读存储器(Read-Only Memory,ROM)、可编程只读存储器(Programmable ROM,PROM)、可擦除可编程只读存储器(Erasable PROM,EPROM)、电可擦除可编程只读存储器(Electrically EPROM,EEPROM)或闪存。易失性存储器可以是随机存取存储器(Random Access Memory,RAM),其用作外部高速缓存。通过示例性但不是限制性说明,许多形式的RAM可用,例如静态随机存取存储器(Static RAM,SRAM)、动态随机存取存储器(Dynamic RAM,DRAM)、同步动态随机存取存储器(Synchronous DRAM,SDRAM)、双倍数据速率同步动态随机存取存储器(Double Data Rate SDRAM,DDRSDRAM)、增强型同步动态随机存取存储器(Enhanced SDRAM,ESDRAM)、同步连接动态随机存取存储器(Synchlink DRAM,SLDRAM)和直接内存总线随机存取存储器(Direct Rambus RAM,DRRAM)。本文描述的系统和方法的存储器旨在包括但不限于这些和任意其它适合类型的存储器。It can be understood that the memory in the embodiments of the present application may be volatile memory or non-volatile memory, or may include both volatile and non-volatile memory. Among them, the non-volatile memory may be read-only memory (Read-Only Memory, ROM), programmable read-only memory (Programmable ROM, PROM), erasable programmable read-only memory (Erasable PROM, EPROM), electronically Erasable programmable read only memory (Electrically, EPROM, EEPROM) or flash memory. The volatile memory may be a random access memory (Random Access Memory, RAM), which is used as an external cache. By way of example but not limitation, many forms of RAM are available, such as static random access memory (Static RAM, SRAM), dynamic random access memory (Dynamic RAM, DRAM), synchronous dynamic random access memory (Synchronous DRAM, SDRAM), double data rate synchronous dynamic random access memory (Double Data Rate SDRAM, DDRSDRAM), enhanced synchronous dynamic random access memory (Enhanced SDRAM, ESDRAM), synchronous connection dynamic random access memory (Synchlink DRAM, SLDRAM) And direct memory bus random access memory (Direct Rambus RAM, DRRAM). The memories of the systems and methods described herein are intended to include, but are not limited to these and any other suitable types of memories.
而处理器可能是一种集成电路芯片,具有信号的处理能力。在实现过程中,上述方法的各步骤可以通过处理器中的硬件的集成逻辑电路或者软件形式的指令完成。上述的处理器可以是通用处理器、数字信号处理器(Digital Signal Processor,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现成可编程门阵列(Field Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器 件、分立硬件组件。可以实现或者执行本申请实施例中的公开的各方法、步骤及逻辑框图。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。结合本申请实施例所公开的方法的步骤可以直接体现为硬件译码处理器执行完成,或者用译码处理器中的硬件及软件模块组合执行完成。软件模块可以位于随机存储器,闪存、只读存储器,可编程只读存储器或者电可擦写可编程存储器、寄存器等本领域成熟的存储介质中。该存储介质位于存储器,处理器读取存储器中的信息,结合其硬件完成上述方法的步骤。The processor may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method may be completed by an integrated logic circuit of hardware in the processor or instructions in the form of software. The above-mentioned processor may be a general-purpose processor, a digital signal processor (Digital Signal Processor, DSP), an application specific integrated circuit (Application Specific Integrated Circuit, ASIC), an existing programmable gate array (Field Programmable Gate Array, FPGA), or other available Programming logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps, and logical block diagrams disclosed in the embodiments of the present application may be implemented or executed. The general-purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of the method disclosed in conjunction with the embodiments of the present application may be directly embodied and executed by a hardware decoding processor, or may be executed and completed by a combination of hardware and software modules in the decoding processor. The software module may be located in a mature storage medium in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, or electrically erasable programmable memory, and registers. The storage medium is located in the memory, and the processor reads the information in the memory and completes the steps of the above method in combination with its hardware.
可以理解的是,本文描述的这些实施例可以用硬件、软件、固件、中间件、微码或其组合来实现。对于硬件实现,处理单元可以实现在一个或多个专用集成电路(Application Specific Integrated Circuits,ASIC)、数字信号处理器(Digital Signal Processing,DSP)、数字信号处理设备(DSP Device,DSPD)、可编程逻辑设备(Programmable Logic Device,PLD)、现场可编程门阵列(Field-Programmable Gate Array,FPGA)、通用处理器、控制器、微控制器、微处理器、用于执行本申请所述功能的其它电子单元或其组合中。It can be understood that the embodiments described herein may be implemented in hardware, software, firmware, middleware, microcode, or a combination thereof. For hardware implementation, the processing unit can be implemented in one or more application specific integrated circuits (Application Specific Integrated Circuits, ASIC), digital signal processor (Digital Signal Processing, DSP), digital signal processing device (DSP Device, DSPD), programmable Logic device (Programmable Logic Device, PLD), field-programmable gate array (Field-Programmable Gate Array, FPGA), general-purpose processor, controller, microcontroller, microprocessor, others used to perform the functions described in this application Electronic unit or its combination.
对于软件实现,可通过执行本文所述功能的模块(例如过程、函数等)来实现本文所述的技术。软件代码可存储在存储器中并通过处理器执行。存储器可以在处理器中或在处理器外部实现。For software implementation, the techniques described herein may be implemented through modules (eg, procedures, functions, etc.) that perform the functions described herein. The software codes can be stored in the memory and executed by the processor. The memory may be implemented in the processor or external to the processor.
需要说明的是,在本文中,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者装置不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者装置所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括该要素的过程、方法、物品或者装置中还存在另外的相同要素。It should be noted that in this article, the terms "include", "include" or any other variant thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device that includes a series of elements includes not only those elements, It also includes other elements that are not explicitly listed, or include elements inherent to such processes, methods, objects, or devices. Without more restrictions, the element defined by the sentence "include one..." does not exclude that there are other identical elements in the process, method, article or device that includes the element.
上述本申请实施例序号仅仅为了描述,不代表实施例的优劣。The sequence numbers of the above embodiments of the present application are for description only, and do not represent the advantages and disadvantages of the embodiments.
通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到上述实施例方法可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件,但很多情况下前者是更佳的实施方式。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质(如ROM/RAM、磁碟、光盘)中,包括若干指令用以使得一台终端(可以是手机、计算机、服务器、或者网络设备等)执行本申请各个实施例所述的方法。Through the description of the above embodiments, those skilled in the art can clearly understand that the methods in the above embodiments can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware, but in many cases the former is better Implementation. Based on this understanding, the technical solutions of the present application can be embodied in the form of software products in essence or part of contributions to the existing technology, and the computer software products are stored in a storage medium (such as ROM/RAM, magnetic disk, The CD-ROM includes several instructions to enable a terminal (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the embodiments of the present application.
上面结合附图对本申请的实施例进行了描述,但是本申请并不局限于上述的具体实施方式,上述的具体实施方式仅仅是示意性的,而不是限制性的,本领域的普通技术人员在本申请的启示下,在不脱离本申请宗旨和权利要求所保护的范围情况下,还可做出很多形式,这些均属于本申请的保护之内。The embodiments of the present application have been described above with reference to the drawings, but the present application is not limited to the above-mentioned specific implementations. The above-mentioned specific implementations are only schematic, not limiting, and those of ordinary skill in the art Under the inspiration of this application, there are many forms that can be made without departing from the scope of the application and the scope of the claims, all of which fall within the protection of this application.
工业实用性Industrial applicability
本申请实施例中,在确定待编码图像帧在当前时刻的QP值考虑到了上一时刻性能参数的变化量,如此,结合性能参数的历史情况,得到的编码图像帧在当前时刻待的QP值更加精确,最后,根据待编码图像帧在当前时刻的QP值,对待编码图像帧在当前时刻进行编码;使得编码过程中不仅仅只是用预先设定的编码参数,还考虑到了编码器性能参数的变化量,这样,有利于提高编码过程中性能参数的控制精度,从而提高了编码过程中的编码性能。In the embodiment of the present application, when determining the QP value of the image frame to be encoded at the current time, the variation amount of the performance parameter at the previous time is taken into consideration. In this way, combined with the historical situation of the performance parameter, the obtained QP value of the encoded image frame at the current time is obtained More accurate. Finally, according to the QP value of the image frame to be encoded at the current time, the image frame to be encoded is encoded at the current time; making the encoding process not only uses the preset encoding parameters, but also takes into account the encoder performance parameters. The amount of change, in this way, is conducive to improving the control accuracy of the performance parameter during the encoding process, thereby improving the encoding performance during the encoding process.

Claims (24)

  1. 一种编码方法,其中,所述方法应用于编码器中,所述方法包括:An encoding method, wherein the method is applied to an encoder, the method includes:
    获取所述编码器在上一时刻的性能参数和待编码图像帧在上一时刻的量化参数QP值;Obtain the performance parameter of the encoder at the last moment and the quantization parameter QP value of the image frame to be encoded at the last moment;
    根据所述编码器的目标性能参数,确定所述编码器在当前时刻与上一时刻性能参数的变化量;According to the target performance parameter of the encoder, determine the change amount of the performance parameter of the encoder at the current time and the previous time;
    根据所述性能参数的变化量、所述编码器在上一时刻的性能参数和所述待编码图像帧在上一时刻的QP值,确定所述待编码图像帧在当前时刻的QP值;Determine the QP value of the image frame to be encoded at the current time according to the change amount of the performance parameter, the performance parameter of the encoder at the previous time and the QP value of the image frame to be encoded at the previous time;
    根据所述待编码图像帧在当前时刻的QP值,对当前时刻的所述待编码图像帧进行编码。According to the QP value of the image frame to be encoded at the current moment, encode the image frame to be encoded at the current moment.
  2. 根据权利要求1所述的方法,其中,当所述性能参数为图像帧的输出速率参数时,且所述图像帧的输出速率参数为输出比特率时,对应地,所述目标性能参数为目标输出比特率;The method according to claim 1, wherein, when the performance parameter is an output rate parameter of an image frame, and the output rate parameter of the image frame is an output bit rate, correspondingly, the target performance parameter is a target Output bit rate;
    所述根据所述编码器的目标性能参数,确定所述编码器在当前时刻与上一时刻性能参数的变化量,包括:The determining, according to the target performance parameter of the encoder, the amount of change in the performance parameter of the encoder at the current time and the previous time includes:
    根据所述编码器的目标输出比特率,确定所述编码器在当前时刻与上一时刻输出比特率的变化量。According to the target output bit rate of the encoder, the change amount of the output bit rate of the encoder at the current time and the previous time is determined.
  3. 根据权利要求2所述的方法,其中,所述根据所述编码器的目标输出比特率,确定所述编码器在当前时刻与上一时刻输出比特率的变化量,包括:The method according to claim 2, wherein the determining the amount of change in the output bit rate of the encoder at the current time and the previous time according to the target output bit rate of the encoder includes:
    获取上一时刻虚拟缓冲区的目标线;Get the target line of the virtual buffer at the last moment;
    获取当前时刻虚拟缓冲区的目标线;Get the target line of the virtual buffer at the current moment;
    根据上一时刻虚拟缓冲区的目标线和当前时刻虚拟缓冲区的目标线,确定所述编码器在当前时刻与上一时刻输出比特率的变化量;According to the target line of the virtual buffer at the previous time and the target line of the virtual buffer at the current time, determine the amount of change in the output bit rate of the encoder between the current time and the previous time;
    其中,所述虚拟缓冲区用于记录所述编码器的输出比特率超过所述目标输出比特率的值。Wherein, the virtual buffer is used to record a value that the output bit rate of the encoder exceeds the target output bit rate.
  4. 根据权利要求3所述的方法,其中,所述获取当前时刻虚拟缓冲区的目标线,包括:The method according to claim 3, wherein the acquiring the target line of the virtual buffer at the current moment comprises:
    确定所述待编码图像帧在当前时刻的编码结构类型;Determine the encoding structure type of the image frame to be encoded at the current moment;
    根据所述待编码图像帧在当前时刻的编码结构类型和所述编码器的目标输出比特率,确定当前时刻虚拟缓冲区的目标线。The target line of the virtual buffer at the current moment is determined according to the coding structure type of the image frame to be encoded at the current moment and the target output bit rate of the encoder.
  5. 根据权利要求4所述的方法,其中,所述根据所述待编码图像帧在当前时刻的编码结构类型和所述编码器的目标输出比特率,确定当前时刻虚拟缓冲区的目标线,包括:The method according to claim 4, wherein the determining the target line of the virtual buffer at the current moment according to the encoding structure type of the image frame to be encoded at the current moment and the target output bit rate of the encoder includes:
    若所述待编码图像帧在当前时刻的编码结构类型为全帧内AI结构时,确定当前时刻虚拟缓冲区的目标线均为零;If the coding structure type of the image frame to be coded at the current moment is an AI structure within a full frame, determine that the target lines of the virtual buffer at the current moment are all zero;
    若所述待编码图像帧在当前时刻的编码结构类型为低延时LD结构时,基于所述目标输出比特率,调用第一预设公式,确定当前时刻虚拟缓冲区的目标线;If the coding structure type of the image frame to be coded at the current moment is a low-latency LD structure, based on the target output bit rate, the first preset formula is called to determine the target line of the virtual buffer at the current moment;
    若所述待编码图像帧在当前时刻的编码结构类型为随机访问RA结构时,基于所述目标输出比特率,调用第二预设公式,确定当前时刻虚拟缓冲区的目标线。If the encoding structure type of the image frame to be encoded at the current moment is a random access RA structure, based on the target output bit rate, a second preset formula is called to determine the target line of the virtual buffer at the current moment.
  6. 根据权利要求4所述的方法,其中,所述根据上一时刻虚拟缓冲区目标线和当前时刻虚拟缓冲区目标线,确定所述编码器在当前时刻与上一时刻输出比特率的变化量,包括:The method according to claim 4, wherein the determining the amount of change in the output bit rate of the encoder at the current time and the previous time based on the virtual buffer target line at the previous time and the virtual buffer target line at the current time, include:
    获取当前时刻虚拟缓冲区的充盈程度;Get the filling level of the virtual buffer at the current moment;
    根据当前时刻虚拟缓冲区的充盈程度和上一时刻虚拟缓冲区的目标线,确定上一时刻虚拟缓冲区的误差;According to the filling degree of the virtual buffer at the current moment and the target line of the virtual buffer at the last moment, determine the error of the virtual buffer at the last moment;
    根据所述编码器在上一时刻的输出比特率和所述目标输出比特率,确定所述编码器在上一时刻的输出误差;Determine the output error of the encoder at the previous time according to the output bit rate of the encoder at the previous time and the target output bit rate;
    根据上一时刻虚拟缓冲区的误差、所述编码器在上一时刻的输出误差、上一时刻虚拟缓冲区的目标线和当前时刻虚拟缓冲区的目标线,确定所述编码器在当前时刻与上一时刻输出比特率的变化量;According to the error of the virtual buffer at the previous time, the output error of the encoder at the previous time, the target line of the virtual buffer at the previous time and the target line of the virtual buffer at the current time, determine that the encoder is at the current time and The output bit rate change at the last moment;
    调用第三预设公式更新当前时刻虚拟缓冲区的充盈程度。Call the third preset formula to update the filling level of the virtual buffer at the current moment.
  7. 根据权利要求6所述的方法,其中,所述根据上一时刻虚拟缓冲区的误差、所述编码器在上一时刻的输出误差、上一时刻虚拟缓冲区的目标线和当前时刻虚拟缓冲区的目标线,确定所述编码器在当前时刻与上一时刻输出比特率的变化量,包括:The method according to claim 6, wherein the error based on the virtual buffer at the previous time, the output error of the encoder at the previous time, the target line of the virtual buffer at the previous time, and the virtual buffer at the current time Target line to determine the output bit rate change of the encoder at the current time and the previous time, including:
    用当前时刻虚拟缓冲区的目标线,减去上一时刻虚拟缓冲区的目标线,减去上一时刻虚拟缓冲区的误差,减去所述编码器在上一时刻的输出误差得到的值,确定为所述编码器在当前时刻与上一时刻输出比特率的变化量。Using the target line of the virtual buffer at the current time, minus the target line of the virtual buffer at the previous time, minus the error of the virtual buffer at the previous time, and the value obtained by subtracting the output error of the encoder at the previous time, It is determined as the amount of change in the output bit rate of the encoder at the current time and the previous time.
  8. 根据权利要求1所述的方法,其中,当所述性能参数为图像帧的输出参数时,且该图像帧的输出速率参数为输出比特率时,对应地,目标性能参数为目标输出比特率;The method according to claim 1, wherein, when the performance parameter is an output parameter of an image frame, and the output rate parameter of the image frame is an output bit rate, correspondingly, the target performance parameter is the target output bit rate;
    对应地,所述根据所述性能参数的变化量、所述编码器在上一时刻的性能参数和所述待编码图像帧在上一时刻的QP值,确定所述待编码图像帧在当前时刻的QP值,包括:Correspondingly, according to the change amount of the performance parameter, the performance parameter of the encoder at the last moment and the QP value of the image frame to be encoded at the last moment, it is determined that the image frame to be encoded is at the current moment QP values, including:
    根据所述输出比特率的变化量、所述编码器在上一时刻的输出比特率和所述待编码图像帧在上一时刻的QP值,确定所述待编码图像帧在当前时刻的QP值。Determine the QP value of the image frame to be encoded at the current time according to the change amount of the output bit rate, the output bit rate of the encoder at the previous time and the QP value of the image frame to be encoded at the previous time .
  9. 根据权利要求8所述的方法,其中,所述根据所述输出比特率的变化量、所述编码器在上一时刻的输出比特率和所述待编码图像帧在上一时刻的QP值,确定所述待编码图像帧在当前时刻的QP值,包括:The method according to claim 8, wherein the change according to the output bit rate, the output bit rate of the encoder at the last moment, and the QP value of the image frame to be encoded at the last moment, Determining the QP value of the image frame to be encoded at the current moment includes:
    根据所述输出比特率的变化量和所述编码器在上一时刻的输出比特率,确定当前时刻的拉格朗日乘子与上一时刻的拉格朗日乘子的比值;Determine the ratio of the Lagrangian multiplier at the current time to the Lagrangian multiplier at the previous time according to the amount of change in the output bit rate and the output bit rate of the encoder at the previous time;
    根据当前时刻的拉格朗日乘子与上一时刻的拉格朗日乘子的比值,以及所述待编码图像帧在上一时刻的QP值,确定所述待编码图像帧在当前时刻的QP值。According to the ratio of the Lagrange multiplier at the current time to the Lagrange multiplier at the previous time, and the QP value of the image frame to be encoded at the previous time, determine the QP value.
  10. 根据权利要求9所述的方法,其中,所述根据所述输出比特率的变化量和所述编码器在上一时刻的输出比特率,确定当前时刻的拉格朗日乘子与上一时刻的拉格朗日乘子的比值中,通过下述公式计算当前时刻的拉格朗日乘子与上一时刻的拉格朗日乘子的比值:The method according to claim 9, wherein the Lagrange multiplier at the current time and the previous time are determined according to the amount of change in the output bit rate and the output bit rate of the encoder at the previous time In the ratio of the Lagrange multiplier of, calculate the ratio of the Lagrange multiplier at the current time to the Lagrange multiplier at the previous time by the following formula:
    Figure PCTCN2018118701-appb-100001
    Figure PCTCN2018118701-appb-100001
    其中,t表示时刻,λ为拉格朗日乘子,R为所述编码器输出比特率,ΔR为所述输出比特率的变化量,β为系数。Where t represents the time, λ is the Lagrangian multiplier, R is the output bit rate of the encoder, ΔR is the amount of change in the output bit rate, and β is the coefficient.
  11. 根据权利要求9所述的方法,其中,所述根据当前时刻的拉格朗日乘子与上一时刻的拉格朗日乘子的比值,以及所述待编码图像帧在上一时刻的QP值,确定所述待编码图像帧在当前时刻的QP值中,通过下述公式计算所述待编码图像帧在当前时刻的QP值:The method according to claim 9, wherein the ratio of the Lagrangian multiplier at the current time to the Lagrangian multiplier at the previous time, and the QP of the image frame to be coded at the previous time Value, determine the QP value of the image frame to be encoded at the current time, and calculate the QP value of the image frame to be encoded at the current time by the following formula:
    Figure PCTCN2018118701-appb-100002
    Figure PCTCN2018118701-appb-100002
    其中,t表示时刻,Q表示QP值,λ为拉格朗日乘子,a为常数。Among them, t represents time, Q represents QP value, λ is Lagrange multiplier, a is constant.
  12. 一种编码器,其中,所述编码器包括:An encoder, wherein the encoder includes:
    第一获取单元,用于获取所述编码器在上一时刻的性能参数和待编码图像帧在上一时刻的量化参数QP值;A first acquiring unit, configured to acquire the performance parameter of the encoder at the last moment and the quantization parameter QP value of the image frame to be encoded at the last moment;
    第一确定单元,用于根据所述编码器的目标性能参数,确定所述编码器在当前时刻与上一时刻性能参数的变化量;A first determining unit, configured to determine the change amount of the performance parameter of the encoder at the current time and the previous time according to the target performance parameter of the encoder;
    第二确定单元,用于根据所述性能参数的变化量、所述编码器在上一时刻的性能参数和所述待编码图像帧在上一时刻的QP值,确定所述待编码图像帧在当前时刻的QP值;The second determining unit is configured to determine that the image frame to be encoded is based on the change amount of the performance parameter, the performance parameter of the encoder at the previous time, and the QP value of the image frame to be encoded at the previous time QP value at the current moment;
    编码单元,用于根据所述待编码图像帧在当前时刻的QP值,对当前时刻的所述待编码图像帧进行编码。The encoding unit is configured to encode the image frame to be encoded at the current time according to the QP value of the image frame to be encoded at the current time.
  13. 根据权利要求12所述的编码器,其中,当所述性能参数为图像帧的输出速率参数时,且所述图像帧的输出速率参数为输出比特率时,对应地,所述目标性能参数为目标输出比特率;The encoder according to claim 12, wherein, when the performance parameter is an output rate parameter of an image frame, and the output rate parameter of the image frame is an output bit rate, correspondingly, the target performance parameter is Target output bit rate;
    所述第一确定单元,具体用于:根据所述编码器的目标输出比特率,确定所述编码器在当前时刻与上一时刻输出比特率的变化量。The first determining unit is specifically configured to: according to the target output bit rate of the encoder, determine the amount of change in the output bit rate of the encoder at the current time and the previous time.
  14. 根据权利要求13所述的编码器,其中,所述第一确定单元,包括:The encoder according to claim 13, wherein the first determining unit includes:
    第一获取子单元,用于获取上一时刻虚拟缓冲区的目标线;The first obtaining subunit is used to obtain the target line of the virtual buffer at the previous moment;
    第二获取子单元,用于获取当前时刻虚拟缓冲区的目标线;The second obtaining subunit is used to obtain the target line of the virtual buffer at the current moment;
    第一确定子单元,用于根据上一时刻虚拟缓冲区的目标线和当前时刻虚拟缓冲区的目标线,确定所述编码器在当前时刻与上一时刻输出比特率的变化量;The first determining subunit is used to determine the change amount of the output bit rate of the encoder between the current time and the previous time according to the target line of the virtual buffer at the previous time and the target line of the virtual buffer at the current time;
    其中,所述虚拟缓冲区用于记录所述编码器的输出比特率超过所述目标输出比特率的值。Wherein, the virtual buffer is used to record a value that the output bit rate of the encoder exceeds the target output bit rate.
  15. 根据权利要求14所述的编码器,其中,所述第二获取子单元,包括:The encoder according to claim 14, wherein the second acquisition subunit includes:
    第二确定子单元,用于确定所述待编码图像帧在当前时刻的编码结构类型;A second determining subunit, configured to determine the encoding structure type of the image frame to be encoded at the current moment;
    第三确定子单元,用于根据所述待编码图像帧在当前时刻的编码结构类型和所述编码器的目标输出比特率,确定当前时刻虚拟缓冲区的目标线。The third determining subunit is used to determine the target line of the virtual buffer at the current moment according to the encoding structure type of the image frame to be encoded at the current moment and the target output bit rate of the encoder.
  16. 根据权利要求15所述的编码器,其中,所述第三确定子单元,具体用于:The encoder according to claim 15, wherein the third determining subunit is specifically used for:
    若所述待编码图像帧在当前时刻的编码结构类型为全帧内AI结构时,确定当前时刻虚拟缓冲区的目标线均为零;If the coding structure type of the image frame to be coded at the current moment is an AI structure within a full frame, determine that the target lines of the virtual buffer at the current moment are all zero;
    若所述待编码图像帧在当前时刻的编码结构类型为低延时LD结构时,基于所述目标输出比特率,调用第一预设公式,确定当前时刻虚拟缓冲区的目标线;If the coding structure type of the image frame to be coded at the current moment is a low-latency LD structure, based on the target output bit rate, the first preset formula is called to determine the target line of the virtual buffer at the current moment;
    若所述待编码图像帧在当前时刻的编码结构类型为随机访问RA结构时,基于所述目标输出比特率,调用第二预设公式,确定当前时刻虚拟缓冲区的目标线。If the encoding structure type of the image frame to be encoded at the current moment is a random access RA structure, based on the target output bit rate, a second preset formula is called to determine the target line of the virtual buffer at the current moment.
  17. 根据权利要求14所述的编码器,其中,所述第一确定子单元,包括:The encoder according to claim 14, wherein the first determining subunit includes:
    第三获取子单元,用于获取当前时刻虚拟缓冲区的充盈程度;The third obtaining subunit is used to obtain the filling degree of the virtual buffer at the current moment;
    第四确定子单元,用于根据当前时刻虚拟缓冲区的充盈程度和上一时刻虚拟缓冲区的目标线,确定上一时刻虚拟缓冲区的误差;The fourth determining subunit is used to determine the error of the virtual buffer at the previous time according to the filling level of the virtual buffer at the current time and the target line of the virtual buffer at the previous time;
    第五确定子单元,用于根据所述编码器在上一时刻的输出比特率和所述目标输出比特率,确定所述编码器在上一时刻的输出误差;A fifth determining subunit, configured to determine the output error of the encoder at the previous time according to the output bit rate of the encoder at the previous time and the target output bit rate;
    第六确定子单元,用于根据上一时刻虚拟缓冲区的误差、所述编码器在上一时刻的输出误差、上一时刻虚拟缓冲区的目标线和当前时刻虚拟缓冲区的目标线,确定所述编码器在当前时刻与上一时刻输出比特率的变化量;The sixth determining subunit is used to determine the error of the virtual buffer at the previous time, the output error of the encoder at the previous time, the target line of the virtual buffer at the previous time and the target line of the virtual buffer at the current time The encoder outputs the amount of change in the bit rate at the current time and the previous time;
    更新子单元,用于调用第三预设公式更新当前时刻虚拟缓冲区的充盈程度。The update subunit is used to call the third preset formula to update the filling degree of the virtual buffer at the current moment.
  18. 根据权利要求17所述的编码器,其中,所述第六确定子单元,具体用于:The encoder according to claim 17, wherein the sixth determining subunit is specifically used for:
    用当前时刻虚拟缓冲区的目标线,减去上一时刻虚拟缓冲区的目标线,减去上一时刻虚拟缓冲区的误差,减去所述编码器在上一时刻的输出误差得到的值,确定为所述编码器在当前时刻与上一时刻输出比特率的变化量。Using the target line of the virtual buffer at the current time, minus the target line of the virtual buffer at the previous time, minus the error of the virtual buffer at the previous time, and the value obtained by subtracting the output error of the encoder at the previous time, It is determined as the amount of change in the output bit rate of the encoder at the current time and the previous time.
  19. 根据权利要求12所述的编码器,其中,当所述性能参数为图像帧的输出参数时,且该图像帧的输出速率参数为输出比特率时,对应地,目标性能参数为目标输出比特率;The encoder according to claim 12, wherein, when the performance parameter is an output parameter of an image frame, and the output rate parameter of the image frame is an output bit rate, correspondingly, the target performance parameter is the target output bit rate ;
    所述第二确定单元,具体用于:The second determining unit is specifically used for:
    根据所述输出比特率的变化量、所述编码器在上一时刻的输出比特率和所述待编码图像帧在上一时刻的QP值,确定所述待编码图像帧在当前时刻的QP值。Determine the QP value of the image frame to be encoded at the current time according to the change amount of the output bit rate, the output bit rate of the encoder at the previous time and the QP value of the image frame to be encoded at the previous time .
  20. 根据权利要求19所述的编码器,其中,所述第二确定单元,包括:The encoder according to claim 19, wherein the second determining unit includes:
    第七确定子单元,用于根据所述输出比特率的变化量和所述编码器在上一时刻的输出比特率,确定当前时刻的拉格朗日乘子与上一时刻的拉格朗日乘子的比值;The seventh determining subunit is used to determine the Lagrangian multiplier at the current time and the Lagrangian at the previous time according to the change amount of the output bit rate and the output bit rate of the encoder at the previous time Ratio of multipliers;
    第八确定子单元,用于根据当前时刻的拉格朗日乘子与上一时刻的拉格朗日乘子的比值,以及所述待编码图像帧在上一时刻的QP值,确定所述待编码图像帧在当前时刻的QP值。The eighth determining subunit is used to determine the ratio of the Lagrange multiplier at the current time to the Lagrange multiplier at the previous time and the QP value of the image frame to be encoded at the previous time QP value of the image frame to be encoded at the current moment.
  21. 根据权利要求20所述的编码器,其中,所述第七确定子单元,具体用于:The encoder according to claim 20, wherein the seventh determining subunit is specifically used for:
    通过下述公式计算当前时刻的拉格朗日乘子与上一时刻的拉格朗日乘子的比值:Calculate the ratio of the Lagrange multiplier at the current moment to the Lagrange multiplier at the previous moment by the following formula:
    Figure PCTCN2018118701-appb-100003
    Figure PCTCN2018118701-appb-100003
    其中,t表示时刻,λ为拉格朗日乘子,R为所述编码器输出比特率,ΔR为所述输出比特率的变化量,β为系数。Where t represents the time, λ is the Lagrangian multiplier, R is the output bit rate of the encoder, ΔR is the amount of change in the output bit rate, and β is the coefficient.
  22. 根据权利要求20所述的编码器,其中,所述第八确定子单元,具体用于:The encoder according to claim 20, wherein the eighth determining subunit is specifically used for:
    通过下述公式计算所述待编码图像帧在当前时刻的QP值:The QP value of the image frame to be encoded at the current moment is calculated by the following formula:
    Figure PCTCN2018118701-appb-100004
    Figure PCTCN2018118701-appb-100004
    其中,t表示时刻,Q表示QP值,λ为拉格朗日乘子,a为常数。Among them, t represents time, Q represents QP value, λ is Lagrange multiplier, a is constant.
  23. 一种编码器,其中,所述编码器包括:An encoder, wherein the encoder includes:
    处理器以及存储有所述处理器可执行指令的存储介质,所述存储介质通过通信总线依赖所述处理器执行操作,当所述指令被所述处理器执行时,执行上述的权利要求1至11任一项所述的编码方法。A processor and a storage medium storing instructions executable by the processor, the storage medium relies on the processor to perform operations through a communication bus, and when the instructions are executed by the processor, the foregoing claims 1 to 11. The encoding method according to any one of the items.
  24. 一种计算机存储介质,其中,存储有可执行指令,当所述可执行指令被一个或多个处理器执行的时候,所述处理器执行所述的权利要求1至11任一项所述的编码方法。A computer storage medium, wherein executable instructions are stored, and when the executable instructions are executed by one or more processors, the processor executes any one of claims 1 to 11 Encoding method.
PCT/CN2018/118701 2018-11-30 2018-11-30 Coding method, coder and computer storage medium WO2020107449A1 (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
PCT/CN2018/118701 WO2020107449A1 (en) 2018-11-30 2018-11-30 Coding method, coder and computer storage medium
CN201880097326.7A CN112655207A (en) 2018-11-30 2018-11-30 Encoding method, encoder, and computer storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2018/118701 WO2020107449A1 (en) 2018-11-30 2018-11-30 Coding method, coder and computer storage medium

Publications (1)

Publication Number Publication Date
WO2020107449A1 true WO2020107449A1 (en) 2020-06-04

Family

ID=70852697

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/118701 WO2020107449A1 (en) 2018-11-30 2018-11-30 Coding method, coder and computer storage medium

Country Status (2)

Country Link
CN (1) CN112655207A (en)
WO (1) WO2020107449A1 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117294316B (en) * 2023-11-24 2024-03-26 北京邮电大学 BCH code-based coupling structure zipper code encoding and decoding method and system

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101340575A (en) * 2007-07-03 2009-01-07 英华达(上海)电子有限公司 Method and terminal for dynamically regulating video code
CN101420601A (en) * 2008-06-06 2009-04-29 浙江大学 Method and device for code rate control in video coding
CN102355584A (en) * 2011-10-31 2012-02-15 电子科技大学 Code rate control method based on intra-frame predictive coding modes
CN104079933A (en) * 2014-07-09 2014-10-01 上海君观信息技术有限公司 Low-latency code rate control method and bit number distribution method suitable for HEVC
CN104113761A (en) * 2013-04-19 2014-10-22 北京大学 Code rate control method for video encoding and encoder

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7453938B2 (en) * 2004-02-06 2008-11-18 Apple Inc. Target bitrate estimator, picture activity and buffer management in rate control for video coder
CN102724510B (en) * 2012-06-21 2014-05-28 中科开元信息技术(北京)有限公司 Code rate control algorithm based on fullness degree of virtual encoding buffer area
CN106231320B (en) * 2016-08-31 2020-07-14 上海交通大学 Joint code rate control method and system supporting multi-machine parallel coding

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101340575A (en) * 2007-07-03 2009-01-07 英华达(上海)电子有限公司 Method and terminal for dynamically regulating video code
CN101420601A (en) * 2008-06-06 2009-04-29 浙江大学 Method and device for code rate control in video coding
CN102355584A (en) * 2011-10-31 2012-02-15 电子科技大学 Code rate control method based on intra-frame predictive coding modes
CN104113761A (en) * 2013-04-19 2014-10-22 北京大学 Code rate control method for video encoding and encoder
CN104079933A (en) * 2014-07-09 2014-10-01 上海君观信息技术有限公司 Low-latency code rate control method and bit number distribution method suitable for HEVC

Also Published As

Publication number Publication date
CN112655207A (en) 2021-04-13

Similar Documents

Publication Publication Date Title
US11523124B2 (en) Coded-block-flag coding and derivation
TW295765B (en)
US20060062481A1 (en) Apparatuses, computer program product and method for bit rate control of digital image encoder
EP2769553B1 (en) Rate-distortion-complexity optimization of video encoding
JP2011055504A (en) Picture-level rate control for video encoding
WO2018113191A1 (en) Bit rate control method and device
ITTO20090486A1 (en) DYNAMIC CONTROLLER OF INDEPENDENT TRANSMISSION SPEED FROM THE GROUP OF IMAGES
CN107846590B (en) Video coding method and video coder
TWI743098B (en) Apparatus and methods for adaptive calculation of quantization parameters in display stream compression
US9667981B2 (en) Rate control for content transcoding
US8483272B2 (en) System and method for frame level bit rate control without pre-analysis
CN101795415A (en) Method and device for controlling code rate in video coding
CN102761741A (en) Video encoding code rate control system and method on basis of caches at encoding and decoding ends
CN105681793A (en) Very-low delay and high-performance video coding intra-frame code rate control method based on video content complexity adaption
CN112738516B (en) Encoding method, encoding device, storage medium and electronic equipment
TWI734865B (en) Method and encoder system for encoding video
US20240040127A1 (en) Video encoding method and apparatus and electronic device
WO2020107449A1 (en) Coding method, coder and computer storage medium
KR20170126934A (en) Content-Adaptive B-Picture Pattern Video Encoding
US7805014B2 (en) Image-encoding controlling apparatus for using a table reflecting statistical frequency of quantization parameter selection and method thereof
TWI405467B (en) Bit rate control circuit and method for image compression
Mys et al. Decoder-driven mode decision in a block-based distributed video codec
US9756344B2 (en) Intra refresh method for video encoding and a video encoder for performing the same
CN114071142A (en) Code rate control method and device based on hardware encoder
TWI301724B (en) Bit rate automatic gear

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: 18941541

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: 18941541

Country of ref document: EP

Kind code of ref document: A1