From 88bf47c911aedc673e02e2369ad161ae0a7029d0 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 26 Apr 2007 08:39:49 +0000 Subject: gst/wavparse/gstwavparse.*: Apply DISCONT to buffers. Original commit message from CVS: * gst/wavparse/gstwavparse.c: (gst_wavparse_perform_seek), (gst_wavparse_stream_headers), (gst_wavparse_stream_data): * gst/wavparse/gstwavparse.h: Apply DISCONT to buffers. Only apply timestamp to the first sample after a DISCONT, too many VBR files cause random jitter in the timestamps. Fixes #433119. --- gst/wavparse/gstwavparse.c | 26 +++++++++++++++++++++++--- gst/wavparse/gstwavparse.h | 2 ++ 2 files changed, 25 insertions(+), 3 deletions(-) (limited to 'gst/wavparse') diff --git a/gst/wavparse/gstwavparse.c b/gst/wavparse/gstwavparse.c index e79d3524..be62a6e2 100644 --- a/gst/wavparse/gstwavparse.c +++ b/gst/wavparse/gstwavparse.c @@ -905,6 +905,9 @@ gst_wavparse_perform_seek (GstWavParse * wav, GstEvent * event) wav->segment.format, wav->segment.last_stop, stop, wav->segment.last_stop); + /* mark discont */ + wav->discont = TRUE; + /* and start the streaming task again */ wav->segment_running = TRUE; if (!wav->streaming) { @@ -1167,6 +1170,9 @@ gst_wavparse_stream_headers (GstWavParse * wav) size = GST_READ_UINT32_LE (GST_BUFFER_DATA (buf) + 4); } + GST_DEBUG_OBJECT (wav, "Got TAG: %" GST_FOURCC_FORMAT, + GST_FOURCC_ARGS (tag)); + gst_wavparse_get_upstream_size (wav, &upstream_size); /* wav is a st00pid format, we don't know for sure where data starts. @@ -1222,6 +1228,7 @@ gst_wavparse_stream_headers (GstWavParse * wav) wav->fact = GST_READ_UINT32_LE (GST_BUFFER_DATA (buf)); gst_buffer_unref (buf); } + GST_DEBUG_OBJECT (wav, "have fact %u", wav->fact); wav->offset += 8 + 4; break; } @@ -1541,10 +1548,23 @@ iterate_adapter: /* update current running segment position */ gst_segment_set_last_stop (&wav->segment, GST_FORMAT_TIME, next_timestamp); + + /* only apply the timestamp to the first DISCONT buffer because we might be + * dealing with VBR data that can make the timestamps drift a lot */ + if (wav->discont) { + GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_DISCONT); + wav->discont = FALSE; + } else { + timestamp = GST_CLOCK_TIME_NONE; + duration = GST_CLOCK_TIME_NONE; + } } else { - /* no bitrate, don't timestamp */ - timestamp = GST_CLOCK_TIME_NONE; - next_timestamp = GST_CLOCK_TIME_NONE; + /* no bitrate, all we know is that the first sample has timestamp 0, all + * other positions and durations have unknown timestamp. */ + if (pos == 0) + timestamp = 0; + else + timestamp = GST_CLOCK_TIME_NONE; duration = GST_CLOCK_TIME_NONE; /* update current running segment position with byte offset */ gst_segment_set_last_stop (&wav->segment, GST_FORMAT_BYTES, nextpos); diff --git a/gst/wavparse/gstwavparse.h b/gst/wavparse/gstwavparse.h index 4f50eff4..18e9ef72 100644 --- a/gst/wavparse/gstwavparse.h +++ b/gst/wavparse/gstwavparse.h @@ -110,6 +110,8 @@ struct _GstWavParse { /* for late pad configuration */ gboolean first; + /* discont after seek */ + gboolean discont; }; struct _GstWavParseClass { -- cgit