CN1166174C - Method for correcting timer reference of programs in multiplexing - Google Patents
Method for correcting timer reference of programs in multiplexing Download PDFInfo
- Publication number
- CN1166174C CN1166174C CNB001235729A CN00123572A CN1166174C CN 1166174 C CN1166174 C CN 1166174C CN B001235729 A CNB001235729 A CN B001235729A CN 00123572 A CN00123572 A CN 00123572A CN 1166174 C CN1166174 C CN 1166174C
- Authority
- CN
- China
- Prior art keywords
- transport stream
- data packet
- time
- output
- stream data
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Expired - Fee Related
Links
Images
Landscapes
- Compression Or Coding Systems Of Tv Signals (AREA)
- Time-Division Multiplex Systems (AREA)
Abstract
一种MPEG-2传输流数据包流在多路复用中,节目时钟基准的校正方法,针对复用系统的每一个输入通道,确定一个传输流数据包经过该通道的固定延迟时间Ts;在复用过程中测量传输流数据包的实际停留时间Ta;以实际停留时间Ta与固定延迟时间Ts的差值Td作为修正值,调整传输流数据包中的节目时钟基准。采用本方法,可以完成多路互不相关的MPEG-2传送码流能够被复用成为一路的MPEG-2传送码流的功能,并且引入的误差非常小。
A kind of MPEG-2 transport stream packet flow in multiplexing, the correction method of program clock reference, for each input channel of multiplexing system, determine the fixed delay time Ts that a transport stream packet passes through this channel; During the multiplexing process, the actual dwell time Ta of the transport stream data packet is measured; the difference Td between the actual dwell time Ta and the fixed delay time Ts is used as a correction value to adjust the program clock reference in the transport stream data packet. By adopting the method, the function that multiple uncorrelated MPEG-2 transmission code streams can be multiplexed into one MPEG-2 transmission code stream can be achieved, and the introduced error is very small.
Description
本发明涉及多媒体通信中媒体同步技术领域,特别是涉及在MPEG-2传输流数据包流(以下又简称传送码流)多路复用过程中,对输入节目的节目时钟基准(以下也简称PCR)在复用输出时进行校正的方法。The present invention relates to the field of media synchronization technology in multimedia communications, in particular to the program clock reference (hereinafter also referred to as PCR ) method to correct when multiplexing the output.
多媒体通信中媒体同步技术的重要性不言而喻,特别是同一节目的视频/音频同步处理更是如此。视频/音频同步包括编码/解码同步和音频/视频唇同步两个方面,哪一个方面做的不够好,都会对编解码过程中的视频/音频质量产生很大的损害。具体的同步处理包括编码阶段的同步信息获取和按照MPEG-2同步信息格式编码加入MPEG-2传输流数据包流(以下也简称TS流或TSP流),多路复用时由于延迟的变化必须对节目同步信息做必要的修改,解码阶段恢复码流同步信息并控制视频/音频同步解码、显示。下面逐一介绍同步处理技术。The importance of media synchronization technology in multimedia communication is self-evident, especially the video/audio synchronization processing of the same program. Video/audio synchronization includes two aspects: encoding/decoding synchronization and audio/video lip synchronization. If any aspect is not done well, it will cause great damage to the video/audio quality during the encoding and decoding process. The specific synchronization process includes acquisition of synchronization information in the encoding stage and encoding according to the MPEG-2 synchronization information format to join the MPEG-2 transport stream packet stream (hereinafter also referred to as TS stream or TSP stream). Due to delay changes during multiplexing, it must Make necessary modifications to the program synchronization information, recover the code stream synchronization information in the decoding stage and control the video/audio synchronization decoding and display. The synchronous processing techniques are introduced one by one below.
图1示出了MPEG-2定义的同步模型,为了保证解码器恢复出节目视频/音频信号的质量,MPEG-2协议定义了时间模型,用来同步解码得到的视频和音频信号输出,控制视频和音频信号以编码时的速率再现。Figure 1 shows the synchronization model defined by MPEG-2. In order to ensure that the decoder recovers the quality of the program video/audio signal, the MPEG-2 protocol defines a time model, which is used to synchronize the decoded video and audio signal output and control the video and audio signals are reproduced at the rate at which they were encoded.
请参照图1所示,在编码端,编码器标记每个视频和音频显示单元的显示时间(PTS)和解码时间(DTS),同时将显示时间标签和解码时间标签按照一定规则编码在传输流中发送。另一方面还必须把系统时钟(STC)编码并加入到码流中同时发送,系统时钟的编码方式为节目时钟基准(PCR)。Please refer to Figure 1, at the encoding end, the encoder marks the display time (PTS) and decoding time (DTS) of each video and audio display unit, and at the same time encodes the display time label and decoding time label in the transport stream according to certain rules sent in. On the other hand, the system clock (STC) must be encoded and added to the code stream and sent at the same time. The encoding method of the system clock is the program clock reference (PCR).
在解码端,解码器利用码流中的节目时钟基准(PCR),恢复还原系统时钟(STC),并根据视频/音频解码时间标签(PTS)安排视频/音频访问单元解码顺序,同理根据显示时间标签(PTS)安排显示单元显示顺序,使得同步的音频/视频得以恢复显示。At the decoding end, the decoder uses the program clock reference (PCR) in the code stream to restore the system clock (STC), and arranges the video/audio access unit decoding sequence according to the video/audio decoding time tag (PTS). Similarly, according to the display The time stamp (PTS) arranges the display order of the display units so that the synchronized audio/video can be resumed.
请参照图1所示,MPEG-2要求在节目的编码、存储、传输和解码的完整过程中,保持端到端的固定延迟。在固定延迟的保证下,解码端才可以利用PCR准确恢复出编码端系统时钟。如果在码流复用过程中引起抖动,必须调整PCR以便解码端可以准确恢复出系统时钟。Please refer to Figure 1, MPEG-2 requires end-to-end fixed delay during the entire process of program encoding, storage, transmission and decoding. Under the guarantee of fixed delay, the decoding end can use PCR to accurately recover the system clock of the encoding end. If jitter is caused during the stream multiplexing process, the PCR must be adjusted so that the decoder can accurately recover the system clock.
编码同步信息就是要为MPEG-2编码输出码流注入正确的PCR、PTS/DTS数据。MPEG-2规定系统时钟(STC)为27MHZ,精度为30PPM。PCR是系统时钟的42bits计数值采样,由33bits的PCR-BASE和9bits的PCR-EXTERN组成,PCR的精度要求为抖动最大范围500ns,PCR的计算公式如下:Encoding synchronization information is to inject correct PCR, PTS/DTS data into MPEG-2 encoding output code stream. MPEG-2 stipulates that the system clock (STC) is 27MHZ, and the precision is 30PPM. PCR is the sampling of the 42bits count value of the system clock. It consists of 33bits PCR-BASE and 9bits PCR-EXTERN. The accuracy of PCR is required to have a maximum jitter range of 500ns. The calculation formula of PCR is as follows:
PCR-BASE=STC/300PCR-BASE=STC/300
PCR-EXTERN=STC%300PCR-EXTERN=STC%300
其中PCR-BASE是STC的90kHz采样,而PCR-EXTERN是STC的27MHz采样。Among them, PCR-BASE is 90kHz sampling of STC, and PCR-EXTERN is 27MHz sampling of STC.
PTS/DTS都是STC的90kHz采样。PTS/DTS are both STC's 90kHz sampling.
同步信息编码的难点在于PCR的精度要求特别高,另一个是PTS/DTS要保持和PCR的正确关系。编码的PCR加入精度太低会影响解码阶段对系统时钟的恢复,以至于影响视频/音频的正确解码,同时也会影响参加多路复用的次数。PTS/DTS必须经过处理,否则有可能引起解码器缓冲区动作出现错误,导致缓冲区上溢或者非正常下溢,这些都是不允许的。The difficulty of synchronous information encoding is that the accuracy of PCR is particularly high, and the other is that PTS/DTS must maintain the correct relationship with PCR. Too low accuracy of the encoded PCR will affect the recovery of the system clock in the decoding stage, so that it will affect the correct decoding of video/audio, and will also affect the number of times to participate in multiplexing. PTS/DTS must be processed, otherwise it may cause errors in the buffer operation of the decoder, resulting in buffer overflow or abnormal underflow, which are not allowed.
解码阶段必须根据码流中提供的同步信息控制恢复出同步的音频/视频信号。MPEG-2解码器恢复同步信息包括恢复系统时钟和根据同步信息安排解码以及显示两方面的技术。The decoding stage must control and recover the synchronous audio/video signal according to the synchronous information provided in the code stream. MPEG-2 decoder restores synchronization information including recovering system clock and arranging decoding and displaying technologies according to synchronization information.
解码器拥有一个本地的27MHZ时钟和一个锁相环(PLL),锁相环的工作原理是,当接收到节目的第一个PCR时,把本地的STC设置成为该PCR值,利用后续接收的PCR的值和当前STC的计数值之间的差值调整本地27MHZ时钟,使其与编码系统时钟同步。The decoder has a local 27MHZ clock and a phase-locked loop (PLL). The working principle of the phase-locked loop is that when the first PCR of the program is received, the local STC is set to the PCR value, and the subsequent received The difference between the PCR value and the current STC count value adjusts the local 27MHZ clock to synchronize it with the encoding system clock.
MPEG-2的视频帧结构有I、P、B帧,I帧是无预测的视频帧,P帧是根据前一帧预测得到的编码视频帧,B帧是根据前面I帧(或者P帧)和后面I帧(或者P帧)预测编码得到的视频帧,由于B帧需要根据后面的帧来预测,所以显示次序和编码/解码次序会有所不同,例如显示次序是IBBP的帧序列,其编码/解码次序应该是IPBB,这就要求解码时要有一个帧重排的过程。MPEG-2采用DTS指示解码时间,PTS指示显示时间,解码时根据DTS安排解码次序,根据PTS安排显示次序。对于PTS/DTS不同的情况,解码器要缓存该帧,并作为预测基准帧。这时,PTS/DTS非正常超前或者落后都有可能造成缓冲区动作出错,而产生溢出。The video frame structure of MPEG-2 includes I, P, and B frames. The I frame is a video frame without prediction, the P frame is a coded video frame predicted according to the previous frame, and the B frame is based on the previous I frame (or P frame). The video frame obtained by predictive coding with the subsequent I frame (or P frame), because the B frame needs to be predicted according to the subsequent frame, the display order and encoding/decoding order will be different, for example, the display order is IBBP frame sequence, its The encoding/decoding sequence should be IPBB, which requires a frame rearrangement process during decoding. MPEG-2 uses DTS to indicate the decoding time, and PTS to indicate the display time. When decoding, the decoding order is arranged according to the DTS, and the display order is arranged according to the PTS. For the case of different PTS/DTS, the decoder should cache the frame and use it as the prediction reference frame. At this time, PTS/DTS abnormal advance or lag may cause buffer operation error, resulting in overflow.
解码软件对码流同步信息进行检测,提取同步信息,并根据同步信息驱动解码器动作,完成音频/视频的同步解码显示控制。同样包括两部分内容,就是提取节目PCR,驱动锁相环,完成系统时钟恢复,另一方面提取PTS/DTS,根据本地STC情况,安排解码和显示。The decoding software detects the synchronous information of the code stream, extracts the synchronous information, and drives the decoder according to the synchronous information to complete the audio/video synchronous decoding and display control. It also includes two parts, that is to extract the program PCR, drive the phase-locked loop, complete the system clock recovery, on the other hand, extract the PTS/DTS, and arrange decoding and display according to the local STC situation.
在多节目复用的情况下,假设每一个传输流数据包TSP在多节目复用时的停留时间都相同,即具有固定延迟,则PCR无须经过任何修改。但是,由于各个TSP在复用过程中的处理时间不尽相同,并且输入/输出FIFO并发情况的存在(总线争用),以及输入/输出码率不同等因素的存在,导致各个TSP在复用板的处理延迟时间(停留时间)有所不同,所以需要调整各路节目的PCR,以使解码端依然能够根据此PCR值恢复出准确的编码系统时钟。In the case of multi-program multiplexing, assuming that the stay time of each transport stream data packet TSP in multi-program multiplexing is the same, that is, has a fixed delay, the PCR does not need any modification. However, due to the different processing time of each TSP in the multiplexing process, the existence of input/output FIFO concurrency (bus contention), and the existence of factors such as different input/output code rates, each TSP is multiplexed. The processing delay time (dwell time) of different boards is different, so it is necessary to adjust the PCR of each program, so that the decoder can still recover the accurate encoding system clock according to the PCR value.
本发明的目的是提供一种在MPEG-2的传送码流多路复用过程中的PCR校正方法,以完成多路互不相关的MPEG-2传送码流能够被复用成为一路的MPEG-2传送码流的功能,同时要达到降低由于PCR校正而引入的PCR抖动的目的。The object of the present invention is to provide a kind of PCR correction method in the MPEG-2 transport code stream multiplexing process, can be multiplexed into one way MPEG-2 transport code stream to complete the MPEG-2 that is independent of each other. 2 The function of transmitting the code stream, and at the same time achieve the purpose of reducing the PCR jitter introduced by PCR correction.
基于以上目的,本发明的技术方案是:一种MPEG-2传输流数据包流在多路复用中,节目时钟基准的校正方法,其中,针对复用系统的每一个输入通道,确定一个传输流数据包经过该通道的固定延迟时间Ts;在复用过程中测量传输流数据包的实际停留时间Ta;以实际停留时间Ta与固定延迟时间Ts的差值Td作为修正值,调整传输流数据包中的节目时钟基准。Based on the above purpose, the technical solution of the present invention is: a method for correcting the program clock reference in the multiplexing of MPEG-2 transport stream data packets, wherein, for each input channel of the multiplexing system, a transmission The fixed delay time Ts of the flow data packet passing through the channel; the actual residence time Ta of the transmission flow data packet is measured during the multiplexing process; the difference Td between the actual residence time Ta and the fixed delay time Ts is used as the correction value to adjust the transmission flow data The program clock reference in the package.
较佳的,在复用过程中,仅测量包含有节目时钟基准的传输流数据包的实际停留时间Ta,并对该传输流数据包中的节目时钟基准进行调整,在这种方案中,需要对进入输入通道的每一个传输流数据包进行判断,判断其是否包含节目时间基准。Preferably, in the multiplexing process, only the actual residence time Ta of the transport stream data packet containing the program clock reference is measured, and the program clock reference in the transport stream data packet is adjusted. In this scheme, it is required Each transport stream data packet entering the input channel is judged to determine whether it contains the program time reference.
较佳的,在复用过程中,测量所有传输流数据包的实际停留时间Ta,但在调整过程中,仅调整包含有节目时钟基准的传输流数据包的节目时钟基准。Preferably, during the multiplexing process, the actual dwell time Ta of all transport stream data packets is measured, but during the adjustment process, only the program clock reference of the transport stream data packets containing the program clock reference is adjusted.
本发明的方法在计算传送数据包的固定延迟和实际延迟时,都是由传送数据包驱动,传送数据包的输入时刻标签和输出时刻标签,都可以由硬件逻辑电路根据传送数据包实际输入和输出时刻进行精确锁定。这样误差主要来自本地复用系统的27MHZ时钟精度误差,以及本地时钟计数器由输入/输出信号触发锁定时的延迟误差。由于27MHZ时钟的精度可以通过采用高精度的晶振来实现,一般要求50ppm以上就可以。而对于触发锁定时的延迟误差最大为一个时钟周期,所以采用本发明的方法进行PCR的校正,引入的误差非常小。The method of the present invention is driven by the transmission data packet when calculating the fixed delay and the actual delay of the transmission data packet, and the input time label and the output time label of the transmission data packet can be input and output by the hardware logic circuit according to the actual input and output time of the transmission data packet. The output is precisely locked at all times. This error mainly comes from the 27MHZ clock precision error of the local multiplexing system, and the delay error when the local clock counter is locked by the input/output signal trigger. Since the precision of the 27MHZ clock can be achieved by using a high-precision crystal oscillator, it generally requires more than 50ppm. However, the maximum delay error when triggering locking is one clock cycle, so the method of the present invention is used to correct the PCR, and the introduced error is very small.
为使本发明的目的、方案、和优点更加清楚明白,以下举实施例,并结合附图,对本发明进一步详细说明。其中In order to make the purpose, solution, and advantages of the present invention clearer, the following examples are given in conjunction with the accompanying drawings to further describe the present invention in detail. in
图1示出了一个MPEG-2同步模型;Figure 1 shows an MPEG-2 synchronization model;
图2示出了本发明第二较佳实施例中一个MPEG-2 TS流多路复用的示例图;Fig. 2 shows an example diagram of MPEG-2 TS stream multiplexing in the second preferred embodiment of the present invention;
图3示出了本发明第二较佳实施例中TS流多路复用和PCR校正方法的实现流程图。Fig. 3 shows a flow chart of the realization of the TS stream multiplexing and PCR correction method in the second preferred embodiment of the present invention.
本发明中PCR校正的原理可以解释为,假设每个TSP在复用板的应该停留时间已知,并且为常量,设为固定延迟时间Ts。在复用过程中可以测量每个TSP的实际停留时间Ta,求得停留时间的差值Td。根据Td来调整PCR。公式如下:The principle of PCR correction in the present invention can be explained as, assuming that the residence time of each TSP in the multiplexing board is known and constant, and is set as a fixed delay time Ts. During the multiplexing process, the actual residence time Ta of each TSP can be measured to obtain the difference Td of the residence time. PCR was adjusted according to Td. The formula is as follows:
Td=Ta-Ts (公式1)Td=Ta-Ts (Formula 1)
固定延迟时间可以是平均停留时间,也可以是提前或者拖后于平均时间的某个值。根据上述公式1就可计算出每个TSP实际停留时间Ta和固定延迟时间Ts的差值Td,用Td为基础来调整PCR。The fixed delay time can be the average dwell time, or a value ahead or behind the average time. According to the above formula 1, the difference Td between the actual residence time Ta of each TSP and the fixed delay time Ts can be calculated, and the PCR can be adjusted based on Td.
较佳的,所述的固定延迟时间Ts是,该输入通道第一个包含有节目时钟基准的传输流数据包的实际延迟时间;并且当输入通道的码率变化时,该输入通道的固定延迟时间Ts应重新计算,当输出通道的码率变化时,所有输入通道的固定延迟时间Ts均应重新计算。Preferably, the fixed delay time Ts is the actual delay time of the first transport stream packet containing the program clock reference of the input channel; and when the code rate of the input channel changes, the fixed delay of the input channel The time Ts should be recalculated. When the code rate of the output channel changes, the fixed delay time Ts of all input channels should be recalculated.
较佳的,复用系统设置了一个27MHZ的系统时钟,并且根据输入和输出端口数N,设置N个系统时钟计数器,每个计数器固定分配给一个输入或者输出端口,用于记录各种输入和输出时刻。Preferably, a 27MHZ system clock is set in the multiplexing system, and N system clock counters are set according to the number N of input and output ports, and each counter is fixedly assigned to an input or output port for recording various input and output ports. output moment.
较佳的,在复用过程中,所述测量传输流数据包的实际停留时间Ta,进一步包含以下步骤:当传输流数据包进入复用系统时,记录其输入时刻标签;当传输流数据包被输出时,记录其输出时刻标签;利用该输出时刻标签与该输入时刻标签计算此传输流数据包在复用系统中的实际停留时间Ta。Preferably, during the multiplexing process, said measuring the actual residence time Ta of the transport stream data packet further includes the following steps: when the transport stream data packet enters the multiplexing system, record its input time tag; when the transport stream data packet When it is output, record its output time tag; use the output time tag and the input time tag to calculate the actual stay time Ta of the transport stream data packet in the multiplexing system.
本发明的第一较佳实施例中,在实现MPEG-2传送码流多路复用过程中PCR校正时,有如下一些技术特征:In the first preferred embodiment of the present invention, when realizing the PCR correction in the multiplexing process of the MPEG-2 transport code stream, there are some following technical characteristics:
系统设置了一个27MHZ的系统时钟,根据输入和输出端口数N,设置N个系统时钟计数器,每个计数器固定分配给一个输入或者输出端口,利用这些计数器来记录各种输入和输出时刻。The system sets a 27MHZ system clock. According to the number N of input and output ports, N system clock counters are set. Each counter is fixedly assigned to an input or output port. These counters are used to record various input and output moments.
每一个传送数据包进入系统时,必须记录其输入时刻标签,并且当此时的传送数据包包含PCR时,此输入时刻标签必须保存到此数据包被输出之后才能丢弃。When each transmission data packet enters the system, its input time label must be recorded, and when the transmission data packet at this time contains PCR, the input time label must be saved until the data packet is output before being discarded.
当一个传送数据包需要被输出时,需要记录其输出时刻标签,当此时输出的传送数据包包含PCR时,需要利用此输出时刻标签与该传送数据包的输入时刻标签计算此传送数据包在复用系统中的延迟时间。When a transmission data packet needs to be output, it is necessary to record its output time tag. When the output transmission data packet contains PCR at this time, it is necessary to use the output time label and the input time label of the transmission data packet to calculate the transmission time Latency in multiplexed systems.
利用传送数据包的输出时刻标签和输入时刻标签计算得到的延迟时间值,减去一个延迟时间的固定值,就可以得到此传送包中PCR应该调整的调整值,利用此调整值校正PCR值,就可得到校正后的PCR值。Using the delay time value calculated by the output time label and input time label of the transmitted data packet, subtracting a fixed value of the delay time, the adjustment value that should be adjusted by the PCR in the transmission packet can be obtained, and the PCR value can be corrected by using this adjustment value. Then the corrected PCR value can be obtained.
在本实施例中,延迟时间的固定值是这样设置的:针对每一个输入通道,都要设置一个固定延迟时间,此固定延迟时间就是该输入通道第一个含有PCR的传送数据包的实际延迟时间。一般的方法是使用一个经验值作为延迟时间固定值,这种做法的缺点是:每一个输入通道的码率范围都很大,而传送数据包的延迟时间是决定于输入和输出通道以及当前输入码流通道数目等因素,为每一种情况取得一个经验值并不容易,或者取得的经验值误差太大。本实施例中使用该输入通道第一个含有PCR的传送数据包的实际延迟时间作为延迟时间固定值可以带来以下优点:更加接近实际的固定延迟时间,使得校正引起的精度误差降低,同时这样做也更加容易实现。In this embodiment, the fixed value of the delay time is set like this: for each input channel, a fixed delay time must be set, and this fixed delay time is the actual delay of the first transmission data packet containing PCR of the input channel time. The general method is to use an empirical value as the fixed value of the delay time. The disadvantage of this approach is that the bit rate range of each input channel is very large, and the delay time of transmitting data packets is determined by the input and output channels and the current input. Due to factors such as the number of stream channels, it is not easy to obtain an experience value for each situation, or the error of the obtained experience value is too large. In this embodiment, using the actual delay time of the first transmission data packet containing PCR of the input channel as the fixed value of the delay time can bring the following advantages: it is closer to the actual fixed delay time, so that the accuracy error caused by the correction is reduced, and at the same time It is also easier to do.
当输入通道码率变化时,需要重新计算该通道的固定延迟时间,当输出通道码率变化时需要重新计算所有输入通道的固定延迟时间。以保持固定延迟时间尽可能接近时间延迟时间,降低由于校正而引入的PCR精度误差。When the code rate of the input channel changes, the fixed delay time of the channel needs to be recalculated, and when the code rate of the output channel changes, the fixed delay time of all input channels needs to be recalculated. To keep the fixed delay time as close as possible to the time delay time, reduce the PCR accuracy error introduced by the correction.
总结本实施例的PCR校正计算方法如下:对于一个含有PCR的传送数据包来说,标记其通道输入时刻标签为T(in)j,其中j表示该通道输入的第j个含有PCR的传送数据包,经过复用之后输出时刻标签为T(out)j,该通道的复用固定延迟时间为ConstDelta,各个传送数据包的复用实际延迟时间为ActualDelta,原来的PCR值记为OrgPCR,校正后的PCR值记为NewPCR。下面是NewPCR的计算公式:To summarize the PCR correction calculation method of this embodiment is as follows: for a transmission data packet containing PCR, mark its channel input time label as T(in)j, where j represents the jth transmission data containing PCR input by the channel package, after multiplexing, the output time label is T(out)j, the multiplexing fixed delay time of this channel is ConstDelta, the multiplexing actual delay time of each transmitted data packet is ActualDelta, and the original PCR value is recorded as OrgPCR, after correction The PCR value of is recorded as NewPCR. The following is the calculation formula of NewPCR:
(1)固定延迟时间:ConstDelta=T(out)1-T(in)1(1) Fixed delay time: ConstDelta=T(out)1-T(in)1
(2)实际延迟时间:ActualDeltaj=T(out)j-T(in)j(2) Actual delay time: ActualDeltaj=T(out)j-T(in)j
(3)PCR校正公式:NewPCRj=OrgPCRj+(ActualDeltaj-ConstDelta)(3) PCR correction formula: NewPCRj=OrgPCRj+(ActualDeltaj-ConstDelta)
图2示出了本发明第二较佳实施例中MPEG-2TS流多路复用的示例图。其中IN_FIFO1接收并缓存第1路输入TS流数据,IN_FIFO2接收并缓存第2路输入TS流数据,IN_FIFOn接收并缓存第n路输入TS流数据。多路的输入TS流数据,经过MPU的复用处理,通过总线分时的传送到输出TS的缓冲OUT_FIFO中,由输出时钟驱动形成输出TS流。TS流是由顺序传送的TS数据包构成,每一个TS数据包都是固定的188字节长度,其中TS包头有4个字节,第1个字节必然是同步字节0X47,同步字节作为TS数据包在TS流中的定界标志,通过对同步字节的定界,可以从TS流中得到正确的TS数据包。需要说明的是,MPU对输入TS流的处理是以188字节TS数据包为单位,输出到OUT_FIFO时也是以188字节的TS数据包为单位。对于MPU来说,复用时的处理包括PCR校正、PID重新分配、PSI重新构造等方面。本发明涉及的是PCR校正方面的处理。Fig. 2 is a diagram showing an example of MPEG-2 TS stream multiplexing in the second preferred embodiment of the present invention. Among them, IN_FIFO1 receives and buffers the first input TS stream data, IN_FIFO2 receives and buffers the second input TS stream data, and IN_FIFOn receives and buffers the nth input TS stream data. Multiple channels of input TS stream data are multiplexed by the MPU and transmitted to the buffer OUT_FIFO of the output TS through the bus in time division, and are driven by the output clock to form an output TS stream. The TS stream is composed of TS data packets transmitted in sequence. Each TS data packet has a fixed length of 188 bytes. The TS packet header has 4 bytes. The first byte must be the synchronization byte 0X47, the synchronization byte As the delimitation mark of the TS data packet in the TS stream, the correct TS data packet can be obtained from the TS stream by demarcating the synchronization byte. It should be noted that the MPU processes the input TS stream in units of 188-byte TS data packets, and the unit of output to OUT_FIFO is also in units of 188-byte TS data packets. For the MPU, the processing during multiplexing includes PCR correction, PID reallocation, PSI reconstruction and other aspects. The present invention relates to the processing of PCR correction.
图3示出了本发明第二较佳实施例中TS流多路复用和PCR校正方法的实现流程图。以下就各个步骤对本实施例详细说明。Fig. 3 shows a flow chart of the realization of the TS stream multiplexing and PCR correction method in the second preferred embodiment of the present invention. Each step will be described in detail below in this embodiment.
步骤202:记录TS数据包到达系统的时刻标签。当TS数据包到达复用系统时,系统根据TS数据包的同步字节,对TS数据包进行定界。定界完成之后,后续的各个输入TS数据包的输入时刻就可以通过同步字节和系统时钟计数器的当前值来获得,也就是当复用系统收到TS数据包的同步字节时,读取系统时钟计数器的当前值,这个值就是TS数据包的输入时刻标签Tinj,j表示从第1个输入到FIFO的TS数据包计起第j个输入的TS数据包。Step 202: Record the time stamp when the TS data packet arrives at the system. When the TS data packet arrives at the multiplexing system, the system demarcates the TS data packet according to the synchronization byte of the TS data packet. After the delimitation is completed, the input time of each subsequent input TS data packet can be obtained through the synchronization byte and the current value of the system clock counter, that is, when the multiplexing system receives the synchronization byte of the TS data packet, it reads The current value of the system clock counter, this value is the input time label Tinj of the TS data packet, and j represents the jth input TS data packet from the first TS data packet input to the FIFO.
步骤203:TS数据包送入FIFO。对于总线式的时分复用系统,多路输入同时请求总线是可能发生的,系统对多路输入的请求需要有一个调度的过程,所以输入数据需要进行缓存。Step 203: TS data packets are sent to FIFO. For a bus-type time-division multiplexing system, it is possible for multiple inputs to request the bus at the same time. The system needs a scheduling process for multiple input requests, so the input data needs to be cached.
步骤204:MPU把输入TS数据包读到处理缓冲区。对于多路的输入请求,MPU在任一时刻只能处理其中的一路,MPU根据输入调度策略(如先来先服务等),选择其中一路的输入请求进行处理。MPU处理TS数据包时需要把TS数据包从输入FIFO中读入到MPU的数据缓冲区中。Step 204: The MPU reads the input TS data packet into the processing buffer. For multiple input requests, the MPU can only process one of them at any time, and the MPU selects one of the input requests for processing according to the input scheduling policy (such as first-come-first-served, etc.). When the MPU processes the TS data packet, it needs to read the TS data packet from the input FIFO into the data buffer of the MPU.
步骤205:MPU对TS数据包进行复用处理。从多路MPEG-2的TS码流复用成为一路MPEG-2的TS码流,需要对输入的TS数据包做相应的处理,以保证复用后的TS码流依然符合MPEG-2标准的规定。这些处理包括PID的重新分配和修改等。Step 205: The MPU performs multiplexing processing on the TS data packets. From the multiplexing of multiple MPEG-2 TS streams into one MPEG-2 TS stream, the input TS data packets need to be processed accordingly to ensure that the multiplexed TS streams still conform to the MPEG-2 standard. Regulation. These processes include reassignment and modification of PID, etc.
步骤206:当输出FIFO请求时,系统根据输出FIFO请求信号和系统时钟计数器的当前值,记录下一个数据包的输出时刻标签,也就是,当输出FIFO产生请求信号时,这时需要送出一个TS数据包,所以当输出FIFO产生请求信号的时刻就是下一个TS数据包送出的时刻,这时的系统时钟计数器的当前值就是下一个TS数据包被输出的时刻标签,记为Toutj,表示从第1个TS数据包被输出开始的第j个数据包的输出时刻标签。Step 206: When the output FIFO request is made, the system records the output time label of the next data packet according to the output FIFO request signal and the current value of the system clock counter, that is, when the output FIFO generates a request signal, a TS needs to be sent at this time data packet, so when the output FIFO generates the request signal, it is the time when the next TS data packet is sent out. At this time, the current value of the system clock counter is the time label when the next TS data packet is output. The output time label of the j-th packet from which 1 TS packet is output.
步骤207:如果TS数据包中还有PCR,则根据输入时刻标签和输出时刻标签计算PCR的校正值,校正TS数据包中的PCR。计算方法如第5节g中所述。Step 207: If there is a PCR in the TS data packet, calculate the correction value of the PCR according to the input time tag and the output time tag, and correct the PCR in the TS data packet. The method of calculation is as described in Section 5g.
步骤208:TS数据包输出到输出FIFO中。经过MPU复用处理和PCR校正的TS数据包被发送到输出FIFO中,由输出时钟驱动,从输出FIFO产生复用后的MPEG-2TS码流。Step 208: The TS data packet is output to the output FIFO. The TS data packets processed by MPU multiplexing and PCR correction are sent to the output FIFO, driven by the output clock, and the multiplexed MPEG-2TS code stream is generated from the output FIFO.
本发明的方法在计算传送数据包的固定延迟和实际延迟时,都是由传送数据包驱动,传送数据包的输入时刻标签和输出时刻标签,都可以由硬件逻辑电路根据传送数据包实际输入和输出时刻进行精确锁定。这样误差主要来自本地复用系统的27MHZ时钟精度误差,以及本地时钟计数器由输入/输出信号触发锁定时的延迟误差。由于27MHZ时钟的精度可以通过采用高精度的晶振来实现,一般要求50ppm以上就可以。而对于触发锁定时的延迟误差最大为一个时钟周期,所以采用本发明的方法进行PCR的校正,引入的误差非常小。The method of the present invention is driven by the transmission data packet when calculating the fixed delay and the actual delay of the transmission data packet, and the input time label and the output time label of the transmission data packet can be input and output by the hardware logic circuit according to the actual input and output time of the transmission data packet. The output is precisely locked at all times. This error mainly comes from the 27MHZ clock precision error of the local multiplexing system, and the delay error when the local clock counter is locked by the input/output signal trigger. Since the precision of the 27MHZ clock can be achieved by using a high-precision crystal oscillator, it generally requires more than 50ppm. However, the maximum delay error when triggering locking is one clock cycle, so the method of the present invention is used to correct the PCR, and the introduced error is very small.
本发明实施例中的技术特征可以进一步组合、修改、替换,而并不脱离本发明的精神和范围,在此不在赘述。并且应理解的是,以上所述仅为本发明的较佳实施例而已,并不应用以限制本发明,凡在本发明的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本发明的权利要求范围之内。The technical features in the embodiments of the present invention can be further combined, modified, and replaced without departing from the spirit and scope of the present invention, so details are not repeated here. And it should be understood that the above descriptions are only preferred embodiments of the present invention, and should not be used to limit the present invention. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present invention, All should be included within the scope of the claims of the present invention.
Claims (10)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CNB001235729A CN1166174C (en) | 2000-08-22 | 2000-08-22 | Method for correcting timer reference of programs in multiplexing |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CNB001235729A CN1166174C (en) | 2000-08-22 | 2000-08-22 | Method for correcting timer reference of programs in multiplexing |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| CN1338862A CN1338862A (en) | 2002-03-06 |
| CN1166174C true CN1166174C (en) | 2004-09-08 |
Family
ID=4589969
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CNB001235729A Expired - Fee Related CN1166174C (en) | 2000-08-22 | 2000-08-22 | Method for correcting timer reference of programs in multiplexing |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN1166174C (en) |
Families Citing this family (7)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN1314269C (en) * | 2002-04-02 | 2007-05-02 | 中兴通讯股份有限公司 | Method and device for regulating program reference clock of motion image expert group 2 |
| US7899302B2 (en) * | 2002-12-16 | 2011-03-01 | Koninklijke Philips Electronics N.V. | System for modifying the time-base of a video signal |
| CN1997162B (en) * | 2006-12-25 | 2010-10-27 | 华为技术有限公司 | PCR calibration method and device |
| CN105306987B (en) * | 2015-10-23 | 2018-06-22 | 深圳国微技术有限公司 | A kind of device for controlling TS stream interface bit rate outputs |
| CN105681864B (en) * | 2015-12-31 | 2020-09-15 | 惠州市伟乐科技股份有限公司 | IP-based transport stream jitter removal method and device |
| CN106231359B (en) * | 2016-07-21 | 2019-04-02 | 四川九州电子科技股份有限公司 | Mpeg TS code stream sending method based on multi-data source dynamic multiplexing algorithm |
| CN113079395A (en) * | 2021-04-07 | 2021-07-06 | 四川航天神坤科技有限公司 | PCR correction algorithm and system for TS stream of DVB-S system |
-
2000
- 2000-08-22 CN CNB001235729A patent/CN1166174C/en not_active Expired - Fee Related
Also Published As
| Publication number | Publication date |
|---|---|
| CN1338862A (en) | 2002-03-06 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN1182722C (en) | Video signal compression apparatus | |
| CN1196320C (en) | Apparatus and method for synchronizing compressed video signal receiving systems | |
| US5703877A (en) | Acquisition and error recovery of audio data carried in a packetized data stream | |
| US20050259946A1 (en) | Video editing apparatus and video editing method | |
| CN1115055C (en) | Buffer management in variable Bit-rate compression systems | |
| US8351514B2 (en) | Method, protocol, and apparatus for transporting advanced video coding content | |
| TWI455573B (en) | Method for reconstructing system time clock (stc) without carrying pcr | |
| US20070140398A1 (en) | Data receiving device and data receiving method | |
| CN108243350B (en) | A method and device for synchronous processing of audio and video | |
| CN1669290A (en) | Jitter Compensation Method for Systems with Wall Clocks | |
| CN1135851C (en) | Synchronous picture circuit and method thereof | |
| CN102640511A (en) | Method and system for playing video information, and video information content | |
| CN101710997A (en) | MPEG-2 (Moving Picture Experts Group-2) system based method and system for realizing video and audio synchronization | |
| CN102547299A (en) | Audio and video synchronous control method based on moving picture experts group (MPEG)-2 | |
| JPH10174111A (en) | Encoder and decoder for high-definition television signal | |
| CN1166174C (en) | Method for correcting timer reference of programs in multiplexing | |
| US20070237187A1 (en) | Multiplexer and multiplexing method | |
| US6266384B1 (en) | Method and apparatus for time base recovery and processing | |
| CN103596043B (en) | Method for converting TS into PS in digital television | |
| CN1286314C (en) | Method and its device for keeping display synchronization in video frequency decoding system | |
| CN1288905C (en) | Data decoder and method of decoding data | |
| KR100211999B1 (en) | Pcr corrector of mpeg-2 transport stream remultiplexer | |
| JP2823806B2 (en) | Image decoding device | |
| CN111988641B (en) | Transport stream multiplexing audio and video time synchronization method | |
| JPH09270994A (en) | Stream control method |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| C10 | Entry into substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| C06 | Publication | ||
| PB01 | Publication | ||
| C14 | Grant of patent or utility model | ||
| GR01 | Patent grant | ||
| ASS | Succession or assignment of patent right |
Owner name: SHANGHAI HUAWEI TECHNOLOGIES CO., LTD. Free format text: FORMER OWNER: HUAWEI TECHNOLOGY CO LTD Effective date: 20100913 |
|
| C41 | Transfer of patent application or patent right or utility model | ||
| COR | Change of bibliographic data |
Free format text: CORRECT: ADDRESS; FROM: 518057 HUAWEI YONGFU BUILDING, KEFA ROAD, SHENZHEN SCIENCE PARK, GUANGDONG PROVINCE TO: 200121 NO.615, NINGQIAO ROAD, PUDONG NEW DISTRICT, SHANGHAI |
|
| TR01 | Transfer of patent right |
Effective date of registration: 20100913 Address after: 200121 No. 615 Nanjing Road, Shanghai, Pudong New Area Patentee after: Shanghai Huawei Technologies Co., Ltd. Address before: 518057 Guangdong city of Shenzhen province science and Technology Park of HUAWEI Road Service Building Patentee before: Huawei Technologies Co., Ltd. |
|
| C17 | Cessation of patent right | ||
| CF01 | Termination of patent right due to non-payment of annual fee |
Granted publication date: 20040908 Termination date: 20120822 |