Summary of the invention
The object of the invention is to propose a kind of in Video coding H.264 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 is selected 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 piece infra-frame prediction, utilize the top of 4 * 4 luminance block and coding and the reconstructed pixel of left, and 9 kinds of forecast models is realized infra-frame prediction;
Step 2:4x4 piece residual values is obtained, and utilizes the actual pixels of object-point to deduct the pixel value of the prediction that step 1 obtains, and obtains 4x4 piece residual values matrix X;
Step 3:DCT conversion, carries out dct transform to described 4x4 piece residual values matrix X, obtains Y matrix;
Step 4: assessment R value, utilize the nonzero coefficient and the hangover coefficient that scan through zig-zag in Y matrix, and motion vector assessment obtains R value;
Step 5:RDO optimizes, and is defined as follows cost function,
, wherein, D is original image pixels value and the absolute value sum of rebuilding the difference of image pixel value,
for the value relevant to quantization parameter QP, the R value that R obtains for assessment, by calculating
value, the person that selects Least-cost in all forecast models of 4x4 infra-frame prediction as optimum frame in forecast model.
Wherein said DCT conversion step comprises the steps:
in representing matrix, each element is multiplied by the coefficient on correspondence position in matrix E.
Wherein said assessment R value step is specially:
total_coeff scans the number of nonzero coefficient in Y matrix through zig-zag, Trailing_ones scans the number of hangover coefficient in Y matrix through zig-zag, Total_zero for scanning the number of last nonzero coefficient leading zero in Y matrix through zig-zag, Total_level in Y matrix through zig-zag scan all nonzero coefficients amplitude absolute value 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 piece intraprediction unit, utilize the top of 4 * 4 luminance block and coding and the reconstructed pixel of left, and 9 kinds of forecast models is realized infra-frame prediction;
4x4 piece residual values acquiring unit, utilizes the actual pixels of object-point to deduct the pixel value of the prediction that described 4x4 piece intraprediction unit obtains, and obtains 4x4 piece residual values matrix X;
Dct transform unit, carries out dct transform to described 4x4 piece residual values matrix X, obtains Y matrix;
Assessment R value cell, utilize the nonzero coefficient and the hangover coefficient that in Y matrix, through zig-zag, scan, and motion vector assessment obtains R value;
RDO optimizes unit, is defined as follows cost function,
, wherein, D is original image pixels value and the absolute value sum of rebuilding the difference of image pixel value,
for the value relevant to quantization parameter QP, the R value that R obtains for assessment, by calculating
value, the person that selects Least-cost in all forecast models of 4x4 infra-frame prediction as optimum frame in forecast model.
Wherein said DCT change unit comprises:
in representing matrix, each element is multiplied by the coefficient on correspondence position in matrix E.
Wherein said assessment R value cell is specially:
total_coeff scans the number of nonzero coefficient in Y matrix through zig-zag, Trailing_ones scans the number of hangover coefficient in Y matrix through zig-zag, Total_zero for scanning the number of last nonzero coefficient leading zero in Y matrix through zig-zag, Total_level in Y matrix through zig-zag scan all nonzero coefficients amplitude absolute value and, mv is motion vector.
Wherein said RDO optimizes in unit,
.
In the present invention, we have designed efficient adaptive frame internal schema and have selected code rate estimation method to predict code check for 4x4 intra prediction mode, under the condition that does not need entropy coding, predict code check.According to coded image, be that static sequence or the sequence of motion are come adaptively selected, thereby 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, in accompanying drawing, only show part related to the present invention but not entire infrastructure.
Embodiment 1:
Referring to Fig. 1, the H.264 rate-distortion optimization method of middle adaptive frame internal schema selection rate estimation is disclosed in the present embodiment, the method comprises the steps:
Step 101: 4x4 piece is carried out to infra-frame prediction
As shown in Figure 3, in this step, utilize the top of 4 * 4 luminance block and left pixel A-M for encoding and reconstructed pixel, as the prediction reference pixel in codec.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 encoded pixels prediction in A-M, and all the other patterns only all provide and could use in required predict pixel.To mode 3~8, predict pixel is obtained by A-M weighted average.
Step 102:4x4 piece residual values is obtained
By 4x4 piece infra-frame prediction, just can obtain the pixel value of the corresponding 4x4 position coordinates under different mode, i.e. the pixel value of a-p shown in Fig. 3, it represents with the matrix of a 4x4.Pixel value actual in Fig. 3 is known in encoder, deducts the pixel value of prediction with the actual pixel value of object-point, just obtains 4x4 piece residual values matrix, in the present embodiment, with X, represents 4x4 piece residual values matrix.
Step 103:DCT conversion
To obtaining 4x4 piece residual values matrix X in step 103, carry out dct transform, obtain matrix Y
In a specific embodiment, conversion process is:
Wherein,
in representing matrix, each element is multiplied by the coefficient on correspondence position in matrix E.
By dct transform, can further save image transmitting code check, compressing image signal, adopts transition coding, removes the correlation in picture signal and reduces the dynamic range of Image Coding.Transition coding is transformed into frequency-region signal by image time-domain signal, and in frequency domain, image signal energy major part concentrates on low frequency region, relative time-domain signal, and code check has larger decline.
Step 104: assessment R value:
The nonzero coefficient that utilization scans through zig-zag in Y matrix and hangover coefficient, and motion vector obtains R value.
Particularly:
First be defined as follows parameter:
1) Total_coeff: the number that scans nonzero coefficient in Y matrix through zig-zag.
2) Trailing_ones: the number that scans hangover coefficient in Y matrix through zig-zag.
3) Total_zero: the number that scans last nonzero coefficient leading zero in Y matrix through zig-zag.
4) Total_level: in Y matrix through zig-zag scan all nonzero coefficients amplitude absolute value and.
According to motion vector mv and formula (1), obtain R value, those skilled in the art should know that mv records and obtains in cataloged procedure H.264:
(1)
Step 105:RDO optimizes
Owing to H.264 only having stipulated the syntactic structure of coded bit stream and the structure of decoder in video encoding standard, and there is no concrete regulation for structure and the implementation pattern of encoder.
Therefore, in this step, according to formula (2), define cost function:
Wherein, D is original image pixels value and rebuild the absolute value sum of the difference of image pixel value, expression be original image through the distortion factor after restoring,
for the value relevant to quantization parameter QP, preferably,, the R value that R obtains for assessment.
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:
Referring to Fig. 2, the rate-distortion optimization device that a kind of H.264 middle adaptive frame internal schema is selected rate estimation is disclosed in the present embodiment, comprise as lower unit:
4x4 piece intraprediction unit, utilize the top of 4 * 4 luminance block and coding and the reconstructed pixel of left, and 9 kinds of forecast models is realized infra-frame prediction;
4x4 piece residual values acquiring unit, utilizes the actual pixels of object-point to deduct the pixel value of the prediction that described 4x4 piece intraprediction unit obtains, and obtains 4x4 piece residual values matrix X;
Dct transform unit, carries out dct transform to described 4x4 piece residual values matrix X, obtains Y matrix;
Assessment R value cell, utilize the nonzero coefficient and the hangover coefficient that in Y matrix, through zig-zag, scan, and motion vector assessment obtains R value;
RDO optimizes unit, is defined as follows cost function,
,
Wherein, D is original image pixels value and the absolute value sum of rebuilding the difference of image pixel value, and original image process is restored the distortion factor afterwards,
for the value relevant to quantization parameter QP, the R value that R obtains for assessment, by calculating
value, the person that selects Least-cost in all forecast models of 4x4 infra-frame prediction as optimum frame in forecast model.
Wherein said DCT change unit comprises:
in representing matrix, each element is multiplied by the coefficient on correspondence position in matrix E.
Wherein said assessment R value cell is specially:
total_coeff scans the number of nonzero coefficient in Y matrix through zig-zag, Trailing_ones scans the number of hangover coefficient in Y matrix through zig-zag, Total_zero for scanning the number of last nonzero coefficient leading zero in Y matrix through zig-zag, Total_level in Y matrix through zig-zag scan all nonzero coefficients amplitude absolute value 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 common joint specialist group forming of ISO and ITU provides, when 4x4 frame mode is selected, assessment R encodes actual computing to obtain by entropy, and operand is large.And rate-distortion optimization method of the present invention can be transplanted in JM, realize adaptive frame internal schema and selected rate estimation assessment R, realize on this basis RDO and optimize.
Again for example, the Video coding free software x264 that adopts GPL to authorize be one based on H.264.The major function of x264 is to carry out the H.264/MPEG-4 Video coding of AVC, at its 4x4 frame mode, selects, in code check estimation procedure, can select flexibly R estimation function according to rate-distortion optimization method of the present invention, obtains estimating code check, uses
the cost obtaining is selected best 4x4 frame mode.
Therefore, for adaptive frame internal schema of the present invention, select the rate distortion algorithm of code check estimation, can, according to the static or adaptive selection intra prediction mode of motion image sequence code check valuation functions, in RDO optimizes, there is adaptivity.And, H.264 in video coding process, can estimate fast the code check that in frame, 4x4 block prediction mode coding takies, and no longer need entropy to encode to obtain code check, can reduce the Video coding time.
Obviously, those skilled in the art should be understood that, above-mentioned each unit of the present invention or each step can realize with general calculation element, they can concentrate on single calculation element, or be distributed on the network that a plurality of calculation elements form, alternatively, they can realize with the executable program code of computer installation, thereby they can be stored in storage device and be carried out by calculation element, or they are made into respectively to each integrated circuit modules, or a plurality of modules in them or step are made into single integrated circuit module to be realized.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 only limits to this; for general technical staff of the technical field of the invention; without departing from the inventive concept of the premise; can also make some simple deduction or replace, all should be considered as belonging to the present invention and determine protection range by submitted to claims.