Summary of the invention
Purpose of the present invention is intended to one of solve the aforementioned problems in the prior at least.
For this reason, embodiments of the invention propose a kind of P frame coding method and device that can significantly reduce encoder complexity.
According to an aspect of the present invention, the embodiment of the invention has proposed a kind of P frame coding method, and described P frame coding method may further comprise the steps: a) P frame to be encoded is carried out down-sampling, be reduced to the down-sampling frame of prearranged multiple to obtain original resolution; B) described down-sampling frame is carried out model selection between intraframe predictive coding Intra and inter prediction encoding Inter coding mode; C) for the macro block that is selected as Intra in the described down-sampling frame, carry out intraframe predictive coding, and when rebuilding, sample on the whole, to obtain the reconstruction Intra macro block of original resolution size; D) for the macro block that is selected as Inter in the described down-sampling frame, the reference frame that utilizes the original resolution size carries out inter prediction encoding to the macro block of described Inter, the motion compensation of asymmetric resolution and residual error up-sampling are to obtain the reconstruction Inter macro block of original resolution; And e) utilize described reconstruction Intra macro block and described reconstruction Inter macro block to form the reconstruction P frame of original resolution.
The further embodiment according to the present invention, described step c comprises: c1) described macro block is carried out infra-frame prediction, conversion, quantification, inverse quantization, inverse transformation and infra-frame prediction compensation, to obtain having the reconstruction Intra macro block of described reduction resolution sizes; And c2) described reconstruction Intra macro block is sampled on the whole, to obtain described reconstruction Intra macro block with original resolution size.
The further embodiment according to the present invention, described steps d comprises: d1) utilize described reference frame that described macro block is carried out Motion estimation and compensation, obtaining corresponding motion vector and residual error, and determine the position of described macro block in described reference frame; D2) according to described position described motion vector is carried out equivalent up-sampling, expand a described motion vector as a plurality of motion vectors of corresponding described multiple take equivalence; D3) described residual error is sampled on the whole, to obtain the up-sampling residual error of corresponding original resolution size; And d4) with the reference block addition of described up-sampling residual error with the corresponding extraction of described a plurality of motion vectors, obtains described reconstruction Inter macro block.
The further embodiment according to the present invention, described step a comprises: described P frame to be encoded is carried out each down-sampling of 1/2 of row, column, to obtain as the described down-sampling frame of original resolution 1/4 multiple size.
The further embodiment according to the present invention, the method also comprises: the residual error that described infra-frame prediction obtains is carried out conversion and quantized to carry out afterwards the entropy coding; And compressed bit stream corresponding to output.Perhaps, with described motion vector and carry out conversion and quantize after residual error carry out the entropy coding; And compressed bit stream corresponding to output.
The further embodiment according to the present invention, described reconstruction P frame be not as the reference frame of next frame to be encoded.
According to a further aspect in the invention, embodiments of the invention propose a kind of P frame code device, described P frame code device comprises: down sample module, described down sample module are used for P frame to be encoded is carried out down-sampling, to obtain decrease resolution as the down-sampling frame of original resolution prearranged multiple; Mode selection module is used for the macro-block coding pattern of described down-sampling frame is carried out model selection between Intra/Inter; The Intra coding module, described Intra coding module carries out infra-frame prediction to the macro block that is selected as the Intra pattern in the described down-sampling frame, and samples on the whole when rebuilding, to obtain the reconstruction Intra macro block of original resolution size; The Inter coding module, described Inter coding module utilizes the reference frame of original resolution size that the macro block that is selected as the Inter pattern is carried out inter prediction encoding, the motion compensation of asymmetric resolution and residual error up-sampling are to obtain the reconstruction Inter macro block of original resolution; And synthesis module, described synthesis module utilizes described reconstruction Intra macro block and described reconstruction Inter macro block to form the reconstruction P frame of original resolution.
The further embodiment according to the present invention, described Intra coding module carries out infra-frame prediction, conversion, quantification, inverse quantization, inverse transformation and infra-frame prediction compensation, the reconstruction Intra macro block that obtains having described reduction resolution sizes to described macro block; And described reconstruction Intra macro block sampled on the whole, to obtain described reconstruction Intra macro block with original resolution size.
The further embodiment according to the present invention, described Inter coding module comprises: the Inter coding unit, described Inter coding unit utilizes described reference frame that described macro block is carried out Motion estimation and compensation, obtaining corresponding motion vector and residual error, and determine the position of described macro block in described reference frame; Motion vector up-sampling unit, described motion vector up-sampling unit carries out equivalent up-sampling with described motion vector, expands a described motion vector as a plurality of motion vectors of corresponding described multiple take equivalence; Residual error up-sampling unit, sample described residual error on the whole in described residual error up-sampling unit, to obtain the up-sampling residual error of corresponding original resolution size; And Inter macro block reconstruction unit, described Inter macro block reconstruction unit is with the reference block addition of described up-sampling residual error with the corresponding extraction of described a plurality of motion vectors, to obtain described reconstruction Inter macro block.
The further embodiment according to the present invention, described down sample module is carried out each down-sampling of 1/2 of row, column with described P frame to be encoded, to obtain as the described down-sampling frame of original resolution 1/4 multiple size.
The further embodiment according to the present invention also comprises the entropy coding module, and described entropy coding module is used for described motion vector and/or the described residual error after quantizing is carried out the entropy coding, and compressed bit stream corresponding to output.
The further embodiment according to the present invention, described reconstruction P frame be not as the reference frame of next frame to be encoded.
The present invention obtains a kind of novel R frame by P frame down-sampling coding.Like this, for Motion estimation and compensation part the most consuming time, its computation complexity is essentially 1/4 of original resolution frame, and several frees of losses of coding efficiency.Therefore, the present invention coding can effectively reduce computation complexity, and simultaneously, the video under, the simple mobile environment of texture little to some motions also can obviously improve code efficiency.The aspect that the present invention adds and advantage in the following description part provide, and part will become obviously from the following description, or recognize by practice of the present invention.
Embodiment
The below describes embodiments of the invention in detail, and the example of described embodiment is shown in the drawings, and wherein same or similar label represents same or similar element or the element with identical or similar functions from start to finish.Be exemplary below by the embodiment that is described with reference to the drawings, only be used for explaining the present invention, and can not be interpreted as limitation of the present invention.
The present invention proposes a kind of P frame code device and method, the P frame that obtains rebuilding can be referred to as a kind of novel R frame here, to solve the problems such as existing P frame coding techniques complexity is high, coding time is excessive.
In one embodiment of the invention, P frame code device can comprise down sample module, mode selection module, intraframe predictive coding (Intra) module, inter prediction encoding (Inter) module and synthesis module.
Specifically, down sample module is used for P frame to be encoded is carried out down-sampling, and to reduce the original resolution of input video, obtaining decrease resolution is the down-sampling frame of original resolution prearranged multiple.
Mode selection module is selected between Intra/Inter for the macro-block coding pattern of the down-sampling frame that will obtain, wherein by the Intra coding module macro block that is selected as the Intra pattern in the down-sampling frame is carried out infra-frame prediction and up-sampling, to obtain the reconstruction Intra macro block of original resolution size.And, utilized the reference frame of original resolution size by the Inter coding module, the macro block that is selected as the Inter pattern in the down-sampling frame is carried out inter prediction encoding, adopt motion compensation technique and the residual block up-sampling of asymmetric resolution, to obtain the reconstruction Inter macro block of original resolution.
At last, then will rebuild the Intra macro block and rebuild the reconstruction P frame that the Inter macro block forms original resolution by synthesis module.
With reference now to Fig. 2 and 3,, below in conjunction with this figure P frame code device structure and the operation principle of the embodiment of the invention are described in detail.
As shown in Figure 2, the P frame to be encoded of input video at first is input in the down sample module 30, thereby P frame to be encoded is carried out down-sampling, and then reduces the original resolution of this P frame.
In one embodiment, the down-sampling that down sample module 30 is carried out can be as shown in Figure 3, and here, down sample module 30 can be carried out each down-sampling of 1/2 of row, column to P frame to be encoded, thereby obtains the down-sampling frame into original resolution 1/4 multiple size.
As shown in Figure 3, according to interlacing, every the principle of row each pixel in the P frame to be encoded of original resolution is divided in four subframes, upper left, upper right, the lower-left that forms that horizontal and vertical resolution reduces by half, 4 subframes in bottom right (being down-sampling P frame).Here, only need to carry out follow-up coding on the basis of a down-sampling P frame therein.Certainly, this subframe can be any one in a plurality of subframes of dividing.
After obtaining the down-sampling frame, the macro block of the down-sampling frame being divided by Intra coding module and Inter coding module carries out the Intra/Inter coding.Usually the down-sampling frame is divided into the macro block of 16x16 size, by follow-up each macro block is encoded, thereby finish coding to this down-sampling frame.
In this case, each macro block still has 4 kinds of 16x16 intra prediction modes, 9 kinds of 4x4 intra prediction modes, and skip, 16x16,16x8,8x16,8x8,8x4,4x8,8 kinds of inter prediction macroblock modes such as 4x4.
Therefore, before macro block being carried out the correspondence coding, at first for all macro blocks to the down-sampling frame, intraprediction unit 31 and motion estimation unit 38 by P frame code device are carried out respectively infra-frame prediction and inter prediction, and according to its cost result of obtaining of corresponding cost function calculation unit 52 and 54 respectively, determine to be fit to the macro block part (Intra macro block) of infra-frame predictions and the macro block part (Inter macro block) of suitable inter prediction by mode selection module 56.Here, it can be existing system of selection that the macro-block coding pattern that mode selection module is corresponding is selected to judge.
Afterwards, Intra coding module and Inter coding module be the predictive mode corresponding according to each macro block respectively, carries out corresponding intraframe coding or interframe encode.
For the part macro block that adopts the Intra coding mode, the Intra coding module carries out infra-frame prediction, conversion, quantification, inverse quantization, inverse transformation and infra-frame prediction compensation to macro block, at first obtain corresponding down-sampling resolution, the reconstruction Intra macro block that namely reduces resolution sizes (also can be referred to as first and rebuild the Intra macro block, corresponding 16x16 size), and then this reconstruction Intra macro block sampled on the whole, with the reconstruction Intra macro block (also can be referred to as second and rebuild the Intra macro block, corresponding 32x32 size) that obtains corresponding original resolution size.
In Fig. 2 embodiment, aforesaid operations can be by the on the whole corresponding execution of sampling unit 48 philosophies of intraprediction unit 31, converter unit 32, quantifying unit 34, inverse quantization unit 44, inverse transformation unit 46, infra-frame prediction reconstruction unit 49 and reconstructed block.
In addition, for the part macro block that adopts the Inter coding mode, the Inter coding module utilizes reference frame that macro block is carried out Motion estimation and compensation.
As shown in Figure 2, the Inter coding module comprises motion estimation unit 38 and motion compensation units 40, obtaining respectively corresponding residual sum motion vector, and the position of definite macro block in reference frame.The reference frame of estimation unit 38 is encoded I frame or P frame of the former frame of original resolution size.
The schematic diagram that carries out estimation about the Inter macro block of 38 pairs of down-sampling frames of motion estimation unit can be with reference to the embodiment of the invention of figure 4.
For example, for decrease resolution be the down-sampling frame f of original resolution 1/4 multiple
t 1/4(corresponding current encoded frame, constantly Time=t), motion estimation unit 38 is in conjunction with reference frame f
T-1(corresponding last coded frame, constantly Time=t-1) can calculate its for motion vector MV.And motion compensation units 40 can determine that by the motion vector MV that estimation unit 38 calculates this macro block is at reference frame f
T-1In the position.
But, because the resolution of down-sampling frame reduces, therefore also need the motion vector that this macro block is corresponding to carry out up-sampling.Motion vector (MV) up-sampling unit 42 is used for the motion vector computation value that each macro block is corresponding and carries out equivalent up-sampling, expands a motion vector as a plurality of motion vectors of corresponding resolution minification take equivalence.
About asymmetric resolution motion compensation (that is, the motion vector up-sampling) principle of motion vector up-sampling unit 42, make an explanation below in conjunction with the embodiment of Fig. 5 and Fig. 6.Wherein, Fig. 5 is the Inter macro block motion compensation principle schematic of the embodiment of the invention, and Fig. 6 is conventional P frame Inter macro block motion compensation principle schematic.
For example, for reduction by 1/4 multiple resolution sizes shown in Figure 5 and be selected from the upper left down-sampling frame of P frame to be encoded f
t 1/4, need to utilize the motion compensation of asymmetric resolution, the motion vector of macro block is carried out equivalent up-sampling, be extended for 4 motion vectors with equivalence.That is, a motion vector that obtains with estimation extracts simultaneously that corresponding this macro block is upper right, the reference block of 3 positions of lower-left, position, bottom right, makes upper right, the lower-left of this macro block, bottom-right macro block have identical motion vector.Like this, with down-sampling frame f
t 1/4The macro block of corresponding 16x16 size is extended for the 32x32 size, is the original resolution reconstruction frames f with 2 * 2 times of sizes of this macro block
t
So, just can in reference frame, extract the reference block of 2 * 2 times of sizes of this macro block, thereby so that reference block had the original resolution size.
From upper and lower two frames shown in Fig. 5 and Fig. 6 right side as can be known, the motion compensation frame corresponding to estimation of conventional P frame Inter macro block is equal resolution, and as can be seen from Figure 5, the motion compensation of Inter macro block of the present invention frame corresponding to estimation is asymmetric resolution frame.
In addition, after motion estimation unit 38 obtains residual error, by converter unit 32, quantifying unit 34 residual error is carried out conversion, quantification.Then, again the residual error after quantizing is carried out inverse quantization, inverse transformation by inverse quantization unit 44, inverse transformation unit 46.Then be input in the residual error up-sampling unit 47, sample on the whole so that the residual error that obtains is carried out residual error, thereby obtain the up-sampling residual error of corresponding original resolution size.
Then, as shown in Figure 2, the up-sampling residual error addition that the reference block that the corresponding up-sampling motion vectors in motion vector up-sampling unit 42 are extracted and up-sampling unit 47 are exported under the Inter pattern, thus the Inter macro block reconstructed value of corresponding original resolution obtained, namely rebuild the Inter macro block.
At last, synthesis module 50 will rebuild Inter macro block and reconstructed block on the whole the reconstruction Intra macro block of the original resolution when Intra predicts, exported of sampling unit 48 form, thereby obtain the reconstruction P frame of original resolution, i.e. novel R frame.
In one embodiment, lose too much for fear of video information, guarantee better picture quality, novel R frame can be not as the reference frame of next frame to be encoded.
In embodiments of the present invention, P frame code device can also comprise entropy coding module 36, is used for carrying out data entropy coding, and compressed bit stream corresponding to output.The residual error that obtains when infra-frame prediction is input in the entropy coding module 36 after change unit 32 and quantifying unit 34 are carried out conversion and quantized, to carry out entropy coding and output squeezing code stream.And when inter prediction, the residual sum motion vector that motion estimation unit 38 obtains also is input in the entropy coding module 36.
In addition, the invention allows for a kind of P frame coding method, the method may further comprise the steps: P frame to be encoded is carried out down-sampling, to obtain decrease resolution as the down-sampling frame of original resolution prearranged multiple.Then, the down-sampling frame is carried out model selection between Intra and Inter coding mode.Wherein, the macro block for being selected as Intra in the down-sampling frame carries out intraframe predictive coding and up-sampling, to obtain the reconstruction Intra macro block of original resolution size; For the macro block that is selected as Inter in the sample frame, the reference frame that utilizes the original resolution size carries out inter prediction encoding to the macro block of Inter, and the motion compensation of asymmetric resolution and residual block up-sampling are to obtain the reconstruction Inter macro block of original resolution.At last, utilize the reconstruction P frame of rebuilding the Intra macro block and rebuilding Inter macro block composition original resolution.
Below, in conjunction with Fig. 6 the concrete steps flow process of the P frame coding method of the embodiment of the invention is provided detailed description.
At first obtain P frame to be encoded (step 202) corresponding to input video, and P frame to be encoded is carried out down-sampling (step 204), thus a plurality of subframes of the resolution that is reduced, and for example resolution is 4 subframes of original resolution 1/4 multiple size.Particularly, P frame to be encoded can be carried out each down-sampling of 1/2 of row, column.Here, only need from a plurality of subframes of dividing, to select any one down-sampling frame as next code, for example select upper left subframe.
After obtaining the down-sampling frame, the macro block that the down-sampling frame is divided carries out the Intra/Inter coding.Usually this down-sampling frame is carried out macroblock partitions (step 205), thereby be divided into the macro block of 16x16 size.By follow-up each macro block is encoded, thereby finish coding to this down-sampling frame.
Wherein each macro block still has 16x16 intra prediction mode in 4, and 9 kinds of 4x4 intra prediction modes except the skip pattern, have 16x16,16x8,8x16,8x8,8x4,4x8,7 kinds of inter prediction macroblock modes such as 4x4.
Before macro block being carried out the correspondence coding, at first for all macro blocks of down-sampling frame, judge which adopts intraframe coding in division macro block corresponding to down-sampling frame, which adopts interframe encode (step 206).
Particularly, for all macro blocks to the down-sampling frame, carry out respectively infra-frame prediction and inter prediction, and according to cost function calculation result corresponding to difference under two kinds of predictive modes, determine to be fit to the Intra macro block of infra-frame prediction and the Inter macro block of suitable inter prediction.
Intra macro block for adopting intraframe coding goes to step 208; Otherwise go to step 210.
When carrying out intraframe coding, at first carry out the infra-frame prediction (step 208) of down-sampling frame, and the residual error that infra-frame prediction obtains is carried out conversion (step 214), quantized (step 216).Then be divided into two-way parallel processing (step 218), the one tunnel carries out entropy coding (step 220), output squeezing code stream (step 222); Another road forwards the reconstruction that step 224 is carried out the Intra macro block to.
In the process of reconstruction of Intra macro block, the residual error after at first step 216 being quantized is carried out inverse quantization (step 224), inverse transformation (step 226).Then, carry out infra-frame prediction and rebuild, obtain corresponding down-sampling resolution, namely reduce the reconstruction Intra macro block (step 230) of resolution sizes, and this reconstruction macro block sampled (step 232) on the whole, obtain the reconstruction Intra macro block of original resolution size.
The Inter macro block that adopts inter prediction is carried out estimation (step 210) and motion compensation (step 212), and its reference frame is P frame former frame to be encoded and is the I frame of original resolution size or the P frame of having encoded.
At first by step 210, obtain residual sum motion vector corresponding to this macro block.And, by step 212, can obtain the position of this macro block in reference frame according to the motion vector computation that estimation obtains.
Then, the residual error that obtains in the motion-estimation step is carried out conversion (step 214), quantized (step 216), be divided into afterwards the two-way parallel processing, one the tunnel with motion vector and the residual error after quantizing carry out entropy coding (step 220), and output squeezing code stream (step 222), another road forwards the reconstruction that step 224 is carried out macro block to.
When the reconstruction of Inter macro block, at first the residual error after quantizing is carried out inverse transformation (step 224), inverse quantization (step 226), then when being judged as the corresponding residual error of inter prediction (step 228), the residual error that obtains is carried out residual error up-sampling (step 234), obtain the up-sampling residual error of corresponding original resolution size.
When motion compensation, except the position that utilizes this macro block of motion vector computation in reference frame, also need the multiple according to down-sampling frame frame decrease resolution, carry out motion vector up-sampling (step 236), be about to this motion vector equivalence and be extended for a plurality of motion vectors.
For example, for reducing by 1/4 multiple resolution sizes and being selected from the upper left down-sampling frame of P frame to be encoded, need to utilize the motion compensation of asymmetric resolution, motion vector to macro block carries out equivalent up-sampling, be extended for 4 motion vectors with equivalence, it is upper right that a motion vector that namely obtains with estimation extracts corresponding this macro block simultaneously, the lower-left, the reference block of 3 positions of position, bottom right, make the upper right of this macro block, the lower-left, bottom-right macro block has identical motion vector, so just, can in reference frame, extract the reference block of this macro block 2 * 2 sizes, thereby so that reference block had the original resolution size.
At this moment, the residual error behind the residual error up-sampling that the corresponding reference block that extracts of a plurality of motion vectors behind the motion vector up-sampling and step 234 are obtained is carried out addition, thereby obtains the Inter macro block reconstructed value of corresponding original resolution.
At last, the Inter macro block of the Intra macro block rebuild and reconstruction is formed the reconstruction P frame (can be defined as the R frame) of original resolution size, this frame can not be re-used as the reference frame of next code.
The present invention can obtain a kind of novel R frame by realize may also be referred to as down-sampling P frame coding by P frame coding such as upper type.The present invention directly before coding with the original video image decrease resolution, like this, for Motion estimation and compensation part the most consuming time, its computation complexity is essentially 1/4 of original resolution frame, and several frees of losses of coding efficiency, therefore the present invention's coding can effectively reduce computation complexity, thereby improves P frame code efficiency.
Although illustrated and described embodiments of the invention, for the ordinary skill in the art, be appreciated that without departing from the principles and spirit of the present invention and can carry out multiple variation, modification, replacement and modification to these embodiment, scope of the present invention is by claims and be equal to and limit.