Commit c947dec9 authored by Zdenek Kabelac's avatar Zdenek Kabelac

* sync with main liba52 sources

Originally committed as revision 1590 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent ca390e72
/* /*
* a52.h * a52.h
* Copyright (C) 2000-2002 Michel Lespinasse <walken@zoy.org> * Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org>
* Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca> * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
* *
* This file is part of a52dec, a free ATSC A-52 stream decoder. * This file is part of a52dec, a free ATSC A-52 stream decoder.
...@@ -30,10 +30,15 @@ ...@@ -30,10 +30,15 @@
#undef free #undef free
#undef realloc #undef realloc
#ifndef LIBA52_DOUBLE #if defined(LIBA52_FIXED)
typedef float sample_t; typedef int32_t sample_t;
#else typedef int32_t level_t;
#elif defined(LIBA52_DOUBLE)
typedef double sample_t; typedef double sample_t;
typedef double level_t;
#else
typedef float sample_t;
typedef float level_t;
#endif #endif
typedef struct a52_state_s a52_state_t; typedef struct a52_state_s a52_state_t;
...@@ -59,9 +64,9 @@ sample_t * a52_samples (a52_state_t * state); ...@@ -59,9 +64,9 @@ sample_t * a52_samples (a52_state_t * state);
int a52_syncinfo (uint8_t * buf, int * flags, int a52_syncinfo (uint8_t * buf, int * flags,
int * sample_rate, int * bit_rate); int * sample_rate, int * bit_rate);
int a52_frame (a52_state_t * state, uint8_t * buf, int * flags, int a52_frame (a52_state_t * state, uint8_t * buf, int * flags,
sample_t * level, sample_t bias); level_t * level, sample_t bias);
void a52_dynrng (a52_state_t * state, void a52_dynrng (a52_state_t * state,
sample_t (* call) (sample_t, void *), void * data); level_t (* call) (level_t, void *), void * data);
int a52_block (a52_state_t * state); int a52_block (a52_state_t * state);
void a52_free (a52_state_t * state); void a52_free (a52_state_t * state);
......
/* /*
* a52_internal.h * a52_internal.h
* Copyright (C) 2000-2002 Michel Lespinasse <walken@zoy.org> * Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org>
* Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca> * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
* *
* This file is part of a52dec, a free ATSC A-52 stream decoder. * This file is part of a52dec, a free ATSC A-52 stream decoder.
...@@ -37,24 +37,24 @@ struct a52_state_s { ...@@ -37,24 +37,24 @@ struct a52_state_s {
uint8_t halfrate; /* halfrate factor */ uint8_t halfrate; /* halfrate factor */
uint8_t acmod; /* coded channels */ uint8_t acmod; /* coded channels */
uint8_t lfeon; /* coded lfe channel */ uint8_t lfeon; /* coded lfe channel */
sample_t clev; /* centre channel mix level */ level_t clev; /* centre channel mix level */
sample_t slev; /* surround channels mix level */ level_t slev; /* surround channels mix level */
int output; /* type of output */ int output; /* type of output */
sample_t level; /* output level */ level_t level; /* output level */
sample_t bias; /* output bias */ sample_t bias; /* output bias */
int dynrnge; /* apply dynamic range */ int dynrnge; /* apply dynamic range */
sample_t dynrng; /* dynamic range */ level_t dynrng; /* dynamic range */
void * dynrngdata; /* dynamic range callback funtion and data */ void * dynrngdata; /* dynamic range callback funtion and data */
sample_t (* dynrngcall) (sample_t range, void * dynrngdata); level_t (* dynrngcall) (level_t range, void * dynrngdata);
uint8_t chincpl; /* channel coupled */ uint8_t chincpl; /* channel coupled */
uint8_t phsflginu; /* phase flags in use (stereo only) */ uint8_t phsflginu; /* phase flags in use (stereo only) */
uint8_t cplstrtmant; /* coupling channel start mantissa */ uint8_t cplstrtmant; /* coupling channel start mantissa */
uint8_t cplendmant; /* coupling channel end mantissa */ uint8_t cplendmant; /* coupling channel end mantissa */
uint32_t cplbndstrc; /* coupling band structure */ uint32_t cplbndstrc; /* coupling band structure */
sample_t cplco[5][18]; /* coupling coordinates */ level_t cplco[5][18]; /* coupling coordinates */
/* derived information */ /* derived information */
uint8_t cplstrtbnd; /* coupling start band (for bit allocation) */ uint8_t cplstrtbnd; /* coupling start band (for bit allocation) */
...@@ -66,6 +66,11 @@ struct a52_state_s { ...@@ -66,6 +66,11 @@ struct a52_state_s {
uint16_t bai; /* bit allocation information */ 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 */ uint8_t csnroffst; /* coarse SNR offset */
ba_t cplba; /* coupling bit allocation parameters */ ba_t cplba; /* coupling bit allocation parameters */
ba_t ba[5]; /* channel bit allocation parameters */ ba_t ba[5]; /* channel bit allocation parameters */
...@@ -102,14 +107,54 @@ void a52_bit_allocate (a52_state_t * state, ba_t * ba, int bndstart, ...@@ -102,14 +107,54 @@ void a52_bit_allocate (a52_state_t * state, ba_t * ba, int bndstart,
int start, int end, int fastleak, int slowleak, int start, int end, int fastleak, int slowleak,
expbap_t * expbap); expbap_t * expbap);
int a52_downmix_init (int input, int flags, sample_t * level, int a52_downmix_init (int input, int flags, level_t * level,
sample_t clev, sample_t slev); level_t clev, level_t slev);
int a52_downmix_coeff (sample_t * coeff, int acmod, int output, sample_t level, int a52_downmix_coeff (level_t * coeff, int acmod, int output, level_t level,
sample_t clev, sample_t slev); level_t clev, level_t slev);
void a52_downmix (sample_t * samples, int acmod, int output, sample_t bias, void a52_downmix (sample_t * samples, int acmod, int output, sample_t bias,
sample_t clev, sample_t slev); level_t clev, level_t slev);
void a52_upmix (sample_t * samples, int acmod, int output); void a52_upmix (sample_t * samples, int acmod, int output);
void a52_imdct_init (uint32_t mm_accel); void a52_imdct_init (uint32_t mm_accel);
void a52_imdct_256 (sample_t * data, sample_t * delay, sample_t bias); 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); 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
/*
* audio_out.h
* Copyright (C) 2000-2002 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
typedef struct ao_instance_s ao_instance_t;
struct ao_instance_s {
int (* setup) (ao_instance_t * instance, int sample_rate, int * flags,
sample_t * level, sample_t * bias);
int (* play) (ao_instance_t * instance, int flags, sample_t * samples);
void (* close) (ao_instance_t * instance);
};
typedef ao_instance_t * ao_open_t (void);
typedef struct ao_driver_s {
char * name;
ao_open_t * open;
} ao_driver_t;
/* return NULL terminated array of all drivers */
ao_driver_t * ao_drivers (void);
static inline ao_instance_t * ao_open (ao_open_t * open)
{
return open ();
}
static inline int ao_setup (ao_instance_t * instance, int sample_rate,
int * flags, sample_t * level, sample_t * bias)
{
return instance->setup (instance, sample_rate, flags, level, bias);
}
static inline int ao_play (ao_instance_t * instance, int flags,
sample_t * samples)
{
return instance->play (instance, flags, samples);
}
static inline void ao_close (ao_instance_t * instance)
{
if (instance->close)
instance->close (instance);
}
/* /*
* bit_allocate.c * bit_allocate.c
* Copyright (C) 2000-2002 Michel Lespinasse <walken@zoy.org> * Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org>
* Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca> * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
* *
* This file is part of a52dec, a free ATSC A-52 stream decoder. * This file is part of a52dec, a free ATSC A-52 stream decoder.
...@@ -20,6 +20,11 @@ ...@@ -20,6 +20,11 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#include "config.h"
#include <inttypes.h>
#include "a52.h" #include "a52.h"
#include "a52_internal.h" #include "a52_internal.h"
...@@ -226,7 +231,7 @@ void a52_bit_allocate (a52_state_t * state, ba_t * ba, int bndstart, ...@@ -226,7 +231,7 @@ void a52_bit_allocate (a52_state_t * state, ba_t * ba, int bndstart,
int startband, endband; int startband, endband;
startband = j; startband = j;
endband = ((bndtab-20)[i] < end) ? (bndtab-20)[i] : end; endband = (bndtab[i-20] < end) ? bndtab[i-20] : end;
psd = 128 * exp[j++]; psd = 128 * exp[j++];
while (j < endband) { while (j < endband) {
int next, delta; int next, delta;
......
/* /*
* bitstream.c * bitstream.c
* Copyright (C) 2000-2002 Michel Lespinasse <walken@zoy.org> * Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org>
* Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca> * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
* *
* This file is part of a52dec, a free ATSC A-52 stream decoder. * This file is part of a52dec, a free ATSC A-52 stream decoder.
...@@ -21,34 +21,33 @@ ...@@ -21,34 +21,33 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#include "config.h"
#include <inttypes.h>
#include "a52.h" #include "a52.h"
#include "a52_internal.h" #include "a52_internal.h"
#include "bitstream.h" #include "bitstream.h"
#define BUFFER_SIZE 4096 #define BUFFER_SIZE 4096
static uint32_t * buffer_start; void a52_bitstream_set_ptr (a52_state_t * state, uint8_t * buf)
uint32_t a52_bits_left;
uint32_t a52_current_word;
void a52_bitstream_set_ptr (uint8_t * buf)
{ {
int align; int align;
align = (long)buf & 3; align = (long)buf & 3;
buffer_start = (uint32_t *) (buf - align); state->buffer_start = (uint32_t *) (buf - align);
a52_bits_left = 0; state->bits_left = 0;
bitstream_get (align * 8); state->current_word = 0;
bitstream_get (state, align * 8);
} }
static inline void static inline void bitstream_fill_current (a52_state_t * state)
bitstream_fill_current()
{ {
uint32_t tmp; uint32_t tmp;
tmp = *(buffer_start++); tmp = *(state->buffer_start++);
a52_current_word = swab32 (tmp); state->current_word = swab32 (tmp);
} }
/* /*
...@@ -60,40 +59,38 @@ bitstream_fill_current() ...@@ -60,40 +59,38 @@ bitstream_fill_current()
* -ah * -ah
*/ */
uint32_t uint32_t a52_bitstream_get_bh (a52_state_t * state, uint32_t num_bits)
a52_bitstream_get_bh(uint32_t num_bits)
{ {
uint32_t result; uint32_t result;
num_bits -= a52_bits_left; num_bits -= state->bits_left;
result = ((a52_current_word << (32 - a52_bits_left)) >> result = ((state->current_word << (32 - state->bits_left)) >>
(32 - a52_bits_left)); (32 - state->bits_left));
bitstream_fill_current(); bitstream_fill_current (state);
if(num_bits != 0) if (num_bits != 0)
result = (result << num_bits) | (a52_current_word >> (32 - num_bits)); result = (result << num_bits) | (state->current_word >> (32 - num_bits));
a52_bits_left = 32 - num_bits; state->bits_left = 32 - num_bits;
return result; return result;
} }
int32_t int32_t a52_bitstream_get_bh_2 (a52_state_t * state, uint32_t num_bits)
a52_bitstream_get_bh_2(uint32_t num_bits)
{ {
int32_t result; int32_t result;
num_bits -= a52_bits_left; num_bits -= state->bits_left;
result = ((((int32_t)a52_current_word) << (32 - a52_bits_left)) >> result = ((((int32_t)state->current_word) << (32 - state->bits_left)) >>
(32 - a52_bits_left)); (32 - state->bits_left));
bitstream_fill_current(); bitstream_fill_current(state);
if(num_bits != 0) if (num_bits != 0)
result = (result << num_bits) | (a52_current_word >> (32 - num_bits)); result = (result << num_bits) | (state->current_word >> (32 - num_bits));
a52_bits_left = 32 - num_bits; state->bits_left = 32 - num_bits;
return result; return result;
} }
/* /*
* bitstream.h * bitstream.h
* Copyright (C) 2000-2002 Michel Lespinasse <walken@zoy.org> * Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org>
* Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca> * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
* *
* This file is part of a52dec, a free ATSC A-52 stream decoder. * This file is part of a52dec, a free ATSC A-52 stream decoder.
...@@ -46,37 +46,32 @@ ...@@ -46,37 +46,32 @@
# endif # endif
#endif #endif
extern uint32_t a52_bits_left; void a52_bitstream_set_ptr (a52_state_t * state, uint8_t * buf);
extern uint32_t a52_current_word; uint32_t a52_bitstream_get_bh (a52_state_t * state, uint32_t num_bits);
int32_t a52_bitstream_get_bh_2 (a52_state_t * state, uint32_t num_bits);
void a52_bitstream_set_ptr (uint8_t * buf); static inline uint32_t bitstream_get (a52_state_t * state, uint32_t num_bits)
uint32_t a52_bitstream_get_bh(uint32_t num_bits);
int32_t a52_bitstream_get_bh_2(uint32_t num_bits);
static inline uint32_t
bitstream_get(uint32_t num_bits)
{ {
uint32_t result; uint32_t result;
if(num_bits < a52_bits_left) { if (num_bits < state->bits_left) {
result = (a52_current_word << (32 - a52_bits_left)) >> (32 - num_bits); result = (state->current_word << (32 - state->bits_left)) >> (32 - num_bits);
a52_bits_left -= num_bits; state->bits_left -= num_bits;
return result; return result;
} }
return a52_bitstream_get_bh(num_bits); return a52_bitstream_get_bh (state, num_bits);
} }
static inline int32_t static inline int32_t bitstream_get_2 (a52_state_t * state, uint32_t num_bits)
bitstream_get_2(uint32_t num_bits)
{ {
int32_t result; int32_t result;
if(num_bits < a52_bits_left) { if (num_bits < state->bits_left) {
result = (((int32_t)a52_current_word) << (32 - a52_bits_left)) >> (32 - num_bits); result = (((int32_t)state->current_word) << (32 - state->bits_left)) >> (32 - num_bits);
a52_bits_left -= num_bits; state->bits_left -= num_bits;
return result; return result;
} }
return a52_bitstream_get_bh_2(num_bits); return a52_bitstream_get_bh_2 (state, num_bits);
} }
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/* /*
* tables.h * tables.h
* Copyright (C) 2000-2002 Michel Lespinasse <walken@zoy.org> * Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org>
* Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca> * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
* *
* This file is part of a52dec, a free ATSC A-52 stream decoder. * This file is part of a52dec, a free ATSC A-52 stream decoder.
...@@ -46,42 +46,44 @@ static const int8_t exp_3[128] = { ...@@ -46,42 +46,44 @@ static const int8_t exp_3[128] = {
25,25,25 25,25,25
}; };
#define Q0 ((-2 << 15) / 3.0) #define Q(x) ROUND (32768.0 * x)
#define Q1 (0)
#define Q2 ((2 << 15) / 3.0)
static const sample_t q_1_0[32] = { #define Q0 Q (-2/3)
Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0, #define Q1 Q (0)
Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1, #define Q2 Q (2/3)
Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,
0,0,0,0,0 static const quantizer_t q_1_0[32] = {
Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0,
Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1,
Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2,
0, 0, 0, 0, 0
}; };
static const sample_t q_1_1[32] = { static const quantizer_t q_1_1[32] = {
Q0,Q0,Q0,Q1,Q1,Q1,Q2,Q2,Q2, Q0, Q0, Q0, Q1, Q1, Q1, Q2, Q2, Q2,
Q0,Q0,Q0,Q1,Q1,Q1,Q2,Q2,Q2, Q0, Q0, Q0, Q1, Q1, Q1, Q2, Q2, Q2,
Q0,Q0,Q0,Q1,Q1,Q1,Q2,Q2,Q2, Q0, Q0, Q0, Q1, Q1, Q1, Q2, Q2, Q2,
0,0,0,0,0 0, 0, 0, 0, 0
}; };
static const sample_t q_1_2[32] = { static const quantizer_t q_1_2[32] = {
Q0,Q1,Q2,Q0,Q1,Q2,Q0,Q1,Q2, Q0, Q1, Q2, Q0, Q1, Q2, Q0, Q1, Q2,
Q0,Q1,Q2,Q0,Q1,Q2,Q0,Q1,Q2, Q0, Q1, Q2, Q0, Q1, Q2, Q0, Q1, Q2,
Q0,Q1,Q2,Q0,Q1,Q2,Q0,Q1,Q2,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q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,
Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4, Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,
...@@ -114,24 +116,23 @@ static const sample_t q_2_2[128] = { ...@@ -114,24 +116,23 @@ static const sample_t q_2_2[128] = {
#undef Q3 #undef Q3
#undef Q4 #undef Q4
static const sample_t q_3[8] = { static const quantizer_t q_3[8] = {
(-6 << 15)/7.0, (-4 << 15)/7.0, (-2 << 15)/7.0, 0, Q (-6/7), Q (-4/7), Q (-2/7), Q (0), Q (2/7), Q (4/7), Q (6/7), 0
( 2 << 15)/7.0, ( 4 << 15)/7.0, ( 6 << 15)/7.0, 0
}; };
#define Q0 ((-10 << 15) / 11.0) #define Q0 Q (-10/11)
#define Q1 ((-8 << 15) / 11.0) #define Q1 Q (-8/11)
#define Q2 ((-6 << 15) / 11.0) #define Q2 Q (-6/11)
#define Q3 ((-4 << 15) / 11.0) #define Q3 Q (-4/11)
#define Q4 ((-2 << 15) / 11.0) #define Q4 Q (-2/11)
#define Q5 (0) #define Q5 Q (0)
#define Q6 ((2 << 15) / 11.0) #define Q6 Q (2/11)
#define Q7 ((4 << 15) / 11.0) #define Q7 Q (4/11)
#define Q8 ((6 << 15) / 11.0) #define Q8 Q (6/11)
#define Q9 ((8 << 15) / 11.0) #define Q9 Q (8/11)
#define QA ((10 << 15) / 11.0) #define QA Q (10/11)
static const sample_t q_4_0[128] = { static const quantizer_t q_4_0[128] = {
Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0,
Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1,
Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2,
...@@ -146,7 +147,7 @@ static const sample_t q_4_0[128] = { ...@@ -146,7 +147,7 @@ static const sample_t q_4_0[128] = {
0, 0, 0, 0, 0, 0, 0 0, 0, 0, 0, 0, 0, 0
}; };
static const sample_t q_4_1[128] = { static const quantizer_t q_4_1[128] = {
Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA, Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA,
Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA, Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA,
Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA, Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA,
...@@ -173,15 +174,13 @@ static const sample_t q_4_1[128] = { ...@@ -173,15 +174,13 @@ static const sample_t q_4_1[128] = {
#undef Q9 #undef Q9
#undef QA #undef QA
static const sample_t q_5[16] = { static const quantizer_t q_5[16] = {
(-14 << 15)/15.0,(-12 << 15)/15.0,(-10 << 15)/15.0, Q (-14/15), Q (-12/15), Q (-10/15), Q (-8/15), Q (-6/15),
( -8 << 15)/15.0,( -6 << 15)/15.0,( -4 << 15)/15.0, Q (-4/15), Q (-2/15), Q (0), Q (2/15), Q (4/15),
( -2 << 15)/15.0, 0 ,( 2 << 15)/15.0, Q (6/15), Q (8/15), Q (10/15), Q (12/15), Q (14/15), 0
( 4 << 15)/15.0,( 6 << 15)/15.0,( 8 << 15)/15.0,
( 10 << 15)/15.0,( 12 << 15)/15.0,( 14 << 15)/15.0,
0
}; };
#ifndef LIBA52_FIXED
static const sample_t scale_factor[25] = { static const sample_t scale_factor[25] = {
0.000030517578125, 0.000030517578125,
0.0000152587890625, 0.0000152587890625,
...@@ -209,6 +208,7 @@ static const sample_t scale_factor[25] = { ...@@ -209,6 +208,7 @@ static const sample_t scale_factor[25] = {
0.00000000000363797880709171295166015625, 0.00000000000363797880709171295166015625,
0.000000000001818989403545856475830078125 0.000000000001818989403545856475830078125
}; };
#endif
static const uint16_t dither_lut[256] = { static const uint16_t dither_lut[256] = {
0x0000, 0xa011, 0xe033, 0x4022, 0x6077, 0xc066, 0x8044, 0x2055, 0x0000, 0xa011, 0xe033, 0x4022, 0x6077, 0xc066, 0x8044, 0x2055,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment