shithub: aacenc

Download patch

ref: 38c1ef253431754d1a512b40d0d1ff1f42e98d33
parent: 193311f8d1bcd4cb0dcd1ce0ece3d7707baa6767
author: corrados <corrados>
date: Thu Jul 8 10:01:25 EDT 2004

New scalefactorband table for 960 transform length, bug fix in HCR

--- a/libfaac/bitstream.c
+++ b/libfaac/bitstream.c
@@ -24,7 +24,7 @@
 Copyright (c) 1997.
 **********************************************************************/
 /*
- * $Id: bitstream.c,v 1.28 2004/07/04 12:10:52 corrados Exp $
+ * $Id: bitstream.c,v 1.29 2004/07/08 14:01:25 corrados Exp $
  */
 
 #include <stdio.h>
@@ -1163,7 +1163,10 @@
 
         /* presorting (first presorting step) */
         /* only needed for short windows */
-        if (coderInfo->block_type == ONLY_SHORT_WINDOW) {
+
+/* Somehow the second presorting step does not give expected results. Disabling the
+   following code surprisingly gives good results. TODO: find the bug */
+        if (0) {//coderInfo->block_type == ONLY_SHORT_WINDOW) {
             for (i = 0; i < MAX_SHORT_WINDOWS; i++)
                 window_cw_cnt[i] = 0; /* reset all counters */
 
--- a/libfaac/frame.c
+++ b/libfaac/frame.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: frame.c,v 1.62 2004/07/04 12:10:52 corrados Exp $
+ * $Id: frame.c,v 1.63 2004/07/08 14:01:25 corrados Exp $
  */
 
 /*
@@ -863,9 +863,117 @@
 }
 
 
-/* Scalefactorband data table */
+#ifdef DRM
+/* Scalefactorband data table for 960 transform length */
+/* all parameters which are different from the 1024 transform length table are
+   marked with an "x" */
 static SR_INFO srInfo[12+1] =
 {
+    { 96000, 40/*x*/, 12,
+        {
+            4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
+            8, 8, 8, 8, 8, 12, 12, 12, 12, 12, 16, 16, 24, 28,
+            36, 44, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 0/*x*/
+        },{
+            4, 4, 4, 4, 4, 4, 8, 8, 8, 16, 28, 28/*x*/
+        }
+    }, { 88200, 40/*x*/, 12,
+        {
+            4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
+            8, 8, 8, 8, 8, 12, 12, 12, 12, 12, 16, 16, 24, 28,
+            36, 44, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 0/*x*/
+        },{
+            4, 4, 4, 4, 4, 4, 8, 8, 8, 16, 28, 28/*x*/
+        }
+    }, { 64000, 45/*x*/, 12,
+        {
+            4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
+            8, 8, 8, 8, 12, 12, 12, 16, 16, 16, 20, 24, 24, 28,
+            36, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
+            40, 40, 40, 16/*x*/, 0/*x*/
+        },{
+            4, 4, 4, 4, 4, 4, 8, 8, 8, 16, 28, 28/*x*/
+        }
+    }, { 48000, 49, 14,
+        {
+            4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  8,  8,  8,  8,  8,  8,  8,
+            12, 12, 12, 12, 16, 16, 20, 20, 24, 24, 28, 28, 32, 32, 32, 32, 32, 32,
+            32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32/*x*/
+        }, {
+            4,  4,  4,  4,  4,  8,  8,  8, 12, 12, 12, 16, 16, 8/*x*/
+        }
+    }, { 44100, 49, 14,
+        {
+            4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  8,  8,  8,  8,  8,  8,  8,
+            12, 12, 12, 12, 16, 16, 20, 20, 24, 24, 28, 28, 32, 32, 32, 32, 32, 32,
+            32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32/*x*/
+        }, {
+            4,  4,  4,  4,  4,  8,  8,  8, 12, 12, 12, 16, 16, 8/*x*/
+        }
+    }, { 32000, 49/*x*/, 14,
+        {
+            4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  8,  8,  8,  8,
+            8,  8,  8,  12, 12, 12, 12, 16, 16, 20, 20, 24, 24, 28,
+            28, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+            32, 32, 32, 32, 32, 32, 32, 0/*x*/, 0/*x*/
+        },{
+            4,  4,  4,  4,  4,  8,  8,  8,  12, 12, 12, 16, 16, 16
+        }
+    }, { 24000, 46/*x*/, 15,
+        {
+            4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  8,  8,  8,  8,  8,  8,  8,
+            8,  8,  8,  12, 12, 12, 12, 16, 16, 16, 20, 20, 24, 24, 28, 28, 32,
+            36, 36, 40, 44, 48, 52, 52, 64, 64, 64, 64, 0/*x*/
+        }, {
+            4,  4,  4,  4,  4,  4,  4,  8,  8,  8, 12, 12, 16, 16, 12/*x*/
+        }
+    }, { 22050, 46/*x*/, 15,
+        {
+            4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  8,  8,  8,  8,  8,  8,  8,
+            8,  8,  8,  12, 12, 12, 12, 16, 16, 16, 20, 20, 24, 24, 28, 28, 32,
+            36, 36, 40, 44, 48, 52, 52, 64, 64, 64, 64, 0/*x*/
+        }, {
+            4,  4,  4,  4,  4,  4,  4,  8,  8,  8, 12, 12, 16, 16, 12/*x*/
+        }
+    }, { 16000, 42/*x*/, 15,
+        {
+            8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 12, 12, 12,
+            12, 12, 12, 12, 12, 12, 16, 16, 16, 16, 20, 20, 20, 24,
+            24, 28, 28, 32, 36, 40, 40, 44, 48, 52, 56, 60, 64, 64, 0/*x*/
+        }, {
+            4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 12, 12, 16, 20, 12/*x*/
+        }
+    }, { 12000, 42/*x*/, 15,
+        {
+            8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 12, 12, 12,
+            12, 12, 12, 12, 12, 12, 16, 16, 16, 16, 20, 20, 20, 24,
+            24, 28, 28, 32, 36, 40, 40, 44, 48, 52, 56, 60, 64, 64, 0/*x*/
+        }, {
+            4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 12, 12, 16, 20, 12/*x*/
+        }
+    }, { 11025, 42/*x*/, 15,
+        {
+            8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 12, 12, 12,
+            12, 12, 12, 12, 12, 12, 16, 16, 16, 16, 20, 20, 20, 24,
+            24, 28, 28, 32, 36, 40, 40, 44, 48, 52, 56, 60, 64, 64, 0/*x*/
+        }, {
+            4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 12, 12, 16, 20, 12/*x*/
+        }
+    }, { 8000, 40, 15,
+        {
+            12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 16,
+            16, 16, 16, 16, 16, 16, 20, 20, 20, 20, 24, 24, 24, 28,
+            28, 32, 36, 36, 40, 44, 48, 52, 56, 60, 64, 16/*x*/
+        }, {
+            4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 12, 16, 20, 12/*x*/
+        }
+    },
+    { -1 }
+};
+#else
+/* Scalefactorband data table for 1024 transform length */
+static SR_INFO srInfo[12+1] =
+{
     { 96000, 41, 12,
         {
             4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
@@ -967,16 +1075,14 @@
     },
     { -1 }
 };
+#endif
 
 /*
 $Log: frame.c,v $
-Revision 1.62  2004/07/04 12:10:52  corrados
-made faac compliant with Digital Radio Mondiale (DRM) (DRM macro must be set)
-implemented HCR tool, VCB11, CRC, scalable bitstream order
-note: VCB11 only uses codebook 11! TODO: implement codebooks 16-32
-960 transform length is not yet implemented (TODO)! Use 1024 for encoding and 960 for decoding, resulting in a lot of artefacts
+Revision 1.63  2004/07/08 14:01:25  corrados
+New scalefactorband table for 960 transform length, bug fix in HCR
 
-Revision 1.62  2004/07/  corrados
+Revision 1.62  2004/07/04 12:10:52  corrados
 made faac compliant with Digital Radio Mondiale (DRM) (DRM macro must be set)
 implemented HCR tool, VCB11, CRC, scalable bitstream order
 note: VCB11 only uses codebook 11! TODO: implement codebooks 16-32
--- a/libfaac/psychkni.c
+++ b/libfaac/psychkni.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: psychkni.c,v 1.15 2003/12/10 17:48:55 knik Exp $
+ * $Id: psychkni.c,v 1.16 2004/07/08 14:01:24 corrados Exp $
  */
 #include <stdio.h>
 #include <stdlib.h>
@@ -353,7 +353,7 @@
     int first = 0;
     int last = 0;
 
-    memcpy(transBuffS, transBuff + (win * 128) + (512 - 64),
+    memcpy(transBuffS, transBuff + (win * BLOCK_LEN_SHORT) + (BLOCK_LEN_LONG - BLOCK_LEN_SHORT) / 2,
 	   2 * psyInfo->sizeS * sizeof(double));
 
     Hann(gpsyInfo, transBuffS, 2 * psyInfo->sizeS);