audiodecoder: propagate resync flag

- propagate resync flag on last input frame to output frame
- resync TS when RESYNC flag is set

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5529>
This commit is contained in:
Daniel Morin 2023-11-09 08:37:39 -05:00 committed by GStreamer Marge Bot
parent c2a357c867
commit 1fc3d43952

View file

@ -1423,9 +1423,23 @@ gst_audio_decoder_finish_frame_or_subframe (GstAudioDecoder * dec,
frames = priv->frames.length;
}
if (G_LIKELY (priv->frames.length))
if (G_LIKELY (buf))
buf = gst_buffer_make_writable (buf);
if (G_LIKELY (priv->frames.length)) {
ts = GST_BUFFER_PTS (priv->frames.head->data);
else
if (G_LIKELY (buf)) {
/* propagate RESYNC flag to output buffer */
if (GST_BUFFER_FLAG_IS_SET (priv->frames.head->data,
GST_BUFFER_FLAG_RESYNC))
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_RESYNC);
if (is_subframe) {
priv->frames.head->data =
gst_buffer_make_writable (priv->frames.head->data);
GST_BUFFER_FLAG_UNSET (priv->frames.head->data, GST_BUFFER_FLAG_RESYNC);
}
}
} else
ts = GST_CLOCK_TIME_NONE;
GST_DEBUG_OBJECT (dec, "leading frame ts %" GST_TIME_FORMAT,
@ -1477,7 +1491,8 @@ gst_audio_decoder_finish_frame_or_subframe (GstAudioDecoder * dec,
* discard buffer ts and carry on producing perfect stream,
* otherwise resync to ts */
if (G_UNLIKELY (diff < (gint64) - dec->priv->tolerance ||
diff > (gint64) dec->priv->tolerance)) {
diff > (gint64) dec->priv->tolerance ||
GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLAG_RESYNC))) {
GST_DEBUG_OBJECT (dec, "base_ts resync");
priv->base_ts = ts;
priv->samples = 0;
@ -1501,7 +1516,6 @@ gst_audio_decoder_finish_frame_or_subframe (GstAudioDecoder * dec,
priv->taglist_changed = FALSE;
}
buf = gst_buffer_make_writable (buf);
if (G_LIKELY (GST_CLOCK_TIME_IS_VALID (priv->base_ts))) {
GST_BUFFER_PTS (buf) =
priv->base_ts +