Japanese
PROGRAMMER'S GUIDEMPEG library
BackForward
MPEG library/12.Function details-2

12.2 Video playback



 one
View
table
 Title

function specification

 Function

Generate MPEG video handle

 Function name

MPG_MvCreate

 No

2.1

Format
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 an MPEG stream. Specify a stream handle for video data and a stream handle for audio data.
You can also specify NULL for either to play audio and video independently.
If you specify both at the same time, playback will be synchronized.
Returns NULL if generation of the MPEG video handle fails.
The following values are set as default values.
 item
 Setting value
 Exit conditions
 system end code
 Image output destination
 VDP2 direct output
 Decoding timing
 VSYNC signal
 Channel selection
 do not
 Stream ID
 ignore
 stream layer
 system layer 

 one
View
table
 Title

function specification

 Function

Erase MPEG video handle

 Function name

MPG_MvDestroy

 No

2.2

Format
Sint32 MPG_MvDestroy(MpgMv mpgmv)
input
mpgmv: MPEG video handle
output
none
function value
Error code
function
Erase the MPEG video handle.
[remarks]
(a) The handle must be in a stopped state for both audio and video.
(b) The handle is not registered as the next handle to be played by the MPG_MvEntryNext function.
(c) This function executes the playback stop function.

 one
View
table
 Title

function specification

 Function

Setting video ending conditions

 Function name

MPG_MvSetTermCond

 No

2.3

Format
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 conditions for each stream. You can logically OR the following values:
(1) MPEG stream termination conditions (common to video/audio)
・MPG_TCND_EOR
 :When transferring a sector with EOR bit set
・MPG_TCND_SEC
 : When a system end code appears in the stream
・MPG_TCND_NONE
 : Do not set termination conditions 

 one
View
table
 Title

function specification

 Function

Setting the video output destination

 Function name

MPG_MvSetVideoDest

 No

2.4

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

 one
View
table
 Title

function specification

 Function

Setting decode timing

 Function name

MPG_MvSetDecTim

 No

2.5

Format
void MPG_MvSetDecTim(MpgMv mpgmv, Sint32 tmg)
input
 mpgmv
 :MPEG video handle
 tmg
 :Decode timing
output
none
function value
none
function
Set the decoding timing for MPEG video.
(1) Decoding timing
・MPG_DECTMG_VSYNC
 : Decode one picture with two VSYNC signals
・MPG_DECTMG_HOST
 :Decode by calling MPG_MvDecNext function
remarks
(a) The settings of this function become effective by calling the MPG_MvStart function.

 one
View
table
 Title

function specification

 Function

Configuring video channels

 Function name

MPG_MvSetVideoChan

 No

2.6

Format
void MPG_MvSetVideoChan(MpgMv mpgmv, Sint32 vch)
input
 mpgmv
 :MPEG video handle
 vch
 :Channel number (MPG_IGNORE: unspecified)
output
none
function value
none
function
Specifies the channel of the video to play. Default is unspecified.
When this function is called, the channel will be switched immediately. Data with mismatched channel numbers will be sequentially erased from the CD buffer.
remarks
(a) This function works on the video layer stream. It cannot be used for system layer streams.

 one
View
table
 Title

function specification

 Function

Configuring audio channels

 Function name

MPG_MvSetAudioChan

 No

2.7

Format
void MPG_MvSetAudioChan(MpgMv mpgmv, Sint32 ach)
input
 mpgmv
 :MPEG video handle
 ach
 :Channel number (MPG_IGNORE: unspecified)
output
none
function value
none
function
Specifies the audio channel to play. Default is unspecified.
When this function is called, the channel will be switched immediately. Data with mismatched channel numbers will be sequentially erased from the CD buffer.
remarks
(a) This function works on the video layer stream. It cannot be used for system layer streams.

 one
View
table
 Title

function specification

 Function

Setting the video stream ID

 Function name

MPG_MvSetVideoId

 No

2.8

Format
void MPG_MvSetVideoId(MpgMv mpgmv, Sint32 vid)
input
 mpgmv
 :MPEG video handle
 vid: Video stream number (MPG_IGNORE
 : unspecified)
output
none
function value
none
function
Specifies the stream number of the video to be played. Default is unspecified.
Data with unmatched stream numbers will be sequentially deleted from the CD buffer.
remarks
(a) If this function is executed during audio/video synchronized playback, synchronization of video and audio is not guaranteed.

 one
