From 42774d3128b91d5a37344cb40d56d3c4d147e5f2 Mon Sep 17 00:00:00 2001 From: Dave Hooper Date: Wed, 17 Feb 2010 00:49:53 +0000 Subject: Merge from branches/mdctexp - faster ifft+imdct in codec lib git-svn-id: svn://svn.rockbox.org/rockbox/trunk@24712 a1c6a512-1295-4272-9138-f99709370657 --- apps/codecs/libwma/wmadec.h | 2 - apps/codecs/libwma/wmadeci.c | 22 ++------- apps/codecs/libwma/wmafixed.c | 110 ------------------------------------------ apps/codecs/libwma/wmafixed.h | 45 +++-------------- 4 files changed, 9 insertions(+), 170 deletions(-) (limited to 'apps/codecs/libwma') diff --git a/apps/codecs/libwma/wmadec.h b/apps/codecs/libwma/wmadec.h index a547ece157..4efaa9b8a2 100644 --- a/apps/codecs/libwma/wmadec.h +++ b/apps/codecs/libwma/wmadec.h @@ -23,8 +23,6 @@ #include "asf.h" #include "bitstream.h" /* For GetBitContext */ #include "types.h" -//#include "dsputil.h" /* For MDCTContext */ - //#define TRACE /* size of blocks */ diff --git a/apps/codecs/libwma/wmadeci.c b/apps/codecs/libwma/wmadeci.c index ae1a93ecf2..6ff6a176ee 100644 --- a/apps/codecs/libwma/wmadeci.c +++ b/apps/codecs/libwma/wmadeci.c @@ -452,17 +452,6 @@ int wma_decode_init(WMADecodeContext* s, asf_waveformatex_t *wfx) } } - /*Not using the ffmpeg IMDCT anymore*/ - - /* mdct_init_global(); - - for(i = 0; i < s->nb_block_sizes; ++i) - { - ff_mdct_init(&s->mdct_ctx[i], s->frame_len_bits - i + 1, 1); - - } - */ - /* ffmpeg uses malloc to only allocate as many window sizes as needed. * However, we're really only interested in the worst case memory usage. * In the worst case you can have 5 window sizes, 128 doubling up 2048 @@ -1253,14 +1242,9 @@ static int wma_decode_block(WMADecodeContext *s, int32_t *scratch_buffer) n4 = s->block_len >>1; - /*faster IMDCT from Vorbis*/ - mdct_backward( (1 << (s->block_len_bits+1)), (int32_t*)(*(s->coefs))[ch], (int32_t*)scratch_buffer); - - /*slower but more easily understood IMDCT from FFMPEG*/ - //ff_imdct_calc(&s->mdct_ctx[bsize], - // output, - // (*(s->coefs))[ch]); - + ff_imdct_calc( (s->frame_len_bits - bsize + 1), + (int32_t*)scratch_buffer, + (*(s->coefs))[ch]); /* add in the frame */ index = (s->frame_len / 2) + s->block_pos - n4; diff --git a/apps/codecs/libwma/wmafixed.c b/apps/codecs/libwma/wmafixed.c index 5569309145..1472ed081c 100644 --- a/apps/codecs/libwma/wmafixed.c +++ b/apps/codecs/libwma/wmafixed.c @@ -250,113 +250,3 @@ fixed64 fixdiv64(fixed64 x, fixed64 y) return (fixed32)(r << (PRECISION / 2)); } - - - -/* Inverse gain of circular cordic rotation in s0.31 format. */ -static const long cordic_circular_gain = 0xb2458939; /* 0.607252929 */ - -/* Table of values of atan(2^-i) in 0.32 format fractions of pi where pi = 0xffffffff / 2 */ -static const unsigned long atan_table[] = { - 0x1fffffff, /* +0.785398163 (or pi/4) */ - 0x12e4051d, /* +0.463647609 */ - 0x09fb385b, /* +0.244978663 */ - 0x051111d4, /* +0.124354995 */ - 0x028b0d43, /* +0.062418810 */ - 0x0145d7e1, /* +0.031239833 */ - 0x00a2f61e, /* +0.015623729 */ - 0x00517c55, /* +0.007812341 */ - 0x0028be53, /* +0.003906230 */ - 0x00145f2e, /* +0.001953123 */ - 0x000a2f98, /* +0.000976562 */ - 0x000517cc, /* +0.000488281 */ - 0x00028be6, /* +0.000244141 */ - 0x000145f3, /* +0.000122070 */ - 0x0000a2f9, /* +0.000061035 */ - 0x0000517c, /* +0.000030518 */ - 0x000028be, /* +0.000015259 */ - 0x0000145f, /* +0.000007629 */ - 0x00000a2f, /* +0.000003815 */ - 0x00000517, /* +0.000001907 */ - 0x0000028b, /* +0.000000954 */ - 0x00000145, /* +0.000000477 */ - 0x000000a2, /* +0.000000238 */ - 0x00000051, /* +0.000000119 */ - 0x00000028, /* +0.000000060 */ - 0x00000014, /* +0.000000030 */ - 0x0000000a, /* +0.000000015 */ - 0x00000005, /* +0.000000007 */ - 0x00000002, /* +0.000000004 */ - 0x00000001, /* +0.000000002 */ - 0x00000000, /* +0.000000001 */ - 0x00000000, /* +0.000000000 */ -}; - - -/* - - Below here functions do not use standard fixed precision! -*/ - - -/** - * Implements sin and cos using CORDIC rotation. - * - * @param phase has range from 0 to 0xffffffff, representing 0 and - * 2*pi respectively. - * @param cos return address for cos - * @return sin of phase, value is a signed value from LONG_MIN to LONG_MAX, - * representing -1 and 1 respectively. - * - * Gives at least 24 bits precision (last 2-8 bits or so are probably off) - */ -long fsincos(unsigned long phase, fixed32 *cos) -{ - int32_t x, x1, y, y1; - unsigned long z, z1; - int i; - - /* Setup initial vector */ - x = cordic_circular_gain; - y = 0; - z = phase; - - /* The phase has to be somewhere between 0..pi for this to work right */ - if (z < 0xffffffff / 4) { - /* z in first quadrant, z += pi/2 to correct */ - x = -x; - z += 0xffffffff / 4; - } else if (z < 3 * (0xffffffff / 4)) { - /* z in third quadrant, z -= pi/2 to correct */ - z -= 0xffffffff / 4; - } else { - /* z in fourth quadrant, z -= 3pi/2 to correct */ - x = -x; - z -= 3 * (0xffffffff / 4); - } - - /* Each iteration adds roughly 1-bit of extra precision */ - for (i = 0; i < 31; i++) { - x1 = x >> i; - y1 = y >> i; - z1 = atan_table[i]; - - /* Decided which direction to rotate vector. Pivot point is pi/2 */ - if (z >= 0xffffffff / 4) { - x -= y1; - y += x1; - z -= z1; - } else { - x += y1; - y -= x1; - z += z1; - } - } - - if (cos) - *cos = x; - - return y; -} - - diff --git a/apps/codecs/libwma/wmafixed.h b/apps/codecs/libwma/wmafixed.h index 6b5137e044..0ecdc5cfbc 100644 --- a/apps/codecs/libwma/wmafixed.h +++ b/apps/codecs/libwma/wmafixed.h @@ -52,10 +52,10 @@ fixed64 fixdiv64(fixed64 x, fixed64 y); fixed32 fixsqrt32(fixed32 x); long fsincos(unsigned long phase, fixed32 *cos); + #ifdef CPU_ARM /*Sign-15.16 format */ - #define fixmul32(x, y) \ ({ int32_t __hi; \ uint32_t __lo; \ @@ -70,18 +70,6 @@ long fsincos(unsigned long phase, fixed32 *cos); __result; \ }) -#define fixmul32b(x, y) \ - ({ int32_t __hi; \ - uint32_t __lo; \ - int32_t __result; \ - asm ("smull %0, %1, %3, %4\n\t" \ - "movs %2, %1, lsl #1" \ - : "=&r" (__lo), "=&r" (__hi), "=r" (__result) \ - : "%r" (x), "r" (y) \ - : "cc"); \ - __result; \ - }) - #elif defined(CPU_COLDFIRE) static inline int32_t fixmul32(int32_t x, int32_t y) @@ -91,9 +79,9 @@ static inline int32_t fixmul32(int32_t x, int32_t y) #endif int32_t t1; asm ( - "mac.l %[x], %[y], %%acc0 \n" /* multiply */ - "mulu.l %[y], %[x] \n" /* get lower half, avoid emac stall */ - "movclr.l %%acc0, %[t1] \n" /* get higher half */ + "mac.l %[x], %[y], %%acc0 \n" // multiply + "mulu.l %[y], %[x] \n" // get lower half, avoid emac stall + "movclr.l %%acc0, %[t1] \n" // get higher half "lsr.l #1, %[t1] \n" "move.w %[t1], %[x] \n" "swap %[x] \n" @@ -103,17 +91,6 @@ static inline int32_t fixmul32(int32_t x, int32_t y) return x; } -static inline int32_t fixmul32b(int32_t x, int32_t y) -{ - asm ( - "mac.l %[x], %[y], %%acc0 \n" /* multiply */ - "movclr.l %%acc0, %[x] \n" /* get higher half */ - : [x] "+d" (x) - : [y] "d" (y) - ); - return x; -} - #else static inline fixed32 fixmul32(fixed32 x, fixed32 y) @@ -127,17 +104,7 @@ static inline fixed32 fixmul32(fixed32 x, fixed32 y) return (fixed32)temp; } -static inline fixed32 fixmul32b(fixed32 x, fixed32 y) -{ - fixed64 temp; - - temp = x; - temp *= y; - - temp >>= 31; //16+31-16 = 31 bits - - return (fixed32)temp; -} - #endif + +/* get fixmul32b from codeclib */ -- cgit v1.2.3