A kind of enhancing pixel domain code stream conversion method
Technical field
The present invention relates to the audio/video encoding/decoding technical field in the signal processing, relate in particular to a kind of enhancing pixel domain code stream conversion method.
Background technology
At present, the source encoding standard that digital television program broadcasting (cable or terrestrial wireless channel via satellite), Digital video disc/high-definition digital video disc/enhanced versatile disc (DVD/HD-DVD/EVD) is published and generally adopt in digital VTR fields such as (DV) is MPEG-2.MPEG-2 is 10 years standards of formulating in the past, the formulation of these source encoding standards be based upon at that time the compress technique level and the integrated circuit technique level on.
In recent years, a collection of digital audio/video encoding and decoding standard has appearred, the representative standard A VS that the autonomous formulation of international standard MPEG-4, H.264/MPEG-4 AVC, and China is arranged, WM9 that Microsoft releases or the like.AVS is the once trial that China gains the initiative on digital audio/video core technology and industrial standard.Great majority are the autonomous patented technologies of China in the AVS standard, and the patent of the external associated companies application of some small parts is also arranged, and add succinct one-stop mandate and novel patent pond management strategy, have solved patent problem preferably.In addition, AVS has apparent in view advantage with H.264 comparing with MPEG-2 on performance.Compression efficiency improves 2~3 times and H.264 suitable than MPEG-2, and H.264 implementation complexity is starkly lower than.
The variation of standard makes the Data Format Transform between the various criterion become more and more important.AVS is the autonomous standard of formulating of China, in order to promote the standard A VS that Chinese associated companies is formulated, need at first solve the transcoding problem of MPEG-2 to AVS, to realize the low transcoding that postpones of the high-quality of video data from MPEG-2 to AVS.
Please earlier referring to shown in Figure 1, the simplest code-transferring method is first complete decoding video data, obtains decoded pixel value, and then with new coding standard recompile.This code-transferring method is called cascade pixel domain code conversion (CPDT, Cascaded Pixel Domain Transcoding), and the advantage of the method is the reconstructed image quality height, and distortion is little, and transcoder is simple in structure.The shortcoming of cascade pixel domain code conversion is that amount of calculation is big, postpones to be difficult to reach the requirement of real-time transcoding greatly.
Another kind of code-transferring method is compression domain transcoding (CDT, Compressed DomainTranscoding), its basic thought is only to utilize in the input code flow information compressed, as discrete cosine transform (DCT) coefficient after video sequence header, macro-block coding pattern information, motion vector information and the quantification etc., directly generate the code stream behind the transcoding, as shown in Figure 2.This method greatly reduces the operand of transcoding process, and the transcoding function can realize by software under existence conditions, and the transcoding efficiency height, postpones little.But this method only is fit to the transcoding between the essentially identical compressed format of Processing Algorithm.
Summary of the invention
The present invention seeks to above-mentioned shortcoming, a kind of enhancing pixel domain code stream conversion method is provided, to realize that MPEG-2 is to the low real-time transcoding transcoding that postpones of AVS high-quality at traditional code-transferring method existence.
To achieve these goals, the following technical scheme of this bright employing,
This enhancing pixel domain code stream conversion method may further comprise the steps:
A is at first MPEG-2 input code flow complete decoding, outside the video data of output yuv format, output decoder information also, decoded information comprises the coding mode of every two field picture, and each macroblock encoding pattern is as motion vector, intra prediction mode, quantization parameter, nonzero coefficient number;
B then, makes full use of the output information that MPEG-2 decoding obtains, and the video data to the yuv format of output carries out the AVS coding again;
C takes all factors into consideration the feature of MPEG-2 coding and AVS coding, and follows the transcoding principle and encode.
Among the described step a,
The coding mode that decoded information is comprised every two field picture, each macroblock encoding pattern, put into a common buffer as motion vector, intra prediction mode, quantization parameter, nonzero coefficient number etc., video image is carried out recompile, export the AVS video-frequency basic flow at last.
Utilize decoded information to help to improve AVS video coding efficient.
Among the described step b, if the discrete cosine transform coefficient of current decoded macroblock is zero among the MPEG-2, just do not carry out discrete cosine transform again when AVS encodes this macro block, the discrete cosine transform of directly looking the AVS of this macro block is zero.
The transcoding principle of being followed comprises,
For the MPEG-2 video flowing that comprises scalable coding, do not do the requirement on the speed;
For the MPEG-2 video flowing of 4:4:4 form, at first down-sampling is the 4:2:0 form, does not still do requirement on the speed;
The high level syntax structure that keeps video flowing, i.e. the invariant position of sequence head, the position and the structure of image sets are constant, and the type of prediction of frame is constant.
Described type of prediction is meant infra-frame prediction, prediction and bi-directional predicted forward, that is to say, and still the I frame behind the I frame transcoding, still the P frame behind the P frame transcoding, still the B frame behind the B frame transcoding.
Among the described step c,
The transcoding principle of being followed also comprises,
Keep the scan type of frame constant, promptly transcoding is preceding according to the frame image encoded as far as possible, still according to the frame coding, according to the field image encoded, still encodes according to the field behind the transcoding before the transcoding behind the transcoding;
Repartition band, be defaulted as each frame and only be divided into 1 band;
Each macro block of I frame all will adopt the intraframe coding algorithm recompile of AVS, when coding with reference to input code flow in corresponding macroblock encoding information.
For the macro block that adopts the field mode coding in the progressive frame, unified changing into according to frame pattern encoded.
Among the described step c,
The transcoding principle of being followed also comprises,
For the macro block that adopts the skip mode coding in the MPEG-2 video flowing, directly according to the skip mode coding, no longer carry out macro-block coding pattern and select and motion compensation during transcoding;
But for motion vector non-zero non-zero discrete cosine transform coefficient number in the MPEG-2 video flowing is 0 macro block, no longer carries out macro-block coding pattern during transcoding and selects and motion compensation, directly adopts the motion vector before the transcoding;
For the macro block that adopts other pattern-codings in the MPEG-2 video flowing, comprise the macro block that adopts the frame mode coding in P frame and the B frame, again carrying out during transcoding that macro-block coding pattern is selected and motion compensation, is that the center is in a small range with the motion vector before the transcoding when searching motion vector.
In technique scheme of the present invention, this method is at first MPEG-2 input code flow complete decoding, outside the video data of output yuv format, output decoder information also, decoded information comprises the coding mode of every two field picture, each macroblock encoding pattern is as motion vector, intra prediction mode, quantization parameter, nonzero coefficient number or the like; Then, make full use of the output information that MPEG-2 decoding obtains, the video data to the yuv format of output carries out the AVS coding again; When coding, take all factors into consideration the feature of MPEG-2 coding and AVS coding, and follow the transcoding principle, at last with quality and the speed of taking into account transcoding.Therefore method of the present invention has been utilized the coded message of input code flow as much as possible in transfer process, as video sequence header, macro-block coding pattern information and motion vector information etc., improve the AVS coding rate, guaranteed the high-quality of transcoding, reduced the operand of transcoding again.
Description of drawings
Fig. 1 is for adopting cascade pixel domain code conversion schematic diagram.
Fig. 2 is for adopting compression domain transcoding schematic diagram.
Fig. 3 is a conversion method schematic diagram of the present invention.
Fig. 4 is the transcoder theory diagram of MPEG-2 to the AVS transcoding.
Fig. 5 is for strengthening the pixel domain code conversion process chart.
Embodiment
For the ease of understanding to enhancing pixel domain code stream conversion method of the present invention (be actually the MPEG-2 code stream is converted to the AVS code stream), earlier digital video transcoding being done one simply introduces: digital video transcoding is exactly that the video data behind the coding is handled end to end, makes it change another kind of form into from a kind of form.So-called form comprises coding standard, spatial resolution, frame rate, data transmission rate or the like, and wherein any one feature changes and all thinks to have taken place transcoding.The transcoding between the main difference coding standard here, promptly the spatial resolution and the frame rate of video do not change before and after the transcoding, and just change has taken place in coding standard, certainly, wherein must be accompanied by the change of data transmission rate.
What we wanted transcoding is two kinds of different standards, at first will compare the similarities and differences of these two kinds of standards.
Common ground:
AVS and MPEG-2 video flowing all are made up of sequence head and frame, and image sets (GOP) structure is an option.The coded system of frame has intraframe predictive coding, predictive coding and bi-directional predictive coding forward.Each frame is made of image head and several strips (slice).Each band (slice) is made up of band (slice) head and some coded macroblockss.
Difference:
AVS video coding and MPEG-2 coding also have very big difference, and be as shown in table 1 below.
The main distinction of table 1 MPEG-2 and AVS standard
Content | ????MPEG2 | ????AVS | Explanation |
Support scalable coding | Support four kinds: data are cut apart, spatial scalable,, the time is scalable, quality scalable | AVS1.0 does not support | |
Support the color samples pattern | 4:2:0、4:2:2、4:4:4 | 4:2:0、4:2:2 | |
Transformation matrix and quantification manner | Be that 8 * 8 discrete cosine transforms (DCT) add the quantification matrix | Be 8 * 8 integral coefficient class discrete cosine transforms (DCT), the position according to conversion coefficient during quantification is divided into three classes to conversion coefficient | Can not use original conversion coefficient in the transcoding, carry out transform and quantization again |
Infra-frame prediction | Transform domain prediction DC coefficient | The spatial domain prediction | Can't directly change between the two |
Band (slice) | Band (slice) can not cross over two | Each band (slice) | |
|
Row or multirow macro block more |
Form by some full line macro blocks |
|
To encoding in the sequence macro block line by line |
Pattern-coding frame by frame in a macro block also can be encoded by field mode |
Only support the frame pattern coding |
|
Please consult Fig. 3 and shown in Figure 5 earlier, enhancing pixel domain code stream conversion method of the present invention, this method when the MPEG-2 code stream is converted to the AVS code stream,
Mainly may further comprise the steps:
A is at first MPEG-2 input code flow complete decoding, outside the video data of output yuv format, output decoder information also, decoded information comprises the coding mode of every two field picture, and each macroblock encoding pattern is as motion vector, intra prediction mode, quantization parameter, nonzero coefficient number or the like;
B then, makes full use of the output information that MPEG-2 decoding obtains, and the video data to the yuv format of output carries out the AVS coding again;
C when coding, takes all factors into consideration the feature of MPEG-2 coding and AVS coding, and follows the transcoding principle, with quality and the speed of taking into account transcoding.
Wherein, behind the video-frequency basic flow process MPEG-2 Video Decoder of MPEG-2, obtain the video data of yuv format, and the coding mode of every two field picture, each macroblock encoding pattern is as information such as motion vector, intra prediction mode, quantization parameter, nonzero coefficient numbers.And these information are put into a common buffer.The AVS video encoder is obtained above-mentioned information from common buffer, and video image is carried out recompile, exports the AVS video-frequency basic flow at last.
These decoded informations can help ensuing AVS video coding to improve code efficiency.These decoded informations comprise the video data of yuv format, and the coding mode of every two field picture, each macroblock encoding pattern, motion vector, intra prediction mode, quantization parameter, nonzero coefficient number or the like information.
The output information that the MPEG-2 decoding obtains can be accelerated the coding rate of AVS effectively.As: if the discrete cosine transform of current decoded macroblock (DCT) coefficient is zero among the MPEG-2, (DCT) with regard to carrying out discrete cosine transform again when AVS encodes this macro block, thought that directly the discrete cosine transform (DCT) of AVS of this macro block is zero.
According to the resulting transcoder of above-mentioned conversion method principle of the present invention can consult shown in Figure 4,
Consider the practicality of transcoding, our transcoder is except being converted to the MPEG-2 video flowing the AVS video flowing, also comprising the multiplexing function of MPEG-2 demultiplexing and AVS, can be the transport stream of MPEG-2 (TS) and program stream (PS) transcoding transport stream (TS) and the program stream (PS) of AVS directly.Be equipped with appropriate interface, the Digital Television that just can be directly embedded into the MPEG-2 form of present use is broadcasted system.In Fig. 4, the transport stream of MPEG-2 (TS) and program stream (PS) are introduced into the MPEG-2 demodulation multiplexer, obtain the video code flow of MPEG-2, and then enter MPEG-2 to the AVS video code translator, basic stream (ES) for MPEG-2 then directly enters transcoder, at output, for output transport stream (TS) and program stream (PS), the video code flow of AVS need be through AVS multiplexer and the multiplexing back output of corresponding voice data.
Behind basic stream (ES) the process MPEG-2 Video Decoder of MPEG-2, obtain the video data of YUV4:2:0 form, and the coding mode of every two field picture, each macroblock encoding pattern information such as (motion vector, intra prediction mode, quantization parameter, nonzero coefficient numbers etc.).And these information are put into a common buffer.The AVS video encoder is obtained above-mentioned information from common buffer, and video image is carried out recompile, exports the AVS video-frequency basic flow at last.
In order to take into account quality and speed, in transcoding, follow following principle:
Temporarily do not support scalable coding, promptly, do not do the requirement on the speed for the MPEG-2 video flowing that comprises scalable coding.
For the MPEG-2 video flowing of 4:4:4 form, at first down-sampling is the 4:2:0 form, does not still do requirement on the speed.
The high level syntax structure that keeps video flowing, i.e. the invariant position of sequence head, the position and the structure of image sets (GOP) are constant, and the type of prediction of frame is constant.Type of prediction is meant infra-frame prediction, prediction and bi-directional predicted forward.That is to say, still be the I frame behind the I frame transcoding, still is the P frame behind the P frame transcoding, still is the B frame behind the B frame transcoding.Adopt this mode except amount of calculation is little, also avoided the frame reorder delay.
Keep the scan type of frame constant, promptly transcoding is preceding according to the frame image encoded as far as possible, still according to the frame coding, according to the field image encoded, still encodes according to the field behind the transcoding before the transcoding behind the transcoding.But,,,, all can only encode behind the transcoding according to frame no matter according to what mode encode before the transcoding therefore for progressive frame because AVS does not allow progressive frame is splitted into two.What deserves to be mentioned is that it is very rare that progressive frame is splitted into two way in MPEG-2.
Repartition band (slice), be defaulted as each frame and only be divided into 1 band (slice).
Each macro block of I frame all will adopt the intraframe coding algorithm recompile of AVS.When coding with reference to input code flow in corresponding macroblock encoding information.
For the macro block that adopts the field mode coding in the progressive frame, unified changing into according to frame pattern encoded.
For adopting the macro block of skipping (skip) pattern-coding in the MPEG-2 video flowing, directly according to the skip mode coding, no longer carry out macro-block coding pattern and select and motion compensation during transcoding.
But for motion vector non-zero non-zero discrete cosine transform (DCT) coefficient number in the MPEG-2 video flowing is 0 macro block, no longer carries out macro-block coding pattern during transcoding and selects and motion compensation, directly adopts the motion vector before the transcoding.
Macro block for adopting other pattern-codings in the MPEG-2 video flowing comprises the macro block that adopts the frame mode coding in P frame and the B frame, carries out macro-block coding pattern during transcoding again and selects and motion compensation.When searching motion vector, be that the center is in a small range with the motion vector before the transcoding.
By shown in Figure 5, as can be seen, through behind the variable-length decoding (VLD), inverse quantization (Q1)-1, anti-cosine transform (IDCT), the DCT coefficient that obtains is directly made second quantization (Q2), the code stream that variable-length encoding (VLC) output needs to the code stream of input.The code check conversion is main by adopting second quantization coefficient Q2 to realize.
Certainly, those of ordinary skill in the art will be appreciated that, above embodiment is used for illustrating the present invention, and be not to be used as limitation of the invention, as long as in connotation scope of the present invention, all will drop in the scope of claims of the present invention variation, the modification of the above embodiment.