View
table
 Title

function specification

 Function

Setting the audio stream ID

 Function name

MPG_MvSetAudioId

 No

2.9

Format
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
Specifies the stream number of the audio to be played. Default is unspecified.
Data with unmatched stream numbers will be sequentially deleted from the CD buffer.

 one
View
table
 Title

function specification

 Function

Start video playback

 Function name

MPG_MvStart

 No

2.10

Format
Sint32 MPG_MvStart(MpgMv mpgmv, Bool picsch)
input
 mpgmv
 :MPEG video handle
 picsch
 :Picture search flag
output
none
function value
Error code
function
Start playing the video. If picsch is ON, perform a picture search and then start playback. If set to OFF, picture search will not be executed.
remarks
(a) If you call this function while playing another stream, MPG_ERR_PLAYING will be returned.
(b) If MPEG decoder connection fails, return MPG_ERR_MCON.
(c) Picture search is a function that searches for sequence headers in an MPEG stream and starts playback from the found position.

 one
View
table
 Title

function specification

 Function

Stopping video playback

 Function name

MPG_MvStop

 No

2.11

Format
void MPG_MvStop(MpgMv mpgmv)
input
mpgmv: MPEG video handle
output
none
function value
Error code
function
Stop playing the video. During audio/video synchronized playback, audio playback is stopped before video playback is stopped.
remarks
(a) If this function is called during restoration processing, 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 performing stop processing.

 one
View
table
 Title

function specification

 Function

Stopping video playback

 Function name

MPG_MvStopVideo

 No

2.12

Format
Sint32 MPG_MvStopVideo(MpgMv mpgmv)
input
mpgmv: MPEG video handle
output
none
function value
none
function
Stop playing the video.
remarks
(a) If this function is called during restoration processing, 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 performing stop processing.

 one
View
table
 Title

function specification

 Function

Stopping audio playback

 Function name

MPG_MvStopAudio

 No

2.13

Format
Sint32 MPG_MvStopAudio(MpgMv mpgmv)
input
mpgmv: MPEG video handle
output
none
function value
none
function
Stop audio playback.
remarks
(a) If this function is called during restoration processing, 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 performing stop processing.

 one
View
table
 Title

function specification

 Function

Pause/frame-by-frame/slow playback

 Function name

MPG_MvPause

 No

2.14

Format
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-by-frame/slow playback. If MPG_PAUSE_ON is further specified in the paused state, it will advance frame by frame. During slow playback, frames advance at a rate of itvl/30 times per second.
(1) Operation specification
・MPG_PAUSE_ON
 : Pause (during normal playback)
・MPG_PAUSE_ON
 :Frame-by-frame forwarding (paused)
・MPG_PAUSE_OFF
 :Normal playback
・MPG_PAUSE_SLOW
 : Slow playback
remarks
(a) During audio/video synchronized playback, please leave an interval of approximately 25 VSYNC between canceling pause and pausing again. Otherwise the audio and video will be out of sync.

 one
View
table
 Title

function specification

 Function

Freeze/Strobe playback

 Function name

MPG_MvFreeze

 No

2.15

Format
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
Performs freeze/strobe playback. If MPG_FREEZE_ON is further specified in the frozen state, it will be refrozen. Strobe playback is refrozen 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

 one
View
table
 Title

function specification

 Function

Setting the left and right audio channels

 Function name

MPG_MvSetPan

 No

2.16

Format
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
Configure MPEG audio output ON/OFF settings.

 one
View
table
 Title

function specification

 Function

Obtaining video operating status

 Function name

MPG_MvGetVideoStat

 No

2.17

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

 one
View
table
 Title

function specification

 Function

Get audio operating status

 Function name

MPG_MvGetAudioStat

 No

2.18

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

 one
View
table
 Title

function specification

 Function

Obtaining video timecode

 Function name

MPG_MvGetTimeCode

 No

2.19

Format
void MPG_MvGetTimeCode(MpgMv mpgmv, Sint32 *hh, Sint32 *mm, Sint32 *ss, Sint32 *pp)
input
mpgmv: MPEG video handle
output
 hh
 : Time code time (0 to 23)
 mm
 : Minute of time code (0 to 59)
 ss
 : Time code seconds (0 to 59)
 pp
 : Time code picture (0 to 29)
