Commit 0900a85f authored by Diego Biurrun's avatar Diego Biurrun
Browse files

Remove internal liba52; external lib still works, native decoder coming up.

Originally committed as revision 7933 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent f70f03f6
......@@ -78,7 +78,6 @@ show_help(){
echo " --enable-x11grab enable X11 grabbing [default=no]"
echo " --enable-dc1394 enable IIDC-1394 grabbing using libdc1394"
echo " and libraw1394 [default=no]"
echo " --enable-a52 enable GPLed liba52 support [default=no]"
echo " --enable-a52bin open liba52.so.0 at runtime [default=no]"
echo " --enable-avisynth allow reading AVISynth script files [default=no]"
echo " --enable-dts enable GPLed libdts support [default=no]"
......@@ -486,7 +485,6 @@ CONFIG_LIST='
ffserver
gpl
ipv6
liba52
liba52bin
libdts
libfaac
......@@ -576,7 +574,7 @@ zmbv_encoder_deps="zlib"
aac_decoder_deps="libfaad"
mpeg4aac_decoder_deps="libfaad"
ac3_decoder_deps="liba52"
ac3_decoder_deps="liba52bin"
amr_nb_decoder_deps_any="amr_nb amr_nb_fixed"
amr_nb_encoder_deps_any="amr_nb amr_nb_fixed"
amr_wb_decoder_deps="amr_wb"
......@@ -741,7 +739,6 @@ avisynth="no"
dc1394="no"
dlfcn_h="no"
dlopen="no"
liba52="no"
liba52bin="no"
libdts="no"
libfaac="no"
......@@ -1040,9 +1037,7 @@ for opt do
;;
--disable-zlib) zlib="no"
;;
--enable-a52) liba52="yes"
;;
--enable-a52bin) liba52bin="yes"; liba52="yes"
--enable-a52bin) liba52bin="yes"
;;
--enable-dts) libdts="yes"
;;
......@@ -1261,7 +1256,7 @@ if disabled gpl ; then
enabled_any $@ && die "$name is under GPL and --enable-gpl is not specified."
}
die_gpl_disabled "The Postprocessing code" pp
die_gpl_disabled "liba52" liba52 liba52bin
die_gpl_disabled "liba52" liba52bin
die_gpl_disabled "libxvidcore" xvid
die_gpl_disabled "x264" x264
die_gpl_disabled "libdts" libdts
......@@ -1885,7 +1880,6 @@ if enabled sdl_too_old; then
fi
echo "Sun medialib support $mlib"
echo "AVISynth enabled $avisynth"
echo "liba52 support $liba52"
echo "liba52 dlopened $liba52bin"
echo "libdts support $libdts"
echo "libfaac enabled $libfaac"
......@@ -2092,7 +2086,6 @@ if enabled source_path_used; then
libavcodec/sparc \
libavcodec/mlib \
libavcodec/ppc \
libavcodec/liba52 \
libavcodec/amr \
libavcodec/amr_float \
libavcodec/amrwb_float \
......
......@@ -248,14 +248,7 @@ OBJS-$(CONFIG_ADPCM_YAMAHA_DECODER) += adpcm.o
OBJS-$(CONFIG_ADPCM_YAMAHA_ENCODER) += adpcm.o
# external codec libraries
OBJS-$(CONFIG_LIBA52) += a52dec.o
OBJS-$(CONFIG_LIBA52)$(CONFIG_LIBA52BIN) += liba52/bit_allocate.o \
liba52/bitstream.o \
liba52/downmix.o \
liba52/imdct.o \
liba52/parse.o \
liba52/crc.o \
liba52/resample.o
OBJS-$(CONFIG_LIBA52BIN) += a52dec.o
OBJS-$(CONFIG_LIBDTS) += dtsdec.o
OBJS-$(CONFIG_LIBFAAC) += faac.o
OBJS-$(CONFIG_LIBFAAD) += faad.o
......@@ -435,7 +428,6 @@ clean::
ps2/*.o ps2/*~ \
sh4/*.o sh4/*~ \
sparc/*.o sparc/*~ \
liba52/*.o liba52/*~ \
amr_float/*.o \
apiexample $(TESTS)
-$(MAKE) -C amr clean
......
......@@ -25,12 +25,9 @@
*/
#include "avcodec.h"
#include "liba52/a52.h"
#ifdef CONFIG_LIBA52BIN
#include <a52dec/a52.h>
#include <dlfcn.h>
static const char* liba52name = "liba52.so.0";
#endif
/**
* liba52 - Copyright (C) Aaron Holtzman
......@@ -70,7 +67,6 @@ typedef struct AC3DecodeState {
} AC3DecodeState;
#ifdef CONFIG_LIBA52BIN
static void* dlsymm(void* handle, const char* symbol)
{
void* f = dlsym(handle, symbol);
......@@ -78,13 +74,11 @@ static void* dlsymm(void* handle, const char* symbol)
av_log( NULL, AV_LOG_ERROR, "A52 Decoder - function '%s' can't be resolved\n", symbol);
return f;
}
#endif
static int a52_decode_init(AVCodecContext *avctx)
{
AC3DecodeState *s = avctx->priv_data;
#ifdef CONFIG_LIBA52BIN
s->handle = dlopen(liba52name, RTLD_LAZY);
if (!s->handle)
{
......@@ -103,16 +97,6 @@ static int a52_decode_init(AVCodecContext *avctx)
dlclose(s->handle);
return -1;
}
#else
/* static linked version */
s->handle = 0;
s->a52_init = a52_init;
s->a52_samples = a52_samples;
s->a52_syncinfo = a52_syncinfo;
s->a52_frame = a52_frame;
s->a52_block = a52_block;
s->a52_free = a52_free;
#endif
s->state = s->a52_init(0); /* later use CPU flags */
s->samples = s->a52_samples(s->state);
s->inbuf_ptr = s->inbuf;
......@@ -242,9 +226,7 @@ static int a52_decode_end(AVCodecContext *avctx)
{
AC3DecodeState *s = avctx->priv_data;
s->a52_free(s->state);
#ifdef CONFIG_LIBA52BIN
dlclose(s->handle);
#endif
return 0;
}
......
/*
* a52.h
* Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org>
* Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
*
* This file is part of a52dec, a free ATSC A-52 stream decoder.
* See http://liba52.sourceforge.net/ for updates.
*
* a52dec 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.
*
* a52dec 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef A52_H
#define A52_H
#include "../avcodec.h"
#undef malloc
#undef free
#undef realloc
#if defined(LIBA52_FIXED)
typedef int32_t sample_t;
typedef int32_t level_t;
#elif defined(LIBA52_DOUBLE)
typedef double sample_t;
typedef double level_t;
#else
typedef float sample_t;
typedef float level_t;
#endif
typedef struct a52_state_s a52_state_t;
#define A52_CHANNEL 0
#define A52_MONO 1
#define A52_STEREO 2
#define A52_3F 3
#define A52_2F1R 4
#define A52_3F1R 5
#define A52_2F2R 6
#define A52_3F2R 7
#define A52_CHANNEL1 8
#define A52_CHANNEL2 9
#define A52_DOLBY 10
#define A52_CHANNEL_MASK 15
#define A52_LFE 16
#define A52_ADJUST_LEVEL 32
a52_state_t * a52_init (uint32_t mm_accel);
sample_t * a52_samples (a52_state_t * state);
int a52_syncinfo (uint8_t * buf, int * flags,
int * sample_rate, int * bit_rate);
int a52_frame (a52_state_t * state, uint8_t * buf, int * flags,
level_t * level, sample_t bias);
void a52_dynrng (a52_state_t * state,
level_t (* call) (level_t, void *), void * data);
int a52_block (a52_state_t * state);
void a52_free (a52_state_t * state);
#endif /* A52_H */
/*
* a52_internal.h
* Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org>
* Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
*
* This file is part of a52dec, a free ATSC A-52 stream decoder.
* See http://liba52.sourceforge.net/ for updates.
*
* a52dec 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.
*
* a52dec 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
typedef struct {
uint8_t bai; /* fine SNR offset, fast gain */
uint8_t deltbae; /* delta bit allocation exists */
int8_t deltba[50]; /* per-band delta bit allocation */
} ba_t;
typedef struct {
uint8_t exp[256]; /* decoded channel exponents */
int8_t bap[256]; /* derived channel bit allocation */
} expbap_t;
struct a52_state_s {
uint8_t fscod; /* sample rate */
uint8_t halfrate; /* halfrate factor */
uint8_t acmod; /* coded channels */
uint8_t lfeon; /* coded lfe channel */
level_t clev; /* centre channel mix level */
level_t slev; /* surround channels mix level */
int output; /* type of output */
level_t level; /* output level */
sample_t bias; /* output bias */
int dynrnge; /* apply dynamic range */
level_t dynrng; /* dynamic range */
void * dynrngdata; /* dynamic range callback funtion and data */
level_t (* dynrngcall) (level_t range, void * dynrngdata);
uint8_t chincpl; /* channel coupled */
uint8_t phsflginu; /* phase flags in use (stereo only) */
uint8_t cplstrtmant; /* coupling channel start mantissa */
uint8_t cplendmant; /* coupling channel end mantissa */
uint32_t cplbndstrc; /* coupling band structure */
level_t cplco[5][18]; /* coupling coordinates */
/* derived information */
uint8_t cplstrtbnd; /* coupling start band (for bit allocation) */
uint8_t ncplbnd; /* number of coupling bands */
uint8_t rematflg; /* stereo rematrixing */
uint8_t endmant[5]; /* channel end mantissa */
uint16_t bai; /* bit allocation information */
uint32_t * buffer_start;
uint16_t lfsr_state; /* dither state */
uint32_t bits_left;
uint32_t current_word;
uint8_t csnroffst; /* coarse SNR offset */
ba_t cplba; /* coupling bit allocation parameters */
ba_t ba[5]; /* channel bit allocation parameters */
ba_t lfeba; /* lfe bit allocation parameters */
uint8_t cplfleak; /* coupling fast leak init */
uint8_t cplsleak; /* coupling slow leak init */
expbap_t cpl_expbap;
expbap_t fbw_expbap[5];
expbap_t lfe_expbap;
sample_t * samples;
int downmixed;
};
#define LEVEL_PLUS6DB 2.0
#define LEVEL_PLUS3DB 1.4142135623730951
#define LEVEL_3DB 0.7071067811865476
#define LEVEL_45DB 0.5946035575013605
#define LEVEL_6DB 0.5
#define EXP_REUSE (0)
#define EXP_D15 (1)
#define EXP_D25 (2)
#define EXP_D45 (3)
#define DELTA_BIT_REUSE (0)
#define DELTA_BIT_NEW (1)
#define DELTA_BIT_NONE (2)
#define DELTA_BIT_RESERVED (3)
void a52_bit_allocate (a52_state_t * state, ba_t * ba, int bndstart,
int start, int end, int fastleak, int slowleak,
expbap_t * expbap);
int a52_downmix_init (int input, int flags, level_t * level,
level_t clev, level_t slev);
int a52_downmix_coeff (level_t * coeff, int acmod, int output, level_t level,
level_t clev, level_t slev);
void a52_downmix (sample_t * samples, int acmod, int output, sample_t bias,
level_t clev, level_t slev);
void a52_upmix (sample_t * samples, int acmod, int output);
void a52_imdct_init (uint32_t mm_accel);
void a52_imdct_256 (sample_t * data, sample_t * delay, sample_t bias);
void a52_imdct_512 (sample_t * data, sample_t * delay, sample_t bias);
//extern void (* a52_imdct_256) (sample_t data[], sample_t delay[], sample_t bias);
//extern void (* a52_imdct_512) (sample_t data[], sample_t delay[], sample_t bias);
#define ROUND(x) ((int)((x) + ((x) > 0 ? 0.5 : -0.5)))
#ifndef LIBA52_FIXED
typedef sample_t quantizer_t;
#define SAMPLE(x) (x)
#define LEVEL(x) (x)
#define MUL(a,b) ((a) * (b))
#define MUL_L(a,b) ((a) * (b))
#define MUL_C(a,b) ((a) * (b))
#define DIV(a,b) ((a) / (b))
#define BIAS(x) ((x) + bias)
#else /* LIBA52_FIXED */
typedef int16_t quantizer_t;
#define SAMPLE(x) (sample_t)((x) * (1 << 30))
#define LEVEL(x) (level_t)((x) * (1 << 26))
#if 0
#define MUL(a,b) ((int)(((int64_t)(a) * (b) + (1 << 29)) >> 30))
#define MUL_L(a,b) ((int)(((int64_t)(a) * (b) + (1 << 25)) >> 26))
#elif 1
#define MUL(a,b) \
({ int32_t _ta=(a), _tb=(b), _tc; \
_tc=(_ta & 0xffff)*(_tb >> 16)+(_ta >> 16)*(_tb & 0xffff); (int32_t)(((_tc >> 14))+ (((_ta >> 16)*(_tb >> 16)) << 2 )); })
#define MUL_L(a,b) \
({ int32_t _ta=(a), _tb=(b), _tc; \
_tc=(_ta & 0xffff)*(_tb >> 16)+(_ta >> 16)*(_tb & 0xffff); (int32_t)((_tc >> 10) + (((_ta >> 16)*(_tb >> 16)) << 6)); })
#else
#define MUL(a,b) (((a) >> 15) * ((b) >> 15))
#define MUL_L(a,b) (((a) >> 13) * ((b) >> 13))
#endif
#define MUL_C(a,b) MUL_L (a, LEVEL (b))
#define DIV(a,b) ((((int64_t)LEVEL (a)) << 26) / (b))
#define BIAS(x) (x)
#endif
/*
* a52_util.h
* Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org>
* Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
*
* This file is part of a52dec, a free ATSC A-52 stream decoder.
* See http://liba52.sourceforge.net/ for updates.
*
* a52dec 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.
*
* a52dec 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef A52_UTIL_H
#define A52_UTIL_H
uint16_t a52_crc16_block(uint8_t *data,uint32_t num_bytes);
void* a52_resample_init(uint32_t mm_accel,int flags,int chans);
extern int (* a52_resample) (float * _f, int16_t * s16);
#endif /* A52_H */
/*
* bit_allocate.c
* Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org>
* Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
*
* This file is part of a52dec, a free ATSC A-52 stream decoder.
* See http://liba52.sourceforge.net/ for updates.
*
* a52dec 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.
*
* a52dec 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "a52.h"
#include "a52_internal.h"
static int hthtab[3][50] = {
{0x730, 0x730, 0x7c0, 0x800, 0x820, 0x840, 0x850, 0x850, 0x860, 0x860,
0x860, 0x860, 0x860, 0x870, 0x870, 0x870, 0x880, 0x880, 0x890, 0x890,
0x8a0, 0x8a0, 0x8b0, 0x8b0, 0x8c0, 0x8c0, 0x8d0, 0x8e0, 0x8f0, 0x900,
0x910, 0x910, 0x910, 0x910, 0x900, 0x8f0, 0x8c0, 0x870, 0x820, 0x7e0,
0x7a0, 0x770, 0x760, 0x7a0, 0x7c0, 0x7c0, 0x6e0, 0x400, 0x3c0, 0x3c0},
{0x710, 0x710, 0x7a0, 0x7f0, 0x820, 0x830, 0x840, 0x850, 0x850, 0x860,
0x860, 0x860, 0x860, 0x860, 0x870, 0x870, 0x870, 0x880, 0x880, 0x880,
0x890, 0x890, 0x8a0, 0x8a0, 0x8b0, 0x8b0, 0x8c0, 0x8c0, 0x8e0, 0x8f0,
0x900, 0x910, 0x910, 0x910, 0x910, 0x900, 0x8e0, 0x8b0, 0x870, 0x820,
0x7e0, 0x7b0, 0x760, 0x770, 0x7a0, 0x7c0, 0x780, 0x5d0, 0x3c0, 0x3c0},
{0x680, 0x680, 0x750, 0x7b0, 0x7e0, 0x810, 0x820, 0x830, 0x840, 0x850,
0x850, 0x850, 0x860, 0x860, 0x860, 0x860, 0x860, 0x860, 0x860, 0x860,
0x870, 0x870, 0x870, 0x870, 0x880, 0x880, 0x880, 0x890, 0x8a0, 0x8b0,
0x8c0, 0x8d0, 0x8e0, 0x8f0, 0x900, 0x910, 0x910, 0x910, 0x900, 0x8f0,
0x8d0, 0x8b0, 0x840, 0x7f0, 0x790, 0x760, 0x7a0, 0x7c0, 0x7b0, 0x720}
};
static int8_t baptab[305] = {
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* 93 padding elems */
16, 16, 16, 16, 16, 16, 16, 16, 16, 14, 14, 14, 14, 14, 14, 14,
14, 12, 12, 12, 12, 11, 11, 11, 11, 10, 10, 10, 10, 9, 9, 9,
9, 8, 8, 8, 8, 7, 7, 7, 7, 6, 6, 6, 6, 5, 5, 5,
5, 4, 4, -3, -3, 3, 3, 3, -2, -2, -1, -1, -1, -1, -1, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0 /* 148 padding elems */
};
static int bndtab[30] = {21, 22, 23, 24, 25, 26, 27, 28, 31, 34,
37, 40, 43, 46, 49, 55, 61, 67, 73, 79,
85, 97, 109, 121, 133, 157, 181, 205, 229, 253};
static int8_t latab[256] = {
-64, -63, -62, -61, -60, -59, -58, -57, -56, -55, -54, -53,
-52, -52, -51, -50, -49, -48, -47, -47, -46, -45, -44, -44,
-43, -42, -41, -41, -40, -39, -38, -38, -37, -36, -36, -35,
-35, -34, -33, -33, -32, -32, -31, -30, -30, -29, -29, -28,
-28, -27, -27, -26, -26, -25, -25, -24, -24, -23, -23, -22,
-22, -21, -21, -21, -20, -20, -19, -19, -19, -18, -18, -18,
-17, -17, -17, -16, -16, -16, -15, -15, -15, -14, -14, -14,
-13, -13, -13, -13, -12, -12, -12, -12, -11, -11, -11, -11,
-10, -10, -10, -10, -10, -9, -9, -9, -9, -9, -8, -8,
-8, -8, -8, -8, -7, -7, -7, -7, -7, -7, -6, -6,
-6, -6, -6, -6, -6, -6, -5, -5, -5, -5, -5, -5,
-5, -5, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4,
-4, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3,
-3, -3, -3, -2, -2, -2, -2, -2, -2, -2, -2, -2,
-2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0
};
#define UPDATE_LEAK() \
do { \
fastleak += fdecay; \
if (fastleak > psd + fgain) \
fastleak = psd + fgain; \
slowleak += sdecay; \
if (slowleak > psd + sgain) \
slowleak = psd + sgain; \
} while (0)
#define COMPUTE_MASK() \
do { \
if (psd > dbknee) \
mask -= (psd - dbknee) >> 2; \
if (mask > hth [i >> halfrate]) \
mask = hth [i >> halfrate]; \
mask -= snroffset + 128 * deltba[i]; \
mask = (mask > 0) ? 0 : ((-mask) >> 5); \
mask -= floor; \
} while (0)
void a52_bit_allocate (a52_state_t * state, ba_t * ba, int bndstart,
int start, int end, int fastleak, int slowleak,
expbap_t * expbap)
{
static int slowgain[4] = {0x540, 0x4d8, 0x478, 0x410};
static int dbpbtab[4] = {0xc00, 0x500, 0x300, 0x100};
static int floortab[8] = {0x910, 0x950, 0x990, 0x9d0,
0xa10, 0xa90, 0xb10, 0x1400};
int i, j;
uint8_t * exp;
int8_t * bap;
int fdecay, fgain, sdecay, sgain, dbknee, floor, snroffset;
int psd, mask;
int8_t * deltba;
int * hth;
int halfrate;
halfrate = state->halfrate;
fdecay = (63 + 20 * ((state->bai >> 7) & 3)) >> halfrate; /* fdcycod */
fgain = 128 + 128 * (ba->bai & 7); /* fgaincod */
sdecay = (15 + 2 * (state->bai >> 9)) >> halfrate; /* sdcycod */
sgain = slowgain[(state->bai >> 5) & 3]; /* sgaincod */
dbknee = dbpbtab[(state->bai >> 3) & 3]; /* dbpbcod */
hth = hthtab[state->fscod];
/*
* if there is no delta bit allocation, make deltba point to an area
* known to contain zeroes. baptab+156 here.
*/
deltba = (ba->deltbae == DELTA_BIT_NONE) ? baptab + 156 : ba->deltba;
floor = floortab[state->bai & 7]; /* floorcod */
snroffset = 960 - 64 * state->csnroffst - 4 * (ba->bai >> 3) + floor;
floor >>= 5;
exp = expbap->exp;
bap = expbap->bap;
i = bndstart;
j = start;
if (start == 0) { /* not the coupling channel */
int lowcomp;
lowcomp = 0;
j = end - 1;
do {
if (i < j) {
if (exp[i+1] == exp[i] - 2)
lowcomp = 384;
else if (lowcomp && (exp[i+1] > exp[i]))
lowcomp -= 64;
}
psd = 128 * exp[i];
mask = psd + fgain + lowcomp;
COMPUTE_MASK ();
bap[i] = (baptab+156)[mask + 4 * exp[i]];
i++;
} while ((i < 3) || ((i < 7) && (exp[i] > exp[i-1])));
fastleak = psd + fgain;
slowleak = psd + sgain