shithub: aacenc

Download patch

ref: 725acfc45ff162d0bfb1896a9e7d8b9375348bf3
parent: 2678c78d8bf698d65bfa9bfc96ea266ebf2c92b8
author: menno <menno>
date: Mon May 28 10:11:47 EDT 2001

Changes for ISO MPEG4 compatibility (sorry :(( )
Old MPEG4 files with ADTS header will not be playable anymore

--- a/libfaac/bitstream.c
+++ b/libfaac/bitstream.c
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: bitstream.c,v 1.14 2001/05/02 05:39:14 menno Exp $
+ * $Id: bitstream.c,v 1.15 2001/05/28 14:11:47 menno Exp $
  */
 
 #include <stdlib.h>
@@ -104,8 +104,11 @@
 	 * 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);
+    if (hEncoder->config.mpegVersion == 0)
+  	  bits += ByteAlign(bitStream, 1,2);
 
+	bits += ByteAlign(bitStream, 1,0);
+
 	return bits;
 }
 
@@ -177,8 +180,12 @@
 	bits += LEN_SE_ID;
 
 	/* Now byte align the bitstream */
-	bits += ByteAlign(bitStream, 0);
 
+    if (hEncoder->config.mpegVersion == 0)
+		bits += ByteAlign(bitStream, 0,2);
+
+	bits += ByteAlign(bitStream, 0,0);
+
 	hEncoder->usedBytes = bit2byte(bits);
 
 	return bits;
@@ -795,15 +802,22 @@
 	return 0;
 }
 
-static int ByteAlign(BitStream *bitStream, int writeFlag)
+static int ByteAlign(BitStream *bitStream, int writeFlag, int offset)
 {
 	int len, i,j;
 
+#if 0
+	assert(offset<8);
+	assert(offset>=0);
+#endif
+
 	len = BufferNumBit(bitStream);
-	   
-	j = (8 - (len%8))%8;
 
-	if ((len % 8) == 0) j = 0;
+	j = (16+offset - (len%8))%8;
+
+	if ((len % 8) == offset) 
+		j = 0;
+
 	if (writeFlag) {
 		for( i=0; i<j; i++ ) {
 			PutBit(bitStream, 0, 1);
@@ -811,4 +825,3 @@
 	}
 	return j;
 }
-
--- a/libfaac/bitstream.h
+++ b/libfaac/bitstream.h
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: bitstream.h,v 1.6 2001/05/02 05:39:14 menno Exp $
+ * $Id: bitstream.h,v 1.7 2001/05/28 14:11:47 menno Exp $
  */
 
 #ifndef BITSTREAM_H
@@ -215,7 +215,8 @@
 		   int numBit);
 
 static int ByteAlign(BitStream* bitStream,
-					 int writeFlag);
+					 int writeFlag,
+					 int offset);
 
 #ifdef __cplusplus
 }