assrender: For synchronizing the text, take the video running time of the next frame

This makes sure that libass already has all text buffers for the next frame
at the time when the next frame is processed. Without this text buffers
might be one frame late or not shown at all if they're only shown for a
single frame.
This commit is contained in:
Sebastian Dröge 2009-12-08 14:06:23 +01:00
parent 77d0ded9ed
commit d7e58ce0a9
2 changed files with 7 additions and 1 deletions

View file

@ -651,7 +651,8 @@ gst_ass_render_setcaps_video (GstPad * pad, GstCaps * caps)
render->height = 0;
if (!gst_video_format_parse_caps (caps, &render->format, &render->width,
&render->height)) {
&render->height) ||
!gst_video_parse_caps_framerate (caps, &render->fps_n, &render->fps_d)) {
GST_ERROR_OBJECT (render, "Can't parse caps: %" GST_PTR_FORMAT, caps);
ret = FALSE;
goto out;
@ -963,6 +964,10 @@ gst_ass_render_chain_text (GstPad * pad, GstBuffer * buffer)
gst_segment_to_running_time (&render->video_segment, GST_FORMAT_TIME,
render->video_segment.last_stop);
if (render->fps_n && render->fps_d)
vid_running_time +=
gst_util_uint64_scale (GST_SECOND, render->fps_d, render->fps_n);
if (sub_running_time > vid_running_time) {
g_assert (render->subtitle_pending == NULL);
g_mutex_lock (render->subtitle_mutex);

View file

@ -55,6 +55,7 @@ struct _GstAssRender
GstVideoFormat format;
gint width, height;
gint fps_n, fps_d;
GstAssRenderBlitFunction blit;
GMutex *subtitle_mutex;