The present invention relates to stream conversion between different formats, and more particularly, to methods and apparatus for transforming a first transport stream of a first format into a second transport stream of a second format by emulating arrival time stamp information.
As Blu-ray Discs (BDs) have become practical for video data recording, the need for recording transport streams derived from various sources (e.g. broadcasting tuner, network streaming, or a storage device such as a flash memory) to a BD has arisen accordingly. As a result, transforming a transport stream complying with conventional specifications such as ISO/IEC 13818-1 specifications into a Blu-ray Disc Audio Visual Moving Picture Experts Group phase 2 (BDAV MPEG-2) transport stream has become an essential issue.
arrival_time_stamp(k)=arrival_time_clock(k) % 230;
where k represents the first byte of transport packets. The aforementioned arrival time clock counter is a counter that counts the pulses of a specific frequency. Please refer to BD specifications for more information.
As a conventional transport stream such as a transport stream complying with ISO/IEC 13818-1 specifications lacks the header TP_extra_header shown in
Please refer to
As shown in
Therefore, the conventional method shown in
It is therefore an objective of the claimed invention to provide methods and apparatus for transforming a first transport stream of a first format into a second transport stream of a second format to solve the above-mentioned problem.
An exemplary embodiment of a method for transforming a first transport stream of a first format into a second transport stream of a second format comprises deriving at least one program clock reference (PCR) value from the first transport stream and calculating an arrival time stamp value according to the PCR value, and further comprises generating a header that carries at least the arrival time stamp value and outputting the second transport stream. In addition, the second transport stream comprises the header and a second packet corresponding to a first packet of the first transport stream.
An exemplary embodiment of an apparatus for transforming a first transport stream of a first format into a second transport stream of a second format comprises a processing circuit and an output stage that is coupled to the processing circuit. The processing circuit is utilized for deriving at least one PCR value from the first transport stream, calculating an arrival time stamp value according to the PCR value, and generating a header carrying at least the arrival time stamp value. In addition, the output stage is utilized for outputting the second transport stream. Additionally, the second transport stream comprises the header and a second packet corresponding to a first packet of the first transport stream.
These and other objectives of the present invention will no doubt become obvious to those of ordinary skill in the art after reading the following detailed description of the preferred embodiment that is illustrated in the various figures and drawings.
Certain terms are used throughout the following description and claims, which refer to particular components. As one skilled in the art will appreciate, electronic equipment manufacturers may refer to a component by different names. This document does not intend to distinguish between components that differ in name but not in function. In the following description and in the claims, the terms “include” and “comprise” are used in an open-ended fashion, and thus should be interpreted to mean “include, but not limited to . . . ”. Also, the term “couple” is intended to mean either an indirect or direct electrical connection. Accordingly, if one device is coupled to another device, that connection may be through a direct electrical connection, or through an indirect electrical connection via other devices and connections.
Please refer to
According to the first embodiment, the first transport stream S1 complies with ISO/IEC 13818-1 specifications, and the second transport stream S2 complies with Blu-ray Disc (BD) specifications. In this embodiment, the first transport stream S1 is a conventional transport stream such as a Moving Picture Experts Group phase 2 (MPEG-2) transport stream complying with the MPEG-2 Transport Stream syntax shown in
Please note that a PCR field illustrated in the lower left portion of
As shown in
Regarding the processing circuit 110, in Step 912, the extractor 112 derives at least one PCR value from the first transport stream S1. In addition, in Step 914, the header generator 114 of this embodiment calculates an arrival time stamp value such as the aforementioned arrival time stamp value arrival_time_stamp according to the PCR value, where the arrival time stamp value arrival_time_stamp may be calculated according to at least one PCR value derived from one or more packets of the first transport stream S1. Additionally, in Step 916, the header generator 114 of this embodiment further generates a header such as the aforementioned header TP_extra_header, where the header TP_extra_header carries the copy permission information mentioned above and the arrival time stamp value arrival_time_stamp.
In Step 918, the output stage 120 outputs the second transport stream S2, where the second transport stream S2 comprises the header TP_extra_header and a second packet corresponding to a first packet of the first transport stream S1. More specifically, when the first packet (i.e. a transport packet in this embodiment) is input into the TS buffer 108, the TS buffer 108 buffers the first packet for being later output as the second packet. Thus, the second packet carries the same video content as the first packet. Regarding the output stage 120, the multiplexer 122 multiplexes the header TP_extra_header received from the processing circuit 110 and then multiplexes the second packet, so as to generate a combined packet comprising the header TP_extra_header and the second packet as a source packet of the second transport stream S2 of this embodiment.
Some details of the aforementioned PCR value are described herein for reference. The PCR value represent a value encoded in a PCR field that indicates the time t(i), where i is an index of the byte containing the last bit of a program_clock_reference_base field. The PCR value is defined according to the following equation:
PCR(i)=PCR_base(i)×300+PCR_ext(i);
where:
PCR_base(i)=((system_clock_frequency×t(i)) DIV 300)% 233; and
PCR_ext(i)=((system_clock_frequency×t(i)) DIV 1)% 300.
The PCR field carrying the PCR value is encoded in two parts: a first part carrying the program clock reference base PCR_base, in units of the period of 1/300 times the system clock frequency, called program_clock_reference_base; and a second part carrying the program clock reference extension PCR_ext, in units of the system clock frequency, called program_clock_reference_extension.
In general, the PCR value only exists in a portion of transport packets of a transport packet stream as defined in
More particularly, the processing circuit 110 calculates the arrival time stamp value arrival_time_stamp not only according to the two PCR values, but also according to a current packet number and two packet numbers of two packets that respectively carry the two PCR values. The processing circuit 110 calculates the arrival time stamp value arrival_time_stamp according to the following equation:
ATS=(PCRb+(PCRa−PCRb)×(PNc−PNb)/(PNa−PNb))% 230;
where ATS represents the arrival time stamp value arrival_time_stamp, PNc represents the current packet number, PCRa and PCRb represent the two PCR values, and PNa and PNb represent the two packet numbers of the two packets that respectively carry the two PCR values PCRa and PCRb.
According to this embodiment, one of the packet numbers PNa and PNb is greater than the current packet number PNc, and the other of the packet numbers PNa and PNb is less than the current packet number PNc. For example, within the first transport stream S1 input into the TS buffer 108, the current packet having the current packet number PNc comes after the packet that carries the PCR value PCRb, and the packet that carries the PCR value PCRa comes after the current packet having the current packet number PNc, where the subscript ‘b’ of notations such as PCRb and PNb stands for “before”, and the subscript ‘a’ of notations such as PCRa and PNa stands for “after”
Taking a situation shown in
According to a variation of this embodiment, both the packet numbers PNa and PNb are greater than the current packet number PNc. In addition, according to another variation of this embodiment, both the packet numbers PNa and PNb are less than the current packet number PNc. Similar descriptions for these variations are not detailed here.
It should be noted that, according to another variation of this embodiment, the packets of the first transport stream S1 can be varied (e.g. re-encoded for correction or trans-coded for type transformation) while being converted into the packets of the second transport stream S2. For example, while being converted into the packets of the second transport stream S2, the packets of the first transport stream S1 can be re-encoded for correction, or trans-coded for type transformation. Similar descriptions for this variation are not detailed here.
The aforementioned processing circuit 110 is replaced with another processing circuit 210 comprising an extractor 212, a processor 214, and a header generator 216, with the extractor 212 performing the same function as the extractor 112 mentioned above in Step 912. However, in Step 914, it is the processor 214 that calculates an arrival time stamp value such as the aforementioned arrival time stamp value arrival_time_stamp according to the PCR value, where the header generator 216 of this embodiment generates a header such as the aforementioned header TP_extra_header carrying the copy permission information mentioned above and the arrival time stamp value arrival_time_stamp in Step 916. Similar descriptions for the second embodiment are not detailed here.
According to a variation of this embodiment, the processor 214 is a micro processing unit (MPU) that is capable of controlling the whole apparatus 200, where the processing circuit 210 represents a logically defined block. Similar descriptions for this variation are not detailed here.
In contrast to the related art, the present invention methods and apparatus emulate arrival time stamp information (e.g. the arrival time stamp value arrival_time_stamp) rather than inserting arrival time stamps that are derived according to a system clock counter. As a result, when the conventional transport stream is a transport stream derived from a storage media rather than from broadcasting, the present invention methods and apparatus still work well without introducing the related art problems.
It is an advantage of the claimed invention that the present invention methods and apparatus emulate the arrival time stamp information according to program clock reference information such as the abovementioned PCR value of the original transport stream, so the transport stream conversion can be properly performed for various types of transport streams, even for transport streams comprising packets with unknown incoming times.
Those skilled in the art will readily observe that numerous modifications and alterations of the device and method may be made while retaining the teachings of the invention.