[0.11] gst-plugins-ugly: mad: handle libmad freeform parsing quirk

Tim Müller tpm at kemper.freedesktop.org
Sun Feb 26 16:37:30 PST 2012


Module: gst-plugins-ugly
Branch: 0.11
Commit: 838493c9a7cc199805563299fc3152a0bdf3a77e
URL:    http://cgit.freedesktop.org/gstreamer/gst-plugins-ugly/commit/?id=838493c9a7cc199805563299fc3152a0bdf3a77e

Author: Mark Nauwelaerts <mark.nauwelaerts at collabora.co.uk>
Date:   Tue Feb 21 18:53:57 2012 +0100

mad: handle libmad freeform parsing quirk

---

 ext/mad/gstmad.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/ext/mad/gstmad.c b/ext/mad/gstmad.c
index cd3d068..a24c89d 100644
--- a/ext/mad/gstmad.c
+++ b/ext/mad/gstmad.c
@@ -339,6 +339,22 @@ gst_mad_parse (GstAudioDecoder * dec, GstAdapter * adapter,
 
       GST_LOG_OBJECT (mad, "decoding the header now");
       if (mad_header_decode (&mad->frame.header, &mad->stream) == -1) {
+        /* HACK it seems mad reports wrong error when it is trying to determine
+         * free bitrate and scanning for next header */
+        if (mad->stream.error == MAD_ERROR_LOSTSYNC) {
+          const guint8 *ptr = mad->stream.this_frame;
+          guint32 header;
+
+          if (ptr >= data && ptr < data + av) {
+            header = GST_READ_UINT32_BE (ptr);
+            /* looks like possible freeform header with not much data */
+            if (((header & 0xFFE00000) == 0xFFE00000) &&
+                (((header >> 12) & 0xF) == 0x0) && (av < 4096)) {
+              GST_DEBUG_OBJECT (mad, "overriding freeform LOST_SYNC to BUFLEN");
+              mad->stream.error = MAD_ERROR_BUFLEN;
+            }
+          }
+        }
         if (mad->stream.error == MAD_ERROR_BUFLEN) {
           GST_LOG_OBJECT (mad,
               "not enough data in tempbuffer (%d), breaking to get more", size);



More information about the gstreamer-commits mailing list