shithub: aacenc

Download patch

ref: 5b286b3f0769059769c9431f952a005146e8f5b1
parent: b9a3af2eda4ea67ee6e71f402052c36c6b9a79a7
author: knik <knik>
date: Wed Jul 16 12:27:34 EDT 2003

Used ID_FIL element to write libfaac info.

--- a/libfaac/bitstream.c
+++ b/libfaac/bitstream.c
@@ -24,9 +24,10 @@
 Copyright (c) 1997.
 **********************************************************************/
 /*
- * $Id: bitstream.c,v 1.25 2003/03/24 10:08:10 menno Exp $
+ * $Id: bitstream.c,v 1.26 2003/07/16 16:27:34 knik Exp $
  */
 
+#include <stdio.h>
 #include <stdlib.h>
 
 #include "coder.h"
@@ -101,6 +102,46 @@
 
 
 
+static int WriteFAACStr(BitStream *bitStream, char *version, int write)
+{
+  int i;
+  char str[200];
+  int len, padbits, count;
+  int bitcnt;
+
+  sprintf(str, "libfaac %s", version);
+
+  len = strlen(str) + 1;
+  padbits = (8 - ((bitStream->numBit + 7) % 8)) % 8;
+  count = len + 3;
+
+  bitcnt = LEN_SE_ID + 4 + ((count < 15) ? 0 : 8) + count * 8;
+  if (!write)
+    return bitcnt;
+
+  PutBit(bitStream, ID_FIL, LEN_SE_ID);
+  if (count < 15)
+  {
+    PutBit(bitStream, count, 4);
+  }
+  else
+  {
+    PutBit(bitStream, 15, 4);
+    PutBit(bitStream, count - 14, 8);
+  }
+
+  PutBit(bitStream, 0, padbits);
+  PutBit(bitStream, 0, 8);
+  PutBit(bitStream, 0, 8); // just in case
+  for (i = 0; i < len; i++)
+    PutBit(bitStream, str[i], 8);
+
+  PutBit(bitStream, 0, 8 - padbits);
+
+  return bitcnt;
+}
+
+
 int WriteBitstream(faacEncHandle hEncoder,
                    CoderInfo *coderInfo,
                    ChannelInfo *channelInfo,
@@ -119,6 +160,9 @@
 		bits = 0; // compilier will remove it, byt anyone will see that current size of bitstream is 0
 	}
 
+    if (hEncoder->frameNum == 4)
+      WriteFAACStr(bitStream, hEncoder->config.name, 1);
+
     for (channel = 0; channel < numChannel; channel++) {
 
         if (channelInfo[channel].present) {
@@ -203,6 +247,8 @@
 		bits = 0; // compilier will remove it, byt anyone will see that current size of bitstream is 0
 	}
 
+    if (hEncoder->frameNum == 4)
+      bits += WriteFAACStr(bitStream, hEncoder->config.name, 0);
 
     for (channel = 0; channel < numChannel; channel++) {