shithub: aacenc

Download patch

ref: 7effd468fa98c306d2e393da4b184ccd0b9f7c76
parent: 15436622f7c20a4a366a2c42b442439b8e7cdd7b
author: menno <menno>
date: Tue Jun 5 14:59:47 EDT 2007

Fixes from SF tracker

--- a/frontend/input.c
+++ b/frontend/input.c
@@ -16,7 +16,7 @@
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: input.c,v 1.12 2004/03/03 15:54:50 knik Exp $
+ * $Id: input.c,v 1.13 2007/06/05 18:59:47 menno Exp $
  */
 
 #ifdef HAVE_CONFIG_H
@@ -140,15 +140,26 @@
     if (memcmp(&(riff.chunk_type), wavel, 4))
       return NULL;
 
+    // handle broadcast extensions. added by pro-tools,otherwise it must be fmt chunk.
     if (fread(&riffsub, 1, sizeof(riffsub), wave_f) != sizeof(riffsub))
-      return NULL;
+        return NULL;
     riffsub.len = UINT32(riffsub.len);
+
+    if (!memcmp(&(riffsub.label), bextl, 4))
+    {
+        fseek(wave_f, riffsub.len, SEEK_CUR);
+
+        if (fread(&riffsub, 1, sizeof(riffsub), wave_f) != sizeof(riffsub))
+            return NULL;
+        riffsub.len = UINT32(riffsub.len);
+    }
+
     if (memcmp(&(riffsub.label), fmtl, 4))
-      return NULL;
+        return NULL;
     memset(&wave, 0, sizeof(wave));
     fmtsize = (riffsub.len < sizeof(wave)) ? riffsub.len : sizeof(wave);
     if (fread(&wave, 1, fmtsize, wave_f) != fmtsize)
-      return NULL;
+        return NULL;
 
     for (skip = riffsub.len - fmtsize; skip > 0; skip--)
       fgetc(wave_f);
--- a/libfaac/bitstream.c
+++ b/libfaac/bitstream.c
@@ -24,7 +24,7 @@
 Copyright (c) 1997.
 **********************************************************************/
 /*
- * $Id: bitstream.c,v 1.33 2006/07/10 12:04:47 sur Exp $
+ * $Id: bitstream.c,v 1.34 2007/06/05 18:59:47 menno Exp $
  */
 
 #include <stdio.h>
@@ -98,7 +98,7 @@
                      unsigned long data,
                      int numBit);
 static int ByteAlign(BitStream* bitStream,
-                     int writeFlag);
+                     int writeFlag, int bitsSoFar);
 #ifdef DRM
 static int PutBitHcr(BitStream *bitStream,
                      unsigned long curpos,
@@ -238,7 +238,7 @@
      * in MPEG4 the byte_alignment() is officially done before the new frame
      * instead of at the end. But this is basically the same.
      */
-    bits += ByteAlign(bitStream, 1);
+    bits += ByteAlign(bitStream, 1, bits);
 
     return bits;
 }
@@ -322,7 +322,7 @@
     bits += LEN_SE_ID;
 
     /* Now byte align the bitstream */
-    bits += ByteAlign(bitStream, 0);
+    bits += ByteAlign(bitStream, 0, bits);
 
     hEncoder->usedBytes = bit2byte(bits);
 
@@ -1010,11 +1010,16 @@
     return 0;
 }
 
-static int ByteAlign(BitStream *bitStream, int writeFlag)
+static int ByteAlign(BitStream *bitStream, int writeFlag, int bitsSoFar)
 {
     int len, i,j;
 
-    len = BufferNumBit(bitStream);
+    if (writeFlag)
+    {
+        len = BufferNumBit(bitStream);
+    } else {
+        len = bitsSoFar;
+    }
 
     j = (8 - (len%8))%8;