The accompanying drawings, which are incorporated in and constitute a part of the specification, illustrate embodiments of the invention, and together with the general description given above and the detailed description of the embodiments given below, serve to explain the principles of the invention.
Now, an apparatus for receiving a TS (transport) packet stream according to the embodiment of the present invention will be described with reference to the accompanying drawings.
As shown in
The packet stream receiving apparatus has an input section (not shown) which receives a transport packet stream (hereinafter, referred to as TS stream) defined in MPEG-2 or the like, and the TS stream is transferred to the packet separation section 1.
Here, the TS stream is composed of a plurality of TS packets as shown in
The packet separation section 1 extracts the TS packet header (PES H) from the TS packet and separates the packetized elementary stream (PES) shown in
Next, the discontinuity detection section 2 detects the discontinuity of the packet based on the continuity index in the TS packet header thus extracted, and when the discontinuity is detected, discontinuity information is transmitted to the audio decoding section 3 together with the PES packet payload. In this example, the discontinuity detection section 2 determines whether the discontinuity occurs or not based on a counter (Continuity Counter), but is not limited thereto.
The audio decoding section 3 decodes the PES packet payload to generate a decoded audio frame (hereinafter, referred to as “decoded frame”). Then, when the decoded frame is inputted from the audio decoding section 3, the presentation time calculation section 5 calculates the presentation time by adding the frame time to the previous presentation time. Then, the storage buffer 4 stores the decoded frames after the audio decoding section 3 has received the discontinuity information responding to the discontinuity information from the discontinuity detection section 2. Hereinafter, the number of decoded frames stored in the storage buffer is referred to as “stored frame number”. The presentation time comparison section 6 determines whether or not any lost frame exists to detect random errors by comparing the presentation time calculated in the presentation time calculation section 5 with the PTS obtained via the audio decoding section 3 because no discontinuity occurs if the stored frame number existing in the storage buffer 4 is “0”.
On the other hand, since packet losses have been occurred if more than one stored frames exist in the storage buffer 4, the presentation time comparison section 6 sets the presentation time of the current frame in the PTS and sets the presentation time in the previous frames by calculating back from the current PTS.
In this manner, if any lost frame exists, the lost frame interpolation section 7 generates interpolation frames depending on the number of lost frames notified by the presentation time comparison section 6 to output the relevant interpolation frames to the presentation control section 8. Then, the presentation control section 8 outputs audio from the speakers 9 while appropriately interpolating the lost frames with interpolation frames transmitted from the lost frame interpolation section 7 based on the presentation time and the decoded frames transmitted from the presentation time calculation section 5.
In contrast thereto, in the packet stream receiving apparatus according to the present embodiment, as shown in
In addition, the errors occurred in a zone where no discontinuity information exists are presumed to be random errors. Thus, as shown in
As a result of the above processing, the audio output shown in
Now, a series of processes performed by the packet separation section 1 in the packet stream receiving apparatus according to one embodiment of the present invention will be described further in detail with reference to the flowchart of
The packet separation section 1 reads a TS packet (Step S1) and judges whether or not any discontinuity occurs based on a counter (Continuity Counter) as a continuity index contained in the TS packet header of the relevant TS packet (Step S2). When determined that no discontinuity occurs, the procedure proceeds to Step 4. On the other hand, when determined in Step 2 that some discontinuity has occurred, discontinuity information (in this example, flag information DisconFlag) is transferred to the audio decoding section 3 and the procedure proceeds to Step S4 (Step 3).
Subsequently, the packet separation section 1 determines whether or not a PTS is contained in the PES packet header of the PES packet multiplexed on the TS packet (Step S4). When the relevant PTS is not contained, the procedure proceeds to Step S6. On the other hand, when the relevant PTS is contained in Step S4, the PTS is transferred to the audio decoding section 3 and the procedure proceeds to Step S6 (Step S5). In this manner, the packet separation section 1 transfers the encoded audio frames Frame #1, #2 . . . of the PES packet payload of the TS packet to the audio decoding section 3 (Step S6), returns to Step 1 and repeats the processing for each TS packet of the TS packet stream.
Now, a series of processes performed by the audio decoding section 3 in the packet stream receiving apparatus according to one embodiment of the present invention will be described further in detail with reference to the flowchart of
When receiving discontinuity information (in this example, flag information DisconFlag), the audio decoding section 3 stores the relevant discontinuity information. In this example, the flag information DisconFlag is stored in storeBufFlag (Step S11), and only one frame of the encoded audio frames is decoded (Step S12). Subsequently, it is determined whether or not the presentation time (PTS) has been obtained (Step S13).
When it is determined in Step S13 that the PTS has not been obtained, it is determined whether or not the discontinuity information is stored (Step S14). In this example, the authenticity of DisconFlag stored in storeBufFlag is determined. When no discontinuity information is stored in Step S14, the frame time length (frameTime) is added to the presentation time previous to the discontinuity (prev.PTS) so that the current presentation time (curPTS) is calculated (Step S15), and the procedure proceeds to Step S25. On the other hand, when discontinuity information is stored in Step S14, decoded frames are stored in the storage buffer 4 (Step S16), and the count concerning the stored frame number is incremented (numStoreFrame++) (Step S17) and the procedure proceeds to Step S25.
On the other hand, when it is determined in Step S13 that the presentation time (PTS) has been obtained, it is then determined whether or not the discontinuity information is stored (Step S18). Similarly as in the above case, the authenticity of DisconFlag stored in storeBufFlag is determined.
When no discontinuity information is stored in Step S18, the presentation time of the current decoded frame is calculated (Step S19). This current presentation time (curPTS) is obtained by adding the frame time length (frameTime) to the presentation time previous to the discontinuity (prev.PTS) (Step S15).
Then, it is determined whether or not the presentation time (PTS) obtained in Step 13 is equal to the current presentation time (curPTS) calculated in Step 19 (Step S20). When both presentation times are determined to be equal to each other, various variables are initialized. In this example, the stored frame number storeframe of the storage buffer 4 is set to 0, and storeBufFlag concerning the discontinuity information is set to FALSE (Step S24) and the procedure proceeds to Step 25. On the other hand, when both presentation times are determined not to be equal to each other, it is assumed that random errors have occurred, the number of lost frames between the current frame and previous frame is calculated ((PTS-prev.PTS)/frameTime) (Step S21), frames as many as the lost frames are interpolated in the lost frame interpolation section 7 (Step S22), and various variables are initialized. In this example, the stored frame number storeframe is set to 0, and storeBufFlag concerning the discontinuity information is set to FALSE (Step S24). On the other hand, it is judged in Step S18 that the discontinuity information is stored, a subroutine “Stored frame processing” described later in detail is executed (Step S23), and various variables are initialized. In this example, the stored frame number storeframe of the storage buffer is set to 0, and storeBufFlag concerning the discontinuity information is set to FALSE (Step S24).
In this manner, the presentation time of the closest previous frame is stored in Step S25. In this example, Prev.PTS=curPTS (Step S25) is set, the presentation control is performed by the presentation control section 8 (Step S26), and a series of processings is ended.
Now, the stored frame processing according to the subroutine executed in Step S23 of
When entering the stored frame processing, the number of lost frames (numLostFrame) at the discontinuity point is calculated first (Step S31). Since the number of the frames from the current time to the discontinuity occurrence time is obtained by dividing a time period (=current presentation time (PTS) - presentation time previous to discontinuity (prev.PTS)) by the frame time length (frameTime), the number of frames from the current time to the discontinuity occurrence time can be obtained by subtracting the number of frames stored in the storage buffer 4 from the number of frames from the current time to the discontinuity occurrence time.
For example, in the example of
Presentation time before discontinuity:
Current presentation time:
Number of frames in storage buffer:
Number of lost frames at discontinuity point:
Then, the lost frame interpolation section 7 interpolates lost frames (Steps S32 to S35). That is, the current presentation time (curPTS) is calculated from the sum of the presentation time previous to discontinuity (prev.PTS) and the frame time length (frameTime) (Step S32), the lost frames are interpolated (Step S33), and the number of lost frames at the discontinuity point is decremented by one (Step S34). The above processes are repeated until numLostFrame becomes equal to 0 (Step S35). Through the processes described above all lost frames are interpolated.
Next, time information is added to the stored frames stored in the storage buffer 4 (Steps S36 to S38). That is, the current presentation time (curPTS) is calculated from the sum of the presentation time previous to discontinuity (prev.PTS) and the frame time length (frameTime) (Step S32). Until the value of the relevant counter becomes equal to the number of stored frames, the addition of the time information to the stored frames is repeated (Steps S37 and S38). After the above processes, the current decoded frame (curPTS=PTS) is identified (Step S39), and the procedure is returned to the processes after Step S23 of
In addition, for the timing for resetting the frames stored in the storage buffer 4, various methods can be employed such as a control method using time information and a control method using data amount.
As described above, according to the embodiment of the present invention, there is provided a packet stream receiving apparatus capable of outputting audio without generating a timing mismatch by inserting discontinuity information at the timing when the discontinuity occurs to accurately comprehend the number of lost frames from the relevant discontinuity information, and PTS interval and so forth.
According to the present invention, there can be provided a packet stream receiving apparatus having an audio error compensation function that enables outputs without generating a timing mismatch by accurately comprehending the number of lost frames caused by packet losses.
Additional advantages and modifications will readily occur to those skilled in the art. Therefore, the invention in its broader aspects is not limited to the specific details and representative embodiments shown and described herein. Accordingly, various modifications may be made without departing from the spirit or scope of the general inventive concept as defined by the appended claims and their equivalents.
Number | Date | Country | Kind |
---|---|---|---|
2006-188577 | Jul 2006 | JP | national |