shithub: aacdec

Download patch

ref: fcae268a4273f53783e4ca67de3896499a6c983f
parent: f5de6d8ba2d1ba17a1fff5a19a60bb3ef7351832
author: menno <menno>
date: Tue Jan 20 13:42:51 EST 2004

Fixed compilation for DRM
New SF huffman codebook

--- a/libfaad/codebook/hcb_sf.h
+++ b/libfaad/codebook/hcb_sf.h
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,252 +22,31 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: hcb_sf.h,v 1.3 2003/09/09 18:12:01 menno Exp $
+** $Id: hcb_sf.h,v 1.4 2004/01/20 18:42:51 menno Exp $
 **/
 
 /* Binary search huffman table HCB_SF */
 
-
-static uint8_t hcb_sf[][2] = {
-    { /*  0 */  1, 2 },
-    { /*  1 */  60, 0 },
-    { /*  2 */  1, 2 },
-    { /*  3 */  2, 3 },
-    { /*  4 */  3, 4 },
-    { /*  5 */  59, 0 },
-    { /*  6 */  3, 4 },
-    { /*  7 */  4, 5 },
-    { /*  8 */  5, 6 },
-    { /*  9 */  61, 0 },
-    { /* 10 */  58, 0 },
-    { /* 11 */  62, 0 },
-    { /* 12 */  3, 4 },
-    { /* 13 */  4, 5 },
-    { /* 14 */  5, 6 },
-    { /* 15 */  57, 0 },
-    { /* 16 */  63, 0 },
-    { /* 17 */  4, 5 },
-    { /* 18 */  5, 6 },
-    { /* 19 */  6, 7 },
-    { /* 20 */  7, 8 },
-    { /* 21 */  56, 0 },
-    { /* 22 */  64, 0 },
-    { /* 23 */  55, 0 },
-    { /* 24 */  65, 0 },
-    { /* 25 */  4, 5 },
-    { /* 26 */  5, 6 },
-    { /* 27 */  6, 7 },
-    { /* 28 */  7, 8 },
-    { /* 29 */  66, 0 },
-    { /* 30 */  54, 0 },
-    { /* 31 */  67, 0 },
-    { /* 32 */  5, 6 },
-    { /* 33 */  6, 7 },
-    { /* 34 */  7, 8 },
-    { /* 35 */  8, 9 },
-    { /* 36 */  9, 10 },
-    { /* 37 */  53, 0 },
-    { /* 38 */  68, 0 },
-    { /* 39 */  52, 0 },
-    { /* 40 */  69, 0 },
-    { /* 41 */  51, 0 },
-    { /* 42 */  5, 6 },
-    { /* 43 */  6, 7 },
-    { /* 44 */  7, 8 },
-    { /* 45 */  8, 9 },
-    { /* 46 */  9, 10 },
-    { /* 47 */  70, 0 },
-    { /* 48 */  50, 0 },
-    { /* 49 */  49, 0 },
-    { /* 50 */  71, 0 },
-    { /* 51 */  6, 7 },
-    { /* 52 */  7, 8 },
-    { /* 53 */  8, 9 },
-    { /* 54 */  9, 10 },
-    { /* 55 */  10, 11 },
-    { /* 56 */  11, 12 },
-    { /* 57 */  72, 0 },
-    { /* 58 */  48, 0 },
-    { /* 59 */  73, 0 },
-    { /* 60 */  47, 0 },
-    { /* 61 */  74, 0 },
-    { /* 62 */  46, 0 },
-    { /* 63 */  6, 7 },
-    { /* 64 */  7, 8 },
-    { /* 65 */  8, 9 },
-    { /* 66 */  9, 10 },
-    { /* 67 */  10, 11 },
-    { /* 68 */  11, 12 },
-    { /* 69 */  76, 0 },
-    { /* 70 */  75, 0 },
-    { /* 71 */  77, 0 },
-    { /* 72 */  78, 0 },
-    { /* 73 */  45, 0 },
-    { /* 74 */  43, 0 },
-    { /* 75 */  6, 7 },
-    { /* 76 */  7, 8 },
-    { /* 77 */  8, 9 },
-    { /* 78 */  9, 10 },
-    { /* 79 */  10, 11 },
-    { /* 80 */  11, 12 },
-    { /* 81 */  44, 0 },
-    { /* 82 */  79, 0 },
-    { /* 83 */  42, 0 },
-    { /* 84 */  41, 0 },
-    { /* 85 */  80, 0 },
-    { /* 86 */  40, 0 },
-    { /* 87 */  6, 7 },
-    { /* 88 */  7, 8 },
-    { /* 89 */  8, 9 },
-    { /* 90 */  9, 10 },
-    { /* 91 */  10, 11 },
-    { /* 92 */  11, 12 },
-    { /* 93 */  81, 0 },
-    { /* 94 */  39, 0 },
-    { /* 95 */  82, 0 },
-    { /* 96 */  38, 0 },
-    { /* 97 */  83, 0 },
-    { /* 98 */  7, 8 },
-    { /* 99 */  8, 9 },
-    { /* 00 */  9, 10 },
-    { /* 01 */  10, 11 },
-    { /* 02 */  11, 12 },
-    { /* 03 */  12, 13 },
-    { /* 04 */  13, 14 },
-    { /* 05 */  37, 0 },
-    { /* 06 */  35, 0 },
-    { /* 07 */  85, 0 },
-    { /* 08 */  33, 0 },
-    { /* 09 */  36, 0 },
-    { /* 10 */  34, 0 },
-    { /* 11 */  84, 0 },
-    { /* 12 */  32, 0 },
-    { /* 13 */  6, 7 },
-    { /* 14 */  7, 8 },
-    { /* 15 */  8, 9 },
-    { /* 16 */  9, 10 },
-    { /* 17 */  10, 11 },
-    { /* 18 */  11, 12 },
-    { /* 19 */  87, 0 },
-    { /* 20 */  89, 0 },
-    { /* 21 */  30, 0 },
-    { /* 22 */  31, 0 },
-    { /* 23 */  8, 9 },
-    { /* 24 */  9, 10 },
-    { /* 25 */  10, 11 },
-    { /* 26 */  11, 12 },
-    { /* 27 */  12, 13 },
-    { /* 28 */  13, 14 },
-    { /* 29 */  14, 15 },
-    { /* 30 */  15, 16 },
-    { /* 31 */  86, 0 },
-    { /* 32 */  29, 0 },
-    { /* 33 */  26, 0 },
-    { /* 34 */  27, 0 },
-    { /* 35 */  28, 0 },
-    { /* 36 */  24, 0 },
-    { /* 37 */  88, 0 },
-    { /* 38 */  9, 10 },
-    { /* 39 */  10, 11 },
-    { /* 40 */  11, 12 },
-    { /* 41 */  12, 13 },
-    { /* 42 */  13, 14 },
-    { /* 43 */  14, 15 },
-    { /* 44 */  15, 16 },
-    { /* 45 */  16, 17 },
-    { /* 46 */  17, 18 },
-    { /* 47 */  25, 0 },
-    { /* 48 */  22, 0 },
-    { /* 49 */  23, 0 },
-    { /* 50 */  15, 16 },
-    { /* 51 */  16, 17 },
-    { /* 52 */  17, 18 },
-    { /* 53 */  18, 19 },
-    { /* 54 */  19, 20 },
-    { /* 55 */  20, 21 },
-    { /* 56 */  21, 22 },
-    { /* 57 */  22, 23 },
-    { /* 58 */  23, 24 },
-    { /* 59 */  24, 25 },
-    { /* 60 */  25, 26 },
-    { /* 61 */  26, 27 },
-    { /* 62 */  27, 28 },
-    { /* 63 */  28, 29 },
-    { /* 64 */  29, 30 },
-    { /* 65 */  90, 0 },
-    { /* 66 */  21, 0 },
-    { /* 67 */  19, 0 },
-    { /* 68 */   3, 0 },
-    { /* 69 */   1, 0 },
-    { /* 70 */   2, 0 },
-    { /* 71 */   0, 0 },
-    { /* 72 */  23, 24 },
-    { /* 73 */  24, 25 },
-    { /* 74 */  25, 26 },
-    { /* 75 */  26, 27 },
-    { /* 76 */  27, 28 },
-    { /* 77 */  28, 29 },
-    { /* 78 */  29, 30 },
-    { /* 79 */  30, 31 },
-    { /* 80 */  31, 32 },
-    { /* 81 */  32, 33 },
-    { /* 82 */  33, 34 },
-    { /* 83 */  34, 35 },
-    { /* 84 */  35, 36 },
-    { /* 85 */  36, 37 },
-    { /* 86 */  37, 38 },
-    { /* 87 */  38, 39 },
-    { /* 88 */  39, 40 },
-    { /* 89 */  40, 41 },
-    { /* 90 */  41, 42 },
-    { /* 91 */  42, 43 },
-    { /* 92 */  43, 44 },
-    { /* 93 */  44, 45 },
-    { /* 94 */  45, 46 },
-    { /* 95 */   98, 0 },
-    { /* 96 */   99, 0 },
-    { /* 97 */  100, 0 },
-    { /* 98 */  101, 0 },
-    { /* 99 */  102, 0 },
-    { /* 00 */  117, 0 },
-    { /* 01 */   97, 0 },
-    { /* 02 */   91, 0 },
-    { /* 03 */   92, 0 },
-    { /* 04 */   93, 0 },
-    { /* 05 */   94, 0 },
-    { /* 06 */   95, 0 },
-    { /* 07 */   96, 0 },
-    { /* 08 */  104, 0 },
-    { /* 09 */  111, 0 },
-    { /* 10 */  112, 0 },
-    { /* 11 */  113, 0 },
-    { /* 12 */  114, 0 },
-    { /* 13 */  115, 0 },
-    { /* 14 */  116, 0 },
-    { /* 15 */  110, 0 },
-    { /* 16 */  105, 0 },
-    { /* 17 */  106, 0 },
-    { /* 18 */  107, 0 },
-    { /* 19 */  108, 0 },
-    { /* 20 */  109, 0 },
-    { /* 21 */  118, 0 },
-    { /* 22 */    6, 0 },
-    { /* 23 */    8, 0 },
-    { /* 24 */    9, 0 },
-    { /* 25 */   10, 0 },
-    { /* 26 */    5, 0 },
-    { /* 27 */  103, 0 },
-    { /* 28 */  120, 0 },
-    { /* 29 */  119, 0 },
-    { /* 30 */    4, 0 },
-    { /* 31 */    7, 0 },
-    { /* 32 */   15, 0 },
-    { /* 33 */   16, 0 },
-    { /* 34 */   18, 0 },
-    { /* 35 */   20, 0 },
-    { /* 36 */   17, 0 },
-    { /* 37 */   11, 0 },
-    { /* 38 */   12, 0 },
-    { /* 39 */   14, 0 },
-    { /* 40 */   13, 0 }
+ALIGN static const int8_t hcb_sf[][2] = {
+    { -61, 1 }, { 2, 3 }, { -62, 4 }, { 5, 6 }, { -60, -63 }, { -59, 7 },
+    { 8, 9 }, { -64, -58 }, { 10, 11 }, { 12, 13 }, { -65, -57 }, { -66, -56 },
+    { 14, 15 }, { 16, 17 }, { -55, -67 }, { -54, 18 }, { 19, 20 }, { 21, 22 },
+    { -68, -53 }, { -69, -52 }, { -70, 23 }, { 24, 25 }, { 26, 27 }, { -51, -71 },
+    { -72, -50 }, { 28, 29 }, { 30, 31 }, { 32, 33 }, { -49, -73 }, { -48, -74 },
+    { -47, -75 }, { 34, 35 }, { 36, 37 }, { 38, 39 }, { -45, -46 }, { -44, -43 },
+    { -76, -78 }, { 40, 41 }, { 42, 43 }, { 44, 45 }, { -77, -42 }, { -79, -80 },
+    { -41, -81 }, { 46, 47 }, { 48, 49 }, { 50, 51 }, { -40, -82 }, { -39, -83 },
+    { -38, 52 }, { 53, 54 }, { 55, 56 }, { 57, 58 }, { -84, -86 }, { -36, -88 },
+    { -85, -87 }, { -37, -89 }, { 59, 60 }, { 61, 62 }, { 63, 64 }, { -34, -32 },
+    { -91, -90 }, { 65, 66 }, { 67, 68 }, { 69, 70 }, { 71, 72 }, { -35, -92 },
+    { -95, -94 }, { -93, -97 }, { -33, 73 }, { 74, 75 }, { 76, 77 }, { 78, 79 },
+    { 80, 81 }, { -96, -99 }, { -98, 82 }, { 83, 84 }, { 85, 86 }, { 87, 88 },
+    { 89, 90 }, { 91, 92 }, { 93, 94 }, { 95, 96 }, { -31, -100 }, { -102, -118 },
+    { -120, -119 }, { -121, 97 }, { 98, 99 }, { 100, 101 }, { 102, 103 },
+    { 104, 105 }, { 106, 107 }, { 108, 109 }, { 110, 111 }, { 112, 113 },
+    { 114, 115 }, { 116, 117 }, { 118, 119 }, { -23, -22 }, { -21, -20 },
+    { -19, -4 }, { -24, -30 }, { -29, -28 }, { -27, -26 }, { -25, -17 },
+    { -10, -9 }, { -8, -7 }, { -6, -5 }, { -11, -16 }, { -15, -14 }, { -13, -12 },
+    { -3, -115 }, { -113, -112 }, { -111, -116 }, { -18, -1 }, { -2, -117 },
+    { -114, -106 }, { -105, -103 }, { -101, -104 }, { -110, -109 }
 };
--- a/libfaad/common.h
+++ b/libfaad/common.h
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: common.h,v 1.46 2004/01/16 20:20:32 menno Exp $
+** $Id: common.h,v 1.47 2004/01/20 18:42:51 menno Exp $
 **/
 
 #ifndef __COMMON_H__
@@ -73,6 +73,7 @@
 //#define SCALABLE_DEC
 /* Allow decoding of Digital Radio Mondiale (DRM) */
 //#define DRM
+//#define DRM_PS
 
 /* LD can't do without LTP */
 #ifdef LD_DEC
--- a/libfaad/huffman.c
+++ b/libfaad/huffman.c
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: huffman.c,v 1.15 2004/01/16 20:20:32 menno Exp $
+** $Id: huffman.c,v 1.16 2004/01/20 18:42:51 menno Exp $
 **/
 
 #include "common.h"
@@ -51,25 +51,18 @@
 static uint8_t huffman_binary_pair_sign(uint8_t cb, bitfile *ld, int16_t *sp);
 static int16_t huffman_codebook(uint8_t i);
 
-
 int8_t huffman_scale_factor(bitfile *ld)
 {
-    uint16_t offset = 0;
+    uint8_t bit;
+    int16_t index = 0;
 
-    while (hcb_sf[offset][1])
+    while (index >= 0)
     {
-        uint8_t b = faad_get1bit(ld
-            DEBUGVAR(1,255,"huffman_scale_factor()"));
-        offset += hcb_sf[offset][b];
-
-        if (offset > 240)
-        {
-            /* printf("ERROR: offset into hcb_sf = %d >240!\n", offset); */
-            return -1;
-        }
+        bit = (uint8_t)faad_get1bit(ld);
+        index = hcb_sf[index][bit];
     }
 
-    return hcb_sf[offset][0];
+    return index + 121;
 }
 
 
--- a/libfaad/sbr_dec.h
+++ b/libfaad/sbr_dec.h
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: sbr_dec.h,v 1.20 2004/01/19 21:49:53 menno Exp $
+** $Id: sbr_dec.h,v 1.21 2004/01/20 18:42:51 menno Exp $
 **/
 
 #ifndef __SBR_DEC_H__
@@ -35,7 +35,7 @@
 #ifdef PS_DEC
 #include "ps_dec.h"
 #endif
-#ifdef DRM
+#ifdef DRM_PS
 #include "drm_dec.h"
 #endif
 
--- a/libfaad/sbr_syntax.c
+++ b/libfaad/sbr_syntax.c
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: sbr_syntax.c,v 1.23 2004/01/19 21:49:53 menno Exp $
+** $Id: sbr_syntax.c,v 1.24 2004/01/20 18:42:51 menno Exp $
 **/
 
 #include "common.h"
@@ -40,7 +40,7 @@
 #ifdef PS_DEC
 #include "ps_dec.h"
 #endif
-#ifdef DRM
+#ifdef DRM_PS
 #include "drm_dec.h"
 #endif
 #include "analysis.h"
@@ -695,7 +695,7 @@
     case EXTENSION_ID_PS:
         return ps_data(&(sbr->ps), ld);
 #endif
-#ifdef DRM
+#ifdef DRM_PS
     case DRM_PARAMETRIC_STEREO:
         return drm_ps_data(&(sbr->drm_ps), ld);
 #endif