ref: 6e334f585508b2e4f92f331f4553a6dae93820a9
parent: f0add29e73e7aa143b43f562f46218d598c254cb
author: menno <menno>
date: Thu Nov 28 13:48:30 EST 2002
First start at SSR Cleanup of syntax.c
--- a/libfaad/Makefile.am
+++ b/libfaad/Makefile.am
@@ -6,8 +6,8 @@
libfaad_la_SOURCES = bits.c cfft.c data.c decoder.c dither.c drc.c \
error.c filtbank.c \
ic_predict.c is.c lt_predict.c mdct.c mp4.c ms.c output.c pns.c \
-pulse.c specrec.c syntax.c tns.c reordered_spectral_data.c \
-rvlc_scale_factors.c \
+pulse.c specrec.c syntax.c tns.c hcr.c \
+rvlc.c ssr.c \
hcb_1.c hcb_2.c hcb_3.c hcb_4.c hcb_5.c hcb_6.c hcb_7.c hcb_8.c \
hcb_9.c hcb_10.c hcb_11.c hcb_sf.c
@@ -14,7 +14,7 @@
libfaad_la_INCLUDES = analysis.h bits.h cfft.h data.h decoder.h dither.h \
drc.h error.h \
filtbank.h huffman.h ic_predict.h is.h kbd_win.h lt_predict.h mdct.h mp4.h \
-ms.h output.h pns.h pulse.h rvlc_scale_factors.h \
+ms.h output.h pns.h pulse.h rvlc.h ssr.h \
specrec.h syntax.h tns.h codebook/hcb.h
CFLAGS = -O2
--- a/libfaad/bits.c
+++ b/libfaad/bits.c
@@ -16,37 +16,50 @@
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
**
-** $Id: bits.c,v 1.16 2002/11/08 13:12:32 menno Exp $
+** $Id: bits.c,v 1.17 2002/11/28 18:48:29 menno Exp $
**/
#include "common.h"
+#include "structs.h"
+
#include <stdlib.h>
+#include <string.h>
#include "bits.h"
/* initialize buffer, call once before first getbits or showbits */
-void faad_initbits(bitfile *ld, void *buffer, uint32_t buffer_size)
+void faad_initbits(bitfile *ld, void *_buffer, uint32_t buffer_size)
{
uint32_t tmp;
+ ld->buffer = malloc((buffer_size+12)*sizeof(uint8_t));
+ memset(ld->buffer, 0, (buffer_size+12)*sizeof(uint8_t));
+ memcpy(ld->buffer, _buffer, buffer_size*sizeof(uint8_t));
+
ld->buffer_size = buffer_size;
- tmp = getdword((uint32_t*)buffer);
+ tmp = getdword((uint32_t*)ld->buffer);
#ifndef ARCH_IS_BIG_ENDIAN
BSWAP(tmp);
#endif
ld->bufa = tmp;
- tmp = getdword((uint32_t*)buffer + 1);
+ tmp = getdword((uint32_t*)ld->buffer + 1);
#ifndef ARCH_IS_BIG_ENDIAN
BSWAP(tmp);
#endif
ld->bufb = tmp;
- ld->start = (uint32_t*)buffer;
- ld->tail = ((uint32_t*)buffer + 2);
+ ld->start = (uint32_t*)ld->buffer;
+ ld->tail = ((uint32_t*)ld->buffer + 2);
ld->bits_left = 32;
}
+
+void faad_endbits(bitfile *ld)
+{
+ if (ld->buffer) free(ld->buffer);
+}
+
uint32_t faad_get_processed_bits(bitfile *ld)
{
--- a/libfaad/bits.h
+++ b/libfaad/bits.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: bits.h,v 1.13 2002/11/08 13:00:35 menno Exp $
+** $Id: bits.h,v 1.14 2002/11/28 18:48:29 menno Exp $
**/
#ifndef __BITS_H__
@@ -43,6 +43,7 @@
uint32_t buffer_size; /* size of the buffer in bytes */
uint32_t *tail;
uint32_t *start;
+ void *buffer;
} bitfile;
@@ -64,6 +65,7 @@
};
void faad_initbits(bitfile *ld, void *buffer, uint32_t buffer_size);
+void faad_endbits(bitfile *ld);
void faad_initbits_rev(bitfile *ld, void *buffer,
uint32_t bits_in_buffer);
uint8_t faad_byte_align(bitfile *ld);
@@ -108,11 +110,11 @@
ld->bufa = ld->bufb;
tmp = getdword(ld->tail);
+ ld->tail++;
#ifndef ARCH_IS_BIG_ENDIAN
BSWAP(tmp);
#endif
ld->bufb = tmp;
- ld->tail++;
ld->bits_left += (32 - bits);
}
}
--- a/libfaad/cfft.c
+++ b/libfaad/cfft.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: cfft.c,v 1.9 2002/11/07 18:24:53 menno Exp $
+** $Id: cfft.c,v 1.10 2002/11/28 18:48:29 menno Exp $
**/
/*
@@ -29,6 +29,7 @@
/* isign is +1 for backward and -1 for forward transforms */
#include "common.h"
+#include "structs.h"
#include <stdlib.h>
#ifdef _WIN32_WCE
--- a/libfaad/cfft.h
+++ b/libfaad/cfft.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: cfft.h,v 1.4 2002/09/26 19:01:45 menno Exp $
+** $Id: cfft.h,v 1.5 2002/11/28 18:48:29 menno Exp $
**/
#ifndef __CFFT_H__
@@ -26,13 +26,6 @@
extern "C" {
#endif
-typedef struct
-{
- uint16_t n;
- uint16_t ifac[15];
- complex_t *work;
- complex_t *tab;
-} cfft_info;
void cfftf(cfft_info *cfft, complex_t *c);
void cfftb(cfft_info *cfft, complex_t *c);
--- a/libfaad/common.c
+++ b/libfaad/common.c
@@ -16,12 +16,13 @@
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
**
-** $Id: common.c,v 1.4 2002/10/01 21:55:49 menno Exp $
+** $Id: common.c,v 1.5 2002/11/28 18:48:29 menno Exp $
**/
/* just some common functions that could be used anywhere */
#include "common.h"
+#include "structs.h"
#include "syntax.h"
@@ -57,7 +58,11 @@
return -1;
#endif
case SSR:
+#ifdef SSR_DEC
+ return 0;
+#else
return -1;
+#endif
case LTP:
#ifdef LTP_DEC
return 0;
--- a/libfaad/common.h
+++ b/libfaad/common.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: common.h,v 1.25 2002/10/26 11:43:12 menno Exp $
+** $Id: common.h,v 1.26 2002/11/28 18:48:29 menno Exp $
**/
#ifndef __COMMON_H__
@@ -26,7 +26,6 @@
extern "C" {
#endif
-
#ifdef LINUX
#define INLINE inline
#else
@@ -57,6 +56,8 @@
/* Allow decoding of MAIN profile AAC */
#define MAIN_DEC
+/* Allow decoding of SSR profile AAC */
+#define SSR_DEC
/* Allow decoding of LTP profile AAC */
#define LTP_DEC
/* Allow decoding of LD profile AAC */
@@ -75,7 +76,11 @@
/* END COMPILE TIME DEFINITIONS */
+#ifndef FIXED_POINT
+#define POW_TABLE_SIZE 200
+#endif
+
#if defined(_WIN32)
@@ -118,9 +123,10 @@
#endif
-/* FIXED_POINT doesn't work with FFTW */
+/* FIXED_POINT doesn't work with MAIN and SSR yet */
#ifdef FIXED_POINT
#undef MAIN_DEC
+ #undef SSR_DEC
#endif
@@ -212,6 +218,7 @@
#ifndef M_PI_2 /* PI/2 */
#define M_PI_2 1.57079632679489661923
#endif
+
#ifdef __cplusplus
}
--- a/libfaad/decoder.c
+++ b/libfaad/decoder.c
@@ -16,12 +16,15 @@
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
**
-** $Id: decoder.c,v 1.39 2002/11/08 13:12:32 menno Exp $
+** $Id: decoder.c,v 1.40 2002/11/28 18:48:29 menno Exp $
**/
+#include "common.h"
+#include "structs.h"
+
#include <stdlib.h>
#include <string.h>
-#include "common.h"
+
#include "decoder.h"
#include "mp4.h"
#include "syntax.h"
@@ -37,6 +40,8 @@
#include "error.h"
#include "output.h"
#include "dither.h"
+#include "ssr.h"
+#include "ssr_fb.h"
#ifdef ANALYSIS
uint16_t dbg_count;
@@ -124,7 +129,7 @@
int32_t FAADAPI faacDecInit(faacDecHandle hDecoder, uint8_t *buffer,
uint32_t buffer_size,
- uint32_t *samplerate, uint8_t *channels)
+ uint32_t *samplerate, uint8_t *channels)
{
uint32_t bits = 0;
bitfile ld;
@@ -172,11 +177,16 @@
*channels = (adts.channel_configuration > 6) ?
2 : adts.channel_configuration;
}
+
+ faad_endbits(&ld);
}
hDecoder->channelConfiguration = *channels;
/* must be done before frameLength is divided by 2 for LD */
- hDecoder->fb = filter_bank_init(hDecoder->frameLength);
+ if (hDecoder->object_type == SSR)
+ hDecoder->fb = ssr_filter_bank_init(hDecoder->frameLength/SSR_BANDS);
+ else
+ hDecoder->fb = filter_bank_init(hDecoder->frameLength);
#ifdef LD_DEC
if (hDecoder->object_type == LD)
@@ -187,7 +197,7 @@
return -1;
#ifndef FIXED_POINT
- if (hDecoder->config.outputFormat > 5)
+ if (hDecoder->config.outputFormat >= 5)
Init_Dither(16, hDecoder->config.outputFormat - 5);
#endif
@@ -236,7 +246,10 @@
hDecoder->frameLength = 960;
/* must be done before frameLength is divided by 2 for LD */
- hDecoder->fb = filter_bank_init(hDecoder->frameLength);
+ if (hDecoder->object_type == SSR)
+ hDecoder->fb = ssr_filter_bank_init(hDecoder->frameLength/SSR_BANDS);
+ else
+ hDecoder->fb = filter_bank_init(hDecoder->frameLength);
#ifdef LD_DEC
if (hDecoder->object_type == LD)
@@ -244,7 +257,7 @@
#endif
#ifndef FIXED_POINT
- if (hDecoder->config.outputFormat > 5)
+ if (hDecoder->config.outputFormat >= 5)
Init_Dither(16, hDecoder->config.outputFormat - 5);
#endif
@@ -266,7 +279,10 @@
#endif
}
- filter_bank_end(hDecoder->fb);
+ if (hDecoder->object_type == SSR)
+ ssr_filter_bank_end(hDecoder->fb);
+ else
+ filter_bank_end(hDecoder->fb);
drc_end(hDecoder->drc);
@@ -316,11 +332,6 @@
#ifdef LTP_DEC
uint16_t *ltp_lag = hDecoder->ltp_lag;
#endif
-#ifdef ERROR_RESILIENCE
- uint8_t aacSectionDataResilienceFlag = hDecoder->aacSectionDataResilienceFlag;
- uint8_t aacScalefactorDataResilienceFlag = hDecoder->aacScalefactorDataResilienceFlag;
- uint8_t aacSpectralDataResilienceFlag = hDecoder->aacSpectralDataResilienceFlag;
-#endif
program_config pce;
element *syntax_elements[MAX_SYNTAX_ELEMENTS];
@@ -368,6 +379,7 @@
/* no more bit reading after this */
faad_byte_align(ld);
hInfo->bytesconsumed = bit2byte(faad_get_processed_bits(ld));
+ faad_endbits(ld);
if (ld) free(ld);
ld = NULL;
@@ -525,16 +537,25 @@
if (time_out[ch] == NULL)
{
- uint16_t r;
time_out[ch] = (real_t*)malloc(frame_len*2*sizeof(real_t));
- for (r = 0; r < frame_len*2; r++)
- time_out[ch][r] = 0;
+ memset(time_out[ch], 0, frame_len*2*sizeof(real_t));
}
/* filter bank */
- ifilter_bank(fb, ics->window_sequence, ics->window_shape,
- window_shape_prev[ch], spec_coef[ch],
- time_out[ch], object_type, frame_len);
+#ifdef SSR_DEC
+ if (object_type != SSR)
+ {
+#endif
+ ifilter_bank(fb, ics->window_sequence, ics->window_shape,
+ window_shape_prev[ch], spec_coef[ch],
+ time_out[ch], object_type, frame_len);
+#ifdef SSR_DEC
+ } else {
+ ssr_decode(&(ics->ssr), fb, ics->window_sequence, ics->window_shape,
+ window_shape_prev[ch], spec_coef[ch],
+ time_out[ch], frame_len);
+ }
+#endif
/* save window shape for next frame */
window_shape_prev[ch] = ics->window_shape;
@@ -592,6 +613,7 @@
error:
/* free all memory that could have been allocated */
+ faad_endbits(ld);
if (ld) free(ld);
/* cleanup */
--- a/libfaad/decoder.h
+++ b/libfaad/decoder.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: decoder.h,v 1.17 2002/11/01 11:19:35 menno Exp $
+** $Id: decoder.h,v 1.18 2002/11/28 18:48:30 menno Exp $
**/
#ifndef __DECODER_H__
@@ -39,6 +39,7 @@
#include "bits.h"
#include "syntax.h"
+#include "drc.h"
#include "specrec.h"
#include "filtbank.h"
#include "ic_predict.h"
@@ -53,66 +54,7 @@
#define FAAD_FMT_16BIT_M_SHAPE 7
#define FAAD_FMT_16BIT_H_SHAPE 8
-typedef struct faacDecConfiguration
-{
- uint8_t defObjectType;
- uint32_t defSampleRate;
- uint8_t outputFormat;
-} faacDecConfiguration, *faacDecConfigurationPtr;
-typedef struct faacDecFrameInfo
-{
- uint32_t bytesconsumed;
- uint32_t samples;
- uint8_t channels;
- uint8_t error;
-} faacDecFrameInfo;
-
-typedef struct
-{
- uint8_t adts_header_present;
- uint8_t adif_header_present;
- uint8_t sf_index;
- uint8_t object_type;
- uint8_t channelConfiguration;
-#ifdef ERROR_RESILIENCE
- uint8_t aacSectionDataResilienceFlag;
- uint8_t aacScalefactorDataResilienceFlag;
- uint8_t aacSpectralDataResilienceFlag;
-#endif
- uint16_t frameLength;
-
- uint32_t frame;
-
- void *sample_buffer;
-
- uint8_t window_shape_prev[MAX_CHANNELS];
-#ifdef LTP_DEC
- uint16_t ltp_lag[MAX_CHANNELS];
-#endif
- fb_info *fb;
- drc_info *drc;
-
- real_t *time_out[MAX_CHANNELS];
-
-#ifdef MAIN_DEC
- pred_state *pred_stat[MAX_CHANNELS];
-#endif
-#ifdef LTP_DEC
- real_t *lt_pred_stat[MAX_CHANNELS];
-#endif
-
-#ifndef FIXED_POINT
-#if POW_TABLE_SIZE
- real_t *pow2_table;
-#endif
-#endif
-
- /* Configuration data */
- faacDecConfiguration config;
-} faacDecStruct, *faacDecHandle;
-
-
int8_t* FAADAPI faacDecGetErrorMessage(uint8_t errcode);
faacDecHandle FAADAPI faacDecOpen();
@@ -141,7 +83,6 @@
uint8_t *buffer,
uint32_t buffer_size);
-/* these functions are in syntax.c */
element *decode_sce_lfe(faacDecHandle hDecoder,
faacDecFrameInfo *hInfo, bitfile *ld,
int16_t **spec_data, real_t **spec_coef,
--- a/libfaad/drc.c
+++ b/libfaad/drc.c
@@ -16,10 +16,11 @@
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
**
-** $Id: drc.c,v 1.11 2002/11/08 13:12:33 menno Exp $
+** $Id: drc.c,v 1.12 2002/11/28 18:48:30 menno Exp $
**/
#include "common.h"
+#include "structs.h"
#include <stdlib.h>
#include <string.h>
@@ -123,11 +124,11 @@
exp = -drc->ctrl1 * (drc->dyn_rng_ctl[bd] - (DRC_REF_LEVEL - drc->prog_ref_level))/24.0;
else /* boost */
exp = drc->ctrl2 * (drc->dyn_rng_ctl[bd] - (DRC_REF_LEVEL - drc->prog_ref_level))/24.0;
- factor = REAL_CONST(pow(2.0, exp));
+ factor = (real_t)pow(2.0, exp);
/* Apply gain factor */
for (i = bottom; i < top; i++)
- spec[i] = MUL(spec[i], factor);
+ spec[i] *= factor;
#else
/* Decode DRC gain factor */
if (drc->dyn_rng_sgn[bd]) /* compress */
--- a/libfaad/drc.h
+++ b/libfaad/drc.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: drc.h,v 1.5 2002/09/08 18:14:37 menno Exp $
+** $Id: drc.h,v 1.6 2002/11/28 18:48:30 menno Exp $
**/
#ifndef __DRC_H__
@@ -27,6 +27,7 @@
#endif
#define DRC_REF_LEVEL 20*4 /* -20 dB */
+
drc_info *drc_init(real_t cut, real_t boost);
void drc_end(drc_info *drc);
--- a/libfaad/filtbank.c
+++ b/libfaad/filtbank.c
@@ -16,10 +16,11 @@
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
**
-** $Id: filtbank.c,v 1.22 2002/11/08 13:12:33 menno Exp $
+** $Id: filtbank.c,v 1.23 2002/11/28 18:48:30 menno Exp $
**/
#include "common.h"
+#include "structs.h"
#include <stdlib.h>
#include <string.h>
@@ -197,7 +198,7 @@
for (i = 0; i < nshort; i++)
time_out[nlong+nflat_ls+i] = MUL_R_C(transf_buf[nlong+nflat_ls+i],window_short[nshort-i-1]);
for (i = 0; i < nflat_ls; i++)
- time_out[nlong+nflat_ls+nshort+i] = REAL_CONST(0.0);
+ time_out[nlong+nflat_ls+nshort+i] = 0;
break;
case EIGHT_SHORT_SEQUENCE:
@@ -227,7 +228,7 @@
time_out[nflat_ls+8*nshort+i] = MUL_R_C(transf_buf[nshort*15+i],window_short[nshort-1-i]);
}
for (i = 0; i < nflat_ls; i++)
- time_out[nlong+nflat_ls+nshort+i] = REAL_CONST(0.0);
+ time_out[nlong+nflat_ls+nshort+i] = 0;
break;
case LONG_STOP_SEQUENCE:
--- a/libfaad/filtbank.h
+++ b/libfaad/filtbank.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: filtbank.h,v 1.9 2002/08/26 18:41:47 menno Exp $
+** $Id: filtbank.h,v 1.10 2002/11/28 18:48:30 menno Exp $
**/
#ifndef __FILTBANK_H__
@@ -27,22 +27,6 @@
#endif
#include "mdct.h"
-
-
-typedef struct
-{
- real_t *long_window[2];
- real_t *short_window[2];
-#ifdef LD_DEC
- real_t *ld_window[2];
-#endif
-
- mdct_info *mdct256;
-#ifdef LD_DEC
- mdct_info *mdct1024;
-#endif
- mdct_info *mdct2048;
-} fb_info;
fb_info *filter_bank_init(uint16_t frame_len);
void filter_bank_end(fb_info *fb);
--- /dev/null
+++ b/libfaad/hcr.c
@@ -1,0 +1,643 @@
+/*
+** FAAD - Freeware Advanced Audio Decoder
+** Copyright (C) 2002 A. Kurpiers
+**
+** 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
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+**
+** $Id: hcr.c,v 1.1 2002/11/28 18:48:30 menno Exp $
+**/
+
+#include "common.h"
+#include "structs.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "syntax.h"
+#include "specrec.h"
+#include "bits.h"
+#include "data.h"
+#include "pulse.h"
+#include "analysis.h"
+#include "bits.h"
+#include "codebook/hcb.h"
+
+/* Implements the HCR11 tool as described in ISO/IEC 14496-3/Amd.1, 8.5.3.3 */
+
+#ifdef ERROR_RESILIENCE
+
+//FIXME these tables are not needed twice actually
+
+static hcb *hcb_table[] = {
+ 0, hcb1_1, hcb2_1, 0, hcb4_1, 0, hcb6_1, 0, hcb8_1, 0, hcb10_1, hcb11_1
+};
+
+static hcb_2_quad *hcb_2_quad_table[] = {
+ 0, hcb1_2, hcb2_2, 0, hcb4_2, 0, 0, 0, 0, 0, 0, 0
+};
+
+static hcb_2_pair *hcb_2_pair_table[] = {
+ 0, 0, 0, 0, 0, 0, hcb6_2, 0, hcb8_2, 0, hcb10_2, hcb11_2
+};
+
+static hcb_bin_pair *hcb_bin_table[] = {
+ 0, 0, 0, 0, 0, hcb5, 0, hcb7, 0, hcb9, 0, 0
+};
+
+static uint8_t hcbN[] = { 0, 5, 5, 0, 5, 0, 5, 0, 5, 0, 6, 5 };
+
+
+/* defines whether a huffman codebook is unsigned or not */
+/* Table 4.6.2 */
+static uint8_t unsigned_cb[] = { 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0,
+ /* codebook 16 to 31 */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
+};
+typedef struct
+{
+ /* bit input */
+ uint32_t bufa;
+ uint32_t bufb;
+ int8_t len;
+} bits_t;
+
+
+static INLINE uint32_t showbits(bits_t *ld, uint8_t bits)
+{
+ if (bits == 0) return 0;
+ if (ld->len <= 32){
+ /* huffman_spectral_data_2 needs to read more than may be available, bits maybe
+ > ld->len, deliver 0 than */
+ if (ld->len >= bits)
+ return ((ld->bufa >> (ld->len - bits)) & (0xFFFFFFFF >> (32 - bits)));
+ else
+ return ((ld->bufa << (bits - ld->len)) & (0xFFFFFFFF >> (32 - bits)));
+ } else {
+ if ((ld->len - bits) < 32)
+ {
+ return ( (ld->bufb & (0xFFFFFFFF >> (64 - ld->len))) << (bits - ld->len + 32)) |
+ (ld->bufa >> (ld->len - bits));
+ } else {
+ return ((ld->bufb >> (ld->len - bits - 32)) & (0xFFFFFFFF >> (32 - bits)));
+ }
+ }
+}
+
+/* return 1 if position is outside of buffer, 0 otherwise */
+static INLINE int8_t flushbits( bits_t *ld, uint8_t bits)
+{
+ ld->len -= bits;
+
+ if (ld->len <0)
+ {
+ ld->len = 0;
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+
+static INLINE int8_t getbits(bits_t *ld, uint8_t n, uint32_t *result)
+{
+ *result = showbits(ld, n);
+ return flushbits(ld, n);
+}
+
+static INLINE int8_t get1bit(bits_t *ld, uint8_t *result)
+{
+ uint32_t res;
+ int8_t ret;
+
+ ret = getbits(ld, 1, &res);
+ *result = res & 1;
+ return ret;
+}
+
+/* Special version of huffman_spectral_data adapted from huffman.h
+Will not read from a bitfile but a bits_t structure.
+Will keep track of the bits decoded and return the number of bits remaining.
+Do not read more than ld->len, return -1 if codeword would be longer */
+
+static int8_t huffman_spectral_data_2(uint8_t cb, bits_t *ld, int16_t *sp )
+{
+ uint32_t cw;
+ uint16_t offset = 0;
+ uint8_t extra_bits;
+ uint8_t i;
+ uint8_t save_cb = cb;
+
+
+ switch (cb)
+ {
+ case 1: /* 2-step method for data quadruples */
+ case 2:
+ case 4:
+
+ cw = showbits(ld, hcbN[cb]);
+ offset = hcb_table[cb][cw].offset;
+ extra_bits = hcb_table[cb][cw].extra_bits;
+
+ if (extra_bits)
+ {
+ /* we know for sure it's more than hcbN[cb] bits long */
+ if ( flushbits(ld, hcbN[cb]) ) return -1;
+ offset += (uint16_t)showbits(ld, extra_bits);
+ if ( flushbits(ld, hcb_2_quad_table[cb][offset].bits - hcbN[cb]) ) return -1;
+ } else {
+ if ( flushbits(ld, hcb_2_quad_table[cb][offset].bits) ) return -1;
+ }
+
+ sp[0] = hcb_2_quad_table[cb][offset].x;
+ sp[1] = hcb_2_quad_table[cb][offset].y;
+ sp[2] = hcb_2_quad_table[cb][offset].v;
+ sp[3] = hcb_2_quad_table[cb][offset].w;
+ break;
+
+ case 6: /* 2-step method for data pairs */
+ case 8:
+ case 10:
+ case 11:
+ /* VCB11 uses codebook 11 */
+ case 16: case 17: case 18: case 19: case 20: case 21: case 22: case 23:
+ case 24: case 25: case 26: case 27: case 28: case 29: case 30: case 31:
+
+ /* TODO: If ER is used, some extra error checking should be done */
+ if (cb >= 16)
+ cb = 11;
+
+ cw = showbits(ld, hcbN[cb]);
+ offset = hcb_table[cb][cw].offset;
+ extra_bits = hcb_table[cb][cw].extra_bits;
+
+ if (extra_bits)
+ {
+ /* we know for sure it's more than hcbN[cb] bits long */
+ if ( flushbits(ld, hcbN[cb]) ) return -1;
+ offset += (uint16_t)showbits(ld, extra_bits);
+ if ( flushbits(ld, hcb_2_pair_table[cb][offset].bits - hcbN[cb]) ) return -1;
+ } else {
+ if ( flushbits(ld, hcb_2_pair_table[cb][offset].bits) ) return -1;
+ }
+ sp[0] = hcb_2_pair_table[cb][offset].x;
+ sp[1] = hcb_2_pair_table[cb][offset].y;
+ break;
+
+ case 3: /* binary search for data quadruples */
+
+ while (!hcb3[offset].is_leaf)
+ {
+ uint8_t b;
+
+ if ( get1bit(ld, &b) ) return -1;
+ offset += hcb3[offset].data[b];
+ }
+
+ sp[0] = hcb3[offset].data[0];
+ sp[1] = hcb3[offset].data[1];
+ sp[2] = hcb3[offset].data[2];
+ sp[3] = hcb3[offset].data[3];
+
+ break;
+
+ case 5: /* binary search for data pairs */
+ case 7:
+ case 9:
+
+ while (!hcb_bin_table[cb][offset].is_leaf)
+ {
+ uint8_t b;
+
+ if (get1bit(ld, &b) ) return -1;
+ offset += hcb_bin_table[cb][offset].data[b];
+ }
+
+ sp[0] = hcb_bin_table[cb][offset].data[0];
+ sp[1] = hcb_bin_table[cb][offset].data[1];
+
+ break;
+ }
+
+ /* decode sign bits */
+ if (unsigned_cb[cb]) {
+
+ for(i = 0; i < ((cb < FIRST_PAIR_HCB) ? QUAD_LEN : PAIR_LEN); i++)
+ {
+ if(sp[i])
+ {
+ uint8_t b;
+ if ( get1bit(ld, &b) ) return -1;
+ if (b != 0) {
+ sp[i] = -sp[i];
+ }
+ }
+ }
+ }
+
+ /* decode huffman escape bits */
+ if ((cb == ESC_HCB) || (cb >= 16))
+ {
+ uint8_t k;
+ for (k = 0; k < 2; k++)
+ {
+ if ((sp[k] == 16) || (sp[k] == -16))
+ {
+ uint8_t neg, i;
+ int32_t j;
+ uint32_t off;
+
+ neg = (sp[k] < 0) ? 1 : 0;
+
+ for (i = 4; ; i++)
+ {
+ uint8_t b;
+ if (get1bit(ld, &b))
+ return -1;
+ if (b == 0)
+ break;
+ }
+// TODO: here we would need to test "off" if VCB11 is used!
+ if (getbits(ld, i, &off))
+ return -1;
+ j = off + (1<<i);
+ sp[k] = neg ? -j : j;
+ }
+ }
+ }
+ return ld->len;
+}
+
+/* rewind len (max. 32) bits so that the MSB becomes LSB */
+
+static uint32_t rewind_word( uint32_t W, uint8_t len)
+{
+ uint8_t i;
+ uint32_t tmp_W=0;
+
+ for ( i=0; i<len; i++ )
+ {
+ tmp_W<<=1;
+ if (W & (1<<i)) tmp_W |= 1;
+ }
+ return tmp_W;
+}
+
+static void rewind_lword( uint32_t *highW, uint32_t *lowW, uint8_t len)
+{
+ uint32_t tmp_lW=0;
+
+ if (len > 32)
+ {
+ tmp_lW = rewind_word( (*highW << (64-len)) | (*lowW >> (len-32)), 32);
+ *highW = rewind_word( *lowW << (64-len) , 32);
+ *lowW = tmp_lW;
+ } else {
+ *highW = 0;
+ *lowW = rewind_word( *lowW, len);
+ }
+}
+
+/* Takes a codeword as stored in r, rewinds the remaining bits and stores it back */
+static void rewind_bits(bits_t * r)
+{
+ uint32_t hw, lw;
+
+ if (r->len == 0) return;
+
+ if (r->len >32)
+ {
+ lw = r->bufa;
+ hw = r->bufb & (0xFFFFFFFF >> (64 - r->len));
+ rewind_lword( &hw, &lw, r->len );
+ r->bufa = lw;
+ r->bufb = hw;
+
+ } else {
+ lw = showbits(r, r->len );
+ r->bufa = rewind_word( lw, r->len);
+ r->bufb = 0;
+ }
+}
+
+/* takes codewords from a and b, concatenate them and store them in b */
+static void concat_bits( bits_t * a, bits_t * b)
+{
+ uint32_t hwa, lwa, hwb, lwb;
+
+ if (a->len == 0) return;
+
+ if (a->len >32)
+ {
+ lwa = a->bufa;
+ hwa = a->bufb & (0xFFFFFFFF >> (64 - a->len));
+ } else {
+ lwa = showbits(a, a->len );
+ hwa = 0;
+ }
+ if (b->len >=32) {
+ lwb = b->bufa;
+ hwb = (b->bufb & (0xFFFFFFFF >> (64 - b->len)) ) | ( lwa << (b->len - 32));
+ } else {
+ lwb = showbits(b, b->len ) | (lwa << (b->len));
+ hwb = (lwa >> (32 - b->len)) | (hwa << (b->len));
+ }
+
+ b->bufa = lwb;
+ b->bufb = hwb;
+ b->len += a->len;
+}
+
+/* 8.5.3.3.1 */
+
+static const uint8_t PresortedCodebook_VCB11[] = { 11, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 9, 7, 5, 3, 1};
+static const uint8_t PresortedCodebook[] = { 11, 9, 7, 5, 3, 1};
+
+static const uint8_t maxCwLen[32] = {0, 11, 9, 20, 16, 13, 11, 14, 12, 17, 14, 49,
+ 0, 0, 0, 0, 14, 17, 21, 21, 25, 25, 29, 29, 29, 29, 33, 33, 33, 37, 37, 41};
+
+typedef struct
+{
+ bits_t bits;
+ uint8_t decoded;
+ uint16_t sp_offset;
+ uint8_t cb;
+} codeword_state;
+
+
+#define segmentWidth( codebook ) min( maxCwLen[codebook], ics->length_of_longest_codeword )
+
+uint8_t reordered_spectral_data(faacDecHandle hDecoder, ic_stream *ics, bitfile *ld,
+ int16_t *spectral_data)
+{
+ uint16_t sp_offset[8];
+ uint16_t g,i, presort;
+ uint16_t NrCodeWords=0, numberOfSegments=0, BitsRead=0;
+ uint8_t numberOfSets, set;
+ codeword_state Codewords[ 1024 ]; // FIXME max length? PCWs are not stored, so index is Codewordnr - numberOfSegments!, maybe malloc()?
+ bits_t Segment[ 512 ];
+
+ uint8_t PCW_decoded=0;
+ uint16_t segment_index=0, codeword_index=0;
+ uint16_t nshort = hDecoder->frameLength/8;
+
+
+ memset (spectral_data, 0, hDecoder->frameLength*sizeof(uint16_t));
+
+ if (ics->length_of_reordered_spectral_data == 0)
+ return 0; /* nothing to do */
+
+ /* if we have a corrupted bitstream this can happen... */
+ if ((ics->length_of_longest_codeword == 0) ||
+ (ics->length_of_reordered_spectral_data <
+ ics->length_of_longest_codeword))
+ {
+ return 10; /* this is not good... */
+ }
+
+ /* store the offset into the spectral data for all the window groups because we can't do it later */
+
+ sp_offset[0] = 0;
+ for (g=1; g < ics->num_window_groups; g++)
+ {
+ sp_offset[g] = sp_offset[g-1] + nshort*ics->window_group_length[g-1];
+ }
+
+ /* All data is sorted according to the codebook used */
+ for (presort = 0; presort < (hDecoder->aacSectionDataResilienceFlag ? 22 : 6); presort++)
+ {
+ uint8_t sfb;
+
+ /* next codebook that has to be processed according to presorting */
+ uint8_t nextCB = hDecoder->aacSectionDataResilienceFlag ? PresortedCodebook_VCB11[ presort ] : PresortedCodebook[ presort ];
+
+ /* Data belonging to the same spectral unit and having the same codebook comes in consecutive codewords.
+ This is done by scanning all sfbs for possible codewords. For sfbs with more than 4 elements this has to be
+ repeated */
+
+ for (sfb=0; sfb<ics->max_sfb; sfb ++)
+ {
+ uint8_t sect_cb, w;
+
+ for (w=0; w< (ics->swb_offset[sfb+1] - ics->swb_offset[sfb]); w+=4)
+ {
+ for(g = 0; g < ics->num_window_groups; g++)
+ {
+ for (i = 0; i < ics->num_sec[g]; i++)
+ {
+ sect_cb = ics->sect_cb[g][i];
+
+ if (
+ /* process only sections that are due now */
+ (( sect_cb == nextCB ) || (( nextCB < ESC_HCB ) && ( sect_cb == nextCB+1)) ) &&
+
+ /* process only sfb's that are due now */
+ ((ics->sect_start[g][i] <= sfb) && (ics->sect_end[g][i] > sfb))
+ )
+ {
+ if ((sect_cb != ZERO_HCB) &&
+ (sect_cb != NOISE_HCB) &&
+ (sect_cb != INTENSITY_HCB) &&
+ (sect_cb != INTENSITY_HCB2))
+ {
+ uint8_t inc = (sect_cb < FIRST_PAIR_HCB) ? QUAD_LEN : PAIR_LEN;
+ uint16_t k;
+
+ uint32_t hw, lw;
+
+ for (k=0; (k < (4/inc)*ics->window_group_length[g]) &&
+ ( (k+w*ics->window_group_length[g]/inc) < (ics->sect_sfb_offset[g][sfb+1] - ics->sect_sfb_offset[g][sfb])); k++)
+ {
+ uint16_t sp = sp_offset[g] + ics->sect_sfb_offset[g][sfb] + inc*(k+w*ics->window_group_length[g]/inc);
+
+ if (!PCW_decoded)
+ {
+ /* if we haven't yet read until the end of the buffer, we can directly decode the so-called PCWs */
+ if ((BitsRead + segmentWidth( sect_cb ))<= ics->length_of_reordered_spectral_data)
+ {
+ Segment[ numberOfSegments ].len = segmentWidth( sect_cb );
+
+ if (segmentWidth( sect_cb ) > 32)
+ {
+ Segment[ numberOfSegments ].bufb = faad_showbits(ld, segmentWidth( sect_cb ) - 32);
+ faad_flushbits(ld, segmentWidth( sect_cb) - 32);
+ Segment[ numberOfSegments ].bufa = faad_showbits(ld, 32),
+ faad_flushbits(ld, 32 );
+
+ } else {
+ Segment[ numberOfSegments ].bufa = faad_showbits(ld, segmentWidth( sect_cb ));
+ Segment[ numberOfSegments ].bufb = 0;
+ faad_flushbits(ld, segmentWidth( sect_cb) );
+ }
+
+ huffman_spectral_data_2(sect_cb, &Segment[ numberOfSegments ], &spectral_data[sp]);
+
+ BitsRead += segmentWidth( sect_cb );
+
+ /* skip to next segment, but store left bits in new buffer */
+ rewind_bits( &Segment[ numberOfSegments ]);
+
+ numberOfSegments++;
+ } else {
+
+ /* the last segment is extended until length_of_reordered_spectral_data */
+
+ if (BitsRead < ics->length_of_reordered_spectral_data)
+ {
+
+ uint8_t additional_bits = (ics->length_of_reordered_spectral_data - BitsRead);
+
+ if ( additional_bits > 32)
+ {
+ hw = faad_showbits(ld, additional_bits - 32);
+ faad_flushbits(ld, additional_bits - 32);
+ lw = faad_showbits(ld, 32);
+ faad_flushbits(ld, 32 );
+ } else {
+ lw = faad_showbits(ld, additional_bits);
+ hw = 0;
+ faad_flushbits(ld, additional_bits );
+ }
+ rewind_lword( &hw, &lw, additional_bits + Segment[ numberOfSegments-1 ].len );
+ if (Segment[ numberOfSegments-1 ].len > 32)
+ {
+ Segment[ numberOfSegments-1 ].bufb = hw +
+ showbits(&Segment[ numberOfSegments-1 ], Segment[ numberOfSegments-1 ].len - 32);
+ Segment[ numberOfSegments-1 ].bufa = lw +
+ showbits(&Segment[ numberOfSegments-1 ], 32);
+ } else {
+ Segment[ numberOfSegments-1 ].bufa = lw +
+ showbits(&Segment[ numberOfSegments-1 ], Segment[ numberOfSegments-1 ].len);
+ Segment[ numberOfSegments-1 ].bufb = hw;
+ }
+ Segment[ numberOfSegments-1 ].len += additional_bits;
+ }
+ BitsRead = ics->length_of_reordered_spectral_data;
+ PCW_decoded = 1;
+
+ Codewords[ 0 ].sp_offset = sp;
+ Codewords[ 0 ].cb = sect_cb;
+ Codewords[ 0 ].decoded = 0;
+ Codewords[ 0 ].bits.len = 0;
+ }
+ } else {
+ Codewords[ NrCodeWords - numberOfSegments ].sp_offset = sp;
+ Codewords[ NrCodeWords - numberOfSegments ].cb = sect_cb;
+ Codewords[ NrCodeWords - numberOfSegments ].decoded = 0;
+ Codewords[ NrCodeWords - numberOfSegments ].bits.len = 0;
+
+ } /* PCW decoded */
+ NrCodeWords++;
+ } /* of k */
+ }
+ }
+ } /* of i */
+ } /* of g */
+ } /* of w */
+ } /* of sfb */
+ } /* of presort */
+
+ numberOfSets = NrCodeWords / numberOfSegments;
+
+ /* second step: decode nonPCWs */
+
+ for (set = 1; set <= numberOfSets; set++)
+ {
+ uint16_t trial;
+
+ for (trial = 0; trial < numberOfSegments; trial++)
+ {
+ uint16_t codewordBase;
+ uint16_t set_decoded=numberOfSegments;
+
+ if (set == numberOfSets)
+ set_decoded = NrCodeWords - set*numberOfSegments; /* last set is shorter than the rest */
+
+ for (codewordBase = 0; codewordBase < numberOfSegments; codewordBase++)
+ {
+ uint16_t segment_index = (trial + codewordBase) % numberOfSegments;
+ uint16_t codeword_index = codewordBase + set*numberOfSegments - numberOfSegments;
+
+ if ((codeword_index + numberOfSegments) >= NrCodeWords)
+ break;
+ if (!Codewords[ codeword_index ].decoded)
+ {
+ if ( Segment[ segment_index ].len > 0)
+ {
+ uint8_t tmplen;
+
+ if (Codewords[ codeword_index ].bits.len != 0)
+ {
+ /* on the first trial the data is only stored in Segment[], not in Codewords[].
+ On next trials first collect the data stored for this codeword and
+ concatenate the new data from Segment[] */
+
+ concat_bits( &Codewords[ codeword_index ].bits, &Segment[ segment_index ]);
+ /* Now everthing is stored in Segment[] */
+ }
+ tmplen = Segment[ segment_index ].len;
+ if ( huffman_spectral_data_2(Codewords[ codeword_index ].cb, &Segment[ segment_index ],
+ &spectral_data[ Codewords[ codeword_index ].sp_offset ]) >=0)
+ {
+ /* CW did fit into segment */
+
+ Codewords[ codeword_index ].decoded = 1;
+ set_decoded--;
+ } else {
+
+ /* CW did not fit, so store for later use */
+
+ Codewords[ codeword_index ].bits.len = tmplen;
+ Codewords[ codeword_index ].bits.bufa = Segment[ segment_index ].bufa;
+ Codewords[ codeword_index ].bits.bufb = Segment[ segment_index ].bufb;
+ }
+ }
+ }
+ } /* of codewordBase */
+
+ if (set_decoded == 0) break; /* no undecoded codewords left in this set */
+
+ } /* of trial */
+
+ /* rewind all bits in remaining segments with len>0 */
+ for (i=0; i < numberOfSegments; i++)
+ rewind_bits( &Segment[ i ] );
+ }
+
+#if 0
+ {
+ int i, r=0, c=0;
+ for (i=0; i< numberOfSegments; i++)
+ r += Segment[ i ].len;
+ if (r != 0)
+ {
+ printf("reordered_spectral_data: %d bits remaining!\n", r);
+ }
+ for (i=0; i< NrCodeWords - numberOfSegments; i++)
+ {
+ if (Codewords[ i ].decoded == 0)
+ {
+ c++;
+ }
+ }
+ if (c != 0)
+ {
+ printf("reordered_spectral_data: %d Undecoded Codewords remaining!\n",c );
+ }
+ if ((r !=0) || (c!=0)) return 10;
+ }
+#endif
+
+ return 0;
+}
+#endif
--- a/libfaad/ic_predict.c
+++ b/libfaad/ic_predict.c
@@ -16,10 +16,11 @@
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
**
-** $Id: ic_predict.c,v 1.9 2002/09/08 18:14:37 menno Exp $
+** $Id: ic_predict.c,v 1.10 2002/11/28 18:48:30 menno Exp $
**/
#include "common.h"
+#include "structs.h"
#ifdef MAIN_DEC
@@ -41,8 +42,8 @@
KOR = state->KOR; /* correlations */
VAR = state->VAR; /* variances */
- if (VAR[0] == REAL_CONST(0.0))
- k1 = REAL_CONST(0.0);
+ if (VAR[0] == 0)
+ k1 = 0;
else
k1 = KOR[0]/VAR[0]*B;
@@ -49,8 +50,8 @@
if (pred)
{
/* only needed for the actual predicted value, k1 is always needed */
- if (VAR[1] == REAL_CONST(0.0))
- k2 = REAL_CONST(0.0);
+ if (VAR[1] == 0)
+ k2 = 0;
else
k2 = KOR[1]/VAR[1]*B;
@@ -78,10 +79,10 @@
static void reset_pred_state(pred_state *state)
{
- state->r[0] = REAL_CONST(0.0);
- state->r[1] = REAL_CONST(0.0);
- state->KOR[0] = REAL_CONST(0.0);
- state->KOR[1] = REAL_CONST(0.0);
+ state->r[0] = 0;
+ state->r[1] = 0;
+ state->KOR[0] = 0;
+ state->KOR[1] = 0;
state->VAR[0] = REAL_CONST(1.0);
state->VAR[1] = REAL_CONST(1.0);
}
--- a/libfaad/ic_predict.h
+++ b/libfaad/ic_predict.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: ic_predict.h,v 1.5 2002/08/17 12:27:33 menno Exp $
+** $Id: ic_predict.h,v 1.6 2002/11/28 18:48:30 menno Exp $
**/
#ifdef MAIN_DEC
@@ -31,14 +31,6 @@
#define ALPHA REAL_CONST(0.90625)
#define A REAL_CONST(0.953125)
#define B REAL_CONST(0.953125)
-
-
-/* used to save the state */
-typedef struct {
- real_t r[2];
- real_t KOR[2];
- real_t VAR[2];
-} pred_state;
void pns_reset_pred_state(ic_stream *ics, pred_state *state);
--- a/libfaad/is.c
+++ b/libfaad/is.c
@@ -16,10 +16,11 @@
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
**
-** $Id: is.c,v 1.9 2002/09/08 18:14:37 menno Exp $
+** $Id: is.c,v 1.10 2002/11/28 18:48:30 menno Exp $
**/
#include "common.h"
+#include "structs.h"
#include "syntax.h"
#include "is.h"
--- a/libfaad/libfaad.dsp
+++ b/libfaad/libfaad.dsp
@@ -25,7 +25,7 @@
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
-CPP=cl.exe
+CPP=xicl6.exe
RSC=rc.exe
!IF "$(CFG)" == "libfaad - Win32 Release"
@@ -47,7 +47,7 @@
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
-LIB32=link.exe -lib
+LIB32=xilink6.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo
@@ -70,7 +70,7 @@
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
-LIB32=link.exe -lib
+LIB32=xilink6.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo
@@ -173,6 +173,10 @@
# End Source File
# Begin Source File
+SOURCE=.\hcr.c
+# End Source File
+# Begin Source File
+
SOURCE=.\ic_predict.c
# End Source File
# Begin Source File
@@ -209,18 +213,26 @@
# End Source File
# Begin Source File
-SOURCE=.\reordered_spectral_data.c
+SOURCE=.\rvlc.c
# End Source File
# Begin Source File
-SOURCE=.\rvlc_scale_factors.c
+SOURCE=.\specrec.c
# End Source File
# Begin Source File
-SOURCE=.\specrec.c
+SOURCE=.\ssr.c
# End Source File
# Begin Source File
+SOURCE=.\ssr_fb.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\ssr_ipqf.c
+# End Source File
+# Begin Source File
+
SOURCE=.\syntax.c
# End Source File
# Begin Source File
@@ -273,10 +285,6 @@
# End Source File
# Begin Source File
-SOURCE=.\fftw\f77_func.h
-# End Source File
-# Begin Source File
-
SOURCE=.\filtbank.h
# End Source File
# Begin Source File
@@ -329,11 +337,15 @@
# End Source File
# Begin Source File
-SOURCE=.\rvlc_scale_factors.h
+SOURCE=.\rvlc.h
# End Source File
# Begin Source File
SOURCE=.\specrec.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\ssr.h
# End Source File
# Begin Source File
--- a/libfaad/libfaad.vcproj
+++ b/libfaad/libfaad.vcproj
@@ -33,13 +33,27 @@
WarningLevel="3"
SuppressStartupBanner="TRUE"
DebugInformationFormat="4"
- CompileAs="0"/>
+ CompileAs="0"
+ AdditionalOptions="">
+ <IntelOptions
+ Optimization="0"
+ MinimalRebuild="1"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ AllOptions="/c /I "fftw" /ZI /nologo /W3 /Od /D "_DEBUG" /D "WIN32" /D "_LIB" /D "FFTW_ENABLE_FLOAT" /D "_MBCS" /Gm /EHsc /RTC1 /MTd /YX"StdAfx.h" /Fp".\Debug/libfaad.pch" /Fo".\Debug/" /Fd".\Debug/" /Gd"
+ MSOriginalAdditionalOptions=""/>
+ </Tool>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLibrarianTool"
OutputFile=".\Debug\libfaad.lib"
- SuppressStartupBanner="TRUE"/>
+ SuppressStartupBanner="TRUE"
+ AdditionalOptions="">
+ <IntelOptions
+ AllOptions="/OUT:".\Debug\libfaad.lib" /NOLOGO"
+ MSOriginalAdditionalOptions=""/>
+ </Tool>
<Tool
Name="VCMIDLTool"/>
<Tool
@@ -54,6 +68,8 @@
Culture="1043"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
+ <IntelOptions
+ CompilerName="0"/>
</Configuration>
<Configuration
Name="Release|Win32"
@@ -65,9 +81,12 @@
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
+ GlobalOptimizations="FALSE"
InlineFunctionExpansion="1"
+ EnableIntrinsicFunctions="TRUE"
+ FavorSizeOrSpeed="1"
OptimizeForProcessor="2"
- AdditionalIncludeDirectories="fftw"
+ AdditionalIncludeDirectories=""
PreprocessorDefinitions="NDEBUG,WIN32,_LIB,FFTW_ENABLE_FLOAT"
StringPooling="TRUE"
RuntimeLibrary="0"
@@ -79,13 +98,38 @@
ProgramDataBaseFileName=".\Release/"
WarningLevel="3"
SuppressStartupBanner="TRUE"
- CompileAs="0"/>
+ Detect64BitPortabilityProblems="FALSE"
+ CompileAs="0"
+ AdditionalOptions="">
+ <IntelOptions
+ Optimization="2"
+ GlobalOptimizations="0"
+ InlineFuncExpansion="1"
+ IntrinsicFuncs="1"
+ FavorSizeSpeed="1"
+ OmitFramePtrs="1"
+ OptimProc="2"
+ UseProcExt="0"
+ RequireProcExt="0"
+ Parallelization="0"
+ StringPooling="1"
+ RuntimeLibrary="0"
+ BufferSecurityCheck="1"
+ FunctionLevelLinking="1"
+ AllOptions="/c /nologo /W3 /O2 /Ob1 /Oi /Ot /Oy /G6 /D "NDEBUG" /D "WIN32" /D "_LIB" /D "FFTW_ENABLE_FLOAT" /D "_MBCS" /GF /FD /EHsc /MT /GS /Gy /YX"StdAfx.h" /Fp".\Release/libfaad.pch" /Fo".\Release/" /Fd".\Release/" /Gd"
+ MSOriginalAdditionalOptions=""/>
+ </Tool>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLibrarianTool"
OutputFile=".\Release\libfaad.lib"
- SuppressStartupBanner="TRUE"/>
+ SuppressStartupBanner="TRUE"
+ AdditionalOptions="">
+ <IntelOptions
+ AllOptions="/OUT:".\Release\libfaad.lib" /NOLOGO"
+ MSOriginalAdditionalOptions=""/>
+ </Tool>
<Tool
Name="VCMIDLTool"/>
<Tool
@@ -100,6 +144,8 @@
Culture="1043"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
+ <IntelOptions
+ CompilerName="0"/>
</Configuration>
</Configurations>
<Files>
@@ -107,113 +153,84 @@
Name="Source Files"
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat">
<File
- RelativePath=".\bits.c">
- </File>
+ RelativePath=".\bits.c"/>
<File
- RelativePath=".\cfft.c">
- </File>
+ RelativePath=".\cfft.c"/>
<File
- RelativePath=".\common.c">
- </File>
+ RelativePath=".\common.c"/>
<File
- RelativePath=".\data.c">
- </File>
+ RelativePath=".\data.c"/>
<File
- RelativePath=".\decoder.c">
- </File>
+ RelativePath=".\decoder.c"/>
<File
- RelativePath=".\dither.c">
- </File>
+ RelativePath=".\dither.c"/>
<File
- RelativePath=".\drc.c">
- </File>
+ RelativePath=".\drc.c"/>
<File
- RelativePath=".\error.c">
- </File>
+ RelativePath=".\error.c"/>
<File
- RelativePath=".\filtbank.c">
- </File>
+ RelativePath=".\filtbank.c"/>
<File
- RelativePath=".\ic_predict.c">
- </File>
+ RelativePath="hcr.c"/>
<File
- RelativePath=".\is.c">
- </File>
+ RelativePath=".\ic_predict.c"/>
<File
- RelativePath=".\lt_predict.c">
- </File>
+ RelativePath=".\is.c"/>
<File
- RelativePath=".\mdct.c">
- </File>
+ RelativePath=".\lt_predict.c"/>
<File
- RelativePath=".\mp4.c">
- </File>
+ RelativePath=".\mdct.c"/>
<File
- RelativePath=".\ms.c">
- </File>
+ RelativePath=".\mp4.c"/>
<File
- RelativePath=".\output.c">
- </File>
+ RelativePath=".\ms.c"/>
<File
- RelativePath=".\pns.c">
- </File>
+ RelativePath=".\output.c"/>
<File
- RelativePath=".\pulse.c">
- </File>
+ RelativePath=".\pns.c"/>
<File
- RelativePath=".\reordered_spectral_data.c">
- </File>
+ RelativePath=".\pulse.c"/>
<File
- RelativePath=".\rvlc_scale_factors.c">
- </File>
+ RelativePath="rvlc.c"/>
<File
- RelativePath=".\specrec.c">
- </File>
+ RelativePath=".\specrec.c"/>
<File
- RelativePath=".\syntax.c">
- </File>
+ RelativePath="ssr.c"/>
<File
- RelativePath=".\tns.c">
- </File>
+ RelativePath="ssr_fb.c"/>
+ <File
+ RelativePath="ssr_ipqf.c"/>
+ <File
+ RelativePath=".\syntax.c"/>
+ <File
+ RelativePath=".\tns.c"/>
<Filter
Name="codebook"
Filter="">
<File
- RelativePath=".\codebook\hcb_1.c">
- </File>
+ RelativePath=".\codebook\hcb_1.c"/>
<File
- RelativePath=".\codebook\hcb_10.c">
- </File>
+ RelativePath=".\codebook\hcb_10.c"/>
<File
- RelativePath=".\codebook\hcb_11.c">
- </File>
+ RelativePath=".\codebook\hcb_11.c"/>
<File
- RelativePath=".\codebook\hcb_2.c">
- </File>
+ RelativePath=".\codebook\hcb_2.c"/>
<File
- RelativePath=".\codebook\hcb_3.c">
- </File>
+ RelativePath=".\codebook\hcb_3.c"/>
<File
- RelativePath=".\codebook\hcb_4.c">
- </File>
+ RelativePath=".\codebook\hcb_4.c"/>
<File
- RelativePath=".\codebook\hcb_5.c">
- </File>
+ RelativePath=".\codebook\hcb_5.c"/>
<File
- RelativePath=".\codebook\hcb_6.c">
- </File>
+ RelativePath=".\codebook\hcb_6.c"/>
<File
- RelativePath=".\codebook\hcb_7.c">
- </File>
+ RelativePath=".\codebook\hcb_7.c"/>
<File
- RelativePath=".\codebook\hcb_8.c">
- </File>
+ RelativePath=".\codebook\hcb_8.c"/>
<File
- RelativePath=".\codebook\hcb_9.c">
- </File>
+ RelativePath=".\codebook\hcb_9.c"/>
<File
- RelativePath=".\codebook\hcb_sf.c">
- </File>
+ RelativePath=".\codebook\hcb_sf.c"/>
</Filter>
</Filter>
<Filter
@@ -220,91 +237,74 @@
Name="Header Files"
Filter="h;hpp;hxx;hm;inl">
<File
- RelativePath=".\analysis.h">
- </File>
+ RelativePath=".\analysis.h"/>
<File
- RelativePath=".\bits.h">
- </File>
+ RelativePath=".\bits.h"/>
<File
- RelativePath=".\cfft.h">
- </File>
+ RelativePath=".\cfft.h"/>
<File
- RelativePath=".\common.h">
- </File>
+ RelativePath=".\common.h"/>
<File
- RelativePath=".\fftw\config.h">
- </File>
+ RelativePath=".\fftw\config.h"/>
<File
- RelativePath=".\data.h">
- </File>
+ RelativePath=".\data.h"/>
<File
- RelativePath=".\decoder.h">
- </File>
+ RelativePath=".\decoder.h"/>
<File
- RelativePath=".\dither.h">
- </File>
+ RelativePath=".\dither.h"/>
<File
- RelativePath=".\drc.h">
- </File>
+ RelativePath=".\drc.h"/>
<File
- RelativePath=".\error.h">
- </File>
+ RelativePath=".\error.h"/>
<File
- RelativePath=".\filtbank.h">
- </File>
+ RelativePath=".\filtbank.h"/>
<File
- RelativePath="fixed.h">
- </File>
+ RelativePath="fixed.h"/>
<File
- RelativePath=".\codebook\hcb.h">
- </File>
+ RelativePath=".\codebook\hcb.h"/>
<File
- RelativePath=".\huffman.h">
- </File>
+ RelativePath=".\huffman.h"/>
<File
- RelativePath=".\ic_predict.h">
- </File>
+ RelativePath=".\ic_predict.h"/>
<File
- RelativePath=".\is.h">
- </File>
+ RelativePath=".\is.h"/>
<File
- RelativePath=".\kbd_win.h">
- </File>
+ RelativePath=".\kbd_win.h"/>
<File
- RelativePath=".\lt_predict.h">
- </File>
+ RelativePath=".\lt_predict.h"/>
<File
- RelativePath=".\mdct.h">
- </File>
+ RelativePath=".\mdct.h"/>
<File
- RelativePath=".\mp4.h">
- </File>
+ RelativePath=".\mp4.h"/>
<File
- RelativePath=".\ms.h">
- </File>
+ RelativePath=".\ms.h"/>
<File
- RelativePath=".\output.h">
- </File>
+ RelativePath=".\output.h"/>
<File
- RelativePath=".\pns.h">
- </File>
+ RelativePath=".\pns.h"/>
<File
- RelativePath=".\pulse.h">
- </File>
+ RelativePath=".\pulse.h"/>
<File
- RelativePath=".\rvlc_scale_factors.h">
- </File>
+ RelativePath="rvlc.h"/>
<File
- RelativePath=".\specrec.h">
- </File>
+ RelativePath="sine_win.h"/>
<File
- RelativePath=".\syntax.h">
- </File>
+ RelativePath=".\specrec.h"/>
<File
- RelativePath=".\tns.h">
- </File>
+ RelativePath="ssr.h"/>
+ <File
+ RelativePath="ssr_fb.h"/>
+ <File
+ RelativePath="ssr_ipqf.h"/>
+ <File
+ RelativePath="ssr_win.h"/>
+ <File
+ RelativePath="structs.h"/>
+ <File
+ RelativePath=".\syntax.h"/>
+ <File
+ RelativePath=".\tns.h"/>
</Filter>
</Files>
- <Globals>
- </Globals>
+ <Globals/>
</VisualStudioProject>
--- a/libfaad/libfaad2_dll.dsp
+++ b/libfaad/libfaad2_dll.dsp
@@ -25,7 +25,7 @@
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
-CPP=cl.exe
+CPP=xicl6.exe
MTL=midl.exe
RSC=rc.exe
@@ -51,7 +51,7 @@
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
-LINK32=link.exe
+LINK32=xilink6.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
# ADD LINK32 /nologo /dll /machine:I386 /out:"ReleaseDLL/libfaad2.dll"
@@ -77,7 +77,7 @@
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
-LINK32=link.exe
+LINK32=xilink6.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 /nologo /dll /debug /machine:I386 /out:"DebugDLL/libfaad2.dll" /pdbtype:sept
@@ -180,6 +180,10 @@
# End Source File
# Begin Source File
+SOURCE=.\hcr.c
+# End Source File
+# Begin Source File
+
SOURCE=.\ic_predict.c
# End Source File
# Begin Source File
@@ -216,15 +220,15 @@
# End Source File
# Begin Source File
-SOURCE=.\reordered_spectral_data.c
+SOURCE=.\rvlc.c
# End Source File
# Begin Source File
-SOURCE=.\rvlc_scale_factors.c
+SOURCE=.\specrec.c
# End Source File
# Begin Source File
-SOURCE=.\specrec.c
+SOURCE=.\ssr.c
# End Source File
# Begin Source File
@@ -328,11 +332,15 @@
# End Source File
# Begin Source File
-SOURCE=.\rvlc_scale_factors.h
+SOURCE=.\rvlc.h
# End Source File
# Begin Source File
SOURCE=.\specrec.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\ssr.h
# End Source File
# Begin Source File
--- a/libfaad/libfaad2_dll.vcproj
+++ b/libfaad/libfaad2_dll.vcproj
@@ -33,7 +33,16 @@
WarningLevel="3"
SuppressStartupBanner="TRUE"
DebugInformationFormat="4"
- CompileAs="0"/>
+ CompileAs="0"
+ AdditionalOptions="">
+ <IntelOptions
+ Optimization="0"
+ MinimalRebuild="1"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ AllOptions="/c /I "fftw" /ZI /nologo /W3 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_USRDLL" /D "libfaad2_dll_EXPORTS" /D "_WINDLL" /D "_MBCS" /Gm /EHsc /RTC1 /MDd /YX"StdAfx.h" /Fp".\DebugDLL/libfaad2_dll.pch" /Fo".\DebugDLL/" /Fd".\DebugDLL/" /Gd"
+ MSOriginalAdditionalOptions=""/>
+ </Tool>
<Tool
Name="VCCustomBuildTool"/>
<Tool
@@ -46,7 +55,11 @@
ModuleDefinitionFile=".\libfaad2.def"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile=".\DebugDLL/libfaad2.pdb"
- ImportLibrary=".\DebugDLL/libfaad2.lib"/>
+ ImportLibrary=".\DebugDLL/libfaad2.lib">
+ <IntelOptions
+ AllOptions="/NOLOGO /DLL /OUT:"DebugDLL/libfaad2.dll" /INCREMENTAL odbc32.lib odbccp32.lib /DEF:".\libfaad2.def" /DEBUG /PDB:".\DebugDLL/libfaad2.pdb" /TLBID:1 /IMPLIB:".\DebugDLL/libfaad2.lib" /MACHINE:I386 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib"
+ MSOriginalAdditionalOptions="/MACHINE:I386"/>
+ </Tool>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="_DEBUG"
@@ -96,7 +109,20 @@
ProgramDataBaseFileName=".\ReleaseDLL/"
WarningLevel="3"
SuppressStartupBanner="TRUE"
- CompileAs="0"/>
+ CompileAs="0"
+ AdditionalOptions="">
+ <IntelOptions
+ Optimization="2"
+ GlobalOptimizations="1"
+ InlineFuncExpansion="1"
+ OmitFramePtrs="1"
+ StringPooling="1"
+ RuntimeLibrary="2"
+ BufferSecurityCheck="1"
+ FunctionLevelLinking="1"
+ AllOptions="/c /nologo /W3 /O2 /Og /Ob1 /Oy /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_USRDLL" /D "libfaad2_dll_EXPORTS" /D "_WINDLL" /D "_MBCS" /GF /FD /EHsc /MD /GS /Gy /YX"StdAfx.h" /Fp".\ReleaseDLL/libfaad2_dll.pch" /Fo".\ReleaseDLL/" /Fd".\ReleaseDLL/" /Gd"
+ MSOriginalAdditionalOptions=""/>
+ </Tool>
<Tool
Name="VCCustomBuildTool"/>
<Tool
@@ -107,7 +133,11 @@
SuppressStartupBanner="TRUE"
ModuleDefinitionFile=".\libfaad2.def"
ProgramDatabaseFile=".\ReleaseDLL/libfaad2.pdb"
- ImportLibrary=".\ReleaseDLL/libfaad2.lib"/>
+ ImportLibrary=".\ReleaseDLL/libfaad2.lib">
+ <IntelOptions
+ AllOptions="/NOLOGO /DLL /OUT:"ReleaseDLL/libfaad2.dll" /INCREMENTAL:NO /DEF:".\libfaad2.def" /PDB:".\ReleaseDLL/libfaad2.pdb" /TLBID:1 /IMPLIB:".\ReleaseDLL/libfaad2.lib" /MACHINE:I386 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib"
+ MSOriginalAdditionalOptions="/MACHINE:I386"/>
+ </Tool>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
@@ -136,113 +166,80 @@
Name="Source Files"
Filter="">
<File
- RelativePath=".\bits.c">
- </File>
+ RelativePath=".\bits.c"/>
<File
- RelativePath=".\cfft.c">
- </File>
+ RelativePath=".\cfft.c"/>
<File
- RelativePath="common.c">
- </File>
+ RelativePath="common.c"/>
<File
- RelativePath=".\data.c">
- </File>
+ RelativePath=".\data.c"/>
<File
- RelativePath=".\decoder.c">
- </File>
+ RelativePath=".\decoder.c"/>
<File
- RelativePath="dither.c">
- </File>
+ RelativePath="dither.c"/>
<File
- RelativePath=".\drc.c">
- </File>
+ RelativePath=".\drc.c"/>
<File
- RelativePath=".\error.c">
- </File>
+ RelativePath=".\error.c"/>
<File
- RelativePath=".\filtbank.c">
- </File>
+ RelativePath=".\filtbank.c"/>
<File
- RelativePath=".\ic_predict.c">
- </File>
+ RelativePath="hcr.c"/>
<File
- RelativePath=".\is.c">
- </File>
+ RelativePath=".\ic_predict.c"/>
<File
- RelativePath=".\lt_predict.c">
- </File>
+ RelativePath=".\is.c"/>
<File
- RelativePath=".\mdct.c">
- </File>
+ RelativePath=".\lt_predict.c"/>
<File
- RelativePath=".\mp4.c">
- </File>
+ RelativePath=".\mdct.c"/>
<File
- RelativePath=".\ms.c">
- </File>
+ RelativePath=".\mp4.c"/>
<File
- RelativePath=".\output.c">
- </File>
+ RelativePath=".\ms.c"/>
<File
- RelativePath=".\pns.c">
- </File>
+ RelativePath=".\output.c"/>
<File
- RelativePath=".\pulse.c">
- </File>
+ RelativePath=".\pns.c"/>
<File
- RelativePath=".\reordered_spectral_data.c">
- </File>
+ RelativePath=".\pulse.c"/>
<File
- RelativePath=".\rvlc_scale_factors.c">
- </File>
+ RelativePath="rvlc.c"/>
<File
- RelativePath=".\specrec.c">
- </File>
+ RelativePath=".\specrec.c"/>
<File
- RelativePath=".\syntax.c">
- </File>
+ RelativePath="ssr.c"/>
<File
- RelativePath=".\tns.c">
- </File>
+ RelativePath=".\syntax.c"/>
+ <File
+ RelativePath=".\tns.c"/>
<Filter
Name="codebook"
Filter="">
<File
- RelativePath=".\codebook\hcb_1.c">
- </File>
+ RelativePath=".\codebook\hcb_1.c"/>
<File
- RelativePath=".\codebook\hcb_10.c">
- </File>
+ RelativePath=".\codebook\hcb_10.c"/>
<File
- RelativePath=".\codebook\hcb_11.c">
- </File>
+ RelativePath=".\codebook\hcb_11.c"/>
<File
- RelativePath=".\codebook\hcb_2.c">
- </File>
+ RelativePath=".\codebook\hcb_2.c"/>
<File
- RelativePath=".\codebook\hcb_3.c">
- </File>
+ RelativePath=".\codebook\hcb_3.c"/>
<File
- RelativePath=".\codebook\hcb_4.c">
- </File>
+ RelativePath=".\codebook\hcb_4.c"/>
<File
- RelativePath=".\codebook\hcb_5.c">
- </File>
+ RelativePath=".\codebook\hcb_5.c"/>
<File
- RelativePath=".\codebook\hcb_6.c">
- </File>
+ RelativePath=".\codebook\hcb_6.c"/>
<File
- RelativePath=".\codebook\hcb_7.c">
- </File>
+ RelativePath=".\codebook\hcb_7.c"/>
<File
- RelativePath=".\codebook\hcb_8.c">
- </File>
+ RelativePath=".\codebook\hcb_8.c"/>
<File
- RelativePath=".\codebook\hcb_9.c">
- </File>
+ RelativePath=".\codebook\hcb_9.c"/>
<File
- RelativePath=".\codebook\hcb_sf.c">
- </File>
+ RelativePath=".\codebook\hcb_sf.c"/>
</Filter>
</Filter>
<Filter
@@ -249,103 +246,62 @@
Name="Header Files"
Filter="">
<File
- RelativePath=".\Tns.h">
- </File>
+ RelativePath=".\Tns.h"/>
<File
- RelativePath=".\analysis.h">
- </File>
+ RelativePath=".\analysis.h"/>
<File
- RelativePath=".\bits.h">
- </File>
+ RelativePath=".\bits.h"/>
<File
- RelativePath=".\cfft.h">
- </File>
+ RelativePath=".\cfft.h"/>
<File
- RelativePath=".\common.h">
- </File>
+ RelativePath=".\common.h"/>
<File
- RelativePath=".\data.h">
- </File>
+ RelativePath=".\data.h"/>
<File
- RelativePath=".\decoder.h">
- </File>
+ RelativePath=".\decoder.h"/>
<File
- RelativePath="dither.h">
- </File>
+ RelativePath="dither.h"/>
<File
- RelativePath=".\drc.h">
- </File>
+ RelativePath=".\drc.h"/>
<File
- RelativePath=".\error.h">
- </File>
+ RelativePath=".\error.h"/>
<File
- RelativePath=".\filtbank.h">
- </File>
+ RelativePath=".\filtbank.h"/>
<File
- RelativePath=".\codebook\hcb.h">
- </File>
+ RelativePath=".\codebook\hcb.h"/>
<File
- RelativePath=".\huffman.h">
- </File>
+ RelativePath=".\huffman.h"/>
<File
- RelativePath=".\ic_predict.h">
- </File>
+ RelativePath=".\ic_predict.h"/>
<File
- RelativePath=".\is.h">
- </File>
+ RelativePath=".\is.h"/>
<File
- RelativePath=".\kbd_win.h">
- </File>
+ RelativePath=".\kbd_win.h"/>
<File
- RelativePath=".\lt_predict.h">
- </File>
+ RelativePath=".\lt_predict.h"/>
<File
- RelativePath=".\mdct.h">
- </File>
+ RelativePath=".\mdct.h"/>
<File
- RelativePath=".\mp4.h">
- </File>
+ RelativePath=".\mp4.h"/>
<File
- RelativePath=".\ms.h">
- </File>
+ RelativePath=".\ms.h"/>
<File
- RelativePath=".\output.h">
- </File>
+ RelativePath=".\output.h"/>
<File
- RelativePath=".\pns.h">
- </File>
+ RelativePath=".\pns.h"/>
<File
- RelativePath=".\pulse.h">
- </File>
+ RelativePath=".\pulse.h"/>
<File
- RelativePath=".\rvlc_scale_factors.h">
- </File>
+ RelativePath="rvlc.h"/>
<File
- RelativePath="sbr_dec.h">
- </File>
+ RelativePath=".\specrec.h"/>
<File
- RelativePath="sbr_huff.h">
- </File>
+ RelativePath="ssr.h"/>
<File
- RelativePath="sbr_qmf.h">
- </File>
- <File
- RelativePath="sbr_syntax.h">
- </File>
- <File
- RelativePath="sbr_util.h">
- </File>
- <File
- RelativePath=".\specrec.h">
- </File>
- <File
- RelativePath=".\syntax.h">
- </File>
+ RelativePath=".\syntax.h"/>
</Filter>
<File
- RelativePath=".\libfaad2.def">
- </File>
+ RelativePath=".\libfaad2.def"/>
</Files>
- <Globals>
- </Globals>
+ <Globals/>
</VisualStudioProject>
--- a/libfaad/lt_predict.c
+++ b/libfaad/lt_predict.c
@@ -16,11 +16,12 @@
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
**
-** $Id: lt_predict.c,v 1.9 2002/08/27 18:16:12 menno Exp $
+** $Id: lt_predict.c,v 1.10 2002/11/28 18:48:30 menno Exp $
**/
#include "common.h"
+#include "structs.h"
#ifdef LTP_DEC
--- 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.22 2002/11/07 18:24:53 menno Exp $
+** $Id: mdct.c,v 1.23 2002/11/28 18:48:30 menno Exp $
**/
/*
@@ -36,6 +36,7 @@
*/
#include "common.h"
+#include "structs.h"
#include <stdlib.h>
#ifdef _WIN32_WCE
@@ -63,6 +64,10 @@
{ 0xBAF4BA, 0xFFFE990, 0x1ACEDD, 0xFFFFFA0, 0x359DD }, /* 960 */
{ 0x16A09E6, 0xFFEC430, 0x648558, 0xFFFFB10, 0xC90FC }, /* 256 */
{ 0x175E974, 0xFFE98B0, 0x6B3885, 0xFFFFA60, 0xD6773 } /* 240 */
+#ifdef SSR_DEC
+ ,{ 0, 0, 0, 0, 0 }, /* 512 */
+ { 0, 0, 0, 0, 0 } /* 64 */
+#endif
};
#else
#ifdef _MSC_VER
@@ -77,6 +82,10 @@
{ 0.0456435465, 0.9999786019, 0.0065449383, 0.9999996424, 0.0008181230 }, /* 960 */
{ 0.0883883476, 0.9996988177, 0.0245412290, 0.9999952912, 0.0030679568 }, /* 256 */
{ 0.0912870929, 0.9996573329, 0.0261769500, 0.9999946356, 0.0032724866 } /* 240 */
+#ifdef SSR_DEC
+ ,{ 0.062500000, 0.999924702, 0.012271538, 0.999998823, 0.00153398 }, /* 512 */
+ { 0.176776695, 0.995184727, 0.09801714, 0.999924702, 0.012271538 } /* 64 */
+#endif
};
#endif
@@ -90,6 +99,10 @@
case 960: return 3;
case 256: return 4;
case 240: return 5;
+#ifdef SSR_DEC
+ case 512: return 6;
+ case 64: return 7;
+#endif
}
return 0;
}
--- 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.12 2002/09/26 19:01:45 menno Exp $
+** $Id: mdct.h,v 1.13 2002/11/28 18:48:30 menno Exp $
**/
#ifndef __MDCT_H__
@@ -27,13 +27,6 @@
#endif
#include "cfft.h"
-
-typedef struct {
- uint16_t N;
- cfft_info *cfft;
- complex_t *sincos;
- complex_t *Z1;
-} mdct_info;
mdct_info *faad_mdct_init(uint16_t N);
void faad_mdct_end(mdct_info *mdct);
--- a/libfaad/mp4.c
+++ b/libfaad/mp4.c
@@ -16,10 +16,12 @@
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
**
-** $Id: mp4.c,v 1.12 2002/11/01 11:19:35 menno Exp $
+** $Id: mp4.c,v 1.13 2002/11/28 18:48:30 menno Exp $
**/
#include "common.h"
+#include "structs.h"
+
#include "bits.h"
#include "mp4.h"
#include "data.h"
@@ -34,7 +36,11 @@
0, /* 1 AAC Main */
#endif
1, /* 2 AAC LC */
+#ifdef SSR_DEC
+ 1, /* 3 AAC SSR */
+#else
0, /* 3 AAC SSR */
+#endif
#ifdef LTP_DEC
1, /* 4 AAC LTP */
#else
@@ -106,6 +112,8 @@
uint8_t *frameLengthFlag)
{
bitfile ld;
+ uint8_t ep_config = 0;
+ int8_t result = 0;
uint8_t ObjectTypeIndex, SamplingFrequencyIndex, ChannelsConfiguration;
faad_initbits(&ld, pBuffer, buffer_size);
@@ -129,16 +137,19 @@
if (ObjectTypesTable[ObjectTypeIndex] != 1)
{
+ faad_endbits(&ld);
return -1;
}
if (*samplerate == 0)
{
+ faad_endbits(&ld);
return -2;
}
if (ChannelsConfiguration > 7)
{
+ faad_endbits(&ld);
return -3;
}
@@ -147,7 +158,7 @@
ObjectTypeIndex == 3 || ObjectTypeIndex == 4 ||
ObjectTypeIndex == 6 || ObjectTypeIndex == 7)
{
- return GASpecificConfig(&ld, channels, ObjectTypeIndex,
+ result = GASpecificConfig(&ld, channels, ObjectTypeIndex,
#ifdef ERROR_RESILIENCE
aacSectionDataResilienceFlag,
aacScalefactorDataResilienceFlag,
@@ -156,7 +167,7 @@
frameLengthFlag);
#ifdef ERROR_RESILIENCE
} else if (ObjectTypeIndex >= ER_OBJECT_START) { /* ER */
- int8_t result = GASpecificConfig(&ld, channels, ObjectTypeIndex,
+ result = GASpecificConfig(&ld, channels, ObjectTypeIndex,
#ifdef ERROR_RESILIENCE
aacSectionDataResilienceFlag,
aacScalefactorDataResilienceFlag,
@@ -163,16 +174,23 @@
aacSpectralDataResilienceFlag,
#endif
frameLengthFlag);
- uint8_t ep_config = (uint8_t)faad_getbits(&ld, 2
+ ep_config = (uint8_t)faad_getbits(&ld, 2
DEBUGVAR(1,143,"parse_audio_decoder_specific_info(): epConfig"));
- if (ep_config != 0)
- return -5;
- return result;
+ if (ep_config != 0)
+ result = -5;
#endif
} else {
- return -4;
+ result = -4;
}
- return 0;
+#ifdef SSR_DEC
+ /* shorter frames not allowed for SSR */
+ if ((ObjectTypeIndex == 4) && *frameLengthFlag)
+ return -6;
+#endif
+
+ faad_endbits(&ld);
+
+ return result;
}
--- a/libfaad/ms.c
+++ b/libfaad/ms.c
@@ -16,10 +16,12 @@
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
**
-** $Id: ms.c,v 1.3 2002/06/13 11:03:27 menno Exp $
+** $Id: ms.c,v 1.4 2002/11/28 18:48:30 menno Exp $
**/
#include "common.h"
+#include "structs.h"
+
#include "syntax.h"
#include "ms.h"
#include "is.h"
--- a/libfaad/output.c
+++ b/libfaad/output.c
@@ -16,10 +16,11 @@
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
**
-** $Id: output.c,v 1.13 2002/09/13 13:08:45 menno Exp $
+** $Id: output.c,v 1.14 2002/11/28 18:48:30 menno Exp $
**/
#include "common.h"
+#include "structs.h"
#include "output.h"
#include "decoder.h"
--- a/libfaad/pns.c
+++ b/libfaad/pns.c
@@ -16,10 +16,11 @@
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
**
-** $Id: pns.c,v 1.18 2002/10/01 21:55:49 menno Exp $
+** $Id: pns.c,v 1.19 2002/11/28 18:48:30 menno Exp $
**/
#include "common.h"
+#include "structs.h"
#include "pns.h"
--- a/libfaad/pulse.c
+++ b/libfaad/pulse.c
@@ -16,10 +16,12 @@
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
**
-** $Id: pulse.c,v 1.2 2002/02/18 10:01:05 menno Exp $
+** $Id: pulse.c,v 1.3 2002/11/28 18:48:30 menno Exp $
**/
#include "common.h"
+#include "structs.h"
+
#include "syntax.h"
#include "pulse.h"
--- a/libfaad/reordered_spectral_data.c
+++ /dev/null
@@ -1,619 +1,0 @@
-#include <stdlib.h>
-#include <string.h>
-#include "common.h"
-#include "syntax.h"
-#include "specrec.h"
-#include "bits.h"
-#include "data.h"
-#include "pulse.h"
-#include "analysis.h"
-#include "bits.h"
-#include "codebook/hcb.h"
-
-/* Implements the HCR11 tool as described in ISO/IEC 14496-3/Amd.1, 8.5.3.3 */
-
-#ifdef ERROR_RESILIENCE
-
-//FIXME these tables are not needed twice actually
-
-static hcb *hcb_table[] = {
- 0, hcb1_1, hcb2_1, 0, hcb4_1, 0, hcb6_1, 0, hcb8_1, 0, hcb10_1, hcb11_1
-};
-
-static hcb_2_quad *hcb_2_quad_table[] = {
- 0, hcb1_2, hcb2_2, 0, hcb4_2, 0, 0, 0, 0, 0, 0, 0
-};
-
-static hcb_2_pair *hcb_2_pair_table[] = {
- 0, 0, 0, 0, 0, 0, hcb6_2, 0, hcb8_2, 0, hcb10_2, hcb11_2
-};
-
-static hcb_bin_pair *hcb_bin_table[] = {
- 0, 0, 0, 0, 0, hcb5, 0, hcb7, 0, hcb9, 0, 0
-};
-
-static uint8_t hcbN[] = { 0, 5, 5, 0, 5, 0, 5, 0, 5, 0, 6, 5 };
-
-
-/* defines whether a huffman codebook is unsigned or not */
-/* Table 4.6.2 */
-static uint8_t unsigned_cb[] = { 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0,
- /* codebook 16 to 31 */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
-};
-typedef struct
-{
- /* bit input */
- uint32_t bufa;
- uint32_t bufb;
- int8_t len;
-} bits_t;
-
-
-static INLINE uint32_t showbits(bits_t *ld, uint8_t bits)
-{
- if (bits == 0) return 0;
- if (ld->len <= 32){
- /* huffman_spectral_data_2 needs to read more than may be available, bits maybe
- > ld->len, deliver 0 than */
- if (ld->len >= bits)
- return ((ld->bufa >> (ld->len - bits)) & (0xFFFFFFFF >> (32 - bits)));
- else
- return ((ld->bufa << (bits - ld->len)) & (0xFFFFFFFF >> (32 - bits)));
- } else {
- if ((ld->len - bits) < 32)
- {
- return ( (ld->bufb & (0xFFFFFFFF >> (64 - ld->len))) << (bits - ld->len + 32)) |
- (ld->bufa >> (ld->len - bits));
- } else {
- return ((ld->bufb >> (ld->len - bits - 32)) & (0xFFFFFFFF >> (32 - bits)));
- }
- }
-}
-
-/* return 1 if position is outside of buffer, 0 otherwise */
-static INLINE int8_t flushbits( bits_t *ld, uint8_t bits)
-{
- ld->len -= bits;
-
- if (ld->len <0)
- {
- ld->len = 0;
- return 1;
- } else {
- return 0;
- }
-}
-
-
-static INLINE int8_t getbits(bits_t *ld, uint8_t n, uint32_t *result)
-{
- *result = showbits(ld, n);
- return flushbits(ld, n);
-}
-
-static INLINE int8_t get1bit(bits_t *ld, uint8_t *result)
-{
- uint32_t res;
- int8_t ret;
-
- ret = getbits(ld, 1, &res);
- *result = res & 1;
- return ret;
-}
-
-/* Special version of huffman_spectral_data adapted from huffman.h
-Will not read from a bitfile but a bits_t structure.
-Will keep track of the bits decoded and return the number of bits remaining.
-Do not read more than ld->len, return -1 if codeword would be longer */
-
-static int8_t huffman_spectral_data_2(uint8_t cb, bits_t *ld, int16_t *sp )
-{
- uint32_t cw;
- uint16_t offset = 0;
- uint8_t extra_bits;
- uint8_t i;
- uint8_t save_cb = cb;
-
-
- switch (cb)
- {
- case 1: /* 2-step method for data quadruples */
- case 2:
- case 4:
-
- cw = showbits(ld, hcbN[cb]);
- offset = hcb_table[cb][cw].offset;
- extra_bits = hcb_table[cb][cw].extra_bits;
-
- if (extra_bits)
- {
- /* we know for sure it's more than hcbN[cb] bits long */
- if ( flushbits(ld, hcbN[cb]) ) return -1;
- offset += (uint16_t)showbits(ld, extra_bits);
- if ( flushbits(ld, hcb_2_quad_table[cb][offset].bits - hcbN[cb]) ) return -1;
- } else {
- if ( flushbits(ld, hcb_2_quad_table[cb][offset].bits) ) return -1;
- }
-
- sp[0] = hcb_2_quad_table[cb][offset].x;
- sp[1] = hcb_2_quad_table[cb][offset].y;
- sp[2] = hcb_2_quad_table[cb][offset].v;
- sp[3] = hcb_2_quad_table[cb][offset].w;
- break;
-
- case 6: /* 2-step method for data pairs */
- case 8:
- case 10:
- case 11:
- /* VCB11 uses codebook 11 */
- case 16: case 17: case 18: case 19: case 20: case 21: case 22: case 23:
- case 24: case 25: case 26: case 27: case 28: case 29: case 30: case 31:
-
- /* TODO: If ER is used, some extra error checking should be done */
- if (cb >= 16)
- cb = 11;
-
- cw = showbits(ld, hcbN[cb]);
- offset = hcb_table[cb][cw].offset;
- extra_bits = hcb_table[cb][cw].extra_bits;
-
- if (extra_bits)
- {
- /* we know for sure it's more than hcbN[cb] bits long */
- if ( flushbits(ld, hcbN[cb]) ) return -1;
- offset += (uint16_t)showbits(ld, extra_bits);
- if ( flushbits(ld, hcb_2_pair_table[cb][offset].bits - hcbN[cb]) ) return -1;
- } else {
- if ( flushbits(ld, hcb_2_pair_table[cb][offset].bits) ) return -1;
- }
- sp[0] = hcb_2_pair_table[cb][offset].x;
- sp[1] = hcb_2_pair_table[cb][offset].y;
- break;
-
- case 3: /* binary search for data quadruples */
-
- while (!hcb3[offset].is_leaf)
- {
- uint8_t b;
-
- if ( get1bit(ld, &b) ) return -1;
- offset += hcb3[offset].data[b];
- }
-
- sp[0] = hcb3[offset].data[0];
- sp[1] = hcb3[offset].data[1];
- sp[2] = hcb3[offset].data[2];
- sp[3] = hcb3[offset].data[3];
-
- break;
-
- case 5: /* binary search for data pairs */
- case 7:
- case 9:
-
- while (!hcb_bin_table[cb][offset].is_leaf)
- {
- uint8_t b;
-
- if (get1bit(ld, &b) ) return -1;
- offset += hcb_bin_table[cb][offset].data[b];
- }
-
- sp[0] = hcb_bin_table[cb][offset].data[0];
- sp[1] = hcb_bin_table[cb][offset].data[1];
-
- break;
- }
-
- /* decode sign bits */
- if (unsigned_cb[cb]) {
-
- for(i = 0; i < ((cb < FIRST_PAIR_HCB) ? QUAD_LEN : PAIR_LEN); i++)
- {
- if(sp[i])
- {
- uint8_t b;
- if ( get1bit(ld, &b) ) return -1;
- if (b != 0) {
- sp[i] = -sp[i];
- }
- }
- }
- }
-
- /* decode huffman escape bits */
- if ((cb == ESC_HCB) || (cb >= 16))
- {
- uint8_t k;
- for (k = 0; k < 2; k++)
- {
- if ((sp[k] == 16) || (sp[k] == -16))
- {
- uint8_t neg, i;
- int32_t j;
- uint32_t off;
-
- neg = (sp[k] < 0) ? 1 : 0;
-
- for (i = 4; ; i++)
- {
- uint8_t b;
- if (get1bit(ld, &b))
- return -1;
- if (b == 0)
- break;
- }
-// TODO: here we would need to test "off" if VCB11 is used!
- if (getbits(ld, i, &off))
- return -1;
- j = off + (1<<i);
- sp[k] = neg ? -j : j;
- }
- }
- }
- return ld->len;
-}
-
-/* rewind len (max. 32) bits so that the MSB becomes LSB */
-
-static uint32_t rewind_word( uint32_t W, uint8_t len)
-{
- uint8_t i;
- uint32_t tmp_W=0;
-
- for ( i=0; i<len; i++ )
- {
- tmp_W<<=1;
- if (W & (1<<i)) tmp_W |= 1;
- }
- return tmp_W;
-}
-
-static void rewind_lword( uint32_t *highW, uint32_t *lowW, uint8_t len)
-{
- uint32_t tmp_lW=0;
-
- if (len > 32)
- {
- tmp_lW = rewind_word( (*highW << (64-len)) | (*lowW >> (len-32)), 32);
- *highW = rewind_word( *lowW << (64-len) , 32);
- *lowW = tmp_lW;
- } else {
- *highW = 0;
- *lowW = rewind_word( *lowW, len);
- }
-}
-
-/* Takes a codeword as stored in r, rewinds the remaining bits and stores it back */
-static void rewind_bits(bits_t * r)
-{
- uint32_t hw, lw;
-
- if (r->len == 0) return;
-
- if (r->len >32)
- {
- lw = r->bufa;
- hw = r->bufb & (0xFFFFFFFF >> (64 - r->len));
- rewind_lword( &hw, &lw, r->len );
- r->bufa = lw;
- r->bufb = hw;
-
- } else {
- lw = showbits(r, r->len );
- r->bufa = rewind_word( lw, r->len);
- r->bufb = 0;
- }
-}
-
-/* takes codewords from a and b, concatenate them and store them in b */
-static void concat_bits( bits_t * a, bits_t * b)
-{
- uint32_t hwa, lwa, hwb, lwb;
-
- if (a->len == 0) return;
-
- if (a->len >32)
- {
- lwa = a->bufa;
- hwa = a->bufb & (0xFFFFFFFF >> (64 - a->len));
- } else {
- lwa = showbits(a, a->len );
- hwa = 0;
- }
- if (b->len >=32) {
- lwb = b->bufa;
- hwb = (b->bufb & (0xFFFFFFFF >> (64 - b->len)) ) | ( lwa << (b->len - 32));
- } else {
- lwb = showbits(b, b->len ) | (lwa << (b->len));
- hwb = (lwa >> (32 - b->len)) | (hwa << (b->len));
- }
-
- b->bufa = lwb;
- b->bufb = hwb;
- b->len += a->len;
-}
-
-/* 8.5.3.3.1 */
-
-static const uint8_t PresortedCodebook_VCB11[] = { 11, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 9, 7, 5, 3, 1};
-static const uint8_t PresortedCodebook[] = { 11, 9, 7, 5, 3, 1};
-
-static const uint8_t maxCwLen[32] = {0, 11, 9, 20, 16, 13, 11, 14, 12, 17, 14, 49,
- 0, 0, 0, 0, 14, 17, 21, 21, 25, 25, 29, 29, 29, 29, 33, 33, 33, 37, 37, 41};
-
-typedef struct
-{
- bits_t bits;
- uint8_t decoded;
- uint16_t sp_offset;
- uint8_t cb;
-} codeword_state;
-
-
-#define segmentWidth( codebook ) min( maxCwLen[codebook], ics->length_of_longest_codeword )
-
-uint8_t reordered_spectral_data(ic_stream *ics, bitfile *ld, int16_t *spectral_data,
- uint16_t frame_len, uint8_t aacSectionDataResilienceFlag)
-{
- uint16_t sp_offset[8];
- uint16_t g,i, presort;
- uint16_t NrCodeWords=0, numberOfSegments=0, BitsRead=0;
- uint8_t numberOfSets, set;
- codeword_state Codewords[ 1024 ]; // FIXME max length? PCWs are not stored, so index is Codewordnr - numberOfSegments!, maybe malloc()?
- bits_t Segment[ 512 ];
-
- uint8_t PCW_decoded=0;
- uint16_t segment_index=0, codeword_index=0;
- uint16_t nshort = frame_len/8;
-
-
- memset (spectral_data, 0, frame_len*sizeof(uint16_t));
-
- if (ics->length_of_reordered_spectral_data == 0)
- return 0; /* nothing to do */
-
- /* if we have a corrupted bitstream this can happen... */
- if ((ics->length_of_longest_codeword == 0) ||
- (ics->length_of_reordered_spectral_data <
- ics->length_of_longest_codeword))
- {
- return 10; /* this is not good... */
- }
-
- /* store the offset into the spectral data for all the window groups because we can't do it later */
-
- sp_offset[0] = 0;
- for (g=1; g < ics->num_window_groups; g++)
- {
- sp_offset[g] = sp_offset[g-1] + nshort*ics->window_group_length[g-1];
- }
-
- /* All data is sorted according to the codebook used */
- for (presort = 0; presort < (aacSectionDataResilienceFlag ? 22 : 6); presort++)
- {
- uint8_t sfb;
-
- /* next codebook that has to be processed according to presorting */
- uint8_t nextCB = aacSectionDataResilienceFlag ? PresortedCodebook_VCB11[ presort ] : PresortedCodebook[ presort ];
-
- /* Data belonging to the same spectral unit and having the same codebook comes in consecutive codewords.
- This is done by scanning all sfbs for possible codewords. For sfbs with more than 4 elements this has to be
- repeated */
-
- for (sfb=0; sfb<ics->max_sfb; sfb ++)
- {
- uint8_t sect_cb, w;
-
- for (w=0; w< (ics->swb_offset[sfb+1] - ics->swb_offset[sfb]); w+=4)
- {
- for(g = 0; g < ics->num_window_groups; g++)
- {
- for (i = 0; i < ics->num_sec[g]; i++)
- {
- sect_cb = ics->sect_cb[g][i];
-
- if (
- /* process only sections that are due now */
- (( sect_cb == nextCB ) || (( nextCB < ESC_HCB ) && ( sect_cb == nextCB+1)) ) &&
-
- /* process only sfb's that are due now */
- ((ics->sect_start[g][i] <= sfb) && (ics->sect_end[g][i] > sfb))
- )
- {
- if ((sect_cb != ZERO_HCB) &&
- (sect_cb != NOISE_HCB) &&
- (sect_cb != INTENSITY_HCB) &&
- (sect_cb != INTENSITY_HCB2))
- {
- uint8_t inc = (sect_cb < FIRST_PAIR_HCB) ? QUAD_LEN : PAIR_LEN;
- uint16_t k;
-
- uint32_t hw, lw;
-
- for (k=0; (k < (4/inc)*ics->window_group_length[g]) &&
- ( (k+w*ics->window_group_length[g]/inc) < (ics->sect_sfb_offset[g][sfb+1] - ics->sect_sfb_offset[g][sfb])); k++)
- {
- uint16_t sp = sp_offset[g] + ics->sect_sfb_offset[g][sfb] + inc*(k+w*ics->window_group_length[g]/inc);
-
- if (!PCW_decoded)
- {
- /* if we haven't yet read until the end of the buffer, we can directly decode the so-called PCWs */
- if ((BitsRead + segmentWidth( sect_cb ))<= ics->length_of_reordered_spectral_data)
- {
- Segment[ numberOfSegments ].len = segmentWidth( sect_cb );
-
- if (segmentWidth( sect_cb ) > 32)
- {
- Segment[ numberOfSegments ].bufb = faad_showbits(ld, segmentWidth( sect_cb ) - 32);
- faad_flushbits(ld, segmentWidth( sect_cb) - 32);
- Segment[ numberOfSegments ].bufa = faad_showbits(ld, 32),
- faad_flushbits(ld, 32 );
-
- } else {
- Segment[ numberOfSegments ].bufa = faad_showbits(ld, segmentWidth( sect_cb ));
- Segment[ numberOfSegments ].bufb = 0;
- faad_flushbits(ld, segmentWidth( sect_cb) );
- }
-
- huffman_spectral_data_2(sect_cb, &Segment[ numberOfSegments ], &spectral_data[sp]);
-
- BitsRead += segmentWidth( sect_cb );
-
- /* skip to next segment, but store left bits in new buffer */
- rewind_bits( &Segment[ numberOfSegments ]);
-
- numberOfSegments++;
- } else {
-
- /* the last segment is extended until length_of_reordered_spectral_data */
-
- if (BitsRead < ics->length_of_reordered_spectral_data)
- {
-
- uint8_t additional_bits = (ics->length_of_reordered_spectral_data - BitsRead);
-
- if ( additional_bits > 32)
- {
- hw = faad_showbits(ld, additional_bits - 32);
- faad_flushbits(ld, additional_bits - 32);
- lw = faad_showbits(ld, 32);
- faad_flushbits(ld, 32 );
- } else {
- lw = faad_showbits(ld, additional_bits);
- hw = 0;
- faad_flushbits(ld, additional_bits );
- }
- rewind_lword( &hw, &lw, additional_bits + Segment[ numberOfSegments-1 ].len );
- if (Segment[ numberOfSegments-1 ].len > 32)
- {
- Segment[ numberOfSegments-1 ].bufb = hw +
- showbits(&Segment[ numberOfSegments-1 ], Segment[ numberOfSegments-1 ].len - 32);
- Segment[ numberOfSegments-1 ].bufa = lw +
- showbits(&Segment[ numberOfSegments-1 ], 32);
- } else {
- Segment[ numberOfSegments-1 ].bufa = lw +
- showbits(&Segment[ numberOfSegments-1 ], Segment[ numberOfSegments-1 ].len);
- Segment[ numberOfSegments-1 ].bufb = hw;
- }
- Segment[ numberOfSegments-1 ].len += additional_bits;
- }
- BitsRead = ics->length_of_reordered_spectral_data;
- PCW_decoded = 1;
-
- Codewords[ 0 ].sp_offset = sp;
- Codewords[ 0 ].cb = sect_cb;
- Codewords[ 0 ].decoded = 0;
- Codewords[ 0 ].bits.len = 0;
- }
- } else {
- Codewords[ NrCodeWords - numberOfSegments ].sp_offset = sp;
- Codewords[ NrCodeWords - numberOfSegments ].cb = sect_cb;
- Codewords[ NrCodeWords - numberOfSegments ].decoded = 0;
- Codewords[ NrCodeWords - numberOfSegments ].bits.len = 0;
-
- } /* PCW decoded */
- NrCodeWords++;
- } /* of k */
- }
- }
- } /* of i */
- } /* of g */
- } /* of w */
- } /* of sfb */
- } /* of presort */
-
- numberOfSets = NrCodeWords / numberOfSegments;
-
- /* second step: decode nonPCWs */
-
- for (set = 1; set <= numberOfSets; set++)
- {
- uint16_t trial;
-
- for (trial = 0; trial < numberOfSegments; trial++)
- {
- uint16_t codewordBase;
- uint16_t set_decoded=numberOfSegments;
-
- if (set == numberOfSets)
- set_decoded = NrCodeWords - set*numberOfSegments; /* last set is shorter than the rest */
-
- for (codewordBase = 0; codewordBase < numberOfSegments; codewordBase++)
- {
- uint16_t segment_index = (trial + codewordBase) % numberOfSegments;
- uint16_t codeword_index = codewordBase + set*numberOfSegments - numberOfSegments;
-
- if ((codeword_index + numberOfSegments) >= NrCodeWords)
- break;
- if (!Codewords[ codeword_index ].decoded)
- {
- if ( Segment[ segment_index ].len > 0)
- {
- uint8_t tmplen;
-
- if (Codewords[ codeword_index ].bits.len != 0)
- {
- /* on the first trial the data is only stored in Segment[], not in Codewords[].
- On next trials first collect the data stored for this codeword and
- concatenate the new data from Segment[] */
-
- concat_bits( &Codewords[ codeword_index ].bits, &Segment[ segment_index ]);
- /* Now everthing is stored in Segment[] */
- }
- tmplen = Segment[ segment_index ].len;
- if ( huffman_spectral_data_2(Codewords[ codeword_index ].cb, &Segment[ segment_index ],
- &spectral_data[ Codewords[ codeword_index ].sp_offset ]) >=0)
- {
- /* CW did fit into segment */
-
- Codewords[ codeword_index ].decoded = 1;
- set_decoded--;
- } else {
-
- /* CW did not fit, so store for later use */
-
- Codewords[ codeword_index ].bits.len = tmplen;
- Codewords[ codeword_index ].bits.bufa = Segment[ segment_index ].bufa;
- Codewords[ codeword_index ].bits.bufb = Segment[ segment_index ].bufb;
- }
- }
- }
- } /* of codewordBase */
-
- if (set_decoded == 0) break; /* no undecoded codewords left in this set */
-
- } /* of trial */
-
- /* rewind all bits in remaining segments with len>0 */
- for (i=0; i < numberOfSegments; i++)
- rewind_bits( &Segment[ i ] );
- }
-
-#if 0
- {
- int i, r=0, c=0;
- for (i=0; i< numberOfSegments; i++)
- r += Segment[ i ].len;
- if (r != 0)
- {
- printf("reordered_spectral_data: %d bits remaining!\n", r);
- }
- for (i=0; i< NrCodeWords - numberOfSegments; i++)
- {
- if (Codewords[ i ].decoded == 0)
- {
- c++;
- }
- }
- if (c != 0)
- {
- printf("reordered_spectral_data: %d Undecoded Codewords remaining!\n",c );
- }
- if ((r !=0) || (c!=0)) return 10;
- }
-#endif
-
- return 0;
-}
-#endif
--- /dev/null
+++ b/libfaad/rvlc.c
@@ -1,0 +1,510 @@
+/*
+** FAAD - Freeware Advanced Audio Decoder
+** Copyright (C) 2002 M. Bakker
+**
+** 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
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+**
+** $Id: rvlc.c,v 1.1 2002/11/28 18:48:30 menno Exp $
+**/
+
+/* RVLC scalefactor decoding
+ *
+ * RVLC works like this:
+ * 1. Only symmetric huffman codewords are used
+ * 2. Total length of the scalefactor data is stored in the bitsream
+ * 3. Scalefactors are DPCM coded
+ * 4. Next to the starting value for DPCM the ending value is also stored
+ *
+ * With all this it is possible to read the scalefactor data from 2 sides.
+ * If there is a bit error in the scalefactor data it is possible to start
+ * decoding from the other end of the data, to find all but 1 scalefactor.
+ */
+
+#include "common.h"
+#include "structs.h"
+
+#include <stdlib.h>
+
+#include "syntax.h"
+#include "bits.h"
+#include "rvlc.h"
+
+
+#ifdef ERROR_RESILIENCE
+
+//#define PRINT_RVLC
+
+uint8_t rvlc_scale_factor_data(ic_stream *ics, bitfile *ld)
+{
+ uint8_t bits = 9;
+
+ ics->sf_concealment = faad_get1bit(ld
+ DEBUGVAR(1,149,"rvlc_scale_factor_data(): sf_concealment"));
+ ics->rev_global_gain = faad_getbits(ld, 8
+ DEBUGVAR(1,150,"rvlc_scale_factor_data(): rev_global_gain"));
+
+ if (ics->window_sequence == EIGHT_SHORT_SEQUENCE)
+ bits = 11;
+
+ /* the number of bits used for the huffman codewords */
+ ics->length_of_rvlc_sf = faad_getbits(ld, bits
+ DEBUGVAR(1,151,"rvlc_scale_factor_data(): length_of_rvlc_sf"));
+
+ if (ics->noise_used)
+ {
+ ics->dpcm_noise_nrg = faad_getbits(ld, 9
+ DEBUGVAR(1,152,"rvlc_scale_factor_data(): dpcm_noise_nrg"));
+
+ ics->length_of_rvlc_sf -= 9;
+ }
+
+ ics->sf_escapes_present = faad_get1bit(ld
+ DEBUGVAR(1,153,"rvlc_scale_factor_data(): sf_escapes_present"));
+
+ if (ics->sf_escapes_present)
+ {
+ ics->length_of_rvlc_escapes = faad_getbits(ld, 8
+ DEBUGVAR(1,154,"rvlc_scale_factor_data(): length_of_rvlc_escapes"));
+ }
+
+ if (ics->noise_used)
+ {
+ ics->dpcm_noise_last_position = faad_getbits(ld, 9
+ DEBUGVAR(1,155,"rvlc_scale_factor_data(): dpcm_noise_last_position"));
+ }
+
+ return 0;
+}
+
+uint8_t rvlc_decode_scale_factors(ic_stream *ics, bitfile *ld)
+{
+ uint8_t result;
+ uint8_t intensity_used = 0;
+ uint8_t *rvlc_sf_buffer = NULL;
+ uint8_t *rvlc_esc_buffer = NULL;
+ bitfile ld_rvlc_sf, ld_rvlc_esc;
+// bitfile ld_rvlc_sf_rev, ld_rvlc_esc_rev;
+
+ if (ics->length_of_rvlc_sf > 0)
+ {
+ /* We read length_of_rvlc_sf bits here to put it in a
+ seperate bitfile.
+ */
+ rvlc_sf_buffer = faad_getbitbuffer(ld, ics->length_of_rvlc_sf
+ DEBUGVAR(1,156,"rvlc_decode_scale_factors(): bitbuffer: length_of_rvlc_sf"));
+
+ faad_initbits(&ld_rvlc_sf, (void*)rvlc_sf_buffer, bit2byte(ics->length_of_rvlc_sf));
+// faad_initbits_rev(&ld_rvlc_sf_rev, (void*)rvlc_sf_buffer,
+// ics->length_of_rvlc_sf);
+ }
+
+ if (ics->sf_escapes_present)
+ {
+ /* We read length_of_rvlc_escapes bits here to put it in a
+ seperate bitfile.
+ */
+ rvlc_esc_buffer = faad_getbitbuffer(ld, ics->length_of_rvlc_escapes
+ DEBUGVAR(1,157,"rvlc_decode_scale_factors(): bitbuffer: length_of_rvlc_escapes"));
+
+ faad_initbits(&ld_rvlc_esc, (void*)rvlc_esc_buffer, bit2byte(ics->length_of_rvlc_escapes));
+// faad_initbits_rev(&ld_rvlc_esc_rev, (void*)rvlc_esc_buffer,
+// ics->length_of_rvlc_escapes);
+ }
+
+ /* decode the rvlc scale factors and escapes */
+ result = rvlc_decode_sf_forward(ics, &ld_rvlc_sf,
+ &ld_rvlc_esc, &intensity_used);
+// result = rvlc_decode_sf_reverse(ics, &ld_rvlc_sf_rev,
+// &ld_rvlc_esc_rev, intensity_used);
+
+
+ if (rvlc_esc_buffer) free(rvlc_esc_buffer);
+ if (rvlc_sf_buffer) free(rvlc_sf_buffer);
+
+ faad_endbits(&ld_rvlc_sf);
+ faad_endbits(&ld_rvlc_esc);
+
+ return result;
+}
+
+static uint8_t rvlc_decode_sf_forward(ic_stream *ics, bitfile *ld_sf, bitfile *ld_esc,
+ uint8_t *intensity_used)
+{
+ int8_t g, sfb;
+ int8_t t = 0;
+ int8_t error = 0;
+ int8_t noise_pcm_flag = 1;
+
+ int16_t scale_factor = ics->global_gain;
+ int16_t is_position = 0;
+ int16_t noise_energy = ics->global_gain - 90 - 256;
+
+#ifdef PRINT_RVLC
+ printf("\nglobal_gain: %d\n", ics->global_gain);
+#endif
+
+ for (g = 0; g < ics->num_window_groups; g++)
+ {
+ for (sfb = 0; sfb < ics->max_sfb; sfb++)
+ {
+ if (error)
+ {
+ ics->scale_factors[g][sfb] = 0;
+ } else {
+ switch (ics->sfb_cb[g][sfb])
+ {
+ case ZERO_HCB: /* zero book */
+ ics->scale_factors[g][sfb] = 0;
+ break;
+ case INTENSITY_HCB: /* intensity books */
+ case INTENSITY_HCB2:
+
+ *intensity_used = 1;
+
+ /* decode intensity position */
+ t = rvlc_huffman_sf(ld_sf, ld_esc, +1);
+
+ is_position += t;
+ ics->scale_factors[g][sfb] = is_position;
+
+ break;
+ case NOISE_HCB: /* noise books */
+
+ /* decode noise energy */
+ if (noise_pcm_flag)
+ {
+ int16_t n = ics->dpcm_noise_nrg;
+ noise_pcm_flag = 0;
+ noise_energy += n;
+ } else {
+ t = rvlc_huffman_sf(ld_sf, ld_esc, +1);
+ noise_energy += t;
+ }
+
+ ics->scale_factors[g][sfb] = noise_energy;
+
+ break;
+ case BOOKSCL: /* invalid books */
+ return 3;
+ default: /* spectral books */
+
+ /* decode scale factor */
+ t = rvlc_huffman_sf(ld_sf, ld_esc, +1);
+
+ scale_factor += t;
+ if (scale_factor < 0)
+ return 4;
+
+ ics->scale_factors[g][sfb] = scale_factor;
+
+ break;
+ }
+#ifdef PRINT_RVLC
+ printf("%3d:%4d%4d\n", sfb, ics->sfb_cb[g][sfb],
+ ics->scale_factors[g][sfb]);
+#endif
+ if (t == 99)
+ {
+ error = 1;
+ }
+ }
+ }
+ }
+#ifdef PRINT_RVLC
+ printf("\n\n");
+#endif
+
+ return 0;
+}
+
+static uint8_t rvlc_decode_sf_reverse(ic_stream *ics, bitfile *ld_sf, bitfile *ld_esc,
+ uint8_t intensity_used)
+{
+ int8_t g, sfb;
+ int8_t t = 0;
+ int8_t error = 0;
+ int8_t noise_pcm_flag = 1, is_pcm_flag = 1, sf_pcm_flag = 1;
+
+ int16_t scale_factor = ics->rev_global_gain;
+ int16_t is_position = 0;
+ int16_t noise_energy = ics->rev_global_gain;
+
+#ifdef PRINT_RVLC
+ printf("\nrev_global_gain: %d\n", ics->rev_global_gain);
+#endif
+
+ if (intensity_used)
+ {
+ is_position = rvlc_huffman_sf(ld_sf, ld_esc, -1);
+#ifdef PRINT_RVLC
+ printf("is_position: %d\n", is_position);
+#endif
+ }
+
+ for (g = ics->num_window_groups-1; g >= 0; g--)
+ {
+ for (sfb = ics->max_sfb-1; sfb >= 0; sfb--)
+ {
+ if (error)
+ {
+ ics->scale_factors[g][sfb] = 0;
+ } else {
+ switch (ics->sfb_cb[g][sfb])
+ {
+ case ZERO_HCB: /* zero book */
+ ics->scale_factors[g][sfb] = 0;
+ break;
+ case INTENSITY_HCB: /* intensity books */
+ case INTENSITY_HCB2:
+
+ if (is_pcm_flag)
+ {
+ is_pcm_flag = 0;
+ ics->scale_factors[g][sfb] = is_position;
+ } else {
+ t = rvlc_huffman_sf(ld_sf, ld_esc, -1);
+ is_position -= t;
+
+ ics->scale_factors[g][sfb] = is_position;
+ }
+
+ break;
+ case NOISE_HCB: /* noise books */
+
+ /* decode noise energy */
+ if (noise_pcm_flag)
+ {
+ noise_pcm_flag = 0;
+ noise_energy = ics->dpcm_noise_last_position;
+ } else {
+ t = rvlc_huffman_sf(ld_sf, ld_esc, -1);
+ noise_energy -= t;
+ }
+
+ ics->scale_factors[g][sfb] = noise_energy;
+
+ break;
+ case BOOKSCL: /* invalid books */
+ return 3;
+ default: /* spectral books */
+
+ if (sf_pcm_flag || (sfb == 0))
+ {
+ sf_pcm_flag = 0;
+ if (sfb == 0)
+ scale_factor = ics->global_gain;
+ } else {
+ /* decode scale factor */
+ t = rvlc_huffman_sf(ld_sf, ld_esc, -1);
+ scale_factor -= t;
+ }
+
+ ics->scale_factors[g][sfb] = scale_factor;
+
+ if (scale_factor < 0)
+ return 4;
+
+ break;
+ }
+#ifdef PRINT_RVLC
+ printf("%3d:%4d%4d\n", sfb, ics->sfb_cb[g][sfb],
+ ics->scale_factors[g][sfb]);
+#endif
+ if (t == 99)
+ {
+ error = 1;
+ }
+ }
+ }
+ }
+
+#ifdef PRINT_RVLC
+ printf("\n\n");
+#endif
+
+ return 0;
+}
+
+/* index == 99 means not allowed codeword */
+static rvlc_huff_table book_rvlc[] = {
+ /*index length codeword */
+ { 0, 1, 0 }, /* 0 */
+ { -1, 3, 5 }, /* 101 */
+ { 1, 3, 7 }, /* 111 */
+ { -2, 4, 9 }, /* 1001 */
+ { -3, 5, 17 }, /* 10001 */
+ { 2, 5, 27 }, /* 11011 */
+ { -4, 6, 33 }, /* 100001 */
+ { 99, 6, 50 }, /* 110010 */
+ { 3, 6, 51 }, /* 110011 */
+ { 99, 6, 52 }, /* 110100 */
+ { -7, 7, 65 }, /* 1000001 */
+ { 99, 7, 96 }, /* 1100000 */
+ { 99, 7, 98 }, /* 1100010 */
+ { 7, 7, 99 }, /* 1100011 */
+ { 4, 7, 107 }, /* 1101011 */
+ { -5, 8, 129 }, /* 10000001 */
+ { 99, 8, 194 }, /* 11000010 */
+ { 5, 8, 195 }, /* 11000011 */
+ { 99, 8, 212 }, /* 11010100 */
+ { 99, 9, 256 }, /* 100000000 */
+ { -6, 9, 257 }, /* 100000001 */
+ { 99, 9, 426 }, /* 110101010 */
+ { 6, 9, 427 }, /* 110101011 */
+ { 99, 10, 0 } /* Shouldn't come this far */
+};
+
+static rvlc_huff_table book_escape[] = {
+ /*index length codeword */
+ { 1, 2, 0 },
+ { 0, 2, 2 },
+ { 3, 3, 2 },
+ { 2, 3, 6 },
+ { 4, 4, 14 },
+ { 7, 5, 13 },
+ { 6, 5, 15 },
+ { 5, 5, 31 },
+ { 11, 6, 24 },
+ { 10, 6, 25 },
+ { 9, 6, 29 },
+ { 8, 6, 61 },
+ { 13, 7, 56 },
+ { 12, 7, 120 },
+ { 15, 8, 114 },
+ { 14, 8, 242 },
+ { 17, 9, 230 },
+ { 16, 9, 486 },
+ { 19, 10, 463 },
+ { 18, 10, 974 },
+ { 22, 11, 925 },
+ { 20, 11, 1950 },
+ { 21, 11, 1951 },
+ { 23, 12, 1848 },
+ { 25, 13, 3698 },
+ { 24, 14, 7399 },
+ { 26, 15, 14797 },
+ { 49, 19, 236736 },
+ { 50, 19, 236737 },
+ { 51, 19, 236738 },
+ { 52, 19, 236739 },
+ { 53, 19, 236740 },
+ { 27, 20, 473482 },
+ { 28, 20, 473483 },
+ { 29, 20, 473484 },
+ { 30, 20, 473485 },
+ { 31, 20, 473486 },
+ { 32, 20, 473487 },
+ { 33, 20, 473488 },
+ { 34, 20, 473489 },
+ { 35, 20, 473490 },
+ { 36, 20, 473491 },
+ { 37, 20, 473492 },
+ { 38, 20, 473493 },
+ { 39, 20, 473494 },
+ { 40, 20, 473495 },
+ { 41, 20, 473496 },
+ { 42, 20, 473497 },
+ { 43, 20, 473498 },
+ { 44, 20, 473499 },
+ { 45, 20, 473500 },
+ { 46, 20, 473501 },
+ { 47, 20, 473502 },
+ { 48, 20, 473503 },
+ { 99, 21, 0 } /* Shouldn't come this far */
+};
+
+static int8_t rvlc_huffman_sf(bitfile *ld_sf, bitfile *ld_esc,
+ int8_t direction)
+{
+ uint8_t i, j;
+ int8_t index;
+ uint32_t cw;
+ rvlc_huff_table *h = book_rvlc;
+
+ i = h->len;
+ if (direction > 0)
+ cw = faad_getbits(ld_sf, i);
+ else
+ cw = faad_getbits_rev(ld_sf, i);
+
+ while ((cw != h->cw)
+ && (i < 10))
+ {
+ h++;
+ j = h->len-i;
+ i += j;
+ cw <<= j;
+ if (direction > 0)
+ cw |= faad_getbits(ld_sf, j);
+ else
+ cw |= faad_getbits_rev(ld_sf, j);
+ }
+
+ index = h->index;
+
+ if (index == +ESC_VAL)
+ {
+ int8_t esc = rvlc_huffman_esc(ld_esc, direction);
+ if (esc == 99)
+ return 99;
+ index += esc;
+#ifdef PRINT_RVLC
+ printf("esc: %d - ", esc);
+#endif
+ }
+ if (index == -ESC_VAL)
+ {
+ int8_t esc = rvlc_huffman_esc(ld_esc, direction);
+ if (esc == 99)
+ return 99;
+ index -= esc;
+#ifdef PRINT_RVLC
+ printf("esc: %d - ", esc);
+#endif
+ }
+
+ return index;
+}
+
+static int8_t rvlc_huffman_esc(bitfile *ld,
+ int8_t direction)
+{
+ uint8_t i, j;
+ uint32_t cw;
+ rvlc_huff_table *h = book_escape;
+
+ i = h->len;
+ if (direction > 0)
+ cw = faad_getbits(ld, i);
+ else
+ cw = faad_getbits_rev(ld, i);
+
+ while ((cw != h->cw)
+ && (i < 21))
+ {
+ h++;
+ j = h->len-i;
+ i += j;
+ cw <<= j;
+ if (direction > 0)
+ cw |= faad_getbits(ld, j);
+ else
+ cw |= faad_getbits_rev(ld, j);
+ }
+
+ return h->index;
+}
+
+#endif
\ No newline at end of file
--- /dev/null
+++ b/libfaad/rvlc.h
@@ -1,0 +1,59 @@
+/*
+** FAAD - Freeware Advanced Audio Decoder
+** Copyright (C) 2002 M. Bakker
+**
+** 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
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+**
+** $Id: rvlc.h,v 1.1 2002/11/28 18:48:30 menno Exp $
+**/
+
+#ifndef __RVLC_SCF_H__
+#define __RVLC_SCF_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct
+{
+ int8_t index;
+ uint8_t len;
+ uint32_t cw;
+} rvlc_huff_table;
+
+
+#define ESC_VAL 7
+
+
+uint8_t rvlc_scale_factor_data(ic_stream *ics, bitfile *ld);
+uint8_t rvlc_decode_scale_factors(ic_stream *ics, bitfile *ld);
+
+static uint8_t rvlc_decode_sf_forward(ic_stream *ics,
+ bitfile *ld_sf,
+ bitfile *ld_esc,
+ uint8_t *is_used);
+static uint8_t rvlc_decode_sf_reverse(ic_stream *ics,
+ bitfile *ld_sf,
+ bitfile *ld_esc,
+ uint8_t is_used);
+static int8_t rvlc_huffman_sf(bitfile *ld_sf, bitfile *ld_esc,
+ int8_t direction);
+static int8_t rvlc_huffman_esc(bitfile *ld_esc, int8_t direction);
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif
--- a/libfaad/rvlc_scale_factors.c
+++ /dev/null
@@ -1,504 +1,0 @@
-/*
-** FAAD - Freeware Advanced Audio Decoder
-** Copyright (C) 2002 M. Bakker
-**
-** 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
-** the Free Software Foundation; either version 2 of the License, or
-** (at your option) any later version.
-**
-** This program is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-** GNU General Public License for more details.
-**
-** You should have received a copy of the GNU General Public License
-** along with this program; if not, write to the Free Software
-** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-**
-** $Id: rvlc_scale_factors.c,v 1.6 2002/11/01 11:19:36 menno Exp $
-**/
-
-/* RVLC scalefactor decoding
- *
- * RVLC works like this:
- * 1. Only symmetric huffman codewords are used
- * 2. Total length of the scalefactor data is stored in the bitsream
- * 3. Scalefactors are DPCM coded
- * 4. Next to the starting value for DPCM the ending value is also stored
- *
- * With all this it is possible to read the scalefactor data from 2 sides.
- * If there is a bit error in the scalefactor data it is possible to start
- * decoding from the other end of the data, to find all but 1 scalefactor.
- */
-
-#include "common.h"
-#include <stdlib.h>
-#include "syntax.h"
-#include "bits.h"
-#include "rvlc_scale_factors.h"
-
-
-#ifdef ERROR_RESILIENCE
-
-//#define PRINT_RVLC
-
-uint8_t rvlc_scale_factor_data(ic_stream *ics, bitfile *ld)
-{
- uint8_t bits = 9;
-
- ics->sf_concealment = faad_get1bit(ld
- DEBUGVAR(1,149,"rvlc_scale_factor_data(): sf_concealment"));
- ics->rev_global_gain = faad_getbits(ld, 8
- DEBUGVAR(1,150,"rvlc_scale_factor_data(): rev_global_gain"));
-
- if (ics->window_sequence == EIGHT_SHORT_SEQUENCE)
- bits = 11;
-
- /* the number of bits used for the huffman codewords */
- ics->length_of_rvlc_sf = faad_getbits(ld, bits
- DEBUGVAR(1,151,"rvlc_scale_factor_data(): length_of_rvlc_sf"));
-
- if (ics->noise_used)
- {
- ics->dpcm_noise_nrg = faad_getbits(ld, 9
- DEBUGVAR(1,152,"rvlc_scale_factor_data(): dpcm_noise_nrg"));
-
- ics->length_of_rvlc_sf -= 9;
- }
-
- ics->sf_escapes_present = faad_get1bit(ld
- DEBUGVAR(1,153,"rvlc_scale_factor_data(): sf_escapes_present"));
-
- if (ics->sf_escapes_present)
- {
- ics->length_of_rvlc_escapes = faad_getbits(ld, 8
- DEBUGVAR(1,154,"rvlc_scale_factor_data(): length_of_rvlc_escapes"));
- }
-
- if (ics->noise_used)
- {
- ics->dpcm_noise_last_position = faad_getbits(ld, 9
- DEBUGVAR(1,155,"rvlc_scale_factor_data(): dpcm_noise_last_position"));
- }
-
- return 0;
-}
-
-uint8_t rvlc_decode_scale_factors(ic_stream *ics, bitfile *ld)
-{
- uint8_t result;
- uint8_t intensity_used = 0;
- uint8_t *rvlc_sf_buffer = NULL;
- uint8_t *rvlc_esc_buffer = NULL;
- bitfile ld_rvlc_sf, ld_rvlc_esc;
-// bitfile ld_rvlc_sf_rev, ld_rvlc_esc_rev;
-
- if (ics->length_of_rvlc_sf > 0)
- {
- /* We read length_of_rvlc_sf bits here to put it in a
- seperate bitfile.
- */
- rvlc_sf_buffer = faad_getbitbuffer(ld, ics->length_of_rvlc_sf
- DEBUGVAR(1,156,"rvlc_decode_scale_factors(): bitbuffer: length_of_rvlc_sf"));
-
- faad_initbits(&ld_rvlc_sf, (void*)rvlc_sf_buffer, bit2byte(ics->length_of_rvlc_sf));
-// faad_initbits_rev(&ld_rvlc_sf_rev, (void*)rvlc_sf_buffer,
-// ics->length_of_rvlc_sf);
- }
-
- if (ics->sf_escapes_present)
- {
- /* We read length_of_rvlc_escapes bits here to put it in a
- seperate bitfile.
- */
- rvlc_esc_buffer = faad_getbitbuffer(ld, ics->length_of_rvlc_escapes
- DEBUGVAR(1,157,"rvlc_decode_scale_factors(): bitbuffer: length_of_rvlc_escapes"));
-
- faad_initbits(&ld_rvlc_esc, (void*)rvlc_esc_buffer, bit2byte(ics->length_of_rvlc_escapes));
-// faad_initbits_rev(&ld_rvlc_esc_rev, (void*)rvlc_esc_buffer,
-// ics->length_of_rvlc_escapes);
- }
-
- /* decode the rvlc scale factors and escapes */
- result = rvlc_decode_sf_forward(ics, &ld_rvlc_sf,
- &ld_rvlc_esc, &intensity_used);
-// result = rvlc_decode_sf_reverse(ics, &ld_rvlc_sf_rev,
-// &ld_rvlc_esc_rev, intensity_used);
-
-
- if (rvlc_esc_buffer) free(rvlc_esc_buffer);
- if (rvlc_sf_buffer) free(rvlc_sf_buffer);
-
- return result;
-}
-
-static uint8_t rvlc_decode_sf_forward(ic_stream *ics, bitfile *ld_sf, bitfile *ld_esc,
- uint8_t *intensity_used)
-{
- int8_t g, sfb;
- int8_t t = 0;
- int8_t error = 0;
- int8_t noise_pcm_flag = 1;
-
- int16_t scale_factor = ics->global_gain;
- int16_t is_position = 0;
- int16_t noise_energy = ics->global_gain - 90 - 256;
-
-#ifdef PRINT_RVLC
- printf("\nglobal_gain: %d\n", ics->global_gain);
-#endif
-
- for (g = 0; g < ics->num_window_groups; g++)
- {
- for (sfb = 0; sfb < ics->max_sfb; sfb++)
- {
- if (error)
- {
- ics->scale_factors[g][sfb] = 0;
- } else {
- switch (ics->sfb_cb[g][sfb])
- {
- case ZERO_HCB: /* zero book */
- ics->scale_factors[g][sfb] = 0;
- break;
- case INTENSITY_HCB: /* intensity books */
- case INTENSITY_HCB2:
-
- *intensity_used = 1;
-
- /* decode intensity position */
- t = rvlc_huffman_sf(ld_sf, ld_esc, +1);
-
- is_position += t;
- ics->scale_factors[g][sfb] = is_position;
-
- break;
- case NOISE_HCB: /* noise books */
-
- /* decode noise energy */
- if (noise_pcm_flag)
- {
- int16_t n = ics->dpcm_noise_nrg;
- noise_pcm_flag = 0;
- noise_energy += n;
- } else {
- t = rvlc_huffman_sf(ld_sf, ld_esc, +1);
- noise_energy += t;
- }
-
- ics->scale_factors[g][sfb] = noise_energy;
-
- break;
- case BOOKSCL: /* invalid books */
- return 3;
- default: /* spectral books */
-
- /* decode scale factor */
- t = rvlc_huffman_sf(ld_sf, ld_esc, +1);
-
- scale_factor += t;
- if (scale_factor < 0)
- return 4;
-
- ics->scale_factors[g][sfb] = scale_factor;
-
- break;
- }
-#ifdef PRINT_RVLC
- printf("%3d:%4d%4d\n", sfb, ics->sfb_cb[g][sfb],
- ics->scale_factors[g][sfb]);
-#endif
- if (t == 99)
- {
- error = 1;
- }
- }
- }
- }
-#ifdef PRINT_RVLC
- printf("\n\n");
-#endif
-
- return 0;
-}
-
-static uint8_t rvlc_decode_sf_reverse(ic_stream *ics, bitfile *ld_sf, bitfile *ld_esc,
- uint8_t intensity_used)
-{
- int8_t g, sfb;
- int8_t t = 0;
- int8_t error = 0;
- int8_t noise_pcm_flag = 1, is_pcm_flag = 1, sf_pcm_flag = 1;
-
- int16_t scale_factor = ics->rev_global_gain;
- int16_t is_position = 0;
- int16_t noise_energy = ics->rev_global_gain;
-
-#ifdef PRINT_RVLC
- printf("\nrev_global_gain: %d\n", ics->rev_global_gain);
-#endif
-
- if (intensity_used)
- {
- is_position = rvlc_huffman_sf(ld_sf, ld_esc, -1);
-#ifdef PRINT_RVLC
- printf("is_position: %d\n", is_position);
-#endif
- }
-
- for (g = ics->num_window_groups-1; g >= 0; g--)
- {
- for (sfb = ics->max_sfb-1; sfb >= 0; sfb--)
- {
- if (error)
- {
- ics->scale_factors[g][sfb] = 0;
- } else {
- switch (ics->sfb_cb[g][sfb])
- {
- case ZERO_HCB: /* zero book */
- ics->scale_factors[g][sfb] = 0;
- break;
- case INTENSITY_HCB: /* intensity books */
- case INTENSITY_HCB2:
-
- if (is_pcm_flag)
- {
- is_pcm_flag = 0;
- ics->scale_factors[g][sfb] = is_position;
- } else {
- t = rvlc_huffman_sf(ld_sf, ld_esc, -1);
- is_position -= t;
-
- ics->scale_factors[g][sfb] = is_position;
- }
-
- break;
- case NOISE_HCB: /* noise books */
-
- /* decode noise energy */
- if (noise_pcm_flag)
- {
- noise_pcm_flag = 0;
- noise_energy = ics->dpcm_noise_last_position;
- } else {
- t = rvlc_huffman_sf(ld_sf, ld_esc, -1);
- noise_energy -= t;
- }
-
- ics->scale_factors[g][sfb] = noise_energy;
-
- break;
- case BOOKSCL: /* invalid books */
- return 3;
- default: /* spectral books */
-
- if (sf_pcm_flag || (sfb == 0))
- {
- sf_pcm_flag = 0;
- if (sfb == 0)
- scale_factor = ics->global_gain;
- } else {
- /* decode scale factor */
- t = rvlc_huffman_sf(ld_sf, ld_esc, -1);
- scale_factor -= t;
- }
-
- ics->scale_factors[g][sfb] = scale_factor;
-
- if (scale_factor < 0)
- return 4;
-
- break;
- }
-#ifdef PRINT_RVLC
- printf("%3d:%4d%4d\n", sfb, ics->sfb_cb[g][sfb],
- ics->scale_factors[g][sfb]);
-#endif
- if (t == 99)
- {
- error = 1;
- }
- }
- }
- }
-
-#ifdef PRINT_RVLC
- printf("\n\n");
-#endif
-
- return 0;
-}
-
-/* index == 99 means not allowed codeword */
-static rvlc_huff_table book_rvlc[] = {
- /*index length codeword */
- { 0, 1, 0 }, /* 0 */
- { -1, 3, 5 }, /* 101 */
- { 1, 3, 7 }, /* 111 */
- { -2, 4, 9 }, /* 1001 */
- { -3, 5, 17 }, /* 10001 */
- { 2, 5, 27 }, /* 11011 */
- { -4, 6, 33 }, /* 100001 */
- { 99, 6, 50 }, /* 110010 */
- { 3, 6, 51 }, /* 110011 */
- { 99, 6, 52 }, /* 110100 */
- { -7, 7, 65 }, /* 1000001 */
- { 99, 7, 96 }, /* 1100000 */
- { 99, 7, 98 }, /* 1100010 */
- { 7, 7, 99 }, /* 1100011 */
- { 4, 7, 107 }, /* 1101011 */
- { -5, 8, 129 }, /* 10000001 */
- { 99, 8, 194 }, /* 11000010 */
- { 5, 8, 195 }, /* 11000011 */
- { 99, 8, 212 }, /* 11010100 */
- { 99, 9, 256 }, /* 100000000 */
- { -6, 9, 257 }, /* 100000001 */
- { 99, 9, 426 }, /* 110101010 */
- { 6, 9, 427 }, /* 110101011 */
- { 99, 10, 0 } /* Shouldn't come this far */
-};
-
-static rvlc_huff_table book_escape[] = {
- /*index length codeword */
- { 1, 2, 0 },
- { 0, 2, 2 },
- { 3, 3, 2 },
- { 2, 3, 6 },
- { 4, 4, 14 },
- { 7, 5, 13 },
- { 6, 5, 15 },
- { 5, 5, 31 },
- { 11, 6, 24 },
- { 10, 6, 25 },
- { 9, 6, 29 },
- { 8, 6, 61 },
- { 13, 7, 56 },
- { 12, 7, 120 },
- { 15, 8, 114 },
- { 14, 8, 242 },
- { 17, 9, 230 },
- { 16, 9, 486 },
- { 19, 10, 463 },
- { 18, 10, 974 },
- { 22, 11, 925 },
- { 20, 11, 1950 },
- { 21, 11, 1951 },
- { 23, 12, 1848 },
- { 25, 13, 3698 },
- { 24, 14, 7399 },
- { 26, 15, 14797 },
- { 49, 19, 236736 },
- { 50, 19, 236737 },
- { 51, 19, 236738 },
- { 52, 19, 236739 },
- { 53, 19, 236740 },
- { 27, 20, 473482 },
- { 28, 20, 473483 },
- { 29, 20, 473484 },
- { 30, 20, 473485 },
- { 31, 20, 473486 },
- { 32, 20, 473487 },
- { 33, 20, 473488 },
- { 34, 20, 473489 },
- { 35, 20, 473490 },
- { 36, 20, 473491 },
- { 37, 20, 473492 },
- { 38, 20, 473493 },
- { 39, 20, 473494 },
- { 40, 20, 473495 },
- { 41, 20, 473496 },
- { 42, 20, 473497 },
- { 43, 20, 473498 },
- { 44, 20, 473499 },
- { 45, 20, 473500 },
- { 46, 20, 473501 },
- { 47, 20, 473502 },
- { 48, 20, 473503 },
- { 99, 21, 0 } /* Shouldn't come this far */
-};
-
-static int8_t rvlc_huffman_sf(bitfile *ld_sf, bitfile *ld_esc,
- int8_t direction)
-{
- uint8_t i, j;
- int8_t index;
- uint32_t cw;
- rvlc_huff_table *h = book_rvlc;
-
- i = h->len;
- if (direction > 0)
- cw = faad_getbits(ld_sf, i);
- else
- cw = faad_getbits_rev(ld_sf, i);
-
- while ((cw != h->cw)
- && (i < 10))
- {
- h++;
- j = h->len-i;
- i += j;
- cw <<= j;
- if (direction > 0)
- cw |= faad_getbits(ld_sf, j);
- else
- cw |= faad_getbits_rev(ld_sf, j);
- }
-
- index = h->index;
-
- if (index == +ESC_VAL)
- {
- int8_t esc = rvlc_huffman_esc(ld_esc, direction);
- if (esc == 99)
- return 99;
- index += esc;
-#ifdef PRINT_RVLC
- printf("esc: %d - ", esc);
-#endif
- }
- if (index == -ESC_VAL)
- {
- int8_t esc = rvlc_huffman_esc(ld_esc, direction);
- if (esc == 99)
- return 99;
- index -= esc;
-#ifdef PRINT_RVLC
- printf("esc: %d - ", esc);
-#endif
- }
-
- return index;
-}
-
-static int8_t rvlc_huffman_esc(bitfile *ld,
- int8_t direction)
-{
- uint8_t i, j;
- uint32_t cw;
- rvlc_huff_table *h = book_escape;
-
- i = h->len;
- if (direction > 0)
- cw = faad_getbits(ld, i);
- else
- cw = faad_getbits_rev(ld, i);
-
- while ((cw != h->cw)
- && (i < 21))
- {
- h++;
- j = h->len-i;
- i += j;
- cw <<= j;
- if (direction > 0)
- cw |= faad_getbits(ld, j);
- else
- cw |= faad_getbits_rev(ld, j);
- }
-
- return h->index;
-}
-
-#endif
\ No newline at end of file
--- a/libfaad/rvlc_scale_factors.h
+++ /dev/null
@@ -1,59 +1,0 @@
-/*
-** FAAD - Freeware Advanced Audio Decoder
-** Copyright (C) 2002 M. Bakker
-**
-** 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
-** the Free Software Foundation; either version 2 of the License, or
-** (at your option) any later version.
-**
-** This program is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-** GNU General Public License for more details.
-**
-** You should have received a copy of the GNU General Public License
-** along with this program; if not, write to the Free Software
-** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-**
-** $Id: rvlc_scale_factors.h,v 1.3 2002/09/29 10:34:00 menno Exp $
-**/
-
-#ifndef __RVLC_SCF_H__
-#define __RVLC_SCF_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct
-{
- int8_t index;
- uint8_t len;
- uint32_t cw;
-} rvlc_huff_table;
-
-
-#define ESC_VAL 7
-
-
-uint8_t rvlc_scale_factor_data(ic_stream *ics, bitfile *ld);
-uint8_t rvlc_decode_scale_factors(ic_stream *ics, bitfile *ld);
-
-static uint8_t rvlc_decode_sf_forward(ic_stream *ics,
- bitfile *ld_sf,
- bitfile *ld_esc,
- uint8_t *is_used);
-static uint8_t rvlc_decode_sf_reverse(ic_stream *ics,
- bitfile *ld_sf,
- bitfile *ld_esc,
- uint8_t is_used);
-static int8_t rvlc_huffman_sf(bitfile *ld_sf, bitfile *ld_esc,
- int8_t direction);
-static int8_t rvlc_huffman_esc(bitfile *ld_esc, int8_t direction);
-
-
-#ifdef __cplusplus
-}
-#endif
-#endif
--- a/libfaad/specrec.c
+++ b/libfaad/specrec.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: specrec.c,v 1.16 2002/09/15 22:02:30 menno Exp $
+** $Id: specrec.c,v 1.17 2002/11/28 18:48:30 menno Exp $
**/
/*
@@ -27,7 +27,9 @@
*/
#include "common.h"
+#include "structs.h"
+#include <string.h>
#include "specrec.h"
#include "syntax.h"
#include "data.h"
@@ -49,11 +51,12 @@
in section named section. This offset depends on window_sequence and
scale_factor_grouping and is needed to decode the spectral_data().
*/
-uint8_t window_grouping_info(ic_stream *ics, uint8_t fs_index,
- uint8_t object_type, uint16_t frame_len)
+uint8_t window_grouping_info(faacDecHandle hDecoder, ic_stream *ics)
{
uint8_t i, g;
+ uint8_t sf_index = hDecoder->sf_index;
+
switch (ics->window_sequence) {
case ONLY_LONG_SEQUENCE:
case LONG_START_SEQUENCE:
@@ -62,15 +65,15 @@
ics->num_window_groups = 1;
ics->window_group_length[ics->num_window_groups-1] = 1;
#ifdef LD_DEC
- if (object_type == LD)
+ if (hDecoder->object_type == LD)
{
- if (frame_len == 512)
- ics->num_swb = num_swb_512_window[fs_index];
- else /* if (frame_len == 480) */
- ics->num_swb = num_swb_480_window[fs_index];
+ if (hDecoder->frameLength == 512)
+ ics->num_swb = num_swb_512_window[sf_index];
+ else /* if (hDecoder->frameLength == 480) */
+ ics->num_swb = num_swb_480_window[sf_index];
} else {
#endif
- ics->num_swb = num_swb_1024_window[fs_index];
+ ics->num_swb = num_swb_1024_window[sf_index];
#ifdef LD_DEC
}
#endif
@@ -78,33 +81,33 @@
/* preparation of sect_sfb_offset for long blocks */
/* also copy the last value! */
#ifdef LD_DEC
- if (object_type == LD)
+ if (hDecoder->object_type == LD)
{
- if (frame_len == 512)
+ if (hDecoder->frameLength == 512)
{
for (i = 0; i < ics->num_swb; i++)
{
- ics->sect_sfb_offset[0][i] = swb_offset_512_window[fs_index][i];
- ics->swb_offset[i] = swb_offset_512_window[fs_index][i];
+ ics->sect_sfb_offset[0][i] = swb_offset_512_window[sf_index][i];
+ ics->swb_offset[i] = swb_offset_512_window[sf_index][i];
}
- } else /* if (frame_len == 480) */ {
+ } else /* if (hDecoder->frameLength == 480) */ {
for (i = 0; i < ics->num_swb; i++)
{
- ics->sect_sfb_offset[0][i] = swb_offset_480_window[fs_index][i];
- ics->swb_offset[i] = swb_offset_480_window[fs_index][i];
+ ics->sect_sfb_offset[0][i] = swb_offset_480_window[sf_index][i];
+ ics->swb_offset[i] = swb_offset_480_window[sf_index][i];
}
}
- ics->sect_sfb_offset[0][ics->num_swb] = frame_len;
- ics->swb_offset[ics->num_swb] = frame_len;
+ ics->sect_sfb_offset[0][ics->num_swb] = hDecoder->frameLength;
+ ics->swb_offset[ics->num_swb] = hDecoder->frameLength;
} else {
#endif
for (i = 0; i < ics->num_swb; i++)
{
- ics->sect_sfb_offset[0][i] = swb_offset_1024_window[fs_index][i];
- ics->swb_offset[i] = swb_offset_1024_window[fs_index][i];
+ ics->sect_sfb_offset[0][i] = swb_offset_1024_window[sf_index][i];
+ ics->swb_offset[i] = swb_offset_1024_window[sf_index][i];
}
- ics->sect_sfb_offset[0][ics->num_swb] = frame_len;
- ics->swb_offset[ics->num_swb] = frame_len;
+ ics->sect_sfb_offset[0][ics->num_swb] = hDecoder->frameLength;
+ ics->swb_offset[ics->num_swb] = hDecoder->frameLength;
#ifdef LD_DEC
}
#endif
@@ -113,11 +116,11 @@
ics->num_windows = 8;
ics->num_window_groups = 1;
ics->window_group_length[ics->num_window_groups-1] = 1;
- ics->num_swb = num_swb_128_window[fs_index];
+ ics->num_swb = num_swb_128_window[sf_index];
for (i = 0; i < ics->num_swb; i++)
- ics->swb_offset[i] = swb_offset_128_window[fs_index][i];
- ics->swb_offset[ics->num_swb] = frame_len/8;
+ ics->swb_offset[i] = swb_offset_128_window[sf_index][i];
+ ics->swb_offset[ics->num_swb] = hDecoder->frameLength/8;
for (i = 0; i < ics->num_windows-1; i++) {
if (bit_set(ics->scale_factor_grouping, 6-i) == 0)
@@ -140,10 +143,10 @@
{
if (i+1 == ics->num_swb)
{
- width = (frame_len/8) - swb_offset_128_window[fs_index][i];
+ width = (hDecoder->frameLength/8) - swb_offset_128_window[sf_index][i];
} else {
- width = swb_offset_128_window[fs_index][i+1] -
- swb_offset_128_window[fs_index][i];
+ width = swb_offset_128_window[sf_index][i+1] -
+ swb_offset_128_window[sf_index][i];
}
width *= ics->window_group_length[g];
ics->sect_sfb_offset[g][sect_sfb++] = offset;
@@ -179,7 +182,6 @@
*/
void quant_to_spec(ic_stream *ics, real_t *spec_data, uint16_t frame_len)
{
- int8_t i;
uint8_t g, sfb, win;
uint16_t width, bin;
real_t *start_inptr, *start_win_ptr, *win_ptr;
@@ -188,17 +190,7 @@
real_t *tmp_spec_ptr, *spec_ptr;
tmp_spec_ptr = tmp_spec;
- for (i = frame_len/16-1; i >= 0; --i)
- {
- *tmp_spec_ptr++ = REAL_CONST(0.0); *tmp_spec_ptr++ = REAL_CONST(0.0);
- *tmp_spec_ptr++ = REAL_CONST(0.0); *tmp_spec_ptr++ = REAL_CONST(0.0);
- *tmp_spec_ptr++ = REAL_CONST(0.0); *tmp_spec_ptr++ = REAL_CONST(0.0);
- *tmp_spec_ptr++ = REAL_CONST(0.0); *tmp_spec_ptr++ = REAL_CONST(0.0);
- *tmp_spec_ptr++ = REAL_CONST(0.0); *tmp_spec_ptr++ = REAL_CONST(0.0);
- *tmp_spec_ptr++ = REAL_CONST(0.0); *tmp_spec_ptr++ = REAL_CONST(0.0);
- *tmp_spec_ptr++ = REAL_CONST(0.0); *tmp_spec_ptr++ = REAL_CONST(0.0);
- *tmp_spec_ptr++ = REAL_CONST(0.0); *tmp_spec_ptr++ = REAL_CONST(0.0);
- }
+ memset(tmp_spec_ptr, 0, frame_len*sizeof(real_t));
spec_ptr = spec_data;
tmp_spec_ptr = tmp_spec;
@@ -225,10 +217,12 @@
for (bin = 0; bin < width; bin += 4)
{
- *tmp_spec_ptr++ = *spec_ptr++;
- *tmp_spec_ptr++ = *spec_ptr++;
- *tmp_spec_ptr++ = *spec_ptr++;
- *tmp_spec_ptr++ = *spec_ptr++;
+ tmp_spec_ptr[0] = spec_ptr[0];
+ tmp_spec_ptr[1] = spec_ptr[1];
+ tmp_spec_ptr[2] = spec_ptr[2];
+ tmp_spec_ptr[3] = spec_ptr[3];
+ tmp_spec_ptr += 4;
+ spec_ptr += 4;
}
win_ptr += win_inc;
@@ -241,17 +235,7 @@
spec_ptr = spec_data;
tmp_spec_ptr = tmp_spec;
- for (i = frame_len/16 - 1; i >= 0; --i)
- {
- *spec_ptr++ = *tmp_spec_ptr++; *spec_ptr++ = *tmp_spec_ptr++;
- *spec_ptr++ = *tmp_spec_ptr++; *spec_ptr++ = *tmp_spec_ptr++;
- *spec_ptr++ = *tmp_spec_ptr++; *spec_ptr++ = *tmp_spec_ptr++;
- *spec_ptr++ = *tmp_spec_ptr++; *spec_ptr++ = *tmp_spec_ptr++;
- *spec_ptr++ = *tmp_spec_ptr++; *spec_ptr++ = *tmp_spec_ptr++;
- *spec_ptr++ = *tmp_spec_ptr++; *spec_ptr++ = *tmp_spec_ptr++;
- *spec_ptr++ = *tmp_spec_ptr++; *spec_ptr++ = *tmp_spec_ptr++;
- *spec_ptr++ = *tmp_spec_ptr++; *spec_ptr++ = *tmp_spec_ptr++;
- }
+ memcpy(spec_ptr, tmp_spec_ptr, frame_len*sizeof(real_t));
}
#ifndef FIXED_POINT
--- a/libfaad/specrec.h
+++ b/libfaad/specrec.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: specrec.h,v 1.9 2002/09/08 18:14:37 menno Exp $
+** $Id: specrec.h,v 1.10 2002/11/28 18:48:30 menno Exp $
**/
#ifndef __SPECREC_H__
@@ -28,12 +28,7 @@
#include "syntax.h"
-#ifndef FIXED_POINT
-#define POW_TABLE_SIZE 200
-#endif
-
-uint8_t window_grouping_info(ic_stream *ics, uint8_t fs_index,
- uint8_t object_type, uint16_t frame_len);
+uint8_t window_grouping_info(faacDecHandle hDecoder, ic_stream *ics);
void quant_to_spec(ic_stream *ics, real_t *spec_data, uint16_t frame_len);
void inverse_quantization(real_t *x_invquant, int16_t *x_quant, uint16_t frame_len);
#ifdef FIXED_POINT
--- /dev/null
+++ b/libfaad/ssr.c
@@ -1,0 +1,117 @@
+/*
+** FAAD - Freeware Advanced Audio Decoder
+** Copyright (C) 2002 M. Bakker
+**
+** 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
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+**
+** $Id: ssr.c,v 1.1 2002/11/28 18:48:30 menno Exp $
+**/
+
+#include "common.h"
+#include "structs.h"
+
+#ifdef SSR_DEC
+
+#include "syntax.h"
+#include "filtbank.h"
+#include "ssr.h"
+#include "ssr_fb.h"
+
+void ssr_decode(ssr_info *ssr, fb_info *fb, uint8_t window_sequence,
+ uint8_t window_shape, uint8_t window_shape_prev,
+ real_t *freq_in, real_t *time_out, uint16_t frame_len)
+{
+ uint8_t band;
+ uint16_t ssr_frame_len = frame_len/SSR_BANDS;
+ real_t time_tmp[2048];
+
+ for (band = 0; band < SSR_BANDS; band++)
+ {
+ int16_t j;
+
+ /* uneven bands have inverted frequency scale */
+ if (band == 1 || band == 3)
+ {
+ for (j = 0; j < ssr_frame_len/2; j++)
+ {
+ real_t tmp;
+ tmp = freq_in[j + ssr_frame_len*band];
+ freq_in[j + ssr_frame_len*band] =
+ freq_in[ssr_frame_len - j - 1 + ssr_frame_len*band];
+ freq_in[ssr_frame_len - j - 1 + ssr_frame_len*band] = tmp;
+ }
+ }
+
+ /* non-overlapping inverse filterbank for SSR */
+ ssr_ifilter_bank(fb, window_sequence, window_shape, window_shape_prev,
+ freq_in + band*ssr_frame_len, time_tmp + band*ssr_frame_len,
+ ssr_frame_len);
+
+#if 0
+ /* gain control */
+ ssr_gain_control(ssr, time_tmp, window_sequence, ssr_frame_len);
+#endif
+ }
+
+#if 0
+ /* inverse pqf to bring subbands together again */
+ ssr_ipqf();
+#endif
+}
+
+static void ssr_gain_control(ssr_info *ssr, real_t *data, uint8_t window_sequence,
+ uint16_t frame_len)
+{
+ if (window_sequence != EIGHT_SHORT_SEQUENCE)
+ {
+// ssr_gc_function();
+ } else {
+ }
+}
+
+#if 0
+static void ssr_gc_function(ssr_info *ssr, real_t *prevFMD,
+ real_t *gc_function, uint16_t frame_len)
+{
+ int32_t aloc[10];
+ real_t alev[10];
+
+ switch (window_sequence)
+ {
+ case ONLY_LONG_SEQUENCE:
+ len_area1 = frame_len/SSR_BANDS;
+ len_area2 = 0;
+ break;
+ case LONG_START_SEQUENCE:
+ len_area1 = (frame_len/SSR_BANDS)*7/32;
+ len_area2 = (frame_len/SSR_BANDS)/16;
+ break;
+ case EIGHT_SHORT_SEQUENCE:
+ len_area1 = (frame_len/8)/SSR_BANDS;
+ len_area2 = 0;
+ break;
+ case LONG_STOP_SEQUENCE:
+ len_area1 = (frame_len/SSR_BANDS);
+ len_area2 = 0;
+ break;
+ }
+
+ /* decode bitstream information */
+
+ /* build array M */
+}
+#endif
+
+#endif
--- /dev/null
+++ b/libfaad/ssr.h
@@ -1,0 +1,38 @@
+/*
+** FAAD - Freeware Advanced Audio Decoder
+** Copyright (C) 2002 M. Bakker
+**
+** 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
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+**
+** $Id: ssr.h,v 1.1 2002/11/28 18:48:30 menno Exp $
+**/
+
+#ifndef __SSR_H__
+#define __SSR_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define SSR_BANDS 4
+
+void ssr_decode(ssr_info *ssr, fb_info *fb, uint8_t window_sequence,
+ uint8_t window_shape, uint8_t window_shape_prev,
+ real_t *freq_in, real_t *time_out, uint16_t frame_len);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
--- /dev/null
+++ b/libfaad/ssr_fb.c
@@ -1,0 +1,176 @@
+/*
+** FAAD - Freeware Advanced Audio Decoder
+** Copyright (C) 2002 M. Bakker
+**
+** 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
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+**
+** $Id: ssr_fb.c,v 1.1 2002/11/28 18:48:30 menno Exp $
+**/
+
+#include "common.h"
+#include "structs.h"
+
+#ifdef SSR_DEC
+
+#include <string.h>
+#include <stdlib.h>
+#include "syntax.h"
+#include "filtbank.h"
+#include "mdct.h"
+#include "ssr_fb.h"
+#include "ssr_win.h"
+
+fb_info *ssr_filter_bank_init(uint16_t frame_len)
+{
+ uint16_t nshort = frame_len/8;
+
+ fb_info *fb = (fb_info*)malloc(sizeof(fb_info));
+ memset(fb, 0, sizeof(fb_info));
+
+ /* normal */
+ fb->mdct256 = faad_mdct_init(2*nshort);
+ fb->mdct2048 = faad_mdct_init(2*frame_len);
+
+ fb->long_window[0] = sine_long_256;
+ fb->short_window[0] = sine_short_32;
+ fb->long_window[1] = kbd_long_256;
+ fb->short_window[1] = kbd_short_32;
+
+ return fb;
+}
+
+void ssr_filter_bank_end(fb_info *fb)
+{
+ faad_mdct_end(fb->mdct256);
+ faad_mdct_end(fb->mdct2048);
+
+ if (fb) free(fb);
+}
+
+static INLINE void imdct_ssr(fb_info *fb, real_t *in_data,
+ real_t *out_data, uint16_t len)
+{
+ mdct_info *mdct;
+
+ switch (len)
+ {
+ case 512:
+ mdct = fb->mdct2048;
+ break;
+ case 64:
+ mdct = fb->mdct256;
+ break;
+ }
+
+ faad_imdct(mdct, in_data, out_data);
+}
+
+/* NON-overlapping inverse filterbank for use with SSR */
+void ssr_ifilter_bank(fb_info *fb, uint8_t window_sequence, uint8_t window_shape,
+ uint8_t window_shape_prev, real_t *freq_in,
+ real_t *time_out, uint16_t frame_len)
+{
+ int16_t i;
+ real_t *transf_buf;
+
+ real_t *window_long;
+ real_t *window_long_prev;
+ real_t *window_short;
+ real_t *window_short_prev;
+
+ uint16_t nlong = frame_len;
+ uint16_t nshort = frame_len/8;
+ uint16_t trans = nshort/2;
+
+ uint16_t nflat_ls = (nlong-nshort)/2;
+
+ transf_buf = (real_t*)malloc(2*nlong*sizeof(real_t));
+
+ window_long = fb->long_window[window_shape];
+ window_long_prev = fb->long_window[window_shape_prev];
+ window_short = fb->short_window[window_shape];
+ window_short_prev = fb->short_window[window_shape_prev];
+
+ switch (window_sequence)
+ {
+ case ONLY_LONG_SEQUENCE:
+ imdct_ssr(fb, freq_in, transf_buf, 2*nlong);
+ for (i = nlong-1; i >= 0; i--)
+ {
+ time_out[i] = MUL_R_C(transf_buf[i],window_long_prev[i]);
+ time_out[nlong+i] = MUL_R_C(transf_buf[nlong+i],window_long[nlong-1-i]);
+ }
+ break;
+
+ case LONG_START_SEQUENCE:
+ imdct_ssr(fb, freq_in, transf_buf, 2*nlong);
+ for (i = 0; i < nlong; i++)
+ time_out[i] = MUL_R_C(transf_buf[i],window_long_prev[i]);
+ for (i = 0; i < nflat_ls; i++)
+ time_out[nlong+i] = transf_buf[nlong+i];
+ for (i = 0; i < nshort; i++)
+ time_out[nlong+nflat_ls+i] = MUL_R_C(transf_buf[nlong+nflat_ls+i],window_short[nshort-i-1]);
+ for (i = 0; i < nflat_ls; i++)
+ time_out[nlong+nflat_ls+nshort+i] = 0;
+ break;
+
+ case EIGHT_SHORT_SEQUENCE:
+ imdct_ssr(fb, freq_in+0*nshort, transf_buf+2*nshort*0, 2*nshort);
+ imdct_ssr(fb, freq_in+1*nshort, transf_buf+2*nshort*1, 2*nshort);
+ imdct_ssr(fb, freq_in+2*nshort, transf_buf+2*nshort*2, 2*nshort);
+ imdct_ssr(fb, freq_in+3*nshort, transf_buf+2*nshort*3, 2*nshort);
+ imdct_ssr(fb, freq_in+4*nshort, transf_buf+2*nshort*4, 2*nshort);
+ imdct_ssr(fb, freq_in+5*nshort, transf_buf+2*nshort*5, 2*nshort);
+ imdct_ssr(fb, freq_in+6*nshort, transf_buf+2*nshort*6, 2*nshort);
+ imdct_ssr(fb, freq_in+7*nshort, transf_buf+2*nshort*7, 2*nshort);
+ for(i = nshort-1; i >= 0; i--)
+ {
+ time_out[i+0*nshort] = MUL_R_C(transf_buf[nshort*0+i],window_short_prev[i]);
+ time_out[i+1*nshort] = MUL_R_C(transf_buf[nshort*1+i],window_short[i]);
+ time_out[i+2*nshort] = MUL_R_C(transf_buf[nshort*2+i],window_short_prev[i]);
+ time_out[i+3*nshort] = MUL_R_C(transf_buf[nshort*3+i],window_short[i]);
+ time_out[i+4*nshort] = MUL_R_C(transf_buf[nshort*4+i],window_short_prev[i]);
+ time_out[i+5*nshort] = MUL_R_C(transf_buf[nshort*5+i],window_short[i]);
+ time_out[i+6*nshort] = MUL_R_C(transf_buf[nshort*6+i],window_short_prev[i]);
+ time_out[i+7*nshort] = MUL_R_C(transf_buf[nshort*7+i],window_short[i]);
+ time_out[i+8*nshort] = MUL_R_C(transf_buf[nshort*8+i],window_short_prev[i]);
+ time_out[i+9*nshort] = MUL_R_C(transf_buf[nshort*9+i],window_short[i]);
+ time_out[i+10*nshort] = MUL_R_C(transf_buf[nshort*10+i],window_short_prev[i]);
+ time_out[i+11*nshort] = MUL_R_C(transf_buf[nshort*11+i],window_short[i]);
+ time_out[i+12*nshort] = MUL_R_C(transf_buf[nshort*12+i],window_short_prev[i]);
+ time_out[i+13*nshort] = MUL_R_C(transf_buf[nshort*13+i],window_short[i]);
+ time_out[i+14*nshort] = MUL_R_C(transf_buf[nshort*14+i],window_short_prev[i]);
+ time_out[i+15*nshort] = MUL_R_C(transf_buf[nshort*15+i],window_short[i]);
+ }
+ break;
+
+ case LONG_STOP_SEQUENCE:
+ imdct_ssr(fb, freq_in, transf_buf, 2*nlong);
+ for (i = 0; i < nflat_ls; i++)
+ time_out[i] = 0;
+ for (i = 0; i < nshort; i++)
+ time_out[nflat_ls+i] = MUL_R_C(transf_buf[nflat_ls+i],window_short_prev[i]);
+ for (i = 0; i < nflat_ls; i++)
+ time_out[nflat_ls+nshort+i] = transf_buf[nflat_ls+nshort+i];
+ for (i = 0; i < nlong; i++)
+ time_out[nlong+i] = MUL_R_C(transf_buf[nlong+i],window_long[nlong-1-i]);
+ break;
+ }
+
+ free(transf_buf);
+}
+
+
+#endif
--- /dev/null
+++ b/libfaad/ssr_fb.h
@@ -1,0 +1,44 @@
+/*
+** FAAD - Freeware Advanced Audio Decoder
+** Copyright (C) 2002 M. Bakker
+**
+** 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
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+**
+** $Id: ssr_fb.h,v 1.1 2002/11/28 18:48:30 menno Exp $
+**/
+
+#ifndef __SSR_FB_H__
+#define __SSR_FB_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+fb_info *ssr_filter_bank_init(uint16_t frame_len);
+void ssr_filter_bank_end(fb_info *fb);
+
+/*non overlapping inverse filterbank */
+void ssr_ifilter_bank(fb_info *fb,
+ uint8_t window_sequence,
+ uint8_t window_shape,
+ uint8_t window_shape_prev,
+ real_t *freq_in,
+ real_t *time_out,
+ uint16_t frame_len);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
--- /dev/null
+++ b/libfaad/ssr_ipqf.c
@@ -1,0 +1,30 @@
+/*
+** FAAD - Freeware Advanced Audio Decoder
+** Copyright (C) 2002 M. Bakker
+**
+** 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
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+**
+** $Id: ssr_ipqf.c,v 1.1 2002/11/28 18:48:30 menno Exp $
+**/
+
+#include "common.h"
+#include "structs.h"
+
+#ifdef SSR_DEC
+
+#include "ssr_ipqf.h"
+
+
+#endif
--- /dev/null
+++ b/libfaad/ssr_ipqf.h
@@ -1,0 +1,34 @@
+/*
+** FAAD - Freeware Advanced Audio Decoder
+** Copyright (C) 2002 M. Bakker
+**
+** 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
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+**
+** $Id: ssr_ipqf.h,v 1.1 2002/11/28 18:48:30 menno Exp $
+**/
+
+#ifndef __SSR_IPQF_H__
+#define __SSR_IPQF_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif
--- /dev/null
+++ b/libfaad/ssr_win.h
@@ -1,0 +1,626 @@
+/*
+** FAAD - Freeware Advanced Audio Decoder
+** Copyright (C) 2002 M. Bakker
+**
+** 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
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+**
+** $Id: ssr_win.h,v 1.1 2002/11/28 18:48:30 menno Exp $
+**/
+
+#ifndef __SSR_WIN_H__
+#define __SSR_WIN_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef _MSC_VER
+#pragma warning(disable:4305)
+#pragma warning(disable:4244)
+#endif
+
+static real_t sine_short_32[] = {
+ 0.0245412290,
+ 0.0735645667,
+ 0.1224106774,
+ 0.1709618866,
+ 0.2191012502,
+ 0.2667127550,
+ 0.3136817515,
+ 0.3598950505,
+ 0.4052413106,
+ 0.4496113360,
+ 0.4928981960,
+ 0.5349976420,
+ 0.5758082271,
+ 0.6152316332,
+ 0.6531728506,
+ 0.6895405650,
+ 0.7242470980,
+ 0.7572088838,
+ 0.7883464694,
+ 0.8175848126,
+ 0.8448535800,
+ 0.8700870275,
+ 0.8932242990,
+ 0.9142097831,
+ 0.9329928160,
+ 0.9495282173,
+ 0.9637760520,
+ 0.9757021666,
+ 0.9852776527,
+ 0.9924795628,
+ 0.9972904325,
+ 0.9996988177
+};
+
+static real_t sine_long_256[] = {
+ 0.0030679568,
+ 0.0092037553,
+ 0.0153392069,
+ 0.0214740802,
+ 0.0276081469,
+ 0.0337411724,
+ 0.0398729295,
+ 0.0460031852,
+ 0.0521317050,
+ 0.0582582653,
+ 0.0643826351,
+ 0.0705045760,
+ 0.0766238645,
+ 0.0827402696,
+ 0.0888535529,
+ 0.0949634984,
+ 0.1010698676,
+ 0.1071724296,
+ 0.1132709533,
+ 0.1193652153,
+ 0.1254549921,
+ 0.1315400302,
+ 0.1376201212,
+ 0.1436950415,
+ 0.1497645378,
+ 0.1558284014,
+ 0.1618863940,
+ 0.1679383069,
+ 0.1739838719,
+ 0.1800229102,
+ 0.1860551536,
+ 0.1920804083,
+ 0.1980984211,
+ 0.2041089684,
+ 0.2101118416,
+ 0.2161068022,
+ 0.2220936269,
+ 0.2280720919,
+ 0.2340419590,
+ 0.2400030345,
+ 0.2459550500,
+ 0.2518978119,
+ 0.2578310966,
+ 0.2637546957,
+ 0.2696683407,
+ 0.2755718231,
+ 0.2814649343,
+ 0.2873474658,
+ 0.2932191789,
+ 0.2990798354,
+ 0.3049292266,
+ 0.3107671738,
+ 0.3165933788,
+ 0.3224076927,
+ 0.3282098472,
+ 0.3339996636,
+ 0.3397769034,
+ 0.3455413282,
+ 0.3512927592,
+ 0.3570309579,
+ 0.3627557456,
+ 0.3684668541,
+ 0.3741640747,
+ 0.3798472285,
+ 0.3855160773,
+ 0.3911703825,
+ 0.3968099952,
+ 0.4024346471,
+ 0.4080441594,
+ 0.4136383235,
+ 0.4192169011,
+ 0.4247796834,
+ 0.4303264916,
+ 0.4358570874,
+ 0.4413712919,
+ 0.4468688369,
+ 0.4523496032,
+ 0.4578133225,
+ 0.4632597864,
+ 0.4686888456,
+ 0.4741002321,
+ 0.4794937670,
+ 0.4848692715,
+ 0.4902265072,
+ 0.4955652654,
+ 0.5008853674,
+ 0.5061866641,
+ 0.5114688873,
+ 0.5167317986,
+ 0.5219752789,
+ 0.5271991491,
+ 0.5324031115,
+ 0.5375871062,
+ 0.5427507758,
+ 0.5478940606,
+ 0.5530167222,
+ 0.5581185222,
+ 0.5631993413,
+ 0.5682589412,
+ 0.5732972026,
+ 0.5783138275,
+ 0.5833086967,
+ 0.5882815719,
+ 0.5932323337,
+ 0.5981607437,
+ 0.6030666232,
+ 0.6079497933,
+ 0.6128100753,
+ 0.6176473498,
+ 0.6224613190,
+ 0.6272518039,
+ 0.6320187449,
+ 0.6367619038,
+ 0.6414810419,
+ 0.6461760402,
+ 0.6508467197,
+ 0.6554928422,
+ 0.6601143479,
+ 0.6647109985,
+ 0.6692826152,
+ 0.6738290191,
+ 0.6783500314,
+ 0.6828455329,
+ 0.6873153448,
+ 0.6917592883,
+ 0.6961771250,
+ 0.7005687952,
+ 0.7049341202,
+ 0.7092728615,
+ 0.7135848999,
+ 0.7178700566,
+ 0.7221282125,
+ 0.7263591886,
+ 0.7305628061,
+ 0.7347388864,
+ 0.7388873696,
+ 0.7430079579,
+ 0.7471006513,
+ 0.7511651516,
+ 0.7552013993,
+ 0.7592092156,
+ 0.7631884217,
+ 0.7671388984,
+ 0.7710605264,
+ 0.7749531269,
+ 0.7788165212,
+ 0.7826505899,
+ 0.7864552140,
+ 0.7902302146,
+ 0.7939754725,
+ 0.7976908684,
+ 0.8013761640,
+ 0.8050313592,
+ 0.8086562157,
+ 0.8122506142,
+ 0.8158144355,
+ 0.8193475604,
+ 0.8228498101,
+ 0.8263210654,
+ 0.8297612667,
+ 0.8331701756,
+ 0.8365477324,
+ 0.8398938179,
+ 0.8432082534,
+ 0.8464909792,
+ 0.8497417569,
+ 0.8529606462,
+ 0.8561473489,
+ 0.8593018055,
+ 0.8624239564,
+ 0.8655136228,
+ 0.8685707450,
+ 0.8715950847,
+ 0.8745866418,
+ 0.8775452971,
+ 0.8804709315,
+ 0.8833633661,
+ 0.8862225413,
+ 0.8890483975,
+ 0.8918406963,
+ 0.8945994973,
+ 0.8973246217,
+ 0.9000158906,
+ 0.9026733041,
+ 0.9052967429,
+ 0.9078861475,
+ 0.9104412794,
+ 0.9129621983,
+ 0.9154487252,
+ 0.9179008007,
+ 0.9203183055,
+ 0.9227011204,
+ 0.9250492454,
+ 0.9273625612,
+ 0.9296408892,
+ 0.9318842888,
+ 0.9340925813,
+ 0.9362657070,
+ 0.9384035468,
+ 0.9405061007,
+ 0.9425731897,
+ 0.9446048737,
+ 0.9466009140,
+ 0.9485613704,
+ 0.9504860640,
+ 0.9523749948,
+ 0.9542281032,
+ 0.9560452700,
+ 0.9578264356,
+ 0.9595715404,
+ 0.9612805247,
+ 0.9629532695,
+ 0.9645897746,
+ 0.9661900401,
+ 0.9677538276,
+ 0.9692812562,
+ 0.9707721472,
+ 0.9722265005,
+ 0.9736442566,
+ 0.9750253558,
+ 0.9763697386,
+ 0.9776773453,
+ 0.9789481759,
+ 0.9801821709,
+ 0.9813792109,
+ 0.9825392962,
+ 0.9836624265,
+ 0.9847484827,
+ 0.9857975245,
+ 0.9868094325,
+ 0.9877841473,
+ 0.9887216687,
+ 0.9896219969,
+ 0.9904850721,
+ 0.9913108945,
+ 0.9920993447,
+ 0.9928504229,
+ 0.9935641289,
+ 0.9942404628,
+ 0.9948793054,
+ 0.9954807758,
+ 0.9960446954,
+ 0.9965711236,
+ 0.9970600605,
+ 0.9975114465,
+ 0.9979252815,
+ 0.9983015656,
+ 0.9986402392,
+ 0.9989413023,
+ 0.9992047548,
+ 0.9994305968,
+ 0.9996188283,
+ 0.9997693896,
+ 0.9998823404,
+ 0.9999576211,
+ 0.9999952912
+};
+
+static real_t kbd_short_32[] = {
+ 0.0000875914060105,
+ 0.0009321760265333,
+ 0.0032114611466596,
+ 0.0081009893216786,
+ 0.0171240286619181,
+ 0.0320720743527833,
+ 0.0548307856028528,
+ 0.0871361822564870,
+ 0.1302923415174603,
+ 0.1848955425508276,
+ 0.2506163195331889,
+ 0.3260874142923209,
+ 0.4089316830907141,
+ 0.4959414909423747,
+ 0.5833939894958904,
+ 0.6674601983218376,
+ 0.7446454751465113,
+ 0.8121892962974020,
+ 0.8683559394406505,
+ 0.9125649996381605,
+ 0.9453396205809574,
+ 0.9680864942677585,
+ 0.9827581789763112,
+ 0.9914756203467121,
+ 0.9961964092194694,
+ 0.9984956609571091,
+ 0.9994855586984285,
+ 0.9998533730714648,
+ 0.9999671864476404,
+ 0.9999948432453556,
+ 0.9999995655238333,
+ 0.9999999961638728
+};
+
+
+static real_t kbd_long_256[] = {
+ 0.0005851230124487,
+ 0.0009642149851497,
+ 0.0013558207534965,
+ 0.0017771849644394,
+ 0.0022352533849672,
+ 0.0027342299070304,
+ 0.0032773001022195,
+ 0.0038671998069216,
+ 0.0045064443384152,
+ 0.0051974336885144,
+ 0.0059425050016407,
+ 0.0067439602523141,
+ 0.0076040812644888,
+ 0.0085251378135895,
+ 0.0095093917383048,
+ 0.0105590986429280,
+ 0.0116765080854300,
+ 0.0128638627792770,
+ 0.0141233971318631,
+ 0.0154573353235409,
+ 0.0168678890600951,
+ 0.0183572550877256,
+ 0.0199276125319803,
+ 0.0215811201042484,
+ 0.0233199132076965,
+ 0.0251461009666641,
+ 0.0270617631981826,
+ 0.0290689473405856,
+ 0.0311696653515848,
+ 0.0333658905863535,
+ 0.0356595546648444,
+ 0.0380525443366107,
+ 0.0405466983507029,
+ 0.0431438043376910,
+ 0.0458455957104702,
+ 0.0486537485902075,
+ 0.0515698787635492,
+ 0.0545955386770205,
+ 0.0577322144743916,
+ 0.0609813230826460,
+ 0.0643442093520723,
+ 0.0678221432558827,
+ 0.0714163171546603,
+ 0.0751278431308314,
+ 0.0789577503982528,
+ 0.0829069827918993,
+ 0.0869763963425241,
+ 0.0911667569410503,
+ 0.0954787380973307,
+ 0.0999129187977865,
+ 0.1044697814663005,
+ 0.1091497100326053,
+ 0.1139529881122542,
+ 0.1188797973021148,
+ 0.1239302155951605,
+ 0.1291042159181728,
+ 0.1344016647957880,
+ 0.1398223211441467,
+ 0.1453658351972151,
+ 0.1510317475686540,
+ 0.1568194884519144,
+ 0.1627283769610327,
+ 0.1687576206143887,
+ 0.1749063149634756,
+ 0.1811734433685097,
+ 0.1875578769224857,
+ 0.1940583745250518,
+ 0.2006735831073503,
+ 0.2074020380087318,
+ 0.2142421635060113,
+ 0.2211922734956977,
+ 0.2282505723293797,
+ 0.2354151558022098,
+ 0.2426840122941792,
+ 0.2500550240636293,
+ 0.2575259686921987,
+ 0.2650945206801527,
+ 0.2727582531907993,
+ 0.2805146399424422,
+ 0.2883610572460804,
+ 0.2962947861868143,
+ 0.3043130149466800,
+ 0.3124128412663888,
+ 0.3205912750432127,
+ 0.3288452410620226,
+ 0.3371715818562547,
+ 0.3455670606953511,
+ 0.3540283646950029,
+ 0.3625521080463003,
+ 0.3711348353596863,
+ 0.3797730251194006,
+ 0.3884630932439016,
+ 0.3972013967475546,
+ 0.4059842374986933,
+ 0.4148078660689724,
+ 0.4236684856687616,
+ 0.4325622561631607,
+ 0.4414852981630577,
+ 0.4504336971855032,
+ 0.4594035078775303,
+ 0.4683907582974173,
+ 0.4773914542472655,
+ 0.4864015836506502,
+ 0.4954171209689973,
+ 0.5044340316502417,
+ 0.5134482766032377,
+ 0.5224558166913167,
+ 0.5314526172383208,
+ 0.5404346525403849,
+ 0.5493979103766972,
+ 0.5583383965124314,
+ 0.5672521391870222,
+ 0.5761351935809411,
+ 0.5849836462541291,
+ 0.5937936195492526,
+ 0.6025612759529649,
+ 0.6112828224083939,
+ 0.6199545145721097,
+ 0.6285726610088878,
+ 0.6371336273176413,
+ 0.6456338401819751,
+ 0.6540697913388968,
+ 0.6624380414593221,
+ 0.6707352239341151,
+ 0.6789580485595255,
+ 0.6871033051160131,
+ 0.6951678668345944,
+ 0.7031486937449871,
+ 0.7110428359000029,
+ 0.7188474364707993,
+ 0.7265597347077880,
+ 0.7341770687621900,
+ 0.7416968783634273,
+ 0.7491167073477523,
+ 0.7564342060337386,
+ 0.7636471334404891,
+ 0.7707533593446514,
+ 0.7777508661725849,
+ 0.7846377507242818,
+ 0.7914122257259034,
+ 0.7980726212080798,
+ 0.8046173857073919,
+ 0.8110450872887550,
+ 0.8173544143867162,
+ 0.8235441764639875,
+ 0.8296133044858474,
+ 0.8355608512093652,
+ 0.8413859912867303,
+ 0.8470880211822968,
+ 0.8526663589032990,
+ 0.8581205435445334,
+ 0.8634502346476508,
+ 0.8686552113760616,
+ 0.8737353715068081,
+ 0.8786907302411250,
+ 0.8835214188357692,
+ 0.8882276830575707,
+ 0.8928098814640207,
+ 0.8972684835130879,
+ 0.9016040675058185,
+ 0.9058173183656508,
+ 0.9099090252587376,
+ 0.9138800790599416,
+ 0.9177314696695282,
+ 0.9214642831859411,
+ 0.9250796989403991,
+ 0.9285789863994010,
+ 0.9319635019415643,
+ 0.9352346855155568,
+ 0.9383940571861993,
+ 0.9414432135761304,
+ 0.9443838242107182,
+ 0.9472176277741918,
+ 0.9499464282852282,
+ 0.9525720912004834,
+ 0.9550965394547873,
+ 0.9575217494469370,
+ 0.9598497469802043,
+ 0.9620826031668507,
+ 0.9642224303060783,
+ 0.9662713777449607,
+ 0.9682316277319895,
+ 0.9701053912729269,
+ 0.9718949039986892,
+ 0.9736024220549734,
+ 0.9752302180233160,
+ 0.9767805768831932,
+ 0.9782557920246753,
+ 0.9796581613210076,
+ 0.9809899832703159,
+ 0.9822535532154261,
+ 0.9834511596505429,
+ 0.9845850806232530,
+ 0.9856575802399989,
+ 0.9866709052828243,
+ 0.9876272819448033,
+ 0.9885289126911557,
+ 0.9893779732525968,
+ 0.9901766097569984,
+ 0.9909269360049311,
+ 0.9916310308941294,
+ 0.9922909359973702,
+ 0.9929086532976777,
+ 0.9934861430841844,
+ 0.9940253220113651,
+ 0.9945280613237534,
+ 0.9949961852476154,
+ 0.9954314695504363,
+ 0.9958356402684387,
+ 0.9962103726017252,
+ 0.9965572899760172,
+ 0.9968779632693499,
+ 0.9971739102014799,
+ 0.9974465948831872,
+ 0.9976974275220812,
+ 0.9979277642809907,
+ 0.9981389072844972,
+ 0.9983321047686901,
+ 0.9985085513687731,
+ 0.9986693885387259,
+ 0.9988157050968516,
+ 0.9989485378906924,
+ 0.9990688725744943,
+ 0.9991776444921379,
+ 0.9992757396582338,
+ 0.9993639958299003,
+ 0.9994432036616085,
+ 0.9995141079353859,
+ 0.9995774088586188,
+ 0.9996337634216871,
+ 0.9996837868076957,
+ 0.9997280538466377,
+ 0.9997671005064359,
+ 0.9998014254134544,
+ 0.9998314913952471,
+ 0.9998577270385304,
+ 0.9998805282555989,
+ 0.9999002598526793,
+ 0.9999172570940037,
+ 0.9999318272557038,
+ 0.9999442511639580,
+ 0.9999547847121726,
+ 0.9999636603523446,
+ 0.9999710885561258,
+ 0.9999772592414866,
+ 0.9999823431612708,
+ 0.9999864932503106,
+ 0.9999898459281599,
+ 0.9999925223548691,
+ 0.9999946296375997,
+ 0.9999962619864214,
+ 0.9999975018180320,
+ 0.9999984208055542,
+ 0.9999990808746198,
+ 0.9999995351446231,
+ 0.9999998288155155
+};
+
+#ifdef __cplusplus
+}
+#endif
+#endif
--- /dev/null
+++ b/libfaad/structs.h
@@ -1,0 +1,347 @@
+/*
+** FAAD - Freeware Advanced Audio Decoder
+** Copyright (C) 2002 M. Bakker
+**
+** 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
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+**
+** $Id: structs.h,v 1.1 2002/11/28 18:48:30 menno Exp $
+**/
+
+#ifndef __STRUCTS_H__
+#define __STRUCTS_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define MAX_CHANNELS 64
+#define MAX_SYNTAX_ELEMENTS 48
+#define MAX_WINDOW_GROUPS 8
+#define MAX_SFB 51
+#define MAX_LTP_SFB 40
+#define MAX_LTP_SFB_S 8
+
+/* used to save the prediction state */
+typedef struct {
+ real_t r[2];
+ real_t KOR[2];
+ real_t VAR[2];
+} pred_state;
+
+typedef struct
+{
+ uint16_t n;
+ uint16_t ifac[15];
+ complex_t *work;
+ complex_t *tab;
+} cfft_info;
+
+typedef struct {
+ uint16_t N;
+ cfft_info *cfft;
+ complex_t *sincos;
+ complex_t *Z1;
+} mdct_info;
+
+typedef struct
+{
+ real_t *long_window[2];
+ real_t *short_window[2];
+#ifdef LD_DEC
+ real_t *ld_window[2];
+#endif
+
+ mdct_info *mdct256;
+#ifdef LD_DEC
+ mdct_info *mdct1024;
+#endif
+ mdct_info *mdct2048;
+} fb_info;
+
+typedef struct
+{
+ uint8_t present;
+
+ uint8_t num_bands;
+ uint8_t pce_instance_tag;
+ uint8_t excluded_chns_present;
+ uint8_t band_top[17];
+ uint8_t prog_ref_level;
+ uint8_t dyn_rng_sgn[17];
+ uint8_t dyn_rng_ctl[17];
+ uint8_t exclude_mask[MAX_CHANNELS];
+ uint8_t additional_excluded_chns[MAX_CHANNELS];
+
+ real_t ctrl1;
+ real_t ctrl2;
+} drc_info;
+
+typedef struct
+{
+ uint8_t element_instance_tag;
+ uint8_t object_type;
+ uint8_t sf_index;
+ uint8_t num_front_channel_elements;
+ uint8_t num_side_channel_elements;
+ uint8_t num_back_channel_elements;
+ uint8_t num_lfe_channel_elements;
+ uint8_t num_assoc_data_elements;
+ uint8_t num_valid_cc_elements;
+ uint8_t mono_mixdown_present;
+ uint8_t mono_mixdown_element_number;
+ uint8_t stereo_mixdown_present;
+ uint8_t stereo_mixdown_element_number;
+ uint8_t matrix_mixdown_idx_present;
+ uint8_t pseudo_surround_enable;
+ uint8_t matrix_mixdown_idx;
+ uint8_t front_element_is_cpe[16];
+ uint8_t front_element_tag_select[16];
+ uint8_t side_element_is_cpe[16];
+ uint8_t side_element_tag_select[16];
+ uint8_t back_element_is_cpe[16];
+ uint8_t back_element_tag_select[16];
+ uint8_t lfe_element_tag_select[16];
+ uint8_t assoc_data_element_tag_select[16];
+ uint8_t cc_element_is_ind_sw[16];
+ uint8_t valid_cc_element_tag_select[16];
+
+ uint8_t channels;
+
+ uint8_t comment_field_bytes;
+ uint8_t comment_field_data[257];
+} program_config;
+
+typedef struct
+{
+ uint16_t syncword;
+ uint8_t id;
+ uint8_t layer;
+ uint8_t protection_absent;
+ uint8_t profile;
+ uint8_t sf_index;
+ uint8_t private_bit;
+ uint8_t channel_configuration;
+ uint8_t original;
+ uint8_t home;
+ uint8_t emphasis;
+ uint8_t copyright_identification_bit;
+ uint8_t copyright_identification_start;
+ uint16_t aac_frame_length;
+ uint16_t adts_buffer_fullness;
+ uint8_t no_raw_data_blocks_in_frame;
+ uint16_t crc_check;
+} adts_header;
+
+typedef struct
+{
+ uint8_t copyright_id_present;
+ int8_t copyright_id[10];
+ uint8_t original_copy;
+ uint8_t home;
+ uint8_t bitstream_type;
+ uint32_t bitrate;
+ uint8_t num_program_config_elements;
+ uint32_t adif_buffer_fullness;
+
+ program_config pce;
+} adif_header;
+
+typedef struct
+{
+ uint8_t last_band;
+ uint8_t data_present;
+ uint16_t lag;
+ uint8_t lag_update;
+ uint8_t coef;
+ uint8_t long_used[MAX_SFB];
+ uint8_t short_used[8];
+ uint8_t short_lag_present[8];
+ uint8_t short_lag[8];
+} ltp_info;
+
+typedef struct
+{
+ uint8_t limit;
+ uint8_t predictor_reset;
+ uint8_t predictor_reset_group_number;
+ uint8_t prediction_used[MAX_SFB];
+} pred_info;
+
+typedef struct
+{
+ uint8_t number_pulse;
+ uint8_t pulse_start_sfb;
+ uint8_t pulse_offset[4];
+ uint8_t pulse_amp[4];
+} pulse_info;
+
+typedef struct
+{
+ uint8_t n_filt[8];
+ uint8_t coef_res[8];
+ uint8_t length[8][4];
+ uint8_t order[8][4];
+ uint8_t direction[8][4];
+ uint8_t coef_compress[8][4];
+ uint8_t coef[8][4][32];
+} tns_info;
+
+#ifdef SSR_DEC
+typedef struct
+{
+ uint8_t max_band;
+
+ uint8_t adjust_num[4][8];
+ uint8_t alevcode[4][8][8];
+ uint8_t aloccode[4][8][8];
+} ssr_info;
+#endif
+
+typedef struct
+{
+ uint8_t max_sfb;
+
+ uint8_t num_swb;
+ uint8_t num_window_groups;
+ uint8_t num_windows;
+ uint8_t window_sequence;
+ uint8_t window_group_length[8];
+ uint8_t window_shape;
+ uint8_t scale_factor_grouping;
+ uint16_t sect_sfb_offset[8][15*8];
+ uint16_t swb_offset[52];
+
+ uint8_t sect_cb[8][15*8];
+ uint16_t sect_start[8][15*8];
+ uint16_t sect_end[8][15*8];
+ uint8_t sfb_cb[8][8*15];
+ uint8_t num_sec[8]; /* number of sections in a group */
+
+ uint8_t global_gain;
+ int16_t scale_factors[8][51];
+
+ uint8_t ms_mask_present;
+ uint8_t ms_used[MAX_WINDOW_GROUPS][MAX_SFB];
+
+ uint8_t noise_used;
+
+ uint8_t pulse_data_present;
+ uint8_t tns_data_present;
+ uint8_t gain_control_data_present;
+ uint8_t predictor_data_present;
+
+ pulse_info pul;
+ tns_info tns;
+ pred_info pred;
+ ltp_info ltp;
+ ltp_info ltp2;
+#ifdef SSR_DEC
+ ssr_info ssr;
+#endif
+
+#ifdef ERROR_RESILIENCE
+ /* ER HCR data */
+ uint16_t length_of_reordered_spectral_data;
+ uint8_t length_of_longest_codeword;
+ /* ER RLVC data */
+ uint8_t sf_concealment;
+ uint8_t rev_global_gain;
+ uint16_t length_of_rvlc_sf;
+ uint16_t dpcm_noise_nrg;
+ uint8_t sf_escapes_present;
+ uint8_t length_of_rvlc_escapes;
+ uint16_t dpcm_noise_last_position;
+#endif
+} ic_stream; /* individual channel stream */
+
+typedef struct
+{
+ uint8_t ele_id;
+
+ uint8_t channel;
+ int16_t paired_channel;
+
+ uint8_t element_instance_tag;
+ uint8_t common_window;
+
+ ic_stream ics1;
+ ic_stream ics2;
+} element; /* syntax element (SCE, CPE, LFE) */
+
+typedef struct faacDecConfiguration
+{
+ uint8_t defObjectType;
+ uint32_t defSampleRate;
+ uint8_t outputFormat;
+} faacDecConfiguration, *faacDecConfigurationPtr;
+
+typedef struct faacDecFrameInfo
+{
+ uint32_t bytesconsumed;
+ uint32_t samples;
+ uint8_t channels;
+ uint8_t error;
+} faacDecFrameInfo;
+
+typedef struct
+{
+ uint8_t adts_header_present;
+ uint8_t adif_header_present;
+ uint8_t sf_index;
+ uint8_t object_type;
+ uint8_t channelConfiguration;
+#ifdef ERROR_RESILIENCE
+ uint8_t aacSectionDataResilienceFlag;
+ uint8_t aacScalefactorDataResilienceFlag;
+ uint8_t aacSpectralDataResilienceFlag;
+#endif
+ uint16_t frameLength;
+
+ uint32_t frame;
+
+ void *sample_buffer;
+
+ uint8_t window_shape_prev[MAX_CHANNELS];
+#ifdef LTP_DEC
+ uint16_t ltp_lag[MAX_CHANNELS];
+#endif
+ fb_info *fb;
+ drc_info *drc;
+
+ real_t *time_out[MAX_CHANNELS];
+
+#ifdef MAIN_DEC
+ pred_state *pred_stat[MAX_CHANNELS];
+#endif
+#ifdef LTP_DEC
+ real_t *lt_pred_stat[MAX_CHANNELS];
+#endif
+
+#ifndef FIXED_POINT
+#if POW_TABLE_SIZE
+ real_t *pow2_table;
+#endif
+#endif
+
+ /* Configuration data */
+ faacDecConfiguration config;
+} faacDecStruct, *faacDecHandle;
+
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif
--- a/libfaad/syntax.c
+++ b/libfaad/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: syntax.c,v 1.31 2002/11/08 13:12:33 menno Exp $
+** $Id: syntax.c,v 1.32 2002/11/28 18:48:30 menno Exp $
**/
/*
@@ -27,9 +27,12 @@
an ADTS header)).
*/
+#include "common.h"
+#include "structs.h"
+
#include <stdlib.h>
#include <string.h>
-#include "common.h"
+
#include "decoder.h"
#include "syntax.h"
#include "specrec.h"
@@ -38,8 +41,9 @@
#include "data.h"
#include "pulse.h"
#include "analysis.h"
+#include "drc.h"
#ifdef ERROR_RESILIENCE
-#include "rvlc_scale_factors.h"
+#include "rvlc.h"
#endif
@@ -251,15 +255,8 @@
ele->channel = channels;
ele->paired_channel = -1;
- hInfo->error = single_lfe_channel_element(ele,
- ld, spec_data[channels], hDecoder->sf_index,
- hDecoder->object_type, hDecoder->frameLength
-#ifdef ERROR_RESILIENCE
- ,hDecoder->aacSectionDataResilienceFlag,
- hDecoder->aacScalefactorDataResilienceFlag,
- hDecoder->aacSpectralDataResilienceFlag
-#endif
- );
+ hInfo->error = single_lfe_channel_element(hDecoder, ele,
+ ld, spec_data[channels]);
return ele;
}
@@ -282,16 +279,8 @@
ele->channel = channels;
ele->paired_channel = channels+1;
- hInfo->error = channel_pair_element(ele,
- ld, spec_data[channels], spec_data[channels+1],
- hDecoder->sf_index, hDecoder->object_type,
- hDecoder->frameLength
-#ifdef ERROR_RESILIENCE
- ,hDecoder->aacSectionDataResilienceFlag,
- hDecoder->aacScalefactorDataResilienceFlag,
- hDecoder->aacSpectralDataResilienceFlag
-#endif
- );
+ hInfo->error = channel_pair_element(hDecoder, ele,
+ ld, spec_data[channels], spec_data[channels+1]);
return ele;
}
@@ -504,16 +493,9 @@
/* Table 4.4.4 and */
/* Table 4.4.9 */
-static uint8_t single_lfe_channel_element(element *sce, bitfile *ld,
- int16_t *spec_data,
- uint8_t sf_index, uint8_t object_type,
- uint16_t frame_len
-#ifdef ERROR_RESILIENCE
- ,uint8_t aacSectionDataResilienceFlag,
- uint8_t aacScalefactorDataResilienceFlag,
- uint8_t aacSpectralDataResilienceFlag
-#endif
- )
+static uint8_t single_lfe_channel_element(faacDecHandle hDecoder,
+ element *sce, bitfile *ld,
+ int16_t *spec_data)
{
ic_stream *ics = &(sce->ics1);
@@ -523,26 +505,13 @@
sce->element_instance_tag = (uint8_t)faad_getbits(ld, LEN_TAG
DEBUGVAR(1,38,"single_lfe_channel_element(): element_instance_tag"));
- return individual_channel_stream(sce, ld, ics, 0, spec_data, sf_index,
- object_type, frame_len
-#ifdef ERROR_RESILIENCE
- ,aacSectionDataResilienceFlag,
- aacScalefactorDataResilienceFlag,
- aacSpectralDataResilienceFlag
-#endif
- );
+ return individual_channel_stream(hDecoder, sce, ld, ics, 0, spec_data);
}
/* Table 4.4.5 */
-static uint8_t channel_pair_element(element *cpe, bitfile *ld, int16_t *spec_data1,
- int16_t *spec_data2, uint8_t sf_index, uint8_t object_type,
- uint16_t frame_len
-#ifdef ERROR_RESILIENCE
- ,uint8_t aacSectionDataResilienceFlag,
- uint8_t aacScalefactorDataResilienceFlag,
- uint8_t aacSpectralDataResilienceFlag
-#endif
- )
+static uint8_t channel_pair_element(faacDecHandle hDecoder, element *cpe,
+ bitfile *ld, int16_t *spec_data1,
+ int16_t *spec_data2)
{
uint8_t result;
ic_stream *ics1 = &(cpe->ics1);
@@ -558,8 +527,7 @@
DEBUGVAR(1,40,"channel_pair_element(): common_window"))) & 1)
{
/* both channels have common ics information */
- if ((result = ics_info(ics1, ld, cpe->common_window, sf_index,
- object_type, frame_len)) > 0)
+ if ((result = ics_info(hDecoder, ics1, ld, cpe->common_window)) > 0)
return result;
ics1->ms_mask_present = (uint8_t)faad_getbits(ld, 2
@@ -578,12 +546,12 @@
}
#ifdef ERROR_RESILIENCE
- if ((object_type >= ER_OBJECT_START) && (ics1->predictor_data_present))
+ if ((hDecoder->object_type >= ER_OBJECT_START) && (ics1->predictor_data_present))
{
if ((ics1->ltp.data_present = faad_get1bit(ld
DEBUGVAR(1,50,"channel_pair_element(): ltp.data_present"))) & 1)
{
- ltp_data(ics1, &(ics1->ltp), ld, object_type);
+ ltp_data(hDecoder, ics1, &(ics1->ltp), ld);
}
}
#endif
@@ -593,44 +561,36 @@
ics1->ms_mask_present = 0;
}
- if ((result = individual_channel_stream(cpe, ld, ics1, 0, spec_data1,
- sf_index, object_type, frame_len
-#ifdef ERROR_RESILIENCE
- ,aacSectionDataResilienceFlag,
- aacScalefactorDataResilienceFlag,
- aacSpectralDataResilienceFlag
-#endif
- )) > 0)
+ if ((result = individual_channel_stream(hDecoder, cpe, ld, ics1,
+ 0, spec_data1)) > 0)
+ {
return result;
+ }
#ifdef ERROR_RESILIENCE
- if (cpe->common_window && (object_type >= ER_OBJECT_START) &&
+ if (cpe->common_window && (hDecoder->object_type >= ER_OBJECT_START) &&
(ics1->predictor_data_present))
{
if ((ics1->ltp2.data_present = faad_get1bit(ld
DEBUGVAR(1,50,"channel_pair_element(): ltp.data_present"))) & 1)
{
- ltp_data(ics1, &(ics1->ltp2), ld, object_type);
+ ltp_data(hDecoder, ics1, &(ics1->ltp2), ld);
}
}
#endif
- if ((result = individual_channel_stream(cpe, ld, ics2, 0, spec_data2,
- sf_index, object_type, frame_len
-#ifdef ERROR_RESILIENCE
- ,aacSectionDataResilienceFlag,
- aacScalefactorDataResilienceFlag,
- aacSpectralDataResilienceFlag
-#endif
- )) > 0)
+ if ((result = individual_channel_stream(hDecoder, cpe, ld, ics2,
+ 0, spec_data2)) > 0)
+ {
return result;
+ }
return 0;
}
/* Table 4.4.6 */
-static uint8_t ics_info(ic_stream *ics, bitfile *ld, uint8_t common_window,
- uint8_t sf_index, uint8_t object_type, uint16_t frame_len)
+static uint8_t ics_info(faacDecHandle hDecoder, ic_stream *ics, bitfile *ld,
+ uint8_t common_window)
{
/* ics->ics_reserved_bit = */ faad_get1bit(ld
DEBUGVAR(1,43,"ics_info(): ics_reserved_bit"));
@@ -652,11 +612,11 @@
if ((ics->predictor_data_present = faad_get1bit(ld
DEBUGVAR(1,49,"ics_info(): predictor_data_present"))) & 1)
{
- if (object_type == MAIN) /* MPEG2 style AAC predictor */
+ if (hDecoder->object_type == MAIN) /* MPEG2 style AAC predictor */
{
uint8_t sfb;
- ics->pred.limit = min(ics->max_sfb, pred_sfb_max[sf_index]);
+ ics->pred.limit = min(ics->max_sfb, pred_sfb_max[hDecoder->sf_index]);
if ((ics->pred.predictor_reset = faad_get1bit(ld
DEBUGVAR(1,53,"ics_info(): pred.predictor_reset"))) & 1)
@@ -673,12 +633,12 @@
}
#ifdef LTP_DEC
else { /* Long Term Prediction */
- if (object_type < ER_OBJECT_START)
+ if (hDecoder->object_type < ER_OBJECT_START)
{
if ((ics->ltp.data_present = faad_get1bit(ld
DEBUGVAR(1,50,"ics_info(): ltp.data_present"))) & 1)
{
- ltp_data(ics, &(ics->ltp), ld, object_type);
+ ltp_data(hDecoder, ics, &(ics->ltp), ld);
}
if (common_window)
{
@@ -685,17 +645,17 @@
if ((ics->ltp2.data_present = faad_get1bit(ld
DEBUGVAR(1,51,"ics_info(): ltp2.data_present"))) & 1)
{
- ltp_data(ics, &(ics->ltp2), ld, object_type);
+ ltp_data(hDecoder, ics, &(ics->ltp2), ld);
}
}
}
#ifdef ERROR_RESILIENCE
- if (!common_window && (object_type >= ER_OBJECT_START))
+ if (!common_window && (hDecoder->object_type >= ER_OBJECT_START))
{
if ((ics->ltp.data_present = faad_get1bit(ld
DEBUGVAR(1,50,"ics_info(): ltp.data_present"))) & 1)
{
- ltp_data(ics, &(ics->ltp), ld, object_type);
+ ltp_data(hDecoder, ics, &(ics->ltp), ld);
}
}
#endif
@@ -705,7 +665,7 @@
}
/* get the grouping information */
- return window_grouping_info(ics, sf_index, object_type, frame_len);
+ return window_grouping_info(hDecoder, ics);
}
/* Table 4.4.7 */
@@ -778,52 +738,51 @@
}
/* Table 4.4.12 */
+#ifdef SSR_DEC
static void gain_control_data(bitfile *ld, ic_stream *ics)
{
uint8_t bd, wd, ad;
- uint8_t adjust_num[4][8];
- uint8_t alevcode[4][8][8];
- uint8_t aloccode[4][8][8];
+ ssr_info *ssr = &(ics->ssr);
- uint8_t max_band = (uint8_t)faad_getbits(ld, 2
+ ssr->max_band = (uint8_t)faad_getbits(ld, 2
DEBUGVAR(1,1000,"gain_control_data(): max_band"));
if (ics->window_sequence == ONLY_LONG_SEQUENCE)
{
- for (bd = 1; bd <= max_band; bd++)
+ for (bd = 1; bd <= ssr->max_band; bd++)
{
- for (wd=0; wd<1; wd++)
+ for (wd = 0; wd < 1; wd++)
{
- adjust_num[bd][wd] = (uint8_t)faad_getbits(ld, 3
+ ssr->adjust_num[bd][wd] = (uint8_t)faad_getbits(ld, 3
DEBUGVAR(1,1001,"gain_control_data(): adjust_num"));
- for (ad = 0; ad < adjust_num[bd][wd]; ad++)
+ for (ad = 0; ad < ssr->adjust_num[bd][wd]; ad++)
{
- alevcode[bd][wd][ad] = (uint8_t)faad_getbits(ld, 4
+ ssr->alevcode[bd][wd][ad] = (uint8_t)faad_getbits(ld, 4
DEBUGVAR(1,1002,"gain_control_data(): alevcode"));
- aloccode[bd][wd][ad] = (uint8_t)faad_getbits(ld, 5
+ ssr->aloccode[bd][wd][ad] = (uint8_t)faad_getbits(ld, 5
DEBUGVAR(1,1003,"gain_control_data(): aloccode"));
}
}
}
} else if (ics->window_sequence == LONG_START_SEQUENCE) {
- for (bd = 1; bd <= max_band; bd++)
+ for (bd = 1; bd <= ssr->max_band; bd++)
{
for (wd = 0; wd < 2; wd++)
{
- adjust_num[bd][wd] = (uint8_t)faad_getbits(ld, 3
+ ssr->adjust_num[bd][wd] = (uint8_t)faad_getbits(ld, 3
DEBUGVAR(1,1001,"gain_control_data(): adjust_num"));
- for (ad = 0; ad < adjust_num[bd][wd]; ad++)
+ for (ad = 0; ad < ssr->adjust_num[bd][wd]; ad++)
{
- alevcode[bd][wd][ad] = (uint8_t)faad_getbits(ld, 4
+ ssr->alevcode[bd][wd][ad] = (uint8_t)faad_getbits(ld, 4
DEBUGVAR(1,1002,"gain_control_data(): alevcode"));
if (wd == 0)
{
- aloccode[bd][wd][ad] = (uint8_t)faad_getbits(ld, 4
+ ssr->aloccode[bd][wd][ad] = (uint8_t)faad_getbits(ld, 4
DEBUGVAR(1,1003,"gain_control_data(): aloccode"));
} else {
- aloccode[bd][wd][ad] = (uint8_t)faad_getbits(ld, 2
+ ssr->aloccode[bd][wd][ad] = (uint8_t)faad_getbits(ld, 2
DEBUGVAR(1,1003,"gain_control_data(): aloccode"));
}
}
@@ -830,41 +789,41 @@
}
}
} else if (ics->window_sequence == EIGHT_SHORT_SEQUENCE) {
- for (bd = 1; bd <= max_band; bd++)
+ for (bd = 1; bd <= ssr->max_band; bd++)
{
- for(wd=0; wd<8; wd++)
+ for (wd = 0; wd < 8; wd++)
{
- adjust_num[bd][wd] = (uint8_t)faad_getbits(ld, 3
+ ssr->adjust_num[bd][wd] = (uint8_t)faad_getbits(ld, 3
DEBUGVAR(1,1001,"gain_control_data(): adjust_num"));
- for (ad = 0; ad < adjust_num[bd][wd]; ad++)
+ for (ad = 0; ad < ssr->adjust_num[bd][wd]; ad++)
{
- alevcode[bd][wd][ad] = (uint8_t)faad_getbits(ld, 4
+ ssr->alevcode[bd][wd][ad] = (uint8_t)faad_getbits(ld, 4
DEBUGVAR(1,1002,"gain_control_data(): alevcode"));
- aloccode[bd][wd][ad] = (uint8_t)faad_getbits(ld, 2
+ ssr->aloccode[bd][wd][ad] = (uint8_t)faad_getbits(ld, 2
DEBUGVAR(1,1003,"gain_control_data(): aloccode"));
}
}
}
} else if (ics->window_sequence == LONG_STOP_SEQUENCE) {
- for (bd = 1; bd <= max_band; bd++)
+ for (bd = 1; bd <= ssr->max_band; bd++)
{
for (wd = 0; wd < 2; wd++)
{
- adjust_num[bd][wd] = (uint8_t)faad_getbits(ld, 3
+ ssr->adjust_num[bd][wd] = (uint8_t)faad_getbits(ld, 3
DEBUGVAR(1,1001,"gain_control_data(): adjust_num"));
- for (ad = 0; ad < adjust_num[bd][wd]; ad++)
+ for (ad = 0; ad < ssr->adjust_num[bd][wd]; ad++)
{
- alevcode[bd][wd][ad] = (uint8_t)faad_getbits(ld, 4
+ ssr->alevcode[bd][wd][ad] = (uint8_t)faad_getbits(ld, 4
DEBUGVAR(1,1002,"gain_control_data(): alevcode"));
if (wd == 0)
{
- aloccode[bd][wd][ad] = (uint8_t)faad_getbits(ld, 4
+ ssr->aloccode[bd][wd][ad] = (uint8_t)faad_getbits(ld, 4
DEBUGVAR(1,1003,"gain_control_data(): aloccode"));
} else {
- aloccode[bd][wd][ad] = (uint8_t)faad_getbits(ld, 5
+ ssr->aloccode[bd][wd][ad] = (uint8_t)faad_getbits(ld, 5
DEBUGVAR(1,1003,"gain_control_data(): aloccode"));
}
}
@@ -872,18 +831,12 @@
}
}
}
+#endif
/* Table 4.4.24 */
-static uint8_t individual_channel_stream(element *ele, bitfile *ld,
- ic_stream *ics, uint8_t scal_flag,
- int16_t *spec_data, uint8_t sf_index,
- uint8_t object_type, uint16_t frame_len
-#ifdef ERROR_RESILIENCE
- ,uint8_t aacSectionDataResilienceFlag,
- uint8_t aacScalefactorDataResilienceFlag,
- uint8_t aacSpectralDataResilienceFlag
-#endif
- )
+static uint8_t individual_channel_stream(faacDecHandle hDecoder, element *ele,
+ bitfile *ld, ic_stream *ics, uint8_t scal_flag,
+ int16_t *spec_data)
{
uint8_t result;
@@ -892,20 +845,11 @@
if (!ele->common_window && !scal_flag)
{
- if ((result = ics_info(ics, ld, ele->common_window, sf_index,
- object_type, frame_len)) > 0)
+ if ((result = ics_info(hDecoder, ics, ld, ele->common_window)) > 0)
return result;
}
- section_data(ics, ld
-#ifdef ERROR_RESILIENCE
- ,aacSectionDataResilienceFlag
-#endif
- );
- if ((result = scale_factor_data(ics, ld
-#ifdef ERROR_RESILIENCE
- ,aacScalefactorDataResilienceFlag
-#endif
- )) > 0)
+ section_data(hDecoder, ics, ld);
+ if ((result = scale_factor_data(hDecoder, ics, ld)) > 0)
return result;
if (!scal_flag)
@@ -927,7 +871,7 @@
DEBUGVAR(1,69,"individual_channel_stream(): tns_data_present"))) & 1)
{
#ifdef ERROR_RESILIENCE
- if (object_type < ER_OBJECT_START)
+ if (hDecoder->object_type < ER_OBJECT_START)
#endif
tns_data(ics, &(ics->tns), ld);
}
@@ -936,16 +880,16 @@
if ((ics->gain_control_data_present = faad_get1bit(ld
DEBUGVAR(1,70,"individual_channel_stream(): gain_control_data_present"))) & 1)
{
-#if 1
- return 1;
-#else
+#ifdef SSR_DEC
gain_control_data(ld, ics);
+#else
+ return 1;
#endif
}
}
#ifdef ERROR_RESILIENCE
- if (aacSpectralDataResilienceFlag)
+ if (hDecoder->aacSpectralDataResilienceFlag)
{
ics->length_of_reordered_spectral_data = (uint16_t)faad_getbits(ld, 14
DEBUGVAR(1,147,"individual_channel_stream(): length_of_reordered_spectral_data"));
@@ -957,23 +901,22 @@
}
/* RVLC spectral data is put here */
- if (aacScalefactorDataResilienceFlag)
+ if (hDecoder->aacScalefactorDataResilienceFlag)
{
if ((result = rvlc_decode_scale_factors(ics, ld)) > 0)
return result;
}
- if (object_type >= ER_OBJECT_START)
+ if (hDecoder->object_type >= ER_OBJECT_START)
{
if (ics->tns_data_present)
tns_data(ics, &(ics->tns), ld);
}
- if (aacSpectralDataResilienceFlag)
+ if (hDecoder->aacSpectralDataResilienceFlag)
{
/* error resilient spectral data decoding */
- if ((result = reordered_spectral_data(ics, ld, spec_data, frame_len,
- aacSectionDataResilienceFlag)) > 0)
+ if ((result = reordered_spectral_data(hDecoder, ics, ld, spec_data)) > 0)
{
return result;
}
@@ -980,7 +923,7 @@
} else {
#endif
/* decode the spectral data */
- if ((result = spectral_data(ics, ld, spec_data, frame_len)) > 0)
+ if ((result = spectral_data(hDecoder, ics, ld, spec_data)) > 0)
{
return result;
}
@@ -1001,11 +944,7 @@
}
/* Table 4.4.25 */
-static void section_data(ic_stream *ics, bitfile *ld
-#ifdef ERROR_RESILIENCE
- ,uint8_t aacSectionDataResilienceFlag
-#endif
- )
+static void section_data(faacDecHandle hDecoder, ic_stream *ics, bitfile *ld)
{
uint8_t g;
uint8_t sect_esc_val, sect_bits;
@@ -1037,7 +976,7 @@
uint8_t sect_cb_bits = 4;
#ifdef ERROR_RESILIENCE
- if (aacSectionDataResilienceFlag)
+ if (hDecoder->aacSectionDataResilienceFlag)
sect_cb_bits = 5;
#endif
@@ -1048,7 +987,7 @@
ics->noise_used = 1;
#ifdef ERROR_RESILIENCE
- if (aacSectionDataResilienceFlag)
+ if (hDecoder->aacSectionDataResilienceFlag)
{
if ((ics->sect_cb[g][i] == 11) ||
((ics->sect_cb[g][i] >= 16) && (ics->sect_cb[g][i] <= 32)))
@@ -1181,14 +1120,10 @@
}
/* Table 4.4.26 */
-static uint8_t scale_factor_data(ic_stream *ics, bitfile *ld
-#ifdef ERROR_RESILIENCE
- ,uint8_t aacScalefactorDataResilienceFlag
-#endif
- )
+static uint8_t scale_factor_data(faacDecHandle hDecoder, ic_stream *ics, bitfile *ld)
{
#ifdef ERROR_RESILIENCE
- if (!aacScalefactorDataResilienceFlag)
+ if (!hDecoder->aacScalefactorDataResilienceFlag)
{
#endif
return decode_scale_factors(ics, ld);
@@ -1264,13 +1199,12 @@
The limit MAX_LTP_SFB is not defined in 14496-3, this is a bug in the document
and will be corrected in one of the corrigenda.
*/
-static void ltp_data(ic_stream *ics, ltp_info *ltp, bitfile *ld,
- uint8_t object_type)
+static void ltp_data(faacDecHandle hDecoder, ic_stream *ics, ltp_info *ltp, bitfile *ld)
{
uint8_t sfb, w;
#ifdef LD_DEC
- if (object_type == LD)
+ if (hDecoder->object_type == LD)
{
ltp->lag_update = (uint8_t)faad_getbits(ld, 1
DEBUGVAR(1,142,"ltp_data(): lag_update"));
@@ -1319,8 +1253,8 @@
#endif
/* Table 4.4.29 */
-static uint8_t spectral_data(ic_stream *ics, bitfile *ld, int16_t *spectral_data,
- uint16_t frame_len)
+static uint8_t spectral_data(faacDecHandle hDecoder, ic_stream *ics, bitfile *ld,
+ int16_t *spectral_data)
{
int8_t i;
uint8_t g;
@@ -1329,16 +1263,10 @@
uint8_t groups = 0;
uint8_t sect_cb;
uint8_t result;
- uint16_t nshort = frame_len/8;
+ uint16_t nshort = hDecoder->frameLength/8;
sp = spectral_data;
- for (i = frame_len/16-1; i >= 0; --i)
- {
- *sp++ = 0; *sp++ = 0; *sp++ = 0; *sp++ = 0;
- *sp++ = 0; *sp++ = 0; *sp++ = 0; *sp++ = 0;
- *sp++ = 0; *sp++ = 0; *sp++ = 0; *sp++ = 0;
- *sp++ = 0; *sp++ = 0; *sp++ = 0; *sp++ = 0;
- }
+ memset(sp, 0, hDecoder->frameLength*sizeof(int16_t));
for(g = 0; g < ics->num_window_groups; g++)
{
--- a/libfaad/syntax.h
+++ b/libfaad/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: syntax.h,v 1.22 2002/10/26 11:43:12 menno Exp $
+** $Id: syntax.h,v 1.23 2002/11/28 18:48:30 menno Exp $
**/
#ifndef __SYNTAX_H__
@@ -26,6 +26,8 @@
extern "C" {
#endif
+#include "decoder.h"
+#include "drc.h"
#include "bits.h"
#define MAIN 0
@@ -60,14 +62,6 @@
#define ID_FIL 0x6
#define ID_END 0x7
-#define MAX_CHANNELS 64
-#define MAX_SYNTAX_ELEMENTS 48
-#define MAX_WINDOW_GROUPS 8
-#define MAX_SFB 51
-#define MAX_LTP_SFB 40
-#define MAX_LTP_SFB_S 8
-
-
#define ONLY_LONG_SEQUENCE 0x0
#define LONG_START_SEQUENCE 0x1
#define EIGHT_SHORT_SEQUENCE 0x2
@@ -84,203 +78,6 @@
#define INTENSITY_HCB 15
-typedef struct
-{
- uint8_t element_instance_tag;
- uint8_t object_type;
- uint8_t sf_index;
- uint8_t num_front_channel_elements;
- uint8_t num_side_channel_elements;
- uint8_t num_back_channel_elements;
- uint8_t num_lfe_channel_elements;
- uint8_t num_assoc_data_elements;
- uint8_t num_valid_cc_elements;
- uint8_t mono_mixdown_present;
- uint8_t mono_mixdown_element_number;
- uint8_t stereo_mixdown_present;
- uint8_t stereo_mixdown_element_number;
- uint8_t matrix_mixdown_idx_present;
- uint8_t pseudo_surround_enable;
- uint8_t matrix_mixdown_idx;
- uint8_t front_element_is_cpe[16];
- uint8_t front_element_tag_select[16];
- uint8_t side_element_is_cpe[16];
- uint8_t side_element_tag_select[16];
- uint8_t back_element_is_cpe[16];
- uint8_t back_element_tag_select[16];
- uint8_t lfe_element_tag_select[16];
- uint8_t assoc_data_element_tag_select[16];
- uint8_t cc_element_is_ind_sw[16];
- uint8_t valid_cc_element_tag_select[16];
-
- uint8_t channels;
-
- uint8_t comment_field_bytes;
- uint8_t comment_field_data[257];
-} program_config;
-
-typedef struct
-{
- uint16_t syncword;
- uint8_t id;
- uint8_t layer;
- uint8_t protection_absent;
- uint8_t profile;
- uint8_t sf_index;
- uint8_t private_bit;
- uint8_t channel_configuration;
- uint8_t original;
- uint8_t home;
- uint8_t emphasis;
- uint8_t copyright_identification_bit;
- uint8_t copyright_identification_start;
- uint16_t aac_frame_length;
- uint16_t adts_buffer_fullness;
- uint8_t no_raw_data_blocks_in_frame;
- uint16_t crc_check;
-} adts_header;
-
-typedef struct
-{
- uint8_t copyright_id_present;
- int8_t copyright_id[10];
- uint8_t original_copy;
- uint8_t home;
- uint8_t bitstream_type;
- uint32_t bitrate;
- uint8_t num_program_config_elements;
- uint32_t adif_buffer_fullness;
-
- program_config pce;
-} adif_header;
-
-typedef struct
-{
- uint8_t last_band;
- uint8_t data_present;
- uint16_t lag;
- uint8_t lag_update;
- uint8_t coef;
- uint8_t long_used[MAX_SFB];
- uint8_t short_used[8];
- uint8_t short_lag_present[8];
- uint8_t short_lag[8];
-} ltp_info;
-
-typedef struct
-{
- uint8_t limit;
- uint8_t predictor_reset;
- uint8_t predictor_reset_group_number;
- uint8_t prediction_used[MAX_SFB];
-} pred_info;
-
-typedef struct
-{
- uint8_t number_pulse;
- uint8_t pulse_start_sfb;
- uint8_t pulse_offset[4];
- uint8_t pulse_amp[4];
-} pulse_info;
-
-typedef struct
-{
- uint8_t n_filt[8];
- uint8_t coef_res[8];
- uint8_t length[8][4];
- uint8_t order[8][4];
- uint8_t direction[8][4];
- uint8_t coef_compress[8][4];
- uint8_t coef[8][4][32];
-} tns_info;
-
-typedef struct
-{
- uint8_t present;
-
- uint8_t num_bands;
- uint8_t pce_instance_tag;
- uint8_t excluded_chns_present;
- uint8_t band_top[17];
- uint8_t prog_ref_level;
- uint8_t dyn_rng_sgn[17];
- uint8_t dyn_rng_ctl[17];
- uint8_t exclude_mask[MAX_CHANNELS];
- uint8_t additional_excluded_chns[MAX_CHANNELS];
-
- real_t ctrl1;
- real_t ctrl2;
-} drc_info;
-
-typedef struct
-{
- uint8_t max_sfb;
-
- uint8_t num_swb;
- uint8_t num_window_groups;
- uint8_t num_windows;
- uint8_t window_sequence;
- uint8_t window_group_length[8];
- uint8_t window_shape;
- uint8_t scale_factor_grouping;
- uint16_t sect_sfb_offset[8][15*8];
- uint16_t swb_offset[52];
-
- uint8_t sect_cb[8][15*8];
- uint16_t sect_start[8][15*8];
- uint16_t sect_end[8][15*8];
- uint8_t sfb_cb[8][8*15];
- uint8_t num_sec[8]; /* number of sections in a group */
-
- uint8_t global_gain;
- int16_t scale_factors[8][51];
-
- uint8_t ms_mask_present;
- uint8_t ms_used[MAX_WINDOW_GROUPS][MAX_SFB];
-
- uint8_t noise_used;
-
- uint8_t pulse_data_present;
- uint8_t tns_data_present;
- uint8_t gain_control_data_present;
- uint8_t predictor_data_present;
-
- pulse_info pul;
- tns_info tns;
- pred_info pred;
- ltp_info ltp;
- ltp_info ltp2;
-
-#ifdef ERROR_RESILIENCE
- /* ER HCR data */
- uint16_t length_of_reordered_spectral_data;
- uint8_t length_of_longest_codeword;
- /* ER RLVC data */
- uint8_t sf_concealment;
- uint8_t rev_global_gain;
- uint16_t length_of_rvlc_sf;
- uint16_t dpcm_noise_nrg;
- uint8_t sf_escapes_present;
- uint8_t length_of_rvlc_escapes;
- uint16_t dpcm_noise_last_position;
-#endif
-} ic_stream; /* individual channel stream */
-
-typedef struct
-{
- uint8_t ele_id;
-
- uint8_t channel;
- int16_t paired_channel;
-
- uint8_t element_instance_tag;
- uint8_t common_window;
-
- ic_stream ics1;
- ic_stream ics2;
-} element; /* syntax element (SCE, CPE, LFE) */
-
-
int8_t GASpecificConfig(bitfile *ld, uint8_t *channelConfiguration,
uint8_t object_type,
#ifdef ERROR_RESILIENCE
@@ -295,63 +92,33 @@
/* static functions */
-static uint8_t single_lfe_channel_element(element *sce, bitfile *ld,
- int16_t *spec_data,
- uint8_t sf_index, uint8_t object_type,
- uint16_t frame_len
-#ifdef ERROR_RESILIENCE
- ,uint8_t aacSectionDataResilienceFlag,
- uint8_t aacScalefactorDataResilienceFlag,
- uint8_t aacSpectralDataResilienceFlag
-#endif
- );
-static uint8_t channel_pair_element(element *cpe, bitfile *ld, int16_t *spec_data1,
- int16_t *spec_data2, uint8_t sf_index, uint8_t object_type,
- uint16_t frame_len
-#ifdef ERROR_RESILIENCE
- ,uint8_t aacSectionDataResilienceFlag,
- uint8_t aacScalefactorDataResilienceFlag,
- uint8_t aacSpectralDataResilienceFlag
-#endif
- );
+static uint8_t single_lfe_channel_element(faacDecHandle hDecoder,
+ element *sce, bitfile *ld,
+ int16_t *spec_data);
+static uint8_t channel_pair_element(faacDecHandle hDecoder, element *cpe,
+ bitfile *ld, int16_t *spec_data1,
+ int16_t *spec_data2);
static uint16_t data_stream_element(bitfile *ld);
static uint8_t program_config_element(program_config *pce, bitfile *ld);
static uint8_t fill_element(bitfile *ld, drc_info *drc);
-static uint8_t individual_channel_stream(element *ele, bitfile *ld,
- ic_stream *ics, uint8_t scal_flag,
- int16_t *spec_data, uint8_t sf_index,
- uint8_t object_type, uint16_t frame_len
-#ifdef ERROR_RESILIENCE
- ,uint8_t aacSectionDataResilienceFlag,
- uint8_t aacScalefactorDataResilienceFlag,
- uint8_t aacSpectralDataResilienceFlag
-#endif
- );
-static uint8_t ics_info(ic_stream *ics, bitfile *ld, uint8_t common_window,
- uint8_t fs_index, uint8_t object_type,
- uint16_t frame_len);
-static void section_data(ic_stream *ics, bitfile *ld
-#ifdef ERROR_RESILIENCE
- ,uint8_t aacSectionDataResilienceFlag
-#endif
- );
-static uint8_t scale_factor_data(ic_stream *ics, bitfile *ld
-#ifdef ERROR_RESILIENCE
- ,uint8_t aacScalefactorDataResilienceFlag
-#endif
- );
+static uint8_t individual_channel_stream(faacDecHandle hDecoder, element *ele,
+ bitfile *ld, ic_stream *ics, uint8_t scal_flag,
+ int16_t *spec_data);
+static uint8_t ics_info(faacDecHandle hDecoder, ic_stream *ics, bitfile *ld,
+ uint8_t common_window);
+static void section_data(faacDecHandle hDecoder, ic_stream *ics, bitfile *ld);
+static uint8_t scale_factor_data(faacDecHandle hDecoder, ic_stream *ics, bitfile *ld);
static void gain_control_data(bitfile *ld, ic_stream *ics);
-static uint8_t spectral_data(ic_stream *ics, bitfile *ld, int16_t *spectral_data,
- uint16_t frame_len);
+static uint8_t spectral_data(faacDecHandle hDecoder, ic_stream *ics, bitfile *ld,
+ int16_t *spectral_data);
static uint16_t extension_payload(bitfile *ld, drc_info *drc, uint16_t count);
#ifdef ERROR_RESILIENCE
-uint8_t reordered_spectral_data(ic_stream *ics, bitfile *ld, int16_t *spectral_data,
- uint16_t frame_len, uint8_t aacSectionDataResilienceFlag);
+uint8_t reordered_spectral_data(faacDecHandle hDecoder, ic_stream *ics,
+ bitfile *ld, int16_t *spectral_data);
#endif
static void pulse_data(pulse_info *pul, bitfile *ld);
static void tns_data(ic_stream *ics, tns_info *tns, bitfile *ld);
-static void ltp_data(ic_stream *ics, ltp_info *ltp, bitfile *ld,
- uint8_t object_type);
+static void ltp_data(faacDecHandle hDecoder, ic_stream *ics, ltp_info *ltp, bitfile *ld);
static uint8_t adts_fixed_header(adts_header *adts, bitfile *ld);
static void adts_variable_header(adts_header *adts, bitfile *ld);
static void adts_error_check(adts_header *adts, bitfile *ld);
--- a/libfaad/tns.c
+++ b/libfaad/tns.c
@@ -16,10 +16,11 @@
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
**
-** $Id: tns.c,v 1.17 2002/09/15 22:02:30 menno Exp $
+** $Id: tns.c,v 1.18 2002/11/28 18:48:30 menno Exp $
**/
#include "common.h"
+#include "structs.h"
#include "syntax.h"
#include "tns.h"
@@ -252,7 +253,7 @@
real_t y, state[TNS_MAX_ORDER];
for (i = 0; i < order; i++)
- state[i] = REAL_CONST(0.0);
+ state[i] = 0;
for (i = 0; i < size; i++)
{