Background technology
H.261 traditional video encoding standard such as ITU formulate, H.263, H.263+, the MPEG-1 that organizes to set up of the MPEG of standard and ISO H.264, MPEG-2, MPEG-4 etc. are based upon on hybrid coding (Hybrid Coding) framework.So-called hybrid encoding frame is a kind of incorporation time space video image code method, and this method comprises: carry out in the frame earlier, the prediction of interframe, to eliminate the correlation of time-domain; Then original picture and the residual error that predicts the outcome are carried out two-dimensional transform (adopting discrete cosine transform or other linear transformation), eliminate spatial coherence; Carry out entropy coding then, remove statistical redundancy.
In order to improve compression efficiency of video signal, prediction is a most important technology in the video encoding standard, and Forecasting Methodology generally is divided into infra-frame prediction and inter prediction.
In above-mentioned video encoding standard, macro block (16 * 16 image pixel pieces) is the base unit of prediction and encoding and decoding.Inter-frame prediction method is with the original picture of these rectangular block sizes (image of original input), it is the original picture piece, carry out estimation in reference picture (being used as the image of reference in the reconstruction frames of former coding), the optimum Match picture block that just obtains the original picture piece is as predicting the outcome.Intra-frame prediction method is an encoded rectangular block around the rectangular block that utilization needs to encode in current encoded frame, and the rectangular block of needs coding is predicted that the prediction rectangular block conduct that obtains predicts the outcome.
In video encoding standard, mainly there are four kinds of predictive coding methods at present.Because the input of vision signal can be divided into line by line scan with interleaved.The vision signal of lining by line scan is called frame image, and interleaved vision signal is called field pattern and resembles.Macro block in the frame image is the frame macro block, and the macro block during field pattern resembles is a macro block.The predictive coding method that with the frame macro block is unit is frame predictive coding method (being called for short the frame coding), is that the predictive coding method of unit is named a field prediction coding method (be called for short encode) with the field macro block.H.261, H.263, H.263+, the MPEG-1 that organizes to set up of the MPEG of standard and ISO H.264, MPEG-2, the frame coding that MPEG-4 standard etc. all comprises, MPEG-2, H.264 MPEG-4 also comprises a coding.In the adaptive frame/field predictive coding method that has H.264 proposed to carry out an adaptively selected frame coding or a coding again according to the coding cost, and based on the right adaptive frame/field predictive coding method of macro block.
Frame field adaptive predictive coding method is: vision signal is carried out a frame coding and a coding at first respectively, and according to both coding costs, a still coding of frame coding is adopted in decision then.This predictive coding method can adapt to frame image and field pattern resembles, but this method is that the coding cost with whole frame serves as according to selecting, when the part of image relatively is fit to framing code, and another part just can't find the coding method of the best when relatively being fit to by coding.
The frame field adaptive predictive coding method right based on macro block is: the coding unit is the pixel block of 32 row * 16 row, carry out earlier based on the right frame of macro block coding (be divided into two macro blocks encode respectively) up and down and a coding (release odd-numbered line and even number line respectively form two macro blocks and encode respectively again), according to both coding costs, a still coding of frame coding is adopted in decision then.This predictive coding method can adapt to the local motion of image preferably, but coding does not utilize first macro block to give a forecast during second macro block when encoding by the field, and efficient still is not very high, and complexity is very big.
Therefore, just needs are a kind of more effective, more flexibly method for encoding images.
Summary of the invention
Because right frame field adaptive coding method respectively has shortcoming to the frame field adaptive coding of entire image with based on macro block in the prior art, all can not well adapt to the variation of picture characteristics.Therefore the invention provides a kind of new view data self-adaptive encoding method.In this method, with image segmentation is image slices, image slices further is being divided into macro block, when carrying out the selection of coded system, with the image slices is that a still coding of frame coding is selected by unit, so promptly overcome the shortcoming of entire image encoding scheme flexibility deficiency, avoided the shortcoming that the scheme operand is too big, complexity is too big again based on macro block.
Technical scheme of the present invention provides a kind of frame field adaptive coding method based on image piece cutting structure, comprises following step:
A. image division is become one or several image slices;
B. to described each image slices, carry out a frame coding and a coding respectively; Wherein, when carrying out the frame coding described image slices is divided into several macro blocks, afterwards each macro block is encoded; At first the odd-numbered line pixel and the even number line pixel of described image slices formed a son section respectively when carrying out coding, afterwards again will described two sons cutting into slices is divided into several macro blocks, each macro block is encoded again;
C. according to the coding cost of a described frame coding and a coding, select a less coded system of cost as described image slices;
D. add an image slices head for described each image slices, itself and several macroblock encoding data are wherein together formed the coded data of image slices, wherein, described image slices leader shows that the macro block in this image slices is to adopt a frame coding mode or a coded system;
E. add a macro index for described each image slices, it is not included in the coded data of described image slices;
F. add an image head for described each image, the coded data of itself and one of them or several image slices and described macro index be the coded data of composition diagram picture together.
In above-mentioned method, the least unit of described image is for adopting the frame line by line scan or adopting interleaved adjacent two.And described image slices is the rectangular area in the described image, and its top left pixel all is 16 integral multiple to the distance on the described image top and the left side, and the height of described image slices and width also are 16 integral multiples.The least unit of described image slices is 32 * 16 pixels.The size of described macro block is 16 * 16 pixels.
Preferable, when adopting this method that described image slices is carried out the field coding, at first select one of them son section to encode, select another height section to encode afterwards again.When a back son section is encoded, carry out motion compensation, the term of reference of described motion compensation can be limited within the described last height section.
Carry out frame coding in the method for the present invention and a coding need be set up different macro index, described image slices is carried out frame when encoding, the described macro index of setting up is according to following step:
Order according to raster scan increases progressively successively since 0, increases by 1 at every turn.
And described image slices is carried out field when coding, set up macro index according to following step:
E1. the index of the upper left corner macro block of first son section is 0;
E2. the order according to raster scan increases progressively successively in same height section, increases by 1 at every turn;
E3. the index of the upper left corner macro block of second son section is that the index of the lower right corner macro block of first son section adds 1.
After adopting technique scheme, can improve the efficient of image encoding and traditional technology widely and compare, method of the present invention has following advantage:
(1) with respect to the frame field adaptive encoding scheme of whole frame, method of the present invention can better adapt to the local motion of image.
(2) with respect to based on macro block concerning the frame field adaptive encoding scheme, only needing to indicate (for example realizing by increasing a flag bit) macro block wherein in the image slices head is a frame macro block or a macro block, do not need to point out a frame macro block or a macro block for each macro block to transmitting a flag bit again, thereby improved code efficiency.
(3) image slices is changeable, and maximum can be an entire image, and minimum can be the pixel block of 32 row * 16 row.Therefore as long as suitably set the size of image slices, method of the present invention not only can realize the frame field adaptive encoding scheme of whole frame but also can realize having better flexibility based on the right frame field adaptive encoding scheme of macro block.
Simultaneously, adopt above-mentioned coding method can also reduce the complexity of codec:
(1) decoder is separated an image slices at every turn.Coding mode at the image slices intra-macroblock is consistent, does not need to switch based on carrying out the frame field the right frame field adaptive encoding scheme of macro block as decoding, thereby has simplified the number of times with memory access write of code.
(2) encoder can be done very simply, also can do very complicatedly.The simplest is exactly the frame field adaptive that degenerates to whole frame, and promptly an image has only an image slices.For non real-time application, encoder can be realized complicated optimized Algorithm, seeks best partitioning scheme in all possible image slices partitioning scheme.But the realization of encoder does not influence decoder, and no matter how encoder encodes, and all is the same for decoder.
Embodiment
Further specify technical scheme of the present invention below in conjunction with drawings and Examples.
Main design philosophy of the present invention is that image at first is divided into image slices, and the size of image slices can change, and maximum can be set at entire image, and the minimum size that can be set at a macro block.In each image slices, be divided into several macro blocks again, when image is encoded, be the coded system (a frame coding or a coding) that the unit consideration is adopted with the image slices, the macro block in the promptly same image slices all adopts identical coded system.By setting image slices, just image reasonably can be cut apart, such as, in image, the zone of a part relatively is fit to use the mode of frame coding, and another part zone relatively is fit to make the mode of use coding, according to method of the present invention, just they can be divided into different image slices, adopt the mode of a frame coding and a coding to encode respectively.Like this, just than more efficient in the conventional art to the technical scheme of entire image Unified coding.Simultaneously, with compare based on the macroblock encoding mode in the conventional art, the area of the image slices among the present invention is bigger, that is to say to have the less image slices of relative populations in the image, so just makes the operand and the complexity of coding computing all obtain effectively reducing.
Frame field adaptive coding method based on image piece cutting structure of the present invention comprises following step:
A. image division is become one or several image slices.The least unit of image is for the frame that adopts the sequence of lining by line scan or adopt interleaved adjacent two among the present invention.And image slices is the rectangular area in the image, and its top left pixel all is 16 integral multiple to the distance on the image top and the left side, and the height of image slices and width also are 16 integral multiples.As previously described, the size of image slices is variable, and maximum can be entire image, can be the size of a macro block (16 * 16 pixel) on the minimum theoretical.But consider the performance of coding and the problem of efficient, the size of minimum image slices is 32 * 16 pixels (sizes of 2 macro blocks) in the method for the present invention.
B. to each image slices, carry out a frame coding and a coding respectively.Wherein, when carrying out the frame coding image slices is divided into several macro blocks, the size of each macro block is 16 * 16 pixels, afterwards each macro block is encoded.At first the odd-numbered line pixel and the even number line pixel of image slices formed a son section respectively when carrying out coding, again two son sections are divided into several macro blocks afterwards, the size of macro block is similarly 16 * 16 pixels, each macro block is encoded again.Because carrying out a coding is that the least unit that needs in fact is two macro blocks, so the least unit of specified image section among the present invention is the size of 2 macro blocks.For coded system, the mode of the mode of frame coding or a coding all is the mature technique in this area, so just no longer spoken more herein, here also be noted that, when carrying out the field coding, one of them is encoded at first to select two son sections, select another height section to encode afterwards again, and when a back son section is encoded, carry out motion compensation, the term of reference of motion compensation can be limited within the last height section, also can not limit the scope of reference.With regard to motion compensation technique itself, it is widely used in this area, so just do not introduced the principle of motion compensation in detail here.The coding that method of the present invention uses the coding result of last section to be cut into slices in back one when an image slices being carried out the field coding carries out motion compensation, has overcome the bigger shortcoming of operand that does not have to get in touch between the macro block of front and back in the prior art and cause.
C. according to the coding cost of a frame coding and a coding, select a less coded system of cost as described image slices.After step b finishes, be the coding cost that unit relatively adopts a frame coding and a coded system, choose a less coded system of cost as this image slices with the image slices.
D. add an image slices head for each image slices, itself and several macroblock encoding data are wherein together formed the coded data of image slices, and wherein, the image slices leader shows that the macro block in this image slices is to adopt a frame coding mode or a coded system.Image slices data after encoded should comprise image slices head and each macroblock encoding data wherein, and according to method of the present invention, each image slices head has shown the coded system that each macro block adopted in this image slices.The front said that the coded system that all macro blocks among the present invention in each image slices adopt was identical.Therefore just passable to need in the image slices head, showing, for example in the image slices head, define a flag bit, the value of this flag bit has just been represented the coded system that the macro block in this image slices is taked.It is the method that coded system is selected by unit that the present invention adopts with the image slices, compare with traditional mode based on macro block, reduce the quantity of cut zone, reduced the conversion times of the code encoding/decoding mode in coding and the decode procedure, reduced computational complexity and operand.
E. add a macro index for each image slices, it is not included in the coded data of image slices.According to the present invention, can have several macro blocks in the image slices, in order to distinguish these macro blocks, set up a macro index, for adopting a frame coding and an image encoded section, the mode of setting up macro index is different:
Image slices is carried out frame when coding, and set up macro index according to following step: the order according to raster scan increases progressively successively since 0, increases by 1 at every turn.
Described image slices is carried out field when coding, sets up macro index according to following step:
E1. the index of the upper left corner macro block of first son section is 0;
E2. the order according to raster scan increases progressively successively in same height section, increases by 1 at every turn;
E3. the index of the upper left corner macro block of second son section is that the index of the lower right corner macro block of first son section adds 1.
F. for each image adds an image head, the coded data of itself and one of them or several image slices and macro index be the coded data of composition diagram picture together.Comprised in the image head that some form video flowings or such as the information of the network address.
After having adopted technical scheme of the present invention, improved the efficient of image encoding and two kinds of traditional technology widely and compared, method of the present invention has following advantage:
With respect to the frame field adaptive encoding scheme of whole frame, method of the present invention can better adapt to the local motion of image.
With respect to based on the macroblock encoding scheme, only needing to indicate (for example realizing by increasing a flag bit) macro block wherein in the image slices head is a frame macro block or a macro block, do not need to point out a frame macro block or a macro block for each macro block to transmitting a flag bit again, thereby improved code efficiency.
Simultaneously, image slices is changeable, and maximum can be an entire image, and minimum can be the pixel block of 32 row * 16 row.Therefore as long as suitably set the size of image slices, method of the present invention not only can realize the frame field adaptive encoding scheme of whole frame but also can realize having better flexibility based on the right frame field adaptive method scheme of macro block.
When decoding adopts method of the present invention to carry out the image encoded data, have some following advantage equally:
Decoder is separated an image slices at every turn.Coding mode at the image slices intra-macroblock is consistent, does not need to switch based on carrying out the frame field the macroblock encoding scheme as decoding, thereby has simplified the number of times with memory access write of code.
Encoder can be done very simply, also can do very complicatedly.The simplest is exactly the frame field adaptive that degenerates to whole frame, and promptly an image has only an image slices.For non real-time application, encoder can be realized complicated optimized Algorithm, seeks best partitioning scheme in all possible image slices partitioning scheme.But the realization of encoder does not influence decoder, and no matter how encoder encodes, and all is the same for decoder.
Introduce employing method of the present invention is carried out Code And Decode to the image in the video flowing concrete implementation step respectively below in conjunction with Fig. 2 and Fig. 3.
Fig. 2 is the flow chart of an embodiment of the process of the image in one video flowing being encoded according to view data self-adaptive encoding method of the present invention.Show as Fig. 2, comprise following step:
S21. obtain the initial data of image in the video sequence;
S22. judge whether to also have uncoded image, if there has not been commentaries on classics S28;
S23. be image division one or several image slices;
S24. judge whether to also have uncoded image slices,, continue to judge next image in the video flowing if there has not been commentaries on classics S22;
S25. the coded system of judging this image slices is a framing code, and no, and words are changeed S27;
S26. this image slices of framing code, and commentaries on classics S24;
S27. press this image slices of coding, and change S24:
S28. finish.
It should be noted that the general steps that the image in the video flowing is encoded just has been described in this flow chart, concrete implementation detail sees also foregoing step a-f.
Fig. 3 is the flow chart of an embodiment of the process of the image in one video flowing being decoded according to view data self-adaptive encoding method of the present invention.
S31. obtaining encoded video sequence coding data, for example is coded according to above-mentioned step S21-S27;
S32. judge whether to also have the not image of decoding, change S38 if it's not true;
S33. judge whether to also have uncoded image slices, change S32 if it's not true;
S34. the image slices head of decoding;
S35. the coded system of judging this image slices is a framing code, and no, and words are changeed S37;
S36. the mode of framing code this image slices of decoding is changeed S33;
S37. by the mode of field coding this image slices of decoding, change S33:
S38. finish.
The foregoing description provides to being familiar with the person in the art and realizes or use of the present invention; those skilled in the art can be under the situation that does not break away from invention thought of the present invention; the foregoing description is made various modifications or variation; thereby protection scope of the present invention do not limit by the foregoing description, and should be the maximum magnitude that meets the inventive features that claims mention.