Based on the method for multichannel video transcoding multiplexing H.264
Technical field
The invention belongs to video compression coding and multiplexing field in the Digital Television.Especially relate to based on the H.264 method and the multiplexer of multichannel video transcoding multiplexing.
Background technology
Mobile digital TV develops rapidly at home in recent years, but vision bandwidth has fettered the expansion of digital video service.In order to take into account code stream efficiency of transmission and video image quality, the common transmission rate of system is at 6~10Mbps.And the digital TV video frequency video program adopts the MPEG-2 video compression standard more, and picture size is bigger.Such as, the MPEG-2 code check of SD is about 4Mbps, and the MPEG-2 code check of high definition is about 10Mbps.Mobile digital TV user's bandwidth generally is difficult to satisfy the real-time Transmission of the video flowing of the high code check of multichannel, can watch more mobile digital TV program smoothly under the situation of lower bandwidth in order to make the user, needs to reduce the code check of video flowing.Add the restriction of storage volume and the appearance of various different digital television terminals, make digital cable customers the video coding technique demand is more and more urgent efficiently.
Do not adopt in the Digital Television information source before the compressed encoding standard of low code check, high definition, the present solution of the problems referred to above has two, and the first is carried out high compression with the digital videos such as MPEG-2 of high code check, transfers the MPEG-2 digital video of low code check to; It two is that the digital videos such as MPEG-2 of high code check are carried out transcoding, transfers H.264 digital video to.First method will cause image quality to descend significantly, and is obviously inadvisable, and second method then can obtain more high compression efficiency and more low transmission code check under the situation that reduces image quality hardly.
Compare with MPEG-2, H.264 under equal picture quality, can improve the compression efficiency more than 4 times.As seen above-mentioned second method is more desirable.But H.264 as simple video compression standard, not about the synthetic content that reaches aspects such as multiplexed transmission of audio frequency and video.There is not at present specialized apparatus to realize that MPEG-2 is to H.264 video code conversion and multiplexing yet.Consider that TV station's original MPEG-2 headend equipment quantity is many and very expensive, abandon existing a large amount of MPEG-2 headend equipment, comprise Digital Video, nonlinear images editing saving device, this is unpractical.How to ensure picture quality, reduce the bandwidth of image simultaneously significantly, promptly make up the transcoding multiplexing special equipment and become the task of top priority.
Do not relate in the prior art based on the H.264 method and the multiplexer of multichannel video transcoding multiplexing.As CN1745573 image pick up equipment and moving picture photographing method thereof, the image pick-up device of under the moving picture photographing pattern, working, before wherein moving picture photographing begins, indicate by the shutter release button on key input part (12), the clock frequency of control section (10) is set to common frequencies, thereby reduce power consumption under the monitor state with extending battery life, and wherein, when the indication moving picture photographing begins, by clock conversion and control part (101) this clock frequency is significantly increased, thereby make during the motion picture data are carried out decoding processing, mpeg converter (7) can be stored yuv data by high speed access, reference data for example, the SDRAM of search data etc. (8), and can carry out Real Time Compression to motion picture.
CN1567271 possesses the MPEG code stream conversion acquisition method and the device of express network interface, data filter, the PID that realizes transport stream in equipment revises, information on services inserts and rate conversion, and equipment has the Fast Ethernet interface and is used for the object transmission after the conversion spread and delivers to computer.Realize the direct collection of code stream, also can handle code stream.
CN1633180 comprises wanting encoded signals to implement conversion 1~n based on the multi-description video coding method of conversion and data fusion; Respectively the signal behind conversion 1~n is quantized and entropy coding; Respectively according to separately path 1~n to quantize and entropy coding after signal 1~n decode; Respectively decoded signal 1~n is carried out inverse transformation; Obtain the limit after the inverse transformation respectively and describe 1~n, the data fusion after 1~n the inverse transformation is become steps such as center description.It can combine the multiple description coded and video coding based on conversion and data fusion, and to one group of video sequence, this coding method can produce a plurality of MPEG code streams, can restore a video sequence that distortion is bigger from each code stream; When a plurality of code streams are received, the less video sequence of distortion will be reduced out.
Summary of the invention
The present invention proposes on the basis of original MPEG-2 mobile digital TV, increase special-purpose H.264 video transcoding multiplexing server, and adopt the video code conversion algorithm of transform domain, reduce the transcoding complexity.Realized that with software mode multichannel MPEG-2 is to H.264 transcoding, the multiplexing and demultiplexing of video and audio frequency and the multichannel multiplexing and demultiplexing of program H.264 H.264.
The technical scheme that the realization of this transcoding multiplexing device is adopted is as follows: based on the H.264 method and the multiplexer of multichannel video transcoding multiplexing, input is the single program stream of multichannel MPEG-2, output is one tunnel Polymera stream H.264, realize MPEG-2 to the demultiplexing of H.264 video code conversion, audio frequency and video and multiplexing, multichannel program multiplexing H.264, its video code conversion comprises the conversions of code check, resolution and form.MPEG-2 adopts transcoding algorithm based on machine learning to H.264 video code conversion algorithm, realizes code check, resolution is adjustable, in the frame, interframe adopts different algorithms.MPEG-2 is to the fast conversion method such as following of sign indicating number H.264.When synthetic TS flows, rewrite pid value according to certain rules again, can not be correctly decoded with the decoder of avoiding the PID conflict to cause.When synthetic TS flows, the stream type field of pmt table is made corresponding modification.Multichannel MPEG-2 program stream is imported the transcoding multiplexing server with the ASI interface by pci bus, single channel behind the transcoding multiplexing H.264 video flowing is exported with the ASI interface mode by pci bus, and the half-full signal that uses FIFO to provide reads data fifo or writes FIFO, to avoid CPU frequent access pci interface.MPEG-2 is to H.264 transcoding and the H.264 video flowing behind the multichannel transcoding and audio stream is multiplexing finishes in same server.
TS stream is wrapped according to certain form packing formation PES by the elementary stream (ES) after encoding, add some system informations again and constitute, at transmitting terminal, the PES packing of basic stream is finished by the audio/video encoder, sound, video data stream and the auxiliary data flow of multiplexer received code end, according to certain multiplexing method it being interweaved becomes single TS stream.In order to realize sound, audio video synchronization, in code stream, also must add the sign of various times and the control information of system.For receiving terminal, then just in time opposite with the transmitting terminal process.
MPEG-2 is to H.264 video code conversion: from the MPEG-2 video to the transcoding of video H.264, mainly contain two kinds of frameworks at present: based on the cascade system transcoding (CPDT) of pixel domain with based on the transcoding (DDT) in DCT territory.Cascade system transcoding based on pixel domain is exactly first complete decoding, processes in pixel domain, recompile again.Because coded portion and decoded portion are structurally independent fully during secondary coding, therefore transcoding has very big flexibility, but the motion vector and the coding mode of macro block data have all been done calculating again, and transcoding efficiency is low, as realizing by software entirely, be difficult to the requirement that reaches real-time.Based on the transcoding (DDT) in DCT territory directly in the DCT territory to revaluation such as DCT coefficient, motion vectors, computation complexity is low, but flexibility is restricted, and when requiring to change motion vector, code check, resolution etc., just is difficult to adopt this architecture.
MPEG-2 of the present invention arrives the H.264 fast conversion method of sign indicating number, utilize H.264 Macroblock Mode Selection and the correlation between the MPEG-2 motion compensated residual, H.264 the Macroblock Mode Selection problem is converted into the data qualification problem, and the motion compensated residual, MB pattern, the coded block pattern (CBPC) that utilize the MPEG-2 decoding to obtain are mapped directly to macro block mode H.264; When the MPEG-2 sign indicating number is decoded, preserve relevant MB information, comprise that (sub-MB with 4 * 4 calculates respectively for the average of MB coding mode, encoding block type (CBPC), MB residual error and variance, totally 16 averages and variance), H.264 the encoder of its decoding back employing standard is to the YUV image encoding, and preserve H.264MB coding mode, and adopt machine learning algorithm to obtain decision tree, be used for the H.264 classification of coding mode; When the MPEG-2 code stream decoding, obtain MC residual error, macro block mode, the coded block pattern (CBPC) of MPEG-2, and calculate the average and the variance of 4 * 4 sub-piece MC residual errors; Macro-block coding pattern in obtaining H.264 by decision tree; When H.264 encoding, to the coding mode indirect assignment of MB; H.264 encoder be input as decoded yuv data of MPEG-2 and MB coding mode, do not use the motion vector of MPEG-2, when estimation, use the MB coding mode that obtains by decision tree.Its transcoding algorithm block diagram as shown in Figure 1.
The method that obtains decision tree is: decision tree classification should be followed principle:
1) list entries is divided into the grader of Intra, Skip, Inter16 * 16 and Inter8 * 8;
2) Inter16 * 16 are divided into 16 * 16,16 * 8,8 * 16 grader;
3) inter8 * 8 are divided into 8 * 8,8 * 4,4 * 8,4 * 4 grader.
Decision tree generates should follow principle:
1) if the MC of MPEG-2MB does not encode, promptly do not have non-zero MV, 48 * 8 do not have code coefficient, H.264MB will be encoded into 16 * 16, need to differentiate by the decision tree secondary, select optimization model;
2) if MPEG-2MB is the intra pattern, then in H.264, this MB is encoded into intra or inter8 * 8, if be encoded into intra, algorithm stops; If inter8 * 8 need to select optimization model by the secondary judgement;
3) if MPEG-2MB is the skip pattern, in H.264, this MB also is the skip pattern.
4) decision tree generates by the WEKA Data Mining Tools.The file format of the data mining program of WEKA is ARFF (Attribute-Relation File Format).An ARFF file adopts American Standard Code for Information Interchange to write, and reflects one group of correlation between attribute.Generally comprise two different sections: 1) file header comprises title, attribute and the type of relation; 2) data.
5) training set is made up of the MPEG-2 sequence of high code check, does not comprise the B frame.Decision set by the MPEG-2 code stream decoding after, H.264 recompile obtains.In cataloged procedure H.264, quantization parameter is 25, uses RD to optimize and obtains macro-block coding pattern.
The transcoding decision tree comprises Three Estate, adopts 3 different WEKA trees, as shown in Figure 2:
1) list entries is divided into the grader of Intra, Skip, Inter16 * 16 and Inter8 * 8;
2) Inter16 * 16 are divided into 16 * 16,16 * 8,8 * 16 grader;
3) inter8 * 8 are divided into 8 * 8,8 * 4,4 * 8,4 * 4 grader.
First WEKA decision tree, training dataset has used average and variance, macro block mode (skip, intra and 3 kinds of non-intra are respectively with 0,1,2,4,8 signs), coded block pattern (CBPC) and the coding mode H.264MB of 16 4 * 4 sub-piece residual errors in macro block of MPEG-2.
The capable sample of the example of ARFF data segment is used to train decision-tree model, and delegation represents a macro block sample.
Second decision tree, training sample set has used the average of 16 4 * 4 sub-piece residual errors in macro block of MPEG-2 and variance, macro block mode (3 kinds of non-intra), coded block pattern (CBPC) and 16 * 16 sub-coding mode (16 * 16 H.264MB, 16 * 8,8 * 16).This decision tree has determined the final coding mode of inter 16 * 16.
The 3rd decision tree, training sample set has used the average of 44 * 4 sub-piece residual errors in macro block of MPEG-2 and variance, macro block mode (3 kinds of non-intra), coded block pattern (CBPC) and 8 * 8 sub-coding mode (8 * 8 H.264MB, 8 * 4,4 * 8,4 * 4).
Based on these training files, use the J48 algorithm to generate decision tree by the WEKA Data Mining Tools.The J48 algorithm is proposed by Ross Quinlan, has a wide range of applications in the data mining field.
TS stream is multiplexing
Realize the multiplexing and synchronous of sound, video data for the H.264 video of multi-channel program behind the transcoding and the audio frequency of original program according to the MPEG-2 system layer, and synthetic one road TS stream of multi-channel program (transport stream) is transmitted.TS stream is wrapped according to certain form packing formation PES by the elementary stream (ES) after encoding, add some system informations again and constitute, at transmitting terminal, the PES packing of basic stream is finished by the audio/video encoder, sound, video data stream and the auxiliary data flow of multiplexer received code end, according to certain multiplexing method it being interweaved becomes single TS stream.In order to realize sound, audio video synchronization, in code stream, also must add the sign of various times and the control information of system.For receiving terminal, then just in time opposite with the transmitting terminal process.
Transport stream can be made of a plurality of programs, and each program can be combined with each other by a plurality of streams, comprises video flowing, audio stream, Program Specific Information stream (PSI) etc.Wherein PSI has four types: Program Association Table (PAT), Program Map Table (PMT), network information table (NIT) and conditional access table (CAT).Multiplexer after with transcoding H.264 video and former audio frequency by the form packing of transport stream.The length of TS bag is 188 bytes, is divided into packet header and bag load two parts.Packet header 4 byte prefixes are link prefixs, comprise sync byte 0 * 47 and package identification PID, can judge the data type of its back load from PID, are video flowing, audio stream, PSI or other packet.The bag load is the actual content of bag, as the case may be, can place PES bag or PSI bag.
PSI is used for describing the composition structure that transmits stream, serves as extremely important role in system, particularly importantly pat table and pmt table in multiplexed.Provided in the pat table in one road TS stream how many programs are arranged, and the corresponding relation between it and the pmt table PID; Pmt table provided a programs concrete composition and with the corresponding relation of PID such as video, audio frequency.
In the transcoding multiplexing device, be multiplexed into Polymera one tunnel behind employing software mode MPEG-2 transmission stream (SPTS) transcoding and H.264 transmit stream (MPTS) the multichannel single programs, its block diagram of system is as shown in Figure 3.
The TS stream of multichannel single-unit order MPEG-2 inserts with the ASI interface mode, by pci bus program data is passed to the transcoding multiplexing server.The server major function is to receive 4 road MPEG-2 single program transport streams, and its video is changed into H.264 video, is multiplexed into the transport stream of a multi-channel program then, and removes empty bag, rewrites pid value and stream type field again; Extract and handle any one PSI that receives and business information (SI), itself and local these class data that produce are integrated; In addition, also need to carry out the identification process again of program clock reference PCR with system clock STC.For finishing above function, and improve system works speed as far as possible, below specific implementation has been considered some:
1) for fear of host CPU frequent access pci interface, the half-full signal that utilizes FIFO to provide, CPU read data fifo or write FIFO.For input FIFO, produce when half-full and interrupt, CPU responds interruption, with the disposable memory buffer that reads in of the data among the FIFO; For output FIFO, situation is similar, disposable FIFO is written to half-full.
2) identification of program synchronization character.Obtaining the data of a program, must find the synchronization character of TS stream packets earlier, because synchronous head is not to satisfy unique transparent principle, might be its value just in the load promptly, therefore needs searching and detecting.
3) solution of PID conflict.PID is the unique identification of loadtype in the TS stream.The pid value of different branch MPEG-2 code stream may be identical, do not revise that tend to cause can not correct decoding if do not add, and the way of solution is to rewrite pid value when synthetic TS flows according to certain rules again.For example, if the PID of program 1 is 100, one program of later every detection, new PID adds 1, and the like.
4) modification of stream type.Because the video format of the MPEG-2TS of input stream is MPEG-2, and the video format of synthetic again TS stream is for H.264, therefore need make corresponding modification to the stream type field of pmt table, the stream type field of MPEG-2 is 0x02 before revising, and amended stream type field is 0x1b.
TS flows demultiplexing
The demultiplexing of TS stream is just opposite with multiplexing flow process, and its flow process as shown in Figure 4.Receiving terminal is that 0 bag is set up pat table by detecting PID, by pat table obtain this road TS stream comprise the PID of the pmt table of each programs, thereby set up pmt table.Obtain the PID of the pairing audio frequency and video bag of every programs at last by pmt table.Receiving terminal is put into buffering area by these PID with corresponding audio, video data, so that the decoding of audio/video decoder.
Description of drawings
Fig. 1 is that MPEG-2 arrives video code conversion algorithm block diagram H.264.
Fig. 2 MPEG-2 arrives H.264 video code translator decision tree block diagram.
Fig. 3 is the transcoding multiplexing block diagram of multichannel Single Program Transport Stream.
Fig. 4 is TS stream demultiplexing flow process figure.
Fig. 5 is the application block diagram of video code conversion in mobile digital TV.
Fig. 6 is the corresponding relation figure that TS stream is respectively shown PID.
Embodiment
In mobile digital TV system based on MPEG-2, video content mainly comes from MPEG-2 library of programmes, satellite television, and video living broadcast programs, by multiplexer with a plurality of MPEG-2 program streams multiplexing after, carry out the chnnel coding modulation, carry out the Digital Television wireless transmission then.
Introducing based on video transcoding multiplexing device H.264 after, system architecture is as shown in Figure 5.It is actually MPEG-2 library of programmes and the reach of MPEG-2 program stream, on the one hand, sets up H.264 video frequency program storehouse by static transcoding, selects for use for Play System; On the other hand, the MPEG-2 program stream to satellite television and net cast carries out the dynamic real-time transcoding, the code check of reduction video flowing, spatial resolution, the frame per second of change video flowing, the transmission demand of adaptation rear end.To overlap H.264 by software repeated usage behind the transcoding synthetic one road TS stream of program transmits more.
The TS stream of multichannel single-unit order MPEG-2 inserts the video transcoding multiplexing device with the ASI interface mode, by pci bus program data is passed to the transcoding multiplexing server.Server receives multichannel MPEG-2 single program transport stream, and its video is changed into H.264 video, is multiplexed into the transport stream of a multi-channel program then, and by the output of ASI interface.
In the MPEG-2 single channel program stream of input, the PID of detected first programs is 100, whenever detects a programs later on, and when synthetic TS flowed, new PID added 1.Because the video format of the MPEG-2TS of input stream is MPEG-2, and the video format of synthetic again TS stream is for H.264, need make corresponding modification to the stream type field of pmt table, the stream type field of MPEG-2 is 0x02 before revising, and amended stream type field is 0x1b.
MPEG-2 classification of adopting in the fast conversion method of sign indicating number H.264 based on decision tree:
The average of the Data Mining Tools WEKA analysis of MPEG-2 macro block residual error that use is increased income and variance, coding mode, encoding block type (CBPC) are obtained H.264 macro-block coding pattern.The decision tree of this transcoder comprises 3 WEKA decision trees, identifies with grey in Fig. 2.First WEKA decision tree is used to differentiate skip, Intra, 8 * 8,16 * 16 patterns, if 8 * 8 patterns or 16 * 16 patterns, then uses second or the 3rd decision tree to adjudicate the final pattern of this MB.Calculate the decision level of average and variance in the decision tree by the WEKA instrument.The work of decision tree is as follows:
Node 1: that import this node is MPEG-2 coding MB.By detecting the residual error size of MPEG-2MB, the coded system of MB is divided into 4 classes: skip, Intra, 8 * 8 or 16 * 16.The Intra decision process is not discussed in patent, and other situations need to carry out the decision-making classification second time according to the classification situation of front.When generating decision tree, will use following rule:
1) if the MC of MPEG-2MB does not encode, promptly do not have non-zero MV, 48 * 8 do not have code coefficient.H.264MB will be encoded into 16 * 16.Need to differentiate, select optimization model by the decision tree secondary.
2) if MPEG-2MB is the intra pattern, then in H.264, this MB is encoded into intra or inter8 * 8.If be encoded into intra, algorithm stops; If inter8 * 8 need to select optimization model by the secondary judgement.
3) if MPEG-2MB is the skip pattern, in H.264, this MB also is the skip pattern.
Node 2: importing this node is the 16 * 16MB that is told by node 1, and this node is with second WEKA decision tree, to pattern (16 * 16,16 * 8 or 8 * 16) classification H.264MB.Detecting 16 * 8 or 8 * 16 sub-pieces and whether generate better prediction, is 16 * 8 or 8 * 16 if differentiate, and then is final coding mode, otherwise, will continue to differentiate by node 4.
Node 3: the 8 * 8MB that tells by node 1 that imports this node.This node is with the 3rd WEKA decision tree, sub-macro block H.2648 * 8 selected optimization model: 8 * 8,8 * 4,4 * 8,4 * 4.This decision tree is carried out 4 times, respectively 48 * 8 sub-pieces in the macro block is differentiated once, and this part is only used 44 * 4 average and variance in 8 * 8 sub-pieces.
Node 4: what import this node is skip mode block of being told by node 1 or 16 * 16 mode blocks of being told by node 2.This node is estimated H.26416 * 16 pattern (not comprising 16 * 8 and 8 * 16 patterns), and selecting optimization model is skip or inter16 * 16.
The judgement of MB pattern and the selection of threshold value determine that by quantization parameter (QP) H.264 along with the difference of QP, the threshold value of average and variance is also different.Solve this situation two kinds of methods can be arranged: 1) each QP is generated a decision tree, when H.264 encoding,, select corresponding decision trees according to used QP value; 2) only generate a decision tree, adjust the thresholding of average and variance according to the QP value.For first method, in a transcoder, need to generate 52 different decision trees, and each needs 3 WEKA decision trees, therefore need 156 WEKA decision trees altogether.In H.264, QP value and quantization step have certain relation, the every increase by 6 of QP, and quantization step doubles, and therefore can adjust the threshold value of average and variance by this relation.In this transcoder, adopted second method.Generated QP and be 25 decision tree, other QP values can realize by adjusting threshold level.When QP increased by 6, threshold value improved 2.5%, otherwise reduces by 2.5%.
At the TS of receiving terminal stream demultiplexing, be that 0 bag is set up pat table by detecting PID, by pat table obtain this road TS stream comprise the PID of the pmt table of each programs, thereby set up pmt table.Obtain the PID of the pairing audio frequency and video bag of every programs at last by pmt table, as shown in Figure 6.Receiving terminal is put into buffering area by these PID with corresponding audio, video data, is decoded by audio/video decoder.
Synthetic TS rewrites pid value when flowing according to certain rules again, for example, if the PID of program 1 is 100, one program of later every detection, new PID adds 1, and the like; When synthetic TS flows the stream type field of pmt table is made corresponding modification, the stream type field of MPEG-2 is 0x02 before revising, and amended stream type field is 0x1b.
Packing forms the PES bag to elementary stream (ES) according to certain form, adds some system informations (as business information (SI), system clock information etc.) again and constitutes.
PSI is used for describing the composition structure that transmits stream, and how many programs have provided one road TS in multiplexed in the pat table has in flowing, and the corresponding relation between it and the pmt table PID; Pmt table provided a programs concrete composition and with the corresponding relation of PID such as video, audio frequency; And the modification of employing stream type: because the video format of the MPEG-2TS of input stream is MPEG-2, and the video format of synthetic again TS stream is for H.264, stream type field to pmt table is made corresponding modification, the stream type field of MPEG-2 is 0x02 before revising, and amended stream type field is 0x1b.
The TS stream of multichannel single-unit order MPEG-2 inserts with the ASI interface mode, by pci bus program data is passed to the transcoding multiplexing server; Server receives 4 road MPEG-2 single program transport streams, and its video is changed into H.264 video, is multiplexed into the transport stream of a multi-channel program then, and removes empty bag, rewrites pid value and stream type field again; Extract and handle any one PSI that receives and business information (SI), itself and local these class data that produce are integrated.In addition, also need to carry out the identification process again of program clock reference PCR with system clock STC.During TS stream demultiplexing, receiving terminal is that 0 bag is set up pat table by detecting PID, by pat table obtain this road TS stream comprise the PID of the pmt table of each programs, thereby set up pmt table; Obtain the PID of the pairing audio frequency and video bag of every programs at last by pmt table.Receiving terminal is put into buffering area by these PID with corresponding audio, video data, is decoded by audio/video decoder.
The invention process flow process also comprises: based on the method for multichannel video transcoding multiplexing H.264, input is the single program stream of multichannel MPEG-2, output is one tunnel Polymera stream H.264, realize MPEG-2 to the demultiplexing of H.264 video code conversion, audio frequency and video and multiplexing, multichannel program multiplexing H.264, its video code conversion comprises the conversions of code check, resolution and form; MPEG-2 adopts MPEG-2 to arrive the H.264 fast conversion method of sign indicating number to video code conversion algorithm H.264, utilize H.264 Macroblock Mode Selection and the correlation between the MPEG-2 motion compensated residual, H.264 the Macroblock Mode Selection problem is converted into the data qualification problem, and the motion compensated residual, MB pattern, the coded block pattern (CBPC) that utilize the MPEG-2 decoding to obtain are mapped directly to macro block mode H.264; When the MPEG-2 code stream decoding, preserve relevant MB information, the average and the variance that comprise MB coding mode, encoding block type, MB residual error, H.264 the encoder of its decoding back employing standard is to the YUV image encoding, and preserve H.264MB coding mode, adopt machine learning algorithm to obtain decision tree, be used for the H.264 classification of coding mode; When the MPEG-2 code stream decoding, obtain MC residual error, macro block mode, the coded block pattern (CBPC) of MPEG-2, and calculate the average and the variance of 4 * 4 sub-piece MC residual errors; Macro-block coding pattern in obtaining H.264 by decision tree; When H.264 encoding, to the coding mode indirect assignment of MB; H.264 encoder be input as decoded yuv data of MPEG-2 and MB coding mode: when estimation, use the MB coding mode that obtains by decision tree; Realize code check, resolution is adjustable, in the frame, interframe adopts different algorithms; And synthetic TS stream is imported transcoding multiplexing server with the ASI interface by pci bus at multichannel MPEG-2 program stream, and the single channel behind the transcoding multiplexing H.264 video flowing is exported with the ASI interface mode by pci bus; TS stream is wrapped according to certain form packing formation PES by the elementary stream (ES) after encoding, add system information again and constitute, at transmitting terminal, the PES packing of basic stream is finished by the audio/video encoder, sound, video data stream and the auxiliary data flow of multiplexer received code end, according to certain multiplexing method it being interweaved becomes single TS stream; In code stream, add the sign of various times and the control information of system; For receiving terminal, then just in time opposite with the transmitting terminal process.Synthetic TS rewrites pid value again when flowing.
The half-full signal that utilizes FIFO to provide when the MPEG-2 code stream decoding, CPU read data fifo or write FIFO; For input FIFO, produce when half-full and interrupt, CPU responds interruption, with the disposable memory buffer that reads in of the data among the FIFO; For output FIFO, disposable FIFO is written to half-full.
Transport stream can be made of a plurality of programs, and each program can be combined with each other by a plurality of streams, comprises video flowing, audio stream, Program Specific Information stream PSI; Wherein Program Specific Information stream PSI has four types: Program Association Table PAT, Program Map Table PMT, network information table (NIT) and conditional access table (CAT); Multiplexer after with transcoding H.264 video and former audio frequency by the form packing of transport stream.The length of TS bag is 188 bytes, is divided into packet header and bag load two parts; Packet header 4 byte prefixes are link prefixs, comprise sync byte 0 * 47 and package identification PID, judge the data type of its back load from PID, are video flowing, audio stream, PSI or other packet; The bag load is the actual content of bag, places PES bag or PSI bag.
PSI is used for describing the composition structure that transmits stream, and how many programs have provided one road TS in multiplexed in the pat table has in flowing, and the corresponding relation between it and the pmt table PID; Pmt table provided a programs concrete composition and with the corresponding relation of PID such as video, audio frequency; And the modification of employing stream type: because the video format of the MPEG-2TS of input stream is MPEG-2, and the video format of synthetic again TS stream is for H.264, stream type field to pmt table is made corresponding modification, the stream type field of MPEG-2 is 0x02 before revising, and amended stream type field is 0x1b.
The TS stream of multichannel single-unit order MPEG-2 inserts with the ASI interface mode, by pci bus program data is passed to the transcoding multiplexing server; Server receives 4 road MPEG-2 single program transport streams, and its video is changed into H.264 video, is multiplexed into the transport stream of a multi-channel program then, and removes empty bag, rewrites pid value and stream type field again; Extract and handle any one PSI that receives and business information (SI), itself and local these class data that produce are integrated.
Also need to carry out the identification process again of program clock reference PCR with system clock STC.
During TS stream demultiplexing, receiving terminal is that 0 bag is set up pat table by detecting PID, by pat table obtain this road TS stream comprise the PID of the pmt table of each programs, thereby set up pmt table; Obtain the PID of the pairing audio frequency and video bag of every programs at last by pmt table; Receiving terminal is put into buffering area by these PID with corresponding audio, video data, is decoded by audio/video decoder.