Japanese
PROGRAMMER'S GUIDECD communication I/F (MPEG part)
BackForward
CD communication I/F (MPEG part)

5. MPEG stream


5.1 Transfer block

5.1.1 Function of transfer block
The transfer block of the MPEG decoder has the following functions.

(1) Stream settings
Set the stream to be decoded by specifying the buffer section to which the decoder is connected.
In order to set a more detailed stream to be decoded, the stream number and channel number can be specified. (This function is called "rear aperture.")

(2) Registering the stream to be played next
Specify the buffer section and register the stream to be played next. When the current stream ends, it switches to the next registered stream. At this time, you can set the conditions for switching.
The switching timing may be as follows.

Figure 5.1 Registering the stream to play next

  1. When a system end code (SEC) is detected
  2. When EOR bit is detected
  3. When the forced switching function is called

(3) Stream data transfer
It monitors the designated buffer section and, when the required amount of data is stored, transfers the stream data to the decoder.

(4) Forced video switching
Forcibly switch to the next registered stream.

5.1.2 Transfer block state transition
A transfer block has the following states: This state is called the operating state of the MPEG decoder. (For details, refer to the data specification "MPEG operation status".)

Table 5.1 Transfer block status
situation explanation Transition condition Transition destination
 1
Stop Stream is not registered. Registration of current stream Preparation 1
 2
Preparation 1 Waiting for 2 sectors to be stored in the specified buffer section. Get decode buffer size Preparation 2
Cancel current stream Stop
 3
Preparation 2 Waiting for data equal to the decode buffer size to be stored in the buffer section. Stores decode buffer size transfer
Forced transfer instruction transfer
Cancel current stream Stop
 4
transfer
(reproduction)
Transferring sector data to decoder. (MPEG playback status) buffer compartment becomes empty Resurrection process
natural switching switching
Forced switch switching
natural end Stop
forced termination Stop
 5
switching Waiting for the beginning of the next stream to be output. The beginning was output transfer
buffer compartment becomes empty Resurrection process
 6
Resurrection process Waiting for a sector to be stored in an empty buffer partition. Necessary sectors are stored Transfer/switch *
* The transition destination from the resurrection process returns to the state before the buffer section became empty (starting the resurrection process).

Figure 5.2 shows the state transition diagram of the transfer block.

Figure 5.2 Transfer block state transition diagram

Executing the MPEG decoder initialization function (CDC_MpInit) returns the system to the stopped state from any state.

5.2 Switching streams

Switching streams means switching the currently playing stream to another stream. By registering the storage destination buffer section of the stream to be played next, the next stream is switched and played at the end of the current stream or by a forced switching function.

5.2.1 Picture input order and display order
In order to decode a B picture, an I picture or a P picture, which is a predicted picture, must be decoded first. Therefore, the input order of pictures to the decoder and the actual display order are swapped.

Figure 5.3 Input order and display order to decoder

5.2.2 Clearing the video decode buffer
In order to switch streams smoothly, it is necessary to avoid outputting previously decoded data after a switching instruction is issued. To do this, the decode buffer must be cleared in a timely manner.
The MPEG/Video decoder has a VBV buffer in front of the decoder and an MPEG frame buffer in the back. The following two methods can be specified as the clearing method (timing and target buffer).

(1) Immediately clear VBV buffer + MPEG frame buffer (VBV + WBC)
In this case, since the picture waiting to be displayed in the MPEG frame buffer is cleared, the instruction is immediately reflected in the display. The displayed picture is not cleared. Therefore, the current picture is actually displayed until the first few pictures of the next stream are completely decoded.
The MPEG frame buffer waiting to be displayed (decoded) is abbreviated as WBC (Write Buffer Control).

(2) Wait for the next I or P picture to start decoding and clear only the VBV buffer
In this case, the picture waiting to be displayed in the MPEG frame buffer is not cleared. After the picture waiting to be displayed is displayed, the picture of the next stream is displayed. Therefore, after the switching instruction, there is a delay corresponding to the picture waiting to be displayed.

Figure 5.4 MPEG video buffer structure

5.2.3 Video stream switching example
Due to the nature of the MPEG video stream, clearing the VBV buffer when the picture start of a P picture is detected results in a very clean connection.
If the switch is simply made when a picture start is detected, the response will be somewhat improved, but the switch may be made at the start of a B picture, and there is a possibility that a frame will be skipped.

As an example, a case where P picture and B picture are switched at the time of picture start detection will be compared. Only the VBV buffer is to be cleared.

(1) When switching by P picture start detection
As shown in the following diagram, if you switch the stream when the picture start of P picture (P10) is detected, the stream will switch smoothly from B5 → B6 → P7 → i1. (P10 is not decoded.)

Figure 5.5 Example of switching based on P picture start detection

(2) When switching by B picture start detection
If the stream is switched when the picture start of a B picture (B6) is detected in the same stream, as shown in the following figure, B6, which is displayed earlier than P7, is not decoded, resulting in frame skipping from B5 to P7.

Figure 5.6 Example of switching based on B picture start detection

5.2.4 Clearing the audio decode buffer
The MPEG/Audio decoder has a one sector buffer in front of the decoder. The following two methods can be specified as clearing methods.

(1) Not cleared
Switching does not occur until one sector worth of data is transferred.

(2) Clear
To immediately clear the buffer and switch even in the middle of one sector.

Figure 5.7 MPEG audio buffer structure


BackForward
PROGRAMMER'S GUIDECD communication I/F (MPEG part)
Copyright SEGA ENTERPRISES, LTD., 1997