Background technology
Along with the develop rapidly of science and technology, digital TV in high resolution broadcasting, multimedia network communication, video monitoring, remote monitoring etc. are more and more outstanding to the demand of video coding and decoding technology efficiently.Video coding and decoding technology is to realize high-quality, storage of low-cost multi-medium data and the key of transmitting efficiently.Popular video coding international standard generally adopts the hybrid coding method of prediction/conversion now.Redundancy by on time, space and the subjective vision of prediction/conversion removal video image makes under the condition that keeps certain visual effect, data volume is dropped to minimum.This prediction can be to carry out in present image, also can be to carry out between image.For inter prediction, the general now motion search strategy that adopts based on the piece coupling both to each piece in the present image, was sought best match position according to certain strategy in its reference picture.In order to improve accuracy for predicting, usually may in several reference pictures, mate, use forward direction, back to two reference frames as the B frame, therefore in codec, need reference picture is effectively managed to improve the access efficiency of reference picture in the codec.Certainly the multiframe reference prediction has certain complexity in realization, distributes more buffer memory to preserve reference picture, need more calculate to carry out reference picture selection etc. as needs.
As MPEG-1, MPEG-2, MPEG-4 etc., inter prediction are divided into two kinds in the former coding standard, and a kind of is the P frame that only comes from forward prediction, and another kind is to carry out bi-directional predicted B frame.The prediction of the P frame here is based on all that a reference picture carries out, the B frame then uses two reference pictures of forward and backward to predict, the inter prediction here is comparatively simple, corresponding reference picture buffer management is also fairly simple, only needing to keep two nearest reference frames can be to P, and the B frame carries out inter prediction.
Along with the fast development of computing technique, the realization of multiframe reference prediction has not been very difficult problem, and can bring significant gain, is to improve an effectively approach of compression efficiency because adopt the multi-reference frame Predicting Technique.But, because the complexity that the prediction of too much reference frame is brought in realization far surpasses the gain that it brought, and because common B frame needs to use former and later two reference frames at least, in order to make full use of the reference picture buffering area, general restriction P frame uses two reference frames at the most, can needn't increase the size of image buffer like this under the condition of the P frame being carried out multi-frame prediction.
An important step of multi-reference frame Predicting Technique is how the reference picture buffering area effectively to be managed.H.264 also adopted the multiframe reference technique at up-to-date coding standard in, but reference picture buffer management wherein is very complicated, at first it is all preserved every width of cloth decoded picture, no matter whether this image is as reference picture, and with its order of index marker, and there is a mark to represent that whether this image is as reference picture in addition; In addition, very complicated regulation is also arranged, do not have only when it is not used as reference picture and is used for showing such as a, two field picture and just shift out from buffering area for reference picture turnover buffering area.Complex management like this, and taken a large amount of memory spaces, the buffering area service efficiency is low.
Embodiment
Reference picture buffer management mechanism of the present invention, make P/B frame or field energy enough carry out access efficiently to reference picture, simultaneously for the macro block of the specific coding pattern in P/B frame/field, as skip macroblock pattern (Skip mode), Direct Model (Direct mode), symmetric pattern (Symmetric mode) can very directly find its forward direction when the access reference picture, afterwards to reference picture.
Technical scheme of the present invention comprises the steps:
Step 1, according to the mode of coding, in buffering area, be preserved for the reference picture of coding/decoding;
Step 2, each reference picture all come mark by a reference key;
Step 3, present image are determined reference picture according to reference key, finish encoding and decoding;
If the current coding/decoding image of step 4 is I frame/field or P frame/field, then decoded I/P frame/field to be replaced in the buffering area from present image reference frame/field farthest, coding/decoding next one image re-executes step 2;
If the current coding/decoding image of step 5 is B frame/field, do not change the reference key of reference picture, the next image of coding/decoding re-executes step 3;
If all images of step 6 have all been finished coding/decoding, then all images in the delete buffer.
No matter be in the coding or decode procedure of image, all relate to image and in buffering area, carry out coding/decoding, all relate to the management of buffering area of the present invention.
Step 1 of the present invention in image buffer, only is preserved for all with image for referencial use, and reference picture can only be I image or P image.According to different coded systems, the quantity of the reference picture of reservation is also inequality, for the coding based on frame, in the reference picture buffering area, keeps nearest 2 reference pictures that are used for reference; For coding, in the reference picture buffering area, keep nearest 4 reference field images that are used for reference based on the field.
The mark of reference picture is a committed step of the present invention, and after the access of image and coding/decoding were finished in the buffering area, the renewal of reference picture all was that the mark according to image carries out.The present invention has realized image buffer management easily by simple mark mode.
Each reference picture all uses a reference key to come mark, and the principle of mark is: the forward direction reference picture is according to DISPLAY ORDER, and reference key is by descending, and the reference key from the nearest reference picture of present image on the DISPLAY ORDER is 0; According to DISPLAY ORDER, reference key is arranged by ascending order to reference picture in the back, and the reference key from the nearest reference picture of present image on the DISPLAY ORDER is 0.
For the coded system based on frame, if present image is the P frame, then its two forward reference frame are these two reference pictures in the buffering area, are 0 from the nearest image tagged of present image on DISPLAY ORDER wherein, and far away another is labeled as 1; For if present frame be the B frame, the back of it is the reference frame be positioned at present image on DISPLAY ORDER after to reference frame, be labeled as 0 in the back in reference sequence, forward reference frame is labeled as 0 for the reference frame before DISPLAY ORDER is positioned at present image in the forward direction reference sequence.
For coded system based on the field, if when the front court be the P field, its 4 forward directions are with reference to being these four reference pictures in the buffering area, are 0 from the nearest image tagged of present image on DISPLAY ORDER wherein; For if when the front court be the B field, the back of it is two reference field be positioned at present image on DISPLAY ORDER after to reference field, on DISPLAY ORDER, be 0 wherein from the nearest image tagged of present image, another is labeled as 1, the forward direction reference field is the reference picture before DISPLAY ORDER is positioned at present image, the field flag nearest from present image is 0, and another is labeled as 1.
Below by concrete a series of examples, the mark mode with under the different situations in the decoding illustrates labeling process of the present invention: the numeral reference key value among the figure, and the image of arrow indication is a reference picture,
As shown in Figure 1, if present image is the I image, and this image is as two codings, and current decoded field is second on DISPLAY ORDER simultaneously, and first of the current decoded field of mark top is 0;
As shown in Figure 2, if present image is the P image, and carry out the frame coding, mark is 0 from the nearest forward direction reference picture of present image; Forefront forward direction reference picture is 1;
As shown in Figure 3, if present image is the P image, and this image is as two codings, current decoded field is first on DISPLAY ORDER simultaneously, mark when second of the nearest forward direction reference picture in front court be 0, to direction away from present image, 4 fields of mark in turn.
As shown in Figure 4, if present image is the P image, and this frame is as two codings, and current decoded field is second on DISPLAY ORDER simultaneously, mark when first of top, front court be 0, to direction away from present image, 4 fields of mark in turn.
As shown in Figure 5, if present image is the B image, and as frame coding, mark forward direction reference picture is 0, also is 0 to reference picture behind the mark, these two images according to and present image different differentiation on sequential.
As shown in Figure 6, if present image is the B image, and as two codings, current decoded field is first on DISPLAY ORDER simultaneously, and it is 1 that second of mark forward direction reference picture is 0, the first; Being 0, the second to first of reference picture behind the mark is 1; The B image can only index before and after to reference picture, under second restriction of the current side after the match of mark not, be to mark 4 reference field equally like this according to the distance of distance when the front court.
As shown in Figure 7, if present image is the B image, and as two codings, current decoded field is second on DISPLAY ORDER simultaneously, and it is 1 that second of mark forward direction reference picture is 0, the first; Being 0, the second to first of reference picture behind the mark is 1, and reason as above.
Specific coding pattern in some P/B frame/fields, the present invention also considers it:
For the I two field picture encode in the field at the end time, the field into P is always compiled in field, the end, its reference picture has only one, promptly top also is to be labeled as 0 field in the reference picture buffering area.
For the Direct mode in B frame or the B field, its default front and back are nearest reference picture to reference picture, promptly are labeled as 0 reference picture.
For the Symmetric mode in the B frame, its default afterwards derives by the forward direction reference picture to reference picture, if the forward direction reference picture is the reference picture of mark 0, then the back is to be labeled as 1 reference picture to reference picture; Otherwise if the forward direction reference picture is the reference picture of mark 1, then the back is to be labeled as 0 reference picture to reference picture.
After finishing the mark of image in the buffering area, just can carry out the coding/decoding of image according to mark.In the coding/decoding process of present image, keep the data in the image buffer constant, finish up to the present image coding/decoding, need upgrade reference picture in the reference picture buffering area.
In the step 3 of the present invention, according to reference picture present image being carried out Methods for Coding can be that any one utilizes reference picture to carry out the method for predictive coding.
Be the flow chart of reference picture in the update image buffering area of the present invention as shown in Figure 8, the decoding piece image if present image is I or P frame/field, is then replaced reference picture buffering area middle distance present image frame/field farthest with this image, carries out index marker again.
For coding based on frame, if current decoded frame is I or P frame, then decoded I/P frame is replaced in the buffering area from present image reference frame farthest, carry out the mark in the step 2 then.
For example, if current decoded frame is I or P frame, then decoded this frame replaced and be labeled as 1 reference frame in the original buffering area, so the reference frame of this new insertion is wanted the nearest reference frame of decoded picture for next, be labeled as 0, another image originally was labeled as 0, and wanting update mark now is 1.
For coding based on the field, if current decoded frame is I or P field, then decoded I/P field is replaced in the buffering area from present image reference field farthest, carry out the mark in the step 2 then.
For example, if current decoded picture is I or P field, then decoded this image is replaced and be labeled as 3 reference field in the original buffering area, so the reference field of this new insertion is wanted the nearest reference field of decoded picture for next, be labeled as 0, another image originally was labeled as 2, and wanting update mark now is 3, former be labeled as 1 be updated to 2 earlier, former be labeled as 0 be updated to 1.
Decoding B frame or B field, buffer state remains unchanged.
If all images have all been finished coding/decoding, then whole coding/decoding process is finished, and all images in the delete buffer discharges resource.
It should be noted last that: above embodiment is the unrestricted technical scheme of the present invention in order to explanation only, although the present invention is had been described in detail with reference to the foregoing description, those of ordinary skill in the art is to be understood that: still can make amendment or be equal to replacement the present invention, and not breaking away from any modification or partial replacement of the spirit and scope of the present invention, it all should be encompassed in the middle of the claim scope of the present invention.