Summary of the invention
The object of the invention is to propose a kind of in H.264 Video coding adaptive frame internal schema select Rate-distortion optimization method (RDO) and the system thereof of rate estimation.
H.264 in Video coding, adaptive frame internal schema selects the Rate-distortion optimization method of rate estimation, comprising: 1. one kind H.264 in adaptive frame internal schema select the Rate-distortion optimization method of rate estimation, comprise the steps:
Step 1:4x4 block infra-frame prediction, utilize the top of 4 × 4 luminance block and the encoded of left and reconstructed pixel, and 9 kinds of forecast models realizes infra-frame prediction;
Step 2:4x4 block residual values obtains, and utilizes the actual pixels of object-point to deduct the pixel value of the prediction that step 1 obtains, obtains 4x4 block residual values matrix X;
Step 3:DCT converts, and carries out dct transform, obtain Y matrix to described 4x4 block residual values matrix X;
Step 4: assessment R value, utilize through the nonzero coefficient of zig-zag scanning and hangover coefficient in Y matrix, and motion vector assessment obtains R value;
Step 5:RDO optimizes, and is defined as follows cost function,
, wherein, D is the absolute value sum of original image pixels value and the difference of rebuilding image pixel value,
for the value relevant to quantization parameter QP, R assesses the R value obtained, by calculating
value, the person that selects Least-cost in all forecast models of 4x4 infra-frame prediction is as forecast model in optimum frame.
Wherein said DCT conversion step comprises the steps:
Wherein,
in representing matrix, each element is multiplied by the coefficient in matrix E on correspondence position.
Wherein said assessment R value step is specially:
total_coeff is the number scanning nonzero coefficient in Y matrix through zig-zag, Trailing_ones is the number through zig-zag scanning hangover coefficient in Y matrix, Total_zero is the number scanning last nonzero coefficient leading zero in Y matrix through zig-zag, Total_level be in Y matrix through zig-zag scan the amplitude absolute value of all nonzero coefficients and, mv is motion vector.
In wherein said RDO Optimization Steps,
。
The invention also discloses a kind of H.264 middle adaptive frame internal schema and select the rate-distortion optimization device of rate estimation, comprise as lower unit:
4x4 block intraprediction unit, utilize the top of 4 × 4 luminance block and the encoded of left and reconstructed pixel, and 9 kinds of forecast models realizes infra-frame prediction;
4x4 block residual values acquiring unit, utilizes the actual pixels of object-point to deduct the pixel value of the prediction that described 4x4 block intraprediction unit obtains, and obtains 4x4 block residual values matrix X;
Dct transform unit, carries out dct transform to described 4x4 block residual values matrix X, obtains Y matrix;
Assessment R value cell, utilize through the nonzero coefficient of zig-zag scanning and hangover coefficient in Y matrix, and motion vector assessment obtains R value;
RDO optimizes unit, is defined as follows cost function,
, wherein, D is the absolute value sum of original image pixels value and the difference of rebuilding image pixel value,
for the value relevant to quantization parameter QP, R assesses the R value obtained, by calculating
value, the person that selects Least-cost in all forecast models of 4x4 infra-frame prediction is as forecast model in optimum frame.
Wherein said DCT change unit comprises:
Wherein,
in representing matrix, each element is multiplied by the coefficient in matrix E on correspondence position.
Wherein said assessment R value cell is specially:
total_coeff is the number scanning nonzero coefficient in Y matrix through zig-zag, Trailing_ones is the number through zig-zag scanning hangover coefficient in Y matrix, Total_zero is the number scanning last nonzero coefficient leading zero in Y matrix through zig-zag, Total_level be in Y matrix through zig-zag scan the amplitude absolute value of all nonzero coefficients and, mv is motion vector.
Wherein said RDO optimizes in unit,
.
In the present invention, we are for 4x4 intra prediction mode, devise efficient adaptive frame internal schema and select code rate estimation method to predict code check, under the condition not needing entropy code, predict code check.Be that static sequence or the sequence of motion are come adaptively selected according to coded image, thus improve code efficiency, reduce time complexity, improve RDO efficiency.
Embodiment
Below in conjunction with drawings and Examples, the present invention is described in further detail.Be understandable that, specific embodiment described herein is only for explaining the present invention, but not limitation of the invention.It also should be noted that, for convenience of description, illustrate only part related to the present invention in accompanying drawing but not entire infrastructure.
Embodiment 1:
See Fig. 1, disclose adaptive frame internal schema H.264 in the present embodiment and select the Rate-distortion optimization method of rate estimation, the method comprises the steps:
Step 101: infra-frame prediction is carried out to 4x4 block
As shown in Figure 3, the top of 4 × 4 luminance block and left pixel A-M is utilized to be encoded and reconstructed pixel, as the prediction reference pixel in codec in this step.A-p is pixel to be predicted, utilizes A-M value and 9 kinds of forecast models to realize the pixel value prediction of a-p.Wherein pattern 2 (DC prediction) is according to pixel prediction encoded in A-M, and all the other patterns only all provide could use in required predict pixel.To mode 3 ~ 8, predict pixel is obtained by A-M weighted average.
Step 102:4x4 block residual values obtains
Just can be obtained the pixel value of the corresponding 4x4 position coordinates under different mode by 4x4 block infra-frame prediction, the pixel value of the a-p namely shown in Fig. 3, it represents with the matrix of a 4x4.Pixel value actual in Fig. 3 is known in the encoder, deducts the pixel value of prediction, just obtains 4x4 block residual values matrix, in the present embodiment, represent 4x4 block residual values matrix with X with the pixel value of the reality of object-point.
Step 103:DCT converts
Carrying out dct transform to obtaining 4x4 block residual values matrix X in step 103, obtaining matrix Y
In a specific embodiment, conversion process is:
Wherein,
in representing matrix, each element is multiplied by the coefficient in matrix E on correspondence position.
By dct transform, image transmitting code check can be saved further, compressing image signal, adopt transition coding, the dynamic range of the correlation in removal picture signal and reduction Image Coding.Image time-domain signal is transformed into frequency-region signal by transition coding, and image signal energy major part concentrates on low frequency region in a frequency domain, relative time-domain signal, and code check has larger decline.
Step 104: assessment R value:
Utilize through the nonzero coefficient of zig-zag scanning and hangover coefficient in Y matrix, and motion vector obtains R value.
Specifically:
First parameter is defined as follows:
1) Total_coeff: the number scanning nonzero coefficient in Y matrix through zig-zag.
2) Trailing_ones: through the number of zig-zag scanning hangover coefficient in Y matrix.
3) Total_zero: the number scanning last nonzero coefficient leading zero in Y matrix through zig-zag.
4) Total_level: scan through zig-zag in Y matrix the amplitude absolute value of all nonzero coefficients and.
Obtain R value according to motion vector mv and formula (1), those skilled in the art should know that mv records to obtain in cataloged procedure H.264:
(1)
Step 105:RDO optimizes
Merely specify the syntactic structure of coded bit stream and the structure of decoder due in H.264 video encoding standard, and concrete regulation is not had for the structure of encoder and implementation pattern.
Therefore, in this step, according to formula (2) definition cost function:
(2)
Wherein, D is original image pixels value and the absolute value sum of difference of rebuilding image pixel value, expression be the distortion factor of original image after restoring,
for the value relevant to quantization parameter QP, preferably, R assesses the R value obtained.
Like this, by calculating
value, at all forecast models of 4x4 infra-frame prediction, i.e. pattern 1-9, middle selection Least-cost person is as forecast model in optimum frame.
Embodiment 2:
See Fig. 2, disclose a kind of H.264 middle adaptive frame internal schema in the present embodiment and select the rate-distortion optimization device of rate estimation, comprise as lower unit:
4x4 block intraprediction unit, utilize the top of 4 × 4 luminance block and the encoded of left and reconstructed pixel, and 9 kinds of forecast models realizes infra-frame prediction;
4x4 block residual values acquiring unit, utilizes the actual pixels of object-point to deduct the pixel value of the prediction that described 4x4 block intraprediction unit obtains, and obtains 4x4 block residual values matrix X;
Dct transform unit, carries out dct transform to described 4x4 block residual values matrix X, obtains Y matrix;
Assessment R value cell, utilize through the nonzero coefficient of zig-zag scanning and hangover coefficient in Y matrix, and motion vector assessment obtains R value;
RDO optimizes unit, is defined as follows cost function,
,
Wherein, D is the absolute value sum of original image pixels value and the difference of rebuilding image pixel value, the distortion factor of original image after restoring,
for the value relevant to quantization parameter QP, R assesses the R value obtained, by calculating
value, the person that selects Least-cost in all forecast models of 4x4 infra-frame prediction is as forecast model in optimum frame.
Wherein said DCT change unit comprises:
Wherein,
in representing matrix, each element is multiplied by the coefficient in matrix E on correspondence position.
Wherein said assessment R value cell is specially:
total_coeff is the number scanning nonzero coefficient in Y matrix through zig-zag, Trailing_ones is the number through zig-zag scanning hangover coefficient in Y matrix, Total_zero is the number scanning last nonzero coefficient leading zero in Y matrix through zig-zag, Total_level be in Y matrix through zig-zag scan the amplitude absolute value of all nonzero coefficients and, mv is motion vector.
Wherein said RDO optimizes in unit,
.
Therefore, in the prior art, in the H.264 codec reference model JM that the joint specialist group that ISO and ITU forms jointly provides, when 4x4 intra mode decision, assessment R carrys out actual computing by entropy code to obtain, and operand is large.And Rate-distortion optimization method of the present invention can be transplanted in JM, achieve adaptive frame internal schema and select rate estimation assessment R, realize RDO on this basis and optimize.
Again such as, the Video coding free software x264 adopting GPL to authorize be one based on H.264.The major function of x264 is the Video coding carrying out H.264/MPEG-4 AVC, in its 4x4 intra mode decision rate estimation process, according to Rate-distortion optimization method of the present invention, can select R estimation function flexibly, obtains estimating code check, use
the cost obtained is to select best 4x4 frame mode.
Therefore, adaptive frame internal schema of the present invention is selected to the rate distortion algorithm of code check estimation, according to static or motion image sequence adaptive selection intra prediction mode code check valuation functions, adaptivity can be had in RDO optimizes.Further, 4x4 block prediction mode in frame can be estimated fast to encode the code check taken in H.264 video coding process, and no longer need entropy code to obtain code check, can video encoding time be reduced.
Obviously, those skilled in the art should be understood that, above-mentioned of the present invention each unit or each step can realize with general calculation element, they can concentrate on single calculation element, or be distributed on network that multiple calculation element forms, alternatively, they can realize with the executable program code of computer installation, thus they storages can be performed by calculation element in the storage device, or they are made into each integrated circuit modules respectively, or the multiple module in them or step are made into single integrated circuit module to realize.Like this, the present invention is not restricted to the combination of any specific hardware and software.
Above content is in conjunction with concrete preferred implementation further description made for the present invention; can not assert that the specific embodiment of the present invention is only limitted to this; for general technical staff of the technical field of the invention; without departing from the inventive concept of the premise; some simple deduction or replace can also be made, all should be considered as belonging to the present invention by submitted to claims determination protection range.