diff options
author | diego <diego@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2004-09-24 17:31:36 +0000 |
---|---|---|
committer | diego <diego@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2004-09-24 17:31:36 +0000 |
commit | e1ece5e2eb68c81b1645c9ff989c833c4d67dfd8 (patch) | |
tree | 8553b3a4ef8164d14ff1b4a3f67e57cfa1d8908a | |
parent | 2887bacbdb6bd320e4840fd230e92a59cc74b9ae (diff) | |
download | mpv-e1ece5e2eb68c81b1645c9ff989c833c4d67dfd8.tar.bz2 mpv-e1ece5e2eb68c81b1645c9ff989c833c4d67dfd8.tar.xz |
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
52 files changed, 20272 insertions, 4607 deletions
diff --git a/libfaad2/Makefile b/libfaad2/Makefile index ad9716cd60..5dd17c2ec4 100644 --- a/libfaad2/Makefile +++ b/libfaad2/Makefile @@ -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) diff --git a/libfaad2/README b/libfaad2/README index 8d2778f96b..6a0ab72602 100644 --- a/libfaad2/README +++ b/libfaad2/README @@ -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 diff --git a/libfaad2/cfft.c b/libfaad2/cfft.c index 72d83d7167..06deb8a1c5 100644 --- a/libfaad2/cfft.c +++ b/libfaad2/cfft.c @@ -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 } diff --git a/libfaad2/common.c b/libfaad2/common.c index 1b91405a2a..d566a9f318 100644 --- a/libfaad2/common.c +++ b/libfaad2/common.c @@ -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 diff --git a/libfaad2/common.h b/libfaad2/common.h index 0d56a411b0..dd515bf2c8 100644 --- a/libfaad2/common.h +++ b/libfaad2/common.h @@ -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 diff --git a/libfaad2/decoder.c b/libfaad2/decoder.c index 7470128a76..c2d534ac0f 100644 --- a/libfaad2/decoder.c +++ b/libfaad2/decoder.c @@ -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; |