mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-07 07:58:51 +00:00
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 Conflicts: gst/dvbsuboverlay/gstdvbsuboverlay.c
This commit is contained in:
parent
76b147e803
commit
5be47b949d
1 changed files with 31 additions and 13 deletions
|
@ -724,9 +724,8 @@ gst_dvbsub_overlay_process_text (GstDVBSubOverlay * overlay, GstBuffer * buffer,
|
||||||
GstMapInfo map;
|
GstMapInfo map;
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (overlay,
|
GST_DEBUG_OBJECT (overlay,
|
||||||
"Processing subtitles with fake PTS=%" G_GUINT64_FORMAT
|
"Processing subtitles with PTS=%" G_GUINT64_FORMAT
|
||||||
" which is a running time of %" GST_TIME_FORMAT,
|
" which is a time of %" GST_TIME_FORMAT, pts, GST_TIME_ARGS (pts));
|
||||||
pts, GST_TIME_ARGS (pts));
|
|
||||||
|
|
||||||
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||||
|
|
||||||
|
@ -753,6 +752,7 @@ new_dvb_subtitles_cb (DvbSub * dvb_sub, DVBSubtitles * subs, gpointer user_data)
|
||||||
{
|
{
|
||||||
GstDVBSubOverlay *overlay = GST_DVBSUB_OVERLAY (user_data);
|
GstDVBSubOverlay *overlay = GST_DVBSUB_OVERLAY (user_data);
|
||||||
int max_page_timeout;
|
int max_page_timeout;
|
||||||
|
gint64 start, stop;
|
||||||
|
|
||||||
max_page_timeout = g_atomic_int_get (&overlay->max_page_timeout);
|
max_page_timeout = g_atomic_int_get (&overlay->max_page_timeout);
|
||||||
if (max_page_timeout > 0)
|
if (max_page_timeout > 0)
|
||||||
|
@ -760,12 +760,38 @@ new_dvb_subtitles_cb (DvbSub * dvb_sub, DVBSubtitles * subs, gpointer user_data)
|
||||||
|
|
||||||
GST_INFO_OBJECT (overlay,
|
GST_INFO_OBJECT (overlay,
|
||||||
"New DVB subtitles arrived with a page_time_out of %d and %d regions for PTS=%"
|
"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,
|
subs->page_time_out, subs->num_rects, subs->pts,
|
||||||
GST_TIME_ARGS (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);
|
g_queue_push_tail (overlay->pending_subtitles, subs);
|
||||||
overlay->pending_sub = FALSE;
|
overlay->pending_sub = FALSE;
|
||||||
|
|
||||||
|
return;
|
||||||
|
|
||||||
|
out_of_segment:
|
||||||
|
{
|
||||||
|
GST_DEBUG_OBJECT (overlay, "subtitle out of segment, discarding");
|
||||||
|
dvb_subtitles_free (subs);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstFlowReturn
|
static GstFlowReturn
|
||||||
|
@ -773,7 +799,6 @@ gst_dvbsub_overlay_chain_text (GstPad * pad, GstObject * parent,
|
||||||
GstBuffer * buffer)
|
GstBuffer * buffer)
|
||||||
{
|
{
|
||||||
GstDVBSubOverlay *overlay = GST_DVBSUB_OVERLAY (parent);
|
GstDVBSubOverlay *overlay = GST_DVBSUB_OVERLAY (parent);
|
||||||
GstClockTime sub_running_time;
|
|
||||||
|
|
||||||
GST_INFO_OBJECT (overlay,
|
GST_INFO_OBJECT (overlay,
|
||||||
"subpicture/x-dvb buffer with size %" G_GSIZE_FORMAT,
|
"subpicture/x-dvb buffer with size %" G_GSIZE_FORMAT,
|
||||||
|
@ -813,16 +838,9 @@ gst_dvbsub_overlay_chain_text (GstPad * pad, GstObject * parent,
|
||||||
|
|
||||||
overlay->subtitle_segment.position = GST_BUFFER_TIMESTAMP (buffer);
|
overlay->subtitle_segment.position = GST_BUFFER_TIMESTAMP (buffer);
|
||||||
|
|
||||||
sub_running_time =
|
gst_dvbsub_overlay_process_text (overlay, buffer,
|
||||||
gst_segment_to_running_time (&overlay->subtitle_segment, GST_FORMAT_TIME,
|
|
||||||
GST_BUFFER_TIMESTAMP (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;
|
return GST_FLOW_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue