Vorbis opts: keep floor1 lookup table in IRAM.
Slightly faster 16-bit clipping function. Misc: changed tabs for spaces to conform with Rockbox coding standards. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6608 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
ead61c1d18
commit
0a3f8e0924
11 changed files with 863 additions and 835 deletions
|
@ -24,102 +24,118 @@
|
|||
#ifndef _V_WIDE_MATH
|
||||
#define _V_WIDE_MATH
|
||||
|
||||
//#define MB() asm volatile ("" : : : "memory")
|
||||
#define MB()
|
||||
|
||||
static inline void mcf5249_init_mac(void) {
|
||||
int r;
|
||||
asm volatile ("move.l #0x20, %%macsr;" // frac, truncate, no saturation
|
||||
"movclr.l %%acc0, %[r];" // clear accumulators
|
||||
"move.l %%acc0, %%acc1;"
|
||||
"move.l %%acc0, %%acc2;"
|
||||
"move.l %%acc0, %%acc3;"
|
||||
: [r] "=r" (r));
|
||||
asm volatile ("move.l #0x20, %%macsr;" /* frac, truncate, no saturation */
|
||||
"movclr.l %%acc0, %[r];" /* clear accumulators */
|
||||
"move.l %%acc0, %%acc1;"
|
||||
"move.l %%acc0, %%acc2;"
|
||||
"move.l %%acc0, %%acc3;"
|
||||
: [r] "=r" (r));
|
||||
}
|
||||
|
||||
static inline ogg_int32_t MULT32(ogg_int32_t x, ogg_int32_t y) {
|
||||
ogg_int32_t r;
|
||||
asm volatile ("mac.l %[x], %[y], %%acc0;" // multiply into acc
|
||||
"movclr.l %%acc0, %[r];" // move & clear acc
|
||||
"asr.l #1, %[r];" // no overflow test
|
||||
: [r] "=d" (r)
|
||||
: [x] "r" (x), [y] "r" (y)
|
||||
: "cc");
|
||||
return r;
|
||||
asm volatile ("mac.l %[x], %[y], %%acc0;" /* multiply & shift */
|
||||
"movclr.l %%acc0, %[x];" /* move & clear acc */
|
||||
"asr.l #1, %[x];" /* no overflow test */
|
||||
: [x] "+&d" (x)
|
||||
: [y] "r" (y)
|
||||
: "cc");
|
||||
return x;
|
||||
}
|
||||
|
||||
static inline ogg_int32_t MULT31(ogg_int32_t x, ogg_int32_t y) {
|
||||
asm volatile ("mac.l %[x], %[y], %%acc0;" // multiply
|
||||
"movclr.l %%acc0, %[x];" // move and clear
|
||||
: [x] "+&r" (x)
|
||||
: [y] "r" (y)
|
||||
: "cc");
|
||||
asm volatile ("mac.l %[x], %[y], %%acc0;" /* multiply */
|
||||
"movclr.l %%acc0, %[x];" /* move and clear */
|
||||
: [x] "+&r" (x)
|
||||
: [y] "r" (y)
|
||||
: "cc");
|
||||
return x;
|
||||
}
|
||||
|
||||
|
||||
static inline ogg_int32_t MULT31_SHIFT15(ogg_int32_t x, ogg_int32_t y) {
|
||||
ogg_int32_t r;
|
||||
asm volatile ("mac.l %[x], %[y], %%acc0;" // multiply
|
||||
"movclr.l %%acc0, %[r];" // get higher half
|
||||
"mulu.l %[y], %[x];" // get lower half
|
||||
"asl.l #8, %[r];" // hi << 17
|
||||
"asl.l #8, %[r];"
|
||||
"lsr.l #8, %[x];" // (unsigned)lo >> 15
|
||||
"lsr.l #7, %[x];"
|
||||
"or.l %[x], %[r];" // or
|
||||
: [r] "=&d" (r), [x] "+d" (x)
|
||||
: [y] "d" (y)
|
||||
: "cc");
|
||||
asm volatile ("mac.l %[x], %[y], %%acc0;" /* multiply */
|
||||
"movclr.l %%acc0, %[r];" /* get higher half */
|
||||
"mulu.l %[y], %[x];" /* get lower half */
|
||||
"asl.l #8, %[r];" /* hi<<16, plus one free */
|
||||
"asl.l #8, %[r];"
|
||||
"lsr.l #8, %[x];" /* (unsigned)lo >> 15 */
|
||||
"lsr.l #7, %[x];"
|
||||
"or.l %[x], %[r];" /* logical-or results */
|
||||
: [r] "=&d" (r), [x] "+d" (x)
|
||||
: [y] "d" (y)
|
||||
: "cc");
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
static inline
|
||||
void XPROD31(ogg_int32_t a, ogg_int32_t b,
|
||||
ogg_int32_t t, ogg_int32_t v,
|
||||
ogg_int32_t *x, ogg_int32_t *y)
|
||||
ogg_int32_t t, ogg_int32_t v,
|
||||
ogg_int32_t *x, ogg_int32_t *y)
|
||||
{
|
||||
asm volatile ("mac.l %[a], %[t], %%acc0;"
|
||||
"mac.l %[b], %[v], %%acc0;"
|
||||
"mac.l %[b], %[t], %%acc1;"
|
||||
"msac.l %[a], %[v], %%acc1;"
|
||||
"movclr.l %%acc0, %[a];"
|
||||
"move.l %[a], (%[x]);"
|
||||
"movclr.l %%acc1, %[a];"
|
||||
"move.l %[a], (%[y]);"
|
||||
: [a] "+&r" (a)
|
||||
: [x] "a" (x), [y] "a" (y),
|
||||
[b] "r" (b), [t] "r" (t), [v] "r" (v)
|
||||
: "cc", "memory");
|
||||
"mac.l %[b], %[v], %%acc0;"
|
||||
"mac.l %[b], %[t], %%acc1;"
|
||||
"msac.l %[a], %[v], %%acc1;"
|
||||
"movclr.l %%acc0, %[a];"
|
||||
"move.l %[a], (%[x]);"
|
||||
"movclr.l %%acc1, %[a];"
|
||||
"move.l %[a], (%[y]);"
|
||||
: [a] "+&r" (a)
|
||||
: [x] "a" (x), [y] "a" (y),
|
||||
[b] "r" (b), [t] "r" (t), [v] "r" (v)
|
||||
: "cc", "memory");
|
||||
}
|
||||
|
||||
|
||||
static inline
|
||||
void XNPROD31(ogg_int32_t a, ogg_int32_t b,
|
||||
ogg_int32_t t, ogg_int32_t v,
|
||||
ogg_int32_t *x, ogg_int32_t *y)
|
||||
ogg_int32_t t, ogg_int32_t v,
|
||||
ogg_int32_t *x, ogg_int32_t *y)
|
||||
{
|
||||
asm volatile ("mac.l %[a], %[t], %%acc0;"
|
||||
"msac.l %[b], %[v], %%acc0;"
|
||||
"mac.l %[b], %[t], %%acc1;"
|
||||
"mac.l %[a], %[v], %%acc1;"
|
||||
"movclr.l %%acc0, %[a];"
|
||||
"move.l %[a], (%[x]);"
|
||||
"movclr.l %%acc1, %[a];"
|
||||
"move.l %[a], (%[y]);"
|
||||
: [a] "+&r" (a)
|
||||
: [x] "a" (x), [y] "a" (y),
|
||||
[b] "r" (b), [t] "r" (t), [v] "r" (v)
|
||||
: "cc", "memory");
|
||||
"msac.l %[b], %[v], %%acc0;"
|
||||
"mac.l %[b], %[t], %%acc1;"
|
||||
"mac.l %[a], %[v], %%acc1;"
|
||||
"movclr.l %%acc0, %[a];"
|
||||
"move.l %[a], (%[x]);"
|
||||
"movclr.l %%acc1, %[a];"
|
||||
"move.l %[a], (%[y]);"
|
||||
: [a] "+&r" (a)
|
||||
: [x] "a" (x), [y] "a" (y),
|
||||
[b] "r" (b), [t] "r" (t), [v] "r" (v)
|
||||
: "cc", "memory");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* is there no better way of doing this using the MAC? */
|
||||
#define XPROD32(_a, _b, _t, _v, _x, _y) \
|
||||
{ (_x)=MULT32(_a,_t)+MULT32(_b,_v); \
|
||||
|
||||
#if 1 /* Canonical definition */
|
||||
#define XPROD32(_a, _b, _t, _v, _x, _y) \
|
||||
{ (_x)=MULT32(_a,_t)+MULT32(_b,_v); \
|
||||
(_y)=MULT32(_b,_t)-MULT32(_a,_v); }
|
||||
#else
|
||||
/* Thom Johansen suggestion; this could loose the lsb by overflow
|
||||
but does it matter in practice? */
|
||||
#define XPROD32(_a, _b, _t, _v, _x, _y) \
|
||||
asm volatile ("mac.l %[a], %[t], %%acc0;" \
|
||||
"mac.l %[b], %[v], %%acc0;" \
|
||||
"mac.l %[b], %[t], %%acc1;" \
|
||||
"msac.l %[a], %[v], %%acc1;" \
|
||||
"movclr.l %%acc0, %[x];" \
|
||||
"asr.l #1, %[x];" \
|
||||
"movclr.l %%acc1, %[y];" \
|
||||
"asr.l #1, %[y];" \
|
||||
: [x] "=&d" (_x), [y] "=&d" (_y) \
|
||||
: [a] "r" (_a), [b] "r" (_b), \
|
||||
[t] "r" (_t), [v] "r" (_v) \
|
||||
: "cc");
|
||||
#endif
|
||||
|
||||
|
||||
/* asm versions of vector multiplication for window.c */
|
||||
|
@ -127,94 +143,94 @@ void XNPROD31(ogg_int32_t a, ogg_int32_t b,
|
|||
static inline
|
||||
void mcf5249_vect_mult_fw(ogg_int32_t *data, LOOKUP_T *window, int n)
|
||||
{
|
||||
asm volatile ("movem.l (%[d]), %%d0-%%d3;" // loop start
|
||||
"movem.l (%[w]), %%a0-%%a3;" // pre-fetch registers
|
||||
"lea.l (4*4, %[w]), %[w];"
|
||||
"bra 1f;" // jump to loop condition
|
||||
"0:" // loop body
|
||||
// multiply and load next window values
|
||||
"mac.l %%d0, %%a0, (%[w])+, %%a0, %%acc0;"
|
||||
"mac.l %%d1, %%a1, (%[w])+, %%a1, %%acc1;"
|
||||
"mac.l %%d2, %%a2, (%[w])+, %%a2, %%acc2;"
|
||||
"mac.l %%d3, %%a3, (%[w])+, %%a3, %%acc3;"
|
||||
"movclr.l %%acc0, %%d0;" // get the products
|
||||
"movclr.l %%acc1, %%d1;"
|
||||
"movclr.l %%acc2, %%d2;"
|
||||
"movclr.l %%acc3, %%d3;"
|
||||
// store and advance
|
||||
"movem.l %%d0-%%d3, (%[d]);"
|
||||
"lea.l (4*4, %[d]), %[d];"
|
||||
"movem.l (%[d]), %%d0-%%d3;"
|
||||
"subq.l #4, %[n];" // done 4 elements
|
||||
"1: cmpi.l #4, %[n];"
|
||||
"bge 0b;"
|
||||
// multiply final elements
|
||||
"tst.l %[n];"
|
||||
"beq 1f;" // n=0
|
||||
"mac.l %%d0, %%a0, %%acc0;"
|
||||
"movclr.l %%acc0, %%d0;"
|
||||
"move.l %%d0, (%[d])+;"
|
||||
"subq.l #1, %[n];"
|
||||
"beq 1f;" // n=1
|
||||
"mac.l %%d1, %%a1, %%acc0;"
|
||||
"movclr.l %%acc0, %%d1;"
|
||||
"move.l %%d1, (%[d])+;"
|
||||
"subq.l #1, %[n];"
|
||||
"beq 1f;" // n=2
|
||||
// otherwise n = 3
|
||||
"mac.l %%d2, %%a2, %%acc0;"
|
||||
"movclr.l %%acc0, %%d2;"
|
||||
"move.l %%d2, (%[d])+;"
|
||||
"1:"
|
||||
: [n] "+d" (n), [d] "+a" (data), [w] "+a" (window)
|
||||
: : "%d0", "%d1", "%d2", "%d3", "%a0", "%a1", "%a2", "%a3",
|
||||
asm volatile ("movem.l (%[d]), %%d0-%%d3;" /* loop start */
|
||||
"movem.l (%[w]), %%a0-%%a3;" /* pre-fetch registers */
|
||||
"lea.l (4*4, %[w]), %[w];"
|
||||
"bra 1f;" /* jump to loop condition */
|
||||
"0:" /* loop body */
|
||||
/* multiply and load next window values */
|
||||
"mac.l %%d0, %%a0, (%[w])+, %%a0, %%acc0;"
|
||||
"mac.l %%d1, %%a1, (%[w])+, %%a1, %%acc1;"
|
||||
"mac.l %%d2, %%a2, (%[w])+, %%a2, %%acc2;"
|
||||
"mac.l %%d3, %%a3, (%[w])+, %%a3, %%acc3;"
|
||||
"movclr.l %%acc0, %%d0;" /* get the products */
|
||||
"movclr.l %%acc1, %%d1;"
|
||||
"movclr.l %%acc2, %%d2;"
|
||||
"movclr.l %%acc3, %%d3;"
|
||||
/* store and advance */
|
||||
"movem.l %%d0-%%d3, (%[d]);"
|
||||
"lea.l (4*4, %[d]), %[d];"
|
||||
"movem.l (%[d]), %%d0-%%d3;"
|
||||
"subq.l #4, %[n];" /* done 4 elements */
|
||||
"1: cmpi.l #4, %[n];"
|
||||
"bge 0b;"
|
||||
/* multiply final elements */
|
||||
"tst.l %[n];"
|
||||
"beq 1f;" /* n=0 */
|
||||
"mac.l %%d0, %%a0, %%acc0;"
|
||||
"movclr.l %%acc0, %%d0;"
|
||||
"move.l %%d0, (%[d])+;"
|
||||
"subq.l #1, %[n];"
|
||||
"beq 1f;" /* n=1 */
|
||||
"mac.l %%d1, %%a1, %%acc0;"
|
||||
"movclr.l %%acc0, %%d1;"
|
||||
"move.l %%d1, (%[d])+;"
|
||||
"subq.l #1, %[n];"
|
||||
"beq 1f;" /* n=2 */
|
||||
/* otherwise n = 3 */
|
||||
"mac.l %%d2, %%a2, %%acc0;"
|
||||
"movclr.l %%acc0, %%d2;"
|
||||
"move.l %%d2, (%[d])+;"
|
||||
"1:"
|
||||
: [n] "+d" (n), [d] "+a" (data), [w] "+a" (window)
|
||||
: : "%d0", "%d1", "%d2", "%d3", "%a0", "%a1", "%a2", "%a3",
|
||||
"cc", "memory");
|
||||
}
|
||||
|
||||
static inline
|
||||
void mcf5249_vect_mult_bw(ogg_int32_t *data, LOOKUP_T *window, int n)
|
||||
{
|
||||
asm volatile ("lea.l (-3*4, %[w]), %[w];" // loop start
|
||||
"movem.l (%[d]), %%d0-%%d3;" // pre-fetch registers
|
||||
"movem.l (%[w]), %%a0-%%a3;"
|
||||
"bra 1f;" // jump to loop condition
|
||||
"0:" // loop body
|
||||
// multiply and load next window value
|
||||
"mac.l %%d0, %%a3, -(%[w]), %%a3, %%acc0;"
|
||||
"mac.l %%d1, %%a2, -(%[w]), %%a2, %%acc1;"
|
||||
"mac.l %%d2, %%a1, -(%[w]), %%a1, %%acc2;"
|
||||
"mac.l %%d3, %%a0, -(%[w]), %%a0, %%acc3;"
|
||||
"movclr.l %%acc0, %%d0;" // get the products
|
||||
"movclr.l %%acc1, %%d1;"
|
||||
"movclr.l %%acc2, %%d2;"
|
||||
"movclr.l %%acc3, %%d3;"
|
||||
// store and advance
|
||||
"movem.l %%d0-%%d3, (%[d]);"
|
||||
"lea.l (4*4, %[d]), %[d];"
|
||||
"movem.l (%[d]), %%d0-%%d3;"
|
||||
"subq.l #4, %[n];" // done 4 elements
|
||||
"1: cmpi.l #4, %[n];"
|
||||
"bge 0b;"
|
||||
// multiply final elements
|
||||
"tst.l %[n];"
|
||||
"beq 1f;" // n=0
|
||||
"mac.l %%d0, %%a3, %%acc0;"
|
||||
"movclr.l %%acc0, %%d0;"
|
||||
"move.l %%d0, (%[d])+;"
|
||||
"subq.l #1, %[n];"
|
||||
"beq 1f;" // n=1
|
||||
"mac.l %%d1, %%a2, %%acc0;"
|
||||
"movclr.l %%acc0, %%d1;"
|
||||
"move.l %%d1, (%[d])+;"
|
||||
"subq.l #1, %[n];"
|
||||
"beq 1f;" // n=2
|
||||
// otherwise n = 3
|
||||
"mac.l %%d2, %%a1, %%acc0;"
|
||||
"movclr.l %%acc0, %%d2;"
|
||||
"move.l %%d2, (%[d])+;"
|
||||
"1:"
|
||||
: [n] "+d" (n), [d] "+a" (data), [w] "+a" (window)
|
||||
: : "%d0", "%d1", "%d2", "%d3", "%a0", "%a1", "%a2", "%a3",
|
||||
asm volatile ("lea.l (-3*4, %[w]), %[w];" /* loop start */
|
||||
"movem.l (%[d]), %%d0-%%d3;" /* pre-fetch registers */
|
||||
"movem.l (%[w]), %%a0-%%a3;"
|
||||
"bra 1f;" /* jump to loop condition */
|
||||
"0:" /* loop body */
|
||||
/* multiply and load next window value */
|
||||
"mac.l %%d0, %%a3, -(%[w]), %%a3, %%acc0;"
|
||||
"mac.l %%d1, %%a2, -(%[w]), %%a2, %%acc1;"
|
||||
"mac.l %%d2, %%a1, -(%[w]), %%a1, %%acc2;"
|
||||
"mac.l %%d3, %%a0, -(%[w]), %%a0, %%acc3;"
|
||||
"movclr.l %%acc0, %%d0;" /* get the products */
|
||||
"movclr.l %%acc1, %%d1;"
|
||||
"movclr.l %%acc2, %%d2;"
|
||||
"movclr.l %%acc3, %%d3;"
|
||||
/* store and advance */
|
||||
"movem.l %%d0-%%d3, (%[d]);"
|
||||
"lea.l (4*4, %[d]), %[d];"
|
||||
"movem.l (%[d]), %%d0-%%d3;"
|
||||
"subq.l #4, %[n];" /* done 4 elements */
|
||||
"1: cmpi.l #4, %[n];"
|
||||
"bge 0b;"
|
||||
/* multiply final elements */
|
||||
"tst.l %[n];"
|
||||
"beq 1f;" /* n=0 */
|
||||
"mac.l %%d0, %%a3, %%acc0;"
|
||||
"movclr.l %%acc0, %%d0;"
|
||||
"move.l %%d0, (%[d])+;"
|
||||
"subq.l #1, %[n];"
|
||||
"beq 1f;" /* n=1 */
|
||||
"mac.l %%d1, %%a2, %%acc0;"
|
||||
"movclr.l %%acc0, %%d1;"
|
||||
"move.l %%d1, (%[d])+;"
|
||||
"subq.l #1, %[n];"
|
||||
"beq 1f;" /* n=2 */
|
||||
/* otherwise n = 3 */
|
||||
"mac.l %%d2, %%a1, %%acc0;"
|
||||
"movclr.l %%acc0, %%d2;"
|
||||
"move.l %%d2, (%[d])+;"
|
||||
"1:"
|
||||
: [n] "+d" (n), [d] "+a" (data), [w] "+a" (window)
|
||||
: : "%d0", "%d1", "%d2", "%d3", "%a0", "%a1", "%a2", "%a3",
|
||||
"cc", "memory");
|
||||
}
|
||||
|
||||
|
@ -223,33 +239,43 @@ static inline
|
|||
void mcf5249_vect_zero(ogg_int32_t *ptr, int n)
|
||||
{
|
||||
asm volatile ("clr.l %%d0;"
|
||||
"clr.l %%d1;"
|
||||
"clr.l %%d2;"
|
||||
"clr.l %%d3;"
|
||||
// loop start
|
||||
"tst.l %[n];"
|
||||
"bra 1f;"
|
||||
"0: movem.l %%d0-%%d3, (%[ptr]);"
|
||||
"lea (4*4, %[ptr]), %[ptr];"
|
||||
"subq.l #4, %[n];"
|
||||
"1: bgt 0b;"
|
||||
// remaing elements
|
||||
"tst.l %[n];"
|
||||
"beq 1f;" // n=0
|
||||
"clr.l (%[ptr])+;"
|
||||
"subq.l #1, %[n];"
|
||||
"beq 1f;" // n=1
|
||||
"clr.l (%[ptr])+;"
|
||||
"subq.l #1, %[n];"
|
||||
"beq 1f;" // n=2
|
||||
// otherwise n = 3
|
||||
"clr.l (%[ptr])+;"
|
||||
"1:"
|
||||
: [n] "+d" (n), [ptr] "+a" (ptr)
|
||||
:
|
||||
: "%d0","%d1","%d2","%d3","cc","memory");
|
||||
"clr.l %%d1;"
|
||||
"clr.l %%d2;"
|
||||
"clr.l %%d3;"
|
||||
/* loop start */
|
||||
"tst.l %[n];"
|
||||
"bra 1f;"
|
||||
"0: movem.l %%d0-%%d3, (%[ptr]);"
|
||||
"lea (4*4, %[ptr]), %[ptr];"
|
||||
"subq.l #4, %[n];"
|
||||
"1: bgt 0b;"
|
||||
/* remaing elements */
|
||||
"tst.l %[n];"
|
||||
"beq 1f;" /* n=0 */
|
||||
"clr.l (%[ptr])+;"
|
||||
"subq.l #1, %[n];"
|
||||
"beq 1f;" /* n=1 */
|
||||
"clr.l (%[ptr])+;"
|
||||
"subq.l #1, %[n];"
|
||||
"beq 1f;" /* n=2 */
|
||||
/* otherwise n = 3 */
|
||||
"clr.l (%[ptr])+;"
|
||||
"1:"
|
||||
: [n] "+d" (n), [ptr] "+a" (ptr)
|
||||
:
|
||||
: "%d0","%d1","%d2","%d3","cc","memory");
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef _V_CLIP_MATH
|
||||
#define _V_CLIP_MATH
|
||||
|
||||
/* this is portable C and simple; why not use this as default? */
|
||||
static inline ogg_int32_t CLIP_TO_15(register ogg_int32_t x) {
|
||||
register ogg_int32_t hi=32767, lo=-32768;
|
||||
return (x>=hi ? hi : (x<=lo ? lo : x));
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -91,7 +91,7 @@ static vorbis_info_floor *floor1_unpack (vorbis_info *vi,oggpack_buffer *opb){
|
|||
for(k=0;k<(1<<info->class_subs[j]);k++){
|
||||
info->class_subbook[j][k]=oggpack_read(opb,8)-1;
|
||||
if(info->class_subbook[j][k]<-1 || info->class_subbook[j][k]>=ci->books)
|
||||
goto err_out;
|
||||
goto err_out;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -104,7 +104,7 @@ static vorbis_info_floor *floor1_unpack (vorbis_info *vi,oggpack_buffer *opb){
|
|||
for(;k<count;k++){
|
||||
int t=info->postlist[k+2]=oggpack_read(opb,rangebits);
|
||||
if(t<0 || t>=(1<<rangebits))
|
||||
goto err_out;
|
||||
goto err_out;
|
||||
}
|
||||
}
|
||||
info->postlist[0]=0;
|
||||
|
@ -179,12 +179,12 @@ static vorbis_look_floor *floor1_look(vorbis_dsp_state *vd,vorbis_info_mode *mi,
|
|||
for(j=0;j<i+2;j++){
|
||||
int x=info->postlist[j];
|
||||
if(x>lx && x<currentx){
|
||||
lo=j;
|
||||
lx=x;
|
||||
lo=j;
|
||||
lx=x;
|
||||
}
|
||||
if(x<hx && x>currentx){
|
||||
hi=j;
|
||||
hx=x;
|
||||
hi=j;
|
||||
hx=x;
|
||||
}
|
||||
}
|
||||
look->loneighbor[i]=lo;
|
||||
|
@ -216,7 +216,8 @@ static int render_point(int x0,int x1,int y0,int y1,int x){
|
|||
# define XdB(n) (n)
|
||||
#endif
|
||||
|
||||
static ogg_int32_t FLOOR_fromdB_LOOKUP[256] ={
|
||||
/* keep the floor lookup table in fast IRAM */
|
||||
static ogg_int32_t FLOOR_fromdB_LOOKUP[256] IDATA_ATTR = {
|
||||
XdB(0x000000e5), XdB(0x000000f4), XdB(0x00000103), XdB(0x00000114),
|
||||
XdB(0x00000126), XdB(0x00000139), XdB(0x0000014e), XdB(0x00000163),
|
||||
XdB(0x0000017a), XdB(0x00000193), XdB(0x000001ad), XdB(0x000001c9),
|
||||
|
@ -334,20 +335,20 @@ static void *floor1_inverse1(vorbis_block *vb,vorbis_look_floor *in){
|
|||
|
||||
/* decode the partition's first stage cascade value */
|
||||
if(csubbits){
|
||||
cval=vorbis_book_decode(books+info->class_book[classv],&vb->opb);
|
||||
cval=vorbis_book_decode(books+info->class_book[classv],&vb->opb);
|
||||
|
||||
if(cval==-1)goto eop;
|
||||
if(cval==-1)goto eop;
|
||||
}
|
||||
|
||||
for(k=0;k<cdim;k++){
|
||||
int book=info->class_subbook[classv][cval&(csub-1)];
|
||||
cval>>=csubbits;
|
||||
if(book>=0){
|
||||
if((fit_value[j+k]=vorbis_book_decode(books+book,&vb->opb))==-1)
|
||||
goto eop;
|
||||
}else{
|
||||
fit_value[j+k]=0;
|
||||
}
|
||||
int book=info->class_subbook[classv][cval&(csub-1)];
|
||||
cval>>=csubbits;
|
||||
if(book>=0){
|
||||
if((fit_value[j+k]=vorbis_book_decode(books+book,&vb->opb))==-1)
|
||||
goto eop;
|
||||
}else{
|
||||
fit_value[j+k]=0;
|
||||
}
|
||||
}
|
||||
j+=cdim;
|
||||
}
|
||||
|
@ -355,38 +356,38 @@ static void *floor1_inverse1(vorbis_block *vb,vorbis_look_floor *in){
|
|||
/* unwrap positive values and reconsitute via linear interpolation */
|
||||
for(i=2;i<look->posts;i++){
|
||||
int predicted=render_point(info->postlist[look->loneighbor[i-2]],
|
||||
info->postlist[look->hineighbor[i-2]],
|
||||
fit_value[look->loneighbor[i-2]],
|
||||
fit_value[look->hineighbor[i-2]],
|
||||
info->postlist[i]);
|
||||
info->postlist[look->hineighbor[i-2]],
|
||||
fit_value[look->loneighbor[i-2]],
|
||||
fit_value[look->hineighbor[i-2]],
|
||||
info->postlist[i]);
|
||||
int hiroom=look->quant_q-predicted;
|
||||
int loroom=predicted;
|
||||
int room=(hiroom<loroom?hiroom:loroom)<<1;
|
||||
int val=fit_value[i];
|
||||
|
||||
if(val){
|
||||
if(val>=room){
|
||||
if(hiroom>loroom){
|
||||
val = val-loroom;
|
||||
}else{
|
||||
val = -1-(val-hiroom);
|
||||
}
|
||||
}else{
|
||||
if(val&1){
|
||||
val= -((val+1)>>1);
|
||||
}else{
|
||||
val>>=1;
|
||||
}
|
||||
}
|
||||
if(val>=room){
|
||||
if(hiroom>loroom){
|
||||
val = val-loroom;
|
||||
}else{
|
||||
val = -1-(val-hiroom);
|
||||
}
|
||||
}else{
|
||||
if(val&1){
|
||||
val= -((val+1)>>1);
|
||||
}else{
|
||||
val>>=1;
|
||||
}
|
||||
}
|
||||
|
||||
fit_value[i]=val+predicted;
|
||||
fit_value[look->loneighbor[i-2]]&=0x7fff;
|
||||
fit_value[look->hineighbor[i-2]]&=0x7fff;
|
||||
fit_value[i]=val+predicted;
|
||||
fit_value[look->loneighbor[i-2]]&=0x7fff;
|
||||
fit_value[look->hineighbor[i-2]]&=0x7fff;
|
||||
|
||||
}else{
|
||||
fit_value[i]=predicted|0x8000;
|
||||
fit_value[i]=predicted|0x8000;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
return(fit_value);
|
||||
|
@ -396,7 +397,7 @@ static void *floor1_inverse1(vorbis_block *vb,vorbis_look_floor *in){
|
|||
}
|
||||
|
||||
static int floor1_inverse2(vorbis_block *vb,vorbis_look_floor *in,void *memo,
|
||||
ogg_int32_t *out){
|
||||
ogg_int32_t *out){
|
||||
vorbis_look_floor1 *look=(vorbis_look_floor1 *)in;
|
||||
vorbis_info_floor1 *info=look->vi;
|
||||
|
||||
|
@ -414,14 +415,14 @@ static int floor1_inverse2(vorbis_block *vb,vorbis_look_floor *in,void *memo,
|
|||
int current=look->forward_index[j];
|
||||
int hy=fit_value[current]&0x7fff;
|
||||
if(hy==fit_value[current]){
|
||||
|
||||
hy*=info->mult;
|
||||
hx=info->postlist[current];
|
||||
|
||||
render_line(lx,hx,ly,hy,out);
|
||||
|
||||
lx=hx;
|
||||
ly=hy;
|
||||
|
||||
hy*=info->mult;
|
||||
hx=info->postlist[current];
|
||||
|
||||
render_line(lx,hx,ly,hy,out);
|
||||
|
||||
lx=hx;
|
||||
ly=hy;
|
||||
}
|
||||
}
|
||||
for(j=hx;j<n;j++)out[j]*=ly; /* be certain */
|
||||
|
|
|
@ -52,7 +52,7 @@ typedef struct {
|
|||
|
||||
int ch;
|
||||
long lastframe; /* if a different mode is called, we need to
|
||||
invalidate decay */
|
||||
invalidate decay */
|
||||
} vorbis_look_mapping0;
|
||||
|
||||
static void mapping0_free_info(vorbis_info_mapping *i){
|
||||
|
@ -83,7 +83,7 @@ static void mapping0_free_look(vorbis_look_mapping *look){
|
|||
}
|
||||
|
||||
static vorbis_look_mapping *mapping0_look(vorbis_dsp_state *vd,vorbis_info_mode *vm,
|
||||
vorbis_info_mapping *m){
|
||||
vorbis_info_mapping *m){
|
||||
int i;
|
||||
vorbis_info *vi=vd->vi;
|
||||
codec_setup_info *ci=(codec_setup_info *)vi->codec_setup;
|
||||
|
@ -147,10 +147,10 @@ static vorbis_info_mapping *mapping0_unpack(vorbis_info *vi,oggpack_buffer *opb)
|
|||
int testA=info->coupling_ang[i]=oggpack_read(opb,ilog(vi->channels));
|
||||
|
||||
if(testM<0 ||
|
||||
testA<0 ||
|
||||
testM==testA ||
|
||||
testM>=vi->channels ||
|
||||
testA>=vi->channels) goto err_out;
|
||||
testA<0 ||
|
||||
testM==testA ||
|
||||
testM>=vi->channels ||
|
||||
testA>=vi->channels) goto err_out;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -237,16 +237,16 @@ static int mapping0_inverse(vorbis_block *vb,vorbis_look_mapping *l){
|
|||
int ch_in_bundle=0;
|
||||
for(j=0;j<vi->channels;j++){
|
||||
if(info->chmuxlist[j]==i){
|
||||
if(nonzero[j])
|
||||
zerobundle[ch_in_bundle]=1;
|
||||
else
|
||||
zerobundle[ch_in_bundle]=0;
|
||||
pcmbundle[ch_in_bundle++]=vb->pcm[j];
|
||||
if(nonzero[j])
|
||||
zerobundle[ch_in_bundle]=1;
|
||||
else
|
||||
zerobundle[ch_in_bundle]=0;
|
||||
pcmbundle[ch_in_bundle++]=vb->pcm[j];
|
||||
}
|
||||
}
|
||||
|
||||
look->residue_func[i]->inverse(vb,look->residue_look[i],
|
||||
pcmbundle,zerobundle,ch_in_bundle);
|
||||
pcmbundle,zerobundle,ch_in_bundle);
|
||||
}
|
||||
|
||||
//for(j=0;j<vi->channels;j++)
|
||||
|
@ -263,21 +263,21 @@ static int mapping0_inverse(vorbis_block *vb,vorbis_look_mapping *l){
|
|||
ogg_int32_t ang=pcmA[j];
|
||||
|
||||
if(mag>0)
|
||||
if(ang>0){
|
||||
pcmM[j]=mag;
|
||||
pcmA[j]=mag-ang;
|
||||
}else{
|
||||
pcmA[j]=mag;
|
||||
pcmM[j]=mag+ang;
|
||||
}
|
||||
if(ang>0){
|
||||
pcmM[j]=mag;
|
||||
pcmA[j]=mag-ang;
|
||||
}else{
|
||||
pcmA[j]=mag;
|
||||
pcmM[j]=mag+ang;
|
||||
}
|
||||
else
|
||||
if(ang>0){
|
||||
pcmM[j]=mag;
|
||||
pcmA[j]=mag+ang;
|
||||
}else{
|
||||
pcmA[j]=mag;
|
||||
pcmM[j]=mag-ang;
|
||||
}
|
||||
if(ang>0){
|
||||
pcmM[j]=mag;
|
||||
pcmA[j]=mag+ang;
|
||||
}else{
|
||||
pcmA[j]=mag;
|
||||
pcmM[j]=mag-ang;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -303,13 +303,13 @@ static int mapping0_inverse(vorbis_block *vb,vorbis_look_mapping *l){
|
|||
ogg_int32_t *pcm=vb->pcm[i];
|
||||
|
||||
if(nonzero[i]) {
|
||||
mdct_backward(n, pcm, pcm);
|
||||
/* window the data */
|
||||
_vorbis_apply_window(pcm,b->window,ci->blocksizes,vb->lW,vb->W,vb->nW);
|
||||
mdct_backward(n, pcm, pcm);
|
||||
/* window the data */
|
||||
_vorbis_apply_window(pcm,b->window,ci->blocksizes,vb->lW,vb->W,vb->nW);
|
||||
}
|
||||
else
|
||||
memset(pcm, 0, sizeof(ogg_int32_t)*n);
|
||||
}
|
||||
memset(pcm, 0, sizeof(ogg_int32_t)*n);
|
||||
}
|
||||
|
||||
//for(j=0;j<vi->channels;j++)
|
||||
//_analysis_output("imdct",seq+j,vb->pcm[j],-24,n,0,0);
|
||||
|
|
|
@ -50,15 +50,15 @@ STIN void mdct_butterfly_8(DATA_TYPE *x){
|
|||
REG_TYPE r6 = x[7] + x[3];
|
||||
REG_TYPE r7 = x[7] - x[3];
|
||||
|
||||
x[0] = r5 + r3;
|
||||
x[1] = r7 - r1;
|
||||
x[2] = r5 - r3;
|
||||
x[3] = r7 + r1;
|
||||
x[0] = r5 + r3;
|
||||
x[1] = r7 - r1;
|
||||
x[2] = r5 - r3;
|
||||
x[3] = r7 + r1;
|
||||
x[4] = r4 - r0;
|
||||
x[5] = r6 - r2;
|
||||
x[5] = r6 - r2;
|
||||
x[6] = r4 + r0;
|
||||
x[7] = r6 + r2;
|
||||
MB();
|
||||
x[7] = r6 + r2;
|
||||
MB();
|
||||
}
|
||||
|
||||
/* 16 point butterfly (in place, 4 register) */
|
||||
|
@ -66,30 +66,30 @@ STIN void mdct_butterfly_16(DATA_TYPE *x){
|
|||
|
||||
REG_TYPE r0, r1;
|
||||
|
||||
r0 = x[ 0] - x[ 8]; x[ 8] += x[ 0];
|
||||
r1 = x[ 1] - x[ 9]; x[ 9] += x[ 1];
|
||||
x[ 0] = MULT31((r0 + r1) , cPI2_8);
|
||||
x[ 1] = MULT31((r1 - r0) , cPI2_8);
|
||||
MB();
|
||||
r0 = x[ 0] - x[ 8]; x[ 8] += x[ 0];
|
||||
r1 = x[ 1] - x[ 9]; x[ 9] += x[ 1];
|
||||
x[ 0] = MULT31((r0 + r1) , cPI2_8);
|
||||
x[ 1] = MULT31((r1 - r0) , cPI2_8);
|
||||
MB();
|
||||
|
||||
r0 = x[10] - x[ 2]; x[10] += x[ 2];
|
||||
r1 = x[ 3] - x[11]; x[11] += x[ 3];
|
||||
x[ 2] = r1; x[ 3] = r0;
|
||||
MB();
|
||||
r0 = x[10] - x[ 2]; x[10] += x[ 2];
|
||||
r1 = x[ 3] - x[11]; x[11] += x[ 3];
|
||||
x[ 2] = r1; x[ 3] = r0;
|
||||
MB();
|
||||
|
||||
r0 = x[12] - x[ 4]; x[12] += x[ 4];
|
||||
r1 = x[13] - x[ 5]; x[13] += x[ 5];
|
||||
x[ 4] = MULT31((r0 - r1) , cPI2_8);
|
||||
x[ 5] = MULT31((r0 + r1) , cPI2_8);
|
||||
MB();
|
||||
r0 = x[12] - x[ 4]; x[12] += x[ 4];
|
||||
r1 = x[13] - x[ 5]; x[13] += x[ 5];
|
||||
x[ 4] = MULT31((r0 - r1) , cPI2_8);
|
||||
x[ 5] = MULT31((r0 + r1) , cPI2_8);
|
||||
MB();
|
||||
|
||||
r0 = x[14] - x[ 6]; x[14] += x[ 6];
|
||||
r1 = x[15] - x[ 7]; x[15] += x[ 7];
|
||||
x[ 6] = r0; x[ 7] = r1;
|
||||
MB();
|
||||
r0 = x[14] - x[ 6]; x[14] += x[ 6];
|
||||
r1 = x[15] - x[ 7]; x[15] += x[ 7];
|
||||
x[ 6] = r0; x[ 7] = r1;
|
||||
MB();
|
||||
|
||||
mdct_butterfly_8(x);
|
||||
mdct_butterfly_8(x+8);
|
||||
mdct_butterfly_8(x);
|
||||
mdct_butterfly_8(x+8);
|
||||
}
|
||||
|
||||
/* 32 point butterfly (in place, 4 register) */
|
||||
|
@ -97,50 +97,50 @@ STIN void mdct_butterfly_32(DATA_TYPE *x){
|
|||
|
||||
REG_TYPE r0, r1;
|
||||
|
||||
r0 = x[30] - x[14]; x[30] += x[14];
|
||||
r1 = x[31] - x[15]; x[31] += x[15];
|
||||
x[14] = r0; x[15] = r1;
|
||||
MB();
|
||||
r0 = x[30] - x[14]; x[30] += x[14];
|
||||
r1 = x[31] - x[15]; x[31] += x[15];
|
||||
x[14] = r0; x[15] = r1;
|
||||
MB();
|
||||
|
||||
r0 = x[28] - x[12]; x[28] += x[12];
|
||||
r1 = x[29] - x[13]; x[29] += x[13];
|
||||
XNPROD31( r0, r1, cPI1_8, cPI3_8, &x[12], &x[13] );
|
||||
MB();
|
||||
r0 = x[28] - x[12]; x[28] += x[12];
|
||||
r1 = x[29] - x[13]; x[29] += x[13];
|
||||
XNPROD31( r0, r1, cPI1_8, cPI3_8, &x[12], &x[13] );
|
||||
MB();
|
||||
|
||||
r0 = x[26] - x[10]; x[26] += x[10];
|
||||
r1 = x[27] - x[11]; x[27] += x[11];
|
||||
x[10] = MULT31((r0 - r1) , cPI2_8);
|
||||
x[11] = MULT31((r0 + r1) , cPI2_8);
|
||||
MB();
|
||||
r0 = x[26] - x[10]; x[26] += x[10];
|
||||
r1 = x[27] - x[11]; x[27] += x[11];
|
||||
x[10] = MULT31((r0 - r1) , cPI2_8);
|
||||
x[11] = MULT31((r0 + r1) , cPI2_8);
|
||||
MB();
|
||||
|
||||
r0 = x[24] - x[ 8]; x[24] += x[ 8];
|
||||
r1 = x[25] - x[ 9]; x[25] += x[ 9];
|
||||
XNPROD31( r0, r1, cPI3_8, cPI1_8, &x[ 8], &x[ 9] );
|
||||
MB();
|
||||
r0 = x[24] - x[ 8]; x[24] += x[ 8];
|
||||
r1 = x[25] - x[ 9]; x[25] += x[ 9];
|
||||
XNPROD31( r0, r1, cPI3_8, cPI1_8, &x[ 8], &x[ 9] );
|
||||
MB();
|
||||
|
||||
r0 = x[22] - x[ 6]; x[22] += x[ 6];
|
||||
r1 = x[ 7] - x[23]; x[23] += x[ 7];
|
||||
x[ 6] = r1; x[ 7] = r0;
|
||||
MB();
|
||||
r0 = x[22] - x[ 6]; x[22] += x[ 6];
|
||||
r1 = x[ 7] - x[23]; x[23] += x[ 7];
|
||||
x[ 6] = r1; x[ 7] = r0;
|
||||
MB();
|
||||
|
||||
r0 = x[ 4] - x[20]; x[20] += x[ 4];
|
||||
r1 = x[ 5] - x[21]; x[21] += x[ 5];
|
||||
XPROD31 ( r0, r1, cPI3_8, cPI1_8, &x[ 4], &x[ 5] );
|
||||
MB();
|
||||
r0 = x[ 4] - x[20]; x[20] += x[ 4];
|
||||
r1 = x[ 5] - x[21]; x[21] += x[ 5];
|
||||
XPROD31 ( r0, r1, cPI3_8, cPI1_8, &x[ 4], &x[ 5] );
|
||||
MB();
|
||||
|
||||
r0 = x[ 2] - x[18]; x[18] += x[ 2];
|
||||
r1 = x[ 3] - x[19]; x[19] += x[ 3];
|
||||
x[ 2] = MULT31((r1 + r0) , cPI2_8);
|
||||
x[ 3] = MULT31((r1 - r0) , cPI2_8);
|
||||
MB();
|
||||
r0 = x[ 2] - x[18]; x[18] += x[ 2];
|
||||
r1 = x[ 3] - x[19]; x[19] += x[ 3];
|
||||
x[ 2] = MULT31((r1 + r0) , cPI2_8);
|
||||
x[ 3] = MULT31((r1 - r0) , cPI2_8);
|
||||
MB();
|
||||
|
||||
r0 = x[ 0] - x[16]; x[16] += x[ 0];
|
||||
r1 = x[ 1] - x[17]; x[17] += x[ 1];
|
||||
XPROD31 ( r0, r1, cPI1_8, cPI3_8, &x[ 0], &x[ 1] );
|
||||
MB();
|
||||
r0 = x[ 0] - x[16]; x[16] += x[ 0];
|
||||
r1 = x[ 1] - x[17]; x[17] += x[ 1];
|
||||
XPROD31 ( r0, r1, cPI1_8, cPI3_8, &x[ 0], &x[ 1] );
|
||||
MB();
|
||||
|
||||
mdct_butterfly_16(x);
|
||||
mdct_butterfly_16(x+16);
|
||||
mdct_butterfly_16(x);
|
||||
mdct_butterfly_16(x+16);
|
||||
}
|
||||
|
||||
/* N/stage point generic N stage butterfly (in place, 4 register) */
|
||||
|
@ -262,34 +262,34 @@ STIN void mdct_bitreverse(DATA_TYPE *x,int n,int step,int shift) {
|
|||
REG_TYPE r0 = x0[0] + x1[0];
|
||||
REG_TYPE r1 = x1[1] - x0[1];
|
||||
|
||||
XPROD32( r0, r1, T[1], T[0], r2, r3 ); T+=step;
|
||||
XPROD32( r0, r1, T[1], T[0], r2, r3 ); T+=step;
|
||||
|
||||
w1 -= 4;
|
||||
w1 -= 4;
|
||||
|
||||
r0 = (x0[1] + x1[1])>>1;
|
||||
r0 = (x0[1] + x1[1])>>1;
|
||||
r1 = (x0[0] - x1[0])>>1;
|
||||
w0[0] = r0 + r2;
|
||||
w0[1] = r1 + r3;
|
||||
w1[2] = r0 - r2;
|
||||
w1[3] = r3 - r1;
|
||||
w0[0] = r0 + r2;
|
||||
w0[1] = r1 + r3;
|
||||
w1[2] = r0 - r2;
|
||||
w1[3] = r3 - r1;
|
||||
|
||||
r3 = bitrev12(bit++);
|
||||
r3 = bitrev12(bit++);
|
||||
x0 = x + ((r3 ^ 0xfff)>>shift) -1;
|
||||
x1 = x + (r3>>shift);
|
||||
|
||||
r0 = x0[0] + x1[0];
|
||||
r1 = x1[1] - x0[1];
|
||||
|
||||
XPROD32( r0, r1, T[1], T[0], r2, r3 ); T+=step;
|
||||
XPROD32( r0, r1, T[1], T[0], r2, r3 ); T+=step;
|
||||
|
||||
r0 = (x0[1] + x1[1])>>1;
|
||||
r1 = (x0[0] - x1[0])>>1;
|
||||
w0[2] = r0 + r2;
|
||||
w0[3] = r1 + r3;
|
||||
w1[0] = r0 - r2;
|
||||
w1[1] = r3 - r1;
|
||||
w0[2] = r0 + r2;
|
||||
w0[3] = r1 + r3;
|
||||
w1[0] = r0 - r2;
|
||||
w1[1] = r3 - r1;
|
||||
|
||||
w0 += 4;
|
||||
w0 += 4;
|
||||
}while(T<Ttop);
|
||||
do{
|
||||
REG_TYPE r3 = bitrev12(bit++);
|
||||
|
@ -299,34 +299,34 @@ STIN void mdct_bitreverse(DATA_TYPE *x,int n,int step,int shift) {
|
|||
REG_TYPE r0 = x0[0] + x1[0];
|
||||
REG_TYPE r1 = x1[1] - x0[1];
|
||||
|
||||
T-=step; XPROD32( r0, r1, T[0], T[1], r2, r3 );
|
||||
T-=step; XPROD32( r0, r1, T[0], T[1], r2, r3 );
|
||||
|
||||
w1 -= 4;
|
||||
w1 -= 4;
|
||||
|
||||
r0 = (x0[1] + x1[1])>>1;
|
||||
r0 = (x0[1] + x1[1])>>1;
|
||||
r1 = (x0[0] - x1[0])>>1;
|
||||
w0[0] = r0 + r2;
|
||||
w0[1] = r1 + r3;
|
||||
w1[2] = r0 - r2;
|
||||
w1[3] = r3 - r1;
|
||||
w0[0] = r0 + r2;
|
||||
w0[1] = r1 + r3;
|
||||
w1[2] = r0 - r2;
|
||||
w1[3] = r3 - r1;
|
||||
|
||||
r3 = bitrev12(bit++);
|
||||
r3 = bitrev12(bit++);
|
||||
x0 = x + ((r3 ^ 0xfff)>>shift) -1;
|
||||
x1 = x + (r3>>shift);
|
||||
|
||||
r0 = x0[0] + x1[0];
|
||||
r1 = x1[1] - x0[1];
|
||||
|
||||
T-=step; XPROD32( r0, r1, T[0], T[1], r2, r3 );
|
||||
T-=step; XPROD32( r0, r1, T[0], T[1], r2, r3 );
|
||||
|
||||
r0 = (x0[1] + x1[1])>>1;
|
||||
r1 = (x0[0] - x1[0])>>1;
|
||||
w0[2] = r0 + r2;
|
||||
w0[3] = r1 + r3;
|
||||
w1[0] = r0 - r2;
|
||||
w1[1] = r3 - r1;
|
||||
w0[2] = r0 + r2;
|
||||
w0[3] = r1 + r3;
|
||||
w1[0] = r0 - r2;
|
||||
w1[1] = r3 - r1;
|
||||
|
||||
w0 += 4;
|
||||
w0 += 4;
|
||||
}while(w0<w1);
|
||||
}
|
||||
|
||||
|
@ -342,7 +342,7 @@ void mdct_backward(int n, DATA_TYPE *in, DATA_TYPE *out) {
|
|||
int step;
|
||||
|
||||
#if CONFIG_CPU == MCF5249
|
||||
mcf5249_init_mac(); /* should be redundant */
|
||||
/* mcf5249_init_mac(); */ /* should be redundant */
|
||||
#endif
|
||||
|
||||
for (shift=6;!(n&(1<<shift));shift++);
|
||||
|
@ -400,77 +400,77 @@ void mdct_backward(int n, DATA_TYPE *in, DATA_TYPE *out) {
|
|||
T=(step>=4)?(sincos_lookup0+(step>>1)):sincos_lookup1;
|
||||
do{
|
||||
oX1-=4;
|
||||
XPROD31( iX[0], -iX[1], T[0], T[1], &oX1[3], &oX2[0] ); T+=step;
|
||||
XPROD31( iX[2], -iX[3], T[0], T[1], &oX1[2], &oX2[1] ); T+=step;
|
||||
XPROD31( iX[4], -iX[5], T[0], T[1], &oX1[1], &oX2[2] ); T+=step;
|
||||
XPROD31( iX[6], -iX[7], T[0], T[1], &oX1[0], &oX2[3] ); T+=step;
|
||||
oX2+=4;
|
||||
iX+=8;
|
||||
}while(iX<oX1);
|
||||
break;
|
||||
XPROD31( iX[0], -iX[1], T[0], T[1], &oX1[3], &oX2[0] ); T+=step;
|
||||
XPROD31( iX[2], -iX[3], T[0], T[1], &oX1[2], &oX2[1] ); T+=step;
|
||||
XPROD31( iX[4], -iX[5], T[0], T[1], &oX1[1], &oX2[2] ); T+=step;
|
||||
XPROD31( iX[6], -iX[7], T[0], T[1], &oX1[0], &oX2[3] ); T+=step;
|
||||
oX2+=4;
|
||||
iX+=8;
|
||||
}while(iX<oX1);
|
||||
break;
|
||||
}
|
||||
|
||||
case 1: {
|
||||
/* linear interpolation between table values: offset=0.5, step=1 */
|
||||
REG_TYPE t0,t1,v0,v1;
|
||||
REG_TYPE t0,t1,v0,v1;
|
||||
T = sincos_lookup0;
|
||||
V = sincos_lookup1;
|
||||
t0 = (*T++)>>1;
|
||||
t1 = (*T++)>>1;
|
||||
t0 = (*T++)>>1;
|
||||
t1 = (*T++)>>1;
|
||||
do{
|
||||
oX1-=4;
|
||||
|
||||
t0 += (v0 = (*V++)>>1);
|
||||
t1 += (v1 = (*V++)>>1);
|
||||
XPROD31( iX[0], -iX[1], t0, t1, &oX1[3], &oX2[0] );
|
||||
v0 += (t0 = (*T++)>>1);
|
||||
v1 += (t1 = (*T++)>>1);
|
||||
XPROD31( iX[2], -iX[3], v0, v1, &oX1[2], &oX2[1] );
|
||||
t0 += (v0 = (*V++)>>1);
|
||||
t1 += (v1 = (*V++)>>1);
|
||||
XPROD31( iX[4], -iX[5], t0, t1, &oX1[1], &oX2[2] );
|
||||
v0 += (t0 = (*T++)>>1);
|
||||
v1 += (t1 = (*T++)>>1);
|
||||
XPROD31( iX[6], -iX[7], v0, v1, &oX1[0], &oX2[3] );
|
||||
t0 += (v0 = (*V++)>>1);
|
||||
t1 += (v1 = (*V++)>>1);
|
||||
XPROD31( iX[0], -iX[1], t0, t1, &oX1[3], &oX2[0] );
|
||||
v0 += (t0 = (*T++)>>1);
|
||||
v1 += (t1 = (*T++)>>1);
|
||||
XPROD31( iX[2], -iX[3], v0, v1, &oX1[2], &oX2[1] );
|
||||
t0 += (v0 = (*V++)>>1);
|
||||
t1 += (v1 = (*V++)>>1);
|
||||
XPROD31( iX[4], -iX[5], t0, t1, &oX1[1], &oX2[2] );
|
||||
v0 += (t0 = (*T++)>>1);
|
||||
v1 += (t1 = (*T++)>>1);
|
||||
XPROD31( iX[6], -iX[7], v0, v1, &oX1[0], &oX2[3] );
|
||||
|
||||
oX2+=4;
|
||||
iX+=8;
|
||||
}while(iX<oX1);
|
||||
break;
|
||||
oX2+=4;
|
||||
iX+=8;
|
||||
}while(iX<oX1);
|
||||
break;
|
||||
}
|
||||
|
||||
case 0: {
|
||||
/* linear interpolation between table values: offset=0.25, step=0.5 */
|
||||
REG_TYPE t0,t1,v0,v1,q0,q1;
|
||||
REG_TYPE t0,t1,v0,v1,q0,q1;
|
||||
T = sincos_lookup0;
|
||||
V = sincos_lookup1;
|
||||
t0 = *T++;
|
||||
t1 = *T++;
|
||||
t0 = *T++;
|
||||
t1 = *T++;
|
||||
do{
|
||||
oX1-=4;
|
||||
|
||||
v0 = *V++;
|
||||
v1 = *V++;
|
||||
t0 += (q0 = (v0-t0)>>2);
|
||||
t1 += (q1 = (v1-t1)>>2);
|
||||
XPROD31( iX[0], -iX[1], t0, t1, &oX1[3], &oX2[0] );
|
||||
t0 = v0-q0;
|
||||
t1 = v1-q1;
|
||||
XPROD31( iX[2], -iX[3], t0, t1, &oX1[2], &oX2[1] );
|
||||
v0 = *V++;
|
||||
v1 = *V++;
|
||||
t0 += (q0 = (v0-t0)>>2);
|
||||
t1 += (q1 = (v1-t1)>>2);
|
||||
XPROD31( iX[0], -iX[1], t0, t1, &oX1[3], &oX2[0] );
|
||||
t0 = v0-q0;
|
||||
t1 = v1-q1;
|
||||
XPROD31( iX[2], -iX[3], t0, t1, &oX1[2], &oX2[1] );
|
||||
|
||||
t0 = *T++;
|
||||
t1 = *T++;
|
||||
v0 += (q0 = (t0-v0)>>2);
|
||||
v1 += (q1 = (t1-v1)>>2);
|
||||
XPROD31( iX[4], -iX[5], v0, v1, &oX1[1], &oX2[2] );
|
||||
v0 = t0-q0;
|
||||
v1 = t1-q1;
|
||||
XPROD31( iX[6], -iX[7], v0, v1, &oX1[0], &oX2[3] );
|
||||
t0 = *T++;
|
||||
t1 = *T++;
|
||||
v0 += (q0 = (t0-v0)>>2);
|
||||
v1 += (q1 = (t1-v1)>>2);
|
||||
XPROD31( iX[4], -iX[5], v0, v1, &oX1[1], &oX2[2] );
|
||||
v0 = t0-q0;
|
||||
v1 = t1-q1;
|
||||
XPROD31( iX[6], -iX[7], v0, v1, &oX1[0], &oX2[3] );
|
||||
|
||||
oX2+=4;
|
||||
iX+=8;
|
||||
}while(iX<oX1);
|
||||
break;
|
||||
oX2+=4;
|
||||
iX+=8;
|
||||
}while(iX<oX1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,8 @@
|
|||
|
||||
#include "os_types.h"
|
||||
|
||||
/* keep lookup tables in fast IRAM */
|
||||
/* we keep the most used sin cosine table in fast IRAM;
|
||||
unfortunately, we don't have the space for both tables */
|
||||
|
||||
/* {sin(2*i*PI/4096), cos(2*i*PI/4096)}, with i = 0 to 512 */
|
||||
static LOOKUP_T sincos_lookup0[1026] IDATA_ATTR = {
|
||||
|
|
|
@ -37,7 +37,7 @@ void* alloca(size_t size);
|
|||
|
||||
#ifndef _LOW_ACCURACY_
|
||||
/* 64 bit multiply */
|
||||
//#include <sys/types.h>
|
||||
/* #include <sys/types.h> */
|
||||
|
||||
#if BYTE_ORDER==LITTLE_ENDIAN
|
||||
union magic {
|
||||
|
|
|
@ -119,7 +119,7 @@ vorbis_info_residue *res0_unpack(vorbis_info *vi,oggpack_buffer *opb){
|
|||
}
|
||||
|
||||
vorbis_look_residue *res0_look(vorbis_dsp_state *vd,vorbis_info_mode *vm,
|
||||
vorbis_info_residue *vr){
|
||||
vorbis_info_residue *vr){
|
||||
vorbis_info_residue0 *info=(vorbis_info_residue0 *)vr;
|
||||
vorbis_look_residue0 *look=(vorbis_look_residue0 *)_ogg_calloc(1,sizeof(*look));
|
||||
codec_setup_info *ci=(codec_setup_info *)vd->vi->codec_setup;
|
||||
|
@ -143,13 +143,13 @@ vorbis_look_residue *res0_look(vorbis_dsp_state *vd,vorbis_info_mode *vm,
|
|||
if(stages>maxstage)maxstage=stages;
|
||||
look->partbooks[j]=(codebook **)_ogg_calloc(stages,sizeof(*look->partbooks[j]));
|
||||
for(k=0;k<stages;k++)
|
||||
if(info->secondstages[j]&(1<<k)){
|
||||
look->partbooks[j][k]=ci->fullbooks+info->booklist[acc++];
|
||||
if(info->secondstages[j]&(1<<k)){
|
||||
look->partbooks[j][k]=ci->fullbooks+info->booklist[acc++];
|
||||
#ifdef TRAIN_RES
|
||||
look->training_data[k][j]=calloc(look->partbooks[j][k]->entries,
|
||||
sizeof(***look->training_data));
|
||||
look->training_data[k][j]=calloc(look->partbooks[j][k]->entries,
|
||||
sizeof(***look->training_data));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -176,9 +176,9 @@ vorbis_look_residue *res0_look(vorbis_dsp_state *vd,vorbis_info_mode *vm,
|
|||
|
||||
/* a truncated packet here just means 'stop working'; it's not an error */
|
||||
static int _01inverse(vorbis_block *vb,vorbis_look_residue *vl,
|
||||
ogg_int32_t **in,int ch,
|
||||
long (*decodepart)(codebook *, ogg_int32_t *,
|
||||
oggpack_buffer *,int,int)){
|
||||
ogg_int32_t **in,int ch,
|
||||
long (*decodepart)(codebook *, ogg_int32_t *,
|
||||
oggpack_buffer *,int,int)){
|
||||
|
||||
long i,j,k,l,s;
|
||||
vorbis_look_residue0 *look=(vorbis_look_residue0 *)vl;
|
||||
|
@ -202,27 +202,27 @@ static int _01inverse(vorbis_block *vb,vorbis_look_residue *vl,
|
|||
partitions_pre_word partitions */
|
||||
for(i=0,l=0;i<partvals;l++){
|
||||
if(s==0){
|
||||
/* fetch the partition word for each channel */
|
||||
for(j=0;j<ch;j++){
|
||||
int temp=vorbis_book_decode(look->phrasebook,&vb->opb);
|
||||
if(temp==-1)goto eopbreak;
|
||||
partword[j][l]=look->decodemap[temp];
|
||||
if(partword[j][l]==NULL)goto errout;
|
||||
}
|
||||
/* fetch the partition word for each channel */
|
||||
for(j=0;j<ch;j++){
|
||||
int temp=vorbis_book_decode(look->phrasebook,&vb->opb);
|
||||
if(temp==-1)goto eopbreak;
|
||||
partword[j][l]=look->decodemap[temp];
|
||||
if(partword[j][l]==NULL)goto errout;
|
||||
}
|
||||
}
|
||||
|
||||
/* now we decode residual values for the partitions */
|
||||
for(k=0;k<partitions_per_word && i<partvals;k++,i++)
|
||||
for(j=0;j<ch;j++){
|
||||
long offset=info->begin+i*samples_per_partition;
|
||||
if(info->secondstages[partword[j][l][k]]&(1<<s)){
|
||||
codebook *stagebook=look->partbooks[partword[j][l][k]][s];
|
||||
if(stagebook){
|
||||
if(decodepart(stagebook,in[j]+offset,&vb->opb,
|
||||
samples_per_partition,-8)==-1)goto eopbreak;
|
||||
}
|
||||
}
|
||||
}
|
||||
for(j=0;j<ch;j++){
|
||||
long offset=info->begin+i*samples_per_partition;
|
||||
if(info->secondstages[partword[j][l][k]]&(1<<s)){
|
||||
codebook *stagebook=look->partbooks[partword[j][l][k]][s];
|
||||
if(stagebook){
|
||||
if(decodepart(stagebook,in[j]+offset,&vb->opb,
|
||||
samples_per_partition,-8)==-1)goto eopbreak;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -232,7 +232,7 @@ static int _01inverse(vorbis_block *vb,vorbis_look_residue *vl,
|
|||
}
|
||||
|
||||
int res0_inverse(vorbis_block *vb,vorbis_look_residue *vl,
|
||||
ogg_int32_t **in,int *nonzero,int ch){
|
||||
ogg_int32_t **in,int *nonzero,int ch){
|
||||
int i,used=0;
|
||||
for(i=0;i<ch;i++)
|
||||
if(nonzero[i])
|
||||
|
@ -244,7 +244,7 @@ int res0_inverse(vorbis_block *vb,vorbis_look_residue *vl,
|
|||
}
|
||||
|
||||
int res1_inverse(vorbis_block *vb,vorbis_look_residue *vl,
|
||||
ogg_int32_t **in,int *nonzero,int ch){
|
||||
ogg_int32_t **in,int *nonzero,int ch){
|
||||
int i,used=0;
|
||||
for(i=0;i<ch;i++)
|
||||
if(nonzero[i])
|
||||
|
@ -259,7 +259,7 @@ int res1_inverse(vorbis_block *vb,vorbis_look_residue *vl,
|
|||
|
||||
/* duplicate code here as speed is somewhat more important */
|
||||
int res2_inverse(vorbis_block *vb,vorbis_look_residue *vl,
|
||||
ogg_int32_t **in,int *nonzero,int ch){
|
||||
ogg_int32_t **in,int *nonzero,int ch){
|
||||
long i,k,l,s;
|
||||
vorbis_look_residue0 *look=(vorbis_look_residue0 *)vl;
|
||||
vorbis_info_residue0 *info=look->info;
|
||||
|
@ -283,25 +283,25 @@ int res2_inverse(vorbis_block *vb,vorbis_look_residue *vl,
|
|||
for(i=0,l=0;i<partvals;l++){
|
||||
|
||||
if(s==0){
|
||||
/* fetch the partition word */
|
||||
int temp=vorbis_book_decode(look->phrasebook,&vb->opb);
|
||||
if(temp==-1)goto eopbreak;
|
||||
partword[l]=look->decodemap[temp];
|
||||
if(partword[l]==NULL)goto errout;
|
||||
/* fetch the partition word */
|
||||
int temp=vorbis_book_decode(look->phrasebook,&vb->opb);
|
||||
if(temp==-1)goto eopbreak;
|
||||
partword[l]=look->decodemap[temp];
|
||||
if(partword[l]==NULL)goto errout;
|
||||
}
|
||||
|
||||
/* now we decode residual values for the partitions */
|
||||
for(k=0;k<partitions_per_word && i<partvals;k++,i++)
|
||||
if(info->secondstages[partword[l][k]]&(1<<s)){
|
||||
codebook *stagebook=look->partbooks[partword[l][k]][s];
|
||||
if(stagebook){
|
||||
if(vorbis_book_decodevv_add(stagebook,in,
|
||||
i*samples_per_partition+beginoff,ch,
|
||||
&vb->opb,
|
||||
samples_per_partition,-8)==-1)
|
||||
goto eopbreak;
|
||||
}
|
||||
}
|
||||
if(info->secondstages[partword[l][k]]&(1<<s)){
|
||||
codebook *stagebook=look->partbooks[partword[l][k]][s];
|
||||
if(stagebook){
|
||||
if(vorbis_book_decodevv_add(stagebook,in,
|
||||
i*samples_per_partition+beginoff,ch,
|
||||
&vb->opb,
|
||||
samples_per_partition,-8)==-1)
|
||||
goto eopbreak;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,8 +26,8 @@
|
|||
|
||||
|
||||
/* IRAM buffer keep the block pcm data; only for windows size upto 2048
|
||||
for space restrictions. No real compromise, larger window sizes
|
||||
are only used for very low quality settings (q<0?) */
|
||||
for space restrictions.
|
||||
libVorbis 1.1 Oggenc doesn't use larger windows anyway. */
|
||||
/* max 2 channels on the ihp-1xx (stereo), 2048 samples (2*2048*4=16Kb) */
|
||||
#define IRAM_PCM_END 2048
|
||||
#define CHANNELS 2
|
||||
|
@ -80,12 +80,12 @@ int vorbis_synthesis(vorbis_block *vb,ogg_packet *op,int decodep){
|
|||
/* use statically allocated iram buffer */
|
||||
vb->pcm = ipcm_vect;
|
||||
for(i=0; i<CHANNELS; i++)
|
||||
vb->pcm[i] = &ipcm_buff[i*IRAM_PCM_END];
|
||||
vb->pcm[i] = &ipcm_buff[i*IRAM_PCM_END];
|
||||
} else {
|
||||
/* dynamic allocation (slower) */
|
||||
vb->pcm=(ogg_int32_t **)_vorbis_block_alloc(vb,sizeof(*vb->pcm)*vi->channels);
|
||||
for(i=0;i<vi->channels;i++)
|
||||
vb->pcm[i]=(ogg_int32_t *)_vorbis_block_alloc(vb,vb->pcmend*sizeof(*vb->pcm[i]));
|
||||
vb->pcm[i]=(ogg_int32_t *)_vorbis_block_alloc(vb,vb->pcmend*sizeof(*vb->pcm[i]));
|
||||
}
|
||||
|
||||
/* unpack_header enforces range checking */
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -54,8 +54,8 @@ const void *_vorbis_window(int type, int left){
|
|||
}
|
||||
|
||||
void _vorbis_apply_window(ogg_int32_t *d,const void *window_p[2],
|
||||
long *blocksizes,
|
||||
int lW,int W,int nW){
|
||||
long *blocksizes,
|
||||
int lW,int W,int nW){
|
||||
LOOKUP_T *window[2]={window_p[0],window_p[1]};
|
||||
long n=blocksizes[W];
|
||||
long ln=blocksizes[lW];
|
||||
|
@ -68,7 +68,7 @@ void _vorbis_apply_window(ogg_int32_t *d,const void *window_p[2],
|
|||
long rightend=rightbegin+rn/2;
|
||||
|
||||
#if CONFIG_CPU == MCF5249
|
||||
mcf5249_init_mac(); /* shouldn't be needed, but just in case */
|
||||
/* mcf5249_init_mac(); */ /* shouldn't be needed, but just in case */
|
||||
mcf5249_vect_zero(&d[0], leftbegin);
|
||||
mcf5249_vect_mult_fw(&d[leftbegin], &window[lW][0], leftend-leftbegin);
|
||||
mcf5249_vect_mult_bw(&d[rightbegin], &window[nW][rn/2-1], rightend-rightbegin);
|
||||
|
|
|
@ -18,8 +18,10 @@
|
|||
|
||||
#include "os_types.h"
|
||||
|
||||
/* keep small window tables in fast IRAM */
|
||||
static LOOKUP_T vwin64[32] IDATA_ATTR = {
|
||||
/* Oggenc 1.1 seems to use exclusively windows sizes 256, 2048
|
||||
keep the most common sizes in fast IRAM;
|
||||
because we have the available space also 128, 512 */
|
||||
static LOOKUP_T vwin64[32] = {
|
||||
X(0x001f0003), X(0x01168c98), X(0x030333c8), X(0x05dfe3a4),
|
||||
X(0x09a49562), X(0x0e45df18), X(0x13b47ef2), X(0x19dcf676),
|
||||
X(0x20a74d83), X(0x27f7137c), X(0x2fabb05a), X(0x37a1105a),
|
||||
|
@ -151,7 +153,7 @@ static LOOKUP_T vwin512[256] IDATA_ATTR = {
|
|||
X(0x7ffffdcd), X(0x7fffff6d), X(0x7fffffed), X(0x7fffffff),
|
||||
};
|
||||
|
||||
static LOOKUP_T vwin1024[512] IDATA_ATTR = {
|
||||
static LOOKUP_T vwin1024[512] = {
|
||||
X(0x00001f02), X(0x0001170e), X(0x00030724), X(0x0005ef40),
|
||||
X(0x0009cf59), X(0x000ea767), X(0x0014775e), X(0x001b3f2e),
|
||||
X(0x0022fec8), X(0x002bb618), X(0x00356508), X(0x00400b81),
|
||||
|
@ -541,8 +543,6 @@ static LOOKUP_T vwin2048[1024] IDATA_ATTR = {
|
|||
X(0x7ffffffe), X(0x7fffffff), X(0x7fffffff), X(0x7fffffff),
|
||||
};
|
||||
|
||||
/* The remaining large window sizes are used only for very low
|
||||
quality Vorbis files so we don't bother to put them in IRAM */
|
||||
static LOOKUP_T vwin4096[2048] = {
|
||||
X(0x000001f0), X(0x00001171), X(0x00003072), X(0x00005ef5),
|
||||
X(0x00009cf8), X(0x0000ea7c), X(0x00014780), X(0x0001b405),
|
||||
|
|
Loading…
Reference in a new issue