diff options
author | Mark Nauwelaerts <mark.nauwelaerts@collabora.co.uk> | 2012-07-10 11:25:30 +0200 |
---|---|---|
committer | Mark Nauwelaerts <mark.nauwelaerts@collabora.co.uk> | 2012-07-10 11:25:30 +0200 |
commit | ba0448111d18b7fda9630a156e3c56ea6fa1c1cd (patch) | |
tree | 1d4a46dad3d436b08f1c332eb35a87a19636f65f | |
parent | a926d6d1186410ff83e234877cd59af6db6c2613 (diff) |
dvbsuboverlay: ensure valid subtitle running time by proper clipping
In particular, pass buffer timestamp (pts) to dvb_sub, and then clip
and convert to running time when the duration (timeout) is known after
decoding it.
Fixes https://bugzilla.gnome.org/show_bug.cgi?id=660233
-rw-r--r-- | gst/dvbsuboverlay/gstdvbsuboverlay.c | 44 |
1 files changed, 31 insertions, 13 deletions
diff --git a/gst/dvbsuboverlay/gstdvbsuboverlay.c b/gst/dvbsuboverlay/gstdvbsuboverlay.c index 80f0ea25a..e22a6a1d7 100644 --- a/gst/dvbsuboverlay/gstdvbsuboverlay.c +++ b/gst/dvbsuboverlay/gstdvbsuboverlay.c @@ -728,9 +728,8 @@ gst_dvbsub_overlay_process_text (GstDVBSubOverlay * overlay, GstBuffer * buffer, guint size = GST_BUFFER_SIZE (buffer); GST_DEBUG_OBJECT (overlay, - "Processing subtitles with fake PTS=%" G_GUINT64_FORMAT - " which is a running time of %" GST_TIME_FORMAT, - pts, GST_TIME_ARGS (pts)); + "Processing subtitles with PTS=%" G_GUINT64_FORMAT + " which is a time of %" GST_TIME_FORMAT, pts, GST_TIME_ARGS (pts)); GST_DEBUG_OBJECT (overlay, "Feeding %u bytes to libdvbsub", size); g_mutex_lock (overlay->dvbsub_mutex); dvb_sub_feed_with_pts (overlay->dvb_sub, pts, data, size); @@ -750,6 +749,7 @@ new_dvb_subtitles_cb (DvbSub * dvb_sub, DVBSubtitles * subs, gpointer user_data) { GstDVBSubOverlay *overlay = GST_DVBSUB_OVERLAY (user_data); int max_page_timeout; + gint64 start, stop; max_page_timeout = g_atomic_int_get (&overlay->max_page_timeout); if (max_page_timeout > 0) @@ -757,12 +757,38 @@ new_dvb_subtitles_cb (DvbSub * dvb_sub, DVBSubtitles * subs, gpointer user_data) GST_INFO_OBJECT (overlay, "New DVB subtitles arrived with a page_time_out of %d and %d regions for PTS=%" - G_GUINT64_FORMAT ", which should be at running time %" GST_TIME_FORMAT, + G_GUINT64_FORMAT ", which should be at time %" GST_TIME_FORMAT, subs->page_time_out, subs->num_rects, subs->pts, GST_TIME_ARGS (subs->pts)); + /* clip and convert to running time */ + start = subs->pts; + stop = subs->pts + subs->page_time_out; + + if (!(gst_segment_clip (&overlay->subtitle_segment, GST_FORMAT_TIME, + start, stop, &start, &stop))) + goto out_of_segment; + + subs->page_time_out = stop - start; + + gst_segment_to_running_time (&overlay->subtitle_segment, GST_FORMAT_TIME, + start); + g_assert (GST_CLOCK_TIME_IS_VALID (start)); + subs->pts = start; + + GST_DEBUG_OBJECT (overlay, "SUBTITLE real running time: %" GST_TIME_FORMAT, + GST_TIME_ARGS (start)); + g_queue_push_tail (overlay->pending_subtitles, subs); overlay->pending_sub = FALSE; + + return; + +out_of_segment: + { + GST_DEBUG_OBJECT (overlay, "subtitle out of segment, discarding"); + dvb_subtitles_free (subs); + } } static GstFlowReturn @@ -791,7 +817,6 @@ static GstFlowReturn gst_dvbsub_overlay_chain_text (GstPad * pad, GstBuffer * buffer) { GstDVBSubOverlay *overlay = GST_DVBSUB_OVERLAY (GST_PAD_PARENT (pad)); - GstClockTime sub_running_time; GST_INFO_OBJECT (overlay, "subpicture/x-dvb buffer with size %u", GST_BUFFER_SIZE (buffer)); @@ -831,16 +856,9 @@ gst_dvbsub_overlay_chain_text (GstPad * pad, GstBuffer * buffer) gst_segment_set_last_stop (&overlay->subtitle_segment, GST_FORMAT_TIME, GST_BUFFER_TIMESTAMP (buffer)); - sub_running_time = - gst_segment_to_running_time (&overlay->subtitle_segment, GST_FORMAT_TIME, + gst_dvbsub_overlay_process_text (overlay, buffer, GST_BUFFER_TIMESTAMP (buffer)); - GST_DEBUG_OBJECT (overlay, "SUBTITLE real running time: %" GST_TIME_FORMAT, - GST_TIME_ARGS (sub_running_time)); - - /* FIXME: We are abusing libdvbsub pts value for tracking our gstreamer running time instead of real PTS. Should be mostly fine though... */ - gst_dvbsub_overlay_process_text (overlay, buffer, sub_running_time); - return GST_FLOW_OK; } |