Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.

patch by adland <adland123 at yahoo dot com>


git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@13454 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
diego 2004-09-24 17:31:36 +00:00
parent 2887bacbdb
commit e1ece5e2eb
52 changed files with 20318 additions and 4653 deletions

View File

@ -3,7 +3,7 @@ LIBNAME = libfaad2.a
include ../config.mak
SRCS = bits.c cfft.c common.c decoder.c drc.c error.c filtbank.c hcr.c huffman.c ic_predict.c is.c lt_predict.c mdct.c mp4.c ms.c output.c pns.c pulse.c rvlc.c sbr_dct.c sbr_dec.c sbr_e_nf.c sbr_fbt.c sbr_hfadj.c sbr_hfgen.c sbr_huff.c sbr_qmf.c sbr_syntax.c sbr_tf_grid.c specrec.c ssr.c ssr_fb.c ssr_ipqf.c syntax.c tns.c
SRCS = bits.c cfft.c common.c decoder.c drc.c error.c filtbank.c hcr.c huffman.c ic_predict.c is.c lt_predict.c mdct.c mp4.c ms.c output.c pns.c ps_dec.c ps_syntax.c pulse.c rvlc.c sbr_dct.c sbr_dec.c sbr_e_nf.c sbr_fbt.c sbr_hfadj.c sbr_hfgen.c sbr_huff.c sbr_qmf.c sbr_syntax.c sbr_tf_grid.c specrec.c ssr.c ssr_fb.c ssr_ipqf.c syntax.c tns.c
OBJS = $(SRCS:.c=.o)
CFLAGS = -I. $(OPTFLAGS)

View File

@ -1 +1 @@
files from libfaad v2.0 tarball's libfaad/ and include/ subdir
files from libfaad 2.1 beta CVS July 7th 2004 libfaad/ and include/ subdir

View File

@ -23,7 +23,7 @@
** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
**
** Initially modified for use with MPlayer by Arpad Gereöffy on 2003/08/30
** $Id: cfft.c,v 1.3 2004/06/02 22:59:02 diego Exp $
** $Id: cfft.c,v 1.4 2004/06/23 13:50:49 diego Exp $
** detailed CVS changelog at http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
**/
@ -1377,17 +1377,17 @@ cfft_info *cffti(uint16_t n)
switch (n)
{
case 64: cfft->tab = cfft_tab_64; break;
case 512: cfft->tab = cfft_tab_512; break;
case 64: cfft->tab = (complex_t*)cfft_tab_64; break;
case 512: cfft->tab = (complex_t*)cfft_tab_512; break;
#ifdef LD_DEC
case 256: cfft->tab = cfft_tab_256; break;
case 256: cfft->tab = (complex_t*)cfft_tab_256; break;
#endif
#ifdef ALLOW_SMALL_FRAMELENGTH
case 60: cfft->tab = cfft_tab_60; break;
case 480: cfft->tab = cfft_tab_480; break;
case 60: cfft->tab = (complex_t*)cfft_tab_60; break;
case 480: cfft->tab = (complex_t*)cfft_tab_480; break;
#ifdef LD_DEC
case 240: cfft->tab = cfft_tab_240; break;
case 240: cfft->tab = (complex_t*)cfft_tab_240; break;
#endif
#endif
}

View File

@ -23,7 +23,7 @@
** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
**
** Initially modified for use with MPlayer by Arpad Gereöffy on 2003/08/30
** $Id: common.c,v 1.3 2004/06/02 22:59:02 diego Exp $
** $Id: common.c,v 1.4 2004/06/23 13:50:49 diego Exp $
** detailed CVS changelog at http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
**/
@ -233,7 +233,7 @@ int8_t can_decode_ot(const uint8_t object_type)
}
/* common malloc function */
void *faad_malloc(int32_t size)
void *faad_malloc(size_t size)
{
#if 0 // defined(_WIN32) && !defined(_WIN32_WCE)
return _aligned_malloc(size, 16);
@ -304,3 +304,236 @@ uint32_t random_int(void)
return (__r1 = (t3 >> 1) | t1 ) ^ (__r2 = (t4 + t4) | t2 );
}
uint32_t ones32(uint32_t x)
{
x -= ((x >> 1) & 0x55555555);
x = (((x >> 2) & 0x33333333) + (x & 0x33333333));
x = (((x >> 4) + x) & 0x0f0f0f0f);
x += (x >> 8);
x += (x >> 16);
return (x & 0x0000003f);
}
uint32_t floor_log2(uint32_t x)
{
#if 1
x |= (x >> 1);
x |= (x >> 2);
x |= (x >> 4);
x |= (x >> 8);
x |= (x >> 16);
return (ones32(x) - 1);
#else
uint32_t count = 0;
while (x >>= 1)
count++;
return count;
#endif
}
/* returns position of first bit that is not 0 from msb,
* starting count at lsb */
uint32_t wl_min_lzc(uint32_t x)
{
#if 1
x |= (x >> 1);
x |= (x >> 2);
x |= (x >> 4);
x |= (x >> 8);
x |= (x >> 16);
return (ones32(x));
#else
uint32_t count = 0;
while (x >>= 1)
count++;
return (count + 1);
#endif
}
#ifdef FIXED_POINT
#define TABLE_BITS 6
/* just take the maximum number of bits for interpolation */
#define INTERP_BITS (REAL_BITS-TABLE_BITS)
static const real_t pow2_tab[] = {
REAL_CONST(1.000000000000000), REAL_CONST(1.010889286051701), REAL_CONST(1.021897148654117),
REAL_CONST(1.033024879021228), REAL_CONST(1.044273782427414), REAL_CONST(1.055645178360557),
REAL_CONST(1.067140400676824), REAL_CONST(1.078760797757120), REAL_CONST(1.090507732665258),
REAL_CONST(1.102382583307841), REAL_CONST(1.114386742595892), REAL_CONST(1.126521618608242),
REAL_CONST(1.138788634756692), REAL_CONST(1.151189229952983), REAL_CONST(1.163724858777578),
REAL_CONST(1.176396991650281), REAL_CONST(1.189207115002721), REAL_CONST(1.202156731452703),
REAL_CONST(1.215247359980469), REAL_CONST(1.228480536106870), REAL_CONST(1.241857812073484),
REAL_CONST(1.255380757024691), REAL_CONST(1.269050957191733), REAL_CONST(1.282870016078778),
REAL_CONST(1.296839554651010), REAL_CONST(1.310961211524764), REAL_CONST(1.325236643159741),
REAL_CONST(1.339667524053303), REAL_CONST(1.354255546936893), REAL_CONST(1.369002422974591),
REAL_CONST(1.383909881963832), REAL_CONST(1.398979672538311), REAL_CONST(1.414213562373095),
REAL_CONST(1.429613338391970), REAL_CONST(1.445180806977047), REAL_CONST(1.460917794180647),
REAL_CONST(1.476826145939499), REAL_CONST(1.492907728291265), REAL_CONST(1.509164427593423),
REAL_CONST(1.525598150744538), REAL_CONST(1.542210825407941), REAL_CONST(1.559004400237837),
REAL_CONST(1.575980845107887), REAL_CONST(1.593142151342267), REAL_CONST(1.610490331949254),
REAL_CONST(1.628027421857348), REAL_CONST(1.645755478153965), REAL_CONST(1.663676580326736),
REAL_CONST(1.681792830507429), REAL_CONST(1.700106353718524), REAL_CONST(1.718619298122478),
REAL_CONST(1.737333835273706), REAL_CONST(1.756252160373300), REAL_CONST(1.775376492526521),
REAL_CONST(1.794709075003107), REAL_CONST(1.814252175500399), REAL_CONST(1.834008086409342),
REAL_CONST(1.853979125083386), REAL_CONST(1.874167634110300), REAL_CONST(1.894575981586966),
REAL_CONST(1.915206561397147), REAL_CONST(1.936061793492294), REAL_CONST(1.957144124175400),
REAL_CONST(1.978456026387951), REAL_CONST(2.000000000000000)
};
static const real_t log2_tab[] = {
REAL_CONST(0.000000000000000), REAL_CONST(0.022367813028455), REAL_CONST(0.044394119358453),
REAL_CONST(0.066089190457772), REAL_CONST(0.087462841250339), REAL_CONST(0.108524456778169),
REAL_CONST(0.129283016944966), REAL_CONST(0.149747119504682), REAL_CONST(0.169925001442312),
REAL_CONST(0.189824558880017), REAL_CONST(0.209453365628950), REAL_CONST(0.228818690495881),
REAL_CONST(0.247927513443585), REAL_CONST(0.266786540694901), REAL_CONST(0.285402218862248),
REAL_CONST(0.303780748177103), REAL_CONST(0.321928094887362), REAL_CONST(0.339850002884625),
REAL_CONST(0.357552004618084), REAL_CONST(0.375039431346925), REAL_CONST(0.392317422778760),
REAL_CONST(0.409390936137702), REAL_CONST(0.426264754702098), REAL_CONST(0.442943495848728),
REAL_CONST(0.459431618637297), REAL_CONST(0.475733430966398), REAL_CONST(0.491853096329675),
REAL_CONST(0.507794640198696), REAL_CONST(0.523561956057013), REAL_CONST(0.539158811108031),
REAL_CONST(0.554588851677637), REAL_CONST(0.569855608330948), REAL_CONST(0.584962500721156),
REAL_CONST(0.599912842187128), REAL_CONST(0.614709844115208), REAL_CONST(0.629356620079610),
REAL_CONST(0.643856189774725), REAL_CONST(0.658211482751795), REAL_CONST(0.672425341971496),
REAL_CONST(0.686500527183218), REAL_CONST(0.700439718141092), REAL_CONST(0.714245517666123),
REAL_CONST(0.727920454563199), REAL_CONST(0.741466986401147), REAL_CONST(0.754887502163469),
REAL_CONST(0.768184324776926), REAL_CONST(0.781359713524660), REAL_CONST(0.794415866350106),
REAL_CONST(0.807354922057604), REAL_CONST(0.820178962415188), REAL_CONST(0.832890014164742),
REAL_CONST(0.845490050944375), REAL_CONST(0.857980995127572), REAL_CONST(0.870364719583405),
REAL_CONST(0.882643049361841), REAL_CONST(0.894817763307943), REAL_CONST(0.906890595608519),
REAL_CONST(0.918863237274595), REAL_CONST(0.930737337562886), REAL_CONST(0.942514505339240),
REAL_CONST(0.954196310386875), REAL_CONST(0.965784284662087), REAL_CONST(0.977279923499917),
REAL_CONST(0.988684686772166), REAL_CONST(1.000000000000000)
};
real_t pow2_fix(real_t val)
{
uint32_t x1, x2;
uint32_t errcorr;
uint32_t index_frac;
real_t retval;
int32_t whole = (val >> REAL_BITS);
/* rest = [0..1] */
int32_t rest = val - (whole << REAL_BITS);
/* index into pow2_tab */
int32_t index = rest >> (REAL_BITS-TABLE_BITS);
if (val == 0)
return (1<<REAL_BITS);
/* leave INTERP_BITS bits */
index_frac = rest >> (REAL_BITS-TABLE_BITS-INTERP_BITS);
index_frac = index_frac & ((1<<INTERP_BITS)-1);
if (whole > 0)
{
retval = 1 << whole;
} else {
retval = REAL_CONST(1) >> -whole;
}
x1 = pow2_tab[index & ((1<<TABLE_BITS)-1)];
x2 = pow2_tab[(index & ((1<<TABLE_BITS)-1)) + 1];
errcorr = ( (index_frac*(x2-x1))) >> INTERP_BITS;
if (whole > 0)
{
retval = retval * (errcorr + x1);
} else {
retval = MUL_R(retval, (errcorr + x1));
}
return retval;
}
int32_t pow2_int(real_t val)
{
uint32_t x1, x2;
uint32_t errcorr;
uint32_t index_frac;
real_t retval;
int32_t whole = (val >> REAL_BITS);
/* rest = [0..1] */
int32_t rest = val - (whole << REAL_BITS);
/* index into pow2_tab */
int32_t index = rest >> (REAL_BITS-TABLE_BITS);
if (val == 0)
return 1;
/* leave INTERP_BITS bits */
index_frac = rest >> (REAL_BITS-TABLE_BITS-INTERP_BITS);
index_frac = index_frac & ((1<<INTERP_BITS)-1);
if (whole > 0)
retval = 1 << whole;
else
retval = 0;
x1 = pow2_tab[index & ((1<<TABLE_BITS)-1)];
x2 = pow2_tab[(index & ((1<<TABLE_BITS)-1)) + 1];
errcorr = ( (index_frac*(x2-x1))) >> INTERP_BITS;
retval = MUL_R(retval, (errcorr + x1));
return retval;
}
/* ld(x) = ld(x*y/y) = ld(x/y) + ld(y), with y=2^N and [1 <= (x/y) < 2] */
int32_t log2_int(uint32_t val)
{
uint32_t frac;
uint32_t whole = (val);
int8_t exp = 0;
uint32_t index;
uint32_t index_frac;
uint32_t x1, x2;
uint32_t errcorr;
/* error */
if (val == 0)
return -10000;
exp = floor_log2(val);
exp -= REAL_BITS;
/* frac = [1..2] */
if (exp >= 0)
frac = val >> exp;
else
frac = val << -exp;
/* index in the log2 table */
index = frac >> (REAL_BITS-TABLE_BITS);
/* leftover part for linear interpolation */
index_frac = frac & ((1<<(REAL_BITS-TABLE_BITS))-1);
/* leave INTERP_BITS bits */
index_frac = index_frac >> (REAL_BITS-TABLE_BITS-INTERP_BITS);
x1 = log2_tab[index & ((1<<TABLE_BITS)-1)];
x2 = log2_tab[(index & ((1<<TABLE_BITS)-1)) + 1];
/* linear interpolation */
/* retval = exp + ((index_frac)*x2 + (1-index_frac)*x1) */
errcorr = (index_frac * (x2-x1)) >> INTERP_BITS;
return ((exp+REAL_BITS) << REAL_BITS) + errcorr + x1;
}
#endif

View File

@ -39,8 +39,12 @@ extern "C" {
#define __STRICT_ANSI__
#endif
#ifdef HAVE_CONFIG_H
# include "../config.h"
#endif
#define INLINE __inline
#if defined(_WIN32) && !defined(_WIN32_WCE)
#if 0 //defined(_WIN32) && !defined(_WIN32_WCE)
#define ALIGN __declspec(align(16))
#else
#define ALIGN
@ -59,6 +63,10 @@ extern "C" {
/* #define USE_DOUBLE_PRECISION */
/* use fixed point reals */
//#define FIXED_POINT
//#define BIG_IQ_TABLE
/* Use if target platform has address generators with autoincrement */
//#define PREFER_POINTERS
#ifdef _WIN32_WCE
#define FIXED_POINT
@ -95,9 +103,10 @@ extern "C" {
#define ALLOW_SMALL_FRAMELENGTH
// Define LC_ONLY_DECODER if you want a pure AAC LC decoder (independant of SBR_DEC)
// Define LC_ONLY_DECODER if you want a pure AAC LC decoder (independant of SBR_DEC and PS_DEC)
//#define LC_ONLY_DECODER
#ifdef LC_ONLY_DECODER
#undef LD_DEC
#undef LTP_DEC
#undef MAIN_DEC
#undef SSR_DEC
@ -108,19 +117,13 @@ extern "C" {
#define SBR_DEC
//#define SBR_LOW_POWER
//#define PS_DEC
#define PS_DEC
/* FIXED POINT: No MAIN decoding, no SBR decoding */
/* FIXED POINT: No MAIN decoding */
#ifdef FIXED_POINT
# ifdef MAIN_DEC
# undef MAIN_DEC
# endif
//# ifndef SBR_LOW_POWER
//# define SBR_LOW_POWER
//# endif
# ifdef SBR_DEC
# undef SBR_DEC
# endif
#endif // FIXED_POINT
#ifdef DRM
@ -137,9 +140,11 @@ extern "C" {
#endif
#ifdef FIXED_POINT
#define SBR_DIV(A, B) (((int64_t)A << REAL_BITS)/B)
#define DIV_R(A, B) (((int64_t)A << REAL_BITS)/B)
#define DIV_C(A, B) (((int64_t)A << COEF_BITS)/B)
#else
#define SBR_DIV(A, B) ((A)/(B))
#define DIV_R(A, B) ((A)/(B))
#define DIV_C(A, B) ((A)/(B))
#endif
#ifndef SBR_LOW_POWER
@ -155,7 +160,9 @@ extern "C" {
/* END COMPILE TIME DEFINITIONS */
#if defined(_WIN32)
#if defined(_WIN32) && !defined(__MINGW32__)
#include <stdlib.h>
#if 0
typedef unsigned __int64 uint64_t;
@ -169,11 +176,11 @@ typedef __int8 int8_t;
#else
#include <inttypes.h>
#endif
typedef float float32_t;
#else
/* Define if needed */
/* #undef HAVE_FLOAT32_T */
/* Define if you have the <inttypes.h> header file. */
@ -295,6 +302,7 @@ char *strchr(), *strrchr();
#define REAL_CONST(A) ((real_t)(A))
#define COEF_CONST(A) ((real_t)(A))
#define Q2_CONST(A) ((real_t)(A))
#define FRAC_CONST(A) ((real_t)(A)) /* pure fractional part */
#else /* Normal floating point operation */
@ -311,6 +319,7 @@ char *strchr(), *strrchr();
#define REAL_CONST(A) ((real_t)(A))
#define COEF_CONST(A) ((real_t)(A))
#define Q2_CONST(A) ((real_t)(A))
#define FRAC_CONST(A) ((real_t)(A)) /* pure fractional part */
/* Complex multiplication */
@ -413,6 +422,15 @@ typedef real_t complex_t[2];
/* common functions */
uint8_t cpu_has_sse(void);
uint32_t random_int(void);
uint32_t ones32(uint32_t x);
uint32_t floor_log2(uint32_t x);
uint32_t wl_min_lzc(uint32_t x);
#ifdef FIXED_POINT
#define LOG2_MIN_INF REAL_CONST(-10000)
int32_t log2_int(uint32_t val);
int32_t pow2_int(real_t val);
real_t pow2_fix(real_t val);
#endif
uint8_t get_sr_index(const uint32_t samplerate);
uint8_t max_pred_sfb(const uint8_t sr_index);
uint8_t max_tns_sfb(const uint8_t sr_index, const uint8_t object_type,
@ -420,7 +438,7 @@ uint8_t max_tns_sfb(const uint8_t sr_index, const uint8_t object_type,
uint32_t get_sample_rate(const uint8_t sr_index);
int8_t can_decode_ot(const uint8_t object_type);
void *faad_malloc(int32_t size);
void *faad_malloc(size_t size);
void faad_free(void *b);
//#define PROFILE

View File

@ -23,7 +23,7 @@
** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
**
** Initially modified for use with MPlayer by Arpad Gereöffy on 2003/08/30
** $Id: decoder.c,v 1.3 2004/06/02 22:59:02 diego Exp $
** $Id: decoder.c,v 1.4 2004/06/23 13:50:49 diego Exp $
** detailed CVS changelog at http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
**/
@ -52,14 +52,21 @@
uint16_t dbg_count;
#endif
int8_t* FAADAPI faacDecGetErrorMessage(uint8_t errcode)
/* static function declarations */
static void* aac_frame_decode(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo,
uint8_t *buffer, uint32_t buffer_size,
void **sample_buffer, uint32_t sample_buffer_size);
static void create_channel_config(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo);
char* NEAACDECAPI NeAACDecGetErrorMessage(uint8_t errcode)
{
if (errcode >= NUM_ERROR_MESSAGES)
return NULL;
return err_msg[errcode];
}
uint32_t FAADAPI faacDecGetCapabilities(void)
uint32_t NEAACDECAPI NeAACDecGetCapabilities(void)
{
uint32_t cap = 0;
@ -85,15 +92,15 @@ uint32_t FAADAPI faacDecGetCapabilities(void)
return cap;
}
faacDecHandle FAADAPI faacDecOpen(void)
NeAACDecHandle NEAACDECAPI NeAACDecOpen(void)
{
uint8_t i;
faacDecHandle hDecoder = NULL;
NeAACDecHandle hDecoder = NULL;
if ((hDecoder = (faacDecHandle)faad_malloc(sizeof(faacDecStruct))) == NULL)
if ((hDecoder = (NeAACDecHandle)faad_malloc(sizeof(NeAACDecStruct))) == NULL)
return NULL;
memset(hDecoder, 0, sizeof(faacDecStruct));
memset(hDecoder, 0, sizeof(NeAACDecStruct));
hDecoder->config.outputFormat = FAAD_FMT_16BIT;
hDecoder->config.defObjectType = MAIN;
@ -150,11 +157,11 @@ faacDecHandle FAADAPI faacDecOpen(void)
return hDecoder;
}
faacDecConfigurationPtr FAADAPI faacDecGetCurrentConfiguration(faacDecHandle hDecoder)
NeAACDecConfigurationPtr NEAACDECAPI NeAACDecGetCurrentConfiguration(NeAACDecHandle hDecoder)
{
if (hDecoder)
{
faacDecConfigurationPtr config = &(hDecoder->config);
NeAACDecConfigurationPtr config = &(hDecoder->config);
return config;
}
@ -162,8 +169,8 @@ faacDecConfigurationPtr FAADAPI faacDecGetCurrentConfiguration(faacDecHandle hDe
return NULL;
}
uint8_t FAADAPI faacDecSetConfiguration(faacDecHandle hDecoder,
faacDecConfigurationPtr config)
uint8_t NEAACDECAPI NeAACDecSetConfiguration(NeAACDecHandle hDecoder,
NeAACDecConfigurationPtr config)
{
if (hDecoder && config)
{
@ -178,12 +185,18 @@ uint8_t FAADAPI faacDecSetConfiguration(faacDecHandle hDecoder,
hDecoder->config.defSampleRate = config->defSampleRate;
/* check output format */
if ((config->outputFormat < 1) || (config->outputFormat > 9))
#ifdef FIXED_POINT
if ((config->outputFormat < 1) || (config->outputFormat > 4))
return 0;
#else
if ((config->outputFormat < 1) || (config->outputFormat > 5))
return 0;
#endif
hDecoder->config.outputFormat = config->outputFormat;
if (config->downMatrix > 1)
hDecoder->config.downMatrix = config->downMatrix;
return 0;
hDecoder->config.downMatrix = config->downMatrix;
/* OK */
return 1;
@ -192,9 +205,9 @@ uint8_t FAADAPI faacDecSetConfiguration(faacDecHandle hDecoder,
return 0;
}
int32_t FAADAPI faacDecInit(faacDecHandle hDecoder, uint8_t *buffer,
uint32_t buffer_size,
uint32_t *samplerate, uint8_t *channels)
int32_t NEAACDECAPI NeAACDecInit(NeAACDecHandle hDecoder, uint8_t *buffer,
uint32_t buffer_size,
uint32_t *samplerate, uint8_t *channels)
{
uint32_t bits = 0;
bitfile ld;
@ -257,12 +270,23 @@ int32_t FAADAPI faacDecInit(faacDecHandle hDecoder, uint8_t *buffer,
}
hDecoder->channelConfiguration = *channels;
#if (defined(PS_DEC) || defined(DRM_PS))
/* check if we have a mono file */
if (*channels == 1)
{
/* upMatrix to 2 channels for implicit signalling of PS */
*channels = 2;
}
#endif
#ifdef SBR_DEC
/* implicit signalling */
if (*samplerate <= 24000 && !(hDecoder->config.dontUpSampleImplicitSBR))
{
*samplerate *= 2;
hDecoder->forceUpSampling = 1;
} else if (*samplerate > 24000 && !(hDecoder->config.dontUpSampleImplicitSBR)) {
hDecoder->downSampledSBR = 1;
}
#endif
@ -286,9 +310,9 @@ int32_t FAADAPI faacDecInit(faacDecHandle hDecoder, uint8_t *buffer,
}
/* Init the library using a DecoderSpecificInfo */
int8_t FAADAPI faacDecInit2(faacDecHandle hDecoder, uint8_t *pBuffer,
uint32_t SizeOfDecoderSpecificInfo,
uint32_t *samplerate, uint8_t *channels)
int8_t NEAACDECAPI NeAACDecInit2(NeAACDecHandle hDecoder, uint8_t *pBuffer,
uint32_t SizeOfDecoderSpecificInfo,
uint32_t *samplerate, uint8_t *channels)
{
int8_t rc;
mp4AudioSpecificConfig mp4ASC;
@ -318,6 +342,14 @@ int8_t FAADAPI faacDecInit2(faacDecHandle hDecoder, uint8_t *pBuffer,
*channels = hDecoder->pce.channels;
hDecoder->pce_set = 1;
}
#if (defined(PS_DEC) || defined(DRM_PS))
/* check if we have a mono file */
if (*channels == 1)
{
/* upMatrix to 2 channels for implicit signalling of PS */
*channels = 2;
}
#endif
hDecoder->sf_index = mp4ASC.samplingFrequencyIndex;
hDecoder->object_type = mp4ASC.objectTypeIndex;
#ifdef ERROR_RESILIENCE
@ -327,13 +359,14 @@ int8_t FAADAPI faacDecInit2(faacDecHandle hDecoder, uint8_t *pBuffer,
#endif
#ifdef SBR_DEC
hDecoder->sbr_present_flag = mp4ASC.sbr_present_flag;
hDecoder->downSampledSBR = mp4ASC.downSampledSBR;
if (hDecoder->config.dontUpSampleImplicitSBR == 0)
hDecoder->forceUpSampling = mp4ASC.forceUpSampling;
else
hDecoder->forceUpSampling = 0;
/* AAC core decoder samplerate is 2 times as low */
if (hDecoder->sbr_present_flag == 1 || hDecoder->forceUpSampling == 1)
if (((hDecoder->sbr_present_flag == 1)&&(!hDecoder->downSampledSBR)) || hDecoder->forceUpSampling == 1)
{
hDecoder->sf_index = get_sr_index(mp4ASC.samplingFrequency / 2);
}
@ -368,100 +401,48 @@ int8_t FAADAPI faacDecInit2(faacDecHandle hDecoder, uint8_t *pBuffer,
}
#ifdef DRM
int8_t FAADAPI faacDecInitDRM(faacDecHandle hDecoder, uint32_t samplerate,
uint8_t channels)
int8_t NEAACDECAPI NeAACDecInitDRM(NeAACDecHandle *hDecoder, uint32_t samplerate,
uint8_t channels)
{
uint8_t i;
if (hDecoder == NULL)
return 1; /* error */
/* Special object type defined for DRM */
hDecoder->config.defObjectType = DRM_ER_LC;
NeAACDecClose(*hDecoder);
hDecoder->config.defSampleRate = samplerate;
*hDecoder = NeAACDecOpen();
/* Special object type defined for DRM */
(*hDecoder)->config.defObjectType = DRM_ER_LC;
(*hDecoder)->config.defSampleRate = samplerate;
#ifdef ERROR_RESILIENCE // This shoudl always be defined for DRM
hDecoder->aacSectionDataResilienceFlag = 1; /* VCB11 */
hDecoder->aacScalefactorDataResilienceFlag = 0; /* no RVLC */
hDecoder->aacSpectralDataResilienceFlag = 1; /* HCR */
(*hDecoder)->aacSectionDataResilienceFlag = 1; /* VCB11 */
(*hDecoder)->aacScalefactorDataResilienceFlag = 0; /* no RVLC */
(*hDecoder)->aacSpectralDataResilienceFlag = 1; /* HCR */
#endif
hDecoder->frameLength = 960;
hDecoder->sf_index = get_sr_index(hDecoder->config.defSampleRate);
hDecoder->object_type = hDecoder->config.defObjectType;
(*hDecoder)->frameLength = 960;
(*hDecoder)->sf_index = get_sr_index((*hDecoder)->config.defSampleRate);
(*hDecoder)->object_type = (*hDecoder)->config.defObjectType;
if ((channels == DRMCH_STEREO) || (channels == DRMCH_SBR_STEREO))
hDecoder->channelConfiguration = 2;
(*hDecoder)->channelConfiguration = 2;
else
hDecoder->channelConfiguration = 1;
(*hDecoder)->channelConfiguration = 1;
#ifdef SBR_DEC
if (channels == DRMCH_SBR_LC_STEREO)
hDecoder->lcstereo_flag = 1;
else
hDecoder->lcstereo_flag = 0;
if ((channels == DRMCH_MONO) || (channels == DRMCH_STEREO))
hDecoder->sbr_present_flag = 0;
(*hDecoder)->sbr_present_flag = 0;
else
hDecoder->sbr_present_flag = 1;
(*hDecoder)->sbr_present_flag = 1;
#endif
/* Reset sbr for new initialization */
sbrDecodeEnd(hDecoder->sbr[0]);
hDecoder->sbr[0] = NULL;
#endif
if (hDecoder->fb) filter_bank_end(hDecoder->fb);
hDecoder->fb = NULL;
/* Take care of buffers */
if (hDecoder->sample_buffer) faad_free(hDecoder->sample_buffer);
hDecoder->sample_buffer = NULL;
hDecoder->alloced_channels = 0;
for (i = 0; i < MAX_CHANNELS; i++)
{
hDecoder->window_shape_prev[i] = 0;
if (hDecoder->time_out[i]) faad_free(hDecoder->time_out[i]);
hDecoder->time_out[i] = NULL;
if (hDecoder->fb_intermed[i]) faad_free(hDecoder->fb_intermed[i]);
hDecoder->fb_intermed[i] = NULL;
#ifdef SSR_DEC
if (hDecoder->ssr_overlap[i]) faad_free(hDecoder->ssr_overlap[i]);
hDecoder->ssr_overlap[i] = NULL;
if (hDecoder->prev_fmd[i]) faad_free(hDecoder->prev_fmd[i]);
hDecoder->prev_fmd[i] = NULL;
#endif
#ifdef MAIN_DEC
if (hDecoder->pred_stat[i]) faad_free(hDecoder->pred_stat[i]);
hDecoder->pred_stat[i] = NULL;
#endif
#ifdef LTP_DEC
hDecoder->ltp_lag[i] = 0;
if (hDecoder->lt_pred_stat[i]) faad_free(hDecoder->lt_pred_stat[i]);
hDecoder->lt_pred_stat[i] = NULL;
#endif
}
for (i = 0; i < MAX_SYNTAX_ELEMENTS; i++)
{
#ifdef SBR_DEC
if (hDecoder->sbr[i])
sbrDecodeEnd(hDecoder->sbr[i]);
hDecoder->sbr_alloced[i] = 0;
#endif
hDecoder->element_alloced[i] = 0;
hDecoder->element_output_channels[i] = 0;
}
hDecoder->fb = filter_bank_init(hDecoder->frameLength);
(*hDecoder)->fb = filter_bank_init((*hDecoder)->frameLength);
return 0;
}
#endif
void FAADAPI faacDecClose(faacDecHandle hDecoder)
void NEAACDECAPI NeAACDecClose(NeAACDecHandle hDecoder)
{
uint8_t i;
@ -514,7 +495,7 @@ void FAADAPI faacDecClose(faacDecHandle hDecoder)
if (hDecoder) faad_free(hDecoder);
}
void FAADAPI faacDecPostSeekReset(faacDecHandle hDecoder, int32_t frame)
void NEAACDECAPI NeAACDecPostSeekReset(NeAACDecHandle hDecoder, int32_t frame)
{
if (hDecoder)
{
@ -525,7 +506,7 @@ void FAADAPI faacDecPostSeekReset(faacDecHandle hDecoder, int32_t frame)
}
}
static void create_channel_config(faacDecHandle hDecoder, faacDecFrameInfo *hInfo)
static void create_channel_config(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo)
{
hInfo->num_front_channels = 0;
hInfo->num_side_channels = 0;
@ -730,9 +711,31 @@ static void create_channel_config(faacDecHandle hDecoder, faacDecFrameInfo *hInf
}
}
void* FAADAPI faacDecDecode(faacDecHandle hDecoder,
faacDecFrameInfo *hInfo,
uint8_t *buffer, uint32_t buffer_size)
void* NEAACDECAPI NeAACDecDecode(NeAACDecHandle hDecoder,
NeAACDecFrameInfo *hInfo,
uint8_t *buffer, uint32_t buffer_size)
{
return aac_frame_decode(hDecoder, hInfo, buffer, buffer_size, NULL, 0);
}
void* NEAACDECAPI NeAACDecDecode2(NeAACDecHandle hDecoder,
NeAACDecFrameInfo *hInfo,
uint8_t *buffer, uint32_t buffer_size,
void **sample_buffer, uint32_t sample_buffer_size)
{
if ((sample_buffer == NULL) || (sample_buffer_size == 0))
{
hInfo->error = 27;
return NULL;
}
return aac_frame_decode(hDecoder, hInfo, buffer, buffer_size,
sample_buffer, sample_buffer_size);
}
static void* aac_frame_decode(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo,
uint8_t *buffer, uint32_t buffer_size,
void **sample_buffer2, uint32_t sample_buffer_size)
{
uint8_t channels = 0;
uint8_t output_channels = 0;
@ -751,27 +754,49 @@ void* FAADAPI faacDecDecode(faacDecHandle hDecoder,
return NULL;
}
#if 0
printf("%d\n", buffer_size*8);
#endif
frame_len = hDecoder->frameLength;
memset(hInfo, 0, sizeof(faacDecFrameInfo));
memset(hInfo, 0, sizeof(NeAACDecFrameInfo));
memset(hDecoder->internal_channel, 0, MAX_CHANNELS*sizeof(hDecoder->internal_channel[0]));
/* initialize the bitstream */
faad_initbits(&ld, buffer, buffer_size);
#if 0
{
int i;
for (i = 0; i < ((buffer_size+3)>>2); i++)
{
uint8_t *buf;
uint32_t temp = 0;
buf = faad_getbitbuffer(&ld, 32);
//temp = getdword((void*)buf);
temp = *((uint32_t*)buf);
printf("0x%.8X\n", temp);
free(buf);
}
faad_endbits(&ld);
faad_initbits(&ld, buffer, buffer_size);
}
#endif
#ifdef DRM
if (hDecoder->object_type == DRM_ER_LC)
{
/* We do not support stereo right now */
if (hDecoder->channelConfiguration == 2)
if (0) //(hDecoder->channelConfiguration == 2)
{
hInfo->error = 8; // Throw CRC error
goto error;
}
faad_getbits(&ld, 8
DEBUGVAR(1,1,"faacDecDecode(): skip CRC"));
DEBUGVAR(1,1,"NeAACDecDecode(): skip CRC"));
}
#endif
@ -831,7 +856,7 @@ void* FAADAPI faacDecDecode(faacDecHandle hDecoder,
if (!hDecoder->adts_header_present && !hDecoder->adif_header_present)
{
if (channels != hDecoder->channelConfiguration)
if (hDecoder->channelConfiguration == 0)
hDecoder->channelConfiguration = channels;
if (channels == 8) /* 7.1 */
@ -848,6 +873,17 @@ void* FAADAPI faacDecDecode(faacDecHandle hDecoder,
output_channels = channels;
}
#if (defined(PS_DEC) || defined(DRM_PS))
hDecoder->upMatrix = 0;
/* check if we have a mono file */
if (output_channels == 1)
{
/* upMatrix to 2 channels for implicit signalling of PS */
hDecoder->upMatrix = 1;
output_channels = 2;
}
#endif
/* Make a channel configuration based on either a PCE or a channelConfiguration */
create_channel_config(hDecoder, hInfo);
@ -885,17 +921,32 @@ void* FAADAPI faacDecDecode(faacDecHandle hDecoder,
};
uint8_t stride = str[hDecoder->config.outputFormat-1];
#ifdef SBR_DEC
if ((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1))
if (((hDecoder->sbr_present_flag == 1)&&(!hDecoder->downSampledSBR)) || (hDecoder->forceUpSampling == 1))
{
stride = 2 * stride;
}
#endif
if (hDecoder->sample_buffer)
faad_free(hDecoder->sample_buffer);
hDecoder->sample_buffer = NULL;
hDecoder->sample_buffer = faad_malloc(frame_len*output_channels*stride);
/* check if we want to use internal sample_buffer */
if (sample_buffer_size == 0)
{
if (hDecoder->sample_buffer)
faad_free(hDecoder->sample_buffer);
hDecoder->sample_buffer = NULL;
hDecoder->sample_buffer = faad_malloc(frame_len*output_channels*stride);
} else if (sample_buffer_size < frame_len*output_channels*stride) {
/* provided sample buffer is not big enough */
hInfo->error = 27;
return NULL;
}
hDecoder->alloced_channels = output_channels;
}
sample_buffer = hDecoder->sample_buffer;
if (sample_buffer_size == 0)
{
sample_buffer = hDecoder->sample_buffer;
} else {
sample_buffer = *sample_buffer2;
}
#ifdef SBR_DEC
if ((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1))
@ -903,9 +954,12 @@ void* FAADAPI faacDecDecode(faacDecHandle hDecoder,
uint8_t ele;
/* this data is different when SBR is used or when the data is upsampled */
frame_len *= 2;
hInfo->samples *= 2;
hInfo->samplerate *= 2;
if (!hDecoder->downSampledSBR)
{
frame_len *= 2;
hInfo->samples *= 2;
hInfo->samplerate *= 2;
}
/* check if every element was provided with SBR data */
for (ele = 0; ele < hDecoder->fr_ch_ele; ele++)
@ -925,6 +979,10 @@ void* FAADAPI faacDecDecode(faacDecHandle hDecoder,
} else {
hInfo->sbr = NO_SBR_UPSAMPLED;
}
if (hDecoder->downSampledSBR)
{
hInfo->sbr = SBR_DOWNSAMPLED;
}
}
#endif

View File

@ -23,7 +23,7 @@
** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
**
** Initially modified for use with MPlayer by Arpad Gereöffy on 2003/08/30
** $Id: decoder.h,v 1.3 2004/06/02 22:59:02 diego Exp $
** $Id: decoder.h,v 1.4 2004/06/23 13:50:49 diego Exp $
** detailed CVS changelog at http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
**/
@ -36,28 +36,22 @@ extern "C" {
#ifdef _WIN32
#pragma pack(push, 8)
#ifndef FAADAPI
#define FAADAPI __cdecl
#ifndef NEAACDECAPI
#define NEAACDECAPI __cdecl
#endif
#else
#ifndef FAADAPI
#define FAADAPI
#ifndef NEAACDECAPI
#define NEAACDECAPI
#endif
#endif
#include "bits.h"
#include "syntax.h"
#include "drc.h"
#include "specrec.h"
#include "filtbank.h"
#include "ic_predict.h"
/* library output formats */
#define FAAD_FMT_16BIT 1
#define FAAD_FMT_24BIT 2
#define FAAD_FMT_32BIT 3
#define FAAD_FMT_FLOAT 4
#define FAAD_FMT_FIXED FAAD_FMT_FLOAT
#define FAAD_FMT_DOUBLE 5
#define LC_DEC_CAP (1<<0)
@ -78,41 +72,46 @@ extern "C" {
#define LFE_CHANNEL (9)
#define UNKNOWN_CHANNEL (0)
int8_t* FAADAPI faacDecGetErrorMessage(uint8_t errcode);
char* NEAACDECAPI NeAACDecGetErrorMessage(uint8_t errcode);
uint32_t FAADAPI faacDecGetCapabilities(void);
uint32_t NEAACDECAPI NeAACDecGetCapabilities(void);
faacDecHandle FAADAPI faacDecOpen(void);
NeAACDecHandle NEAACDECAPI NeAACDecOpen(void);
faacDecConfigurationPtr FAADAPI faacDecGetCurrentConfiguration(faacDecHandle hDecoder);
NeAACDecConfigurationPtr NEAACDECAPI NeAACDecGetCurrentConfiguration(NeAACDecHandle hDecoder);
uint8_t FAADAPI faacDecSetConfiguration(faacDecHandle hDecoder,
faacDecConfigurationPtr config);
uint8_t NEAACDECAPI NeAACDecSetConfiguration(NeAACDecHandle hDecoder,
NeAACDecConfigurationPtr config);
/* Init the library based on info from the AAC file (ADTS/ADIF) */
int32_t FAADAPI faacDecInit(faacDecHandle hDecoder,
uint8_t *buffer,
uint32_t buffer_size,
uint32_t *samplerate,
uint8_t *channels);
int32_t NEAACDECAPI NeAACDecInit(NeAACDecHandle hDecoder,
uint8_t *buffer,
uint32_t buffer_size,
uint32_t *samplerate,
uint8_t *channels);
/* Init the library using a DecoderSpecificInfo */
int8_t FAADAPI faacDecInit2(faacDecHandle hDecoder, uint8_t *pBuffer,
uint32_t SizeOfDecoderSpecificInfo,
uint32_t *samplerate, uint8_t *channels);
int8_t NEAACDECAPI NeAACDecInit2(NeAACDecHandle hDecoder, uint8_t *pBuffer,
uint32_t SizeOfDecoderSpecificInfo,
uint32_t *samplerate, uint8_t *channels);
/* Init the library for DRM */
int8_t FAADAPI faacDecInitDRM(faacDecHandle hDecoder, uint32_t samplerate,
uint8_t channels);
int8_t NEAACDECAPI NeAACDecInitDRM(NeAACDecHandle *hDecoder, uint32_t samplerate,
uint8_t channels);
void FAADAPI faacDecClose(faacDecHandle hDecoder);
void NEAACDECAPI NeAACDecClose(NeAACDecHandle hDecoder);
void FAADAPI faacDecPostSeekReset(faacDecHandle hDecoder, int32_t frame);
void NEAACDECAPI NeAACDecPostSeekReset(NeAACDecHandle hDecoder, int32_t frame);
void* FAADAPI faacDecDecode(faacDecHandle hDecoder,
faacDecFrameInfo *hInfo,
uint8_t *buffer,
uint32_t buffer_size);
void* NEAACDECAPI NeAACDecDecode(NeAACDecHandle hDecoder,
NeAACDecFrameInfo *hInfo,
uint8_t *buffer,
uint32_t buffer_size);
void* NEAACDECAPI NeAACDecDecode2(NeAACDecHandle hDecoder,
NeAACDecFrameInfo *hInfo,
uint8_t *buffer, uint32_t buffer_size,
void **sample_buffer, uint32_t sample_buffer_size);
#ifdef _WIN32
#pragma pack(pop)

View File

@ -23,19 +23,19 @@
** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
**
** Initially modified for use with MPlayer by Arpad Gereöffy on 2003/08/30
** $Id: error.c,v 1.2 2004/06/02 22:59:02 diego Exp $
** $Id: error.c,v 1.3 2004/06/23 13:50:49 diego Exp $
** detailed CVS changelog at http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
**/
#include "common.h"
#include "error.h"
int8_t *err_msg[] = {
char *err_msg[] = {
"No error",
"Gain control not yet implemented",
"Pulse coding not allowed in short blocks",
"Invalid huffman codebook",
"Negative scalefactor found, should be impossible",
"Scalefactor out of range",
"Unable to find ADTS syncword",
"Channel coupling not yet implemented",
"Channel configuration not allowed in error resilient frame",
@ -56,6 +56,8 @@ int8_t *err_msg[] = {
"Error in program_config_element",
"First SBR frame is not the same as first AAC frame",
"Unexpected fill element with SBR data",
"Not all elements were provided with SBR data"
"Not all elements were provided with SBR data",
"LTP decoding not available",
"Output data buffer too small"
};

View File

@ -23,7 +23,7 @@
** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
**
** Initially modified for use with MPlayer by Arpad Gereöffy on 2003/08/30
** $Id: error.h,v 1.2 2004/06/02 22:59:02 diego Exp $
** $Id: error.h,v 1.3 2004/06/23 13:50:49 diego Exp $
** detailed CVS changelog at http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
**/
@ -34,8 +34,8 @@
extern "C" {
#endif
#define NUM_ERROR_MESSAGES 26
extern int8_t *err_msg[];
#define NUM_ERROR_MESSAGES 28
extern char *err_msg[];
#ifdef __cplusplus
}

View File

@ -23,200 +23,11 @@
** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
**
** Initially modified for use with MPlayer by Arpad Gereöffy on 2003/08/30
** $Id: faad.h,v 1.3 2004/06/02 22:59:02 diego Exp $
** $Id: faad.h,v 1.4 2004/06/23 13:50:49 diego Exp $
** detailed CVS changelog at http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
**/
/* warn people for update */
#pragma message("please update faad2 include filename and function names!")
#ifndef __AACDEC_H__
#define __AACDEC_H__
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#ifdef _WIN32
#pragma pack(push, 8)
#ifndef FAADAPI
#define FAADAPI __cdecl
#endif
#else
#ifndef FAADAPI
#define FAADAPI
#endif
#endif
#define FAAD2_VERSION "2.0"
/* object types for AAC */
#define MAIN 1
#define LC 2
#define SSR 3
#define LTP 4
#define HE_AAC 5
#define ER_LC 17
#define ER_LTP 19
#define LD 23
#define DRM_ER_LC 27 /* special object type for DRM */
/* header types */
#define RAW 0
#define ADIF 1
#define ADTS 2
/* SBR signalling */
#define NO_SBR 0
#define SBR_UPSAMPLED 1
#define SBR_DOWNSAMPLED 2
#define NO_SBR_UPSAMPLED 3
/* library output formats */
#define FAAD_FMT_16BIT 1
#define FAAD_FMT_24BIT 2
#define FAAD_FMT_32BIT 3
#define FAAD_FMT_FLOAT 4
#define FAAD_FMT_DOUBLE 5
#define FAAD_FMT_16BIT_DITHER 6
#define FAAD_FMT_16BIT_L_SHAPE 7
#define FAAD_FMT_16BIT_M_SHAPE 8
#define FAAD_FMT_16BIT_H_SHAPE 9
/* Capabilities */
#define LC_DEC_CAP (1<<0)
#define MAIN_DEC_CAP (1<<1)
#define LTP_DEC_CAP (1<<2)
#define LD_DEC_CAP (1<<3)
#define ERROR_RESILIENCE_CAP (1<<4)
#define FIXED_POINT_CAP (1<<5)
/* Channel definitions */
#define FRONT_CHANNEL_CENTER (1)
#define FRONT_CHANNEL_LEFT (2)
#define FRONT_CHANNEL_RIGHT (3)
#define SIDE_CHANNEL_LEFT (4)
#define SIDE_CHANNEL_RIGHT (5)
#define BACK_CHANNEL_LEFT (6)
#define BACK_CHANNEL_RIGHT (7)
#define BACK_CHANNEL_CENTER (8)
#define LFE_CHANNEL (9)
#define UNKNOWN_CHANNEL (0)
/* DRM channel definitions */
#define DRMCH_MONO 1
#define DRMCH_STEREO 2
#define DRMCH_SBR_MONO 3
#define DRMCH_SBR_LC_STEREO 4
#define DRMCH_SBR_STEREO 5
/* A decode call can eat up to FAAD_MIN_STREAMSIZE bytes per decoded channel,
so at least so much bytes per channel should be available in this stream */
#define FAAD_MIN_STREAMSIZE 768 /* 6144 bits/channel */
typedef void *faacDecHandle;
typedef struct mp4AudioSpecificConfig
{
/* Audio Specific Info */
unsigned char objectTypeIndex;
unsigned char samplingFrequencyIndex;
unsigned long samplingFrequency;
unsigned char channelsConfiguration;
/* GA Specific Info */
unsigned char frameLengthFlag;
unsigned char dependsOnCoreCoder;
unsigned short coreCoderDelay;
unsigned char extensionFlag;
unsigned char aacSectionDataResilienceFlag;
unsigned char aacScalefactorDataResilienceFlag;
unsigned char aacSpectralDataResilienceFlag;
unsigned char epConfig;
char sbr_present_flag;
char forceUpSampling;
} mp4AudioSpecificConfig;
typedef struct faacDecConfiguration
{
unsigned char defObjectType;
unsigned long defSampleRate;
unsigned char outputFormat;
unsigned char downMatrix;
unsigned char useOldADTSFormat;
} faacDecConfiguration, *faacDecConfigurationPtr;
typedef struct faacDecFrameInfo
{
unsigned long bytesconsumed;
unsigned long samples;
unsigned char channels;
unsigned char error;
unsigned long samplerate;
/* SBR: 0: off, 1: on; upsample, 2: on; downsampled, 3: off; upsampled */
unsigned char sbr;
/* MPEG-4 ObjectType */
unsigned char object_type;
/* AAC header type; MP4 will be signalled as RAW also */
unsigned char header_type;
/* multichannel configuration */
unsigned char num_front_channels;
unsigned char num_side_channels;
unsigned char num_back_channels;
unsigned char num_lfe_channels;
unsigned char channel_position[64];
} faacDecFrameInfo;
char* FAADAPI faacDecGetErrorMessage(unsigned char errcode);
unsigned long FAADAPI faacDecGetCapabilities();
faacDecHandle FAADAPI faacDecOpen();
faacDecConfigurationPtr FAADAPI faacDecGetCurrentConfiguration(faacDecHandle hDecoder);
unsigned char FAADAPI faacDecSetConfiguration(faacDecHandle hDecoder,
faacDecConfigurationPtr config);
/* Init the library based on info from the AAC file (ADTS/ADIF) */
long FAADAPI faacDecInit(faacDecHandle hDecoder,
unsigned char *buffer,
unsigned long buffer_size,
unsigned long *samplerate,
unsigned char *channels);
/* Init the library using a DecoderSpecificInfo */
char FAADAPI faacDecInit2(faacDecHandle hDecoder, unsigned char *pBuffer,
unsigned long SizeOfDecoderSpecificInfo,
unsigned long *samplerate, unsigned char *channels);
/* Init the library for DRM */
char FAADAPI faacDecInitDRM(faacDecHandle hDecoder, unsigned long samplerate,
unsigned char channels);
void FAADAPI faacDecPostSeekReset(faacDecHandle hDecoder, long frame);
void FAADAPI faacDecClose(faacDecHandle hDecoder);
void* FAADAPI faacDecDecode(faacDecHandle hDecoder,
faacDecFrameInfo *hInfo,
unsigned char *buffer,
unsigned long buffer_size);
char FAADAPI AudioSpecificConfig(unsigned char *pBuffer,
unsigned long buffer_size,
mp4AudioSpecificConfig *mp4ASC);
#ifdef _WIN32
#pragma pack(pop)
#endif
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif
/* Backwards compatible link */
#include "neaacdec.h"

View File

@ -23,7 +23,7 @@
** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
**
** Initially modified for use with MPlayer by Arpad Gereöffy on 2003/08/30
** $Id: filtbank.c,v 1.3 2004/06/02 22:59:02 diego Exp $
** $Id: filtbank.c,v 1.4 2004/06/23 13:50:49 diego Exp $
** detailed CVS changelog at http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
**/
@ -217,6 +217,7 @@ void ifilter_bank(fb_info *fb, uint8_t window_sequence, uint8_t window_shape,
int64_t count = faad_get_ts();
#endif
/* select windows of current frame and previous frame (Sine or KBD) */
#ifdef LD_DEC
if (object_type == LD)
{
@ -232,11 +233,24 @@ void ifilter_bank(fb_info *fb, uint8_t window_sequence, uint8_t window_shape,
}
#endif
#if 0
for (i = 0; i < 1024; i++)
{
printf("%d\n", freq_in[i]);
}
#endif
#if 0
printf("%d %d\n", window_sequence, window_shape);
#endif
switch (window_sequence)
{
case ONLY_LONG_SEQUENCE:
/* perform iMDCT */
imdct_long(fb, freq_in, transf_buf, 2*nlong);
/* add second half output of previous frame to windowed output of current frame */
for (i = 0; i < nlong; i+=4)
{
time_out[i] = overlap[i] + MUL_F(transf_buf[i],window_long_prev[i]);
@ -244,6 +258,8 @@ void ifilter_bank(fb_info *fb, uint8_t window_sequence, uint8_t window_shape,
time_out[i+2] = overlap[i+2] + MUL_F(transf_buf[i+2],window_long_prev[i+2]);
time_out[i+3] = overlap[i+3] + MUL_F(transf_buf[i+3],window_long_prev[i+3]);
}
/* window the second half and save as overlap for next frame */
for (i = 0; i < nlong; i+=4)
{
overlap[i] = MUL_F(transf_buf[nlong+i],window_long[nlong-1-i]);
@ -254,7 +270,10 @@ void ifilter_bank(fb_info *fb, uint8_t window_sequence, uint8_t window_shape,
break;
case LONG_START_SEQUENCE:
/* perform iMDCT */
imdct_long(fb, freq_in, transf_buf, 2*nlong);
/* add second half output of previous frame to windowed output of current frame */
for (i = 0; i < nlong; i+=4)
{
time_out[i] = overlap[i] + MUL_F(transf_buf[i],window_long_prev[i]);
@ -262,6 +281,9 @@ void ifilter_bank(fb_info *fb, uint8_t window_sequence, uint8_t window_shape,
time_out[i+2] = overlap[i+2] + MUL_F(transf_buf[i+2],window_long_prev[i+2]);
time_out[i+3] = overlap[i+3] + MUL_F(transf_buf[i+3],window_long_prev[i+3]);
}
/* window the second half and save as overlap for next frame */
/* construct second half window using padding with 1's and 0's */
for (i = 0; i < nflat_ls; i++)
overlap[i] = transf_buf[nlong+i];
for (i = 0; i < nshort; i++)
@ -271,6 +293,7 @@ void ifilter_bank(fb_info *fb, uint8_t window_sequence, uint8_t window_shape,
break;
case EIGHT_SHORT_SEQUENCE:
/* perform iMDCT for each short block */
faad_imdct(fb->mdct256, freq_in+0*nshort, transf_buf+2*nshort*0);
faad_imdct(fb->mdct256, freq_in+1*nshort, transf_buf+2*nshort*1);
faad_imdct(fb->mdct256, freq_in+2*nshort, transf_buf+2*nshort*2);
@ -279,6 +302,8 @@ void ifilter_bank(fb_info *fb, uint8_t window_sequence, uint8_t window_shape,
faad_imdct(fb->mdct256, freq_in+5*nshort, transf_buf+2*nshort*5);
faad_imdct(fb->mdct256, freq_in+6*nshort, transf_buf+2*nshort*6);
faad_imdct(fb->mdct256, freq_in+7*nshort, transf_buf+2*nshort*7);
/* add second half output of previous frame to windowed output of current frame */
for (i = 0; i < nflat_ls; i++)
time_out[i] = overlap[i];
for(i = 0; i < nshort; i++)
@ -290,6 +315,8 @@ void ifilter_bank(fb_info *fb, uint8_t window_sequence, uint8_t window_shape,
if (i < trans)
time_out[nflat_ls+4*nshort+i] = overlap[nflat_ls+nshort*4+i] + MUL_F(transf_buf[nshort*7+i],window_short[nshort-1-i]) + MUL_F(transf_buf[nshort*8+i],window_short[i]);
}
/* window the second half and save as overlap for next frame */
for(i = 0; i < nshort; i++)
{
if (i >= trans)
@ -304,18 +331,33 @@ void ifilter_bank(fb_info *fb, uint8_t window_sequence, uint8_t window_shape,
break;
case LONG_STOP_SEQUENCE:
/* perform iMDCT */
imdct_long(fb, freq_in, transf_buf, 2*nlong);
/* add second half output of previous frame to windowed output of current frame */
/* construct first half window using padding with 1's and 0's */
for (i = 0; i < nflat_ls; i++)
time_out[i] = overlap[i];
for (i = 0; i < nshort; i++)
time_out[nflat_ls+i] = overlap[nflat_ls+i] + MUL_F(transf_buf[nflat_ls+i],window_short_prev[i]);
for (i = 0; i < nflat_ls; i++)
time_out[nflat_ls+nshort+i] = overlap[nflat_ls+nshort+i] + transf_buf[nflat_ls+nshort+i];
/* window the second half and save as overlap for next frame */
for (i = 0; i < nlong; i++)
overlap[i] = MUL_F(transf_buf[nlong+i],window_long[nlong-1-i]);
break;
}
#if 0
for (i = 0; i < 1024; i++)
{
//printf("%d\n", time_out[i]);
printf("0x%.8X\n", time_out[i]);
}
#endif
#ifdef PROFILE
count = faad_get_ts() - count;
fb->cycles += count;

View File

@ -23,7 +23,7 @@
** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
**
** Initially modified for use with MPlayer by Arpad Gereöffy on 2003/08/30
** $Id: fixed.h,v 1.3 2004/06/02 22:59:03 diego Exp $
** $Id: fixed.h,v 1.4 2004/06/23 13:50:50 diego Exp $
** detailed CVS changelog at http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
**/
@ -34,7 +34,7 @@
extern "C" {
#endif
#ifdef _WIN32_WCE
#if defined(_WIN32_WCE) && defined(_ARM_)
#include <cmnintrin.h>
#endif
@ -55,6 +55,11 @@ typedef int32_t real_t;
#define REAL_CONST(A) (((A) >= 0) ? ((real_t)((A)*(REAL_PRECISION)+0.5)) : ((real_t)((A)*(REAL_PRECISION)-0.5)))
#define COEF_CONST(A) (((A) >= 0) ? ((real_t)((A)*(COEF_PRECISION)+0.5)) : ((real_t)((A)*(COEF_PRECISION)-0.5)))
#define FRAC_CONST(A) (((A) == 1.00) ? ((real_t)FRAC_MAX) : (((A) >= 0) ? ((real_t)((A)*(FRAC_PRECISION)+0.5)) : ((real_t)((A)*(FRAC_PRECISION)-0.5))))
//#define FRAC_CONST(A) (((A) >= 0) ? ((real_t)((A)*(FRAC_PRECISION)+0.5)) : ((real_t)((A)*(FRAC_PRECISION)-0.5)))
#define Q2_BITS 22
#define Q2_PRECISION (1 << Q2_BITS)
#define Q2_CONST(A) (((A) >= 0) ? ((real_t)((A)*(Q2_PRECISION)+0.5)) : ((real_t)((A)*(Q2_PRECISION)-0.5)))
#if defined(_WIN32) && !defined(_WIN32_WCE)
@ -78,6 +83,34 @@ static INLINE real_t MUL_C(real_t A, real_t B)
}
}
static INLINE real_t MUL_Q2(real_t A, real_t B)
{
_asm {
mov eax,A
imul B
shrd eax,edx,Q2_BITS
}
}
static INLINE real_t MUL_SHIFT6(real_t A, real_t B)
{
_asm {
mov eax,A
imul B
shrd eax,edx,6
}
}
static INLINE real_t MUL_SHIFT23(real_t A, real_t B)
{
_asm {
mov eax,A
imul B
shrd eax,edx,23
}
}
#if 1
static INLINE real_t _MulHigh(real_t A, real_t B)
{
_asm {
@ -100,6 +133,24 @@ static INLINE void ComplexMult(real_t *y1, real_t *y2,
*y1 = (_MulHigh(x1, c1) + _MulHigh(x2, c2))<<(FRAC_SIZE-FRAC_BITS);
*y2 = (_MulHigh(x2, c1) - _MulHigh(x1, c2))<<(FRAC_SIZE-FRAC_BITS);
}
#else
static INLINE real_t MUL_F(real_t A, real_t B)
{
_asm {
mov eax,A
imul B
shrd eax,edx,FRAC_BITS
}
}
/* Complex multiplication */
static INLINE void ComplexMult(real_t *y1, real_t *y2,
real_t x1, real_t x2, real_t c1, real_t c2)
{
*y1 = MUL_F(x1, c1) + MUL_F(x2, c2);
*y2 = MUL_F(x2, c1) - MUL_F(x1, c2);
}
#endif
#elif defined(__GNUC__) && defined (__arm__)
@ -129,6 +180,21 @@ static INLINE real_t MUL_C(real_t A, real_t B)
return arm_mul(A, B, COEF_BITS);
}
static INLINE real_t MUL_Q2(real_t A, real_t B)
{
return arm_mul(A, B, Q2_BITS);
}
static INLINE real_t MUL_SHIFT6(real_t A, real_t B)
{
return arm_mul(A, B, 6);
}
static INLINE real_t MUL_SHIFT23(real_t A, real_t B)
{
return arm_mul(A, B, 23);
}
static INLINE real_t _MulHigh(real_t x, real_t y)
{
uint32_t __lo;
@ -169,16 +235,19 @@ static INLINE void ComplexMult(real_t *y1, real_t *y2,
/* multiply with coef shift */
#define MUL_C(A,B) (real_t)(((int64_t)(A)*(int64_t)(B)+(1 << (COEF_BITS-1))) >> COEF_BITS)
/* multiply with fractional shift */
#ifndef _WIN32_WCE
#define _MulHigh(A,B) (real_t)(((int64_t)(A)*(int64_t)(B)+(1 << (FRAC_SIZE-1))) >> FRAC_SIZE)
#define MUL_F(A,B) (real_t)(((int64_t)(A)*(int64_t)(B)+(1 << (FRAC_BITS-1))) >> FRAC_BITS)
#else
#if defined(_WIN32_WCE) && defined(_ARM_)
/* eVC for PocketPC has an intrinsic function that returns only the high 32 bits of a 32x32 bit multiply */
static INLINE real_t MUL_F(real_t A, real_t B)
{
return _MulHigh(A,B) << (32-FRAC_BITS);
}
#else
#define _MulHigh(A,B) (real_t)(((int64_t)(A)*(int64_t)(B)+(1 << (FRAC_SIZE-1))) >> FRAC_SIZE)
#define MUL_F(A,B) (real_t)(((int64_t)(A)*(int64_t)(B)+(1 << (FRAC_BITS-1))) >> FRAC_BITS)
#endif
#define MUL_Q2(A,B) (real_t)(((int64_t)(A)*(int64_t)(B)+(1 << (Q2_BITS-1))) >> Q2_BITS)
#define MUL_SHIFT6(A,B) (real_t)(((int64_t)(A)*(int64_t)(B)+(1 << (6-1))) >> 6)
#define MUL_SHIFT23(A,B) (real_t)(((int64_t)(A)*(int64_t)(B)+(1 << (23-1))) >> 23)
/* Complex multiplication */
static INLINE void ComplexMult(real_t *y1, real_t *y2,

View File

@ -23,7 +23,7 @@
** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
**
** Initially modified for use with MPlayer by Arpad Gereöffy on 2003/08/30
** $Id: hcr.c,v 1.3 2004/06/02 22:59:03 diego Exp $
** $Id: hcr.c,v 1.4 2004/06/23 13:50:50 diego Exp $
** detailed CVS changelog at http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
**/
@ -144,7 +144,7 @@ typedef struct
#define segmentWidth( codebook ) min( maxCwLen[codebook], ics->length_of_longest_codeword )
uint8_t reordered_spectral_data(faacDecHandle hDecoder, ic_stream *ics, bitfile *ld,
uint8_t reordered_spectral_data(NeAACDecHandle hDecoder, ic_stream *ics, bitfile *ld,
int16_t *spectral_data)
{
uint16_t sp_offset[8];

View File

@ -23,7 +23,7 @@
** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
**
** Initially modified for use with MPlayer by Alex Beregszaszi on 2003/10/03
** $Id: huffman.c,v 1.2 2004/06/02 22:59:03 diego Exp $
** $Id: huffman.c,v 1.3 2004/06/23 13:50:50 diego Exp $
** detailed CVS changelog at http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
**/
@ -122,8 +122,8 @@ static INLINE void huffman_sign_bits(bitfile *ld, int16_t *sp, uint8_t len)
static INLINE int16_t huffman_getescape(bitfile *ld, int16_t sp)
{
uint8_t neg, i;
int32_t j;
int32_t off;
int16_t j;
int16_t off;
if (sp < 0)
{
@ -145,7 +145,7 @@ static INLINE int16_t huffman_getescape(bitfile *ld, int16_t sp)
}
}
off = faad_getbits(ld, i
off = (int16_t)faad_getbits(ld, i
DEBUGVAR(1,9,"huffman_getescape(): escape"));
j = off | (1<<i);

File diff suppressed because it is too large Load Diff

View File

@ -23,7 +23,7 @@
** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
**
** Initially modified for use with MPlayer by Arpad Gereöffy on 2003/08/30
** $Id: is.c,v 1.3 2004/06/02 22:59:03 diego Exp $
** $Id: is.c,v 1.4 2004/06/23 13:50:50 diego Exp $
** detailed CVS changelog at http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
**/
@ -68,12 +68,14 @@ void is_decode(ic_stream *ics, ic_stream *icsr, real_t *l_spec, real_t *r_spec,
{
if (is_intensity(icsr, g, sfb))
{
#ifdef MAIN_DEC
/* For scalefactor bands coded in intensity stereo the
corresponding predictors in the right channel are
switched to "off".
*/
ics->pred.prediction_used[sfb] = 0;
icsr->pred.prediction_used[sfb] = 0;
#endif
#ifndef FIXED_POINT
scale = (real_t)pow(0.5, (0.25*icsr->scale_factors[g][sfb]));

View File

@ -23,7 +23,7 @@
** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
**
** Initially modified for use with MPlayer by Arpad Gereöffy on 2003/08/30
** $Id: mdct.c,v 1.3 2004/06/02 22:59:03 diego Exp $
** $Id: mdct.c,v 1.4 2004/06/23 13:50:51 diego Exp $
** detailed CVS changelog at http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
**/
@ -55,139 +55,40 @@
#include "cfft.h"
#include "mdct.h"
#include "mdct_tab.h"
/* const_tab[]:
0: sqrt(2 / N)
1: cos(2 * PI / N)
2: sin(2 * PI / N)
3: cos(2 * PI * (1/8) / N)
4: sin(2 * PI * (1/8) / N)
*/
#ifdef FIXED_POINT
real_t const_tab[][5] =
{
{ /* 2048 */
COEF_CONST(1),
FRAC_CONST(0.99999529380957619),
FRAC_CONST(0.0030679567629659761),
FRAC_CONST(0.99999992646571789),
FRAC_CONST(0.00038349518757139556)
}, { /* 1920 */
COEF_CONST(/* sqrt(1024/960) */ 1.0327955589886444),
FRAC_CONST(0.99999464540169647),
FRAC_CONST(0.0032724865065266251),
FRAC_CONST(0.99999991633432805),
FRAC_CONST(0.00040906153202803459)
}, { /* 1024 */
COEF_CONST(1),
FRAC_CONST(0.99998117528260111),
FRAC_CONST(0.0061358846491544753),
FRAC_CONST(0.99999970586288223),
FRAC_CONST(0.00076699031874270449)
}, { /* 960 */
COEF_CONST(/* sqrt(512/480) */ 1.0327955589886444),
FRAC_CONST(0.99997858166412923),
FRAC_CONST(0.0065449379673518581),
FRAC_CONST(0.99999966533732598),
FRAC_CONST(0.00081812299560725323)
}, { /* 256 */
COEF_CONST(1),
FRAC_CONST(0.99969881869620425),
FRAC_CONST(0.024541228522912288),
FRAC_CONST(0.99999529380957619),
FRAC_CONST(0.0030679567629659761)
}, { /* 240 */
COEF_CONST(/* sqrt(256/240) */ 1.0327955589886444),
FRAC_CONST(0.99965732497555726),
FRAC_CONST(0.026176948307873149),
FRAC_CONST(0.99999464540169647),
FRAC_CONST(0.0032724865065266251)
}
#ifdef SSR_DEC
,{ /* 512 */
COEF_CONST(1),
FRAC_CONST(0.9999247018391445),
FRAC_CONST(0.012271538285719925),
FRAC_CONST(0.99999882345170188),
FRAC_CONST(0.0015339801862847655)
}, { /* 64 */
COEF_CONST(1),
FRAC_CONST(0.99518472667219693),
FRAC_CONST(0.098017140329560604),
FRAC_CONST(0.9999247018391445),
FRAC_CONST(0.012271538285719925)
}
#endif
};
#endif
#ifdef FIXED_POINT
static uint8_t map_N_to_idx(uint16_t N)
{
/* gives an index into const_tab above */
/* for normal AAC deocding (eg. no scalable profile) only */
/* index 0 and 4 will be used */
switch(N)
{
case 2048: return 0;
case 1920: return 1;
case 1024: return 2;
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;
}
#endif
mdct_info *faad_mdct_init(uint16_t N)
{
uint16_t k;
#ifdef FIXED_POINT
uint16_t N_idx;
real_t cangle, sangle, c, s, cold;
#endif
real_t scale;
mdct_info *mdct = (mdct_info*)faad_malloc(sizeof(mdct_info));
assert(N % 8 == 0);
mdct->N = N;
mdct->sincos = (complex_t*)faad_malloc(N/4*sizeof(complex_t));
#ifdef FIXED_POINT
N_idx = map_N_to_idx(N);
/* NOTE: For "small framelengths" in FIXED_POINT the coefficients need to be
* scaled by sqrt("(nearest power of 2) > N" / N) */
scale = const_tab[N_idx][0];
cangle = const_tab[N_idx][1];
sangle = const_tab[N_idx][2];
c = const_tab[N_idx][3];
s = const_tab[N_idx][4];
#else
scale = (real_t)sqrt(2.0 / (real_t)N);
#endif
/* (co)sine table build using recurrence relations */
/* this can also be done using static table lookup or */
/* some form of interpolation */
for (k = 0; k < N/4; k++)
/* RE(mdct->sincos[k]) = scale*(real_t)(cos(2.0*M_PI*(k+1./8.) / (real_t)N));
* IM(mdct->sincos[k]) = scale*(real_t)(sin(2.0*M_PI*(k+1./8.) / (real_t)N)); */
/* scale is 1 for fixed point, sqrt(N) for floating point */
switch (N)
{
#ifdef FIXED_POINT
RE(mdct->sincos[k]) = c; //MUL_C_C(c,scale);
IM(mdct->sincos[k]) = s; //MUL_C_C(s,scale);
cold = c;
c = MUL_F(c,cangle) - MUL_F(s,sangle);
s = MUL_F(s,cangle) + MUL_F(cold,sangle);
#else
/* no recurrence, just sines */
RE(mdct->sincos[k]) = scale*(real_t)(cos(2.0*M_PI*(k+1./8.) / (real_t)N));
IM(mdct->sincos[k]) = scale*(real_t)(sin(2.0*M_PI*(k+1./8.) / (real_t)N));
case 2048: mdct->sincos = (complex_t*)mdct_tab_2048; break;
case 256: mdct->sincos = (complex_t*)mdct_tab_256; break;
#ifdef LD_DEC
case 1024: mdct->sincos = (complex_t*)mdct_tab_1024; break;
#endif
#ifdef ALLOW_SMALL_FRAMELENGTH
case 1920: mdct->sincos = (complex_t*)mdct_tab_1920; break;
case 240: mdct->sincos = (complex_t*)mdct_tab_240; break;
#ifdef LD_DEC
case 960: mdct->sincos = (complex_t*)mdct_tab_960; break;
#endif
#endif
#ifdef SSR_DEC
case 512: mdct->sincos = (complex_t*)mdct_tab_512; break;
case 64: mdct->sincos = (complex_t*)mdct_tab_64; break;
#endif
}
@ -213,8 +114,6 @@ void faad_mdct_end(mdct_info *mdct)
cfftu(mdct->cfft);
if (mdct->sincos) faad_free(mdct->sincos);
faad_free(mdct);
}
}
@ -224,6 +123,11 @@ void faad_imdct(mdct_info *mdct, real_t *X_in, real_t *X_out)
uint16_t k;
complex_t x;
#ifdef ALLOW_SMALL_FRAMELENGTH
#ifdef FIXED_POINT
real_t scale, b_scale = 0;
#endif
#endif
ALIGN complex_t Z1[512];
complex_t *sincos = mdct->sincos;
@ -236,6 +140,19 @@ void faad_imdct(mdct_info *mdct, real_t *X_in, real_t *X_out)
int64_t count1, count2 = faad_get_ts();
#endif
#ifdef ALLOW_SMALL_FRAMELENGTH
#ifdef FIXED_POINT
/* detect non-power of 2 */
if (N & (N-1))
{
/* adjust scale for non-power of 2 MDCT */
/* 2048/1920 */
b_scale = 1;
scale = COEF_CONST(1.0666666666666667);
}
#endif
#endif
/* pre-IFFT complex multiplication */
for (k = 0; k < N4; k++)
{
@ -261,6 +178,17 @@ void faad_imdct(mdct_info *mdct, real_t *X_in, real_t *X_out)
IM(x) = IM(Z1[k]);
ComplexMult(&IM(Z1[k]), &RE(Z1[k]),
IM(x), RE(x), RE(sincos[k]), IM(sincos[k]));
#ifdef ALLOW_SMALL_FRAMELENGTH
#ifdef FIXED_POINT
/* non-power of 2 MDCT scaling */
if (b_scale)
{
RE(Z1[k]) = MUL_C(RE(Z1[k]), scale);
IM(Z1[k]) = MUL_C(IM(Z1[k]), scale);
}
#endif
#endif
}
/* reordering */
@ -298,166 +226,6 @@ void faad_imdct(mdct_info *mdct, real_t *X_in, real_t *X_out)
#endif
}
#ifdef USE_SSE
void faad_imdct_sse(mdct_info *mdct, real_t *X_in, real_t *X_out)
{
uint16_t k;
ALIGN complex_t Z1[512];
complex_t *sincos = mdct->sincos;
uint16_t N = mdct->N;
uint16_t N2 = N >> 1;
uint16_t N4 = N >> 2;
uint16_t N8 = N >> 3;
#ifdef PROFILE
int64_t count1, count2 = faad_get_ts();
#endif
/* pre-IFFT complex multiplication */
for (k = 0; k < N4; k+=4)
{
__m128 m12, m13, m14, m0, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11;
__m128 n12, n13, n14, n0, n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11;
n12 = _mm_load_ps(&X_in[N2 - 2*k - 8]);
m12 = _mm_load_ps(&X_in[N2 - 2*k - 4]);
m13 = _mm_load_ps(&X_in[2*k]);
n13 = _mm_load_ps(&X_in[2*k + 4]);
m1 = _mm_load_ps(&RE(sincos[k]));
n1 = _mm_load_ps(&RE(sincos[k+2]));
m0 = _mm_shuffle_ps(m12, m13, _MM_SHUFFLE(2,0,1,3));
m2 = _mm_shuffle_ps(m1, m1, _MM_SHUFFLE(2,3,0,1));
m14 = _mm_shuffle_ps(m0, m0, _MM_SHUFFLE(3,1,2,0));
n0 = _mm_shuffle_ps(n12, n13, _MM_SHUFFLE(2,0,1,3));
n2 = _mm_shuffle_ps(n1, n1, _MM_SHUFFLE(2,3,0,1));
n14 = _mm_shuffle_ps(n0, n0, _MM_SHUFFLE(3,1,2,0));
m3 = _mm_mul_ps(m14, m1);
n3 = _mm_mul_ps(n14, n1);
m4 = _mm_mul_ps(m14, m2);
n4 = _mm_mul_ps(n14, n2);
m5 = _mm_shuffle_ps(m3, m4, _MM_SHUFFLE(2,0,2,0));
n5 = _mm_shuffle_ps(n3, n4, _MM_SHUFFLE(2,0,2,0));
m6 = _mm_shuffle_ps(m3, m4, _MM_SHUFFLE(3,1,3,1));
n6 = _mm_shuffle_ps(n3, n4, _MM_SHUFFLE(3,1,3,1));
m7 = _mm_add_ps(m5, m6);
n7 = _mm_add_ps(n5, n6);
m8 = _mm_sub_ps(m5, m6);
n8 = _mm_sub_ps(n5, n6);
m9 = _mm_shuffle_ps(m7, m7, _MM_SHUFFLE(3,2,3,2));
n9 = _mm_shuffle_ps(n7, n7, _MM_SHUFFLE(3,2,3,2));
m10 = _mm_shuffle_ps(m8, m8, _MM_SHUFFLE(1,0,1,0));
n10 = _mm_shuffle_ps(n8, n8, _MM_SHUFFLE(1,0,1,0));
m11 = _mm_unpacklo_ps(m10, m9);
n11 = _mm_unpacklo_ps(n10, n9);
_mm_store_ps(&RE(Z1[k]), m11);
_mm_store_ps(&RE(Z1[k+2]), n11);
}
#ifdef PROFILE
count1 = faad_get_ts();
#endif
/* complex IFFT, any non-scaling FFT can be used here */
cfftb_sse(mdct->cfft, Z1);
#ifdef PROFILE
count1 = faad_get_ts() - count1;
#endif
/* post-IFFT complex multiplication */
for (k = 0; k < N4; k+=4)
{
__m128 m0, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11;
__m128 n0, n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11;
m0 = _mm_load_ps(&RE(Z1[k]));
n0 = _mm_load_ps(&RE(Z1[k+2]));
m1 = _mm_load_ps(&RE(sincos[k]));
n1 = _mm_load_ps(&RE(sincos[k+2]));
m2 = _mm_shuffle_ps(m1, m1, _MM_SHUFFLE(2,3,0,1));
n2 = _mm_shuffle_ps(n1, n1, _MM_SHUFFLE(2,3,0,1));
m3 = _mm_mul_ps(m0, m1);
n3 = _mm_mul_ps(n0, n1);
m4 = _mm_mul_ps(m0, m2);
n4 = _mm_mul_ps(n0, n2);
m5 = _mm_shuffle_ps(m3, m4, _MM_SHUFFLE(2,0,2,0));
n5 = _mm_shuffle_ps(n3, n4, _MM_SHUFFLE(2,0,2,0));
m6 = _mm_shuffle_ps(m3, m4, _MM_SHUFFLE(3,1,3,1));
n6 = _mm_shuffle_ps(n3, n4, _MM_SHUFFLE(3,1,3,1));
m7 = _mm_add_ps(m5, m6);
n7 = _mm_add_ps(n5, n6);
m8 = _mm_sub_ps(m5, m6);
n8 = _mm_sub_ps(n5, n6);
m9 = _mm_shuffle_ps(m7, m7, _MM_SHUFFLE(3,2,3,2));
n9 = _mm_shuffle_ps(n7, n7, _MM_SHUFFLE(3,2,3,2));
m10 = _mm_shuffle_ps(m8, m8, _MM_SHUFFLE(1,0,1,0));
n10 = _mm_shuffle_ps(n8, n8, _MM_SHUFFLE(1,0,1,0));
m11 = _mm_unpacklo_ps(m10, m9);
n11 = _mm_unpacklo_ps(n10, n9);
_mm_store_ps(&RE(Z1[k]), m11);
_mm_store_ps(&RE(Z1[k+2]), n11);
}
/* reordering */
for (k = 0; k < N8; k+=2)
{
__m128 m0, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m13;
__m128 n4, n5, n6, n7, n8, n9;
__m128 neg1 = _mm_set_ps(-1.0, 1.0, -1.0, 1.0);
__m128 neg2 = _mm_set_ps(-1.0, -1.0, -1.0, -1.0);
m0 = _mm_load_ps(&RE(Z1[k]));
m1 = _mm_load_ps(&RE(Z1[N8 - 2 - k]));
m2 = _mm_load_ps(&RE(Z1[N8 + k]));
m3 = _mm_load_ps(&RE(Z1[N4 - 2 - k]));
m10 = _mm_mul_ps(m0, neg1);
m11 = _mm_mul_ps(m1, neg2);
m13 = _mm_mul_ps(m3, neg1);
m5 = _mm_shuffle_ps(m2, m2, _MM_SHUFFLE(3,1,2,0));
n4 = _mm_shuffle_ps(m10, m10, _MM_SHUFFLE(3,1,2,0));
m4 = _mm_shuffle_ps(m11, m11, _MM_SHUFFLE(3,1,2,0));
n5 = _mm_shuffle_ps(m13, m13, _MM_SHUFFLE(3,1,2,0));
m6 = _mm_shuffle_ps(m4, m5, _MM_SHUFFLE(3,2,1,0));
n6 = _mm_shuffle_ps(n4, n5, _MM_SHUFFLE(3,2,1,0));
m7 = _mm_shuffle_ps(m5, m4, _MM_SHUFFLE(3,2,1,0));
n7 = _mm_shuffle_ps(n5, n4, _MM_SHUFFLE(3,2,1,0));
m8 = _mm_shuffle_ps(m6, m6, _MM_SHUFFLE(0,3,1,2));
n8 = _mm_shuffle_ps(n6, n6, _MM_SHUFFLE(2,1,3,0));
m9 = _mm_shuffle_ps(m7, m7, _MM_SHUFFLE(2,1,3,0));
n9 = _mm_shuffle_ps(n7, n7, _MM_SHUFFLE(0,3,1,2));
_mm_store_ps(&X_out[2*k], m8);
_mm_store_ps(&X_out[N4 + 2*k], n8);
_mm_store_ps(&X_out[N2 + 2*k], m9);
_mm_store_ps(&X_out[N2 + N4 + 2*k], n9);
}
#ifdef PROFILE
count2 = faad_get_ts() - count2;
mdct->fft_cycles += count1;
mdct->cycles += (count2 - count1);
#endif
}
#endif
#ifdef LTP_DEC
void faad_mdct(mdct_info *mdct, real_t *X_in, real_t *X_out)
{
@ -478,6 +246,18 @@ void faad_mdct(mdct_info *mdct, real_t *X_in, real_t *X_out)
real_t scale = REAL_CONST(4.0/N);
#endif
#ifdef ALLOW_SMALL_FRAMELENGTH
#ifdef FIXED_POINT
/* detect non-power of 2 */
if (N & (N-1))
{
/* adjust scale for non-power of 2 MDCT */
/* *= sqrt(2048/1920) */
scale = MUL_C(scale, COEF_CONST(1.0327955589886444));
}
#endif
#endif
/* pre-FFT complex multiplication */
for (k = 0; k < N8; k++)
{

3653
libfaad2/mdct_tab.h Normal file

File diff suppressed because it is too large Load Diff

View File

@ -23,7 +23,7 @@
** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
**
** Initially modified for use with MPlayer by Arpad Gereöffy on 2003/08/30
** $Id: mp4.c,v 1.3 2004/06/02 22:59:03 diego Exp $
** $Id: mp4.c,v 1.4 2004/06/23 13:50:51 diego Exp $
** detailed CVS changelog at http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
**/
@ -121,17 +121,17 @@ static uint8_t ObjectTypesTable[32] = {
};
/* Table 1.6.1 */
int8_t FAADAPI AudioSpecificConfig(uint8_t *pBuffer,
uint32_t buffer_size,
mp4AudioSpecificConfig *mp4ASC)
int8_t NEAACDECAPI NeAACDecAudioSpecificConfig(uint8_t *pBuffer,
uint32_t buffer_size,
mp4AudioSpecificConfig *mp4ASC)
{
return AudioSpecificConfig2(pBuffer, buffer_size, mp4ASC, NULL);
}
int8_t FAADAPI AudioSpecificConfig2(uint8_t *pBuffer,
uint32_t buffer_size,
mp4AudioSpecificConfig *mp4ASC,
program_config *pce)
int8_t AudioSpecificConfig2(uint8_t *pBuffer,
uint32_t buffer_size,
mp4AudioSpecificConfig *mp4ASC,
program_config *pce)
{
bitfile ld;
int8_t result = 0;
@ -178,13 +178,28 @@ int8_t FAADAPI AudioSpecificConfig2(uint8_t *pBuffer,
return -3;
}
#if (defined(PS_DEC) || defined(DRM_PS))
/* check if we have a mono file */
if (mp4ASC->channelsConfiguration == 1)
{
/* upMatrix to 2 channels for implicit signalling of PS */
mp4ASC->channelsConfiguration = 2;
}
#endif
#ifdef SBR_DEC
mp4ASC->sbr_present_flag = -1;
if (mp4ASC->objectTypeIndex == 5)
{
uint8_t tmp;
mp4ASC->sbr_present_flag = 1;
mp4ASC->samplingFrequencyIndex = (uint8_t)faad_getbits(&ld, 4
tmp = (uint8_t)faad_getbits(&ld, 4
DEBUGVAR(1,5,"parse_audio_decoder_specific_info(): extensionSamplingFrequencyIndex"));
/* check for downsampled SBR */
if (tmp == mp4ASC->samplingFrequencyIndex)
mp4ASC->downSampledSBR = 1;
mp4ASC->samplingFrequencyIndex = tmp;
if (mp4ASC->samplingFrequencyIndex == 15)
{
mp4ASC->samplingFrequency = (uint32_t)faad_getbits(&ld, 24
@ -245,8 +260,15 @@ int8_t FAADAPI AudioSpecificConfig2(uint8_t *pBuffer,
if (mp4ASC->sbr_present_flag)
{
mp4ASC->samplingFrequencyIndex = (uint8_t)faad_getbits(&ld, 4
uint8_t tmp;
tmp = (uint8_t)faad_getbits(&ld, 4
DEBUGVAR(1,12,"parse_audio_decoder_specific_info(): extensionSamplingFrequencyIndex"));
/* check for downsampled SBR */
if (tmp == mp4ASC->samplingFrequencyIndex)
mp4ASC->downSampledSBR = 1;
mp4ASC->samplingFrequencyIndex = tmp;
if (mp4ASC->samplingFrequencyIndex == 15)
{
mp4ASC->samplingFrequency = (uint32_t)faad_getbits(&ld, 24
@ -267,6 +289,8 @@ int8_t FAADAPI AudioSpecificConfig2(uint8_t *pBuffer,
{
mp4ASC->samplingFrequency *= 2;
mp4ASC->forceUpSampling = 1;
} else /* > 24000*/ {
mp4ASC->downSampledSBR = 1;
}
}
#endif

View File

@ -23,7 +23,7 @@
** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
**
** Initially modified for use with MPlayer by Arpad Gereöffy on 2003/08/30
** $Id: mp4.h,v 1.3 2004/06/02 22:59:03 diego Exp $
** $Id: mp4.h,v 1.4 2004/06/23 13:50:51 diego Exp $
** detailed CVS changelog at http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
**/
@ -36,14 +36,14 @@ extern "C" {
#include "decoder.h"
int8_t FAADAPI AudioSpecificConfig(uint8_t *pBuffer,
uint32_t buffer_size,
mp4AudioSpecificConfig *mp4ASC);
int8_t NEAACDECAPI NeAACDecAudioSpecificConfig(uint8_t *pBuffer,
uint32_t buffer_size,
mp4AudioSpecificConfig *mp4ASC);
int8_t FAADAPI AudioSpecificConfig2(uint8_t *pBuffer,
uint32_t buffer_size,
mp4AudioSpecificConfig *mp4ASC,
program_config *pce);
int8_t AudioSpecificConfig2(uint8_t *pBuffer,
uint32_t buffer_size,
mp4AudioSpecificConfig *mp4ASC,
program_config *pce);
#ifdef __cplusplus
}

243
libfaad2/neaacdec.h Normal file
View File

@ -0,0 +1,243 @@
/*
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** 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.
**
** Any non-GPL usage of this software or parts of this software is strictly
** forbidden.
**
** Commercial non-GPL licensing of this software is possible.
** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
**
** Initially modified for use with MPlayer by Diego Biurrun on 2004/09/24
** detailed CVS changelog at http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
**/
#ifndef __NEAACDEC_H__
#define __NEAACDEC_H__
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#if 1
/* MACROS FOR BACKWARDS COMPATIBILITY */
/* structs */
#define faacDecHandle NeAACDecHandle
#define faacDecConfiguration NeAACDecConfiguration
#define faacDecConfigurationPtr NeAACDecConfigurationPtr
#define faacDecFrameInfo NeAACDecFrameInfo
/* functions */
#define faacDecGetErrorMessage NeAACDecGetErrorMessage
#define faacDecSetConfiguration NeAACDecSetConfiguration
#define faacDecGetCurrentConfiguration NeAACDecGetCurrentConfiguration
#define faacDecInit NeAACDecInit
#define faacDecInit2 NeAACDecInit2
#define faacDecInitDRM NeAACDecInitDRM
#define faacDecPostSeekReset NeAACDecPostSeekReset
#define faacDecOpen NeAACDecOpen
#define faacDecClose NeAACDecClose
#define faacDecDecode NeAACDecDecode
#define AudioSpecificConfig NeAACDecAudioSpecificConfig
#endif
#ifdef _WIN32
#pragma pack(push, 8)
#ifndef NEAACDECAPI
#define NEAACDECAPI __cdecl
#endif
#else
#ifndef NEAACDECAPI
#define NEAACDECAPI
#endif
#endif
#define FAAD2_VERSION "2.1 beta"
/* object types for AAC */
#define MAIN 1
#define LC 2
#define SSR 3
#define LTP 4
#define HE_AAC 5
#define ER_LC 17
#define ER_LTP 19
#define LD 23
#define DRM_ER_LC 27 /* special object type for DRM */
/* header types */
#define RAW 0
#define ADIF 1
#define ADTS 2
/* SBR signalling */
#define NO_SBR 0
#define SBR_UPSAMPLED 1
#define SBR_DOWNSAMPLED 2
#define NO_SBR_UPSAMPLED 3
/* library output formats */
#define FAAD_FMT_16BIT 1
#define FAAD_FMT_24BIT 2
#define FAAD_FMT_32BIT 3
#define FAAD_FMT_FLOAT 4
#define FAAD_FMT_FIXED FAAD_FMT_FLOAT
#define FAAD_FMT_DOUBLE 5
/* Capabilities */
#define LC_DEC_CAP (1<<0) /* Can decode LC */
#define MAIN_DEC_CAP (1<<1) /* Can decode MAIN */
#define LTP_DEC_CAP (1<<2) /* Can decode LTP */
#define LD_DEC_CAP (1<<3) /* Can decode LD */
#define ERROR_RESILIENCE_CAP (1<<4) /* Can decode ER */
#define FIXED_POINT_CAP (1<<5) /* Fixed point */
/* Channel definitions */
#define FRONT_CHANNEL_CENTER (1)
#define FRONT_CHANNEL_LEFT (2)
#define FRONT_CHANNEL_RIGHT (3)
#define SIDE_CHANNEL_LEFT (4)
#define SIDE_CHANNEL_RIGHT (5)
#define BACK_CHANNEL_LEFT (6)
#define BACK_CHANNEL_RIGHT (7)
#define BACK_CHANNEL_CENTER (8)
#define LFE_CHANNEL (9)
#define UNKNOWN_CHANNEL (0)
/* DRM channel definitions */
#define DRMCH_MONO 1
#define DRMCH_STEREO 2
#define DRMCH_SBR_MONO 3
#define DRMCH_SBR_STEREO 4
#define DRMCH_SBR_PS_STEREO 5
/* A decode call can eat up to FAAD_MIN_STREAMSIZE bytes per decoded channel,
so at least so much bytes per channel should be available in this stream */
#define FAAD_MIN_STREAMSIZE 768 /* 6144 bits/channel */
typedef void *NeAACDecHandle;
typedef struct mp4AudioSpecificConfig
{
/* Audio Specific Info */
unsigned char objectTypeIndex;
unsigned char samplingFrequencyIndex;
unsigned long samplingFrequency;
unsigned char channelsConfiguration;
/* GA Specific Info */
unsigned char frameLengthFlag;
unsigned char dependsOnCoreCoder;
unsigned short coreCoderDelay;
unsigned char extensionFlag;
unsigned char aacSectionDataResilienceFlag;
unsigned char aacScalefactorDataResilienceFlag;
unsigned char aacSpectralDataResilienceFlag;
unsigned char epConfig;
char sbr_present_flag;
char forceUpSampling;
char downSampledSBR;
} mp4AudioSpecificConfig;
typedef struct NeAACDecConfiguration
{
unsigned char defObjectType;
unsigned long defSampleRate;
unsigned char outputFormat;
unsigned char downMatrix;
unsigned char useOldADTSFormat;
unsigned char dontUpSampleImplicitSBR;
} NeAACDecConfiguration, *NeAACDecConfigurationPtr;
typedef struct NeAACDecFrameInfo
{
unsigned long bytesconsumed;
unsigned long samples;
unsigned char channels;
unsigned char error;
unsigned long samplerate;
/* SBR: 0: off, 1: on; upsample, 2: on; downsampled, 3: off; upsampled */
unsigned char sbr;
/* MPEG-4 ObjectType */
unsigned char object_type;
/* AAC header type; MP4 will be signalled as RAW also */
unsigned char header_type;
/* multichannel configuration */
unsigned char num_front_channels;
unsigned char num_side_channels;
unsigned char num_back_channels;
unsigned char num_lfe_channels;
unsigned char channel_position[64];
} NeAACDecFrameInfo;
char* NEAACDECAPI NeAACDecGetErrorMessage(unsigned char errcode);
unsigned long NEAACDECAPI NeAACDecGetCapabilities(void);
NeAACDecHandle NEAACDECAPI NeAACDecOpen(void);
NeAACDecConfigurationPtr NEAACDECAPI NeAACDecGetCurrentConfiguration(NeAACDecHandle hDecoder);
unsigned char NEAACDECAPI NeAACDecSetConfiguration(NeAACDecHandle hDecoder,
NeAACDecConfigurationPtr config);
/* Init the library based on info from the AAC file (ADTS/ADIF) */
long NEAACDECAPI NeAACDecInit(NeAACDecHandle hDecoder,
unsigned char *buffer,
unsigned long buffer_size,
unsigned long *samplerate,
unsigned char *channels);
/* Init the library using a DecoderSpecificInfo */
char NEAACDECAPI NeAACDecInit2(NeAACDecHandle hDecoder, unsigned char *pBuffer,
unsigned long SizeOfDecoderSpecificInfo,
unsigned long *samplerate, unsigned char *channels);
/* Init the library for DRM */
char NEAACDECAPI NeAACDecInitDRM(NeAACDecHandle *hDecoder, unsigned long samplerate,
unsigned char channels);
void NEAACDECAPI NeAACDecPostSeekReset(NeAACDecHandle hDecoder, long frame);
void NEAACDECAPI NeAACDecClose(NeAACDecHandle hDecoder);
void* NEAACDECAPI NeAACDecDecode(NeAACDecHandle hDecoder,
NeAACDecFrameInfo *hInfo,
unsigned char *buffer,
unsigned long buffer_size);
char NEAACDECAPI NeAACDecAudioSpecificConfig(unsigned char *pBuffer,
unsigned long buffer_size,
mp4AudioSpecificConfig *mp4ASC);
#ifdef _WIN32
#pragma pack(pop)
#endif
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif

View File

@ -86,7 +86,7 @@ if (sample >= 0.0f) \
#define CONV(a,b) ((a<<1)|(b&0x1))
static void to_PCM_16bit(faacDecHandle hDecoder, real_t **input,
static void to_PCM_16bit(NeAACDecHandle hDecoder, real_t **input,
uint8_t channels, uint16_t frame_len,
int16_t **sample_buffer)
{
@ -107,18 +107,32 @@ static void to_PCM_16bit(faacDecHandle hDecoder, real_t **input,
}
break;
case CONV(2,0):
ch = hDecoder->internal_channel[0];
ch1 = hDecoder->internal_channel[1];
for(i = 0; i < frame_len; i++)
if (hDecoder->upMatrix)
{
real_t inp0 = input[ch ][i];
real_t inp1 = input[ch1][i];
ch = hDecoder->internal_channel[0];
for(i = 0; i < frame_len; i++)
{
real_t inp0 = input[ch][i];
CLIP(inp0, 32767.0f, -32768.0f);
CLIP(inp1, 32767.0f, -32768.0f);
CLIP(inp0, 32767.0f, -32768.0f);
(*sample_buffer)[(i*2)+0] = (int16_t)lrintf(inp0);
(*sample_buffer)[(i*2)+1] = (int16_t)lrintf(inp1);
(*sample_buffer)[(i*2)+0] = (int16_t)lrintf(inp0);
(*sample_buffer)[(i*2)+1] = (int16_t)lrintf(inp0);
}
} else {
ch = hDecoder->internal_channel[0];
ch1 = hDecoder->internal_channel[1];
for(i = 0; i < frame_len; i++)
{
real_t inp0 = input[ch ][i];
real_t inp1 = input[ch1][i];
CLIP(inp0, 32767.0f, -32768.0f);
CLIP(inp1, 32767.0f, -32768.0f);
(*sample_buffer)[(i*2)+0] = (int16_t)lrintf(inp0);
(*sample_buffer)[(i*2)+1] = (int16_t)lrintf(inp1);
}
}
break;
default:
@ -137,7 +151,7 @@ static void to_PCM_16bit(faacDecHandle hDecoder, real_t **input,
}
}
static void to_PCM_24bit(faacDecHandle hDecoder, real_t **input,
static void to_PCM_24bit(NeAACDecHandle hDecoder, real_t **input,
uint8_t channels, uint16_t frame_len,
int32_t **sample_buffer)
{
@ -159,20 +173,35 @@ static void to_PCM_24bit(faacDecHandle hDecoder, real_t **input,
}
break;
case CONV(2,0):
ch = hDecoder->internal_channel[0];
ch1 = hDecoder->internal_channel[1];
for(i = 0; i < frame_len; i++)
if (hDecoder->upMatrix)
{
real_t inp0 = input[ch ][i];
real_t inp1 = input[ch1][i];
ch = hDecoder->internal_channel[0];
for(i = 0; i < frame_len; i++)
{
real_t inp0 = input[ch][i];
inp0 *= 256.0f;
inp1 *= 256.0f;
CLIP(inp0, 8388607.0f, -8388608.0f);
CLIP(inp1, 8388607.0f, -8388608.0f);
inp0 *= 256.0f;
CLIP(inp0, 8388607.0f, -8388608.0f);
(*sample_buffer)[(i*2)+0] = (int32_t)lrintf(inp0);
(*sample_buffer)[(i*2)+1] = (int32_t)lrintf(inp1);
(*sample_buffer)[(i*2)+0] = (int32_t)lrintf(inp0);
(*sample_buffer)[(i*2)+1] = (int32_t)lrintf(inp0);
}
} else {
ch = hDecoder->internal_channel[0];
ch1 = hDecoder->internal_channel[1];
for(i = 0; i < frame_len; i++)
{
real_t inp0 = input[ch ][i];
real_t inp1 = input[ch1][i];
inp0 *= 256.0f;
inp1 *= 256.0f;
CLIP(inp0, 8388607.0f, -8388608.0f);
CLIP(inp1, 8388607.0f, -8388608.0f);
(*sample_buffer)[(i*2)+0] = (int32_t)lrintf(inp0);
(*sample_buffer)[(i*2)+1] = (int32_t)lrintf(inp1);
}
}
break;
default:
@ -192,7 +221,7 @@ static void to_PCM_24bit(faacDecHandle hDecoder, real_t **input,
}
}
static void to_PCM_32bit(faacDecHandle hDecoder, real_t **input,
static void to_PCM_32bit(NeAACDecHandle hDecoder, real_t **input,
uint8_t channels, uint16_t frame_len,
int32_t **sample_buffer)
{
@ -214,20 +243,35 @@ static void to_PCM_32bit(faacDecHandle hDecoder, real_t **input,
}
break;
case CONV(2,0):
ch = hDecoder->internal_channel[0];
ch1 = hDecoder->internal_channel[1];
for(i = 0; i < frame_len; i++)
if (hDecoder->upMatrix)
{
real_t inp0 = input[ch ][i];
real_t inp1 = input[ch1][i];
ch = hDecoder->internal_channel[0];
for(i = 0; i < frame_len; i++)
{
real_t inp0 = input[ch][i];
inp0 *= 65536.0f;
inp1 *= 65536.0f;
CLIP(inp0, 2147483647.0f, -2147483648.0f);
CLIP(inp1, 2147483647.0f, -2147483648.0f);
inp0 *= 65536.0f;
CLIP(inp0, 2147483647.0f, -2147483648.0f);
(*sample_buffer)[(i*2)+0] = (int32_t)lrintf(inp0);
(*sample_buffer)[(i*2)+1] = (int32_t)lrintf(inp1);
(*sample_buffer)[(i*2)+0] = (int32_t)lrintf(inp0);
(*sample_buffer)[(i*2)+1] = (int32_t)lrintf(inp0);
}
} else {
ch = hDecoder->internal_channel[0];
ch1 = hDecoder->internal_channel[1];
for(i = 0; i < frame_len; i++)
{
real_t inp0 = input[ch ][i];
real_t inp1 = input[ch1][i];
inp0 *= 65536.0f;
inp1 *= 65536.0f;
CLIP(inp0, 2147483647.0f, -2147483648.0f);
CLIP(inp1, 2147483647.0f, -2147483648.0f);
(*sample_buffer)[(i*2)+0] = (int32_t)lrintf(inp0);
(*sample_buffer)[(i*2)+1] = (int32_t)lrintf(inp1);
}
}
break;
default:
@ -247,7 +291,7 @@ static void to_PCM_32bit(faacDecHandle hDecoder, real_t **input,
}
}
static void to_PCM_float(faacDecHandle hDecoder, real_t **input,
static void to_PCM_float(NeAACDecHandle hDecoder, real_t **input,
uint8_t channels, uint16_t frame_len,
float32_t **sample_buffer)
{
@ -265,14 +309,25 @@ static void to_PCM_float(faacDecHandle hDecoder, real_t **input,
}
break;
case CONV(2,0):
ch = hDecoder->internal_channel[0];
ch1 = hDecoder->internal_channel[1];
for(i = 0; i < frame_len; i++)
if (hDecoder->upMatrix)
{
real_t inp0 = input[ch ][i];
real_t inp1 = input[ch1][i];
(*sample_buffer)[(i*2)+0] = inp0*FLOAT_SCALE;
(*sample_buffer)[(i*2)+1] = inp1*FLOAT_SCALE;
ch = hDecoder->internal_channel[0];
for(i = 0; i < frame_len; i++)
{
real_t inp0 = input[ch][i];
(*sample_buffer)[(i*2)+0] = inp0*FLOAT_SCALE;
(*sample_buffer)[(i*2)+1] = inp0*FLOAT_SCALE;
}
} else {
ch = hDecoder->internal_channel[0];
ch1 = hDecoder->internal_channel[1];
for(i = 0; i < frame_len; i++)
{
real_t inp0 = input[ch ][i];
real_t inp1 = input[ch1][i];
(*sample_buffer)[(i*2)+0] = inp0*FLOAT_SCALE;
(*sample_buffer)[(i*2)+1] = inp1*FLOAT_SCALE;
}
}
break;
default:
@ -288,7 +343,7 @@ static void to_PCM_float(faacDecHandle hDecoder, real_t **input,
}
}
static void to_PCM_double(faacDecHandle hDecoder, real_t **input,
static void to_PCM_double(NeAACDecHandle hDecoder, real_t **input,
uint8_t channels, uint16_t frame_len,
double **sample_buffer)
{
@ -306,14 +361,25 @@ static void to_PCM_double(faacDecHandle hDecoder, real_t **input,
}
break;
case CONV(2,0):
ch = hDecoder->internal_channel[0];
ch1 = hDecoder->internal_channel[1];
for(i = 0; i < frame_len; i++)
if (hDecoder->upMatrix)
{
real_t inp0 = input[ch ][i];
real_t inp1 = input[ch1][i];
(*sample_buffer)[(i*2)+0] = (double)inp0*FLOAT_SCALE;
(*sample_buffer)[(i*2)+1] = (double)inp1*FLOAT_SCALE;
ch = hDecoder->internal_channel[0];
for(i = 0; i < frame_len; i++)
{
real_t inp0 = input[ch][i];
(*sample_buffer)[(i*2)+0] = (double)inp0*FLOAT_SCALE;
(*sample_buffer)[(i*2)+1] = (double)inp0*FLOAT_SCALE;
}
} else {
ch = hDecoder->internal_channel[0];
ch1 = hDecoder->internal_channel[1];
for(i = 0; i < frame_len; i++)
{
real_t inp0 = input[ch ][i];
real_t inp1 = input[ch1][i];
(*sample_buffer)[(i*2)+0] = (double)inp0*FLOAT_SCALE;
(*sample_buffer)[(i*2)+1] = (double)inp1*FLOAT_SCALE;
}
}
break;
default:
@ -329,7 +395,7 @@ static void to_PCM_double(faacDecHandle hDecoder, real_t **input,
}
}
void *output_to_PCM(faacDecHandle hDecoder,
void *output_to_PCM(NeAACDecHandle hDecoder,
real_t **input, void *sample_buffer, uint8_t channels,
uint16_t frame_len, uint8_t format)
{
@ -376,8 +442,12 @@ void *output_to_PCM(faacDecHandle hDecoder,
#define RSQRT2 FRAC_CONST(0.7071067811865475244) // 1/sqrt(2)
static INLINE real_t get_sample(real_t **input, uint8_t channel, uint16_t sample,
uint8_t down_matrix, uint8_t *internal_channel)
uint8_t down_matrix, uint8_t up_matrix,
uint8_t *internal_channel)
{
if (up_matrix == 1)
return input[internal_channel[0]][sample];
if (!down_matrix)
return input[internal_channel[channel]][sample];
@ -395,7 +465,7 @@ static INLINE real_t get_sample(real_t **input, uint8_t channel, uint16_t sample
}
}
void* output_to_PCM(faacDecHandle hDecoder,
void* output_to_PCM(NeAACDecHandle hDecoder,
real_t **input, void *sample_buffer, uint8_t channels,
uint16_t frame_len, uint8_t format)
{
@ -412,8 +482,8 @@ void* output_to_PCM(faacDecHandle hDecoder,
case FAAD_FMT_16BIT:
for(i = 0; i < frame_len; i++)
{
//int32_t tmp = input[ch][i];
int32_t tmp = get_sample(input, ch, i, hDecoder->downMatrix, hDecoder->internal_channel);
int32_t tmp = get_sample(input, ch, i, hDecoder->downMatrix, hDecoder->upMatrix,
hDecoder->internal_channel);
if (tmp >= 0)
{
tmp += (1 << (REAL_BITS-1));
@ -435,8 +505,8 @@ void* output_to_PCM(faacDecHandle hDecoder,
case FAAD_FMT_24BIT:
for(i = 0; i < frame_len; i++)
{
//int32_t tmp = input[ch][i];
int32_t tmp = get_sample(input, ch, i, hDecoder->downMatrix, hDecoder->internal_channel);
int32_t tmp = get_sample(input, ch, i, hDecoder->downMatrix, hDecoder->upMatrix,
hDecoder->internal_channel);
if (tmp >= 0)
{
tmp += (1 << (REAL_BITS-9));
@ -459,8 +529,8 @@ void* output_to_PCM(faacDecHandle hDecoder,
case FAAD_FMT_32BIT:
for(i = 0; i < frame_len; i++)
{
//int32_t tmp = input[ch][i];
int32_t tmp = get_sample(input, ch, i, hDecoder->downMatrix, hDecoder->internal_channel);
int32_t tmp = get_sample(input, ch, i, hDecoder->downMatrix, hDecoder->upMatrix,
hDecoder->internal_channel);
if (tmp >= 0)
{
tmp += (1 << (16-REAL_BITS-1));
@ -472,6 +542,14 @@ void* output_to_PCM(faacDecHandle hDecoder,
int_sample_buffer[(i*channels)+ch] = (int32_t)tmp;
}
break;
case FAAD_FMT_FIXED:
for(i = 0; i < frame_len; i++)
{
real_t tmp = get_sample(input, ch, i, hDecoder->downMatrix, hDecoder->upMatrix,
hDecoder->internal_channel);
int_sample_buffer[(i*channels)+ch] = (int32_t)tmp;
}
break;
}
}

View File

@ -23,7 +23,7 @@
** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
**
** Initially modified for use with MPlayer by Arpad Gereöffy on 2003/08/30
** $Id: output.h,v 1.3 2004/06/02 22:59:03 diego Exp $
** $Id: output.h,v 1.4 2004/06/23 13:50:51 diego Exp $
** detailed CVS changelog at http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
**/
@ -34,7 +34,7 @@
extern "C" {
#endif
void* output_to_PCM(faacDecHandle hDecoder,
void* output_to_PCM(NeAACDecHandle hDecoder,
real_t **input,
void *samplebuffer,
uint8_t channels,

View File

@ -23,7 +23,7 @@
** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
**
** Initially modified for use with MPlayer by Arpad Gereöffy on 2003/08/30
** $Id: pns.c,v 1.3 2004/06/02 22:59:03 diego Exp $
** $Id: pns.c,v 1.4 2004/06/23 13:50:51 diego Exp $
** detailed CVS changelog at http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
**/
@ -72,9 +72,6 @@ real_t fp_sqrt(real_t value)
static real_t pow2_table[] =
{
COEF_CONST(0.59460355750136),
COEF_CONST(0.70710678118655),
COEF_CONST(0.84089641525371),
COEF_CONST(1.0),
COEF_CONST(1.18920711500272),
COEF_CONST(1.41421356237310),
@ -133,8 +130,8 @@ static INLINE void gen_rand_vector(real_t *spec, int16_t scale_factor, uint16_t
{
scale = DIV(REAL_CONST(1),energy);
exp = scale_factor / 4;
frac = scale_factor % 4;
exp = scale_factor >> 2;
frac = scale_factor & 3;
/* IMDCT pre-scaling */
exp -= sub;
@ -145,7 +142,7 @@ static INLINE void gen_rand_vector(real_t *spec, int16_t scale_factor, uint16_t
scale <<= exp;
if (frac)
scale = MUL_C(scale, pow2_table[frac + 3]);
scale = MUL_C(scale, pow2_table[frac]);
for (i = 0; i < size; i++)
{
@ -189,6 +186,7 @@ void pns_decode(ic_stream *ics_left, ic_stream *ics_right,
{
if (is_noise(ics_left, g, sfb))
{
#ifdef LTP_DEC
/* Simultaneous use of LTP and PNS is not prevented in the
syntax. If both LTP, and PNS are enabled on the same
scalefactor band, PNS takes precedence, and no prediction
@ -196,11 +194,14 @@ void pns_decode(ic_stream *ics_left, ic_stream *ics_right,
*/
ics_left->ltp.long_used[sfb] = 0;
ics_left->ltp2.long_used[sfb] = 0;
#endif
#ifdef MAIN_DEC
/* For scalefactor bands coded using PNS the corresponding
predictors are switched to "off".
*/
ics_left->pred.prediction_used[sfb] = 0;
#endif
offs = ics_left->swb_offset[sfb];
size = ics_left->swb_offset[sfb+1] - offs;
@ -242,9 +243,13 @@ void pns_decode(ic_stream *ics_left, ic_stream *ics_right,
spec_left[(group*nshort) + offs + c];
}
} else /*if (ics_left->ms_mask_present == 0)*/ {
#ifdef LTP_DEC
ics_right->ltp.long_used[sfb] = 0;
ics_right->ltp2.long_used[sfb] = 0;
#endif
#ifdef MAIN_DEC
ics_right->pred.prediction_used[sfb] = 0;
#endif
offs = ics_right->swb_offset[sfb];
size = ics_right->swb_offset[sfb+1] - offs;

View File

@ -23,7 +23,7 @@
** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
**
** Initially modified for use with MPlayer by Arpad Gereöffy on 2003/08/30
** $Id: pns.h,v 1.3 2004/06/02 22:59:03 diego Exp $
** $Id: pns.h,v 1.4 2004/06/23 13:50:51 diego Exp $
** detailed CVS changelog at http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
**/
@ -34,8 +34,6 @@
extern "C" {
#endif
#include "common.h"
#include "syntax.h"
#define NOISE_OFFSET 90

1986
libfaad2/ps_dec.c Normal file

File diff suppressed because it is too large Load Diff

146
libfaad2/ps_dec.h Normal file
View File

@ -0,0 +1,146 @@
/*
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** 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.
**
** Any non-GPL usage of this software or parts of this software is strictly
** forbidden.
**
** Commercial non-GPL licensing of this software is possible.
** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
**
** Initially modified for use with MPlayer by Diego Biurrun on 2004/09/24
** detailed CVS changelog at http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
**/
#ifndef __PS_DEC_H__
#define __PS_DEC_H__
#ifdef __cplusplus
extern "C" {
#endif
#include "bits.h"
#define EXTENSION_ID_PS 2
#define MAX_PS_ENVELOPES 5
#define NO_ALLPASS_LINKS 3
typedef struct
{
/* bitstream parameters */
uint8_t enable_iid;
uint8_t enable_icc;
uint8_t enable_ext;
uint8_t iid_mode;
uint8_t icc_mode;
uint8_t nr_iid_par;
uint8_t nr_ipdopd_par;
uint8_t nr_icc_par;
uint8_t frame_class;
uint8_t num_env;
uint8_t border_position[MAX_PS_ENVELOPES+1];
uint8_t iid_dt[MAX_PS_ENVELOPES];
uint8_t icc_dt[MAX_PS_ENVELOPES];
uint8_t enable_ipdopd;
uint8_t ipd_mode;
uint8_t ipd_dt[MAX_PS_ENVELOPES];
uint8_t opd_dt[MAX_PS_ENVELOPES];
/* indices */
int8_t iid_index_prev[34];
int8_t icc_index_prev[34];
int8_t ipd_index_prev[17];
int8_t opd_index_prev[17];
int8_t iid_index[MAX_PS_ENVELOPES][34];
int8_t icc_index[MAX_PS_ENVELOPES][34];
int8_t ipd_index[MAX_PS_ENVELOPES][17];
int8_t opd_index[MAX_PS_ENVELOPES][17];
int8_t ipd_index_1[17];
int8_t opd_index_1[17];
int8_t ipd_index_2[17];
int8_t opd_index_2[17];
/* ps data was correctly read */
uint8_t ps_data_available;
/* hybrid filterbank parameters */
void *hyb;
uint8_t use34hybrid_bands;
/**/
uint8_t num_groups;
uint8_t num_hybrid_groups;
uint8_t nr_par_bands;
uint8_t nr_allpass_bands;
uint8_t decay_cutoff;
uint8_t *group_border;
uint16_t *map_group2bk;
/* filter delay handling */
uint8_t saved_delay;
uint8_t delay_buf_index_ser[NO_ALLPASS_LINKS];
uint8_t num_sample_delay_ser[NO_ALLPASS_LINKS];
uint8_t delay_D[64];
uint8_t delay_buf_index_delay[64];
complex_t delay_Qmf[14][64]; /* 14 samples delay max, 64 QMF channels */
complex_t delay_SubQmf[2][32]; /* 2 samples delay max (SubQmf is always allpass filtered) */
complex_t delay_Qmf_ser[NO_ALLPASS_LINKS][5][64]; /* 5 samples delay max (table 8.34), 64 QMF channels */
complex_t delay_SubQmf_ser[NO_ALLPASS_LINKS][5][32]; /* 5 samples delay max (table 8.34) */
/* transients */
real_t alpha_decay;
real_t alpha_smooth;
real_t P_PeakDecayNrg[34];
real_t P_prev[34];
real_t P_SmoothPeakDecayDiffNrg_prev[34];
/* mixing and phase */
complex_t h11_prev[50];
complex_t h12_prev[50];
complex_t h21_prev[50];
complex_t h22_prev[50];
uint8_t phase_hist;
complex_t ipd_prev[20][2];
complex_t opd_prev[20][2];
} ps_info;
/* ps_syntax.c */
uint16_t ps_data(ps_info *ps, bitfile *ld);
/* ps_dec.c */
ps_info *ps_init(uint8_t sr_index);
void ps_free(ps_info *ps);
uint8_t ps_decode(ps_info *ps, qmf_t X_left[38][64], qmf_t X_right[38][64]);
#ifdef __cplusplus
}
#endif
#endif

536
libfaad2/ps_syntax.c Normal file
View File

@ -0,0 +1,536 @@
/*
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR and PS decoding
** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** 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.
**
** Any non-GPL usage of this software or parts of this software is strictly
** forbidden.
**
** Commercial non-GPL licensing of this software is possible.
** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
**
** Initially modified for use with MPlayer by Diego Biurrun on 2004/09/24
** detailed CVS changelog at http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
**/
#include "common.h"
#ifdef PS_DEC
#include "bits.h"
#include "ps_dec.h"
/* type definitaions */
typedef const int8_t (*ps_huff_tab)[2];
/* static data tables */
static const uint8_t nr_iid_par_tab[] = {
10, 20, 34, 10, 20, 34, 0, 0
};
static const uint8_t nr_ipdopd_par_tab[] = {
5, 11, 17, 5, 11, 17, 0, 0
};
static const uint8_t nr_icc_par_tab[] = {
10, 20, 34, 10, 20, 34, 0, 0
};
static const uint8_t num_env_tab[][4] = {
{ 0, 1, 2, 4 },
{ 1, 2, 3, 4 }
};
/* binary lookup huffman tables */
static const int8_t f_huff_iid_def[][2] = {
{ /*0*/ -31, 1 }, /* index 0: 1 bits: x */
{ 2, 3 }, /* index 1: 2 bits: 1x */
{ /*1*/ -30, /*-1*/ -32 }, /* index 2: 3 bits: 10x */
{ 4, 5 }, /* index 3: 3 bits: 11x */
{ /*2*/ -29, /*-2*/ -33 }, /* index 4: 4 bits: 110x */
{ 6, 7 }, /* index 5: 4 bits: 111x */
{ /*3*/ -28, /*-3*/ -34 }, /* index 6: 5 bits: 1110x */
{ 8, 9 }, /* index 7: 5 bits: 1111x */
{ /*-4*/ -35, /*4*/ -27 }, /* index 8: 6 bits: 11110x */
{ /*5*/ -26, 10 }, /* index 9: 6 bits: 11111x */
{ /*-5*/ -36, 11 }, /* index 10: 7 bits: 111111x */
{ /*6*/ -25, 12 }, /* index 11: 8 bits: 1111111x */
{ /*-6*/ -37, 13 }, /* index 12: 9 bits: 11111111x */
{ /*-7*/ -38, 14 }, /* index 13: 10 bits: 111111111x */
{ /*7*/ -24, 15 }, /* index 14: 11 bits: 1111111111x */
{ 16, 17 }, /* index 15: 12 bits: 11111111111x */
{ /*8*/ -23, /*-8*/ -39 }, /* index 16: 13 bits: 111111111110x */
{ 18, 19 }, /* index 17: 13 bits: 111111111111x */
{ /*9*/ -22, /*10*/ -21 }, /* index 18: 14 bits: 1111111111110x */
{ 20, 21 }, /* index 19: 14 bits: 1111111111111x */
{ /*-9*/ -40, /*11*/ -20 }, /* index 20: 15 bits: 11111111111110x */
{ 22, 23 }, /* index 21: 15 bits: 11111111111111x */
{ /*-10*/ -41, 24 }, /* index 22: 16 bits: 111111111111110x */
{ 25, 26 }, /* index 23: 16 bits: 111111111111111x */
{ /*-11*/ -42, /*-14*/ -45 }, /* index 24: 17 bits: 1111111111111101x */
{ /*-13*/ -44, /*-12*/ -43 }, /* index 25: 17 bits: 1111111111111110x */
{ /*12*/ -19, 27 }, /* index 26: 17 bits: 1111111111111111x */
{ /*13*/ -18, /*14*/ -17 } /* index 27: 18 bits: 11111111111111111x */
};
static const int8_t t_huff_iid_def[][2] = {
{ /*0*/ -31, 1 }, /* index 0: 1 bits: x */
{ /*-1*/ -32, 2 }, /* index 1: 2 bits: 1x */
{ /*1*/ -30, 3 }, /* index 2: 3 bits: 11x */
{ /*-2*/ -33, 4 }, /* index 3: 4 bits: 111x */
{ /*2*/ -29, 5 }, /* index 4: 5 bits: 1111x */
{ /*-3*/ -34, 6 }, /* index 5: 6 bits: 11111x */
{ /*3*/ -28, 7 }, /* index 6: 7 bits: 111111x */
{ /*-4*/ -35, 8 }, /* index 7: 8 bits: 1111111x */
{ /*4*/ -27, 9 }, /* index 8: 9 bits: 11111111x */
{ /*-5*/ -36, 10 }, /* index 9: 10 bits: 111111111x */
{ /*5*/ -26, 11 }, /* index 10: 11 bits: 1111111111x */
{ /*-6*/ -37, 12 }, /* index 11: 12 bits: 11111111111x */
{ /*6*/ -25, 13 }, /* index 12: 13 bits: 111111111111x */
{ /*7*/ -24, 14 }, /* index 13: 14 bits: 1111111111111x */
{ /*-7*/ -38, 15 }, /* index 14: 15 bits: 11111111111111x */
{ 16, 17 }, /* index 15: 16 bits: 111111111111111x */
{ /*8*/ -23, /*-8*/ -39 }, /* index 16: 17 bits: 1111111111111110x */
{ 18, 19 }, /* index 17: 17 bits: 1111111111111111x */
{ 20, 21 }, /* index 18: 18 bits: 11111111111111110x */
{ 22, 23 }, /* index 19: 18 bits: 11111111111111111x */
{ /*9*/ -22, /*-14*/ -45 }, /* index 20: 19 bits: 111111111111111100x */
{ /*-13*/ -44, /*-12*/ -43 }, /* index 21: 19 bits: 111111111111111101x */
{ 24, 25 }, /* index 22: 19 bits: 111111111111111110x */
{ 26, 27 }, /* index 23: 19 bits: 111111111111111111x */
{ /*-11*/ -42, /*-10*/ -41 }, /* index 24: 20 bits: 1111111111111111100x */
{ /*-9*/ -40, /*10*/ -21 }, /* index 25: 20 bits: 1111111111111111101x */
{ /*11*/ -20, /*12*/ -19 }, /* index 26: 20 bits: 1111111111111111110x */
{ /*13*/ -18, /*14*/ -17 } /* index 27: 20 bits: 1111111111111111111x */
};
static const int8_t f_huff_iid_fine[][2] = {
{ 1, /*0*/ -31 }, /* index 0: 1 bits: x */
{ 2, 3 }, /* index 1: 2 bits: 0x */
{ 4, /*-1*/ -32 }, /* index 2: 3 bits: 00x */
{ /*1*/ -30, 5 }, /* index 3: 3 bits: 01x */
{ /*-2*/ -33, /*2*/ -29 }, /* index 4: 4 bits: 000x */
{ 6, 7 }, /* index 5: 4 bits: 011x */
{ /*-3*/ -34, /*3*/ -28 }, /* index 6: 5 bits: 0110x */
{ 8, 9 }, /* index 7: 5 bits: 0111x */
{ /*-4*/ -35, /*4*/ -27 }, /* index 8: 6 bits: 01110x */
{ 10, 11 }, /* index 9: 6 bits: 01111x */
{ /*-5*/ -36, /*5*/ -26 }, /* index 10: 7 bits: 011110x */
{ 12, 13 }, /* index 11: 7 bits: 011111x */
{ /*-6*/ -37, /*6*/ -25 }, /* index 12: 8 bits: 0111110x */
{ 14, 15 }, /* index 13: 8 bits: 0111111x */
{ /*7*/ -24, 16 }, /* index 14: 9 bits: 01111110x */
{ 17, 18 }, /* index 15: 9 bits: 01111111x */
{ 19, /*-8*/ -39 }, /* index 16: 10 bits: 011111101x */
{ /*8*/ -23, 20 }, /* index 17: 10 bits: 011111110x */
{ 21, /*-7*/ -38 }, /* index 18: 10 bits: 011111111x */
{ /*10*/ -21, 22 }, /* index 19: 11 bits: 0111111010x */
{ 23, /*-9*/ -40 }, /* index 20: 11 bits: 0111111101x */
{ /*9*/ -22, 24 }, /* index 21: 11 bits: 0111111110x */
{ /*-11*/ -42, /*11*/ -20 }, /* index 22: 12 bits: 01111110101x */
{ 25, 26 }, /* index 23: 12 bits: 01111111010x */
{ 27, /*-10*/ -41 }, /* index 24: 12 bits: 01111111101x */
{ 28, /*-12*/ -43 }, /* index 25: 13 bits: 011111110100x */
{ /*12*/ -19, 29 }, /* index 26: 13 bits: 011111110101x */
{ 30, 31 }, /* index 27: 13 bits: 011111111010x */
{ 32, /*-14*/ -45 }, /* index 28: 14 bits: 0111111101000x */
{ /*14*/ -17, 33 }, /* index 29: 14 bits: 0111111101011x */
{ 34, /*-13*/ -44 }, /* index 30: 14 bits: 0111111110100x */
{ /*13*/ -18, 35 }, /* index 31: 14 bits: 0111111110101x */
{ 36, 37 }, /* index 32: 15 bits: 01111111010000x */
{ 38, /*-15*/ -46 }, /* index 33: 15 bits: 01111111010111x */
{ /*15*/ -16, 39 }, /* index 34: 15 bits: 01111111101000x */
{ 40, 41 }, /* index 35: 15 bits: 01111111101011x */
{ 42, 43 }, /* index 36: 16 bits: 011111110100000x */
{ /*-17*/ -48, /*17*/ -14 }, /* index 37: 16 bits: 011111110100001x */
{ 44, 45 }, /* index 38: 16 bits: 011111110101110x */
{ 46, 47 }, /* index 39: 16 bits: 011111111010001x */
{ 48, 49 }, /* index 40: 16 bits: 011111111010110x */
{ /*-16*/ -47, /*16*/ -15 }, /* index 41: 16 bits: 011111111010111x */
{ /*-21*/ -52, /*21*/ -10 }, /* index 42: 17 bits: 0111111101000000x */
{ /*-19*/ -50, /*19*/ -12 }, /* index 43: 17 bits: 0111111101000001x */
{ /*-18*/ -49, /*18*/ -13 }, /* index 44: 17 bits: 0111111101011100x */
{ 50, 51 }, /* index 45: 17 bits: 0111111101011101x */
{ 52, 53 }, /* index 46: 17 bits: 0111111110100010x */
{ 54, 55 }, /* index 47: 17 bits: 0111111110100011x */
{ 56, 57 }, /* index 48: 17 bits: 0111111110101100x */
{ 58, 59 }, /* index 49: 17 bits: 0111111110101101x */
{ /*-26*/ -57, /*-25*/ -56 }, /* index 50: 18 bits: 01111111010111010x */
{ /*-28*/ -59, /*-27*/ -58 }, /* index 51: 18 bits: 01111111010111011x */
{ /*-22*/ -53, /*22*/ -9 }, /* index 52: 18 bits: 01111111101000100x */
{ /*-24*/ -55, /*-23*/ -54 }, /* index 53: 18 bits: 01111111101000101x */
{ /*25*/ -6, /*26*/ -5 }, /* index 54: 18 bits: 01111111101000110x */
{ /*23*/ -8, /*24*/ -7 }, /* index 55: 18 bits: 01111111101000111x */
{ /*29*/ -2, /*30*/ -1 }, /* index 56: 18 bits: 01111111101011000x */
{ /*27*/ -4, /*28*/ -3 }, /* index 57: 18 bits: 01111111101011001x */
{ /*-30*/ -61, /*-29*/ -60 }, /* index 58: 18 bits: 01111111101011010x */
{ /*-20*/ -51, /*20*/ -11 } /* index 59: 18 bits: 01111111101011011x */
};
static const int8_t t_huff_iid_fine[][2] = {
{ 1, /*0*/ -31 }, /* index 0: 1 bits: x */
{ /*1*/ -30, 2 }, /* index 1: 2 bits: 0x */
{ 3, /*-1*/ -32 }, /* index 2: 3 bits: 01x */
{ 4, 5 }, /* index 3: 4 bits: 010x */
{ 6, 7 }, /* index 4: 5 bits: 0100x */
{ /*-2*/ -33, /*2*/ -29 }, /* index 5: 5 bits: 0101x */
{ 8, /*-3*/ -34 }, /* index 6: 6 bits: 01000x */
{ /*3*/ -28, 9 }, /* index 7: 6 bits: 01001x */
{ /*-4*/ -35, /*4*/ -27 }, /* index 8: 7 bits: 010000x */
{ 10, 11 }, /* index 9: 7 bits: 010011x */
{ /*5*/ -26, 12 }, /* index 10: 8 bits: 0100110x */
{ 13, 14 }, /* index 11: 8 bits: 0100111x */
{ /*-6*/ -37, /*6*/ -25 }, /* index 12: 9 bits: 01001101x */
{ 15, 16 }, /* index 13: 9 bits: 01001110x */
{ 17, /*-5*/ -36 }, /* index 14: 9 bits: 01001111x */
{ 18, /*-7*/ -38 }, /* index 15: 10 bits: 010011100x */
{ /*7*/ -24, 19 }, /* index 16: 10 bits: 010011101x */
{ 20, 21 }, /* index 17: 10 bits: 010011110x */
{ /*9*/ -22, 22 }, /* index 18: 11 bits: 0100111000x */
{ 23, 24 }, /* index 19: 11 bits: 0100111011x */
{ /*-8*/ -39, /*8*/ -23 }, /* index 20: 11 bits: 0100111100x */
{ 25, 26 }, /* index 21: 11 bits: 0100111101x */
{ /*11*/ -20, 27 }, /* index 22: 12 bits: 01001110001x */
{ 28, 29 }, /* index 23: 12 bits: 01001110110x */
{ /*-10*/ -41, /*10*/ -21 }, /* index 24: 12 bits: 01001110111x */
{ 30, 31 }, /* index 25: 12 bits: 01001111010x */
{ 32, /*-9*/ -40 }, /* index 26: 12 bits: 01001111011x */
{ 33, /*-13*/ -44 }, /* index 27: 13 bits: 010011100011x */
{ /*13*/ -18, 34 }, /* index 28: 13 bits: 010011101100x */
{ 35, 36 }, /* index 29: 13 bits: 010011101101x */
{ 37, /*-12*/ -43 }, /* index 30: 13 bits: 010011110100x */
{ /*12*/ -19, 38 }, /* index 31: 13 bits: 010011110101x */
{ 39, /*-11*/ -42 }, /* index 32: 13 bits: 010011110110x */
{ 40, 41 }, /* index 33: 14 bits: 0100111000110x */
{ 42, 43 }, /* index 34: 14 bits: 0100111011001x */
{ 44, 45 }, /* index 35: 14 bits: 0100111011010x */
{ 46, /*-15*/ -46 }, /* index 36: 14 bits: 0100111011011x */
{ /*15*/ -16, 47 }, /* index 37: 14 bits: 0100111101000x */
{ /*-14*/ -45, /*14*/ -17 }, /* index 38: 14 bits: 0100111101011x */
{ 48, 49 }, /* index 39: 14 bits: 0100111101100x */
{ /*-21*/ -52, /*-20*/ -51 }, /* index 40: 15 bits: 01001110001100x */
{ /*18*/ -13, /*19*/ -12 }, /* index 41: 15 bits: 01001110001101x */
{ /*-19*/ -50, /*-18*/ -49 }, /* index 42: 15 bits: 01001110110010x */
{ 50, 51 }, /* index 43: 15 bits: 01001110110011x */
{ 52, 53 }, /* index 44: 15 bits: 01001110110100x */
{ 54, 55 }, /* index 45: 15 bits: 01001110110101x */
{ 56, /*-17*/ -48 }, /* index 46: 15 bits: 01001110110110x */
{ /*17*/ -14, 57 }, /* index 47: 15 bits: 01001111010001x */
{ 58, /*-16*/ -47 }, /* index 48: 15 bits: 01001111011000x */
{ /*16*/ -15, 59 }, /* index 49: 15 bits: 01001111011001x */
{ /*-26*/ -57, /*26*/ -5 }, /* index 50: 16 bits: 010011101100110x */
{ /*-28*/ -59, /*-27*/ -58 }, /* index 51: 16 bits: 010011101100111x */
{ /*29*/ -2, /*30*/ -1 }, /* index 52: 16 bits: 010011101101000x */
{ /*27*/ -4, /*28*/ -3 }, /* index 53: 16 bits: 010011101101001x */
{ /*-30*/ -61, /*-29*/ -60 }, /* index 54: 16 bits: 010011101101010x */
{ /*-25*/ -56, /*25*/ -6 }, /* index 55: 16 bits: 010011101101011x */
{ /*-24*/ -55, /*24*/ -7 }, /* index 56: 16 bits: 010011101101100x */
{ /*-23*/ -54, /*23*/ -8 }, /* index 57: 16 bits: 010011110100011x */
{ /*-22*/ -53, /*22*/ -9 }, /* index 58: 16 bits: 010011110110000x */
{ /*20*/ -11, /*21*/ -10 } /* index 59: 16 bits: 010011110110011x */
};
static const int8_t f_huff_icc[][2] = {
{ /*0*/ -31, 1 }, /* index 0: 1 bits: x */
{ /*1*/ -30, 2 }, /* index 1: 2 bits: 1x */
{ /*-1*/ -32, 3 }, /* index 2: 3 bits: 11x */
{ /*2*/ -29, 4 }, /* index 3: 4 bits: 111x */
{ /*-2*/ -33, 5 }, /* index 4: 5 bits: 1111x */
{ /*3*/ -28, 6 }, /* index 5: 6 bits: 11111x */
{ /*-3*/ -34, 7 }, /* index 6: 7 bits: 111111x */
{ /*4*/ -27, 8 }, /* index 7: 8 bits: 1111111x */
{ /*5*/ -26, 9 }, /* index 8: 9 bits: 11111111x */
{ /*-4*/ -35, 10 }, /* index 9: 10 bits: 111111111x */
{ /*6*/ -25, 11 }, /* index 10: 11 bits: 1111111111x */
{ /*-5*/ -36, 12 }, /* index 11: 12 bits: 11111111111x */
{ /*7*/ -24, 13 }, /* index 12: 13 bits: 111111111111x */
{ /*-6*/ -37, /*-7*/ -38 } /* index 13: 14 bits: 1111111111111x */
};
static const int8_t t_huff_icc[][2] = {
{ /*0*/ -31, 1 }, /* index 0: 1 bits: x */
{ /*1*/ -30, 2 }, /* index 1: 2 bits: 1x */
{ /*-1*/ -32, 3 }, /* index 2: 3 bits: 11x */
{ /*2*/ -29, 4 }, /* index 3: 4 bits: 111x */
{ /*-2*/ -33, 5 }, /* index 4: 5 bits: 1111x */
{ /*3*/ -28, 6 }, /* index 5: 6 bits: 11111x */
{ /*-3*/ -34, 7 }, /* index 6: 7 bits: 111111x */
{ /*4*/ -27, 8 }, /* index 7: 8 bits: 1111111x */
{ /*-4*/ -35, 9 }, /* index 8: 9 bits: 11111111x */
{ /*5*/ -26, 10 }, /* index 9: 10 bits: 111111111x */
{ /*-5*/ -36, 11 }, /* index 10: 11 bits: 1111111111x */
{ /*6*/ -25, 12 }, /* index 11: 12 bits: 11111111111x */
{ /*-6*/ -37, 13 }, /* index 12: 13 bits: 111111111111x */
{ /*-7*/ -38, /*7*/ -24 } /* index 13: 14 bits: 1111111111111x */
};
static const int8_t f_huff_ipd[][2] = {
{ 1, /*0*/ -31 }, /* index 0: 1 bits: x */
{ 2, 3 }, /* index 1: 2 bits: 0x */
{ /*1*/ -30, 4 }, /* index 2: 3 bits: 00x */
{ 5, 6 }, /* index 3: 3 bits: 01x */
{ /*4*/ -27, /*5*/ -26 }, /* index 4: 4 bits: 001x */
{ /*3*/ -28, /*6*/ -25 }, /* index 5: 4 bits: 010x */
{ /*2*/ -29, /*7*/ -24 } /* index 6: 4 bits: 011x */
};
static const int8_t t_huff_ipd[][2] = {
{ 1, /*0*/ -31 }, /* index 0: 1 bits: x */
{ 2, 3 }, /* index 1: 2 bits: 0x */
{ 4, 5 }, /* index 2: 3 bits: 00x */
{ /*1*/ -30, /*7*/ -24 }, /* index 3: 3 bits: 01x */
{ /*5*/ -26, 6 }, /* index 4: 4 bits: 000x */
{ /*2*/ -29, /*6*/ -25 }, /* index 5: 4 bits: 001x */
{ /*4*/ -27, /*3*/ -28 } /* index 6: 5 bits: 0001x */
};
static const int8_t f_huff_opd[][2] = {
{ 1, /*0*/ -31 }, /* index 0: 1 bits: x */
{ 2, 3 }, /* index 1: 2 bits: 0x */
{ /*7*/ -24, /*1*/ -30 }, /* index 2: 3 bits: 00x */
{ 4, 5 }, /* index 3: 3 bits: 01x */
{ /*3*/ -28, /*6*/ -25 }, /* index 4: 4 bits: 010x */
{ /*2*/ -29, 6 }, /* index 5: 4 bits: 011x */
{ /*5*/ -26, /*4*/ -27 } /* index 6: 5 bits: 0111x */
};
static const int8_t t_huff_opd[][2] = {
{ 1, /*0*/ -31 }, /* index 0: 1 bits: x */
{ 2, 3 }, /* index 1: 2 bits: 0x */
{ 4, 5 }, /* index 2: 3 bits: 00x */
{ /*1*/ -30, /*7*/ -24 }, /* index 3: 3 bits: 01x */
{ /*5*/ -26, 6 }, /* index 4: 4 bits: 000x */
{ /*2*/ -29, /*6*/ -25 }, /* index 5: 4 bits: 001x */
{ /*4*/ -27, /*3*/ -28 } /* index 6: 5 bits: 0001x */
};
/* static function declarations */
static uint16_t ps_extension(ps_info *ps, bitfile *ld,
const uint8_t ps_extension_id,
const uint16_t num_bits_left);
static void huff_data(bitfile *ld, const uint8_t dt, const uint8_t nr_par,
ps_huff_tab t_huff, ps_huff_tab f_huff, int8_t *par);
static INLINE int8_t ps_huff_dec(bitfile *ld, ps_huff_tab t_huff);
uint16_t ps_data(ps_info *ps, bitfile *ld)
{
uint8_t tmp, n;
uint16_t bits = (uint16_t)faad_get_processed_bits(ld);
/* check for new PS header */
if (faad_get1bit(ld
DEBUGVAR(1,1000,"ps_data(): enable_ps_header")))
{
ps->use34hybrid_bands = 0;
/* Inter-channel Intensity Difference (IID) parameters enabled */
ps->enable_iid = (uint8_t)faad_get1bit(ld
DEBUGVAR(1,1001,"ps_data(): enable_iid"));
if (ps->enable_iid)
{
ps->iid_mode = (uint8_t)faad_getbits(ld, 3
DEBUGVAR(1,1002,"ps_data(): iid_mode"));
ps->nr_iid_par = nr_iid_par_tab[ps->iid_mode];
ps->nr_ipdopd_par = nr_ipdopd_par_tab[ps->iid_mode];
if (ps->iid_mode == 2 || ps->iid_mode == 5)
ps->use34hybrid_bands = 1;
/* IPD freq res equal to IID freq res */
ps->ipd_mode = ps->iid_mode;
}
/* Inter-channel Coherence (ICC) parameters enabled */
ps->enable_icc = (uint8_t)faad_get1bit(ld
DEBUGVAR(1,1003,"ps_data(): enable_icc"));
if (ps->enable_icc)
{
ps->icc_mode = (uint8_t)faad_getbits(ld, 3
DEBUGVAR(1,1004,"ps_data(): icc_mode"));
ps->nr_icc_par = nr_icc_par_tab[ps->icc_mode];
if (ps->icc_mode == 2 || ps->icc_mode == 5)
ps->use34hybrid_bands = 1;
}
/* PS extension layer enabled */
ps->enable_ext = (uint8_t)faad_get1bit(ld
DEBUGVAR(1,1005,"ps_data(): enable_ext"));
}
ps->frame_class = (uint8_t)faad_get1bit(ld
DEBUGVAR(1,1006,"ps_data(): frame_class"));
tmp = (uint8_t)faad_getbits(ld, 2
DEBUGVAR(1,1007,"ps_data(): num_env_idx"));
ps->num_env = num_env_tab[ps->frame_class][tmp];
if (ps->frame_class)
{
for (n = 1; n < ps->num_env+1; n++)
{
ps->border_position[n] = (uint8_t)faad_getbits(ld, 5
DEBUGVAR(1,1008,"ps_data(): border_position"));
}
}
if (ps->enable_iid)
{
for (n = 0; n < ps->num_env; n++)
{
ps->iid_dt[n] = (uint8_t)faad_get1bit(ld
DEBUGVAR(1,1009,"ps_data(): iid_dt"));
/* iid_data */
if (ps->iid_mode < 3)
{
huff_data(ld, ps->iid_dt[n], ps->nr_iid_par, t_huff_iid_def,
f_huff_iid_def, ps->iid_index[n]);
} else {
huff_data(ld, ps->iid_dt[n], ps->nr_iid_par, t_huff_iid_fine,
f_huff_iid_fine, ps->iid_index[n]);
}
}
}
if (ps->enable_icc)
{
for (n = 0; n < ps->num_env; n++)
{
ps->icc_dt[n] = (uint8_t)faad_get1bit(ld
DEBUGVAR(1,1010,"ps_data(): icc_dt"));
/* icc_data */
huff_data(ld, ps->icc_dt[n], ps->nr_icc_par, t_huff_icc,
f_huff_icc, ps->icc_index[n]);
}
}
if (ps->enable_ext)
{
uint16_t num_bits_left;
uint16_t cnt = (uint16_t)faad_getbits(ld, 4
DEBUGVAR(1,1011,"ps_data(): ps_extension_size"));
if (cnt == 15)
{
cnt += (uint16_t)faad_getbits(ld, 8
DEBUGVAR(1,1012,"ps_data(): esc_count"));
}
num_bits_left = 8 * cnt;
while (num_bits_left > 7)
{
uint8_t ps_extension_id = (uint8_t)faad_getbits(ld, 2
DEBUGVAR(1,1013,"ps_data(): ps_extension_size"));
num_bits_left -= 2;
num_bits_left -= ps_extension(ps, ld, ps_extension_id, num_bits_left);
}
faad_getbits(ld, num_bits_left
DEBUGVAR(1,1014,"ps_data(): fill_bits"));
}
bits = (uint16_t)faad_get_processed_bits(ld) - bits;
ps->ps_data_available = 1;
return bits;
}
static uint16_t ps_extension(ps_info *ps, bitfile *ld,
const uint8_t ps_extension_id,
const uint16_t num_bits_left)
{
uint8_t n;
uint16_t bits = (uint16_t)faad_get_processed_bits(ld);
if (ps_extension_id == 0)
{
ps->enable_ipdopd = (uint8_t)faad_get1bit(ld
DEBUGVAR(1,1015,"ps_extension(): enable_ipdopd"));
if (ps->enable_ipdopd)
{
for (n = 0; n < ps->num_env; n++)
{
ps->ipd_dt[n] = (uint8_t)faad_get1bit(ld
DEBUGVAR(1,1016,"ps_extension(): ipd_dt"));
/* ipd_data */
huff_data(ld, ps->ipd_dt[n], ps->nr_ipdopd_par, t_huff_ipd,
f_huff_ipd, ps->ipd_index[n]);
ps->opd_dt[n] = (uint8_t)faad_get1bit(ld
DEBUGVAR(1,1017,"ps_extension(): opd_dt"));
/* opd_data */
huff_data(ld, ps->opd_dt[n], ps->nr_ipdopd_par, t_huff_opd,
f_huff_opd, ps->opd_index[n]);
}
}
faad_get1bit(ld
DEBUGVAR(1,1018,"ps_extension(): reserved_ps"));
}
/* return number of bits read */
bits = (uint16_t)faad_get_processed_bits(ld) - bits;
return bits;
}
/* read huffman data coded in either the frequency or the time direction */
static void huff_data(bitfile *ld, const uint8_t dt, const uint8_t nr_par,
ps_huff_tab t_huff, ps_huff_tab f_huff, int8_t *par)
{
uint8_t n;
if (dt)
{
/* coded in time direction */
for (n = 0; n < nr_par; n++)
{
par[n] = ps_huff_dec(ld, t_huff);
}
} else {
/* coded in frequency direction */
par[0] = ps_huff_dec(ld, f_huff);
for (n = 1; n < nr_par; n++)
{
par[n] = ps_huff_dec(ld, f_huff);
}
}
}
/* binary search huffman decoding */
static INLINE int8_t ps_huff_dec(bitfile *ld, ps_huff_tab t_huff)
{
uint8_t bit;
int16_t index = 0;
while (index >= 0)
{
bit = (uint8_t)faad_get1bit(ld);
index = t_huff[index][bit];
}
return index + 31;
}
#endif

548
libfaad2/ps_tables.h Normal file
View File

@ -0,0 +1,548 @@
/*
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** 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.
**
** Any non-GPL usage of this software or parts of this software is strictly
** forbidden.
**
** Commercial non-GPL licensing of this software is possible.
** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
**
** Initially modified for use with MPlayer by Diego Biurrun on 2004/09/24
** detailed CVS changelog at http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
**/
#ifndef __PS_TABLES_H__
#define __PS_TABLES_H__
#ifdef __cplusplus
extern "C" {
#endif
#ifdef _MSC_VER
#pragma warning(disable:4305)
#pragma warning(disable:4244)
#endif
#if 0
#if 0
float f_center_20[12] = {
0.5/4, 1.5/4, 2.5/4, 3.5/4,
4.5/4*0, 5.5/4*0, -1.5/4, -0.5/4,
3.5/2, 2.5/2, 4.5/2, 5.5/2
};
#else
float f_center_20[12] = {
0.5/8, 1.5/8, 2.5/8, 3.5/8,
4.5/8*0, 5.5/8*0, -1.5/8, -0.5/8,
3.5/4, 2.5/4, 4.5/4, 5.5/4
};
#endif
float f_center_34[32] = {
1/12, 3/12, 5/12, 7/12,
9/12, 11/12, 13/12, 15/12,
17/12, -5/12, -3/12, -1/12,
17/8, 19/8, 5/8, 7/8,
9/8, 11/8, 13/8, 15/8,
9/4, 11/4, 13/4, 7/4,
17/4, 11/4, 13/4, 15/4,
17/4, 19/4, 21/4, 15/4
};
static const real_t frac_delay_q[] = {
FRAC_CONST(0.43),
FRAC_CONST(0.75),
FRAC_CONST(0.347)
};
#endif
/* RE(ps->Phi_Fract_Qmf[j]) = (float)cos(M_PI*(j+0.5)*(0.39)); */
/* IM(ps->Phi_Fract_Qmf[j]) = (float)sin(M_PI*(j+0.5)*(0.39)); */
static const complex_t Phi_Fract_Qmf[] = {
{ FRAC_CONST(0.8181497455), FRAC_CONST(0.5750052333) },
{ FRAC_CONST(-0.2638730407), FRAC_CONST(0.9645574093) },
{ FRAC_CONST(-0.9969173074), FRAC_CONST(0.0784590989) },
{ FRAC_CONST(-0.4115143716), FRAC_CONST(-0.9114032984) },
{ FRAC_CONST(0.7181262970), FRAC_CONST(-0.6959127784) },
{ FRAC_CONST(0.8980275989), FRAC_CONST(0.4399391711) },
{ FRAC_CONST(-0.1097343117), FRAC_CONST(0.9939609766) },
{ FRAC_CONST(-0.9723699093), FRAC_CONST(0.2334453613) },
{ FRAC_CONST(-0.5490227938), FRAC_CONST(-0.8358073831) },
{ FRAC_CONST(0.6004202366), FRAC_CONST(-0.7996846437) },
{ FRAC_CONST(0.9557930231), FRAC_CONST(0.2940403223) },
{ FRAC_CONST(0.0471064523), FRAC_CONST(0.9988898635) },
{ FRAC_CONST(-0.9238795042), FRAC_CONST(0.3826834261) },
{ FRAC_CONST(-0.6730124950), FRAC_CONST(-0.7396311164) },
{ FRAC_CONST(0.4679298103), FRAC_CONST(-0.8837656379) },
{ FRAC_CONST(0.9900236726), FRAC_CONST(0.1409012377) },
{ FRAC_CONST(0.2027872950), FRAC_CONST(0.9792228341) },
{ FRAC_CONST(-0.8526401520), FRAC_CONST(0.5224985480) },
{ FRAC_CONST(-0.7804304361), FRAC_CONST(-0.6252426505) },
{ FRAC_CONST(0.3239174187), FRAC_CONST(-0.9460853338) },
{ FRAC_CONST(0.9998766184), FRAC_CONST(-0.0157073177) },
{ FRAC_CONST(0.3534748554), FRAC_CONST(0.9354440570) },
{ FRAC_CONST(-0.7604059577), FRAC_CONST(0.6494480371) },
{ FRAC_CONST(-0.8686315417), FRAC_CONST(-0.4954586625) },
{ FRAC_CONST(0.1719291061), FRAC_CONST(-0.9851093292) },
{ FRAC_CONST(0.9851093292), FRAC_CONST(-0.1719291061) },
{ FRAC_CONST(0.4954586625), FRAC_CONST(0.8686315417) },
{ FRAC_CONST(-0.6494480371), FRAC_CONST(0.7604059577) },
{ FRAC_CONST(-0.9354440570), FRAC_CONST(-0.3534748554) },
{ FRAC_CONST(0.0157073177), FRAC_CONST(-0.9998766184) },
{ FRAC_CONST(0.9460853338), FRAC_CONST(-0.3239174187) },
{ FRAC_CONST(0.6252426505), FRAC_CONST(0.7804304361) },
{ FRAC_CONST(-0.5224985480), FRAC_CONST(0.8526401520) },
{ FRAC_CONST(-0.9792228341), FRAC_CONST(-0.2027872950) },
{ FRAC_CONST(-0.1409012377), FRAC_CONST(-0.9900236726) },
{ FRAC_CONST(0.8837656379), FRAC_CONST(-0.4679298103) },
{ FRAC_CONST(0.7396311164), FRAC_CONST(0.6730124950) },
{ FRAC_CONST(-0.3826834261), FRAC_CONST(0.9238795042) },
{ FRAC_CONST(-0.9988898635), FRAC_CONST(-0.0471064523) },
{ FRAC_CONST(-0.2940403223), FRAC_CONST(-0.9557930231) },
{ FRAC_CONST(0.7996846437), FRAC_CONST(-0.6004202366) },
{ FRAC_CONST(0.8358073831), FRAC_CONST(0.5490227938) },
{ FRAC_CONST(-0.2334453613), FRAC_CONST(0.9723699093) },
{ FRAC_CONST(-0.9939609766), FRAC_CONST(0.1097343117) },
{ FRAC_CONST(-0.4399391711), FRAC_CONST(-0.8980275989) },
{ FRAC_CONST(0.6959127784), FRAC_CONST(-0.7181262970) },
{ FRAC_CONST(0.9114032984), FRAC_CONST(0.4115143716) },
{ FRAC_CONST(-0.0784590989), FRAC_CONST(0.9969173074) },
{ FRAC_CONST(-0.9645574093), FRAC_CONST(0.2638730407) },
{ FRAC_CONST(-0.5750052333), FRAC_CONST(-0.8181497455) },
{ FRAC_CONST(0.5750052333), FRAC_CONST(-0.8181497455) },
{ FRAC_CONST(0.9645574093), FRAC_CONST(0.2638730407) },
{ FRAC_CONST(0.0784590989), FRAC_CONST(0.9969173074) },
{ FRAC_CONST(-0.9114032984), FRAC_CONST(0.4115143716) },
{ FRAC_CONST(-0.6959127784), FRAC_CONST(-0.7181262970) },
{ FRAC_CONST(0.4399391711), FRAC_CONST(-0.8980275989) },
{ FRAC_CONST(0.9939609766), FRAC_CONST(0.1097343117) },
{ FRAC_CONST(0.2334453613), FRAC_CONST(0.9723699093) },
{ FRAC_CONST(-0.8358073831), FRAC_CONST(0.5490227938) },
{ FRAC_CONST(-0.7996846437), FRAC_CONST(-0.6004202366) },
{ FRAC_CONST(0.2940403223), FRAC_CONST(-0.9557930231) },
{ FRAC_CONST(0.9988898635), FRAC_CONST(-0.0471064523) },
{ FRAC_CONST(0.3826834261), FRAC_CONST(0.9238795042) },
{ FRAC_CONST(-0.7396311164), FRAC_CONST(0.6730124950) }
};
/* RE(Phi_Fract_SubQmf20[j]) = (float)cos(M_PI*f_center_20[j]*0.39); */
/* IM(Phi_Fract_SubQmf20[j]) = (float)sin(M_PI*f_center_20[j]*0.39); */
static const complex_t Phi_Fract_SubQmf20[] = {
{ FRAC_CONST(0.9882950187), FRAC_CONST(0.1525546312) },
{ FRAC_CONST(0.8962930441), FRAC_CONST(0.4434623122) },
{ FRAC_CONST(0.7208535671), FRAC_CONST(0.6930873394) },
{ FRAC_CONST(0.4783087075), FRAC_CONST(0.8781917691) },
{ FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) },
{ FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) },
{ FRAC_CONST(0.8962930441), FRAC_CONST(-0.4434623122) },
{ FRAC_CONST(0.9882950187), FRAC_CONST(-0.1525546312) },
{ FRAC_CONST(-0.5424415469), FRAC_CONST(0.8400935531) },
{ FRAC_CONST(0.0392598175), FRAC_CONST(0.9992290139) },
{ FRAC_CONST(-0.9268565774), FRAC_CONST(0.3754155636) },
{ FRAC_CONST(-0.9741733670), FRAC_CONST(-0.2258012742) }
};
/* RE(Phi_Fract_SubQmf34[j]) = (float)cos(M_PI*f_center_34[j]*0.39); */
/* IM(Phi_Fract_SubQmf34[j]) = (float)sin(M_PI*f_center_34[j]*0.39); */
static const complex_t Phi_Fract_SubQmf34[] = {
{ FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) },
{ FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) },
{ FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) },
{ FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) },
{ FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) },
{ FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) },
{ FRAC_CONST(0.3387379348), FRAC_CONST(0.9408807755) },
{ FRAC_CONST(0.3387379348), FRAC_CONST(0.9408807755) },
{ FRAC_CONST(0.3387379348), FRAC_CONST(0.9408807755) },
{ FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) },
{ FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) },
{ FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) },
{ FRAC_CONST(-0.7705132365), FRAC_CONST(0.6374239922) },
{ FRAC_CONST(-0.7705132365), FRAC_CONST(0.6374239922) },
{ FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) },
{ FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) },
{ FRAC_CONST(0.3387379348), FRAC_CONST(0.9408807755) },
{ FRAC_CONST(0.3387379348), FRAC_CONST(0.9408807755) },
{ FRAC_CONST(0.3387379348), FRAC_CONST(0.9408807755) },
{ FRAC_CONST(0.3387379348), FRAC_CONST(0.9408807755) },
{ FRAC_CONST(-0.7705132365), FRAC_CONST(0.6374239922) },
{ FRAC_CONST(-0.7705132365), FRAC_CONST(0.6374239922) },
{ FRAC_CONST(-0.8607420325), FRAC_CONST(-0.5090414286) },
{ FRAC_CONST(0.3387379348), FRAC_CONST(0.9408807755) },
{ FRAC_CONST(0.1873813123), FRAC_CONST(-0.9822872281) },
{ FRAC_CONST(-0.7705132365), FRAC_CONST(0.6374239922) },
{ FRAC_CONST(-0.8607420325), FRAC_CONST(-0.5090414286) },
{ FRAC_CONST(-0.8607420325), FRAC_CONST(-0.5090414286) },
{ FRAC_CONST(0.1873813123), FRAC_CONST(-0.9822872281) },
{ FRAC_CONST(0.1873813123), FRAC_CONST(-0.9822872281) },
{ FRAC_CONST(0.9876883626), FRAC_CONST(-0.1564344615) },
{ FRAC_CONST(-0.8607420325), FRAC_CONST(-0.5090414286) }
};
/* RE(Q_Fract_allpass_Qmf[j][i]) = (float)cos(M_PI*(j+0.5)*(frac_delay_q[i])); */
/* IM(Q_Fract_allpass_Qmf[j][i]) = (float)sin(M_PI*(j+0.5)*(frac_delay_q[i])); */
static const complex_t Q_Fract_allpass_Qmf[][3] = {
{ { FRAC_CONST(0.7804303765), FRAC_CONST(0.6252426505) }, { FRAC_CONST(0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(0.8550928831), FRAC_CONST(0.5184748173) } },
{ { FRAC_CONST(-0.4399392009), FRAC_CONST(0.8980275393) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(-0.0643581524), FRAC_CONST(0.9979268909) } },
{ { FRAC_CONST(-0.9723699093), FRAC_CONST(-0.2334454209) }, { FRAC_CONST(0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(-0.9146071672), FRAC_CONST(0.4043435752) } },
{ { FRAC_CONST(0.0157073960), FRAC_CONST(-0.9998766184) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(-0.7814115286), FRAC_CONST(-0.6240159869) } },
{ { FRAC_CONST(0.9792228341), FRAC_CONST(-0.2027871907) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(0.1920081824), FRAC_CONST(-0.9813933372) } },
{ { FRAC_CONST(0.4115142524), FRAC_CONST(0.9114032984) }, { FRAC_CONST(0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(0.9589683414), FRAC_CONST(-0.2835132182) } },
{ { FRAC_CONST(-0.7996847630), FRAC_CONST(0.6004201174) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(0.6947838664), FRAC_CONST(0.7192186117) } },
{ { FRAC_CONST(-0.7604058385), FRAC_CONST(-0.6494481564) }, { FRAC_CONST(0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(-0.3164770305), FRAC_CONST(0.9486001730) } },
{ { FRAC_CONST(0.4679299891), FRAC_CONST(-0.8837655187) }, { FRAC_CONST(0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(-0.9874414206), FRAC_CONST(0.1579856575) } },
{ { FRAC_CONST(0.9645573497), FRAC_CONST(0.2638732493) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(-0.5966450572), FRAC_CONST(-0.8025052547) } },
{ { FRAC_CONST(-0.0471066870), FRAC_CONST(0.9988898635) }, { FRAC_CONST(0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(0.4357025325), FRAC_CONST(-0.9000906944) } },
{ { FRAC_CONST(-0.9851093888), FRAC_CONST(0.1719288528) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(0.9995546937), FRAC_CONST(-0.0298405960) } },
{ { FRAC_CONST(-0.3826831877), FRAC_CONST(-0.9238796234) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(0.4886211455), FRAC_CONST(0.8724960685) } },
{ { FRAC_CONST(0.8181498647), FRAC_CONST(-0.5750049949) }, { FRAC_CONST(0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(-0.5477093458), FRAC_CONST(0.8366686702) } },
{ { FRAC_CONST(0.7396308780), FRAC_CONST(0.6730127335) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(-0.9951074123), FRAC_CONST(-0.0987988561) } },
{ { FRAC_CONST(-0.4954589605), FRAC_CONST(0.8686313629) }, { FRAC_CONST(0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(-0.3725017905), FRAC_CONST(-0.9280315042) } },
{ { FRAC_CONST(-0.9557929039), FRAC_CONST(-0.2940406799) }, { FRAC_CONST(0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(0.6506417990), FRAC_CONST(-0.7593847513) } },
{ { FRAC_CONST(0.0784594864), FRAC_CONST(-0.9969173074) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(0.9741733670), FRAC_CONST(0.2258014232) } },
{ { FRAC_CONST(0.9900237322), FRAC_CONST(-0.1409008205) }, { FRAC_CONST(0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(0.2502108514), FRAC_CONST(0.9681913853) } },
{ { FRAC_CONST(0.3534744382), FRAC_CONST(0.9354441762) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(-0.7427945137), FRAC_CONST(0.6695194840) } },
{ { FRAC_CONST(-0.8358076215), FRAC_CONST(0.5490224361) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(-0.9370992780), FRAC_CONST(-0.3490629196) } },
{ { FRAC_CONST(-0.7181259394), FRAC_CONST(-0.6959131360) }, { FRAC_CONST(0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(-0.1237744763), FRAC_CONST(-0.9923103452) } },
{ { FRAC_CONST(0.5224990249), FRAC_CONST(-0.8526399136) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(0.8226406574), FRAC_CONST(-0.5685616732) } },
{ { FRAC_CONST(0.9460852146), FRAC_CONST(0.3239179254) }, { FRAC_CONST(0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(0.8844994903), FRAC_CONST(0.4665412009) } },
{ { FRAC_CONST(-0.1097348556), FRAC_CONST(0.9939609170) }, { FRAC_CONST(0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(-0.0047125919), FRAC_CONST(0.9999889135) } },
{ { FRAC_CONST(-0.9939610362), FRAC_CONST(0.1097337380) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(-0.8888573647), FRAC_CONST(0.4581840038) } },
{ { FRAC_CONST(-0.3239168525), FRAC_CONST(-0.9460855722) }, { FRAC_CONST(0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(-0.8172453642), FRAC_CONST(-0.5762898922) } },
{ { FRAC_CONST(0.8526405096), FRAC_CONST(-0.5224980116) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(0.1331215799), FRAC_CONST(-0.9910997152) } },
{ { FRAC_CONST(0.6959123611), FRAC_CONST(0.7181267142) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(0.9403476119), FRAC_CONST(-0.3402152061) } },
{ { FRAC_CONST(-0.5490233898), FRAC_CONST(0.8358070254) }, { FRAC_CONST(0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(0.7364512086), FRAC_CONST(0.6764906645) } },
{ { FRAC_CONST(-0.9354437590), FRAC_CONST(-0.3534754813) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(-0.2593250275), FRAC_CONST(0.9657900929) } },
{ { FRAC_CONST(0.1409019381), FRAC_CONST(-0.9900235534) }, { FRAC_CONST(0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(-0.9762582779), FRAC_CONST(0.2166097313) } },
{ { FRAC_CONST(0.9969173670), FRAC_CONST(-0.0784583688) }, { FRAC_CONST(0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(-0.6434556246), FRAC_CONST(-0.7654833794) } },
{ { FRAC_CONST(0.2940396070), FRAC_CONST(0.9557932615) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(0.3812320232), FRAC_CONST(-0.9244794250) } },
{ { FRAC_CONST(-0.8686318994), FRAC_CONST(0.4954580069) }, { FRAC_CONST(0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(0.9959943891), FRAC_CONST(-0.0894154981) } },
{ { FRAC_CONST(-0.6730118990), FRAC_CONST(-0.7396316528) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(0.5397993922), FRAC_CONST(0.8417937160) } },
{ { FRAC_CONST(0.5750059485), FRAC_CONST(-0.8181492686) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(-0.4968227744), FRAC_CONST(0.8678520322) } },
{ { FRAC_CONST(0.9238792062), FRAC_CONST(0.3826842010) }, { FRAC_CONST(0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(-0.9992290139), FRAC_CONST(-0.0392601527) } },
{ { FRAC_CONST(-0.1719299555), FRAC_CONST(0.9851091504) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(-0.4271997511), FRAC_CONST(-0.9041572809) } },
{ { FRAC_CONST(-0.9988899231), FRAC_CONST(0.0471055657) }, { FRAC_CONST(0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(0.6041822433), FRAC_CONST(-0.7968461514) } },
{ { FRAC_CONST(-0.2638721764), FRAC_CONST(-0.9645576477) }, { FRAC_CONST(0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(0.9859085083), FRAC_CONST(0.1672853529) } },
{ { FRAC_CONST(0.8837660551), FRAC_CONST(-0.4679289758) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(0.3075223565), FRAC_CONST(0.9515408874) } },
{ { FRAC_CONST(0.6494473219), FRAC_CONST(0.7604066133) }, { FRAC_CONST(0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(-0.7015317082), FRAC_CONST(0.7126382589) } },
{ { FRAC_CONST(-0.6004210114), FRAC_CONST(0.7996840477) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(-0.9562535882), FRAC_CONST(-0.2925389707) } },
{ { FRAC_CONST(-0.9114028811), FRAC_CONST(-0.4115152657) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(-0.1827499419), FRAC_CONST(-0.9831594229) } },
{ { FRAC_CONST(0.2027882934), FRAC_CONST(-0.9792225957) }, { FRAC_CONST(0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(0.7872582674), FRAC_CONST(-0.6166234016) } },
{ { FRAC_CONST(0.9998766780), FRAC_CONST(-0.0157062728) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(0.9107555747), FRAC_CONST(0.4129458666) } },
{ { FRAC_CONST(0.2334443331), FRAC_CONST(0.9723701477) }, { FRAC_CONST(0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(0.0549497530), FRAC_CONST(0.9984891415) } },
{ { FRAC_CONST(-0.8980280757), FRAC_CONST(0.4399381876) }, { FRAC_CONST(0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(-0.8599416018), FRAC_CONST(0.5103924870) } },
{ { FRAC_CONST(-0.6252418160), FRAC_CONST(-0.7804310918) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(-0.8501682281), FRAC_CONST(-0.5265110731) } },
{ { FRAC_CONST(0.6252435446), FRAC_CONST(-0.7804297209) }, { FRAC_CONST(0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(0.0737608299), FRAC_CONST(-0.9972759485) } },
{ { FRAC_CONST(0.8980270624), FRAC_CONST(0.4399402142) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(0.9183775187), FRAC_CONST(-0.3957053721) } },
{ { FRAC_CONST(-0.2334465086), FRAC_CONST(0.9723696709) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(0.7754954696), FRAC_CONST(0.6313531399) } },
{ { FRAC_CONST(-0.9998766184), FRAC_CONST(-0.0157085191) }, { FRAC_CONST(0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(-0.2012493610), FRAC_CONST(0.9795400500) } },
{ { FRAC_CONST(-0.2027861029), FRAC_CONST(-0.9792230725) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(-0.9615978599), FRAC_CONST(0.2744622827) } },
{ { FRAC_CONST(0.9114037752), FRAC_CONST(-0.4115132093) }, { FRAC_CONST(0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(-0.6879743338), FRAC_CONST(-0.7257350087) } },
{ { FRAC_CONST(0.6004192233), FRAC_CONST(0.7996854186) }, { FRAC_CONST(0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(0.3254036009), FRAC_CONST(-0.9455752373) } },
{ { FRAC_CONST(-0.6494490504), FRAC_CONST(0.7604051232) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(0.9888865948), FRAC_CONST(-0.1486719251) } },
{ { FRAC_CONST(-0.8837650418), FRAC_CONST(-0.4679309726) }, { FRAC_CONST(0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(0.5890548825), FRAC_CONST(0.8080930114) } },
{ { FRAC_CONST(0.2638743520), FRAC_CONST(-0.9645570517) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(-0.4441666007), FRAC_CONST(0.8959442377) } },
{ { FRAC_CONST(0.9988898039), FRAC_CONST(0.0471078083) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(-0.9997915030), FRAC_CONST(0.0204183888) } },
{ { FRAC_CONST(0.1719277352), FRAC_CONST(0.9851095676) }, { FRAC_CONST(0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(-0.4803760946), FRAC_CONST(-0.8770626187) } },
{ { FRAC_CONST(-0.9238800406), FRAC_CONST(0.3826821446) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(0.5555707216), FRAC_CONST(-0.8314692974) } },
{ { FRAC_CONST(-0.5750041008), FRAC_CONST(-0.8181505203) }, { FRAC_CONST(0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(0.9941320419), FRAC_CONST(0.1081734300) } }
};
/* RE(Q_Fract_allpass_SubQmf20[j][i]) = (float)cos(M_PI*f_center_20[j]*frac_delay_q[i]); */
/* IM(Q_Fract_allpass_SubQmf20[j][i]) = (float)sin(M_PI*f_center_20[j]*frac_delay_q[i]); */
static const complex_t Q_Fract_allpass_SubQmf20[][3] = {
{ { FRAC_CONST(0.9857769012), FRAC_CONST(0.1680592746) }, { FRAC_CONST(0.9569403529), FRAC_CONST(0.2902846634) }, { FRAC_CONST(0.9907300472), FRAC_CONST(0.1358452588) } },
{ { FRAC_CONST(0.8744080663), FRAC_CONST(0.4851911962) }, { FRAC_CONST(0.6343932748), FRAC_CONST(0.7730104327) }, { FRAC_CONST(0.9175986052), FRAC_CONST(0.3975082636) } },
{ { FRAC_CONST(0.6642524004), FRAC_CONST(0.7475083470) }, { FRAC_CONST(0.0980171412), FRAC_CONST(0.9951847196) }, { FRAC_CONST(0.7767338753), FRAC_CONST(0.6298289299) } },
{ { FRAC_CONST(0.3790524006), FRAC_CONST(0.9253752232) }, { FRAC_CONST(-0.4713967443), FRAC_CONST(0.8819212914) }, { FRAC_CONST(0.5785340071), FRAC_CONST(0.8156582713) } },
{ { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) } },
{ { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) } },
{ { FRAC_CONST(0.8744080663), FRAC_CONST(-0.4851911962) }, { FRAC_CONST(0.6343932748), FRAC_CONST(-0.7730104327) }, { FRAC_CONST(0.9175986052), FRAC_CONST(-0.3975082636) } },
{ { FRAC_CONST(0.9857769012), FRAC_CONST(-0.1680592746) }, { FRAC_CONST(0.9569403529), FRAC_CONST(-0.2902846634) }, { FRAC_CONST(0.9907300472), FRAC_CONST(-0.1358452588) } },
{ { FRAC_CONST(-0.7126385570), FRAC_CONST(0.7015314102) }, { FRAC_CONST(-0.5555702448), FRAC_CONST(-0.8314695954) }, { FRAC_CONST(-0.3305967748), FRAC_CONST(0.9437720776) } },
{ { FRAC_CONST(-0.1175374240), FRAC_CONST(0.9930684566) }, { FRAC_CONST(-0.9807852507), FRAC_CONST(0.1950903237) }, { FRAC_CONST(0.2066311091), FRAC_CONST(0.9784189463) } },
{ { FRAC_CONST(-0.9947921634), FRAC_CONST(0.1019244045) }, { FRAC_CONST(0.5555702448), FRAC_CONST(-0.8314695954) }, { FRAC_CONST(-0.7720130086), FRAC_CONST(0.6356067061) } },
{ { FRAC_CONST(-0.8400934935), FRAC_CONST(-0.5424416065) }, { FRAC_CONST(0.9807852507), FRAC_CONST(0.1950903237) }, { FRAC_CONST(-0.9896889329), FRAC_CONST(0.1432335079) } }
};
/* RE(Q_Fract_allpass_SubQmf34[j][i]) = (float)cos(M_PI*f_center_34[j]*frac_delay_q[i]); */
/* IM(Q_Fract_allpass_SubQmf34[j][i]) = (float)sin(M_PI*f_center_34[j]*frac_delay_q[i]); */
static const complex_t Q_Fract_allpass_SubQmf34[][3] = {
{ { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) } },
{ { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) } },
{ { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) } },
{ { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) } },
{ { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) } },
{ { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) } },
{ { FRAC_CONST(0.2181432247), FRAC_CONST(0.9759167433) }, { FRAC_CONST(-0.7071067691), FRAC_CONST(0.7071067691) }, { FRAC_CONST(0.4623677433), FRAC_CONST(0.8866882324) } },
{ { FRAC_CONST(0.2181432247), FRAC_CONST(0.9759167433) }, { FRAC_CONST(-0.7071067691), FRAC_CONST(0.7071067691) }, { FRAC_CONST(0.4623677433), FRAC_CONST(0.8866882324) } },
{ { FRAC_CONST(0.2181432247), FRAC_CONST(0.9759167433) }, { FRAC_CONST(-0.7071067691), FRAC_CONST(0.7071067691) }, { FRAC_CONST(0.4623677433), FRAC_CONST(0.8866882324) } },
{ { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) } },
{ { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) } },
{ { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) } },
{ { FRAC_CONST(-0.9048270583), FRAC_CONST(0.4257792532) }, { FRAC_CONST(-0.0000000000), FRAC_CONST(-1.0000000000) }, { FRAC_CONST(-0.5724321604), FRAC_CONST(0.8199520707) } },
{ { FRAC_CONST(-0.9048270583), FRAC_CONST(0.4257792532) }, { FRAC_CONST(-0.0000000000), FRAC_CONST(-1.0000000000) }, { FRAC_CONST(-0.5724321604), FRAC_CONST(0.8199520707) } },
{ { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) } },
{ { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) } },
{ { FRAC_CONST(0.2181432247), FRAC_CONST(0.9759167433) }, { FRAC_CONST(-0.7071067691), FRAC_CONST(0.7071067691) }, { FRAC_CONST(0.4623677433), FRAC_CONST(0.8866882324) } },
{ { FRAC_CONST(0.2181432247), FRAC_CONST(0.9759167433) }, { FRAC_CONST(-0.7071067691), FRAC_CONST(0.7071067691) }, { FRAC_CONST(0.4623677433), FRAC_CONST(0.8866882324) } },
{ { FRAC_CONST(0.2181432247), FRAC_CONST(0.9759167433) }, { FRAC_CONST(-0.7071067691), FRAC_CONST(0.7071067691) }, { FRAC_CONST(0.4623677433), FRAC_CONST(0.8866882324) } },
{ { FRAC_CONST(0.2181432247), FRAC_CONST(0.9759167433) }, { FRAC_CONST(-0.7071067691), FRAC_CONST(0.7071067691) }, { FRAC_CONST(0.4623677433), FRAC_CONST(0.8866882324) } },
{ { FRAC_CONST(-0.9048270583), FRAC_CONST(0.4257792532) }, { FRAC_CONST(-0.0000000000), FRAC_CONST(-1.0000000000) }, { FRAC_CONST(-0.5724321604), FRAC_CONST(0.8199520707) } },
{ { FRAC_CONST(-0.9048270583), FRAC_CONST(0.4257792532) }, { FRAC_CONST(-0.0000000000), FRAC_CONST(-1.0000000000) }, { FRAC_CONST(-0.5724321604), FRAC_CONST(0.8199520707) } },
{ { FRAC_CONST(-0.6129069924), FRAC_CONST(-0.7901550531) }, { FRAC_CONST(0.7071067691), FRAC_CONST(0.7071067691) }, { FRAC_CONST(-0.9917160273), FRAC_CONST(-0.1284494549) } },
{ { FRAC_CONST(0.2181432247), FRAC_CONST(0.9759167433) }, { FRAC_CONST(-0.7071067691), FRAC_CONST(0.7071067691) }, { FRAC_CONST(0.4623677433), FRAC_CONST(0.8866882324) } },
{ { FRAC_CONST(0.6374240518), FRAC_CONST(-0.7705131769) }, { FRAC_CONST(-1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(-0.3446428776), FRAC_CONST(-0.9387338758) } },
{ { FRAC_CONST(-0.9048270583), FRAC_CONST(0.4257792532) }, { FRAC_CONST(-0.0000000000), FRAC_CONST(-1.0000000000) }, { FRAC_CONST(-0.5724321604), FRAC_CONST(0.8199520707) } },
{ { FRAC_CONST(-0.6129069924), FRAC_CONST(-0.7901550531) }, { FRAC_CONST(0.7071067691), FRAC_CONST(0.7071067691) }, { FRAC_CONST(-0.9917160273), FRAC_CONST(-0.1284494549) } },
{ { FRAC_CONST(-0.6129069924), FRAC_CONST(-0.7901550531) }, { FRAC_CONST(0.7071067691), FRAC_CONST(0.7071067691) }, { FRAC_CONST(-0.9917160273), FRAC_CONST(-0.1284494549) } },
{ { FRAC_CONST(0.6374240518), FRAC_CONST(-0.7705131769) }, { FRAC_CONST(-1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(-0.3446428776), FRAC_CONST(-0.9387338758) } },
{ { FRAC_CONST(0.6374240518), FRAC_CONST(-0.7705131769) }, { FRAC_CONST(-1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(-0.3446428776), FRAC_CONST(-0.9387338758) } },
{ { FRAC_CONST(0.8910064697), FRAC_CONST(0.4539906085) }, { FRAC_CONST(0.7071067691), FRAC_CONST(-0.7071067691) }, { FRAC_CONST(0.6730125546), FRAC_CONST(-0.7396310568) } },
{ { FRAC_CONST(-0.6129069924), FRAC_CONST(-0.7901550531) }, { FRAC_CONST(0.7071067691), FRAC_CONST(0.7071067691) }, { FRAC_CONST(-0.9917160273), FRAC_CONST(-0.1284494549) } }
};
#if 0
static float quant_rho[8] =
{
FRAC_CONST(1.0), FRAC_CONST(0.937), FRAC_CONST(0.84118), FRAC_CONST(0.60092),
FRAC_CONST(0.36764), FRAC_CONST(0.0), FRAC_CONST(-0.589), FRAC_CONST(-1.0)
};
static const uint8_t quant_iid_normal[7] =
{
2, 4, 7, 10, 14, 18, 25
};
static const uint8_t quant_iid_fine[15] =
{
2, 4, 6, 8, 10, 13, 16, 19, 22, 25, 30, 35, 40, 45, 50
};
#endif
static const real_t cos_alphas[] = {
COEF_CONST(1.0000000000), COEF_CONST(0.9841239700), COEF_CONST(0.9594738210),
COEF_CONST(0.8946843079), COEF_CONST(0.8269340931), COEF_CONST(0.7071067812),
COEF_CONST(0.4533210856), COEF_CONST(0.0000000000)
};
static const real_t sin_alphas[] = {
COEF_CONST(0.0000000000), COEF_CONST(0.1774824264), COEF_CONST(0.2817977763),
COEF_CONST(0.4466989918), COEF_CONST(0.5622988580), COEF_CONST(0.7071067812),
COEF_CONST(0.8913472911), COEF_CONST(1.0000000000)
};
static const real_t cos_betas_normal[][8] = {
{ COEF_CONST(1.0000000000), COEF_CONST(1.0000000000), COEF_CONST(1.0000000000), COEF_CONST(1.0000000000), COEF_CONST(1.0000000000), COEF_CONST(1.0000000000), COEF_CONST(1.0000000000), COEF_CONST(1.0000000000) },
{ COEF_CONST(1.0000000000), COEF_CONST(0.9995871699), COEF_CONST(0.9989419133), COEF_CONST(0.9972204583), COEF_CONST(0.9953790839), COEF_CONST(0.9920112747), COEF_CONST(0.9843408180), COEF_CONST(0.9681727381) },
{ COEF_CONST(1.0000000000), COEF_CONST(0.9984497744), COEF_CONST(0.9960279377), COEF_CONST(0.9895738413), COEF_CONST(0.9826814632), COEF_CONST(0.9701058164), COEF_CONST(0.9416098832), COEF_CONST(0.8822105900) },
{ COEF_CONST(1.0000000000), COEF_CONST(0.9959398908), COEF_CONST(0.9896038018), COEF_CONST(0.9727589768), COEF_CONST(0.9548355329), COEF_CONST(0.9223070404), COEF_CONST(0.8494349490), COEF_CONST(0.7013005535) },
{ COEF_CONST(1.0000000000), COEF_CONST(0.9932417400), COEF_CONST(0.9827071856), COEF_CONST(0.9547730996), COEF_CONST(0.9251668930), COEF_CONST(0.8717461589), COEF_CONST(0.7535520592), COEF_CONST(0.5198827312) },
{ COEF_CONST(1.0000000000), COEF_CONST(0.9902068095), COEF_CONST(0.9749613872), COEF_CONST(0.9346538534), COEF_CONST(0.8921231300), COEF_CONST(0.8158851259), COEF_CONST(0.6495964302), COEF_CONST(0.3313370772) },
{ COEF_CONST(1.0000000000), COEF_CONST(0.9880510933), COEF_CONST(0.9694670261), COEF_CONST(0.9204347876), COEF_CONST(0.8688622825), COEF_CONST(0.7768516704), COEF_CONST(0.5782161800), COEF_CONST(0.2069970356) },
{ COEF_CONST(1.0000000000), COEF_CONST(0.9858996945), COEF_CONST(0.9639898866), COEF_CONST(0.9063034786), COEF_CONST(0.8458214608), COEF_CONST(0.7384262300), COEF_CONST(0.5089811277), COEF_CONST(0.0905465944) }
};
static const real_t sin_betas_normal[][8] = {
{ COEF_CONST(0.0000000000), COEF_CONST(0.0000000000), COEF_CONST(0.0000000000), COEF_CONST(0.0000000000), COEF_CONST(0.0000000000), COEF_CONST(0.0000000000), COEF_CONST(0.0000000000), COEF_CONST(0.0000000000) },
{ COEF_CONST(0.0000000000), COEF_CONST(-0.0287313368), COEF_CONST(-0.0459897147), COEF_CONST(-0.0745074328), COEF_CONST(-0.0960233266), COEF_CONST(-0.1261492408), COEF_CONST(-0.1762757894), COEF_CONST(-0.2502829383) },
{ COEF_CONST(0.0000000000), COEF_CONST(-0.0556601118), COEF_CONST(-0.0890412670), COEF_CONST(-0.1440264301), COEF_CONST(-0.1853028382), COEF_CONST(-0.2426823129), COEF_CONST(-0.3367058477), COEF_CONST(-0.4708550466) },
{ COEF_CONST(0.0000000000), COEF_CONST(-0.0900207420), COEF_CONST(-0.1438204281), COEF_CONST(-0.2318188366), COEF_CONST(-0.2971348264), COEF_CONST(-0.3864579191), COEF_CONST(-0.5276933461), COEF_CONST(-0.7128657193) },
{ COEF_CONST(0.0000000000), COEF_CONST(-0.1160639735), COEF_CONST(-0.1851663774), COEF_CONST(-0.2973353800), COEF_CONST(-0.3795605619), COEF_CONST(-0.4899577884), COEF_CONST(-0.6573882369), COEF_CONST(-0.8542376401) },
{ COEF_CONST(0.0000000000), COEF_CONST(-0.1396082894), COEF_CONST(-0.2223742196), COEF_CONST(-0.3555589603), COEF_CONST(-0.4517923427), COEF_CONST(-0.5782140273), COEF_CONST(-0.7602792104), COEF_CONST(-0.9435124489) },
{ COEF_CONST(0.0000000000), COEF_CONST(-0.1541266914), COEF_CONST(-0.2452217065), COEF_CONST(-0.3908961522), COEF_CONST(-0.4950538699), COEF_CONST(-0.6296836366), COEF_CONST(-0.8158836002), COEF_CONST(-0.9783415698) },
{ COEF_CONST(0.0000000000), COEF_CONST(-0.1673373610), COEF_CONST(-0.2659389001), COEF_CONST(-0.4226275012), COEF_CONST(-0.5334660781), COEF_CONST(-0.6743342664), COEF_CONST(-0.8607776784), COEF_CONST(-0.9958922202) }
};
static const real_t cos_betas_fine[][8] = {
{ COEF_CONST(1.0000000000), COEF_CONST(1.0000000000), COEF_CONST(1.0000000000), COEF_CONST(1.0000000000), COEF_CONST(1.0000000000), COEF_CONST(1.0000000000), COEF_CONST(1.0000000000), COEF_CONST(1.0000000000) },
{ COEF_CONST(1.0000000000), COEF_CONST(0.9995871699), COEF_CONST(0.9989419133), COEF_CONST(0.9972204583), COEF_CONST(0.9953790839), COEF_CONST(0.9920112747), COEF_CONST(0.9843408180), COEF_CONST(0.9681727381) },
{ COEF_CONST(1.0000000000), COEF_CONST(0.9984497744), COEF_CONST(0.9960279377), COEF_CONST(0.9895738413), COEF_CONST(0.9826814632), COEF_CONST(0.9701058164), COEF_CONST(0.9416098832), COEF_CONST(0.8822105900) },
{ COEF_CONST(1.0000000000), COEF_CONST(0.9968361371), COEF_CONST(0.9918968104), COEF_CONST(0.9787540479), COEF_CONST(0.9647515190), COEF_CONST(0.9392903010), COEF_CONST(0.8820167114), COEF_CONST(0.7645325390) },
{ COEF_CONST(1.0000000000), COEF_CONST(0.9950262915), COEF_CONST(0.9872675041), COEF_CONST(0.9666584578), COEF_CONST(0.9447588606), COEF_CONST(0.9050918405), COEF_CONST(0.8165997379), COEF_CONST(0.6383824796) },
{ COEF_CONST(1.0000000000), COEF_CONST(0.9932417400), COEF_CONST(0.9827071856), COEF_CONST(0.9547730996), COEF_CONST(0.9251668930), COEF_CONST(0.8717461589), COEF_CONST(0.7535520592), COEF_CONST(0.5198827312) },
{ COEF_CONST(1.0000000000), COEF_CONST(0.9908827998), COEF_CONST(0.9766855904), COEF_CONST(0.9391249214), COEF_CONST(0.8994531782), COEF_CONST(0.8282352693), COEF_CONST(0.6723983174), COEF_CONST(0.3719473225) },
{ COEF_CONST(1.0000000000), COEF_CONST(0.9890240165), COEF_CONST(0.9719459866), COEF_CONST(0.9268448110), COEF_CONST(0.8793388536), COEF_CONST(0.7944023271), COEF_CONST(0.6101812098), COEF_CONST(0.2621501145) },
{ COEF_CONST(1.0000000000), COEF_CONST(0.9876350461), COEF_CONST(0.9684073447), COEF_CONST(0.9176973944), COEF_CONST(0.8643930070), COEF_CONST(0.7693796058), COEF_CONST(0.5646720713), COEF_CONST(0.1838899556) },
{ COEF_CONST(1.0000000000), COEF_CONST(0.9866247085), COEF_CONST(0.9658349704), COEF_CONST(0.9110590761), COEF_CONST(0.8535668048), COEF_CONST(0.7513165426), COEF_CONST(0.5320914819), COEF_CONST(0.1289530943) },
{ COEF_CONST(1.0000000000), COEF_CONST(0.9858996945), COEF_CONST(0.9639898866), COEF_CONST(0.9063034786), COEF_CONST(0.8458214608), COEF_CONST(0.7384262300), COEF_CONST(0.5089811277), COEF_CONST(0.0905465944) },
{ COEF_CONST(1.0000000000), COEF_CONST(0.9851245614), COEF_CONST(0.9620180268), COEF_CONST(0.9012265590), COEF_CONST(0.8375623272), COEF_CONST(0.7247108045), COEF_CONST(0.4845204297), COEF_CONST(0.0504115003) },
{ COEF_CONST(1.0000000000), COEF_CONST(0.9846869856), COEF_CONST(0.9609052357), COEF_CONST(0.8983639533), COEF_CONST(0.8329098386), COEF_CONST(0.7169983441), COEF_CONST(0.4708245354), COEF_CONST(0.0281732509) },
{ COEF_CONST(1.0000000000), COEF_CONST(0.9844406325), COEF_CONST(0.9602788522), COEF_CONST(0.8967533934), COEF_CONST(0.8302936455), COEF_CONST(0.7126658102), COEF_CONST(0.4631492839), COEF_CONST(0.0157851140) },
{ COEF_CONST(1.0000000000), COEF_CONST(0.9843020502), COEF_CONST(0.9599265269), COEF_CONST(0.8958477331), COEF_CONST(0.8288229094), COEF_CONST(0.7102315840), COEF_CONST(0.4588429315), COEF_CONST(0.0088578059) },
{ COEF_CONST(1.0000000000), COEF_CONST(0.9842241136), COEF_CONST(0.9597283916), COEF_CONST(0.8953385094), COEF_CONST(0.8279961409), COEF_CONST(0.7088635748), COEF_CONST(0.4564246834), COEF_CONST(0.0049751355) }
};
static const real_t sin_betas_fine[][8] = {
{ COEF_CONST(0.0000000000), COEF_CONST(0.0000000000), COEF_CONST(0.0000000000), COEF_CONST(0.0000000000), COEF_CONST(0.0000000000), COEF_CONST(0.0000000000), COEF_CONST(0.0000000000), COEF_CONST(0.0000000000) },
{ COEF_CONST(0.0000000000), COEF_CONST(-0.0287313368), COEF_CONST(-0.0459897147), COEF_CONST(-0.0745074328), COEF_CONST(-0.0960233266), COEF_CONST(-0.1261492408), COEF_CONST(-0.1762757894), COEF_CONST(-0.2502829383) },
{ COEF_CONST(0.0000000000), COEF_CONST(-0.0556601118), COEF_CONST(-0.0890412670), COEF_CONST(-0.1440264301), COEF_CONST(-0.1853028382), COEF_CONST(-0.2426823129), COEF_CONST(-0.3367058477), COEF_CONST(-0.4708550466) },
{ COEF_CONST(0.0000000000), COEF_CONST(-0.0794840594), COEF_CONST(-0.1270461238), COEF_CONST(-0.2050378347), COEF_CONST(-0.2631625097), COEF_CONST(-0.3431234916), COEF_CONST(-0.4712181245), COEF_CONST(-0.6445851354) },
{ COEF_CONST(0.0000000000), COEF_CONST(-0.0996126459), COEF_CONST(-0.1590687758), COEF_CONST(-0.2560691819), COEF_CONST(-0.3277662204), COEF_CONST(-0.4252161335), COEF_CONST(-0.5772043556), COEF_CONST(-0.7697193058) },
{ COEF_CONST(0.0000000000), COEF_CONST(-0.1160639735), COEF_CONST(-0.1851663774), COEF_CONST(-0.2973353800), COEF_CONST(-0.3795605619), COEF_CONST(-0.4899577884), COEF_CONST(-0.6573882369), COEF_CONST(-0.8542376401) },
{ COEF_CONST(0.0000000000), COEF_CONST(-0.1347266752), COEF_CONST(-0.2146747714), COEF_CONST(-0.3435758752), COEF_CONST(-0.4370171396), COEF_CONST(-0.5603805303), COEF_CONST(-0.7401895046), COEF_CONST(-0.9282538388) },
{ COEF_CONST(0.0000000000), COEF_CONST(-0.1477548470), COEF_CONST(-0.2352041647), COEF_CONST(-0.3754446647), COEF_CONST(-0.4761965776), COEF_CONST(-0.6073919186), COEF_CONST(-0.7922618830), COEF_CONST(-0.9650271071) },
{ COEF_CONST(0.0000000000), COEF_CONST(-0.1567705832), COEF_CONST(-0.2493736450), COEF_CONST(-0.3972801182), COEF_CONST(-0.5028167951), COEF_CONST(-0.6387918458), COEF_CONST(-0.8253153651), COEF_CONST(-0.9829468369) },
{ COEF_CONST(0.0000000000), COEF_CONST(-0.1630082348), COEF_CONST(-0.2591578860), COEF_CONST(-0.4122758299), COEF_CONST(-0.5209834064), COEF_CONST(-0.6599420072), COEF_CONST(-0.8466868694), COEF_CONST(-0.9916506943) },
{ COEF_CONST(0.0000000000), COEF_CONST(-0.1673373610), COEF_CONST(-0.2659389001), COEF_CONST(-0.4226275012), COEF_CONST(-0.5334660781), COEF_CONST(-0.6743342664), COEF_CONST(-0.8607776784), COEF_CONST(-0.9958922202) },
{ COEF_CONST(0.0000000000), COEF_CONST(-0.1718417832), COEF_CONST(-0.2729859267), COEF_CONST(-0.4333482310), COEF_CONST(-0.5463417868), COEF_CONST(-0.6890531546), COEF_CONST(-0.8747799456), COEF_CONST(-0.9987285320) },
{ COEF_CONST(0.0000000000), COEF_CONST(-0.1743316967), COEF_CONST(-0.2768774604), COEF_CONST(-0.4392518725), COEF_CONST(-0.5534087104), COEF_CONST(-0.6970748701), COEF_CONST(-0.8822268738), COEF_CONST(-0.9996030552) },
{ COEF_CONST(0.0000000000), COEF_CONST(-0.1757175038), COEF_CONST(-0.2790421580), COEF_CONST(-0.4425306221), COEF_CONST(-0.5573261722), COEF_CONST(-0.7015037013), COEF_CONST(-0.8862802834), COEF_CONST(-0.9998754073) },
{ COEF_CONST(0.0000000000), COEF_CONST(-0.1764921355), COEF_CONST(-0.2802517850), COEF_CONST(-0.4443611583), COEF_CONST(-0.5595110229), COEF_CONST(-0.7039681080), COEF_CONST(-0.8885173967), COEF_CONST(-0.9999607689) },
{ COEF_CONST(0.0000000000), COEF_CONST(-0.1769262394), COEF_CONST(-0.2809295540), COEF_CONST(-0.4453862969), COEF_CONST(-0.5607337966), COEF_CONST(-0.7053456119), COEF_CONST(-0.8897620516), COEF_CONST(-0.9999876239) }
};
static const real_t sincos_alphas_B_normal[][8] = {
{ COEF_CONST(0.0561454100), COEF_CONST(0.0526385859), COEF_CONST(0.0472937334), COEF_CONST(0.0338410641), COEF_CONST(0.0207261065), COEF_CONST(0.0028205635), COEF_CONST(0.0028205635), COEF_CONST(0.0028205635) },
{ COEF_CONST(0.1249065138), COEF_CONST(0.1173697697), COEF_CONST(0.1057888284), COEF_CONST(0.0761985131), COEF_CONST(0.0468732723), COEF_CONST(0.0063956103), COEF_CONST(0.0063956103), COEF_CONST(0.0063956103) },
{ COEF_CONST(0.1956693050), COEF_CONST(0.1846090179), COEF_CONST(0.1673645109), COEF_CONST(0.1220621836), COEF_CONST(0.0757362479), COEF_CONST(0.0103882630), COEF_CONST(0.0103882630), COEF_CONST(0.0103882630) },
{ COEF_CONST(0.3015113269), COEF_CONST(0.2870525790), COEF_CONST(0.2637738799), COEF_CONST(0.1984573949), COEF_CONST(0.1260749909), COEF_CONST(0.0175600126), COEF_CONST(0.0175600126), COEF_CONST(0.0175600126) },
{ COEF_CONST(0.4078449476), COEF_CONST(0.3929852420), COEF_CONST(0.3680589270), COEF_CONST(0.2911029124), COEF_CONST(0.1934512363), COEF_CONST(0.0278686716), COEF_CONST(0.0278686716), COEF_CONST(0.0278686716) },
{ COEF_CONST(0.5336171261), COEF_CONST(0.5226637762), COEF_CONST(0.5033652606), COEF_CONST(0.4349162672), COEF_CONST(0.3224682122), COEF_CONST(0.0521999036), COEF_CONST(0.0521999036), COEF_CONST(0.0521999036) },
{ COEF_CONST(0.6219832023), COEF_CONST(0.6161847276), COEF_CONST(0.6057251063), COEF_CONST(0.5654342668), COEF_CONST(0.4826149915), COEF_CONST(0.1058044758), COEF_CONST(0.1058044758), COEF_CONST(0.1058044758) },
{ COEF_CONST(0.7071067657), COEF_CONST(0.7071067657), COEF_CONST(0.7071067657), COEF_CONST(0.7071067657), COEF_CONST(0.7071067657), COEF_CONST(0.7071067657), COEF_CONST(0.7071067657), COEF_CONST(0.7071067657) },
{ COEF_CONST(0.7830305572), COEF_CONST(0.7876016373), COEF_CONST(0.7956739618), COEF_CONST(0.8247933372), COEF_CONST(0.8758325942), COEF_CONST(0.9943869542), COEF_CONST(0.9943869542), COEF_CONST(0.9943869542) },
{ COEF_CONST(0.8457261833), COEF_CONST(0.8525388778), COEF_CONST(0.8640737401), COEF_CONST(0.9004708933), COEF_CONST(0.9465802987), COEF_CONST(0.9986366532), COEF_CONST(0.9986366532), COEF_CONST(0.9986366532) },
{ COEF_CONST(0.9130511848), COEF_CONST(0.9195447612), COEF_CONST(0.9298024282), COEF_CONST(0.9566917233), COEF_CONST(0.9811098801), COEF_CONST(0.9996115928), COEF_CONST(0.9996115928), COEF_CONST(0.9996115928) },
{ COEF_CONST(0.9534625907), COEF_CONST(0.9579148236), COEF_CONST(0.9645845234), COEF_CONST(0.9801095128), COEF_CONST(0.9920207064), COEF_CONST(0.9998458099), COEF_CONST(0.9998458099), COEF_CONST(0.9998458099) },
{ COEF_CONST(0.9806699215), COEF_CONST(0.9828120260), COEF_CONST(0.9858950861), COEF_CONST(0.9925224431), COEF_CONST(0.9971278825), COEF_CONST(0.9999460406), COEF_CONST(0.9999460406), COEF_CONST(0.9999460406) },
{ COEF_CONST(0.9921685024), COEF_CONST(0.9930882705), COEF_CONST(0.9943886135), COEF_CONST(0.9970926648), COEF_CONST(0.9989008403), COEF_CONST(0.9999795479), COEF_CONST(0.9999795479), COEF_CONST(0.9999795479) },
{ COEF_CONST(0.9984226014), COEF_CONST(0.9986136287), COEF_CONST(0.9988810254), COEF_CONST(0.9994272242), COEF_CONST(0.9997851906), COEF_CONST(0.9999960221), COEF_CONST(0.9999960221), COEF_CONST(0.9999960221) }
};
static const real_t sincos_alphas_B_fine[][8] = {
{ COEF_CONST(0.0031622158), COEF_CONST(0.0029630181), COEF_CONST(0.0026599892), COEF_CONST(0.0019002704), COEF_CONST(0.0011626042), COEF_CONST(0.0001580278), COEF_CONST(0.0001580278), COEF_CONST(0.0001580278) },
{ COEF_CONST(0.0056232673), COEF_CONST(0.0052689825), COEF_CONST(0.0047302825), COEF_CONST(0.0033791756), COEF_CONST(0.0020674015), COEF_CONST(0.0002811710), COEF_CONST(0.0002811710), COEF_CONST(0.0002811710) },
{ COEF_CONST(0.0099994225), COEF_CONST(0.0093696693), COEF_CONST(0.0084117414), COEF_CONST(0.0060093796), COEF_CONST(0.0036766009), COEF_CONST(0.0005000392), COEF_CONST(0.0005000392), COEF_CONST(0.0005000392) },
{ COEF_CONST(0.0177799194), COEF_CONST(0.0166607102), COEF_CONST(0.0149581377), COEF_CONST(0.0106875809), COEF_CONST(0.0065392545), COEF_CONST(0.0008893767), COEF_CONST(0.0008893767), COEF_CONST(0.0008893767) },
{ COEF_CONST(0.0316069684), COEF_CONST(0.0296211579), COEF_CONST(0.0265987295), COEF_CONST(0.0190113813), COEF_CONST(0.0116349973), COEF_CONST(0.0015826974), COEF_CONST(0.0015826974), COEF_CONST(0.0015826974) },
{ COEF_CONST(0.0561454100), COEF_CONST(0.0526385859), COEF_CONST(0.0472937334), COEF_CONST(0.0338410641), COEF_CONST(0.0207261065), COEF_CONST(0.0028205635), COEF_CONST(0.0028205635), COEF_CONST(0.0028205635) },
{ COEF_CONST(0.0791834041), COEF_CONST(0.0742798103), COEF_CONST(0.0667907269), COEF_CONST(0.0478705292), COEF_CONST(0.0293500747), COEF_CONST(0.0039966755), COEF_CONST(0.0039966755), COEF_CONST(0.0039966755) },
{ COEF_CONST(0.1115021177), COEF_CONST(0.1047141985), COEF_CONST(0.0943053154), COEF_CONST(0.0678120561), COEF_CONST(0.0416669150), COEF_CONST(0.0056813213), COEF_CONST(0.0056813213), COEF_CONST(0.0056813213) },
{ COEF_CONST(0.1565355066), COEF_CONST(0.1473258371), COEF_CONST(0.1330924027), COEF_CONST(0.0963282233), COEF_CONST(0.0594509113), COEF_CONST(0.0081277946), COEF_CONST(0.0081277946), COEF_CONST(0.0081277946) },
{ COEF_CONST(0.2184643682), COEF_CONST(0.2064579524), COEF_CONST(0.1876265439), COEF_CONST(0.1375744167), COEF_CONST(0.0856896681), COEF_CONST(0.0117817338), COEF_CONST(0.0117817338), COEF_CONST(0.0117817338) },
{ COEF_CONST(0.3015113269), COEF_CONST(0.2870525790), COEF_CONST(0.2637738799), COEF_CONST(0.1984573949), COEF_CONST(0.1260749909), COEF_CONST(0.0175600126), COEF_CONST(0.0175600126), COEF_CONST(0.0175600126) },
{ COEF_CONST(0.3698741335), COEF_CONST(0.3547727297), COEF_CONST(0.3298252076), COEF_CONST(0.2556265829), COEF_CONST(0.1665990017), COEF_CONST(0.0236344541), COEF_CONST(0.0236344541), COEF_CONST(0.0236344541) },
{ COEF_CONST(0.4480623975), COEF_CONST(0.4339410024), COEF_CONST(0.4098613774), COEF_CONST(0.3322709108), COEF_CONST(0.2266784729), COEF_CONST(0.0334094131), COEF_CONST(0.0334094131), COEF_CONST(0.0334094131) },
{ COEF_CONST(0.5336171261), COEF_CONST(0.5226637762), COEF_CONST(0.5033652606), COEF_CONST(0.4349162672), COEF_CONST(0.3224682122), COEF_CONST(0.0521999036), COEF_CONST(0.0521999036), COEF_CONST(0.0521999036) },
{ COEF_CONST(0.6219832023), COEF_CONST(0.6161847276), COEF_CONST(0.6057251063), COEF_CONST(0.5654342668), COEF_CONST(0.4826149915), COEF_CONST(0.1058044758), COEF_CONST(0.1058044758), COEF_CONST(0.1058044758) },
{ COEF_CONST(0.7071067657), COEF_CONST(0.7071067657), COEF_CONST(0.7071067657), COEF_CONST(0.7071067657), COEF_CONST(0.7071067657), COEF_CONST(0.7071067657), COEF_CONST(0.7071067657), COEF_CONST(0.7071067657) },
{ COEF_CONST(0.7830305572), COEF_CONST(0.7876016373), COEF_CONST(0.7956739618), COEF_CONST(0.8247933372), COEF_CONST(0.8758325942), COEF_CONST(0.9943869542), COEF_CONST(0.9943869542), COEF_CONST(0.9943869542) },
{ COEF_CONST(0.8457261833), COEF_CONST(0.8525388778), COEF_CONST(0.8640737401), COEF_CONST(0.9004708933), COEF_CONST(0.9465802987), COEF_CONST(0.9986366532), COEF_CONST(0.9986366532), COEF_CONST(0.9986366532) },
{ COEF_CONST(0.8940022267), COEF_CONST(0.9009412572), COEF_CONST(0.9121477564), COEF_CONST(0.9431839770), COEF_CONST(0.9739696219), COEF_CONST(0.9994417480), COEF_CONST(0.9994417480), COEF_CONST(0.9994417480) },
{ COEF_CONST(0.9290818561), COEF_CONST(0.9349525662), COEF_CONST(0.9440420138), COEF_CONST(0.9667755833), COEF_CONST(0.9860247275), COEF_CONST(0.9997206664), COEF_CONST(0.9997206664), COEF_CONST(0.9997206664) },
{ COEF_CONST(0.9534625907), COEF_CONST(0.9579148236), COEF_CONST(0.9645845234), COEF_CONST(0.9801095128), COEF_CONST(0.9920207064), COEF_CONST(0.9998458099), COEF_CONST(0.9998458099), COEF_CONST(0.9998458099) },
{ COEF_CONST(0.9758449068), COEF_CONST(0.9784554646), COEF_CONST(0.9822404252), COEF_CONST(0.9904914275), COEF_CONST(0.9963218730), COEF_CONST(0.9999305926), COEF_CONST(0.9999305926), COEF_CONST(0.9999305926) },
{ COEF_CONST(0.9876723320), COEF_CONST(0.9890880155), COEF_CONST(0.9911036356), COEF_CONST(0.9953496173), COEF_CONST(0.9982312259), COEF_CONST(0.9999669685), COEF_CONST(0.9999669685), COEF_CONST(0.9999669685) },
{ COEF_CONST(0.9937641889), COEF_CONST(0.9945023501), COEF_CONST(0.9955433130), COEF_CONST(0.9976981117), COEF_CONST(0.9991315558), COEF_CONST(0.9999838610), COEF_CONST(0.9999838610), COEF_CONST(0.9999838610) },
{ COEF_CONST(0.9968600642), COEF_CONST(0.9972374385), COEF_CONST(0.9977670024), COEF_CONST(0.9988535464), COEF_CONST(0.9995691924), COEF_CONST(0.9999920129), COEF_CONST(0.9999920129), COEF_CONST(0.9999920129) },
{ COEF_CONST(0.9984226014), COEF_CONST(0.9986136287), COEF_CONST(0.9988810254), COEF_CONST(0.9994272242), COEF_CONST(0.9997851906), COEF_CONST(0.9999960221), COEF_CONST(0.9999960221), COEF_CONST(0.9999960221) },
{ COEF_CONST(0.9995003746), COEF_CONST(0.9995611974), COEF_CONST(0.9996461891), COEF_CONST(0.9998192657), COEF_CONST(0.9999323103), COEF_CONST(0.9999987475), COEF_CONST(0.9999987475), COEF_CONST(0.9999987475) },
{ COEF_CONST(0.9998419236), COEF_CONST(0.9998611991), COEF_CONST(0.9998881193), COEF_CONST(0.9999428861), COEF_CONST(0.9999786185), COEF_CONST(0.9999996045), COEF_CONST(0.9999996045), COEF_CONST(0.9999996045) },
{ COEF_CONST(0.9999500038), COEF_CONST(0.9999561034), COEF_CONST(0.9999646206), COEF_CONST(0.9999819429), COEF_CONST(0.9999932409), COEF_CONST(0.9999998750), COEF_CONST(0.9999998750), COEF_CONST(0.9999998750) },
{ COEF_CONST(0.9999841890), COEF_CONST(0.9999861183), COEF_CONST(0.9999888121), COEF_CONST(0.9999942902), COEF_CONST(0.9999978628), COEF_CONST(0.9999999605), COEF_CONST(0.9999999605), COEF_CONST(0.9999999605) },
{ COEF_CONST(0.9999950000), COEF_CONST(0.9999956102), COEF_CONST(0.9999964621), COEF_CONST(0.9999981945), COEF_CONST(0.9999993242), COEF_CONST(0.9999999875), COEF_CONST(0.9999999875), COEF_CONST(0.9999999875) }
};
static const real_t cos_gammas_normal[][8] = {
{ COEF_CONST(1.0000000000), COEF_CONST(0.9841239707), COEF_CONST(0.9594738226), COEF_CONST(0.8946843024), COEF_CONST(0.8269341029), COEF_CONST(0.7245688486), COEF_CONST(0.7245688486), COEF_CONST(0.7245688486) },
{ COEF_CONST(1.0000000000), COEF_CONST(0.9849690570), COEF_CONST(0.9617776789), COEF_CONST(0.9020941550), COEF_CONST(0.8436830391), COEF_CONST(0.7846832804), COEF_CONST(0.7846832804), COEF_CONST(0.7846832804) },
{ COEF_CONST(1.0000000000), COEF_CONST(0.9871656089), COEF_CONST(0.9676774734), COEF_CONST(0.9199102884), COEF_CONST(0.8785067015), COEF_CONST(0.8464232214), COEF_CONST(0.8464232214), COEF_CONST(0.8464232214) },
{ COEF_CONST(1.0000000000), COEF_CONST(0.9913533967), COEF_CONST(0.9786000177), COEF_CONST(0.9496063381), COEF_CONST(0.9277157252), COEF_CONST(0.9133354077), COEF_CONST(0.9133354077), COEF_CONST(0.9133354077) },
{ COEF_CONST(1.0000000000), COEF_CONST(0.9948924435), COEF_CONST(0.9875319180), COEF_CONST(0.9716329849), COEF_CONST(0.9604805241), COEF_CONST(0.9535949574), COEF_CONST(0.9535949574), COEF_CONST(0.9535949574) },
{ COEF_CONST(1.0000000000), COEF_CONST(0.9977406278), COEF_CONST(0.9945423840), COEF_CONST(0.9878736667), COEF_CONST(0.9833980494), COEF_CONST(0.9807207440), COEF_CONST(0.9807207440), COEF_CONST(0.9807207440) },
{ COEF_CONST(1.0000000000), COEF_CONST(0.9990607067), COEF_CONST(0.9977417734), COEF_CONST(0.9950323970), COEF_CONST(0.9932453273), COEF_CONST(0.9921884740), COEF_CONST(0.9921884740), COEF_CONST(0.9921884740) },
{ COEF_CONST(1.0000000000), COEF_CONST(0.9998081748), COEF_CONST(0.9995400312), COEF_CONST(0.9989936459), COEF_CONST(0.9986365356), COEF_CONST(0.9984265591), COEF_CONST(0.9984265591), COEF_CONST(0.9984265591) }
};
static const real_t cos_gammas_fine[][8] = {
{ COEF_CONST(1.0000000000), COEF_CONST(0.9841239707), COEF_CONST(0.9594738226), COEF_CONST(0.8946843024), COEF_CONST(0.8269341029), COEF_CONST(0.7245688486), COEF_CONST(0.7245688486), COEF_CONST(0.7245688486) },
{ COEF_CONST(1.0000000000), COEF_CONST(0.9849690570), COEF_CONST(0.9617776789), COEF_CONST(0.9020941550), COEF_CONST(0.8436830391), COEF_CONST(0.7846832804), COEF_CONST(0.7846832804), COEF_CONST(0.7846832804) },
{ COEF_CONST(1.0000000000), COEF_CONST(0.9871656089), COEF_CONST(0.9676774734), COEF_CONST(0.9199102884), COEF_CONST(0.8785067015), COEF_CONST(0.8464232214), COEF_CONST(0.8464232214), COEF_CONST(0.8464232214) },
{ COEF_CONST(1.0000000000), COEF_CONST(0.9899597309), COEF_CONST(0.9750098690), COEF_CONST(0.9402333855), COEF_CONST(0.9129698759), COEF_CONST(0.8943765944), COEF_CONST(0.8943765944), COEF_CONST(0.8943765944) },
{ COEF_CONST(1.0000000000), COEF_CONST(0.9926607607), COEF_CONST(0.9819295710), COEF_CONST(0.9580160104), COEF_CONST(0.9404993670), COEF_CONST(0.9293004472), COEF_CONST(0.9293004472), COEF_CONST(0.9293004472) },
{ COEF_CONST(1.0000000000), COEF_CONST(0.9948924435), COEF_CONST(0.9875319180), COEF_CONST(0.9716329849), COEF_CONST(0.9604805241), COEF_CONST(0.9535949574), COEF_CONST(0.9535949574), COEF_CONST(0.9535949574) },
{ COEF_CONST(1.0000000000), COEF_CONST(0.9972074644), COEF_CONST(0.9932414270), COEF_CONST(0.9849197629), COEF_CONST(0.9792926592), COEF_CONST(0.9759092525), COEF_CONST(0.9759092525), COEF_CONST(0.9759092525) },
{ COEF_CONST(1.0000000000), COEF_CONST(0.9985361982), COEF_CONST(0.9964742028), COEF_CONST(0.9922136306), COEF_CONST(0.9893845420), COEF_CONST(0.9877041371), COEF_CONST(0.9877041371), COEF_CONST(0.9877041371) },
{ COEF_CONST(1.0000000000), COEF_CONST(0.9992494366), COEF_CONST(0.9981967170), COEF_CONST(0.9960386625), COEF_CONST(0.9946185834), COEF_CONST(0.9937800239), COEF_CONST(0.9937800239), COEF_CONST(0.9937800239) },
{ COEF_CONST(1.0000000000), COEF_CONST(0.9996194722), COEF_CONST(0.9990869422), COEF_CONST(0.9979996269), COEF_CONST(0.9972873651), COEF_CONST(0.9968679747), COEF_CONST(0.9968679747), COEF_CONST(0.9968679747) },
{ COEF_CONST(1.0000000000), COEF_CONST(0.9998081748), COEF_CONST(0.9995400312), COEF_CONST(0.9989936459), COEF_CONST(0.9986365356), COEF_CONST(0.9984265591), COEF_CONST(0.9984265591), COEF_CONST(0.9984265591) },
{ COEF_CONST(1.0000000000), COEF_CONST(0.9999390971), COEF_CONST(0.9998540271), COEF_CONST(0.9996809352), COEF_CONST(0.9995679735), COEF_CONST(0.9995016284), COEF_CONST(0.9995016284), COEF_CONST(0.9995016284) },
{ COEF_CONST(1.0000000000), COEF_CONST(0.9999807170), COEF_CONST(0.9999537862), COEF_CONST(0.9998990191), COEF_CONST(0.9998632947), COEF_CONST(0.9998423208), COEF_CONST(0.9998423208), COEF_CONST(0.9998423208) },
{ COEF_CONST(1.0000000000), COEF_CONST(0.9999938979), COEF_CONST(0.9999853814), COEF_CONST(0.9999680568), COEF_CONST(0.9999567596), COEF_CONST(0.9999501270), COEF_CONST(0.9999501270), COEF_CONST(0.9999501270) },
{ COEF_CONST(1.0000000000), COEF_CONST(0.9999980703), COEF_CONST(0.9999953731), COEF_CONST(0.9999898968), COEF_CONST(0.9999863277), COEF_CONST(0.9999842265), COEF_CONST(0.9999842265), COEF_CONST(0.9999842265) },
{ COEF_CONST(1.0000000000), COEF_CONST(0.9999993891), COEF_CONST(0.9999985397), COEF_CONST(0.9999968037), COEF_CONST(0.9999956786), COEF_CONST(0.9999950155), COEF_CONST(0.9999950155), COEF_CONST(0.9999950155) }
};
static const real_t sin_gammas_normal[][8] = {
{ COEF_CONST(0.0000000000), COEF_CONST(0.1774824223), COEF_CONST(0.2817977711), COEF_CONST(0.4466990028), COEF_CONST(0.5622988435), COEF_CONST(0.6892024258), COEF_CONST(0.6892024258), COEF_CONST(0.6892024258) },
{ COEF_CONST(0.0000000000), COEF_CONST(0.1727308798), COEF_CONST(0.2738315110), COEF_CONST(0.4315392630), COEF_CONST(0.5368416242), COEF_CONST(0.6198968861), COEF_CONST(0.6198968861), COEF_CONST(0.6198968861) },
{ COEF_CONST(0.0000000000), COEF_CONST(0.1596999079), COEF_CONST(0.2521910140), COEF_CONST(0.3921288836), COEF_CONST(0.4777300236), COEF_CONST(0.5325107795), COEF_CONST(0.5325107795), COEF_CONST(0.5325107795) },
{ COEF_CONST(0.0000000000), COEF_CONST(0.1312190642), COEF_CONST(0.2057717310), COEF_CONST(0.3134450552), COEF_CONST(0.3732874674), COEF_CONST(0.4072080955), COEF_CONST(0.4072080955), COEF_CONST(0.4072080955) },
{ COEF_CONST(0.0000000000), COEF_CONST(0.1009407043), COEF_CONST(0.1574189028), COEF_CONST(0.2364938532), COEF_CONST(0.2783471983), COEF_CONST(0.3010924396), COEF_CONST(0.3010924396), COEF_CONST(0.3010924396) },
{ COEF_CONST(0.0000000000), COEF_CONST(0.0671836269), COEF_CONST(0.1043333428), COEF_CONST(0.1552598422), COEF_CONST(0.1814615013), COEF_CONST(0.1954144885), COEF_CONST(0.1954144885), COEF_CONST(0.1954144885) },
{ COEF_CONST(0.0000000000), COEF_CONST(0.0433324862), COEF_CONST(0.0671666110), COEF_CONST(0.0995516398), COEF_CONST(0.1160332699), COEF_CONST(0.1247478739), COEF_CONST(0.1247478739), COEF_CONST(0.1247478739) },
{ COEF_CONST(0.0000000000), COEF_CONST(0.0195860576), COEF_CONST(0.0303269852), COEF_CONST(0.0448519274), COEF_CONST(0.0522022017), COEF_CONST(0.0560750040), COEF_CONST(0.0560750040), COEF_CONST(0.0560750040) }
};
static const real_t sin_gammas_fine[][8] = {
{ COEF_CONST(0.0000000000), COEF_CONST(0.1774824223), COEF_CONST(0.2817977711), COEF_CONST(0.4466990028), COEF_CONST(0.5622988435), COEF_CONST(0.6892024258), COEF_CONST(0.6892024258), COEF_CONST(0.6892024258) },
{ COEF_CONST(0.0000000000), COEF_CONST(0.1727308798), COEF_CONST(0.2738315110), COEF_CONST(0.4315392630), COEF_CONST(0.5368416242), COEF_CONST(0.6198968861), COEF_CONST(0.6198968861), COEF_CONST(0.6198968861) },
{ COEF_CONST(0.0000000000), COEF_CONST(0.1596999079), COEF_CONST(0.2521910140), COEF_CONST(0.3921288836), COEF_CONST(0.4777300236), COEF_CONST(0.5325107795), COEF_CONST(0.5325107795), COEF_CONST(0.5325107795) },
{ COEF_CONST(0.0000000000), COEF_CONST(0.1413496768), COEF_CONST(0.2221615526), COEF_CONST(0.3405307340), COEF_CONST(0.4080269669), COEF_CONST(0.4473147744), COEF_CONST(0.4473147744), COEF_CONST(0.4473147744) },
{ COEF_CONST(0.0000000000), COEF_CONST(0.1209322714), COEF_CONST(0.1892467110), COEF_CONST(0.2867147079), COEF_CONST(0.3397954394), COEF_CONST(0.3693246252), COEF_CONST(0.3693246252), COEF_CONST(0.3693246252) },
{ COEF_CONST(0.0000000000), COEF_CONST(0.1009407043), COEF_CONST(0.1574189028), COEF_CONST(0.2364938532), COEF_CONST(0.2783471983), COEF_CONST(0.3010924396), COEF_CONST(0.3010924396), COEF_CONST(0.3010924396) },
{ COEF_CONST(0.0000000000), COEF_CONST(0.0746811420), COEF_CONST(0.1160666523), COEF_CONST(0.1730117353), COEF_CONST(0.2024497161), COEF_CONST(0.2181768341), COEF_CONST(0.2181768341), COEF_CONST(0.2181768341) },
{ COEF_CONST(0.0000000000), COEF_CONST(0.0540875291), COEF_CONST(0.0838997203), COEF_CONST(0.1245476266), COEF_CONST(0.1453211203), COEF_CONST(0.1563346972), COEF_CONST(0.1563346972), COEF_CONST(0.1563346972) },
{ COEF_CONST(0.0000000000), COEF_CONST(0.0387371058), COEF_CONST(0.0600276114), COEF_CONST(0.0889212171), COEF_CONST(0.1036044086), COEF_CONST(0.1113609634), COEF_CONST(0.1113609634), COEF_CONST(0.1113609634) },
{ COEF_CONST(0.0000000000), COEF_CONST(0.0275846110), COEF_CONST(0.0427233177), COEF_CONST(0.0632198125), COEF_CONST(0.0736064637), COEF_CONST(0.0790837596), COEF_CONST(0.0790837596), COEF_CONST(0.0790837596) },
{ COEF_CONST(0.0000000000), COEF_CONST(0.0195860576), COEF_CONST(0.0303269852), COEF_CONST(0.0448519274), COEF_CONST(0.0522022017), COEF_CONST(0.0560750040), COEF_CONST(0.0560750040), COEF_CONST(0.0560750040) },
{ COEF_CONST(0.0000000000), COEF_CONST(0.0110363955), COEF_CONST(0.0170857974), COEF_CONST(0.0252592108), COEF_CONST(0.0293916021), COEF_CONST(0.0315673054), COEF_CONST(0.0315673054), COEF_CONST(0.0315673054) },
{ COEF_CONST(0.0000000000), COEF_CONST(0.0062101284), COEF_CONST(0.0096138203), COEF_CONST(0.0142109649), COEF_CONST(0.0165345659), COEF_CONST(0.0177576316), COEF_CONST(0.0177576316), COEF_CONST(0.0177576316) },
{ COEF_CONST(0.0000000000), COEF_CONST(0.0034934509), COEF_CONST(0.0054071189), COEF_CONST(0.0079928316), COEF_CONST(0.0092994041), COEF_CONST(0.0099871631), COEF_CONST(0.0099871631), COEF_CONST(0.0099871631) },
{ COEF_CONST(0.0000000000), COEF_CONST(0.0019645397), COEF_CONST(0.0030419905), COEF_CONST(0.0044951511), COEF_CONST(0.0052291853), COEF_CONST(0.0056166498), COEF_CONST(0.0056166498), COEF_CONST(0.0056166498) },
{ COEF_CONST(0.0000000000), COEF_CONST(0.0011053943), COEF_CONST(0.0017089869), COEF_CONST(0.0025283670), COEF_CONST(0.0029398552), COEF_CONST(0.0031573685), COEF_CONST(0.0031573685), COEF_CONST(0.0031573685) }
};
static const real_t sf_iid_normal[] = {
COEF_CONST(1.4119827747), COEF_CONST(1.4031381607), COEF_CONST(1.3868767023),
COEF_CONST(1.3483997583), COEF_CONST(1.2912493944), COEF_CONST(1.1960374117),
COEF_CONST(1.1073724031), COEF_CONST(1.0000000000), COEF_CONST(0.8796171546),
COEF_CONST(0.7546485662), COEF_CONST(0.5767799020), COEF_CONST(0.4264014363),
COEF_CONST(0.2767182887), COEF_CONST(0.1766446233), COEF_CONST(0.0794016272)
};
static const real_t sf_iid_fine[] = {
COEF_CONST(1.4142065048), COEF_CONST(1.4141912460), COEF_CONST(1.4141428471),
COEF_CONST(1.4139900208), COEF_CONST(1.4135069847), COEF_CONST(1.4119827747),
COEF_CONST(1.4097729921), COEF_CONST(1.4053947926), COEF_CONST(1.3967796564),
COEF_CONST(1.3800530434), COEF_CONST(1.3483997583), COEF_CONST(1.3139201403),
COEF_CONST(1.2643101215), COEF_CONST(1.1960374117), COEF_CONST(1.1073724031),
COEF_CONST(1.0000000000), COEF_CONST(0.8796171546), COEF_CONST(0.7546485662),
COEF_CONST(0.6336560845), COEF_CONST(0.5230810642), COEF_CONST(0.4264014363),
COEF_CONST(0.3089554012), COEF_CONST(0.2213746458), COEF_CONST(0.1576878875),
COEF_CONST(0.1119822487), COEF_CONST(0.0794016272), COEF_CONST(0.0446990170),
COEF_CONST(0.0251446925), COEF_CONST(0.0141414283), COEF_CONST(0.0079525812),
COEF_CONST(0.0044721137)
};
#ifdef __cplusplus
#endif
#endif

File diff suppressed because it is too large Load Diff

View File

@ -23,7 +23,7 @@
** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
**
** Initially modified for use with MPlayer by Arpad Gereöffy on 2003/08/30
** $Id: sbr_dct.h,v 1.3 2004/06/02 22:59:03 diego Exp $
** $Id: sbr_dct.h,v 1.4 2004/06/23 13:50:51 diego Exp $
** detailed CVS changelog at http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
**/
@ -34,11 +34,14 @@
extern "C" {
#endif
void dct4_kernel(real_t * in_real, real_t * in_imag, real_t * out_real, real_t * out_imag);
void DCT3_32_unscaled(real_t *y, real_t *x);
void DCT2_64_unscaled(real_t *y, real_t *x);
void DST2_64_unscaled(real_t *y, real_t *x);
void DCT4_64(real_t *y, real_t *x);
void DCT4_64_kernel(real_t *y, real_t *t2);
void DCT4_32(real_t *y, real_t *x);
void DST4_32(real_t *y, real_t *x);
void DCT2_32_unscaled(real_t *y, real_t *x);
void DCT4_16(real_t *y, real_t *x);
void DCT2_16_unscaled(real_t *y, real_t *x);
#ifdef __cplusplus

View File

@ -23,7 +23,7 @@
** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
**
** Initially modified for use with MPlayer by Arpad Gereöffy on 2003/08/30
** $Id: sbr_dec.c,v 1.3 2004/06/02 22:59:03 diego Exp $
** $Id: sbr_dec.c,v 1.4 2004/06/23 13:50:51 diego Exp $
** detailed CVS changelog at http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
**/
@ -43,11 +43,14 @@
#include "sbr_hfgen.h"
#include "sbr_hfadj.h"
/* static function declarations */
static uint8_t sbr_save_prev_data(sbr_info *sbr, uint8_t ch);
static void sbr_save_matrix(sbr_info *sbr, uint8_t ch);
sbr_info *sbrDecodeInit(uint16_t framelength, uint8_t id_aac,
uint32_t sample_rate
uint32_t sample_rate, uint8_t downSampledSBR
#ifdef DRM
, uint8_t IsDRM
#endif
@ -73,6 +76,7 @@ sbr_info *sbrDecodeInit(uint16_t framelength, uint8_t id_aac,
sbr->prevEnvIsShort[0] = -1;
sbr->prevEnvIsShort[1] = -1;
sbr->header_count = 0;
sbr->Reset = 1;
#ifdef DRM
sbr->Is_DRM_SBR = IsDRM;
@ -81,6 +85,11 @@ sbr_info *sbrDecodeInit(uint16_t framelength, uint8_t id_aac,
sbr->tHFGen = T_HFGEN;
sbr->tHFAdj = T_HFADJ;
sbr->bsco = 0;
sbr->bsco_prev = 0;
sbr->M_prev = 0;
sbr->frame_len = framelength;
/* force sbr reset */
sbr->bs_start_freq_prev = -1;
@ -93,6 +102,44 @@ sbr_info *sbrDecodeInit(uint16_t framelength, uint8_t id_aac,
sbr->numTimeSlots = NO_TIME_SLOTS;
}
sbr->GQ_ringbuf_index[0] = 0;
sbr->GQ_ringbuf_index[1] = 0;
if (id_aac == ID_CPE)
{
/* stereo */
uint8_t j;
sbr->qmfa[0] = qmfa_init(32);
sbr->qmfa[1] = qmfa_init(32);
sbr->qmfs[0] = qmfs_init((downSampledSBR)?32:64);
sbr->qmfs[1] = qmfs_init((downSampledSBR)?32:64);
for (j = 0; j < 5; j++)
{
sbr->G_temp_prev[0][j] = faad_malloc(64*sizeof(real_t));
sbr->G_temp_prev[1][j] = faad_malloc(64*sizeof(real_t));
sbr->Q_temp_prev[0][j] = faad_malloc(64*sizeof(real_t));
sbr->Q_temp_prev[1][j] = faad_malloc(64*sizeof(real_t));
}
memset(sbr->Xsbr[0], 0, (sbr->numTimeSlotsRate+sbr->tHFGen)*64 * sizeof(qmf_t));
memset(sbr->Xsbr[1], 0, (sbr->numTimeSlotsRate+sbr->tHFGen)*64 * sizeof(qmf_t));
} else {
/* mono */
uint8_t j;
sbr->qmfa[0] = qmfa_init(32);
sbr->qmfs[0] = qmfs_init((downSampledSBR)?32:64);
sbr->qmfs[1] = NULL;
for (j = 0; j < 5; j++)
{
sbr->G_temp_prev[0][j] = faad_malloc(64*sizeof(real_t));
sbr->Q_temp_prev[0][j] = faad_malloc(64*sizeof(real_t));
}
memset(sbr->Xsbr[0], 0, (sbr->numTimeSlotsRate+sbr->tHFGen)*64 * sizeof(qmf_t));
}
return sbr;
}
@ -118,6 +165,16 @@ void sbrDecodeEnd(sbr_info *sbr)
if (sbr->Q_temp_prev[1][j]) faad_free(sbr->Q_temp_prev[1][j]);
}
#ifdef PS_DEC
if (sbr->ps != NULL)
ps_free(sbr->ps);
#endif
#ifdef DRM_PS
if (sbr->drm_ps != NULL)
drm_ps_free(sbr->drm_ps);
#endif
faad_free(sbr);
}
}
@ -128,6 +185,8 @@ static uint8_t sbr_save_prev_data(sbr_info *sbr, uint8_t ch)
/* save data for next frame */
sbr->kx_prev = sbr->kx;
sbr->M_prev = sbr->M;
sbr->bsco_prev = sbr->bsco;
sbr->L_E_prev[ch] = sbr->L_E[ch];
@ -136,13 +195,13 @@ static uint8_t sbr_save_prev_data(sbr_info *sbr, uint8_t ch)
return 19;
sbr->f_prev[ch] = sbr->f[ch][sbr->L_E[ch] - 1];
for (i = 0; i < 64; i++)
for (i = 0; i < MAX_M; i++)
{
sbr->E_prev[ch][i] = sbr->E[ch][i][sbr->L_E[ch] - 1];
sbr->Q_prev[ch][i] = sbr->Q[ch][i][sbr->L_Q[ch] - 1];
}
for (i = 0; i < 64; i++)
for (i = 0; i < MAX_M; i++)
{
sbr->bs_add_harmonic_prev[ch][i] = sbr->bs_add_harmonic[ch][i];
}
@ -156,43 +215,66 @@ static uint8_t sbr_save_prev_data(sbr_info *sbr, uint8_t ch)
return 0;
}
static void sbr_process_channel(sbr_info *sbr, real_t *channel_buf, qmf_t X[MAX_NTSR][64],
uint8_t ch, uint8_t dont_process)
static void sbr_save_matrix(sbr_info *sbr, uint8_t ch)
{
int16_t i, k, l;
uint8_t i;
for (i = 0; i < sbr->tHFGen; i++)
{
memmove(sbr->Xsbr[ch][i], sbr->Xsbr[ch][i+sbr->numTimeSlotsRate], 64 * sizeof(qmf_t));
}
for (i = sbr->tHFGen; i < MAX_NTSRHFG; i++)
{
memset(sbr->Xsbr[ch][i], 0, 64 * sizeof(qmf_t));
}
}
static void sbr_process_channel(sbr_info *sbr, real_t *channel_buf, qmf_t X[MAX_NTSR][64],
uint8_t ch, uint8_t dont_process,
const uint8_t downSampledSBR)
{
int16_t k, l;
#ifdef SBR_LOW_POWER
ALIGN real_t deg[64];
#endif
if (sbr->frame == 0)
#ifdef DRM
if (sbr->Is_DRM_SBR)
{
uint8_t j;
sbr->qmfa[ch] = qmfa_init(32);
sbr->qmfs[ch] = qmfs_init(64);
for (j = 0; j < 5; j++)
{
sbr->G_temp_prev[ch][j] = faad_malloc(64*sizeof(real_t));
sbr->Q_temp_prev[ch][j] = faad_malloc(64*sizeof(real_t));
}
memset(sbr->Xsbr[ch], 0, (sbr->numTimeSlotsRate+sbr->tHFGen)*64 * sizeof(qmf_t));
memset(sbr->Xcodec[ch], 0, (sbr->numTimeSlotsRate+sbr->tHFGen)*32 * sizeof(qmf_t));
sbr->bsco = max((int32_t)sbr->maxAACLine*32/(int32_t)sbr->frame_len - (int32_t)sbr->kx, 0);
} else {
#endif
sbr->bsco = 0;
#ifdef DRM
}
#endif
//#define PRE_QMF_PRINT
#ifdef PRE_QMF_PRINT
{
int i;
for (i = 0; i < 1024; i++)
{
printf("%d\n", channel_buf[i]);
}
}
#endif
/* subband analysis */
if (dont_process)
sbr_qmf_analysis_32(sbr, sbr->qmfa[ch], channel_buf, sbr->Xcodec[ch], sbr->tHFGen, 32);
sbr_qmf_analysis_32(sbr, sbr->qmfa[ch], channel_buf, sbr->Xsbr[ch], sbr->tHFGen, 32);
else
sbr_qmf_analysis_32(sbr, sbr->qmfa[ch], channel_buf, sbr->Xcodec[ch], sbr->tHFGen, sbr->kx);
sbr_qmf_analysis_32(sbr, sbr->qmfa[ch], channel_buf, sbr->Xsbr[ch], sbr->tHFGen, sbr->kx);
if (!dont_process)
{
#if 1
/* insert high frequencies here */
/* hf generation using patching */
hf_generation(sbr, sbr->Xcodec[ch], sbr->Xsbr[ch]
hf_generation(sbr, sbr->Xsbr[ch], sbr->Xsbr[ch]
#ifdef SBR_LOW_POWER
,deg
#endif
@ -225,9 +307,9 @@ static void sbr_process_channel(sbr_info *sbr, real_t *channel_buf, qmf_t X[MAX_
{
for (k = 0; k < 32; k++)
{
QMF_RE(X[l][k]) = QMF_RE(sbr->Xcodec[ch][l + sbr->tHFAdj][k]);
QMF_RE(X[l][k]) = QMF_RE(sbr->Xsbr[ch][l + sbr->tHFAdj][k]);
#ifndef SBR_LOW_POWER
QMF_IM(X[l][k]) = QMF_IM(sbr->Xcodec[ch][l + sbr->tHFAdj][k]);
QMF_IM(X[l][k]) = QMF_IM(sbr->Xsbr[ch][l + sbr->tHFAdj][k]);
#endif
}
for (k = 32; k < 64; k++)
@ -241,42 +323,57 @@ static void sbr_process_channel(sbr_info *sbr, real_t *channel_buf, qmf_t X[MAX_
} else {
for (l = 0; l < sbr->numTimeSlotsRate; l++)
{
uint8_t xover_band;
uint8_t kx_band, M_band, bsco_band;
if (l < sbr->t_E[ch][0])
xover_band = sbr->kx_prev;
else
xover_band = sbr->kx;
for (k = 0; k < xover_band; k++)
{
QMF_RE(X[l][k]) = QMF_RE(sbr->Xcodec[ch][l + sbr->tHFAdj][k]);
#ifndef SBR_LOW_POWER
QMF_IM(X[l][k]) = QMF_IM(sbr->Xcodec[ch][l + sbr->tHFAdj][k]);
#endif
kx_band = sbr->kx_prev;
M_band = sbr->M_prev;
bsco_band = sbr->bsco_prev;
} else {
kx_band = sbr->kx;
M_band = sbr->M;
bsco_band = sbr->bsco;
}
for (k = xover_band; k < 64; k++)
#ifndef SBR_LOW_POWER
for (k = 0; k < kx_band + bsco_band; k++)
{
QMF_RE(X[l][k]) = QMF_RE(sbr->Xsbr[ch][l + sbr->tHFAdj][k]);
#ifndef SBR_LOW_POWER
QMF_IM(X[l][k]) = QMF_IM(sbr->Xsbr[ch][l + sbr->tHFAdj][k]);
#endif
}
#ifdef SBR_LOW_POWER
QMF_RE(X[l][xover_band - 1]) += QMF_RE(sbr->Xsbr[ch][l + sbr->tHFAdj][xover_band - 1]);
for (k = kx_band + bsco_band; k < kx_band + M_band; k++)
{
QMF_RE(X[l][k]) = QMF_RE(sbr->Xsbr[ch][l + sbr->tHFAdj][k]);
QMF_IM(X[l][k]) = QMF_IM(sbr->Xsbr[ch][l + sbr->tHFAdj][k]);
}
for (k = max(kx_band + bsco_band, kx_band + M_band); k < 64; k++)
{
QMF_RE(X[l][k]) = 0;
QMF_IM(X[l][k]) = 0;
}
#else
for (k = 0; k < kx_band + bsco_band; k++)
{
QMF_RE(X[l][k]) = QMF_RE(sbr->Xsbr[ch][l + sbr->tHFAdj][k]);
}
for (k = kx_band + bsco_band; k < min(kx_band + M_band, 63); k++)
{
QMF_RE(X[l][k]) = QMF_RE(sbr->Xsbr[ch][l + sbr->tHFAdj][k]);
}
for (k = max(kx_band + bsco_band, kx_band + M_band); k < 64; k++)
{
QMF_RE(X[l][k]) = 0;
}
QMF_RE(X[l][kx_band - 1 + bsco_band]) +=
QMF_RE(sbr->Xsbr[ch][l + sbr->tHFAdj][kx_band - 1 + bsco_band]);
#endif
}
}
for (i = 0; i < sbr->tHFGen; i++)
{
memmove(sbr->Xcodec[ch][i], sbr->Xcodec[ch][i+sbr->numTimeSlotsRate], 32 * sizeof(qmf_t));
memmove(sbr->Xsbr[ch][i], sbr->Xsbr[ch][i+sbr->numTimeSlotsRate], 64 * sizeof(qmf_t));
}
}
uint8_t sbrDecodeCoupleFrame(sbr_info *sbr, real_t *left_chan, real_t *right_chan,
const uint8_t just_seeked, const uint8_t upsample_only)
const uint8_t just_seeked, const uint8_t downSampledSBR)
{
uint8_t dont_process = 0;
uint8_t ret = 0;
@ -306,21 +403,23 @@ uint8_t sbrDecodeCoupleFrame(sbr_info *sbr, real_t *left_chan, real_t *right_cha
sbr->just_seeked = 0;
}
sbr_process_channel(sbr, left_chan, X, 0, dont_process);
sbr_process_channel(sbr, left_chan, X, 0, dont_process, downSampledSBR);
/* subband synthesis */
#ifndef USE_SSE
sbr_qmf_synthesis_64(sbr, sbr->qmfs[0], X, left_chan);
#else
sbr->qmfs[ch]->qmf_func(sbr, sbr->qmfs[0], X, left_chan);
#endif
if (downSampledSBR)
{
sbr_qmf_synthesis_32(sbr, sbr->qmfs[0], X, left_chan);
} else {
sbr_qmf_synthesis_64(sbr, sbr->qmfs[0], X, left_chan);
}
sbr_process_channel(sbr, right_chan, X, 1, dont_process);
sbr_process_channel(sbr, right_chan, X, 1, dont_process, downSampledSBR);
/* subband synthesis */
#ifndef USE_SSE
sbr_qmf_synthesis_64(sbr, sbr->qmfs[1], X, right_chan);
#else
sbr->qmfs[ch]->qmf_func(sbr, sbr->qmfs[1], X, right_chan);
#endif
if (downSampledSBR)
{
sbr_qmf_synthesis_32(sbr, sbr->qmfs[1], X, right_chan);
} else {
sbr_qmf_synthesis_64(sbr, sbr->qmfs[1], X, right_chan);
}
if (sbr->bs_header_flag)
sbr->just_seeked = 0;
@ -333,13 +432,31 @@ uint8_t sbrDecodeCoupleFrame(sbr_info *sbr, real_t *left_chan, real_t *right_cha
if (ret) return ret;
}
sbr_save_matrix(sbr, 0);
sbr_save_matrix(sbr, 1);
sbr->frame++;
//#define POST_QMF_PRINT
#ifdef POST_QMF_PRINT
{
int i;
for (i = 0; i < 2048; i++)
{
printf("%d\n", left_chan[i]);
}
for (i = 0; i < 2048; i++)
{
printf("%d\n", right_chan[i]);
}
}
#endif
return 0;
}
uint8_t sbrDecodeSingleFrame(sbr_info *sbr, real_t *channel,
const uint8_t just_seeked, const uint8_t upsample_only)
const uint8_t just_seeked, const uint8_t downSampledSBR)
{
uint8_t dont_process = 0;
uint8_t ret = 0;
@ -369,13 +486,14 @@ uint8_t sbrDecodeSingleFrame(sbr_info *sbr, real_t *channel,
sbr->just_seeked = 0;
}
sbr_process_channel(sbr, channel, X, 0, dont_process);
sbr_process_channel(sbr, channel, X, 0, dont_process, downSampledSBR);
/* subband synthesis */
#ifndef USE_SSE
sbr_qmf_synthesis_64(sbr, sbr->qmfs[0], X, channel);
#else
sbr->qmfs[ch]->qmf_func(sbr, sbr->qmfs[0], X, channel);
#endif
if (downSampledSBR)
{
sbr_qmf_synthesis_32(sbr, sbr->qmfs[0], X, channel);
} else {
sbr_qmf_synthesis_64(sbr, sbr->qmfs[0], X, channel);
}
if (sbr->bs_header_flag)
sbr->just_seeked = 0;
@ -386,39 +504,33 @@ uint8_t sbrDecodeSingleFrame(sbr_info *sbr, real_t *channel,
if (ret) return ret;
}
sbr_save_matrix(sbr, 0);
sbr->frame++;
//#define POST_QMF_PRINT
#ifdef POST_QMF_PRINT
{
int i;
for (i = 0; i < 2048; i++)
{
printf("%d\n", channel[i]);
}
}
#endif
return 0;
}
static void ps_dummy_function(qmf_t X_mono[MAX_NTSR][64],
qmf_t X_left[MAX_NTSR][64], qmf_t X_right[MAX_NTSR][64])
{
uint8_t i, j;
for (i = 0; i < MAX_NTSR; i++)
{
for (j = 0; j < 64; j++)
{
QMF_RE(X_left[i][j]) = QMF_RE(X_mono[i][j]);
QMF_RE(X_right[i][j]) = QMF_RE(X_mono[i][j]);
#ifndef SBR_LOW_POWER
QMF_IM(X_left[i][j]) = QMF_IM(X_mono[i][j]);
QMF_IM(X_right[i][j]) = QMF_IM(X_mono[i][j]);
#endif
}
}
}
#if (defined(PS_DEC) || defined(DRM_PS))
uint8_t sbrDecodeSingleFramePS(sbr_info *sbr, real_t *left_channel, real_t *right_channel,
const uint8_t just_seeked, const uint8_t upsample_only)
const uint8_t just_seeked, const uint8_t downSampledSBR)
{
uint8_t l, k;
uint8_t dont_process = 0;
uint8_t ret = 0;
ALIGN qmf_t X_mono[MAX_NTSR][64];
ALIGN qmf_t X_left[MAX_NTSR][64];
ALIGN qmf_t X_right[MAX_NTSR][64];
ALIGN qmf_t X_left[38][64] = {{0}};
ALIGN qmf_t X_right[38][64] = {{0}}; /* must set this to 0 */
if (sbr == NULL)
return 20;
@ -444,24 +556,46 @@ uint8_t sbrDecodeSingleFramePS(sbr_info *sbr, real_t *left_channel, real_t *righ
sbr->just_seeked = 0;
}
if (sbr->frame == 0)
if (sbr->qmfs[1] == NULL)
{
sbr->qmfs[1] = qmfs_init(64);
sbr->qmfs[1] = qmfs_init((downSampledSBR)?32:64);
}
sbr_process_channel(sbr, left_channel, X_mono, 0, dont_process);
sbr_process_channel(sbr, left_channel, X_left, 0, dont_process, downSampledSBR);
/* copy some extra data for PS */
for (l = 32; l < 38; l++)
{
for (k = 0; k < 5; k++)
{
QMF_RE(X_left[l][k]) = QMF_RE(sbr->Xsbr[0][sbr->tHFAdj+l][k]);
QMF_IM(X_left[l][k]) = QMF_IM(sbr->Xsbr[0][sbr->tHFAdj+l][k]);
}
}
/* perform parametric stereo */
ps_dummy_function(X_mono, X_left, X_right);
#ifdef DRM_PS
if (sbr->Is_DRM_SBR)
{
drm_ps_decode(sbr->drm_ps, sbr->sample_rate, X_left, X_right);
} else {
#endif
#ifdef PS_DEC
ps_decode(sbr->ps, X_left, X_right);
#endif
#ifdef DRM_PS
}
#endif
/* subband synthesis */
#ifndef USE_SSE
sbr_qmf_synthesis_64(sbr, sbr->qmfs[0], X_left, left_channel);
sbr_qmf_synthesis_64(sbr, sbr->qmfs[1], X_right, right_channel);
#else
sbr->qmfs[ch]->qmf_func(sbr, sbr->qmfs[0], X_left, left_channel);
sbr->qmfs[ch]->qmf_func(sbr, sbr->qmfs[1], X_right, right_channel);
#endif
if (downSampledSBR)
{
sbr_qmf_synthesis_32(sbr, sbr->qmfs[0], X_left, left_channel);
sbr_qmf_synthesis_32(sbr, sbr->qmfs[1], X_right, right_channel);
} else {
sbr_qmf_synthesis_64(sbr, sbr->qmfs[0], X_left, left_channel);
sbr_qmf_synthesis_64(sbr, sbr->qmfs[1], X_right, right_channel);
}
if (sbr->bs_header_flag)
sbr->just_seeked = 0;
@ -472,6 +606,8 @@ uint8_t sbrDecodeSingleFramePS(sbr_info *sbr, real_t *left_channel, real_t *righ
if (ret) return ret;
}
sbr_save_matrix(sbr, 0);
sbr->frame++;
return 0;

View File

@ -23,7 +23,7 @@
** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
**
** Initially modified for use with MPlayer by Arpad Gereöffy on 2003/08/30
** $Id: sbr_dec.h,v 1.3 2004/06/02 22:59:03 diego Exp $
** $Id: sbr_dec.h,v 1.4 2004/06/23 13:50:51 diego Exp $
** detailed CVS changelog at http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
**/
@ -45,24 +45,27 @@ extern "C" {
#define MAX_NTSRHFG 40
#define MAX_NTSR 32 /* max number_time_slots * rate, ok for DRM and not DRM mode */
/* MAX_M: maximum value for M */
#define MAX_M 49
/* MAX_L_E: maximum value for L_E */
#define MAX_L_E 5
typedef struct {
real_t *x;
int16_t x_index;
uint8_t channels;
} qmfa_info;
typedef struct {
real_t *v[2];
uint8_t v_index;
real_t *v;
int16_t v_index;
uint8_t channels;
#ifdef USE_SSE
void (*qmf_func)(void *a, void *b, void *c, void *d);
#endif
} qmfs_info;
typedef struct
{
uint32_t sample_rate;
uint32_t maxAACLine;
uint8_t rate;
uint8_t just_seeked;
@ -100,27 +103,33 @@ typedef struct
uint8_t L_E_prev[2];
uint8_t L_Q[2];
uint8_t t_E[2][6];
uint8_t t_E[2][MAX_L_E+1];
uint8_t t_Q[2][3];
uint8_t f[2][6];
uint8_t f[2][MAX_L_E+1];
uint8_t f_prev[2];
real_t *G_temp_prev[2][5];
real_t *Q_temp_prev[2][5];
int8_t GQ_ringbuf_index[2];
int16_t E[2][64][5];
int16_t E[2][64][MAX_L_E];
int16_t E_prev[2][64];
real_t E_orig[2][64][5];
real_t E_curr[2][64][5];
#ifndef FIXED_POINT
real_t E_orig[2][64][MAX_L_E];
#endif
real_t E_curr[2][64][MAX_L_E];
int32_t Q[2][64][2];
#ifndef FIXED_POINT
real_t Q_div[2][64][2];
real_t Q_div2[2][64][2];
#endif
int32_t Q_prev[2][64];
real_t Q_orig[2][64][2];
int8_t l_A[2];
int8_t l_A_prev[2];
uint8_t bs_invf_mode[2][5];
uint8_t bs_invf_mode_prev[2][5];
uint8_t bs_invf_mode[2][MAX_L_E];
uint8_t bs_invf_mode_prev[2][MAX_L_E];
real_t bwArray[2][64];
real_t bwArray_prev[2][64];
@ -144,6 +153,10 @@ typedef struct
int8_t prevEnvIsShort[2];
int8_t kx_prev;
uint8_t bsco;
uint8_t bsco_prev;
uint8_t M_prev;
uint16_t frame_len;
uint8_t Reset;
uint32_t frame;
@ -154,24 +167,21 @@ typedef struct
qmfs_info *qmfs[2];
qmf_t Xsbr[2][MAX_NTSRHFG][64];
qmf_t Xcodec[2][MAX_NTSRHFG][32];
#ifdef DRM
int8_t lcstereo_flag;
uint8_t bs_dataextra;
uint8_t Is_DRM_SBR;
#ifdef DRM_PS
drm_ps_info drm_ps;
drm_ps_info *drm_ps;
#endif
#endif
uint8_t numTimeSlotsRate;
uint8_t numTimeSlots;
uint8_t tHFGen;
uint8_t tHFAdj;
uint8_t numTimeSlotsRate;
uint8_t numTimeSlots;
uint8_t tHFGen;
uint8_t tHFAdj;
#ifdef PS_DEC
ps_info ps;
ps_info *ps;
#endif
#if (defined(PS_DEC) || defined(DRM_PS))
uint8_t ps_used;
@ -217,20 +227,20 @@ typedef struct
} sbr_info;
sbr_info *sbrDecodeInit(uint16_t framelength, uint8_t id_aac,
uint32_t sample_rate
uint32_t sample_rate, uint8_t downSampledSBR
#ifdef DRM
, uint8_t IsDRM
, uint8_t IsDRM
#endif
);
);
void sbrDecodeEnd(sbr_info *sbr);
uint8_t sbrDecodeCoupleFrame(sbr_info *sbr, real_t *left_chan, real_t *right_chan,
const uint8_t just_seeked, const uint8_t upsample_only);
const uint8_t just_seeked, const uint8_t downSampledSBR);
uint8_t sbrDecodeSingleFrame(sbr_info *sbr, real_t *channel,
const uint8_t just_seeked, const uint8_t upsample_only);
const uint8_t just_seeked, const uint8_t downSampledSBR);
#if (defined(PS_DEC) || defined(DRM_PS))
uint8_t sbrDecodeSingleFramePS(sbr_info *sbr, real_t *left_channel, real_t *right_channel,
const uint8_t just_seeked, const uint8_t upsample_only);
const uint8_t just_seeked, const uint8_t downSampledSBR);
#endif

View File

@ -23,7 +23,7 @@
** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
**
** Initially modified for use with MPlayer by Arpad Gereöffy on 2003/08/30
** $Id: sbr_e_nf.c,v 1.3 2004/06/02 22:59:03 diego Exp $
** $Id: sbr_e_nf.c,v 1.4 2004/06/23 13:50:51 diego Exp $
** detailed CVS changelog at http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
**/
@ -37,110 +37,6 @@
#include "sbr_syntax.h"
#include "sbr_e_nf.h"
ALIGN static const real_t pow2deq[] = {
REAL_CONST(2.9103830456733704E-011), REAL_CONST(5.8207660913467407E-011),
REAL_CONST(1.1641532182693481E-010), REAL_CONST(2.3283064365386963E-010),
REAL_CONST(4.6566128730773926E-010), REAL_CONST(9.3132257461547852E-010),
REAL_CONST(1.862645149230957E-009), REAL_CONST(3.7252902984619141E-009),
REAL_CONST(7.4505805969238281E-009), REAL_CONST(1.4901161193847656E-008),
REAL_CONST(2.9802322387695313E-008), REAL_CONST(5.9604644775390625E-008),
REAL_CONST(1.1920928955078125E-007), REAL_CONST(2.384185791015625E-007),
REAL_CONST(4.76837158203125E-007), REAL_CONST(9.5367431640625E-007),
REAL_CONST(1.9073486328125E-006), REAL_CONST(3.814697265625E-006),
REAL_CONST(7.62939453125E-006), REAL_CONST(1.52587890625E-005),
REAL_CONST(3.0517578125E-005), REAL_CONST(6.103515625E-005),
REAL_CONST(0.0001220703125), REAL_CONST(0.000244140625),
REAL_CONST(0.00048828125), REAL_CONST(0.0009765625),
REAL_CONST(0.001953125), REAL_CONST(0.00390625),
REAL_CONST(0.0078125), REAL_CONST(0.015625),
REAL_CONST(0.03125), REAL_CONST(0.0625),
REAL_CONST(0.125), REAL_CONST(0.25),
REAL_CONST(0.5), REAL_CONST(1.0),
REAL_CONST(2.0), REAL_CONST(4.0),
REAL_CONST(8.0), REAL_CONST(16.0),
REAL_CONST(32.0), REAL_CONST(64.0),
REAL_CONST(128.0), REAL_CONST(256.0),
REAL_CONST(512.0), REAL_CONST(1024.0),
REAL_CONST(2048.0), REAL_CONST(4096.0),
REAL_CONST(8192.0), REAL_CONST(16384.0),
REAL_CONST(32768.0), REAL_CONST(65536.0),
REAL_CONST(131072.0), REAL_CONST(262144.0),
REAL_CONST(524288.0), REAL_CONST(1048576.0),
REAL_CONST(2097152.0), REAL_CONST(4194304.0),
REAL_CONST(8388608.0), REAL_CONST(16777216.0),
REAL_CONST(33554432.0), REAL_CONST(67108864.0),
REAL_CONST(134217728.0), REAL_CONST(268435456.0),
REAL_CONST(536870912.0), REAL_CONST(1073741824.0),
REAL_CONST(2147483648.0), REAL_CONST(4294967296.0),
REAL_CONST(8589934592.0), REAL_CONST(17179869184.0),
REAL_CONST(34359738368.0), REAL_CONST(68719476736.0),
REAL_CONST(137438953472.0), REAL_CONST(274877906944.0),
REAL_CONST(549755813888.0), REAL_CONST(1099511627776.0),
REAL_CONST(2199023255552.0), REAL_CONST(4398046511104.0),
REAL_CONST(8796093022208.0), REAL_CONST(17592186044416.0),
REAL_CONST(35184372088832.0), REAL_CONST(70368744177664.0),
REAL_CONST(140737488355328.0), REAL_CONST(281474976710656.0),
REAL_CONST(562949953421312.0), REAL_CONST(1125899906842624.0),
REAL_CONST(2251799813685248.0), REAL_CONST(4503599627370496.0),
REAL_CONST(9007199254740992.0), REAL_CONST(18014398509481984.0),
REAL_CONST(36028797018963968.0), REAL_CONST(72057594037927936.0),
REAL_CONST(144115188075855870.0), REAL_CONST(288230376151711740.0),
REAL_CONST(576460752303423490.0), REAL_CONST(1152921504606847000.0),
REAL_CONST(2305843009213694000.0), REAL_CONST(4611686018427387900.0),
REAL_CONST(9223372036854775800.0), REAL_CONST(1.8446744073709552E+019),
REAL_CONST(3.6893488147419103E+019), REAL_CONST(7.3786976294838206E+019),
REAL_CONST(1.4757395258967641E+020), REAL_CONST(2.9514790517935283E+020),
REAL_CONST(5.9029581035870565E+020), REAL_CONST(1.1805916207174113E+021),
REAL_CONST(2.3611832414348226E+021), REAL_CONST(4.7223664828696452E+021),
REAL_CONST(9.4447329657392904E+021), REAL_CONST(1.8889465931478581E+022),
REAL_CONST(3.7778931862957162E+022), REAL_CONST(7.5557863725914323E+022),
REAL_CONST(1.5111572745182865E+023), REAL_CONST(3.0223145490365729E+023),
REAL_CONST(6.0446290980731459E+023), REAL_CONST(1.2089258196146292E+024),
REAL_CONST(2.4178516392292583E+024), REAL_CONST(4.8357032784585167E+024),
REAL_CONST(9.6714065569170334E+024), REAL_CONST(1.9342813113834067E+025),
REAL_CONST(3.8685626227668134E+025), REAL_CONST(7.7371252455336267E+025),
REAL_CONST(1.5474250491067253E+026), REAL_CONST(3.0948500982134507E+026),
REAL_CONST(6.1897001964269014E+026), REAL_CONST(1.2379400392853803E+027),
REAL_CONST(2.4758800785707605E+027)
};
/* 1.0 / (1.0 + pow(2.0, x - 12) */
ALIGN static const real_t pow2deq_rcp[] = {
FRAC_CONST(0.99975591896509641),
FRAC_CONST(0.99951195705222062),
FRAC_CONST(0.99902439024390244),
FRAC_CONST(0.99805068226120852),
FRAC_CONST(0.99610894941634243),
FRAC_CONST(0.99224806201550386),
FRAC_CONST(0.98461538461538467),
FRAC_CONST(0.96969696969696972),
FRAC_CONST(0.94117647058823528),
FRAC_CONST(0.88888888888888884),
FRAC_CONST(0.80000000000000004),
FRAC_CONST(0.66666666666666663),
FRAC_CONST(0.5),
FRAC_CONST(0.33333333333333331),
FRAC_CONST(0.20000000000000001),
FRAC_CONST(0.1111111111111111),
FRAC_CONST(0.058823529411764705),
FRAC_CONST(0.030303030303030304),
FRAC_CONST(0.015384615384615385),
FRAC_CONST(0.0077519379844961239),
FRAC_CONST(0.0038910505836575876),
FRAC_CONST(0.0019493177387914229),
FRAC_CONST(0.00097560975609756097),
FRAC_CONST(0.0004880429477794046),
FRAC_CONST(0.00024408103490358799),
FRAC_CONST(0.00012205541315757354),
FRAC_CONST(6.1031431187061336E-005),
FRAC_CONST(3.0516646830846227E-005),
FRAC_CONST(1.5258556235409006E-005),
FRAC_CONST(7.6293363240331724E-006),
FRAC_CONST(3.8146827137652828E-006),
FRAC_CONST(1.9073449948406318E-006),
FRAC_CONST(9.5367340691241559E-007)
};
void extract_envelope_data(sbr_info *sbr, uint8_t ch)
{
uint8_t l, k;
@ -152,6 +48,8 @@ void extract_envelope_data(sbr_info *sbr, uint8_t ch)
for (k = 1; k < sbr->n[sbr->f[ch][l]]; k++)
{
sbr->E[ch][k][l] = sbr->E[ch][k - 1][l] + sbr->E[ch][k][l];
if (sbr->E[ch][k][l] < 0)
sbr->E[ch][k][l] = 0;
}
} else { /* bs_df_env == 1 */
@ -243,6 +141,256 @@ void extract_noise_floor_data(sbr_info *sbr, uint8_t ch)
}
}
#ifndef FIXED_POINT
/* table for Q_div values when no coupling */
static const real_t Q_div_tab[31] = {
FRAC_CONST(0.0153846), FRAC_CONST(0.030303),
FRAC_CONST(0.0588235), FRAC_CONST(0.111111),
FRAC_CONST(0.2), FRAC_CONST(0.333333),
FRAC_CONST(0.5), FRAC_CONST(0.666667),
FRAC_CONST(0.8), FRAC_CONST(0.888889),
FRAC_CONST(0.941176), FRAC_CONST(0.969697),
FRAC_CONST(0.984615), FRAC_CONST(0.992248),
FRAC_CONST(0.996109), FRAC_CONST(0.998051),
FRAC_CONST(0.999024), FRAC_CONST(0.999512),
FRAC_CONST(0.999756), FRAC_CONST(0.999878),
FRAC_CONST(0.999939), FRAC_CONST(0.999969),
FRAC_CONST(0.999985), FRAC_CONST(0.999992),
FRAC_CONST(0.999996), FRAC_CONST(0.999998),
FRAC_CONST(0.999999), FRAC_CONST(1),
FRAC_CONST(1), FRAC_CONST(1),
FRAC_CONST(1)
};
static const real_t Q_div_tab_left[31][13] = {
{ FRAC_CONST(0.969704), FRAC_CONST(0.888985), FRAC_CONST(0.667532), FRAC_CONST(0.336788), FRAC_CONST(0.117241), FRAC_CONST(0.037594), FRAC_CONST(0.0153846), FRAC_CONST(0.00967118), FRAC_CONST(0.00823245), FRAC_CONST(0.00787211), FRAC_CONST(0.00778198), FRAC_CONST(0.00775945), FRAC_CONST(0.00775382) },
{ FRAC_CONST(0.984619), FRAC_CONST(0.94123), FRAC_CONST(0.800623), FRAC_CONST(0.503876), FRAC_CONST(0.209877), FRAC_CONST(0.0724638), FRAC_CONST(0.030303), FRAC_CONST(0.0191571), FRAC_CONST(0.0163305), FRAC_CONST(0.0156212), FRAC_CONST(0.0154438), FRAC_CONST(0.0153994), FRAC_CONST(0.0153883) },
{ FRAC_CONST(0.99225), FRAC_CONST(0.969726), FRAC_CONST(0.889273), FRAC_CONST(0.670103), FRAC_CONST(0.346939), FRAC_CONST(0.135135), FRAC_CONST(0.0588235), FRAC_CONST(0.037594), FRAC_CONST(0.0321361), FRAC_CONST(0.0307619), FRAC_CONST(0.0304178), FRAC_CONST(0.0303317), FRAC_CONST(0.0303102) },
{ FRAC_CONST(0.99611), FRAC_CONST(0.98463), FRAC_CONST(0.941392), FRAC_CONST(0.802469), FRAC_CONST(0.515152), FRAC_CONST(0.238095), FRAC_CONST(0.111111), FRAC_CONST(0.0724638), FRAC_CONST(0.0622711), FRAC_CONST(0.0596878), FRAC_CONST(0.0590397), FRAC_CONST(0.0588776), FRAC_CONST(0.058837) },
{ FRAC_CONST(0.998051), FRAC_CONST(0.992256), FRAC_CONST(0.969811), FRAC_CONST(0.890411), FRAC_CONST(0.68), FRAC_CONST(0.384615), FRAC_CONST(0.2), FRAC_CONST(0.135135), FRAC_CONST(0.117241), FRAC_CONST(0.112652), FRAC_CONST(0.111497), FRAC_CONST(0.111208), FRAC_CONST(0.111135) },
{ FRAC_CONST(0.999025), FRAC_CONST(0.996113), FRAC_CONST(0.984674), FRAC_CONST(0.942029), FRAC_CONST(0.809524), FRAC_CONST(0.555556), FRAC_CONST(0.333333), FRAC_CONST(0.238095), FRAC_CONST(0.209877), FRAC_CONST(0.202492), FRAC_CONST(0.200625), FRAC_CONST(0.200156), FRAC_CONST(0.200039) },
{ FRAC_CONST(0.999512), FRAC_CONST(0.998053), FRAC_CONST(0.992278), FRAC_CONST(0.970149), FRAC_CONST(0.894737), FRAC_CONST(0.714286), FRAC_CONST(0.5), FRAC_CONST(0.384615), FRAC_CONST(0.346939), FRAC_CONST(0.336788), FRAC_CONST(0.3342), FRAC_CONST(0.33355), FRAC_CONST(0.333388) },
{ FRAC_CONST(0.999756), FRAC_CONST(0.999025), FRAC_CONST(0.996124), FRAC_CONST(0.984848), FRAC_CONST(0.944444), FRAC_CONST(0.833333), FRAC_CONST(0.666667), FRAC_CONST(0.555556), FRAC_CONST(0.515152), FRAC_CONST(0.503876), FRAC_CONST(0.500975), FRAC_CONST(0.500244), FRAC_CONST(0.500061) },
{ FRAC_CONST(0.999878), FRAC_CONST(0.999512), FRAC_CONST(0.998058), FRAC_CONST(0.992366), FRAC_CONST(0.971429), FRAC_CONST(0.909091), FRAC_CONST(0.8), FRAC_CONST(0.714286), FRAC_CONST(0.68), FRAC_CONST(0.670103), FRAC_CONST(0.667532), FRAC_CONST(0.666884), FRAC_CONST(0.666721) },
{ FRAC_CONST(0.999939), FRAC_CONST(0.999756), FRAC_CONST(0.999028), FRAC_CONST(0.996169), FRAC_CONST(0.985507), FRAC_CONST(0.952381), FRAC_CONST(0.888889), FRAC_CONST(0.833333), FRAC_CONST(0.809524), FRAC_CONST(0.802469), FRAC_CONST(0.800623), FRAC_CONST(0.800156), FRAC_CONST(0.800039) },
{ FRAC_CONST(0.999969), FRAC_CONST(0.999878), FRAC_CONST(0.999514), FRAC_CONST(0.998081), FRAC_CONST(0.992701), FRAC_CONST(0.97561), FRAC_CONST(0.941176), FRAC_CONST(0.909091), FRAC_CONST(0.894737), FRAC_CONST(0.890411), FRAC_CONST(0.889273), FRAC_CONST(0.888985), FRAC_CONST(0.888913) },
{ FRAC_CONST(0.999985), FRAC_CONST(0.999939), FRAC_CONST(0.999757), FRAC_CONST(0.999039), FRAC_CONST(0.996337), FRAC_CONST(0.987654), FRAC_CONST(0.969697), FRAC_CONST(0.952381), FRAC_CONST(0.944444), FRAC_CONST(0.942029), FRAC_CONST(0.941392), FRAC_CONST(0.94123), FRAC_CONST(0.94119) },
{ FRAC_CONST(0.999992), FRAC_CONST(0.99997), FRAC_CONST(0.999878), FRAC_CONST(0.999519), FRAC_CONST(0.998165), FRAC_CONST(0.993789), FRAC_CONST(0.984615), FRAC_CONST(0.97561), FRAC_CONST(0.971429), FRAC_CONST(0.970149), FRAC_CONST(0.969811), FRAC_CONST(0.969726), FRAC_CONST(0.969704) },
{ FRAC_CONST(0.999996), FRAC_CONST(0.999985), FRAC_CONST(0.999939), FRAC_CONST(0.99976), FRAC_CONST(0.999082), FRAC_CONST(0.996885), FRAC_CONST(0.992248), FRAC_CONST(0.987654), FRAC_CONST(0.985507), FRAC_CONST(0.984848), FRAC_CONST(0.984674), FRAC_CONST(0.98463), FRAC_CONST(0.984619) },
{ FRAC_CONST(0.999998), FRAC_CONST(0.999992), FRAC_CONST(0.99997), FRAC_CONST(0.99988), FRAC_CONST(0.999541), FRAC_CONST(0.99844), FRAC_CONST(0.996109), FRAC_CONST(0.993789), FRAC_CONST(0.992701), FRAC_CONST(0.992366), FRAC_CONST(0.992278), FRAC_CONST(0.992256), FRAC_CONST(0.99225) },
{ FRAC_CONST(0.999999), FRAC_CONST(0.999996), FRAC_CONST(0.999985), FRAC_CONST(0.99994), FRAC_CONST(0.99977), FRAC_CONST(0.999219), FRAC_CONST(0.998051), FRAC_CONST(0.996885), FRAC_CONST(0.996337), FRAC_CONST(0.996169), FRAC_CONST(0.996124), FRAC_CONST(0.996113), FRAC_CONST(0.99611) },
{ FRAC_CONST(1), FRAC_CONST(0.999998), FRAC_CONST(0.999992), FRAC_CONST(0.99997), FRAC_CONST(0.999885), FRAC_CONST(0.99961), FRAC_CONST(0.999024), FRAC_CONST(0.99844), FRAC_CONST(0.998165), FRAC_CONST(0.998081), FRAC_CONST(0.998058), FRAC_CONST(0.998053), FRAC_CONST(0.998051) },
{ FRAC_CONST(1), FRAC_CONST(0.999999), FRAC_CONST(0.999996), FRAC_CONST(0.999985), FRAC_CONST(0.999943), FRAC_CONST(0.999805), FRAC_CONST(0.999512), FRAC_CONST(0.999219), FRAC_CONST(0.999082), FRAC_CONST(0.999039), FRAC_CONST(0.999028), FRAC_CONST(0.999025), FRAC_CONST(0.999025) },
{ FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(0.999998), FRAC_CONST(0.999992), FRAC_CONST(0.999971), FRAC_CONST(0.999902), FRAC_CONST(0.999756), FRAC_CONST(0.99961), FRAC_CONST(0.999541), FRAC_CONST(0.999519), FRAC_CONST(0.999514), FRAC_CONST(0.999512), FRAC_CONST(0.999512) },
{ FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(0.999999), FRAC_CONST(0.999996), FRAC_CONST(0.999986), FRAC_CONST(0.999951), FRAC_CONST(0.999878), FRAC_CONST(0.999805), FRAC_CONST(0.99977), FRAC_CONST(0.99976), FRAC_CONST(0.999757), FRAC_CONST(0.999756), FRAC_CONST(0.999756) },
{ FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(0.999998), FRAC_CONST(0.999993), FRAC_CONST(0.999976), FRAC_CONST(0.999939), FRAC_CONST(0.999902), FRAC_CONST(0.999885), FRAC_CONST(0.99988), FRAC_CONST(0.999878), FRAC_CONST(0.999878), FRAC_CONST(0.999878) },
{ FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(0.999999), FRAC_CONST(0.999996), FRAC_CONST(0.999988), FRAC_CONST(0.999969), FRAC_CONST(0.999951), FRAC_CONST(0.999943), FRAC_CONST(0.99994), FRAC_CONST(0.999939), FRAC_CONST(0.999939), FRAC_CONST(0.999939) },
{ FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(0.999998), FRAC_CONST(0.999994), FRAC_CONST(0.999985), FRAC_CONST(0.999976), FRAC_CONST(0.999971), FRAC_CONST(0.99997), FRAC_CONST(0.99997), FRAC_CONST(0.99997), FRAC_CONST(0.999969) },
{ FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(0.999999), FRAC_CONST(0.999997), FRAC_CONST(0.999992), FRAC_CONST(0.999988), FRAC_CONST(0.999986), FRAC_CONST(0.999985), FRAC_CONST(0.999985), FRAC_CONST(0.999985), FRAC_CONST(0.999985) },
{ FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(0.999998), FRAC_CONST(0.999996), FRAC_CONST(0.999994), FRAC_CONST(0.999993), FRAC_CONST(0.999992), FRAC_CONST(0.999992), FRAC_CONST(0.999992), FRAC_CONST(0.999992) },
{ FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(0.999999), FRAC_CONST(0.999998), FRAC_CONST(0.999997), FRAC_CONST(0.999996), FRAC_CONST(0.999996), FRAC_CONST(0.999996), FRAC_CONST(0.999996), FRAC_CONST(0.999996) },
{ FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(0.999999), FRAC_CONST(0.999998), FRAC_CONST(0.999998), FRAC_CONST(0.999998), FRAC_CONST(0.999998), FRAC_CONST(0.999998), FRAC_CONST(0.999998) },
{ FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(0.999999), FRAC_CONST(0.999999), FRAC_CONST(0.999999), FRAC_CONST(0.999999), FRAC_CONST(0.999999), FRAC_CONST(0.999999) },
{ FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1) },
{ FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1) },
{ FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1) }
};
static const real_t Q_div_tab_right[31][13] = {
{ FRAC_CONST(0.00775382), FRAC_CONST(0.00775945), FRAC_CONST(0.00778198), FRAC_CONST(0.00787211), FRAC_CONST(0.00823245), FRAC_CONST(0.00967118), FRAC_CONST(0.0153846), FRAC_CONST(0.037594), FRAC_CONST(0.117241), FRAC_CONST(0.336788), FRAC_CONST(0.667532), FRAC_CONST(0.888985), FRAC_CONST(0.969704) },
{ FRAC_CONST(0.0153883), FRAC_CONST(0.0153994), FRAC_CONST(0.0154438), FRAC_CONST(0.0156212), FRAC_CONST(0.0163305), FRAC_CONST(0.0191571), FRAC_CONST(0.030303), FRAC_CONST(0.0724638), FRAC_CONST(0.209877), FRAC_CONST(0.503876), FRAC_CONST(0.800623), FRAC_CONST(0.94123), FRAC_CONST(0.984619) },
{ FRAC_CONST(0.0303102), FRAC_CONST(0.0303317), FRAC_CONST(0.0304178), FRAC_CONST(0.0307619), FRAC_CONST(0.0321361), FRAC_CONST(0.037594), FRAC_CONST(0.0588235), FRAC_CONST(0.135135), FRAC_CONST(0.346939), FRAC_CONST(0.670103), FRAC_CONST(0.889273), FRAC_CONST(0.969726), FRAC_CONST(0.99225) },
{ FRAC_CONST(0.058837), FRAC_CONST(0.0588776), FRAC_CONST(0.0590397), FRAC_CONST(0.0596878), FRAC_CONST(0.0622711), FRAC_CONST(0.0724638), FRAC_CONST(0.111111), FRAC_CONST(0.238095), FRAC_CONST(0.515152), FRAC_CONST(0.802469), FRAC_CONST(0.941392), FRAC_CONST(0.98463), FRAC_CONST(0.99611) },
{ FRAC_CONST(0.111135), FRAC_CONST(0.111208), FRAC_CONST(0.111497), FRAC_CONST(0.112652), FRAC_CONST(0.117241), FRAC_CONST(0.135135), FRAC_CONST(0.2), FRAC_CONST(0.384615), FRAC_CONST(0.68), FRAC_CONST(0.890411), FRAC_CONST(0.969811), FRAC_CONST(0.992256), FRAC_CONST(0.998051) },
{ FRAC_CONST(0.200039), FRAC_CONST(0.200156), FRAC_CONST(0.200625), FRAC_CONST(0.202492), FRAC_CONST(0.209877), FRAC_CONST(0.238095), FRAC_CONST(0.333333), FRAC_CONST(0.555556), FRAC_CONST(0.809524), FRAC_CONST(0.942029), FRAC_CONST(0.984674), FRAC_CONST(0.996113), FRAC_CONST(0.999025) },
{ FRAC_CONST(0.333388), FRAC_CONST(0.33355), FRAC_CONST(0.3342), FRAC_CONST(0.336788), FRAC_CONST(0.346939), FRAC_CONST(0.384615), FRAC_CONST(0.5), FRAC_CONST(0.714286), FRAC_CONST(0.894737), FRAC_CONST(0.970149), FRAC_CONST(0.992278), FRAC_CONST(0.998053), FRAC_CONST(0.999512) },
{ FRAC_CONST(0.500061), FRAC_CONST(0.500244), FRAC_CONST(0.500975), FRAC_CONST(0.503876), FRAC_CONST(0.515152), FRAC_CONST(0.555556), FRAC_CONST(0.666667), FRAC_CONST(0.833333), FRAC_CONST(0.944444), FRAC_CONST(0.984848), FRAC_CONST(0.996124), FRAC_CONST(0.999025), FRAC_CONST(0.999756) },
{ FRAC_CONST(0.666721), FRAC_CONST(0.666884), FRAC_CONST(0.667532), FRAC_CONST(0.670103), FRAC_CONST(0.68), FRAC_CONST(0.714286), FRAC_CONST(0.8), FRAC_CONST(0.909091), FRAC_CONST(0.971429), FRAC_CONST(0.992366), FRAC_CONST(0.998058), FRAC_CONST(0.999512), FRAC_CONST(0.999878) },
{ FRAC_CONST(0.800039), FRAC_CONST(0.800156), FRAC_CONST(0.800623), FRAC_CONST(0.802469), FRAC_CONST(0.809524), FRAC_CONST(0.833333), FRAC_CONST(0.888889), FRAC_CONST(0.952381), FRAC_CONST(0.985507), FRAC_CONST(0.996169), FRAC_CONST(0.999028), FRAC_CONST(0.999756), FRAC_CONST(0.999939) },
{ FRAC_CONST(0.888913), FRAC_CONST(0.888985), FRAC_CONST(0.889273), FRAC_CONST(0.890411), FRAC_CONST(0.894737), FRAC_CONST(0.909091), FRAC_CONST(0.941176), FRAC_CONST(0.97561), FRAC_CONST(0.992701), FRAC_CONST(0.998081), FRAC_CONST(0.999514), FRAC_CONST(0.999878), FRAC_CONST(0.999969) },
{ FRAC_CONST(0.94119), FRAC_CONST(0.94123), FRAC_CONST(0.941392), FRAC_CONST(0.942029), FRAC_CONST(0.944444), FRAC_CONST(0.952381), FRAC_CONST(0.969697), FRAC_CONST(0.987654), FRAC_CONST(0.996337), FRAC_CONST(0.999039), FRAC_CONST(0.999757), FRAC_CONST(0.999939), FRAC_CONST(0.999985) },
{ FRAC_CONST(0.969704), FRAC_CONST(0.969726), FRAC_CONST(0.969811), FRAC_CONST(0.970149), FRAC_CONST(0.971429), FRAC_CONST(0.97561), FRAC_CONST(0.984615), FRAC_CONST(0.993789), FRAC_CONST(0.998165), FRAC_CONST(0.999519), FRAC_CONST(0.999878), FRAC_CONST(0.99997), FRAC_CONST(0.999992) },
{ FRAC_CONST(0.984619), FRAC_CONST(0.98463), FRAC_CONST(0.984674), FRAC_CONST(0.984848), FRAC_CONST(0.985507), FRAC_CONST(0.987654), FRAC_CONST(0.992248), FRAC_CONST(0.996885), FRAC_CONST(0.999082), FRAC_CONST(0.99976), FRAC_CONST(0.999939), FRAC_CONST(0.999985), FRAC_CONST(0.999996) },
{ FRAC_CONST(0.99225), FRAC_CONST(0.992256), FRAC_CONST(0.992278), FRAC_CONST(0.992366), FRAC_CONST(0.992701), FRAC_CONST(0.993789), FRAC_CONST(0.996109), FRAC_CONST(0.99844), FRAC_CONST(0.999541), FRAC_CONST(0.99988), FRAC_CONST(0.99997), FRAC_CONST(0.999992), FRAC_CONST(0.999998) },
{ FRAC_CONST(0.99611), FRAC_CONST(0.996113), FRAC_CONST(0.996124), FRAC_CONST(0.996169), FRAC_CONST(0.996337), FRAC_CONST(0.996885), FRAC_CONST(0.998051), FRAC_CONST(0.999219), FRAC_CONST(0.99977), FRAC_CONST(0.99994), FRAC_CONST(0.999985), FRAC_CONST(0.999996), FRAC_CONST(0.999999) },
{ FRAC_CONST(0.998051), FRAC_CONST(0.998053), FRAC_CONST(0.998058), FRAC_CONST(0.998081), FRAC_CONST(0.998165), FRAC_CONST(0.99844), FRAC_CONST(0.999024), FRAC_CONST(0.99961), FRAC_CONST(0.999885), FRAC_CONST(0.99997), FRAC_CONST(0.999992), FRAC_CONST(0.999998), FRAC_CONST(1) },
{ FRAC_CONST(0.999025), FRAC_CONST(0.999025), FRAC_CONST(0.999028), FRAC_CONST(0.999039), FRAC_CONST(0.999082), FRAC_CONST(0.999219), FRAC_CONST(0.999512), FRAC_CONST(0.999805), FRAC_CONST(0.999943), FRAC_CONST(0.999985), FRAC_CONST(0.999996), FRAC_CONST(0.999999), FRAC_CONST(1) },
{ FRAC_CONST(0.999512), FRAC_CONST(0.999512), FRAC_CONST(0.999514), FRAC_CONST(0.999519), FRAC_CONST(0.999541), FRAC_CONST(0.99961), FRAC_CONST(0.999756), FRAC_CONST(0.999902), FRAC_CONST(0.999971), FRAC_CONST(0.999992), FRAC_CONST(0.999998), FRAC_CONST(1), FRAC_CONST(1) },
{ FRAC_CONST(0.999756), FRAC_CONST(0.999756), FRAC_CONST(0.999757), FRAC_CONST(0.99976), FRAC_CONST(0.99977), FRAC_CONST(0.999805), FRAC_CONST(0.999878), FRAC_CONST(0.999951), FRAC_CONST(0.999986), FRAC_CONST(0.999996), FRAC_CONST(0.999999), FRAC_CONST(1), FRAC_CONST(1) },
{ FRAC_CONST(0.999878), FRAC_CONST(0.999878), FRAC_CONST(0.999878), FRAC_CONST(0.99988), FRAC_CONST(0.999885), FRAC_CONST(0.999902), FRAC_CONST(0.999939), FRAC_CONST(0.999976), FRAC_CONST(0.999993), FRAC_CONST(0.999998), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1) },
{ FRAC_CONST(0.999939), FRAC_CONST(0.999939), FRAC_CONST(0.999939), FRAC_CONST(0.99994), FRAC_CONST(0.999943), FRAC_CONST(0.999951), FRAC_CONST(0.999969), FRAC_CONST(0.999988), FRAC_CONST(0.999996), FRAC_CONST(0.999999), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1) },
{ FRAC_CONST(0.999969), FRAC_CONST(0.99997), FRAC_CONST(0.99997), FRAC_CONST(0.99997), FRAC_CONST(0.999971), FRAC_CONST(0.999976), FRAC_CONST(0.999985), FRAC_CONST(0.999994), FRAC_CONST(0.999998), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1) },
{ FRAC_CONST(0.999985), FRAC_CONST(0.999985), FRAC_CONST(0.999985), FRAC_CONST(0.999985), FRAC_CONST(0.999986), FRAC_CONST(0.999988), FRAC_CONST(0.999992), FRAC_CONST(0.999997), FRAC_CONST(0.999999), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1) },
{ FRAC_CONST(0.999992), FRAC_CONST(0.999992), FRAC_CONST(0.999992), FRAC_CONST(0.999992), FRAC_CONST(0.999993), FRAC_CONST(0.999994), FRAC_CONST(0.999996), FRAC_CONST(0.999998), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1) },
{ FRAC_CONST(0.999996), FRAC_CONST(0.999996), FRAC_CONST(0.999996), FRAC_CONST(0.999996), FRAC_CONST(0.999996), FRAC_CONST(0.999997), FRAC_CONST(0.999998), FRAC_CONST(0.999999), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1) },
{ FRAC_CONST(0.999998), FRAC_CONST(0.999998), FRAC_CONST(0.999998), FRAC_CONST(0.999998), FRAC_CONST(0.999998), FRAC_CONST(0.999998), FRAC_CONST(0.999999), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1) },
{ FRAC_CONST(0.999999), FRAC_CONST(0.999999), FRAC_CONST(0.999999), FRAC_CONST(0.999999), FRAC_CONST(0.999999), FRAC_CONST(0.999999), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1) },
{ FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1) },
{ FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1) },
{ FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1) }
};
/* calculates 1/(1+Q) */
/* [0..1] */
real_t calc_Q_div(sbr_info *sbr, uint8_t ch, uint8_t m, uint8_t l)
{
if (sbr->bs_coupling)
{
/* left channel */
if ((sbr->Q[0][m][l] < 0 || sbr->Q[0][m][l] > 30) ||
(sbr->Q[1][m][l] < 0 || sbr->Q[1][m][l] > 24 /* 2*panOffset(1) */))
{
return 0;
} else {
/* the pan parameter is always even */
if (ch == 0)
{
return Q_div_tab_left[sbr->Q[0][m][l]][sbr->Q[1][m][l] >> 1];
} else {
return Q_div_tab_right[sbr->Q[0][m][l]][sbr->Q[1][m][l] >> 1];
}
}
} else {
/* no coupling */
if (sbr->Q[ch][m][l] < 0 || sbr->Q[ch][m][l] > 30)
{
return 0;
} else {
return Q_div_tab[sbr->Q[ch][m][l]];
}
}
}
/* table for Q_div2 values when no coupling */
static const real_t Q_div2_tab[31] = {
FRAC_CONST(0.984615), FRAC_CONST(0.969697),
FRAC_CONST(0.941176), FRAC_CONST(0.888889),
FRAC_CONST(0.8), FRAC_CONST(0.666667),
FRAC_CONST(0.5), FRAC_CONST(0.333333),
FRAC_CONST(0.2), FRAC_CONST(0.111111),
FRAC_CONST(0.0588235), FRAC_CONST(0.030303),
FRAC_CONST(0.0153846), FRAC_CONST(0.00775194),
FRAC_CONST(0.00389105), FRAC_CONST(0.00194932),
FRAC_CONST(0.00097561), FRAC_CONST(0.000488043),
FRAC_CONST(0.000244081), FRAC_CONST(0.000122055),
FRAC_CONST(6.10314E-005), FRAC_CONST(3.05166E-005),
FRAC_CONST(1.52586E-005), FRAC_CONST(7.62934E-006),
FRAC_CONST(3.81468E-006), FRAC_CONST(1.90734E-006),
FRAC_CONST(9.53673E-007), FRAC_CONST(4.76837E-007),
FRAC_CONST(2.38419E-007), FRAC_CONST(1.19209E-007),
FRAC_CONST(5.96046E-008)
};
static const real_t Q_div2_tab_left[31][13] = {
{ FRAC_CONST(0.0302959), FRAC_CONST(0.111015), FRAC_CONST(0.332468), FRAC_CONST(0.663212), FRAC_CONST(0.882759), FRAC_CONST(0.962406), FRAC_CONST(0.984615), FRAC_CONST(0.990329), FRAC_CONST(0.991768), FRAC_CONST(0.992128), FRAC_CONST(0.992218), FRAC_CONST(0.992241), FRAC_CONST(0.992246) },
{ FRAC_CONST(0.0153809), FRAC_CONST(0.0587695), FRAC_CONST(0.199377), FRAC_CONST(0.496124), FRAC_CONST(0.790123), FRAC_CONST(0.927536), FRAC_CONST(0.969697), FRAC_CONST(0.980843), FRAC_CONST(0.98367), FRAC_CONST(0.984379), FRAC_CONST(0.984556), FRAC_CONST(0.984601), FRAC_CONST(0.984612) },
{ FRAC_CONST(0.00775006), FRAC_CONST(0.0302744), FRAC_CONST(0.110727), FRAC_CONST(0.329897), FRAC_CONST(0.653061), FRAC_CONST(0.864865), FRAC_CONST(0.941176), FRAC_CONST(0.962406), FRAC_CONST(0.967864), FRAC_CONST(0.969238), FRAC_CONST(0.969582), FRAC_CONST(0.969668), FRAC_CONST(0.96969) },
{ FRAC_CONST(0.0038901), FRAC_CONST(0.0153698), FRAC_CONST(0.0586081), FRAC_CONST(0.197531), FRAC_CONST(0.484848), FRAC_CONST(0.761905), FRAC_CONST(0.888889), FRAC_CONST(0.927536), FRAC_CONST(0.937729), FRAC_CONST(0.940312), FRAC_CONST(0.94096), FRAC_CONST(0.941122), FRAC_CONST(0.941163) },
{ FRAC_CONST(0.00194884), FRAC_CONST(0.00774443), FRAC_CONST(0.0301887), FRAC_CONST(0.109589), FRAC_CONST(0.32), FRAC_CONST(0.615385), FRAC_CONST(0.8), FRAC_CONST(0.864865), FRAC_CONST(0.882759), FRAC_CONST(0.887348), FRAC_CONST(0.888503), FRAC_CONST(0.888792), FRAC_CONST(0.888865) },
{ FRAC_CONST(0.000975372), FRAC_CONST(0.00388727), FRAC_CONST(0.0153257), FRAC_CONST(0.057971), FRAC_CONST(0.190476), FRAC_CONST(0.444444), FRAC_CONST(0.666667), FRAC_CONST(0.761905), FRAC_CONST(0.790123), FRAC_CONST(0.797508), FRAC_CONST(0.799375), FRAC_CONST(0.799844), FRAC_CONST(0.799961) },
{ FRAC_CONST(0.000487924), FRAC_CONST(0.00194742), FRAC_CONST(0.00772201), FRAC_CONST(0.0298507), FRAC_CONST(0.105263), FRAC_CONST(0.285714), FRAC_CONST(0.5), FRAC_CONST(0.615385), FRAC_CONST(0.653061), FRAC_CONST(0.663212), FRAC_CONST(0.6658), FRAC_CONST(0.66645), FRAC_CONST(0.666612) },
{ FRAC_CONST(0.000244021), FRAC_CONST(0.000974659), FRAC_CONST(0.00387597), FRAC_CONST(0.0151515), FRAC_CONST(0.0555556), FRAC_CONST(0.166667), FRAC_CONST(0.333333), FRAC_CONST(0.444444), FRAC_CONST(0.484848), FRAC_CONST(0.496124), FRAC_CONST(0.499025), FRAC_CONST(0.499756), FRAC_CONST(0.499939) },
{ FRAC_CONST(0.000122026), FRAC_CONST(0.000487567), FRAC_CONST(0.00194175), FRAC_CONST(0.00763359), FRAC_CONST(0.0285714), FRAC_CONST(0.0909091), FRAC_CONST(0.2), FRAC_CONST(0.285714), FRAC_CONST(0.32), FRAC_CONST(0.329897), FRAC_CONST(0.332468), FRAC_CONST(0.333116), FRAC_CONST(0.333279) },
{ FRAC_CONST(6.10165E-005), FRAC_CONST(0.000243843), FRAC_CONST(0.000971817), FRAC_CONST(0.00383142), FRAC_CONST(0.0144928), FRAC_CONST(0.047619), FRAC_CONST(0.111111), FRAC_CONST(0.166667), FRAC_CONST(0.190476), FRAC_CONST(0.197531), FRAC_CONST(0.199377), FRAC_CONST(0.199844), FRAC_CONST(0.199961) },
{ FRAC_CONST(3.05092E-005), FRAC_CONST(0.000121936), FRAC_CONST(0.000486145), FRAC_CONST(0.00191939), FRAC_CONST(0.00729927), FRAC_CONST(0.0243902), FRAC_CONST(0.0588235), FRAC_CONST(0.0909091), FRAC_CONST(0.105263), FRAC_CONST(0.109589), FRAC_CONST(0.110727), FRAC_CONST(0.111015), FRAC_CONST(0.111087) },
{ FRAC_CONST(1.52548E-005), FRAC_CONST(6.09719E-005), FRAC_CONST(0.000243132), FRAC_CONST(0.000960615), FRAC_CONST(0.003663), FRAC_CONST(0.0123457), FRAC_CONST(0.030303), FRAC_CONST(0.047619), FRAC_CONST(0.0555556), FRAC_CONST(0.057971), FRAC_CONST(0.0586081), FRAC_CONST(0.0587695), FRAC_CONST(0.05881) },
{ FRAC_CONST(7.62747E-006), FRAC_CONST(3.04869E-005), FRAC_CONST(0.000121581), FRAC_CONST(0.000480538), FRAC_CONST(0.00183486), FRAC_CONST(0.00621118), FRAC_CONST(0.0153846), FRAC_CONST(0.0243902), FRAC_CONST(0.0285714), FRAC_CONST(0.0298507), FRAC_CONST(0.0301887), FRAC_CONST(0.0302744), FRAC_CONST(0.0302959) },
{ FRAC_CONST(3.81375E-006), FRAC_CONST(1.52437E-005), FRAC_CONST(6.0794E-005), FRAC_CONST(0.000240327), FRAC_CONST(0.000918274), FRAC_CONST(0.00311526), FRAC_CONST(0.00775194), FRAC_CONST(0.0123457), FRAC_CONST(0.0144928), FRAC_CONST(0.0151515), FRAC_CONST(0.0153257), FRAC_CONST(0.0153698), FRAC_CONST(0.0153809) },
{ FRAC_CONST(1.90688E-006), FRAC_CONST(7.62189E-006), FRAC_CONST(3.03979E-005), FRAC_CONST(0.000120178), FRAC_CONST(0.000459348), FRAC_CONST(0.00156006), FRAC_CONST(0.00389105), FRAC_CONST(0.00621118), FRAC_CONST(0.00729927), FRAC_CONST(0.00763359), FRAC_CONST(0.00772201), FRAC_CONST(0.00774443), FRAC_CONST(0.00775006) },
{ FRAC_CONST(9.53441E-007), FRAC_CONST(3.81096E-006), FRAC_CONST(1.51992E-005), FRAC_CONST(6.00925E-005), FRAC_CONST(0.000229727), FRAC_CONST(0.00078064), FRAC_CONST(0.00194932), FRAC_CONST(0.00311526), FRAC_CONST(0.003663), FRAC_CONST(0.00383142), FRAC_CONST(0.00387597), FRAC_CONST(0.00388727), FRAC_CONST(0.0038901) },
{ FRAC_CONST(4.76721E-007), FRAC_CONST(1.90548E-006), FRAC_CONST(7.59965E-006), FRAC_CONST(3.00472E-005), FRAC_CONST(0.000114877), FRAC_CONST(0.000390472), FRAC_CONST(0.00097561), FRAC_CONST(0.00156006), FRAC_CONST(0.00183486), FRAC_CONST(0.00191939), FRAC_CONST(0.00194175), FRAC_CONST(0.00194742), FRAC_CONST(0.00194884) },
{ FRAC_CONST(2.3836E-007), FRAC_CONST(9.52743E-007), FRAC_CONST(3.79984E-006), FRAC_CONST(1.50238E-005), FRAC_CONST(5.74416E-005), FRAC_CONST(0.000195274), FRAC_CONST(0.000488043), FRAC_CONST(0.00078064), FRAC_CONST(0.000918274), FRAC_CONST(0.000960615), FRAC_CONST(0.000971817), FRAC_CONST(0.000974659), FRAC_CONST(0.000975372) },
{ FRAC_CONST(1.1918E-007), FRAC_CONST(4.76372E-007), FRAC_CONST(1.89992E-006), FRAC_CONST(7.51196E-006), FRAC_CONST(2.87216E-005), FRAC_CONST(9.76467E-005), FRAC_CONST(0.000244081), FRAC_CONST(0.000390472), FRAC_CONST(0.000459348), FRAC_CONST(0.000480538), FRAC_CONST(0.000486145), FRAC_CONST(0.000487567), FRAC_CONST(0.000487924) },
{ FRAC_CONST(5.95901E-008), FRAC_CONST(2.38186E-007), FRAC_CONST(9.49963E-007), FRAC_CONST(3.756E-006), FRAC_CONST(1.4361E-005), FRAC_CONST(4.88257E-005), FRAC_CONST(0.000122055), FRAC_CONST(0.000195274), FRAC_CONST(0.000229727), FRAC_CONST(0.000240327), FRAC_CONST(0.000243132), FRAC_CONST(0.000243843), FRAC_CONST(0.000244021) },
{ FRAC_CONST(2.9795E-008), FRAC_CONST(1.19093E-007), FRAC_CONST(4.74982E-007), FRAC_CONST(1.878E-006), FRAC_CONST(7.18056E-006), FRAC_CONST(2.44135E-005), FRAC_CONST(6.10314E-005), FRAC_CONST(9.76467E-005), FRAC_CONST(0.000114877), FRAC_CONST(0.000120178), FRAC_CONST(0.000121581), FRAC_CONST(0.000121936), FRAC_CONST(0.000122026) },
{ FRAC_CONST(1.48975E-008), FRAC_CONST(5.95465E-008), FRAC_CONST(2.37491E-007), FRAC_CONST(9.39002E-007), FRAC_CONST(3.59029E-006), FRAC_CONST(1.22069E-005), FRAC_CONST(3.05166E-005), FRAC_CONST(4.88257E-005), FRAC_CONST(5.74416E-005), FRAC_CONST(6.00925E-005), FRAC_CONST(6.0794E-005), FRAC_CONST(6.09719E-005), FRAC_CONST(6.10165E-005) },
{ FRAC_CONST(7.44876E-009), FRAC_CONST(2.97732E-008), FRAC_CONST(1.18745E-007), FRAC_CONST(4.69501E-007), FRAC_CONST(1.79515E-006), FRAC_CONST(6.10348E-006), FRAC_CONST(1.52586E-005), FRAC_CONST(2.44135E-005), FRAC_CONST(2.87216E-005), FRAC_CONST(3.00472E-005), FRAC_CONST(3.03979E-005), FRAC_CONST(3.04869E-005), FRAC_CONST(3.05092E-005) },
{ FRAC_CONST(3.72438E-009), FRAC_CONST(1.48866E-008), FRAC_CONST(5.93727E-008), FRAC_CONST(2.34751E-007), FRAC_CONST(8.97575E-007), FRAC_CONST(3.05175E-006), FRAC_CONST(7.62934E-006), FRAC_CONST(1.22069E-005), FRAC_CONST(1.4361E-005), FRAC_CONST(1.50238E-005), FRAC_CONST(1.51992E-005), FRAC_CONST(1.52437E-005), FRAC_CONST(1.52548E-005) },
{ FRAC_CONST(1.86219E-009), FRAC_CONST(7.44331E-009), FRAC_CONST(2.96864E-008), FRAC_CONST(1.17375E-007), FRAC_CONST(4.48788E-007), FRAC_CONST(1.52588E-006), FRAC_CONST(3.81468E-006), FRAC_CONST(6.10348E-006), FRAC_CONST(7.18056E-006), FRAC_CONST(7.51196E-006), FRAC_CONST(7.59965E-006), FRAC_CONST(7.62189E-006), FRAC_CONST(7.62747E-006) },
{ FRAC_CONST(9.31095E-010), FRAC_CONST(3.72166E-009), FRAC_CONST(1.48432E-008), FRAC_CONST(5.86876E-008), FRAC_CONST(2.24394E-007), FRAC_CONST(7.62939E-007), FRAC_CONST(1.90734E-006), FRAC_CONST(3.05175E-006), FRAC_CONST(3.59029E-006), FRAC_CONST(3.756E-006), FRAC_CONST(3.79984E-006), FRAC_CONST(3.81096E-006), FRAC_CONST(3.81375E-006) },
{ FRAC_CONST(4.65548E-010), FRAC_CONST(1.86083E-009), FRAC_CONST(7.42159E-009), FRAC_CONST(2.93438E-008), FRAC_CONST(1.12197E-007), FRAC_CONST(3.8147E-007), FRAC_CONST(9.53673E-007), FRAC_CONST(1.52588E-006), FRAC_CONST(1.79515E-006), FRAC_CONST(1.878E-006), FRAC_CONST(1.89992E-006), FRAC_CONST(1.90548E-006), FRAC_CONST(1.90688E-006) },
{ FRAC_CONST(2.32774E-010), FRAC_CONST(9.30414E-010), FRAC_CONST(3.71079E-009), FRAC_CONST(1.46719E-008), FRAC_CONST(5.60985E-008), FRAC_CONST(1.90735E-007), FRAC_CONST(4.76837E-007), FRAC_CONST(7.62939E-007), FRAC_CONST(8.97575E-007), FRAC_CONST(9.39002E-007), FRAC_CONST(9.49963E-007), FRAC_CONST(9.52743E-007), FRAC_CONST(9.53441E-007) },
{ FRAC_CONST(1.16387E-010), FRAC_CONST(4.65207E-010), FRAC_CONST(1.8554E-009), FRAC_CONST(7.33596E-009), FRAC_CONST(2.80492E-008), FRAC_CONST(9.53674E-008), FRAC_CONST(2.38419E-007), FRAC_CONST(3.8147E-007), FRAC_CONST(4.48788E-007), FRAC_CONST(4.69501E-007), FRAC_CONST(4.74982E-007), FRAC_CONST(4.76372E-007), FRAC_CONST(4.76721E-007) },
{ FRAC_CONST(5.81935E-011), FRAC_CONST(2.32603E-010), FRAC_CONST(9.27699E-010), FRAC_CONST(3.66798E-009), FRAC_CONST(1.40246E-008), FRAC_CONST(4.76837E-008), FRAC_CONST(1.19209E-007), FRAC_CONST(1.90735E-007), FRAC_CONST(2.24394E-007), FRAC_CONST(2.34751E-007), FRAC_CONST(2.37491E-007), FRAC_CONST(2.38186E-007), FRAC_CONST(2.3836E-007) },
{ FRAC_CONST(2.90967E-011), FRAC_CONST(1.16302E-010), FRAC_CONST(4.63849E-010), FRAC_CONST(1.83399E-009), FRAC_CONST(7.01231E-009), FRAC_CONST(2.38419E-008), FRAC_CONST(5.96046E-008), FRAC_CONST(9.53674E-008), FRAC_CONST(1.12197E-007), FRAC_CONST(1.17375E-007), FRAC_CONST(1.18745E-007), FRAC_CONST(1.19093E-007), FRAC_CONST(1.1918E-007) }
};
static const real_t Q_div2_tab_right[31][13] = {
{ FRAC_CONST(0.992246), FRAC_CONST(0.992241), FRAC_CONST(0.992218), FRAC_CONST(0.992128), FRAC_CONST(0.991768), FRAC_CONST(0.990329), FRAC_CONST(0.984615), FRAC_CONST(0.962406), FRAC_CONST(0.882759), FRAC_CONST(0.663212), FRAC_CONST(0.332468), FRAC_CONST(0.111015), FRAC_CONST(0.0302959) },
{ FRAC_CONST(0.984612), FRAC_CONST(0.984601), FRAC_CONST(0.984556), FRAC_CONST(0.984379), FRAC_CONST(0.98367), FRAC_CONST(0.980843), FRAC_CONST(0.969697), FRAC_CONST(0.927536), FRAC_CONST(0.790123), FRAC_CONST(0.496124), FRAC_CONST(0.199377), FRAC_CONST(0.0587695), FRAC_CONST(0.0153809) },
{ FRAC_CONST(0.96969), FRAC_CONST(0.969668), FRAC_CONST(0.969582), FRAC_CONST(0.969238), FRAC_CONST(0.967864), FRAC_CONST(0.962406), FRAC_CONST(0.941176), FRAC_CONST(0.864865), FRAC_CONST(0.653061), FRAC_CONST(0.329897), FRAC_CONST(0.110727), FRAC_CONST(0.0302744), FRAC_CONST(0.00775006) },
{ FRAC_CONST(0.941163), FRAC_CONST(0.941122), FRAC_CONST(0.94096), FRAC_CONST(0.940312), FRAC_CONST(0.937729), FRAC_CONST(0.927536), FRAC_CONST(0.888889), FRAC_CONST(0.761905), FRAC_CONST(0.484848), FRAC_CONST(0.197531), FRAC_CONST(0.0586081), FRAC_CONST(0.0153698), FRAC_CONST(0.0038901) },
{ FRAC_CONST(0.888865), FRAC_CONST(0.888792), FRAC_CONST(0.888503), FRAC_CONST(0.887348), FRAC_CONST(0.882759), FRAC_CONST(0.864865), FRAC_CONST(0.8), FRAC_CONST(0.615385), FRAC_CONST(0.32), FRAC_CONST(0.109589), FRAC_CONST(0.0301887), FRAC_CONST(0.00774443), FRAC_CONST(0.00194884) },
{ FRAC_CONST(0.799961), FRAC_CONST(0.799844), FRAC_CONST(0.799375), FRAC_CONST(0.797508), FRAC_CONST(0.790123), FRAC_CONST(0.761905), FRAC_CONST(0.666667), FRAC_CONST(0.444444), FRAC_CONST(0.190476), FRAC_CONST(0.057971), FRAC_CONST(0.0153257), FRAC_CONST(0.00388727), FRAC_CONST(0.000975372) },
{ FRAC_CONST(0.666612), FRAC_CONST(0.66645), FRAC_CONST(0.6658), FRAC_CONST(0.663212), FRAC_CONST(0.653061), FRAC_CONST(0.615385), FRAC_CONST(0.5), FRAC_CONST(0.285714), FRAC_CONST(0.105263), FRAC_CONST(0.0298507), FRAC_CONST(0.00772201), FRAC_CONST(0.00194742), FRAC_CONST(0.000487924) },
{ FRAC_CONST(0.499939), FRAC_CONST(0.499756), FRAC_CONST(0.499025), FRAC_CONST(0.496124), FRAC_CONST(0.484848), FRAC_CONST(0.444444), FRAC_CONST(0.333333), FRAC_CONST(0.166667), FRAC_CONST(0.0555556), FRAC_CONST(0.0151515), FRAC_CONST(0.00387597), FRAC_CONST(0.000974659), FRAC_CONST(0.000244021) },
{ FRAC_CONST(0.333279), FRAC_CONST(0.333116), FRAC_CONST(0.332468), FRAC_CONST(0.329897), FRAC_CONST(0.32), FRAC_CONST(0.285714), FRAC_CONST(0.2), FRAC_CONST(0.0909091), FRAC_CONST(0.0285714), FRAC_CONST(0.00763359), FRAC_CONST(0.00194175), FRAC_CONST(0.000487567), FRAC_CONST(0.000122026) },
{ FRAC_CONST(0.199961), FRAC_CONST(0.199844), FRAC_CONST(0.199377), FRAC_CONST(0.197531), FRAC_CONST(0.190476), FRAC_CONST(0.166667), FRAC_CONST(0.111111), FRAC_CONST(0.047619), FRAC_CONST(0.0144928), FRAC_CONST(0.00383142), FRAC_CONST(0.000971817), FRAC_CONST(0.000243843), FRAC_CONST(6.10165E-005) },
{ FRAC_CONST(0.111087), FRAC_CONST(0.111015), FRAC_CONST(0.110727), FRAC_CONST(0.109589), FRAC_CONST(0.105263), FRAC_CONST(0.0909091), FRAC_CONST(0.0588235), FRAC_CONST(0.0243902), FRAC_CONST(0.00729927), FRAC_CONST(0.00191939), FRAC_CONST(0.000486145), FRAC_CONST(0.000121936), FRAC_CONST(3.05092E-005) },
{ FRAC_CONST(0.05881), FRAC_CONST(0.0587695), FRAC_CONST(0.0586081), FRAC_CONST(0.057971), FRAC_CONST(0.0555556), FRAC_CONST(0.047619), FRAC_CONST(0.030303), FRAC_CONST(0.0123457), FRAC_CONST(0.003663), FRAC_CONST(0.000960615), FRAC_CONST(0.000243132), FRAC_CONST(6.09719E-005), FRAC_CONST(1.52548E-005) },
{ FRAC_CONST(0.0302959), FRAC_CONST(0.0302744), FRAC_CONST(0.0301887), FRAC_CONST(0.0298507), FRAC_CONST(0.0285714), FRAC_CONST(0.0243902), FRAC_CONST(0.0153846), FRAC_CONST(0.00621118), FRAC_CONST(0.00183486), FRAC_CONST(0.000480538), FRAC_CONST(0.000121581), FRAC_CONST(3.04869E-005), FRAC_CONST(7.62747E-006) },
{ FRAC_CONST(0.0153809), FRAC_CONST(0.0153698), FRAC_CONST(0.0153257), FRAC_CONST(0.0151515), FRAC_CONST(0.0144928), FRAC_CONST(0.0123457), FRAC_CONST(0.00775194), FRAC_CONST(0.00311526), FRAC_CONST(0.000918274), FRAC_CONST(0.000240327), FRAC_CONST(6.0794E-005), FRAC_CONST(1.52437E-005), FRAC_CONST(3.81375E-006) },
{ FRAC_CONST(0.00775006), FRAC_CONST(0.00774443), FRAC_CONST(0.00772201), FRAC_CONST(0.00763359), FRAC_CONST(0.00729927), FRAC_CONST(0.00621118), FRAC_CONST(0.00389105), FRAC_CONST(0.00156006), FRAC_CONST(0.000459348), FRAC_CONST(0.000120178), FRAC_CONST(3.03979E-005), FRAC_CONST(7.62189E-006), FRAC_CONST(1.90688E-006) },
{ FRAC_CONST(0.0038901), FRAC_CONST(0.00388727), FRAC_CONST(0.00387597), FRAC_CONST(0.00383142), FRAC_CONST(0.003663), FRAC_CONST(0.00311526), FRAC_CONST(0.00194932), FRAC_CONST(0.00078064), FRAC_CONST(0.000229727), FRAC_CONST(6.00925E-005), FRAC_CONST(1.51992E-005), FRAC_CONST(3.81096E-006), FRAC_CONST(9.53441E-007) },
{ FRAC_CONST(0.00194884), FRAC_CONST(0.00194742), FRAC_CONST(0.00194175), FRAC_CONST(0.00191939), FRAC_CONST(0.00183486), FRAC_CONST(0.00156006), FRAC_CONST(0.00097561), FRAC_CONST(0.000390472), FRAC_CONST(0.000114877), FRAC_CONST(3.00472E-005), FRAC_CONST(7.59965E-006), FRAC_CONST(1.90548E-006), FRAC_CONST(4.76721E-007) },
{ FRAC_CONST(0.000975372), FRAC_CONST(0.000974659), FRAC_CONST(0.000971817), FRAC_CONST(0.000960615), FRAC_CONST(0.000918274), FRAC_CONST(0.00078064), FRAC_CONST(0.000488043), FRAC_CONST(0.000195274), FRAC_CONST(5.74416E-005), FRAC_CONST(1.50238E-005), FRAC_CONST(3.79984E-006), FRAC_CONST(9.52743E-007), FRAC_CONST(2.3836E-007) },
{ FRAC_CONST(0.000487924), FRAC_CONST(0.000487567), FRAC_CONST(0.000486145), FRAC_CONST(0.000480538), FRAC_CONST(0.000459348), FRAC_CONST(0.000390472), FRAC_CONST(0.000244081), FRAC_CONST(9.76467E-005), FRAC_CONST(2.87216E-005), FRAC_CONST(7.51196E-006), FRAC_CONST(1.89992E-006), FRAC_CONST(4.76372E-007), FRAC_CONST(1.1918E-007) },
{ FRAC_CONST(0.000244021), FRAC_CONST(0.000243843), FRAC_CONST(0.000243132), FRAC_CONST(0.000240327), FRAC_CONST(0.000229727), FRAC_CONST(0.000195274), FRAC_CONST(0.000122055), FRAC_CONST(4.88257E-005), FRAC_CONST(1.4361E-005), FRAC_CONST(3.756E-006), FRAC_CONST(9.49963E-007), FRAC_CONST(2.38186E-007), FRAC_CONST(5.95901E-008) },
{ FRAC_CONST(0.000122026), FRAC_CONST(0.000121936), FRAC_CONST(0.000121581), FRAC_CONST(0.000120178), FRAC_CONST(0.000114877), FRAC_CONST(9.76467E-005), FRAC_CONST(6.10314E-005), FRAC_CONST(2.44135E-005), FRAC_CONST(7.18056E-006), FRAC_CONST(1.878E-006), FRAC_CONST(4.74982E-007), FRAC_CONST(1.19093E-007), FRAC_CONST(2.9795E-008) },
{ FRAC_CONST(6.10165E-005), FRAC_CONST(6.09719E-005), FRAC_CONST(6.0794E-005), FRAC_CONST(6.00925E-005), FRAC_CONST(5.74416E-005), FRAC_CONST(4.88257E-005), FRAC_CONST(3.05166E-005), FRAC_CONST(1.22069E-005), FRAC_CONST(3.59029E-006), FRAC_CONST(9.39002E-007), FRAC_CONST(2.37491E-007), FRAC_CONST(5.95465E-008), FRAC_CONST(1.48975E-008) },
{ FRAC_CONST(3.05092E-005), FRAC_CONST(3.04869E-005), FRAC_CONST(3.03979E-005), FRAC_CONST(3.00472E-005), FRAC_CONST(2.87216E-005), FRAC_CONST(2.44135E-005), FRAC_CONST(1.52586E-005), FRAC_CONST(6.10348E-006), FRAC_CONST(1.79515E-006), FRAC_CONST(4.69501E-007), FRAC_CONST(1.18745E-007), FRAC_CONST(2.97732E-008), FRAC_CONST(7.44876E-009) },
{ FRAC_CONST(1.52548E-005), FRAC_CONST(1.52437E-005), FRAC_CONST(1.51992E-005), FRAC_CONST(1.50238E-005), FRAC_CONST(1.4361E-005), FRAC_CONST(1.22069E-005), FRAC_CONST(7.62934E-006), FRAC_CONST(3.05175E-006), FRAC_CONST(8.97575E-007), FRAC_CONST(2.34751E-007), FRAC_CONST(5.93727E-008), FRAC_CONST(1.48866E-008), FRAC_CONST(3.72438E-009) },
{ FRAC_CONST(7.62747E-006), FRAC_CONST(7.62189E-006), FRAC_CONST(7.59965E-006), FRAC_CONST(7.51196E-006), FRAC_CONST(7.18056E-006), FRAC_CONST(6.10348E-006), FRAC_CONST(3.81468E-006), FRAC_CONST(1.52588E-006), FRAC_CONST(4.48788E-007), FRAC_CONST(1.17375E-007), FRAC_CONST(2.96864E-008), FRAC_CONST(7.44331E-009), FRAC_CONST(1.86219E-009) },
{ FRAC_CONST(3.81375E-006), FRAC_CONST(3.81096E-006), FRAC_CONST(3.79984E-006), FRAC_CONST(3.756E-006), FRAC_CONST(3.59029E-006), FRAC_CONST(3.05175E-006), FRAC_CONST(1.90734E-006), FRAC_CONST(7.62939E-007), FRAC_CONST(2.24394E-007), FRAC_CONST(5.86876E-008), FRAC_CONST(1.48432E-008), FRAC_CONST(3.72166E-009), FRAC_CONST(9.31095E-010) },
{ FRAC_CONST(1.90688E-006), FRAC_CONST(1.90548E-006), FRAC_CONST(1.89992E-006), FRAC_CONST(1.878E-006), FRAC_CONST(1.79515E-006), FRAC_CONST(1.52588E-006), FRAC_CONST(9.53673E-007), FRAC_CONST(3.8147E-007), FRAC_CONST(1.12197E-007), FRAC_CONST(2.93438E-008), FRAC_CONST(7.42159E-009), FRAC_CONST(1.86083E-009), FRAC_CONST(4.65548E-010) },
{ FRAC_CONST(9.53441E-007), FRAC_CONST(9.52743E-007), FRAC_CONST(9.49963E-007), FRAC_CONST(9.39002E-007), FRAC_CONST(8.97575E-007), FRAC_CONST(7.62939E-007), FRAC_CONST(4.76837E-007), FRAC_CONST(1.90735E-007), FRAC_CONST(5.60985E-008), FRAC_CONST(1.46719E-008), FRAC_CONST(3.71079E-009), FRAC_CONST(9.30414E-010), FRAC_CONST(2.32774E-010) },
{ FRAC_CONST(4.76721E-007), FRAC_CONST(4.76372E-007), FRAC_CONST(4.74982E-007), FRAC_CONST(4.69501E-007), FRAC_CONST(4.48788E-007), FRAC_CONST(3.8147E-007), FRAC_CONST(2.38419E-007), FRAC_CONST(9.53674E-008), FRAC_CONST(2.80492E-008), FRAC_CONST(7.33596E-009), FRAC_CONST(1.8554E-009), FRAC_CONST(4.65207E-010), FRAC_CONST(1.16387E-010) },
{ FRAC_CONST(2.3836E-007), FRAC_CONST(2.38186E-007), FRAC_CONST(2.37491E-007), FRAC_CONST(2.34751E-007), FRAC_CONST(2.24394E-007), FRAC_CONST(1.90735E-007), FRAC_CONST(1.19209E-007), FRAC_CONST(4.76837E-008), FRAC_CONST(1.40246E-008), FRAC_CONST(3.66798E-009), FRAC_CONST(9.27699E-010), FRAC_CONST(2.32603E-010), FRAC_CONST(5.81935E-011) },
{ FRAC_CONST(1.1918E-007), FRAC_CONST(1.19093E-007), FRAC_CONST(1.18745E-007), FRAC_CONST(1.17375E-007), FRAC_CONST(1.12197E-007), FRAC_CONST(9.53674E-008), FRAC_CONST(5.96046E-008), FRAC_CONST(2.38419E-008), FRAC_CONST(7.01231E-009), FRAC_CONST(1.83399E-009), FRAC_CONST(4.63849E-010), FRAC_CONST(1.16302E-010), FRAC_CONST(2.90967E-011) }
};
/* calculates Q/(1+Q) */
/* [0..1] */
real_t calc_Q_div2(sbr_info *sbr, uint8_t ch, uint8_t m, uint8_t l)
{
if (sbr->bs_coupling)
{
if ((sbr->Q[0][m][l] < 0 || sbr->Q[0][m][l] > 30) ||
(sbr->Q[1][m][l] < 0 || sbr->Q[1][m][l] > 24 /* 2*panOffset(1) */))
{
return 0;
} else {
/* the pan parameter is always even */
if (ch == 0)
{
return Q_div2_tab_left[sbr->Q[0][m][l]][sbr->Q[1][m][l] >> 1];
} else {
return Q_div2_tab_right[sbr->Q[0][m][l]][sbr->Q[1][m][l] >> 1];
}
}
} else {
/* no coupling */
if (sbr->Q[ch][m][l] < 0 || sbr->Q[ch][m][l] > 30)
{
return 0;
} else {
return Q_div2_tab[sbr->Q[ch][m][l]];
}
}
}
static const real_t E_deq_tab[64] = {
64.0f, 128.0f, 256.0f, 512.0f, 1024.0f, 2048.0f, 4096.0f, 8192.0f,
16384.0f, 32768.0f, 65536.0f, 131072.0f, 262144.0f, 524288.0f, 1.04858E+006f, 2.09715E+006f,
4.1943E+006f, 8.38861E+006f, 1.67772E+007f, 3.35544E+007f, 6.71089E+007f, 1.34218E+008f, 2.68435E+008f, 5.36871E+008f,
1.07374E+009f, 2.14748E+009f, 4.29497E+009f, 8.58993E+009f, 1.71799E+010f, 3.43597E+010f, 6.87195E+010f, 1.37439E+011f,
2.74878E+011f, 5.49756E+011f, 1.09951E+012f, 2.19902E+012f, 4.39805E+012f, 8.79609E+012f, 1.75922E+013f, 3.51844E+013f,
7.03687E+013f, 1.40737E+014f, 2.81475E+014f, 5.6295E+014f, 1.1259E+015f, 2.2518E+015f, 4.5036E+015f, 9.0072E+015f,
1.80144E+016f, 3.60288E+016f, 7.20576E+016f, 1.44115E+017f, 2.8823E+017f, 5.76461E+017f, 1.15292E+018f, 2.30584E+018f,
4.61169E+018f, 9.22337E+018f, 1.84467E+019f, 3.68935E+019f, 7.3787E+019f, 1.47574E+020f, 2.95148E+020f, 5.90296E+020f
};
void envelope_noise_dequantisation(sbr_info *sbr, uint8_t ch)
{
if (sbr->bs_coupling == 0)
@ -255,22 +403,22 @@ void envelope_noise_dequantisation(sbr_info *sbr, uint8_t ch)
{
for (k = 0; k < sbr->n[sbr->f[ch][l]]; k++)
{
/* +6 for the *64 and -10 for the /32 in the synthesis QMF
/* +6 for the *64 and -10 for the /32 in the synthesis QMF (fixed)
* since this is a energy value: (x/32)^2 = (x^2)/1024
*/
exp = (sbr->E[ch][k][l] >> amp) + 6;
/* exp = (sbr->E[ch][k][l] >> amp) + 6; */
exp = (sbr->E[ch][k][l] >> amp);
if ((exp < -P2_TABLE_OFFSET) || (exp > P2_TABLE_MAX))
if ((exp < 0) || (exp >= 64))
{
sbr->E_orig[ch][k][l] = 0;
} else {
/* FIXED POINT TODO: E_orig: INTEGER!! */
sbr->E_orig[ch][k][l] = pow2deq[exp + P2_TABLE_OFFSET];
sbr->E_orig[ch][k][l] = E_deq_tab[exp];
/* save half the table size at the cost of 1 multiply */
if (amp && (sbr->E[ch][k][l] & 1))
{
sbr->E_orig[ch][k][l] = MUL_R(sbr->E_orig[ch][k][l], REAL_CONST(1.414213562));
sbr->E_orig[ch][k][l] = MUL_C(sbr->E_orig[ch][k][l], COEF_CONST(1.414213562));
}
}
}
@ -280,18 +428,29 @@ void envelope_noise_dequantisation(sbr_info *sbr, uint8_t ch)
{
for (k = 0; k < sbr->N_Q; k++)
{
if (sbr->Q[ch][k][l] < 0 || sbr->Q[ch][k][l] > 30)
{
sbr->Q_orig[ch][k][l] = 0;
} else {
exp = NOISE_FLOOR_OFFSET - sbr->Q[ch][k][l];
sbr->Q_orig[ch][k][l] = pow2deq[exp + P2_TABLE_OFFSET];
}
sbr->Q_div[ch][k][l] = calc_Q_div(sbr, ch, k, l);
sbr->Q_div2[ch][k][l] = calc_Q_div2(sbr, ch, k, l);
}
}
}
}
static const real_t E_pan_tab[25] = {
FRAC_CONST(0.000244081), FRAC_CONST(0.000488043),
FRAC_CONST(0.00097561), FRAC_CONST(0.00194932),
FRAC_CONST(0.00389105), FRAC_CONST(0.00775194),
FRAC_CONST(0.0153846), FRAC_CONST(0.030303),
FRAC_CONST(0.0588235), FRAC_CONST(0.111111),
FRAC_CONST(0.2), FRAC_CONST(0.333333),
FRAC_CONST(0.5), FRAC_CONST(0.666667),
FRAC_CONST(0.8), FRAC_CONST(0.888889),
FRAC_CONST(0.941176), FRAC_CONST(0.969697),
FRAC_CONST(0.984615), FRAC_CONST(0.992248),
FRAC_CONST(0.996109), FRAC_CONST(0.998051),
FRAC_CONST(0.999024), FRAC_CONST(0.999512),
FRAC_CONST(0.999756)
};
void unmap_envelope_noise(sbr_info *sbr)
{
real_t tmp;
@ -304,49 +463,47 @@ void unmap_envelope_noise(sbr_info *sbr)
{
for (k = 0; k < sbr->n[sbr->f[0][l]]; k++)
{
/* +6: * 64 ; +1: * 2 ; -10: /1024 QMF */
exp0 = (sbr->E[0][k][l] >> amp0) + 7;
/* +6: * 64 ; +1: * 2 ; */
exp0 = (sbr->E[0][k][l] >> amp0) + 1;
/* UN_MAP removed: (x / 4096) same as (x >> 12) */
/* E[1] is always even so no need for compensating the divide by 2 with
* an extra multiplication
*/
exp1 = (sbr->E[1][k][l] >> amp1) - 12;
/* exp1 = (sbr->E[1][k][l] >> amp1) - 12; */
exp1 = (sbr->E[1][k][l] >> amp1);
if ((exp0 < -P2_TABLE_OFFSET) || (exp0 > P2_TABLE_MAX) ||
(exp1 < -P2_TABLE_RCP_OFFSET) || (exp1 > P2_TABLE_RCP_MAX))
if ((exp0 < 0) || (exp0 >= 64) ||
(exp1 < 0) || (exp1 > 24))
{
sbr->E_orig[1][k][l] = 0;
sbr->E_orig[0][k][l] = 0;
} else {
tmp = pow2deq[exp0 + P2_TABLE_OFFSET];
tmp = E_deq_tab[exp0];
if (amp0 && (sbr->E[0][k][l] & 1))
tmp = MUL_R(tmp, REAL_CONST(1.414213562));
{
tmp = MUL_C(tmp, COEF_CONST(1.414213562));
}
/* FIXED POINT TODO: E_orig: INTEGER!! */
sbr->E_orig[1][k][l] = MUL_F(tmp, pow2deq_rcp[exp1 + P2_TABLE_RCP_OFFSET]);
sbr->E_orig[0][k][l] = MUL_R(sbr->E_orig[1][k][l], pow2deq[exp1 + P2_TABLE_OFFSET]);
/* panning */
sbr->E_orig[0][k][l] = MUL_F(tmp, E_pan_tab[exp1]);
sbr->E_orig[1][k][l] = MUL_F(tmp, E_pan_tab[24 - exp1]);
}
}
}
for (l = 0; l < sbr->L_Q[0]; l++)
{
for (k = 0; k < sbr->N_Q; k++)
{
if ((sbr->Q[0][k][l] < 0 || sbr->Q[0][k][l] > 30) ||
(sbr->Q[1][k][l] < 0 || sbr->Q[1][k][l] > 24 /* 2*panOffset(1) */))
{
sbr->Q_orig[0][k][l] = 0;
sbr->Q_orig[1][k][l] = 0;
} else {
exp0 = NOISE_FLOOR_OFFSET - sbr->Q[0][k][l] + 1;
exp1 = sbr->Q[1][k][l] - 12;
sbr->Q_orig[1][k][l] = MUL_F(pow2deq[exp0 + P2_TABLE_OFFSET], pow2deq_rcp[exp1 + P2_TABLE_RCP_OFFSET]);
sbr->Q_orig[0][k][l] = MUL_R(sbr->Q_orig[1][k][l], pow2deq[exp1 + P2_TABLE_OFFSET]);
}
sbr->Q_div[0][k][l] = calc_Q_div(sbr, 0, k, l);
sbr->Q_div[1][k][l] = calc_Q_div(sbr, 1, k, l);
sbr->Q_div2[0][k][l] = calc_Q_div2(sbr, 0, k, l);
sbr->Q_div2[1][k][l] = calc_Q_div2(sbr, 1, k, l);
}
}
}
#endif
#endif

View File

@ -23,7 +23,7 @@
** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
**
** Initially modified for use with MPlayer by Arpad Gereöffy on 2003/08/30
** $Id: sbr_e_nf.h,v 1.3 2004/06/02 22:59:03 diego Exp $
** $Id: sbr_e_nf.h,v 1.4 2004/06/23 13:50:51 diego Exp $
** detailed CVS changelog at http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
**/
@ -35,23 +35,12 @@ extern "C" {
#endif
#ifndef FIXED_POINT
#define P2_TABLE_OFFSET 35
#define P2_TABLE_MAX 91
#else
#define P2Q_TABLE_OFFSET 24
#define P2Q_TABLE_MAX 7
#define P2_TABLE_OFFSET 0
#define P2_TABLE_MAX 31
#endif
#define P2_TABLE_RCP_OFFSET 12
#define P2_TABLE_RCP_MAX 21
void extract_envelope_data(sbr_info *sbr, uint8_t ch);
void extract_noise_floor_data(sbr_info *sbr, uint8_t ch);
#ifndef FIXED_POINT
void envelope_noise_dequantisation(sbr_info *sbr, uint8_t ch);
void unmap_envelope_noise(sbr_info *sbr);
#endif
#ifdef __cplusplus
}

View File

@ -23,7 +23,7 @@
** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
**
** Initially modified for use with MPlayer by Arpad Gereöffy on 2003/08/30
** $Id: sbr_fbt.c,v 1.3 2004/06/02 22:59:03 diego Exp $
** $Id: sbr_fbt.c,v 1.4 2004/06/23 13:50:51 diego Exp $
** detailed CVS changelog at http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
**/
@ -226,7 +226,7 @@ uint8_t master_frequency_table_fs0(sbr_info *sbr, uint8_t k0, uint8_t k2,
if (k2Diff)
{
incr = (k2Diff > 0) ? -1 : 1;
k = (k2Diff > 0) ? (nrBands-1) : 0;
k = (uint8_t) ((k2Diff > 0) ? (nrBands-1) : 0);
while (k2Diff != 0)
{
@ -238,10 +238,10 @@ uint8_t master_frequency_table_fs0(sbr_info *sbr, uint8_t k0, uint8_t k2,
sbr->f_master[0] = k0;
for (k = 1; k <= nrBands; k++)
sbr->f_master[k] = sbr->f_master[k-1] + vDk[k-1];
sbr->f_master[k] = (uint8_t)(sbr->f_master[k-1] + vDk[k-1]);
sbr->N_master = nrBands;
sbr->N_master = min(sbr->N_master, 64);
sbr->N_master = (uint8_t)nrBands;
sbr->N_master = (min(sbr->N_master, 64));
#if 0
printf("f_master[%d]: ", nrBands);
@ -357,6 +357,9 @@ uint8_t master_frequency_table(sbr_info *sbr, uint8_t k0, uint8_t k2,
uint8_t temp1[] = { 6, 5, 4 };
real_t q, qk;
int32_t A_1;
#ifdef FIXED_POINT
real_t rk2, rk0;
#endif
/* mft only defined for k2 > k0 */
if (k2 <= k0)
@ -368,7 +371,9 @@ uint8_t master_frequency_table(sbr_info *sbr, uint8_t k0, uint8_t k2,
bands = temp1[bs_freq_scale-1];
#ifdef FIXED_POINT
if (REAL_CONST(k2) > MUL_R(REAL_CONST(k0),REAL_CONST(2.2449)))
rk0 = (real_t)k0 << REAL_BITS;
rk2 = (real_t)k2 << REAL_BITS;
if (rk2 > MUL_C(rk0, COEF_CONST(2.2449)))
#else
if ((float)k2/(float)k0 > 2.2449)
#endif
@ -380,16 +385,18 @@ uint8_t master_frequency_table(sbr_info *sbr, uint8_t k0, uint8_t k2,
k1 = k2;
}
nrBand0 = 2 * find_bands(0, bands, k0, k1);
nrBand0 = (uint8_t)(2 * find_bands(0, bands, k0, k1));
nrBand0 = min(nrBand0, 63);
if (nrBand0 <= 0)
return 1;
q = find_initial_power(nrBand0, k0, k1);
qk = REAL_CONST(k0);
#ifdef FIXED_POINT
A_1 = (int32_t)((qk + REAL_CONST(0.5)) >> REAL_BITS);
qk = (real_t)k0 << REAL_BITS;
//A_1 = (int32_t)((qk + REAL_CONST(0.5)) >> REAL_BITS);
A_1 = k0;
#else
qk = REAL_CONST(k0);
A_1 = (int32_t)(qk + .5);
#endif
for (k = 0; k <= nrBand0; k++)
@ -419,21 +426,23 @@ uint8_t master_frequency_table(sbr_info *sbr, uint8_t k0, uint8_t k2,
if (!twoRegions)
{
for (k = 0; k <= nrBand0; k++)
sbr->f_master[k] = vk0[k];
sbr->f_master[k] = (uint8_t) vk0[k];
sbr->N_master = nrBand0;
sbr->N_master = min(sbr->N_master, 64);
return 0;
}
nrBand1 = 2 * find_bands(1 /* warped */, bands, k1, k2);
nrBand1 = (uint8_t)(2 * find_bands(1 /* warped */, bands, k1, k2));
nrBand1 = min(nrBand1, 63);
q = find_initial_power(nrBand1, k1, k2);
qk = REAL_CONST(k1);
#ifdef FIXED_POINT
A_1 = (int32_t)((qk + REAL_CONST(0.5)) >> REAL_BITS);
qk = (real_t)k1 << REAL_BITS;
//A_1 = (int32_t)((qk + REAL_CONST(0.5)) >> REAL_BITS);
A_1 = k1;
#else
qk = REAL_CONST(k1);
A_1 = (int32_t)(qk + .5);
#endif
for (k = 0; k <= nrBand1 - 1; k++)
@ -474,11 +483,11 @@ uint8_t master_frequency_table(sbr_info *sbr, uint8_t k0, uint8_t k2,
sbr->N_master = min(sbr->N_master, 64);
for (k = 0; k <= nrBand0; k++)
{
sbr->f_master[k] = vk0[k];
sbr->f_master[k] = (uint8_t) vk0[k];
}
for (k = nrBand0 + 1; k <= sbr->N_master; k++)
{
sbr->f_master[k] = vk1[k - nrBand0];
sbr->f_master[k] = (uint8_t) vk1[k - nrBand0];
}
#if 0
@ -529,11 +538,13 @@ uint8_t derived_frequency_table(sbr_info *sbr, uint8_t bs_xover_band,
if (k == 0)
i = 0;
else
i = 2*k - minus;
i = (uint8_t)(2*k - minus);
sbr->f_table_res[LO_RES][k] = sbr->f_table_res[HI_RES][i];
}
#if 0
printf("bs_freq_scale: %d\n", sbr->bs_freq_scale);
printf("bs_limiter_bands: %d\n", sbr->bs_limiter_bands);
printf("f_table_res[HI_RES][%d]: ", sbr->N_high);
for (k = 0; k <= sbr->N_high; k++)
{
@ -558,7 +569,7 @@ uint8_t derived_frequency_table(sbr_info *sbr, uint8_t bs_xover_band,
#if 0
sbr->N_Q = max(1, (int32_t)(sbr->bs_noise_bands*(log(k2/(float)sbr->kx)/log(2.0)) + 0.5));
#else
sbr->N_Q = max(1, find_bands(0, sbr->bs_noise_bands, sbr->kx, k2));
sbr->N_Q = (uint8_t)(max(1, find_bands(0, sbr->bs_noise_bands, sbr->kx, k2)));
#endif
sbr->N_Q = min(5, sbr->N_Q);
}
@ -594,7 +605,7 @@ uint8_t derived_frequency_table(sbr_info *sbr, uint8_t bs_xover_band,
printf("f_table_noise[%d]: ", sbr->N_Q);
for (k = 0; k <= sbr->N_Q; k++)
{
printf("%d ", sbr->f_table_noise[k]);
printf("%d ", sbr->f_table_noise[k] - sbr->kx);
}
printf("\n");
#endif
@ -613,8 +624,8 @@ void limiter_frequency_table(sbr_info *sbr)
static const real_t limiterBandsPerOctave[] = { REAL_CONST(1.2),
REAL_CONST(2), REAL_CONST(3) };
#else
static const real_t limiterBandsCompare[] = { REAL_CONST(1.328125),
REAL_CONST(1.1875), REAL_CONST(1.125) };
static const real_t limiterBandsCompare[] = { REAL_CONST(1.327152),
REAL_CONST(1.185093), REAL_CONST(1.119872) };
#endif
uint8_t k, s;
int8_t nrLim;
@ -626,6 +637,15 @@ void limiter_frequency_table(sbr_info *sbr)
sbr->f_table_lim[0][1] = sbr->f_table_res[LO_RES][sbr->N_low] - sbr->kx;
sbr->N_L[0] = 1;
#if 0
printf("f_table_lim[%d][%d]: ", 0, sbr->N_L[0]);
for (k = 0; k <= sbr->N_L[0]; k++)
{
printf("%d ", sbr->f_table_lim[0][k]);
}
printf("\n");
#endif
for (s = 1; s < 4; s++)
{
int32_t limTable[100 /*TODO*/] = {0};
@ -666,17 +686,18 @@ restart:
if (limTable[k-1] != 0)
#if 0
nOctaves = REAL_CONST(log((float)limTable[k]/(float)limTable[k-1])/log(2.0));
#endif
#else
#ifdef FIXED_POINT
nOctaves = SBR_DIV(REAL_CONST(limTable[k]),REAL_CONST(limTable[k-1]));
nOctaves = DIV_R((limTable[k]<<REAL_BITS),REAL_CONST(limTable[k-1]));
#else
nOctaves = (real_t)limTable[k]/(real_t)limTable[k-1];
#endif
#endif
else
nOctaves = 0;
#if 0
if ((MUL(nOctaves,limBands)) < REAL_CONST(0.49))
if ((MUL_R(nOctaves,limBands)) < REAL_CONST(0.49))
#else
if (nOctaves < limiterBandsCompare[s - 1])
#endif

File diff suppressed because it is too large Load Diff

View File

@ -23,7 +23,7 @@
** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
**
** Initially modified for use with MPlayer by Arpad Gereöffy on 2003/08/30
** $Id: sbr_hfadj.h,v 1.3 2004/06/02 22:59:03 diego Exp $
** $Id: sbr_hfadj.h,v 1.4 2004/06/23 13:50:52 diego Exp $
** detailed CVS changelog at http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
**/
@ -34,17 +34,11 @@
extern "C" {
#endif
typedef struct {
real_t Q_mapped[64][5];
uint8_t S_index_mapped[64][5];
uint8_t S_mapped[64][5];
real_t G_lim_boost[5][64];
real_t Q_M_lim_boost[5][64];
real_t S_M_boost[5][64];
typedef struct
{
real_t G_lim_boost[MAX_L_E][MAX_M];
real_t Q_M_lim_boost[MAX_L_E][MAX_M];
real_t S_M_boost[MAX_L_E][MAX_M];
} sbr_hfadj_info;

View File

@ -23,7 +23,7 @@
** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
**
** Initially modified for use with MPlayer by Arpad Gereöffy on 2003/08/30
** $Id: sbr_hfgen.c,v 1.3 2004/06/02 22:59:03 diego Exp $
** $Id: sbr_hfgen.c,v 1.4 2004/06/23 13:50:52 diego Exp $
** detailed CVS changelog at http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
**/
@ -40,20 +40,19 @@
/* static function declarations */
static void calc_prediction_coef(sbr_info *sbr, qmf_t Xlow[MAX_NTSRHFG][32],
complex_t *alpha_0, complex_t *alpha_1
#ifdef SBR_LOW_POWER
, real_t *rxx
#endif
);
#ifdef SBR_LOW_POWER
static void calc_prediction_coef_lp(sbr_info *sbr, qmf_t Xlow[MAX_NTSRHFG][64],
complex_t *alpha_0, complex_t *alpha_1, real_t *rxx);
static void calc_aliasing_degree(sbr_info *sbr, real_t *rxx, real_t *deg);
#else
static void calc_prediction_coef(sbr_info *sbr, qmf_t Xlow[MAX_NTSRHFG][64],
complex_t *alpha_0, complex_t *alpha_1, uint8_t k);
#endif
static void calc_chirp_factors(sbr_info *sbr, uint8_t ch);
static void patch_construction(sbr_info *sbr);
void hf_generation(sbr_info *sbr, qmf_t Xlow[MAX_NTSRHFG][32],
void hf_generation(sbr_info *sbr, qmf_t Xlow[MAX_NTSRHFG][64],
qmf_t Xhigh[MAX_NTSRHFG][64]
#ifdef SBR_LOW_POWER
,real_t *deg
@ -70,26 +69,18 @@ void hf_generation(sbr_info *sbr, qmf_t Xlow[MAX_NTSRHFG][32],
uint8_t first = sbr->t_E[ch][0];
uint8_t last = sbr->t_E[ch][sbr->L_E[ch]];
// printf("%d %d\n", first, last);
calc_chirp_factors(sbr, ch);
for (i = first; i < last; i++)
{
memset(Xhigh[i + offset], 0, 64 * sizeof(qmf_t));
}
#ifdef SBR_LOW_POWER
memset(deg, 0, 64*sizeof(real_t));
#endif
if ((ch == 0) && (sbr->Reset))
patch_construction(sbr);
/* calculate the prediction coefficients */
calc_prediction_coef(sbr, Xlow, alpha_0, alpha_1
#ifdef SBR_LOW_POWER
, rxx
#endif
);
#ifdef SBR_LOW_POWER
calc_prediction_coef_lp(sbr, Xlow, alpha_0, alpha_1, rxx);
calc_aliasing_degree(sbr, rxx, deg);
#endif
@ -98,7 +89,7 @@ void hf_generation(sbr_info *sbr, qmf_t Xlow[MAX_NTSRHFG][32],
{
for (x = 0; x < sbr->patchNoSubbands[i]; x++)
{
complex_t a0, a1;
real_t a0_r, a0_i, a1_r, a1_i;
real_t bw, bw2;
uint8_t q, p, k, g;
@ -126,35 +117,54 @@ void hf_generation(sbr_info *sbr, qmf_t Xlow[MAX_NTSRHFG][32],
/* with or without filtering */
if (bw2 > 0)
{
RE(a0) = MUL_C(RE(alpha_0[p]), bw);
RE(a1) = MUL_C(RE(alpha_1[p]), bw2);
real_t temp1_r, temp2_r, temp3_r;
#ifndef SBR_LOW_POWER
IM(a0) = MUL_C(IM(alpha_0[p]), bw);
IM(a1) = MUL_C(IM(alpha_1[p]), bw2);
real_t temp1_i, temp2_i, temp3_i;
calc_prediction_coef(sbr, Xlow, alpha_0, alpha_1, p);
#endif
a0_r = MUL_C(RE(alpha_0[p]), bw);
a1_r = MUL_C(RE(alpha_1[p]), bw2);
#ifndef SBR_LOW_POWER
a0_i = MUL_C(IM(alpha_0[p]), bw);
a1_i = MUL_C(IM(alpha_1[p]), bw2);
#endif
temp2_r = QMF_RE(Xlow[first - 2 + offset][p]);
temp3_r = QMF_RE(Xlow[first - 1 + offset][p]);
#ifndef SBR_LOW_POWER
temp2_i = QMF_IM(Xlow[first - 2 + offset][p]);
temp3_i = QMF_IM(Xlow[first - 1 + offset][p]);
#endif
for (l = first; l < last; l++)
{
QMF_RE(Xhigh[l + offset][k]) = QMF_RE(Xlow[l + offset][p]);
temp1_r = temp2_r;
temp2_r = temp3_r;
temp3_r = QMF_RE(Xlow[l + offset][p]);
#ifndef SBR_LOW_POWER
QMF_IM(Xhigh[l + offset][k]) = QMF_IM(Xlow[l + offset][p]);
temp1_i = temp2_i;
temp2_i = temp3_i;
temp3_i = QMF_IM(Xlow[l + offset][p]);
#endif
#ifdef SBR_LOW_POWER
QMF_RE(Xhigh[l + offset][k]) += (
MUL_R(RE(a0), QMF_RE(Xlow[l - 1 + offset][p])) +
MUL_R(RE(a1), QMF_RE(Xlow[l - 2 + offset][p])));
QMF_RE(Xhigh[l + offset][k]) =
temp3_r
+(MUL_R(a0_r, temp2_r) +
MUL_R(a1_r, temp1_r));
#else
QMF_RE(Xhigh[l + offset][k]) += (
RE(a0) * QMF_RE(Xlow[l - 1 + offset][p]) -
IM(a0) * QMF_IM(Xlow[l - 1 + offset][p]) +
RE(a1) * QMF_RE(Xlow[l - 2 + offset][p]) -
IM(a1) * QMF_IM(Xlow[l - 2 + offset][p]));
QMF_IM(Xhigh[l + offset][k]) += (
IM(a0) * QMF_RE(Xlow[l - 1 + offset][p]) +
RE(a0) * QMF_IM(Xlow[l - 1 + offset][p]) +
IM(a1) * QMF_RE(Xlow[l - 2 + offset][p]) +
RE(a1) * QMF_IM(Xlow[l - 2 + offset][p]));
QMF_RE(Xhigh[l + offset][k]) =
temp3_r
+(MUL_R(a0_r, temp2_r) -
MUL_R(a0_i, temp2_i) +
MUL_R(a1_r, temp1_r) -
MUL_R(a1_i, temp1_i));
QMF_IM(Xhigh[l + offset][k]) =
temp3_i
+(MUL_R(a0_i, temp2_r) +
MUL_R(a0_r, temp2_i) +
MUL_R(a1_i, temp1_r) +
MUL_R(a1_r, temp1_i));
#endif
}
} else {
@ -185,19 +195,57 @@ typedef struct
real_t det;
} acorr_coef;
#define SBR_ABS(A) ((A) < 0) ? -(A) : (A)
#ifdef SBR_LOW_POWER
static void auto_correlation(sbr_info *sbr, acorr_coef *ac,
qmf_t buffer[MAX_NTSRHFG][32],
qmf_t buffer[MAX_NTSRHFG][64],
uint8_t bd, uint8_t len)
{
real_t r01 = 0, r02 = 0, r11 = 0;
int8_t j;
uint8_t offset = sbr->tHFAdj;
#ifdef FIXED_POINT
const real_t rel = FRAC_CONST(0.999999); // 1 / (1 + 1e-6f);
uint32_t maxi = 0;
uint32_t pow2, exp;
#else
const real_t rel = 1 / (1 + 1e-6f);
#endif
#ifdef FIXED_POINT
mask = 0;
for (j = (offset-2); j < (len + offset); j++)
{
real_t x;
x = QMF_RE(buffer[j][bd])>>REAL_BITS;
mask |= x ^ (x >> 31);
}
exp = wl_min_lzc(mask);
/* improves accuracy */
if (exp > 0)
exp -= 1;
for (j = offset; j < len + offset; j++)
{
real_t buf_j = ((QMF_RE(buffer[j][bd])+(1<<(exp-1)))>>exp);
real_t buf_j_1 = ((QMF_RE(buffer[j-1][bd])+(1<<(exp-1)))>>exp);
real_t buf_j_2 = ((QMF_RE(buffer[j-2][bd])+(1<<(exp-1)))>>exp);
/* normalisation with rounding */
r01 += MUL_R(buf_j, buf_j_1);
r02 += MUL_R(buf_j, buf_j_2);
r11 += MUL_R(buf_j_1, buf_j_1);
}
RE(ac->r12) = r01 -
MUL_R(((QMF_RE(buffer[len+offset-1][bd])+(1<<(exp-1)))>>exp), ((QMF_RE(buffer[len+offset-2][bd])+(1<<(exp-1)))>>exp)) +
MUL_R(((QMF_RE(buffer[offset-1][bd])+(1<<(exp-1)))>>exp), ((QMF_RE(buffer[offset-2][bd])+(1<<(exp-1)))>>exp));
RE(ac->r22) = r11 -
MUL_R(((QMF_RE(buffer[len+offset-2][bd])+(1<<(exp-1)))>>exp), ((QMF_RE(buffer[len+offset-2][bd])+(1<<(exp-1)))>>exp)) +
MUL_R(((QMF_RE(buffer[offset-2][bd])+(1<<(exp-1)))>>exp), ((QMF_RE(buffer[offset-2][bd])+(1<<(exp-1)))>>exp));
#else
for (j = offset; j < len + offset; j++)
{
r01 += QMF_RE(buffer[j][bd]) * QMF_RE(buffer[j-1][bd]);
@ -210,63 +258,213 @@ static void auto_correlation(sbr_info *sbr, acorr_coef *ac,
RE(ac->r22) = r11 -
QMF_RE(buffer[len+offset-2][bd]) * QMF_RE(buffer[len+offset-2][bd]) +
QMF_RE(buffer[offset-2][bd]) * QMF_RE(buffer[offset-2][bd]);
#endif
RE(ac->r01) = r01;
RE(ac->r02) = r02;
RE(ac->r11) = r11;
ac->det = MUL_R(RE(ac->r11), RE(ac->r22)) - MUL_C(MUL_R(RE(ac->r12), RE(ac->r12)), rel);
ac->det = MUL_R(RE(ac->r11), RE(ac->r22)) - MUL_F(MUL_R(RE(ac->r12), RE(ac->r12)), rel);
}
#else
static void auto_correlation(sbr_info *sbr, acorr_coef *ac, qmf_t buffer[MAX_NTSRHFG][32],
static void auto_correlation(sbr_info *sbr, acorr_coef *ac, qmf_t buffer[MAX_NTSRHFG][64],
uint8_t bd, uint8_t len)
{
real_t r01r = 0, r01i = 0, r02r = 0, r02i = 0, r11r = 0;
real_t temp1_r, temp1_i, temp2_r, temp2_i, temp3_r, temp3_i, temp4_r, temp4_i, temp5_r, temp5_i;
#ifdef FIXED_POINT
const real_t rel = FRAC_CONST(0.999999); // 1 / (1 + 1e-6f);
uint32_t mask, exp;
real_t pow2_to_exp;
#else
const real_t rel = 1 / (1 + 1e-6f);
#endif
int8_t j;
uint8_t offset = sbr->tHFAdj;
#ifdef FIXED_POINT
mask = 0;
for (j = (offset-2); j < (len + offset); j++)
{
real_t x;
x = QMF_RE(buffer[j][bd])>>REAL_BITS;
mask |= x ^ (x >> 31);
x = QMF_IM(buffer[j][bd])>>REAL_BITS;
mask |= x ^ (x >> 31);
}
exp = wl_min_lzc(mask);
/* improves accuracy */
if (exp > 0)
exp -= 1;
pow2_to_exp = 1<<(exp-1);
temp2_r = (QMF_RE(buffer[offset-2][bd]) + pow2_to_exp) >> exp;
temp2_i = (QMF_IM(buffer[offset-2][bd]) + pow2_to_exp) >> exp;
temp3_r = (QMF_RE(buffer[offset-1][bd]) + pow2_to_exp) >> exp;
temp3_i = (QMF_IM(buffer[offset-1][bd]) + pow2_to_exp) >> exp;
// Save these because they are needed after loop
temp4_r = temp2_r;
temp4_i = temp2_i;
temp5_r = temp3_r;
temp5_i = temp3_i;
for (j = offset; j < len + offset; j++)
{
r01r += QMF_RE(buffer[j][bd]) * QMF_RE(buffer[j-1][bd]) +
QMF_IM(buffer[j][bd]) * QMF_IM(buffer[j-1][bd]);
r01i += QMF_IM(buffer[j][bd]) * QMF_RE(buffer[j-1][bd]) -
QMF_RE(buffer[j][bd]) * QMF_IM(buffer[j-1][bd]);
r02r += QMF_RE(buffer[j][bd]) * QMF_RE(buffer[j-2][bd]) +
QMF_IM(buffer[j][bd]) * QMF_IM(buffer[j-2][bd]);
r02i += QMF_IM(buffer[j][bd]) * QMF_RE(buffer[j-2][bd]) -
QMF_RE(buffer[j][bd]) * QMF_IM(buffer[j-2][bd]);
r11r += QMF_RE(buffer[j-1][bd]) * QMF_RE(buffer[j-1][bd]) +
QMF_IM(buffer[j-1][bd]) * QMF_IM(buffer[j-1][bd]);
temp1_r = temp2_r; // temp1_r = (QMF_RE(buffer[offset-2][bd] + (1<<(exp-1))) >> exp;
temp1_i = temp2_i; // temp1_i = (QMF_IM(buffer[offset-2][bd] + (1<<(exp-1))) >> exp;
temp2_r = temp3_r; // temp2_r = (QMF_RE(buffer[offset-1][bd] + (1<<(exp-1))) >> exp;
temp2_i = temp3_i; // temp2_i = (QMF_IM(buffer[offset-1][bd] + (1<<(exp-1))) >> exp;
temp3_r = (QMF_RE(buffer[j][bd]) + pow2_to_exp) >> exp;
temp3_i = (QMF_IM(buffer[j][bd]) + pow2_to_exp) >> exp;
r01r += MUL_R(temp3_r, temp2_r) + MUL_R(temp3_i, temp2_i);
r01i += MUL_R(temp3_i, temp2_r) - MUL_R(temp3_r, temp2_i);
r02r += MUL_R(temp3_r, temp1_r) + MUL_R(temp3_i, temp1_i);
r02i += MUL_R(temp3_i, temp1_r) - MUL_R(temp3_r, temp1_i);
r11r += MUL_R(temp2_r, temp2_r) + MUL_R(temp2_i, temp2_i);
}
// These are actual values in temporary variable at this point
// temp1_r = (QMF_RE(buffer[len+offset-1-2][bd] + (1<<(exp-1))) >> exp;
// temp1_i = (QMF_IM(buffer[len+offset-1-2][bd] + (1<<(exp-1))) >> exp;
// temp2_r = (QMF_RE(buffer[len+offset-1-1][bd] + (1<<(exp-1))) >> exp;
// temp2_i = (QMF_IM(buffer[len+offset-1-1][bd] + (1<<(exp-1))) >> exp;
// temp3_r = (QMF_RE(buffer[len+offset-1][bd]) + (1<<(exp-1))) >> exp;
// temp3_i = (QMF_IM(buffer[len+offset-1][bd]) + (1<<(exp-1))) >> exp;
// temp4_r = (QMF_RE(buffer[offset-2][bd]) + (1<<(exp-1))) >> exp;
// temp4_i = (QMF_IM(buffer[offset-2][bd]) + (1<<(exp-1))) >> exp;
// temp5_r = (QMF_RE(buffer[offset-1][bd]) + (1<<(exp-1))) >> exp;
// temp5_i = (QMF_IM(buffer[offset-1][bd]) + (1<<(exp-1))) >> exp;
RE(ac->r12) = r01r -
(MUL_R(temp3_r, temp2_r) + MUL_R(temp3_i, temp2_i)) +
(MUL_R(temp5_r, temp4_r) + MUL_R(temp5_i, temp4_i));
IM(ac->r12) = r01i -
(MUL_R(temp3_i, temp2_r) - MUL_R(temp3_r, temp2_i)) +
(MUL_R(temp5_i, temp4_r) - MUL_R(temp5_r, temp4_i));
RE(ac->r22) = r11r -
(MUL_R(temp2_r, temp2_r) + MUL_R(temp2_i, temp2_i)) +
(MUL_R(temp4_r, temp4_r) + MUL_R(temp4_i, temp4_i));
#else
temp2_r = QMF_RE(buffer[offset-2][bd]);
temp2_i = QMF_IM(buffer[offset-2][bd]);
temp3_r = QMF_RE(buffer[offset-1][bd]);
temp3_i = QMF_IM(buffer[offset-1][bd]);
// Save these because they are needed after loop
temp4_r = temp2_r;
temp4_i = temp2_i;
temp5_r = temp3_r;
temp5_i = temp3_i;
for (j = offset; j < len + offset; j++)
{
temp1_r = temp2_r; // temp1_r = QMF_RE(buffer[j-2][bd];
temp1_i = temp2_i; // temp1_i = QMF_IM(buffer[j-2][bd];
temp2_r = temp3_r; // temp2_r = QMF_RE(buffer[j-1][bd];
temp2_i = temp3_i; // temp2_i = QMF_IM(buffer[j-1][bd];
temp3_r = QMF_RE(buffer[j][bd]);
temp3_i = QMF_IM(buffer[j][bd]);
r01r += temp3_r * temp2_r + temp3_i * temp2_i;
r01i += temp3_i * temp2_r - temp3_r * temp2_i;
r02r += temp3_r * temp1_r + temp3_i * temp1_i;
r02i += temp3_i * temp1_r - temp3_r * temp1_i;
r11r += temp2_r * temp2_r + temp2_i * temp2_i;
}
// These are actual values in temporary variable at this point
// temp1_r = QMF_RE(buffer[len+offset-1-2][bd];
// temp1_i = QMF_IM(buffer[len+offset-1-2][bd];
// temp2_r = QMF_RE(buffer[len+offset-1-1][bd];
// temp2_i = QMF_IM(buffer[len+offset-1-1][bd];
// temp3_r = QMF_RE(buffer[len+offset-1][bd]);
// temp3_i = QMF_IM(buffer[len+offset-1][bd]);
// temp4_r = QMF_RE(buffer[offset-2][bd]);
// temp4_i = QMF_IM(buffer[offset-2][bd]);
// temp5_r = QMF_RE(buffer[offset-1][bd]);
// temp5_i = QMF_IM(buffer[offset-1][bd]);
RE(ac->r12) = r01r -
(temp3_r * temp2_r + temp3_i * temp2_i) +
(temp5_r * temp4_r + temp5_i * temp4_i);
IM(ac->r12) = r01i -
(temp3_i * temp2_r - temp3_r * temp2_i) +
(temp5_i * temp4_r - temp5_r * temp4_i);
RE(ac->r22) = r11r -
(temp2_r * temp2_r + temp2_i * temp2_i) +
(temp4_r * temp4_r + temp4_i * temp4_i);
#endif
RE(ac->r01) = r01r;
IM(ac->r01) = r01i;
RE(ac->r02) = r02r;
IM(ac->r02) = r02i;
RE(ac->r11) = r11r;
RE(ac->r12) = r01r -
(QMF_RE(buffer[len+offset-1][bd]) * QMF_RE(buffer[len+offset-2][bd]) + QMF_IM(buffer[len+offset-1][bd]) * QMF_IM(buffer[len+offset-2][bd])) +
(QMF_RE(buffer[offset-1][bd]) * QMF_RE(buffer[offset-2][bd]) + QMF_IM(buffer[offset-1][bd]) * QMF_IM(buffer[offset-2][bd]));
IM(ac->r12) = r01i -
(QMF_IM(buffer[len+offset-1][bd]) * QMF_RE(buffer[len+offset-2][bd]) - QMF_RE(buffer[len+offset-1][bd]) * QMF_IM(buffer[len+offset-2][bd])) +
(QMF_IM(buffer[offset-1][bd]) * QMF_RE(buffer[offset-2][bd]) - QMF_RE(buffer[offset-1][bd]) * QMF_IM(buffer[offset-2][bd]));
RE(ac->r22) = r11r -
(QMF_RE(buffer[len+offset-2][bd]) * QMF_RE(buffer[len+offset-2][bd]) + QMF_IM(buffer[len+offset-2][bd]) * QMF_IM(buffer[len+offset-2][bd])) +
(QMF_RE(buffer[offset-2][bd]) * QMF_RE(buffer[offset-2][bd]) + QMF_IM(buffer[offset-2][bd]) * QMF_IM(buffer[offset-2][bd]));
ac->det = RE(ac->r11) * RE(ac->r22) - rel * (RE(ac->r12) * RE(ac->r12) + IM(ac->r12) * IM(ac->r12));
ac->det = MUL_R(RE(ac->r11), RE(ac->r22)) - MUL_F(rel, (MUL_R(RE(ac->r12), RE(ac->r12)) + MUL_R(IM(ac->r12), IM(ac->r12))));
}
#endif
/* calculate linear prediction coefficients using the covariance method */
static void calc_prediction_coef(sbr_info *sbr, qmf_t Xlow[MAX_NTSRHFG][32],
complex_t *alpha_0, complex_t *alpha_1
#ifdef SBR_LOW_POWER
, real_t *rxx
#ifndef SBR_LOW_POWER
static void calc_prediction_coef(sbr_info *sbr, qmf_t Xlow[MAX_NTSRHFG][64],
complex_t *alpha_0, complex_t *alpha_1, uint8_t k)
{
real_t tmp;
acorr_coef ac;
auto_correlation(sbr, &ac, Xlow, k, sbr->numTimeSlotsRate + 6);
if (ac.det == 0)
{
RE(alpha_1[k]) = 0;
IM(alpha_1[k]) = 0;
} else {
#ifdef FIXED_POINT
tmp = (MUL_R(RE(ac.r01), RE(ac.r12)) - MUL_R(IM(ac.r01), IM(ac.r12)) - MUL_R(RE(ac.r02), RE(ac.r11)));
RE(alpha_1[k]) = DIV_R(tmp, ac.det);
tmp = (MUL_R(IM(ac.r01), RE(ac.r12)) + MUL_R(RE(ac.r01), IM(ac.r12)) - MUL_R(IM(ac.r02), RE(ac.r11)));
IM(alpha_1[k]) = DIV_R(tmp, ac.det);
#else
tmp = REAL_CONST(1.0) / ac.det;
RE(alpha_1[k]) = (MUL_R(RE(ac.r01), RE(ac.r12)) - MUL_R(IM(ac.r01), IM(ac.r12)) - MUL_R(RE(ac.r02), RE(ac.r11))) * tmp;
IM(alpha_1[k]) = (MUL_R(IM(ac.r01), RE(ac.r12)) + MUL_R(RE(ac.r01), IM(ac.r12)) - MUL_R(IM(ac.r02), RE(ac.r11))) * tmp;
#endif
)
}
if (RE(ac.r11) == 0)
{
RE(alpha_0[k]) = 0;
IM(alpha_0[k]) = 0;
} else {
#ifdef FIXED_POINT
tmp = -(RE(ac.r01) + MUL_R(RE(alpha_1[k]), RE(ac.r12)) + MUL_R(IM(alpha_1[k]), IM(ac.r12)));
RE(alpha_0[k]) = DIV_R(tmp, RE(ac.r11));
tmp = -(IM(ac.r01) + MUL_R(IM(alpha_1[k]), RE(ac.r12)) - MUL_R(RE(alpha_1[k]), IM(ac.r12)));
IM(alpha_0[k]) = DIV_R(tmp, RE(ac.r11));
#else
tmp = 1.0f / RE(ac.r11);
RE(alpha_0[k]) = -(RE(ac.r01) + MUL_R(RE(alpha_1[k]), RE(ac.r12)) + MUL_R(IM(alpha_1[k]), IM(ac.r12))) * tmp;
IM(alpha_0[k]) = -(IM(ac.r01) + MUL_R(IM(alpha_1[k]), RE(ac.r12)) - MUL_R(RE(alpha_1[k]), IM(ac.r12))) * tmp;
#endif
}
if ((MUL_R(RE(alpha_0[k]),RE(alpha_0[k])) + MUL_R(IM(alpha_0[k]),IM(alpha_0[k])) >= REAL_CONST(16)) ||
(MUL_R(RE(alpha_1[k]),RE(alpha_1[k])) + MUL_R(IM(alpha_1[k]),IM(alpha_1[k])) >= REAL_CONST(16)))
{
RE(alpha_0[k]) = 0;
IM(alpha_0[k]) = 0;
RE(alpha_1[k]) = 0;
IM(alpha_1[k]) = 0;
}
}
#else
static void calc_prediction_coef_lp(sbr_info *sbr, qmf_t Xlow[MAX_NTSRHFG][64],
complex_t *alpha_0, complex_t *alpha_1, real_t *rxx)
{
uint8_t k;
real_t tmp;
@ -276,21 +474,16 @@ static void calc_prediction_coef(sbr_info *sbr, qmf_t Xlow[MAX_NTSRHFG][32],
{
auto_correlation(sbr, &ac, Xlow, k, sbr->numTimeSlotsRate + 6);
#ifdef SBR_LOW_POWER
if (ac.det == 0)
{
RE(alpha_0[k]) = 0;
RE(alpha_1[k]) = 0;
} else {
tmp = MUL_R(RE(ac.r01), RE(ac.r12)) - MUL_R(RE(ac.r02), RE(ac.r11));
RE(alpha_1[k]) = SBR_DIV(tmp, ac.det);
}
tmp = MUL_R(RE(ac.r01), RE(ac.r22)) - MUL_R(RE(ac.r12), RE(ac.r02));
RE(alpha_0[k]) = DIV_R(tmp, (-ac.det));
if (RE(ac.r11) == 0)
{
RE(alpha_0[k]) = 0;
} else {
tmp = RE(ac.r01) + MUL_R(RE(alpha_1[k]), RE(ac.r12));
RE(alpha_0[k]) = -SBR_DIV(tmp, RE(ac.r11));
tmp = MUL_R(RE(ac.r01), RE(ac.r12)) - MUL_R(RE(ac.r02), RE(ac.r11));
RE(alpha_1[k]) = DIV_R(tmp, ac.det);
}
if ((RE(alpha_0[k]) >= REAL_CONST(4)) || (RE(alpha_1[k]) >= REAL_CONST(4)))
@ -302,84 +495,54 @@ static void calc_prediction_coef(sbr_info *sbr, qmf_t Xlow[MAX_NTSRHFG][32],
/* reflection coefficient */
if (RE(ac.r11) == 0)
{
rxx[k] = REAL_CONST(0.0);
rxx[k] = COEF_CONST(0.0);
} else {
rxx[k] = -SBR_DIV(RE(ac.r01), RE(ac.r11));
if (rxx[k] > REAL_CONST(1.0)) rxx[k] = REAL_CONST(1.0);
if (rxx[k] < REAL_CONST(-1.0)) rxx[k] = REAL_CONST(-1.0);
rxx[k] = DIV_C(RE(ac.r01), RE(ac.r11));
rxx[k] = -rxx[k];
if (rxx[k] > COEF_CONST(1.0)) rxx[k] = COEF_CONST(1.0);
if (rxx[k] < COEF_CONST(-1.0)) rxx[k] = COEF_CONST(-1.0);
}
#else
if (ac.det == 0)
{
RE(alpha_1[k]) = 0;
IM(alpha_1[k]) = 0;
} else {
tmp = REAL_CONST(1.0) / ac.det;
RE(alpha_1[k]) = (RE(ac.r01) * RE(ac.r12) - IM(ac.r01) * IM(ac.r12) - RE(ac.r02) * RE(ac.r11)) * tmp;
IM(alpha_1[k]) = (IM(ac.r01) * RE(ac.r12) + RE(ac.r01) * IM(ac.r12) - IM(ac.r02) * RE(ac.r11)) * tmp;
}
if (RE(ac.r11) == 0)
{
RE(alpha_0[k]) = 0;
IM(alpha_0[k]) = 0;
} else {
tmp = 1.0f / RE(ac.r11);
RE(alpha_0[k]) = -(RE(ac.r01) + RE(alpha_1[k]) * RE(ac.r12) + IM(alpha_1[k]) * IM(ac.r12)) * tmp;
IM(alpha_0[k]) = -(IM(ac.r01) + IM(alpha_1[k]) * RE(ac.r12) - RE(alpha_1[k]) * IM(ac.r12)) * tmp;
}
if ((RE(alpha_0[k])*RE(alpha_0[k]) + IM(alpha_0[k])*IM(alpha_0[k]) >= 16) ||
(RE(alpha_1[k])*RE(alpha_1[k]) + IM(alpha_1[k])*IM(alpha_1[k]) >= 16))
{
RE(alpha_0[k]) = 0;
IM(alpha_0[k]) = 0;
RE(alpha_1[k]) = 0;
IM(alpha_1[k]) = 0;
}
#endif
}
}
#ifdef SBR_LOW_POWER
static void calc_aliasing_degree(sbr_info *sbr, real_t *rxx, real_t *deg)
{
uint8_t k;
rxx[0] = REAL_CONST(0.0);
deg[1] = REAL_CONST(0.0);
rxx[0] = COEF_CONST(0.0);
deg[1] = COEF_CONST(0.0);
for (k = 2; k < sbr->k0; k++)
{
deg[k] = 0.0;
if ((k % 2 == 0) && (rxx[k] < REAL_CONST(0.0)))
if ((k % 2 == 0) && (rxx[k] < COEF_CONST(0.0)))
{
if (rxx[k-1] < 0.0)
{
deg[k] = REAL_CONST(1.0);
deg[k] = COEF_CONST(1.0);
if (rxx[k-2] > REAL_CONST(0.0))
if (rxx[k-2] > COEF_CONST(0.0))
{
deg[k-1] = REAL_CONST(1.0) - MUL_R(rxx[k-1], rxx[k-1]);
deg[k-1] = COEF_CONST(1.0) - MUL_C(rxx[k-1], rxx[k-1]);
}
} else if (rxx[k-2] > REAL_CONST(0.0)) {
deg[k] = REAL_CONST(1.0) - MUL_R(rxx[k-1], rxx[k-1]);
} else if (rxx[k-2] > COEF_CONST(0.0)) {
deg[k] = COEF_CONST(1.0) - MUL_C(rxx[k-1], rxx[k-1]);
}
}
if ((k % 2 == 1) && (rxx[k] > REAL_CONST(0.0)))
if ((k % 2 == 1) && (rxx[k] > COEF_CONST(0.0)))
{
if (rxx[k-1] > REAL_CONST(0.0))
if (rxx[k-1] > COEF_CONST(0.0))
{
deg[k] = REAL_CONST(1.0);
deg[k] = COEF_CONST(1.0);
if (rxx[k-2] < REAL_CONST(0.0))
if (rxx[k-2] < COEF_CONST(0.0))
{
deg[k-1] = REAL_CONST(1.0) - MUL_R(rxx[k-1], rxx[k-1]);
deg[k-1] = COEF_CONST(1.0) - MUL_C(rxx[k-1], rxx[k-1]);
}
} else if (rxx[k-2] < REAL_CONST(0.0)) {
deg[k] = REAL_CONST(1.0) - MUL_R(rxx[k-1], rxx[k-1]);
} else if (rxx[k-2] < COEF_CONST(0.0)) {
deg[k] = COEF_CONST(1.0) - MUL_C(rxx[k-1], rxx[k-1]);
}
}
}
@ -442,7 +605,7 @@ static void patch_construction(sbr_info *sbr)
uint8_t odd, sb;
uint8_t msb = sbr->k0;
uint8_t usb = sbr->kx;
uint8_t goalSbTab[] = { 21, 23, 43, 46, 64, 85, 93, 128, 0, 0, 0 };
uint8_t goalSbTab[] = { 21, 23, 32, 43, 46, 64, 85, 93, 128, 0, 0, 0 };
/* (uint8_t)(2.048e6/sbr->sample_rate + 0.5); */
uint8_t goalSb = goalSbTab[get_sr_index(sbr->sample_rate)];

View File

@ -23,7 +23,7 @@
** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
**
** Initially modified for use with MPlayer by Arpad Gereöffy on 2003/08/30
** $Id: sbr_hfgen.h,v 1.3 2004/06/02 22:59:03 diego Exp $
** $Id: sbr_hfgen.h,v 1.4 2004/06/23 13:50:52 diego Exp $
** detailed CVS changelog at http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
**/
@ -34,7 +34,7 @@
extern "C" {
#endif
void hf_generation(sbr_info *sbr, qmf_t Xlow[MAX_NTSRHFG][32],
void hf_generation(sbr_info *sbr, qmf_t Xlow[MAX_NTSRHFG][64],
qmf_t Xhigh[MAX_NTSRHFG][64]
#ifdef SBR_LOW_POWER
,real_t *deg

View File

@ -23,7 +23,7 @@
** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
**
** Initially modified for use with MPlayer by Arpad Gereöffy on 2003/08/30
** $Id: sbr_huff.c,v 1.3 2004/06/02 22:59:03 diego Exp $
** $Id: sbr_huff.c,v 1.4 2004/06/23 13:50:52 diego Exp $
** detailed CVS changelog at http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
**/
@ -192,7 +192,6 @@ static const int8_t f_huffman_env_bal_3_0dB[24][2] = {
{ -57, -56 }, { 22, 23 }, { -55, -54 }, { -53, -52 }
};
static const int8_t t_huffman_noise_3_0dB[62][2] = {
{ -64, 1 }, { -63, 2 }, { -65, 3 }, { -66, 4 },
{ -62, 5 }, { -67, 6 }, { 7, 8 }, { -61, -68 },
@ -229,7 +228,7 @@ static INLINE int16_t sbr_huff_dec(bitfile *ld, sbr_huff_tab t_huff)
while (index >= 0)
{
bit = (uint8_t)faad_getbits(ld, 1);
bit = (uint8_t)faad_get1bit(ld);
index = t_huff[index][bit];
}

View File

@ -23,7 +23,7 @@
** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
**
** Initially modified for use with MPlayer by Arpad Gereöffy on 2003/08/30
** $Id: sbr_qmf.c,v 1.3 2004/06/02 22:59:03 diego Exp $
** $Id: sbr_qmf.c,v 1.4 2004/06/23 13:50:52 diego Exp $
** detailed CVS changelog at http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
**/
@ -40,12 +40,16 @@
#include "sbr_qmf_c.h"
#include "sbr_syntax.h"
qmfa_info *qmfa_init(uint8_t channels)
{
qmfa_info *qmfa = (qmfa_info*)faad_malloc(sizeof(qmfa_info));
qmfa->x = (real_t*)faad_malloc(channels * 10 * sizeof(real_t));
memset(qmfa->x, 0, channels * 10 * sizeof(real_t));
/* x is implemented as double ringbuffer */
qmfa->x = (real_t*)faad_malloc(2 * channels * 10 * sizeof(real_t));
memset(qmfa->x, 0, 2 * channels * 10 * sizeof(real_t));
/* ringbuffer index */
qmfa->x_index = 0;
qmfa->channels = channels;
@ -62,11 +66,11 @@ void qmfa_end(qmfa_info *qmfa)
}
void sbr_qmf_analysis_32(sbr_info *sbr, qmfa_info *qmfa, const real_t *input,
qmf_t X[MAX_NTSRHFG][32], uint8_t offset, uint8_t kx)
qmf_t X[MAX_NTSRHFG][64], uint8_t offset, uint8_t kx)
{
ALIGN real_t u[64];
#ifndef SBR_LOW_POWER
ALIGN real_t x[64], y[64];
ALIGN real_t in_real[32], in_imag[32], out_real[32], out_imag[32];
#else
ALIGN real_t y[32];
#endif
@ -79,28 +83,34 @@ void sbr_qmf_analysis_32(sbr_info *sbr, qmfa_info *qmfa, const real_t *input,
int16_t n;
/* shift input buffer x */
memmove(qmfa->x + 32, qmfa->x, (320-32)*sizeof(real_t));
/* input buffer is not shifted anymore, x is implemented as double ringbuffer */
//memmove(qmfa->x + 32, qmfa->x, (320-32)*sizeof(real_t));
/* add new samples to input buffer x */
for (n = 32 - 1; n >= 0; n--)
{
#ifdef FIXED_POINT
qmfa->x[n] = (input[in++]) >> 5;
qmfa->x[qmfa->x_index + n] = qmfa->x[qmfa->x_index + n + 320] = (input[in++]) >> 4;
#else
qmfa->x[n] = input[in++];
qmfa->x[qmfa->x_index + n] = qmfa->x[qmfa->x_index + n + 320] = input[in++];
#endif
}
/* window and summation to create array u */
for (n = 0; n < 64; n++)
{
u[n] = MUL_F(qmfa->x[n], qmf_c[2*n]) +
MUL_F(qmfa->x[n + 64], qmf_c[2*(n + 64)]) +
MUL_F(qmfa->x[n + 128], qmf_c[2*(n + 128)]) +
MUL_F(qmfa->x[n + 192], qmf_c[2*(n + 192)]) +
MUL_F(qmfa->x[n + 256], qmf_c[2*(n + 256)]);
u[n] = MUL_F(qmfa->x[qmfa->x_index + n], qmf_c[2*n]) +
MUL_F(qmfa->x[qmfa->x_index + n + 64], qmf_c[2*(n + 64)]) +
MUL_F(qmfa->x[qmfa->x_index + n + 128], qmf_c[2*(n + 128)]) +
MUL_F(qmfa->x[qmfa->x_index + n + 192], qmf_c[2*(n + 192)]) +
MUL_F(qmfa->x[qmfa->x_index + n + 256], qmf_c[2*(n + 256)]);
}
/* update ringbuffer index */
qmfa->x_index -= 32;
if (qmfa->x_index < 0)
qmfa->x_index = (320-32);
/* calculate 32 subband samples by introducing X */
#ifdef SBR_LOW_POWER
y[0] = u[48];
@ -116,7 +126,7 @@ void sbr_qmf_analysis_32(sbr_info *sbr, qmfa_info *qmfa, const real_t *input,
if (n < kx)
{
#ifdef FIXED_POINT
QMF_RE(X[l + offset][n]) = u[n] << 1;
QMF_RE(X[l + offset][n]) = u[n] /*<< 1*/;
#else
QMF_RE(X[l + offset][n]) = 2. * u[n];
#endif
@ -125,64 +135,105 @@ void sbr_qmf_analysis_32(sbr_info *sbr, qmfa_info *qmfa, const real_t *input,
}
}
#else
x[0] = u[0];
for (n = 0; n < 31; n++)
// Reordering of data moved from DCT_IV to here
in_imag[31] = u[1];
in_real[0] = u[0];
for (n = 1; n < 31; n++)
{
x[2*n+1] = u[n+1] + u[63-n];
x[2*n+2] = u[n+1] - u[63-n];
in_imag[31 - n] = u[n+1];
in_real[n] = -u[64-n];
}
x[63] = u[32];
in_imag[0] = u[32];
in_real[31] = -u[33];
DCT4_64_kernel(y, x);
// dct4_kernel is DCT_IV without reordering which is done before and after FFT
dct4_kernel(in_real, in_imag, out_real, out_imag);
for (n = 0; n < 32; n++)
{
if (n < kx)
{
// Reordering of data moved from DCT_IV to here
for (n = 0; n < 16; n++) {
if (2*n+1 < kx) {
#ifdef FIXED_POINT
QMF_RE(X[l + offset][n]) = y[n] << 1;
QMF_IM(X[l + offset][n]) = -y[63-n] << 1;
QMF_RE(X[l + offset][2*n]) = out_real[n];
QMF_IM(X[l + offset][2*n]) = out_imag[n];
QMF_RE(X[l + offset][2*n+1]) = -out_imag[31-n];
QMF_IM(X[l + offset][2*n+1]) = -out_real[31-n];
#else
QMF_RE(X[l + offset][n]) = 2. * y[n];
QMF_IM(X[l + offset][n]) = -2. * y[63-n];
QMF_RE(X[l + offset][2*n]) = 2. * out_real[n];
QMF_IM(X[l + offset][2*n]) = 2. * out_imag[n];
QMF_RE(X[l + offset][2*n+1]) = -2. * out_imag[31-n];
QMF_IM(X[l + offset][2*n+1]) = -2. * out_real[31-n];
#endif
} else {
QMF_RE(X[l + offset][n]) = 0;
QMF_IM(X[l + offset][n]) = 0;
if (2*n < kx) {
#ifdef FIXED_POINT
QMF_RE(X[l + offset][2*n]) = out_real[n];
QMF_IM(X[l + offset][2*n]) = out_imag[n];
#else
QMF_RE(X[l + offset][2*n]) = 2. * out_real[n];
QMF_IM(X[l + offset][2*n]) = 2. * out_imag[n];
#endif
}
else {
QMF_RE(X[l + offset][2*n]) = 0;
QMF_IM(X[l + offset][2*n]) = 0;
}
QMF_RE(X[l + offset][2*n+1]) = 0;
QMF_IM(X[l + offset][2*n+1]) = 0;
}
}
#endif
}
}
static const complex_t qmf32_pre_twiddle[] =
{
{ FRAC_CONST(0.999924701839145), FRAC_CONST(-0.012271538285720) },
{ FRAC_CONST(0.999322384588350), FRAC_CONST(-0.036807222941359) },
{ FRAC_CONST(0.998118112900149), FRAC_CONST(-0.061320736302209) },
{ FRAC_CONST(0.996312612182778), FRAC_CONST(-0.085797312344440) },
{ FRAC_CONST(0.993906970002356), FRAC_CONST(-0.110222207293883) },
{ FRAC_CONST(0.990902635427780), FRAC_CONST(-0.134580708507126) },
{ FRAC_CONST(0.987301418157858), FRAC_CONST(-0.158858143333861) },
{ FRAC_CONST(0.983105487431216), FRAC_CONST(-0.183039887955141) },
{ FRAC_CONST(0.978317370719628), FRAC_CONST(-0.207111376192219) },
{ FRAC_CONST(0.972939952205560), FRAC_CONST(-0.231058108280671) },
{ FRAC_CONST(0.966976471044852), FRAC_CONST(-0.254865659604515) },
{ FRAC_CONST(0.960430519415566), FRAC_CONST(-0.278519689385053) },
{ FRAC_CONST(0.953306040354194), FRAC_CONST(-0.302005949319228) },
{ FRAC_CONST(0.945607325380521), FRAC_CONST(-0.325310292162263) },
{ FRAC_CONST(0.937339011912575), FRAC_CONST(-0.348418680249435) },
{ FRAC_CONST(0.928506080473216), FRAC_CONST(-0.371317193951838) },
{ FRAC_CONST(0.919113851690058), FRAC_CONST(-0.393992040061048) },
{ FRAC_CONST(0.909167983090522), FRAC_CONST(-0.416429560097637) },
{ FRAC_CONST(0.898674465693954), FRAC_CONST(-0.438616238538528) },
{ FRAC_CONST(0.887639620402854), FRAC_CONST(-0.460538710958240) },
{ FRAC_CONST(0.876070094195407), FRAC_CONST(-0.482183772079123) },
{ FRAC_CONST(0.863972856121587), FRAC_CONST(-0.503538383725718) },
{ FRAC_CONST(0.851355193105265), FRAC_CONST(-0.524589682678469) },
{ FRAC_CONST(0.838224705554838), FRAC_CONST(-0.545324988422046) },
{ FRAC_CONST(0.824589302785025), FRAC_CONST(-0.565731810783613) },
{ FRAC_CONST(0.810457198252595), FRAC_CONST(-0.585797857456439) },
{ FRAC_CONST(0.795836904608884), FRAC_CONST(-0.605511041404326) },
{ FRAC_CONST(0.780737228572094), FRAC_CONST(-0.624859488142386) },
{ FRAC_CONST(0.765167265622459), FRAC_CONST(-0.643831542889791) },
{ FRAC_CONST(0.749136394523459), FRAC_CONST(-0.662415777590172) },
{ FRAC_CONST(0.732654271672413), FRAC_CONST(-0.680600997795453) },
{ FRAC_CONST(0.715730825283819), FRAC_CONST(-0.698376249408973) }
};
qmfs_info *qmfs_init(uint8_t channels)
{
qmfs_info *qmfs = (qmfs_info*)faad_malloc(sizeof(qmfs_info));
#ifndef SBR_LOW_POWER
qmfs->v[0] = (real_t*)faad_malloc(channels * 10 * sizeof(real_t));
memset(qmfs->v[0], 0, channels * 10 * sizeof(real_t));
qmfs->v[1] = (real_t*)faad_malloc(channels * 10 * sizeof(real_t));
memset(qmfs->v[1], 0, channels * 10 * sizeof(real_t));
#else
qmfs->v[0] = (real_t*)faad_malloc(channels * 20 * sizeof(real_t));
memset(qmfs->v[0], 0, channels * 20 * sizeof(real_t));
qmfs->v[1] = NULL;
#endif
/* v is a double ringbuffer */
qmfs->v = (real_t*)faad_malloc(2 * channels * 20 * sizeof(real_t));
memset(qmfs->v, 0, 2 * channels * 20 * sizeof(real_t));
qmfs->v_index = 0;
qmfs->channels = channels;
#ifdef USE_SSE
if (cpu_has_sse())
{
qmfs->qmf_func = sbr_qmf_synthesis_64_sse;
} else {
qmfs->qmf_func = sbr_qmf_synthesis_64;
}
#endif
return qmfs;
}
@ -190,15 +241,82 @@ void qmfs_end(qmfs_info *qmfs)
{
if (qmfs)
{
if (qmfs->v[0]) faad_free(qmfs->v[0]);
#ifndef SBR_LOW_POWER
if (qmfs->v[1]) faad_free(qmfs->v[1]);
#endif
if (qmfs->v) faad_free(qmfs->v);
faad_free(qmfs);
}
}
#ifdef SBR_LOW_POWER
void sbr_qmf_synthesis_32(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSRHFG][64],
real_t *output)
{
ALIGN real_t x[16];
ALIGN real_t y[16];
int16_t n, k, out = 0;
uint8_t l;
/* qmf subsample l */
for (l = 0; l < sbr->numTimeSlotsRate; l++)
{
/* shift buffers */
/* we are not shifting v, it is a double ringbuffer */
//memmove(qmfs->v + 64, qmfs->v, (640-64)*sizeof(real_t));
/* calculate 64 samples */
for (k = 0; k < 16; k++)
{
#ifdef FIXED_POINT
y[k] = (QMF_RE(X[l][k]) - QMF_RE(X[l][31 - k]));
x[k] = (QMF_RE(X[l][k]) + QMF_RE(X[l][31 - k]));
#else
y[k] = (QMF_RE(X[l][k]) - QMF_RE(X[l][31 - k])) / 32.0;
x[k] = (QMF_RE(X[l][k]) + QMF_RE(X[l][31 - k])) / 32.0;
#endif
}
/* even n samples */
DCT2_16_unscaled(x, x);
/* odd n samples */
DCT4_16(y, y);
for (n = 8; n < 24; n++)
{
qmfs->v[qmfs->v_index + n*2] = qmfs->v[qmfs->v_index + 640 + n*2] = x[n-8];
qmfs->v[qmfs->v_index + n*2+1] = qmfs->v[qmfs->v_index + 640 + n*2+1] = y[n-8];
}
for (n = 0; n < 16; n++)
{
qmfs->v[qmfs->v_index + n] = qmfs->v[qmfs->v_index + 640 + n] = qmfs->v[qmfs->v_index + 32-n];
}
qmfs->v[qmfs->v_index + 48] = qmfs->v[qmfs->v_index + 640 + 48] = 0;
for (n = 1; n < 16; n++)
{
qmfs->v[qmfs->v_index + 48+n] = qmfs->v[qmfs->v_index + 640 + 48+n] = -qmfs->v[qmfs->v_index + 48-n];
}
/* calculate 32 output samples and window */
for (k = 0; k < 32; k++)
{
output[out++] = MUL_F(qmfs->v[qmfs->v_index + k], qmf_c[2*k]) +
MUL_F(qmfs->v[qmfs->v_index + 96 + k], qmf_c[64 + 2*k]) +
MUL_F(qmfs->v[qmfs->v_index + 128 + k], qmf_c[128 + 2*k]) +
MUL_F(qmfs->v[qmfs->v_index + 224 + k], qmf_c[192 + 2*k]) +
MUL_F(qmfs->v[qmfs->v_index + 256 + k], qmf_c[256 + 2*k]) +
MUL_F(qmfs->v[qmfs->v_index + 352 + k], qmf_c[320 + 2*k]) +
MUL_F(qmfs->v[qmfs->v_index + 384 + k], qmf_c[384 + 2*k]) +
MUL_F(qmfs->v[qmfs->v_index + 480 + k], qmf_c[448 + 2*k]) +
MUL_F(qmfs->v[qmfs->v_index + 512 + k], qmf_c[512 + 2*k]) +
MUL_F(qmfs->v[qmfs->v_index + 608 + k], qmf_c[576 + 2*k]);
}
/* update the ringbuffer index */
qmfs->v_index -= 64;
if (qmfs->v_index < 0)
qmfs->v_index = (640-64);
}
}
void sbr_qmf_synthesis_64(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSRHFG][64],
real_t *output)
{
@ -211,172 +329,154 @@ void sbr_qmf_synthesis_64(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSRHFG][6
/* qmf subsample l */
for (l = 0; l < sbr->numTimeSlotsRate; l++)
{
//real_t *v0, *v1;
/* shift buffers */
//memmove(qmfs->v[0] + 64, qmfs->v[0], (640-64)*sizeof(real_t));
//memmove(qmfs->v[1] + 64, qmfs->v[1], (640-64)*sizeof(real_t));
memmove(qmfs->v[0] + 128, qmfs->v[0], (1280-128)*sizeof(real_t));
//v0 = qmfs->v[qmfs->v_index];
//v1 = qmfs->v[(qmfs->v_index + 1) & 0x1];
//qmfs->v_index = (qmfs->v_index + 1) & 0x1;
/* we are not shifting v, it is a double ringbuffer */
//memmove(qmfs->v + 128, qmfs->v, (1280-128)*sizeof(real_t));
/* calculate 128 samples */
for (k = 0; k < 64; k++)
for (k = 0; k < 32; k++)
{
#ifdef FIXED_POINT
x[k] = QMF_RE(X[l][k]);
y[k] = (QMF_RE(X[l][k]) - QMF_RE(X[l][63 - k]));
x[k] = (QMF_RE(X[l][k]) + QMF_RE(X[l][63 - k]));
#else
x[k] = QMF_RE(X[l][k]) / 32.;
y[k] = (QMF_RE(X[l][k]) - QMF_RE(X[l][63 - k])) / 32.0;
x[k] = (QMF_RE(X[l][k]) + QMF_RE(X[l][63 - k])) / 32.0;
#endif
}
for (n = 0; n < 32; n++)
{
y[2*n] = -x[2*n];
y[2*n+1] = x[2*n+1];
}
/* even n samples */
DCT2_32_unscaled(x, x);
/* odd n samples */
DCT4_32(y, y);
DCT2_64_unscaled(x, x);
for (n = 0; n < 64; n++)
for (n = 16; n < 48; n++)
{
qmfs->v[0][n+32] = x[n];
qmfs->v[qmfs->v_index + n*2] = qmfs->v[qmfs->v_index + 1280 + n*2] = x[n-16];
qmfs->v[qmfs->v_index + n*2+1] = qmfs->v[qmfs->v_index + 1280 + n*2+1] = y[n-16];
}
for (n = 0; n < 32; n++)
{
qmfs->v[0][31 - n] = x[n + 1];
qmfs->v[qmfs->v_index + n] = qmfs->v[qmfs->v_index + 1280 + n] = qmfs->v[qmfs->v_index + 64-n];
}
DST2_64_unscaled(x, y);
qmfs->v[0][96] = 0;
qmfs->v[qmfs->v_index + 96] = qmfs->v[qmfs->v_index + 1280 + 96] = 0;
for (n = 1; n < 32; n++)
{
qmfs->v[0][n + 96] = x[n-1];
qmfs->v[qmfs->v_index + 96+n] = qmfs->v[qmfs->v_index + 1280 + 96+n] = -qmfs->v[qmfs->v_index + 96-n];
}
/* calculate 64 output samples and window */
for (k = 0; k < 64; k++)
{
#if 1
output[out++] = MUL_F(qmfs->v[0][k], qmf_c[k]) +
MUL_F(qmfs->v[0][192 + k], qmf_c[64 + k]) +
MUL_F(qmfs->v[0][256 + k], qmf_c[128 + k]) +
MUL_F(qmfs->v[0][256 + 192 + k], qmf_c[128 + 64 + k]) +
MUL_F(qmfs->v[0][512 + k], qmf_c[256 + k]) +
MUL_F(qmfs->v[0][512 + 192 + k], qmf_c[256 + 64 + k]) +
MUL_F(qmfs->v[0][768 + k], qmf_c[384 + k]) +
MUL_F(qmfs->v[0][768 + 192 + k], qmf_c[384 + 64 + k]) +
MUL_F(qmfs->v[0][1024 + k], qmf_c[512 + k]) +
MUL_F(qmfs->v[0][1024 + 192 + k], qmf_c[512 + 64 + k]);
#else
output[out++] = MUL_F(v0[k], qmf_c[k]) +
MUL_F(v0[64 + k], qmf_c[64 + k]) +
MUL_F(v0[128 + k], qmf_c[128 + k]) +
MUL_F(v0[192 + k], qmf_c[192 + k]) +
MUL_F(v0[256 + k], qmf_c[256 + k]) +
MUL_F(v0[320 + k], qmf_c[320 + k]) +
MUL_F(v0[384 + k], qmf_c[384 + k]) +
MUL_F(v0[448 + k], qmf_c[448 + k]) +
MUL_F(v0[512 + k], qmf_c[512 + k]) +
MUL_F(v0[576 + k], qmf_c[576 + k]);
#endif
output[out++] = MUL_F(qmfs->v[qmfs->v_index + k], qmf_c[k]) +
MUL_F(qmfs->v[qmfs->v_index + 192 + k], qmf_c[64 + k]) +
MUL_F(qmfs->v[qmfs->v_index + 256 + k], qmf_c[128 + k]) +
MUL_F(qmfs->v[qmfs->v_index + 256 + 192 + k], qmf_c[128 + 64 + k]) +
MUL_F(qmfs->v[qmfs->v_index + 512 + k], qmf_c[256 + k]) +
MUL_F(qmfs->v[qmfs->v_index + 512 + 192 + k], qmf_c[256 + 64 + k]) +
MUL_F(qmfs->v[qmfs->v_index + 768 + k], qmf_c[384 + k]) +
MUL_F(qmfs->v[qmfs->v_index + 768 + 192 + k], qmf_c[384 + 64 + k]) +
MUL_F(qmfs->v[qmfs->v_index + 1024 + k], qmf_c[512 + k]) +
MUL_F(qmfs->v[qmfs->v_index + 1024 + 192 + k], qmf_c[512 + 64 + k]);
}
/* update the ringbuffer index */
qmfs->v_index -= 128;
if (qmfs->v_index < 0)
qmfs->v_index = (1280-128);
}
}
void sbr_qmf_synthesis_64_sse(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSRHFG][64],
real_t *output)
#else
void sbr_qmf_synthesis_32(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSRHFG][64],
real_t *output)
{
ALIGN real_t x[64];
ALIGN real_t y[64];
ALIGN real_t y2[64];
ALIGN real_t x1[32], x2[32];
#ifndef FIXED_POINT
real_t scale = 1.f/64.f;
#endif
int16_t n, k, out = 0;
uint8_t l;
/* qmf subsample l */
for (l = 0; l < sbr->numTimeSlotsRate; l++)
{
//real_t *v0, *v1;
/* shift buffer v */
/* buffer is not shifted, we are using a ringbuffer */
//memmove(qmfs->v + 64, qmfs->v, (640-64)*sizeof(real_t));
/* shift buffers */
//memmove(qmfs->v[0] + 64, qmfs->v[0], (640-64)*sizeof(real_t));
//memmove(qmfs->v[1] + 64, qmfs->v[1], (640-64)*sizeof(real_t));
memmove(qmfs->v[0] + 128, qmfs->v[0], (1280-128)*sizeof(real_t));
//v0 = qmfs->v[qmfs->v_index];
//v1 = qmfs->v[(qmfs->v_index + 1) & 0x1];
//qmfs->v_index = (qmfs->v_index + 1) & 0x1;
/* calculate 128 samples */
for (k = 0; k < 64; k++)
/* calculate 64 samples */
/* complex pre-twiddle */
for (k = 0; k < 32; k++)
{
#ifdef FIXED_POINT
x[k] = QMF_RE(X[l][k]);
x1[k] = MUL_F(QMF_RE(X[l][k]), RE(qmf32_pre_twiddle[k])) - MUL_F(QMF_IM(X[l][k]), IM(qmf32_pre_twiddle[k]));
x2[k] = MUL_F(QMF_IM(X[l][k]), RE(qmf32_pre_twiddle[k])) + MUL_F(QMF_RE(X[l][k]), IM(qmf32_pre_twiddle[k]));
#ifndef FIXED_POINT
x1[k] *= scale;
x2[k] *= scale;
#else
x[k] = QMF_RE(X[l][k]) / 32.;
x1[k] >>= 1;
x2[k] >>= 1;
#endif
}
/* transform */
DCT4_32(x1, x1);
DST4_32(x2, x2);
for (n = 0; n < 32; n++)
{
y[2*n] = -x[2*n];
y[2*n+1] = x[2*n+1];
qmfs->v[qmfs->v_index + n] = qmfs->v[qmfs->v_index + 640 + n] = -x1[n] + x2[n];
qmfs->v[qmfs->v_index + 63 - n] = qmfs->v[qmfs->v_index + 640 + 63 - n] = x1[n] + x2[n];
}
DCT2_64_unscaled(x, x);
for (n = 0; n < 64; n++)
/* calculate 32 output samples and window */
for (k = 0; k < 32; k++)
{
qmfs->v[0][n+32] = x[n];
}
for (n = 0; n < 32; n++)
{
qmfs->v[0][31 - n] = x[n + 1];
output[out++] = MUL_F(qmfs->v[qmfs->v_index + k], qmf_c[2*k]) +
MUL_F(qmfs->v[qmfs->v_index + 96 + k], qmf_c[64 + 2*k]) +
MUL_F(qmfs->v[qmfs->v_index + 128 + k], qmf_c[128 + 2*k]) +
MUL_F(qmfs->v[qmfs->v_index + 224 + k], qmf_c[192 + 2*k]) +
MUL_F(qmfs->v[qmfs->v_index + 256 + k], qmf_c[256 + 2*k]) +
MUL_F(qmfs->v[qmfs->v_index + 352 + k], qmf_c[320 + 2*k]) +
MUL_F(qmfs->v[qmfs->v_index + 384 + k], qmf_c[384 + 2*k]) +
MUL_F(qmfs->v[qmfs->v_index + 480 + k], qmf_c[448 + 2*k]) +
MUL_F(qmfs->v[qmfs->v_index + 512 + k], qmf_c[512 + 2*k]) +
MUL_F(qmfs->v[qmfs->v_index + 608 + k], qmf_c[576 + 2*k]);
}
DST2_64_unscaled(x, y);
qmfs->v[0][96] = 0;
for (n = 1; n < 32; n++)
{
qmfs->v[0][n + 96] = x[n-1];
}
/* calculate 64 output samples and window */
for (k = 0; k < 64; k++)
{
#if 1
output[out++] = MUL_F(qmfs->v[0][k], qmf_c[k]) +
MUL_F(qmfs->v[0][192 + k], qmf_c[64 + k]) +
MUL_F(qmfs->v[0][256 + k], qmf_c[128 + k]) +
MUL_F(qmfs->v[0][256 + 192 + k], qmf_c[128 + 64 + k]) +
MUL_F(qmfs->v[0][512 + k], qmf_c[256 + k]) +
MUL_F(qmfs->v[0][512 + 192 + k], qmf_c[256 + 64 + k]) +
MUL_F(qmfs->v[0][768 + k], qmf_c[384 + k]) +
MUL_F(qmfs->v[0][768 + 192 + k], qmf_c[384 + 64 + k]) +
MUL_F(qmfs->v[0][1024 + k], qmf_c[512 + k]) +
MUL_F(qmfs->v[0][1024 + 192 + k], qmf_c[512 + 64 + k]);
#else
output[out++] = MUL_F(v0[k], qmf_c[k]) +
MUL_F(v0[64 + k], qmf_c[64 + k]) +
MUL_F(v0[128 + k], qmf_c[128 + k]) +
MUL_F(v0[192 + k], qmf_c[192 + k]) +
MUL_F(v0[256 + k], qmf_c[256 + k]) +
MUL_F(v0[320 + k], qmf_c[320 + k]) +
MUL_F(v0[384 + k], qmf_c[384 + k]) +
MUL_F(v0[448 + k], qmf_c[448 + k]) +
MUL_F(v0[512 + k], qmf_c[512 + k]) +
MUL_F(v0[576 + k], qmf_c[576 + k]);
#endif
}
/* update ringbuffer index */
qmfs->v_index -= 64;
if (qmfs->v_index < 0)
qmfs->v_index = (640 - 64);
}
}
#else
void sbr_qmf_synthesis_64(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSRHFG][64],
real_t *output)
{
ALIGN real_t x1[64], x2[64];
// ALIGN real_t x1[64], x2[64];
#ifndef SBR_LOW_POWER
ALIGN real_t in_real1[32], in_imag1[32], out_real1[32], out_imag1[32];
ALIGN real_t in_real2[32], in_imag2[32], out_real2[32], out_imag2[32];
#endif
qmf_t * pX;
real_t * pring_buffer_1, * pring_buffer_3;
// real_t * ptemp_1, * ptemp_2;
#ifdef PREFER_POINTERS
// These pointers are used if target platform has autoinc address generators
real_t * pring_buffer_2, * pring_buffer_4;
real_t * pring_buffer_5, * pring_buffer_6;
real_t * pring_buffer_7, * pring_buffer_8;
real_t * pring_buffer_9, * pring_buffer_10;
const real_t * pqmf_c_1, * pqmf_c_2, * pqmf_c_3, * pqmf_c_4;
const real_t * pqmf_c_5, * pqmf_c_6, * pqmf_c_7, * pqmf_c_8;
const real_t * pqmf_c_9, * pqmf_c_10;
#endif // #ifdef PREFER_POINTERS
#ifndef FIXED_POINT
real_t scale = 1.f/64.f;
#endif
int16_t n, k, out = 0;
uint8_t l;
@ -384,179 +484,152 @@ void sbr_qmf_synthesis_64(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSRHFG][6
/* qmf subsample l */
for (l = 0; l < sbr->numTimeSlotsRate; l++)
{
real_t *v0, *v1;
/* shift buffers */
memmove(qmfs->v[0] + 64, qmfs->v[0], (640-64)*sizeof(real_t));
memmove(qmfs->v[1] + 64, qmfs->v[1], (640-64)*sizeof(real_t));
v0 = qmfs->v[qmfs->v_index];
v1 = qmfs->v[(qmfs->v_index + 1) & 0x1];
qmfs->v_index = (qmfs->v_index + 1) & 0x1;
/* shift buffer v */
/* buffer is not shifted, we use double ringbuffer */
//memmove(qmfs->v + 128, qmfs->v, (1280-128)*sizeof(real_t));
/* calculate 128 samples */
x1[0] = scale*QMF_RE(X[l][0]);
x2[63] = scale*QMF_IM(X[l][0]);
for (k = 0; k < 31; k++)
#ifndef FIXED_POINT
pX = X[l];
in_imag1[31] = scale*QMF_RE(pX[1]);
in_real1[0] = scale*QMF_RE(pX[0]);
in_imag2[31] = scale*QMF_IM(pX[63-1]);
in_real2[0] = scale*QMF_IM(pX[63-0]);
for (k = 1; k < 31; k++)
{
x1[2*k+1] = scale*(QMF_RE(X[l][2*k+1]) - QMF_RE(X[l][2*k+2]));
x1[2*k+2] = scale*(QMF_RE(X[l][2*k+1]) + QMF_RE(X[l][2*k+2]));
x2[61 - 2*k] = scale*(QMF_IM(X[l][2*k+2]) - QMF_IM(X[l][2*k+1]));
x2[62 - 2*k] = scale*(QMF_IM(X[l][2*k+2]) + QMF_IM(X[l][2*k+1]));
in_imag1[31 - k] = scale*QMF_RE(pX[2*k + 1]);
in_real1[ k] = scale*QMF_RE(pX[2*k ]);
in_imag2[31 - k] = scale*QMF_IM(pX[63 - (2*k + 1)]);
in_real2[ k] = scale*QMF_IM(pX[63 - (2*k )]);
}
x1[63] = scale*QMF_RE(X[l][63]);
x2[0] = scale*QMF_IM(X[l][63]);
in_imag1[0] = scale*QMF_RE(pX[63]);
in_real1[31] = scale*QMF_RE(pX[62]);
in_imag2[0] = scale*QMF_IM(pX[63-63]);
in_real2[31] = scale*QMF_IM(pX[63-62]);
DCT4_64_kernel(x1, x1);
DCT4_64_kernel(x2, x2);
#else
pX = X[l];
in_imag1[31] = QMF_RE(pX[1]) >> 1;
in_real1[0] = QMF_RE(pX[0]) >> 1;
in_imag2[31] = QMF_IM(pX[62]) >> 1;
in_real2[0] = QMF_IM(pX[63]) >> 1;
for (k = 1; k < 31; k++)
{
in_imag1[31 - k] = QMF_RE(pX[2*k + 1]) >> 1;
in_real1[ k] = QMF_RE(pX[2*k ]) >> 1;
in_imag2[31 - k] = QMF_IM(pX[63 - (2*k + 1)]) >> 1;
in_real2[ k] = QMF_IM(pX[63 - (2*k )]) >> 1;
}
in_imag1[0] = QMF_RE(pX[63]) >> 1;
in_real1[31] = QMF_RE(pX[62]) >> 1;
in_imag2[0] = QMF_IM(pX[0]) >> 1;
in_real2[31] = QMF_IM(pX[1]) >> 1;
#endif
// dct4_kernel is DCT_IV without reordering which is done before and after FFT
dct4_kernel(in_real1, in_imag1, out_real1, out_imag1);
dct4_kernel(in_real2, in_imag2, out_real2, out_imag2);
pring_buffer_1 = qmfs->v + qmfs->v_index;
pring_buffer_3 = pring_buffer_1 + 1280;
#ifdef PREFER_POINTERS
pring_buffer_2 = pring_buffer_1 + 127;
pring_buffer_4 = pring_buffer_1 + (1280 + 127);
#endif // #ifdef PREFER_POINTERS
// ptemp_1 = x1;
// ptemp_2 = x2;
#ifdef PREFER_POINTERS
for (n = 0; n < 32; n ++)
{
//real_t x1 = *ptemp_1++;
//real_t x2 = *ptemp_2++;
// pring_buffer_3 and pring_buffer_4 are needed only for double ring buffer
*pring_buffer_1++ = *pring_buffer_3++ = out_real2[n] - out_real1[n];
*pring_buffer_2-- = *pring_buffer_4-- = out_real2[n] + out_real1[n];
//x1 = *ptemp_1++;
//x2 = *ptemp_2++;
*pring_buffer_1++ = *pring_buffer_3++ = out_imag2[31-n] + out_imag1[31-n];
*pring_buffer_2-- = *pring_buffer_4-- = out_imag2[31-n] - out_imag1[31-n];
}
#else // #ifdef PREFER_POINTERS
for (n = 0; n < 32; n++)
{
v0[ 2*n] = x2[2*n] - x1[2*n];
v1[63-2*n] = x2[2*n] + x1[2*n];
v0[ 2*n+1] = -x2[2*n+1] - x1[2*n+1];
v1[62-2*n] = -x2[2*n+1] + x1[2*n+1];
// pring_buffer_3 and pring_buffer_4 are needed only for double ring buffer
pring_buffer_1[2*n] = pring_buffer_3[2*n] = out_real2[n] - out_real1[n];
pring_buffer_1[127-2*n] = pring_buffer_3[127-2*n] = out_real2[n] + out_real1[n];
pring_buffer_1[2*n+1] = pring_buffer_3[2*n+1] = out_imag2[31-n] + out_imag1[31-n];
pring_buffer_1[127-(2*n+1)] = pring_buffer_3[127-(2*n+1)] = out_imag2[31-n] - out_imag1[31-n];
}
#endif // #ifdef PREFER_POINTERS
pring_buffer_1 = qmfs->v + qmfs->v_index;
#ifdef PREFER_POINTERS
pring_buffer_2 = pring_buffer_1 + 192;
pring_buffer_3 = pring_buffer_1 + 256;
pring_buffer_4 = pring_buffer_1 + (256 + 192);
pring_buffer_5 = pring_buffer_1 + 512;
pring_buffer_6 = pring_buffer_1 + (512 + 192);
pring_buffer_7 = pring_buffer_1 + 768;
pring_buffer_8 = pring_buffer_1 + (768 + 192);
pring_buffer_9 = pring_buffer_1 + 1024;
pring_buffer_10 = pring_buffer_1 + (1024 + 192);
pqmf_c_1 = qmf_c;
pqmf_c_2 = qmf_c + 64;
pqmf_c_3 = qmf_c + 128;
pqmf_c_4 = qmf_c + 192;
pqmf_c_5 = qmf_c + 256;
pqmf_c_6 = qmf_c + 320;
pqmf_c_7 = qmf_c + 384;
pqmf_c_8 = qmf_c + 448;
pqmf_c_9 = qmf_c + 512;
pqmf_c_10 = qmf_c + 576;
#endif // #ifdef PREFER_POINTERS
/* calculate 64 output samples and window */
for (k = 0; k < 64; k++)
{
output[out++] = MUL_F(v0[k], qmf_c[k]) +
MUL_F(v0[64 + k], qmf_c[64 + k]) +
MUL_F(v0[128 + k], qmf_c[128 + k]) +
MUL_F(v0[192 + k], qmf_c[192 + k]) +
MUL_F(v0[256 + k], qmf_c[256 + k]) +
MUL_F(v0[320 + k], qmf_c[320 + k]) +
MUL_F(v0[384 + k], qmf_c[384 + k]) +
MUL_F(v0[448 + k], qmf_c[448 + k]) +
MUL_F(v0[512 + k], qmf_c[512 + k]) +
MUL_F(v0[576 + k], qmf_c[576 + k]);
}
}
}
#ifdef USE_SSE
void memmove_sse_576(real_t *out, const real_t *in)
{
__m128 m[144];
uint16_t i;
for (i = 0; i < 144; i++)
{
m[i] = _mm_load_ps(&in[i*4]);
}
for (i = 0; i < 144; i++)
{
_mm_store_ps(&out[i*4], m[i]);
}
}
void sbr_qmf_synthesis_64_sse(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSRHFG][64],
real_t *output)
{
ALIGN real_t x1[64], x2[64];
real_t scale = 1.f/64.f;
int16_t n, k, out = 0;
uint8_t l;
/* qmf subsample l */
for (l = 0; l < sbr->numTimeSlotsRate; l++)
{
real_t *v0, *v1;
/* shift buffers */
memmove_sse_576(qmfs->v[0] + 64, qmfs->v[0]);
memmove_sse_576(qmfs->v[1] + 64, qmfs->v[1]);
v0 = qmfs->v[qmfs->v_index];
v1 = qmfs->v[(qmfs->v_index + 1) & 0x1];
qmfs->v_index = (qmfs->v_index + 1) & 0x1;
/* calculate 128 samples */
x1[0] = scale*QMF_RE(X[l][0]);
x2[63] = scale*QMF_IM(X[l][0]);
for (k = 0; k < 31; k++)
{
x1[2*k+1] = scale*(QMF_RE(X[l][2*k+1]) - QMF_RE(X[l][2*k+2]));
x1[2*k+2] = scale*(QMF_RE(X[l][2*k+1]) + QMF_RE(X[l][2*k+2]));
x2[61 - 2*k] = scale*(QMF_IM(X[l][2*k+2]) - QMF_IM(X[l][2*k+1]));
x2[62 - 2*k] = scale*(QMF_IM(X[l][2*k+2]) + QMF_IM(X[l][2*k+1]));
}
x1[63] = scale*QMF_RE(X[l][63]);
x2[0] = scale*QMF_IM(X[l][63]);
DCT4_64_kernel(x1, x1);
DCT4_64_kernel(x2, x2);
for (n = 0; n < 32; n++)
{
v0[ 2*n ] = x2[2*n] - x1[2*n];
v1[63- 2*n ] = x2[2*n] + x1[2*n];
v0[ 2*n+1 ] = -x2[2*n+1] - x1[2*n+1];
v1[63-(2*n+1)] = -x2[2*n+1] + x1[2*n+1];
#ifdef PREFER_POINTERS
output[out++] =
MUL_F(*pring_buffer_1++, *pqmf_c_1++) +
MUL_F(*pring_buffer_2++, *pqmf_c_2++) +
MUL_F(*pring_buffer_3++, *pqmf_c_3++) +
MUL_F(*pring_buffer_4++, *pqmf_c_4++) +
MUL_F(*pring_buffer_5++, *pqmf_c_5++) +
MUL_F(*pring_buffer_6++, *pqmf_c_6++) +
MUL_F(*pring_buffer_7++, *pqmf_c_7++) +
MUL_F(*pring_buffer_8++, *pqmf_c_8++) +
MUL_F(*pring_buffer_9++, *pqmf_c_9++) +
MUL_F(*pring_buffer_10++, *pqmf_c_10++);
#else // #ifdef PREFER_POINTERS
output[out++] =
MUL_F(pring_buffer_1[k+0], qmf_c[k+0]) +
MUL_F(pring_buffer_1[k+192], qmf_c[k+64]) +
MUL_F(pring_buffer_1[k+256], qmf_c[k+128]) +
MUL_F(pring_buffer_1[k+(256+192)], qmf_c[k+192]) +
MUL_F(pring_buffer_1[k+512], qmf_c[k+256]) +
MUL_F(pring_buffer_1[k+(512+192)], qmf_c[k+320]) +
MUL_F(pring_buffer_1[k+768], qmf_c[k+384]) +
MUL_F(pring_buffer_1[k+(768+192)], qmf_c[k+448]) +
MUL_F(pring_buffer_1[k+1024], qmf_c[k+512]) +
MUL_F(pring_buffer_1[k+(1024+192)], qmf_c[k+576]);
#endif // #ifdef PREFER_POINTERS
}
/* calculate 64 output samples and window */
for (k = 0; k < 64; k+=4)
{
__m128 m0, m1, m2, m3, m4, m5, m6, m7, m8, m9;
__m128 c0, c1, c2, c3, c4, c5, c6, c7, c8, c9;
__m128 s1, s2, s3, s4, s5, s6, s7, s8, s9;
m0 = _mm_load_ps(&v0[k]);
m1 = _mm_load_ps(&v0[k + 64]);
m2 = _mm_load_ps(&v0[k + 128]);
m3 = _mm_load_ps(&v0[k + 192]);
m4 = _mm_load_ps(&v0[k + 256]);
c0 = _mm_load_ps(&qmf_c[k]);
c1 = _mm_load_ps(&qmf_c[k + 64]);
c2 = _mm_load_ps(&qmf_c[k + 128]);
c3 = _mm_load_ps(&qmf_c[k + 192]);
c4 = _mm_load_ps(&qmf_c[k + 256]);
m0 = _mm_mul_ps(m0, c0);
m1 = _mm_mul_ps(m1, c1);
m2 = _mm_mul_ps(m2, c2);
m3 = _mm_mul_ps(m3, c3);
m4 = _mm_mul_ps(m4, c4);
s1 = _mm_add_ps(m0, m1);
s2 = _mm_add_ps(m2, m3);
s6 = _mm_add_ps(s1, s2);
m5 = _mm_load_ps(&v0[k + 320]);
m6 = _mm_load_ps(&v0[k + 384]);
m7 = _mm_load_ps(&v0[k + 448]);
m8 = _mm_load_ps(&v0[k + 512]);
m9 = _mm_load_ps(&v0[k + 576]);
c5 = _mm_load_ps(&qmf_c[k + 320]);
c6 = _mm_load_ps(&qmf_c[k + 384]);
c7 = _mm_load_ps(&qmf_c[k + 448]);
c8 = _mm_load_ps(&qmf_c[k + 512]);
c9 = _mm_load_ps(&qmf_c[k + 576]);
m5 = _mm_mul_ps(m5, c5);
m6 = _mm_mul_ps(m6, c6);
m7 = _mm_mul_ps(m7, c7);
m8 = _mm_mul_ps(m8, c8);
m9 = _mm_mul_ps(m9, c9);
s3 = _mm_add_ps(m4, m5);
s4 = _mm_add_ps(m6, m7);
s5 = _mm_add_ps(m8, m9);
s7 = _mm_add_ps(s3, s4);
s8 = _mm_add_ps(s5, s6);
s9 = _mm_add_ps(s7, s8);
_mm_store_ps(&output[out], s9);
out += 4;
}
/* update ringbuffer index */
qmfs->v_index -= 128;
if (qmfs->v_index < 0)
qmfs->v_index = (1280 - 128);
}
}
#endif
#endif
#endif

View File

@ -23,7 +23,7 @@
** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
**
** Initially modified for use with MPlayer by Arpad Gereöffy on 2003/08/30
** $Id: sbr_qmf.h,v 1.3 2004/06/02 22:59:03 diego Exp $
** $Id: sbr_qmf.h,v 1.4 2004/06/23 13:50:52 diego Exp $
** detailed CVS changelog at http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
**/
@ -40,7 +40,9 @@ qmfs_info *qmfs_init(uint8_t channels);
void qmfs_end(qmfs_info *qmfs);
void sbr_qmf_analysis_32(sbr_info *sbr, qmfa_info *qmfa, const real_t *input,
qmf_t X[MAX_NTSRHFG][32], uint8_t offset, uint8_t kx);
qmf_t X[MAX_NTSRHFG][64], uint8_t offset, uint8_t kx);
void sbr_qmf_synthesis_32(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSRHFG][64],
real_t *output);
void sbr_qmf_synthesis_64(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSRHFG][64],
real_t *output);
#ifdef USE_SSE
@ -53,4 +55,3 @@ void sbr_qmf_synthesis_64_sse(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSRHF
}
#endif
#endif

View File

@ -23,7 +23,7 @@
** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
**
** Initially modified for use with MPlayer by Alex Beregszaszi on 2003/10/03
** $Id: sbr_qmf_c.h,v 1.2 2004/06/02 22:59:03 diego Exp $
** $Id: sbr_qmf_c.h,v 1.3 2004/06/23 13:50:52 diego Exp $
** detailed CVS changelog at http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
**/
@ -201,7 +201,7 @@ ALIGN static const real_t qmf_c[640] = {
FRAC_CONST(0.84803157770763), FRAC_CONST(0.84978051984268),
FRAC_CONST(0.85119715249343), FRAC_CONST(0.85230470352147),
FRAC_CONST(0.85310209497017), FRAC_CONST(0.85357205739107),
FRAC_CONST(0.85373856005937), FRAC_CONST(0.85357205739107),
FRAC_CONST(0.85373856005937 /*max*/), FRAC_CONST(0.85357205739107),
FRAC_CONST(0.85310209497017), FRAC_CONST(0.85230470352147),
FRAC_CONST(0.85119715249343), FRAC_CONST(0.84978051984268),
FRAC_CONST(0.84803157770763), FRAC_CONST(0.84598184698206),

View File

@ -23,7 +23,7 @@
** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
**
** Initially modified for use with MPlayer by Arpad Gereöffy on 2003/08/30
** $Id: sbr_syntax.c,v 1.3 2004/06/02 22:59:03 diego Exp $
** $Id: sbr_syntax.c,v 1.4 2004/06/23 13:50:52 diego Exp $
** detailed CVS changelog at http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
**/
@ -49,6 +49,9 @@
/* static function declarations */
static void sbr_header(bitfile *ld, sbr_info *sbr);
static uint8_t calc_sbr_tables(sbr_info *sbr, uint8_t start_freq, uint8_t stop_freq,
uint8_t samplerate_mode, uint8_t freq_scale,
uint8_t alter_scale, uint8_t xover_band);
static uint8_t sbr_data(bitfile *ld, sbr_info *sbr);
static uint16_t sbr_extension(bitfile *ld, sbr_info *sbr,
uint8_t bs_extension_id, uint16_t num_bits_left);
@ -100,11 +103,43 @@ static void sbr_reset(sbr_info *sbr)
sbr->bs_alter_scale_prev = sbr->bs_alter_scale;
sbr->bs_xover_band_prev = sbr->bs_xover_band;
sbr->bs_noise_bands_prev = sbr->bs_noise_bands;
}
if (sbr->frame == 0)
static uint8_t calc_sbr_tables(sbr_info *sbr, uint8_t start_freq, uint8_t stop_freq,
uint8_t samplerate_mode, uint8_t freq_scale,
uint8_t alter_scale, uint8_t xover_band)
{
uint8_t result = 0;
uint8_t k2;
/* calculate the Master Frequency Table */
sbr->k0 = qmf_start_channel(start_freq, samplerate_mode, sbr->sample_rate);
k2 = qmf_stop_channel(stop_freq, sbr->sample_rate, sbr->k0);
/* check k0 and k2 */
if (sbr->sample_rate >= 48000)
{
sbr->Reset = 1;
if ((k2 - sbr->k0) > 32)
result += 1;
} else if (sbr->sample_rate <= 32000) {
if ((k2 - sbr->k0) > 48)
result += 1;
} else { /* (sbr->sample_rate == 44100) */
if ((k2 - sbr->k0) > 45)
result += 1;
}
if (freq_scale == 0)
{
result += master_frequency_table_fs0(sbr, sbr->k0, k2, alter_scale);
} else {
result += master_frequency_table(sbr, sbr->k0, k2, freq_scale, alter_scale);
}
result += derived_frequency_table(sbr, xover_band, k2);
result = (result > 0) ? 1 : 0;
return result;
}
/* table 2 */
@ -114,6 +149,10 @@ uint8_t sbr_extension_data(bitfile *ld, sbr_info *sbr, uint16_t cnt)
uint16_t num_align_bits = 0;
uint16_t num_sbr_bits = (uint16_t)faad_get_processed_bits(ld);
uint8_t saved_start_freq, saved_samplerate_mode;
uint8_t saved_stop_freq, saved_freq_scale;
uint8_t saved_alter_scale, saved_xover_band;
#ifdef DRM
if (!sbr->Is_DRM_SBR)
#endif
@ -128,6 +167,14 @@ uint8_t sbr_extension_data(bitfile *ld, sbr_info *sbr, uint16_t cnt)
}
}
/* save old header values, in case the new ones are corrupted */
saved_start_freq = sbr->bs_start_freq;
saved_samplerate_mode = sbr->bs_samplerate_mode;
saved_stop_freq = sbr->bs_stop_freq;
saved_freq_scale = sbr->bs_freq_scale;
saved_alter_scale = sbr->bs_alter_scale;
saved_xover_band = sbr->bs_xover_band;
sbr->bs_header_flag = faad_get1bit(ld
DEBUGVAR(1,200,"sbr_bitstream(): bs_header_flag"));
@ -143,41 +190,40 @@ uint8_t sbr_extension_data(bitfile *ld, sbr_info *sbr, uint16_t cnt)
{
if (sbr->Reset || (sbr->bs_header_flag && sbr->just_seeked))
{
uint8_t k2;
uint8_t rt = calc_sbr_tables(sbr, sbr->bs_start_freq, sbr->bs_stop_freq,
sbr->bs_samplerate_mode, sbr->bs_freq_scale,
sbr->bs_alter_scale, sbr->bs_xover_band);
/* calculate the Master Frequency Table */
sbr->k0 = qmf_start_channel(sbr->bs_start_freq, sbr->bs_samplerate_mode,
sbr->sample_rate);
k2 = qmf_stop_channel(sbr->bs_stop_freq, sbr->sample_rate, sbr->k0);
/* check k0 and k2 */
if (sbr->sample_rate >= 48000)
/* if an error occured with the new header values revert to the old ones */
if (rt > 0)
{
if ((k2 - sbr->k0) > 32)
result += 1;
} else if (sbr->sample_rate <= 32000) {
if ((k2 - sbr->k0) > 48)
result += 1;
} else { /* (sbr->sample_rate == 44100) */
if ((k2 - sbr->k0) > 45)
result += 1;
calc_sbr_tables(sbr, saved_start_freq, saved_stop_freq,
saved_samplerate_mode, saved_freq_scale,
saved_alter_scale, saved_xover_band);
}
if (sbr->bs_freq_scale == 0)
{
result += master_frequency_table_fs0(sbr, sbr->k0, k2,
sbr->bs_alter_scale);
} else {
result += master_frequency_table(sbr, sbr->k0, k2, sbr->bs_freq_scale,
sbr->bs_alter_scale);
}
result += derived_frequency_table(sbr, sbr->bs_xover_band, k2);
result = (result > 0) ? 1 : 0;
}
if (result == 0)
{
result = sbr_data(ld, sbr);
/* sbr_data() returning an error means that there was an error in
envelope_time_border_vector().
In this case the old time border vector is saved and all the previous
data normally read after sbr_grid() is saved.
*/
/* to be on the safe side, calculate old sbr tables in case of error */
if ((result > 0) &&
(sbr->Reset || (sbr->bs_header_flag && sbr->just_seeked)))
{
calc_sbr_tables(sbr, saved_start_freq, saved_stop_freq,
saved_samplerate_mode, saved_freq_scale,
saved_alter_scale, saved_xover_band);
}
/* we should be able to safely set result to 0 now */
result = 0;
}
} else {
result = 1;
}
@ -187,6 +233,11 @@ uint8_t sbr_extension_data(bitfile *ld, sbr_info *sbr, uint16_t cnt)
#endif
{
num_sbr_bits = (uint16_t)faad_get_processed_bits(ld) - num_sbr_bits;
/* check if we read more bits then were available for sbr */
if (8*cnt < num_sbr_bits)
return 1;
/* -4 does not apply, bs_extension_type is re-read in this function */
num_align_bits = 8*cnt /*- 4*/ - num_sbr_bits;
@ -335,7 +386,9 @@ static uint8_t sbr_single_channel_element(bitfile *ld, sbr_info *sbr)
sbr_envelope(ld, sbr, 0);
sbr_noise(ld, sbr, 0);
#ifndef FIXED_POINT
envelope_noise_dequantisation(sbr, 0);
#endif
memset(sbr->bs_add_harmonic[0], 0, 64*sizeof(uint8_t));
@ -346,6 +399,7 @@ static uint8_t sbr_single_channel_element(bitfile *ld, sbr_info *sbr)
sbr->bs_extended_data = faad_get1bit(ld
DEBUGVAR(1,224,"sbr_single_channel_element(): bs_extended_data[0]"));
if (sbr->bs_extended_data)
{
uint16_t nr_bits_left;
@ -360,10 +414,18 @@ static uint8_t sbr_single_channel_element(bitfile *ld, sbr_info *sbr)
nr_bits_left = 8 * cnt;
while (nr_bits_left > 7)
{
uint16_t tmp_nr_bits = 0;
sbr->bs_extension_id = (uint8_t)faad_getbits(ld, 2
DEBUGVAR(1,227,"sbr_single_channel_element(): bs_extension_id"));
nr_bits_left -= 2;
nr_bits_left -= sbr_extension(ld, sbr, sbr->bs_extension_id, nr_bits_left);
tmp_nr_bits += 2;
tmp_nr_bits += sbr_extension(ld, sbr, sbr->bs_extension_id, nr_bits_left);
/* check if the data read is bigger than the number of available bits */
if (tmp_nr_bits > nr_bits_left)
return 1;
nr_bits_left -= tmp_nr_bits;
}
/* Corrigendum */
@ -439,10 +501,31 @@ static uint8_t sbr_channel_pair_element(bitfile *ld, sbr_info *sbr)
if (sbr->bs_add_harmonic_flag[1])
sinusoidal_coding(ld, sbr, 1);
} else {
uint8_t saved_t_E[6] = {0}, saved_t_Q[3] = {0};
uint8_t saved_L_E = sbr->L_E[0];
uint8_t saved_L_Q = sbr->L_Q[0];
uint8_t saved_frame_class = sbr->bs_frame_class[0];
for (n = 0; n < saved_L_E; n++)
saved_t_E[n] = sbr->t_E[0][n];
for (n = 0; n < saved_L_Q; n++)
saved_t_Q[n] = sbr->t_Q[0][n];
if ((result = sbr_grid(ld, sbr, 0)) > 0)
return result;
if ((result = sbr_grid(ld, sbr, 1)) > 0)
{
/* restore first channel data as well */
sbr->bs_frame_class[0] = saved_frame_class;
sbr->L_E[0] = saved_L_E;
sbr->L_Q[0] = saved_L_Q;
for (n = 0; n < 6; n++)
sbr->t_E[0][n] = saved_t_E[n];
for (n = 0; n < 3; n++)
sbr->t_Q[0][n] = saved_t_Q[n];
return result;
}
sbr_dtdf(ld, sbr, 0);
sbr_dtdf(ld, sbr, 1);
invf_mode(ld, sbr, 0);
@ -465,11 +548,13 @@ static uint8_t sbr_channel_pair_element(bitfile *ld, sbr_info *sbr)
if (sbr->bs_add_harmonic_flag[1])
sinusoidal_coding(ld, sbr, 1);
}
#ifndef FIXED_POINT
envelope_noise_dequantisation(sbr, 0);
envelope_noise_dequantisation(sbr, 1);
if (sbr->bs_coupling)
unmap_envelope_noise(sbr);
#endif
sbr->bs_extended_data = faad_get1bit(ld
DEBUGVAR(1,233,"sbr_channel_pair_element(): bs_extended_data[0]"));
@ -487,10 +572,18 @@ static uint8_t sbr_channel_pair_element(bitfile *ld, sbr_info *sbr)
nr_bits_left = 8 * cnt;
while (nr_bits_left > 7)
{
uint16_t tmp_nr_bits = 0;
sbr->bs_extension_id = (uint8_t)faad_getbits(ld, 2
DEBUGVAR(1,236,"sbr_channel_pair_element(): bs_extension_id"));
nr_bits_left -= 2;
sbr_extension(ld, sbr, sbr->bs_extension_id, nr_bits_left);
tmp_nr_bits += 2;
tmp_nr_bits += sbr_extension(ld, sbr, sbr->bs_extension_id, nr_bits_left);
/* check if the data read is bigger than the number of available bits */
if (tmp_nr_bits > nr_bits_left)
return 1;
nr_bits_left -= tmp_nr_bits;
}
/* Corrigendum */
@ -521,6 +614,9 @@ static uint8_t sbr_grid(bitfile *ld, sbr_info *sbr, uint8_t ch)
uint8_t i, env, rel, result;
uint8_t bs_abs_bord, bs_abs_bord_1;
uint8_t bs_num_env = 0;
uint8_t saved_L_E = sbr->L_E[ch];
uint8_t saved_L_Q = sbr->L_Q[ch];
uint8_t saved_frame_class = sbr->bs_frame_class[ch];
sbr->bs_frame_class[ch] = (uint8_t)faad_getbits(ld, 2
DEBUGVAR(1,248,"sbr_grid(): bs_frame_class"));
@ -652,9 +748,21 @@ static uint8_t sbr_grid(bitfile *ld, sbr_info *sbr, uint8_t ch)
/* TODO: this code can probably be integrated into the code above! */
if ((result = envelope_time_border_vector(sbr, ch)) > 0)
{
sbr->bs_frame_class[ch] = saved_frame_class;
sbr->L_E[ch] = saved_L_E;
sbr->L_Q[ch] = saved_L_Q;
return result;
}
noise_floor_time_border_vector(sbr, ch);
#if 0
for (env = 0; env < bs_num_env; env++)
{
printf("freq_res[ch:%d][env:%d]: %d\n", ch, env, sbr->f[ch][env]);
}
#endif
return 0;
}
@ -696,12 +804,20 @@ static uint16_t sbr_extension(bitfile *ld, sbr_info *sbr,
#ifdef PS_DEC
case EXTENSION_ID_PS:
sbr->ps_used = 1;
return ps_data(&(sbr->ps), ld);
if (!sbr->ps)
{
sbr->ps = ps_init(get_sr_index(sbr->sample_rate));
}
return ps_data(sbr->ps, ld);
#endif
#ifdef DRM_PS
case DRM_PARAMETRIC_STEREO:
sbr->ps_used = 1;
return drm_ps_data(&(sbr->drm_ps), ld);
if (!sbr->drm_ps)
{
sbr->drm_ps = drm_ps_init();
}
return drm_ps_data(sbr->drm_ps, ld);
#endif
default:
sbr->bs_extension_data = (uint8_t)faad_getbits(ld, 6

View File

@ -23,7 +23,7 @@
** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
**
** Initially modified for use with MPlayer by Arpad Gereöffy on 2003/08/30
** $Id: sbr_tf_grid.c,v 1.3 2004/06/02 22:59:03 diego Exp $
** $Id: sbr_tf_grid.c,v 1.4 2004/06/23 13:50:52 diego Exp $
** detailed CVS changelog at http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
**/
@ -48,17 +48,15 @@ static int16_t rel_bord_trail(sbr_info *sbr, uint8_t ch, uint8_t l);
static uint8_t middleBorder(sbr_info *sbr, uint8_t ch);
/* function constructs new time border vector */
/* first build into temp vector to be able to use previous vector on error */
uint8_t envelope_time_border_vector(sbr_info *sbr, uint8_t ch)
{
uint8_t l, border, temp;
uint8_t t_E_temp[6] = {0};
for (l = 0; l <= sbr->L_E[ch]; l++)
{
sbr->t_E[ch][l] = 0;
}
sbr->t_E[ch][0] = sbr->rate * sbr->abs_bord_lead[ch];
sbr->t_E[ch][sbr->L_E[ch]] = sbr->rate * sbr->abs_bord_trail[ch];
t_E_temp[0] = sbr->rate * sbr->abs_bord_lead[ch];
t_E_temp[sbr->L_E[ch]] = sbr->rate * sbr->abs_bord_trail[ch];
switch (sbr->bs_frame_class[ch])
{
@ -67,12 +65,12 @@ uint8_t envelope_time_border_vector(sbr_info *sbr, uint8_t ch)
{
case 4:
temp = (int) (sbr->numTimeSlots / 4);
sbr->t_E[ch][3] = sbr->rate * 3 * temp;
sbr->t_E[ch][2] = sbr->rate * 2 * temp;
sbr->t_E[ch][1] = sbr->rate * temp;
t_E_temp[3] = sbr->rate * 3 * temp;
t_E_temp[2] = sbr->rate * 2 * temp;
t_E_temp[1] = sbr->rate * temp;
break;
case 2:
sbr->t_E[ch][1] = sbr->rate * (int) (sbr->numTimeSlots / 2);
t_E_temp[1] = sbr->rate * (int) (sbr->numTimeSlots / 2);
break;
default:
break;
@ -91,7 +89,7 @@ uint8_t envelope_time_border_vector(sbr_info *sbr, uint8_t ch)
return 1;
border -= sbr->bs_rel_bord[ch][l];
sbr->t_E[ch][--i] = sbr->rate * border;
t_E_temp[--i] = sbr->rate * border;
}
}
break;
@ -109,7 +107,7 @@ uint8_t envelope_time_border_vector(sbr_info *sbr, uint8_t ch)
if (sbr->rate * border + sbr->tHFAdj > sbr->numTimeSlotsRate+sbr->tHFGen)
return 1;
sbr->t_E[ch][i++] = sbr->rate * border;
t_E_temp[i++] = sbr->rate * border;
}
}
break;
@ -127,7 +125,7 @@ uint8_t envelope_time_border_vector(sbr_info *sbr, uint8_t ch)
if (sbr->rate * border + sbr->tHFAdj > sbr->numTimeSlotsRate+sbr->tHFGen)
return 1;
sbr->t_E[ch][i++] = sbr->rate * border;
t_E_temp[i++] = sbr->rate * border;
}
}
@ -142,12 +140,18 @@ uint8_t envelope_time_border_vector(sbr_info *sbr, uint8_t ch)
return 1;
border -= sbr->bs_rel_bord_1[ch][l];
sbr->t_E[ch][--i] = sbr->rate * border;
t_E_temp[--i] = sbr->rate * border;
}
}
break;
}
/* no error occured, we can safely use this t_E vector */
for (l = 0; l < 6; l++)
{
sbr->t_E[ch][l] = t_E_temp[l];
}
return 0;
}

View File

@ -23,7 +23,7 @@
** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
**
** Initially modified for use with MPlayer by Arpad Gereöffy on 2003/08/30
** $Id: specrec.c,v 1.3 2004/06/02 22:59:03 diego Exp $
** $Id: specrec.c,v 1.4 2004/06/23 13:50:52 diego Exp $
** detailed CVS changelog at http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
**/
@ -40,6 +40,7 @@
#include <string.h>
#include <stdlib.h>
#include "specrec.h"
#include "filtbank.h"
#include "syntax.h"
#include "iq_table.h"
#include "ms.h"
@ -56,8 +57,9 @@
/* static function declarations */
static void quant_to_spec(ic_stream *ics, real_t *spec_data, uint16_t frame_len);
static uint8_t inverse_quantization(real_t *x_invquant, const int16_t *x_quant, const uint16_t frame_len);
static uint8_t quant_to_spec(NeAACDecHandle hDecoder,
ic_stream *ics, int16_t *quant_data,
real_t *spec_data, uint16_t frame_len);
#ifdef LD_DEC
@ -297,7 +299,7 @@ ALIGN static const uint16_t *swb_offset_128_window[] =
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(faacDecHandle hDecoder, ic_stream *ics)
uint8_t window_grouping_info(NeAACDecHandle hDecoder, ic_stream *ics)
{
uint8_t i, g;
@ -409,75 +411,24 @@ uint8_t window_grouping_info(faacDecHandle hDecoder, ic_stream *ics)
}
}
/*
For ONLY_LONG_SEQUENCE windows (num_window_groups = 1,
window_group_length[0] = 1) the spectral data is in ascending spectral
order.
For the EIGHT_SHORT_SEQUENCE window, the spectral order depends on the
grouping in the following manner:
- Groups are ordered sequentially
- Within a group, a scalefactor band consists of the spectral data of all
grouped SHORT_WINDOWs for the associated scalefactor window band. To
clarify via example, the length of a group is in the range of one to eight
SHORT_WINDOWs.
- If there are eight groups each with length one (num_window_groups = 8,
window_group_length[0..7] = 1), the result is a sequence of eight spectra,
each in ascending spectral order.
- If there is only one group with length eight (num_window_groups = 1,
window_group_length[0] = 8), the result is that spectral data of all eight
SHORT_WINDOWs is interleaved by scalefactor window bands.
- Within a scalefactor window band, the coefficients are in ascending
spectral order.
*/
static void quant_to_spec(ic_stream *ics, real_t *spec_data, uint16_t frame_len)
{
uint8_t g, sfb, win;
uint16_t width, bin, k, gindex;
ALIGN real_t tmp_spec[1024] = {0};
k = 0;
gindex = 0;
for (g = 0; g < ics->num_window_groups; g++)
{
uint16_t j = 0;
uint16_t gincrease = 0;
uint16_t win_inc = ics->swb_offset[ics->num_swb];
for (sfb = 0; sfb < ics->num_swb; sfb++)
{
width = ics->swb_offset[sfb+1] - ics->swb_offset[sfb];
for (win = 0; win < ics->window_group_length[g]; win++)
{
for (bin = 0; bin < width; bin += 4)
{
tmp_spec[gindex+(win*win_inc)+j+bin+0] = spec_data[k+0];
tmp_spec[gindex+(win*win_inc)+j+bin+1] = spec_data[k+1];
tmp_spec[gindex+(win*win_inc)+j+bin+2] = spec_data[k+2];
tmp_spec[gindex+(win*win_inc)+j+bin+3] = spec_data[k+3];
gincrease += 4;
k += 4;
}
}
j += width;
}
gindex += gincrease;
}
memcpy(spec_data, tmp_spec, frame_len*sizeof(real_t));
}
/* iquant() *
/* output = sign(input)*abs(input)^(4/3) */
/**/
static INLINE real_t iquant(int16_t q, const real_t *tab, uint8_t *error)
{
#ifdef FIXED_POINT
/* For FIXED_POINT the iq_table is prescaled by 3 bits (iq_table[]/8) */
/* BIG_IQ_TABLE allows you to use the full 8192 value table, if this is not
* defined a 1026 value table and interpolation will be used
*/
#ifndef BIG_IQ_TABLE
static const real_t errcorr[] = {
REAL_CONST(0), REAL_CONST(1.0/8.0), REAL_CONST(2.0/8.0), REAL_CONST(3.0/8.0),
REAL_CONST(4.0/8.0), REAL_CONST(5.0/8.0), REAL_CONST(6.0/8.0), REAL_CONST(7.0/8.0),
REAL_CONST(0)
};
real_t x1, x2;
#endif
int16_t sgn = 1;
if (q < 0)
@ -487,12 +438,31 @@ static INLINE real_t iquant(int16_t q, const real_t *tab, uint8_t *error)
}
if (q < IQ_TABLE_SIZE)
{
//#define IQUANT_PRINT
#ifdef IQUANT_PRINT
//printf("0x%.8X\n", sgn * tab[q]);
printf("%d\n", sgn * tab[q]);
#endif
return sgn * tab[q];
}
#ifndef BIG_IQ_TABLE
if (q >= 8192)
{
*error = 17;
return 0;
}
/* linear interpolation */
x1 = tab[q>>3];
x2 = tab[(q>>3) + 1];
return sgn * 16 * (MUL_R(errcorr[q&7],(x2-x1)) + x1);
#else
*error = 17;
return 0;
#endif
#else
if (q < 0)
{
@ -513,23 +483,6 @@ static INLINE real_t iquant(int16_t q, const real_t *tab, uint8_t *error)
#endif
}
static uint8_t inverse_quantization(real_t *x_invquant, const int16_t *x_quant, const uint16_t frame_len)
{
int16_t i;
uint8_t error = 0; /* Init error flag */
const real_t *tab = iq_table;
for (i = 0; i < frame_len; i+=4)
{
x_invquant[i] = iquant(x_quant[i], tab, &error);
x_invquant[i+1] = iquant(x_quant[i+1], tab, &error);
x_invquant[i+2] = iquant(x_quant[i+2], tab, &error);
x_invquant[i+3] = iquant(x_quant[i+3], tab, &error);
}
return error;
}
#ifndef FIXED_POINT
ALIGN static const real_t pow2sf_tab[] = {
2.9802322387695313E-008, 5.9604644775390625E-008, 1.1920928955078125E-007,
@ -556,39 +509,61 @@ ALIGN static const real_t pow2sf_tab[] = {
};
#endif
ALIGN static real_t pow2_table[] =
/* quant_to_spec: perform dequantisation and scaling
* and in case of short block it also does the deinterleaving
*/
/*
For ONLY_LONG_SEQUENCE windows (num_window_groups = 1,
window_group_length[0] = 1) the spectral data is in ascending spectral
order.
For the EIGHT_SHORT_SEQUENCE window, the spectral order depends on the
grouping in the following manner:
- Groups are ordered sequentially
- Within a group, a scalefactor band consists of the spectral data of all
grouped SHORT_WINDOWs for the associated scalefactor window band. To
clarify via example, the length of a group is in the range of one to eight
SHORT_WINDOWs.
- If there are eight groups each with length one (num_window_groups = 8,
window_group_length[0..7] = 1), the result is a sequence of eight spectra,
each in ascending spectral order.
- If there is only one group with length eight (num_window_groups = 1,
window_group_length[0] = 8), the result is that spectral data of all eight
SHORT_WINDOWs is interleaved by scalefactor window bands.
- Within a scalefactor window band, the coefficients are in ascending
spectral order.
*/
static uint8_t quant_to_spec(NeAACDecHandle hDecoder,
ic_stream *ics, int16_t *quant_data,
real_t *spec_data, uint16_t frame_len)
{
#if 0
COEF_CONST(0.59460355750136053335874998528024), /* 2^-0.75 */
COEF_CONST(0.70710678118654752440084436210485), /* 2^-0.5 */
COEF_CONST(0.84089641525371454303112547623321), /* 2^-0.25 */
#endif
COEF_CONST(1.0),
COEF_CONST(1.1892071150027210667174999705605), /* 2^0.25 */
COEF_CONST(1.4142135623730950488016887242097), /* 2^0.5 */
COEF_CONST(1.6817928305074290860622509524664) /* 2^0.75 */
};
ALIGN static const real_t pow2_table[] =
{
COEF_CONST(1.0),
COEF_CONST(1.1892071150027210667174999705605), /* 2^0.25 */
COEF_CONST(1.4142135623730950488016887242097), /* 2^0.5 */
COEF_CONST(1.6817928305074290860622509524664) /* 2^0.75 */
};
const real_t *tab = iq_table;
void apply_scalefactors(faacDecHandle hDecoder, ic_stream *ics,
real_t *x_invquant, uint16_t frame_len)
{
uint8_t g, sfb;
uint16_t top;
int32_t exp, frac;
uint8_t groups = 0;
uint16_t nshort = frame_len/8;
uint8_t g, sfb, win;
uint16_t width, bin, k, gindex;
uint8_t error = 0; /* Init error flag */
k = 0;
gindex = 0;
for (g = 0; g < ics->num_window_groups; g++)
{
uint16_t k = 0;
uint16_t j = 0;
uint16_t gincrease = 0;
uint16_t win_inc = ics->swb_offset[ics->num_swb];
/* using this nshort*groups doesn't hurt long blocks, because
long blocks only have 1 group, so that means 'groups' is
always 0 for long blocks
*/
for (sfb = 0; sfb < ics->max_sfb; sfb++)
for (sfb = 0; sfb < ics->num_swb; sfb++)
{
top = ics->sect_sfb_offset[g][sfb+1];
int32_t exp, frac;
width = ics->swb_offset[sfb+1] - ics->swb_offset[sfb];
/* this could be scalefactor for IS or PNS, those can be negative or bigger then 255 */
/* just ignore them */
@ -599,6 +574,7 @@ void apply_scalefactors(faacDecHandle hDecoder, ic_stream *ics,
} else {
/* ics->scale_factors[g][sfb] must be between 0 and 255 */
exp = (ics->scale_factors[g][sfb] /* - 100 */) >> 2;
/* frac must always be > 0 */
frac = (ics->scale_factors[g][sfb] /* - 100 */) & 3;
}
@ -616,81 +592,67 @@ void apply_scalefactors(faacDecHandle hDecoder, ic_stream *ics,
}
#endif
/* minimum size of a sf band is 4 and always a multiple of 4 */
for ( ; k < top; k += 4)
for (win = 0; win < ics->window_group_length[g]; win++)
{
#ifdef FIXED_POINT
if (exp < 0)
for (bin = 0; bin < width; bin += 4)
{
x_invquant[k+(groups*nshort)] >>= -exp;
x_invquant[k+(groups*nshort)+1] >>= -exp;
x_invquant[k+(groups*nshort)+2] >>= -exp;
x_invquant[k+(groups*nshort)+3] >>= -exp;
} else {
x_invquant[k+(groups*nshort)] <<= exp;
x_invquant[k+(groups*nshort)+1] <<= exp;
x_invquant[k+(groups*nshort)+2] <<= exp;
x_invquant[k+(groups*nshort)+3] <<= exp;
}
#ifndef FIXED_POINT
spec_data[gindex+(win*win_inc)+j+bin+0] = iquant(quant_data[k+0], tab, &error) *
pow2sf_tab[exp/*+25*/] * pow2_table[frac];
spec_data[gindex+(win*win_inc)+j+bin+1] = iquant(quant_data[k+1], tab, &error) *
pow2sf_tab[exp/*+25*/] * pow2_table[frac];
spec_data[gindex+(win*win_inc)+j+bin+2] = iquant(quant_data[k+2], tab, &error) *
pow2sf_tab[exp/*+25*/] * pow2_table[frac];
spec_data[gindex+(win*win_inc)+j+bin+3] = iquant(quant_data[k+3], tab, &error) *
pow2sf_tab[exp/*+25*/] * pow2_table[frac];
#else
x_invquant[k+(groups*nshort)] = x_invquant[k+(groups*nshort)] * pow2sf_tab[exp/*+25*/];
x_invquant[k+(groups*nshort)+1] = x_invquant[k+(groups*nshort)+1] * pow2sf_tab[exp/*+25*/];
x_invquant[k+(groups*nshort)+2] = x_invquant[k+(groups*nshort)+2] * pow2sf_tab[exp/*+25*/];
x_invquant[k+(groups*nshort)+3] = x_invquant[k+(groups*nshort)+3] * pow2sf_tab[exp/*+25*/];
real_t iq0 = iquant(quant_data[k+0], tab, &error);
real_t iq1 = iquant(quant_data[k+1], tab, &error);
real_t iq2 = iquant(quant_data[k+2], tab, &error);
real_t iq3 = iquant(quant_data[k+3], tab, &error);
if (exp < 0)
{
spec_data[gindex+(win*win_inc)+j+bin+0] = iq0 >>= -exp;
spec_data[gindex+(win*win_inc)+j+bin+1] = iq1 >>= -exp;
spec_data[gindex+(win*win_inc)+j+bin+2] = iq2 >>= -exp;
spec_data[gindex+(win*win_inc)+j+bin+3] = iq3 >>= -exp;
} else {
spec_data[gindex+(win*win_inc)+j+bin+0] = iq0 <<= exp;
spec_data[gindex+(win*win_inc)+j+bin+1] = iq1 <<= exp;
spec_data[gindex+(win*win_inc)+j+bin+2] = iq2 <<= exp;
spec_data[gindex+(win*win_inc)+j+bin+3] = iq3 <<= exp;
}
spec_data[gindex+(win*win_inc)+j+bin+0] = MUL_C(spec_data[gindex+(win*win_inc)+j+bin+0],pow2_table[frac]);
spec_data[gindex+(win*win_inc)+j+bin+1] = MUL_C(spec_data[gindex+(win*win_inc)+j+bin+1],pow2_table[frac]);
spec_data[gindex+(win*win_inc)+j+bin+2] = MUL_C(spec_data[gindex+(win*win_inc)+j+bin+2],pow2_table[frac]);
spec_data[gindex+(win*win_inc)+j+bin+3] = MUL_C(spec_data[gindex+(win*win_inc)+j+bin+3],pow2_table[frac]);
//#define SCFS_PRINT
#ifdef SCFS_PRINT
//printf("%d\n", spec_data[gindex+(win*win_inc)+j+bin+0]);
//printf("%d\n", spec_data[gindex+(win*win_inc)+j+bin+1]);
//printf("%d\n", spec_data[gindex+(win*win_inc)+j+bin+2]);
//printf("%d\n", spec_data[gindex+(win*win_inc)+j+bin+3]);
printf("0x%.8X\n", spec_data[gindex+(win*win_inc)+j+bin+0]);
printf("0x%.8X\n", spec_data[gindex+(win*win_inc)+j+bin+1]);
printf("0x%.8X\n", spec_data[gindex+(win*win_inc)+j+bin+2]);
printf("0x%.8X\n", spec_data[gindex+(win*win_inc)+j+bin+3]);
#endif
#endif
x_invquant[k+(groups*nshort)] = MUL_C(x_invquant[k+(groups*nshort)],pow2_table[frac /* + 3*/]);
x_invquant[k+(groups*nshort)+1] = MUL_C(x_invquant[k+(groups*nshort)+1],pow2_table[frac /* + 3*/]);
x_invquant[k+(groups*nshort)+2] = MUL_C(x_invquant[k+(groups*nshort)+2],pow2_table[frac /* + 3*/]);
x_invquant[k+(groups*nshort)+3] = MUL_C(x_invquant[k+(groups*nshort)+3],pow2_table[frac /* + 3*/]);
gincrease += 4;
k += 4;
}
}
j += width;
}
groups += ics->window_group_length[g];
gindex += gincrease;
}
return error;
}
#ifdef USE_SSE
void apply_scalefactors_sse(faacDecHandle hDecoder, ic_stream *ics,
real_t *x_invquant, uint16_t frame_len)
{
uint8_t g, sfb;
uint16_t top;
int32_t exp, frac;
uint8_t groups = 0;
uint16_t nshort = frame_len/8;
for (g = 0; g < ics->num_window_groups; g++)
{
uint16_t k = 0;
/* using this nshort*groups doesn't hurt long blocks, because
long blocks only have 1 group, so that means 'groups' is
always 0 for long blocks
*/
for (sfb = 0; sfb < ics->max_sfb; sfb++)
{
top = ics->sect_sfb_offset[g][sfb+1];
exp = (ics->scale_factors[g][sfb] /* - 100 */) >> 2;
frac = (ics->scale_factors[g][sfb] /* - 100 */) & 3;
/* minimum size of a sf band is 4 and always a multiple of 4 */
for ( ; k < top; k += 4)
{
__m128 m1 = _mm_load_ps(&x_invquant[k+(groups*nshort)]);
__m128 m2 = _mm_load_ps1(&pow2sf_tab[exp /*+25*/]);
__m128 m3 = _mm_load_ps1(&pow2_table[frac /* + 3*/]);
__m128 m4 = _mm_mul_ps(m1, m2);
__m128 m5 = _mm_mul_ps(m3, m4);
_mm_store_ps(&x_invquant[k+(groups*nshort)], m5);
}
}
groups += ics->window_group_length[g];
}
}
#endif
static uint8_t allocate_single_channel(faacDecHandle hDecoder, uint8_t channel,
static uint8_t allocate_single_channel(NeAACDecHandle hDecoder, uint8_t channel,
uint8_t output_channels)
{
uint8_t mul = 1;
@ -773,7 +735,7 @@ static uint8_t allocate_single_channel(faacDecHandle hDecoder, uint8_t channel,
return 0;
}
static uint8_t allocate_channel_pair(faacDecHandle hDecoder,
static uint8_t allocate_channel_pair(NeAACDecHandle hDecoder,
uint8_t channel, uint8_t paired_channel)
{
uint8_t mul = 1;
@ -878,7 +840,7 @@ static uint8_t allocate_channel_pair(faacDecHandle hDecoder,
return 0;
}
uint8_t reconstruct_single_channel(faacDecHandle hDecoder, ic_stream *ics,
uint8_t reconstruct_single_channel(NeAACDecHandle hDecoder, ic_stream *ics,
element *sce, int16_t *spec_data)
{
uint8_t retval, output_channels;
@ -894,6 +856,12 @@ uint8_t reconstruct_single_channel(faacDecHandle hDecoder, ic_stream *ics,
output_channels = hDecoder->ps_used[hDecoder->fr_ch_ele] ? 2 : 1;
#else
output_channels = 1;
#endif
#ifdef DRM_PS
/* for DRM error recovery is crucial */
/* simply always allocate 2 channels, you never know when PS will pop up */
if (hDecoder->object_type == DRM_ER_LC)
output_channels = 2;
#endif
if (hDecoder->element_output_channels[hDecoder->fr_ch_ele] == 0)
{
@ -904,7 +872,6 @@ uint8_t reconstruct_single_channel(faacDecHandle hDecoder, ic_stream *ics,
return 21;
}
if (hDecoder->element_alloced[hDecoder->fr_ch_ele] == 0)
{
retval = allocate_single_channel(hDecoder, sce->channel, output_channels);
@ -915,22 +882,11 @@ uint8_t reconstruct_single_channel(faacDecHandle hDecoder, ic_stream *ics,
}
/* inverse quantization */
retval = inverse_quantization(spec_coef, spec_data, hDecoder->frameLength);
/* dequantisation and scaling */
retval = quant_to_spec(hDecoder, ics, spec_data, spec_coef, hDecoder->frameLength);
if (retval > 0)
return retval;
/* apply scalefactors */
#ifndef USE_SSE
apply_scalefactors(hDecoder, ics, spec_coef, hDecoder->frameLength);
#else
hDecoder->apply_sf_func(hDecoder, ics, spec_coef, hDecoder->frameLength);
#endif
/* deinterleave short block grouping */
if (ics->window_sequence == EIGHT_SHORT_SEQUENCE)
quant_to_spec(ics, spec_coef, hDecoder->frameLength);
#ifdef PROFILE
count = faad_get_ts() - count;
hDecoder->requant_cycles += count;
@ -989,7 +945,6 @@ uint8_t reconstruct_single_channel(faacDecHandle hDecoder, ic_stream *ics,
drc_decode(hDecoder->drc, spec_coef);
}
/* filter bank */
#ifdef SSR_DEC
if (hDecoder->object_type != SSR)
@ -1036,25 +991,31 @@ uint8_t reconstruct_single_channel(faacDecHandle hDecoder, ic_stream *ics,
if (hDecoder->sbr[ele] == NULL)
{
hDecoder->sbr[ele] = sbrDecodeInit(hDecoder->frameLength,
sce->ele_id, 2*get_sample_rate(hDecoder->sf_index)
hDecoder->element_id[ele], 2*get_sample_rate(hDecoder->sf_index),
hDecoder->downSampledSBR
#ifdef DRM
, 0
#endif
);
}
if (sce->ics1.window_sequence == EIGHT_SHORT_SEQUENCE)
hDecoder->sbr[ele]->maxAACLine = 8*sce->ics1.swb_offset[max(sce->ics1.max_sfb-1, 0)];
else
hDecoder->sbr[ele]->maxAACLine = sce->ics1.swb_offset[max(sce->ics1.max_sfb-1, 0)];
/* check if any of the PS tools is used */
#if (defined(PS_DEC) || defined(DRM_PS))
if (output_channels == 1)
if (hDecoder->ps_used[ele] == 0)
{
#endif
retval = sbrDecodeSingleFrame(hDecoder->sbr[ele], hDecoder->time_out[ch],
hDecoder->postSeekResetFlag, hDecoder->forceUpSampling);
hDecoder->postSeekResetFlag, hDecoder->downSampledSBR);
#if (defined(PS_DEC) || defined(DRM_PS))
} else {
retval = sbrDecodeSingleFramePS(hDecoder->sbr[ele], hDecoder->time_out[ch],
hDecoder->time_out[ch+1], hDecoder->postSeekResetFlag,
hDecoder->forceUpSampling);
hDecoder->downSampledSBR);
}
#endif
if (retval > 0)
@ -1066,10 +1027,24 @@ uint8_t reconstruct_single_channel(faacDecHandle hDecoder, ic_stream *ics,
}
#endif
#ifdef DRM_PS
/* copy L to R for DRM when no PS is used */
if ((hDecoder->object_type == DRM_ER_LC) &&
(hDecoder->ps_used[hDecoder->fr_ch_ele] == 0))
{
uint8_t ele = hDecoder->fr_ch_ele;
uint8_t ch = sce->channel;
uint16_t frame_size = (hDecoder->sbr_alloced[ele]) ? 2 : 1;
frame_size *= hDecoder->frameLength*sizeof(real_t);
memcpy(hDecoder->time_out[ch+1], hDecoder->time_out[ch], frame_size);
}
#endif
return 0;
}
uint8_t reconstruct_channel_pair(faacDecHandle hDecoder, ic_stream *ics1, ic_stream *ics2,
uint8_t reconstruct_channel_pair(NeAACDecHandle hDecoder, ic_stream *ics1, ic_stream *ics2,
element *cpe, int16_t *spec_data1, int16_t *spec_data2)
{
uint8_t retval;
@ -1081,37 +1056,21 @@ uint8_t reconstruct_channel_pair(faacDecHandle hDecoder, ic_stream *ics1, ic_str
#endif
if (hDecoder->element_alloced[hDecoder->fr_ch_ele] == 0)
{
retval = allocate_channel_pair(hDecoder, cpe->channel, cpe->paired_channel);
retval = allocate_channel_pair(hDecoder, cpe->channel, (uint8_t)cpe->paired_channel);
if (retval > 0)
return retval;
hDecoder->element_alloced[hDecoder->fr_ch_ele] = 1;
}
/* inverse quantization */
retval = inverse_quantization(spec_coef1, spec_data1, hDecoder->frameLength);
/* dequantisation and scaling */
retval = quant_to_spec(hDecoder, ics1, spec_data1, spec_coef1, hDecoder->frameLength);
if (retval > 0)
return retval;
retval = inverse_quantization(spec_coef2, spec_data2, hDecoder->frameLength);
retval = quant_to_spec(hDecoder, ics2, spec_data2, spec_coef2, hDecoder->frameLength);
if (retval > 0)
return retval;
/* apply scalefactors */
#ifndef USE_SSE
apply_scalefactors(hDecoder, ics1, spec_coef1, hDecoder->frameLength);
apply_scalefactors(hDecoder, ics2, spec_coef2, hDecoder->frameLength);
#else
hDecoder->apply_sf_func(hDecoder, ics1, spec_coef1, hDecoder->frameLength);
hDecoder->apply_sf_func(hDecoder, ics2, spec_coef2, hDecoder->frameLength);
#endif
/* deinterleave short block grouping */
if (ics1->window_sequence == EIGHT_SHORT_SEQUENCE)
quant_to_spec(ics1, spec_coef1, hDecoder->frameLength);
if (ics2->window_sequence == EIGHT_SHORT_SEQUENCE)
quant_to_spec(ics2, spec_coef2, hDecoder->frameLength);
#ifdef PROFILE
count = faad_get_ts() - count;
hDecoder->requant_cycles += count;
@ -1261,16 +1220,22 @@ uint8_t reconstruct_channel_pair(faacDecHandle hDecoder, ic_stream *ics1, ic_str
if (hDecoder->sbr[ele] == NULL)
{
hDecoder->sbr[ele] = sbrDecodeInit(hDecoder->frameLength,
cpe->ele_id, 2*get_sample_rate(hDecoder->sf_index)
hDecoder->element_id[ele], 2*get_sample_rate(hDecoder->sf_index),
hDecoder->downSampledSBR
#ifdef DRM
, 0
#endif
);
}
if (cpe->ics1.window_sequence == EIGHT_SHORT_SEQUENCE)
hDecoder->sbr[ele]->maxAACLine = 8*cpe->ics1.swb_offset[max(cpe->ics1.max_sfb-1, 0)];
else
hDecoder->sbr[ele]->maxAACLine = cpe->ics1.swb_offset[max(cpe->ics1.max_sfb-1, 0)];
retval = sbrDecodeCoupleFrame(hDecoder->sbr[ele],
hDecoder->time_out[ch0], hDecoder->time_out[ch1],
hDecoder->postSeekResetFlag, hDecoder->forceUpSampling);
hDecoder->postSeekResetFlag, hDecoder->downSampledSBR);
if (retval > 0)
return retval;
} else if (((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1))

View File

@ -23,7 +23,7 @@
** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
**
** Initially modified for use with MPlayer by Arpad Gereöffy on 2003/08/30
** $Id: specrec.h,v 1.3 2004/06/02 22:59:03 diego Exp $
** $Id: specrec.h,v 1.4 2004/06/23 13:50:52 diego Exp $
** detailed CVS changelog at http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
**/
@ -36,16 +36,10 @@ extern "C" {
#include "syntax.h"
uint8_t window_grouping_info(faacDecHandle hDecoder, ic_stream *ics);
void apply_scalefactors(faacDecHandle hDecoder, ic_stream *ics, real_t *x_invquant,
uint16_t frame_len);
#ifdef USE_SSE
void apply_scalefactors_sse(faacDecHandle hDecoder, ic_stream *ics, real_t *x_invquant,
uint16_t frame_len);
#endif
uint8_t reconstruct_channel_pair(faacDecHandle hDecoder, ic_stream *ics1, ic_stream *ics2,
uint8_t window_grouping_info(NeAACDecHandle hDecoder, ic_stream *ics);
uint8_t reconstruct_channel_pair(NeAACDecHandle hDecoder, ic_stream *ics1, ic_stream *ics2,
element *cpe, int16_t *spec_data1, int16_t *spec_data2);
uint8_t reconstruct_single_channel(faacDecHandle hDecoder, ic_stream *ics, element *sce,
uint8_t reconstruct_single_channel(NeAACDecHandle hDecoder, ic_stream *ics, element *sce,
int16_t *spec_data);
#ifdef __cplusplus

View File

@ -23,7 +23,7 @@
** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
**
** Initially modified for use with MPlayer by Arpad Gereöffy on 2003/08/30
** $Id: structs.h,v 1.3 2004/06/02 22:59:04 diego Exp $
** $Id: structs.h,v 1.4 2004/06/23 13:50:53 diego Exp $
** detailed CVS changelog at http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
**/
@ -184,6 +184,7 @@ typedef struct
program_config pce[16];
} adif_header;
#ifdef LTP_DEC
typedef struct
{
uint8_t last_band;
@ -196,7 +197,9 @@ typedef struct
uint8_t short_lag_present[8];
uint8_t short_lag[8];
} ltp_info;
#endif
#ifdef MAIN_DEC
typedef struct
{
uint8_t limit;
@ -204,6 +207,7 @@ typedef struct
uint8_t predictor_reset_group_number;
uint8_t prediction_used[MAX_SFB];
} pred_info;
#endif
typedef struct
{
@ -270,9 +274,13 @@ typedef struct
pulse_info pul;
tns_info tns;
#ifdef MAIN_DEC
pred_info pred;
#endif
#ifdef LTP_DEC
ltp_info ltp;
ltp_info ltp2;
#endif
#ifdef SSR_DEC
ssr_info ssr;
#endif
@ -294,8 +302,6 @@ typedef struct
typedef struct
{
uint8_t ele_id;
uint8_t channel;
int16_t paired_channel;
@ -309,59 +315,60 @@ typedef struct
typedef struct mp4AudioSpecificConfig
{
/* Audio Specific Info */
uint8_t objectTypeIndex;
uint8_t samplingFrequencyIndex;
uint32_t samplingFrequency;
uint8_t channelsConfiguration;
/*uint8_t*/ unsigned char objectTypeIndex;
/*uint8_t*/ unsigned char samplingFrequencyIndex;
/*uint32_t*/ unsigned long samplingFrequency;
/*uint8_t*/ unsigned char channelsConfiguration;
/* GA Specific Info */
uint8_t frameLengthFlag;
uint8_t dependsOnCoreCoder;
uint16_t coreCoderDelay;
uint8_t extensionFlag;
uint8_t aacSectionDataResilienceFlag;
uint8_t aacScalefactorDataResilienceFlag;
uint8_t aacSpectralDataResilienceFlag;
uint8_t epConfig;
/*uint8_t*/ unsigned char frameLengthFlag;
/*uint8_t*/ unsigned char dependsOnCoreCoder;
/*uint16_t*/ unsigned short coreCoderDelay;
/*uint8_t*/ unsigned char extensionFlag;
/*uint8_t*/ unsigned char aacSectionDataResilienceFlag;
/*uint8_t*/ unsigned char aacScalefactorDataResilienceFlag;
/*uint8_t*/ unsigned char aacSpectralDataResilienceFlag;
/*uint8_t*/ unsigned char epConfig;
int8_t sbr_present_flag;
int8_t forceUpSampling;
/*uint8_t*/ char sbr_present_flag;
/*uint8_t*/ char forceUpSampling;
/*uint8_t*/ char downSampledSBR;
} mp4AudioSpecificConfig;
typedef struct faacDecConfiguration
typedef struct NeAACDecConfiguration
{
uint8_t defObjectType;
uint32_t defSampleRate;
uint8_t outputFormat;
uint8_t downMatrix;
uint8_t useOldADTSFormat;
uint8_t dontUpSampleImplicitSBR;
} faacDecConfiguration, *faacDecConfigurationPtr;
/*uint8_t*/ unsigned char defObjectType;
/*uint32_t*/ unsigned long defSampleRate;
/*uint8_t*/ unsigned char outputFormat;
/*uint8_t*/ unsigned char downMatrix;
/*uint8_t*/ unsigned char useOldADTSFormat;
/*uint8_t*/ unsigned char dontUpSampleImplicitSBR;
} NeAACDecConfiguration, *NeAACDecConfigurationPtr;
typedef struct faacDecFrameInfo
typedef struct NeAACDecFrameInfo
{
uint32_t bytesconsumed;
uint32_t samples;
uint8_t channels;
uint8_t error;
uint32_t samplerate;
/*uint32_t*/ unsigned long bytesconsumed;
/*uint32_t*/ unsigned long samples;
/*uint8_t*/ unsigned char channels;
/*uint8_t*/ unsigned char error;
/*uint32_t*/ unsigned long samplerate;
/* SBR: 0: off, 1: on; normal, 2: on; downsampled */
uint8_t sbr;
/*uint8_t*/ unsigned char sbr;
/* MPEG-4 ObjectType */
uint8_t object_type;
/*uint8_t*/ unsigned char object_type;
/* AAC header type; MP4 will be signalled as RAW also */
uint8_t header_type;
/*uint8_t*/ unsigned char header_type;
/* multichannel configuration */
uint8_t num_front_channels;
uint8_t num_side_channels;
uint8_t num_back_channels;
uint8_t num_lfe_channels;
uint8_t channel_position[MAX_CHANNELS];
} faacDecFrameInfo;
/*uint8_t*/ unsigned char num_front_channels;
/*uint8_t*/ unsigned char num_side_channels;
/*uint8_t*/ unsigned char num_back_channels;
/*uint8_t*/ unsigned char num_lfe_channels;
/*uint8_t*/ unsigned char channel_position[MAX_CHANNELS];
} NeAACDecFrameInfo;
typedef struct
{
@ -381,6 +388,7 @@ typedef struct
uint32_t frame;
uint8_t downMatrix;
uint8_t upMatrix;
uint8_t first_syn_ele;
uint8_t has_lfe;
/* number of channels in current frame */
@ -417,13 +425,11 @@ typedef struct
#ifdef SBR_DEC
int8_t sbr_present_flag;
int8_t forceUpSampling;
int8_t downSampledSBR;
/* determines whether SBR data is allocated for the gives element */
uint8_t sbr_alloced[MAX_SYNTAX_ELEMENTS];
sbr_info *sbr[MAX_SYNTAX_ELEMENTS];
#ifdef DRM
int8_t lcstereo_flag;
#endif
#endif
#if (defined(PS_DEC) || defined(DRM_PS))
uint8_t ps_used[MAX_SYNTAX_ELEMENTS];
@ -449,7 +455,7 @@ typedef struct
uint8_t internal_channel[MAX_CHANNELS];
/* Configuration data */
faacDecConfiguration config;
NeAACDecConfiguration config;
#ifdef USE_SSE
void (*apply_sf_func)(void *a, void *b, void *c, uint16_t d);
@ -462,7 +468,7 @@ typedef struct
int64_t scalefac_cycles;
int64_t requant_cycles;
#endif
} faacDecStruct, *faacDecHandle;
} NeAACDecStruct, *NeAACDecHandle;

View File

@ -23,7 +23,7 @@
** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
**
** Initially modified for use with MPlayer by Arpad Gereöffy on 2003/08/30
** $Id: syntax.c,v 1.3 2004/06/02 22:59:04 diego Exp $
** $Id: syntax.c,v 1.4 2004/06/23 13:50:53 diego Exp $
** detailed CVS changelog at http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
**/
@ -54,47 +54,49 @@
/* static function declarations */
static void decode_sce_lfe(faacDecHandle hDecoder, faacDecFrameInfo *hInfo, bitfile *ld,
static void decode_sce_lfe(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo, bitfile *ld,
uint8_t id_syn_ele);
static void decode_cpe(faacDecHandle hDecoder, faacDecFrameInfo *hInfo, bitfile *ld,
static void decode_cpe(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo, bitfile *ld,
uint8_t id_syn_ele);
static uint8_t single_lfe_channel_element(faacDecHandle hDecoder, bitfile *ld,
static uint8_t single_lfe_channel_element(NeAACDecHandle hDecoder, bitfile *ld,
uint8_t channel, uint8_t *tag);
static uint8_t channel_pair_element(faacDecHandle hDecoder, bitfile *ld,
static uint8_t channel_pair_element(NeAACDecHandle hDecoder, bitfile *ld,
uint8_t channel, uint8_t *tag);
#ifdef COUPLING_DEC
static uint8_t coupling_channel_element(faacDecHandle hDecoder, bitfile *ld);
static uint8_t coupling_channel_element(NeAACDecHandle hDecoder, bitfile *ld);
#endif
static uint16_t data_stream_element(faacDecHandle hDecoder, bitfile *ld);
static uint16_t data_stream_element(NeAACDecHandle hDecoder, bitfile *ld);
static uint8_t program_config_element(program_config *pce, bitfile *ld);
static uint8_t fill_element(faacDecHandle hDecoder, bitfile *ld, drc_info *drc
static uint8_t fill_element(NeAACDecHandle hDecoder, bitfile *ld, drc_info *drc
#ifdef SBR_DEC
,uint8_t sbr_ele
#endif
);
static uint8_t individual_channel_stream(faacDecHandle hDecoder, element *ele,
static uint8_t individual_channel_stream(NeAACDecHandle 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,
static uint8_t ics_info(NeAACDecHandle hDecoder, ic_stream *ics, bitfile *ld,
uint8_t common_window);
static uint8_t section_data(faacDecHandle hDecoder, ic_stream *ics, bitfile *ld);
static uint8_t scale_factor_data(faacDecHandle hDecoder, ic_stream *ics, bitfile *ld);
static uint8_t section_data(NeAACDecHandle hDecoder, ic_stream *ics, bitfile *ld);
static uint8_t scale_factor_data(NeAACDecHandle hDecoder, ic_stream *ics, bitfile *ld);
#ifdef SSR_DEC
static void gain_control_data(bitfile *ld, ic_stream *ics);
#endif
static uint8_t spectral_data(faacDecHandle hDecoder, ic_stream *ics, bitfile *ld,
static uint8_t spectral_data(NeAACDecHandle hDecoder, ic_stream *ics, bitfile *ld,
int16_t *spectral_data);
static uint16_t extension_payload(bitfile *ld, drc_info *drc, uint16_t count);
static uint8_t pulse_data(ic_stream *ics, pulse_info *pul, bitfile *ld);
static void tns_data(ic_stream *ics, tns_info *tns, bitfile *ld);
static uint8_t ltp_data(faacDecHandle hDecoder, ic_stream *ics, ltp_info *ltp, bitfile *ld);
#ifdef LTP_DEC
static uint8_t ltp_data(NeAACDecHandle hDecoder, ic_stream *ics, ltp_info *ltp, bitfile *ld);
#endif
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);
static uint8_t dynamic_range_info(bitfile *ld, drc_info *drc);
static uint8_t excluded_channels(bitfile *ld, drc_info *drc);
#ifdef SCALABLE_DEC
static int8_t aac_scalable_main_header(faacDecHandle hDecoder, ic_stream *ics1, ic_stream *ics2,
static int8_t aac_scalable_main_header(NeAACDecHandle hDecoder, ic_stream *ics1, ic_stream *ics2,
bitfile *ld, uint8_t this_layer_stereo);
#endif
@ -316,8 +318,8 @@ static uint8_t program_config_element(program_config *pce, bitfile *ld)
return 0;
}
static void decode_sce_lfe(faacDecHandle hDecoder,
faacDecFrameInfo *hInfo, bitfile *ld,
static void decode_sce_lfe(NeAACDecHandle hDecoder,
NeAACDecFrameInfo *hInfo, bitfile *ld,
uint8_t id_syn_ele)
{
uint8_t channels = hDecoder->fr_channels;
@ -361,7 +363,7 @@ static void decode_sce_lfe(faacDecHandle hDecoder,
hDecoder->fr_ch_ele++;
}
static void decode_cpe(faacDecHandle hDecoder, faacDecFrameInfo *hInfo, bitfile *ld,
static void decode_cpe(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo, bitfile *ld,
uint8_t id_syn_ele)
{
uint8_t channels = hDecoder->fr_channels;
@ -409,7 +411,7 @@ static void decode_cpe(faacDecHandle hDecoder, faacDecFrameInfo *hInfo, bitfile
hDecoder->fr_ch_ele++;
}
void raw_data_block(faacDecHandle hDecoder, faacDecFrameInfo *hInfo,
void raw_data_block(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo,
bitfile *ld, program_config *pce, drc_info *drc)
{
uint8_t id_syn_ele;
@ -425,7 +427,7 @@ void raw_data_block(faacDecHandle hDecoder, faacDecFrameInfo *hInfo,
#endif
/* Table 4.4.3: raw_data_block() */
while ((id_syn_ele = (uint8_t)faad_getbits(ld, LEN_SE_ID
DEBUGVAR(1,4,"faacDecDecode(): id_syn_ele"))) != ID_END)
DEBUGVAR(1,4,"NeAACDecDecode(): id_syn_ele"))) != ID_END)
{
switch (id_syn_ele) {
case ID_SCE:
@ -558,7 +560,7 @@ void raw_data_block(faacDecHandle hDecoder, faacDecFrameInfo *hInfo,
/* Table 4.4.4 and */
/* Table 4.4.9 */
static uint8_t single_lfe_channel_element(faacDecHandle hDecoder, bitfile *ld,
static uint8_t single_lfe_channel_element(NeAACDecHandle hDecoder, bitfile *ld,
uint8_t channel, uint8_t *tag)
{
uint8_t retval = 0;
@ -601,7 +603,7 @@ static uint8_t single_lfe_channel_element(faacDecHandle hDecoder, bitfile *ld,
}
/* Table 4.4.5 */
static uint8_t channel_pair_element(faacDecHandle hDecoder, bitfile *ld,
static uint8_t channel_pair_element(NeAACDecHandle hDecoder, bitfile *ld,
uint8_t channels, uint8_t *tag)
{
ALIGN int16_t spec_data1[1024] = {0};
@ -643,13 +645,20 @@ static uint8_t channel_pair_element(faacDecHandle hDecoder, bitfile *ld,
#ifdef ERROR_RESILIENCE
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)
if ((
#ifdef LTP_DEC
ics1->ltp.data_present =
#endif
faad_get1bit(ld DEBUGVAR(1,50,"channel_pair_element(): ltp.data_present"))) & 1)
{
#ifdef LTP_DEC
if ((result = ltp_data(hDecoder, ics1, &(ics1->ltp), ld)) > 0)
{
return result;
}
#else
return 26;
#endif
}
}
#endif
@ -669,13 +678,20 @@ static uint8_t channel_pair_element(faacDecHandle hDecoder, bitfile *ld,
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)
if ((
#ifdef LTP_DEC
ics1->ltp2.data_present =
#endif
faad_get1bit(ld DEBUGVAR(1,50,"channel_pair_element(): ltp.data_present"))) & 1)
{
#ifdef LTP_DEC
if ((result = ltp_data(hDecoder, ics1, &(ics1->ltp2), ld)) > 0)
{
return result;
}
#else
return 26;
#endif
}
}
#endif
@ -712,7 +728,7 @@ static uint8_t channel_pair_element(faacDecHandle hDecoder, bitfile *ld,
}
/* Table 4.4.6 */
static uint8_t ics_info(faacDecHandle hDecoder, ic_stream *ics, bitfile *ld,
static uint8_t ics_info(NeAACDecHandle hDecoder, ic_stream *ics, bitfile *ld,
uint8_t common_window)
{
uint8_t retval = 0;
@ -753,19 +769,29 @@ static uint8_t ics_info(faacDecHandle hDecoder, ic_stream *ics, bitfile *ld,
{
uint8_t sfb;
ics->pred.limit = min(ics->max_sfb, max_pred_sfb(hDecoder->sf_index));
uint8_t limit = min(ics->max_sfb, max_pred_sfb(hDecoder->sf_index));
#ifdef MAIN_DEC
ics->pred.limit = limit;
#endif
if ((ics->pred.predictor_reset = faad_get1bit(ld
DEBUGVAR(1,53,"ics_info(): pred.predictor_reset"))) & 1)
if ((
#ifdef MAIN_DEC
ics->pred.predictor_reset =
#endif
faad_get1bit(ld DEBUGVAR(1,53,"ics_info(): pred.predictor_reset"))) & 1)
{
ics->pred.predictor_reset_group_number = (uint8_t)faad_getbits(ld, 5
DEBUGVAR(1,54,"ics_info(): pred.predictor_reset_group_number"));
#ifdef MAIN_DEC
ics->pred.predictor_reset_group_number =
#endif
(uint8_t)faad_getbits(ld, 5 DEBUGVAR(1,54,"ics_info(): pred.predictor_reset_group_number"));
}
for (sfb = 0; sfb < ics->pred.limit; sfb++)
for (sfb = 0; sfb < limit; sfb++)
{
ics->pred.prediction_used[sfb] = faad_get1bit(ld
DEBUGVAR(1,55,"ics_info(): pred.prediction_used"));
#ifdef MAIN_DEC
ics->pred.prediction_used[sfb] =
#endif
faad_get1bit(ld DEBUGVAR(1,55,"ics_info(): pred.prediction_used"));
}
}
#ifdef LTP_DEC
@ -828,8 +854,14 @@ static uint8_t pulse_data(ic_stream *ics, pulse_info *pul, bitfile *ld)
{
pul->pulse_offset[i] = (uint8_t)faad_getbits(ld, 5
DEBUGVAR(1,58,"pulse_data(): pulse_offset"));
#if 0
printf("%d\n", pul->pulse_offset[i]);
#endif
pul->pulse_amp[i] = (uint8_t)faad_getbits(ld, 4
DEBUGVAR(1,59,"pulse_data(): pulse_amp"));
#if 0
printf("%d\n", pul->pulse_amp[i]);
#endif
}
return 0;
@ -837,7 +869,7 @@ static uint8_t pulse_data(ic_stream *ics, pulse_info *pul, bitfile *ld)
#ifdef COUPLING_DEC
/* Table 4.4.8: Currently just for skipping the bits... */
static uint8_t coupling_channel_element(faacDecHandle hDecoder, bitfile *ld)
static uint8_t coupling_channel_element(NeAACDecHandle hDecoder, bitfile *ld)
{
uint8_t c, result = 0;
uint8_t ind_sw_cce_flag = 0;
@ -926,7 +958,7 @@ static uint8_t coupling_channel_element(faacDecHandle hDecoder, bitfile *ld)
#endif
/* Table 4.4.10 */
static uint16_t data_stream_element(faacDecHandle hDecoder, bitfile *ld)
static uint16_t data_stream_element(NeAACDecHandle hDecoder, bitfile *ld)
{
uint8_t byte_aligned;
uint16_t i, count;
@ -955,7 +987,7 @@ static uint16_t data_stream_element(faacDecHandle hDecoder, bitfile *ld)
}
/* Table 4.4.11 */
static uint8_t fill_element(faacDecHandle hDecoder, bitfile *ld, drc_info *drc
static uint8_t fill_element(NeAACDecHandle hDecoder, bitfile *ld, drc_info *drc
#ifdef SBR_DEC
,uint8_t sbr_ele
#endif
@ -988,7 +1020,8 @@ static uint8_t fill_element(faacDecHandle hDecoder, bitfile *ld, drc_info *drc
if (!hDecoder->sbr[sbr_ele])
{
hDecoder->sbr[sbr_ele] = sbrDecodeInit(hDecoder->frameLength,
hDecoder->element_id[sbr_ele], 2*get_sample_rate(hDecoder->sf_index)
hDecoder->element_id[sbr_ele], 2*get_sample_rate(hDecoder->sf_index),
hDecoder->downSampledSBR
#ifdef DRM
, 0
#endif
@ -999,6 +1032,14 @@ static uint8_t fill_element(faacDecHandle hDecoder, bitfile *ld, drc_info *drc
/* parse the SBR data */
hDecoder->sbr[sbr_ele]->ret = sbr_extension_data(ld, hDecoder->sbr[sbr_ele], count);
#if 0
if (hDecoder->sbr[sbr_ele]->ret > 0)
{
printf("%s\n", NeAACDecGetErrorMessage(hDecoder->sbr[sbr_ele]->ret));
}
#endif
#if (defined(PS_DEC) || defined(DRM_PS))
if (hDecoder->sbr[sbr_ele]->ps_used)
{
@ -1117,7 +1158,7 @@ static void gain_control_data(bitfile *ld, ic_stream *ics)
#ifdef SCALABLE_DEC
/* Table 4.4.13 ASME */
void aac_scalable_main_element(faacDecHandle hDecoder, faacDecFrameInfo *hInfo,
void aac_scalable_main_element(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo,
bitfile *ld, program_config *pce, drc_info *drc)
{
uint8_t retval = 0;
@ -1139,11 +1180,13 @@ void aac_scalable_main_element(faacDecHandle hDecoder, faacDecFrameInfo *hInfo,
cpe.common_window = 1;
if (this_layer_stereo)
cpe.ele_id = ID_CPE;
else
cpe.ele_id = ID_SCE;
hDecoder->element_output_channels[hDecoder->fr_ch_ele] = (this_layer_stereo ? 2 : 0);
{
hDecoder->element_id[0] = ID_CPE;
if (hDecoder->element_output_channels[hDecoder->fr_ch_ele] == 0)
hDecoder->element_output_channels[hDecoder->fr_ch_ele] = 2;
} else {
hDecoder->element_id[0] = ID_SCE;
}
for (ch = 0; ch < (this_layer_stereo ? 2 : 1); ch++)
{
@ -1187,8 +1230,8 @@ void aac_scalable_main_element(faacDecHandle hDecoder, faacDecFrameInfo *hInfo,
if (!hDecoder->sbr[0])
{
hDecoder->sbr[0] = sbrDecodeInit(hDecoder->frameLength, cpe.ele_id,
2*get_sample_rate(hDecoder->sf_index), 1);
hDecoder->sbr[0] = sbrDecodeInit(hDecoder->frameLength, hDecoder->element_id[0],
2*get_sample_rate(hDecoder->sf_index), 0 /* ds SBR */, 1);
}
/* Reverse bit reading of SBR data in DRM audio frame */
@ -1203,8 +1246,6 @@ void aac_scalable_main_element(faacDecHandle hDecoder, faacDecFrameInfo *hInfo,
count = (uint16_t)bit2byte(buffer_size*8 - bitsconsumed);
faad_initbits(&ld_sbr, revbuffer, count);
hDecoder->sbr[0]->lcstereo_flag = hDecoder->lcstereo_flag;
hDecoder->sbr[0]->sample_rate = get_sample_rate(hDecoder->sf_index);
hDecoder->sbr[0]->sample_rate *= 2;
@ -1220,8 +1261,8 @@ void aac_scalable_main_element(faacDecHandle hDecoder, faacDecFrameInfo *hInfo,
/* check CRC */
/* no need to check it if there was already an error */
if (hDecoder->sbr[0]->ret == 0)
hDecoder->sbr[0]->ret = faad_check_CRC(&ld_sbr, faad_get_processed_bits(&ld_sbr) - 8);
// if (hDecoder->sbr[0]->ret == 0)
// hDecoder->sbr[0]->ret = (uint8_t)faad_check_CRC(&ld_sbr, (uint16_t)faad_get_processed_bits(&ld_sbr) - 8);
faad_endbits(&ld_sbr);
@ -1252,8 +1293,6 @@ void aac_scalable_main_element(faacDecHandle hDecoder, faacDecFrameInfo *hInfo,
hDecoder->internal_channel[channels] = channels;
}
hDecoder->element_id[hDecoder->fr_ch_ele] = cpe.ele_id;
hDecoder->fr_channels += hDecoder->element_output_channels[hDecoder->fr_ch_ele];
hDecoder->fr_ch_ele++;
@ -1261,7 +1300,7 @@ void aac_scalable_main_element(faacDecHandle hDecoder, faacDecFrameInfo *hInfo,
}
/* Table 4.4.15 */
static int8_t aac_scalable_main_header(faacDecHandle hDecoder, ic_stream *ics1, ic_stream *ics2,
static int8_t aac_scalable_main_header(NeAACDecHandle hDecoder, ic_stream *ics1, ic_stream *ics2,
bitfile *ld, uint8_t this_layer_stereo)
{
uint8_t retval = 0;
@ -1353,13 +1392,20 @@ static int8_t aac_scalable_main_header(faacDecHandle hDecoder, ic_stream *ics1,
diff_control_data_lr();
} else {
#endif
if ((ics->ltp.data_present = faad_get1bit(ld
DEBUGVAR(1,310,"aac_scalable_main_header(): ltp.data_present"))) & 1)
if ((
#ifdef LTP_DEC
ics->ltp.data_present =
#endif
faad_get1bit(ld DEBUGVAR(1,310,"aac_scalable_main_header(): ltp.data_present"))) & 1)
{
#ifdef LTP_DEC
if ((retval = ltp_data(hDecoder, ics, &(ics->ltp), ld)) > 0)
{
return retval;
}
#else
return 26;
#endif
}
#if 0
}
@ -1371,7 +1417,7 @@ static int8_t aac_scalable_main_header(faacDecHandle hDecoder, ic_stream *ics1,
#endif
/* Table 4.4.24 */
static uint8_t individual_channel_stream(faacDecHandle hDecoder, element *ele,
static uint8_t individual_channel_stream(NeAACDecHandle hDecoder, element *ele,
bitfile *ld, ic_stream *ics, uint8_t scal_flag,
int16_t *spec_data)
{
@ -1469,7 +1515,7 @@ static uint8_t individual_channel_stream(faacDecHandle hDecoder, element *ele,
#ifdef DRM
/* CRC check */
if (hDecoder->object_type == DRM_ER_LC)
if ((result = faad_check_CRC(ld, faad_get_processed_bits(ld) - 8)) > 0)
if ((result = (uint8_t)faad_check_CRC(ld, (uint16_t)faad_get_processed_bits(ld) - 8)) > 0)
return result;
#endif
@ -1507,7 +1553,7 @@ static uint8_t individual_channel_stream(faacDecHandle hDecoder, element *ele,
}
/* Table 4.4.25 */
static uint8_t section_data(faacDecHandle hDecoder, ic_stream *ics, bitfile *ld)
static uint8_t section_data(NeAACDecHandle hDecoder, ic_stream *ics, bitfile *ld)
{
uint8_t g;
uint8_t sect_esc_val, sect_bits;
@ -1551,6 +1597,10 @@ static uint8_t section_data(faacDecHandle hDecoder, ic_stream *ics, bitfile *ld)
ics->sect_cb[g][i] = (uint8_t)faad_getbits(ld, sect_cb_bits
DEBUGVAR(1,71,"section_data(): sect_cb"));
#if 0
printf("%d\n", ics->sect_cb[g][i]);
#endif
if (ics->sect_cb[g][i] == NOISE_HCB)
ics->noise_used = 1;
@ -1586,13 +1636,25 @@ static uint8_t section_data(faacDecHandle hDecoder, ic_stream *ics, bitfile *ld)
ics->sect_start[g][i] = k;
ics->sect_end[g][i] = k + sect_len;
#if 0
printf("%d\n", ics->sect_start[g][i]);
#endif
#if 0
printf("%d\n", ics->sect_end[g][i]);
#endif
if (k + sect_len >= 8*15)
return 15;
if (i >= 8*15)
return 15;
for (sfb = k; sfb < k + sect_len; sfb++)
{
ics->sfb_cb[g][sfb] = ics->sect_cb[g][i];
#if 0
printf("%d\n", ics->sfb_cb[g][sfb]);
#endif
}
#if 0
printf(" %6d %6d %6d\n",
@ -1605,6 +1667,9 @@ static uint8_t section_data(faacDecHandle hDecoder, ic_stream *ics, bitfile *ld)
i++;
}
ics->num_sec[g] = i;
#if 0
printf("%d\n", ics->num_sec[g]);
#endif
}
#if 0
@ -1643,6 +1708,10 @@ static uint8_t decode_scale_factors(ic_stream *ics, bitfile *ld)
{
case ZERO_HCB: /* zero book */
ics->scale_factors[g][sfb] = 0;
//#define SF_PRINT
#ifdef SF_PRINT
printf("%d\n", ics->scale_factors[g][sfb]);
#endif
break;
case INTENSITY_HCB: /* intensity books */
case INTENSITY_HCB2:
@ -1651,6 +1720,9 @@ static uint8_t decode_scale_factors(ic_stream *ics, bitfile *ld)
t = huffman_scale_factor(ld);
is_position += (t - 60);
ics->scale_factors[g][sfb] = is_position;
#ifdef SF_PRINT
printf("%d\n", ics->scale_factors[g][sfb]);
#endif
break;
case NOISE_HCB: /* noise books */
@ -1667,6 +1739,9 @@ static uint8_t decode_scale_factors(ic_stream *ics, bitfile *ld)
}
noise_energy += t;
ics->scale_factors[g][sfb] = noise_energy;
#ifdef SF_PRINT
printf("%d\n", ics->scale_factors[g][sfb]);
#endif
break;
default: /* spectral books */
@ -1681,6 +1756,9 @@ static uint8_t decode_scale_factors(ic_stream *ics, bitfile *ld)
if (scale_factor < 0 || scale_factor > 255)
return 4;
ics->scale_factors[g][sfb] = scale_factor;
#ifdef SF_PRINT
printf("%d\n", ics->scale_factors[g][sfb]);
#endif
break;
}
@ -1691,7 +1769,7 @@ static uint8_t decode_scale_factors(ic_stream *ics, bitfile *ld)
}
/* Table 4.4.26 */
static uint8_t scale_factor_data(faacDecHandle hDecoder, ic_stream *ics, bitfile *ld)
static uint8_t scale_factor_data(NeAACDecHandle hDecoder, ic_stream *ics, bitfile *ld)
{
uint8_t ret = 0;
#ifdef PROFILE
@ -1740,6 +1818,9 @@ static void tns_data(ic_stream *ics, tns_info *tns, bitfile *ld)
{
tns->n_filt[w] = (uint8_t)faad_getbits(ld, n_filt_bits
DEBUGVAR(1,74,"tns_data(): n_filt"));
#if 0
printf("%d\n", tns->n_filt[w]);
#endif
if (tns->n_filt[w])
{
@ -1750,26 +1831,44 @@ static void tns_data(ic_stream *ics, tns_info *tns, bitfile *ld)
} else {
start_coef_bits = 3;
}
#if 0
printf("%d\n", tns->coef_res[w]);
#endif
}
for (filt = 0; filt < tns->n_filt[w]; filt++)
{
tns->length[w][filt] = (uint8_t)faad_getbits(ld, length_bits
DEBUGVAR(1,76,"tns_data(): length"));
#if 0
printf("%d\n", tns->length[w][filt]);
#endif
tns->order[w][filt] = (uint8_t)faad_getbits(ld, order_bits
DEBUGVAR(1,77,"tns_data(): order"));
#if 0
printf("%d\n", tns->order[w][filt]);
#endif
if (tns->order[w][filt])
{
tns->direction[w][filt] = faad_get1bit(ld
DEBUGVAR(1,78,"tns_data(): direction"));
#if 0
printf("%d\n", tns->direction[w][filt]);
#endif
tns->coef_compress[w][filt] = faad_get1bit(ld
DEBUGVAR(1,79,"tns_data(): coef_compress"));
#if 0
printf("%d\n", tns->coef_compress[w][filt]);
#endif
coef_bits = start_coef_bits - tns->coef_compress[w][filt];
for (i = 0; i < tns->order[w][filt]; i++)
{
tns->coef[w][filt][i] = (uint8_t)faad_getbits(ld, coef_bits
DEBUGVAR(1,80,"tns_data(): coef"));
#if 0
printf("%d\n", tns->coef[w][filt][i]);
#endif
}
}
}
@ -1778,7 +1877,7 @@ static void tns_data(ic_stream *ics, tns_info *tns, bitfile *ld)
#ifdef LTP_DEC
/* Table 4.4.28 */
static uint8_t ltp_data(faacDecHandle hDecoder, ic_stream *ics, ltp_info *ltp, bitfile *ld)
static uint8_t ltp_data(NeAACDecHandle hDecoder, ic_stream *ics, ltp_info *ltp, bitfile *ld)
{
uint8_t sfb, w;
@ -1841,7 +1940,7 @@ static uint8_t ltp_data(faacDecHandle hDecoder, ic_stream *ics, ltp_info *ltp, b
#endif
/* Table 4.4.29 */
static uint8_t spectral_data(faacDecHandle hDecoder, ic_stream *ics, bitfile *ld,
static uint8_t spectral_data(NeAACDecHandle hDecoder, ic_stream *ics, bitfile *ld,
int16_t *spectral_data)
{
int8_t i;
@ -1872,15 +1971,41 @@ static uint8_t spectral_data(faacDecHandle hDecoder, ic_stream *ics, bitfile *ld
case NOISE_HCB:
case INTENSITY_HCB:
case INTENSITY_HCB2:
//#define SD_PRINT
#ifdef SD_PRINT
{
int j;
for (j = ics->sect_sfb_offset[g][ics->sect_start[g][i]]; j < ics->sect_sfb_offset[g][ics->sect_end[g][i]]; j++)
{
printf("%d\n", 0);
}
}
#endif
//#define SFBO_PRINT
#ifdef SFBO_PRINT
printf("%d\n", ics->sect_sfb_offset[g][ics->sect_start[g][i]]);
#endif
p += (ics->sect_sfb_offset[g][ics->sect_end[g][i]] -
ics->sect_sfb_offset[g][ics->sect_start[g][i]]);
break;
default:
#ifdef SFBO_PRINT
printf("%d\n", ics->sect_sfb_offset[g][ics->sect_start[g][i]]);
#endif
for (k = ics->sect_sfb_offset[g][ics->sect_start[g][i]];
k < ics->sect_sfb_offset[g][ics->sect_end[g][i]]; k += inc)
{
if ((result = huffman_spectral_data(sect_cb, ld, &spectral_data[p])) > 0)
return result;
#ifdef SD_PRINT
{
int j;
for (j = p; j < p+inc; j++)
{
printf("%d\n", spectral_data[j]);
}
}
#endif
p += inc;
}
break;

View File

@ -23,7 +23,7 @@
** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
**
** Initially modified for use with MPlayer by Arpad Gereöffy on 2003/08/30
** $Id: syntax.h,v 1.3 2004/06/02 22:59:04 diego Exp $
** $Id: syntax.h,v 1.4 2004/06/23 13:50:53 diego Exp $
** detailed CVS changelog at http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
**/
@ -62,8 +62,8 @@ extern "C" {
#define DRMCH_MONO 1
#define DRMCH_STEREO 2
#define DRMCH_SBR_MONO 3
#define DRMCH_SBR_LC_STEREO 4
#define DRMCH_SBR_STEREO 5
#define DRMCH_SBR_STEREO 4
#define DRMCH_SBR_PS_STEREO 5
/* First object type that has ER */
@ -112,10 +112,12 @@ int8_t GASpecificConfig(bitfile *ld, mp4AudioSpecificConfig *mp4ASC,
uint8_t adts_frame(adts_header *adts, bitfile *ld);
void get_adif_header(adif_header *adif, bitfile *ld);
void raw_data_block(faacDecHandle hDecoder, faacDecFrameInfo *hInfo,
void raw_data_block(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo,
bitfile *ld, program_config *pce, drc_info *drc);
uint8_t reordered_spectral_data(faacDecHandle hDecoder, ic_stream *ics, bitfile *ld,
uint8_t reordered_spectral_data(NeAACDecHandle hDecoder, ic_stream *ics, bitfile *ld,
int16_t *spectral_data);
void aac_scalable_main_element(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo,
bitfile *ld, program_config *pce, drc_info *drc);
#ifdef __cplusplus

View File

@ -23,7 +23,7 @@
** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
**
** Initially modified for use with MPlayer by Arpad Gereöffy on 2003/08/30
** $Id: tns.c,v 1.3 2004/06/02 22:59:04 diego Exp $
** $Id: tns.c,v 1.4 2004/06/23 13:50:53 diego Exp $
** detailed CVS changelog at http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
**/
@ -241,24 +241,32 @@ static void tns_ar_filter(real_t *spectrum, uint16_t size, int8_t inc, real_t *l
uint8_t j;
uint16_t i;
real_t y, state[TNS_MAX_ORDER];
for (i = 0; i < order; i++)
state[i] = 0;
real_t y;
/* state is stored as a double ringbuffer */
real_t state[2*TNS_MAX_ORDER] = {0};
int8_t state_index = 0;
for (i = 0; i < size; i++)
{
y = *spectrum;
for (j = 0; j < order; j++)
y -= MUL_C(state[j], lpc[j+1]);
y -= MUL_C(state[state_index+j], lpc[j+1]);
for (j = order-1; j > 0; j--)
state[j] = state[j-1];
/* double ringbuffer state */
state_index--;
if (state_index < 0)
state_index = order-1;
state[state_index] = state[state_index + order] = y;
state[0] = y;
*spectrum = y;
spectrum += inc;
//#define TNS_PRINT
#ifdef TNS_PRINT
//printf("%d\n", y);
printf("0x%.8X\n", y);
#endif
}
}
@ -276,10 +284,10 @@ static void tns_ma_filter(real_t *spectrum, uint16_t size, int8_t inc, real_t *l
uint8_t j;
uint16_t i;
real_t y, state[TNS_MAX_ORDER];
for (i = 0; i < order; i++)
state[i] = REAL_CONST(0.0);
real_t y;
/* state is stored as a double ringbuffer */
real_t state[2*TNS_MAX_ORDER] = {0};
int8_t state_index = 0;
for (i = 0; i < size; i++)
{
@ -288,10 +296,12 @@ static void tns_ma_filter(real_t *spectrum, uint16_t size, int8_t inc, real_t *l
for (j = 0; j < order; j++)
y += MUL_C(state[j], lpc[j+1]);
for (j = order-1; j > 0; j--)
state[j] = state[j-1];
/* double ringbuffer state */
state_index--;
if (state_index < 0)
state_index = order-1;
state[state_index] = state[state_index + order] = *spectrum;
state[0] = *spectrum;
*spectrum = y;
spectrum += inc;
}