summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlessandro Decina <alessandro.d@gmail.com>2012-04-04 20:43:23 +0200
committerAlessandro Decina <alessandro.d@gmail.com>2012-04-04 20:52:50 +0200
commit38803239c026163589dde04259b00c5fe33ad706 (patch)
treeac6042be0478a8b61ae6d009a46bffe4020bb999
parent4b349306b0e35ae62e932dedae7092f6ebadd78d (diff)
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.
-rw-r--r--gst-libs/gst/audio/gstaudiodecoder.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/gst-libs/gst/audio/gstaudiodecoder.c b/gst-libs/gst/audio/gstaudiodecoder.c
index 5dfd278e1..6bc054d47 100644
--- a/gst-libs/gst/audio/gstaudiodecoder.c
+++ b/gst-libs/gst/audio/gstaudiodecoder.c
@@ -220,6 +220,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 */
@@ -445,6 +446,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;
@@ -977,6 +979,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) {
@@ -1016,12 +1019,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_metadata_writable (buffer);