function value
none
function
Get the timecode present in the video stream. Outputs 0 when no video stream is playing.
remarks
(a) The video stream must be encoded with NTSC drop frames.
(b) A picture is sometimes called a frame.

 one
View
table
 Title

function specification

 Function

Get audio playback time

 Function name

MPG_MvGetPlaytime

 No

2.20

Format
Sint32 MPG_MvGetPlaytime(MpgMv mpgmv)
input
mpgmv: MPEG video handle
output
none
function value
Current playback time of audio (in msec)
function
Returns the current playback time of the audio in milliseconds.
remarks
(a) Always returns 0 if the MPEG video handle is set to play video only.

 one
View
table
 Title

function specification

 Function

Video MPEG window connection

 Function name

MPG_MvConnectWin

 No

2.21

Format
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 and the MPEG window. The decoded video will be displayed through this MPEG window.
remarks
(a) If the playback mode of the MPEG video handle is audio only, nothing will be done.

 one
View
table
 Title

function specification

 Function

Detaching the MPEG window of a video

 Function name

MPG_MvDisconnectWin

 No

2.22

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

 one
View
table
 Title

function specification

 Function

Perform video decoding

 Function name

MPG_MvDecNext

 No

2.23

Format
Sint32 MPG_MvDecNext(MpgMv mpgmv)
input
mpgmv: MPEG video handle
output
none
function value
Error code
function
Decode the next picture. The decode timing must be MPG_DECTMG_HOST.
【Note】
Only when decoding the first picture, use the MPG_IsDecReady function to confirm that decoding is ready before executing this function.
After that, be sure to execute this function at intervals of at least one frame's decoding time (2VSYNC). Normally, it is necessary to obtain synchronization timing using VSYNC, audio playback amount, etc.
For details, see page 57 "Decode synchronization signal transmission" in the CDC manual (MPEG part).
(See CDC_MpOutDsync function).

 one
View
table
 Title

function specification

 Function

Video output

 Function name

MPG_MvOutput

 No

2.24

Format
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 will be transferred to the host and output. When this function is called, image data is transferred to the buffer area of the host transfer window connected to the MPEG video handle.
(Execute MPG_WnTrans function for each MPEG window)
When the picture update check switch is ON, video will be output only when a picture update occurs. This check is not performed when it is OFF.
remarks
(a)mpgmv must be in host output mode and the video operation status must be playing. If this is not the case, video output will fail. (b) If the decoding timing is MPG_DECTMG_HOST, picture updates cannot be detected, so turn off the picture update check switch.

 one
View
table
 Title

function specification

 Function

Registering the MPEG handle to be played next

 Function name

MPG_MvEntryNext

 No

2.25

Format
Sint32 MPG_MvEntryNext(MpgMv mpgmv, MpgMv nextmv)
input
mpgmv: MPEG video handle nextmv: Next MPEG video handle to play
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 using the MPG_MvChange function, the stream registered using this function will be played next. When the stream is switched, the MPEG handle that was being played becomes stopped, and the registered MPEG handle becomes 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 host transfer output next to an MPEG video handle for VDP2 direct output.
(b) Do not register MPEG video handles with different streams to play. For example, do not register a video handle for video-only playback next to a video handle for audio/video synchronized playback.
(c) The following items will not be set when switching videos. The settings before switching will be applied after switching.
・Video channel and audio channel ・Video stream ID and audio stream ID
・Slow playback speed ・Strobe interval ・Left and right audio channels 

 one
View
table
 Title

function specification

 Function

Forced stream switching

 Function name

MPG_MvChange

 No

2.26

Format
Sint32 MPG_MvChange(MpgMv mpgmv)
input
mpgmv: Handle of the currently playing MPEG video
output
none
function value
Error code
function
Force switching of MPEG streams. The currently playing stream 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.

 one
View
table
 Title

function specification

 Function

Setting the buffer clearing method

 Function name

MPG_MvSetClearMode

 No

2.27

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

 one
View
table
 Title

function specification

 Function

Stream layer settings

 Function name

MPG_MvSetLay

 No

2.28

Format
void MPG_MvSetLay(MpgMv mpgmv, Sint32 vlay, Sint32 alay)
input
 mpgmv
 :MPEG video handle
 vlay
 :Video stream layer (MPG_NOCHG: Do not change)
 alay
 : Audio stream layer (MPG_NOCHG: Do not change)
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