PROGRAMMER'S GUIDEMPEG library
BackForward
MPEG Library / 12. Function Details-2

12.2 Video playback



 List
 Title

Function specifications

 Function

Generate MPEG video handle

 Function Name

MPG_MvCreate

 No

2.1

Form
MpgMv MPG_MvCreate (StmHn vstm, StmHn astm)
input
 vstm
 : Video stream handle
 astm
 : Audio stream handle
output
none
Function value
MPEG video handle
function
Generates an MPEG video handle for playing MPEG streams. Specifies the stream handle for video data and the stream handle for audio data.
You can also specify NULL for either to play the audio and video independently.
If both are specified at the same time, they will be played back in synchronization.
Returns NULL if the generation of the MPEG video handle fails.
The following values are set as the default values.
 item
 Set value
 Exit conditions
 System end code
 Image output destination
 VDP2 direct output
 Decode timing
 VSYNC signal
 Channel selection
 do not
 Stream ID
 ignore
 Stream layer
 System layer 

 List
 Title

Function specifications

 Function

Erase MPEG video handle

 Function Name

MPG_MvDestroy

 No

2.2

Form
Sint32 MPG_MvDestroy (MpgMv mpgmv)
input
mpgmv: MPEG video handle
output
none
Function value
Error code
function
Erases the MPEG video handle.
[remarks]
(a) The handle must be stopped for both audio and video.
(b) The handle is not registered as the handle to be played next by the MPG_MvEntryNext function.
(c) In this function, the playback stop function is executed.

 List
 Title

Function specifications

 Function

Setting the end condition of the video

 Function Name

MPG_MvSetTermCond

 No

2.3

Form
void MPG_MvSetTermCond (MpgMv mpgmv, Sint32 vcnd, Sint32 acnd)
input
 mpgmv
 : MPEG video handle
 vcnd
 : MPEG video stream termination condition
 acnd
 : MPEG audio stream termination condition
output
none
Function value
none
function
Set the transfer end condition for each stream. You can OR the following values.
(1) MPEG stream termination conditions (common to video / audio)
・ MPG_TCND_EOR
 : When transferring a sector with an EOR bit set
・ MPG_TCND_SEC
 : When system end code appears in the stream
・ MPG_TCND_NONE
 : Do not set the end condition 

 List
 Title

Function specifications

 Function

Video output destination settings

 Function Name

MPG_MvSetVideoDest

 No

2.4

Form
void MPG_MvSetVideoDest (MpgMv mpgmv, Sint32 dst)
input
 mpgmv
 : MPEG video handle
 dst
 :Output destination
output
none
Function value
none
function
Set the output destination of the video.
(1) Output destination
・ MPG_OUTDST_DRCT
 : VDP2 direct output
・ MPG_OUTDST_HOST
 : Host transfer output
remarks
(a) The setting of this function is valid by calling the MPG_MvStart function.

 List
 Title

Function specifications

 Function

Decoding timing setting

 Function Name

MPG_MvSetDecTim

 No

2.5

Form
void MPG_MvSetDecTim (MpgMv mpgmv, Sint32 tmg)
input
 mpgmv
 : MPEG video handle
 tmg
 : Decoding timing
output
none
Function value
none
function
Set the decoding timing of MPEG video.
(1) Decoding timing
・ MPG_DECTMG_VSYNC
 : VSYNC signal decodes one picture twice
・ MPG_DECTMG_HOST
 : Decode by calling the MPG_MvDecNext function
remarks
(a) The setting of this function is valid by calling the MPG_MvStart function.

 List
 Title

Function specifications

 Function

Video channel settings

 Function Name

MPG_MvSetVideoChan

 No

2.6

Form
void MPG_MvSetVideoChan (MpgMv mpgmv, Sint32 vch)
input
 mpgmv
 : MPEG video handle
 vch
 : Channel number (MPG_IGNORE: not specified)
output
none
Function value
none
function
Specifies the video channel to play. The default is unspecified.
The channel switches immediately when this function is called. Data whose channel numbers do not match will be erased sequentially from the CD buffer.
remarks
(a) This function works for streams in the video layer. Not available for system layer streams.

 List
 Title

Function specifications

 Function

Audio channel settings

 Function Name

MPG_MvSetAudioChan

 No

2.7 2.7

Form
void MPG_MvSetAudioChan (MpgMv mpgmv, Sint32 ach)
input
 mpgmv
 : MPEG video handle
 ach
 : Channel number (MPG_IGNORE: not specified)
output
none
Function value
none
function
Specifies the audio channel to play. The default is unspecified.
The channel switches immediately when this function is called. Data whose channel numbers do not match will be erased sequentially from the CD buffer.
remarks
(a) This function works for streams in the video layer. Not available for system layer streams.

 List
 Title

