ref: b823b1ec32373b28794aa01cca69ea9c472ec20a
parent: a620eaf54c2d009298287d41158bfeb9745ee8f9
author: menno <menno>
date: Wed Feb 4 14:55:03 EST 2004
fixed stupid wrong huffman table
--- 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-2004 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003 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,31 +22,252 @@
** 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.4 2004/01/20 18:42:51 menno Exp $
+** $Id: hcb_sf.h,v 1.5 2004/02/04 19:55:02 menno Exp $
**/
/* Binary search huffman table HCB_SF */
-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 }
+
+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 }
};
--- 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.17 2004/01/28 19:17:25 menno Exp $
+** $Id: huffman.c,v 1.18 2004/02/04 19:55:02 menno Exp $
**/
#include "common.h"
@@ -53,16 +53,22 @@
int8_t huffman_scale_factor(bitfile *ld)
{
- uint8_t bit;
- int16_t index = 0;
+ uint16_t offset = 0;
- while (index >= 0)
+ while (hcb_sf[offset][1])
{
- bit = (uint8_t)faad_get1bit(ld);
- index = hcb_sf[index][bit];
+ 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;
+ }
}
- return index + 61;
+ return hcb_sf[offset][0];
}
--- a/libfaad/syntax.c
+++ b/libfaad/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: syntax.c,v 1.70 2004/01/29 11:31:11 menno Exp $
+** $Id: syntax.c,v 1.71 2004/02/04 19:55:03 menno Exp $
**/
/*
@@ -1141,6 +1141,8 @@
else
cpe.ele_id = ID_SCE;
+ hDecoder->element_output_channels[hDecoder->fr_ch_ele] = (this_layer_stereo ? 2 : 0);
+
for (ch = 0; ch < (this_layer_stereo ? 2 : 1); ch++)
{
ic_stream *ics;
@@ -1153,8 +1155,6 @@
spec_data = spec_data2;
}
- hDecoder->internal_channel[channels+ch] = channels+ch;
-
hInfo->error = individual_channel_stream(hDecoder, &cpe, ld, ics, 1, spec_data);
if (hInfo->error > 0)
return;
@@ -1240,9 +1240,19 @@
return;
}
+ /* map output channels position to internal data channels */
+ if (hDecoder->element_output_channels[hDecoder->fr_ch_ele] == 2)
+ {
+ /* this might be faulty when pce_set is true */
+ hDecoder->internal_channel[channels] = channels;
+ hDecoder->internal_channel[channels+1] = channels+1;
+ } else {
+ hDecoder->internal_channel[channels] = channels;
+ }
+
hDecoder->element_id[hDecoder->fr_ch_ele] = cpe.ele_id;
- hDecoder->fr_channels += (this_layer_stereo ? 2 : 1);
+ hDecoder->fr_channels += hDecoder->element_output_channels[hDecoder->fr_ch_ele];
hDecoder->fr_ch_ele++;
return;
@@ -1637,7 +1647,7 @@
/* decode intensity position */
t = huffman_scale_factor(ld);
- is_position += t;
+ is_position += (t - 60);
ics->scale_factors[g][sfb] = is_position;
break;
@@ -1651,6 +1661,7 @@
DEBUGVAR(1,73,"scale_factor_data(): first noise")) - 256;
} else {
t = huffman_scale_factor(ld);
+ t -= 60;
}
noise_energy += t;
ics->scale_factors[g][sfb] = noise_energy;
@@ -1664,7 +1675,7 @@
/* decode scale factor */
t = huffman_scale_factor(ld);
- scale_factor += t;
+ scale_factor += (t - 60);
if (scale_factor < 0 || scale_factor > 255)
return 4;
ics->scale_factors[g][sfb] = scale_factor;