mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-23 22:46:24 +00:00
matroskademux: Parse and handle CodecDelay, SeekPreroll and DiscardPadding
https://bugzilla.gnome.org/show_bug.cgi?id=727305
This commit is contained in:
parent
52122f9206
commit
d620ca4740
1 changed files with 70 additions and 0 deletions
|
@ -940,6 +940,34 @@ gst_matroska_demux_add_stream (GstMatroskaDemux * demux, GstEbmlRead * ebml)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* codec delay */
|
||||||
|
case GST_MATROSKA_ID_CODECDELAY:{
|
||||||
|
guint64 num;
|
||||||
|
|
||||||
|
if ((ret = gst_ebml_read_uint (ebml, &id, &num)) != GST_FLOW_OK)
|
||||||
|
break;
|
||||||
|
|
||||||
|
context->codec_delay = num;
|
||||||
|
|
||||||
|
GST_DEBUG_OBJECT (demux, "CodecDelay: %" GST_TIME_FORMAT,
|
||||||
|
GST_TIME_ARGS (num));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* codec delay */
|
||||||
|
case GST_MATROSKA_ID_SEEKPREROLL:{
|
||||||
|
guint64 num;
|
||||||
|
|
||||||
|
if ((ret = gst_ebml_read_uint (ebml, &id, &num)) != GST_FLOW_OK)
|
||||||
|
break;
|
||||||
|
|
||||||
|
context->seek_preroll = num;
|
||||||
|
|
||||||
|
GST_DEBUG_OBJECT (demux, "SeekPreroll: %" GST_TIME_FORMAT,
|
||||||
|
GST_TIME_ARGS (num));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
/* name of this track */
|
/* name of this track */
|
||||||
case GST_MATROSKA_ID_TRACKNAME:{
|
case GST_MATROSKA_ID_TRACKNAME:{
|
||||||
gchar *text;
|
gchar *text;
|
||||||
|
@ -3162,6 +3190,7 @@ gst_matroska_demux_parse_blockgroup_or_simpleblock (GstMatroskaDemux * demux,
|
||||||
gboolean readblock = FALSE;
|
gboolean readblock = FALSE;
|
||||||
guint32 id;
|
guint32 id;
|
||||||
guint64 block_duration = -1;
|
guint64 block_duration = -1;
|
||||||
|
gint64 block_discardpadding = 0;
|
||||||
GstBuffer *buf = NULL;
|
GstBuffer *buf = NULL;
|
||||||
GstMapInfo map;
|
GstMapInfo map;
|
||||||
gint stream_num = -1, n, laces = 0;
|
gint stream_num = -1, n, laces = 0;
|
||||||
|
@ -3326,6 +3355,13 @@ gst_matroska_demux_parse_blockgroup_or_simpleblock (GstMatroskaDemux * demux,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case GST_MATROSKA_ID_DISCARDPADDING:{
|
||||||
|
ret = gst_ebml_read_sint (ebml, &id, &block_discardpadding);
|
||||||
|
GST_DEBUG_OBJECT (demux, "DiscardPadding: %" GST_STIME_FORMAT,
|
||||||
|
GST_STIME_ARGS (block_discardpadding));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case GST_MATROSKA_ID_REFERENCEBLOCK:{
|
case GST_MATROSKA_ID_REFERENCEBLOCK:{
|
||||||
ret = gst_ebml_read_sint (ebml, &id, &referenceblock);
|
ret = gst_ebml_read_sint (ebml, &id, &referenceblock);
|
||||||
GST_DEBUG_OBJECT (demux, "ReferenceBlock: %" G_GINT64_FORMAT,
|
GST_DEBUG_OBJECT (demux, "ReferenceBlock: %" G_GINT64_FORMAT,
|
||||||
|
@ -3703,6 +3739,40 @@ gst_matroska_demux_parse_blockgroup_or_simpleblock (GstMatroskaDemux * demux,
|
||||||
Therefore, create an aligned copy if necessary. */
|
Therefore, create an aligned copy if necessary. */
|
||||||
sub = gst_matroska_demux_align_buffer (demux, sub, stream->alignment);
|
sub = gst_matroska_demux_align_buffer (demux, sub, stream->alignment);
|
||||||
|
|
||||||
|
if (!strcmp (stream->codec_id, GST_MATROSKA_CODEC_ID_AUDIO_OPUS)) {
|
||||||
|
guint64 start_clip = 0, end_clip = 0;
|
||||||
|
|
||||||
|
/* Codec delay is part of the timestamps */
|
||||||
|
if (GST_BUFFER_PTS_IS_VALID (sub) && stream->codec_delay) {
|
||||||
|
if (GST_BUFFER_PTS (sub) > stream->codec_delay) {
|
||||||
|
GST_BUFFER_PTS (sub) -= stream->codec_delay;
|
||||||
|
} else {
|
||||||
|
GST_BUFFER_PTS (sub) = 0;
|
||||||
|
start_clip =
|
||||||
|
gst_util_uint64_scale_round (stream->codec_delay, 48000,
|
||||||
|
GST_SECOND);
|
||||||
|
|
||||||
|
if (GST_BUFFER_DURATION_IS_VALID (sub)) {
|
||||||
|
if (GST_BUFFER_DURATION (sub) > stream->codec_delay)
|
||||||
|
GST_BUFFER_DURATION (sub) -= stream->codec_delay;
|
||||||
|
else
|
||||||
|
GST_BUFFER_DURATION (sub) = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (block_discardpadding) {
|
||||||
|
end_clip =
|
||||||
|
gst_util_uint64_scale_round (block_discardpadding, 48000,
|
||||||
|
GST_SECOND);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (start_clip || end_clip) {
|
||||||
|
gst_buffer_add_audio_clipping_meta (sub, GST_FORMAT_DEFAULT,
|
||||||
|
start_clip, end_clip);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (GST_BUFFER_PTS_IS_VALID (sub)) {
|
if (GST_BUFFER_PTS_IS_VALID (sub)) {
|
||||||
stream->pos = GST_BUFFER_PTS (sub);
|
stream->pos = GST_BUFFER_PTS (sub);
|
||||||
if (GST_BUFFER_DURATION_IS_VALID (sub))
|
if (GST_BUFFER_DURATION_IS_VALID (sub))
|
||||||
|
|
Loading…
Reference in a new issue