# HG changeset patch # User glantau # Date 1021762688 0 # Node ID 4ef26ed293999208e725624e7301faa45e716e93 # Parent ddb1be8aa479490432d3efbca9c19c1f69e9758b put all integer init code to compute n^(4/3) - memory alloc and header fixes diff -r ddb1be8aa479 -r 4ef26ed29399 mpegaudiodec.c --- a/mpegaudiodec.c Sat May 18 22:56:50 2002 +0000 +++ b/mpegaudiodec.c Sat May 18 22:58:08 2002 +0000 @@ -18,7 +18,6 @@ */ //#define DEBUG #include "avcodec.h" -#include #include "mpegaudio.h" /* @@ -221,6 +220,72 @@ #endif } +/* all integer n^(4/3) computation code */ +#define DEV_ORDER 13 + +#define POW_FRAC_BITS 24 +#define POW_FRAC_ONE (1 << POW_FRAC_BITS) +#define POW_FIX(a) ((int)((a) * POW_FRAC_ONE)) +#define POW_MULL(a,b) (((INT64)(a) * (INT64)(b)) >> POW_FRAC_BITS) + +static int dev_4_3_coefs[DEV_ORDER]; + +static int pow_mult3[3] = { + POW_FIX(1.0), + POW_FIX(1.25992104989487316476), + POW_FIX(1.58740105196819947474), +}; + +static void int_pow_init(void) +{ + int i, a; + + a = POW_FIX(1.0); + for(i=0;i= 0; j--) + a1 = POW_MULL(a, dev_4_3_coefs[j] + a1); + a = (1 << POW_FRAC_BITS) + a1; + /* exponent compute (exact) */ + e = e * 4; + er = e % 3; + eq = e / 3; + a = POW_MULL(a, pow_mult3[er]); + while (a >= 2 * POW_FRAC_ONE) { + a = a >> 1; + eq++; + } + /* convert to float */ + while (a < POW_FRAC_ONE) { + a = a << 1; + eq--; + } + *exp_ptr = eq; +#if POW_FRAC_BITS == FRAC_BITS + return a; +#else + return (a + (1 << (POW_FRAC_BITS - FRAC_BITS - 1))) >> (POW_FRAC_BITS - FRAC_BITS); +#endif +} static int decode_init(AVCodecContext * avctx) { @@ -315,20 +380,37 @@ table_4_3_value = av_mallocz(TABLE_4_3_SIZE * sizeof(table_4_3_value[0])); if (!table_4_3_value) { - free(table_4_3_exp); + av_free(table_4_3_exp); return -1; } + int_pow_init(); for(i=1;i