ext/wavpack/: Improve discont handling by checking if the next Wavpack block has...
authorSebastian Dröge <slomo@circular-chaos.org>
Sat, 9 Jun 2007 15:33:32 +0000 (15:33 +0000)
committerSebastian Dröge <slomo@circular-chaos.org>
Sat, 9 Jun 2007 15:33:32 +0000 (15:33 +0000)
Original commit message from CVS:
* ext/wavpack/gstwavpackdec.c: (gst_wavpack_dec_reset),
(gst_wavpack_dec_chain):
* ext/wavpack/gstwavpackdec.h:
* ext/wavpack/gstwavpackparse.c: (gst_wavpack_parse_reset),
(gst_wavpack_parse_push_buffer):
* ext/wavpack/gstwavpackparse.h:
Improve discont handling by checking if the next Wavpack block has
the expected, following block index.

ChangeLog
ext/wavpack/gstwavpackdec.c
ext/wavpack/gstwavpackdec.h
ext/wavpack/gstwavpackparse.c
ext/wavpack/gstwavpackparse.h

index 0865a85..9b11b2b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2007-06-09  Sebastian Dröge  <slomo@circular-chaos.org>
+
+       * ext/wavpack/gstwavpackdec.c: (gst_wavpack_dec_reset),
+       (gst_wavpack_dec_chain):
+       * ext/wavpack/gstwavpackdec.h:
+       * ext/wavpack/gstwavpackparse.c: (gst_wavpack_parse_reset),
+       (gst_wavpack_parse_push_buffer):
+       * ext/wavpack/gstwavpackparse.h:
+       Improve discont handling by checking if the next Wavpack block has
+       the expected, following block index.
+
 2007-06-08  Thomas Vander Stichele  <thomas at apestaart dot org>
 
        * gst/rtp/gstrtpmp4vpay.c (gst_rtp_mp4vpay_details):
index 5adaf1b..437ba0d 100644 (file)
@@ -130,6 +130,7 @@ gst_wavpack_dec_reset (GstWavpackDec * dec)
   dec->depth = 0;
 
   gst_segment_init (&dec->segment, GST_FORMAT_UNDEFINED);
+  dec->next_block_index = 0;
 }
 
 static void
@@ -362,9 +363,11 @@ gst_wavpack_dec_chain (GstPad * pad, GstBuffer * buf)
   /* If we got a DISCONT buffer forward the flag. Nothing else
    * has to be done as libwavpack doesn't store state between
    * Wavpack blocks */
-  if (GST_BUFFER_IS_DISCONT (buf))
+  if (GST_BUFFER_IS_DISCONT (buf) || dec->next_block_index != wph.block_index)
     GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DISCONT);
 
+  dec->next_block_index = wph.block_index + wph.block_samples;
+
   /* decode */
   decoded = WavpackUnpackSamples (dec->context,
       (int32_t *) GST_BUFFER_DATA (outbuf), wph.block_samples);
index 68380ca..007e7c2 100644 (file)
@@ -57,6 +57,7 @@ struct _GstWavpackDec
   read_id wv_id;
 
   GstSegment segment;           /* used for clipping, TIME format */
+  guint32 next_block_index;
 
   gint sample_rate;
   gint depth;
index 61c94f1..0c77d55 100644 (file)
@@ -218,6 +218,7 @@ gst_wavpack_parse_reset (GstWavpackParse * parse)
   parse->channels = 0;
 
   gst_segment_init (&parse->segment, GST_FORMAT_UNDEFINED);
+  parse->next_block_index = 0;
 
   parse->current_offset = 0;
   parse->need_newsegment = TRUE;
@@ -890,11 +891,13 @@ gst_wavpack_parse_push_buffer (GstWavpackParse * wvparse, GstBuffer * buf,
   GST_BUFFER_OFFSET (buf) = header->block_index;
   GST_BUFFER_OFFSET_END (buf) = header->block_index + header->block_samples;
 
-  if (wvparse->discont) {
+  if (wvparse->discont || wvparse->next_block_index != header->block_index) {
     GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_DISCONT);
     wvparse->discont = FALSE;
   }
 
+  wvparse->next_block_index = header->block_index + header->block_samples;
+
   gst_buffer_set_caps (buf, GST_PAD_CAPS (wvparse->srcpad));
 
   GST_LOG_OBJECT (wvparse, "Pushing buffer with time %" GST_TIME_FORMAT,
index c1d6fee..0b089d9 100644 (file)
@@ -67,6 +67,7 @@ struct _GstWavpackParse
 
   GstSegment segment;           /* the currently configured segment, in
                                  * samples/audio frames (DEFAULT format) */
+  guint32 next_block_index;
 
   GstAdapter *adapter;          /* when operating chain-based, otherwise NULL */