diff options
author | jep <jep@2b0047a9-a6d8-0310-accf-f7200b2a168c> | 2014-05-20 09:51:46 +0000 |
---|---|---|
committer | jep <jep@2b0047a9-a6d8-0310-accf-f7200b2a168c> | 2014-05-20 09:51:46 +0000 |
commit | 97c26379e88933a1d6ae6f575395b27ceb1d1274 (patch) | |
tree | f905dca4028a6558877ecc0b4f538dc06f9524a9 | |
parent | 58c96b41aabd19a6960f546d64bca1430971c54b (diff) |
* src/flump3dec-0_10.c: (_update_ts), (gst_flump3dec_decode),
(gst_flump3dec_sink_chain):
Fix tracking of input timestamps.
git-svn-id: https://core.fluendo.com/gstreamer/svn/trunk/gst-fluendo-mp3@2612 2b0047a9-a6d8-0310-accf-f7200b2a168c
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | src/flump3dec-0_10.c | 35 |
2 files changed, 32 insertions, 9 deletions
@@ -1,3 +1,9 @@ +2014-05-20 Josep Torra <josep@fluendo.com> + + * src/flump3dec-0_10.c: (_update_ts), (gst_flump3dec_decode), + (gst_flump3dec_sink_chain): + Fix tracking of input timestamps. + 2014-05-15 Julien Moutte <julien@fluendo.com> * src/mp3-c.c: Remove unused variable. diff --git a/src/flump3dec-0_10.c b/src/flump3dec-0_10.c index 7631786..5942b92 100644 --- a/src/flump3dec-0_10.c +++ b/src/flump3dec-0_10.c @@ -136,7 +136,7 @@ _update_ts (GstFluMp3Dec * dec, GstClockTime new_ts, const fr_header * mp3hdr) diff = ABS ((GstClockTimeDiff) (new_ts - out_ts)); if ((GstClockTime) diff > (frame_dur / 2)) { GST_DEBUG_OBJECT (dec, "Got frame with new TS %" - G_GUINT64_FORMAT " - using.", new_ts); + GST_TIME_FORMAT " - using.", GST_TIME_ARGS (new_ts)); out_ts = new_ts; } } @@ -461,7 +461,11 @@ gst_flump3dec_decode (GstFluMp3Dec * dec, GstClockTime dec_ts, GST_BUFFER_TIMESTAMP (out_buf) = dec->next_ts; GST_BUFFER_DURATION (out_buf) = gst_util_uint64_scale (GST_SECOND, mp3hdr->frame_samples, mp3hdr->sample_rate); + /* Next_ts is used to generate a continuous serie of timestamps and + * handle resynchronizations on original timestamps */ dec->next_ts += GST_BUFFER_DURATION (out_buf); + /* The in_ts is used to detect invalid DISCONT flags */ + dec->in_ts += GST_BUFFER_DURATION (out_buf); GST_DEBUG_OBJECT (dec, "Have new buffer, size %" G_GSIZE_FORMAT ", ts %" GST_TIME_FORMAT, out_size, @@ -536,17 +540,18 @@ gst_flump3dec_sink_chain (GstPad * pad, GstBuffer * buffer) { GstFluMp3Dec *dec = GST_FLUMP3DEC (gst_pad_get_parent (pad)); GstFlowReturn res = GST_FLOW_OK; - GstClockTime new_ts; + GstClockTime pts, duration; gboolean discont; gsize avail; discont = GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_DISCONT); - new_ts = GST_BUFFER_TIMESTAMP (buffer); + pts = GST_BUFFER_TIMESTAMP (buffer); + duration = GST_BUFFER_DURATION (buffer); /* check that we really have a discont */ if (G_UNLIKELY (discont)) { - if (GST_CLOCK_TIME_IS_VALID (new_ts) && GST_CLOCK_TIME_IS_VALID (dec->in_ts) - && new_ts == dec->in_ts) { + if (GST_CLOCK_TIME_IS_VALID (pts) && GST_CLOCK_TIME_IS_VALID (dec->in_ts) + && pts == dec->in_ts) { GST_DEBUG_OBJECT (dec, "Ignoring discontinuity flag, not needed"); } else { /* We flush on disconts */ @@ -557,9 +562,15 @@ gst_flump3dec_sink_chain (GstPad * pad, GstBuffer * buffer) } /* We've got a new buffer. Decode it! */ - GST_DEBUG_OBJECT (dec, "New input buffer with TS %" G_GUINT64_FORMAT, new_ts); + GST_DEBUG_OBJECT (dec, "New input buffer with TS %" GST_TIME_FORMAT, + GST_TIME_ARGS (pts)); gst_adapter_push (dec->adapter, buffer); + /* Store the new timestamp if it's valid. The input timestamp is tracked to + * detect invalid DISCONT flags */ + if (GST_CLOCK_TIME_IS_VALID (pts)) + dec->in_ts = pts; + /* Give data to the decoder */ if ((avail = gst_adapter_available (dec->adapter))) { const guint8 *data = gst_adapter_peek (dec->adapter, avail); @@ -567,17 +578,23 @@ gst_flump3dec_sink_chain (GstPad * pad, GstBuffer * buffer) bs_set_data (dec->bs, data, avail); - res = gst_flump3dec_decode (dec, new_ts, TRUE); + res = gst_flump3dec_decode (dec, pts, TRUE); - if (GST_CLOCK_TIME_IS_VALID (new_ts) && + if (GST_CLOCK_TIME_IS_VALID (pts) && GST_CLOCK_TIME_IS_VALID (GST_BUFFER_DURATION (buffer))) - dec->in_ts = new_ts + GST_BUFFER_DURATION (buffer); + dec->in_ts = pts + GST_BUFFER_DURATION (buffer); + if ((consumed = bs_get_consumed (dec->bs))) { GST_DEBUG_OBJECT (dec, "consumed %u bytes", consumed); gst_adapter_flush (dec->adapter, consumed); } } + /* Update the in_ts with the duration if it was provided */ + if (GST_CLOCK_TIME_IS_VALID (duration)) { + dec->in_ts += pts + duration; + } + gst_object_unref (dec); return res; } |