Function specifications

 Function

Video stream ID setting

 Function Name

MPG_MvSetVideoId

 No

2.8

Form
void MPG_MvSetVideoId (MpgMv mpgmv, Sint32 vid)
input
 mpgmv
 : MPEG video handle
 vid: Video stream number (MPG_IGNORE)
 : Not specified)
output
none
Function value
none
function
Specify the stream number of the video to be played. The default is unspecified.
Data whose stream numbers do not match will be erased sequentially from the CD buffer.
remarks
(a) Audio / video synchronization If this function is executed during playback, video and audio synchronization is not guaranteed.

 List
 Title

Function specifications

 Function

Audio stream ID setting

 Function Name

MPG_MvSetAudioId

 No

2.9

Form
void MPG_MvSetAudioId (MpgMv mpgmv, Sint32 ai / d)
input
 mpgmv
 : MPEG video handle
 aid
 : Audio stream number (MPG_IGNORE: unspecified)
output
none
Function value
none
function
Specify the stream number of the audio to be played. The default is unspecified.
Data whose stream numbers do not match will be erased sequentially from the CD buffer.

 List
 Title

Function specifications

 Function

Start video playback

 Function Name

MPG_MvStart

 No

2.10

Form
Sint32 MPG_MvStart (MpgMv mpgmv, Bool picsch)
input
 mpgmv
 : MPEG video handle
 picsch
 : Picture search flag
output
none
Function value
Error code
function
The video will start playing. If picsch is ON, perform a picture search before starting playback. If it is OFF, the picture search will not be executed.
remarks
(a) If this function is called while playing another stream, MPG_ERR_PLAYING is returned.
(b) If the MPEG decoder connection fails, MPG_ERR_MCON is returned.
(c) Picture search is a function that searches the sequence header in the MPEG stream and starts playback from the found position.

 List
 Title

Function specifications

 Function

Stop video playback

 Function Name

MPG_MvStop

 No

2.11

Form
void MPG_MvStop (MpgMv mpgmv)
input
mpgmv: MPEG video handle
output
none
Function value
Error code
function
Stops playing the video. During audio / video sync playback, stop audio playback and then stop video playback.
remarks
(a) If this function is called during the restoration process, the MPEG decoder will be initialized and MPG_ERR_RCV will be returned.
(b) If this function is called during stream switching processing, MPG_ERR_CHG is returned without stopping processing.

 List
 Title

Function specifications

 Function

Stop video playback

 Function Name

MPG_MvStopVideo

 No

2.12

Form
Sint32 MPG_MvStopVideo (MpgMv mpgmv)
input
mpgmv: MPEG video handle
output
none
Function value
none
function
Stops playing the video.
remarks
(a) If this function is called during the restoration process, MPEG will be reset and MPG_ERR_RCV will be returned. (b) If this function is called during stream switching processing, MPG_ERR_CHG is returned without stopping processing.

 List
 Title

Function specifications

 Function

Stop audio playback

 Function Name

MPG_MvStopAudio

 No

2.13

Form
Sint32 MPG_MvStopAudio (MpgMv mpgmv)
input
mpgmv: MPEG video handle
output
none
Function value
none
function
Stops playing the audio.
remarks
(a) If this function is called during the restoration process, MPEG will be reset and MPG_ERR_RCV will be returned.
(b) If this function is called during stream switching processing, MPG_ERR_CHG is returned without stopping processing.

 List
 Title

Function specifications

 Function

Pause / frame advance / slow play

 Function Name

MPG_MvPause

 No

2.14

Form
void MPG_MvPause (MpgMv mpgmv, Sint32 cmd, Sint32 itvl)
input
 mpgmv
 : MPEG video handle
 cmd
 : Operation specification
 itvl
 : Slow playback speed
output
none
Function value
none
function
Pause / frame advance / slow play. If MPG_PAUSE_ON is specified in the paused state, frame advance will be performed. In slow playback, frames advance at a rate of itvl / 30 times per second.
(1) Operation specification
・ MPG_PAUSE_ON
 : Pause (normal playback)
・ MPG_PAUSE_ON
 : Frame advance (paused)
・ MPG_PAUSE_OFF
 : Normal playback
・ MPG_PAUSE_SLOW
 : Slow play
remarks
(a) When playing audio / video synchronously, leave an interval of about 25VSYNC between canceling the pause and pausing again. Otherwise the audio and video will be out of sync.

 List
 Title

Function specifications

 Function

Freeze / Strobe playback

 Function Name

MPG_MvFreeze

 No

