mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 05:16:13 +00:00
dvbsuboverlay: Improve selection of current to be displayed subpictures
Drop all subpictures that are too old anyway and clear the currently displayed subpictures if num_rects==0 happens.
This commit is contained in:
parent
01cf79ae59
commit
2282a08890
1 changed files with 36 additions and 12 deletions
|
@ -899,16 +899,39 @@ gst_dvbsub_overlay_chain_video (GstPad * pad, GstBuffer * buffer)
|
||||||
|
|
||||||
g_mutex_lock (overlay->dvbsub_mutex);
|
g_mutex_lock (overlay->dvbsub_mutex);
|
||||||
if (!g_queue_is_empty (overlay->pending_subtitles)) {
|
if (!g_queue_is_empty (overlay->pending_subtitles)) {
|
||||||
DVBSubtitles *pending_sub = g_queue_peek_head (overlay->pending_subtitles);
|
DVBSubtitles *pending_sub = NULL;
|
||||||
if (vid_running_time >= pending_sub->pts) {
|
|
||||||
GST_DEBUG_OBJECT (overlay,
|
while (!g_queue_is_empty (overlay->pending_subtitles)) {
|
||||||
"Time to show the next subtitle page (%" GST_TIME_FORMAT " >= %"
|
pending_sub = g_queue_peek_head (overlay->pending_subtitles);
|
||||||
GST_TIME_FORMAT ") - it has %u regions",
|
|
||||||
GST_TIME_ARGS (vid_running_time), GST_TIME_ARGS (pending_sub->pts),
|
if (pending_sub->pts +
|
||||||
pending_sub->num_rects);
|
pending_sub->page_time_out * GST_SECOND *
|
||||||
dvb_subtitles_free (overlay->current_subtitle);
|
overlay->subtitle_segment.abs_rate < vid_running_time) {
|
||||||
overlay->current_subtitle = g_queue_pop_head (overlay->pending_subtitles);
|
/* Drop all subpictures that are too late anyway */
|
||||||
/* FIXME: Pre-convert current_subtitle to a quick-blend format, num_rects=0 means that there are no regions, e.g, a subtitle "clear" happened */
|
dvb_subtitles_free (pending_sub);
|
||||||
|
g_queue_pop_head (overlay->pending_subtitles);
|
||||||
|
pending_sub = NULL;
|
||||||
|
} else if (pending_sub->num_rects == 0) {
|
||||||
|
/* Clear screen */
|
||||||
|
if (overlay->current_subtitle)
|
||||||
|
dvb_subtitles_free (overlay->current_subtitle);
|
||||||
|
overlay->current_subtitle = NULL;
|
||||||
|
dvb_subtitles_free (pending_sub);
|
||||||
|
g_queue_pop_head (overlay->pending_subtitles);
|
||||||
|
} else if (vid_running_time >= pending_sub->pts) {
|
||||||
|
GST_DEBUG_OBJECT (overlay,
|
||||||
|
"Time to show the next subtitle page (%" GST_TIME_FORMAT " >= %"
|
||||||
|
GST_TIME_FORMAT ") - it has %u regions",
|
||||||
|
GST_TIME_ARGS (vid_running_time), GST_TIME_ARGS (pending_sub->pts),
|
||||||
|
pending_sub->num_rects);
|
||||||
|
dvb_subtitles_free (overlay->current_subtitle);
|
||||||
|
overlay->current_subtitle =
|
||||||
|
g_queue_pop_head (overlay->pending_subtitles);
|
||||||
|
/* FIXME: Pre-convert current_subtitle to a quick-blend format, num_rects=0 means that there are no regions, e.g, a subtitle "clear" happened */
|
||||||
|
} else {
|
||||||
|
/* Keep old */
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -916,7 +939,8 @@ gst_dvbsub_overlay_chain_video (GstPad * pad, GstBuffer * buffer)
|
||||||
if (overlay->current_subtitle
|
if (overlay->current_subtitle
|
||||||
&& vid_running_time >
|
&& vid_running_time >
|
||||||
(overlay->current_subtitle->pts +
|
(overlay->current_subtitle->pts +
|
||||||
(overlay->current_subtitle->page_time_out * GST_SECOND))) {
|
overlay->current_subtitle->page_time_out * GST_SECOND *
|
||||||
|
overlay->subtitle_segment.abs_rate)) {
|
||||||
GST_INFO_OBJECT (overlay,
|
GST_INFO_OBJECT (overlay,
|
||||||
"Subtitle page not redefined before fallback page_time_out of %u seconds (missed data?) - deleting current page",
|
"Subtitle page not redefined before fallback page_time_out of %u seconds (missed data?) - deleting current page",
|
||||||
overlay->current_subtitle->page_time_out);
|
overlay->current_subtitle->page_time_out);
|
||||||
|
@ -925,7 +949,7 @@ gst_dvbsub_overlay_chain_video (GstPad * pad, GstBuffer * buffer)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now render it */
|
/* Now render it */
|
||||||
if (overlay->current_subtitle && overlay->current_subtitle->num_rects > 0) {
|
if (overlay->current_subtitle) {
|
||||||
buffer = gst_buffer_make_writable (buffer);
|
buffer = gst_buffer_make_writable (buffer);
|
||||||
blit_i420 (overlay, overlay->current_subtitle, buffer);
|
blit_i420 (overlay, overlay->current_subtitle, buffer);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue