[gst-cvs] gst-plugins-bad: celtdec: Handle lookahead, discont

David Schleef ds at kemper.freedesktop.org
Fri Oct 2 22:10:51 PDT 2009


Module: gst-plugins-bad
Branch: master
Commit: 05a1e071b9d1ad06536814e546d7256169654adf
URL:    http://cgit.freedesktop.org/gstreamer/gst-plugins-bad/commit/?id=05a1e071b9d1ad06536814e546d7256169654adf

Author: David Schleef <ds at schleef.org>
Date:   Wed Sep 23 13:17:54 2009 -0700

celtdec: Handle lookahead, discont

---

 ext/celt/gstceltdec.c |   21 +++++++++++++++++++++
 ext/celt/gstceltdec.h |    1 +
 2 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/ext/celt/gstceltdec.c b/ext/celt/gstceltdec.c
index 2f3d780..4837237 100644
--- a/ext/celt/gstceltdec.c
+++ b/ext/celt/gstceltdec.c
@@ -609,6 +609,7 @@ celt_dec_chain_parse_data (GstCeltDec * dec, GstBuffer * buf,
   GstBuffer *outbuf;
   gint16 *out_data;
   gint error = CELT_OK;
+  int skip = 0;
 
   if (timestamp != -1) {
     dec->segment.last_stop = timestamp;
@@ -636,6 +637,10 @@ celt_dec_chain_parse_data (GstCeltDec * dec, GstBuffer * buf,
     size = 0;
   }
 
+  if (dec->discont) {
+    celt_mode_info (dec->mode, CELT_GET_LOOKAHEAD, &skip);
+  }
+
   res = gst_pad_alloc_buffer_and_set_caps (dec->srcpad,
       GST_BUFFER_OFFSET_NONE, dec->frame_size * dec->header.nb_channels * 2,
       GST_PAD_CAPS (dec->srcpad), &outbuf);
@@ -655,6 +660,14 @@ celt_dec_chain_parse_data (GstCeltDec * dec, GstBuffer * buf,
     return GST_FLOW_ERROR;
   }
 
+  if (skip > 0) {
+    GST_ERROR ("skipping %d samples", skip);
+    GST_BUFFER_DATA (outbuf) = GST_BUFFER_DATA (outbuf) +
+        skip * dec->header.nb_channels * 2;
+    GST_BUFFER_SIZE (outbuf) = GST_BUFFER_SIZE (outbuf) -
+        skip * dec->header.nb_channels * 2;
+  }
+
   if (dec->granulepos == -1) {
     if (dec->segment.format != GST_FORMAT_TIME) {
       GST_WARNING_OBJECT (dec, "segment not initialized or not TIME format");
@@ -672,6 +685,10 @@ celt_dec_chain_parse_data (GstCeltDec * dec, GstBuffer * buf,
       gst_util_uint64_scale_int (dec->granulepos - dec->frame_size, GST_SECOND,
       dec->header.sample_rate);
   GST_BUFFER_DURATION (outbuf) = dec->frame_duration;
+  if (dec->discont) {
+    GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DISCONT);
+    dec->discont = 0;
+  }
 
   dec->granulepos += dec->frame_size;
   dec->segment.last_stop += dec->frame_duration;
@@ -696,6 +713,10 @@ celt_dec_chain (GstPad * pad, GstBuffer * buf)
 
   dec = GST_CELT_DEC (gst_pad_get_parent (pad));
 
+  if (GST_BUFFER_IS_DISCONT (buf)) {
+    dec->discont = TRUE;
+  }
+
   if (dec->packetno == 0)
     res = celt_dec_chain_parse_header (dec, buf);
   else if (dec->packetno == 1)
diff --git a/ext/celt/gstceltdec.h b/ext/celt/gstceltdec.h
index 7785133..8d86290 100644
--- a/ext/celt/gstceltdec.h
+++ b/ext/celt/gstceltdec.h
@@ -58,6 +58,7 @@ struct _GstCeltDec {
 
   GstSegment            segment;    /* STREAM LOCK */
   gint64                granulepos; /* -1 = needs to be set from current time */
+  gboolean              discont;
 };
 
 struct _GstCeltDecClass {





More information about the Gstreamer-commits mailing list