The method of maximum macro block (mb) type and coded block pattern associating coding/decoding
Technical field
The present invention relates to a kind of coding method of video image, especially a kind of method with maximum macro block (mb) type of video image and coded block pattern (being CBP) combined coding belongs to image coding technology field.
Background technology
Along with the develop rapidly of science and technology, multimedia, network service have become the part in our life, and they make a great contribution for the service and the abundant mankind's life.Digital compression becomes the key of multimedia application development as one of core of digitizing technique.Video coding and decoding technology is to realize high-quality, the storage of low-cost multi-medium data and transmit indispensable efficiently.
The raising of coding and decoding video performance can realize a lot of multimedia application under limited condition.Popular image encoding international standard, the infra-frame prediction, motion compensation, discrete cosine transform and the quantification that are based on the piece coupling of general employing and the coding method that entropy coding combines now.Remove the redundancy on video image time, space and the subjective vision, make under the condition that keeps certain video effect, drop to the group/cording quantity of needs minimum.
The image of video sequence is based on that macro block encodes.Usually, a kind of image type has multiple macro block (mb) type, selects a kind of macro block (mb) type that current macro is encoded during coding.These macro block (mb) types are given different from small to large parameter values according to certain order.These parameter values are exactly the sign of macro block (mb) type.The macro block (mb) type of macro block (mb) type parameter value maximum is exactly so-called maximum macro block (mb) type under certain image type.
For example: image type is the P frame, 6 kinds of macro block (mb) types 16 * 16,16 * 8,8 * 16,8 * 8,8 * 8ref0, Intra8 * 8 are arranged in the P frame, give the numerical value (seeing Table 1) of 0-5,16 * 16-0,16 * 8-1,8 * 16-2,8 * 8-3,8 * 8ref0-4, Intra-5 according to this order to them.Here maximum macro block (mb) type is exactly Intra, and its parameter value is the parameter value maximum in P two field picture type, is 5.
These parameter values of encoding exactly during the coded macroblocks type.16 * 8 the macro block (mb) type if encode is just to parameter value 1 coding.During the decoded macroblock type, if the value that obtains is 1, decoder just can determine that macro block (mb) type is 16 * 8.
Table 1.P frame macro block (mb) type and parameter value mapping table thereof
????Code_number | ????MB_Type |
The P frame |
????0 | ????16×16 |
????1 | ????16×8 |
????2 | ????8×16 |
????3 | ????8×8 |
????4 | ????8×8(ref=0) |
????5 | ????Intra |
The macro block (mb) type of having encoded also will be encoded to the CBP mapping value of macro block.CBP is several 8 * 8 luminance block of expression macro block and 6 the binary system macroblock parameters whether chrominance block contains non-0 transform coefficient values.Respectively corresponding 48 * 8 luminance block in each bit position of low four of CBP.If a certain 8 * 8 luminance block conversion coefficients are 0 entirely, corresponding bit position is 0, if the luminance block conversion coefficient has at least one not to be 0, corresponding bit is for being 1.
The fast conversion coefficient situation of two colourities of the high two bit representation macro blocks of CBP, the same with luminance block, if a chrominance block has non-0 coefficient, corresponding binary digit is 1, otherwise is 0.6 binary systems can have 2 altogether
6The CBP value is planted in=64 (0~64), and in order to reduce code check, encoder is not directly write the value of CBP in the code stream, but adds up the probability that various CBP values take place earlier, after arranging from high to low according to probability, gives mapping value (seeing Table 2).
Such as, statistics intraframe coding CBP value is that probability of happening is the highest under 63 situations, and 31 probability that take place take second place, and 47 come after 63 and 31.Just being that 63 mapping value assignment is 0 with CBP, is that 31 mapping value assignment is 1 with the CBP value, and the CBP value is that 47 assignment is 2, and the rest may be inferred according to the probability size for the mapping value of other CBP.The mapping value of encoder encodes CBP.
The relation of table 2.CBP actual value and mapping value
????codeNum | ????CBP?xxxxxx??(543210) |
Intra-frame encoding mode | Interframe encoding mode |
????0 | ????63 | ????0 |
????1 | ????31 | ????1 |
????2 | ????47 | ????2 |
????3 | ????15 | ????4 |
????4 | ????0 | ????8 |
????5 | ????7 | ????16 |
????6 | ????11 | ????32 |
????7 | ????13 | ????48 |
????8 | ????14 | ????3 |
????9 | ????55 | ????5 |
???... | ???... | ????... |
Macroblock parameters such as macro block (mb) type and CBP all is to use 0 rank Columbus's sign indicating number (as table 3) that parameter value is encoded.Be the form of 0 rank Columbus's sign indicating number below:
1
0?1?x0
0?0?1?x1?x0
0?0?0?1?x2?x1?x0
0?0?0?0?1?x3?x2?x1?x0
.................
Wherein: xn (n=0,1,2 ...) value is 0 or 1.INFO=xn...,x1,x0。The bit number of INFO is n+1.The relation of the decimal system parameter value (code_number) of 0 rank Columbus's code word and its expression is
Code_number=2^L/2+INFO-1???????????????????????(1)
L/2 is the integer part of L divided by 2 results, INFO=0 when L=1.Wherein: L is the length of Columbus's sign indicating number bit position, 0 rank, L=2 (n+1)+1.The enantiomorphic relationship of Columbus's sign indicating number and parameter value sees Table 3.
The enantiomorphic relationship table of unified variable-length encoding (Columbus's sign indicating number) of table 3. and parameter value
????Code_number | ????Code?word |
????0 | ????1 |
????1 | ????010 |
????2 | ????011 |
????3 | ????00100 |
????4 | ????00101 |
????5 | ????00110 |
????6 | ????00111 |
????7 | ????0001000 |
????8 | ????0001001 |
????9 | ????0001010 |
????10 | ????0001011 |
????...... | ????....... |
For example: parameter value 5 in the table, Columbus's code length L=5 and INFO=10 (binary system)=2 (decimal system).5=2^5/2+2-1 satisfies formula (1).Encoder converts parameter value to Columbus sign indicating number according to formula (1) and writes in the code stream.Decoder by read N-1 bit 0 after read one 1, and then read the value of N-1 bit position, the binary value of this N bit position is exactly the INFO value.Know INFO value and N (=n+1) value just can be solved the parameter value of mapping by formula (1).
In the prior art, next the macro block (mb) type value is exactly the CBP mapping value in the code stream, and both are absolute codings.As: the macro block (mb) type value is 3 (Columbus's sign indicating number is 00100), the CBP mapping value is 10 (Columbus's sign indicating number is 0001011), then code stream is ... 001000001011..., and decoding end is read 00100 and known that the macro block (mb) type parameter value is 3, next reads 0001011 and knows that the CBP mapping value is 10.If but the parameter value of macro block (mb) type is 5 (Columbus's sign indicating number is 00110), suppose that 5 is parameter values of maximum macro block (mb) type, the CBP mapping value is 7 (Columbus's sign indicating number is 0001000), then code stream is ... 001100001000...
By above description, the code efficiency of this as can be seen mode of independently encoding respectively is very low, and for image encoding, the efficient of coding is very important, directly determined the cost of transmission, how to solve the low problem of this code efficiency, become a difficult problem of further raising video image coding code efficiency.
Summary of the invention
Technical problem to be solved by this invention is: propose the method for a kind of video image macro-block type and CBP combined coding, further reduce the bit number after the image encoding, improve code efficiency, reduce transmission cost.
The method of a kind of maximum macro block (mb) type and CBP combined coding at coding side, comprises the steps:
Step 1, obtain the macro block (mb) type of image to be encoded, judge whether macro block (mb) type value i to be encoded is maximum macro block (mb) type value M, and whether i equals M;
Step 2, if not maximum macro block (mb) type value (be i ≠ M), coded macroblocks types value i then, the CBP mapping value of encoding then j;
Step 3 is if maximum macro block (mb) type value (being i=M) then reads CBP mapping value j, calculate then maximum macro block (mb) type value and CBP mapping value and (M+j), and coding (M+j).
In decoding end, comprise the steps:
Step 1, from code stream, read macro block (mb) type value i;
Do you step 2, judge that i is more than or equal to maximum macro block (mb) type value (i>=M?);
Step 3, if not (i<M), be exactly the macro block (mb) type of coding side predetermined parameter value i mapping then, and then from code stream, read the mapping value of CBP by macro block (mb) type;
If step 4 macro block (mb) type value is more than or equal to maximum macro block (mb) type value (i>=M) then determine that macro block (mb) type is maximum macro block (mb) type, and CBP mapping value j=i-M.
The present invention can save more coding bit number by maximum macro block (mb) type and CBP combined coding, improves compression efficiency, does not change the syntactic structure of decoding end simultaneously, and increases the decoding complex degree of decoding end and the implementation complexity of decoder hardware hardly.
Description of drawings
The schematic flow sheet of Fig. 1 technical solution of the present invention coding side coding;
The schematic flow sheet of Fig. 2 technical solution of the present invention decoding end decoding.
Embodiment
The solution of the present invention does not relate to macroblock encoding, only relates to the coding of macro block (mb) type and the coding of CBP.The present invention considers when the encoder encodes macro block (mb) type, if this macro block (mb) type is maximum macro block (mb) type, with this macro block (mb) type parameter value and CBP mapping value combined coding, just need not encode CBP again, improves code efficiency with this.
Because the CBP mapping value is 0~63 integer, thus maximum macro block (mb) type parameter value and CBP mapping value with necessarily more than or equal to maximum macro block (mb) type parameter value.Like this, if obtain the parameter value of macro block (mb) type parameter value less than maximum macro block (mb) type in decoding end, can know macro block (mb) type that should parameter value, as usual from code stream, read CBP then, otherwise, the macro block (mb) type parameter value is equal to or greater than maximum macro block (mb) type parameter value, can affirm that this macro block (mb) type is the macro block (mb) type of parameter value maximum, this parameter value is the parameter value that has the CBP combined coding simultaneously, just can obtain the mapping value of CBP as long as deduct the parameter value of maximum with this parameter value, just needn't arrive in the code stream of back and read CBP.
Technical scheme of the present invention at coding side, as shown in Figure 1, comprises the steps:
Step 1, selection macro block (mb) type judge whether the macro block (mb) type value i that selects is maximum macro block (mb) type value M, and whether i equals M;
Step 2, if not maximum macro block (mb) type value (be i ≠ M), coded macroblocks types value i then, the CBP mapping value of encoding then j;
Step 3 is if maximum macro block (mb) type value (being i=M) then reads CBP mapping value j, calculate then maximum macro block (mb) type value and CBP mapping value and (M+j), and coding (M+j).
In decoding end, as shown in Figure 2, comprise the steps:
Step 1, from code stream, read macro block (mb) type value i;
Do you step 2, judge that i is more than or equal to maximum macro block (mb) type value (i>=M?);
Step 3, if not (i<M), be exactly the macro block (mb) type of coding side predetermined parameter value i mapping then, and then from code stream, read the mapping value of CBP by macro block (mb) type;
If step 4 macro block (mb) type value is more than or equal to maximum macro block (mb) type value (i>=M) then determine that macro block (mb) type is maximum macro block (mb) type, and CBP mapping value j=i-M.
For example: the macroblock encoding type parameter value is 5, and the CBP mapping value is 7,5 to be macro block (mb) type parameter value maximum under the present image type, then adopts combined coding
5 (macro block (mb) type parameter value)+7 (CBP mapping value)=12 (combined coding value)
The value 12 (Columbus's sign indicating number is 0001101) of combined coding is write on the position of macro block (mb) type in the code stream, no longer write the mapping value of CBP.During decoding, obtain the macro block (mb) type parameter value after, if should the value less than 5, then also such according to macro block (mb) type and CBP absolute coding, next continue to read code stream and obtain the CBP mapping value.Otherwise parameter value is more than or equal to 5, and this value is exactly the combined coding value.Can determine that the macro block (mb) type parameter value is 5, and need not from code stream, read the CBP mapping value again that can obtain the CBP mapping value by 12-5=7 is 7.
From this example, find out, the coding method before using, the macro block (mb) type parameter value is 5, and the CBP mapping value is 7, and code stream is 001100001000, is 0001101 and use our method code stream, has saved 5bit.
As shown in table 4, be the effect list behind P frame macro block (mb) type and the CBP combined coding, method of the present invention is not limited to the two field picture to P; Go for I frame and B frame too.
Maximum macro block (mb) type of table 4. and CBP combined coding and absolute coding comparison sheet
Maximum macro block (mb) type parameter value | The CBP mapping value | The combined coding value | The absolute coding value | Save (bit) |
Columbus's sign indicating number | Decimal value | Columbus's sign indicating number | Decimal value | Columbus's sign indicating number | Decimal value | Columbus's sign indicating number | |
00110 | 5 | 1 | 0 | 00110 | 5 | 001101 | 1 |
00110 | 5 | 010 | 1 | 00111 | 6 | 00110010 | 3 |
00110 | 5 | 011 | 2 | 0001000 | 7 | 00110011 | 1 |
00110 | 5 | 00100 | 3 | 0001001 | 8 | 0011000100 | 3 |
00110 | 5 | 00101 | 4 | 0001010 | 9 | 0011000101 | 3 |
00110 | 5 | 00110 | 5 | 0001011 | 10 | 0011000110 | 3 |
00110 | 5 | 00111 | 6 | 0001100 | 11 | 0011000111 | 3 |
00110 | 5 | 0001000 | 7 | 0001101 | 12 | 001100001000 | 5 |
00110 | 5 | 0001001 | 8 | 0001110 | 13 | 001100001001 | 5 |
00110 | 5 | 0001010 | 9 | 0001111 | 14 | 001100001010 | 5 |
....... | ....... | ....... | ....... | ....... | ....... | ....... | ....... |
Below by a specific embodiment, further specify technical scheme of the present invention:
Coding side: current encoded frame is the P frame, has 16 * 16,16 * 8,8 * 16,8 * 8 in the P frame, a 8 * 8ref0, Intra6 kind macro block (mb) type, and the corresponding parameters value is followed successively by 0~5.Intra is a macro block (mb) type maximum in all types, and value is 5.
Current macro is selected through RDO, if adopted Intra macro block (mb) type coding.Calculating the macro block CBP value of encoding under the Intra type then is 101000, and its mapping value is 8.Ask 5+8=13,13 as macro block (mb) type, and Columbus's sign indicating number of its mapping is written to and is transferred to decoding end in the code stream.
Decoding end: the macro block (mb) type value that obtains in the code stream is 13, and judges that present frame is the P frame.Find that macro block (mb) type maximum in the P frame is 5, and be 13 now, just determine that 13 is combined coding values of Intra macro block (mb) type and CBP.Therefore determine that the current macro type is Intra, and needn't read next code word as the CBP mapping value.Its CBP mapping value can obtain by 13-5=8.
The joint coding method of maximum type and data thereafter is except to macro block (mb) type and the CBP combined coding in the code table of the present invention, can also be suitable for and the combined coding of the conversion coefficient of image block with thereafter escape_level value.
If codeNum equals 59,59th when the conversion coefficient to image block carries out entropy coding, the maximum codeNum value that the entropy coding code table allows, the codeNum value 59 that can this is maximum and the escape_level value combined coding of its back.Be specially:
Step 01, obtain the codeNum of image to be encoded, judge whether this codeNum value equals 59;
If whether this codeNum value of step 02 is not equal to 59, the codeNum value of then encoding, the escape_level value of encoding again;
If whether this codeNum value of step 03 equals 59, then read escape_level value thereafter, calculate escape_level+59 then, and direct coding escape_level+59.
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 do not break away from any modification or partial replacement of the spirit and scope of the present invention, all should be encompassed in the middle of the claim scope of the present invention.