mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-17 19:55:32 +00:00
audiodecoder: don't discard timestamps when consecutive input buffers have the same ts
Avoid pushing out buffers with the same timestamp only if the out buffers are decoded from the same input buffer. Instead keep the timestamps when upstream pushes consecutive buffers with the same ts.
This commit is contained in:
parent
6eeca397fc
commit
ebf80977c4
1 changed files with 8 additions and 4 deletions
|
@ -216,6 +216,7 @@ struct _GstAudioDecoderPrivate
|
|||
GstAdapter *adapter;
|
||||
/* tracking input ts for changes */
|
||||
GstClockTime prev_ts;
|
||||
guint64 prev_distance;
|
||||
/* frames obtained from input */
|
||||
GQueue frames;
|
||||
/* collected output data */
|
||||
|
@ -475,6 +476,7 @@ gst_audio_decoder_reset (GstAudioDecoder * dec, gboolean full)
|
|||
dec->priv->out_ts = GST_CLOCK_TIME_NONE;
|
||||
dec->priv->out_dur = 0;
|
||||
dec->priv->prev_ts = GST_CLOCK_TIME_NONE;
|
||||
dec->priv->prev_distance = 0;
|
||||
dec->priv->drained = TRUE;
|
||||
dec->priv->base_ts = GST_CLOCK_TIME_NONE;
|
||||
dec->priv->samples = 0;
|
||||
|
@ -1055,6 +1057,7 @@ gst_audio_decoder_push_buffers (GstAudioDecoder * dec, gboolean force)
|
|||
if (G_LIKELY (av)) {
|
||||
gint len;
|
||||
GstClockTime ts;
|
||||
guint64 distance;
|
||||
|
||||
/* parse if needed */
|
||||
if (klass->parse) {
|
||||
|
@ -1094,12 +1097,13 @@ gst_audio_decoder_push_buffers (GstAudioDecoder * dec, gboolean force)
|
|||
len = av;
|
||||
}
|
||||
/* track upstream ts, but do not get stuck if nothing new upstream */
|
||||
ts = gst_adapter_prev_timestamp (priv->adapter, NULL);
|
||||
if (ts == priv->prev_ts) {
|
||||
ts = gst_adapter_prev_timestamp (priv->adapter, &distance);
|
||||
if (ts != priv->prev_ts || distance <= priv->prev_distance) {
|
||||
priv->prev_ts = ts;
|
||||
priv->prev_distance = distance;
|
||||
} else {
|
||||
GST_LOG_OBJECT (dec, "ts == prev_ts; discarding");
|
||||
ts = GST_CLOCK_TIME_NONE;
|
||||
} else {
|
||||
priv->prev_ts = ts;
|
||||
}
|
||||
buffer = gst_adapter_take_buffer (priv->adapter, len);
|
||||
buffer = gst_buffer_make_writable (buffer);
|
||||
|
|
Loading…
Reference in a new issue