diff --git a/sc2/src/sc2code/libs/video/dukvid.c b/sc2/src/sc2code/libs/video/dukvid.c index 6cecf8175..f15f28eb4 100644 --- a/sc2/src/sc2code/libs/video/dukvid.c +++ b/sc2/src/sc2code/libs/video/dukvid.c @@ -529,8 +529,6 @@ dukv_RenderFrame (THIS_PTR) default: ; } - if (!This->audio_synced) - This->callbacks.SetTimer (This, (uint32) (1000.0f / DUCK_GENERAL_FPS)); } static const char* @@ -701,7 +699,12 @@ dukv_DecodeNext (THIS_PTR) dukv->iframe++; + This->callbacks.BeginFrame (This); dukv_RenderFrame (This); + This->callbacks.EndFrame (This); + + if (!This->audio_synced) + This->callbacks.SetTimer (This, (uint32) (1000.0f / DUCK_GENERAL_FPS)); return 1; } diff --git a/sc2/src/sc2code/libs/video/videodec.h b/sc2/src/sc2code/libs/video/videodec.h index 8f4f8c8b5..f209cdc09 100644 --- a/sc2/src/sc2code/libs/video/videodec.h +++ b/sc2/src/sc2code/libs/video/videodec.h @@ -49,7 +49,9 @@ typedef struct tfb_videodecoderfunc // from the player typedef struct tfb_videocallbacks { - // any decoder calls this + // any decoder calls these + void (* BeginFrame) (THIS_PTR); + void (* EndFrame) (THIS_PTR); void* (* GetCanvasLine) (THIS_PTR, uint32 line); // non-audio-driven decoders call this to figure out // when the next frame should be drawn diff --git a/sc2/src/sc2code/libs/video/vidplayer.c b/sc2/src/sc2code/libs/video/vidplayer.c index a0affd479..4fe23703f 100644 --- a/sc2/src/sc2code/libs/video/vidplayer.c +++ b/sc2/src/sc2code/libs/video/vidplayer.c @@ -25,6 +25,8 @@ #include "libs/log.h" // video callbacks +static void vp_BeginFrame (TFB_VideoDecoder*); +static void vp_EndFrame (TFB_VideoDecoder*); static void* vp_GetCanvasLine (TFB_VideoDecoder*, uint32 line); static uint32 vp_GetTicks (TFB_VideoDecoder*); static bool vp_SetTimer (TFB_VideoDecoder*, uint32 msecs); @@ -32,6 +34,8 @@ static bool vp_SetTimer (TFB_VideoDecoder*, uint32 msecs); TFB_VideoCallbacks vp_DecoderCBs = { + vp_BeginFrame, + vp_EndFrame, vp_GetCanvasLine, vp_GetTicks, vp_SetTimer @@ -472,6 +476,24 @@ TFB_VideoInput (VIDEO_REF VidRef) DoInput (&vis, TRUE); } +static void +vp_BeginFrame (TFB_VideoDecoder* decoder) +{ + TFB_VideoClip* vid = (TFB_VideoClip*) decoder->data; + + if (vid) + TFB_DrawCanvas_Lock (vid->frame->NormalImg); +} + +static void +vp_EndFrame (TFB_VideoDecoder* decoder) +{ + TFB_VideoClip* vid = (TFB_VideoClip*) decoder->data; + + if (vid) + TFB_DrawCanvas_Unlock (vid->frame->NormalImg); +} + static void* vp_GetCanvasLine (TFB_VideoDecoder* decoder, uint32 line) {