2.15

Form
void MPG_MvFreeze (MpgMv mpgmv, Sint32 cmd, Sint32 itvl)
input
 mpgmv
 : MPEG video handle
 cmd
 : Operation specification
 itvl
 : Strobe interval
output
none
Function value
none
function
Freeze / strobe playback. If MPG_FREEZE_ON is specified in the frozen state, it will be frozen again. Strobe playback is re-frozen at a rate of itvl / 30 times per second.
(1) Operation specification
・ MPG_FREEZE_ON
 : Freeze execution
・ MPG_FREEZE_OFF
 : Normal playback
・ MPG_FREEZE_STRB
 : Strobe playback 

 List
 Title

Function specifications

 Function

Audio left and right channel settings

 Function Name

MPG_MvSetPan

 No

2.16

Form
void MPG_MvSetPan (MpgMv mpgmv, Bool lsw, Bool rsw)
input
 mpgmv
 : MPEG video handle
 lsw
 : Left channel ON / OFF (default ON)
 rsw
 : Right channel ON / OFF (default ON)
output
none
Function value
none
function
Set the MPEG audio output ON / OFF.

 List
 Title

Function specifications

 Function

Get video operating status

 Function Name

MPG_MvGetVideoStat

 No

2.17

Form
Sint32 MPG_MvGetVideoStat (MpgMv mpgmv)
input
mpgmv: MPEG video handle
output
none
Function value
Current video operating status
function
Gets the current operating status as shown below.
(1) Current video operating status
・ MPG_VSTAT_STOP
 : Stopped
・ MPG_VSTAT_PREP
 :in preparation
・ MPG_VSTAT_PLAY
 : Playing
・ MPG_VSTAT_ERR
 :error 

 List
 Title

Function specifications

 Function

Acquiring the operating status of audio

 Function Name

MPG_MvGetAudioStat

 No

2.18

Form
Sint32 MPG_MvGetAudioStat (MpgMv mpgmv)
input
mpgmv: MPEG video handle
output
none
Function value
Current audio operating status
function
Gets the current operating status as shown below.
(1) Current audio operating status
・ MPG_ASTAT_STOP
 : Stopped
・ MPG_ASTAT_PREP
 :in preparation
・ MPG_ASTAT_PLAY
 : Playing
・ MPG_ASTAT_ERR
 :error 

 List
 Title

Function specifications

 Function

Get video timecode

 Function Name

MPG_MvGetTimeCode

 No

2.19

Form
void MPG_MvGetTimeCode (MpgMv mpgmv, Sint32 * hh, Sint32 * mm, Sint32 * ss, Sint32 * pp)
input
mpgmv: MPEG video handle
output
 hh
 : Timecode time (0-23)
 mm
 : Timecode minutes (0-59)
 ss
 : Timecode seconds (0-59)
 pp
 : Timecode picture (0-29)
Function value
none
function
Gets the timecode in the video stream. Outputs 0 when the video stream is not playing.
remarks
(a) The video stream must be encoded in NTSC drop frames.
(b) Pictures are sometimes called frames.

 List
 Title

Function specifications

 Function

Get audio playback time

 Function Name

MPG_MvGetPlaytime

 No

2.20

Form
Sint32 MPG_MvGetPlaytime (MpgMv mpgmv)
input
mpgmv: MPEG video handle
output
none
Function value
Audio playback time to date (in msec)
function
Returns the audio playback time to date in msec.
remarks
(a) If the MPEG video handle is for video-only playback, it always returns 0.

 List
 Title

Function specifications

 Function

Video MPEG window connection

 Function Name

MPG_MvConnectWin

 No

2.21

Form
void MPG_MvConnectWin (MpgMv mpgmv, MpgWn mpgwn)
input
 mpgmv
 : MPEG video handle
 mpgwn
 : MPEG window
output
none
Function value
none
function
Connect the MPEG video handle to the MPEG window. The decoded video is displayed through this MPEG window.
remarks
(a) Do nothing when the playback mode of the MPEG video handle is audio only.

 List
 Title

Function specifications

 Function

Detaching the video MPEG window

 Function Name

MPG_MvDisconnectWin

 No

2.22

Form
void MPG_MvDisconnectWin (MpgMv mpgmv, MpgWn mpgwn)
input
 mpgmv
 : MPEG video handle
 mpgwn
 : MPEG window
output
none
Function value
none
function
Disconnects the MPEG video handle from the MPEG window.

 List
 Title

Function specifications

 Function

Perform video decoding

 Function Name

MPG_MvDecNext

 No

2.23

Form
Sint32 MPG_MvDecNext (MpgMv mpgmv)
input
mpgmv: MPEG video handle
output
none
Function value
Error code
function
Decodes the next picture. The decode timing must be MPG_DECTMG_HOST.
【caution】
Only when decoding the first picture, make sure you are ready to decode using the MPG_IsDecReady function before executing this function.
After that, be sure to execute this function at intervals of 1 frame worth of decoding time (2VSYNC) or more. Normally, it is necessary to take synchronization timing using VSYNC, audio playback volume, and so on.
For details, see P.57 "Sending Decode Synchronous Signals" in the CDC Manual (MPEG Part).
See (CDC_MpOutDsync function).

 List
 Title

Function specifications

 Function

Video output

 Function Name

MPG_MvOutput

 No

2.24

Form
Sint32 MPG_MvOutput (MpgMv mpgmv, Bool chkupic)
input
 mpgmv
 : MPEG video handle
 chkupic
 : Picture update check switch (ON / OFF)
output
none
Function value
Error code
function
By calling this function for each VSYNC, the video is transferred to the host and output. When this function is called, the image data is transferred to the buffer area of the host transfer window connected to the MPEG video handle.
(Execute the MPG_WnTrans function for each MPEG window)
When the picture update check switch is ON, the video is output only when a picture update occurs. When it is OFF, this check is not performed.
remarks
(a) mpgmv must be in host output mode and the video operating state must be playing. If this is not the case, the video output will fail. (b) If the decoding timing is MPG_DECTMG_HOST, picture update cannot be detected, so turn off the picture update check switch.

 List
 Title

Function specifications

 Function

Registration of MPEG handle to play next

 Function Name

MPG_MvEntryNext

 No

2.25

Form
Sint32 MPG_MvEntryNext (MpgMv mpgmv, MpgMv nextmv)
input
mpgmv: MPEG video handle nextmv: MPEG video handle to play next
output
none
Function value
Error code
function
Registers the MPEG video handle that will be played next when the stream switches.
Even when forced switching is performed by the MPG_MvChange function, the stream registered by this function is played next. When the stream is switched, the MPEG handle that was being played will be stopped, and the registered MPEG handle will be playing.
remarks
(a) Do not register MPEG video handles with different video output destinations or decoding timings. For example, do not register an MPEG video handle for VDP2 direct output next to an MPEG video handle for host transfer output.
(b) Do not register MPEG video handles with different streams to play. For example, do not register a video hand for playing video only next to the video handle for audio / video sync playback.
(c) The following items are not set when switching videos. The settings before switching are applied even after switching.
-Video channel and audio channel-Video stream ID and audio stream ID
・ Slow playback speed ・ Strobe interval ・ Left and right audio channels 

 List
 Title

Function specifications

 Function

Forced stream switching

 Function Name

MPG_MvChange

 No

2.26

Form
Sint32 MPG_MvChange (MpgMv mpgmv)
input
mpgmv: MPEG video handle currently playing
output
none
Function value
Error code
function
Forcibly switches the MPEG stream. The stream currently playing mpgmv is interrupted, and the stream registered with the MPG_MvEntryNext function is played next.
remarks
(a) In the following cases, switching will fail, so please reissue.

 List
 Title

Function specifications

 Function

Setting the buffer clearing method

 Function Name

MPG_MvSetClearMode

 No

2.27

Form
void MPG_MvSetClearMode (MpgMv mpgmv, Sint32 vmode, Sint32 amode)
input
 mpgmv
 : MPEG video handle
 vmode
 : Erase video stream mode
 amode
 : Erase mode of audio stream
output
none
Function value
none
function
Sets how to clear the buffer when forcibly switching streams.
(1) Erase mode of video stream
・ MPG_VCLR_VBV_IP
 : Clear VBV buffer at next I or P picture start
・ MPG_VCLR_ALL
 : Immediately clear framebuffer and VBV buffer
(2) Audio storm erase mode
・ MPG_ACLR_NONE
 : Do not clear
・ MPG_ACLR_ALL
 : Clear all instantly 

 List
 Title

Function specifications

 Function

Stream layer settings

 Function Name

MPG_MvSetLay

 No

2.28

Form
void MPG_MvSetLay (MpgMv mpgmv, Sint32 vlay, Sint32 alay)
input
 mpgmv
 : MPEG video handle
 vlay
 : Video stream layer (MPG_NOCHG: unchanged)
 alay
 : Audio stream layer (MPG_NOCHG: unchanged)
output
none
Function value
none
function
Set the stream layer. Must be set before starting playback.
(1) Video stream layer
(2) Audio stream layer

BackForward
PROGRAMMER'S GUIDEMPEG library
Copyright SEGA ENTERPRISES, LTD., 1997