ref: d6839757dffdf592ae300726a64e0f3199a9cd56
parent: d192652be0d3eb46ef2c96c073ef183fef1eb063
author: menno <menno>
date: Tue Apr 23 17:08:26 EDT 2002
More updates for SBR
--- a/libfaad/mdct.c
+++ b/libfaad/mdct.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: mdct.c,v 1.8 2002/04/21 09:00:40 menno Exp $
+** $Id: mdct.c,v 1.9 2002/04/23 21:08:26 menno Exp $
**/
/*
@@ -57,8 +57,8 @@
mdct->N = N;
mdct->sincos = (faad_sincos*)malloc(N/4*sizeof(faad_sincos));
- mdct->Z1 = (complex_t*)malloc(N/4*sizeof(complex_t));
- mdct->Z2 = (complex_t*)malloc(N/4*sizeof(complex_t));
+ mdct->Z1 = (fftw_complex*)malloc(N/4*sizeof(fftw_complex));
+ mdct->Z2 = (fftw_complex*)malloc(N/4*sizeof(fftw_complex));
for (k = 0; k < N/4; k++)
{
@@ -89,8 +89,8 @@
{
uint16_t k;
- complex_t *Z1 = mdct->Z1;
- complex_t *Z2 = mdct->Z2;
+ fftw_complex *Z1 = mdct->Z1;
+ fftw_complex *Z2 = mdct->Z2;
faad_sincos *sincos = mdct->sincos;
uint16_t N = mdct->N;
@@ -142,8 +142,8 @@
{
uint16_t k;
- complex_t *Z1 = mdct->Z1;
- complex_t *Z2 = mdct->Z2;
+ fftw_complex *Z1 = mdct->Z1;
+ fftw_complex *Z2 = mdct->Z2;
faad_sincos *sincos = mdct->sincos;
uint16_t N = mdct->N;
--- a/libfaad/mdct.h
+++ b/libfaad/mdct.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: mdct.h,v 1.7 2002/04/21 09:00:40 menno Exp $
+** $Id: mdct.h,v 1.8 2002/04/23 21:08:26 menno Exp $
**/
#ifndef __MDCT_H__
@@ -34,8 +34,8 @@
} faad_sincos;
typedef struct {
- complex_t *Z1;
- complex_t *Z2;
+ fftw_complex *Z1;
+ fftw_complex *Z2;
faad_sincos *sincos;
fftw_plan plan_backward;
#ifdef LTP_DEC
--- a/libfaad/sbr_dec.c
+++ b/libfaad/sbr_dec.c
@@ -16,8 +16,39 @@
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
**
-** $Id: sbr_dec.c,v 1.2 2002/04/21 09:00:40 menno Exp $
+** $Id: sbr_dec.c,v 1.3 2002/04/23 21:08:26 menno Exp $
**/
+
+/*
+ SBR Decoder overview:
+
+ To achieve a synchronized output signal, the following steps have to be
+ acknowledged in the decoder:
+ - The bitstream parser divides the bitstream into two parts; the AAC
+ core coder part and the SBR part.
+ - The SBR bitstream part is fed to the bitstream de-multiplexer followed
+ by de-quantization The raw data is Huffman decoded.
+ - The AAC bitstream part is fed to the AAC core decoder, where the
+ bitstream data of the current frame is decoded, yielding a time domain
+ audio signal block of 1024 samples. The block length could easily be
+ adapted to other sizes e.g. 960.
+ - The core coder audio block is fed to the analysis QMF bank using a
+ delay of 1312 samples.
+ - The analysis QMF bank performs the filtering of the delayed core coder
+ audio signal. The output from the filtering is stored in the matrix
+ Xlow. The output from the analysis QMF bank is delayed tHFGen subband
+ samples, before being fed to the synthesis QMF bank. To achieve
+ synchronization tHFGen = 32, i.e. the value must equal the number of
+ subband samples corresponding to one frame.
+ - The HF generator calculates XHigh given the matrix XLow. The process
+ is guided by the SBR data contained in the current frame.
+ - The envelope adjuster calculates the matrix Y given the matrix XHigh
+ and the SBR envelope data, extracted from the SBR bitstream. To
+ achieve synchronization, tHFAdj has to be set to tHFAdj = 0, i.e. the
+ envelope adjuster operates on data delayed tHFGen subband samples.
+ - The synthesis QMF bank operates on the delayed output from the analysis
+ QMF bank and the output from the envelope adjuster.
+ */
#include "common.h"
--- a/libfaad/sbr_huff.c
+++ b/libfaad/sbr_huff.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: sbr_huff.c,v 1.2 2002/04/21 09:00:40 menno Exp $
+** $Id: sbr_huff.c,v 1.3 2002/04/23 21:08:26 menno Exp $
**/
#include "common.h"
@@ -24,6 +24,650 @@
#ifdef SBR
#include "bits.h"
+#include "sbr_huff.h"
+
+/* huffman tables all have some offset LAV */
+uint16_t sbr_huff_dec(bitfile *ld, sbr_huff_tab *t_huff)
+{
+}
+
+
+sbr_huff_tab t_huffman_env_1_5dB[] = {
+{ /* */ 0, 60},
+{ /* */ 1, 59},
+{ /* */ 4, 61},
+{ /* */ 5, 58},
+{ /* */ 12, 62},
+{ /* */ 13, 57},
+{ /* */ 28, 63},
+{ /* */ 29, 56},
+{ /* */ 60, 64},
+{ /* */ 61, 55},
+{ /* */ 124, 65},
+{ /* */ 125, 54},
+{ /* */ 252, 66},
+{ /* */ 253, 53},
+{ /* */ 508, 67},
+{ /* */ 509, 52},
+{ /* */ 1020, 51},
+{ /* */ 1021, 68},
+{ /* */ 2044, 50},
+{ /* */ 4090, 69},
+{ /* */ 4091, 49},
+{ /* */ 8184, 70},
+{ /* */ 8185, 48},
+{ /* */ 8186, 47},
+{ /* */ 16374, 71},
+{ /* */ 16375, 46},
+{ /* */ 16376, 72},
+{ /* */ 16377, 45},
+{ /* */ 32756, 44},
+{ /* */ 32757, 73},
+{ /* */ 65516, 41},
+{ /* */ 65517, 42},
+{ /* */ 65518, 43},
+{ /* */ 65519, 74},
+{ /* */ 65520, 36},
+{ /* */ 65521, 40},
+{ /* */ 65522, 76},
+{ /* */ 131046, 34},
+{ /* */ 131047, 39},
+{ /* */ 131048, 75},
+{ /* */ 131049, 37},
+{ /* */ 262100, 35},
+{ /* */ 262101, 38},
+{ /* */ 262102, 0},
+{ /* */ 262103, 1},
+{ /* */ 262104, 2},
+{ /* */ 262105, 3},
+{ /* */ 262106, 4},
+{ /* */ 262107, 5},
+{ /* */ 524216, 6},
+{ /* */ 524217, 7},
+{ /* */ 524218, 8},
+{ /* */ 524219, 9},
+{ /* */ 524220, 10},
+{ /* */ 524221, 11},
+{ /* */ 524222, 12},
+{ /* */ 524223, 13},
+{ /* */ 524224, 14},
+{ /* */ 524225, 15},
+{ /* */ 524226, 16},
+{ /* */ 524227, 17},
+{ /* */ 524228, 18},
+{ /* */ 524229, 19},
+{ /* */ 524230, 20},
+{ /* */ 524231, 21},
+{ /* */ 524232, 22},
+{ /* */ 524233, 23},
+{ /* */ 524234, 24},
+{ /* */ 524235, 25},
+{ /* */ 524236, 26},
+{ /* */ 524237, 27},
+{ /* */ 524238, 28},
+{ /* */ 524239, 29},
+{ /* */ 524240, 30},
+{ /* */ 524241, 31},
+{ /* */ 524242, 32},
+{ /* */ 524243, 33},
+{ /* */ 524244, 77},
+{ /* */ 524245, 78},
+{ /* */ 524246, 79},
+{ /* */ 524247, 80},
+{ /* */ 524248, 81},
+{ /* */ 524249, 82},
+{ /* */ 524250, 83},
+{ /* */ 524251, 84},
+{ /* */ 524252, 85},
+{ /* */ 524253, 86},
+{ /* */ 524254, 87},
+{ /* */ 524255, 88},
+{ /* */ 524256, 89},
+{ /* */ 524257, 90},
+{ /* */ 524258, 91},
+{ /* */ 524259, 92},
+{ /* */ 524260, 93},
+{ /* */ 524261, 94},
+{ /* */ 524262, 95},
+{ /* */ 524263, 96},
+{ /* */ 524264, 97},
+{ /* */ 524265, 98},
+{ /* */ 524266, 99},
+{ /* */ 524267, 100},
+{ /* */ 524268, 101},
+{ /* */ 524269, 102},
+{ /* */ 524270, 103},
+{ /* */ 524271, 104},
+{ /* */ 524272, 105},
+{ /* */ 524273, 106},
+{ /* */ 524274, 107},
+{ /* */ 524275, 108},
+{ /* */ 524276, 109},
+{ /* */ 524277, 110},
+{ /* */ 524278, 111},
+{ /* */ 524279, 112},
+{ /* */ 524280, 113},
+{ /* */ 524281, 114},
+{ /* */ 524282, 115},
+{ /* */ 524283, 116},
+{ /* */ 524284, 117},
+{ /* */ 524285, 118},
+{ /* */ 524286, 119},
+{ /* */ 524287, 120}
+};
+
+sbr_huff_tab f_huffman_env_1_5dB[] = {
+{ /* */ 0, 60},
+{ /* */ 1, 59},
+{ /* */ 4, 61},
+{ /* */ 5, 58},
+{ /* */ 12, 57},
+{ /* */ 13, 62},
+{ /* */ 28, 56},
+{ /* */ 29, 63},
+{ /* */ 60, 55},
+{ /* */ 61, 64},
+{ /* */ 124, 54},
+{ /* */ 250, 65},
+{ /* */ 251, 53},
+{ /* */ 252, 66},
+{ /* */ 506, 52},
+{ /* */ 507, 67},
+{ /* */ 508, 51},
+{ /* */ 1018, 68},
+{ /* */ 1019, 50},
+{ /* */ 2040, 69},
+{ /* */ 2041, 49},
+{ /* */ 2042, 70},
+{ /* */ 2043, 71},
+{ /* */ 4088, 48},
+{ /* */ 4089, 72},
+{ /* */ 4090, 47},
+{ /* */ 4091, 73},
+{ /* */ 8184, 74},
+{ /* */ 8185, 46},
+{ /* */ 8186, 45},
+{ /* */ 8187, 75},
+{ /* */ 16376, 76},
+{ /* */ 16377, 77},
+{ /* */ 16378, 44},
+{ /* */ 32758, 43},
+{ /* */ 32759, 42},
+{ /* */ 65520, 41},
+{ /* */ 65521, 78},
+{ /* */ 65522, 79},
+{ /* */ 65523, 40},
+{ /* */ 65524, 39},
+{ /* */ 131050, 80},
+{ /* */ 131051, 81},
+{ /* */ 131052, 36},
+{ /* */ 131053, 37},
+{ /* */ 131054, 38},
+{ /* */ 131055, 34},
+{ /* */ 262112, 32},
+{ /* */ 262113, 82},
+{ /* */ 262114, 83},
+{ /* */ 262115, 85},
+{ /* */ 262116, 19},
+{ /* */ 262117, 35},
+{ /* */ 262118, 86},
+{ /* */ 262119, 87},
+{ /* */ 262120, 30},
+{ /* */ 262121, 33},
+{ /* */ 262122, 84},
+{ /* */ 262123, 88},
+{ /* */ 262124, 104},
+{ /* */ 524250, 9},
+{ /* */ 524251, 14},
+{ /* */ 524252, 16},
+{ /* */ 524253, 17},
+{ /* */ 524254, 23},
+{ /* */ 524255, 27},
+{ /* */ 524256, 29},
+{ /* */ 524257, 31},
+{ /* */ 524258, 90},
+{ /* */ 524259, 97},
+{ /* */ 524260, 102},
+{ /* */ 524261, 107},
+{ /* */ 524262, 108},
+{ /* */ 524263, 0},
+{ /* */ 524264, 1},
+{ /* */ 1048530, 2},
+{ /* */ 1048531, 3},
+{ /* */ 1048532, 4},
+{ /* */ 1048533, 5},
+{ /* */ 1048534, 6},
+{ /* */ 1048535, 7},
+{ /* */ 1048536, 8},
+{ /* */ 1048537, 10},
+{ /* */ 1048538, 11},
+{ /* */ 1048539, 12},
+{ /* */ 1048540, 13},
+{ /* */ 1048541, 15},
+{ /* */ 1048542, 18},
+{ /* */ 1048543, 20},
+{ /* */ 1048544, 21},
+{ /* */ 1048545, 22},
+{ /* */ 1048546, 24},
+{ /* */ 1048547, 25},
+{ /* */ 1048548, 26},
+{ /* */ 1048549, 28},
+{ /* */ 1048550, 89},
+{ /* */ 1048551, 91},
+{ /* */ 1048552, 92},
+{ /* */ 1048553, 93},
+{ /* */ 1048554, 94},
+{ /* */ 1048555, 95},
+{ /* */ 1048556, 96},
+{ /* */ 1048557, 98},
+{ /* */ 1048558, 99},
+{ /* */ 1048559, 100},
+{ /* */ 1048560, 101},
+{ /* */ 1048561, 103},
+{ /* */ 1048562, 105},
+{ /* */ 1048563, 106},
+{ /* */ 1048564, 109},
+{ /* */ 1048565, 110},
+{ /* */ 1048566, 111},
+{ /* */ 1048567, 112},
+{ /* */ 1048568, 113},
+{ /* */ 1048569, 114},
+{ /* */ 1048570, 115},
+{ /* */ 1048571, 116},
+{ /* */ 1048572, 117},
+{ /* */ 1048573, 118},
+{ /* */ 1048574, 119},
+{ /* */ 1048575, 120}
+};
+
+sbr_huff_tab t_huffman_env_bal_1_5dB[] = {
+{ /* */ 0, 24},
+{ /* */ 2, 25},
+{ /* */ 6, 23},
+{ /* */ 14, 26},
+{ /* */ 30, 22},
+{ /* */ 62, 27},
+{ /* */ 126, 21},
+{ /* */ 254, 28},
+{ /* */ 510, 20},
+{ /* */ 2044, 19},
+{ /* */ 2045, 29},
+{ /* */ 4092, 18},
+{ /* */ 4093, 30},
+{ /* */ 32752, 31},
+{ /* */ 65506, 17},
+{ /* */ 65507, 32},
+{ /* */ 65508, 0},
+{ /* */ 65509, 1},
+{ /* */ 65510, 2},
+{ /* */ 65511, 3},
+{ /* */ 65512, 4},
+{ /* */ 65513, 5},
+{ /* */ 65514, 6},
+{ /* */ 65515, 7},
+{ /* */ 65516, 8},
+{ /* */ 65517, 9},
+{ /* */ 65518, 10},
+{ /* */ 65519, 11},
+{ /* */ 65520, 12},
+{ /* */ 65521, 13},
+{ /* */ 65522, 14},
+{ /* */ 65523, 15},
+{ /* */ 65524, 16},
+{ /* */ 65525, 33},
+{ /* */ 65526, 34},
+{ /* */ 65527, 35},
+{ /* */ 65528, 36},
+{ /* */ 65529, 37},
+{ /* */ 65530, 38},
+{ /* */ 131062, 39},
+{ /* */ 131063, 40},
+{ /* */ 131064, 41},
+{ /* */ 131065, 42},
+{ /* */ 131066, 43},
+{ /* */ 131067, 44},
+{ /* */ 131068, 45},
+{ /* */ 131069, 46},
+{ /* */ 131070, 47},
+{ /* */ 131071, 48}
+};
+
+sbr_huff_tab f_huffman_env_bal_1_5dB[] = {
+{ /* */ 0, 24},
+{ /* */ 2, 23},
+{ /* */ 6, 25},
+{ /* */ 14, 22},
+{ /* */ 30, 26},
+{ /* */ 62, 27},
+{ /* */ 115, 21},
+{ /* */ 243, 20},
+{ /* */ 510, 28},
+{ /* */ 2044, 19},
+{ /* */ 2045, 29},
+{ /* */ 2046, 18},
+{ /* */ 4094, 30},
+{ /* */ 16380, 17},
+{ /* */ 32762, 31},
+{ /* */ 65526, 32},
+{ /* */ 65527, 15},
+{ /* */ 131056, 16},
+{ /* */ 262114, 0},
+{ /* */ 262115, 1},
+{ /* */ 262116, 2},
+{ /* */ 262117, 3},
+{ /* */ 262118, 4},
+{ /* */ 262119, 5},
+{ /* */ 262120, 6},
+{ /* */ 262121, 7},
+{ /* */ 262122, 8},
+{ /* */ 262123, 9},
+{ /* */ 262124, 10},
+{ /* */ 262125, 11},
+{ /* */ 262126, 12},
+{ /* */ 262127, 13},
+{ /* */ 262128, 14},
+{ /* */ 262129, 33},
+{ /* */ 262130, 34},
+{ /* */ 262131, 35},
+{ /* */ 262132, 36},
+{ /* */ 262133, 37},
+{ /* */ 262134, 38},
+{ /* */ 262135, 39},
+{ /* */ 262136, 40},
+{ /* */ 262137, 41},
+{ /* */ 262138, 42},
+{ /* */ 262139, 43},
+{ /* */ 262140, 44},
+{ /* */ 262141, 45},
+{ /* */ 262142, 46},
+{ /* */ 524286, 47},
+{ /* */ 524287, 48}
+};
+
+sbr_huff_tab t_huffman_env_3_0dB[] = {
+{ /* */ 0, 31},
+{ /* */ 2, 30},
+{ /* */ 6, 32},
+{ /* */ 14, 29},
+{ /* */ 30, 33},
+{ /* */ 62, 28},
+{ /* */ 126, 34},
+{ /* */ 254, 27},
+{ /* */ 510, 35},
+{ /* */ 2044, 26},
+{ /* */ 2045, 36},
+{ /* */ 4092, 25},
+{ /* */ 8186, 24},
+{ /* */ 8187, 37},
+{ /* */ 16376, 23},
+{ /* */ 16377, 38},
+{ /* */ 16378, 22},
+{ /* */ 16379, 21},
+{ /* */ 16380, 39},
+{ /* */ 32762, 40},
+{ /* */ 65526, 41},
+{ /* */ 65527, 18},
+{ /* */ 65528, 20},
+{ /* */ 65529, 19},
+{ /* */ 131060, 17},
+{ /* */ 131061, 42},
+{ /* */ 262124, 43},
+{ /* */ 262125, 0},
+{ /* */ 262126, 1},
+{ /* */ 524254, 2},
+{ /* */ 524255, 3},
+{ /* */ 524256, 4},
+{ /* */ 524257, 5},
+{ /* */ 524258, 6},
+{ /* */ 524259, 7},
+{ /* */ 524260, 8},
+{ /* */ 524261, 9},
+{ /* */ 524262, 10},
+{ /* */ 524263, 11},
+{ /* */ 524264, 12},
+{ /* */ 524265, 13},
+{ /* */ 524266, 14},
+{ /* */ 524267, 15},
+{ /* */ 524268, 16},
+{ /* */ 524269, 44},
+{ /* */ 524270, 45},
+{ /* */ 524271, 46},
+{ /* */ 524272, 47},
+{ /* */ 524273, 48},
+{ /* */ 524274, 49},
+{ /* */ 524275, 50},
+{ /* */ 524276, 51},
+{ /* */ 524277, 52},
+{ /* */ 524278, 53},
+{ /* */ 524279, 54},
+{ /* */ 524280, 55},
+{ /* */ 524281, 56},
+{ /* */ 524282, 57},
+{ /* */ 524283, 58},
+{ /* */ 524284, 59},
+{ /* */ 524285, 60},
+{ /* */ 524286, 61},
+{ /* */ 524287, 62}
+};
+
+sbr_huff_tab f_huffman_env_3_0dB[] = {
+{ /* */ 0, 31},
+{ /* */ 2, 30},
+{ /* */ 6, 32},
+{ /* */ 14, 29},
+{ /* */ 30, 33},
+{ /* */ 62, 28},
+{ /* */ 252, 34},
+{ /* */ 253, 27},
+{ /* */ 508, 35},
+{ /* */ 509, 26},
+{ /* */ 1020, 36},
+{ /* */ 1021, 25},
+{ /* */ 2044, 37},
+{ /* */ 2045, 24},
+{ /* */ 4092, 38},
+{ /* */ 4093, 23},
+{ /* */ 8188, 39},
+{ /* */ 16378, 40},
+{ /* */ 16379, 22},
+{ /* */ 32760, 21},
+{ /* */ 32761, 41},
+{ /* */ 32762, 42},
+{ /* */ 65526, 20},
+{ /* */ 65527, 19},
+{ /* */ 65528, 43},
+{ /* */ 65529, 44},
+{ /* */ 131060, 18},
+{ /* */ 131061, 16},
+{ /* */ 131062, 45},
+{ /* */ 131063, 46},
+{ /* */ 262128, 17},
+{ /* */ 262129, 49},
+{ /* */ 262130, 13},
+{ /* */ 262131, 7},
+{ /* */ 262132, 12},
+{ /* */ 262133, 47},
+{ /* */ 262134, 48},
+{ /* */ 524270, 9},
+{ /* */ 524271, 10},
+{ /* */ 524272, 15},
+{ /* */ 524273, 51},
+{ /* */ 524274, 52},
+{ /* */ 524275, 53},
+{ /* */ 524276, 56},
+{ /* */ 524277, 8},
+{ /* */ 524278, 11},
+{ /* */ 524279, 55},
+{ /* */ 1048560, 0},
+{ /* */ 1048561, 1},
+{ /* */ 1048562, 2},
+{ /* */ 1048563, 3},
+{ /* */ 1048564, 4},
+{ /* */ 1048565, 5},
+{ /* */ 1048566, 6},
+{ /* */ 1048567, 14},
+{ /* */ 1048568, 50},
+{ /* */ 1048569, 54},
+{ /* */ 1048570, 57},
+{ /* */ 1048571, 58},
+{ /* */ 1048572, 59},
+{ /* */ 1048573, 60},
+{ /* */ 1048574, 61},
+{ /* */ 1048575, 62}
+};
+
+sbr_huff_tab t_huffman_env_bal_3_0dB[] = {
+{ /* */ 0, 12},
+{ /* */ 2, 13},
+{ /* */ 6, 11},
+{ /* */ 14, 10},
+{ /* */ 30, 14},
+{ /* */ 62, 15},
+{ /* */ 126, 9},
+{ /* */ 254, 8},
+{ /* */ 510, 16},
+{ /* */ 4088, 7},
+{ /* */ 8178, 0},
+{ /* */ 8179, 1},
+{ /* */ 8180, 2},
+{ /* */ 8181, 3},
+{ /* */ 8182, 4},
+{ /* */ 8183, 5},
+{ /* */ 8184, 6},
+{ /* */ 8185, 17},
+{ /* */ 8186, 18},
+{ /* */ 8187, 19},
+{ /* */ 8188, 20},
+{ /* */ 8189, 21},
+{ /* */ 8190, 22},
+{ /* */ 16382, 23},
+{ /* */ 16383, 24}
+};
+
+sbr_huff_tab f_huffman_env_bal_3_0dB[] = {
+{ /* */ 0, 12},
+{ /* */ 2, 11},
+{ /* */ 6, 13},
+{ /* */ 14, 10},
+{ /* */ 30, 14},
+{ /* */ 62, 15},
+{ /* */ 126, 9},
+{ /* */ 254, 8},
+{ /* */ 510, 16},
+{ /* */ 2044, 7},
+{ /* */ 4090, 17},
+{ /* */ 8182, 18},
+{ /* */ 8183, 0},
+{ /* */ 8184, 1},
+{ /* */ 8185, 2},
+{ /* */ 8186, 3},
+{ /* */ 8187, 4},
+{ /* */ 16376, 5},
+{ /* */ 16377, 6},
+{ /* */ 16378, 19},
+{ /* */ 16379, 20},
+{ /* */ 16380, 21},
+{ /* */ 16381, 22},
+{ /* */ 16382, 23},
+{ /* */ 16383, 24}
+};
+
+sbr_huff_tab t_huffman_noise_3_0dB[] = {
+{ /* */ 0, 31},
+{ /* */ 2, 32},
+{ /* */ 6, 30},
+{ /* */ 14, 29},
+{ /* */ 30, 33},
+{ /* */ 62, 28},
+{ /* */ 252, 34},
+{ /* */ 253, 27},
+{ /* */ 1016, 35},
+{ /* */ 2034, 26},
+{ /* */ 8140, 36},
+{ /* */ 8141, 42},
+{ /* */ 8142, 0},
+{ /* */ 8143, 1},
+{ /* */ 8144, 2},
+{ /* */ 8145, 3},
+{ /* */ 8146, 4},
+{ /* */ 8147, 5},
+{ /* */ 8148, 6},
+{ /* */ 8149, 7},
+{ /* */ 8150, 8},
+{ /* */ 8151, 9},
+{ /* */ 8152, 10},
+{ /* */ 8153, 11},
+{ /* */ 8154, 12},
+{ /* */ 8155, 13},
+{ /* */ 8156, 14},
+{ /* */ 8157, 15},
+{ /* */ 8158, 16},
+{ /* */ 8159, 17},
+{ /* */ 8160, 18},
+{ /* */ 8161, 19},
+{ /* */ 8162, 20},
+{ /* */ 8163, 21},
+{ /* */ 8164, 22},
+{ /* */ 8165, 23},
+{ /* */ 8166, 24},
+{ /* */ 8167, 25},
+{ /* */ 8168, 37},
+{ /* */ 8169, 38},
+{ /* */ 8170, 39},
+{ /* */ 8171, 40},
+{ /* */ 8172, 41},
+{ /* */ 8173, 43},
+{ /* */ 8174, 44},
+{ /* */ 8175, 45},
+{ /* */ 8176, 46},
+{ /* */ 8177, 47},
+{ /* */ 8178, 48},
+{ /* */ 8179, 49},
+{ /* */ 8180, 50},
+{ /* */ 8181, 51},
+{ /* */ 8182, 52},
+{ /* */ 8183, 53},
+{ /* */ 8184, 54},
+{ /* */ 8185, 55},
+{ /* */ 8186, 56},
+{ /* */ 8187, 57},
+{ /* */ 8188, 58},
+{ /* */ 8189, 59},
+{ /* */ 8190, 60},
+{ /* */ 16382, 61},
+{ /* */ 16383, 62}
+};
+
+sbr_huff_tab t_huffman_noise_bal_3_0dB[] = {
+{ /* */ 0, 12},
+{ /* */ 2, 11},
+{ /* */ 6, 13},
+{ /* */ 28, 10},
+{ /* */ 58, 14},
+{ /* */ 236, 0},
+{ /* */ 237, 1},
+{ /* */ 238, 2},
+{ /* */ 239, 3},
+{ /* */ 240, 4},
+{ /* */ 241, 5},
+{ /* */ 242, 6},
+{ /* */ 243, 7},
+{ /* */ 244, 8},
+{ /* */ 245, 9},
+{ /* */ 246, 15},
+{ /* */ 247, 16},
+{ /* */ 248, 17},
+{ /* */ 249, 18},
+{ /* */ 250, 19},
+{ /* */ 251, 20},
+{ /* */ 252, 21},
+{ /* */ 253, 22},
+{ /* */ 254, 23},
+{ /* */ 255, 24}
+};
+
+sbr_huff_tab *f_huffman_noise_3_0dB = t_huffman_noise_3_0dB;
+sbr_huff_tab *f_huffman_noise_bal_3_0dB = t_huffman_noise_bal_3_0dB;
#endif
--- a/libfaad/sbr_huff.h
+++ b/libfaad/sbr_huff.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: sbr_huff.h,v 1.1 2002/04/20 14:45:13 menno Exp $
+** $Id: sbr_huff.h,v 1.2 2002/04/23 21:08:26 menno Exp $
**/
#ifdef SBR
@@ -28,7 +28,27 @@
extern "C" {
#endif
+typedef struct
+{
+ uint32_t codeword;
+ uint16_t index;
+} sbr_huff_tab;
+
+uint16_t sbr_huff_dec(bitfile *ld, sbr_huff_tab *t_huff);
+
+sbr_huff_tab t_huffman_env_1_5dB[];
+sbr_huff_tab f_huffman_env_1_5dB[];
+sbr_huff_tab t_huffman_env_bal_1_5dB[];
+sbr_huff_tab f_huffman_env_bal_1_5dB[];
+sbr_huff_tab t_huffman_env_3_0dB[];
+sbr_huff_tab f_huffman_env_3_0dB[];
+sbr_huff_tab t_huffman_env_bal_3_0dB[];
+sbr_huff_tab f_huffman_env_bal_3_0dB[];
+sbr_huff_tab t_huffman_noise_3_0dB[];
+sbr_huff_tab *f_huffman_noise_3_0dB;
+sbr_huff_tab t_huffman_noise_bal_3_0dB[];
+sbr_huff_tab *f_huffman_noise_bal_3_0dB;
#ifdef __cplusplus
}
--- a/libfaad/sbr_syntax.c
+++ b/libfaad/sbr_syntax.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: sbr_syntax.c,v 1.3 2002/04/21 09:00:40 menno Exp $
+** $Id: sbr_syntax.c,v 1.4 2002/04/23 21:08:26 menno Exp $
**/
/*
@@ -328,6 +328,7 @@
static void sbr_grid(bitfile *ld, sbr_info *sbr, uint8_t ch)
{
uint8_t i, env, rel;
+ uint8_t bs_abs_bord, bs_abs_bord_1;
sbr->bs_frame_class = faad_getbits(ld, 2
DEBUGVAR(1,248,"sbr_grid(): bs_frame_class"));
@@ -346,10 +347,13 @@
DEBUGVAR(1,250,"sbr_grid(): bs_freq_res_flag"));
for (env = 0; env < sbr->bs_num_env[ch]; env++)
sbr->bs_freq_res[ch][env] = i;
+
+ sbr->abs_bord_lead[ch] = 0;
+ sbr->abs_bord_trail[ch] = NO_TIME_SLOTS;
break;
case FIXVAR:
- sbr->bs_abs_bord[ch] = faad_getbits(ld, 3
+ bs_abs_bord = faad_getbits(ld, 3
DEBUGVAR(1,251,"sbr_grid(): bs_abs_bord")) + NO_TIME_SLOTS;
sbr->bs_num_env[ch] = faad_getbits(ld, 2
DEBUGVAR(1,252,"sbr_grid(): bs_num_env")) + 1;
@@ -368,10 +372,13 @@
sbr->bs_freq_res[ch][sbr->bs_num_env[ch] - env - 1] = faad_get1bit(ld
DEBUGVAR(1,255,"sbr_grid(): bs_freq_res"));
}
+
+ sbr->abs_bord_lead[ch] = 0;
+ sbr->abs_bord_trail[ch] = bs_abs_bord;
break;
case VARFIX:
- sbr->bs_abs_bord[ch] = faad_getbits(ld, 3
+ bs_abs_bord = faad_getbits(ld, 3
DEBUGVAR(1,256,"sbr_grid(): bs_abs_bord"));
sbr->bs_num_env[ch] = faad_getbits(ld, 2
DEBUGVAR(1,257,"sbr_grid(): bs_num_env")) + 1;
@@ -390,12 +397,15 @@
sbr->bs_freq_res[ch][env] = faad_get1bit(ld
DEBUGVAR(1,260,"sbr_grid(): bs_freq_res"));
}
+
+ sbr->abs_bord_lead[ch] = bs_abs_bord;
+ sbr->abs_bord_trail[ch] = NO_TIME_SLOTS;
break;
case VARVAR:
- sbr->bs_abs_bord_0[ch] = faad_getbits(ld, 3
+ bs_abs_bord = faad_getbits(ld, 3
DEBUGVAR(1,261,"sbr_grid(): bs_abs_bord_0"));
- sbr->bs_abs_bord_1[ch] = faad_getbits(ld, 3
+ bs_abs_bord_1 = faad_getbits(ld, 3
DEBUGVAR(1,262,"sbr_grid(): bs_abs_bord_1")) + NO_TIME_SLOTS;
sbr->bs_num_rel_0[ch] = faad_getbits(ld, 2
DEBUGVAR(1,263,"sbr_grid(): bs_num_rel_0"));
@@ -422,6 +432,9 @@
sbr->bs_freq_res[ch][env] = faad_get1bit(ld
DEBUGVAR(1,268,"sbr_grid(): bs_freq_res"));
}
+
+ sbr->abs_bord_lead[ch] = bs_abs_bord;
+ sbr->abs_bord_trail[ch] = bs_abs_bord_1;
break;
}
@@ -461,10 +474,12 @@
}
}
-#if 0
/* table 10 */
static void sbr_envelope(bitfile *ld, sbr_info *sbr, uint8_t ch)
{
+ uint8_t env, band;
+ sbr_huff_tab *t_huff, *f_huff;
+
if (sbr->bs_coupling)
{
if (ch)
@@ -513,7 +528,7 @@
DEBUGVAR(1,273,"sbr_envelope(): bs_data_env"));
}
} else {
- if (bs_amp_res)
+ if (sbr->bs_amp_res)
{
sbr->bs_data_env[ch][env][0] = faad_getbits(ld, 6
DEBUGVAR(1,274,"sbr_envelope(): bs_data_env"));
@@ -521,14 +536,14 @@
sbr->bs_data_env[ch][env][0] = faad_getbits(ld, 7
DEBUGVAR(1,275,"sbr_envelope(): bs_data_env"));
}
- for (band = 1; band < sbr->num_env_bands[bs_freq_res[ch][env]]; band++)
+ for (band = 1; band < sbr->num_env_bands[sbr->bs_freq_res[ch][env]]; band++)
{
- sbr->bs_data_env[ch][env][band] = huff_dec(ld, f_huff, bs_codeword);
+ sbr->bs_data_env[ch][env][band] = sbr_huff_dec(ld, f_huff);
}
}
} else {
- for (band = 0; band < sbr->num_env_bands[bs_freq_res[ch][env]]; band++)
- sbr->bs_data_env[ch][env][band] = huff_dec(ld, t_huff, bs_codeword);
+ for (band = 0; band < sbr->num_env_bands[sbr->bs_freq_res[ch][env]]; band++)
+ sbr->bs_data_env[ch][env][band] = sbr_huff_dec(ld, t_huff);
}
}
}
@@ -536,6 +551,9 @@
/* table 11 */
static void sbr_noise(bitfile *ld, sbr_info *sbr, uint8_t ch)
{
+ uint8_t noise, band;
+ sbr_huff_tab *t_huff, *f_huff;
+
if (sbr->bs_coupling)
{
if (ch) {
@@ -564,17 +582,16 @@
}
for (band = 1; band < sbr->num_noise_bands[ch]; band++)
{
- sbr->bs_data_noise[ch][noise][band] = huff_dec(ld, f_huff, bs_codeword);
+ sbr->bs_data_noise[ch][noise][band] = sbr_huff_dec(ld, f_huff);
}
} else {
for (band = 0; band < sbr->num_noise_bands[ch]; band++)
{
- sbr->bs_data_noise[ch][noise][band] = huff_dec(ld, t_huff, bs_codeword);
+ sbr->bs_data_noise[ch][noise][band] = sbr_huff_dec(ld, t_huff);
}
}
}
}
-#endif
/* table 12 */
static void sinusoidal_coding(bitfile *ld, sbr_info *sbr, uint8_t ch)
--- a/libfaad/sbr_syntax.h
+++ b/libfaad/sbr_syntax.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: sbr_syntax.h,v 1.2 2002/04/20 22:20:15 menno Exp $
+** $Id: sbr_syntax.h,v 1.3 2002/04/23 21:08:26 menno Exp $
**/
#ifdef SBR
@@ -43,6 +43,15 @@
typedef struct
{
+ /* really used */
+ uint8_t abs_bord_lead[2];
+ uint8_t abs_bord_trail[2];
+
+
+ /* to get it compiling */
+ /* we'll see during the coding of all the tools, whether
+ these are all used or not.
+ */
uint8_t bs_crc_flag;
uint8_t bs_sbr_crc_bits;
uint8_t bs_protocol_version;
@@ -65,7 +74,6 @@
uint8_t bs_frame_class;
uint8_t bs_num_env[2];
uint8_t bs_freq_res[2][6];
- uint8_t bs_abs_bord[2];
uint8_t bs_rel_bord[2][9];
uint8_t bs_rel_bord_0[2][9];
uint8_t bs_rel_bord_1[2][9];
@@ -81,6 +89,9 @@
uint8_t bs_invf_mode_vec[2][/*??*/10];
uint8_t num_high_res[2];
uint8_t bs_add_harmonic[2][/*??*/10];
+ uint16_t bs_data_env[2][/*??*/10][/*??*/10];
+ uint16_t bs_data_noise[2][/*??*/10][/*??*/10];
+ uint8_t num_env_bands[2];
} sbr_info;
uint8_t sbr_bitstream(bitfile *ld, sbr_info *sbr, uint8_t id_aac,