matroskademux: fix decoder glitches with H264 content

To avoid decoder starvation causing glitches on screen,
the demuxer shall clip only when the buffer is a key frame
and the lace time is greater than the stop time.

Fixes gst-editing-services#128

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/973>
This commit is contained in:
Stéphane Cerveau 2021-05-05 13:20:04 +02:00
parent c75bd32539
commit 918d882021

View file

@ -4799,11 +4799,15 @@ gst_matroska_demux_parse_blockgroup_or_simpleblock (GstMatroskaDemux * demux,
if (GST_CLOCK_TIME_IS_VALID (lace_time)) {
GstClockTime last_stop_end;
/* Check if this stream is after segment stop */
if (GST_CLOCK_TIME_IS_VALID (demux->common.segment.stop) &&
lace_time >= demux->common.segment.stop) {
/* Check if this stream is after segment stop,
* but only terminate if we hit the next keyframe,
* to make sure that all frames potentially inside the segment
* are available to the decoder for decoding / reordering.*/
if (!delta_unit && GST_CLOCK_TIME_IS_VALID (demux->common.segment.stop)
&& lace_time >= demux->common.segment.stop) {
GST_DEBUG_OBJECT (demux,
"Stream %d after segment stop %" GST_TIME_FORMAT, stream->index,
"Stream %d lace time: %" GST_TIME_FORMAT " after segment stop: %"
GST_TIME_FORMAT, stream->index, GST_TIME_ARGS (lace_time),
GST_TIME_ARGS (demux->common.segment.stop));
gst_buffer_unref (sub);
goto eos;