WO2020172813A1 - Rate distortion optimization method and apparatus, and computer-readable storage medium - Google Patents

Rate distortion optimization method and apparatus, and computer-readable storage medium Download PDF

Info

Publication number
WO2020172813A1
WO2020172813A1 PCT/CN2019/076305 CN2019076305W WO2020172813A1 WO 2020172813 A1 WO2020172813 A1 WO 2020172813A1 CN 2019076305 W CN2019076305 W CN 2019076305W WO 2020172813 A1 WO2020172813 A1 WO 2020172813A1
Authority
WO
WIPO (PCT)
Prior art keywords
image
bit rate
frame
encoded
coding
Prior art date
Application number
PCT/CN2019/076305
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 CN201980073133.2A priority Critical patent/CN112970254B/en
Priority to PCT/CN2019/076305 priority patent/WO2020172813A1/en
Publication of WO2020172813A1 publication Critical patent/WO2020172813A1/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/134Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the element, parameter or criterion affecting or controlling the adaptive coding
    • H04N19/146Data rate or code amount at the encoder output
    • H04N19/147Data rate or code amount at the encoder output according to rate distortion criteria

Definitions

  • the embodiments of the present application relate to video coding technology, and in particular to a method and device for optimizing rate-distortion, and a computer-readable storage medium.
  • the rate-distortion optimization technique is a technique widely used in video coding.
  • the rate-distortion optimization technique selects a set of parameters in the encoding parameter set so that the encoding result can obtain the smallest image distortion at a limited bit rate.
  • the current rate-distortion optimization of video coding is performed under the assumption that the coding units are independent, and the Lagrangian multiplier method is used to obtain unlimited coding cost.
  • the cost function: min ⁇ J D+ ⁇ R ⁇ to get the coding cost, so as to select the best coding mode among multiple coding modes, and use the best coding mode for video coding; where J represents the coding cost, and ⁇ is the introduced Lager Lange multiplier, D represents the distortion of the reconstructed image, and R represents the coding bit rate.
  • the value of ⁇ is calculated by setting the first-order differential of the cost function to be constant at zero.
  • the distortion of the image is related to the quantization step size, and the Lagrangian is finally obtained.
  • the daily multiplier ⁇ is a quantity that is only positively correlated with the square of the quantization step.
  • an image is divided into several equal-sized coding blocks, namely coding units.
  • the square of the quantization step size is constant, all coding units in an image will share a pre-calculated ⁇ value. This is somewhat different from the actual different coding units corresponding to different Lagrangian multipliers. That is to say, the estimation of the coding cost of different coding units of a frame of image is inaccurate when using the existing ⁇ . The problem leads to inaccurate rate distortion estimation, which affects the coding efficiency of the image.
  • the embodiments of the present application provide a rate-distortion optimization method and device, and a computer-readable storage medium, which can improve coding efficiency.
  • An embodiment of the present application provides a rate-distortion optimization method, including:
  • the initial Lagrangian multiplier, the encoding unit-level encoding bit rate of the image to be encoded in the previous frame, and the encoding unit of the image to be encoded in the previous frame are acquired Estimated Lagrange multiplier of the order;
  • the coding unit-level coding bit rate of the image to be coded in the previous frame and the estimated Lagrangian multiplier and pre-coding unit level of the image to be coded in the previous frame
  • the coding bit rate and the estimated Lagrangian multiplier model to obtain the estimated Lagrangian multiplier at the coding unit level of the image to be coded in the current frame
  • the estimated Lagrangian multiplier at the coding unit level of the image to be encoded in the current frame is used to perform rate-distortion processing of the image to be encoded in the current frame to complete the encoding of the image to be encoded in the current frame.
  • the initial Lagrangian multiplier the encoding unit-level encoding bit rate of the image to be encoded in the previous frame, and the previous image are acquired.
  • the estimated Lagrangian multiplier at the coding unit level of the frame to be encoded includes:
  • the i-th coding unit of the image to be encoded in the current frame is acquired.
  • the coding bit rate of i coding units and the estimated Lagrangian multiplier of the i-th coding unit of the image to be coded in the previous frame where i is a positive integer greater than or equal to 1 and less than or equal to N, and N is a frame to be coded.
  • the coding unit-level coding bit rate of the image to be coded in the previous frame, and the coding unit-level estimation of the image to be coded in the previous frame are adjusted according to the initial Lagrangian multiplier,
  • the Grange multiplier, the preset coding bit rate and the estimated Lagrangian multiplier model to obtain the estimated Lagrangian multiplier at the coding unit level of the image to be coded in the current frame includes:
  • the coding bit rate of the i-th coding unit of the image to be coded in the previous frame, and the estimated Lagrangian of the i-th coding unit of the image to be coded in the previous frame A multiplier and the preset encoding bit rate and an estimated Lagrangian multiplier model to obtain an estimated Lagrangian multiplier of the i-th coding unit of the image to be encoded in the current frame;
  • the estimated Lagrangian multiplier at the coding unit level of the image to be encoded in the current frame is used to perform rate-distortion processing of the image to be encoded in the current frame to complete the image to be encoded in the current frame
  • the encoding includes:
  • the rate-distortion processing of the image to be encoded further completes the encoding of the image to be encoded in the current frame.
  • the coding unit-level coding bit rate of the image to be coded in the previous frame, and the coding unit-level estimation of the image to be coded in the previous frame are adjusted according to the initial Lagrangian multiplier, Before the Grange multiplier and the preset coding bit rate and the estimated Lagrangian multiplier model are used to obtain the estimated Lagrangian multiplier at the coding unit level of the image to be coded in the current frame, the method further includes:
  • the preset frame-level coding bit rate model is used to obtain the preset coding bit rate and the estimated Lagrangian multiplier model.
  • the preset frame-level coding bit rate model, the preset temporal proximity approximate coding bit rate model, and the pre-coding bit rate model are based on the initial coding bit rate and the Lagrangian multiplier model.
  • Supposing the temporal proximity approximate frame-level coding bit rate model, obtaining the preset coding bit rate and the estimated Lagrangian multiplier model includes:
  • the theoretical coding bit rate and estimated Lagrangian multiplier model of the coding unit and the actual coding bit rate and estimated Lagrangian multiplier model of the coding unit are derived ;
  • the preset temporal proximity approximate coding bit rate model the preset temporal proximity approximate frame-level coding bit rate model, and the actual frame of one frame Level coding bit rate model to obtain the preset coding bit rate and the estimated Lagrangian multiplier model.
  • the method further includes:
  • the initial Lagrangian multiplier is used to perform rate-distortion processing of the image to be encoded in the current frame, thereby completing the encoding of the image to be encoded in the current frame.
  • the estimated Lagrangian multiplier at the coding unit level of the image to be encoded in the current frame is used to perform rate-distortion processing of the image to be encoded in the current frame to complete the image to be encoded in the current frame
  • the method further includes:
  • the encoding of the image to be encoded until the last frame of the video sequence to be encoded is processed.
  • An embodiment of the present application provides a rate-distortion optimization device, including:
  • a processor a memory storing a rate-distortion optimization instruction executable by the processor, and a communication bus for connecting the processor and the memory, and when the rate-distortion optimization instruction is executed, the above-mentioned rate distortion is realized Optimization.
  • An embodiment of the present application provides a computer-readable storage medium on which a rate-distortion optimization instruction is stored, where the rate-distortion optimization instruction is executed by a processor to implement the above-mentioned rate-distortion optimization method.
  • the rate-distortion optimization device performs rate-distortion optimization processing on the image to be encoded in the current frame.
  • the encoding unit level of the image to be encoded in the previous frame that has been encoded can be used.
  • the coding bit rate and the estimated Lagrangian multiplier are combined with the preset coding bit rate and the estimated Lagrangian multiplier model to obtain the estimated Lagrangian multiplier at the coding unit level of the image to be coded in the current frame, and then Realize the rate-distortion optimization processing and encoding, because the rate-distortion optimization device can intervene in the estimated Lagrangian of all coding units of the image to be encoded in the current frame based on the bit rate of the image to be encoded in the previous frame and the estimated Lagrangian multiplier
  • the multiplier of the day interferes with the balance of the bit distribution of the coding unit within the frame, thereby improving the coding efficiency.
  • FIG. 1 is a first flowchart of a rate-distortion optimization method provided by an embodiment of this application;
  • FIG. 2 is a second flowchart of a rate-distortion optimization method provided by an embodiment of the application
  • Figure 3 is an exemplary current frame to-be-encoded image provided by an embodiment of the application.
  • FIG. 4 is a schematic diagram of encoding after turning off the exemplary rate-distortion optimization method provided by the present application
  • FIG. 5 is a schematic diagram of encoding after the exemplary rate-distortion optimization method provided by the present application is turned on;
  • Fig. 6 is an analysis diagram of coding unit division after closing the exemplary rate-distortion optimization method provided by the present application
  • FIG. 7 is an analysis diagram of coding unit division after the exemplary rate-distortion optimization method provided by the present application is turned on;
  • FIG. 8 is a diagram showing the division and analysis of two coding units after the rate-distortion optimization method provided by the present application is turned off;
  • FIG. 9 is an analysis diagram of the division of two coding units after the rate-distortion optimization method provided by the present application is turned on;
  • FIG. 10 is a first structural diagram of a rate-distortion optimization device provided by an embodiment of the application.
  • FIG. 11 is a second structural diagram of a rate-distortion optimization apparatus provided by an embodiment of the application.
  • the rate-distortion optimization method is applied in the video encoding process.
  • Video coding methods including prediction, transformation, quantization and entropy coding.
  • the prediction method includes intra-frame prediction and inter-frame prediction, and the coding mode, motion vector, and reconstruction data in the prediction information of the current coding unit are used to assist in predicting the subsequent coding unit.
  • the embodiments of this application due to the extensive use of temporal prediction technology, there is a strong correlation between coding units, that is, the coding performance of the current coding unit will affect the encoding of subsequent coding units. Therefore, the embodiments of this application are based on time. The idea of domain proximity is used to obtain the optimal Lagrangian multiplier to realize the rate-distortion optimization method.
  • rate-distortion optimization device provided in the embodiment of the present application may be an encoder, which is not limited in the embodiment of the present application.
  • the embodiment of the present application provides a rate-distortion optimization method. As shown in FIG. 1, the method may include:
  • the image to be encoded in the current frame is not the first frame to be encoded, acquire the initial Lagrangian multiplier, the encoding unit-level encoding bit rate of the image to be encoded in the previous frame, and the encoding unit of the image to be encoded in the previous frame Estimated Lagrange multiplier of the order;
  • the rate-distortion optimization apparatus may perform rate-distortion optimization processing for the frame-level coding unit, and then select the image of each frame in the video sequence to be encoded.
  • the optimal coding mode of each coding unit adopts the optimal coding mode to encode each coding unit of each frame of the image to be coded, thereby completing the coding of the video sequence to be coded.
  • the most important process of the rate-distortion optimization device for the rate-distortion optimization of each coding unit is the process of obtaining the Lagrangian multiplier corresponding to each coding unit.
  • the rate-distortion optimization apparatus obtains the current frame to be encoded image in the to-be-encoded video sequence, where the current frame to be encoded image may be the first frame to be encoded image or the non-first frame to be encoded image.
  • coding units which are the basic units of coding.
  • the coding unit represents the local information of the image. If the spatial correlation between the coding units is not considered, the sum of the cost of all the coding units in an image can be regarded as the cost of the entire image. Therefore, the rate-distortion optimization problem in the embodiment of the present application can be solved at the coding unit level.
  • the rate-distortion optimization apparatus uses the system Lagrangian multiplier (ie, the initial Lagrangian multiplier) as the first frame to be encoded for the first frame of the image to be encoded in the video sequence to be encoded.
  • Lagrangian multiplier ie, the initial Lagrangian multiplier
  • Each coding unit in the coded image corresponds to the Lagrangian multiplier
  • the rate-distortion optimization device regards the current frame to be coded as a non-first frame to be coded, and uses the coded bits of the image to be coded adjacent to the time domain Rate and estimate the Lagrangian multiplier (the Lagrangian multiplier actually used in the previous frame) to calculate the Lagrangian multiplier corresponding to each coding unit in the image to be encoded in the current frame.
  • the rate-distortion optimization device obtains the initial Lagrangian multiplier, the encoding unit-level encoding bit rate of the image to be encoded in the previous frame, and The estimated Lagrangian multiplier at the coding unit level of the image to be coded in the previous frame, so that the initial Lagrangian multiplier, the coding unit-level coding bit rate of the image to be coded in the previous frame and the previous frame to be coded are subsequently used.
  • the estimated Lagrangian multiplier at the coding unit level of the image acquires the Lagrangian multiplier of the coding unit of the image to be coded in the current frame.
  • the initial Lagrangian multiplier in the embodiment of the present application can be obtained according to a preset Lagrangian multiplier model.
  • the preset Lagrangian multiplier model is formula (1), as follows:
  • c is a constant, taking an empirical value
  • is the initial Lagrangian multiplier, that is, the system Lagrangian multiplier
  • q step represents the quantization step length
  • the acquisition process of the preset Lagrangian multiplier model may be as follows:
  • the embodiment of the application adopts the Lagrangian method.
  • the value of ⁇ is calculated by setting the first-order differential of the cost function to be constant, as shown in formula (2):
  • D represents the distortion of the reconstructed image
  • J represents the cost of encoding
  • R represents the encoding bit rate, which can also be understood as the number of bits for encoding a unit.
  • q step represents the quantization step length, which is uniquely determined by the quantization parameter.
  • is used to indicate the intensity of image changes.
  • formula (1) of the preset Lagrangian multiplier model can be derived.
  • c can be obtained through experience or experiment.
  • c is 0.85, which is not limited in the embodiments of the present application.
  • is a quantity that is only positively correlated with the square of the quantization step size. Since the quantization step q step is uniquely determined by the quantization parameter QP, when the quantization parameter QP is given, the value of ⁇ will be directly calculated.
  • the initial Lagrangian multiplier ⁇ sys is calculated according to formula (1) when the quantization parameter QP of the coding system is determined.
  • the rate-distortion optimization device when the rate-distortion optimization device is processing the image to be encoded in the current frame, the encoding of the image to be encoded in the previous frame has been completed, and the rate-distortion processing and encoding process are performed in each frame of the image to be encoded.
  • the rate-distortion optimization device can record the encoding bit rate of each coding unit of each frame of the image to be encoded and estimate the Lagrangian multiplier. Therefore, the rate-distortion optimization device can process the image to be encoded in the current frame. , You can directly obtain the coding unit-level coding bit rate of the image to be coded in the previous frame and the estimated Lagrangian multiplier at the coding unit level of the image to be coded in the previous frame.
  • the image to be encoded in the current frame is represented as the image to be encoded at time t, then the encoding unit-level encoding bit rate of the image to be encoded in the previous frame is Indicates that the estimated Lagrangian multiplier of the coding unit level of the image to be coded in the previous frame adopts It means that the embodiments of this application are not limited.
  • the rate-distortion optimization device obtains the initial Lagrangian multiplier, the coding unit-level coding bit rate of the image to be encoded in the previous frame, and the estimated Lagrangian coefficient at the coding unit level of the image to be encoded in the previous frame.
  • the parameters obtained above can be combined with the preset encoding bit rate and the estimated Lagrangian multiplier model to obtain the estimated Lagrangian multiplier at the coding unit level of the image to be encoded in the current frame.
  • the preset encoding bit rate and the estimated Lagrangian multiplier model are R- ⁇ models, and the preset encoding bit rate and the estimated Lagrangian multiplier model are the sum of the encoded bits of the frame-level coding unit. Approximate the optimal estimation of the correspondence between Lagrangian multipliers.
  • the preset coding bit rate and the estimated Lagrangian multiplier model can be expressed as formula (5), as follows:
  • ⁇ sys represents the initial Lagrangian multiplier
  • represents the model parameter, which is determined by data fitting.
  • the preset coding bit rate and the estimated Lagrangian multiplier model represent the R- ⁇ model between the coding units to be coded adjacent in the time domain.
  • the rate-distortion optimization device can determine the Lagrangian multiplier of the corresponding coding unit of the current frame through the coded coding unit of the previous frame. Since the Lagrangian multiplier ⁇ is the first derivative of the image distortion and the encoding bit rate, its physical meaning is the slope of the rate-distortion curve (R-D curve) at a given point (R, D).
  • the rate-distortion optimization device calculates Lagrangian multipliers for each coding unit of the current frame of the image to be coded by analyzing the bit distribution characteristics of the image to be coded in the previous frame that has been coded, aiming to control the bit consumption of the coding unit in a targeted manner , Improve the overall coding efficiency of the image to be coded in the current frame.
  • the rate-distortion optimization device can use the coding unit-level estimation of the image to be coded in the current frame.
  • the Grange multiplier performs rate-distortion processing of the image to be encoded in the current frame, selects the best encoding mode of the encoding unit, and then uses the best encoding mode to encode the encoding unit to complete the encoding of the image to be encoded in the current frame.
  • the rate-distortion optimization device uses a cost function to perform rate-distortion processing on the image to be encoded in the current frame to obtain the encoding cost, and compare the encoding costs in different encoding modes according to the encoding cost to select the smallest cost The best encoding mode.
  • the cost function can be expressed as formula (6), as follows:
  • J i represents the coding cost of the i-th coding unit in a frame of image to be coded
  • ⁇ i represents the Lagrangian multiplier of the i-th coding unit in a frame of image to be coded
  • D i represents a frame of image to be coded
  • R i represents the coding bit rate of the i-th coding unit in a frame of image to be coded.
  • the estimated Lagrangian multiplier at the coding unit level of the image to be coded in the current frame is used to perform rate-distortion processing for each coding unit of the image to be coded in the current frame to obtain the coding cost, thereby completing the current frame
  • the encoding of the image to be encoded is used to perform rate-distortion processing for each coding unit of the image to be coded in the current frame to obtain the coding cost, thereby completing the current frame The encoding of the image to be encoded.
  • the rate-distortion optimization device performs rate-distortion optimization processing on the image to be encoded in the current frame.
  • the encoding unit-level encoding bit rate of the image to be encoded in the previous frame that has been encoded can be used to estimate the bit rate.
  • the Grange multiplier combines the preset coding bit rate and the estimated Lagrangian multiplier model to obtain the estimated Lagrangian multiplier at the coding unit level of the image to be coded in the current frame, thereby realizing the rate-distortion optimization processing, Realize encoding, because the rate-distortion optimization device can intervene in the estimated Lagrangian multipliers of all coding units of the image to be encoded in the current frame based on the bit rate of the image to be encoded in the previous frame and the estimated Lagrangian multiplier, thereby intervening in the frame
  • the bit distribution of the inner coding unit tends to be balanced, thereby improving the coding efficiency.
  • the specific implementation process includes: S201-S205. as follows:
  • S201 Acquire an image to be encoded in the current frame.
  • the image to be encoded in the current frame is not the first image to be encoded, obtain the i-th coding unit of the image to be encoded in the current frame, the initial Lagrangian multiplier, and the i-th encoding unit of the image to be encoded in the previous frame.
  • the coding bit rate and the estimated Lagrangian multiplier of the i-th coding unit of the image to be coded in the previous frame where i is a positive integer greater than or equal to 1 and less than or equal to N, and N is the corresponding to a frame of image to be coded The total number of coding units.
  • the estimated Lagrangian multiplier of the i-th coding unit of the image to be coded in the current frame is obtained.
  • the rate-distortion optimization device after the rate-distortion optimization device obtains the image to be encoded in the current frame of the video sequence to be encoded, it can process each coding unit in the image to be encoded in the current frame. Is the image to be encoded in the non-first frame, the rate-distortion optimization device obtains the encoding bit rate of the i-th coding unit of the image to be encoded in the current frame, the initial Lagrangian multiplier, and the encoding bit rate of the i-th encoding unit of the image to be encoded in the previous frame And the estimated Lagrangian multiplier of the i-th coding unit of the image to be coded in the previous frame, based on the relevant parameters of the corresponding i-th coding unit of the image to be coded in the previous frame, to obtain the i-th coding unit of the image to be coded in the current frame
  • the estimated Lagrangian multiplier of a coding unit is used to realize rate-distortion processing and
  • each frame of image to be encoded can be divided into N coding units. Therefore, there may be N coding units in the image to be encoded in the current frame. Starting from the first coding unit and proceeding to the Nth coding unit in sequence, the processing of the coding cost of the image to be coded in the current frame is completed, the best coding mode is selected, and the coding of the image to be coded in the current frame is performed.
  • i is a positive integer greater than or equal to 1 and less than or equal to N
  • N is the total number of coding units corresponding to a frame of image to be encoded.
  • the rate-distortion optimization device for the i-th coding unit of the unit to be coded in the current frame is based on the initial Lagrangian multiplier and the coding bit rate of the i-th coding unit of the image to be coded in the previous frame ,
  • the estimated Lagrangian multiplier and preset coding bit rate and estimated Lagrangian multiplier model of the i-th coding unit of the image to be encoded in the previous frame that is, according to formula (5) to obtain the image of the current frame to be encoded
  • the estimated Lagrangian multiplier of the i-th coding unit is obtained.
  • the i-th coding unit can be rate-distorted Processing and encoding, so as to obtain the encoding bit rate of the i-th coding unit of the image to be encoded in the current frame, so that the rate-distortion optimization device can use the encoding bit rate of the i-th encoding unit of the image to be encoded in the current frame and the current frame to be encoded
  • the estimated Lagrangian multiplier of the i-th coding unit of the image is obtained, and the estimated Lagrangian multiplier of the i+1-th coding unit of the image to be coded in the current frame is obtained, that is, i is increased by 1, and the current frame is waiting
  • the rate-distortion optimization device adopts such a loop implementation method until the estimated Lagrangian of the Nth coding unit of the image
  • the rate-distortion optimization device uses the estimated Lagrangian multiplier of the first coding unit of the image to be coded in the current frame to the estimated Lagrangian multiplier of the Nth coding unit of the image to be coded in the current frame to perform the current frame waiting
  • the rate-distortion processing of each coding unit of the coded image completes the coding of the image to be coded in the current frame.
  • each encoding unit thereof is encoded according to the process of S201-S205.
  • the rate-distortion optimization device uses the estimated Lagrangian multiplier of the frame-level coding unit to perform rate-distortion processing, and the rate-distortion optimization device can be based on the bit rate of the previous frame to be encoded and the estimated pull
  • the Grange multiplier interferes with the estimated Lagrange multiplier of all coding units of the image to be coded in the current frame, thereby interfering with the bit distribution of the coding unit in the frame to balance, thereby improving the coding efficiency.
  • a rate-distortion optimization method provided in an embodiment of the present application further includes: S105 and S106. as follows:
  • the preset frame-level coding bit rate model, the preset time-domain proximity approximate coding bit rate model, and the preset time-domain proximity approximate frame-level coding bit rate model obtain Preset encoding bit rate and estimated Lagrangian multiplier model.
  • the rate-distortion optimization apparatus obtains the preset coding bit rate and the estimated Lagrangian multiplier model by first obtaining the known initial coding bit rate and the Lagrangian multiplier model , Preset frame-level coding bit rate model, preset time-domain proximity approximate coding bit rate model, and preset time-domain proximity approximate frame-level coding bit rate model; then based on the above known model, the preset coding bit rate and estimate Lagrange multiplier model formula (5).
  • the rate-distortion optimization device is based on the initial encoding bit rate and the Lagrangian multiplier model, the preset frame-level encoding bit rate model, the preset temporal proximity approximate encoding bit rate model, and the preset timing.
  • the domain proximity approximates the frame-level coding bit rate model, the process of obtaining the preset coding bit rate and the estimated Lagrangian multiplier model includes: S1061-S1064. as follows:
  • S1063 Obtain the actual frame-level encoding bit rate model of one frame according to the actual encoding bit rate and the estimated Lagrangian multiplier model and the preset frame-level encoding bit rate model;
  • the preset temporal proximity approximate coding bit rate model the preset temporal proximity approximate frame-level coding bit rate model and the actual frame-level coding bit rate model of one frame, Obtain the preset coding bit rate and the estimated Lagrangian multiplier model.
  • the rate-distortion optimization device can deduce the theoretical encoding bit rate of the coding unit and the estimated Lagrangian multiplier model based on the initial encoding bit rate and the Lagrangian multiplier model.
  • the initial encoding bit rate and the Lagrangian multiplier model represent the R- ⁇ model, which is the currently adopted R- ⁇ model, which represents the unity of the initial encoding bit rate and the system Lagrangian multiplier Correspondence, the embodiment of this application does not limit its manifestation.
  • the initial encoding bit rate and the Lagrangian multiplier model can be expressed as formula (7), as follows:
  • ⁇ and ⁇ are model parameters, which need to be determined by data fitting in the actual use process.
  • the optimal Lagrangian multiplier of the i-th coding unit is numerically equal to the optimal use of the coding unit i Bit rate generated by encoding
  • the ratio of the bit rate R t,i ( ⁇ sys ) generated by the ⁇ sys encoding of the current frame to the image to be encoded using the system configuration is the theoretical encoding bit rate of the coding unit and the estimated Lagrangian multiplier model, as shown in formula (8 ) Shows:
  • the theoretical coding bit rate of the coding unit and the estimated Lagrangian multiplier model calculates the ratio of the two cases.
  • the coding unit i at time t if the system Lagrangian multiplier ⁇ sys is used for coding, the resulting bit rate is represented by R t,i ( ⁇ sys ); if the ideal optimal drawing is used Grange Multiplier Encoding, the resulting bit rate is Representation, that is, R t,i ( ⁇ sys ) represents the bit rate of each coding unit of the frame.
  • Optimal Lagrangian multiplier To seek an approaching goal.
  • the embodiment of the present application constructs a hypothetical "frame-level abstract coding unit", which represents the overall coding situation of the entire frame image.
  • the bit rate of the "frame-level abstract coding unit” adopts the actual average bit rate of all coding units of the frame image.
  • the “frame-level abstract coding unit” corresponding to the system Lagrangian multiplier ⁇ sys as an example, the coding bit rate R t,i ( ⁇ sys ) of the “frame-level abstract coding unit” is obtained. It is the average bit rate of the "frame-level abstract coding unit”.
  • the preset frame-level coding bit rate model represents the average bit rate of each coding unit of a frame of image to be coded and the system Lagrangian multiplier (initial Lagrangian multiplier) The corresponding relationship.
  • the rate-distortion optimization device after the rate-distortion optimization device obtains the theoretical encoding bit rate and the estimated Lagrangian multiplier model and the preset frame-level encoding bit rate model, it can calculate the theoretical encoding bit rate and the estimated Lagrangian
  • the daily multiplier model and the preset frame-level coding bit rate model are used to obtain the theoretical optimal Lagrangian multiplier model at the coding unit level.
  • the rate-distortion optimization device substitutes formula (9) into formula (8) to obtain the theoretical optimal Lagrangian multiplier model at the coding unit level.
  • the theoretical optimal Lagrangian multiplier model can be expressed as formula (10), as follows:
  • bit rate generated by the adjacent coding unit in the time domain is very similar to the bit rate generated by the current coding unit. Therefore, the bit rate of the adjacent coding unit in the time domain is adopted. Instead of the bit rate generated by encoding the current coding unit, as shown in formula (11):
  • the coding units adjacent in the time domain are used in the encoding process although they are not the optimal Lagrangian multipliers.
  • the estimated Lagrangian multiplier actually used in the previous frame is used. because Is the optimal Lagrangian multiplier A better estimate, so it is used to approximate the optimal Lagrangian multiplier.
  • the rate-distortion optimization device can obtain the preset time-domain proximity approximate coding bit rate model according to formula (11) and formula (12), as shown in formula (13):
  • the rate-distortion optimization device may also deduce the actual coding bit rate of the coding unit and the estimated Lagrangian multiplier model based on the initial coding bit rate and the Lagrangian multiplier model.
  • the actual encoding bit rate of the rate-distortion optimization device and the estimated Lagrangian multiplier model and the preset frame-level encoding bit rate model are obtained to obtain the actual frame-level encoding bit rate model of one frame.
  • formula (14) is substituted into formula (10), that is, formula (14) is applied to all coding units at t-1, then the "frame-level abstract coding at t-1" can be calculated
  • the bit rate expression of “unit” is the actual frame-level coding bit rate model of one frame, namely formula (15), as follows:
  • the bit rate of the "frame-level abstract coding unit" at time t It cannot be obtained directly. Also because of the time-domain correlation between the video sequences to be encoded, the bit rates of the “frame-level abstract coding units” of neighboring images in the time domain are very close, so the average bit rate at the previous moment is used to approximate the average bit rate at the current moment.
  • the preset time-domain proximity approximate frame-level coding bit rate model can be obtained, as shown in formula (16):
  • the rate-distortion optimization device obtains the theoretical optimal Lagrangian multiplier model formula (10), the preset time-domain proximity approximate coding bit rate model formula (13), and the preset time-domain proximity approximate frame-level coding bits Rate model formula (16) and the actual frame-level coding bit rate model formula (15) of one frame, in this way, the rate-distortion optimization device can be based on the theoretically optimal Lagrangian multiplier model and preset temporal proximity approximate coding
  • the bit rate model, the preset time-domain proximity approximate frame-level coding bit rate model, and the actual frame-level coding bit rate model of one frame obtain the preset coding bit rate and the estimated Lagrangian multiplier model formula (5).
  • the rate-distortion optimization device substitutes formula (15) into formula (16) to obtain Then Substituting formula (13) into formula (10), formula (5) is obtained. In this way, the coding unit-level coding bit rate and estimated Lagrangian multiplier of the coding unit level of the previous frame to be coded are obtained, and the estimated Lagrangian multiplier of the coding unit level of the current frame to be coded image is obtained. Preset encoding bitrate and estimated Lagrangian multiplier model.
  • the rate-distortion optimization device uses the coding unit-level coding bit rate and estimated Lagrangian multiplier of the previously encoded image to be coded, combining the preset coding bit rate and the estimated Lagrangian multiplier.
  • the sub-model is used to obtain the estimated Lagrangian multiplier at the coding unit level of the image to be encoded in the current frame, and then to achieve rate-distortion optimization processing and encoding, because the rate-distortion optimization device can be based on the bit rate of the image to be encoded in the previous frame And estimated Lagrangian multipliers, intervene in the estimated Lagrangian multipliers of all coding units of the image to be coded in the current frame, and further interfere with the bit distribution of the intra-frame coding units tending to balance, thereby improving coding efficiency.
  • the encoding process is performed using the encoding image of the current frame as shown in FIG. 3.
  • Figure 4 is a schematic diagram of encoding after the rate-distortion optimization method provided by this application is turned off
  • Figure 5 is a schematic diagram of encoding after the rate-distortion optimization method provided by this application is turned on; the lighter the color in the figure, the higher the bit rate of the encoding unit, and vice versa. The deeper it is, the lower the bit rate for encoding the unit. It can be seen from the comparison between FIG. 4 and FIG. 5 that the encoding rate after the rate-distortion optimization method provided by this application is turned on is higher, for example, area 1.
  • FIG. 6 is an analysis diagram of coding unit division after the rate-distortion optimization method provided by this application is turned off
  • FIG. 7 is an analysis diagram of coding unit division after the rate-distortion optimization method provided by this application is turned on. Comparing Fig. 6 and Fig. 7, it can be found that the bits of some areas are improved and the division becomes finer, such as area 2.
  • Figure 8 is an analysis diagram of the division of two coding units after the rate-distortion optimization method provided by this application is turned off
  • Figure 9 is an analysis diagram of the division of two coding units after the rate-distortion optimization method provided by this application is turned on, and the two coding units correspond to The video image content is lawn with complex texture.
  • the coding block division in Fig. 8 is simple and the level is shallow; the coding block division in Fig. 9 becomes finer, the division level is deepened, and a relatively large number of coding bits are used.
  • the embodiment of the present application does not directly control the encoding bit rate, but indirectly adjusts the bit distribution by updating the Lagrangian multiplier, intervening in encoding mode selection and encoding quadtree division depth.
  • Table 1 shows the coding performance test situation in the low-latency configuration.
  • the video sequence used in the test is the general test video sequence of H.265/HEVC, and the 4 quantization parameter points 22, 27, 32, 37 (ie Class B, Class C, Class D, and Class E) are tested according to the general test standard.
  • Performance evaluation uses BD-Rate as the evaluation index. BD-Rate represents the increase in bit rate under the same PSNR. When the BD-Rate is negative, it indicates that the encoder performance has been improved.
  • the test uses the open source commercial encoder x265v2.3 version, and the test results of all video sequences are shown in Table 1:
  • Summary is -, which means that the encoder has achieved performance
  • the improvement can save an average bit rate of 3.08% on Y (brightness), an average bit rate of 3.6% on U (chroma), and an average bit rate of 2.7% on V (concentration).
  • a rate-distortion optimization method provided in an embodiment of the present application further includes: S107 and S108. as follows:
  • S108 Using the initial Lagrangian multiplier, perform rate-distortion processing of the image to be encoded in the current frame, and then complete the encoding of the image to be encoded in the current frame.
  • the rate-distortion optimization device obtains the initial Lagrangian multiplier, and uses the initial Lagrangian multiplier to perform the image processing of the current frame to be encoded Rate distortion processing, and then complete the encoding of the image to be encoded in the current frame.
  • the image to be encoded in the first frame does not have a temporally adjacent coding unit. Therefore, it is necessary to use the initial Lagrangian multiplier to perform rate-distortion processing of the image to be encoded in the first frame, and then complete the image to be encoded in the first frame. Coded.
  • the estimated Lagrangian multiplier at the coding unit level of the image to be coded in the current frame is used to perform rate-distortion processing of the image to be coded in the current frame to complete the image to be coded in the current frame
  • the rate-distortion optimization method provided in the embodiment of the present application further includes: S109 and S110. as follows:
  • the rate-distortion optimization device after the rate-distortion optimization device has processed the image to be encoded in the current frame, it can process the image to be encoded in the next frame, that is, the process of S101-104, that is, S201-S205, is cyclically executed until processing When the encoding of the last frame of the to-be-encoded video sequence is completed, the process ends.
  • an embodiment of the present application also provides a rate-distortion optimization device 1, including:
  • the acquiring part 10 is configured to acquire the image to be encoded in the current frame; and if the image to be encoded in the current frame is not the first frame to be encoded, acquiring the initial Lagrangian multiplier and the coding unit level of the image to be encoded in the previous frame The coding bit rate and the estimated Lagrangian multiplier at the coding unit level of the image to be coded in the previous frame;
  • the calculation part 11 is configured to estimate the Lagrange based on the initial Lagrangian multiplier, the coding unit-level coding bit rate of the image to be coded in the previous frame, and the coding unit level of the image to be coded in the previous frame.
  • a Lange multiplier and a preset encoding bit rate and an estimated Lagrangian multiplier model to obtain an estimated Lagrangian multiplier at the coding unit level of the image to be encoded in the current frame;
  • the processing part 12 is configured to use the estimated Lagrangian multiplier at the coding unit level of the image to be encoded in the current frame to perform rate-distortion processing of the image to be encoded in the current frame, and then to complete the processing of the image to be encoded in the current frame coding.
  • the acquiring part 10 is specifically configured to acquire the i-th coding unit of the current frame to be encoded if the image to be encoded in the current frame is not the first frame to be encoded,
  • the calculation part 11 is specifically configured to be based on the initial Lagrangian multiplier, the encoding bit rate of the i-th coding unit of the image to be encoded in the previous frame, and the The estimated Lagrangian multiplier of the i-th coding unit of the image to be encoded in the previous frame and the preset encoding bit rate and the estimated Lagrangian multiplier model to obtain the i-th image of the image to be encoded in the current frame.
  • the estimated Lagrangian multiplier of the coding unit and adding 1 to i to obtain the estimated Lagrangian multiplier of the i+1-th coding unit of the image to be encoded in the current frame until the image to be encoded in the current frame is obtained
  • the estimated Lagrangian multiplier of the Nth coding unit is specifically configured to be based on the initial Lagrangian multiplier, the encoding bit rate of the i-th coding unit of the image to be encoded in the previous frame, and the The estimated Lagrangian multiplier of the i-th coding unit
  • the processing part 12 is specifically configured to use the estimated Lagrangian multiplier of the first coding unit of the image to be encoded in the current frame to the first coding unit of the image to be encoded in the current frame.
  • the estimated Lagrangian multipliers of the N coding units perform rate-distortion processing of the image to be encoded in the current frame, and then complete the encoding of the image to be encoded in the current frame.
  • the acquiring part 10 is further configured to encode the bit rate according to the initial Lagrangian multiplier, the encoding unit level of the image to be encoded in the previous frame, and the The estimated Lagrangian multiplier at the coding unit level of the image to be coded in the previous frame and the preset coding bit rate and the estimated Lagrangian multiplier model to obtain the estimated Lagrangian at the coding unit level of the image to be coded in the current frame
  • the calculation part 11 is further configured to be based on the initial encoding bit rate and the Lagrangian multiplier model, the preset frame-level encoding bit rate model, the preset temporal proximity approximate encoding bit rate model, and the The preset time-domain proximity approximates the frame-level coding bit rate model, and the preset coding bit rate and the estimated Lagrangian multiplier model are obtained.
  • the calculation part 11 is further specifically configured to deduce the theoretical encoding bit rate of the coding unit and the estimated Lagrangian multiplier according to the initial encoding bit rate and the Lagrangian multiplier model.
  • the acquiring part 10 is further configured to acquire the initial Lagrangian multiplier after acquiring the image to be encoded in the current frame, if the image to be encoded in the current frame is the first image to be encoded child;
  • the processing part 12 is further configured to use the initial Lagrangian multiplier to perform rate-distortion processing of the image to be encoded in the current frame, and then to complete the encoding of the image to be encoded in the current frame.
  • the processing part 12 is further configured to use the estimated Lagrangian multiplier at the coding unit level of the image to be encoded in the current frame to perform the calculation of the image to be encoded in the current frame.
  • Rate-distortion processing and after completing the encoding of the image to be encoded in the current frame, enter the rate-distortion optimization process of the image to be encoded in the next frame; the encoding of the image to be encoded in the last frame of the video sequence to be encoded is completed.
  • an embodiment of the present application also provides a rate-distortion optimization device, including:
  • the aforementioned processor 13 may be an Application Specific Integrated Circuit (ASIC), a digital signal processor (Digital Signal Processor, DSP), a digital signal processing device (Digital Signal Processing Device, DSPD). ), programmable logic device (ProgRAMmable Logic Device, PLD), field programmable gate array (Field ProgRAMmable Gate Array, FPGA), central processing unit (Central Processing Unit, CPU), controller, microcontroller, microprocessor At least one of. It is understandable that, for different devices, the electronic devices used to implement the above-mentioned processor functions may also be other, which is not specifically limited in the embodiment of the present application.
  • ASIC Application Specific Integrated Circuit
  • DSP Digital Signal Processor
  • DSPD Digital Signal Processing Device
  • PLD programmable logic device
  • FPGA field programmable gate array
  • CPU Central Processing Unit
  • controller microcontroller
  • microprocessor At least one of.
  • the intra-frame prediction apparatus may also include a memory 14, which may be connected to the processor 13, wherein the memory 14 is used to store executable program code, the program code includes computer operation instructions, and the memory 14 may be a volatile memory ( Volatile memory, such as random access memory (Random-Access Memory, RAM); or non-volatile memory (non-volatile memory), such as read-only memory (ROM), flash memory (flash memory) ), a hard disk (Hard Disk Drive, HDD) or a solid-state drive (Solid-State Drive, SSD); or a combination of the foregoing types of memories, and provides instructions and data to the processor 13.
  • volatile memory volatile memory
  • RAM random access memory
  • non-volatile memory non-volatile memory
  • ROM read-only memory
  • flash memory flash memory
  • HDD Hard Disk Drive
  • SSD solid-state drive
  • the communication bus 15 is used to connect the processor 13 and the memory 14 and the mutual communication between these devices.
  • the functional modules in the embodiments of the present application 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-mentioned integrated unit can be realized in the form of hardware or software function module.
  • the integrated unit is implemented in the form of a software function module and is not sold or used as an independent product, it can be stored in a computer readable storage medium.
  • the technical solution of this embodiment is essentially or correct
  • the part that contributes to the prior art 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 enable a computer device (which can be a personal A computer, a server, or a network device, etc.) or a processor (processor) execute all or part of the steps of the method in this embodiment.
  • the aforementioned storage media include: U disk, mobile hard disk, read only memory (Read Only Memory, ROM), random access memory (Random Access Memory, RAM), magnetic disk or optical disk and other media that can store program codes.
  • An embodiment of the present application provides a computer-readable storage medium on which a rate-distortion optimization instruction is stored, where the rate-distortion optimization instruction is executed by a processor to implement the above-mentioned rate-distortion optimization method.
  • the rate-distortion optimization device performs rate-distortion optimization processing on the image to be encoded in the current frame.
  • the encoding unit-level encoding bit rate of the image to be encoded in the previous frame that has been encoded can be used to estimate the bit rate.
  • the Grange multiplier combines the preset coding bit rate and the estimated Lagrangian multiplier model to obtain the estimated Lagrangian multiplier at the coding unit level of the image to be coded in the current frame, thereby realizing the rate-distortion optimization processing, Realize encoding, because the rate-distortion optimization device can intervene in the estimated Lagrangian multipliers of all coding units of the image to be encoded in the current frame based on the bit rate of the image to be encoded in the previous frame and the estimated Lagrangian multiplier, thereby intervening in the frame
  • the bit distribution of the inner coding unit tends to be balanced, thereby improving the coding efficiency.
  • this application can be provided as methods, systems, or computer program products. Therefore, this application may adopt the form of hardware embodiments, software embodiments, or embodiments combining software and hardware. Moreover, this application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, optical storage, etc.) containing computer-usable program codes.
  • These computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable data processing equipment to work in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture including the instruction device.
  • the device realizes the functions specified in one or more processes in the schematic diagram and/or one block or more in the block diagram.
  • These computer program instructions can also be loaded on a computer or other programmable data processing equipment, so that a series of operation steps are executed on the computer or other programmable equipment to produce computer-implemented processing, so as to execute on the computer or other programmable equipment.
  • the instructions provide steps for implementing functions specified in one or more processes in the schematic diagram and/or one block or more in the block diagram.
  • the embodiments of the present application provide a rate-distortion optimization method and device, and a computer-readable storage medium.
  • the rate-distortion optimization device performs rate-distortion optimization processing on the image to be encoded in the current frame.
  • the encoding process can be completed by encoding.
  • the coding unit-level coding bit rate and estimated Lagrangian multiplier of a frame of image to be coded are combined with the preset coding bit rate and the estimated Lagrangian multiplier model to obtain the coding unit level of the image to be coded in the current frame Estimate the Lagrangian multiplier, and then realize the rate-distortion optimization process and realize the encoding.
  • the rate-distortion optimization device can intervene in the current frame of the image to be encoded based on the bit rate of the image to be encoded in the previous frame and the estimated Lagrange multiplier
  • the estimated Lagrangian multipliers of all coding units in the frame and then interfere with the bit distribution of the intra-frame coding units tend to be balanced, thereby improving the coding efficiency.

Abstract

Provided are a rate distortion optimization method and apparatus, and a computer-readable storage medium. The method can comprise: acquiring a current frame of image to be coded; if the current frame of image to be coded is not the first frame of image to be coded, acquiring an initial Lagrange multiplier, a coding bit rate of a coding unit level of the previous frame of image to be coded and an estimated Lagrange multiplier of the coding unit level of the previous frame of image to be coded; according to the initial Lagrange multiplier, the coding bit rate of the coding unit level of the previous frame of image to be coded, the estimated Lagrange multiplier of the coding unit level of the previous frame of image to be coded, a pre-set coding bit rate and an estimated Lagrange multiplier model, obtaining an estimated Lagrange multiplier of a coding unit level of the current frame of image to be coded; and using the estimated Lagrange multiplier of the coding unit level of the current frame of image to be coded to perform rate distortion processing of the current frame of image to be coded, so as to complete the coding of the current frame of image to be coded.

Description

率失真优化方法及装置、计算机可读存储介质Rate-distortion optimization method and device, and computer readable storage medium 技术领域Technical field
本申请实施例涉及视频编码技术,尤其涉及一种率失真优化方法及装置、计算机可读存储介质。The embodiments of the present application relate to video coding technology, and in particular to a method and device for optimizing rate-distortion, and a computer-readable storage medium.
背景技术Background technique
率失真优化技术是视频编码中广泛使用的技术,率失真优化技术在编码参数集中选取一组参数,使得编码结果在限定的比特率下获取最小图像的失真。The rate-distortion optimization technique is a technique widely used in video coding. The rate-distortion optimization technique selects a set of parameters in the encoding parameter set so that the encoding result can obtain the smallest image distortion at a limited bit rate.
目前,当前的视频编码的率失真优化是在假设编码单元间独立的情况下进行的,使用拉格朗日乘子法进行无限制的编码代价的获取,例如,采用代价函数:min{J=D+λ·R}得到编码代价,从而选取出多种编码模式中的最佳的编码模式,采用最佳的编码模式进行视频编码;其中,J表示编码的代价,λ是被引入的拉格朗日乘子,D表示重构图像的失真,R表示编码比特率。At present, the current rate-distortion optimization of video coding is performed under the assumption that the coding units are independent, and the Lagrangian multiplier method is used to obtain unlimited coding cost. For example, the cost function: min{J= D+λ·R} to get the coding cost, so as to select the best coding mode among multiple coding modes, and use the best coding mode for video coding; where J represents the coding cost, and λ is the introduced Lager Lange multiplier, D represents the distortion of the reconstructed image, and R represents the coding bit rate.
然而,由于根据拉格朗日优化理论,λ的取值是置代价函数一阶微分恒为零计算取得,在高比特率假设下,图像的失真与量化步长有关,最终得到拉格朗日乘子λ一个只与量化步长平方呈正相关的量。在视频图像的编码过程中,一幅图像被分割成为若干等大的编码块,即编码单元。在量化步长平方一定的情况下,一幅图像中所有的编码单元都将共用一个预计算给出的λ值。这与实际的不同编码单元对应不同的拉格朗日乘子有所偏差,也就是说,采用现有的λ的进行一帧图像的不同的编码单元的编码代价的估计时存在估计不准确的问题,从而导致率失真估计不准确,进而影响了图像的编码效率。However, due to the Lagrangian optimization theory, the value of λ is calculated by setting the first-order differential of the cost function to be constant at zero. Under the assumption of high bit rate, the distortion of the image is related to the quantization step size, and the Lagrangian is finally obtained. The daily multiplier λ is a quantity that is only positively correlated with the square of the quantization step. In the coding process of a video image, an image is divided into several equal-sized coding blocks, namely coding units. When the square of the quantization step size is constant, all coding units in an image will share a pre-calculated λ value. This is somewhat different from the actual different coding units corresponding to different Lagrangian multipliers. That is to say, the estimation of the coding cost of different coding units of a frame of image is inaccurate when using the existing λ. The problem leads to inaccurate rate distortion estimation, which affects the coding efficiency of the image.
发明内容Summary of the invention
本申请实施例提供一种率失真优化方法及装置、计算机可读存储介质,能够提高编码效率。The embodiments of the present application provide a rate-distortion optimization method and device, and a computer-readable storage medium, which can improve coding efficiency.
本申请实施例的技术方案是这样实现的:The technical solutions of the embodiments of the present application are implemented as follows:
本申请实施例提供了一种率失真优化方法,包括:An embodiment of the present application provides a rate-distortion optimization method, including:
获取当前帧待编码图像;Acquiring the image to be encoded in the current frame;
若所述当前帧待编码图像为非首帧待编码图像,则获取初始拉格朗日乘子、上一帧待编码图像的编码单元级的编码比特率和上一帧待编码图像的编码单元级的估计拉格朗日乘子;If the image to be encoded in the current frame is not the first frame to be encoded, the initial Lagrangian multiplier, the encoding unit-level encoding bit rate of the image to be encoded in the previous frame, and the encoding unit of the image to be encoded in the previous frame are acquired Estimated Lagrange multiplier of the order;
根据所述初始拉格朗日乘子、所述上一帧待编码图像的编码单元级的编码比特率和所述上一帧待编码图像的编码单元级的估计拉格朗日乘子和预设编码比特率与估计拉格朗日乘子模型,得到所述当前帧待编码图像的编码单元级的估计拉格朗日乘子;According to the initial Lagrangian multiplier, the coding unit-level coding bit rate of the image to be coded in the previous frame, and the estimated Lagrangian multiplier and pre-coding unit level of the image to be coded in the previous frame Set the coding bit rate and the estimated Lagrangian multiplier model to obtain the estimated Lagrangian multiplier at the coding unit level of the image to be coded in the current frame;
采用所述当前帧待编码图像的编码单元级的估计拉格朗日乘子,进行所述当前帧待编码图像的率失真处理,进而完成所述当前帧待编码图像的编码。The estimated Lagrangian multiplier at the coding unit level of the image to be encoded in the current frame is used to perform rate-distortion processing of the image to be encoded in the current frame to complete the encoding of the image to be encoded in the current frame.
在上述方案中,所述若所述当前帧待编码图像为非首帧待编码图像,则获取初始拉格朗日乘子、上一帧待编码图像的编码单元级的编码比特率和上一帧待编码图像的编码 单元级的估计拉格朗日乘子,包括:In the above solution, if the image to be encoded in the current frame is not the first image to be encoded, the initial Lagrangian multiplier, the encoding unit-level encoding bit rate of the image to be encoded in the previous frame, and the previous image are acquired. The estimated Lagrangian multiplier at the coding unit level of the frame to be encoded includes:
若所述当前帧待编码图像为非首帧待编码图像,则获取所述当前帧待编码图像的第i个编码单元、所述初始拉格朗日乘子、上一帧待编码图像的第i个编码单元的编码比特率和上一帧待编码图像的第i个编码单元的估计拉格朗日乘子,其中i为大于等于1,且小于等于N的正整数,N为一帧待编码图像对应的编码单元的总数量。If the image to be encoded in the current frame is not the first image to be encoded, the i-th coding unit of the image to be encoded in the current frame, the initial Lagrangian multiplier, and the image to be encoded in the previous frame are acquired. The coding bit rate of i coding units and the estimated Lagrangian multiplier of the i-th coding unit of the image to be coded in the previous frame, where i is a positive integer greater than or equal to 1 and less than or equal to N, and N is a frame to be coded The total number of coding units corresponding to the coded image.
在上述方案中,所述根据所述初始拉格朗日乘子、所述上一帧待编码图像的编码单元级的编码比特率和所述上一帧待编码图像的编码单元级的估计拉格朗日乘子和预设编码比特率与估计拉格朗日乘子模型,得到所述当前帧待编码图像的编码单元级的估计拉格朗日乘子,包括:In the above solution, the coding unit-level coding bit rate of the image to be coded in the previous frame, and the coding unit-level estimation of the image to be coded in the previous frame are adjusted according to the initial Lagrangian multiplier, The Grange multiplier, the preset coding bit rate and the estimated Lagrangian multiplier model to obtain the estimated Lagrangian multiplier at the coding unit level of the image to be coded in the current frame includes:
根据所述初始拉格朗日乘子、所述上一帧待编码图像的第i个编码单元的编码比特率、所述上一帧待编码图像的第i个编码单元的估计拉格朗日乘子和所述预设编码比特率与估计拉格朗日乘子模型,得到所述当前帧待编码图像的第i个编码单元的估计拉格朗日乘子;According to the initial Lagrangian multiplier, the coding bit rate of the i-th coding unit of the image to be coded in the previous frame, and the estimated Lagrangian of the i-th coding unit of the image to be coded in the previous frame A multiplier and the preset encoding bit rate and an estimated Lagrangian multiplier model to obtain an estimated Lagrangian multiplier of the i-th coding unit of the image to be encoded in the current frame;
将i加1,进行当前帧待编码图像的第i+1个编码单元的估计拉格朗日乘子的获取,直至获取到当前帧待编码图像的第N个编码单元的估计拉格朗日乘子为止。Add 1 to i to obtain the estimated Lagrangian multiplier of the i+1th coding unit of the image to be coded in the current frame until the estimated Lagrangian multiplier of the Nth coding unit of the image to be coded in the current frame is obtained Until the multiplier.
在上述方案中,所述采用所述当前帧待编码图像的编码单元级的估计拉格朗日乘子,进行所述当前帧待编码图像的率失真处理,进而完成所述当前帧待编码图像的编码,包括:In the above solution, the estimated Lagrangian multiplier at the coding unit level of the image to be encoded in the current frame is used to perform rate-distortion processing of the image to be encoded in the current frame to complete the image to be encoded in the current frame The encoding includes:
采用所述当前帧待编码图像的第1个编码单元的估计拉格朗日乘子至所述当前帧待编码图像的第N个编码单元的估计拉格朗日乘子,进行所述当前帧待编码图像的率失真处理,进而完成所述当前帧待编码图像的编码。Use the estimated Lagrangian multiplier of the first coding unit of the image to be coded in the current frame to the estimated Lagrangian multiplier of the Nth coding unit of the image to be coded in the current frame to perform the current frame The rate-distortion processing of the image to be encoded further completes the encoding of the image to be encoded in the current frame.
在上述方案中,所述根据所述初始拉格朗日乘子、所述上一帧待编码图像的编码单元级的编码比特率和所述上一帧待编码图像的编码单元级的估计拉格朗日乘子和预设编码比特率与估计拉格朗日乘子模型,得到所述当前帧待编码图像的编码单元级的估计拉格朗日乘子之前,所述方法还包括:In the above solution, the coding unit-level coding bit rate of the image to be coded in the previous frame, and the coding unit-level estimation of the image to be coded in the previous frame are adjusted according to the initial Lagrangian multiplier, Before the Grange multiplier and the preset coding bit rate and the estimated Lagrangian multiplier model are used to obtain the estimated Lagrangian multiplier at the coding unit level of the image to be coded in the current frame, the method further includes:
获取初始编码比特率与拉格朗日乘子模型、预设帧级编码比特率模型、预设时域邻近近似编码比特率模型和预设时域邻近近似帧级编码比特率模型;Obtain the initial coding bit rate and the Lagrangian multiplier model, the preset frame-level coding bit rate model, the preset time-domain proximity approximate coding bit rate model, and the preset time-domain proximity approximate frame-level coding bit rate model;
根据所述初始编码比特率与拉格朗日乘子模型、所述预设帧级编码比特率模型、所述预设时域邻近近似编码比特率模型和所述预设时域邻近近似帧级编码比特率模型,得到所述预设编码比特率与估计拉格朗日乘子模型。According to the initial coding bit rate and the Lagrangian multiplier model, the preset frame-level coding bit rate model, the preset time domain proximity approximate coding bit rate model, and the preset time domain proximity approximate frame level The coding bit rate model is used to obtain the preset coding bit rate and the estimated Lagrangian multiplier model.
在上述方案中,所述根据所述初始编码比特率与拉格朗日乘子模型、所述预设帧级编码比特率模型、所述预设时域邻近近似编码比特率模型和所述预设时域邻近近似帧级编码比特率模型,得到所述预设编码比特率与估计拉格朗日乘子模型,包括:In the above solution, the preset frame-level coding bit rate model, the preset temporal proximity approximate coding bit rate model, and the pre-coding bit rate model are based on the initial coding bit rate and the Lagrangian multiplier model. Supposing the temporal proximity approximate frame-level coding bit rate model, obtaining the preset coding bit rate and the estimated Lagrangian multiplier model includes:
根据所述初始编码比特率与拉格朗日乘子模型,推出编码单元的理论编码比特率与估计拉格朗日乘子模型和编码单元的实际编码比特率与估计拉格朗日乘子模型;According to the initial coding bit rate and Lagrangian multiplier model, the theoretical coding bit rate and estimated Lagrangian multiplier model of the coding unit and the actual coding bit rate and estimated Lagrangian multiplier model of the coding unit are derived ;
根据所述理论编码比特率与估计拉格朗日乘子模型和所述预设帧级编码比特率模型,得到编码单元级的理论最优拉格朗日乘子模型;Obtaining a theoretical optimal Lagrangian multiplier model at the coding unit level according to the theoretical coding bit rate and the estimated Lagrangian multiplier model and the preset frame-level coding bit rate model;
根据实际编码比特率与估计拉格朗日乘子模型和所述预设帧级编码比特率模型,得到实际上一帧的帧级编码比特率模型;According to the actual encoding bit rate and the estimated Lagrangian multiplier model and the preset frame-level encoding bit rate model, obtain the actual frame-level encoding bit rate model of one frame;
根据所述理论最优拉格朗日乘子模型、所述预设时域邻近近似编码比特率模型、所述预设时域邻近近似帧级编码比特率模型和所述实际上一帧的帧级编码比特率模型,得到所述预设编码比特率与估计拉格朗日乘子模型。According to the theoretical optimal Lagrangian multiplier model, the preset temporal proximity approximate coding bit rate model, the preset temporal proximity approximate frame-level coding bit rate model, and the actual frame of one frame Level coding bit rate model to obtain the preset coding bit rate and the estimated Lagrangian multiplier model.
在上述方案中,所述获取当前帧待编码图像之后,所述方法还包括:In the above solution, after the obtaining the image to be encoded in the current frame, the method further includes:
若所述当前帧待编码图像为首帧待编码图像,则获取初始拉格朗日乘子;If the image to be encoded in the current frame is the image to be encoded in the first frame, obtaining an initial Lagrangian multiplier;
采用所述初始拉格朗日乘子,进行所述当前帧待编码图像的率失真处理,进而完成所述当前帧待编码图像的编码。The initial Lagrangian multiplier is used to perform rate-distortion processing of the image to be encoded in the current frame, thereby completing the encoding of the image to be encoded in the current frame.
在上述方案中,所述采用所述当前帧待编码图像的编码单元级的估计拉格朗日乘子,进行所述当前帧待编码图像的率失真处理,进而完成所述当前帧待编码图像的编码之后,所述方法还包括:In the above solution, the estimated Lagrangian multiplier at the coding unit level of the image to be encoded in the current frame is used to perform rate-distortion processing of the image to be encoded in the current frame to complete the image to be encoded in the current frame After the encoding, the method further includes:
进入下一帧待编码图像的率失真优化流程;Enter the rate-distortion optimization process of the next frame to be encoded;
直至处理完待编码视频序列的最后一帧待编码图像编码完成。The encoding of the image to be encoded until the last frame of the video sequence to be encoded is processed.
本申请实施例提供了一种率失真优化装置,包括:An embodiment of the present application provides a rate-distortion optimization device, including:
处理器、存储有所述处理器可执行率失真优化指令的存储器,和用于连接所述处理器、所述存储器的通信总线,当所述率失真优化指令被执行时,实现上述的率失真优化方法。A processor, a memory storing a rate-distortion optimization instruction executable by the processor, and a communication bus for connecting the processor and the memory, and when the rate-distortion optimization instruction is executed, the above-mentioned rate distortion is realized Optimization.
本申请实施例提供了一种计算机可读存储介质,其上存储有率失真优化指令,其中,所述率失真优化指令被处理器执行时,实现上述的率失真优化方法。An embodiment of the present application provides a computer-readable storage medium on which a rate-distortion optimization instruction is stored, where the rate-distortion optimization instruction is executed by a processor to implement the above-mentioned rate-distortion optimization method.
本申请实施例中,采用上述技术实现方案,率失真优化装置对当前帧待编码图像进行率失真优化处理,实现编码的过程中,可以通过已编码完成的上一帧待编码图像的编码单元级的编码比特率和估计拉格朗日乘子,结合预设编码比特率与估计拉格朗日乘子模型,来得到当前帧待编码图像的编码单元级的估计拉格朗日乘子,进而实现对率失真优化处理,实现编码,由于率失真优化装置可以基于上一帧待编码图像的比特率和估计拉格朗日乘子,干预当前帧待编码图像的所有编码单元的估计拉格朗日乘子,进而干预帧内编码单元的比特分布趋于平衡,从而提高了编码效率。In the embodiment of the application, the above-mentioned technical implementation scheme is adopted, and the rate-distortion optimization device performs rate-distortion optimization processing on the image to be encoded in the current frame. During the encoding process, the encoding unit level of the image to be encoded in the previous frame that has been encoded can be used. The coding bit rate and the estimated Lagrangian multiplier are combined with the preset coding bit rate and the estimated Lagrangian multiplier model to obtain the estimated Lagrangian multiplier at the coding unit level of the image to be coded in the current frame, and then Realize the rate-distortion optimization processing and encoding, because the rate-distortion optimization device can intervene in the estimated Lagrangian of all coding units of the image to be encoded in the current frame based on the bit rate of the image to be encoded in the previous frame and the estimated Lagrangian multiplier The multiplier of the day, in turn, interferes with the balance of the bit distribution of the coding unit within the frame, thereby improving the coding efficiency.
附图说明Description of the drawings
图1为本申请实施例提供的一种率失真优化方法的流程图一;FIG. 1 is a first flowchart of a rate-distortion optimization method provided by an embodiment of this application;
图2为本申请实施例提供的一种率失真优化方法的流程图二;FIG. 2 is a second flowchart of a rate-distortion optimization method provided by an embodiment of the application;
图3为本申请实施例提供的示例性的当前帧待编码图像;Figure 3 is an exemplary current frame to-be-encoded image provided by an embodiment of the application;
图4为关闭本申请提供的示例性的率失真优化方式后的编码示意图;FIG. 4 is a schematic diagram of encoding after turning off the exemplary rate-distortion optimization method provided by the present application;
图5为开启本申请提供的示例性的率失真优化方式后的编码示意图;FIG. 5 is a schematic diagram of encoding after the exemplary rate-distortion optimization method provided by the present application is turned on;
图6为关闭本申请提供的示例性的率失真优化方式后的编码单元划分分析图;Fig. 6 is an analysis diagram of coding unit division after closing the exemplary rate-distortion optimization method provided by the present application;
图7为开启本申请提供的示例性的率失真优化方式后的编码单元划分分析图;FIG. 7 is an analysis diagram of coding unit division after the exemplary rate-distortion optimization method provided by the present application is turned on;
图8为关闭本申请提供的率失真优化方式后的两个编码单元划分分析图;FIG. 8 is a diagram showing the division and analysis of two coding units after the rate-distortion optimization method provided by the present application is turned off;
图9为开启本申请提供的率失真优化方式后的两个编码单元划分分析图;FIG. 9 is an analysis diagram of the division of two coding units after the rate-distortion optimization method provided by the present application is turned on;
图10为本申请实施例提供的一种率失真优化装置的结构示意图一;FIG. 10 is a first structural diagram of a rate-distortion optimization device provided by an embodiment of the application;
图11为本申请实施例提供的一种率失真优化装置的结构示意图二。FIG. 11 is a second structural diagram of a rate-distortion optimization apparatus provided by an embodiment of the application.
具体实施方式detailed description
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述。可以理解的是,此处所描述的具体实施例仅仅用于解释相关申请,而非对该申请的限定。另外还需要说明的是,为了便于描述,附图中仅示出了与有关申请相关的部分。The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. It is understandable that the specific embodiments described here are only used to explain the related application, but not to limit the application. In addition, it should be noted that, for ease of description, only the parts related to the relevant application are shown in the drawings.
在本申请实施例中,率失真优化方法应用于视频编码过程中。视频编码方法,包括预测、变换、量化和熵编码。其中,预测方法包括帧内预测和帧间预测,当前编码单元的预测信息中的编码模式、运动矢量和重建数据用于协助预测后面的编码单元。In the embodiment of the present application, the rate-distortion optimization method is applied in the video encoding process. Video coding methods, including prediction, transformation, quantization and entropy coding. Among them, the prediction method includes intra-frame prediction and inter-frame prediction, and the coding mode, motion vector, and reconstruction data in the prediction information of the current coding unit are used to assist in predicting the subsequent coding unit.
在本申请实施例中,由于时域预测技术的大量使用导致编码单元之间存在强相关性,即当前编码单元的编码性能会影响到后面编码单元的编码,因此,本申请实施例是基于时域邻近思想来得到最优的拉格朗日乘子,实现率失真优化方法的。In the embodiments of this application, due to the extensive use of temporal prediction technology, there is a strong correlation between coding units, that is, the coding performance of the current coding unit will affect the encoding of subsequent coding units. Therefore, the embodiments of this application are based on time. The idea of domain proximity is used to obtain the optimal Lagrangian multiplier to realize the rate-distortion optimization method.
下面结合附图和实施例对本申请的技术方案进一步详细阐述。The technical solution of the present application will be further elaborated below in conjunction with the drawings and embodiments.
需要说明的是,本申请实施例提供的一种率失真优化装置可以为编码器,本申请实施例不作限制。It should be noted that the rate-distortion optimization device provided in the embodiment of the present application may be an encoder, which is not limited in the embodiment of the present application.
本申请实施例提供了一种率失真优化方法,如图1所示,该方法可以包括:The embodiment of the present application provides a rate-distortion optimization method. As shown in FIG. 1, the method may include:
S101、获取当前帧待编码图像。S101. Obtain an image to be encoded in the current frame.
S102、若当前帧待编码图像为非首帧待编码图像,则获取初始拉格朗日乘子、上一帧待编码图像的编码单元级的编码比特率和上一帧待编码图像的编码单元级的估计拉格朗日乘子;S102. If the image to be encoded in the current frame is not the first frame to be encoded, acquire the initial Lagrangian multiplier, the encoding unit-level encoding bit rate of the image to be encoded in the previous frame, and the encoding unit of the image to be encoded in the previous frame Estimated Lagrange multiplier of the order;
S103、根据初始拉格朗日乘子、上一帧待编码图像的编码单元级的编码比特率和上一帧待编码图像的编码单元级的估计拉格朗日乘子和预设编码比特率与估计拉格朗日乘子模型,得到当前帧待编码图像的编码单元级的估计拉格朗日乘子。S103. According to the initial Lagrangian multiplier, the coding unit-level coding bit rate of the image to be coded in the previous frame, and the estimated Lagrangian multiplier and the preset coding bit rate at the coding unit level of the image to be coded in the previous frame With the estimated Lagrangian multiplier model, the estimated Lagrangian multiplier of the coding unit level of the image to be encoded in the current frame is obtained.
S104、采用当前帧待编码图像的编码单元级的估计拉格朗日乘子,进行当前帧待编码图像的率失真处理,进而完成当前帧待编码图像的编码。S104. Using the estimated Lagrangian multiplier at the coding unit level of the image to be encoded in the current frame, perform rate-distortion processing of the image to be encoded in the current frame, and then complete the encoding of the image to be encoded in the current frame.
在本申请实施例中,在针对待编码视频序列进行编码的过程中,率失真优化装置可以针对帧级编码单元进行率失真优化处理后,选取出待编码视频序列中的每帧待编码图像的每个编码单元的最优编码模式,采用最优编码模式进行每帧待编码图像的每个编码单元的编码,进而完成待编码视频序列的编码。In the embodiment of the present application, in the process of encoding the video sequence to be encoded, the rate-distortion optimization apparatus may perform rate-distortion optimization processing for the frame-level coding unit, and then select the image of each frame in the video sequence to be encoded. The optimal coding mode of each coding unit adopts the optimal coding mode to encode each coding unit of each frame of the image to be coded, thereby completing the coding of the video sequence to be coded.
需要说明的是,在本申请实施例中,率失真优化装置对每个编码单元的率失真优化的过程最重要的就是得到每个编码单元对应的拉格朗日乘子的过程。It should be noted that, in the embodiment of the present application, the most important process of the rate-distortion optimization device for the rate-distortion optimization of each coding unit is the process of obtaining the Lagrangian multiplier corresponding to each coding unit.
在S101中,率失真优化装置获取待编码视频序列中的当前帧待编码图像,这里的当前帧待编码图像可能是首帧待编码图像,也可能是非首帧待编码图像。In S101, the rate-distortion optimization apparatus obtains the current frame to be encoded image in the to-be-encoded video sequence, where the current frame to be encoded image may be the first frame to be encoded image or the non-first frame to be encoded image.
需要说明的是,在本申请实施例中,在视频序列在编码过程中,一幅图像被分割成为若干等大的块。这些被分割出来的块被称为编码单元,它是编码的基本单位。编码单元表示的是图像的局部信息,若不考虑编码单元之间的空域相关性,那么一幅图像中所有的编码单元代价之和即可视为整幅图像的代价。因此,本申请实施例的率失真优化问题的求解就可以在编码单元级进行。It should be noted that, in the embodiment of the present application, during the encoding process of the video sequence, an image is divided into several blocks of equal size. These divided blocks are called coding units, which are the basic units of coding. The coding unit represents the local information of the image. If the spatial correlation between the coding units is not considered, the sum of the cost of all the coding units in an image can be regarded as the cost of the entire image. Therefore, the rate-distortion optimization problem in the embodiment of the present application can be solved at the coding unit level.
在S102中,在本申请实施例中,率失真优化装置针对待编码视频序列中的首帧待编码图像是采用系统拉格朗日乘子(即初始拉格朗日乘子)作为首帧待编码图像中的每个编码单元对应的拉格朗日乘子的,而针对率失真优化装置针对当前帧待编码图像为非首帧待编码图像,是采用时域邻近的待编码图像的编码比特率和估计拉格朗日乘子(上一帧实际采用的拉格朗日乘子)来计算当前帧待编码图像中的每个编码单元对应的拉格朗日乘子的。In S102, in the embodiment of the present application, the rate-distortion optimization apparatus uses the system Lagrangian multiplier (ie, the initial Lagrangian multiplier) as the first frame to be encoded for the first frame of the image to be encoded in the video sequence to be encoded. Each coding unit in the coded image corresponds to the Lagrangian multiplier, and the rate-distortion optimization device regards the current frame to be coded as a non-first frame to be coded, and uses the coded bits of the image to be coded adjacent to the time domain Rate and estimate the Lagrangian multiplier (the Lagrangian multiplier actually used in the previous frame) to calculate the Lagrangian multiplier corresponding to each coding unit in the image to be encoded in the current frame.
在本申请实施例中,当当前帧待编码图像为非首帧待编码图像时,率失真优化装置获取初始拉格朗日乘子、上一帧待编码图像的编码单元级的编码比特率和上一帧待编码图像的编码单元级的估计拉格朗日乘子,以便后续采用初始拉格朗日乘子、上一帧待编码图像的编码单元级的编码比特率和上一帧待编码图像的编码单元级的估计拉格朗日乘子进行当前帧待编码图像的编码单元的拉格朗日乘子的获取。In the embodiment of the present application, when the image to be encoded in the current frame is not the first frame to be encoded, the rate-distortion optimization device obtains the initial Lagrangian multiplier, the encoding unit-level encoding bit rate of the image to be encoded in the previous frame, and The estimated Lagrangian multiplier at the coding unit level of the image to be coded in the previous frame, so that the initial Lagrangian multiplier, the coding unit-level coding bit rate of the image to be coded in the previous frame and the previous frame to be coded are subsequently used The estimated Lagrangian multiplier at the coding unit level of the image acquires the Lagrangian multiplier of the coding unit of the image to be coded in the current frame.
需要说明的是,本申请实施例中的初始拉格朗日乘子是可以根据预设拉格朗日乘子模型得到的。It should be noted that the initial Lagrangian multiplier in the embodiment of the present application can be obtained according to a preset Lagrangian multiplier model.
在本申请的一些实施例中,预设拉格朗日乘子模型为公式(1),如下:In some embodiments of the present application, the preset Lagrangian multiplier model is formula (1), as follows:
Figure PCTCN2019076305-appb-000001
Figure PCTCN2019076305-appb-000001
其中,c是常数,取经验值;λ为初始拉格朗日乘子,即系统拉格朗日乘子,q step表示量化步长。 Among them, c is a constant, taking an empirical value; λ is the initial Lagrangian multiplier, that is, the system Lagrangian multiplier, and q step represents the quantization step length.
需要说明的是,在本申请实施例中,预设拉格朗日乘子模型的获取过程可以如下:It should be noted that, in the embodiment of the present application, the acquisition process of the preset Lagrangian multiplier model may be as follows:
本申请实施例采用拉格朗日方法,根据拉格朗日优化理论,λ的取值是置代价函数一阶微分恒为零计算取得,如公式(2)所示:The embodiment of the application adopts the Lagrangian method. According to the Lagrangian optimization theory, the value of λ is calculated by setting the first-order differential of the cost function to be constant, as shown in formula (2):
Figure PCTCN2019076305-appb-000002
Figure PCTCN2019076305-appb-000002
其中,D表示重构图像的失真,J表示编码的代价,R表示编码比特率,也可以理解为编码一个单元的比特数。Among them, D represents the distortion of the reconstructed image, J represents the cost of encoding, and R represents the encoding bit rate, which can also be understood as the number of bits for encoding a unit.
由于编码前不可能获取真实的比特率R,因此公式(2)的计算只能依靠经验数学模型进行推导。在高比特率假设下,图像的失真与量化步长之间的关系一般用(3)表示,如下:Since it is impossible to obtain the real bit rate R before encoding, the calculation of formula (2) can only be derived from an empirical mathematical model. Under the assumption of high bit rate, the relationship between image distortion and quantization step size is generally represented by (3), as follows:
Figure PCTCN2019076305-appb-000003
Figure PCTCN2019076305-appb-000003
其中,q step表示量化步长,它由量化参数唯一确定。 Among them, q step represents the quantization step length, which is uniquely determined by the quantization parameter.
并且,编码比特率R与重构图像的失真D的函数关系一般用公式(4)表示,如下:Moreover, the functional relationship between the encoding bit rate R and the distortion D of the reconstructed image is generally expressed by formula (4), as follows:
Figure PCTCN2019076305-appb-000004
Figure PCTCN2019076305-appb-000004
其中,δ用于表示图像变化的强度。Among them, δ is used to indicate the intensity of image changes.
这样,根据公式(2)、(3)和(4),可以推导出预设拉格朗日乘子模型公式(1)。In this way, according to formulas (2), (3) and (4), formula (1) of the preset Lagrangian multiplier model can be derived.
在本申请实施例中,c可以通过经验或实验进行取值,例如c为0.85,本申请实施例不作限制。In the embodiments of the present application, c can be obtained through experience or experiment. For example, c is 0.85, which is not limited in the embodiments of the present application.
需要说明的是,从公式(1)中可知,在高比特假设下λ是一个只与量化步长平方呈正相关的量。由于量化步长q step由量化参数QP唯一确定,因此当量化参数QP给定之后,λ的值将被直接计算得到。 It should be noted that, from the formula (1), under the assumption of high bits, λ is a quantity that is only positively correlated with the square of the quantization step size. Since the quantization step q step is uniquely determined by the quantization parameter QP, when the quantization parameter QP is given, the value of λ will be directly calculated.
需要说明的是,在本申请实施例中,初始拉格朗日乘子λ sys是根据公式(1),在编码系统的量化参数QP确定的时候,计算得到的。 It should be noted that, in the embodiment of the present application, the initial Lagrangian multiplier λ sys is calculated according to formula (1) when the quantization parameter QP of the coding system is determined.
在本申请实施例中,率失真优化装置在进行当前帧待编码图像的处理过程中,上一帧待编码图像是已经进行完编码的,在每一帧待编码图像进行率失真处理及编码过程中,率失真优化装置都是可以记录每一帧待编码图像的每个编码单元的编码比特率和估计拉格朗日乘子的,因此,率失真优化装置在对当前帧待编码图像处理时,就可以直接获取到上一帧待编码图像的编码单元级的编码比特率和上一帧待编码图像的编码单元级的估计拉格朗日乘子了。In the embodiment of this application, when the rate-distortion optimization device is processing the image to be encoded in the current frame, the encoding of the image to be encoded in the previous frame has been completed, and the rate-distortion processing and encoding process are performed in each frame of the image to be encoded. The rate-distortion optimization device can record the encoding bit rate of each coding unit of each frame of the image to be encoded and estimate the Lagrangian multiplier. Therefore, the rate-distortion optimization device can process the image to be encoded in the current frame. , You can directly obtain the coding unit-level coding bit rate of the image to be coded in the previous frame and the estimated Lagrangian multiplier at the coding unit level of the image to be coded in the previous frame.
在本申请的一些实施例中,当前帧待编码图像表示为t时刻的待编码图线,那么,上一帧待编码图像的编码单元级的编码比特率采用
Figure PCTCN2019076305-appb-000005
表示,上一帧待编码图像的编码单元级的估计拉格朗日乘子采用
Figure PCTCN2019076305-appb-000006
表示,本申请实施例不作限制。
In some embodiments of the present application, the image to be encoded in the current frame is represented as the image to be encoded at time t, then the encoding unit-level encoding bit rate of the image to be encoded in the previous frame is
Figure PCTCN2019076305-appb-000005
Indicates that the estimated Lagrangian multiplier of the coding unit level of the image to be coded in the previous frame adopts
Figure PCTCN2019076305-appb-000006
It means that the embodiments of this application are not limited.
在S103中,率失真优化装置在获取了初始拉格朗日乘子、上一帧待编码图像的编码单元级的编码比特率和上一帧待编码图像的编码单元级的估计拉格朗日乘子之后,就可以上述获取的参数,结合预设编码比特率与估计拉格朗日乘子模型,得到当前帧待编码图像的编码单元级的估计拉格朗日乘子了。In S103, the rate-distortion optimization device obtains the initial Lagrangian multiplier, the coding unit-level coding bit rate of the image to be encoded in the previous frame, and the estimated Lagrangian coefficient at the coding unit level of the image to be encoded in the previous frame. After the multiplier, the parameters obtained above can be combined with the preset encoding bit rate and the estimated Lagrangian multiplier model to obtain the estimated Lagrangian multiplier at the coding unit level of the image to be encoded in the current frame.
在本申请实施例中,预设编码比特率与估计拉格朗日乘子模型是R-λ模型,预设编码比特率与估计拉格朗日乘子模型是帧级编码单元的编码比特和逼近最优的估计拉格 朗日乘子之间的对应关系。In the embodiment of the present application, the preset encoding bit rate and the estimated Lagrangian multiplier model are R-λ models, and the preset encoding bit rate and the estimated Lagrangian multiplier model are the sum of the encoded bits of the frame-level coding unit. Approximate the optimal estimation of the correspondence between Lagrangian multipliers.
在本申请的一些实施例中,预设编码比特率与估计拉格朗日乘子模型可以表示为公式(5),如下:In some embodiments of the present application, the preset coding bit rate and the estimated Lagrangian multiplier model can be expressed as formula (5), as follows:
Figure PCTCN2019076305-appb-000007
Figure PCTCN2019076305-appb-000007
其中,
Figure PCTCN2019076305-appb-000008
表示当前帧待编码图像的编码单元级的估计拉格朗日乘子,λ sys表示初始拉格朗日乘子,
Figure PCTCN2019076305-appb-000009
表示上一帧待编码图像的编码单元级的编码比特率,
Figure PCTCN2019076305-appb-000010
表示上一帧待编码图像的编码单元级的估计拉格朗日乘子,β表示模型参数,是通过数据拟合来确定的。
among them,
Figure PCTCN2019076305-appb-000008
Represents the estimated Lagrangian multiplier at the coding unit level of the image to be encoded in the current frame, λ sys represents the initial Lagrangian multiplier,
Figure PCTCN2019076305-appb-000009
Indicates the coding unit-level coding bit rate of the image to be coded in the previous frame,
Figure PCTCN2019076305-appb-000010
It represents the estimated Lagrangian multiplier at the coding unit level of the image to be coded in the previous frame, and β represents the model parameter, which is determined by data fitting.
可以理解的是,预设编码比特率与估计拉格朗日乘子模型表征的是时域邻近的待编码的编码单元间的R-λ模型。这样率失真优化装置就可以通过上一帧的已编码的编码单元来确定出当前帧的对应的编码单元的拉格朗日乘子了。由于拉格朗日乘子λ是图像的失真与编码比特率一阶导数,其物理意义就是率-失真曲线(R-D curve)在给定(R,D)点对应的斜率。那么,基于视频图像的信源变化多样性,待编码的视频序列的率-失真曲线形状与信源内容纹理及画面运动情况密切相关。因此,每个待编码视频序列,每帧待编码图像甚至每个编码单元都对应着独一无二的率-失真曲线,因此,不同的编码单元将对应不同的定点斜率值,各编码单元拉格朗日乘子λ的值将各不相同。率失真优化装置通过分析已编码的上一帧待编码图像的比特分布特性,为当前帧待编码图像的各个编码单元计算拉格朗日乘子,旨在有针对性地控制编码单元的比特消耗,提升当前帧待编码图像整体的编码效率。It is understandable that the preset coding bit rate and the estimated Lagrangian multiplier model represent the R-λ model between the coding units to be coded adjacent in the time domain. In this way, the rate-distortion optimization device can determine the Lagrangian multiplier of the corresponding coding unit of the current frame through the coded coding unit of the previous frame. Since the Lagrangian multiplier λ is the first derivative of the image distortion and the encoding bit rate, its physical meaning is the slope of the rate-distortion curve (R-D curve) at a given point (R, D). Then, based on the diversity of the source changes of the video image, the shape of the rate-distortion curve of the video sequence to be encoded is closely related to the texture of the source content and the picture motion. Therefore, each video sequence to be coded, each frame of image to be coded, and even each coding unit corresponds to a unique rate-distortion curve. Therefore, different coding units will correspond to different fixed-point slope values, and each coding unit Lagrangian The value of the multiplier λ will vary. The rate-distortion optimization device calculates Lagrangian multipliers for each coding unit of the current frame of the image to be coded by analyzing the bit distribution characteristics of the image to be coded in the previous frame that has been coded, aiming to control the bit consumption of the coding unit in a targeted manner , Improve the overall coding efficiency of the image to be coded in the current frame.
在S104中,率失真优化装置在得到了当前帧待编码图像的编码单元级的估计拉格朗日乘子之后,该率失真优化装置就可以采用当前帧待编码图像的编码单元级的估计拉格朗日乘子,进行当前帧待编码图像的率失真处理,选出编码单元的最佳编码模式,进而采用最佳编码模式对编码单元进行编码完成当前帧待编码图像的编码。In S104, after the rate-distortion optimization device obtains the estimated Lagrangian multiplier at the coding unit level of the image to be coded in the current frame, the rate-distortion optimization device can use the coding unit-level estimation of the image to be coded in the current frame. The Grange multiplier performs rate-distortion processing of the image to be encoded in the current frame, selects the best encoding mode of the encoding unit, and then uses the best encoding mode to encode the encoding unit to complete the encoding of the image to be encoded in the current frame.
需要说明的是,在本申请实施例中,率失真优化装置采用代价函数对当前帧待编码图像进行率失真处理,得到编码代价,根据编码代价进行不同编码模式下的比较,从而选择出代价最小的最佳编码模式。It should be noted that in the embodiment of the present application, the rate-distortion optimization device uses a cost function to perform rate-distortion processing on the image to be encoded in the current frame to obtain the encoding cost, and compare the encoding costs in different encoding modes according to the encoding cost to select the smallest cost The best encoding mode.
在本申请的一些实施例中,针对一帧待编码图像而言,代价函数可以表示为公式(6),如下:In some embodiments of the present application, for a frame of image to be encoded, the cost function can be expressed as formula (6), as follows:
min{J i=D ii·R i}                                (6) min{J i =D ii ·R i } (6)
其中,J i表示一帧待编码图像中第i个编码单元的编码代价,λ i表示一帧待编码图像中第i个编码单元的拉格朗日乘子,D i表示一帧待编码图像中第i个编码单元的重构图像的失真,R i表示一帧待编码图像中第i个编码单元的编码比特率。 Among them, J i represents the coding cost of the i-th coding unit in a frame of image to be coded, λ i represents the Lagrangian multiplier of the i-th coding unit in a frame of image to be coded, and D i represents a frame of image to be coded The distortion of the reconstructed image of the i-th coding unit in, R i represents the coding bit rate of the i-th coding unit in a frame of image to be coded.
在本申请实施例中,采用当前帧待编码图像的编码单元级的估计拉格朗日乘子,进行当前帧待编码图像的每个编码单元的率失真处理,得到编码代价,进而完成当前帧待编码图像的编码。In the embodiment of the present application, the estimated Lagrangian multiplier at the coding unit level of the image to be coded in the current frame is used to perform rate-distortion processing for each coding unit of the image to be coded in the current frame to obtain the coding cost, thereby completing the current frame The encoding of the image to be encoded.
可以理解的是,率失真优化装置对当前帧待编码图像进行率失真优化处理,实现编码的过程中,可以通过已编码完成的上一帧待编码图像的编码单元级的编码比特率和估计拉格朗日乘子,结合预设编码比特率与估计拉格朗日乘子模型,来得到当前帧待编码 图像的编码单元级的估计拉格朗日乘子,进而实现对率失真优化处理,实现编码,由于率失真优化装置可以基于上一帧待编码图像的比特率和估计拉格朗日乘子,干预当前帧待编码图像的所有编码单元的估计拉格朗日乘子,进而干预帧内编码单元的比特分布趋于平衡,从而提高了编码效率。It can be understood that the rate-distortion optimization device performs rate-distortion optimization processing on the image to be encoded in the current frame. During the encoding process, the encoding unit-level encoding bit rate of the image to be encoded in the previous frame that has been encoded can be used to estimate the bit rate. The Grange multiplier combines the preset coding bit rate and the estimated Lagrangian multiplier model to obtain the estimated Lagrangian multiplier at the coding unit level of the image to be coded in the current frame, thereby realizing the rate-distortion optimization processing, Realize encoding, because the rate-distortion optimization device can intervene in the estimated Lagrangian multipliers of all coding units of the image to be encoded in the current frame based on the bit rate of the image to be encoded in the previous frame and the estimated Lagrangian multiplier, thereby intervening in the frame The bit distribution of the inner coding unit tends to be balanced, thereby improving the coding efficiency.
基于上述实施例的实现基础上,下面详细介绍针对当前帧待编码图像的每个编码单元进行率失真优化的过程,如图2所示,具体实现过程包括:S201-S205。如下:Based on the implementation of the foregoing embodiment, the following describes in detail the process of rate-distortion optimization for each coding unit of the image to be encoded in the current frame. As shown in FIG. 2, the specific implementation process includes: S201-S205. as follows:
S201、获取当前帧待编码图像。S201: Acquire an image to be encoded in the current frame.
S202、若当前帧待编码图像为非首帧待编码图像,则获取当前帧待编码图像的第i个编码单元、初始拉格朗日乘子、上一帧待编码图像的第i个编码单元的编码比特率和上一帧待编码图像的第i个编码单元的估计拉格朗日乘子,其中i为大于等于1,且小于等于N的正整数,N为一帧待编码图像对应的编码单元的总数量。S202. If the image to be encoded in the current frame is not the first image to be encoded, obtain the i-th coding unit of the image to be encoded in the current frame, the initial Lagrangian multiplier, and the i-th encoding unit of the image to be encoded in the previous frame. The coding bit rate and the estimated Lagrangian multiplier of the i-th coding unit of the image to be coded in the previous frame, where i is a positive integer greater than or equal to 1 and less than or equal to N, and N is the corresponding to a frame of image to be coded The total number of coding units.
S203、根据初始拉格朗日乘子、上一帧待编码图像的第i个编码单元的编码比特率、上一帧待编码图像的第i个编码单元的估计拉格朗日乘子和预设编码比特率与估计拉格朗日乘子模型,得到当前帧待编码图像的第i个编码单元的估计拉格朗日乘子。S203. According to the initial Lagrangian multiplier, the coding bit rate of the i-th coding unit of the image to be coded in the previous frame, the estimated Lagrangian multiplier and the pre-coding unit of the i-th coding unit of the image to be coded in the previous frame Assuming the coding bit rate and the estimated Lagrangian multiplier model, the estimated Lagrangian multiplier of the i-th coding unit of the image to be coded in the current frame is obtained.
S204、将i加1,进行当前帧待编码图像的第i+1个编码单元的估计拉格朗日乘子的获取,直至获取到当前帧待编码图像的第N个编码单元的估计拉格朗日乘子为止。S204. Add 1 to i to obtain the estimated Lagrangian multiplier of the i+1th coding unit of the image to be coded in the current frame, until the estimated Lagrangian of the Nth coding unit of the image to be coded in the current frame is obtained Longer multiplier.
S205、采用当前帧待编码图像的第1个编码单元的估计拉格朗日乘子至当前帧待编码图像的第N个编码单元的估计拉格朗日乘子,进行当前帧待编码图像的率失真处理,进而完成当前帧待编码图像的编码。S205. Use the estimated Lagrangian multiplier of the first coding unit of the image to be coded in the current frame to the estimated Lagrangian multiplier of the Nth coding unit of the image to be coded in the current frame, and perform the calculation of the image to be coded in the current frame. Rate distortion processing, and then complete the encoding of the image to be encoded in the current frame.
在本申请实施例中,率失真优化装置在获取了待编码视频序列中的当前帧待编码图像之后,就可以对当前帧待编码图像中的每个编码单元进行处理,若当前帧待编码图像为非首帧待编码图像,率失真优化装置则获取当前帧待编码图像的第i个编码单元、初始拉格朗日乘子、上一帧待编码图像的第i个编码单元的编码比特率和上一帧待编码图像的第i个编码单元的估计拉格朗日乘子,基于上一帧待编码图像的对应的第i个编码单元的相关参数,得到当前帧待编码图像的第i个编码单元的估计拉格朗日乘子,进而实现率失真处理和编码了。In the embodiment of the present application, after the rate-distortion optimization device obtains the image to be encoded in the current frame of the video sequence to be encoded, it can process each coding unit in the image to be encoded in the current frame. Is the image to be encoded in the non-first frame, the rate-distortion optimization device obtains the encoding bit rate of the i-th coding unit of the image to be encoded in the current frame, the initial Lagrangian multiplier, and the encoding bit rate of the i-th encoding unit of the image to be encoded in the previous frame And the estimated Lagrangian multiplier of the i-th coding unit of the image to be coded in the previous frame, based on the relevant parameters of the corresponding i-th coding unit of the image to be coded in the previous frame, to obtain the i-th coding unit of the image to be coded in the current frame The estimated Lagrangian multiplier of a coding unit is used to realize rate-distortion processing and coding.
需要说明的是,在本申请实施例中,针对一帧待编码图像,可以将每帧待编码图像都划分为N个编码单元,因此,在当前帧待编码图像中可以有N个编码单元,从第1个编码单元开始,依次进行至第N个编码单元为止,完成当前帧待编码图像的编码代价的处理,选择最佳编码模式,进行当前帧待编码图像的编码。It should be noted that in the embodiment of the present application, for a frame of image to be encoded, each frame of image to be encoded can be divided into N coding units. Therefore, there may be N coding units in the image to be encoded in the current frame. Starting from the first coding unit and proceeding to the Nth coding unit in sequence, the processing of the coding cost of the image to be coded in the current frame is completed, the best coding mode is selected, and the coding of the image to be coded in the current frame is performed.
在本申请实施例中,i为大于等于1,且小于等于N的正整数,N为一帧待编码图像对应的编码单元的总数量。In this embodiment of the present application, i is a positive integer greater than or equal to 1 and less than or equal to N, and N is the total number of coding units corresponding to a frame of image to be encoded.
在本申请实施例中,率失真优化装置针对当前帧待编码单元的第i个编码单元,是根据初始拉格朗日乘子、上一帧待编码图像的第i个编码单元的编码比特率、上一帧待编码图像的第i个编码单元的估计拉格朗日乘子和预设编码比特率与估计拉格朗日乘子模型,即根据公式(5)得到当前帧待编码图像的第i个编码单元的估计拉格朗日乘子了,在得到当前帧待编码图像的第i个编码单元的估计拉格朗日乘子之后,就可以对该第i个编码单元进行率失真处理和编码,从而得到当前帧待编码图像的第i个编码单元的编码比特率了,这样率失真优化装置就可以采用当前帧待编码图像第i个编码单元的编码比特率和当前帧待编码图像第i个编码单元的估计拉格朗日乘子,进行当前帧待编码图像的第i+1个编码单元的估计拉格朗日乘子的获取了,即将i加1,进行当前帧待编码图像的第i+1个编码单元的估计拉格朗日乘子的获取,率失真优化装置采用这样的循环实现方式直至获取到当前帧待编码图像的第N个编码单元的估计拉格朗日乘子为止,完成了当前帧待编码图像的编码。即率失真优化装置采用当前帧待编码图像的第1个编码 单元的估计拉格朗日乘子至当前帧待编码图像的第N个编码单元的估计拉格朗日乘子,进行当前帧待编码图像的每个编码单元的率失真处理,进而完成当前帧待编码图像的编码。In the embodiment of the present application, the rate-distortion optimization device for the i-th coding unit of the unit to be coded in the current frame is based on the initial Lagrangian multiplier and the coding bit rate of the i-th coding unit of the image to be coded in the previous frame , The estimated Lagrangian multiplier and preset coding bit rate and estimated Lagrangian multiplier model of the i-th coding unit of the image to be encoded in the previous frame, that is, according to formula (5) to obtain the image of the current frame to be encoded The estimated Lagrangian multiplier of the i-th coding unit is obtained. After the estimated Lagrangian multiplier of the i-th coding unit of the image to be encoded in the current frame is obtained, the i-th coding unit can be rate-distorted Processing and encoding, so as to obtain the encoding bit rate of the i-th coding unit of the image to be encoded in the current frame, so that the rate-distortion optimization device can use the encoding bit rate of the i-th encoding unit of the image to be encoded in the current frame and the current frame to be encoded The estimated Lagrangian multiplier of the i-th coding unit of the image is obtained, and the estimated Lagrangian multiplier of the i+1-th coding unit of the image to be coded in the current frame is obtained, that is, i is increased by 1, and the current frame is waiting To obtain the estimated Lagrangian multiplier of the i+1th coding unit of the coded image, the rate-distortion optimization device adopts such a loop implementation method until the estimated Lagrangian of the Nth coding unit of the image to be coded in the current frame is obtained By the date of multiplier, the encoding of the image to be encoded in the current frame is completed. That is, the rate-distortion optimization device uses the estimated Lagrangian multiplier of the first coding unit of the image to be coded in the current frame to the estimated Lagrangian multiplier of the Nth coding unit of the image to be coded in the current frame to perform the current frame waiting The rate-distortion processing of each coding unit of the coded image completes the coding of the image to be coded in the current frame.
需要说明的是,在当前帧待编码图像为非首帧图像时,其每个编码单元都是按照S201-S205的过程实现编码的。It should be noted that when the image to be encoded in the current frame is a non-first frame image, each encoding unit thereof is encoded according to the process of S201-S205.
可以理解的是,由于率失真优化装置采用的是帧级编码单元的估计拉格朗日乘子进行率失真处理的,且率失真优化装置可以基于上一帧待编码图像的比特率和估计拉格朗日乘子,干预当前帧待编码图像的所有编码单元的估计拉格朗日乘子,进而干预帧内编码单元的比特分布趋于平衡,从而提高了编码效率。It is understandable that the rate-distortion optimization device uses the estimated Lagrangian multiplier of the frame-level coding unit to perform rate-distortion processing, and the rate-distortion optimization device can be based on the bit rate of the previous frame to be encoded and the estimated pull The Grange multiplier interferes with the estimated Lagrange multiplier of all coding units of the image to be coded in the current frame, thereby interfering with the bit distribution of the coding unit in the frame to balance, thereby improving the coding efficiency.
在本申请的一些实施例中,S103之前,本申请实施例提供的一种率失真优化方法还包括:S105和S106。如下:In some embodiments of the present application, before S103, a rate-distortion optimization method provided in an embodiment of the present application further includes: S105 and S106. as follows:
S105、获取初始编码比特率与拉格朗日乘子模型、预设帧级编码比特率模型、预设时域邻近近似编码比特率模型和预设时域邻近近似帧级编码比特率模型;S105. Obtain an initial coding bit rate and a Lagrangian multiplier model, a preset frame-level coding bit rate model, a preset time-domain proximity approximate coding bit rate model, and a preset time-domain proximity approximate frame-level coding bit rate model;
S106、根据初始编码比特率与拉格朗日乘子模型、预设帧级编码比特率模型、预设时域邻近近似编码比特率模型和预设时域邻近近似帧级编码比特率模型,得到预设编码比特率与估计拉格朗日乘子模型。S106. According to the initial coding bit rate and the Lagrangian multiplier model, the preset frame-level coding bit rate model, the preset time-domain proximity approximate coding bit rate model, and the preset time-domain proximity approximate frame-level coding bit rate model, obtain Preset encoding bit rate and estimated Lagrangian multiplier model.
在本申请实施例中,率失真优化装置在S103之前,获取预设编码比特率与估计拉格朗日乘子模型的过程为先获取已知的初始编码比特率与拉格朗日乘子模型、预设帧级编码比特率模型、预设时域邻近近似编码比特率模型和预设时域邻近近似帧级编码比特率模型;然后基于上述已知的模型获知到预设编码比特率与估计拉格朗日乘子模型公式(5)。In the embodiment of the present application, before S103, the rate-distortion optimization apparatus obtains the preset coding bit rate and the estimated Lagrangian multiplier model by first obtaining the known initial coding bit rate and the Lagrangian multiplier model , Preset frame-level coding bit rate model, preset time-domain proximity approximate coding bit rate model, and preset time-domain proximity approximate frame-level coding bit rate model; then based on the above known model, the preset coding bit rate and estimate Lagrange multiplier model formula (5).
在本申请的一些实施例中,率失真优化装置根据初始编码比特率与拉格朗日乘子模型、预设帧级编码比特率模型、预设时域邻近近似编码比特率模型和预设时域邻近近似帧级编码比特率模型,得到预设编码比特率与估计拉格朗日乘子模型的过程包括:S1061-S1064。如下:In some embodiments of the present application, the rate-distortion optimization device is based on the initial encoding bit rate and the Lagrangian multiplier model, the preset frame-level encoding bit rate model, the preset temporal proximity approximate encoding bit rate model, and the preset timing. The domain proximity approximates the frame-level coding bit rate model, the process of obtaining the preset coding bit rate and the estimated Lagrangian multiplier model includes: S1061-S1064. as follows:
S1061、根据初始编码比特率与拉格朗日乘子模型,推出编码单元的理论编码比特率与估计拉格朗日乘子模型和编码单元的实际编码比特率与估计拉格朗日乘子模型;S1061, according to the initial coding bit rate and Lagrangian multiplier model, deduces the theoretical coding bit rate and estimated Lagrangian multiplier model of the coding unit and the actual coding bit rate and estimated Lagrangian multiplier model of the coding unit ;
S1062、根据理论编码比特率与估计拉格朗日乘子模型和预设帧级编码比特率模型,得到编码单元级的理论最优拉格朗日乘子模型;S1062, according to the theoretical encoding bit rate and the estimated Lagrangian multiplier model and the preset frame-level encoding bit rate model, obtain the theoretical optimal Lagrangian multiplier model at the coding unit level;
S1063、根据实际编码比特率与估计拉格朗日乘子模型和预设帧级编码比特率模型,得到实际上一帧的帧级编码比特率模型;S1063: Obtain the actual frame-level encoding bit rate model of one frame according to the actual encoding bit rate and the estimated Lagrangian multiplier model and the preset frame-level encoding bit rate model;
S1064、根据理论最优拉格朗日乘子模型、预设时域邻近近似编码比特率模型、预设时域邻近近似帧级编码比特率模型和实际上一帧的帧级编码比特率模型,得到预设编码比特率与估计拉格朗日乘子模型。S1064. According to the theoretical optimal Lagrangian multiplier model, the preset temporal proximity approximate coding bit rate model, the preset temporal proximity approximate frame-level coding bit rate model and the actual frame-level coding bit rate model of one frame, Obtain the preset coding bit rate and the estimated Lagrangian multiplier model.
在本申请实施例中,率失真优化装置根据初始编码比特率与拉格朗日乘子模型,可以推出编码单元的理论编码比特率与估计拉格朗日乘子模型。In the embodiment of the present application, the rate-distortion optimization device can deduce the theoretical encoding bit rate of the coding unit and the estimated Lagrangian multiplier model based on the initial encoding bit rate and the Lagrangian multiplier model.
在本申请实施例中,初始编码比特率与拉格朗日乘子模型表征R-λ模型,是目前采用的R-λ模型,代表初始编码比特率与系统拉格朗日乘子的统一的对应关系,本申请实施例不限制其表现形式。In the embodiments of this application, the initial encoding bit rate and the Lagrangian multiplier model represent the R-λ model, which is the currently adopted R-λ model, which represents the unity of the initial encoding bit rate and the system Lagrangian multiplier Correspondence, the embodiment of this application does not limit its manifestation.
在本申请的一些实施例中,初始编码比特率与拉格朗日乘子模型可以表示为公式(7),如下:In some embodiments of the present application, the initial encoding bit rate and the Lagrangian multiplier model can be expressed as formula (7), as follows:
R=α·λ β                                              (7) R=α·λ β (7)
其中,α和β是模型参数,在实际使用过程中需要前期进行数据拟合来确定。Among them, α and β are model parameters, which need to be determined by data fitting in the actual use process.
在本申请实施例中,理论上,根据公式(7)可以推出在时刻t,对于当前帧待编码图像的第i个编码单元,其第i个编码单元的最优拉格朗日乘子
Figure PCTCN2019076305-appb-000011
与系统配置的系统拉格朗日乘子λ sys比值的β次方在数值上等于该编码单元i使用最优
Figure PCTCN2019076305-appb-000012
编码所产生的比特率
Figure PCTCN2019076305-appb-000013
与当前帧待编码图像使用系统配置的λ sys编码所产生比特率比值R t,isys),即得到编码单元的理论编码比特率与估计拉格朗日乘子模型,如公式(8)所示:
In the embodiment of this application, theoretically, according to formula (7), it can be inferred that at time t, for the i-th coding unit of the image to be coded in the current frame, the optimal Lagrangian multiplier of the i-th coding unit
Figure PCTCN2019076305-appb-000011
The ratio β to the system Lagrangian multiplier λ sys of the system configuration is numerically equal to the optimal use of the coding unit i
Figure PCTCN2019076305-appb-000012
Bit rate generated by encoding
Figure PCTCN2019076305-appb-000013
The ratio of the bit rate R t,isys ) generated by the λ sys encoding of the current frame to the image to be encoded using the system configuration is the theoretical encoding bit rate of the coding unit and the estimated Lagrangian multiplier model, as shown in formula (8 ) Shows:
Figure PCTCN2019076305-appb-000014
Figure PCTCN2019076305-appb-000014
其中,编码单元的理论编码比特率与估计拉格朗日乘子模型计算了两种情况的比值。不失一般性,在t时刻的编码单元i,若采用系统拉格朗日乘子λ sys进行编码,则产生的比特率用R t,isys)表示;若采用理想的最优拉格朗日乘子
Figure PCTCN2019076305-appb-000015
进行编码,则产生的比特率用
Figure PCTCN2019076305-appb-000016
表示,即R t,isys)表示为该帧的每个编码单元的比特率。最优拉格朗日乘子
Figure PCTCN2019076305-appb-000017
为寻求逼近的目标。
Among them, the theoretical coding bit rate of the coding unit and the estimated Lagrangian multiplier model calculates the ratio of the two cases. Without loss of generality, the coding unit i at time t, if the system Lagrangian multiplier λ sys is used for coding, the resulting bit rate is represented by R t,isys ); if the ideal optimal drawing is used Grange Multiplier
Figure PCTCN2019076305-appb-000015
Encoding, the resulting bit rate is
Figure PCTCN2019076305-appb-000016
Representation, that is, R t,isys ) represents the bit rate of each coding unit of the frame. Optimal Lagrangian multiplier
Figure PCTCN2019076305-appb-000017
To seek an approaching goal.
根据公式(9)来计算
Figure PCTCN2019076305-appb-000018
λ sys已知,R t,isys)和
Figure PCTCN2019076305-appb-000019
不能直接读取,因此需要对R t,isys)和
Figure PCTCN2019076305-appb-000020
进行建模。
Calculate according to formula (9)
Figure PCTCN2019076305-appb-000018
λ sys is known, R t,isys ) and
Figure PCTCN2019076305-appb-000019
It cannot be read directly, so R t,isys ) and
Figure PCTCN2019076305-appb-000020
Perform modeling.
需要说明的是,本申请实施例构建了一个假设的“帧级抽象编码单元”,代表整帧图像总体编码情况。该“帧级抽象编码单元”的比特率采用该帧图像所有编码单元实际的比特率均值。以系统拉格朗日乘子λ sys对应的“帧级抽象编码单元”为例,得到的“帧级抽象编码单元”的编码比特率R t,isys)。
Figure PCTCN2019076305-appb-000021
即为“帧级抽象编码单元”的比特率均值。
It should be noted that the embodiment of the present application constructs a hypothetical "frame-level abstract coding unit", which represents the overall coding situation of the entire frame image. The bit rate of the "frame-level abstract coding unit" adopts the actual average bit rate of all coding units of the frame image. Taking the “frame-level abstract coding unit” corresponding to the system Lagrangian multiplier λ sys as an example, the coding bit rate R t,isys ) of the “frame-level abstract coding unit” is obtained.
Figure PCTCN2019076305-appb-000021
It is the average bit rate of the "frame-level abstract coding unit".
也就是说,在本申请实施例中,预设帧级编码比特率模型表征一帧待编码图像的每个编码单元比特率均值与系统拉格朗日乘子(初始拉格朗日乘子)的对应关系。That is, in the embodiment of the present application, the preset frame-level coding bit rate model represents the average bit rate of each coding unit of a frame of image to be coded and the system Lagrangian multiplier (initial Lagrangian multiplier) The corresponding relationship.
示例性的,假设t时刻的帧待编码图像的预设帧级编码比特率模型可以表示为公式(9),如下:Exemplarily, it is assumed that the preset frame-level coding bit rate model of the frame to be coded at time t can be expressed as formula (9), as follows:
Figure PCTCN2019076305-appb-000022
Figure PCTCN2019076305-appb-000022
其中,
Figure PCTCN2019076305-appb-000023
表示为该帧的比特率均值,用于直接代替R t,isys)。
among them,
Figure PCTCN2019076305-appb-000023
It is expressed as the average bit rate of the frame, which is used to directly replace R t,isys ).
在本申请实施例中,率失真优化装置在得到了理论编码比特率与估计拉格朗日乘子模型和预设帧级编码比特率模型之后,就可以根据理论编码比特率与估计拉格朗日乘子模型和预设帧级编码比特率模型,得到编码单元级的理论最优拉格朗日乘子模型。In the embodiment of the present application, after the rate-distortion optimization device obtains the theoretical encoding bit rate and the estimated Lagrangian multiplier model and the preset frame-level encoding bit rate model, it can calculate the theoretical encoding bit rate and the estimated Lagrangian The daily multiplier model and the preset frame-level coding bit rate model are used to obtain the theoretical optimal Lagrangian multiplier model at the coding unit level.
率失真优化装置将公式(9)代入公式(8)中,得到编码单元级的理论最优拉格朗日乘子模型。The rate-distortion optimization device substitutes formula (9) into formula (8) to obtain the theoretical optimal Lagrangian multiplier model at the coding unit level.
在本申请实施例中,理论最优拉格朗日乘子模型可以表示为公式(10),如下:In the embodiment of this application, the theoretical optimal Lagrangian multiplier model can be expressed as formula (10), as follows:
Figure PCTCN2019076305-appb-000024
Figure PCTCN2019076305-appb-000024
需要说明的是,
Figure PCTCN2019076305-appb-000025
Figure PCTCN2019076305-appb-000026
在编码前无法获取。考虑到每帧待编码图像之间 的时域相关性,时域邻近的编码单元产生的比特率与当前编码单元编码产生的比特率极为近似,因此,采用时域邻近的编码单元比特率
Figure PCTCN2019076305-appb-000027
代替当前编码单元编码产生的比特率,如公式(11)所示:
It should be noted,
Figure PCTCN2019076305-appb-000025
with
Figure PCTCN2019076305-appb-000026
Not available before encoding. Taking into account the time domain correlation between the images to be encoded in each frame, the bit rate generated by the adjacent coding unit in the time domain is very similar to the bit rate generated by the current coding unit. Therefore, the bit rate of the adjacent coding unit in the time domain is adopted.
Figure PCTCN2019076305-appb-000027
Instead of the bit rate generated by encoding the current coding unit, as shown in formula (11):
Figure PCTCN2019076305-appb-000028
Figure PCTCN2019076305-appb-000028
在本申请实施例中,时域邻近的编码单元在编码过程使用的虽然不是最优拉格朗日乘子
Figure PCTCN2019076305-appb-000029
但是编码时域邻近的编码单元时使用的是上一帧实际使用的估计拉格朗日乘子
Figure PCTCN2019076305-appb-000030
因为
Figure PCTCN2019076305-appb-000031
是对最优拉格朗日乘子
Figure PCTCN2019076305-appb-000032
较好的估计,所以用来近似使用最优拉格朗日乘子
Figure PCTCN2019076305-appb-000033
产生的比特率结果,如公式(12)所示:
In the embodiment of this application, the coding units adjacent in the time domain are used in the encoding process although they are not the optimal Lagrangian multipliers.
Figure PCTCN2019076305-appb-000029
However, when coding adjacent coding units in the time domain, the estimated Lagrangian multiplier actually used in the previous frame is used.
Figure PCTCN2019076305-appb-000030
because
Figure PCTCN2019076305-appb-000031
Is the optimal Lagrangian multiplier
Figure PCTCN2019076305-appb-000032
A better estimate, so it is used to approximate the optimal Lagrangian multiplier
Figure PCTCN2019076305-appb-000033
The resulting bit rate result is shown in equation (12):
Figure PCTCN2019076305-appb-000034
Figure PCTCN2019076305-appb-000034
这样,率失真优化装置就可以根据公式(11)和公式(12)获取预设时域邻近近似编码比特率模型了,如公式(13)所示:In this way, the rate-distortion optimization device can obtain the preset time-domain proximity approximate coding bit rate model according to formula (11) and formula (12), as shown in formula (13):
Figure PCTCN2019076305-appb-000035
Figure PCTCN2019076305-appb-000035
在本申请实施例中,率失真优化装置还可以根据初始编码比特率与拉格朗日乘子模型,推出编码单元的实际编码比特率与估计拉格朗日乘子模型。In the embodiment of the present application, the rate-distortion optimization device may also deduce the actual coding bit rate of the coding unit and the estimated Lagrangian multiplier model based on the initial coding bit rate and the Lagrangian multiplier model.
需要说明的是,在t-1时刻的编码过程中,所有编码单元采用了独立的拉格朗日乘子
Figure PCTCN2019076305-appb-000036
进行编码,皆与系统分配的λ sys不相同。为了刻画t-1时刻的“帧级抽象编码单元”的比特率,以编码单元i为例,根据上一帧的第i个编码单元的实际编码使用的拉格朗日乘子
Figure PCTCN2019076305-appb-000037
和实际编码比特率
Figure PCTCN2019076305-appb-000038
结合系统拉格朗日乘子λ sys,基于公式(7)可以得到编码单元的实际编码比特率与估计拉格朗日乘子模型。
It should be noted that in the encoding process at time t-1, all coding units use independent Lagrangian multipliers
Figure PCTCN2019076305-appb-000036
Encoding is different from the λ sys allocated by the system. In order to characterize the bit rate of the "frame-level abstract coding unit" at time t-1, take coding unit i as an example, according to the Lagrangian multiplier used in the actual coding of the i-th coding unit of the previous frame
Figure PCTCN2019076305-appb-000037
And the actual encoding bit rate
Figure PCTCN2019076305-appb-000038
Combining the system Lagrangian multiplier λ sys , based on formula (7), the actual coding bit rate of the coding unit and the estimated Lagrangian multiplier model can be obtained.
示例性的,实际编码比特率与估计拉格朗日乘子模型如公式(14)所示:Exemplarily, the actual coding bit rate and the estimated Lagrangian multiplier model are shown in formula (14):
Figure PCTCN2019076305-appb-000039
Figure PCTCN2019076305-appb-000039
这样,率失真优化装置实际编码比特率与估计拉格朗日乘子模型和预设帧级编码比特率模型,得到实际上一帧的帧级编码比特率模型。In this way, the actual encoding bit rate of the rate-distortion optimization device and the estimated Lagrangian multiplier model and the preset frame-level encoding bit rate model are obtained to obtain the actual frame-level encoding bit rate model of one frame.
在本申请实施例中,将公式(14)代入到公式(10),即,将公式(14)应用至t-1时刻的所有编码单元,则可计算获得t-1时刻“帧级抽象编码单元”的比特率表达式,即得到实际上一帧的帧级编码比特率模型,即公式(15),如下:In the embodiment of this application, formula (14) is substituted into formula (10), that is, formula (14) is applied to all coding units at t-1, then the "frame-level abstract coding at t-1" can be calculated The bit rate expression of “unit” is the actual frame-level coding bit rate model of one frame, namely formula (15), as follows:
Figure PCTCN2019076305-appb-000040
Figure PCTCN2019076305-appb-000040
在本申请实施例中,t时刻“帧级抽象编码单元”的比特率
Figure PCTCN2019076305-appb-000041
也无法直接获取。同样因为待编码视频序列之间的时域相关性,时域邻近图像的“帧级抽象编码单元”比特率非常接近,那么将上一时刻的比特率均值用于近似当前时刻比特率均值,就可以得到预设时域邻近近似帧级编码比特率模型,如公式(16)所示:
In the embodiment of this application, the bit rate of the "frame-level abstract coding unit" at time t
Figure PCTCN2019076305-appb-000041
It cannot be obtained directly. Also because of the time-domain correlation between the video sequences to be encoded, the bit rates of the “frame-level abstract coding units” of neighboring images in the time domain are very close, so the average bit rate at the previous moment is used to approximate the average bit rate at the current moment. The preset time-domain proximity approximate frame-level coding bit rate model can be obtained, as shown in formula (16):
Figure PCTCN2019076305-appb-000042
Figure PCTCN2019076305-appb-000042
基于此,率失真优化装置就获取到了理论最优拉格朗日乘子模型公式(10)、预设时域邻近近似编码比特率模型公式(13)、预设时域邻近近似帧级编码比特率模型公式(16)和实际上一帧的帧级编码比特率模型公式(15),这样,率失真优化装置就可以根据理论最优拉格朗日乘子模型、预设时域邻近近似编码比特率模型、预设时域邻近近似帧级编码比特率模型和实际上一帧的帧级编码比特率模型,得到预设编码比特率与估 计拉格朗日乘子模型公式(5)了。Based on this, the rate-distortion optimization device obtains the theoretical optimal Lagrangian multiplier model formula (10), the preset time-domain proximity approximate coding bit rate model formula (13), and the preset time-domain proximity approximate frame-level coding bits Rate model formula (16) and the actual frame-level coding bit rate model formula (15) of one frame, in this way, the rate-distortion optimization device can be based on the theoretically optimal Lagrangian multiplier model and preset temporal proximity approximate coding The bit rate model, the preset time-domain proximity approximate frame-level coding bit rate model, and the actual frame-level coding bit rate model of one frame, obtain the preset coding bit rate and the estimated Lagrangian multiplier model formula (5).
在本申请实施例中,率失真优化装置将公式(15)代入公式(16),得到
Figure PCTCN2019076305-appb-000043
再将
Figure PCTCN2019076305-appb-000044
和公式(13)代入到公式(10),就得到了公式(5)。这样就得到了已编码完成的上一帧待编码图像的编码单元级的编码比特率和估计拉格朗日乘子,得到当前帧待编码图像的编码单元级的估计拉格朗日乘子的预设编码比特率与估计拉格朗日乘子模型了。
In the embodiment of this application, the rate-distortion optimization device substitutes formula (15) into formula (16) to obtain
Figure PCTCN2019076305-appb-000043
Then
Figure PCTCN2019076305-appb-000044
Substituting formula (13) into formula (10), formula (5) is obtained. In this way, the coding unit-level coding bit rate and estimated Lagrangian multiplier of the coding unit level of the previous frame to be coded are obtained, and the estimated Lagrangian multiplier of the coding unit level of the current frame to be coded image is obtained. Preset encoding bitrate and estimated Lagrangian multiplier model.
可以理解的是,率失真优化装置通过已编码完成的上一帧待编码图像的编码单元级的编码比特率和估计拉格朗日乘子,结合预设编码比特率与估计拉格朗日乘子模型,来得到当前帧待编码图像的编码单元级的估计拉格朗日乘子,进而实现对率失真优化处理,实现编码,由于率失真优化装置可以基于上一帧待编码图像的比特率和估计拉格朗日乘子,干预当前帧待编码图像的所有编码单元的估计拉格朗日乘子,进而干预帧内编码单元的比特分布趋于平衡,从而提高了编码效率。It is understandable that the rate-distortion optimization device uses the coding unit-level coding bit rate and estimated Lagrangian multiplier of the previously encoded image to be coded, combining the preset coding bit rate and the estimated Lagrangian multiplier. The sub-model is used to obtain the estimated Lagrangian multiplier at the coding unit level of the image to be encoded in the current frame, and then to achieve rate-distortion optimization processing and encoding, because the rate-distortion optimization device can be based on the bit rate of the image to be encoded in the previous frame And estimated Lagrangian multipliers, intervene in the estimated Lagrangian multipliers of all coding units of the image to be coded in the current frame, and further interfere with the bit distribution of the intra-frame coding units tending to balance, thereby improving coding efficiency.
示例性的,采用如图3所示的当前帧编码图像进行编码处理。图4为关闭本申请提供的率失真优化方式后的编码示意图,图5为开启本申请提供的率失真优化方式后的编码示意图;图中颜色越浅表示编码该单元比特率越高,反之颜色越深表示编码该单元的比特率越低,由图4和图5对比后可知:开启本申请提供的率失真优化方式后的编码率高,例如区域1。Exemplarily, the encoding process is performed using the encoding image of the current frame as shown in FIG. 3. Figure 4 is a schematic diagram of encoding after the rate-distortion optimization method provided by this application is turned off, and Figure 5 is a schematic diagram of encoding after the rate-distortion optimization method provided by this application is turned on; the lighter the color in the figure, the higher the bit rate of the encoding unit, and vice versa. The deeper it is, the lower the bit rate for encoding the unit. It can be seen from the comparison between FIG. 4 and FIG. 5 that the encoding rate after the rate-distortion optimization method provided by this application is turned on is higher, for example, area 1.
图6为关闭本申请提供的率失真优化方式后的编码单元划分分析图;图7为开启本申请提供的率失真优化方式后的编码单元划分分析图。对比图6和图7对比可以发现,部分区域比特提升,划分变得细密,例如区域2。图8为关闭本申请提供的率失真优化方式后的两个编码单元划分分析图;图9为开启本申请提供的率失真优化方式后的两个编码单元划分分析图,两个编码单元对应的视频图像内容为草坪,纹理复杂。图8中编码块划分简单,层次浅;图9中编码块的划分变得细密,划分层次加深,使用了相对多的编码比特数。FIG. 6 is an analysis diagram of coding unit division after the rate-distortion optimization method provided by this application is turned off; FIG. 7 is an analysis diagram of coding unit division after the rate-distortion optimization method provided by this application is turned on. Comparing Fig. 6 and Fig. 7, it can be found that the bits of some areas are improved and the division becomes finer, such as area 2. Figure 8 is an analysis diagram of the division of two coding units after the rate-distortion optimization method provided by this application is turned off; Figure 9 is an analysis diagram of the division of two coding units after the rate-distortion optimization method provided by this application is turned on, and the two coding units correspond to The video image content is lawn with complex texture. The coding block division in Fig. 8 is simple and the level is shallow; the coding block division in Fig. 9 becomes finer, the division level is deepened, and a relatively large number of coding bits are used.
通过上述图示可以看出本申请实施例提供的率失真优化方式可以提高编码效率。It can be seen from the above illustration that the rate-distortion optimization method provided by the embodiment of the present application can improve coding efficiency.
需要说明的是,本申请实施例并非直接控制编码比特率,而是通过更新拉格朗日乘子,干预编码模式抉择与编码四叉树划分深度来间接调整比特分布的。It should be noted that the embodiment of the present application does not directly control the encoding bit rate, but indirectly adjusts the bit distribution by updating the Lagrangian multiplier, intervening in encoding mode selection and encoding quadtree division depth.
示例性的,表1给出了在低延迟配置下的编码性能测试情况。测试使用的视频序列为H.265/HEVC的通用测试视频序列,按照通用测试标准对4个量化参数点22、27、32、37(即Class B、Class C、Class D和Class E)进行测试。性能评测以BD-Rate作为评测指标。BD-Rate表示在相同PSNR下,比特率的增加情况。BD-Rate为负值时表明编码器性能得到提升。测试使用开源的商用编码器x265v2.3版本,所有视频序列的测试结果如表1所示:引入本申请实施例提供的率失真优化方法时,Summary为-,表征提升,即编码器获得了性能提升,在Y(明亮度)上能够平均节省3.08%的比特率,在U(色度)能够平均节省3.6%的比特率,以及V(浓度)能够平均节省2.7%的比特率。Exemplarily, Table 1 shows the coding performance test situation in the low-latency configuration. The video sequence used in the test is the general test video sequence of H.265/HEVC, and the 4 quantization parameter points 22, 27, 32, 37 (ie Class B, Class C, Class D, and Class E) are tested according to the general test standard. . Performance evaluation uses BD-Rate as the evaluation index. BD-Rate represents the increase in bit rate under the same PSNR. When the BD-Rate is negative, it indicates that the encoder performance has been improved. The test uses the open source commercial encoder x265v2.3 version, and the test results of all video sequences are shown in Table 1: When the rate-distortion optimization method provided by the embodiment of this application is introduced, Summary is -, which means that the encoder has achieved performance The improvement can save an average bit rate of 3.08% on Y (brightness), an average bit rate of 3.6% on U (chroma), and an average bit rate of 2.7% on V (concentration).
表1Table 1
Figure PCTCN2019076305-appb-000045
Figure PCTCN2019076305-appb-000045
Figure PCTCN2019076305-appb-000046
Figure PCTCN2019076305-appb-000046
在本申请的一些实施例中,在S101之后,即获取当前帧待编码图像之后,本申请实施例提供的一种率失真优化方法还包括:S107和S108。如下:In some embodiments of the present application, after S101, that is, after acquiring the image to be encoded in the current frame, a rate-distortion optimization method provided in an embodiment of the present application further includes: S107 and S108. as follows:
S107、若当前帧待编码图像为首帧待编码图像,则获取初始拉格朗日乘子。S107: If the image to be encoded in the current frame is the image to be encoded in the first frame, obtain an initial Lagrangian multiplier.
S108、采用初始拉格朗日乘子,进行当前帧待编码图像的率失真处理,进而完成当前帧待编码图像的编码。S108: Using the initial Lagrangian multiplier, perform rate-distortion processing of the image to be encoded in the current frame, and then complete the encoding of the image to be encoded in the current frame.
在本申请实施例中,若当前帧待编码图像为首帧待编码图像,率失真优化装置则获取初始拉格朗日乘子,并采用初始拉格朗日乘子,进行当前帧待编码图像的率失真处理,进而完成当前帧待编码图像的编码。In the embodiment of the present application, if the image to be encoded in the current frame is the first image to be encoded, the rate-distortion optimization device obtains the initial Lagrangian multiplier, and uses the initial Lagrangian multiplier to perform the image processing of the current frame to be encoded Rate distortion processing, and then complete the encoding of the image to be encoded in the current frame.
需要说明的是,首帧待编码图像没有时域邻近的编码单元,因此,是需要采用初始拉格朗日乘子,进行首帧待编码图像的率失真处理,进而完成首帧待编码图像的编码的。It should be noted that the image to be encoded in the first frame does not have a temporally adjacent coding unit. Therefore, it is necessary to use the initial Lagrangian multiplier to perform rate-distortion processing of the image to be encoded in the first frame, and then complete the image to be encoded in the first frame. Coded.
在本申请的一些实施例中,S104之后,即采用当前帧待编码图像的编码单元级的估计拉格朗日乘子,进行当前帧待编码图像的率失真处理,进而完成当前帧待编码图像的编码之后,本申请实施例提供的一种率失真优化方法还包括:S109和S110。如下:In some embodiments of the present application, after S104, the estimated Lagrangian multiplier at the coding unit level of the image to be coded in the current frame is used to perform rate-distortion processing of the image to be coded in the current frame to complete the image to be coded in the current frame After the encoding, the rate-distortion optimization method provided in the embodiment of the present application further includes: S109 and S110. as follows:
S109、进入下一帧待编码图像的率失真优化流程。S109: Enter the rate-distortion optimization process of the next frame to be encoded.
S110、直至处理完待编码视频序列的最后一帧待编码图像编码完成。S110: Encoding of the last frame of the to-be-encoded image of the to-be-encoded video sequence is completed.
在本申请实施例中,率失真优化装置在处理完当前帧待编码图像之后,就可以进行下一帧待编码图像的处理了,即循环执行S101-104,即S201-S205的过程,直至处理完待编码视频序列的最后一帧待编码图像编码完成,结束流程。In the embodiment of the present application, after the rate-distortion optimization device has processed the image to be encoded in the current frame, it can process the image to be encoded in the next frame, that is, the process of S101-104, that is, S201-S205, is cyclically executed until processing When the encoding of the last frame of the to-be-encoded video sequence is completed, the process ends.
基于前述实施例的实现基础上,如图10所示,本申请实施例还提供了一种率失真优化装置1,包括:Based on the implementation of the foregoing embodiment, as shown in FIG. 10, an embodiment of the present application also provides a rate-distortion optimization device 1, including:
获取部分10,配置为获取当前帧待编码图像;及若所述当前帧待编码图像为非首帧待编码图像,则获取初始拉格朗日乘子、上一帧待编码图像的编码单元级的编码比特率和上一帧待编码图像的编码单元级的估计拉格朗日乘子;The acquiring part 10 is configured to acquire the image to be encoded in the current frame; and if the image to be encoded in the current frame is not the first frame to be encoded, acquiring the initial Lagrangian multiplier and the coding unit level of the image to be encoded in the previous frame The coding bit rate and the estimated Lagrangian multiplier at the coding unit level of the image to be coded in the previous frame;
计算部分11,配置为根据所述初始拉格朗日乘子、所述上一帧待编码图像的编码单元级的编码比特率和所述上一帧待编码图像的编码单元级的估计拉格朗日乘子和预设编码比特率与估计拉格朗日乘子模型,得到所述当前帧待编码图像的编码单元级的估计拉格朗日乘子;The calculation part 11 is configured to estimate the Lagrange based on the initial Lagrangian multiplier, the coding unit-level coding bit rate of the image to be coded in the previous frame, and the coding unit level of the image to be coded in the previous frame. A Lange multiplier and a preset encoding bit rate and an estimated Lagrangian multiplier model to obtain an estimated Lagrangian multiplier at the coding unit level of the image to be encoded in the current frame;
处理部分12,配置为采用所述当前帧待编码图像的编码单元级的估计拉格朗日乘子,进行所述当前帧待编码图像的率失真处理,进而完成所述当前帧待编码图像的编码。The processing part 12 is configured to use the estimated Lagrangian multiplier at the coding unit level of the image to be encoded in the current frame to perform rate-distortion processing of the image to be encoded in the current frame, and then to complete the processing of the image to be encoded in the current frame coding.
在本申请的一些实施例中,所述获取部分10,具体配置为若所述当前帧待编码图像为非首帧待编码图像,则获取所述当前帧待编码图像的第i个编码单元、所述初 始拉格朗日乘子、上一帧待编码图像的第i个编码单元的编码比特率和上一帧待编码图像的第i个编码单元的估计拉格朗日乘子,其中i为大于等于1,且小于等于N的正整数,N为一帧待编码图像对应的编码单元的总数量。In some embodiments of the present application, the acquiring part 10 is specifically configured to acquire the i-th coding unit of the current frame to be encoded if the image to be encoded in the current frame is not the first frame to be encoded, The initial Lagrangian multiplier, the coding bit rate of the i-th coding unit of the image to be coded in the previous frame, and the estimated Lagrangian multiplier of the i-th coding unit of the image to be coded in the previous frame, where i It is a positive integer greater than or equal to 1 and less than or equal to N, where N is the total number of coding units corresponding to a frame of image to be encoded.
在本申请的一些实施例中,所述计算部分11,具体配置为根据所述初始拉格朗日乘子、所述上一帧待编码图像的第i个编码单元的编码比特率、所述上一帧待编码图像的第i个编码单元的估计拉格朗日乘子和所述预设编码比特率与估计拉格朗日乘子模型,得到所述当前帧待编码图像的第i个编码单元的估计拉格朗日乘子;及将i加1,进行当前帧待编码图像的第i+1个编码单元的估计拉格朗日乘子的获取,直至获取到当前帧待编码图像的第N个编码单元的估计拉格朗日乘子为止。In some embodiments of the present application, the calculation part 11 is specifically configured to be based on the initial Lagrangian multiplier, the encoding bit rate of the i-th coding unit of the image to be encoded in the previous frame, and the The estimated Lagrangian multiplier of the i-th coding unit of the image to be encoded in the previous frame and the preset encoding bit rate and the estimated Lagrangian multiplier model to obtain the i-th image of the image to be encoded in the current frame The estimated Lagrangian multiplier of the coding unit; and adding 1 to i to obtain the estimated Lagrangian multiplier of the i+1-th coding unit of the image to be encoded in the current frame until the image to be encoded in the current frame is obtained The estimated Lagrangian multiplier of the Nth coding unit.
在本申请的一些实施例中,所述处理部分12,具体配置为采用所述当前帧待编码图像的第1个编码单元的估计拉格朗日乘子至所述当前帧待编码图像的第N个编码单元的估计拉格朗日乘子,进行所述当前帧待编码图像的率失真处理,进而完成所述当前帧待编码图像的编码。In some embodiments of the present application, the processing part 12 is specifically configured to use the estimated Lagrangian multiplier of the first coding unit of the image to be encoded in the current frame to the first coding unit of the image to be encoded in the current frame. The estimated Lagrangian multipliers of the N coding units perform rate-distortion processing of the image to be encoded in the current frame, and then complete the encoding of the image to be encoded in the current frame.
在本申请的一些实施例中,所述获取部分10,还配置为所述根据所述初始拉格朗日乘子、所述上一帧待编码图像的编码单元级的编码比特率和所述上一帧待编码图像的编码单元级的估计拉格朗日乘子和预设编码比特率与估计拉格朗日乘子模型,得到所述当前帧待编码图像的编码单元级的估计拉格朗日乘子之前,获取初始编码比特率与拉格朗日乘子模型、预设帧级编码比特率模型、预设时域邻近近似编码比特率模型和预设时域邻近近似帧级编码比特率模型;In some embodiments of the present application, the acquiring part 10 is further configured to encode the bit rate according to the initial Lagrangian multiplier, the encoding unit level of the image to be encoded in the previous frame, and the The estimated Lagrangian multiplier at the coding unit level of the image to be coded in the previous frame and the preset coding bit rate and the estimated Lagrangian multiplier model to obtain the estimated Lagrangian at the coding unit level of the image to be coded in the current frame Before the Lange multiplier, obtain the initial encoding bit rate and the Lagrangian multiplier model, the preset frame-level encoding bit rate model, the preset temporal proximity approximate encoding bit rate model, and the preset temporal proximity approximate frame-level encoding bits Rate model
所述计算部分11,还配置为根据所述初始编码比特率与拉格朗日乘子模型、所述预设帧级编码比特率模型、所述预设时域邻近近似编码比特率模型和所述预设时域邻近近似帧级编码比特率模型,得到所述预设编码比特率与估计拉格朗日乘子模型。The calculation part 11 is further configured to be based on the initial encoding bit rate and the Lagrangian multiplier model, the preset frame-level encoding bit rate model, the preset temporal proximity approximate encoding bit rate model, and the The preset time-domain proximity approximates the frame-level coding bit rate model, and the preset coding bit rate and the estimated Lagrangian multiplier model are obtained.
在本申请的一些实施例中,所述计算部分11,还具体配置为根据所述初始编码比特率与拉格朗日乘子模型,推出编码单元的理论编码比特率与估计拉格朗日乘子模型和编码单元的实际编码比特率与估计拉格朗日乘子模型;及根据所述理论编码比特率与估计拉格朗日乘子模型和所述预设帧级编码比特率模型,得到编码单元级的理论最优拉格朗日乘子模型;及根据实际编码比特率与估计拉格朗日乘子模型和所述预设帧级编码比特率模型,得到实际前一帧的帧级编码比特率模型;以及根据所述理论最优拉格朗日乘子模型、所述预设时域邻近近似编码比特率模型、所述预设时域邻近近似帧级编码比特率模型和所述实际前一帧的帧级编码比特率模型,得到所述预设编码比特率与估计拉格朗日乘子模型。In some embodiments of the present application, the calculation part 11 is further specifically configured to deduce the theoretical encoding bit rate of the coding unit and the estimated Lagrangian multiplier according to the initial encoding bit rate and the Lagrangian multiplier model. The actual coding bit rate and estimated Lagrangian multiplier model of the sub-model and coding unit; and according to the theoretical coding bit rate and the estimated Lagrangian multiplier model and the preset frame-level coding bit rate model, obtain The theoretical optimal Lagrangian multiplier model at the coding unit level; and according to the actual encoding bit rate and the estimated Lagrangian multiplier model and the preset frame-level encoding bit rate model, the actual frame level of the previous frame is obtained Coding bit rate model; and according to the theoretical optimal Lagrangian multiplier model, the preset time domain proximity approximate coding bit rate model, the preset time domain proximity approximate frame-level coding bit rate model, and the The actual frame-level coding bit rate model of the previous frame is used to obtain the preset coding bit rate and the estimated Lagrangian multiplier model.
在本申请的一些实施例中,所述获取部分10,还配置为所述获取当前帧待编码图像之后,若所述当前帧待编码图像为首帧待编码图像,则获取初始拉格朗日乘子;In some embodiments of the present application, the acquiring part 10 is further configured to acquire the initial Lagrangian multiplier after acquiring the image to be encoded in the current frame, if the image to be encoded in the current frame is the first image to be encoded child;
所述处理部分12,还配置为采用所述初始拉格朗日乘子,进行所述当前帧待编码图像的率失真处理,进而完成所述当前帧待编码图像的编码。The processing part 12 is further configured to use the initial Lagrangian multiplier to perform rate-distortion processing of the image to be encoded in the current frame, and then to complete the encoding of the image to be encoded in the current frame.
在本申请的一些实施例中,所述处理部分12,还配置为所述采用所述当前帧待编码图像的编码单元级的估计拉格朗日乘子,进行所述当前帧待编码图像的率失真处理,进而完成所述当前帧待编码图像的编码之后,进入下一帧待编码图像的率失真优化流程;直至处理完待编码视频序列的最后一帧待编码图像编码完成。In some embodiments of the present application, the processing part 12 is further configured to use the estimated Lagrangian multiplier at the coding unit level of the image to be encoded in the current frame to perform the calculation of the image to be encoded in the current frame. Rate-distortion processing, and after completing the encoding of the image to be encoded in the current frame, enter the rate-distortion optimization process of the image to be encoded in the next frame; the encoding of the image to be encoded in the last frame of the video sequence to be encoded is completed.
如图11所示,本申请实施例还提供了一种率失真优化装置,包括:As shown in FIG. 11, an embodiment of the present application also provides a rate-distortion optimization device, including:
处理器13、存储有所述处理器13可执行率失真优化指令的存储器14,和用于连接所述处理器13、所述存储器14的通信总线15,当所述率失真优化指令被执行时,实现上述的率失真优化方法。The processor 13, the memory 14 storing the rate-distortion optimization instruction executable by the processor 13, and the communication bus 15 for connecting the processor 13 and the memory 14, when the rate-distortion optimization instruction is executed , To achieve the above-mentioned rate-distortion optimization method.
在本申请的实施例中,上述处理器13可以为特定用途集成电路(Application  Specific Integrated Circuit,ASIC)、数字信号处理器(Digital Signal Processor,DSP)、数字信号处理装置(Digital Signal Processing Device,DSPD)、可编程逻辑装置(ProgRAMmable Logic Device,PLD)、现场可编程门阵列(Field ProgRAMmable Gate Array,FPGA)、中央处理器(Central Processing Unit,CPU)、控制器、微控制器、微处理器中的至少一种。可以理解地,对于不同的设备,用于实现上述处理器功能的电子器件还可以为其它,本申请实施例不作具体限定。帧内预测装置还可以包括存储器14,该存储器14可以与处理器13连接,其中,存储器14用于存储可执行程序代码,该程序代码包括计算机操作指令,上述存储器14可以是易失性存储器(volatile memory),例如随机存取存储器(Random-Access Memory,RAM);或者非易失性存储器(non-volatile memory),例如只读存储器(Read-Only Memory,ROM),快闪存储器(flash memory),硬盘(Hard Disk Drive,HDD)或固态硬盘(Solid-State Drive,SSD);或者上述种类的存储器的组合,并向处理器13提供指令和数据。In the embodiment of the present application, the aforementioned processor 13 may be an Application Specific Integrated Circuit (ASIC), a digital signal processor (Digital Signal Processor, DSP), a digital signal processing device (Digital Signal Processing Device, DSPD). ), programmable logic device (ProgRAMmable Logic Device, PLD), field programmable gate array (Field ProgRAMmable Gate Array, FPGA), central processing unit (Central Processing Unit, CPU), controller, microcontroller, microprocessor At least one of. It is understandable that, for different devices, the electronic devices used to implement the above-mentioned processor functions may also be other, which is not specifically limited in the embodiment of the present application. The intra-frame prediction apparatus may also include a memory 14, which may be connected to the processor 13, wherein the memory 14 is used to store executable program code, the program code includes computer operation instructions, and the memory 14 may be a volatile memory ( Volatile memory, such as random access memory (Random-Access Memory, RAM); or non-volatile memory (non-volatile memory), such as read-only memory (ROM), flash memory (flash memory) ), a hard disk (Hard Disk Drive, HDD) or a solid-state drive (Solid-State Drive, SSD); or a combination of the foregoing types of memories, and provides instructions and data to the processor 13.
在本申请的实施例中,通信总线15用于连接处理器13以及存储器14以及这些器件之间的相互通信。In the embodiment of the present application, the communication bus 15 is used to connect the processor 13 and the memory 14 and the mutual communication between these devices.
另外,在本申请实施例中的各功能模块可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能模块的形式实现。In addition, the functional modules in the embodiments of the present application 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-mentioned integrated unit can be realized 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 can be stored in a computer readable storage medium. Based on this understanding, the technical solution of this embodiment is essentially or correct The part that contributes to the prior art 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 enable a computer device (which can be a personal A computer, a server, or a network device, etc.) or a processor (processor) execute all or part of the steps of the method in this embodiment. The aforementioned storage media include: U disk, mobile hard disk, read only memory (Read Only Memory, ROM), random access memory (Random Access Memory, RAM), magnetic disk or optical disk and other media that can store program codes.
本申请实施例提供了一种计算机可读存储介质,其上存储有率失真优化指令,其中,所述率失真优化指令被处理器执行时,实现上述的率失真优化方法。An embodiment of the present application provides a computer-readable storage medium on which a rate-distortion optimization instruction is stored, where the rate-distortion optimization instruction is executed by a processor to implement the above-mentioned rate-distortion optimization method.
可以理解的是,率失真优化装置对当前帧待编码图像进行率失真优化处理,实现编码的过程中,可以通过已编码完成的上一帧待编码图像的编码单元级的编码比特率和估计拉格朗日乘子,结合预设编码比特率与估计拉格朗日乘子模型,来得到当前帧待编码图像的编码单元级的估计拉格朗日乘子,进而实现对率失真优化处理,实现编码,由于率失真优化装置可以基于上一帧待编码图像的比特率和估计拉格朗日乘子,干预当前帧待编码图像的所有编码单元的估计拉格朗日乘子,进而干预帧内编码单元的比特分布趋于平衡,从而提高了编码效率。It can be understood that the rate-distortion optimization device performs rate-distortion optimization processing on the image to be encoded in the current frame. During the encoding process, the encoding unit-level encoding bit rate of the image to be encoded in the previous frame that has been encoded can be used to estimate the bit rate. The Grange multiplier combines the preset coding bit rate and the estimated Lagrangian multiplier model to obtain the estimated Lagrangian multiplier at the coding unit level of the image to be coded in the current frame, thereby realizing the rate-distortion optimization processing, Realize encoding, because the rate-distortion optimization device can intervene in the estimated Lagrangian multipliers of all coding units of the image to be encoded in the current frame based on the bit rate of the image to be encoded in the previous frame and the estimated Lagrangian multiplier, thereby intervening in the frame The bit distribution of the inner coding unit tends to be balanced, thereby improving the coding efficiency.
本领域内的技术人员应明白,本申请的实施例可提供为方法、系统、或计算机程序产品。因此,本申请可采用硬件实施例、软件实施例、或结合软件和硬件方面的实施例的形式。而且,本申请可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器和光学存储器等)上实施的计算机程序产品的形式。Those skilled in the art should understand that the embodiments of the present application can be provided as methods, systems, or computer program products. Therefore, this application may adopt the form of hardware embodiments, software embodiments, or embodiments combining software and hardware. Moreover, this application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, optical storage, etc.) containing computer-usable program codes.
本申请是参照根据本申请实施例的方法、设备(系统)、和计算机程序产品的实现流程示意图和/或方框图来描述的。应理解可由计算机程序指令实现流程示意图和/或方框图中的每一流程和/或方框、以及实现流程示意图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数 据处理设备的处理器执行的指令产生用于实现在实现流程示意图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。This application is described with reference to the schematic diagrams and/or block diagrams of the implementation process of the method, equipment (system), and computer program product according to the embodiments of the application. It should be understood that computer program instructions can be used to implement each process and/or block in the schematic flow diagram and/or block diagram, and to implement a combination of processes and/or blocks in the schematic flow diagram and/or block diagram. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing equipment to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing equipment are generated A device for realizing the functions specified in one or more processes in the schematic flow chart and/or one block or multiple blocks in the block diagram.
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在实现流程示意图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。These computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable data processing equipment to work in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture including the instruction device. The device realizes the functions specified in one or more processes in the schematic diagram and/or one block or more in the block diagram.
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在实现流程示意图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。These computer program instructions can also be loaded on a computer or other programmable data processing equipment, so that a series of operation steps are executed on the computer or other programmable equipment to produce computer-implemented processing, so as to execute on the computer or other programmable equipment. The instructions provide steps for implementing functions specified in one or more processes in the schematic diagram and/or one block or more in the block diagram.
以上所述,仅为本申请的较佳实施例而已,并非用于限定本申请的保护范围。The above are only the preferred embodiments of the present application, and are not used to limit the protection scope of the present application.
工业实用性Industrial applicability
本申请实施例提供了一种率失真优化方法及装置、计算机可读存储介质,率失真优化装置对当前帧待编码图像进行率失真优化处理,实现编码的过程中,可以通过已编码完成的上一帧待编码图像的编码单元级的编码比特率和估计拉格朗日乘子,结合预设编码比特率与估计拉格朗日乘子模型,来得到当前帧待编码图像的编码单元级的估计拉格朗日乘子,进而实现对率失真优化处理,实现编码,由于率失真优化装置可以基于上一帧待编码图像的比特率和估计拉格朗日乘子,干预当前帧待编码图像的所有编码单元的估计拉格朗日乘子,进而干预帧内编码单元的比特分布趋于平衡,从而提高了编码效率。The embodiments of the present application provide a rate-distortion optimization method and device, and a computer-readable storage medium. The rate-distortion optimization device performs rate-distortion optimization processing on the image to be encoded in the current frame. During the encoding process, the encoding process can be completed by encoding. The coding unit-level coding bit rate and estimated Lagrangian multiplier of a frame of image to be coded are combined with the preset coding bit rate and the estimated Lagrangian multiplier model to obtain the coding unit level of the image to be coded in the current frame Estimate the Lagrangian multiplier, and then realize the rate-distortion optimization process and realize the encoding. Because the rate-distortion optimization device can intervene in the current frame of the image to be encoded based on the bit rate of the image to be encoded in the previous frame and the estimated Lagrange multiplier The estimated Lagrangian multipliers of all coding units in the frame, and then interfere with the bit distribution of the intra-frame coding units tend to be balanced, thereby improving the coding efficiency.

Claims (10)

  1. 一种率失真优化方法,其特征在于,包括:A rate-distortion optimization method, characterized in that it includes:
    获取当前帧待编码图像;Acquiring the image to be encoded in the current frame;
    若所述当前帧待编码图像为非首帧待编码图像,则获取初始拉格朗日乘子、上一帧待编码图像的编码单元级的编码比特率和上一帧待编码图像的编码单元级的估计拉格朗日乘子;If the image to be encoded in the current frame is not the first frame to be encoded, the initial Lagrangian multiplier, the encoding unit-level encoding bit rate of the image to be encoded in the previous frame, and the encoding unit of the image to be encoded in the previous frame are acquired Estimated Lagrange multiplier of the order;
    根据所述初始拉格朗日乘子、所述上一帧待编码图像的编码单元级的编码比特率和所述上一帧待编码图像的编码单元级的估计拉格朗日乘子和预设编码比特率与估计拉格朗日乘子模型,得到所述当前帧待编码图像的编码单元级的估计拉格朗日乘子;According to the initial Lagrangian multiplier, the coding unit-level coding bit rate of the image to be coded in the previous frame, and the estimated Lagrangian multiplier and pre-coding unit level of the image to be coded in the previous frame Set the coding bit rate and the estimated Lagrangian multiplier model to obtain the estimated Lagrangian multiplier at the coding unit level of the image to be coded in the current frame;
    采用所述当前帧待编码图像的编码单元级的估计拉格朗日乘子,进行所述当前帧待编码图像的率失真处理,进而完成所述当前帧待编码图像的编码。The estimated Lagrangian multiplier at the coding unit level of the image to be encoded in the current frame is used to perform rate-distortion processing of the image to be encoded in the current frame to complete the encoding of the image to be encoded in the current frame.
  2. 根据权利要求1所述的方法,其特征在于,所述若所述当前帧待编码图像为非首帧待编码图像,则获取初始拉格朗日乘子、上一帧待编码图像的编码单元级的编码比特率和上一帧待编码图像的编码单元级的估计拉格朗日乘子,包括:The method according to claim 1, wherein if the image to be encoded in the current frame is not the image to be encoded in the first frame, the initial Lagrangian multiplier and the encoding unit of the image to be encoded in the previous frame are acquired The coding bit rate of the previous frame and the estimated Lagrangian multiplier of the coding unit of the image to be coded in the previous frame include:
    若所述当前帧待编码图像为非首帧待编码图像,则获取所述当前帧待编码图像的第i个编码单元、所述初始拉格朗日乘子、上一帧待编码图像的第i个编码单元的编码比特率和上一帧待编码图像的第i个编码单元的估计拉格朗日乘子,其中i为大于等于1,且小于等于N的正整数,N为一帧待编码图像对应的编码单元的总数量。If the image to be encoded in the current frame is not the first image to be encoded, the i-th coding unit of the image to be encoded in the current frame, the initial Lagrangian multiplier, and the image to be encoded in the previous frame are acquired. The coding bit rate of i coding units and the estimated Lagrangian multiplier of the i-th coding unit of the image to be coded in the previous frame, where i is a positive integer greater than or equal to 1 and less than or equal to N, and N is a frame to be coded The total number of coding units corresponding to the coded image.
  3. 根据权利要求2所述的方法,其特征在于,所述根据所述初始拉格朗日乘子、所述上一帧待编码图像的编码单元级的编码比特率和所述上一帧待编码图像的编码单元级的估计拉格朗日乘子和预设编码比特率与估计拉格朗日乘子模型,得到所述当前帧待编码图像的编码单元级的估计拉格朗日乘子,包括:The method according to claim 2, wherein the encoding bit rate according to the initial Lagrangian multiplier, the coding unit level of the previous frame to be encoded, and the previous frame to be encoded The estimated Lagrangian multiplier at the coding unit level of the image and the preset coding bit rate and the estimated Lagrangian multiplier model to obtain the estimated Lagrangian multiplier at the coding unit level of the image to be coded in the current frame, include:
    根据所述初始拉格朗日乘子、所述上一帧待编码图像的第i个编码单元的编码比特率、所述上一帧待编码图像的第i个编码单元的估计拉格朗日乘子和所述预设编码比特率与估计拉格朗日乘子模型,得到所述当前帧待编码图像的第i个编码单元的估计拉格朗日乘子;According to the initial Lagrangian multiplier, the coding bit rate of the i-th coding unit of the image to be coded in the previous frame, and the estimated Lagrangian of the i-th coding unit of the image to be coded in the previous frame A multiplier and the preset encoding bit rate and an estimated Lagrangian multiplier model to obtain an estimated Lagrangian multiplier of the i-th coding unit of the image to be encoded in the current frame;
    将i加1,进行当前帧待编码图像的第i+1个编码单元的估计拉格朗日乘子的获取,直至获取到当前帧待编码图像的第N个编码单元的估计拉格朗日乘子为止。Add 1 to i to obtain the estimated Lagrangian multiplier of the i+1th coding unit of the image to be coded in the current frame until the estimated Lagrangian multiplier of the Nth coding unit of the image to be coded in the current frame is obtained Until the multiplier.
  4. 根据权利要求3所述的方法,其特征在于,所述采用所述当前帧待编码图像的编码单元级的估计拉格朗日乘子,进行所述当前帧待编码图像的率失真处理,进而完成所述当前帧待编码图像的编码,包括:The method according to claim 3, wherein the estimated Lagrangian multiplier at the coding unit level of the image to be encoded in the current frame is used to perform rate-distortion processing of the image to be encoded in the current frame, and then Completing the encoding of the image to be encoded in the current frame includes:
    采用所述当前帧待编码图像的第1个编码单元的估计拉格朗日乘子至所述当前帧待编码图像的第N个编码单元的估计拉格朗日乘子,进行所述当前帧待编码图像的率失真处理,进而完成所述当前帧待编码图像的编码。Use the estimated Lagrangian multiplier of the first coding unit of the image to be coded in the current frame to the estimated Lagrangian multiplier of the Nth coding unit of the image to be coded in the current frame to perform the current frame The rate-distortion processing of the image to be encoded further completes the encoding of the image to be encoded in the current frame.
  5. 根据权利要求1至4任一项所述的方法,其特征在于,所述根据所述初始拉格朗日乘子、所述上一帧待编码图像的编码单元级的编码比特率和所述上一帧待编码图像的编码单元级的估计拉格朗日乘子和预设编码比特率与估计拉格朗日乘子模型,得到所述当前帧待编码图像的编码单元级的估计拉格朗日乘子之前,所述方法还包括:The method according to any one of claims 1 to 4, wherein the encoding bit rate according to the initial Lagrangian multiplier, the encoding unit level of the image to be encoded in the previous frame, and the The estimated Lagrangian multiplier at the coding unit level of the image to be coded in the previous frame and the preset coding bit rate and the estimated Lagrangian multiplier model to obtain the estimated Lagrangian at the coding unit level of the image to be coded in the current frame Before the Lange multiplier, the method further includes:
    获取初始编码比特率与拉格朗日乘子模型、预设帧级编码比特率模型、预设时域邻近近似编码比特率模型和预设时域邻近近似帧级编码比特率模型;Obtain the initial coding bit rate and the Lagrangian multiplier model, the preset frame-level coding bit rate model, the preset time-domain proximity approximate coding bit rate model, and the preset time-domain proximity approximate frame-level coding bit rate model;
    根据所述初始编码比特率与拉格朗日乘子模型、所述预设帧级编码比特率模型、 所述预设时域邻近近似编码比特率模型和所述预设时域邻近近似帧级编码比特率模型,得到所述预设编码比特率与估计拉格朗日乘子模型。According to the initial coding bit rate and the Lagrangian multiplier model, the preset frame-level coding bit rate model, the preset time domain proximity approximate coding bit rate model, and the preset time domain proximity approximate frame level The coding bit rate model is used to obtain the preset coding bit rate and the estimated Lagrangian multiplier model.
  6. 根据权利要求5所述的方法,其特征在于,所述根据所述初始编码比特率与拉格朗日乘子模型、所述预设帧级编码比特率模型、所述预设时域邻近近似编码比特率模型和所述预设时域邻近近似帧级编码比特率模型,得到所述预设编码比特率与估计拉格朗日乘子模型,包括:The method according to claim 5, characterized in that, according to the initial coding bit rate and the Lagrangian multiplier model, the preset frame-level coding bit rate model, the preset time domain proximity approximation The coding bit rate model and the preset time-domain proximity approximate frame-level coding bit rate model to obtain the preset coding bit rate and the estimated Lagrangian multiplier model include:
    根据所述初始编码比特率与拉格朗日乘子模型,推出编码单元的理论编码比特率与估计拉格朗日乘子模型和编码单元的实际编码比特率与估计拉格朗日乘子模型;According to the initial coding bit rate and Lagrangian multiplier model, the theoretical coding bit rate and estimated Lagrangian multiplier model of the coding unit and the actual coding bit rate and estimated Lagrangian multiplier model of the coding unit are derived ;
    根据所述理论编码比特率与估计拉格朗日乘子模型和所述预设帧级编码比特率模型,得到编码单元级的理论最优拉格朗日乘子模型;Obtaining a theoretical optimal Lagrangian multiplier model at the coding unit level according to the theoretical coding bit rate and the estimated Lagrangian multiplier model and the preset frame-level coding bit rate model;
    根据实际编码比特率与估计拉格朗日乘子模型和所述预设帧级编码比特率模型,得到实际上一帧的帧级编码比特率模型;According to the actual encoding bit rate and the estimated Lagrangian multiplier model and the preset frame-level encoding bit rate model, obtain the actual frame-level encoding bit rate model of one frame;
    根据所述理论最优拉格朗日乘子模型、所述预设时域邻近近似编码比特率模型、所述预设时域邻近近似帧级编码比特率模型和所述实际上一帧的帧级编码比特率模型,得到所述预设编码比特率与估计拉格朗日乘子模型。According to the theoretical optimal Lagrangian multiplier model, the preset temporal proximity approximate coding bit rate model, the preset temporal proximity approximate frame-level coding bit rate model, and the actual frame of one frame Level coding bit rate model to obtain the preset coding bit rate and the estimated Lagrangian multiplier model.
  7. 根据权利要求1所述的方法,其特征在于,所述获取当前帧待编码图像之后,所述方法还包括:The method according to claim 1, characterized in that, after the obtaining the image to be coded in the current frame, the method further comprises:
    若所述当前帧待编码图像为首帧待编码图像,则获取初始拉格朗日乘子;If the image to be encoded in the current frame is the image to be encoded in the first frame, obtaining an initial Lagrangian multiplier;
    采用所述初始拉格朗日乘子,进行所述当前帧待编码图像的率失真处理,进而完成所述当前帧待编码图像的编码。The initial Lagrangian multiplier is used to perform rate-distortion processing of the image to be encoded in the current frame, thereby completing the encoding of the image to be encoded in the current frame.
  8. 根据权利要求1所述的方法,其特征在于,所述采用所述当前帧待编码图像的编码单元级的估计拉格朗日乘子,进行所述当前帧待编码图像的率失真处理,进而完成所述当前帧待编码图像的编码之后,所述方法还包括:The method according to claim 1, wherein the estimated Lagrangian multiplier at the coding unit level of the image to be encoded in the current frame is used to perform rate-distortion processing on the image to be encoded in the current frame, and then After the encoding of the image to be encoded in the current frame is completed, the method further includes:
    进入下一帧待编码图像的率失真优化流程;Enter the rate-distortion optimization process of the next frame to be encoded;
    直至处理完待编码视频序列的最后一帧待编码图像编码完成。The encoding of the image to be encoded until the last frame of the video sequence to be encoded is processed.
  9. 一种率失真优化装置,其特征在于,包括:A rate-distortion optimization device, characterized by comprising:
    处理器、存储有所述处理器可执行率失真优化指令的存储器,和用于连接所述处理器、所述存储器的通信总线,当所述率失真优化指令被执行时,实现如权利要求1-8任一项所述的方法。A processor, a memory storing a rate-distortion optimization instruction executable by the processor, and a communication bus for connecting the processor and the memory, and when the rate-distortion optimization instruction is executed, the implementation is as claimed in claim 1. -8 The method described in any one.
  10. 一种计算机可读存储介质,其特征在于,其上存储有率失真优化指令,其中,所述率失真优化指令被处理器执行时,实现如权利要求1-8任一项所述的方法。A computer-readable storage medium, characterized in that a rate-distortion optimization instruction is stored thereon, wherein, when the rate-distortion optimization instruction is executed by a processor, the method according to any one of claims 1-8 is implemented.
PCT/CN2019/076305 2019-02-27 2019-02-27 Rate distortion optimization method and apparatus, and computer-readable storage medium WO2020172813A1 (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201980073133.2A CN112970254B (en) 2019-02-27 2019-02-27 Rate distortion optimization method and device, and computer readable storage medium
PCT/CN2019/076305 WO2020172813A1 (en) 2019-02-27 2019-02-27 Rate distortion optimization method and apparatus, and computer-readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2019/076305 WO2020172813A1 (en) 2019-02-27 2019-02-27 Rate distortion optimization method and apparatus, and computer-readable storage medium

Publications (1)

Publication Number Publication Date
WO2020172813A1 true WO2020172813A1 (en) 2020-09-03

Family

ID=72238800

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/076305 WO2020172813A1 (en) 2019-02-27 2019-02-27 Rate distortion optimization method and apparatus, and computer-readable storage medium

Country Status (2)

Country Link
CN (1) CN112970254B (en)
WO (1) WO2020172813A1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116405690A (en) * 2023-06-01 2023-07-07 中南大学 Method, system and equipment for optimizing fast frame-level self-adaptive Lagrangian multiplier

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114554219A (en) * 2022-02-21 2022-05-27 翱捷科技股份有限公司 Rate distortion optimization method and device based on motion detection
CN116506631B (en) * 2023-06-20 2023-09-22 深圳比特微电子科技有限公司 Video encoding method, video encoding device and readable storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7738561B2 (en) * 2004-11-16 2010-06-15 Industrial Technology Research Institute MPEG-4 streaming system with adaptive error concealment
CN102780884A (en) * 2012-07-23 2012-11-14 深圳广晟信源技术有限公司 Rate distortion optimization method
CN103607590A (en) * 2013-11-28 2014-02-26 北京邮电大学 High efficiency video coding sensing rate-distortion optimization method based on structural similarity
CN104349167A (en) * 2014-11-17 2015-02-11 电子科技大学 Adjustment method of video code rate distortion optimization
CN105120282A (en) * 2015-08-07 2015-12-02 上海交通大学 Code rate control bit distribution method of temporal dependency
US9781449B2 (en) * 2011-10-06 2017-10-03 Synopsys, Inc. Rate distortion optimization in image and video encoding

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8094716B1 (en) * 2005-08-25 2012-01-10 Maxim Integrated Products, Inc. Method and apparatus of adaptive lambda estimation in Lagrangian rate-distortion optimization for video coding
CN102780886B (en) * 2012-07-23 2016-02-03 深圳广晟信源技术有限公司 Rate distortion optimization method
CN104954792B (en) * 2014-03-24 2018-02-27 兴唐通信科技有限公司 A kind of method and device that well as subjective video quality Optimized Coding Based is carried out to P frame sequences
CN106231320B (en) * 2016-08-31 2020-07-14 上海交通大学 Joint code rate control method and system supporting multi-machine parallel coding
US10469854B2 (en) * 2017-06-21 2019-11-05 Intel Corporation Content, psychovisual, region of interest, and persistence based adaptive quantization for video coding
CN108347611B (en) * 2018-03-02 2021-02-02 电子科技大学 Optimization method of coding block-level Lagrange multiplier for theodolite

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7738561B2 (en) * 2004-11-16 2010-06-15 Industrial Technology Research Institute MPEG-4 streaming system with adaptive error concealment
US9781449B2 (en) * 2011-10-06 2017-10-03 Synopsys, Inc. Rate distortion optimization in image and video encoding
CN102780884A (en) * 2012-07-23 2012-11-14 深圳广晟信源技术有限公司 Rate distortion optimization method
CN103607590A (en) * 2013-11-28 2014-02-26 北京邮电大学 High efficiency video coding sensing rate-distortion optimization method based on structural similarity
CN104349167A (en) * 2014-11-17 2015-02-11 电子科技大学 Adjustment method of video code rate distortion optimization
CN105120282A (en) * 2015-08-07 2015-12-02 上海交通大学 Code rate control bit distribution method of temporal dependency

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116405690A (en) * 2023-06-01 2023-07-07 中南大学 Method, system and equipment for optimizing fast frame-level self-adaptive Lagrangian multiplier
CN116405690B (en) * 2023-06-01 2023-09-01 中南大学 Method, system and equipment for optimizing fast frame-level self-adaptive Lagrangian multiplier

Also Published As

Publication number Publication date
CN112970254B (en) 2023-06-02
CN112970254A (en) 2021-06-15

Similar Documents

Publication Publication Date Title
WO2020172813A1 (en) Rate distortion optimization method and apparatus, and computer-readable storage medium
CN105049850B (en) HEVC bit rate control methods based on area-of-interest
CN105379269B (en) The Video coding of interest region perception
TWI677239B (en) Non-local adaptive loop filter combining multiple denoising technologies and grouping image patches in parallel
WO2022027881A1 (en) TIME DOMAIN RATE DISTORTION OPTIMIZATION METHOD BASED ON VIDEO SEQUENCE FEATURE AND QP-λ CORRECTION
CN108737841B (en) Coding unit depth determination method and device
EP3545677A1 (en) Methods and apparatuses for encoding and decoding video based on perceptual metric classification
CN107846593B (en) Rate distortion optimization method and device
US9210435B2 (en) Video encoding method and apparatus for estimating a code amount based on bit string length and symbol occurrence frequency
CN109413427A (en) A kind of video frame coding method and terminal
WO2021196682A1 (en) Time domain rate distortion optimization method based on distortion type propagation analysis
CN104754335B (en) A kind of code rate controlling method for video coding
CN108040256A (en) It is a kind of based on bit rate control method H.265, system and device
CN109660801A (en) The method for video coding that quantization parameter is limited
US10616585B2 (en) Encoding data arrays
WO2022021422A1 (en) Video coding method and system, coder, and computer storage medium
Zhang et al. Globally variance-constrained sparse representation and its application in image set coding
CN107682701B (en) Distributed video compression sensing self-adaptive grouping method based on perceptual hash algorithm
Hu et al. Frame level rate control for H. 264/AVC with novel rate-quantization model
Sanz-Rodríguez et al. A rate control algorithm for HEVC with hierarchical GOP structures
CN113709459B (en) Intra-frame prediction method, device and computer storage medium
CN112584143A (en) Video coding method, device and system and computer readable storage medium
Gao et al. Phase congruency based edge saliency detection and rate control for perceptual image and video coding
TW202137769A (en) Bit rate control method and video processing device
CN116405690B (en) Method, system and equipment for optimizing fast frame-level self-adaptive Lagrangian multiplier

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

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

Country of ref document: EP

Kind code of ref document: A1