1
0
Fork 0
forked from len0rd/rockbox

Remove all tabs within codec path.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@24862 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Andree Buschmann 2010-02-22 19:44:05 +00:00
parent c1bb06c3af
commit 398b37124e
84 changed files with 8801 additions and 8801 deletions

View file

@ -49,7 +49,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
#define XfilterB 20 /* int32_t XfilterB; */
#define YfilterA 24 /* int32_t YfilterA; */
#define YcoeffsA 28 /* int32_t YcoeffsA[4]; */
#define XcoeffsA 44 /* int32_t XcoeffsA[4]; */
#define YcoeffsB 60 /* int32_t YcoeffsB[5]; */

View file

@ -34,8 +34,8 @@ static inline uint64_t ByteSwap64(uint64_t x)
#elif defined(ARCH_X86)
static inline unsigned short ByteSwap16(unsigned short x)
{
__asm("xchgb %b0,%h0" :
"=q" (x) :
__asm("xchgb %b0,%h0" :
"=q" (x) :
"0" (x));
return x;
}
@ -44,13 +44,13 @@ static inline unsigned short ByteSwap16(unsigned short x)
static inline unsigned int ByteSwap32(unsigned int x)
{
#if __CPU__ > 386
__asm("bswap %0":
__asm("bswap %0":
"=r" (x) :
#else
__asm("xchgb %b0,%h0\n"
" rorl $16,%0\n"
" xchgb %b0,%h0":
"=q" (x) :
__asm("xchgb %b0,%h0\n"
" rorl $16,%0\n"
" xchgb %b0,%h0":
"=q" (x) :
#endif
"0" (x));
return x;
@ -61,7 +61,7 @@ static inline unsigned long long int ByteSwap64(unsigned long long int x)
{
register union { __extension__ uint64_t __ll;
uint32_t __l[2]; } __x;
asm("xchgl %0,%1":
asm("xchgl %0,%1":
"=r"(__x.__l[0]),"=r"(__x.__l[1]):
"0"(bswap_32((unsigned long)x)),"1"(bswap_32((unsigned long)(x>>32))));
return __x.__ll;
@ -71,17 +71,17 @@ static inline unsigned long long int ByteSwap64(unsigned long long int x)
#elif defined(ARCH_SH4)
static inline uint16_t ByteSwap16(uint16_t x) {
__asm__("swap.b %0,%0":"=r"(x):"0"(x));
return x;
__asm__("swap.b %0,%0":"=r"(x):"0"(x));
return x;
}
static inline uint32_t ByteSwap32(uint32_t x) {
__asm__(
"swap.b %0,%0\n"
"swap.w %0,%0\n"
"swap.b %0,%0\n"
:"=r"(x):"0"(x));
return x;
__asm__(
"swap.b %0,%0\n"
"swap.w %0,%0\n"
"swap.b %0,%0\n"
:"=r"(x):"0"(x));
return x;
}
#define bswap_16(x) ByteSwap16(x)
@ -124,9 +124,9 @@ static inline uint64_t ByteSwap64(uint64_t x)
}
#define bswap_64(x) ByteSwap64(x)
#endif /* !ARCH_X86 */
#endif /* !ARCH_X86 */
#endif /* !HAVE_BYTESWAP_H */
#endif /* !HAVE_BYTESWAP_H */
// be2me ... BigEndian to MachineEndian
// le2me ... LittleEndian to MachineEndian

View file

@ -463,7 +463,7 @@ int main (void)
//exec_time = (((double)end-(double)start)/CLOCKS_PER_SEC);
for(j = 0; j < FFT_SIZE; j++)
{
printf("%8.4f\n", sqrt(pow(fixtof32(z[j].re),2)+ pow(fixtof32(z[j].im), 2)));
printf("%8.4f\n", sqrt(pow(fixtof32(z[j].re),2)+ pow(fixtof32(z[j].im), 2)));
//getchar();
}
printf("muls = %d, adds = %d\n", muls, adds);

View file

@ -18,10 +18,10 @@
#ifdef CPU_COLDFIRE
/*
* onsstack,sigmask,sp,pc,psl,d2-d7,a2-a6,
* fp2-fp7 for 68881.
* fp2-fp7 for 68881.
* All else recovered by under/over(flow) handling.
*/
#define _JBLEN 34
#define _JBLEN 34
#endif
#ifdef CPU_MIPS
@ -48,9 +48,9 @@
#ifdef _JBLEN
#ifdef _JBTYPE
typedef _JBTYPE jmp_buf[_JBLEN];
typedef _JBTYPE jmp_buf[_JBLEN];
#else
typedef int jmp_buf[_JBLEN];
typedef int jmp_buf[_JBLEN];
#endif
#else
typedef int jmp_buf;

View file

@ -27,10 +27,10 @@
in both interworked and non-interworked environments as well as with
older processors which do not have the BX instruction we do the
following:
Test the return address.
If the bottom bit is clear perform an "old style" function exit.
(We know that we are in ARM mode and returning to an ARM mode caller).
Otherwise use the BX instruction to perform the function exit.
Test the return address.
If the bottom bit is clear perform an "old style" function exit.
(We know that we are in ARM mode and returning to an ARM mode caller).
Otherwise use the BX instruction to perform the function exit.
We know that we will never attempt to perform the BX instruction on
an older processor, because that kind of processor will never be
@ -47,7 +47,7 @@
test the bottom bit, because this is part of the processor status.
Instead we just do a normal return, since we know that we cannot be
returning to a Thumb caller - the Thumb does not support APCS-26.
Function entry is much simpler. If we are compiling for the Thumb we
just switch into ARM mode and then drop through into the rest of the
function. The function exit code will take care of the restore to
@ -56,18 +56,18 @@
For Thumb-2 do everything in Thumb mode. */
#ifdef __APCS_26__
#define RET movs pc, lr
#define RET movs pc, lr
#elif defined(__thumb2__)
#define RET bx lr
#define RET bx lr
#else
#define RET tst lr, #1; \
moveq pc, lr ; \
.word 0xe12fff1e /* bx lr */
#define RET tst lr, #1; \
moveq pc, lr ; \
.word 0xe12fff1e /* bx lr */
#endif
#ifdef __thumb2__
.macro COND where when
i\where \when
i\where \when
.endm
#else
.macro COND where when
@ -77,96 +77,96 @@
#if defined(__thumb2__)
.syntax unified
.macro MODE
.thumb
.thumb_func
.thumb
.thumb_func
.endm
.macro PROLOGUE name
.endm
#elif defined(__thumb__)
#define MODE .thumb_func
#define MODE .thumb_func
.macro PROLOGUE name
.code 16
bx pc
nop
.code 32
.code 16
bx pc
nop
.code 32
SYM (.arm_start_of.\name):
.endm
#else /* Arm */
#define MODE .code 32
#define MODE .code 32
.macro PROLOGUE name
.endm
#endif
.macro FUNC_START name
.text
.align 2
MODE
.globl SYM (\name)
TYPE (\name)
.text
.align 2
MODE
.globl SYM (\name)
TYPE (\name)
SYM (\name):
PROLOGUE \name
PROLOGUE \name
.endm
.macro FUNC_END name
RET
SIZE (\name)
RET
SIZE (\name)
.endm
/* --------------------------------------------------------------------
int setjmp (jmp_buf);
-------------------------------------------------------------------- */
FUNC_START setjmp
FUNC_START setjmp
/* Save all the callee-preserved registers into the jump buffer. */
/* Save all the callee-preserved registers into the jump buffer. */
#ifdef __thumb2__
stmea a1!, { v1-v7, fp, ip, lr }
str sp, [a1],#+4
stmea a1!, { v1-v7, fp, ip, lr }
str sp, [a1],#+4
#else
stmea a1!, { v1-v7, fp, ip, sp, lr }
stmea a1!, { v1-v7, fp, ip, sp, lr }
#endif
#if 0 /* Simulator does not cope with FP instructions yet. */
#if 0 /* Simulator does not cope with FP instructions yet. */
#ifndef __SOFTFP__
/* Save the floating point registers. */
sfmea f4, 4, [a1]
/* Save the floating point registers. */
sfmea f4, 4, [a1]
#endif
#endif
/* When setting up the jump buffer return 0. */
mov a1, #0
#endif
/* When setting up the jump buffer return 0. */
mov a1, #0
FUNC_END setjmp
FUNC_END setjmp
/* --------------------------------------------------------------------
volatile void longjmp (jmp_buf, int);
volatile void longjmp (jmp_buf, int);
-------------------------------------------------------------------- */
FUNC_START longjmp
FUNC_START longjmp
/* If we have stack extension code it ought to be handled here. */
/* Restore the registers, retrieving the state when setjmp() was called. */
/* If we have stack extension code it ought to be handled here. */
/* Restore the registers, retrieving the state when setjmp() was called. */
#ifdef __thumb2__
ldmfd a1!, { v1-v7, fp, ip, lr }
ldr sp, [a1],#+4
ldmfd a1!, { v1-v7, fp, ip, lr }
ldr sp, [a1],#+4
#else
ldmfd a1!, { v1-v7, fp, ip, sp, lr }
ldmfd a1!, { v1-v7, fp, ip, sp, lr }
#endif
#if 0 /* Simulator does not cope with FP instructions yet. */
#if 0 /* Simulator does not cope with FP instructions yet. */
#ifndef __SOFTFP__
/* Restore floating point registers as well. */
lfmfd f4, 4, [a1]
/* Restore floating point registers as well. */
lfmfd f4, 4, [a1]
#endif
#endif
/* Put the return value into the integer result register.
But if it is zero then return 1 instead. */
movs a1, a2
#endif
/* Put the return value into the integer result register.
But if it is zero then return 1 instead. */
movs a1, a2
#ifdef __thumb2__
it eq
it eq
#endif
moveq a1, #1
moveq a1, #1
FUNC_END longjmp
FUNC_END longjmp

View file

@ -34,46 +34,46 @@
.global SYM (longjmp)
SYM (setjmp):
moveal sp@(4),a0
movel sp@(0),a0@(12)
movel sp,a0@(8)
moveml d2-d7/a2-a6,a0@(20)
clrl d0
rts
moveal sp@(4),a0
movel sp@(0),a0@(12)
movel sp,a0@(8)
moveml d2-d7/a2-a6,a0@(20)
clrl d0
rts
SYM (longjmp):
moveal sp@(4),a0
movel sp@(8),d0
bne 1f
movel &1,d0
moveal sp@(4),a0
movel sp@(8),d0
bne 1f
movel &1,d0
1:
moveml a0@(20),d2-d7/a2-a6
moveal a0@(8),sp
movel a0@(12),sp@
rts
moveml a0@(20),d2-d7/a2-a6
moveal a0@(8),sp
movel a0@(12),sp@
rts
#ifdef M68881
.global SYM (setjmp_68881)
.global SYM (longjmp_68881)
SYM (setjmp_68881):
moveal sp@(4),a0
movel sp@(0),a0@(12)
movel sp,a0@(8)
moveml d2-d7/a2-a6,a0@(20)
fmovemx fp2-fp7,a0@(64)
clrl d0
rts
moveal sp@(4),a0
movel sp@(0),a0@(12)
movel sp,a0@(8)
moveml d2-d7/a2-a6,a0@(20)
fmovemx fp2-fp7,a0@(64)
clrl d0
rts
SYM (longjmp_68881):
moveal sp@(4),a0
fmovemx a0@(64),fp2-fp7
movel sp@(8),d0
bne 1f
movel &1,d0
moveal sp@(4),a0
fmovemx a0@(64),fp2-fp7
movel sp@(8),d0
bne 1f
movel &1,d0
1:
moveml a0@(20),d2-d7/a2-a6
moveal a0@(8),sp
movel a0@(12),sp@
rts
moveml a0@(20),d2-d7/a2-a6
moveal a0@(8),sp
movel a0@(12),sp@
rts
#endif

View file

@ -56,19 +56,19 @@
#include <string.h>
#ifndef TLSF_USE_LOCKS
#define TLSF_USE_LOCKS (0)
#define TLSF_USE_LOCKS (0)
#endif
#ifndef TLSF_STATISTIC
#define TLSF_STATISTIC (0)
#define TLSF_STATISTIC (0)
#endif
#ifndef USE_MMAP
#define USE_MMAP (0)
#define USE_MMAP (0)
#endif
#ifndef USE_SBRK
#define USE_SBRK (0)
#define USE_SBRK (0)
#endif
@ -82,18 +82,18 @@
#endif
#if TLSF_STATISTIC
#define TLSF_ADD_SIZE(tlsf, b) do { \
tlsf->used_size += (b->size & BLOCK_SIZE) + BHDR_OVERHEAD; \
if (tlsf->used_size > tlsf->max_size) \
tlsf->max_size = tlsf->used_size; \
} while(0)
#define TLSF_ADD_SIZE(tlsf, b) do { \
tlsf->used_size += (b->size & BLOCK_SIZE) + BHDR_OVERHEAD; \
if (tlsf->used_size > tlsf->max_size) \
tlsf->max_size = tlsf->used_size; \
} while(0)
#define TLSF_REMOVE_SIZE(tlsf, b) do { \
tlsf->used_size -= (b->size & BLOCK_SIZE) + BHDR_OVERHEAD; \
} while(0)
#define TLSF_REMOVE_SIZE(tlsf, b) do { \
tlsf->used_size -= (b->size & BLOCK_SIZE) + BHDR_OVERHEAD; \
} while(0)
#else
#define TLSF_ADD_SIZE(tlsf, b) do{}while(0)
#define TLSF_REMOVE_SIZE(tlsf, b) do{}while(0)
#define TLSF_ADD_SIZE(tlsf, b) do{}while(0)
#define TLSF_REMOVE_SIZE(tlsf, b) do{}while(0)
#endif
#if USE_MMAP || USE_SBRK
@ -125,37 +125,37 @@
/* Unlike the preview TLSF versions, now they are statics */
#define BLOCK_ALIGN (sizeof(void *) * 2)
#define MAX_FLI (30)
#define MAX_LOG2_SLI (5)
#define MAX_SLI (1 << MAX_LOG2_SLI) /* MAX_SLI = 2^MAX_LOG2_SLI */
#define MAX_FLI (30)
#define MAX_LOG2_SLI (5)
#define MAX_SLI (1 << MAX_LOG2_SLI) /* MAX_SLI = 2^MAX_LOG2_SLI */
#define FLI_OFFSET (6) /* tlsf structure just will manage blocks bigger */
#define FLI_OFFSET (6) /* tlsf structure just will manage blocks bigger */
/* than 128 bytes */
#define SMALL_BLOCK (128)
#define REAL_FLI (MAX_FLI - FLI_OFFSET)
#define MIN_BLOCK_SIZE (sizeof (free_ptr_t))
#define BHDR_OVERHEAD (sizeof (bhdr_t) - MIN_BLOCK_SIZE)
#define TLSF_SIGNATURE (0x2A59FA59)
#define SMALL_BLOCK (128)
#define REAL_FLI (MAX_FLI - FLI_OFFSET)
#define MIN_BLOCK_SIZE (sizeof (free_ptr_t))
#define BHDR_OVERHEAD (sizeof (bhdr_t) - MIN_BLOCK_SIZE)
#define TLSF_SIGNATURE (0x2A59FA59)
#define PTR_MASK (sizeof(void *) - 1)
#define BLOCK_SIZE (0xFFFFFFFF - PTR_MASK)
#define PTR_MASK (sizeof(void *) - 1)
#define BLOCK_SIZE (0xFFFFFFFF - PTR_MASK)
#define GET_NEXT_BLOCK(_addr, _r) ((bhdr_t *) ((char *) (_addr) + (_r)))
#define MEM_ALIGN ((BLOCK_ALIGN) - 1)
#define MEM_ALIGN ((BLOCK_ALIGN) - 1)
#define ROUNDUP_SIZE(_r) (((_r) + MEM_ALIGN) & ~MEM_ALIGN)
#define ROUNDDOWN_SIZE(_r) ((_r) & ~MEM_ALIGN)
#define ROUNDUP(_x, _v) ((((~(_x)) + 1) & ((_v)-1)) + (_x))
#define BLOCK_STATE (0x1)
#define PREV_STATE (0x2)
#define BLOCK_STATE (0x1)
#define PREV_STATE (0x2)
/* bit 0 of the block size */
#define FREE_BLOCK (0x1)
#define USED_BLOCK (0x0)
#define FREE_BLOCK (0x1)
#define USED_BLOCK (0x0)
/* bit 1 of the block size */
#define PREV_FREE (0x2)
#define PREV_USED (0x0)
#define PREV_FREE (0x2)
#define PREV_USED (0x0)
#define DEFAULT_AREA_SIZE (1024*10)
@ -352,46 +352,46 @@ static __inline__ bhdr_t *FIND_SUITABLE_BLOCK(tlsf_t * _tlsf, int *_fl, int *_sl
}
#define EXTRACT_BLOCK_HDR(_b, _tlsf, _fl, _sl) do { \
_tlsf -> matrix [_fl] [_sl] = _b -> ptr.free_ptr.next; \
if (_tlsf -> matrix[_fl][_sl]) \
_tlsf -> matrix[_fl][_sl] -> ptr.free_ptr.prev = NULL; \
else { \
clear_bit (_sl, &_tlsf -> sl_bitmap [_fl]); \
if (!_tlsf -> sl_bitmap [_fl]) \
clear_bit (_fl, &_tlsf -> fl_bitmap); \
} \
_b -> ptr.free_ptr.prev = NULL; \
_b -> ptr.free_ptr.next = NULL; \
}while(0)
#define EXTRACT_BLOCK_HDR(_b, _tlsf, _fl, _sl) do { \
_tlsf -> matrix [_fl] [_sl] = _b -> ptr.free_ptr.next; \
if (_tlsf -> matrix[_fl][_sl]) \
_tlsf -> matrix[_fl][_sl] -> ptr.free_ptr.prev = NULL; \
else { \
clear_bit (_sl, &_tlsf -> sl_bitmap [_fl]); \
if (!_tlsf -> sl_bitmap [_fl]) \
clear_bit (_fl, &_tlsf -> fl_bitmap); \
} \
_b -> ptr.free_ptr.prev = NULL; \
_b -> ptr.free_ptr.next = NULL; \
}while(0)
#define EXTRACT_BLOCK(_b, _tlsf, _fl, _sl) do { \
if (_b -> ptr.free_ptr.next) \
_b -> ptr.free_ptr.next -> ptr.free_ptr.prev = _b -> ptr.free_ptr.prev; \
if (_b -> ptr.free_ptr.prev) \
_b -> ptr.free_ptr.prev -> ptr.free_ptr.next = _b -> ptr.free_ptr.next; \
if (_tlsf -> matrix [_fl][_sl] == _b) { \
_tlsf -> matrix [_fl][_sl] = _b -> ptr.free_ptr.next; \
if (!_tlsf -> matrix [_fl][_sl]) { \
clear_bit (_sl, &_tlsf -> sl_bitmap[_fl]); \
if (!_tlsf -> sl_bitmap [_fl]) \
clear_bit (_fl, &_tlsf -> fl_bitmap); \
} \
} \
_b -> ptr.free_ptr.prev = NULL; \
_b -> ptr.free_ptr.next = NULL; \
} while(0)
#define EXTRACT_BLOCK(_b, _tlsf, _fl, _sl) do { \
if (_b -> ptr.free_ptr.next) \
_b -> ptr.free_ptr.next -> ptr.free_ptr.prev = _b -> ptr.free_ptr.prev; \
if (_b -> ptr.free_ptr.prev) \
_b -> ptr.free_ptr.prev -> ptr.free_ptr.next = _b -> ptr.free_ptr.next; \
if (_tlsf -> matrix [_fl][_sl] == _b) { \
_tlsf -> matrix [_fl][_sl] = _b -> ptr.free_ptr.next; \
if (!_tlsf -> matrix [_fl][_sl]) { \
clear_bit (_sl, &_tlsf -> sl_bitmap[_fl]); \
if (!_tlsf -> sl_bitmap [_fl]) \
clear_bit (_fl, &_tlsf -> fl_bitmap); \
} \
} \
_b -> ptr.free_ptr.prev = NULL; \
_b -> ptr.free_ptr.next = NULL; \
} while(0)
#define INSERT_BLOCK(_b, _tlsf, _fl, _sl) do { \
_b -> ptr.free_ptr.prev = NULL; \
_b -> ptr.free_ptr.next = _tlsf -> matrix [_fl][_sl]; \
if (_tlsf -> matrix [_fl][_sl]) \
_tlsf -> matrix [_fl][_sl] -> ptr.free_ptr.prev = _b; \
_tlsf -> matrix [_fl][_sl] = _b; \
set_bit (_sl, &_tlsf -> sl_bitmap [_fl]); \
set_bit (_fl, &_tlsf -> fl_bitmap); \
} while(0)
#define INSERT_BLOCK(_b, _tlsf, _fl, _sl) do { \
_b -> ptr.free_ptr.prev = NULL; \
_b -> ptr.free_ptr.next = _tlsf -> matrix [_fl][_sl]; \
if (_tlsf -> matrix [_fl][_sl]) \
_tlsf -> matrix [_fl][_sl] -> ptr.free_ptr.prev = _b; \
_tlsf -> matrix [_fl][_sl] = _b; \
set_bit (_sl, &_tlsf -> sl_bitmap [_fl]); \
set_bit (_fl, &_tlsf -> fl_bitmap); \
} while(0)
#if USE_SBRK || USE_MMAP
static __inline__ void *get_new_area(size_t * size)
@ -656,9 +656,9 @@ void *tlsf_realloc(void *ptr, size_t size)
void *ret;
#if USE_MMAP || USE_SBRK
if (!mp) {
return tlsf_malloc(size);
}
if (!mp) {
return tlsf_malloc(size);
}
#endif
TLSF_ACQUIRE_LOCK(&((tlsf_t *)mp)->lock);
@ -813,7 +813,7 @@ void *realloc_ex(void *ptr, size_t new_size, void *mem_pool)
new_size = (new_size < MIN_BLOCK_SIZE) ? MIN_BLOCK_SIZE : ROUNDUP_SIZE(new_size);
tmp_size = (b->size & BLOCK_SIZE);
if (new_size <= tmp_size) {
TLSF_REMOVE_SIZE(tlsf, b);
TLSF_REMOVE_SIZE(tlsf, b);
if (next_b->size & FREE_BLOCK) {
MAPPING_INSERT(next_b->size & BLOCK_SIZE, &fl, &sl);
EXTRACT_BLOCK(next_b, tlsf, fl, sl);
@ -833,12 +833,12 @@ void *realloc_ex(void *ptr, size_t new_size, void *mem_pool)
INSERT_BLOCK(tmp_b, tlsf, fl, sl);
b->size = new_size | (b->size & PREV_STATE);
}
TLSF_ADD_SIZE(tlsf, b);
TLSF_ADD_SIZE(tlsf, b);
return (void *) b->ptr.buffer;
}
if ((next_b->size & FREE_BLOCK)) {
if (new_size <= (tmp_size + (next_b->size & BLOCK_SIZE))) {
TLSF_REMOVE_SIZE(tlsf, b);
TLSF_REMOVE_SIZE(tlsf, b);
MAPPING_INSERT(next_b->size & BLOCK_SIZE, &fl, &sl);
EXTRACT_BLOCK(next_b, tlsf, fl, sl);
b->size += (next_b->size & BLOCK_SIZE) + BHDR_OVERHEAD;
@ -856,7 +856,7 @@ void *realloc_ex(void *ptr, size_t new_size, void *mem_pool)
INSERT_BLOCK(tmp_b, tlsf, fl, sl);
b->size = new_size | (b->size & PREV_STATE);
}
TLSF_ADD_SIZE(tlsf, b);
TLSF_ADD_SIZE(tlsf, b);
return (void *) b->ptr.buffer;
}
}

View file

@ -56,11 +56,11 @@ typedef struct a52_state_s a52_state_t;
a52_state_t * a52_init (uint32_t mm_accel);
sample_t * a52_samples (a52_state_t * state);
int a52_syncinfo (uint8_t * buf, int * flags,
int * sample_rate, int * bit_rate);
int * sample_rate, int * bit_rate);
int a52_frame (a52_state_t * state, uint8_t * buf, int * flags,
level_t * level, sample_t bias);
level_t * level, sample_t bias);
void a52_dynrng (a52_state_t * state,
level_t (* call) (level_t, void *), void * data);
level_t (* call) (level_t, void *), void * data);
int a52_block (a52_state_t * state);
void a52_free (a52_state_t * state);

View file

@ -22,62 +22,62 @@
*/
typedef struct {
uint8_t bai; /* fine SNR offset, fast gain */
uint8_t deltbae; /* delta bit allocation exists */
int8_t deltba[50]; /* per-band delta bit allocation */
uint8_t bai; /* fine SNR offset, fast gain */
uint8_t deltbae; /* delta bit allocation exists */
int8_t deltba[50]; /* per-band delta bit allocation */
} ba_t;
typedef struct {
uint8_t exp[256]; /* decoded channel exponents */
int8_t bap[256]; /* derived channel bit allocation */
uint8_t exp[256]; /* decoded channel exponents */
int8_t bap[256]; /* derived channel bit allocation */
} expbap_t;
struct a52_state_s {
uint8_t fscod; /* sample rate */
uint8_t halfrate; /* halfrate factor */
uint8_t acmod; /* coded channels */
uint8_t lfeon; /* coded lfe channel */
level_t clev; /* centre channel mix level */
level_t slev; /* surround channels mix level */
uint8_t fscod; /* sample rate */
uint8_t halfrate; /* halfrate factor */
uint8_t acmod; /* coded channels */
uint8_t lfeon; /* coded lfe channel */
level_t clev; /* centre channel mix level */
level_t slev; /* surround channels mix level */
int output; /* type of output */
level_t level; /* output level */
sample_t bias; /* output bias */
int output; /* type of output */
level_t level; /* output level */
sample_t bias; /* output bias */
int dynrnge; /* apply dynamic range */
level_t dynrng; /* dynamic range */
void * dynrngdata; /* dynamic range callback funtion and data */
int dynrnge; /* apply dynamic range */
level_t dynrng; /* dynamic range */
void * dynrngdata; /* dynamic range callback funtion and data */
level_t (* dynrngcall) (level_t range, void * dynrngdata);
uint8_t chincpl; /* channel coupled */
uint8_t phsflginu; /* phase flags in use (stereo only) */
uint8_t cplstrtmant; /* coupling channel start mantissa */
uint8_t cplendmant; /* coupling channel end mantissa */
uint32_t cplbndstrc; /* coupling band structure */
level_t cplco[5][18]; /* coupling coordinates */
uint8_t chincpl; /* channel coupled */
uint8_t phsflginu; /* phase flags in use (stereo only) */
uint8_t cplstrtmant; /* coupling channel start mantissa */
uint8_t cplendmant; /* coupling channel end mantissa */
uint32_t cplbndstrc; /* coupling band structure */
level_t cplco[5][18]; /* coupling coordinates */
/* derived information */
uint8_t cplstrtbnd; /* coupling start band (for bit allocation) */
uint8_t ncplbnd; /* number of coupling bands */
uint8_t cplstrtbnd; /* coupling start band (for bit allocation) */
uint8_t ncplbnd; /* number of coupling bands */
uint8_t rematflg; /* stereo rematrixing */
uint8_t rematflg; /* stereo rematrixing */
uint8_t endmant[5]; /* channel end mantissa */
uint8_t endmant[5]; /* channel end mantissa */
uint16_t bai; /* bit allocation information */
uint16_t bai; /* bit allocation information */
uint32_t * buffer_start;
uint16_t lfsr_state; /* dither state */
uint16_t lfsr_state; /* dither state */
uint32_t bits_left;
uint32_t current_word;
uint8_t csnroffst; /* coarse SNR offset */
ba_t cplba; /* coupling bit allocation parameters */
ba_t ba[5]; /* channel bit allocation parameters */
ba_t lfeba; /* lfe bit allocation parameters */
uint8_t csnroffst; /* coarse SNR offset */
ba_t cplba; /* coupling bit allocation parameters */
ba_t ba[5]; /* channel bit allocation parameters */
ba_t lfeba; /* lfe bit allocation parameters */
uint8_t cplfleak; /* coupling fast leak init */
uint8_t cplsleak; /* coupling slow leak init */
uint8_t cplfleak; /* coupling fast leak init */
uint8_t cplsleak; /* coupling slow leak init */
expbap_t cpl_expbap;
expbap_t fbw_expbap[5];
@ -104,15 +104,15 @@ struct a52_state_s {
#define DELTA_BIT_RESERVED (3)
void a52_bit_allocate (a52_state_t * state, ba_t * ba, int bndstart,
int start, int end, int fastleak, int slowleak,
expbap_t * expbap);
int start, int end, int fastleak, int slowleak,
expbap_t * expbap);
int a52_downmix_init (int input, int flags, level_t * level,
level_t clev, level_t slev);
level_t clev, level_t slev);
int a52_downmix_coeff (level_t * coeff, int acmod, int output, level_t level,
level_t clev, level_t slev);
level_t clev, level_t slev);
void a52_downmix (sample_t * samples, int acmod, int output,
level_t clev, level_t slev);
level_t clev, level_t slev);
void a52_upmix (sample_t * samples, int acmod, int output);
void a52_imdct_init (uint32_t mm_accel);

View file

@ -52,7 +52,7 @@ static int8_t baptab[305] IDATA_ATTR = {
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* 93 padding elems */
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* 93 padding elems */
16, 16, 16, 16, 16, 16, 16, 16, 16, 14, 14, 14, 14, 14, 14, 14,
14, 12, 12, 12, 12, 11, 11, 11, 11, 10, 10, 10, 10, 9, 9, 9,
@ -68,12 +68,12 @@ static int8_t baptab[305] IDATA_ATTR = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0 /* 148 padding elems */
0, 0, 0, 0 /* 148 padding elems */
};
static int bndtab[30] IDATA_ATTR = {21, 22, 23, 24, 25, 26, 27, 28, 31, 34,
37, 40, 43, 46, 49, 55, 61, 67, 73, 79,
85, 97, 109, 121, 133, 157, 181, 205, 229, 253};
37, 40, 43, 46, 49, 55, 61, 67, 73, 79,
85, 97, 109, 121, 133, 157, 181, 205, 229, 253};
static int8_t latab[256] IDATA_ATTR = {
-64, -63, -62, -61, -60, -59, -58, -57, -56, -55, -54, -53,
@ -100,35 +100,35 @@ static int8_t latab[256] IDATA_ATTR = {
0, 0, 0, 0
};
#define UPDATE_LEAK() \
do { \
fastleak += fdecay; \
if (fastleak > psd + fgain) \
fastleak = psd + fgain; \
slowleak += sdecay; \
if (slowleak > psd + sgain) \
slowleak = psd + sgain; \
#define UPDATE_LEAK() \
do { \
fastleak += fdecay; \
if (fastleak > psd + fgain) \
fastleak = psd + fgain; \
slowleak += sdecay; \
if (slowleak > psd + sgain) \
slowleak = psd + sgain; \
} while (0)
#define COMPUTE_MASK() \
do { \
if (psd > dbknee) \
mask -= (psd - dbknee) >> 2; \
if (mask > hth [i >> halfrate]) \
mask = hth [i >> halfrate]; \
mask -= snroffset + 128 * deltba[i]; \
mask = (mask > 0) ? 0 : ((-mask) >> 5); \
mask -= floor; \
#define COMPUTE_MASK() \
do { \
if (psd > dbknee) \
mask -= (psd - dbknee) >> 2; \
if (mask > hth [i >> halfrate]) \
mask = hth [i >> halfrate]; \
mask -= snroffset + 128 * deltba[i]; \
mask = (mask > 0) ? 0 : ((-mask) >> 5); \
mask -= floor; \
} while (0)
void a52_bit_allocate (a52_state_t * state, ba_t * ba, int bndstart,
int start, int end, int fastleak, int slowleak,
expbap_t * expbap)
int start, int end, int fastleak, int slowleak,
expbap_t * expbap)
{
static int slowgain[4] = {0x540, 0x4d8, 0x478, 0x410};
static int dbpbtab[4] = {0xc00, 0x500, 0x300, 0x100};
static int floortab[8] = {0x910, 0x950, 0x990, 0x9d0,
0xa10, 0xa90, 0xb10, 0x1400};
0xa10, 0xa90, 0xb10, 0x1400};
int i, j;
uint8_t * exp;
@ -140,18 +140,18 @@ void a52_bit_allocate (a52_state_t * state, ba_t * ba, int bndstart,
int halfrate;
halfrate = state->halfrate;
fdecay = (63 + 20 * ((state->bai >> 7) & 3)) >> halfrate; /* fdcycod */
fgain = 128 + 128 * (ba->bai & 7); /* fgaincod */
sdecay = (15 + 2 * (state->bai >> 9)) >> halfrate; /* sdcycod */
sgain = slowgain[(state->bai >> 5) & 3]; /* sgaincod */
dbknee = dbpbtab[(state->bai >> 3) & 3]; /* dbpbcod */
fdecay = (63 + 20 * ((state->bai >> 7) & 3)) >> halfrate; /* fdcycod */
fgain = 128 + 128 * (ba->bai & 7); /* fgaincod */
sdecay = (15 + 2 * (state->bai >> 9)) >> halfrate; /* sdcycod */
sgain = slowgain[(state->bai >> 5) & 3]; /* sgaincod */
dbknee = dbpbtab[(state->bai >> 3) & 3]; /* dbpbcod */
hth = hthtab[state->fscod];
/*
* if there is no delta bit allocation, make deltba point to an area
* known to contain zeroes. baptab+156 here.
*/
deltba = (ba->deltbae == DELTA_BIT_NONE) ? baptab + 156 : ba->deltba;
floor = floortab[state->bai & 7]; /* floorcod */
floor = floortab[state->bai & 7]; /* floorcod */
snroffset = 960 - 64 * state->csnroffst - 4 * (ba->bai >> 3) + floor;
floor >>= 5;
@ -160,106 +160,106 @@ void a52_bit_allocate (a52_state_t * state, ba_t * ba, int bndstart,
i = bndstart;
j = start;
if (start == 0) { /* not the coupling channel */
int lowcomp;
if (start == 0) { /* not the coupling channel */
int lowcomp;
lowcomp = 0;
j = end - 1;
do {
if (i < j) {
if (exp[i+1] == exp[i] - 2)
lowcomp = 384;
else if (lowcomp && (exp[i+1] > exp[i]))
lowcomp -= 64;
}
psd = 128 * exp[i];
mask = psd + fgain + lowcomp;
COMPUTE_MASK ();
bap[i] = (baptab+156)[mask + 4 * exp[i]];
i++;
} while ((i < 3) || ((i < 7) && (exp[i] > exp[i-1])));
fastleak = psd + fgain;
slowleak = psd + sgain;
lowcomp = 0;
j = end - 1;
do {
if (i < j) {
if (exp[i+1] == exp[i] - 2)
lowcomp = 384;
else if (lowcomp && (exp[i+1] > exp[i]))
lowcomp -= 64;
}
psd = 128 * exp[i];
mask = psd + fgain + lowcomp;
COMPUTE_MASK ();
bap[i] = (baptab+156)[mask + 4 * exp[i]];
i++;
} while ((i < 3) || ((i < 7) && (exp[i] > exp[i-1])));
fastleak = psd + fgain;
slowleak = psd + sgain;
while (i < 7) {
if (i < j) {
if (exp[i+1] == exp[i] - 2)
lowcomp = 384;
else if (lowcomp && (exp[i+1] > exp[i]))
lowcomp -= 64;
}
psd = 128 * exp[i];
UPDATE_LEAK ();
mask = ((fastleak + lowcomp < slowleak) ?
fastleak + lowcomp : slowleak);
COMPUTE_MASK ();
bap[i] = (baptab+156)[mask + 4 * exp[i]];
i++;
}
while (i < 7) {
if (i < j) {
if (exp[i+1] == exp[i] - 2)
lowcomp = 384;
else if (lowcomp && (exp[i+1] > exp[i]))
lowcomp -= 64;
}
psd = 128 * exp[i];
UPDATE_LEAK ();
mask = ((fastleak + lowcomp < slowleak) ?
fastleak + lowcomp : slowleak);
COMPUTE_MASK ();
bap[i] = (baptab+156)[mask + 4 * exp[i]];
i++;
}
if (end == 7) /* lfe channel */
return;
if (end == 7) /* lfe channel */
return;
do {
if (exp[i+1] == exp[i] - 2)
lowcomp = 320;
else if (lowcomp && (exp[i+1] > exp[i]))
lowcomp -= 64;
psd = 128 * exp[i];
UPDATE_LEAK ();
mask = ((fastleak + lowcomp < slowleak) ?
fastleak + lowcomp : slowleak);
COMPUTE_MASK ();
bap[i] = (baptab+156)[mask + 4 * exp[i]];
i++;
} while (i < 20);
do {
if (exp[i+1] == exp[i] - 2)
lowcomp = 320;
else if (lowcomp && (exp[i+1] > exp[i]))
lowcomp -= 64;
psd = 128 * exp[i];
UPDATE_LEAK ();
mask = ((fastleak + lowcomp < slowleak) ?
fastleak + lowcomp : slowleak);
COMPUTE_MASK ();
bap[i] = (baptab+156)[mask + 4 * exp[i]];
i++;
} while (i < 20);
while (lowcomp > 128) { /* two iterations maximum */
lowcomp -= 128;
psd = 128 * exp[i];
UPDATE_LEAK ();
mask = ((fastleak + lowcomp < slowleak) ?
fastleak + lowcomp : slowleak);
COMPUTE_MASK ();
bap[i] = (baptab+156)[mask + 4 * exp[i]];
i++;
}
j = i;
while (lowcomp > 128) { /* two iterations maximum */
lowcomp -= 128;
psd = 128 * exp[i];
UPDATE_LEAK ();
mask = ((fastleak + lowcomp < slowleak) ?
fastleak + lowcomp : slowleak);
COMPUTE_MASK ();
bap[i] = (baptab+156)[mask + 4 * exp[i]];
i++;
}
j = i;
}
do {
int startband, endband;
int startband, endband;
startband = j;
endband = (bndtab[i-20] < end) ? bndtab[i-20] : end;
psd = 128 * exp[j++];
while (j < endband) {
int next, delta;
startband = j;
endband = (bndtab[i-20] < end) ? bndtab[i-20] : end;
psd = 128 * exp[j++];
while (j < endband) {
int next, delta;
next = 128 * exp[j++];
delta = next - psd;
switch (delta >> 9) {
case -6: case -5: case -4: case -3: case -2:
psd = next;
break;
case -1:
psd = next + latab[(-delta) >> 1];
break;
case 0:
psd += latab[delta >> 1];
break;
}
}
/* minpsd = -289 */
UPDATE_LEAK ();
mask = (fastleak < slowleak) ? fastleak : slowleak;
COMPUTE_MASK ();
i++;
j = startband;
do {
/* max(mask+4*exp)=147=-(minpsd+fgain-deltba-snroffset)>>5+4*exp */
/* min(mask+4*exp)=-156=-(sgain-deltba-snroffset)>>5 */
bap[j] = (baptab+156)[mask + 4 * exp[j]];
} while (++j < endband);
next = 128 * exp[j++];
delta = next - psd;
switch (delta >> 9) {
case -6: case -5: case -4: case -3: case -2:
psd = next;
break;
case -1:
psd = next + latab[(-delta) >> 1];
break;
case 0:
psd += latab[delta >> 1];
break;
}
}
/* minpsd = -289 */
UPDATE_LEAK ();
mask = (fastleak < slowleak) ? fastleak : slowleak;
COMPUTE_MASK ();
i++;
j = startband;
do {
/* max(mask+4*exp)=147=-(minpsd+fgain-deltba-snroffset)>>5+4*exp */
/* min(mask+4*exp)=-156=-(sgain-deltba-snroffset)>>5 */
bap[j] = (baptab+156)[mask + 4 * exp[j]];
} while (++j < endband);
} while (j < end);
}

View file

@ -40,7 +40,7 @@ void a52_bitstream_set_ptr (a52_state_t * state, uint8_t * buf)
state->bits_left = 0;
state->current_word = 0;
bitstream_get (state, align * 8);
bitstream_get_2 (state, 0); /* pretend function is used - keep gcc happy */
bitstream_get_2 (state, 0); /* pretend function is used - keep gcc happy */
}
static inline void bitstream_fill_current (a52_state_t * state)
@ -66,12 +66,12 @@ uint32_t a52_bitstream_get_bh (a52_state_t * state, uint32_t num_bits)
num_bits -= state->bits_left;
result = ((state->current_word << (32 - state->bits_left)) >>
(32 - state->bits_left));
(32 - state->bits_left));
bitstream_fill_current (state);
if (num_bits != 0)
result = (result << num_bits) | (state->current_word >> (32 - num_bits));
result = (result << num_bits) | (state->current_word >> (32 - num_bits));
state->bits_left = 32 - num_bits;
@ -84,13 +84,13 @@ int32_t a52_bitstream_get_bh_2 (a52_state_t * state, uint32_t num_bits)
num_bits -= state->bits_left;
result = ((((int32_t)state->current_word) << (32 - state->bits_left)) >>
(32 - state->bits_left));
(32 - state->bits_left));
bitstream_fill_current(state);
if (num_bits != 0)
result = (result << num_bits) | (state->current_word >> (32 - num_bits));
result = (result << num_bits) | (state->current_word >> (32 - num_bits));
state->bits_left = 32 - num_bits;
return result;

View file

@ -30,11 +30,11 @@ int32_t a52_bitstream_get_bh_2 (a52_state_t * state, uint32_t num_bits);
static inline uint32_t bitstream_get (a52_state_t * state, uint32_t num_bits)
{
uint32_t result;
if (num_bits < state->bits_left) {
result = (state->current_word << (32 - state->bits_left)) >> (32 - num_bits);
state->bits_left -= num_bits;
return result;
result = (state->current_word << (32 - state->bits_left)) >> (32 - num_bits);
state->bits_left -= num_bits;
return result;
}
return a52_bitstream_get_bh (state, num_bits);
@ -43,11 +43,11 @@ static inline uint32_t bitstream_get (a52_state_t * state, uint32_t num_bits)
static inline int32_t bitstream_get_2 (a52_state_t * state, uint32_t num_bits)
{
int32_t result;
if (num_bits < state->bits_left) {
result = (((int32_t)state->current_word) << (32 - state->bits_left)) >> (32 - num_bits);
state->bits_left -= num_bits;
return result;
result = (((int32_t)state->current_word) << (32 - state->bits_left)) >> (32 - num_bits);
state->bits_left -= num_bits;
return result;
}
return a52_bitstream_get_bh_2 (state, num_bits);

View file

@ -32,135 +32,135 @@
#define CONVERT(acmod,output) (((output) << 3) + (acmod))
int a52_downmix_init (int input, int flags, level_t * level,
level_t clev, level_t slev)
level_t clev, level_t slev)
{
static uint8_t table[11][8] = {
{A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_STEREO,
A52_STEREO, A52_STEREO, A52_STEREO, A52_STEREO},
{A52_MONO, A52_MONO, A52_MONO, A52_MONO,
A52_MONO, A52_MONO, A52_MONO, A52_MONO},
{A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_STEREO,
A52_STEREO, A52_STEREO, A52_STEREO, A52_STEREO},
{A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_3F,
A52_STEREO, A52_3F, A52_STEREO, A52_3F},
{A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_STEREO,
A52_2F1R, A52_2F1R, A52_2F1R, A52_2F1R},
{A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_STEREO,
A52_2F1R, A52_3F1R, A52_2F1R, A52_3F1R},
{A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_3F,
A52_2F2R, A52_2F2R, A52_2F2R, A52_2F2R},
{A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_3F,
A52_2F2R, A52_3F2R, A52_2F2R, A52_3F2R},
{A52_CHANNEL1, A52_MONO, A52_MONO, A52_MONO,
A52_MONO, A52_MONO, A52_MONO, A52_MONO},
{A52_CHANNEL2, A52_MONO, A52_MONO, A52_MONO,
A52_MONO, A52_MONO, A52_MONO, A52_MONO},
{A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_DOLBY,
A52_DOLBY, A52_DOLBY, A52_DOLBY, A52_DOLBY}
{A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_STEREO,
A52_STEREO, A52_STEREO, A52_STEREO, A52_STEREO},
{A52_MONO, A52_MONO, A52_MONO, A52_MONO,
A52_MONO, A52_MONO, A52_MONO, A52_MONO},
{A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_STEREO,
A52_STEREO, A52_STEREO, A52_STEREO, A52_STEREO},
{A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_3F,
A52_STEREO, A52_3F, A52_STEREO, A52_3F},
{A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_STEREO,
A52_2F1R, A52_2F1R, A52_2F1R, A52_2F1R},
{A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_STEREO,
A52_2F1R, A52_3F1R, A52_2F1R, A52_3F1R},
{A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_3F,
A52_2F2R, A52_2F2R, A52_2F2R, A52_2F2R},
{A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_3F,
A52_2F2R, A52_3F2R, A52_2F2R, A52_3F2R},
{A52_CHANNEL1, A52_MONO, A52_MONO, A52_MONO,
A52_MONO, A52_MONO, A52_MONO, A52_MONO},
{A52_CHANNEL2, A52_MONO, A52_MONO, A52_MONO,
A52_MONO, A52_MONO, A52_MONO, A52_MONO},
{A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_DOLBY,
A52_DOLBY, A52_DOLBY, A52_DOLBY, A52_DOLBY}
};
int output;
output = flags & A52_CHANNEL_MASK;
if (output > A52_DOLBY)
return -1;
return -1;
output = table[output][input & 7];
if (output == A52_STEREO &&
(input == A52_DOLBY || (input == A52_3F && clev == LEVEL (LEVEL_3DB))))
output = A52_DOLBY;
(input == A52_DOLBY || (input == A52_3F && clev == LEVEL (LEVEL_3DB))))
output = A52_DOLBY;
if (flags & A52_ADJUST_LEVEL) {
level_t adjust;
level_t adjust;
switch (CONVERT (input & 7, output)) {
switch (CONVERT (input & 7, output)) {
case CONVERT (A52_3F, A52_MONO):
adjust = DIV (LEVEL_3DB, LEVEL (1) + clev);
break;
case CONVERT (A52_3F, A52_MONO):
adjust = DIV (LEVEL_3DB, LEVEL (1) + clev);
break;
case CONVERT (A52_STEREO, A52_MONO):
case CONVERT (A52_2F2R, A52_2F1R):
case CONVERT (A52_3F2R, A52_3F1R):
level_3db:
adjust = LEVEL (LEVEL_3DB);
break;
case CONVERT (A52_STEREO, A52_MONO):
case CONVERT (A52_2F2R, A52_2F1R):
case CONVERT (A52_3F2R, A52_3F1R):
level_3db:
adjust = LEVEL (LEVEL_3DB);
break;
case CONVERT (A52_3F2R, A52_2F1R):
if (clev < LEVEL (LEVEL_PLUS3DB - 1))
goto level_3db;
/* break thru */
case CONVERT (A52_3F, A52_STEREO):
case CONVERT (A52_3F1R, A52_2F1R):
case CONVERT (A52_3F1R, A52_2F2R):
case CONVERT (A52_3F2R, A52_2F2R):
adjust = DIV (1, LEVEL (1) + clev);
break;
case CONVERT (A52_3F2R, A52_2F1R):
if (clev < LEVEL (LEVEL_PLUS3DB - 1))
goto level_3db;
/* break thru */
case CONVERT (A52_3F, A52_STEREO):
case CONVERT (A52_3F1R, A52_2F1R):
case CONVERT (A52_3F1R, A52_2F2R):
case CONVERT (A52_3F2R, A52_2F2R):
adjust = DIV (1, LEVEL (1) + clev);
break;
case CONVERT (A52_2F1R, A52_MONO):
adjust = DIV (LEVEL_PLUS3DB, LEVEL (2) + slev);
break;
case CONVERT (A52_2F1R, A52_MONO):
adjust = DIV (LEVEL_PLUS3DB, LEVEL (2) + slev);
break;
case CONVERT (A52_2F1R, A52_STEREO):
case CONVERT (A52_3F1R, A52_3F):
adjust = DIV (1, LEVEL (1) + MUL_C (slev, LEVEL_3DB));
break;
case CONVERT (A52_2F1R, A52_STEREO):
case CONVERT (A52_3F1R, A52_3F):
adjust = DIV (1, LEVEL (1) + MUL_C (slev, LEVEL_3DB));
break;
case CONVERT (A52_3F1R, A52_MONO):
adjust = DIV (LEVEL_3DB, LEVEL (1) + clev + MUL_C (slev, 0.5));
break;
case CONVERT (A52_3F1R, A52_MONO):
adjust = DIV (LEVEL_3DB, LEVEL (1) + clev + MUL_C (slev, 0.5));
break;
case CONVERT (A52_3F1R, A52_STEREO):
adjust = DIV (1, LEVEL (1) + clev + MUL_C (slev, LEVEL_3DB));
break;
case CONVERT (A52_3F1R, A52_STEREO):
adjust = DIV (1, LEVEL (1) + clev + MUL_C (slev, LEVEL_3DB));
break;
case CONVERT (A52_2F2R, A52_MONO):
adjust = DIV (LEVEL_3DB, LEVEL (1) + slev);
break;
case CONVERT (A52_2F2R, A52_MONO):
adjust = DIV (LEVEL_3DB, LEVEL (1) + slev);
break;
case CONVERT (A52_2F2R, A52_STEREO):
case CONVERT (A52_3F2R, A52_3F):
adjust = DIV (1, LEVEL (1) + slev);
break;
case CONVERT (A52_2F2R, A52_STEREO):
case CONVERT (A52_3F2R, A52_3F):
adjust = DIV (1, LEVEL (1) + slev);
break;
case CONVERT (A52_3F2R, A52_MONO):
adjust = DIV (LEVEL_3DB, LEVEL (1) + clev + slev);
break;
case CONVERT (A52_3F2R, A52_MONO):
adjust = DIV (LEVEL_3DB, LEVEL (1) + clev + slev);
break;
case CONVERT (A52_3F2R, A52_STEREO):
adjust = DIV (1, LEVEL (1) + clev + slev);
break;
case CONVERT (A52_3F2R, A52_STEREO):
adjust = DIV (1, LEVEL (1) + clev + slev);
break;
case CONVERT (A52_MONO, A52_DOLBY):
adjust = LEVEL (LEVEL_PLUS3DB);
break;
case CONVERT (A52_MONO, A52_DOLBY):
adjust = LEVEL (LEVEL_PLUS3DB);
break;
case CONVERT (A52_3F, A52_DOLBY):
case CONVERT (A52_2F1R, A52_DOLBY):
adjust = LEVEL (1 / (1 + LEVEL_3DB));
break;
case CONVERT (A52_3F, A52_DOLBY):
case CONVERT (A52_2F1R, A52_DOLBY):
adjust = LEVEL (1 / (1 + LEVEL_3DB));
break;
case CONVERT (A52_3F1R, A52_DOLBY):
case CONVERT (A52_2F2R, A52_DOLBY):
adjust = LEVEL (1 / (1 + 2 * LEVEL_3DB));
break;
case CONVERT (A52_3F1R, A52_DOLBY):
case CONVERT (A52_2F2R, A52_DOLBY):
adjust = LEVEL (1 / (1 + 2 * LEVEL_3DB));
break;
case CONVERT (A52_3F2R, A52_DOLBY):
adjust = LEVEL (1 / (1 + 3 * LEVEL_3DB));
break;
case CONVERT (A52_3F2R, A52_DOLBY):
adjust = LEVEL (1 / (1 + 3 * LEVEL_3DB));
break;
default:
return output;
}
default:
return output;
}
*level = MUL_L (*level, adjust);
*level = MUL_L (*level, adjust);
}
return output;
}
int a52_downmix_coeff (level_t * coeff, int acmod, int output, level_t level,
level_t clev, level_t slev)
level_t clev, level_t slev)
{
level_t level_3db;
@ -177,156 +177,156 @@ int a52_downmix_coeff (level_t * coeff, int acmod, int output, level_t level,
case CONVERT (A52_2F2R, A52_2F2R):
case CONVERT (A52_3F2R, A52_3F2R):
case CONVERT (A52_STEREO, A52_DOLBY):
coeff[0] = coeff[1] = coeff[2] = coeff[3] = coeff[4] = level;
return 0;
coeff[0] = coeff[1] = coeff[2] = coeff[3] = coeff[4] = level;
return 0;
case CONVERT (A52_CHANNEL, A52_MONO):
coeff[0] = coeff[1] = MUL_C (level, LEVEL_6DB);
return 3;
coeff[0] = coeff[1] = MUL_C (level, LEVEL_6DB);
return 3;
case CONVERT (A52_STEREO, A52_MONO):
coeff[0] = coeff[1] = level_3db;
return 3;
coeff[0] = coeff[1] = level_3db;
return 3;
case CONVERT (A52_3F, A52_MONO):
coeff[0] = coeff[2] = level_3db;
coeff[1] = MUL_C (MUL_L (level_3db, clev), LEVEL_PLUS6DB);
return 7;
coeff[0] = coeff[2] = level_3db;
coeff[1] = MUL_C (MUL_L (level_3db, clev), LEVEL_PLUS6DB);
return 7;
case CONVERT (A52_2F1R, A52_MONO):
coeff[0] = coeff[1] = level_3db;
coeff[2] = MUL_L (level_3db, slev);
return 7;
coeff[0] = coeff[1] = level_3db;
coeff[2] = MUL_L (level_3db, slev);
return 7;
case CONVERT (A52_2F2R, A52_MONO):
coeff[0] = coeff[1] = level_3db;
coeff[2] = coeff[3] = MUL_L (level_3db, slev);
return 15;
coeff[0] = coeff[1] = level_3db;
coeff[2] = coeff[3] = MUL_L (level_3db, slev);
return 15;
case CONVERT (A52_3F1R, A52_MONO):
coeff[0] = coeff[2] = level_3db;
coeff[1] = MUL_C (MUL_L (level_3db, clev), LEVEL_PLUS6DB);
coeff[3] = MUL_L (level_3db, slev);
return 15;
coeff[0] = coeff[2] = level_3db;
coeff[1] = MUL_C (MUL_L (level_3db, clev), LEVEL_PLUS6DB);
coeff[3] = MUL_L (level_3db, slev);
return 15;
case CONVERT (A52_3F2R, A52_MONO):
coeff[0] = coeff[2] = level_3db;
coeff[1] = MUL_C (MUL_L (level_3db, clev), LEVEL_PLUS6DB);
coeff[3] = coeff[4] = MUL_L (level_3db, slev);
return 31;
coeff[0] = coeff[2] = level_3db;
coeff[1] = MUL_C (MUL_L (level_3db, clev), LEVEL_PLUS6DB);
coeff[3] = coeff[4] = MUL_L (level_3db, slev);
return 31;
case CONVERT (A52_MONO, A52_DOLBY):
coeff[0] = level_3db;
return 0;
coeff[0] = level_3db;
return 0;
case CONVERT (A52_3F, A52_DOLBY):
coeff[0] = coeff[2] = coeff[3] = coeff[4] = level;
coeff[1] = level_3db;
return 7;
coeff[0] = coeff[2] = coeff[3] = coeff[4] = level;
coeff[1] = level_3db;
return 7;
case CONVERT (A52_3F, A52_STEREO):
case CONVERT (A52_3F1R, A52_2F1R):
case CONVERT (A52_3F2R, A52_2F2R):
coeff[0] = coeff[2] = coeff[3] = coeff[4] = level;
coeff[1] = MUL_L (level, clev);
return 7;
coeff[0] = coeff[2] = coeff[3] = coeff[4] = level;
coeff[1] = MUL_L (level, clev);
return 7;
case CONVERT (A52_2F1R, A52_DOLBY):
coeff[0] = coeff[1] = level;
coeff[2] = level_3db;
return 7;
coeff[0] = coeff[1] = level;
coeff[2] = level_3db;
return 7;
case CONVERT (A52_2F1R, A52_STEREO):
coeff[0] = coeff[1] = level;
coeff[2] = MUL_L (level_3db, slev);
return 7;
coeff[0] = coeff[1] = level;
coeff[2] = MUL_L (level_3db, slev);
return 7;
case CONVERT (A52_3F1R, A52_DOLBY):
coeff[0] = coeff[2] = level;
coeff[1] = coeff[3] = level_3db;
return 15;
coeff[0] = coeff[2] = level;
coeff[1] = coeff[3] = level_3db;
return 15;
case CONVERT (A52_3F1R, A52_STEREO):
coeff[0] = coeff[2] = level;
coeff[1] = MUL_L (level, clev);
coeff[3] = MUL_L (level_3db, slev);
return 15;
coeff[0] = coeff[2] = level;
coeff[1] = MUL_L (level, clev);
coeff[3] = MUL_L (level_3db, slev);
return 15;
case CONVERT (A52_2F2R, A52_DOLBY):
coeff[0] = coeff[1] = level;
coeff[2] = coeff[3] = level_3db;
return 15;
coeff[0] = coeff[1] = level;
coeff[2] = coeff[3] = level_3db;
return 15;
case CONVERT (A52_2F2R, A52_STEREO):
coeff[0] = coeff[1] = level;
coeff[2] = coeff[3] = MUL_L (level, slev);
return 15;
coeff[0] = coeff[1] = level;
coeff[2] = coeff[3] = MUL_L (level, slev);
return 15;
case CONVERT (A52_3F2R, A52_DOLBY):
coeff[0] = coeff[2] = level;
coeff[1] = coeff[3] = coeff[4] = level_3db;
return 31;
coeff[0] = coeff[2] = level;
coeff[1] = coeff[3] = coeff[4] = level_3db;
return 31;
case CONVERT (A52_3F2R, A52_2F1R):
coeff[0] = coeff[2] = level;
coeff[1] = MUL_L (level, clev);
coeff[3] = coeff[4] = level_3db;
return 31;
coeff[0] = coeff[2] = level;
coeff[1] = MUL_L (level, clev);
coeff[3] = coeff[4] = level_3db;
return 31;
case CONVERT (A52_3F2R, A52_STEREO):
coeff[0] = coeff[2] = level;
coeff[1] = MUL_L (level, clev);
coeff[3] = coeff[4] = MUL_L (level, slev);
return 31;
coeff[0] = coeff[2] = level;
coeff[1] = MUL_L (level, clev);
coeff[3] = coeff[4] = MUL_L (level, slev);
return 31;
case CONVERT (A52_3F1R, A52_3F):
coeff[0] = coeff[1] = coeff[2] = level;
coeff[3] = MUL_L (level_3db, slev);
return 13;
coeff[0] = coeff[1] = coeff[2] = level;
coeff[3] = MUL_L (level_3db, slev);
return 13;
case CONVERT (A52_3F2R, A52_3F):
coeff[0] = coeff[1] = coeff[2] = level;
coeff[3] = coeff[4] = MUL_L (level, slev);
return 29;
coeff[0] = coeff[1] = coeff[2] = level;
coeff[3] = coeff[4] = MUL_L (level, slev);
return 29;
case CONVERT (A52_2F2R, A52_2F1R):
coeff[0] = coeff[1] = level;
coeff[2] = coeff[3] = level_3db;
return 12;
coeff[0] = coeff[1] = level;
coeff[2] = coeff[3] = level_3db;
return 12;
case CONVERT (A52_3F2R, A52_3F1R):
coeff[0] = coeff[1] = coeff[2] = level;
coeff[3] = coeff[4] = level_3db;
return 24;
coeff[0] = coeff[1] = coeff[2] = level;
coeff[3] = coeff[4] = level_3db;
return 24;
case CONVERT (A52_2F1R, A52_2F2R):
coeff[0] = coeff[1] = level;
coeff[2] = level_3db;
return 0;
coeff[0] = coeff[1] = level;
coeff[2] = level_3db;
return 0;
case CONVERT (A52_3F1R, A52_2F2R):
coeff[0] = coeff[2] = level;
coeff[1] = MUL_L (level, clev);
coeff[3] = level_3db;
return 7;
coeff[0] = coeff[2] = level;
coeff[1] = MUL_L (level, clev);
coeff[3] = level_3db;
return 7;
case CONVERT (A52_3F1R, A52_3F2R):
coeff[0] = coeff[1] = coeff[2] = level;
coeff[3] = level_3db;
return 0;
coeff[0] = coeff[1] = coeff[2] = level;
coeff[3] = level_3db;
return 0;
case CONVERT (A52_CHANNEL, A52_CHANNEL1):
coeff[0] = level;
coeff[1] = 0;
return 0;
coeff[0] = level;
coeff[1] = 0;
return 0;
case CONVERT (A52_CHANNEL, A52_CHANNEL2):
coeff[0] = 0;
coeff[1] = level;
return 0;
coeff[0] = 0;
coeff[1] = level;
return 0;
}
return -1; /* NOTREACHED */
return -1; /* NOTREACHED */
}
static void mix2to1 (sample_t * dest, sample_t * src)
@ -334,7 +334,7 @@ static void mix2to1 (sample_t * dest, sample_t * src)
int i;
for (i = 0; i < 256; i++)
dest[i] += BIAS (src[i]);
dest[i] += BIAS (src[i]);
}
static void mix3to1 (sample_t * samples)
@ -342,7 +342,7 @@ static void mix3to1 (sample_t * samples)
int i;
for (i = 0; i < 256; i++)
samples[i] += BIAS (samples[i + 256] + samples[i + 512]);
samples[i] += BIAS (samples[i + 256] + samples[i + 512]);
}
static void mix4to1 (sample_t * samples)
@ -350,8 +350,8 @@ static void mix4to1 (sample_t * samples)
int i;
for (i = 0; i < 256; i++)
samples[i] += BIAS (samples[i + 256] + samples[i + 512] +
samples[i + 768]);
samples[i] += BIAS (samples[i + 256] + samples[i + 512] +
samples[i + 768]);
}
static void mix5to1 (sample_t * samples)
@ -359,8 +359,8 @@ static void mix5to1 (sample_t * samples)
int i;
for (i = 0; i < 256; i++)
samples[i] += BIAS (samples[i + 256] + samples[i + 512] +
samples[i + 768] + samples[i + 1024]);
samples[i] += BIAS (samples[i + 256] + samples[i + 512] +
samples[i + 768] + samples[i + 1024]);
}
static void mix3to2 (sample_t * samples)
@ -369,9 +369,9 @@ static void mix3to2 (sample_t * samples)
sample_t common;
for (i = 0; i < 256; i++) {
common = BIAS (samples[i + 256]);
samples[i] += common;
samples[i + 256] = samples[i + 512] + common;
common = BIAS (samples[i + 256]);
samples[i] += common;
samples[i + 256] = samples[i + 512] + common;
}
}
@ -381,9 +381,9 @@ static void mix21to2 (sample_t * left, sample_t * right)
sample_t common;
for (i = 0; i < 256; i++) {
common = BIAS (right[i + 256]);
left[i] += common;
right[i] += common;
common = BIAS (right[i + 256]);
left[i] += common;
right[i] += common;
}
}
@ -393,9 +393,9 @@ static void mix21toS (sample_t * samples)
sample_t surround;
for (i = 0; i < 256; i++) {
surround = samples[i + 512];
samples[i] += BIAS (-surround);
samples[i + 256] += BIAS (surround);
surround = samples[i + 512];
samples[i] += BIAS (-surround);
samples[i + 256] += BIAS (surround);
}
}
@ -405,9 +405,9 @@ static void mix31to2 (sample_t * samples)
sample_t common;
for (i = 0; i < 256; i++) {
common = BIAS (samples[i + 256] + samples[i + 768]);
samples[i] += common;
samples[i + 256] = samples[i + 512] + common;
common = BIAS (samples[i + 256] + samples[i + 768]);
samples[i] += common;
samples[i + 256] = samples[i + 512] + common;
}
}
@ -417,10 +417,10 @@ static void mix31toS (sample_t * samples)
sample_t common, surround;
for (i = 0; i < 256; i++) {
common = BIAS (samples[i + 256]);
surround = samples[i + 768];
samples[i] += common - surround;
samples[i + 256] = samples[i + 512] + common + surround;
common = BIAS (samples[i + 256]);
surround = samples[i + 768];
samples[i] += common - surround;
samples[i + 256] = samples[i + 512] + common + surround;
}
}
@ -430,9 +430,9 @@ static void mix22toS (sample_t * samples)
sample_t surround;
for (i = 0; i < 256; i++) {
surround = samples[i + 512] + samples[i + 768];
samples[i] += BIAS (-surround);
samples[i + 256] += BIAS (surround);
surround = samples[i + 512] + samples[i + 768];
samples[i] += BIAS (-surround);
samples[i + 256] += BIAS (surround);
}
}
@ -442,9 +442,9 @@ static void mix32to2 (sample_t * samples)
sample_t common;
for (i = 0; i < 256; i++) {
common = BIAS (samples[i + 256]);
samples[i] += common + samples[i + 768];
samples[i + 256] = common + samples[i + 512] + samples[i + 1024];
common = BIAS (samples[i + 256]);
samples[i] += common + samples[i + 768];
samples[i + 256] = common + samples[i + 512] + samples[i + 1024];
}
}
@ -454,10 +454,10 @@ static void mix32toS (sample_t * samples)
sample_t common, surround;
for (i = 0; i < 256; i++) {
common = BIAS (samples[i + 256]);
surround = samples[i + 768] + samples[i + 1024];
samples[i] += common - surround;
samples[i + 256] = samples[i + 512] + common + surround;
common = BIAS (samples[i + 256]);
surround = samples[i + 768] + samples[i + 1024];
samples[i] += common - surround;
samples[i + 256] = samples[i + 512] + common + surround;
}
}
@ -466,7 +466,7 @@ static void move2to1 (sample_t * src, sample_t * dest)
int i;
for (i = 0; i < 256; i++)
dest[i] = BIAS (src[i] + src[i + 256]);
dest[i] = BIAS (src[i] + src[i + 256]);
}
static void zero (sample_t * samples)
@ -474,11 +474,11 @@ static void zero (sample_t * samples)
int i;
for (i = 0; i < 256; i++)
samples[i] = 0;
samples[i] = 0;
}
void a52_downmix (sample_t * samples, int acmod, int output,
level_t clev, level_t slev)
level_t clev, level_t slev)
{
/* avoid compiler warning */
(void)clev;
@ -486,138 +486,138 @@ void a52_downmix (sample_t * samples, int acmod, int output,
switch (CONVERT (acmod, output & A52_CHANNEL_MASK)) {
case CONVERT (A52_CHANNEL, A52_CHANNEL2):
memcpy (samples, samples + 256, 256 * sizeof (sample_t));
break;
memcpy (samples, samples + 256, 256 * sizeof (sample_t));
break;
case CONVERT (A52_CHANNEL, A52_MONO):
case CONVERT (A52_STEREO, A52_MONO):
mix_2to1:
mix2to1 (samples, samples + 256);
break;
mix2to1 (samples, samples + 256);
break;
case CONVERT (A52_2F1R, A52_MONO):
if (slev == 0)
goto mix_2to1;
if (slev == 0)
goto mix_2to1;
case CONVERT (A52_3F, A52_MONO):
mix_3to1:
mix3to1 (samples);
break;
mix3to1 (samples);
break;
case CONVERT (A52_3F1R, A52_MONO):
if (slev == 0)
goto mix_3to1;
if (slev == 0)
goto mix_3to1;
case CONVERT (A52_2F2R, A52_MONO):
if (slev == 0)
goto mix_2to1;
mix4to1 (samples);
break;
if (slev == 0)
goto mix_2to1;
mix4to1 (samples);
break;
case CONVERT (A52_3F2R, A52_MONO):
if (slev == 0)
goto mix_3to1;
mix5to1 (samples);
break;
if (slev == 0)
goto mix_3to1;
mix5to1 (samples);
break;
case CONVERT (A52_MONO, A52_DOLBY):
memcpy (samples + 256, samples, 256 * sizeof (sample_t));
break;
memcpy (samples + 256, samples, 256 * sizeof (sample_t));
break;
case CONVERT (A52_3F, A52_STEREO):
case CONVERT (A52_3F, A52_DOLBY):
mix_3to2:
mix3to2 (samples);
break;
mix3to2 (samples);
break;
case CONVERT (A52_2F1R, A52_STEREO):
if (slev == 0)
break;
mix21to2 (samples, samples + 256);
break;
if (slev == 0)
break;
mix21to2 (samples, samples + 256);
break;
case CONVERT (A52_2F1R, A52_DOLBY):
mix21toS (samples);
break;
mix21toS (samples);
break;
case CONVERT (A52_3F1R, A52_STEREO):
if (slev == 0)
goto mix_3to2;
mix31to2 (samples);
break;
if (slev == 0)
goto mix_3to2;
mix31to2 (samples);
break;
case CONVERT (A52_3F1R, A52_DOLBY):
mix31toS (samples);
break;
mix31toS (samples);
break;
case CONVERT (A52_2F2R, A52_STEREO):
if (slev == 0)
break;
mix2to1 (samples, samples + 512);
mix2to1 (samples + 256, samples + 768);
break;
if (slev == 0)
break;
mix2to1 (samples, samples + 512);
mix2to1 (samples + 256, samples + 768);
break;
case CONVERT (A52_2F2R, A52_DOLBY):
mix22toS (samples);
break;
mix22toS (samples);
break;
case CONVERT (A52_3F2R, A52_STEREO):
if (slev == 0)
goto mix_3to2;
mix32to2 (samples);
break;
if (slev == 0)
goto mix_3to2;
mix32to2 (samples);
break;
case CONVERT (A52_3F2R, A52_DOLBY):
mix32toS (samples);
break;
mix32toS (samples);
break;
case CONVERT (A52_3F1R, A52_3F):
if (slev == 0)
break;
mix21to2 (samples, samples + 512);
break;
if (slev == 0)
break;
mix21to2 (samples, samples + 512);
break;
case CONVERT (A52_3F2R, A52_3F):
if (slev == 0)
break;
mix2to1 (samples, samples + 768);
mix2to1 (samples + 512, samples + 1024);
break;
if (slev == 0)
break;
mix2to1 (samples, samples + 768);
mix2to1 (samples + 512, samples + 1024);
break;
case CONVERT (A52_3F1R, A52_2F1R):
mix3to2 (samples);
memcpy (samples + 512, samples + 768, 256 * sizeof (sample_t));
break;
mix3to2 (samples);
memcpy (samples + 512, samples + 768, 256 * sizeof (sample_t));
break;
case CONVERT (A52_2F2R, A52_2F1R):
mix2to1 (samples + 512, samples + 768);
break;
mix2to1 (samples + 512, samples + 768);
break;
case CONVERT (A52_3F2R, A52_2F1R):
mix3to2 (samples);
move2to1 (samples + 768, samples + 512);
break;
mix3to2 (samples);
move2to1 (samples + 768, samples + 512);
break;
case CONVERT (A52_3F2R, A52_3F1R):
mix2to1 (samples + 768, samples + 1024);
break;
mix2to1 (samples + 768, samples + 1024);
break;
case CONVERT (A52_2F1R, A52_2F2R):
memcpy (samples + 768, samples + 512, 256 * sizeof (sample_t));
break;
memcpy (samples + 768, samples + 512, 256 * sizeof (sample_t));
break;
case CONVERT (A52_3F1R, A52_2F2R):
mix3to2 (samples);
memcpy (samples + 512, samples + 768, 256 * sizeof (sample_t));
break;
mix3to2 (samples);
memcpy (samples + 512, samples + 768, 256 * sizeof (sample_t));
break;
case CONVERT (A52_3F2R, A52_2F2R):
mix3to2 (samples);
memcpy (samples + 512, samples + 768, 256 * sizeof (sample_t));
memcpy (samples + 768, samples + 1024, 256 * sizeof (sample_t));
break;
mix3to2 (samples);
memcpy (samples + 512, samples + 768, 256 * sizeof (sample_t));
memcpy (samples + 768, samples + 1024, 256 * sizeof (sample_t));
break;
case CONVERT (A52_3F1R, A52_3F2R):
memcpy (samples + 1024, samples + 768, 256 * sizeof (sample_t));
break;
memcpy (samples + 1024, samples + 768, 256 * sizeof (sample_t));
break;
}
}
@ -626,63 +626,63 @@ void a52_upmix (sample_t * samples, int acmod, int output)
switch (CONVERT (acmod, output & A52_CHANNEL_MASK)) {
case CONVERT (A52_CHANNEL, A52_CHANNEL2):
memcpy (samples + 256, samples, 256 * sizeof (sample_t));
break;
memcpy (samples + 256, samples, 256 * sizeof (sample_t));
break;
case CONVERT (A52_3F2R, A52_MONO):
zero (samples + 1024);
zero (samples + 1024);
case CONVERT (A52_3F1R, A52_MONO):
case CONVERT (A52_2F2R, A52_MONO):
zero (samples + 768);
zero (samples + 768);
case CONVERT (A52_3F, A52_MONO):
case CONVERT (A52_2F1R, A52_MONO):
zero (samples + 512);
zero (samples + 512);
case CONVERT (A52_CHANNEL, A52_MONO):
case CONVERT (A52_STEREO, A52_MONO):
zero (samples + 256);
break;
zero (samples + 256);
break;
case CONVERT (A52_3F2R, A52_STEREO):
case CONVERT (A52_3F2R, A52_DOLBY):
zero (samples + 1024);
zero (samples + 1024);
case CONVERT (A52_3F1R, A52_STEREO):
case CONVERT (A52_3F1R, A52_DOLBY):
zero (samples + 768);
zero (samples + 768);
case CONVERT (A52_3F, A52_STEREO):
case CONVERT (A52_3F, A52_DOLBY):
mix_3to2:
memcpy (samples + 512, samples + 256, 256 * sizeof (sample_t));
zero (samples + 256);
break;
memcpy (samples + 512, samples + 256, 256 * sizeof (sample_t));
zero (samples + 256);
break;
case CONVERT (A52_2F2R, A52_STEREO):
case CONVERT (A52_2F2R, A52_DOLBY):
zero (samples + 768);
zero (samples + 768);
case CONVERT (A52_2F1R, A52_STEREO):
case CONVERT (A52_2F1R, A52_DOLBY):
zero (samples + 512);
break;
zero (samples + 512);
break;
case CONVERT (A52_3F2R, A52_3F):
zero (samples + 1024);
zero (samples + 1024);
case CONVERT (A52_3F1R, A52_3F):
case CONVERT (A52_2F2R, A52_2F1R):
zero (samples + 768);
break;
zero (samples + 768);
break;
case CONVERT (A52_3F2R, A52_3F1R):
zero (samples + 1024);
break;
zero (samples + 1024);
break;
case CONVERT (A52_3F2R, A52_2F1R):
zero (samples + 1024);
zero (samples + 1024);
case CONVERT (A52_3F1R, A52_2F1R):
mix_31to21:
memcpy (samples + 768, samples + 512, 256 * sizeof (sample_t));
goto mix_3to2;
memcpy (samples + 768, samples + 512, 256 * sizeof (sample_t));
goto mix_3to2;
case CONVERT (A52_3F2R, A52_2F2R):
memcpy (samples + 1024, samples + 768, 256 * sizeof (sample_t));
goto mix_31to21;
memcpy (samples + 1024, samples + 768, 256 * sizeof (sample_t));
goto mix_31to21;
}
}

View file

@ -114,73 +114,73 @@ static inline void ifft4 (complex_t * buf)
*/
/* basic radix-2 ifft butterfly */
#define BUTTERFLY_0(t0,t1,W0,W1,d0,d1) do { \
t0 = MUL (W1, d1) + MUL (W0, d0); \
t1 = MUL (W0, d1) - MUL (W1, d0); \
#define BUTTERFLY_0(t0,t1,W0,W1,d0,d1) do { \
t0 = MUL (W1, d1) + MUL (W0, d0); \
t1 = MUL (W0, d1) - MUL (W1, d0); \
} while (0)
/* radix-2 ifft butterfly with bias */
#define BUTTERFLY_B(t0,t1,W0,W1,d0,d1) do { \
t0 = BIAS (MUL (d1, W1) + MUL (d0, W0)); \
t1 = BIAS (MUL (d1, W0) - MUL (d0, W1)); \
#define BUTTERFLY_B(t0,t1,W0,W1,d0,d1) do { \
t0 = BIAS (MUL (d1, W1) + MUL (d0, W0)); \
t1 = BIAS (MUL (d1, W0) - MUL (d0, W1)); \
} while (0)
/* the basic split-radix ifft butterfly */
#define BUTTERFLY(a0,a1,a2,a3,wr,wi) do { \
BUTTERFLY_0 (tmp5, tmp6, wr, wi, a2.real, a2.imag); \
BUTTERFLY_0 (tmp8, tmp7, wr, wi, a3.imag, a3.real); \
tmp1 = tmp5 + tmp7; \
tmp2 = tmp6 + tmp8; \
tmp3 = tmp6 - tmp8; \
tmp4 = tmp7 - tmp5; \
a2.real = a0.real - tmp1; \
a2.imag = a0.imag - tmp2; \
a3.real = a1.real - tmp3; \
a3.imag = a1.imag - tmp4; \
a0.real += tmp1; \
a0.imag += tmp2; \
a1.real += tmp3; \
a1.imag += tmp4; \
#define BUTTERFLY(a0,a1,a2,a3,wr,wi) do { \
BUTTERFLY_0 (tmp5, tmp6, wr, wi, a2.real, a2.imag); \
BUTTERFLY_0 (tmp8, tmp7, wr, wi, a3.imag, a3.real); \
tmp1 = tmp5 + tmp7; \
tmp2 = tmp6 + tmp8; \
tmp3 = tmp6 - tmp8; \
tmp4 = tmp7 - tmp5; \
a2.real = a0.real - tmp1; \
a2.imag = a0.imag - tmp2; \
a3.real = a1.real - tmp3; \
a3.imag = a1.imag - tmp4; \
a0.real += tmp1; \
a0.imag += tmp2; \
a1.real += tmp3; \
a1.imag += tmp4; \
} while (0)
/* split-radix ifft butterfly, specialized for wr=1 wi=0 */
#define BUTTERFLY_ZERO(a0,a1,a2,a3) do { \
tmp1 = a2.real + a3.real; \
tmp2 = a2.imag + a3.imag; \
tmp3 = a2.imag - a3.imag; \
tmp4 = a3.real - a2.real; \
a2.real = a0.real - tmp1; \
a2.imag = a0.imag - tmp2; \
a3.real = a1.real - tmp3; \
a3.imag = a1.imag - tmp4; \
a0.real += tmp1; \
a0.imag += tmp2; \
a1.real += tmp3; \
a1.imag += tmp4; \
#define BUTTERFLY_ZERO(a0,a1,a2,a3) do { \
tmp1 = a2.real + a3.real; \
tmp2 = a2.imag + a3.imag; \
tmp3 = a2.imag - a3.imag; \
tmp4 = a3.real - a2.real; \
a2.real = a0.real - tmp1; \
a2.imag = a0.imag - tmp2; \
a3.real = a1.real - tmp3; \
a3.imag = a1.imag - tmp4; \
a0.real += tmp1; \
a0.imag += tmp2; \
a1.real += tmp3; \
a1.imag += tmp4; \
} while (0)
/* split-radix ifft butterfly, specialized for wr=wi */
/*
#define BUTTERFLY_HALF(a0,a1,a2,a3,w) do { \
tmp5 = MUL (a2.real + a2.imag, w); \
tmp6 = MUL (a2.imag - a2.real, w); \
tmp7 = MUL (a3.real - a3.imag, w); \
tmp8 = MUL (a3.imag + a3.real, w); \
tmp1 = tmp5 + tmp7; \
tmp2 = tmp6 + tmp8; \
tmp3 = tmp6 - tmp8; \
tmp4 = tmp7 - tmp5; \
a2.real = a0.real - tmp1; \
a2.imag = a0.imag - tmp2; \
a3.real = a1.real - tmp3; \
a3.imag = a1.imag - tmp4; \
a0.real += tmp1; \
a0.imag += tmp2; \
a1.real += tmp3; \
a1.imag += tmp4; \
#define BUTTERFLY_HALF(a0,a1,a2,a3,w) do { \
tmp5 = MUL (a2.real + a2.imag, w); \
tmp6 = MUL (a2.imag - a2.real, w); \
tmp7 = MUL (a3.real - a3.imag, w); \
tmp8 = MUL (a3.imag + a3.real, w); \
tmp1 = tmp5 + tmp7; \
tmp2 = tmp6 + tmp8; \
tmp3 = tmp6 - tmp8; \
tmp4 = tmp7 - tmp5; \
a2.real = a0.real - tmp1; \
a2.imag = a0.imag - tmp2; \
a3.real = a1.real - tmp3; \
a3.imag = a1.imag - tmp4; \
a0.real += tmp1; \
a0.imag += tmp2; \
a1.real += tmp3; \
a1.imag += tmp4; \
} while (0)
static inline void ifft8 (complex_t * buf)
@ -212,13 +212,13 @@ static void ifft_pass (complex_t * buf, const sample_t * weight, int n)
i = n - 1;
do {
BUTTERFLY (buf[0], buf1[0], buf2[0], buf3[0],
weight[0], weight[2*i-n]);
buf++;
buf1++;
buf2++;
buf3++;
weight++;
BUTTERFLY (buf[0], buf1[0], buf2[0], buf3[0],
weight[0], weight[2*i-n]);
buf++;
buf1++;
buf2++;
buf3++;
weight++;
} while (--i);
}
@ -264,7 +264,7 @@ void a52_imdct_512 (sample_t * data, sample_t * delay)
sample_t t_r, t_i, a_r, a_i, b_r, b_i, w_1, w_2;
const sample_t * window = a52_imdct_window;
FFTComplex buf[128];
for (i = 0; i < 128; i++) {
k = fftorder[i];
t_r = pre1[i].real;
@ -357,7 +357,7 @@ static double besselI0 (double x)
int i = 100;
do
bessel = bessel * x / (i * i) + 1;
bessel = bessel * x / (i * i) + 1;
while (--i);
return bessel;
}
@ -376,13 +376,13 @@ void a52_imdct_init (uint32_t mm_accel)
/* compute imdct window - kaiser-bessel derived window, alpha = 5.0 */
/* sum = 0;
for (i = 0; i < 256; i++) {
sum += besselI0 (i * (256 - i) * (5 * M_PI / 256) * (5 * M_PI / 256));
local_imdct_window[i] = sum;
sum += besselI0 (i * (256 - i) * (5 * M_PI / 256) * (5 * M_PI / 256));
local_imdct_window[i] = sum;
}
sum++;
*/
/* for (i = 0; i < 256; i++)
a52_imdct_window[i] = SAMPLE (sqrt (local_imdct_window[i] / sum));
a52_imdct_window[i] = SAMPLE (sqrt (local_imdct_window[i] / sum));
printf("static sample_t a52_imdct_window[256]={");
for (i=0;i<256;i++) {
@ -393,26 +393,26 @@ void a52_imdct_init (uint32_t mm_accel)
*/
/* for (i = 0; i < 3; i++)
roots16[i] = SAMPLE (cos ((M_PI / 8) * (i + 1)));
roots16[i] = SAMPLE (cos ((M_PI / 8) * (i + 1)));
printf("static sample_t roots16[3]={%d,%d,%d};\n\n",roots16[0],roots16[1],roots16[2]);
for (i = 0; i < 7; i++)
roots32[i] = SAMPLE (cos ((M_PI / 16) * (i + 1)));
roots32[i] = SAMPLE (cos ((M_PI / 16) * (i + 1)));
printf("static sample_t roots32[7]={");
for (i=0;i<7;i++) { printf("%d%s",roots32[i],(i < 6 ? "," : "")); }
printf("};\n");
for (i = 0; i < 15; i++)
roots64[i] = SAMPLE (cos ((M_PI / 32) * (i + 1)));
roots64[i] = SAMPLE (cos ((M_PI / 32) * (i + 1)));
printf("static sample_t roots64[15]={");
for (i=0;i<15;i++) { printf("%d%s",roots64[i],(i < 14 ? "," : "")); }
printf("};\n");
for (i = 0; i < 31; i++)
roots128[i] = SAMPLE (cos ((M_PI / 64) * (i + 1)));
roots128[i] = SAMPLE (cos ((M_PI / 64) * (i + 1)));
printf("static sample_t roots128[31]={");
for (i=0;i<31;i++) { printf("%d%s",roots128[i],(i < 30 ? "," : "")); }
@ -420,15 +420,15 @@ void a52_imdct_init (uint32_t mm_accel)
*/
/*
for (i = 0; i < 64; i++) {
k = fftorder[i] / 2 + 64;
pre1[i].real = SAMPLE (cos ((M_PI / 256) * (k - 0.25)));
pre1[i].imag = SAMPLE (sin ((M_PI / 256) * (k - 0.25)));
k = fftorder[i] / 2 + 64;
pre1[i].real = SAMPLE (cos ((M_PI / 256) * (k - 0.25)));
pre1[i].imag = SAMPLE (sin ((M_PI / 256) * (k - 0.25)));
}
for (i = 64; i < 128; i++) {
k = fftorder[i] / 2 + 64;
pre1[i].real = SAMPLE (-cos ((M_PI / 256) * (k - 0.25)));
pre1[i].imag = SAMPLE (-sin ((M_PI / 256) * (k - 0.25)));
k = fftorder[i] / 2 + 64;
pre1[i].real = SAMPLE (-cos ((M_PI / 256) * (k - 0.25)));
pre1[i].imag = SAMPLE (-sin ((M_PI / 256) * (k - 0.25)));
}
printf("static complex_t pre1[128]={");
@ -437,8 +437,8 @@ void a52_imdct_init (uint32_t mm_accel)
*/
/*
for (i = 0; i < 64; i++) {
post1[i].real = SAMPLE (cos ((M_PI / 256) * (i + 0.5)));
post1[i].imag = SAMPLE (sin ((M_PI / 256) * (i + 0.5)));
post1[i].real = SAMPLE (cos ((M_PI / 256) * (i + 0.5)));
post1[i].imag = SAMPLE (sin ((M_PI / 256) * (i + 0.5)));
}
printf("static complex_t post1[64]={");
@ -448,9 +448,9 @@ void a52_imdct_init (uint32_t mm_accel)
/*
for (i = 0; i < 64; i++) {
k = fftorder[i] / 4;
pre2[i].real = SAMPLE (cos ((M_PI / 128) * (k - 0.25)));
pre2[i].imag = SAMPLE (sin ((M_PI / 128) * (k - 0.25)));
k = fftorder[i] / 4;
pre2[i].real = SAMPLE (cos ((M_PI / 128) * (k - 0.25)));
pre2[i].imag = SAMPLE (sin ((M_PI / 128) * (k - 0.25)));
}
printf("static complex_t pre2[64]={");
@ -458,8 +458,8 @@ void a52_imdct_init (uint32_t mm_accel)
printf("};\n");
for (i = 0; i < 32; i++) {
post2[i].real = SAMPLE (cos ((M_PI / 128) * (i + 0.5)));
post2[i].imag = SAMPLE (sin ((M_PI / 128) * (i + 0.5)));
post2[i].real = SAMPLE (cos ((M_PI / 128) * (i + 0.5)));
post2[i].imag = SAMPLE (sin ((M_PI / 128) * (i + 0.5)));
}
printf("static complex_t post2[32]={");
@ -470,17 +470,17 @@ void a52_imdct_init (uint32_t mm_accel)
#ifdef LIBA52_DJBFFT
if (mm_accel & MM_ACCEL_DJBFFT) {
#ifndef LIBA52_DOUBLE
ifft128 = (void (*) (complex_t *)) fftc4_un128;
ifft64 = (void (*) (complex_t *)) fftc4_un64;
ifft128 = (void (*) (complex_t *)) fftc4_un128;
ifft64 = (void (*) (complex_t *)) fftc4_un64;
#else
ifft128 = (void (*) (complex_t *)) fftc8_un128;
ifft64 = (void (*) (complex_t *)) fftc8_un64;
ifft128 = (void (*) (complex_t *)) fftc8_un128;
ifft64 = (void (*) (complex_t *)) fftc8_un64;
#endif
} else
#endif
{
ifft128 = ifft128_c;
ifft64 = ifft64_c;
ifft128 = ifft128_c;
ifft64 = ifft64_c;
}
*/
}

View file

@ -1,5 +1,5 @@
static const sample_t a52_imdct_window[256]ICONST_ATTR={
146020,261886,393529,545197,719447,918478,1144416,1399394,1685589,2005234,2360623,2754115,3188134,3665170,4187773,4758556, 5380193,6055411,6786995,7577779,8430645,9348521,10334375,11391212,12522071,13730020,15018150,16389576,17847424,19394833,21034947,22770912, 24605865,26542938,28585242,30735872,32997891,35374332,37868188,40482408,43219889,46083473,49075937,52199993,55458273,58853331,62387636,66063559, 69883377,73849259,77963266,82227341,86643307,91212859,95937560,100818835,105857968,111056092,116414194,121933098,127613474,133455822,139460477,145627601, 151957182,158449029,165102772,171917855,178893540,186028900,193322822,200774000,208380940,216141958,224055176,232118527,240329753,248686407,257185854,265825270, 274601649,283511802,292552357,301719768,311010314,320420105,329945084,339581031,349323572,359168178,369110174,379144743,389266934,399471665,409753732,420107815, 430528483,441010205,451547355,462134219,472765003,483433845,494134818,504861939,515609181,526370480,537139740,547910849,558677680,569434108,580174011,590891284, 601579849,612233658,622846709,633413050,643926788,654382103,664773249,675094567,685340494,695505569,705584441,715571877,725462772,735252152,744935184,754507184, 763963620,773300119,782512477,791596659,800548807,809365245,818042484,826577226,834966364,843206992,851296404,859232096,867011771,874633340,882094922,889394844, 896531647,903504079,910311101,916951881,923425798,929732436,935871584,941843233,947647575,953284997,958756080,964061593,969202490,974179906,978995149,983649698, 988145195,992483442,996666390,1000696136,1004574919,1008305104,1011889185,1015329772,1018629583,1021791439,1024818257,1027713038,1030478862,1033118881,1035636308,1038034411, 1040316504,1042485942,1044546109,1046500412,1048352275,1050105129,1051762405,1053327531,1054803917,1056194958,1057504020,1058734435,1059889501,1060972468,1061986539,1062934861, 1063820523,1064646551,1065415903,1066131467,1066796055,1067412403,1067983168,1068510924,1068998160,1069447282,1069860607,1070240366,1070588702,1070907668,1071199230,1071465266, 1071707567,1071927836,1072127692,1072308670,1072472221,1072619716,1072752449,1072871635,1072978415,1073073858,1073158963,1073234663,1073301826,1073361257,1073413702,1073459852, 1073500344,1073535763,1073566646,1073593486,1073616731,1073636791,1073654036,1073668804,1073681398,1073692090,1073701126,1073708726,1073715084,1073720373,1073724748,1073728344, 1073731279,1073733657,1073735568,1073737090,1073738291,1073739229,1073739951,1073740500,1073740912,1073741214,1073741431,1073741582,1073741685,1073741751,1073741792,1073741814
146020,261886,393529,545197,719447,918478,1144416,1399394,1685589,2005234,2360623,2754115,3188134,3665170,4187773,4758556, 5380193,6055411,6786995,7577779,8430645,9348521,10334375,11391212,12522071,13730020,15018150,16389576,17847424,19394833,21034947,22770912, 24605865,26542938,28585242,30735872,32997891,35374332,37868188,40482408,43219889,46083473,49075937,52199993,55458273,58853331,62387636,66063559, 69883377,73849259,77963266,82227341,86643307,91212859,95937560,100818835,105857968,111056092,116414194,121933098,127613474,133455822,139460477,145627601, 151957182,158449029,165102772,171917855,178893540,186028900,193322822,200774000,208380940,216141958,224055176,232118527,240329753,248686407,257185854,265825270, 274601649,283511802,292552357,301719768,311010314,320420105,329945084,339581031,349323572,359168178,369110174,379144743,389266934,399471665,409753732,420107815, 430528483,441010205,451547355,462134219,472765003,483433845,494134818,504861939,515609181,526370480,537139740,547910849,558677680,569434108,580174011,590891284, 601579849,612233658,622846709,633413050,643926788,654382103,664773249,675094567,685340494,695505569,705584441,715571877,725462772,735252152,744935184,754507184, 763963620,773300119,782512477,791596659,800548807,809365245,818042484,826577226,834966364,843206992,851296404,859232096,867011771,874633340,882094922,889394844, 896531647,903504079,910311101,916951881,923425798,929732436,935871584,941843233,947647575,953284997,958756080,964061593,969202490,974179906,978995149,983649698, 988145195,992483442,996666390,1000696136,1004574919,1008305104,1011889185,1015329772,1018629583,1021791439,1024818257,1027713038,1030478862,1033118881,1035636308,1038034411, 1040316504,1042485942,1044546109,1046500412,1048352275,1050105129,1051762405,1053327531,1054803917,1056194958,1057504020,1058734435,1059889501,1060972468,1061986539,1062934861, 1063820523,1064646551,1065415903,1066131467,1066796055,1067412403,1067983168,1068510924,1068998160,1069447282,1069860607,1070240366,1070588702,1070907668,1071199230,1071465266, 1071707567,1071927836,1072127692,1072308670,1072472221,1072619716,1072752449,1072871635,1072978415,1073073858,1073158963,1073234663,1073301826,1073361257,1073413702,1073459852, 1073500344,1073535763,1073566646,1073593486,1073616731,1073636791,1073654036,1073668804,1073681398,1073692090,1073701126,1073708726,1073715084,1073720373,1073724748,1073728344, 1073731279,1073733657,1073735568,1073737090,1073738291,1073739229,1073739951,1073740500,1073740912,1073741214,1073741431,1073741582,1073741685,1073741751,1073741792,1073741814
};
static const sample_t roots16[3]ICONST_ATTR={992008094,759250124,410903206};

View file

@ -25,12 +25,12 @@
#define MM_ACCEL_H
/* generic accelerations */
#define MM_ACCEL_DJBFFT 0x00000001
#define MM_ACCEL_DJBFFT 0x00000001
/* x86 accelerations */
#define MM_ACCEL_X86_MMX 0x80000000
#define MM_ACCEL_X86_3DNOW 0x40000000
#define MM_ACCEL_X86_MMXEXT 0x20000000
#define MM_ACCEL_X86_MMX 0x80000000
#define MM_ACCEL_X86_3DNOW 0x40000000
#define MM_ACCEL_X86_MMXEXT 0x20000000
uint32_t mm_accel (void);

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -37,19 +37,19 @@ extern "C" {
/* Short credits of the ASAP engine. */
#define ASAP_YEARS "2005-2010"
#define ASAP_CREDITS \
"Another Slight Atari Player (C) 2005-2010 Piotr Fusik\n" \
"CMC, MPT, TMC, TM2 players (C) 1994-2005 Marcin Lewandowski\n" \
"RMT player (C) 2002-2005 Radek Sterba\n" \
"DLT player (C) 2009 Marek Konopka\n" \
"CMS player (C) 1999 David Spilka\n"
"Another Slight Atari Player (C) 2005-2010 Piotr Fusik\n" \
"CMC, MPT, TMC, TM2 players (C) 1994-2005 Marcin Lewandowski\n" \
"RMT player (C) 2002-2005 Radek Sterba\n" \
"DLT player (C) 2009 Marek Konopka\n" \
"CMS player (C) 1999 David Spilka\n"
/* Short GPL notice.
Display after the credits. */
#define ASAP_COPYRIGHT \
"This program is free software; you can redistribute it and/or modify\n" \
"it under the terms of the GNU General Public License as published\n" \
"by the Free Software Foundation; either version 2 of the License,\n" \
"or (at your option) any later version."
"This program is free software; you can redistribute it and/or modify\n" \
"it under the terms of the GNU General Public License as published\n" \
"by the Free Software Foundation; either version 2 of the License,\n" \
"or (at your option) any later version."
/* Maximum length of AUTHOR, NAME and DATE tags including the terminator. */
#define ASAP_INFO_CHARS 128
@ -72,9 +72,9 @@ extern "C" {
/* Output formats. */
typedef enum {
ASAP_FORMAT_U8 = 8, /* unsigned char */
ASAP_FORMAT_S16_LE = 16, /* signed short, little-endian */
ASAP_FORMAT_S16_BE = -16 /* signed short, big-endian */
ASAP_FORMAT_U8 = 8, /* unsigned char */
ASAP_FORMAT_S16_LE = 16, /* signed short, little-endian */
ASAP_FORMAT_S16_BE = -16 /* signed short, big-endian */
} ASAP_SampleFormat;
/* Useful type definitions. */
@ -89,106 +89,106 @@ typedef unsigned char byte;
/* Information about a music file. */
typedef struct {
char author[ASAP_INFO_CHARS]; /* author's name */
char name[ASAP_INFO_CHARS]; /* title */
char date[ASAP_INFO_CHARS]; /* creation date */
int channels; /* 1 for mono or 2 for stereo */
int songs; /* number of subsongs */
int default_song; /* 0-based index of the "main" subsong */
int durations[ASAP_SONGS_MAX]; /* lengths of songs, in milliseconds, -1 = indeterminate */
abool loops[ASAP_SONGS_MAX]; /* whether songs repeat or not */
/* the following technical information should not be used outside ASAP. */
int type;
int fastplay;
int music;
int init;
int player;
int covox_addr;
int header_len;
byte song_pos[ASAP_SONGS_MAX];
char author[ASAP_INFO_CHARS]; /* author's name */
char name[ASAP_INFO_CHARS]; /* title */
char date[ASAP_INFO_CHARS]; /* creation date */
int channels; /* 1 for mono or 2 for stereo */
int songs; /* number of subsongs */
int default_song; /* 0-based index of the "main" subsong */
int durations[ASAP_SONGS_MAX]; /* lengths of songs, in milliseconds, -1 = indeterminate */
abool loops[ASAP_SONGS_MAX]; /* whether songs repeat or not */
/* the following technical information should not be used outside ASAP. */
int type;
int fastplay;
int music;
int init;
int player;
int covox_addr;
int header_len;
byte song_pos[ASAP_SONGS_MAX];
} ASAP_ModuleInfo;
/* POKEY state.
Not for use outside the ASAP engine. */
typedef struct {
int audctl;
abool init;
int poly_index;
int div_cycles;
int mute1;
int mute2;
int mute3;
int mute4;
int audf1;
int audf2;
int audf3;
int audf4;
int audc1;
int audc2;
int audc3;
int audc4;
int tick_cycle1;
int tick_cycle2;
int tick_cycle3;
int tick_cycle4;
int period_cycles1;
int period_cycles2;
int period_cycles3;
int period_cycles4;
int reload_cycles1;
int reload_cycles3;
int out1;
int out2;
int out3;
int out4;
int delta1;
int delta2;
int delta3;
int delta4;
int skctl;
int delta_buffer[888];
int audctl;
abool init;
int poly_index;
int div_cycles;
int mute1;
int mute2;
int mute3;
int mute4;
int audf1;
int audf2;
int audf3;
int audf4;
int audc1;
int audc2;
int audc3;
int audc4;
int tick_cycle1;
int tick_cycle2;
int tick_cycle3;
int tick_cycle4;
int period_cycles1;
int period_cycles2;
int period_cycles3;
int period_cycles4;
int reload_cycles1;
int reload_cycles3;
int out1;
int out2;
int out3;
int out4;
int delta1;
int delta2;
int delta3;
int delta4;
int skctl;
int delta_buffer[888];
} PokeyState;
/* Player state.
Only module_info is meant to be read outside the ASAP engine. */
typedef struct {
int cycle;
int cpu_pc;
int cpu_a;
int cpu_x;
int cpu_y;
int cpu_s;
int cpu_nz;
int cpu_c;
int cpu_vdi;
int scanline_number;
int nearest_event_cycle;
int next_scanline_cycle;
int timer1_cycle;
int timer2_cycle;
int timer4_cycle;
int irqst;
int extra_pokey_mask;
int consol;
byte covox[4];
PokeyState base_pokey;
PokeyState extra_pokey;
int sample_offset;
int sample_index;
int samples;
int iir_acc_left;
int iir_acc_right;
ASAP_ModuleInfo module_info;
int tmc_per_frame;
int tmc_per_frame_counter;
int current_song;
int current_duration;
int blocks_played;
int silence_cycles;
int silence_cycles_counter;
byte poly9_lookup[511];
byte poly17_lookup[16385];
byte memory[65536];
int cycle;
int cpu_pc;
int cpu_a;
int cpu_x;
int cpu_y;
int cpu_s;
int cpu_nz;
int cpu_c;
int cpu_vdi;
int scanline_number;
int nearest_event_cycle;
int next_scanline_cycle;
int timer1_cycle;
int timer2_cycle;
int timer4_cycle;
int irqst;
int extra_pokey_mask;
int consol;
byte covox[4];
PokeyState base_pokey;
PokeyState extra_pokey;
int sample_offset;
int sample_index;
int samples;
int iir_acc_left;
int iir_acc_right;
ASAP_ModuleInfo module_info;
int tmc_per_frame;
int tmc_per_frame_counter;
int current_song;
int current_duration;
int blocks_played;
int silence_cycles;
int silence_cycles_counter;
byte poly9_lookup[511];
byte poly17_lookup[16385];
byte memory[65536];
} ASAP_State;
/* Parses the string in the "mm:ss.xxx" format

File diff suppressed because it is too large Load diff

View file

@ -78,7 +78,7 @@ typedef struct
{
uint8_t cb;
uint8_t decoded;
uint16_t sp_offset;
uint16_t sp_offset;
bits_t bits;
} codeword_t;

View file

@ -124,7 +124,7 @@ static INLINE int16_t huffman_getescape(bitfile *ld, int16_t sp)
{
uint8_t neg, i;
int16_t j;
int16_t off;
int16_t off;
if (sp < 0)
{
@ -500,14 +500,14 @@ int8_t huffman_spectral_data_2(uint8_t cb, bits_t *ld, int16_t *sp)
break;
}
/* decode sign bits */
/* decode sign bits */
if (unsigned_cb[cb])
{
for(i = 0; i < ((cb < FIRST_PAIR_HCB) ? QUAD_LEN : PAIR_LEN); i++)
{
if(sp[i])
{
uint8_t b;
uint8_t b;
if ( get1bit_hcr(ld, &b) ) return -1;
if (b != 0) {
sp[i] = -sp[i];

View file

@ -1489,7 +1489,7 @@ static void fft_dif(real_t * Real, real_t * Imag)
// First 2 stages of 32 point FFT decimation in frequency
// 4*16*2=64*2=128 multiplications
// 6*16*2=96*2=192 additions
// Stage 1 of 32 point FFT decimation in frequency
// Stage 1 of 32 point FFT decimation in frequency
for (i = 0; i < 16; i++)
{
point1_real = Real[i];
@ -1519,7 +1519,7 @@ static void fft_dif(real_t * Real, real_t * Imag)
w_real = w_array_real[w_index];
w_imag = w_array_imag[w_index];
i = j;
i = j;
point1_real = Real[i];
point1_imag = Imag[i];
i2 = i+8;
@ -1818,9 +1818,9 @@ void dct4_kernel(real_t * in_real, real_t * in_imag, real_t * out_real, real_t *
// 3*32=96 additions
for (i = 0; i < 32; i++)
{
real_t x_re, x_im, tmp;
x_re = in_real[i];
x_im = in_imag[i];
real_t x_re, x_im, tmp;
x_re = in_real[i];
x_im = in_imag[i];
tmp = MUL_C(x_re + x_im, dct4_64_tab[i]);
in_real[i] = MUL_C(x_im, dct4_64_tab[i + 64]) + tmp;
in_imag[i] = MUL_C(x_re, dct4_64_tab[i + 32]) + tmp;
@ -1834,10 +1834,10 @@ void dct4_kernel(real_t * in_real, real_t * in_imag, real_t * out_real, real_t *
// 3*31+2=95 additions
for (i = 0; i < 16; i++)
{
real_t x_re, x_im, tmp;
i_rev = bit_rev_tab[i];
x_re = in_real[i_rev];
x_im = in_imag[i_rev];
real_t x_re, x_im, tmp;
i_rev = bit_rev_tab[i];
x_re = in_real[i_rev];
x_im = in_imag[i_rev];
tmp = MUL_C(x_re + x_im, dct4_64_tab[i + 3*32]);
out_real[i] = MUL_C(x_im, dct4_64_tab[i + 5*32]) + tmp;
@ -1848,10 +1848,10 @@ void dct4_kernel(real_t * in_real, real_t * in_imag, real_t * out_real, real_t *
out_real[16] = MUL_C(in_real[1] + in_imag[1], dct4_64_tab[16 + 3*32]);
for (i = 17; i < 32; i++)
{
real_t x_re, x_im, tmp;
i_rev = bit_rev_tab[i];
x_re = in_real[i_rev];
x_im = in_imag[i_rev];
real_t x_re, x_im, tmp;
i_rev = bit_rev_tab[i];
x_re = in_real[i_rev];
x_im = in_imag[i_rev];
tmp = MUL_C(x_re + x_im, dct4_64_tab[i + 3*32]);
out_real[i] = MUL_C(x_im, dct4_64_tab[i + 5*32]) + tmp;
out_imag[i] = MUL_C(x_re, dct4_64_tab[i + 4*32]) + tmp;

View file

@ -50,7 +50,7 @@ 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, uint8_t downSampledSBR
#ifdef DRM
, uint8_t IsDRM
, uint8_t IsDRM
#endif
)
{

View file

@ -1561,7 +1561,7 @@ static void hf_assembly(sbr_info *sbr, sbr_hfadj_info *adj,
#ifndef SBR_LOW_POWER
if (h_SL != 0)
{
uint8_t ri = sbr->GQ_ringbuf_index[ch];
uint8_t ri = sbr->GQ_ringbuf_index[ch];
for (n = 0; n <= 4; n++)
{
real_t curr_h_smooth = h_smooth[n];

View file

@ -128,20 +128,20 @@ void hf_generation(sbr_info *sbr, qmf_t Xlow[MAX_NTSRHFG][64],
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]);
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]);
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++)
for (l = first; l < last; l++)
{
temp1_r = temp2_r;
temp2_r = temp3_r;
temp3_r = 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
temp1_i = temp2_i;
temp2_i = temp3_i;
temp1_i = temp2_i;
temp2_i = temp3_i;
temp3_i = QMF_IM(Xlow[l + offset][p]);
#endif
@ -303,10 +303,10 @@ static void auto_correlation(sbr_info *sbr, acorr_coef *ac, qmf_t buffer[MAX_NTS
for (j = offset; j < len + offset; j++)
{
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;
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);
@ -352,10 +352,10 @@ static void auto_correlation(sbr_info *sbr, acorr_coef *ac, qmf_t buffer[MAX_NTS
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];
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;

View file

@ -42,12 +42,12 @@ qmfa_info *qmfa_init(uint8_t channels)
{
qmfa_info *qmfa = (qmfa_info*)faad_malloc(sizeof(qmfa_info));
/* x is implemented as double ringbuffer */
/* 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;
/* ringbuffer index */
qmfa->x_index = 0;
qmfa->channels = channels;
@ -81,7 +81,7 @@ void sbr_qmf_analysis_32(sbr_info *sbr, qmfa_info *qmfa, const real_t *input,
int16_t n;
/* shift input buffer x */
/* input buffer is not shifted anymore, x is implemented as double ringbuffer */
/* 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 */
@ -104,10 +104,10 @@ void sbr_qmf_analysis_32(sbr_info *sbr, qmfa_info *qmfa, const real_t *input,
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);
/* 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
@ -224,7 +224,7 @@ qmfs_info *qmfs_init(uint8_t channels)
{
qmfs_info *qmfs = (qmfs_info*)faad_malloc(sizeof(qmfs_info));
/* v is a double ringbuffer */
/* 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));
@ -483,8 +483,8 @@ void sbr_qmf_synthesis_64(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSRHFG][6
for (l = 0; l < sbr->numTimeSlotsRate; l++)
{
/* shift buffer v */
/* buffer is not shifted, we use double ringbuffer */
//memmove(qmfs->v + 128, qmfs->v, (1280-128)*sizeof(real_t));
/* buffer is not shifted, we use double ringbuffer */
//memmove(qmfs->v + 128, qmfs->v, (1280-128)*sizeof(real_t));
/* calculate 128 samples */
#ifndef FIXED_POINT

View file

@ -337,16 +337,16 @@ static uint8_t sbr_data(bitfile *ld, sbr_info *sbr)
switch (sbr->id_aac)
{
case ID_SCE:
if ((result = sbr_single_channel_element(ld, sbr)) > 0)
return result;
if ((result = sbr_single_channel_element(ld, sbr)) > 0)
return result;
break;
case ID_CPE:
if ((result = sbr_channel_pair_element(ld, sbr)) > 0)
return result;
if ((result = sbr_channel_pair_element(ld, sbr)) > 0)
return result;
break;
}
return 0;
return 0;
}
/* table 5 */

View file

@ -100,7 +100,7 @@ typedef struct RL_VLC_ELEM {
# ifdef __GNUC__
static inline uint32_t unaligned32(const void *v) {
struct Unaligned {
uint32_t i;
uint32_t i;
} __attribute__((packed));
return ((const struct Unaligned *) v)->i;
@ -165,10 +165,10 @@ for examples see get_bits, show_bits, skip_bits, get_vlc
static inline int unaligned32_be(const void *v)
{
#ifdef CONFIG_ALIGN
const uint8_t *p=v;
return (((p[0]<<8) | p[1])<<16) | (p[2]<<8) | (p[3]);
const uint8_t *p=v;
return (((p[0]<<8) | p[1])<<16) | (p[2]<<8) | (p[3]);
#else
return betoh32( unaligned32(v)); //original
return betoh32( unaligned32(v)); //original
#endif
}

View file

@ -93,7 +93,7 @@ static inline int get_sr_golomb_flac(GetBitContext *gb, int k, int limit, int es
#define get_ur_golomb_shorten(gb, k) get_ur_golomb_jpegls(gb, k, INT_MAX, 0)
/*
static inline unsigned int get_ur_golomb_shorten(GetBitContext *gb, int k){
return get_ur_golomb_jpegls(gb, k, INT_MAX, 0);
return get_ur_golomb_jpegls(gb, k, INT_MAX, 0);
}
*/

View file

@ -221,7 +221,7 @@ static bool flac_init(int fd, FLACContext* fc)
offset_lo=betoh32(*(p++));
if ((seekpoint_hi != 0xffffffff) && (seekpoint_lo != 0xffffffff)) {
fprintf(stderr,"Seekpoint: %u, Offset=%u\n",seekpoint_lo,offset_lo);
fprintf(stderr,"Seekpoint: %u, Offset=%u\n",seekpoint_lo,offset_lo);
}
}
lseek(fd, blocklength, SEEK_CUR);

View file

@ -87,8 +87,8 @@ unsigned short const crc_table[256] = {
#endif
/*
* NAME: bit->init()
* DESCRIPTION: initialize bit pointer struct
* NAME: bit->init()
* DESCRIPTION: initialize bit pointer struct
*/
void mad_bit_init(struct mad_bitptr *bitptr, unsigned char const *byte)
{
@ -97,11 +97,11 @@ void mad_bit_init(struct mad_bitptr *bitptr, unsigned char const *byte)
}
/*
* NAME: bit->length()
* DESCRIPTION: return number of bits between start and end points
* NAME: bit->length()
* DESCRIPTION: return number of bits between start and end points
*/
unsigned int mad_bit_length(struct mad_bitptr const *begin,
struct mad_bitptr const *end)
struct mad_bitptr const *end)
{
return end->readbit - begin->readbit;
}
@ -111,8 +111,8 @@ unsigned char mad_bit_bitsleft(struct mad_bitptr const *bitptr)
return 8 - (bitptr->readbit & 7);
}
/*
* NAME: bit->nextbyte()
* DESCRIPTION: return pointer to next unprocessed byte
* NAME: bit->nextbyte()
* DESCRIPTION: return pointer to next unprocessed byte
*/
unsigned char const *mad_bit_nextbyte(struct mad_bitptr const *bitptr)
{
@ -120,8 +120,8 @@ unsigned char const *mad_bit_nextbyte(struct mad_bitptr const *bitptr)
}
/*
* NAME: bit->skip()
* DESCRIPTION: advance bit pointer
* NAME: bit->skip()
* DESCRIPTION: advance bit pointer
*/
void mad_bit_skip(struct mad_bitptr *bitptr, unsigned int len)
{
@ -129,8 +129,8 @@ void mad_bit_skip(struct mad_bitptr *bitptr, unsigned int len)
}
/*
* NAME: bit->read()
* DESCRIPTION: read an arbitrary number of bits and return their UIMSBF value
* NAME: bit->read()
* DESCRIPTION: read an arbitrary number of bits and return their UIMSBF value
*/
uint32_t mad_bit_read(struct mad_bitptr *bitptr, unsigned int len) ICODE_ATTR;
@ -154,11 +154,11 @@ uint32_t mad_bit_read(struct mad_bitptr *bitptr, unsigned int len)
# if 0
/*
* NAME: bit->write()
* DESCRIPTION: write an arbitrary number of bits
* NAME: bit->write()
* DESCRIPTION: write an arbitrary number of bits
*/
void mad_bit_write(struct mad_bitptr *bitptr, unsigned int len,
uint32_t value)
uint32_t value)
{
unsigned char *ptr;
@ -169,11 +169,11 @@ void mad_bit_write(struct mad_bitptr *bitptr, unsigned int len,
# endif
/*
* NAME: bit->crc()
* DESCRIPTION: compute CRC-check word
* NAME: bit->crc()
* DESCRIPTION: compute CRC-check word
*/
unsigned short mad_bit_crc(struct mad_bitptr bitptr, unsigned int len,
unsigned short init)
unsigned short init)
{
register unsigned int crc;
@ -190,11 +190,11 @@ unsigned short mad_bit_crc(struct mad_bitptr bitptr, unsigned int len,
switch (len / 8) {
case 3: crc = (crc << 8) ^
crc_table[((crc >> 8) ^ mad_bit_read(&bitptr, 8)) & 0xff];
crc_table[((crc >> 8) ^ mad_bit_read(&bitptr, 8)) & 0xff];
case 2: crc = (crc << 8) ^
crc_table[((crc >> 8) ^ mad_bit_read(&bitptr, 8)) & 0xff];
crc_table[((crc >> 8) ^ mad_bit_read(&bitptr, 8)) & 0xff];
case 1: crc = (crc << 8) ^
crc_table[((crc >> 8) ^ mad_bit_read(&bitptr, 8)) & 0xff];
crc_table[((crc >> 8) ^ mad_bit_read(&bitptr, 8)) & 0xff];
len %= 8;

View file

@ -29,10 +29,10 @@ struct mad_bitptr {
void mad_bit_init(struct mad_bitptr *, unsigned char const *);
# define mad_bit_finish(bitptr) /* nothing */
# define mad_bit_finish(bitptr) /* nothing */
unsigned int mad_bit_length(struct mad_bitptr const *,
struct mad_bitptr const *);
struct mad_bitptr const *);
unsigned char mad_bit_bitsleft(struct mad_bitptr const *bitptr);
unsigned char const *mad_bit_nextbyte(struct mad_bitptr const *);

View file

@ -51,25 +51,25 @@
# include "decoder.h"
/*
* NAME: decoder->init()
* DESCRIPTION: initialize a decoder object with callback routines
* NAME: decoder->init()
* DESCRIPTION: initialize a decoder object with callback routines
*/
void mad_decoder_init(struct mad_decoder *decoder, void *data,
enum mad_flow (*input_func)(void *,
struct mad_stream *),
enum mad_flow (*header_func)(void *,
struct mad_header const *),
enum mad_flow (*filter_func)(void *,
struct mad_stream const *,
struct mad_frame *),
enum mad_flow (*output_func)(void *,
struct mad_header const *,
struct mad_pcm *),
enum mad_flow (*error_func)(void *,
struct mad_stream *,
struct mad_frame *),
enum mad_flow (*message_func)(void *,
void *, unsigned int *))
enum mad_flow (*input_func)(void *,
struct mad_stream *),
enum mad_flow (*header_func)(void *,
struct mad_header const *),
enum mad_flow (*filter_func)(void *,
struct mad_stream const *,
struct mad_frame *),
enum mad_flow (*output_func)(void *,
struct mad_header const *,
struct mad_pcm *),
enum mad_flow (*error_func)(void *,
struct mad_stream *,
struct mad_frame *),
enum mad_flow (*message_func)(void *,
void *, unsigned int *))
{
decoder->mode = -1;
@ -237,9 +237,9 @@ enum mad_flow receive(int fd, void **message, unsigned int *size)
if (*size > 0) {
if (*message == 0) {
*message = malloc(*size);
if (*message == 0)
return MAD_FLOW_BREAK;
*message = malloc(*size);
if (*message == 0)
return MAD_FLOW_BREAK;
}
result = receive_io_blocking(fd, *message, *size);
@ -278,8 +278,8 @@ enum mad_flow check_message(struct mad_decoder *decoder)
result = decoder->message_func(decoder->cb_data, message, &size);
if (result == MAD_FLOW_IGNORE ||
result == MAD_FLOW_BREAK)
size = 0;
result == MAD_FLOW_BREAK)
size = 0;
}
if (send(decoder->async.out, message, size) != MAD_FLOW_CONTINUE)
@ -295,7 +295,7 @@ enum mad_flow check_message(struct mad_decoder *decoder)
static
enum mad_flow error_default(void *data, struct mad_stream *stream,
struct mad_frame *frame)
struct mad_frame *frame)
{
int *bad_last_frame = data;
@ -361,92 +361,92 @@ int run_sync(struct mad_decoder *decoder)
while (1) {
# if defined(USE_ASYNC)
if (decoder->mode == MAD_DECODER_MODE_ASYNC) {
switch (check_message(decoder)) {
case MAD_FLOW_IGNORE:
case MAD_FLOW_CONTINUE:
break;
case MAD_FLOW_BREAK:
goto fail;
case MAD_FLOW_STOP:
goto done;
}
switch (check_message(decoder)) {
case MAD_FLOW_IGNORE:
case MAD_FLOW_CONTINUE:
break;
case MAD_FLOW_BREAK:
goto fail;
case MAD_FLOW_STOP:
goto done;
}
}
# endif
if (decoder->header_func) {
if (mad_header_decode(&frame->header, stream) == -1) {
if (!MAD_RECOVERABLE(stream->error))
break;
if (mad_header_decode(&frame->header, stream) == -1) {
if (!MAD_RECOVERABLE(stream->error))
break;
switch (error_func(error_data, stream, frame)) {
case MAD_FLOW_STOP:
goto done;
case MAD_FLOW_BREAK:
goto fail;
case MAD_FLOW_IGNORE:
case MAD_FLOW_CONTINUE:
default:
continue;
}
}
switch (error_func(error_data, stream, frame)) {
case MAD_FLOW_STOP:
goto done;
case MAD_FLOW_BREAK:
goto fail;
case MAD_FLOW_IGNORE:
case MAD_FLOW_CONTINUE:
default:
continue;
}
}
switch (decoder->header_func(decoder->cb_data, &frame->header)) {
case MAD_FLOW_STOP:
goto done;
case MAD_FLOW_BREAK:
goto fail;
case MAD_FLOW_IGNORE:
continue;
case MAD_FLOW_CONTINUE:
break;
}
switch (decoder->header_func(decoder->cb_data, &frame->header)) {
case MAD_FLOW_STOP:
goto done;
case MAD_FLOW_BREAK:
goto fail;
case MAD_FLOW_IGNORE:
continue;
case MAD_FLOW_CONTINUE:
break;
}
}
if (mad_frame_decode(frame, stream) == -1) {
if (!MAD_RECOVERABLE(stream->error))
break;
if (!MAD_RECOVERABLE(stream->error))
break;
switch (error_func(error_data, stream, frame)) {
case MAD_FLOW_STOP:
goto done;
case MAD_FLOW_BREAK:
goto fail;
case MAD_FLOW_IGNORE:
break;
case MAD_FLOW_CONTINUE:
default:
continue;
}
switch (error_func(error_data, stream, frame)) {
case MAD_FLOW_STOP:
goto done;
case MAD_FLOW_BREAK:
goto fail;
case MAD_FLOW_IGNORE:
break;
case MAD_FLOW_CONTINUE:
default:
continue;
}
}
else
bad_last_frame = 0;
bad_last_frame = 0;
if (decoder->filter_func) {
switch (decoder->filter_func(decoder->cb_data, stream, frame)) {
case MAD_FLOW_STOP:
goto done;
case MAD_FLOW_BREAK:
goto fail;
case MAD_FLOW_IGNORE:
continue;
case MAD_FLOW_CONTINUE:
break;
}
switch (decoder->filter_func(decoder->cb_data, stream, frame)) {
case MAD_FLOW_STOP:
goto done;
case MAD_FLOW_BREAK:
goto fail;
case MAD_FLOW_IGNORE:
continue;
case MAD_FLOW_CONTINUE:
break;
}
}
mad_synth_frame(synth, frame);
if (decoder->output_func) {
switch (decoder->output_func(decoder->cb_data,
&frame->header, &synth->pcm)) {
case MAD_FLOW_STOP:
goto done;
case MAD_FLOW_BREAK:
goto fail;
case MAD_FLOW_IGNORE:
case MAD_FLOW_CONTINUE:
break;
}
switch (decoder->output_func(decoder->cb_data,
&frame->header, &synth->pcm)) {
case MAD_FLOW_STOP:
goto done;
case MAD_FLOW_BREAK:
goto fail;
case MAD_FLOW_IGNORE:
case MAD_FLOW_CONTINUE:
break;
}
}
}
}
@ -528,8 +528,8 @@ int run_async(struct mad_decoder *decoder)
# endif
/*
* NAME: decoder->run()
* DESCRIPTION: run the decoder thread either synchronously or asynchronously
* NAME: decoder->run()
* DESCRIPTION: run the decoder thread either synchronously or asynchronously
*/
int mad_decoder_run(struct mad_decoder *decoder, enum mad_decoder_mode mode)
{
@ -564,11 +564,11 @@ int mad_decoder_run(struct mad_decoder *decoder, enum mad_decoder_mode mode)
}
/*
* NAME: decoder->message()
* DESCRIPTION: send a message to and receive a reply from the decoder process
* NAME: decoder->message()
* DESCRIPTION: send a message to and receive a reply from the decoder process
*/
int mad_decoder_message(struct mad_decoder *decoder,
void *message, unsigned int *len)
void *message, unsigned int *len)
{
# if defined(USE_ASYNC)
if (decoder->mode != MAD_DECODER_MODE_ASYNC ||

View file

@ -32,10 +32,10 @@ enum mad_decoder_mode {
};
enum mad_flow {
MAD_FLOW_CONTINUE = 0x0000, /* continue normally */
MAD_FLOW_STOP = 0x0010, /* stop decoding normally */
MAD_FLOW_BREAK = 0x0011, /* stop decoding and signal an error */
MAD_FLOW_IGNORE = 0x0020 /* ignore the current frame */
MAD_FLOW_CONTINUE = 0x0000, /* continue normally */
MAD_FLOW_STOP = 0x0010, /* stop decoding normally */
MAD_FLOW_BREAK = 0x0011, /* stop decoding and signal an error */
MAD_FLOW_IGNORE = 0x0020 /* ignore the current frame */
};
struct mad_decoder {
@ -60,26 +60,26 @@ struct mad_decoder {
enum mad_flow (*input_func)(void *, struct mad_stream *);
enum mad_flow (*header_func)(void *, struct mad_header const *);
enum mad_flow (*filter_func)(void *,
struct mad_stream const *, struct mad_frame *);
struct mad_stream const *, struct mad_frame *);
enum mad_flow (*output_func)(void *,
struct mad_header const *, struct mad_pcm *);
struct mad_header const *, struct mad_pcm *);
enum mad_flow (*error_func)(void *, struct mad_stream *, struct mad_frame *);
enum mad_flow (*message_func)(void *, void *, unsigned int *);
};
void mad_decoder_init(struct mad_decoder *, void *,
enum mad_flow (*)(void *, struct mad_stream *),
enum mad_flow (*)(void *, struct mad_header const *),
enum mad_flow (*)(void *,
struct mad_stream const *,
struct mad_frame *),
enum mad_flow (*)(void *,
struct mad_header const *,
struct mad_pcm *),
enum mad_flow (*)(void *,
struct mad_stream *,
struct mad_frame *),
enum mad_flow (*)(void *, void *, unsigned int *));
enum mad_flow (*)(void *, struct mad_stream *),
enum mad_flow (*)(void *, struct mad_header const *),
enum mad_flow (*)(void *,
struct mad_stream const *,
struct mad_frame *),
enum mad_flow (*)(void *,
struct mad_header const *,
struct mad_pcm *),
enum mad_flow (*)(void *,
struct mad_stream *,
struct mad_frame *),
enum mad_flow (*)(void *, void *, unsigned int *));
int mad_decoder_finish(struct mad_decoder *);
# define mad_decoder_options(decoder, opts) \

View file

@ -28,8 +28,8 @@
# include "fixed.h"
/*
* NAME: fixed->abs()
* DESCRIPTION: return absolute value of a fixed-point number
* NAME: fixed->abs()
* DESCRIPTION: return absolute value of a fixed-point number
*/
mad_fixed_t mad_f_abs(mad_fixed_t x)
{
@ -37,8 +37,8 @@ mad_fixed_t mad_f_abs(mad_fixed_t x)
}
/*
* NAME: fixed->div()
* DESCRIPTION: perform division using fixed-point math
* NAME: fixed->div()
* DESCRIPTION: perform division using fixed-point math
*/
mad_fixed_t mad_f_div(mad_fixed_t x, mad_fixed_t y)
{

View file

@ -64,50 +64,50 @@ typedef mad_fixed_t mad_sample_t;
* supported, and must be done with care.
*/
# define MAD_F_FRACBITS 28
# define MAD_F_FRACBITS 28
# if MAD_F_FRACBITS == 28
# define MAD_F(x) ((mad_fixed_t) (x##L))
# define MAD_F(x) ((mad_fixed_t) (x##L))
# else
# if MAD_F_FRACBITS < 28
# warning "MAD_F_FRACBITS < 28"
# define MAD_F(x) ((mad_fixed_t) \
(((x##L) + \
(1L << (28 - MAD_F_FRACBITS - 1))) >> \
(28 - MAD_F_FRACBITS)))
# define MAD_F(x) ((mad_fixed_t) \
(((x##L) + \
(1L << (28 - MAD_F_FRACBITS - 1))) >> \
(28 - MAD_F_FRACBITS)))
# elif MAD_F_FRACBITS > 28
# error "MAD_F_FRACBITS > 28 not currently supported"
# define MAD_F(x) ((mad_fixed_t) \
((x##L) << (MAD_F_FRACBITS - 28)))
# define MAD_F(x) ((mad_fixed_t) \
((x##L) << (MAD_F_FRACBITS - 28)))
# endif
# endif
# define MAD_F_MIN ((mad_fixed_t) -0x80000000L)
# define MAD_F_MAX ((mad_fixed_t) +0x7fffffffL)
# define MAD_F_MIN ((mad_fixed_t) -0x80000000L)
# define MAD_F_MAX ((mad_fixed_t) +0x7fffffffL)
# define MAD_F_ONE MAD_F(0x10000000)
# define MAD_F_ONE MAD_F(0x10000000)
# define mad_f_tofixed(x) ((mad_fixed_t) \
((x) * (double) (1L << MAD_F_FRACBITS) + 0.5))
# define mad_f_todouble(x) ((double) \
((x) / (double) (1L << MAD_F_FRACBITS)))
# define mad_f_tofixed(x) ((mad_fixed_t) \
((x) * (double) (1L << MAD_F_FRACBITS) + 0.5))
# define mad_f_todouble(x) ((double) \
((x) / (double) (1L << MAD_F_FRACBITS)))
# define mad_f_intpart(x) ((x) >> MAD_F_FRACBITS)
# define mad_f_fracpart(x) ((x) & ((1L << MAD_F_FRACBITS) - 1))
/* (x should be positive) */
# define mad_f_intpart(x) ((x) >> MAD_F_FRACBITS)
# define mad_f_fracpart(x) ((x) & ((1L << MAD_F_FRACBITS) - 1))
/* (x should be positive) */
# define mad_f_fromint(x) ((x) << MAD_F_FRACBITS)
# define mad_f_fromint(x) ((x) << MAD_F_FRACBITS)
# define mad_f_add(x, y) ((x) + (y))
# define mad_f_sub(x, y) ((x) - (y))
# define mad_f_add(x, y) ((x) + (y))
# define mad_f_sub(x, y) ((x) - (y))
# if defined(FPM_FLOAT)
# error "FPM_FLOAT not yet supported"
# undef MAD_F
# define MAD_F(x) mad_f_todouble(x)
# define MAD_F(x) mad_f_todouble(x)
# define mad_f_mul(x, y) ((x) * (y))
# define mad_f_mul(x, y) ((x) * (y))
# define mad_f_scale64
# undef ASO_ZEROCHECK
@ -154,7 +154,7 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
}
# pragma warning(pop)
# define mad_f_mul mad_f_mul_inline
# define mad_f_mul mad_f_mul_inline
# define mad_f_scale64
# else
/*
@ -163,9 +163,9 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
*/
# define MAD_F_MLX(hi, lo, x, y) \
asm ("imull %3" \
: "=a" (lo), "=d" (hi) \
: "%a" (x), "rm" (y) \
: "cc")
: "=a" (lo), "=d" (hi) \
: "%a" (x), "rm" (y) \
: "cc")
# if defined(OPT_ACCURACY)
/*
@ -176,10 +176,10 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
mad_fixed64lo_t __lo; \
MAD_F_MLX(__hi, __lo, (x), (y)); \
asm ("addl %2,%0\n\t" \
"adcl %3,%1" \
: "=rm" (lo), "=rm" (hi) \
: "r" (__lo), "r" (__hi), "0" (lo), "1" (hi) \
: "cc"); \
"adcl %3,%1" \
: "=rm" (lo), "=rm" (hi) \
: "r" (__lo), "r" (__hi), "0" (lo), "1" (hi) \
: "cc"); \
})
# endif /* OPT_ACCURACY */
@ -192,15 +192,15 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
mad_fixed64lo_t __lo_; \
mad_fixed_t __result; \
asm ("addl %4,%2\n\t" \
"adcl %5,%3" \
: "=rm" (__lo_), "=rm" (__hi_) \
: "0" (lo), "1" (hi), \
"ir" (1L << (MAD_F_SCALEBITS - 1)), "ir" (0) \
: "cc"); \
"adcl %5,%3" \
: "=rm" (__lo_), "=rm" (__hi_) \
: "0" (lo), "1" (hi), \
"ir" (1L << (MAD_F_SCALEBITS - 1)), "ir" (0) \
: "cc"); \
asm ("shrdl %3,%2,%1" \
: "=rm" (__result) \
: "0" (__lo_), "r" (__hi_), "I" (MAD_F_SCALEBITS) \
: "cc"); \
: "=rm" (__result) \
: "0" (__lo_), "r" (__hi_), "I" (MAD_F_SCALEBITS) \
: "cc"); \
__result; \
})
# elif defined(OPT_INTEL)
@ -210,21 +210,21 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
# define mad_f_scale64(hi, lo) \
({ mad_fixed_t __result; \
asm ("shrl %3,%1\n\t" \
"shll %4,%2\n\t" \
"orl %2,%1" \
: "=rm" (__result) \
: "0" (lo), "r" (hi), \
"I" (MAD_F_SCALEBITS), "I" (32 - MAD_F_SCALEBITS) \
: "cc"); \
"shll %4,%2\n\t" \
"orl %2,%1" \
: "=rm" (__result) \
: "0" (lo), "r" (hi), \
"I" (MAD_F_SCALEBITS), "I" (32 - MAD_F_SCALEBITS) \
: "cc"); \
__result; \
})
# else
# define mad_f_scale64(hi, lo) \
({ mad_fixed_t __result; \
asm ("shrdl %3,%2,%1" \
: "=rm" (__result) \
: "0" (lo), "r" (hi), "I" (MAD_F_SCALEBITS) \
: "cc"); \
: "=rm" (__result) \
: "0" (lo), "r" (hi), "I" (MAD_F_SCALEBITS) \
: "cc"); \
__result; \
})
# endif /* OPT_ACCURACY */
@ -249,42 +249,42 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
({ mad_fixed64hi_t __hi; \
mad_fixed64lo_t __lo; \
mad_fixed_t __result; \
asm ("smull %0, %1, %3, %4\n\t" \
"movs %0, %0, lsr %5\n\t" \
"adc %2, %0, %1, lsl %6" \
: "=&r" (__lo), "=&r" (__hi), "=r" (__result) \
: "%r" (x), "r" (y), \
"M" (MAD_F_SCALEBITS), "M" (32 - MAD_F_SCALEBITS) \
: "cc"); \
asm ("smull %0, %1, %3, %4\n\t" \
"movs %0, %0, lsr %5\n\t" \
"adc %2, %0, %1, lsl %6" \
: "=&r" (__lo), "=&r" (__hi), "=r" (__result) \
: "%r" (x), "r" (y), \
"M" (MAD_F_SCALEBITS), "M" (32 - MAD_F_SCALEBITS) \
: "cc"); \
__result; \
})
# endif
# define MAD_F_MLX(hi, lo, x, y) \
asm ("smull %0, %1, %2, %3" \
: "=&r" (lo), "=&r" (hi) \
: "%r" (x), "r" (y))
asm ("smull %0, %1, %2, %3" \
: "=&r" (lo), "=&r" (hi) \
: "%r" (x), "r" (y))
# define MAD_F_MLA(hi, lo, x, y) \
asm ("smlal %0, %1, %2, %3" \
: "+r" (lo), "+r" (hi) \
: "%r" (x), "r" (y))
asm ("smlal %0, %1, %2, %3" \
: "+r" (lo), "+r" (hi) \
: "%r" (x), "r" (y))
# define MAD_F_MLN(hi, lo) \
asm ("rsbs %0, %2, #0\n\t" \
"rsc %1, %3, #0" \
: "=r" (lo), "=r" (hi) \
: "0" (lo), "1" (hi) \
: "cc")
asm ("rsbs %0, %2, #0\n\t" \
"rsc %1, %3, #0" \
: "=r" (lo), "=r" (hi) \
: "0" (lo), "1" (hi) \
: "cc")
# define mad_f_scale64(hi, lo) \
({ mad_fixed_t __result; \
asm ("movs %0, %1, lsr %3\n\t" \
"adc %0, %0, %2, lsl %4" \
: "=&r" (__result) \
: "r" (lo), "r" (hi), \
"M" (MAD_F_SCALEBITS), "M" (32 - MAD_F_SCALEBITS) \
: "cc"); \
asm ("movs %0, %1, lsr %3\n\t" \
"adc %0, %0, %2, lsl %4" \
: "=&r" (__result) \
: "r" (lo), "r" (hi), \
"M" (MAD_F_SCALEBITS), "M" (32 - MAD_F_SCALEBITS) \
: "cc"); \
__result; \
})
@ -299,28 +299,28 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
* significant bit depends on OPT_ACCURACY via mad_f_scale64().
*/
# define MAD_F_MLX(hi, lo, x, y) \
asm ("mult %2,%3" \
: "=l" (lo), "=h" (hi) \
: "%r" (x), "r" (y))
asm ("mult %2,%3" \
: "=l" (lo), "=h" (hi) \
: "%r" (x), "r" (y))
# if defined(HAVE_MADD_ASM)
# define MAD_F_MLA(hi, lo, x, y) \
asm ("madd %2,%3" \
: "+l" (lo), "+h" (hi) \
: "%r" (x), "r" (y))
asm ("madd %2,%3" \
: "+l" (lo), "+h" (hi) \
: "%r" (x), "r" (y))
# elif defined(HAVE_MADD16_ASM)
/*
* This loses significant accuracy due to the 16-bit integer limit in the
* multiply/accumulate instruction.
*/
# define MAD_F_ML0(hi, lo, x, y) \
asm ("mult %2,%3" \
: "=l" (lo), "=h" (hi) \
: "%r" ((x) >> 12), "r" ((y) >> 16))
asm ("mult %2,%3" \
: "=l" (lo), "=h" (hi) \
: "%r" ((x) >> 12), "r" ((y) >> 16))
# define MAD_F_MLA(hi, lo, x, y) \
asm ("madd16 %2,%3" \
: "+l" (lo), "+h" (hi) \
: "%r" ((x) >> 12), "r" ((y) >> 16))
asm ("madd16 %2,%3" \
: "+l" (lo), "+h" (hi) \
: "%r" ((x) >> 12), "r" ((y) >> 16))
# define MAD_F_MLZ(hi, lo) ((mad_fixed_t) (lo))
# endif
@ -340,9 +340,9 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
*/
# define MAD_F_MLX(hi, lo, x, y) \
asm ("smul %2, %3, %0\n\t" \
"rd %%y, %1" \
: "=r" (lo), "=r" (hi) \
: "%r" (x), "rI" (y))
"rd %%y, %1" \
: "=r" (lo), "=r" (hi) \
: "%r" (x), "rI" (y))
/* --- PowerPC ------------------------------------------------------------- */
@ -355,11 +355,11 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
# define MAD_F_MLX(hi, lo, x, y) \
do { \
asm ("mullw %0,%1,%2" \
: "=r" (lo) \
: "%r" (x), "r" (y)); \
: "=r" (lo) \
: "%r" (x), "r" (y)); \
asm ("mulhw %0,%1,%2" \
: "=r" (hi) \
: "%r" (x), "r" (y)); \
: "=r" (hi) \
: "%r" (x), "r" (y)); \
} \
while (0)
@ -372,11 +372,11 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
mad_fixed64lo_t __lo; \
MAD_F_MLX(__hi, __lo, (x), (y)); \
asm ("addc %0,%2,%3\n\t" \
"adde %1,%4,%5" \
: "=r" (lo), "=r" (hi) \
: "%r" (lo), "r" (__lo), \
"%r" (hi), "r" (__hi) \
: "xer"); \
"adde %1,%4,%5" \
: "=r" (lo), "=r" (hi) \
: "%r" (lo), "r" (__lo), \
"%r" (hi), "r" (__hi) \
: "xer"); \
})
# endif
@ -387,28 +387,28 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
# define mad_f_scale64(hi, lo) \
({ mad_fixed_t __result, __round; \
asm ("rotrwi %0,%1,%2" \
: "=r" (__result) \
: "r" (lo), "i" (MAD_F_SCALEBITS)); \
: "=r" (__result) \
: "r" (lo), "i" (MAD_F_SCALEBITS)); \
asm ("extrwi %0,%1,1,0" \
: "=r" (__round) \
: "r" (__result)); \
: "=r" (__round) \
: "r" (__result)); \
asm ("insrwi %0,%1,%2,0" \
: "+r" (__result) \
: "r" (hi), "i" (MAD_F_SCALEBITS)); \
: "+r" (__result) \
: "r" (hi), "i" (MAD_F_SCALEBITS)); \
asm ("add %0,%1,%2" \
: "=r" (__result) \
: "%r" (__result), "r" (__round)); \
: "=r" (__result) \
: "%r" (__result), "r" (__round)); \
__result; \
})
# else
# define mad_f_scale64(hi, lo) \
({ mad_fixed_t __result; \
asm ("rotrwi %0,%1,%2" \
: "=r" (__result) \
: "r" (lo), "i" (MAD_F_SCALEBITS)); \
: "=r" (__result) \
: "r" (lo), "i" (MAD_F_SCALEBITS)); \
asm ("insrwi %0,%1,%2,0" \
: "+r" (__result) \
: "r" (hi), "i" (MAD_F_SCALEBITS)); \
: "+r" (__result) \
: "r" (hi), "i" (MAD_F_SCALEBITS)); \
__result; \
})
# endif
@ -452,10 +452,10 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
* Pre-rounding is required to stay within the limits of compliance.
*/
# if defined(OPT_SPEED)
# define mad_f_mul(x, y) (((x) >> 12) * ((y) >> 16))
# define mad_f_mul(x, y) (((x) >> 12) * ((y) >> 16))
# else
# define mad_f_mul(x, y) ((((x) + (1L << 11)) >> 12) * \
(((y) + (1L << 15)) >> 16))
# define mad_f_mul(x, y) ((((x) + (1L << 11)) >> 12) * \
(((y) + (1L << 15)) >> 16))
# endif
/* ------------------------------------------------------------------------- */
@ -476,22 +476,22 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
# endif
# if !defined(MAD_F_MLA)
# define MAD_F_ML0(hi, lo, x, y) ((lo) = mad_f_mul((x), (y)))
# define MAD_F_MLA(hi, lo, x, y) ((lo) += mad_f_mul((x), (y)))
# define MAD_F_MLN(hi, lo) ((lo) = -(lo))
# define MAD_F_MLZ(hi, lo) ((void) (hi), (mad_fixed_t) (lo))
# define MAD_F_ML0(hi, lo, x, y) ((lo) = mad_f_mul((x), (y)))
# define MAD_F_MLA(hi, lo, x, y) ((lo) += mad_f_mul((x), (y)))
# define MAD_F_MLN(hi, lo) ((lo) = -(lo))
# define MAD_F_MLZ(hi, lo) ((void) (hi), (mad_fixed_t) (lo))
# endif
# if !defined(MAD_F_ML0)
# define MAD_F_ML0(hi, lo, x, y) MAD_F_MLX((hi), (lo), (x), (y))
# define MAD_F_ML0(hi, lo, x, y) MAD_F_MLX((hi), (lo), (x), (y))
# endif
# if !defined(MAD_F_MLN)
# define MAD_F_MLN(hi, lo) ((hi) = ((lo) = -(lo)) ? ~(hi) : -(hi))
# define MAD_F_MLN(hi, lo) ((hi) = ((lo) = -(lo)) ? ~(hi) : -(hi))
# endif
# if !defined(MAD_F_MLZ)
# define MAD_F_MLZ(hi, lo) mad_f_scale64((hi), (lo))
# define MAD_F_MLZ(hi, lo) mad_f_scale64((hi), (lo))
# endif
# if !defined(mad_f_scale64)
@ -499,7 +499,7 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
# define mad_f_scale64(hi, lo) \
((((mad_fixed_t) \
(((hi) << (32 - (MAD_F_SCALEBITS - 1))) | \
((lo) >> (MAD_F_SCALEBITS - 1)))) + 1) >> 1)
((lo) >> (MAD_F_SCALEBITS - 1)))) + 1) >> 1)
# else
# define mad_f_scale64(hi, lo) \
((mad_fixed_t) \

View file

@ -61,8 +61,8 @@ int (*const decoder_table[3])(struct mad_stream *, struct mad_frame *) = {
};
/*
* NAME: header->init()
* DESCRIPTION: initialize header struct
* NAME: header->init()
* DESCRIPTION: initialize header struct
*/
void mad_header_init(struct mad_header *header)
{
@ -84,8 +84,8 @@ void mad_header_init(struct mad_header *header)
}
/*
* NAME: frame->init()
* DESCRIPTION: initialize frame struct
* NAME: frame->init()
* DESCRIPTION: initialize frame struct
*/
void mad_frame_init(struct mad_frame *frame)
{
@ -98,8 +98,8 @@ void mad_frame_init(struct mad_frame *frame)
}
/*
* NAME: frame->finish()
* DESCRIPTION: deallocate any dynamic memory associated with frame
* NAME: frame->finish()
* DESCRIPTION: deallocate any dynamic memory associated with frame
*/
void mad_frame_finish(struct mad_frame *frame)
{
@ -112,8 +112,8 @@ void mad_frame_finish(struct mad_frame *frame)
}
/*
* NAME: decode_header()
* DESCRIPTION: read header data and following CRC word
* NAME: decode_header()
* DESCRIPTION: read header data and following CRC word
*/
static
int decode_header(struct mad_header *header, struct mad_stream *stream)
@ -231,8 +231,8 @@ int decode_header(struct mad_header *header, struct mad_stream *stream)
}
/*
* NAME: free_bitrate()
* DESCRIPTION: attempt to discover the bitstream's free bitrate
* NAME: free_bitrate()
* DESCRIPTION: attempt to discover the bitstream's free bitrate
*/
static
int free_bitrate(struct mad_stream *stream, struct mad_header const *header)
@ -246,7 +246,7 @@ int free_bitrate(struct mad_stream *stream, struct mad_header const *header)
pad_slot = (header->flags & MAD_FLAG_PADDING) ? 1 : 0;
slots_per_frame = (header->layer == MAD_LAYER_III &&
(header->flags & MAD_FLAG_LSF_EXT)) ? 72 : 144;
(header->flags & MAD_FLAG_LSF_EXT)) ? 72 : 144;
while (mad_stream_sync(stream) == 0) {
struct mad_stream peek_stream;
@ -256,8 +256,8 @@ int free_bitrate(struct mad_stream *stream, struct mad_header const *header)
peek_header = *header;
if (decode_header(&peek_header, &peek_stream) == 0 &&
peek_header.layer == header->layer &&
peek_header.samplerate == header->samplerate) {
peek_header.layer == header->layer &&
peek_header.samplerate == header->samplerate) {
unsigned int N;
ptr = mad_bit_nextbyte(&stream->ptr);
@ -265,16 +265,16 @@ int free_bitrate(struct mad_stream *stream, struct mad_header const *header)
N = ptr - stream->this_frame;
if (header->layer == MAD_LAYER_I) {
rate = (unsigned long) header->samplerate *
(N - 4 * pad_slot + 4) / 48 / 1000;
rate = (unsigned long) header->samplerate *
(N - 4 * pad_slot + 4) / 48 / 1000;
}
else {
rate = (unsigned long) header->samplerate *
(N - pad_slot + 1) / slots_per_frame / 1000;
rate = (unsigned long) header->samplerate *
(N - pad_slot + 1) / slots_per_frame / 1000;
}
if (rate >= 8)
break;
break;
}
mad_bit_skip(&stream->ptr, 8);
@ -293,8 +293,8 @@ int free_bitrate(struct mad_stream *stream, struct mad_header const *header)
}
/*
* NAME: header->decode()
* DESCRIPTION: read the next frame header from the stream
* NAME: header->decode()
* DESCRIPTION: read the next frame header from the stream
*/
int mad_header_decode(struct mad_header *header, struct mad_stream *stream)
{
@ -351,7 +351,7 @@ int mad_header_decode(struct mad_header *header, struct mad_stream *stream)
if (mad_stream_sync(stream) == -1) {
if (end - stream->next_frame >= MAD_BUFFER_GUARD)
stream->next_frame = end - MAD_BUFFER_GUARD;
stream->next_frame = end - MAD_BUFFER_GUARD;
stream->error = MAD_ERROR_BUFLEN;
goto fail;
@ -371,13 +371,13 @@ int mad_header_decode(struct mad_header *header, struct mad_stream *stream)
/* calculate frame duration */
mad_timer_set(&header->duration, 0,
32 * MAD_NSBSAMPLES(header), header->samplerate);
32 * MAD_NSBSAMPLES(header), header->samplerate);
/* calculate free bit rate */
if (header->bitrate == 0) {
if ((stream->freerate == 0 || !stream->sync ||
(header->layer == MAD_LAYER_III && stream->freerate > 640000)) &&
free_bitrate(stream, header) == -1)
(header->layer == MAD_LAYER_III && stream->freerate > 640000)) &&
free_bitrate(stream, header) == -1)
goto fail;
header->bitrate = stream->freerate;
@ -393,7 +393,7 @@ int mad_header_decode(struct mad_header *header, struct mad_stream *stream)
unsigned int slots_per_frame;
slots_per_frame = (header->layer == MAD_LAYER_III &&
(header->flags & MAD_FLAG_LSF_EXT)) ? 72 : 144;
(header->flags & MAD_FLAG_LSF_EXT)) ? 72 : 144;
N = (slots_per_frame * header->bitrate / header->samplerate) + pad_slot;
}
@ -431,8 +431,8 @@ int mad_header_decode(struct mad_header *header, struct mad_stream *stream)
}
/*
* NAME: frame->decode()
* DESCRIPTION: decode a single frame from a bitstream
* NAME: frame->decode()
* DESCRIPTION: decode a single frame from a bitstream
*/
int mad_frame_decode(struct mad_frame *frame, struct mad_stream *stream)
{
@ -479,8 +479,8 @@ int mad_frame_decode(struct mad_frame *frame, struct mad_stream *stream)
}
/*
* NAME: frame->mute()
* DESCRIPTION: zero all subband values so the frame becomes silent
* NAME: frame->mute()
* DESCRIPTION: zero all subband values so the frame becomes silent
*/
void mad_frame_mute(struct mad_frame *frame)
{
@ -496,8 +496,8 @@ void mad_frame_mute(struct mad_frame *frame)
if (frame->overlap) {
for (s = 0; s < 18; ++s) {
for (sb = 0; sb < 32; ++sb) {
(*frame->overlap)[0][sb][s] =
(*frame->overlap)[1][sb][s] = 0;
(*frame->overlap)[0][sb][s] =
(*frame->overlap)[1][sb][s] = 0;
}
}
}

View file

@ -27,41 +27,41 @@
# include "stream.h"
enum mad_layer {
MAD_LAYER_I = 1, /* Layer I */
MAD_LAYER_II = 2, /* Layer II */
MAD_LAYER_III = 3 /* Layer III */
MAD_LAYER_I = 1, /* Layer I */
MAD_LAYER_II = 2, /* Layer II */
MAD_LAYER_III = 3 /* Layer III */
};
enum mad_mode {
MAD_MODE_SINGLE_CHANNEL = 0, /* single channel */
MAD_MODE_DUAL_CHANNEL = 1, /* dual channel */
MAD_MODE_JOINT_STEREO = 2, /* joint (MS/intensity) stereo */
MAD_MODE_STEREO = 3 /* normal LR stereo */
MAD_MODE_SINGLE_CHANNEL = 0, /* single channel */
MAD_MODE_DUAL_CHANNEL = 1, /* dual channel */
MAD_MODE_JOINT_STEREO = 2, /* joint (MS/intensity) stereo */
MAD_MODE_STEREO = 3 /* normal LR stereo */
};
enum mad_emphasis {
MAD_EMPHASIS_NONE = 0, /* no emphasis */
MAD_EMPHASIS_50_15_US = 1, /* 50/15 microseconds emphasis */
MAD_EMPHASIS_CCITT_J_17 = 3, /* CCITT J.17 emphasis */
MAD_EMPHASIS_RESERVED = 2 /* unknown emphasis */
MAD_EMPHASIS_NONE = 0, /* no emphasis */
MAD_EMPHASIS_50_15_US = 1, /* 50/15 microseconds emphasis */
MAD_EMPHASIS_CCITT_J_17 = 3, /* CCITT J.17 emphasis */
MAD_EMPHASIS_RESERVED = 2 /* unknown emphasis */
};
struct mad_header {
enum mad_layer layer; /* audio layer (1, 2, or 3) */
enum mad_mode mode; /* channel mode (see above) */
int mode_extension; /* additional mode info */
enum mad_emphasis emphasis; /* de-emphasis to use (see above) */
enum mad_layer layer; /* audio layer (1, 2, or 3) */
enum mad_mode mode; /* channel mode (see above) */
int mode_extension; /* additional mode info */
enum mad_emphasis emphasis; /* de-emphasis to use (see above) */
unsigned long bitrate; /* stream bitrate (bps) */
unsigned int samplerate; /* sampling frequency (Hz) */
unsigned long bitrate; /* stream bitrate (bps) */
unsigned int samplerate; /* sampling frequency (Hz) */
unsigned short crc_check; /* frame CRC accumulator */
unsigned short crc_target; /* final target CRC checksum */
unsigned short crc_check; /* frame CRC accumulator */
unsigned short crc_target; /* final target CRC checksum */
int flags; /* flags (see below) */
int private_bits; /* private bits (see below) */
int flags; /* flags (see below) */
int private_bits; /* private bits (see below) */
mad_timer_t duration; /* audio playing time of frame */
mad_timer_t duration; /* audio playing time of frame */
};
struct mad_frame {
@ -76,33 +76,33 @@ struct mad_frame {
mad_fixed_t (*overlap)[2][32][18]; /* Layer III block overlap data */
};
# define MAD_NCHANNELS(header) ((header)->mode ? 2 : 1)
# define MAD_NCHANNELS(header) ((header)->mode ? 2 : 1)
# define MAD_NSBSAMPLES(header) \
((header)->layer == MAD_LAYER_I ? 12 : \
(((header)->layer == MAD_LAYER_III && \
((header)->flags & MAD_FLAG_LSF_EXT)) ? 18 : 36))
enum {
MAD_FLAG_NPRIVATE_III = 0x0007, /* number of Layer III private bits */
MAD_FLAG_INCOMPLETE = 0x0008, /* header but not data is decoded */
MAD_FLAG_NPRIVATE_III = 0x0007, /* number of Layer III private bits */
MAD_FLAG_INCOMPLETE = 0x0008, /* header but not data is decoded */
MAD_FLAG_PROTECTION = 0x0010, /* frame has CRC protection */
MAD_FLAG_COPYRIGHT = 0x0020, /* frame is copyright */
MAD_FLAG_ORIGINAL = 0x0040, /* frame is original (else copy) */
MAD_FLAG_PADDING = 0x0080, /* frame has additional slot */
MAD_FLAG_PROTECTION = 0x0010, /* frame has CRC protection */
MAD_FLAG_COPYRIGHT = 0x0020, /* frame is copyright */
MAD_FLAG_ORIGINAL = 0x0040, /* frame is original (else copy) */
MAD_FLAG_PADDING = 0x0080, /* frame has additional slot */
MAD_FLAG_I_STEREO = 0x0100, /* uses intensity joint stereo */
MAD_FLAG_MS_STEREO = 0x0200, /* uses middle/side joint stereo */
MAD_FLAG_FREEFORMAT = 0x0400, /* uses free format bitrate */
MAD_FLAG_I_STEREO = 0x0100, /* uses intensity joint stereo */
MAD_FLAG_MS_STEREO = 0x0200, /* uses middle/side joint stereo */
MAD_FLAG_FREEFORMAT = 0x0400, /* uses free format bitrate */
MAD_FLAG_LSF_EXT = 0x1000, /* lower sampling freq. extension */
MAD_FLAG_MC_EXT = 0x2000, /* multichannel audio extension */
MAD_FLAG_MPEG_2_5_EXT = 0x4000 /* MPEG 2.5 (unofficial) extension */
MAD_FLAG_LSF_EXT = 0x1000, /* lower sampling freq. extension */
MAD_FLAG_MC_EXT = 0x2000, /* multichannel audio extension */
MAD_FLAG_MPEG_2_5_EXT = 0x4000 /* MPEG 2.5 (unofficial) extension */
};
enum {
MAD_PRIVATE_HEADER = 0x0100, /* header private bit */
MAD_PRIVATE_III = 0x001f /* Layer III private bits (up to 5) */
MAD_PRIVATE_HEADER = 0x0100, /* header private bit */
MAD_PRIVATE_III = 0x001f /* Layer III private bits (up to 5) */
};
void mad_header_init(struct mad_header *);

View file

@ -64,9 +64,9 @@
# if !defined(HAVE_ASSERT_H)
# if defined(NDEBUG)
# define assert(x) /* nothing */
# define assert(x) /* nothing */
# else
# define assert(x) do { if (!(x)) abort(); } while (0)
# define assert(x) do { if (!(x)) abort(); } while (0)
# endif
# endif

File diff suppressed because it is too large Load diff

View file

@ -69,8 +69,8 @@ mad_fixed_t const linear_table[14] ICONST_ATTR = {
};
/*
* NAME: I_sample()
* DESCRIPTION: decode one requantized Layer I sample from a bitstream
* NAME: I_sample()
* DESCRIPTION: decode one requantized Layer I sample from a bitstream
*/
static inline
mad_fixed_t I_sample(struct mad_bitptr *ptr, unsigned int nb)
@ -99,8 +99,8 @@ mad_fixed_t I_sample(struct mad_bitptr *ptr, unsigned int nb)
}
/*
* NAME: layer->I()
* DESCRIPTION: decode a single Layer I frame
* NAME: layer->I()
* DESCRIPTION: decode a single Layer I frame
*/
int mad_layer_I(struct mad_stream *stream, struct mad_frame *frame)
{
@ -121,10 +121,10 @@ int mad_layer_I(struct mad_stream *stream, struct mad_frame *frame)
if (header->flags & MAD_FLAG_PROTECTION) {
header->crc_check =
mad_bit_crc(stream->ptr, 4 * (bound * nch + (32 - bound)),
header->crc_check);
header->crc_check);
if (header->crc_check != header->crc_target &&
!(frame->options & MAD_OPTION_IGNORECRC)) {
!(frame->options & MAD_OPTION_IGNORECRC)) {
stream->error = MAD_ERROR_BADCRC;
return -1;
}
@ -137,8 +137,8 @@ int mad_layer_I(struct mad_stream *stream, struct mad_frame *frame)
nb = mad_bit_read(&stream->ptr, 4);
if (nb == 15) {
stream->error = MAD_ERROR_BADBITALLOC;
return -1;
stream->error = MAD_ERROR_BADBITALLOC;
return -1;
}
allocation[ch][sb] = nb ? nb + 1 : 0;
@ -162,18 +162,18 @@ int mad_layer_I(struct mad_stream *stream, struct mad_frame *frame)
for (sb = 0; sb < 32; ++sb) {
for (ch = 0; ch < nch; ++ch) {
if (allocation[ch][sb]) {
scalefactor[ch][sb] = mad_bit_read(&stream->ptr, 6);
scalefactor[ch][sb] = mad_bit_read(&stream->ptr, 6);
# if defined(OPT_STRICT)
/*
* Scalefactor index 63 does not appear in Table B.1 of
* ISO/IEC 11172-3. Nonetheless, other implementations accept it,
* so we only reject it if OPT_STRICT is defined.
*/
if (scalefactor[ch][sb] == 63) {
stream->error = MAD_ERROR_BADSCALEFACTOR;
return -1;
}
/*
* Scalefactor index 63 does not appear in Table B.1 of
* ISO/IEC 11172-3. Nonetheless, other implementations accept it,
* so we only reject it if OPT_STRICT is defined.
*/
if (scalefactor[ch][sb] == 63) {
stream->error = MAD_ERROR_BADSCALEFACTOR;
return -1;
}
# endif
}
}
@ -184,27 +184,27 @@ int mad_layer_I(struct mad_stream *stream, struct mad_frame *frame)
for (s = 0; s < 12; ++s) {
for (sb = 0; sb < bound; ++sb) {
for (ch = 0; ch < nch; ++ch) {
nb = allocation[ch][sb];
(*frame->sbsample)[ch][s][sb] = nb ?
mad_f_mul(I_sample(&stream->ptr, nb),
sf_table[scalefactor[ch][sb]]) : 0;
nb = allocation[ch][sb];
(*frame->sbsample)[ch][s][sb] = nb ?
mad_f_mul(I_sample(&stream->ptr, nb),
sf_table[scalefactor[ch][sb]]) : 0;
}
}
for (sb = bound; sb < 32; ++sb) {
if ((nb = allocation[0][sb])) {
mad_fixed_t sample;
mad_fixed_t sample;
sample = I_sample(&stream->ptr, nb);
sample = I_sample(&stream->ptr, nb);
for (ch = 0; ch < nch; ++ch) {
(*frame->sbsample)[ch][s][sb] =
mad_f_mul(sample, sf_table[scalefactor[ch][sb]]);
}
for (ch = 0; ch < nch; ++ch) {
(*frame->sbsample)[ch][s][sb] =
mad_f_mul(sample, sf_table[scalefactor[ch][sb]]);
}
}
else {
for (ch = 0; ch < nch; ++ch)
(*frame->sbsample)[ch][s][sb] = 0;
for (ch = 0; ch < nch; ++ch)
(*frame->sbsample)[ch][s][sb] = 0;
}
}
}
@ -221,18 +221,18 @@ struct {
unsigned char const offsets[30];
} const sbquant_table[5] = {
/* ISO/IEC 11172-3 Table B.2a */
{ 27, { 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 6, 3, 3, 3, 3, 3, /* 0 */
3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0 } },
{ 27, { 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 6, 3, 3, 3, 3, 3, /* 0 */
3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0 } },
/* ISO/IEC 11172-3 Table B.2b */
{ 30, { 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 6, 3, 3, 3, 3, 3, /* 1 */
3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0 } },
{ 30, { 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 6, 3, 3, 3, 3, 3, /* 1 */
3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0 } },
/* ISO/IEC 11172-3 Table B.2c */
{ 8, { 5, 5, 2, 2, 2, 2, 2, 2 } }, /* 2 */
{ 8, { 5, 5, 2, 2, 2, 2, 2, 2 } }, /* 2 */
/* ISO/IEC 11172-3 Table B.2d */
{ 12, { 5, 5, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 } }, /* 3 */
{ 12, { 5, 5, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 } }, /* 3 */
/* ISO/IEC 13818-3 Table B.1 */
{ 30, { 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, /* 4 */
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 } }
{ 30, { 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, /* 4 */
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 } }
};
/* bit allocation table */
@ -275,13 +275,13 @@ struct quantclass {
};
/*
* NAME: II_samples()
* DESCRIPTION: decode three requantized Layer II samples from a bitstream
* NAME: II_samples()
* DESCRIPTION: decode three requantized Layer II samples from a bitstream
*/
static
void II_samples(struct mad_bitptr *ptr,
struct quantclass const *quantclass,
mad_fixed_t output[3])
struct quantclass const *quantclass,
mad_fixed_t output[3])
{
unsigned int nb, s, sample[3];
@ -326,8 +326,8 @@ void II_samples(struct mad_bitptr *ptr,
}
/*
* NAME: layer->II()
* DESCRIPTION: decode a single Layer II frame
* NAME: layer->II()
* DESCRIPTION: decode a single Layer II frame
*/
int mad_layer_II(struct mad_stream *stream, struct mad_frame *frame)
{
@ -358,19 +358,19 @@ int mad_layer_II(struct mad_stream *stream, struct mad_frame *frame)
* restriction. We enforce it if OPT_STRICT is defined.
*/
if (bitrate_per_channel <= 28000 || bitrate_per_channel == 40000) {
stream->error = MAD_ERROR_BADMODE;
return -1;
stream->error = MAD_ERROR_BADMODE;
return -1;
}
# endif
}
else { /* nch == 1 */
if (bitrate_per_channel > 192000) {
/*
* ISO/IEC 11172-3 does not allow single channel mode for 224, 256,
* 320, or 384 kbps bitrates in Layer II.
*/
stream->error = MAD_ERROR_BADMODE;
return -1;
/*
* ISO/IEC 11172-3 does not allow single channel mode for 224, 256,
* 320, or 384 kbps bitrates in Layer II.
*/
stream->error = MAD_ERROR_BADMODE;
return -1;
}
}
@ -419,7 +419,7 @@ int mad_layer_II(struct mad_stream *stream, struct mad_frame *frame)
for (sb = 0; sb < sblimit; ++sb) {
for (ch = 0; ch < nch; ++ch) {
if (allocation[ch][sb])
scfsi[ch][sb] = mad_bit_read(&stream->ptr, 2);
scfsi[ch][sb] = mad_bit_read(&stream->ptr, 2);
}
}
@ -428,10 +428,10 @@ int mad_layer_II(struct mad_stream *stream, struct mad_frame *frame)
if (header->flags & MAD_FLAG_PROTECTION) {
header->crc_check =
mad_bit_crc(start, mad_bit_length(&start, &stream->ptr),
header->crc_check);
header->crc_check);
if (header->crc_check != header->crc_target &&
!(frame->options & MAD_OPTION_IGNORECRC)) {
!(frame->options & MAD_OPTION_IGNORECRC)) {
stream->error = MAD_ERROR_BADCRC;
return -1;
}
@ -442,39 +442,39 @@ int mad_layer_II(struct mad_stream *stream, struct mad_frame *frame)
for (sb = 0; sb < sblimit; ++sb) {
for (ch = 0; ch < nch; ++ch) {
if (allocation[ch][sb]) {
scalefactor[ch][sb][0] = mad_bit_read(&stream->ptr, 6);
scalefactor[ch][sb][0] = mad_bit_read(&stream->ptr, 6);
switch (scfsi[ch][sb]) {
case 2:
scalefactor[ch][sb][2] =
scalefactor[ch][sb][1] =
scalefactor[ch][sb][0];
break;
switch (scfsi[ch][sb]) {
case 2:
scalefactor[ch][sb][2] =
scalefactor[ch][sb][1] =
scalefactor[ch][sb][0];
break;
case 0:
scalefactor[ch][sb][1] = mad_bit_read(&stream->ptr, 6);
/* fall through */
case 0:
scalefactor[ch][sb][1] = mad_bit_read(&stream->ptr, 6);
/* fall through */
case 1:
case 3:
scalefactor[ch][sb][2] = mad_bit_read(&stream->ptr, 6);
}
case 1:
case 3:
scalefactor[ch][sb][2] = mad_bit_read(&stream->ptr, 6);
}
if (scfsi[ch][sb] & 1)
scalefactor[ch][sb][1] = scalefactor[ch][sb][scfsi[ch][sb] - 1];
if (scfsi[ch][sb] & 1)
scalefactor[ch][sb][1] = scalefactor[ch][sb][scfsi[ch][sb] - 1];
# if defined(OPT_STRICT)
/*
* Scalefactor index 63 does not appear in Table B.1 of
* ISO/IEC 11172-3. Nonetheless, other implementations accept it,
* so we only reject it if OPT_STRICT is defined.
*/
if (scalefactor[ch][sb][0] == 63 ||
scalefactor[ch][sb][1] == 63 ||
scalefactor[ch][sb][2] == 63) {
stream->error = MAD_ERROR_BADSCALEFACTOR;
return -1;
}
/*
* Scalefactor index 63 does not appear in Table B.1 of
* ISO/IEC 11172-3. Nonetheless, other implementations accept it,
* so we only reject it if OPT_STRICT is defined.
*/
if (scalefactor[ch][sb][0] == 63 ||
scalefactor[ch][sb][1] == 63 ||
scalefactor[ch][sb][2] == 63) {
stream->error = MAD_ERROR_BADSCALEFACTOR;
return -1;
}
# endif
}
}
@ -485,50 +485,50 @@ int mad_layer_II(struct mad_stream *stream, struct mad_frame *frame)
for (gr = 0; gr < 12; ++gr) {
for (sb = 0; sb < bound; ++sb) {
for (ch = 0; ch < nch; ++ch) {
if ((index = allocation[ch][sb])) {
if ((index = allocation[ch][sb])) {
int off = bitalloc_table[offsets[sb]].offset;
index = offset_table[off][index - 1];
index = offset_table[off][index - 1];
II_samples(&stream->ptr, &qc_table[index], samples);
II_samples(&stream->ptr, &qc_table[index], samples);
for (s = 0; s < 3; ++s) {
(*frame->sbsample)[ch][3 * gr + s][sb] =
mad_f_mul(samples[s], sf_table[scalefactor[ch][sb][gr / 4]]);
}
}
else {
for (s = 0; s < 3; ++s)
(*frame->sbsample)[ch][3 * gr + s][sb] = 0;
}
for (s = 0; s < 3; ++s) {
(*frame->sbsample)[ch][3 * gr + s][sb] =
mad_f_mul(samples[s], sf_table[scalefactor[ch][sb][gr / 4]]);
}
}
else {
for (s = 0; s < 3; ++s)
(*frame->sbsample)[ch][3 * gr + s][sb] = 0;
}
}
}
for (sb = bound; sb < sblimit; ++sb) {
if ((index = allocation[0][sb])) {
int off = bitalloc_table[offsets[sb]].offset;
index = offset_table[off][index - 1];
index = offset_table[off][index - 1];
II_samples(&stream->ptr, &qc_table[index], samples);
II_samples(&stream->ptr, &qc_table[index], samples);
for (ch = 0; ch < nch; ++ch) {
for (s = 0; s < 3; ++s) {
(*frame->sbsample)[ch][3 * gr + s][sb] =
mad_f_mul(samples[s], sf_table[scalefactor[ch][sb][gr / 4]]);
}
}
for (ch = 0; ch < nch; ++ch) {
for (s = 0; s < 3; ++s) {
(*frame->sbsample)[ch][3 * gr + s][sb] =
mad_f_mul(samples[s], sf_table[scalefactor[ch][sb][gr / 4]]);
}
}
}
else {
for (ch = 0; ch < nch; ++ch) {
for (s = 0; s < 3; ++s)
(*frame->sbsample)[ch][3 * gr + s][sb] = 0;
}
for (ch = 0; ch < nch; ++ch) {
for (s = 0; s < 3; ++s)
(*frame->sbsample)[ch][3 * gr + s][sb] = 0;
}
}
}
for (ch = 0; ch < nch; ++ch) {
for (s = 0; s < 3; ++s) {
for (sb = sblimit; sb < 32; ++sb)
(*frame->sbsample)[ch][3 * gr + s][sb] = 0;
for (sb = sblimit; sb < 32; ++sb)
(*frame->sbsample)[ch][3 * gr + s][sb] = 0;
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -27,28 +27,28 @@ extern "C" {
# endif
# define FPM_DEFAULT
/* Id: version.h,v 1.26 2004/01/23 09:41:33 rob Exp */
# ifndef LIBMAD_VERSION_H
# define LIBMAD_VERSION_H
# define MAD_VERSION_MAJOR 0
# define MAD_VERSION_MINOR 15
# define MAD_VERSION_PATCH 1
# define MAD_VERSION_EXTRA " (beta)"
# define MAD_VERSION_MAJOR 0
# define MAD_VERSION_MINOR 15
# define MAD_VERSION_PATCH 1
# define MAD_VERSION_EXTRA " (beta)"
# define MAD_VERSION_STRINGIZE(str) #str
# define MAD_VERSION_STRING(num) MAD_VERSION_STRINGIZE(num)
# define MAD_VERSION_STRINGIZE(str) #str
# define MAD_VERSION_STRING(num) MAD_VERSION_STRINGIZE(num)
# define MAD_VERSION MAD_VERSION_STRING(MAD_VERSION_MAJOR) "." \
MAD_VERSION_STRING(MAD_VERSION_MINOR) "." \
MAD_VERSION_STRING(MAD_VERSION_PATCH) \
MAD_VERSION_EXTRA
# define MAD_VERSION MAD_VERSION_STRING(MAD_VERSION_MAJOR) "." \
MAD_VERSION_STRING(MAD_VERSION_MINOR) "." \
MAD_VERSION_STRING(MAD_VERSION_PATCH) \
MAD_VERSION_EXTRA
# define MAD_PUBLISHYEAR "2000-2004"
# define MAD_AUTHOR "Underbit Technologies, Inc."
# define MAD_EMAIL "info@underbit.com"
# define MAD_PUBLISHYEAR "2000-2004"
# define MAD_AUTHOR "Underbit Technologies, Inc."
# define MAD_EMAIL "info@underbit.com"
extern char const mad_version[];
extern char const mad_copyright[];
@ -102,50 +102,50 @@ typedef mad_fixed_t mad_sample_t;
* supported, and must be done with care.
*/
# define MAD_F_FRACBITS 28
# define MAD_F_FRACBITS 28
# if MAD_F_FRACBITS == 28
# define MAD_F(x) ((mad_fixed_t) (x##L))
# define MAD_F(x) ((mad_fixed_t) (x##L))
# else
# if MAD_F_FRACBITS < 28
# warning "MAD_F_FRACBITS < 28"
# define MAD_F(x) ((mad_fixed_t) \
(((x##L) + \
(1L << (28 - MAD_F_FRACBITS - 1))) >> \
(28 - MAD_F_FRACBITS)))
# define MAD_F(x) ((mad_fixed_t) \
(((x##L) + \
(1L << (28 - MAD_F_FRACBITS - 1))) >> \
(28 - MAD_F_FRACBITS)))
# elif MAD_F_FRACBITS > 28
# error "MAD_F_FRACBITS > 28 not currently supported"
# define MAD_F(x) ((mad_fixed_t) \
((x##L) << (MAD_F_FRACBITS - 28)))
# define MAD_F(x) ((mad_fixed_t) \
((x##L) << (MAD_F_FRACBITS - 28)))
# endif
# endif
# define MAD_F_MIN ((mad_fixed_t) -0x80000000L)
# define MAD_F_MAX ((mad_fixed_t) +0x7fffffffL)
# define MAD_F_MIN ((mad_fixed_t) -0x80000000L)
# define MAD_F_MAX ((mad_fixed_t) +0x7fffffffL)
# define MAD_F_ONE MAD_F(0x10000000)
# define MAD_F_ONE MAD_F(0x10000000)
# define mad_f_tofixed(x) ((mad_fixed_t) \
((x) * (double) (1L << MAD_F_FRACBITS) + 0.5))
# define mad_f_todouble(x) ((double) \
((x) / (double) (1L << MAD_F_FRACBITS)))
# define mad_f_tofixed(x) ((mad_fixed_t) \
((x) * (double) (1L << MAD_F_FRACBITS) + 0.5))
# define mad_f_todouble(x) ((double) \
((x) / (double) (1L << MAD_F_FRACBITS)))
# define mad_f_intpart(x) ((x) >> MAD_F_FRACBITS)
# define mad_f_fracpart(x) ((x) & ((1L << MAD_F_FRACBITS) - 1))
/* (x should be positive) */
# define mad_f_intpart(x) ((x) >> MAD_F_FRACBITS)
# define mad_f_fracpart(x) ((x) & ((1L << MAD_F_FRACBITS) - 1))
/* (x should be positive) */
# define mad_f_fromint(x) ((x) << MAD_F_FRACBITS)
# define mad_f_fromint(x) ((x) << MAD_F_FRACBITS)
# define mad_f_add(x, y) ((x) + (y))
# define mad_f_sub(x, y) ((x) - (y))
# define mad_f_add(x, y) ((x) + (y))
# define mad_f_sub(x, y) ((x) - (y))
# if defined(FPM_FLOAT)
# error "FPM_FLOAT not yet supported"
# undef MAD_F
# define MAD_F(x) mad_f_todouble(x)
# define MAD_F(x) mad_f_todouble(x)
# define mad_f_mul(x, y) ((x) * (y))
# define mad_f_mul(x, y) ((x) * (y))
# define mad_f_scale64
# undef ASO_ZEROCHECK
@ -192,7 +192,7 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
}
# pragma warning(pop)
# define mad_f_mul mad_f_mul_inline
# define mad_f_mul mad_f_mul_inline
# define mad_f_scale64
# else
/*
@ -201,9 +201,9 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
*/
# define MAD_F_MLX(hi, lo, x, y) \
asm ("imull %3" \
: "=a" (lo), "=d" (hi) \
: "%a" (x), "rm" (y) \
: "cc")
: "=a" (lo), "=d" (hi) \
: "%a" (x), "rm" (y) \
: "cc")
# if defined(OPT_ACCURACY)
/*
@ -214,10 +214,10 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
mad_fixed64lo_t __lo; \
MAD_F_MLX(__hi, __lo, (x), (y)); \
asm ("addl %2,%0\n\t" \
"adcl %3,%1" \
: "=rm" (lo), "=rm" (hi) \
: "r" (__lo), "r" (__hi), "0" (lo), "1" (hi) \
: "cc"); \
"adcl %3,%1" \
: "=rm" (lo), "=rm" (hi) \
: "r" (__lo), "r" (__hi), "0" (lo), "1" (hi) \
: "cc"); \
})
# endif /* OPT_ACCURACY */
@ -230,15 +230,15 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
mad_fixed64lo_t __lo_; \
mad_fixed_t __result; \
asm ("addl %4,%2\n\t" \
"adcl %5,%3" \
: "=rm" (__lo_), "=rm" (__hi_) \
: "0" (lo), "1" (hi), \
"ir" (1L << (MAD_F_SCALEBITS - 1)), "ir" (0) \
: "cc"); \
"adcl %5,%3" \
: "=rm" (__lo_), "=rm" (__hi_) \
: "0" (lo), "1" (hi), \
"ir" (1L << (MAD_F_SCALEBITS - 1)), "ir" (0) \
: "cc"); \
asm ("shrdl %3,%2,%1" \
: "=rm" (__result) \
: "0" (__lo_), "r" (__hi_), "I" (MAD_F_SCALEBITS) \
: "cc"); \
: "=rm" (__result) \
: "0" (__lo_), "r" (__hi_), "I" (MAD_F_SCALEBITS) \
: "cc"); \
__result; \
})
# elif defined(OPT_INTEL)
@ -248,21 +248,21 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
# define mad_f_scale64(hi, lo) \
({ mad_fixed_t __result; \
asm ("shrl %3,%1\n\t" \
"shll %4,%2\n\t" \
"orl %2,%1" \
: "=rm" (__result) \
: "0" (lo), "r" (hi), \
"I" (MAD_F_SCALEBITS), "I" (32 - MAD_F_SCALEBITS) \
: "cc"); \
"shll %4,%2\n\t" \
"orl %2,%1" \
: "=rm" (__result) \
: "0" (lo), "r" (hi), \
"I" (MAD_F_SCALEBITS), "I" (32 - MAD_F_SCALEBITS) \
: "cc"); \
__result; \
})
# else
# define mad_f_scale64(hi, lo) \
({ mad_fixed_t __result; \
asm ("shrdl %3,%2,%1" \
: "=rm" (__result) \
: "0" (lo), "r" (hi), "I" (MAD_F_SCALEBITS) \
: "cc"); \
: "=rm" (__result) \
: "0" (lo), "r" (hi), "I" (MAD_F_SCALEBITS) \
: "cc"); \
__result; \
})
# endif /* OPT_ACCURACY */
@ -287,42 +287,42 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
({ mad_fixed64hi_t __hi; \
mad_fixed64lo_t __lo; \
mad_fixed_t __result; \
asm ("smull %0, %1, %3, %4\n\t" \
"movs %0, %0, lsr %5\n\t" \
"adc %2, %0, %1, lsl %6" \
: "=&r" (__lo), "=&r" (__hi), "=r" (__result) \
: "%r" (x), "r" (y), \
"M" (MAD_F_SCALEBITS), "M" (32 - MAD_F_SCALEBITS) \
: "cc"); \
asm ("smull %0, %1, %3, %4\n\t" \
"movs %0, %0, lsr %5\n\t" \
"adc %2, %0, %1, lsl %6" \
: "=&r" (__lo), "=&r" (__hi), "=r" (__result) \
: "%r" (x), "r" (y), \
"M" (MAD_F_SCALEBITS), "M" (32 - MAD_F_SCALEBITS) \
: "cc"); \
__result; \
})
# endif
# define MAD_F_MLX(hi, lo, x, y) \
asm ("smull %0, %1, %2, %3" \
: "=&r" (lo), "=&r" (hi) \
: "%r" (x), "r" (y))
asm ("smull %0, %1, %2, %3" \
: "=&r" (lo), "=&r" (hi) \
: "%r" (x), "r" (y))
# define MAD_F_MLA(hi, lo, x, y) \
asm ("smlal %0, %1, %2, %3" \
: "+r" (lo), "+r" (hi) \
: "%r" (x), "r" (y))
asm ("smlal %0, %1, %2, %3" \
: "+r" (lo), "+r" (hi) \
: "%r" (x), "r" (y))
# define MAD_F_MLN(hi, lo) \
asm ("rsbs %0, %2, #0\n\t" \
"rsc %1, %3, #0" \
: "=r" (lo), "=r" (hi) \
: "0" (lo), "1" (hi) \
: "cc")
asm ("rsbs %0, %2, #0\n\t" \
"rsc %1, %3, #0" \
: "=r" (lo), "=r" (hi) \
: "0" (lo), "1" (hi) \
: "cc")
# define mad_f_scale64(hi, lo) \
({ mad_fixed_t __result; \
asm ("movs %0, %1, lsr %3\n\t" \
"adc %0, %0, %2, lsl %4" \
: "=&r" (__result) \
: "r" (lo), "r" (hi), \
"M" (MAD_F_SCALEBITS), "M" (32 - MAD_F_SCALEBITS) \
: "cc"); \
asm ("movs %0, %1, lsr %3\n\t" \
"adc %0, %0, %2, lsl %4" \
: "=&r" (__result) \
: "r" (lo), "r" (hi), \
"M" (MAD_F_SCALEBITS), "M" (32 - MAD_F_SCALEBITS) \
: "cc"); \
__result; \
})
@ -337,28 +337,28 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
* significant bit depends on OPT_ACCURACY via mad_f_scale64().
*/
# define MAD_F_MLX(hi, lo, x, y) \
asm ("mult %2,%3" \
: "=l" (lo), "=h" (hi) \
: "%r" (x), "r" (y))
asm ("mult %2,%3" \
: "=l" (lo), "=h" (hi) \
: "%r" (x), "r" (y))
# if defined(HAVE_MADD_ASM)
# define MAD_F_MLA(hi, lo, x, y) \
asm ("madd %2,%3" \
: "+l" (lo), "+h" (hi) \
: "%r" (x), "r" (y))
asm ("madd %2,%3" \
: "+l" (lo), "+h" (hi) \
: "%r" (x), "r" (y))
# elif defined(HAVE_MADD16_ASM)
/*
* This loses significant accuracy due to the 16-bit integer limit in the
* multiply/accumulate instruction.
*/
# define MAD_F_ML0(hi, lo, x, y) \
asm ("mult %2,%3" \
: "=l" (lo), "=h" (hi) \
: "%r" ((x) >> 12), "r" ((y) >> 16))
asm ("mult %2,%3" \
: "=l" (lo), "=h" (hi) \
: "%r" ((x) >> 12), "r" ((y) >> 16))
# define MAD_F_MLA(hi, lo, x, y) \
asm ("madd16 %2,%3" \
: "+l" (lo), "+h" (hi) \
: "%r" ((x) >> 12), "r" ((y) >> 16))
asm ("madd16 %2,%3" \
: "+l" (lo), "+h" (hi) \
: "%r" ((x) >> 12), "r" ((y) >> 16))
# define MAD_F_MLZ(hi, lo) ((mad_fixed_t) (lo))
# endif
@ -378,9 +378,9 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
*/
# define MAD_F_MLX(hi, lo, x, y) \
asm ("smul %2, %3, %0\n\t" \
"rd %%y, %1" \
: "=r" (lo), "=r" (hi) \
: "%r" (x), "rI" (y))
"rd %%y, %1" \
: "=r" (lo), "=r" (hi) \
: "%r" (x), "rI" (y))
/* --- PowerPC ------------------------------------------------------------- */
@ -393,11 +393,11 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
# define MAD_F_MLX(hi, lo, x, y) \
do { \
asm ("mullw %0,%1,%2" \
: "=r" (lo) \
: "%r" (x), "r" (y)); \
: "=r" (lo) \
: "%r" (x), "r" (y)); \
asm ("mulhw %0,%1,%2" \
: "=r" (hi) \
: "%r" (x), "r" (y)); \
: "=r" (hi) \
: "%r" (x), "r" (y)); \
} \
while (0)
@ -410,11 +410,11 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
mad_fixed64lo_t __lo; \
MAD_F_MLX(__hi, __lo, (x), (y)); \
asm ("addc %0,%2,%3\n\t" \
"adde %1,%4,%5" \
: "=r" (lo), "=r" (hi) \
: "%r" (lo), "r" (__lo), \
"%r" (hi), "r" (__hi) \
: "xer"); \
"adde %1,%4,%5" \
: "=r" (lo), "=r" (hi) \
: "%r" (lo), "r" (__lo), \
"%r" (hi), "r" (__hi) \
: "xer"); \
})
# endif
@ -425,28 +425,28 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
# define mad_f_scale64(hi, lo) \
({ mad_fixed_t __result, __round; \
asm ("rotrwi %0,%1,%2" \
: "=r" (__result) \
: "r" (lo), "i" (MAD_F_SCALEBITS)); \
: "=r" (__result) \
: "r" (lo), "i" (MAD_F_SCALEBITS)); \
asm ("extrwi %0,%1,1,0" \
: "=r" (__round) \
: "r" (__result)); \
: "=r" (__round) \
: "r" (__result)); \
asm ("insrwi %0,%1,%2,0" \
: "+r" (__result) \
: "r" (hi), "i" (MAD_F_SCALEBITS)); \
: "+r" (__result) \
: "r" (hi), "i" (MAD_F_SCALEBITS)); \
asm ("add %0,%1,%2" \
: "=r" (__result) \
: "%r" (__result), "r" (__round)); \
: "=r" (__result) \
: "%r" (__result), "r" (__round)); \
__result; \
})
# else
# define mad_f_scale64(hi, lo) \
({ mad_fixed_t __result; \
asm ("rotrwi %0,%1,%2" \
: "=r" (__result) \
: "r" (lo), "i" (MAD_F_SCALEBITS)); \
: "=r" (__result) \
: "r" (lo), "i" (MAD_F_SCALEBITS)); \
asm ("insrwi %0,%1,%2,0" \
: "+r" (__result) \
: "r" (hi), "i" (MAD_F_SCALEBITS)); \
: "+r" (__result) \
: "r" (hi), "i" (MAD_F_SCALEBITS)); \
__result; \
})
# endif
@ -467,10 +467,10 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
* Pre-rounding is required to stay within the limits of compliance.
*/
# if defined(OPT_SPEED)
# define mad_f_mul(x, y) (((x) >> 12) * ((y) >> 16))
# define mad_f_mul(x, y) (((x) >> 12) * ((y) >> 16))
# else
# define mad_f_mul(x, y) ((((x) + (1L << 11)) >> 12) * \
(((y) + (1L << 15)) >> 16))
# define mad_f_mul(x, y) ((((x) + (1L << 11)) >> 12) * \
(((y) + (1L << 15)) >> 16))
# endif
/* ------------------------------------------------------------------------- */
@ -491,22 +491,22 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
# endif
# if !defined(MAD_F_MLA)
# define MAD_F_ML0(hi, lo, x, y) ((lo) = mad_f_mul((x), (y)))
# define MAD_F_MLA(hi, lo, x, y) ((lo) += mad_f_mul((x), (y)))
# define MAD_F_MLN(hi, lo) ((lo) = -(lo))
# define MAD_F_MLZ(hi, lo) ((void) (hi), (mad_fixed_t) (lo))
# define MAD_F_ML0(hi, lo, x, y) ((lo) = mad_f_mul((x), (y)))
# define MAD_F_MLA(hi, lo, x, y) ((lo) += mad_f_mul((x), (y)))
# define MAD_F_MLN(hi, lo) ((lo) = -(lo))
# define MAD_F_MLZ(hi, lo) ((void) (hi), (mad_fixed_t) (lo))
# endif
# if !defined(MAD_F_ML0)
# define MAD_F_ML0(hi, lo, x, y) MAD_F_MLX((hi), (lo), (x), (y))
# define MAD_F_ML0(hi, lo, x, y) MAD_F_MLX((hi), (lo), (x), (y))
# endif
# if !defined(MAD_F_MLN)
# define MAD_F_MLN(hi, lo) ((hi) = ((lo) = -(lo)) ? ~(hi) : -(hi))
# define MAD_F_MLN(hi, lo) ((hi) = ((lo) = -(lo)) ? ~(hi) : -(hi))
# endif
# if !defined(MAD_F_MLZ)
# define MAD_F_MLZ(hi, lo) mad_f_scale64((hi), (lo))
# define MAD_F_MLZ(hi, lo) mad_f_scale64((hi), (lo))
# endif
# if !defined(mad_f_scale64)
@ -514,7 +514,7 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
# define mad_f_scale64(hi, lo) \
((((mad_fixed_t) \
(((hi) << (32 - (MAD_F_SCALEBITS - 1))) | \
((lo) >> (MAD_F_SCALEBITS - 1)))) + 1) >> 1)
((lo) >> (MAD_F_SCALEBITS - 1)))) + 1) >> 1)
# else
# define mad_f_scale64(hi, lo) \
((mad_fixed_t) \
@ -544,10 +544,10 @@ struct mad_bitptr {
void mad_bit_init(struct mad_bitptr *, unsigned char const *);
# define mad_bit_finish(bitptr) /* nothing */
# define mad_bit_finish(bitptr) /* nothing */
unsigned int mad_bit_length(struct mad_bitptr const *,
struct mad_bitptr const *);
struct mad_bitptr const *);
# define mad_bit_bitsleft(bitptr) ((bitptr)->left)
unsigned char const *mad_bit_nextbyte(struct mad_bitptr const *);
@ -566,67 +566,67 @@ unsigned short mad_bit_crc(struct mad_bitptr, unsigned int, unsigned short);
# define LIBMAD_TIMER_H
typedef struct {
signed long seconds; /* whole seconds */
unsigned long fraction; /* 1/MAD_TIMER_RESOLUTION seconds */
signed long seconds; /* whole seconds */
unsigned long fraction; /* 1/MAD_TIMER_RESOLUTION seconds */
} mad_timer_t;
extern mad_timer_t const mad_timer_zero;
# define MAD_TIMER_RESOLUTION 352800000UL
# define MAD_TIMER_RESOLUTION 352800000UL
enum mad_units {
MAD_UNITS_HOURS = -2,
MAD_UNITS_MINUTES = -1,
MAD_UNITS_SECONDS = 0,
MAD_UNITS_HOURS = -2,
MAD_UNITS_MINUTES = -1,
MAD_UNITS_SECONDS = 0,
/* metric units */
MAD_UNITS_DECISECONDS = 10,
MAD_UNITS_DECISECONDS = 10,
MAD_UNITS_CENTISECONDS = 100,
MAD_UNITS_MILLISECONDS = 1000,
/* audio sample units */
MAD_UNITS_8000_HZ = 8000,
MAD_UNITS_11025_HZ = 11025,
MAD_UNITS_12000_HZ = 12000,
MAD_UNITS_8000_HZ = 8000,
MAD_UNITS_11025_HZ = 11025,
MAD_UNITS_12000_HZ = 12000,
MAD_UNITS_16000_HZ = 16000,
MAD_UNITS_22050_HZ = 22050,
MAD_UNITS_24000_HZ = 24000,
MAD_UNITS_16000_HZ = 16000,
MAD_UNITS_22050_HZ = 22050,
MAD_UNITS_24000_HZ = 24000,
MAD_UNITS_32000_HZ = 32000,
MAD_UNITS_44100_HZ = 44100,
MAD_UNITS_48000_HZ = 48000,
MAD_UNITS_32000_HZ = 32000,
MAD_UNITS_44100_HZ = 44100,
MAD_UNITS_48000_HZ = 48000,
/* video frame/field units */
MAD_UNITS_24_FPS = 24,
MAD_UNITS_25_FPS = 25,
MAD_UNITS_30_FPS = 30,
MAD_UNITS_48_FPS = 48,
MAD_UNITS_50_FPS = 50,
MAD_UNITS_60_FPS = 60,
MAD_UNITS_24_FPS = 24,
MAD_UNITS_25_FPS = 25,
MAD_UNITS_30_FPS = 30,
MAD_UNITS_48_FPS = 48,
MAD_UNITS_50_FPS = 50,
MAD_UNITS_60_FPS = 60,
/* CD audio frames */
MAD_UNITS_75_FPS = 75,
MAD_UNITS_75_FPS = 75,
/* video drop-frame units */
MAD_UNITS_23_976_FPS = -24,
MAD_UNITS_24_975_FPS = -25,
MAD_UNITS_29_97_FPS = -30,
MAD_UNITS_47_952_FPS = -48,
MAD_UNITS_49_95_FPS = -50,
MAD_UNITS_59_94_FPS = -60
MAD_UNITS_23_976_FPS = -24,
MAD_UNITS_24_975_FPS = -25,
MAD_UNITS_29_97_FPS = -30,
MAD_UNITS_47_952_FPS = -48,
MAD_UNITS_49_95_FPS = -50,
MAD_UNITS_59_94_FPS = -60
};
# define mad_timer_reset(timer) ((void) (*(timer) = mad_timer_zero))
# define mad_timer_reset(timer) ((void) (*(timer) = mad_timer_zero))
int mad_timer_compare(mad_timer_t, mad_timer_t);
# define mad_timer_sign(timer) mad_timer_compare((timer), mad_timer_zero)
# define mad_timer_sign(timer) mad_timer_compare((timer), mad_timer_zero)
void mad_timer_negate(mad_timer_t *);
mad_timer_t mad_timer_abs(mad_timer_t);
@ -638,7 +638,7 @@ void mad_timer_multiply(mad_timer_t *, signed long);
signed long mad_timer_count(mad_timer_t, enum mad_units);
unsigned long mad_timer_fraction(mad_timer_t, unsigned long);
void mad_timer_string(mad_timer_t, char *, char const *,
enum mad_units, enum mad_units, unsigned long);
enum mad_units, enum mad_units, unsigned long);
# endif
@ -648,70 +648,70 @@ void mad_timer_string(mad_timer_t, char *, char const *,
# define LIBMAD_STREAM_H
# define MAD_BUFFER_GUARD 8
# define MAD_BUFFER_MDLEN (511 + 2048 + MAD_BUFFER_GUARD)
# define MAD_BUFFER_GUARD 8
# define MAD_BUFFER_MDLEN (511 + 2048 + MAD_BUFFER_GUARD)
enum mad_error {
MAD_ERROR_NONE = 0x0000, /* no error */
MAD_ERROR_NONE = 0x0000, /* no error */
MAD_ERROR_BUFLEN = 0x0001, /* input buffer too small (or EOF) */
MAD_ERROR_BUFPTR = 0x0002, /* invalid (null) buffer pointer */
MAD_ERROR_BUFLEN = 0x0001, /* input buffer too small (or EOF) */
MAD_ERROR_BUFPTR = 0x0002, /* invalid (null) buffer pointer */
MAD_ERROR_NOMEM = 0x0031, /* not enough memory */
MAD_ERROR_NOMEM = 0x0031, /* not enough memory */
MAD_ERROR_LOSTSYNC = 0x0101, /* lost synchronization */
MAD_ERROR_BADLAYER = 0x0102, /* reserved header layer value */
MAD_ERROR_BADBITRATE = 0x0103, /* forbidden bitrate value */
MAD_ERROR_BADSAMPLERATE = 0x0104, /* reserved sample frequency value */
MAD_ERROR_BADEMPHASIS = 0x0105, /* reserved emphasis value */
MAD_ERROR_LOSTSYNC = 0x0101, /* lost synchronization */
MAD_ERROR_BADLAYER = 0x0102, /* reserved header layer value */
MAD_ERROR_BADBITRATE = 0x0103, /* forbidden bitrate value */
MAD_ERROR_BADSAMPLERATE = 0x0104, /* reserved sample frequency value */
MAD_ERROR_BADEMPHASIS = 0x0105, /* reserved emphasis value */
MAD_ERROR_BADCRC = 0x0201, /* CRC check failed */
MAD_ERROR_BADBITALLOC = 0x0211, /* forbidden bit allocation value */
MAD_ERROR_BADSCALEFACTOR = 0x0221, /* bad scalefactor index */
MAD_ERROR_BADMODE = 0x0222, /* bad bitrate/mode combination */
MAD_ERROR_BADFRAMELEN = 0x0231, /* bad frame length */
MAD_ERROR_BADBIGVALUES = 0x0232, /* bad big_values count */
MAD_ERROR_BADBLOCKTYPE = 0x0233, /* reserved block_type */
MAD_ERROR_BADSCFSI = 0x0234, /* bad scalefactor selection info */
MAD_ERROR_BADDATAPTR = 0x0235, /* bad main_data_begin pointer */
MAD_ERROR_BADPART3LEN = 0x0236, /* bad audio data length */
MAD_ERROR_BADHUFFTABLE = 0x0237, /* bad Huffman table select */
MAD_ERROR_BADHUFFDATA = 0x0238, /* Huffman data overrun */
MAD_ERROR_BADSTEREO = 0x0239 /* incompatible block_type for JS */
MAD_ERROR_BADCRC = 0x0201, /* CRC check failed */
MAD_ERROR_BADBITALLOC = 0x0211, /* forbidden bit allocation value */
MAD_ERROR_BADSCALEFACTOR = 0x0221, /* bad scalefactor index */
MAD_ERROR_BADMODE = 0x0222, /* bad bitrate/mode combination */
MAD_ERROR_BADFRAMELEN = 0x0231, /* bad frame length */
MAD_ERROR_BADBIGVALUES = 0x0232, /* bad big_values count */
MAD_ERROR_BADBLOCKTYPE = 0x0233, /* reserved block_type */
MAD_ERROR_BADSCFSI = 0x0234, /* bad scalefactor selection info */
MAD_ERROR_BADDATAPTR = 0x0235, /* bad main_data_begin pointer */
MAD_ERROR_BADPART3LEN = 0x0236, /* bad audio data length */
MAD_ERROR_BADHUFFTABLE = 0x0237, /* bad Huffman table select */
MAD_ERROR_BADHUFFDATA = 0x0238, /* Huffman data overrun */
MAD_ERROR_BADSTEREO = 0x0239 /* incompatible block_type for JS */
};
# define MAD_RECOVERABLE(error) ((error) & 0xff00)
# define MAD_RECOVERABLE(error) ((error) & 0xff00)
struct mad_stream {
unsigned char const *buffer; /* input bitstream buffer */
unsigned char const *bufend; /* end of buffer */
unsigned long skiplen; /* bytes to skip before next frame */
unsigned char const *buffer; /* input bitstream buffer */
unsigned char const *bufend; /* end of buffer */
unsigned long skiplen; /* bytes to skip before next frame */
int sync; /* stream sync found */
unsigned long freerate; /* free bitrate (fixed) */
int sync; /* stream sync found */
unsigned long freerate; /* free bitrate (fixed) */
unsigned char const *this_frame; /* start of current frame */
unsigned char const *next_frame; /* start of next frame */
struct mad_bitptr ptr; /* current processing bit pointer */
unsigned char const *this_frame; /* start of current frame */
unsigned char const *next_frame; /* start of next frame */
struct mad_bitptr ptr; /* current processing bit pointer */
struct mad_bitptr anc_ptr; /* ancillary bits pointer */
unsigned int anc_bitlen; /* number of ancillary bits */
struct mad_bitptr anc_ptr; /* ancillary bits pointer */
unsigned int anc_bitlen; /* number of ancillary bits */
unsigned char (*main_data)[MAD_BUFFER_MDLEN];
/* Layer III main_data() */
unsigned int md_len; /* bytes in main_data */
/* Layer III main_data() */
unsigned int md_len; /* bytes in main_data */
int options; /* decoding options (see below) */
enum mad_error error; /* error code (see above) */
int options; /* decoding options (see below) */
enum mad_error error; /* error code (see above) */
};
enum {
MAD_OPTION_IGNORECRC = 0x0001, /* ignore CRC errors */
MAD_OPTION_HALFSAMPLERATE = 0x0002 /* generate PCM at 1/2 sample rate */
MAD_OPTION_IGNORECRC = 0x0001, /* ignore CRC errors */
MAD_OPTION_HALFSAMPLERATE = 0x0002 /* generate PCM at 1/2 sample rate */
# if 0 /* not yet implemented */
MAD_OPTION_LEFTCHANNEL = 0x0010, /* decode left channel only */
MAD_OPTION_RIGHTCHANNEL = 0x0020, /* decode right channel only */
MAD_OPTION_SINGLECHANNEL = 0x0030 /* combine channels */
MAD_OPTION_LEFTCHANNEL = 0x0010, /* decode left channel only */
MAD_OPTION_RIGHTCHANNEL = 0x0020, /* decode right channel only */
MAD_OPTION_SINGLECHANNEL = 0x0030 /* combine channels */
# endif
};
@ -722,7 +722,7 @@ void mad_stream_finish(struct mad_stream *);
((void) ((stream)->options = (opts)))
void mad_stream_buffer(struct mad_stream *,
unsigned char const *, unsigned long);
unsigned char const *, unsigned long);
void mad_stream_skip(struct mad_stream *, unsigned long);
int mad_stream_sync(struct mad_stream *);
@ -738,82 +738,82 @@ char const *mad_stream_errorstr(struct mad_stream const *);
enum mad_layer {
MAD_LAYER_I = 1, /* Layer I */
MAD_LAYER_II = 2, /* Layer II */
MAD_LAYER_III = 3 /* Layer III */
MAD_LAYER_I = 1, /* Layer I */
MAD_LAYER_II = 2, /* Layer II */
MAD_LAYER_III = 3 /* Layer III */
};
enum mad_mode {
MAD_MODE_SINGLE_CHANNEL = 0, /* single channel */
MAD_MODE_DUAL_CHANNEL = 1, /* dual channel */
MAD_MODE_JOINT_STEREO = 2, /* joint (MS/intensity) stereo */
MAD_MODE_STEREO = 3 /* normal LR stereo */
MAD_MODE_SINGLE_CHANNEL = 0, /* single channel */
MAD_MODE_DUAL_CHANNEL = 1, /* dual channel */
MAD_MODE_JOINT_STEREO = 2, /* joint (MS/intensity) stereo */
MAD_MODE_STEREO = 3 /* normal LR stereo */
};
enum mad_emphasis {
MAD_EMPHASIS_NONE = 0, /* no emphasis */
MAD_EMPHASIS_50_15_US = 1, /* 50/15 microseconds emphasis */
MAD_EMPHASIS_CCITT_J_17 = 3, /* CCITT J.17 emphasis */
MAD_EMPHASIS_RESERVED = 2 /* unknown emphasis */
MAD_EMPHASIS_NONE = 0, /* no emphasis */
MAD_EMPHASIS_50_15_US = 1, /* 50/15 microseconds emphasis */
MAD_EMPHASIS_CCITT_J_17 = 3, /* CCITT J.17 emphasis */
MAD_EMPHASIS_RESERVED = 2 /* unknown emphasis */
};
struct mad_header {
enum mad_layer layer; /* audio layer (1, 2, or 3) */
enum mad_mode mode; /* channel mode (see above) */
int mode_extension; /* additional mode info */
enum mad_emphasis emphasis; /* de-emphasis to use (see above) */
enum mad_layer layer; /* audio layer (1, 2, or 3) */
enum mad_mode mode; /* channel mode (see above) */
int mode_extension; /* additional mode info */
enum mad_emphasis emphasis; /* de-emphasis to use (see above) */
unsigned long bitrate; /* stream bitrate (bps) */
unsigned int samplerate; /* sampling frequency (Hz) */
unsigned long bitrate; /* stream bitrate (bps) */
unsigned int samplerate; /* sampling frequency (Hz) */
unsigned short crc_check; /* frame CRC accumulator */
unsigned short crc_target; /* final target CRC checksum */
unsigned short crc_check; /* frame CRC accumulator */
unsigned short crc_target; /* final target CRC checksum */
int flags; /* flags (see below) */
int private_bits; /* private bits (see below) */
int flags; /* flags (see below) */
int private_bits; /* private bits (see below) */
mad_timer_t duration; /* audio playing time of frame */
mad_timer_t duration; /* audio playing time of frame */
};
struct mad_frame {
struct mad_header header; /* MPEG audio header */
int options; /* decoding options (from stream) */
struct mad_header header; /* MPEG audio header */
int options; /* decoding options (from stream) */
mad_fixed_t (*sbsample)[2][36][32]; /* synthesis subband filter samples */
mad_fixed_t (*sbsample)[2][36][32]; /* synthesis subband filter samples */
mad_fixed_t (*sbsample_prev)[2][36][32]; /* synthesis subband filter samples
from previous frame only needed
when synthesis is on cop */
mad_fixed_t (*overlap)[2][32][18]; /* Layer III block overlap data */
mad_fixed_t (*overlap)[2][32][18]; /* Layer III block overlap data */
};
# define MAD_NCHANNELS(header) ((header)->mode ? 2 : 1)
# define MAD_NCHANNELS(header) ((header)->mode ? 2 : 1)
# define MAD_NSBSAMPLES(header) \
((header)->layer == MAD_LAYER_I ? 12 : \
(((header)->layer == MAD_LAYER_III && \
((header)->flags & MAD_FLAG_LSF_EXT)) ? 18 : 36))
enum {
MAD_FLAG_NPRIVATE_III = 0x0007, /* number of Layer III private bits */
MAD_FLAG_INCOMPLETE = 0x0008, /* header but not data is decoded */
MAD_FLAG_NPRIVATE_III = 0x0007, /* number of Layer III private bits */
MAD_FLAG_INCOMPLETE = 0x0008, /* header but not data is decoded */
MAD_FLAG_PROTECTION = 0x0010, /* frame has CRC protection */
MAD_FLAG_COPYRIGHT = 0x0020, /* frame is copyright */
MAD_FLAG_ORIGINAL = 0x0040, /* frame is original (else copy) */
MAD_FLAG_PADDING = 0x0080, /* frame has additional slot */
MAD_FLAG_PROTECTION = 0x0010, /* frame has CRC protection */
MAD_FLAG_COPYRIGHT = 0x0020, /* frame is copyright */
MAD_FLAG_ORIGINAL = 0x0040, /* frame is original (else copy) */
MAD_FLAG_PADDING = 0x0080, /* frame has additional slot */
MAD_FLAG_I_STEREO = 0x0100, /* uses intensity joint stereo */
MAD_FLAG_MS_STEREO = 0x0200, /* uses middle/side joint stereo */
MAD_FLAG_FREEFORMAT = 0x0400, /* uses free format bitrate */
MAD_FLAG_I_STEREO = 0x0100, /* uses intensity joint stereo */
MAD_FLAG_MS_STEREO = 0x0200, /* uses middle/side joint stereo */
MAD_FLAG_FREEFORMAT = 0x0400, /* uses free format bitrate */
MAD_FLAG_LSF_EXT = 0x1000, /* lower sampling freq. extension */
MAD_FLAG_MC_EXT = 0x2000, /* multichannel audio extension */
MAD_FLAG_MPEG_2_5_EXT = 0x4000 /* MPEG 2.5 (unofficial) extension */
MAD_FLAG_LSF_EXT = 0x1000, /* lower sampling freq. extension */
MAD_FLAG_MC_EXT = 0x2000, /* multichannel audio extension */
MAD_FLAG_MPEG_2_5_EXT = 0x4000 /* MPEG 2.5 (unofficial) extension */
};
enum {
MAD_PRIVATE_HEADER = 0x0100, /* header private bit */
MAD_PRIVATE_III = 0x001f /* Layer III private bits (up to 5) */
MAD_PRIVATE_HEADER = 0x0100, /* header private bit */
MAD_PRIVATE_III = 0x001f /* Layer III private bits (up to 5) */
};
void mad_header_init(struct mad_header *);
@ -838,19 +838,19 @@ void mad_frame_mute(struct mad_frame *);
struct mad_pcm {
unsigned int samplerate; /* sampling frequency (Hz) */
unsigned short channels; /* number of channels */
unsigned short length; /* number of samples per channel */
mad_fixed_t samples[2][1152]; /* PCM output samples [ch][sample] */
unsigned int samplerate; /* sampling frequency (Hz) */
unsigned short channels; /* number of channels */
unsigned short length; /* number of samples per channel */
mad_fixed_t samples[2][1152]; /* PCM output samples [ch][sample] */
};
struct mad_synth {
mad_fixed_t filter[2][2][2][16][8]; /* polyphase filterbank outputs */
/* [ch][eo][peo][s][v] */
mad_fixed_t filter[2][2][2][16][8]; /* polyphase filterbank outputs */
/* [ch][eo][peo][s][v] */
unsigned int phase; /* current processing phase */
unsigned int phase; /* current processing phase */
struct mad_pcm pcm; /* PCM output */
struct mad_pcm pcm; /* PCM output */
};
/* single channel PCM selector */
@ -892,10 +892,10 @@ enum mad_decoder_mode {
};
enum mad_flow {
MAD_FLOW_CONTINUE = 0x0000, /* continue normally */
MAD_FLOW_STOP = 0x0010, /* stop decoding normally */
MAD_FLOW_BREAK = 0x0011, /* stop decoding and signal an error */
MAD_FLOW_IGNORE = 0x0020 /* ignore the current frame */
MAD_FLOW_CONTINUE = 0x0000, /* continue normally */
MAD_FLOW_STOP = 0x0010, /* stop decoding normally */
MAD_FLOW_BREAK = 0x0011, /* stop decoding and signal an error */
MAD_FLOW_IGNORE = 0x0020 /* ignore the current frame */
};
struct mad_decoder {
@ -920,26 +920,26 @@ struct mad_decoder {
enum mad_flow (*input_func)(void *, struct mad_stream *);
enum mad_flow (*header_func)(void *, struct mad_header const *);
enum mad_flow (*filter_func)(void *,
struct mad_stream const *, struct mad_frame *);
struct mad_stream const *, struct mad_frame *);
enum mad_flow (*output_func)(void *,
struct mad_header const *, struct mad_pcm *);
struct mad_header const *, struct mad_pcm *);
enum mad_flow (*error_func)(void *, struct mad_stream *, struct mad_frame *);
enum mad_flow (*message_func)(void *, void *, unsigned int *);
};
void mad_decoder_init(struct mad_decoder *, void *,
enum mad_flow (*)(void *, struct mad_stream *),
enum mad_flow (*)(void *, struct mad_header const *),
enum mad_flow (*)(void *,
struct mad_stream const *,
struct mad_frame *),
enum mad_flow (*)(void *,
struct mad_header const *,
struct mad_pcm *),
enum mad_flow (*)(void *,
struct mad_stream *,
struct mad_frame *),
enum mad_flow (*)(void *, void *, unsigned int *));
enum mad_flow (*)(void *, struct mad_stream *),
enum mad_flow (*)(void *, struct mad_header const *),
enum mad_flow (*)(void *,
struct mad_stream const *,
struct mad_frame *),
enum mad_flow (*)(void *,
struct mad_header const *,
struct mad_pcm *),
enum mad_flow (*)(void *,
struct mad_stream *,
struct mad_frame *),
enum mad_flow (*)(void *, void *, unsigned int *));
int mad_decoder_finish(struct mad_decoder *);
# define mad_decoder_options(decoder, opts) \

View file

@ -82,7 +82,7 @@ struct buffer {
static
enum mad_flow input(void *data,
struct mad_stream *stream)
struct mad_stream *stream)
{
struct buffer *buffer = data;
@ -128,8 +128,8 @@ signed int scale(mad_fixed_t sample)
static
enum mad_flow output(void *data,
struct mad_header const *header,
struct mad_pcm *pcm)
struct mad_header const *header,
struct mad_pcm *pcm)
{
unsigned int nchannels, nsamples;
mad_fixed_t const *left_ch, *right_ch;
@ -169,14 +169,14 @@ enum mad_flow output(void *data,
static
enum mad_flow error(void *data,
struct mad_stream *stream,
struct mad_frame *frame)
struct mad_stream *stream,
struct mad_frame *frame)
{
struct buffer *buffer = data;
fprintf(stderr, "decoding error 0x%04x (%s) at byte offset %u\n",
stream->error, mad_stream_errorstr(stream),
stream->this_frame - buffer->start);
stream->error, mad_stream_errorstr(stream),
stream->this_frame - buffer->start);
/* return MAD_FLOW_BREAK here to stop decoding (and propagate an error) */
@ -207,8 +207,8 @@ int decode(unsigned char const *start, unsigned long length)
/* configure input, output, and error functions */
mad_decoder_init(&decoder, &buffer,
input, 0 /* header */, 0 /* filter */, output,
error, 0 /* message */);
input, 0 /* header */, 0 /* filter */, output,
error, 0 /* message */);
/* start decoding */

View file

@ -29,8 +29,8 @@
# include "stream.h"
/*
* NAME: stream->init()
* DESCRIPTION: initialize stream struct
* NAME: stream->init()
* DESCRIPTION: initialize stream struct
*/
void mad_stream_init(struct mad_stream *stream)
{
@ -56,8 +56,8 @@ void mad_stream_init(struct mad_stream *stream)
}
/*
* NAME: stream->finish()
* DESCRIPTION: deallocate any dynamic memory associated with stream
* NAME: stream->finish()
* DESCRIPTION: deallocate any dynamic memory associated with stream
*/
void mad_stream_finish(struct mad_stream *stream)
{
@ -71,11 +71,11 @@ void mad_stream_finish(struct mad_stream *stream)
}
/*
* NAME: stream->buffer()
* DESCRIPTION: set stream buffer pointers
* NAME: stream->buffer()
* DESCRIPTION: set stream buffer pointers
*/
void mad_stream_buffer(struct mad_stream *stream,
unsigned char const *buffer, unsigned long length)
unsigned char const *buffer, unsigned long length)
{
stream->buffer = buffer;
stream->bufend = buffer + length;
@ -89,8 +89,8 @@ void mad_stream_buffer(struct mad_stream *stream,
}
/*
* NAME: stream->skip()
* DESCRIPTION: arrange to skip bytes before the next frame
* NAME: stream->skip()
* DESCRIPTION: arrange to skip bytes before the next frame
*/
void mad_stream_skip(struct mad_stream *stream, unsigned long length)
{
@ -98,8 +98,8 @@ void mad_stream_skip(struct mad_stream *stream, unsigned long length)
}
/*
* NAME: stream->sync()
* DESCRIPTION: locate the next stream sync word
* NAME: stream->sync()
* DESCRIPTION: locate the next stream sync word
*/
int mad_stream_sync(struct mad_stream *stream)
{
@ -109,7 +109,7 @@ int mad_stream_sync(struct mad_stream *stream)
end = stream->bufend;
while (ptr < end - 1 &&
!(ptr[0] == 0xff && (ptr[1] & 0xe0) == 0xe0))
!(ptr[0] == 0xff && (ptr[1] & 0xe0) == 0xe0))
++ptr;
if (end - ptr < MAD_BUFFER_GUARD)
@ -121,38 +121,38 @@ int mad_stream_sync(struct mad_stream *stream)
}
/*
* NAME: stream->errorstr()
* DESCRIPTION: return a string description of the current error condition
* NAME: stream->errorstr()
* DESCRIPTION: return a string description of the current error condition
*/
char const *mad_stream_errorstr(struct mad_stream const *stream)
{
switch (stream->error) {
case MAD_ERROR_NONE: return "no error";
case MAD_ERROR_NONE: return "no error";
case MAD_ERROR_BUFLEN: return "input buffer too small (or EOF)";
case MAD_ERROR_BUFPTR: return "invalid (null) buffer pointer";
case MAD_ERROR_BUFLEN: return "input buffer too small (or EOF)";
case MAD_ERROR_BUFPTR: return "invalid (null) buffer pointer";
case MAD_ERROR_NOMEM: return "not enough memory";
case MAD_ERROR_NOMEM: return "not enough memory";
case MAD_ERROR_LOSTSYNC: return "lost synchronization";
case MAD_ERROR_BADLAYER: return "reserved header layer value";
case MAD_ERROR_BADBITRATE: return "forbidden bitrate value";
case MAD_ERROR_BADSAMPLERATE: return "reserved sample frequency value";
case MAD_ERROR_BADEMPHASIS: return "reserved emphasis value";
case MAD_ERROR_LOSTSYNC: return "lost synchronization";
case MAD_ERROR_BADLAYER: return "reserved header layer value";
case MAD_ERROR_BADBITRATE: return "forbidden bitrate value";
case MAD_ERROR_BADSAMPLERATE: return "reserved sample frequency value";
case MAD_ERROR_BADEMPHASIS: return "reserved emphasis value";
case MAD_ERROR_BADCRC: return "CRC check failed";
case MAD_ERROR_BADBITALLOC: return "forbidden bit allocation value";
case MAD_ERROR_BADCRC: return "CRC check failed";
case MAD_ERROR_BADBITALLOC: return "forbidden bit allocation value";
case MAD_ERROR_BADSCALEFACTOR: return "bad scalefactor index";
case MAD_ERROR_BADMODE: return "bad bitrate/mode combination";
case MAD_ERROR_BADFRAMELEN: return "bad frame length";
case MAD_ERROR_BADBIGVALUES: return "bad big_values count";
case MAD_ERROR_BADBLOCKTYPE: return "reserved block_type";
case MAD_ERROR_BADSCFSI: return "bad scalefactor selection info";
case MAD_ERROR_BADDATAPTR: return "bad main_data_begin pointer";
case MAD_ERROR_BADPART3LEN: return "bad audio data length";
case MAD_ERROR_BADHUFFTABLE: return "bad Huffman table select";
case MAD_ERROR_BADHUFFDATA: return "Huffman data overrun";
case MAD_ERROR_BADSTEREO: return "incompatible block_type for JS";
case MAD_ERROR_BADMODE: return "bad bitrate/mode combination";
case MAD_ERROR_BADFRAMELEN: return "bad frame length";
case MAD_ERROR_BADBIGVALUES: return "bad big_values count";
case MAD_ERROR_BADBLOCKTYPE: return "reserved block_type";
case MAD_ERROR_BADSCFSI: return "bad scalefactor selection info";
case MAD_ERROR_BADDATAPTR: return "bad main_data_begin pointer";
case MAD_ERROR_BADPART3LEN: return "bad audio data length";
case MAD_ERROR_BADHUFFTABLE: return "bad Huffman table select";
case MAD_ERROR_BADHUFFDATA: return "Huffman data overrun";
case MAD_ERROR_BADSTEREO: return "incompatible block_type for JS";
}
return 0;

View file

@ -24,70 +24,70 @@
# include "bit.h"
# define MAD_BUFFER_GUARD 8
# define MAD_BUFFER_MDLEN (511 + 2048 + MAD_BUFFER_GUARD)
# define MAD_BUFFER_GUARD 8
# define MAD_BUFFER_MDLEN (511 + 2048 + MAD_BUFFER_GUARD)
enum mad_error {
MAD_ERROR_NONE = 0x0000, /* no error */
MAD_ERROR_NONE = 0x0000, /* no error */
MAD_ERROR_BUFLEN = 0x0001, /* input buffer too small (or EOF) */
MAD_ERROR_BUFPTR = 0x0002, /* invalid (null) buffer pointer */
MAD_ERROR_BUFLEN = 0x0001, /* input buffer too small (or EOF) */
MAD_ERROR_BUFPTR = 0x0002, /* invalid (null) buffer pointer */
MAD_ERROR_NOMEM = 0x0031, /* not enough memory */
MAD_ERROR_NOMEM = 0x0031, /* not enough memory */
MAD_ERROR_LOSTSYNC = 0x0101, /* lost synchronization */
MAD_ERROR_BADLAYER = 0x0102, /* reserved header layer value */
MAD_ERROR_BADBITRATE = 0x0103, /* forbidden bitrate value */
MAD_ERROR_BADSAMPLERATE = 0x0104, /* reserved sample frequency value */
MAD_ERROR_BADEMPHASIS = 0x0105, /* reserved emphasis value */
MAD_ERROR_LOSTSYNC = 0x0101, /* lost synchronization */
MAD_ERROR_BADLAYER = 0x0102, /* reserved header layer value */
MAD_ERROR_BADBITRATE = 0x0103, /* forbidden bitrate value */
MAD_ERROR_BADSAMPLERATE = 0x0104, /* reserved sample frequency value */
MAD_ERROR_BADEMPHASIS = 0x0105, /* reserved emphasis value */
MAD_ERROR_BADCRC = 0x0201, /* CRC check failed */
MAD_ERROR_BADBITALLOC = 0x0211, /* forbidden bit allocation value */
MAD_ERROR_BADSCALEFACTOR = 0x0221, /* bad scalefactor index */
MAD_ERROR_BADMODE = 0x0222, /* bad bitrate/mode combination */
MAD_ERROR_BADFRAMELEN = 0x0231, /* bad frame length */
MAD_ERROR_BADBIGVALUES = 0x0232, /* bad big_values count */
MAD_ERROR_BADBLOCKTYPE = 0x0233, /* reserved block_type */
MAD_ERROR_BADSCFSI = 0x0234, /* bad scalefactor selection info */
MAD_ERROR_BADDATAPTR = 0x0235, /* bad main_data_begin pointer */
MAD_ERROR_BADPART3LEN = 0x0236, /* bad audio data length */
MAD_ERROR_BADHUFFTABLE = 0x0237, /* bad Huffman table select */
MAD_ERROR_BADHUFFDATA = 0x0238, /* Huffman data overrun */
MAD_ERROR_BADSTEREO = 0x0239 /* incompatible block_type for JS */
MAD_ERROR_BADCRC = 0x0201, /* CRC check failed */
MAD_ERROR_BADBITALLOC = 0x0211, /* forbidden bit allocation value */
MAD_ERROR_BADSCALEFACTOR = 0x0221, /* bad scalefactor index */
MAD_ERROR_BADMODE = 0x0222, /* bad bitrate/mode combination */
MAD_ERROR_BADFRAMELEN = 0x0231, /* bad frame length */
MAD_ERROR_BADBIGVALUES = 0x0232, /* bad big_values count */
MAD_ERROR_BADBLOCKTYPE = 0x0233, /* reserved block_type */
MAD_ERROR_BADSCFSI = 0x0234, /* bad scalefactor selection info */
MAD_ERROR_BADDATAPTR = 0x0235, /* bad main_data_begin pointer */
MAD_ERROR_BADPART3LEN = 0x0236, /* bad audio data length */
MAD_ERROR_BADHUFFTABLE = 0x0237, /* bad Huffman table select */
MAD_ERROR_BADHUFFDATA = 0x0238, /* Huffman data overrun */
MAD_ERROR_BADSTEREO = 0x0239 /* incompatible block_type for JS */
};
# define MAD_RECOVERABLE(error) ((error) & 0xff00)
# define MAD_RECOVERABLE(error) ((error) & 0xff00)
struct mad_stream {
unsigned char const *buffer; /* input bitstream buffer */
unsigned char const *bufend; /* end of buffer */
unsigned long skiplen; /* bytes to skip before next frame */
unsigned char const *buffer; /* input bitstream buffer */
unsigned char const *bufend; /* end of buffer */
unsigned long skiplen; /* bytes to skip before next frame */
int sync; /* stream sync found */
unsigned long freerate; /* free bitrate (fixed) */
int sync; /* stream sync found */
unsigned long freerate; /* free bitrate (fixed) */
unsigned char const *this_frame; /* start of current frame */
unsigned char const *next_frame; /* start of next frame */
struct mad_bitptr ptr; /* current processing bit pointer */
unsigned char const *this_frame; /* start of current frame */
unsigned char const *next_frame; /* start of next frame */
struct mad_bitptr ptr; /* current processing bit pointer */
struct mad_bitptr anc_ptr; /* ancillary bits pointer */
unsigned int anc_bitlen; /* number of ancillary bits */
struct mad_bitptr anc_ptr; /* ancillary bits pointer */
unsigned int anc_bitlen; /* number of ancillary bits */
unsigned char (*main_data)[MAD_BUFFER_MDLEN];
/* Layer III main_data() */
unsigned int md_len; /* bytes in main_data */
/* Layer III main_data() */
unsigned int md_len; /* bytes in main_data */
int options; /* decoding options (see below) */
enum mad_error error; /* error code (see above) */
int options; /* decoding options (see below) */
enum mad_error error; /* error code (see above) */
};
enum {
MAD_OPTION_IGNORECRC = 0x0001, /* ignore CRC errors */
MAD_OPTION_HALFSAMPLERATE = 0x0002 /* generate PCM at 1/2 sample rate */
MAD_OPTION_IGNORECRC = 0x0001, /* ignore CRC errors */
MAD_OPTION_HALFSAMPLERATE = 0x0002 /* generate PCM at 1/2 sample rate */
# if 0 /* not yet implemented */
MAD_OPTION_LEFTCHANNEL = 0x0010, /* decode left channel only */
MAD_OPTION_RIGHTCHANNEL = 0x0020, /* decode right channel only */
MAD_OPTION_SINGLECHANNEL = 0x0030 /* combine channels */
MAD_OPTION_LEFTCHANNEL = 0x0010, /* decode left channel only */
MAD_OPTION_RIGHTCHANNEL = 0x0020, /* decode right channel only */
MAD_OPTION_SINGLECHANNEL = 0x0030 /* combine channels */
# endif
};
@ -98,7 +98,7 @@ void mad_stream_finish(struct mad_stream *);
((void) ((stream)->options = (opts)))
void mad_stream_buffer(struct mad_stream *,
unsigned char const *, unsigned long);
unsigned char const *, unsigned long);
void mad_stream_skip(struct mad_stream *, unsigned long);
int mad_stream_sync(struct mad_stream *);

View file

@ -30,8 +30,8 @@
# include "synth.h"
/*
* NAME: synth->init()
* DESCRIPTION: initialize synth struct
* NAME: synth->init()
* DESCRIPTION: initialize synth struct
*/
void mad_synth_init(struct mad_synth *synth)
{
@ -50,8 +50,8 @@ void mad_synth_init(struct mad_synth *synth)
}
/*
* NAME: synth->mute()
* DESCRIPTION: zero all polyphase filterbank values, resetting synthesis
* NAME: synth->mute()
* DESCRIPTION: zero all polyphase filterbank values, resetting synthesis
*/
void mad_synth_mute(struct mad_synth *synth)
{
@ -60,8 +60,8 @@ void mad_synth_mute(struct mad_synth *synth)
for (ch = 0; ch < 2; ++ch) {
for (s = 0; s < 16; ++s) {
for (v = 0; v < 8; ++v) {
synth->filter[ch][0][0][s][v] = synth->filter[ch][0][1][s][v] =
synth->filter[ch][1][0][s][v] = synth->filter[ch][1][1][s][v] = 0;
synth->filter[ch][0][0][s][v] = synth->filter[ch][0][1][s][v] =
synth->filter[ch][1][0][s][v] = synth->filter[ch][1][1][s][v] = 0;
}
}
}
@ -142,12 +142,12 @@ void dct32(mad_fixed_t const in[32], unsigned int slot,
# endif
/*
* NAME: dct32()
* DESCRIPTION: perform fast in[32]->out[32] DCT
* NAME: dct32()
* DESCRIPTION: perform fast in[32]->out[32] DCT
*/
static
void dct32(mad_fixed_t const in[32], unsigned int slot,
mad_fixed_t lo[16][8], mad_fixed_t hi[16][8])
mad_fixed_t lo[16][8], mad_fixed_t hi[16][8])
{
mad_fixed_t t0, t1, t2, t3, t4, t5, t6, t7;
mad_fixed_t t8, t9, t10, t11, t12, t13, t14, t15;
@ -176,69 +176,69 @@ void dct32(mad_fixed_t const in[32], unsigned int slot,
/* costab[i] = cos(PI / (2 * 32) * i) */
# if defined(OPT_DCTO)
# define costab1 MAD_F(0x7fd8878e)
# define costab2 MAD_F(0x7f62368f)
# define costab3 MAD_F(0x7e9d55fc)
# define costab4 MAD_F(0x7d8a5f40)
# define costab5 MAD_F(0x7c29fbee)
# define costab6 MAD_F(0x7a7d055b)
# define costab7 MAD_F(0x78848414)
# define costab8 MAD_F(0x7641af3d)
# define costab9 MAD_F(0x73b5ebd1)
# define costab10 MAD_F(0x70e2cbc6)
# define costab11 MAD_F(0x6dca0d14)
# define costab12 MAD_F(0x6a5d98a4)
# define costab13 MAD_F(0x66cf8120)
# define costab14 MAD_F(0x62f201ac)
# define costab15 MAD_F(0x5ed77c8a)
# define costab16 MAD_F(0x5a82799a)
# define costab17 MAD_F(0x55f5a4d2)
# define costab18 MAD_F(0x5133cc94)
# define costab19 MAD_F(0x4c3fdff4)
# define costab20 MAD_F(0x471cece7)
# define costab21 MAD_F(0x41ce1e65)
# define costab22 MAD_F(0x3c56ba70)
# define costab23 MAD_F(0x36ba2014)
# define costab24 MAD_F(0x30fbc54d)
# define costab25 MAD_F(0x2b1f34eb)
# define costab26 MAD_F(0x25280c5e)
# define costab27 MAD_F(0x1f19f97b)
# define costab28 MAD_F(0x18f8b83c)
# define costab29 MAD_F(0x12c8106f)
# define costab30 MAD_F(0x0c8bd35e)
# define costab31 MAD_F(0x0647d97c)
# define costab1 MAD_F(0x7fd8878e)
# define costab2 MAD_F(0x7f62368f)
# define costab3 MAD_F(0x7e9d55fc)
# define costab4 MAD_F(0x7d8a5f40)
# define costab5 MAD_F(0x7c29fbee)
# define costab6 MAD_F(0x7a7d055b)
# define costab7 MAD_F(0x78848414)
# define costab8 MAD_F(0x7641af3d)
# define costab9 MAD_F(0x73b5ebd1)
# define costab10 MAD_F(0x70e2cbc6)
# define costab11 MAD_F(0x6dca0d14)
# define costab12 MAD_F(0x6a5d98a4)
# define costab13 MAD_F(0x66cf8120)
# define costab14 MAD_F(0x62f201ac)
# define costab15 MAD_F(0x5ed77c8a)
# define costab16 MAD_F(0x5a82799a)
# define costab17 MAD_F(0x55f5a4d2)
# define costab18 MAD_F(0x5133cc94)
# define costab19 MAD_F(0x4c3fdff4)
# define costab20 MAD_F(0x471cece7)
# define costab21 MAD_F(0x41ce1e65)
# define costab22 MAD_F(0x3c56ba70)
# define costab23 MAD_F(0x36ba2014)
# define costab24 MAD_F(0x30fbc54d)
# define costab25 MAD_F(0x2b1f34eb)
# define costab26 MAD_F(0x25280c5e)
# define costab27 MAD_F(0x1f19f97b)
# define costab28 MAD_F(0x18f8b83c)
# define costab29 MAD_F(0x12c8106f)
# define costab30 MAD_F(0x0c8bd35e)
# define costab31 MAD_F(0x0647d97c)
# else
# define costab1 MAD_F(0x0ffb10f2) /* 0.998795456 */
# define costab2 MAD_F(0x0fec46d2) /* 0.995184727 */
# define costab3 MAD_F(0x0fd3aac0) /* 0.989176510 */
# define costab4 MAD_F(0x0fb14be8) /* 0.980785280 */
# define costab5 MAD_F(0x0f853f7e) /* 0.970031253 */
# define costab6 MAD_F(0x0f4fa0ab) /* 0.956940336 */
# define costab7 MAD_F(0x0f109082) /* 0.941544065 */
# define costab8 MAD_F(0x0ec835e8) /* 0.923879533 */
# define costab9 MAD_F(0x0e76bd7a) /* 0.903989293 */
# define costab10 MAD_F(0x0e1c5979) /* 0.881921264 */
# define costab11 MAD_F(0x0db941a3) /* 0.857728610 */
# define costab12 MAD_F(0x0d4db315) /* 0.831469612 */
# define costab13 MAD_F(0x0cd9f024) /* 0.803207531 */
# define costab14 MAD_F(0x0c5e4036) /* 0.773010453 */
# define costab15 MAD_F(0x0bdaef91) /* 0.740951125 */
# define costab16 MAD_F(0x0b504f33) /* 0.707106781 */
# define costab17 MAD_F(0x0abeb49a) /* 0.671558955 */
# define costab18 MAD_F(0x0a267993) /* 0.634393284 */
# define costab19 MAD_F(0x0987fbfe) /* 0.595699304 */
# define costab20 MAD_F(0x08e39d9d) /* 0.555570233 */
# define costab21 MAD_F(0x0839c3cd) /* 0.514102744 */
# define costab22 MAD_F(0x078ad74e) /* 0.471396737 */
# define costab23 MAD_F(0x06d74402) /* 0.427555093 */
# define costab24 MAD_F(0x061f78aa) /* 0.382683432 */
# define costab25 MAD_F(0x0563e69d) /* 0.336889853 */
# define costab26 MAD_F(0x04a5018c) /* 0.290284677 */
# define costab27 MAD_F(0x03e33f2f) /* 0.242980180 */
# define costab28 MAD_F(0x031f1708) /* 0.195090322 */
# define costab29 MAD_F(0x0259020e) /* 0.146730474 */
# define costab30 MAD_F(0x01917a5c) /* 0.098017140 */
# define costab31 MAD_F(0x00c8fb30) /* 0.049067674 */
# define costab1 MAD_F(0x0ffb10f2) /* 0.998795456 */
# define costab2 MAD_F(0x0fec46d2) /* 0.995184727 */
# define costab3 MAD_F(0x0fd3aac0) /* 0.989176510 */
# define costab4 MAD_F(0x0fb14be8) /* 0.980785280 */
# define costab5 MAD_F(0x0f853f7e) /* 0.970031253 */
# define costab6 MAD_F(0x0f4fa0ab) /* 0.956940336 */
# define costab7 MAD_F(0x0f109082) /* 0.941544065 */
# define costab8 MAD_F(0x0ec835e8) /* 0.923879533 */
# define costab9 MAD_F(0x0e76bd7a) /* 0.903989293 */
# define costab10 MAD_F(0x0e1c5979) /* 0.881921264 */
# define costab11 MAD_F(0x0db941a3) /* 0.857728610 */
# define costab12 MAD_F(0x0d4db315) /* 0.831469612 */
# define costab13 MAD_F(0x0cd9f024) /* 0.803207531 */
# define costab14 MAD_F(0x0c5e4036) /* 0.773010453 */
# define costab15 MAD_F(0x0bdaef91) /* 0.740951125 */
# define costab16 MAD_F(0x0b504f33) /* 0.707106781 */
# define costab17 MAD_F(0x0abeb49a) /* 0.671558955 */
# define costab18 MAD_F(0x0a267993) /* 0.634393284 */
# define costab19 MAD_F(0x0987fbfe) /* 0.595699304 */
# define costab20 MAD_F(0x08e39d9d) /* 0.555570233 */
# define costab21 MAD_F(0x0839c3cd) /* 0.514102744 */
# define costab22 MAD_F(0x078ad74e) /* 0.471396737 */
# define costab23 MAD_F(0x06d74402) /* 0.427555093 */
# define costab24 MAD_F(0x061f78aa) /* 0.382683432 */
# define costab25 MAD_F(0x0563e69d) /* 0.336889853 */
# define costab26 MAD_F(0x04a5018c) /* 0.290284677 */
# define costab27 MAD_F(0x03e33f2f) /* 0.242980180 */
# define costab28 MAD_F(0x031f1708) /* 0.195090322 */
# define costab29 MAD_F(0x0259020e) /* 0.146730474 */
# define costab30 MAD_F(0x01917a5c) /* 0.098017140 */
# define costab31 MAD_F(0x00c8fb30) /* 0.049067674 */
# endif
t0 = in[0] + in[31]; t16 = MUL(in[0] - in[31], costab1);
@ -395,7 +395,7 @@ void dct32(mad_fixed_t const in[32], unsigned int slot,
/* 8 */ hi[ 7][slot] = SHIFT(t143);
/* 24 */ lo[ 8][slot] =
SHIFT((MUL(t141 - t142, costab16) * 2) - t143);
SHIFT((MUL(t141 - t142, costab16) * 2) - t143);
t144 = MUL(t73 - t74, costab8);
t145 = MUL(t75 - t76, costab24);
@ -435,7 +435,7 @@ void dct32(mad_fixed_t const in[32], unsigned int slot,
/* 20 */ lo[ 4][slot] = SHIFT(t160);
/* 28 */ lo[12][slot] =
SHIFT((((MUL(t157 - t158, costab16) * 2) - t159) * 2) - t160);
SHIFT((((MUL(t157 - t158, costab16) * 2) - t159) * 2) - t160);
t161 = MUL(t94 - t95, costab8);
t162 = MUL(t96 - t97, costab24);
@ -473,8 +473,8 @@ void dct32(mad_fixed_t const in[32], unsigned int slot,
/* 26 */ lo[10][slot] = SHIFT(t170);
/* 30 */ lo[14][slot] =
SHIFT((((((MUL(t166 - t167, costab16) * 2) -
t168) * 2) - t169) * 2) - t170);
SHIFT((((((MUL(t166 - t167, costab16) * 2) -
t168) * 2) - t169) * 2) - t170);
t171 = MUL(t106 - t107, costab8);
t172 = MUL(t108 - t109, costab24);
@ -521,12 +521,12 @@ void dct32(mad_fixed_t const in[32], unsigned int slot,
/* 27 */ lo[11][slot] = SHIFT(t165);
t176 = (((((MUL(t161 - t162, costab16) * 2) -
t163) * 2) - t164) * 2) - t165;
t163) * 2) - t164) * 2) - t165;
/* 29 */ lo[13][slot] = SHIFT(t176);
/* 31 */ lo[15][slot] =
SHIFT((((((((MUL(t171 - t172, costab16) * 2) -
t173) * 2) - t174) * 2) - t175) * 2) - t176);
SHIFT((((((((MUL(t171 - t172, costab16) * 2) -
t173) * 2) - t174) * 2) - t175) * 2) - t176);
/*
* Totals:
@ -548,24 +548,24 @@ void dct32(mad_fixed_t const in[32], unsigned int slot,
# if MAD_F_FRACBITS != 28
# error "MAD_F_FRACBITS must be 28 to use OPT_SSO"
# endif
# define ML0(hi, lo, x, y) ((lo) = (x) * (y))
# define MLA(hi, lo, x, y) ((lo) += (x) * (y))
# define MLN(hi, lo) ((lo) = -(lo))
# define MLZ(hi, lo) ((void) (hi), (mad_fixed_t) (lo))
# define SHIFT(x) ((x) >> 2)
# define PRESHIFT(x) ((MAD_F(x) + (1L << 13)) >> 14)
# define ML0(hi, lo, x, y) ((lo) = (x) * (y))
# define MLA(hi, lo, x, y) ((lo) += (x) * (y))
# define MLN(hi, lo) ((lo) = -(lo))
# define MLZ(hi, lo) ((void) (hi), (mad_fixed_t) (lo))
# define SHIFT(x) ((x) >> 2)
# define PRESHIFT(x) ((MAD_F(x) + (1L << 13)) >> 14)
# else
# define ML0(hi, lo, x, y) MAD_F_ML0((hi), (lo), (x), (y))
# define MLA(hi, lo, x, y) MAD_F_MLA((hi), (lo), (x), (y))
# define MLN(hi, lo) MAD_F_MLN((hi), (lo))
# define MLZ(hi, lo) MAD_F_MLZ((hi), (lo))
# define SHIFT(x) (x)
# define ML0(hi, lo, x, y) MAD_F_ML0((hi), (lo), (x), (y))
# define MLA(hi, lo, x, y) MAD_F_MLA((hi), (lo), (x), (y))
# define MLN(hi, lo) MAD_F_MLN((hi), (lo))
# define MLZ(hi, lo) MAD_F_MLZ((hi), (lo))
# define SHIFT(x) (x)
# if defined(MAD_F_SCALEBITS)
# undef MAD_F_SCALEBITS
# define MAD_F_SCALEBITS (MAD_F_FRACBITS - 12)
# define PRESHIFT(x) (MAD_F(x) >> 12)
# define MAD_F_SCALEBITS (MAD_F_FRACBITS - 12)
# define PRESHIFT(x) (MAD_F(x) >> 12)
# else
# define PRESHIFT(x) MAD_F(x)
# define PRESHIFT(x) MAD_F(x)
# endif
# endif
@ -576,18 +576,18 @@ mad_fixed_t const D[17][32] ICONST_ATTR = {
# if defined(ASO_SYNTH)
void synth_full(struct mad_synth *, struct mad_frame const *,
unsigned int, unsigned int);
unsigned int, unsigned int);
# else
/*
* NAME: synth->full()
* DESCRIPTION: perform full frequency PCM synthesis
* NAME: synth->full()
* DESCRIPTION: perform full frequency PCM synthesis
*/
/* optimised version of synth_full */
# ifdef FPM_COLDFIRE_EMAC
static
void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
unsigned int nch, unsigned int ns)
unsigned int nch, unsigned int ns)
{
int sb;
unsigned int phase, ch, s, p;
@ -606,7 +606,7 @@ void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
for (s = 0; s < ns; ++s) {
dct32((*sbsample)[s], phase >> 1,
(*filter)[0][phase & 1], (*filter)[1][phase & 1]);
(*filter)[0][phase & 1], (*filter)[1][phase & 1]);
p = (phase - 1) & 0xf;
@ -649,11 +649,11 @@ void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
pcm += 16;
for (sb = 15; sb; sb--, fo++) {
++fe;
++D0ptr;
++D1ptr;
++fe;
++D0ptr;
++D1ptr;
/* D[32 - sb][i] == -D[sb][31 - i] */
/* D[32 - sb][i] == -D[sb][31 - i] */
asm volatile (
"movem.l (%0), %%d0-%%d7\n\t"
"move.l 4(%2), %%a5\n\t"
@ -697,8 +697,8 @@ void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
"movclr.l %%acc0, %0\n\t"
"movclr.l %%acc1, %1\n\t" : "=d" (hi0), "=d" (hi1) );
pcm[-sb] = hi0 << 3;
pcm[ sb] = hi1 << 3;
pcm[-sb] = hi0 << 3;
pcm[ sb] = hi1 << 3;
}
++D0ptr;
@ -750,11 +750,11 @@ void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
pcm += 16;
for (sb = 15; sb; sb--, fo++) {
++fe;
++D0ptr;
++D1ptr;
++fe;
++D0ptr;
++D1ptr;
/* D[32 - sb][i] == -D[sb][31 - i] */
/* D[32 - sb][i] == -D[sb][31 - i] */
asm volatile (
"movem.l (%0), %%d0-%%d7\n\t"
"move.l (%2), %%a5\n\t"
@ -798,8 +798,8 @@ void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
"movclr.l %%acc0, %0\n\t"
"movclr.l %%acc1, %1\n\t" : "=d" (hi0), "=d" (hi1) );
pcm[-sb] = hi0 << 3;
pcm[ sb] = hi1 << 3;
pcm[-sb] = hi0 << 3;
pcm[ sb] = hi1 << 3;
}
++D0ptr;
@ -1045,10 +1045,10 @@ void synth_full2(mad_fixed_t *pcm, mad_fixed_t (*fo)[8], mad_fixed_t (*fe)[8],
static
void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
unsigned int nch, unsigned int ns) ICODE_ATTR_MPA_SYNTH;
unsigned int nch, unsigned int ns) ICODE_ATTR_MPA_SYNTH;
static
void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
unsigned int nch, unsigned int ns)
unsigned int nch, unsigned int ns)
{
int p;
unsigned int phase, ch, s;
@ -1068,7 +1068,7 @@ void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
for (s = 0; s < ns; ++s) {
dct32((*sbsample)[s], phase >> 1,
(*filter)[0][phase & 1], (*filter)[1][phase & 1]);
(*filter)[0][phase & 1], (*filter)[1][phase & 1]);
p = (phase - 1) & 0xf;
@ -1189,7 +1189,7 @@ void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
static
void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
unsigned int nch, unsigned int ns)
unsigned int nch, unsigned int ns)
{
int p, sb;
unsigned int phase, ch, s;
@ -1209,7 +1209,7 @@ void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
for (s = 0; s < ns; ++s) {
dct32((*sbsample)[s], phase >> 1,
(*filter)[0][phase & 1], (*filter)[1][phase & 1]);
(*filter)[0][phase & 1], (*filter)[1][phase & 1]);
p = (phase - 1) & 0xf;
@ -1246,49 +1246,49 @@ void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
for (sb = 15; sb; sb--, fo++)
{
++fe;
++D0ptr;
++D1ptr;
++fe;
++D0ptr;
++D1ptr;
/* D[32 - sb][i] == -D[sb][31 - i] */
ptr = *D0ptr;
ML0(hi, lo, (*fo)[0], ptr[ 1]);
MLA(hi, lo, (*fo)[1], ptr[15]);
MLA(hi, lo, (*fo)[2], ptr[13]);
MLA(hi, lo, (*fo)[3], ptr[11]);
MLA(hi, lo, (*fo)[4], ptr[ 9]);
MLA(hi, lo, (*fo)[5], ptr[ 7]);
MLA(hi, lo, (*fo)[6], ptr[ 5]);
MLA(hi, lo, (*fo)[7], ptr[ 3]);
MLN(hi, lo);
MLA(hi, lo, (*fe)[7], ptr[ 2]);
MLA(hi, lo, (*fe)[6], ptr[ 4]);
MLA(hi, lo, (*fe)[5], ptr[ 6]);
MLA(hi, lo, (*fe)[4], ptr[ 8]);
MLA(hi, lo, (*fe)[3], ptr[10]);
MLA(hi, lo, (*fe)[2], ptr[12]);
MLA(hi, lo, (*fe)[1], ptr[14]);
MLA(hi, lo, (*fe)[0], ptr[ 0]);
pcm[-sb] = SHIFT(MLZ(hi, lo));
/* D[32 - sb][i] == -D[sb][31 - i] */
ptr = *D0ptr;
ML0(hi, lo, (*fo)[0], ptr[ 1]);
MLA(hi, lo, (*fo)[1], ptr[15]);
MLA(hi, lo, (*fo)[2], ptr[13]);
MLA(hi, lo, (*fo)[3], ptr[11]);
MLA(hi, lo, (*fo)[4], ptr[ 9]);
MLA(hi, lo, (*fo)[5], ptr[ 7]);
MLA(hi, lo, (*fo)[6], ptr[ 5]);
MLA(hi, lo, (*fo)[7], ptr[ 3]);
MLN(hi, lo);
MLA(hi, lo, (*fe)[7], ptr[ 2]);
MLA(hi, lo, (*fe)[6], ptr[ 4]);
MLA(hi, lo, (*fe)[5], ptr[ 6]);
MLA(hi, lo, (*fe)[4], ptr[ 8]);
MLA(hi, lo, (*fe)[3], ptr[10]);
MLA(hi, lo, (*fe)[2], ptr[12]);
MLA(hi, lo, (*fe)[1], ptr[14]);
MLA(hi, lo, (*fe)[0], ptr[ 0]);
pcm[-sb] = SHIFT(MLZ(hi, lo));
ptr = *D1ptr;
ML0(hi, lo, (*fe)[0], ptr[31 - 16]);
MLA(hi, lo, (*fe)[1], ptr[31 - 14]);
MLA(hi, lo, (*fe)[2], ptr[31 - 12]);
MLA(hi, lo, (*fe)[3], ptr[31 - 10]);
MLA(hi, lo, (*fe)[4], ptr[31 - 8]);
MLA(hi, lo, (*fe)[5], ptr[31 - 6]);
MLA(hi, lo, (*fe)[6], ptr[31 - 4]);
MLA(hi, lo, (*fe)[7], ptr[31 - 2]);
ptr = *D1ptr;
ML0(hi, lo, (*fe)[0], ptr[31 - 16]);
MLA(hi, lo, (*fe)[1], ptr[31 - 14]);
MLA(hi, lo, (*fe)[2], ptr[31 - 12]);
MLA(hi, lo, (*fe)[3], ptr[31 - 10]);
MLA(hi, lo, (*fe)[4], ptr[31 - 8]);
MLA(hi, lo, (*fe)[5], ptr[31 - 6]);
MLA(hi, lo, (*fe)[6], ptr[31 - 4]);
MLA(hi, lo, (*fe)[7], ptr[31 - 2]);
MLA(hi, lo, (*fo)[7], ptr[31 - 3]);
MLA(hi, lo, (*fo)[6], ptr[31 - 5]);
MLA(hi, lo, (*fo)[5], ptr[31 - 7]);
MLA(hi, lo, (*fo)[4], ptr[31 - 9]);
MLA(hi, lo, (*fo)[3], ptr[31 - 11]);
MLA(hi, lo, (*fo)[2], ptr[31 - 13]);
MLA(hi, lo, (*fo)[1], ptr[31 - 15]);
MLA(hi, lo, (*fo)[0], ptr[31 - 1]);
pcm[sb] = SHIFT(MLZ(hi, lo));
MLA(hi, lo, (*fo)[6], ptr[31 - 5]);
MLA(hi, lo, (*fo)[5], ptr[31 - 7]);
MLA(hi, lo, (*fo)[4], ptr[31 - 9]);
MLA(hi, lo, (*fo)[3], ptr[31 - 11]);
MLA(hi, lo, (*fo)[2], ptr[31 - 13]);
MLA(hi, lo, (*fo)[1], ptr[31 - 15]);
MLA(hi, lo, (*fo)[0], ptr[31 - 1]);
pcm[sb] = SHIFT(MLZ(hi, lo));
}
ptr = *(D0ptr + 1);
@ -1327,49 +1327,49 @@ void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
for (sb = 15; sb; sb--, fo++)
{
++fe;
++D0ptr;
++D1ptr;
++fe;
++D0ptr;
++D1ptr;
/* D[32 - sb][i] == -D[sb][31 - i] */
ptr = *D0ptr;
ML0(hi, lo, (*fo)[0], ptr[ 0]);
MLA(hi, lo, (*fo)[1], ptr[14]);
MLA(hi, lo, (*fo)[2], ptr[12]);
MLA(hi, lo, (*fo)[3], ptr[10]);
MLA(hi, lo, (*fo)[4], ptr[ 8]);
MLA(hi, lo, (*fo)[5], ptr[ 6]);
MLA(hi, lo, (*fo)[6], ptr[ 4]);
MLA(hi, lo, (*fo)[7], ptr[ 2]);
MLN(hi, lo);
MLA(hi, lo, (*fe)[7], ptr[ 3]);
MLA(hi, lo, (*fe)[6], ptr[ 5]);
MLA(hi, lo, (*fe)[5], ptr[ 7]);
MLA(hi, lo, (*fe)[4], ptr[ 9]);
MLA(hi, lo, (*fe)[3], ptr[11]);
MLA(hi, lo, (*fe)[2], ptr[13]);
MLA(hi, lo, (*fe)[1], ptr[15]);
MLA(hi, lo, (*fe)[0], ptr[ 1]);
pcm[-sb] = SHIFT(MLZ(hi, lo));
/* D[32 - sb][i] == -D[sb][31 - i] */
ptr = *D0ptr;
ML0(hi, lo, (*fo)[0], ptr[ 0]);
MLA(hi, lo, (*fo)[1], ptr[14]);
MLA(hi, lo, (*fo)[2], ptr[12]);
MLA(hi, lo, (*fo)[3], ptr[10]);
MLA(hi, lo, (*fo)[4], ptr[ 8]);
MLA(hi, lo, (*fo)[5], ptr[ 6]);
MLA(hi, lo, (*fo)[6], ptr[ 4]);
MLA(hi, lo, (*fo)[7], ptr[ 2]);
MLN(hi, lo);
MLA(hi, lo, (*fe)[7], ptr[ 3]);
MLA(hi, lo, (*fe)[6], ptr[ 5]);
MLA(hi, lo, (*fe)[5], ptr[ 7]);
MLA(hi, lo, (*fe)[4], ptr[ 9]);
MLA(hi, lo, (*fe)[3], ptr[11]);
MLA(hi, lo, (*fe)[2], ptr[13]);
MLA(hi, lo, (*fe)[1], ptr[15]);
MLA(hi, lo, (*fe)[0], ptr[ 1]);
pcm[-sb] = SHIFT(MLZ(hi, lo));
ptr = *D1ptr;
ML0(hi, lo, (*fe)[0], ptr[31 - 1]);
MLA(hi, lo, (*fe)[1], ptr[31 - 15]);
MLA(hi, lo, (*fe)[2], ptr[31 - 13]);
MLA(hi, lo, (*fe)[3], ptr[31 - 11]);
MLA(hi, lo, (*fe)[4], ptr[31 - 9]);
MLA(hi, lo, (*fe)[5], ptr[31 - 7]);
MLA(hi, lo, (*fe)[6], ptr[31 - 5]);
MLA(hi, lo, (*fe)[7], ptr[31 - 3]);
MLA(hi, lo, (*fo)[7], ptr[31 - 2]);
MLA(hi, lo, (*fo)[6], ptr[31 - 4]);
MLA(hi, lo, (*fo)[5], ptr[31 - 6]);
MLA(hi, lo, (*fo)[4], ptr[31 - 8]);
MLA(hi, lo, (*fo)[3], ptr[31 - 10]);
MLA(hi, lo, (*fo)[2], ptr[31 - 12]);
MLA(hi, lo, (*fo)[1], ptr[31 - 14]);
MLA(hi, lo, (*fo)[0], ptr[31 - 16]);
pcm[sb] = SHIFT(MLZ(hi, lo));
ptr = *D1ptr;
ML0(hi, lo, (*fe)[0], ptr[31 - 1]);
MLA(hi, lo, (*fe)[1], ptr[31 - 15]);
MLA(hi, lo, (*fe)[2], ptr[31 - 13]);
MLA(hi, lo, (*fe)[3], ptr[31 - 11]);
MLA(hi, lo, (*fe)[4], ptr[31 - 9]);
MLA(hi, lo, (*fe)[5], ptr[31 - 7]);
MLA(hi, lo, (*fe)[6], ptr[31 - 5]);
MLA(hi, lo, (*fe)[7], ptr[31 - 3]);
MLA(hi, lo, (*fo)[7], ptr[31 - 2]);
MLA(hi, lo, (*fo)[6], ptr[31 - 4]);
MLA(hi, lo, (*fo)[5], ptr[31 - 6]);
MLA(hi, lo, (*fo)[4], ptr[31 - 8]);
MLA(hi, lo, (*fo)[3], ptr[31 - 10]);
MLA(hi, lo, (*fo)[2], ptr[31 - 12]);
MLA(hi, lo, (*fo)[1], ptr[31 - 14]);
MLA(hi, lo, (*fo)[0], ptr[31 - 16]);
pcm[sb] = SHIFT(MLZ(hi, lo));
}
ptr = *(D0ptr + 1);
@ -1394,12 +1394,12 @@ void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
# endif
/*
* NAME: synth->half()
* DESCRIPTION: perform half frequency PCM synthesis
* NAME: synth->half()
* DESCRIPTION: perform half frequency PCM synthesis
*/
static
void synth_half(struct mad_synth *synth, struct mad_frame const *frame,
unsigned int nch, unsigned int ns)
unsigned int nch, unsigned int ns)
{
unsigned int phase, ch, s, sb, pe, po;
mad_fixed_t *pcm1, *pcm2, (*filter)[2][2][16][8];
@ -1417,7 +1417,7 @@ void synth_half(struct mad_synth *synth, struct mad_frame const *frame,
for (s = 0; s < ns; ++s) {
dct32((*sbsample)[s], phase >> 1,
(*filter)[0][phase & 1], (*filter)[1][phase & 1]);
(*filter)[0][phase & 1], (*filter)[1][phase & 1]);
pe = phase & ~1;
po = ((phase - 1) & 0xf) | 1;
@ -1456,59 +1456,59 @@ void synth_half(struct mad_synth *synth, struct mad_frame const *frame,
pcm2 = pcm1 + 14;
for (sb = 1; sb < 16; ++sb) {
++fe;
++Dptr;
++fe;
++Dptr;
/* D[32 - sb][i] == -D[sb][31 - i] */
/* D[32 - sb][i] == -D[sb][31 - i] */
if (!(sb & 1)) {
ptr = *Dptr + po;
ML0(hi, lo, (*fo)[0], ptr[ 0]);
MLA(hi, lo, (*fo)[1], ptr[14]);
MLA(hi, lo, (*fo)[2], ptr[12]);
MLA(hi, lo, (*fo)[3], ptr[10]);
MLA(hi, lo, (*fo)[4], ptr[ 8]);
MLA(hi, lo, (*fo)[5], ptr[ 6]);
MLA(hi, lo, (*fo)[6], ptr[ 4]);
MLA(hi, lo, (*fo)[7], ptr[ 2]);
MLN(hi, lo);
if (!(sb & 1)) {
ptr = *Dptr + po;
ML0(hi, lo, (*fo)[0], ptr[ 0]);
MLA(hi, lo, (*fo)[1], ptr[14]);
MLA(hi, lo, (*fo)[2], ptr[12]);
MLA(hi, lo, (*fo)[3], ptr[10]);
MLA(hi, lo, (*fo)[4], ptr[ 8]);
MLA(hi, lo, (*fo)[5], ptr[ 6]);
MLA(hi, lo, (*fo)[6], ptr[ 4]);
MLA(hi, lo, (*fo)[7], ptr[ 2]);
MLN(hi, lo);
ptr = *Dptr + pe;
MLA(hi, lo, (*fe)[7], ptr[ 2]);
MLA(hi, lo, (*fe)[6], ptr[ 4]);
MLA(hi, lo, (*fe)[5], ptr[ 6]);
MLA(hi, lo, (*fe)[4], ptr[ 8]);
MLA(hi, lo, (*fe)[3], ptr[10]);
MLA(hi, lo, (*fe)[2], ptr[12]);
MLA(hi, lo, (*fe)[1], ptr[14]);
MLA(hi, lo, (*fe)[0], ptr[ 0]);
ptr = *Dptr + pe;
MLA(hi, lo, (*fe)[7], ptr[ 2]);
MLA(hi, lo, (*fe)[6], ptr[ 4]);
MLA(hi, lo, (*fe)[5], ptr[ 6]);
MLA(hi, lo, (*fe)[4], ptr[ 8]);
MLA(hi, lo, (*fe)[3], ptr[10]);
MLA(hi, lo, (*fe)[2], ptr[12]);
MLA(hi, lo, (*fe)[1], ptr[14]);
MLA(hi, lo, (*fe)[0], ptr[ 0]);
*pcm1++ = SHIFT(MLZ(hi, lo));
*pcm1++ = SHIFT(MLZ(hi, lo));
ptr = *Dptr - po;
ML0(hi, lo, (*fo)[7], ptr[31 - 2]);
MLA(hi, lo, (*fo)[6], ptr[31 - 4]);
MLA(hi, lo, (*fo)[5], ptr[31 - 6]);
MLA(hi, lo, (*fo)[4], ptr[31 - 8]);
MLA(hi, lo, (*fo)[3], ptr[31 - 10]);
MLA(hi, lo, (*fo)[2], ptr[31 - 12]);
MLA(hi, lo, (*fo)[1], ptr[31 - 14]);
MLA(hi, lo, (*fo)[0], ptr[31 - 16]);
ptr = *Dptr - po;
ML0(hi, lo, (*fo)[7], ptr[31 - 2]);
MLA(hi, lo, (*fo)[6], ptr[31 - 4]);
MLA(hi, lo, (*fo)[5], ptr[31 - 6]);
MLA(hi, lo, (*fo)[4], ptr[31 - 8]);
MLA(hi, lo, (*fo)[3], ptr[31 - 10]);
MLA(hi, lo, (*fo)[2], ptr[31 - 12]);
MLA(hi, lo, (*fo)[1], ptr[31 - 14]);
MLA(hi, lo, (*fo)[0], ptr[31 - 16]);
ptr = *Dptr - pe;
MLA(hi, lo, (*fe)[0], ptr[31 - 16]);
MLA(hi, lo, (*fe)[1], ptr[31 - 14]);
MLA(hi, lo, (*fe)[2], ptr[31 - 12]);
MLA(hi, lo, (*fe)[3], ptr[31 - 10]);
MLA(hi, lo, (*fe)[4], ptr[31 - 8]);
MLA(hi, lo, (*fe)[5], ptr[31 - 6]);
MLA(hi, lo, (*fe)[6], ptr[31 - 4]);
MLA(hi, lo, (*fe)[7], ptr[31 - 2]);
ptr = *Dptr - pe;
MLA(hi, lo, (*fe)[0], ptr[31 - 16]);
MLA(hi, lo, (*fe)[1], ptr[31 - 14]);
MLA(hi, lo, (*fe)[2], ptr[31 - 12]);
MLA(hi, lo, (*fe)[3], ptr[31 - 10]);
MLA(hi, lo, (*fe)[4], ptr[31 - 8]);
MLA(hi, lo, (*fe)[5], ptr[31 - 6]);
MLA(hi, lo, (*fe)[6], ptr[31 - 4]);
MLA(hi, lo, (*fe)[7], ptr[31 - 2]);
*pcm2-- = SHIFT(MLZ(hi, lo));
}
*pcm2-- = SHIFT(MLZ(hi, lo));
}
++fo;
++fo;
}
++Dptr;
@ -1532,14 +1532,14 @@ void synth_half(struct mad_synth *synth, struct mad_frame const *frame,
}
/*
* NAME: synth->frame()
* DESCRIPTION: perform PCM synthesis of frame subband samples
* NAME: synth->frame()
* DESCRIPTION: perform PCM synthesis of frame subband samples
*/
void mad_synth_frame(struct mad_synth *synth, struct mad_frame const *frame)
{
unsigned int nch, ns;
void (*synth_frame)(struct mad_synth *, struct mad_frame const *,
unsigned int, unsigned int);
unsigned int, unsigned int);
nch = MAD_NCHANNELS(&frame->header);
ns = MAD_NSBSAMPLES(&frame->header);

View file

@ -26,19 +26,19 @@
# include "frame.h"
struct mad_pcm {
unsigned int samplerate; /* sampling frequency (Hz) */
unsigned short channels; /* number of channels */
unsigned short length; /* number of samples per channel */
mad_fixed_t samples[2][1152]; /* PCM output samples [ch][sample] */
unsigned int samplerate; /* sampling frequency (Hz) */
unsigned short channels; /* number of channels */
unsigned short length; /* number of samples per channel */
mad_fixed_t samples[2][1152]; /* PCM output samples [ch][sample] */
};
struct mad_synth {
mad_fixed_t filter[2][2][2][16][8]; /* polyphase filterbank outputs */
/* [ch][eo][peo][s][v] */
mad_fixed_t filter[2][2][2][16][8]; /* polyphase filterbank outputs */
/* [ch][eo][peo][s][v] */
unsigned int phase; /* current processing phase */
unsigned int phase; /* current processing phase */
struct mad_pcm pcm; /* PCM output */
struct mad_pcm pcm; /* PCM output */
};
/* single channel PCM selector */

View file

@ -36,8 +36,8 @@
mad_timer_t const mad_timer_zero = { 0, 0 };
/*
* NAME: timer->compare()
* DESCRIPTION: indicate relative order of two timers
* NAME: timer->compare()
* DESCRIPTION: indicate relative order of two timers
*/
int mad_timer_compare(mad_timer_t timer1, mad_timer_t timer2)
{
@ -59,8 +59,8 @@ int mad_timer_compare(mad_timer_t timer1, mad_timer_t timer2)
}
/*
* NAME: timer->negate()
* DESCRIPTION: invert the sign of a timer
* NAME: timer->negate()
* DESCRIPTION: invert the sign of a timer
*/
void mad_timer_negate(mad_timer_t *timer)
{
@ -73,8 +73,8 @@ void mad_timer_negate(mad_timer_t *timer)
}
/*
* NAME: timer->abs()
* DESCRIPTION: return the absolute value of a timer
* NAME: timer->abs()
* DESCRIPTION: return the absolute value of a timer
*/
mad_timer_t mad_timer_abs(mad_timer_t timer)
{
@ -85,8 +85,8 @@ mad_timer_t mad_timer_abs(mad_timer_t timer)
}
/*
* NAME: reduce_timer()
* DESCRIPTION: carry timer fraction into seconds
* NAME: reduce_timer()
* DESCRIPTION: carry timer fraction into seconds
*/
static
void reduce_timer(mad_timer_t *timer)
@ -96,8 +96,8 @@ void reduce_timer(mad_timer_t *timer)
}
/*
* NAME: gcd()
* DESCRIPTION: compute greatest common denominator
* NAME: gcd()
* DESCRIPTION: compute greatest common denominator
*/
static
unsigned long gcd(unsigned long num1, unsigned long num2)
@ -114,8 +114,8 @@ unsigned long gcd(unsigned long num1, unsigned long num2)
}
/*
* NAME: reduce_rational()
* DESCRIPTION: convert rational expression to lowest terms
* NAME: reduce_rational()
* DESCRIPTION: convert rational expression to lowest terms
*/
static
void reduce_rational(unsigned long *numer, unsigned long *denom)
@ -131,12 +131,12 @@ void reduce_rational(unsigned long *numer, unsigned long *denom)
}
/*
* NAME: scale_rational()
* DESCRIPTION: solve numer/denom == ?/scale avoiding overflowing
* NAME: scale_rational()
* DESCRIPTION: solve numer/denom == ?/scale avoiding overflowing
*/
static
unsigned long scale_rational(unsigned long numer, unsigned long denom,
unsigned long scale)
unsigned long scale)
{
reduce_rational(&numer, &denom);
reduce_rational(&scale, &denom);
@ -152,11 +152,11 @@ unsigned long scale_rational(unsigned long numer, unsigned long denom,
}
/*
* NAME: timer->set()
* DESCRIPTION: set timer to specific (positive) value
* NAME: timer->set()
* DESCRIPTION: set timer to specific (positive) value
*/
void mad_timer_set(mad_timer_t *timer, unsigned long seconds,
unsigned long numer, unsigned long denom)
unsigned long numer, unsigned long denom)
{
timer->seconds = seconds;
if (numer >= denom && denom > 0) {
@ -224,8 +224,8 @@ void mad_timer_set(mad_timer_t *timer, unsigned long seconds,
}
/*
* NAME: timer->add()
* DESCRIPTION: add one timer to another
* NAME: timer->add()
* DESCRIPTION: add one timer to another
*/
void mad_timer_add(mad_timer_t *timer, mad_timer_t incr)
{
@ -237,8 +237,8 @@ void mad_timer_add(mad_timer_t *timer, mad_timer_t incr)
}
/*
* NAME: timer->multiply()
* DESCRIPTION: multiply a timer by a scalar value
* NAME: timer->multiply()
* DESCRIPTION: multiply a timer by a scalar value
*/
void mad_timer_multiply(mad_timer_t *timer, signed long scalar)
{
@ -264,8 +264,8 @@ void mad_timer_multiply(mad_timer_t *timer, signed long scalar)
}
/*
* NAME: timer->count()
* DESCRIPTION: return timer value in selected units
* NAME: timer->count()
* DESCRIPTION: return timer value in selected units
*/
signed long mad_timer_count(mad_timer_t timer, enum mad_units units)
{
@ -302,7 +302,7 @@ signed long mad_timer_count(mad_timer_t timer, enum mad_units units)
case MAD_UNITS_75_FPS:
return timer.seconds * (signed long) units +
(signed long) scale_rational(timer.fraction, MAD_TIMER_RESOLUTION,
units);
units);
case MAD_UNITS_23_976_FPS:
case MAD_UNITS_24_975_FPS:
@ -318,8 +318,8 @@ signed long mad_timer_count(mad_timer_t timer, enum mad_units units)
}
/*
* NAME: timer->fraction()
* DESCRIPTION: return fractional part of timer in arbitrary terms
* NAME: timer->fraction()
* DESCRIPTION: return fractional part of timer in arbitrary terms
*/
unsigned long mad_timer_fraction(mad_timer_t timer, unsigned long denom)
{
@ -339,12 +339,12 @@ unsigned long mad_timer_fraction(mad_timer_t timer, unsigned long denom)
}
/*
* NAME: timer->string()
* DESCRIPTION: write a string representation of a timer using a template
* NAME: timer->string()
* DESCRIPTION: write a string representation of a timer using a template
*/
void mad_timer_string(mad_timer_t timer,
char *dest, char const *format, enum mad_units units,
enum mad_units fracunits, unsigned long subparts)
char *dest, char const *format, enum mad_units units,
enum mad_units fracunits, unsigned long subparts)
{
unsigned long hours, minutes, seconds, sub;
unsigned int frac;
@ -413,7 +413,7 @@ void mad_timer_string(mad_timer_t timer,
m = frame % cycle;
frame += (10 - 1) * 2 * d;
if (m > 2)
frame += 2 * ((m - 2) / (cycle / 10));
frame += 2 * ((m - 2) / (cycle / 10));
frac = frame % -fracunits;
seconds = frame / -fracunits;
@ -427,25 +427,25 @@ void mad_timer_string(mad_timer_t timer,
hours = minutes / 60;
// sprintf(dest, format,
// hours,
// (unsigned int) (minutes % 60),
// (unsigned int) (seconds % 60),
// frac, sub);
// hours,
// (unsigned int) (minutes % 60),
// (unsigned int) (seconds % 60),
// frac, sub);
break;
case MAD_UNITS_MINUTES:
minutes = seconds / 60;
// sprintf(dest, format,
// minutes,
// (unsigned int) (seconds % 60),
// frac, sub);
// minutes,
// (unsigned int) (seconds % 60),
// frac, sub);
break;
case MAD_UNITS_SECONDS:
// sprintf(dest, format,
// seconds,
// frac, sub);
// seconds,
// frac, sub);
break;
case MAD_UNITS_23_976_FPS:

View file

@ -23,67 +23,67 @@
# define LIBMAD_TIMER_H
typedef struct {
signed long seconds; /* whole seconds */
unsigned long fraction; /* 1/MAD_TIMER_RESOLUTION seconds */
signed long seconds; /* whole seconds */
unsigned long fraction; /* 1/MAD_TIMER_RESOLUTION seconds */
} mad_timer_t;
extern mad_timer_t const mad_timer_zero;
# define MAD_TIMER_RESOLUTION 352800000UL
# define MAD_TIMER_RESOLUTION 352800000UL
enum mad_units {
MAD_UNITS_HOURS = -2,
MAD_UNITS_MINUTES = -1,
MAD_UNITS_SECONDS = 0,
MAD_UNITS_HOURS = -2,
MAD_UNITS_MINUTES = -1,
MAD_UNITS_SECONDS = 0,
/* metric units */
MAD_UNITS_DECISECONDS = 10,
MAD_UNITS_DECISECONDS = 10,
MAD_UNITS_CENTISECONDS = 100,
MAD_UNITS_MILLISECONDS = 1000,
/* audio sample units */
MAD_UNITS_8000_HZ = 8000,
MAD_UNITS_11025_HZ = 11025,
MAD_UNITS_12000_HZ = 12000,
MAD_UNITS_8000_HZ = 8000,
MAD_UNITS_11025_HZ = 11025,
MAD_UNITS_12000_HZ = 12000,
MAD_UNITS_16000_HZ = 16000,
MAD_UNITS_22050_HZ = 22050,
MAD_UNITS_24000_HZ = 24000,
MAD_UNITS_16000_HZ = 16000,
MAD_UNITS_22050_HZ = 22050,
MAD_UNITS_24000_HZ = 24000,
MAD_UNITS_32000_HZ = 32000,
MAD_UNITS_44100_HZ = 44100,
MAD_UNITS_48000_HZ = 48000,
MAD_UNITS_32000_HZ = 32000,
MAD_UNITS_44100_HZ = 44100,
MAD_UNITS_48000_HZ = 48000,
/* video frame/field units */
MAD_UNITS_24_FPS = 24,
MAD_UNITS_25_FPS = 25,
MAD_UNITS_30_FPS = 30,
MAD_UNITS_48_FPS = 48,
MAD_UNITS_50_FPS = 50,
MAD_UNITS_60_FPS = 60,
MAD_UNITS_24_FPS = 24,
MAD_UNITS_25_FPS = 25,
MAD_UNITS_30_FPS = 30,
MAD_UNITS_48_FPS = 48,
MAD_UNITS_50_FPS = 50,
MAD_UNITS_60_FPS = 60,
/* CD audio frames */
MAD_UNITS_75_FPS = 75,
MAD_UNITS_75_FPS = 75,
/* video drop-frame units */
MAD_UNITS_23_976_FPS = -24,
MAD_UNITS_24_975_FPS = -25,
MAD_UNITS_29_97_FPS = -30,
MAD_UNITS_47_952_FPS = -48,
MAD_UNITS_49_95_FPS = -50,
MAD_UNITS_59_94_FPS = -60
MAD_UNITS_23_976_FPS = -24,
MAD_UNITS_24_975_FPS = -25,
MAD_UNITS_29_97_FPS = -30,
MAD_UNITS_47_952_FPS = -48,
MAD_UNITS_49_95_FPS = -50,
MAD_UNITS_59_94_FPS = -60
};
# define mad_timer_reset(timer) ((void) (*(timer) = mad_timer_zero))
# define mad_timer_reset(timer) ((void) (*(timer) = mad_timer_zero))
int mad_timer_compare(mad_timer_t, mad_timer_t);
# define mad_timer_sign(timer) mad_timer_compare((timer), mad_timer_zero)
# define mad_timer_sign(timer) mad_timer_compare((timer), mad_timer_zero)
void mad_timer_negate(mad_timer_t *);
mad_timer_t mad_timer_abs(mad_timer_t);
@ -95,6 +95,6 @@ void mad_timer_multiply(mad_timer_t *, signed long);
signed long mad_timer_count(mad_timer_t, enum mad_units);
unsigned long mad_timer_fraction(mad_timer_t, unsigned long);
void mad_timer_string(mad_timer_t, char *, char const *,
enum mad_units, enum mad_units, unsigned long);
enum mad_units, enum mad_units, unsigned long);
# endif

View file

@ -22,22 +22,22 @@
# ifndef LIBMAD_VERSION_H
# define LIBMAD_VERSION_H
# define MAD_VERSION_MAJOR 0
# define MAD_VERSION_MINOR 15
# define MAD_VERSION_PATCH 1
# define MAD_VERSION_EXTRA " (beta)"
# define MAD_VERSION_MAJOR 0
# define MAD_VERSION_MINOR 15
# define MAD_VERSION_PATCH 1
# define MAD_VERSION_EXTRA " (beta)"
# define MAD_VERSION_STRINGIZE(str) #str
# define MAD_VERSION_STRING(num) MAD_VERSION_STRINGIZE(num)
# define MAD_VERSION_STRINGIZE(str) #str
# define MAD_VERSION_STRING(num) MAD_VERSION_STRINGIZE(num)
# define MAD_VERSION MAD_VERSION_STRING(MAD_VERSION_MAJOR) "." \
MAD_VERSION_STRING(MAD_VERSION_MINOR) "." \
MAD_VERSION_STRING(MAD_VERSION_PATCH) \
MAD_VERSION_EXTRA
# define MAD_VERSION MAD_VERSION_STRING(MAD_VERSION_MAJOR) "." \
MAD_VERSION_STRING(MAD_VERSION_MINOR) "." \
MAD_VERSION_STRING(MAD_VERSION_PATCH) \
MAD_VERSION_EXTRA
# define MAD_PUBLISHYEAR "2000-2004"
# define MAD_AUTHOR "Underbit Technologies, Inc."
# define MAD_EMAIL "info@underbit.com"
# define MAD_PUBLISHYEAR "2000-2004"
# define MAD_AUTHOR "Underbit Technologies, Inc."
# define MAD_EMAIL "info@underbit.com"
extern char const mad_version[];
extern char const mad_copyright[];

View file

@ -430,7 +430,7 @@ int real_parse_header(int fd, RMContext *rmctx)
read_uint32be(fd,&next_data_off);
skipped += 4;
if (!rmctx->nb_packets && (rmctx->flags & 4))
rmctx->nb_packets = 3600 * 25;
rmctx->nb_packets = 3600 * 25;
/***
* nb_packets correction :
@ -444,7 +444,7 @@ int real_parse_header(int fd, RMContext *rmctx)
DEBUGF(" data_nb_packets = %d\n",rmctx->nb_packets);
DEBUGF(" next DATA offset = %d\n",next_data_off);
header_end = 1;
header_end = 1;
break;
}
if(header_end) break;

View file

@ -60,8 +60,8 @@ struct kiss_fft_state{
#if defined(CHECK_OVERFLOW)
# define CHECK_OVERFLOW_OP(a,op,b) \
if ( (SAMPPROD)(a) op (SAMPPROD)(b) > SAMP_MAX || (SAMPPROD)(a) op (SAMPPROD)(b) < SAMP_MIN ) { \
fprintf(stderr,"WARNING:overflow @ " __FILE__ "(%d): (%d " #op" %d) = %ld\n",__LINE__,(a),(b),(SAMPPROD)(a) op (SAMPPROD)(b) ); }
if ( (SAMPPROD)(a) op (SAMPPROD)(b) > SAMP_MAX || (SAMPPROD)(a) op (SAMPPROD)(b) < SAMP_MIN ) { \
fprintf(stderr,"WARNING:overflow @ " __FILE__ "(%d): (%d " #op" %d) = %ld\n",__LINE__,(a),(b),(SAMPPROD)(a) op (SAMPPROD)(b) ); }
#endif
@ -79,11 +79,11 @@ struct kiss_fft_state{
(m).i = PSHR32( smul((a).r,(b).i) + smul((a).i,(b).r),17 ); }while(0)
# define DIVSCALAR(x,k) \
(x) = sround( smul( x, SAMP_MAX/k ) )
(x) = sround( smul( x, SAMP_MAX/k ) )
# define C_FIXDIV(c,div) \
do { DIVSCALAR( (c).r , div); \
DIVSCALAR( (c).i , div); }while (0)
do { DIVSCALAR( (c).r , div); \
DIVSCALAR( (c).i , div); }while (0)
# define C_MULBYSCALAR( c, s ) \
do{ (c).r = sround( smul( (c).r , s ) ) ;\
@ -110,28 +110,28 @@ struct kiss_fft_state{
#define C_ADD( res, a,b)\
do { \
CHECK_OVERFLOW_OP((a).r,+,(b).r)\
CHECK_OVERFLOW_OP((a).i,+,(b).i)\
(res).r=(a).r+(b).r; (res).i=(a).i+(b).i; \
CHECK_OVERFLOW_OP((a).r,+,(b).r)\
CHECK_OVERFLOW_OP((a).i,+,(b).i)\
(res).r=(a).r+(b).r; (res).i=(a).i+(b).i; \
}while(0)
#define C_SUB( res, a,b)\
do { \
CHECK_OVERFLOW_OP((a).r,-,(b).r)\
CHECK_OVERFLOW_OP((a).i,-,(b).i)\
(res).r=(a).r-(b).r; (res).i=(a).i-(b).i; \
CHECK_OVERFLOW_OP((a).r,-,(b).r)\
CHECK_OVERFLOW_OP((a).i,-,(b).i)\
(res).r=(a).r-(b).r; (res).i=(a).i-(b).i; \
}while(0)
#define C_ADDTO( res , a)\
do { \
CHECK_OVERFLOW_OP((res).r,+,(a).r)\
CHECK_OVERFLOW_OP((res).i,+,(a).i)\
(res).r += (a).r; (res).i += (a).i;\
CHECK_OVERFLOW_OP((res).r,+,(a).r)\
CHECK_OVERFLOW_OP((res).i,+,(a).i)\
(res).r += (a).r; (res).i += (a).i;\
}while(0)
#define C_SUBFROM( res , a)\
do {\
CHECK_OVERFLOW_OP((res).r,-,(a).r)\
CHECK_OVERFLOW_OP((res).i,-,(a).i)\
(res).r -= (a).r; (res).i -= (a).i; \
CHECK_OVERFLOW_OP((res).r,-,(a).r)\
CHECK_OVERFLOW_OP((res).i,-,(a).i)\
(res).r -= (a).r; (res).i -= (a).i; \
}while(0)
@ -150,10 +150,10 @@ struct kiss_fft_state{
#endif
#define kf_cexp(x,phase) \
do{ \
(x)->r = KISS_FFT_COS(phase);\
(x)->i = KISS_FFT_SIN(phase);\
}while(0)
do{ \
(x)->r = KISS_FFT_COS(phase);\
(x)->i = KISS_FFT_SIN(phase);\
}while(0)
#define kf_cexp2(x,phase) \
do{ \
(x)->r = spx_cos_norm((phase));\

View file

@ -99,10 +99,10 @@ static inline void target_update(spx_word16_t *t, spx_word16_t g, spx_word16_t *
static void split_cb_search_shape_sign_N1(
spx_word16_t target[], /* target vector */
spx_coef_t ak[], /* LPCs for this subframe */
spx_coef_t awk1[], /* Weighted LPCs for this subframe */
spx_coef_t awk2[], /* Weighted LPCs for this subframe */
spx_word16_t target[], /* target vector */
spx_coef_t ak[], /* LPCs for this subframe */
spx_coef_t awk1[], /* Weighted LPCs for this subframe */
spx_coef_t awk2[], /* Weighted LPCs for this subframe */
const void *par, /* Codebook/search parameters*/
int p, /* number of LPC coeffs */
int nsf, /* number of samples in subframe */
@ -241,10 +241,10 @@ int update_target
void split_cb_search_shape_sign(
spx_word16_t target[], /* target vector */
spx_coef_t ak[], /* LPCs for this subframe */
spx_coef_t awk1[], /* Weighted LPCs for this subframe */
spx_coef_t awk2[], /* Weighted LPCs for this subframe */
spx_word16_t target[], /* target vector */
spx_coef_t ak[], /* LPCs for this subframe */
spx_coef_t awk1[], /* Weighted LPCs for this subframe */
spx_coef_t awk2[], /* Weighted LPCs for this subframe */
const void *par, /* Codebook/search parameters*/
int p, /* number of LPC coeffs */
int nsf, /* number of samples in subframe */
@ -576,10 +576,10 @@ spx_int32_t *seed
#ifndef SPEEX_DISABLE_ENCODER
void noise_codebook_quant(
spx_word16_t target[], /* target vector */
spx_coef_t ak[], /* LPCs for this subframe */
spx_coef_t awk1[], /* Weighted LPCs for this subframe */
spx_coef_t awk2[], /* Weighted LPCs for this subframe */
spx_word16_t target[], /* target vector */
spx_coef_t ak[], /* LPCs for this subframe */
spx_coef_t awk1[], /* Weighted LPCs for this subframe */
spx_coef_t awk2[], /* Weighted LPCs for this subframe */
const void *par, /* Codebook/search parameters*/
int p, /* number of LPC coeffs */
int nsf, /* number of samples in subframe */

View file

@ -184,7 +184,7 @@ static void kf_bfly3(
do{
if (!st->inverse) {
C_FIXDIV(*Fout,3); C_FIXDIV(Fout[m],3); C_FIXDIV(Fout[m2],3);
}
}
C_MUL(scratch[1],Fout[m] , *tw1);
C_MUL(scratch[2],Fout[m2] , *tw2);
@ -237,7 +237,7 @@ static void kf_bfly5(
for ( u=0; u<m; ++u ) {
if (!st->inverse) {
C_FIXDIV( *Fout0,5); C_FIXDIV( *Fout1,5); C_FIXDIV( *Fout2,5); C_FIXDIV( *Fout3,5); C_FIXDIV( *Fout4,5);
}
}
scratch[0] = *Fout0;
C_MUL(scratch[1] ,*Fout1, tw[u*fstride]);
@ -299,7 +299,7 @@ static void kf_bfly_generic(
scratchbuf[q1] = Fout[ k ];
if (!st->inverse) {
C_FIXDIV(scratchbuf[q1],p);
}
}
k += m;
}

View file

@ -26,13 +26,13 @@ extern "C" {
# include <xmmintrin.h>
# define kiss_fft_scalar __m128
#define KISS_FFT_MALLOC(nbytes) memalign(16,nbytes)
#else
#else
#define KISS_FFT_MALLOC speex_alloc
#endif
#endif
#ifdef FIXED_POINT
#include "arch.h"
#include "arch.h"
# define kiss_fft_scalar spx_int16_t
#else
# ifndef kiss_fft_scalar
@ -99,7 +99,7 @@ void kiss_fft_stride(kiss_fft_cfg cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout
your compiler output to call this before you exit.
*/
void kiss_fft_cleanup(void);
#ifdef __cplusplus
}

View file

@ -1,8 +1,8 @@
/*---------------------------------------------------------------------------*\
Original copyright
FILE........: lsp.c
AUTHOR......: David Rowe
DATE CREATED: 24/2/93
FILE........: lsp.c
AUTHOR......: David Rowe
DATE CREATED: 24/2/93
Heavily modified by Jean-Marc Valin (c) 2002-2006 (fixed-point,
optimizations, additional functions, ...)
@ -219,31 +219,31 @@ static float cheb_poly_eva(spx_word32_t *coef, spx_word16_t x, int m, char *stac
int lpc_to_lsp (spx_coef_t *a,int lpcrdr,spx_lsp_t *freq,int nb,spx_word16_t delta, char *stack)
/* float *a lpc coefficients */
/* int lpcrdr order of LPC coefficients (10) */
/* float *freq LSP frequencies in the x domain */
/* int nb number of sub-intervals (4) */
/* float delta grid spacing interval (0.02) */
/* float *a lpc coefficients */
/* int lpcrdr order of LPC coefficients (10) */
/* float *freq LSP frequencies in the x domain */
/* int nb number of sub-intervals (4) */
/* float delta grid spacing interval (0.02) */
{
spx_word16_t temp_xr,xl,xr,xm=0;
spx_word32_t psuml,psumr,psumm,temp_psumr/*,temp_qsumr*/;
int i,j,m,flag,k;
VARDECL(spx_word32_t *Q); /* ptrs for memory allocation */
VARDECL(spx_word32_t *Q); /* ptrs for memory allocation */
VARDECL(spx_word32_t *P);
VARDECL(spx_word16_t *Q16); /* ptrs for memory allocation */
VARDECL(spx_word16_t *Q16); /* ptrs for memory allocation */
VARDECL(spx_word16_t *P16);
spx_word32_t *px; /* ptrs of respective P'(z) & Q'(z) */
spx_word32_t *px; /* ptrs of respective P'(z) & Q'(z) */
spx_word32_t *qx;
spx_word32_t *p;
spx_word32_t *q;
spx_word16_t *pt; /* ptr used for cheb_poly_eval()
whether P' or Q' */
int roots=0; /* DR 8/2/94: number of roots found */
flag = 1; /* program is searching for a root when,
1 else has found one */
m = lpcrdr/2; /* order of P'(z) & Q'(z) polynomials */
spx_word16_t *pt; /* ptr used for cheb_poly_eval()
whether P' or Q' */
int roots=0; /* DR 8/2/94: number of roots found */
flag = 1; /* program is searching for a root when,
1 else has found one */
m = lpcrdr/2; /* order of P'(z) & Q'(z) polynomials */
/* Allocate memory space for polynomials */
ALLOC(Q, (m+1), spx_word32_t);
@ -252,7 +252,7 @@ int lpc_to_lsp (spx_coef_t *a,int lpcrdr,spx_lsp_t *freq,int nb,spx_word16_t del
/* determine P'(z)'s and Q'(z)'s coefficients where
P'(z) = P(z)/(1 + z^(-1)) and Q'(z) = Q(z)/(1-z^(-1)) */
px = P; /* initialise ptrs */
px = P; /* initialise ptrs */
qx = Q;
p = px;
q = qx;
@ -297,7 +297,7 @@ int lpc_to_lsp (spx_coef_t *a,int lpcrdr,spx_lsp_t *freq,int nb,spx_word16_t del
}
#endif
px = P; /* re-initialise ptrs */
px = P; /* re-initialise ptrs */
qx = Q;
/* now that we have computed P and Q convert to 16 bits to
@ -313,20 +313,20 @@ int lpc_to_lsp (spx_coef_t *a,int lpcrdr,spx_lsp_t *freq,int nb,spx_word16_t del
}
/* Search for a zero in P'(z) polynomial first and then alternate to Q'(z).
Keep alternating between the two polynomials as each zero is found */
Keep alternating between the two polynomials as each zero is found */
xr = 0; /* initialise xr to zero */
xl = FREQ_SCALE; /* start at point xl = 1 */
xr = 0; /* initialise xr to zero */
xl = FREQ_SCALE; /* start at point xl = 1 */
for(j=0;j<lpcrdr;j++){
if(j&1) /* determines whether P' or Q' is eval. */
pt = Q16;
else
pt = P16;
if(j&1) /* determines whether P' or Q' is eval. */
pt = Q16;
else
pt = P16;
psuml = cheb_poly_eva(pt,xl,m,stack); /* evals poly. at xl */
flag = 1;
while(flag && (xr >= -FREQ_SCALE)){
psuml = cheb_poly_eva(pt,xl,m,stack); /* evals poly. at xl */
flag = 1;
while(flag && (xr >= -FREQ_SCALE)){
spx_word16_t dd;
/* Modified by JMV to provide smaller steps around x=+-1 */
#ifdef FIXED_POINT
@ -338,10 +338,10 @@ int lpc_to_lsp (spx_coef_t *a,int lpcrdr,spx_lsp_t *freq,int nb,spx_word16_t del
if (fabs(psuml)<.2)
dd *= .5;
#endif
xr = SUB16(xl, dd); /* interval spacing */
psumr = cheb_poly_eva(pt,xr,m,stack);/* poly(xl-delta_x) */
temp_psumr = psumr;
temp_xr = xr;
xr = SUB16(xl, dd); /* interval spacing */
psumr = cheb_poly_eva(pt,xr,m,stack);/* poly(xl-delta_x) */
temp_psumr = psumr;
temp_xr = xr;
/* if no sign change increment xr and re-evaluate poly(xr). Repeat til
sign change.
@ -350,41 +350,41 @@ int lpc_to_lsp (spx_coef_t *a,int lpcrdr,spx_lsp_t *freq,int nb,spx_word16_t del
interval the zero lies in.
If there is no sign change between poly(xm) and poly(xl) set interval
between xm and xr else set interval between xl and xr and repeat till
root is located within the specified limits */
root is located within the specified limits */
if(SIGN_CHANGE(psumr,psuml))
if(SIGN_CHANGE(psumr,psuml))
{
roots++;
roots++;
psumm=psuml;
for(k=0;k<=nb;k++){
psumm=psuml;
for(k=0;k<=nb;k++){
#ifdef FIXED_POINT
xm = ADD16(PSHR16(xl,1),PSHR16(xr,1)); /* bisect the interval */
xm = ADD16(PSHR16(xl,1),PSHR16(xr,1)); /* bisect the interval */
#else
xm = .5*(xl+xr); /* bisect the interval */
xm = .5*(xl+xr); /* bisect the interval */
#endif
psumm=cheb_poly_eva(pt,xm,m,stack);
/*if(psumm*psuml>0.)*/
if(!SIGN_CHANGE(psumm,psuml))
psumm=cheb_poly_eva(pt,xm,m,stack);
/*if(psumm*psuml>0.)*/
if(!SIGN_CHANGE(psumm,psuml))
{
psuml=psumm;
xl=xm;
} else {
psumr=psumm;
xr=xm;
}
}
psuml=psumm;
xl=xm;
} else {
psumr=psumm;
xr=xm;
}
}
/* once zero is found, reset initial interval to xr */
freq[j] = X2ANGLE(xm);
xl = xm;
flag = 0; /* reset flag for next search */
}
else{
psuml=temp_psumr;
xl=temp_xr;
}
}
/* once zero is found, reset initial interval to xr */
freq[j] = X2ANGLE(xm);
xl = xm;
flag = 0; /* reset flag for next search */
}
else{
psuml=temp_psumr;
xl=temp_xr;
}
}
}
return(roots);
}
@ -393,10 +393,10 @@ int lpc_to_lsp (spx_coef_t *a,int lpcrdr,spx_lsp_t *freq,int nb,spx_word16_t del
/*---------------------------------------------------------------------------*\
FUNCTION....: lsp_to_lpc()
FUNCTION....: lsp_to_lpc()
AUTHOR......: David Rowe
DATE CREATED: 24/2/93
AUTHOR......: David Rowe
DATE CREATED: 24/2/93
Converts LSP coefficients to LPC coefficients.
@ -405,9 +405,9 @@ int lpc_to_lsp (spx_coef_t *a,int lpcrdr,spx_lsp_t *freq,int nb,spx_word16_t del
#ifdef FIXED_POINT
void lsp_to_lpc(spx_lsp_t *freq,spx_coef_t *ak,int lpcrdr, char *stack)
/* float *freq array of LSP frequencies in the x domain */
/* float *ak array of LPC coefficients */
/* int lpcrdr order of LPC coefficients */
/* float *freq array of LSP frequencies in the x domain */
/* float *ak array of LPC coefficients */
/* int lpcrdr order of LPC coefficients */
{
(void)stack;
int i,j;
@ -488,10 +488,10 @@ void lsp_to_lpc(spx_lsp_t *freq,spx_coef_t *ak,int lpcrdr, char *stack)
for(i=1;i<m;i++) {
for(j=1;j<2*(i+1)-1;j++) {
mult = MULT16_32_Q14(freqn[2*i],xp[i][j+1]);
xp[i+1][j+2] = ADD32(SUB32(xp[i][j+2], mult), xp[i][j]);
mult = MULT16_32_Q14(freqn[2*i+1],xq[i][j+1]);
xq[i+1][j+2] = ADD32(SUB32(xq[i][j+2], mult), xq[i][j]);
mult = MULT16_32_Q14(freqn[2*i],xp[i][j+1]);
xp[i+1][j+2] = ADD32(SUB32(xp[i][j+2], mult), xp[i][j]);
mult = MULT16_32_Q14(freqn[2*i+1],xq[i][j+1]);
xq[i+1][j+2] = ADD32(SUB32(xq[i][j+2], mult), xq[i][j]);
}
/* for last col xp[i][j+2] = xq[i][j+2] = 0 */
@ -525,9 +525,9 @@ void lsp_to_lpc(spx_lsp_t *freq,spx_coef_t *ak,int lpcrdr, char *stack)
#else
void lsp_to_lpc(spx_lsp_t *freq,spx_coef_t *ak,int lpcrdr, char *stack)
/* float *freq array of LSP frequencies in the x domain */
/* float *ak array of LPC coefficients */
/* int lpcrdr order of LPC coefficients */
/* float *freq array of LSP frequencies in the x domain */
/* float *ak array of LPC coefficients */
/* int lpcrdr order of LPC coefficients */
{
@ -543,8 +543,8 @@ void lsp_to_lpc(spx_lsp_t *freq,spx_coef_t *ak,int lpcrdr, char *stack)
/* initialise contents of array */
for(i=0;i<=4*m+1;i++){ /* set contents of buffer to 0 */
*pw++ = 0.0;
for(i=0;i<=4*m+1;i++){ /* set contents of buffer to 0 */
*pw++ = 0.0;
}
/* Set pointers up */
@ -563,29 +563,29 @@ void lsp_to_lpc(spx_lsp_t *freq,spx_coef_t *ak,int lpcrdr, char *stack)
for(j=0;j<=lpcrdr;j++){
int i2=0;
for(i=0;i<m;i++,i2+=2){
n1 = pw+(i*4);
n2 = n1 + 1;
n3 = n2 + 1;
n4 = n3 + 1;
xout1 = xin1 - 2.f*x_freq[i2] * *n1 + *n2;
xout2 = xin2 - 2.f*x_freq[i2+1] * *n3 + *n4;
*n2 = *n1;
*n4 = *n3;
*n1 = xin1;
*n3 = xin2;
xin1 = xout1;
xin2 = xout2;
}
xout1 = xin1 + *(n4+1);
xout2 = xin2 - *(n4+2);
if (j>0)
ak[j-1] = (xout1 + xout2)*0.5f;
*(n4+1) = xin1;
*(n4+2) = xin2;
for(i=0;i<m;i++,i2+=2){
n1 = pw+(i*4);
n2 = n1 + 1;
n3 = n2 + 1;
n4 = n3 + 1;
xout1 = xin1 - 2.f*x_freq[i2] * *n1 + *n2;
xout2 = xin2 - 2.f*x_freq[i2+1] * *n3 + *n4;
*n2 = *n1;
*n4 = *n3;
*n1 = xin1;
*n3 = xin2;
xin1 = xout1;
xin2 = xout2;
}
xout1 = xin1 + *(n4+1);
xout2 = xin2 - *(n4+2);
if (j>0)
ak[j-1] = (xout1 + xout2)*0.5f;
*(n4+1) = xin1;
*(n4+2) = xin2;
xin1 = 0.0;
xin2 = 0.0;
xin1 = 0.0;
xin2 = 0.0;
}
}

View file

@ -1,10 +1,10 @@
/*---------------------------------------------------------------------------*\
Original Copyright
FILE........: AK2LSPD.H
TYPE........: Turbo C header file
COMPANY.....: Voicetronix
AUTHOR......: James Whitehall
DATE CREATED: 21/11/95
FILE........: AK2LSPD.H
TYPE........: Turbo C header file
COMPANY.....: Voicetronix
AUTHOR......: James Whitehall
DATE CREATED: 21/11/95
Modified by Jean-Marc Valin
@ -61,4 +61,4 @@ void lsp_enforce_margin(spx_lsp_t *lsp, int len, spx_word16_t margin);
void lsp_interpolate(spx_lsp_t *old_lsp, spx_lsp_t *new_lsp, spx_lsp_t *interp_lsp, int len, int subframe, int nb_subframes);
#endif /* __AK2LSPD__ */
#endif /* __AK2LSPD__ */

View file

@ -220,7 +220,7 @@ void open_loop_nbest_pitch(spx_word16_t *sw, int start, int end, int len, int *p
normalize16(energy, ener16, 180, end-start+1);
if (N == 1) {
/* optimised asm to handle N==1 case */
/* optimised asm to handle N==1 case */
__asm__ __volatile__
(
" I0 = %1;\n\t" /* I0: corr16[] */
@ -253,35 +253,35 @@ void open_loop_nbest_pitch(spx_word16_t *sw, int start, int end, int len, int *p
}
else {
for (i=start;i<=end;i++)
{
spx_word16_t tmp = MULT16_16_16(corr16[i-start],corr16[i-start]);
/* Instead of dividing the tmp by the energy, we multiply on the other side */
if (MULT16_16(tmp,best_ener[N-1])>MULT16_16(best_score[N-1],ADD16(1,ener16[i-start])))
{
/* We can safely put it last and then check */
best_score[N-1]=tmp;
best_ener[N-1]=ener16[i-start]+1;
pitch[N-1]=i;
/* Check if it comes in front of others */
for (j=0;j<N-1;j++)
{
if (MULT16_16(tmp,best_ener[j])>MULT16_16(best_score[j],ADD16(1,ener16[i-start])))
{
for (k=N-1;k>j;k--)
{
best_score[k]=best_score[k-1];
best_ener[k]=best_ener[k-1];
pitch[k]=pitch[k-1];
}
best_score[j]=tmp;
best_ener[j]=ener16[i-start]+1;
pitch[j]=i;
break;
}
}
}
}
for (i=start;i<=end;i++)
{
spx_word16_t tmp = MULT16_16_16(corr16[i-start],corr16[i-start]);
/* Instead of dividing the tmp by the energy, we multiply on the other side */
if (MULT16_16(tmp,best_ener[N-1])>MULT16_16(best_score[N-1],ADD16(1,ener16[i-start])))
{
/* We can safely put it last and then check */
best_score[N-1]=tmp;
best_ener[N-1]=ener16[i-start]+1;
pitch[N-1]=i;
/* Check if it comes in front of others */
for (j=0;j<N-1;j++)
{
if (MULT16_16(tmp,best_ener[j])>MULT16_16(best_score[j],ADD16(1,ener16[i-start])))
{
for (k=N-1;k>j;k--)
{
best_score[k]=best_score[k-1];
best_ener[k]=best_ener[k-1];
pitch[k]=pitch[k-1];
}
best_score[j]=tmp;
best_ener[j]=ener16[i-start]+1;
pitch[j]=i;
break;
}
}
}
}
}
}

View file

@ -1019,7 +1019,7 @@ void nb_decoder_destroy(void *state)
*/
}
#define median3(a, b, c) ((a) < (b) ? ((b) < (c) ? (b) : ((a) < (c) ? (c) : (a))) : ((c) < (b) ? (b) : ((c) < (a) ? (c) : (a))))
#define median3(a, b, c) ((a) < (b) ? ((b) < (c) ? (b) : ((a) < (c) ? (c) : (a))) : ((c) < (b) ? (b) : ((c) < (a) ? (c) : (a))))
#ifdef FIXED_POINT
const spx_word16_t attenuation[10] = {32767, 31483, 27923, 22861, 17278, 12055, 7764, 4616, 2533, 1283};
@ -1353,10 +1353,10 @@ int nb_decode(void *state, SpeexBits *bits, void *vout)
*/
pit_min = ol_pitch-margin+1;
if (pit_min < st->min_pitch)
pit_min = st->min_pitch;
pit_min = st->min_pitch;
pit_max = ol_pitch+margin;
if (pit_max > st->max_pitch)
pit_max = st->max_pitch;
pit_max = st->max_pitch;
} else {
pit_min = pit_max = ol_pitch;
}

View file

@ -58,16 +58,16 @@ spx_ogg_int64_t spx_ogg_page_granulepos(spx_ogg_page *og){
int spx_ogg_page_serialno(spx_ogg_page *og){
return(og->header[14] |
(og->header[15]<<8) |
(og->header[16]<<16) |
(og->header[17]<<24));
(og->header[15]<<8) |
(og->header[16]<<16) |
(og->header[17]<<24));
}
long spx_ogg_page_pageno(spx_ogg_page *og){
return(og->header[18] |
(og->header[19]<<8) |
(og->header[20]<<16) |
(og->header[21]<<24));
(og->header[19]<<8) |
(og->header[20]<<16) |
(og->header[21]<<24));
}
@ -109,9 +109,9 @@ static spx_ogg_uint32_t _spx_ogg_crc_entry(unsigned long index){
for (i=0; i<8; i++)
if (r & 0x80000000UL)
r = (r << 1) ^ 0x04c11db7; /* The same as the ethernet generator
polynomial, although we use an
unreflected alg and an init/final
of 0, not 0xffffffff */
polynomial, although we use an
unreflected alg and an init/final
of 0, not 0xffffffff */
else
r<<=1;
return (r & 0xffffffffUL);
@ -280,7 +280,7 @@ int spx_ogg_stream_packetin(spx_ogg_stream_state *os,spx_ogg_packet *op){
os->body_fill-=os->body_returned;
if(os->body_fill)
memmove(os->body_data,os->body_data+os->body_returned,
os->body_fill);
os->body_fill);
os->body_returned=0;
}
@ -350,8 +350,8 @@ int spx_ogg_stream_flush(spx_ogg_stream_state *os,spx_ogg_page *og){
granule_pos=0;
for(vals=0;vals<maxvals;vals++){
if((os->lacing_vals[vals]&0x0ff)<255){
vals++;
break;
vals++;
break;
}
}
}else{
@ -396,10 +396,10 @@ int spx_ogg_stream_flush(spx_ogg_stream_state *os,spx_ogg_page *og){
/* 32 bits of page counter (we have both counter and page header
because this val can roll over) */
if(os->pageno==-1)os->pageno=0; /* because someone called
stream_reset; this would be a
strange thing to do in an
encode stream, but it has
plausible uses */
stream_reset; this would be a
strange thing to do in an
encode stream, but it has
plausible uses */
{
long pageno=os->pageno++;
for(i=18;i<22;i++){
@ -595,7 +595,7 @@ long spx_ogg_sync_pageseek(spx_ogg_sync_state *oy,spx_ogg_page *og){
/* Compare */
if(memcmp(chksum,page+22,4)){
/* D'oh. Mismatch! Corrupt page (or miscapture and not a page
at all) */
at all) */
/* replace the computed checksum with the one actually read in */
memcpy(page+22,chksum,4);
@ -703,17 +703,17 @@ int spx_ogg_stream_pagein(spx_ogg_stream_state *os, spx_ogg_page *og){
if(br){
os->body_fill-=br;
if(os->body_fill)
memmove(os->body_data,os->body_data+br,os->body_fill);
memmove(os->body_data,os->body_data+br,os->body_fill);
os->body_returned=0;
}
if(lr){
/* segment table */
if(os->lacing_fill-lr){
memmove(os->lacing_vals,os->lacing_vals+lr,
(os->lacing_fill-lr)*sizeof(*os->lacing_vals));
memmove(os->granule_vals,os->granule_vals+lr,
(os->lacing_fill-lr)*sizeof(*os->granule_vals));
memmove(os->lacing_vals,os->lacing_vals+lr,
(os->lacing_fill-lr)*sizeof(*os->lacing_vals));
memmove(os->granule_vals,os->granule_vals+lr,
(os->lacing_fill-lr)*sizeof(*os->granule_vals));
}
os->lacing_fill-=lr;
os->lacing_packet-=lr;
@ -750,13 +750,13 @@ int spx_ogg_stream_pagein(spx_ogg_stream_state *os, spx_ogg_page *og){
os->lacing_vals[os->lacing_fill-1]==0x400){
bos=0;
for(;segptr<segments;segptr++){
int val=header[27+segptr];
body+=val;
bodysize-=val;
if(val<255){
segptr++;
break;
}
int val=header[27+segptr];
body+=val;
bodysize-=val;
if(val<255){
segptr++;
break;
}
}
}
}
@ -775,8 +775,8 @@ int spx_ogg_stream_pagein(spx_ogg_stream_state *os, spx_ogg_page *og){
os->granule_vals[os->lacing_fill]=-1;
if(bos){
os->lacing_vals[os->lacing_fill]|=0x100;
bos=0;
os->lacing_vals[os->lacing_fill]|=0x100;
bos=0;
}
if(val<255)saved=os->lacing_fill;

View file

@ -55,9 +55,9 @@ static int lsp_quant(
__asm__ __volatile__
(
" %0 = 1 (X);\n\t" /* %0: best_dist */
" %0 <<= 30;\n\t"
" %1 = 0 (X);\n\t" /* %1: best_i */
" %0 = 1 (X);\n\t" /* %0: best_dist */
" %0 <<= 30;\n\t"
" %1 = 0 (X);\n\t" /* %1: best_i */
" P2 = %3\n\t" /* P2: ptr to cdbk */
" R5 = 0;\n\t" /* R5: best cb entry */
@ -68,18 +68,18 @@ static int lsp_quant(
" B0 = %2;\n\t"
" R2.L = W [I0++];\n\t"
" LSETUP (lq1, lq2) LC0 = %4;\n\t"
"lq1: R3 = 0;\n\t" /* R3: dist */
" LSETUP (lq3, lq4) LC1 = %5;\n\t"
" LSETUP (lq1, lq2) LC0 = %4;\n\t"
"lq1: R3 = 0;\n\t" /* R3: dist */
" LSETUP (lq3, lq4) LC1 = %5;\n\t"
"lq3: R1 = B [P2++] (X);\n\t"
" R1 <<= 5;\n\t"
" R0.L = R2.L - R1.L || R2.L = W [I0++];\n\t"
" R0 = R0.L*R0.L;\n\t"
"lq4: R3 = R3 + R0;\n\t"
" R1 <<= 5;\n\t"
" R0.L = R2.L - R1.L || R2.L = W [I0++];\n\t"
" R0 = R0.L*R0.L;\n\t"
"lq4: R3 = R3 + R0;\n\t"
" cc =R3<%0;\n\t"
" if cc %0=R3;\n\t"
" if cc %1=R5;\n\t"
" cc =R3<%0;\n\t"
" if cc %0=R3;\n\t"
" if cc %1=R5;\n\t"
"lq2: R5 += 1;\n\t"
" L0 = 0;\n\t"
: "=&d" (best_dist), "=&d" (best_id)
@ -117,9 +117,9 @@ static int lsp_weight_quant(
__asm__ __volatile__
(
" %0 = 1 (X);\n\t" /* %0: best_dist */
" %0 <<= 30;\n\t"
" %1 = 0 (X);\n\t" /* %1: best_i */
" %0 = 1 (X);\n\t" /* %0: best_dist */
" %0 <<= 30;\n\t"
" %1 = 0 (X);\n\t" /* %1: best_i */
" P2 = %4\n\t" /* P2: ptr to cdbk */
" R5 = 0;\n\t" /* R5: best cb entry */
@ -128,26 +128,26 @@ static int lsp_weight_quant(
" L0 = R0;\n\t"
" L1 = R0;\n\t"
" I0 = %2;\n\t" /* %2: &x[0] */
" I1 = %3;\n\t" /* %3: &weight[0] */
" I1 = %3;\n\t" /* %3: &weight[0] */
" B0 = %2;\n\t"
" B1 = %3;\n\t"
" B1 = %3;\n\t"
" LSETUP (lwq1, lwq2) LC0 = %5;\n\t"
"lwq1: R3 = 0 (X);\n\t" /* R3: dist */
" LSETUP (lwq3, lwq4) LC1 = %6;\n\t"
"lwq3: R0.L = W [I0++] || R2.L = W [I1++];\n\t"
" LSETUP (lwq1, lwq2) LC0 = %5;\n\t"
"lwq1: R3 = 0 (X);\n\t" /* R3: dist */
" LSETUP (lwq3, lwq4) LC1 = %6;\n\t"
"lwq3: R0.L = W [I0++] || R2.L = W [I1++];\n\t"
" R1 = B [P2++] (X);\n\t"
" R1 <<= 5;\n\t"
" R0.L = R0.L - R1.L;\n\t"
" R1 <<= 5;\n\t"
" R0.L = R0.L - R1.L;\n\t"
" R0 = R0.L*R0.L;\n\t"
" A1 = R2.L*R0.L (M,IS);\n\t"
" A1 = A1 >>> 16;\n\t"
" R1 = (A1 += R2.L*R0.H) (IS);\n\t"
"lwq4: R3 = R3 + R1;\n\t"
" A1 = R2.L*R0.L (M,IS);\n\t"
" A1 = A1 >>> 16;\n\t"
" R1 = (A1 += R2.L*R0.H) (IS);\n\t"
"lwq4: R3 = R3 + R1;\n\t"
" cc =R3<%0;\n\t"
" if cc %0=R3;\n\t"
" if cc %1=R5;\n\t"
" cc =R3<%0;\n\t"
" if cc %0=R3;\n\t"
" if cc %1=R5;\n\t"
"lwq2: R5 += 1;\n\t"
" L0 = 0;\n\t"
" L1 = 0;\n\t"

View file

@ -459,7 +459,7 @@ int sb_encode(void *state, void *vin, SpeexBits *bits)
spx_int32_t modeid;
modeid = mode->nb_modes-1;
st->relative_quality+=1.0*(ratio+2);
if (st->relative_quality<-1)
if (st->relative_quality<-1)
st->relative_quality=-1;
while (modeid)
{

View file

@ -96,10 +96,10 @@ static void drfti1(int n, float *wa, int *ifac){
argld=(float)ld*argh;
fi=0.f;
for (ii=2;ii<ido;ii+=2){
fi+=1.f;
arg=fi*argld;
wa[i++]=cos(arg);
wa[i++]=sin(arg);
fi+=1.f;
arg=fi*argld;
wa[i++]=cos(arg);
wa[i++]=sin(arg);
}
is+=ido;
}
@ -169,7 +169,7 @@ static void dradf2(int ido,int l1,float *cc,float *ch,float *wa1){
}
static void dradf4(int ido,int l1,float *cc,float *ch,float *wa1,
float *wa2,float *wa3){
float *wa2,float *wa3){
static float hsqt2 = .70710678118654752f;
int i,k,t0,t1,t2,t3,t4,t5,t6;
float ci2,ci3,ci4,cr2,cr3,cr4,ti1,ti2,ti3,ti4,tr1,tr2,tr3,tr4;
@ -749,7 +749,7 @@ static void dradb3(int ido,int l1,float *cc,float *ch,float *wa1,
}
static void dradb4(int ido,int l1,float *cc,float *ch,float *wa1,
float *wa2,float *wa3){
float *wa2,float *wa3){
static float sqrt2=1.414213562373095f;
int i,k,t0,t1,t2,t3,t4,t5,t6,t7,t8;
float ci2,ci3,ci4,cr2,cr3,cr4,ti1,ti2,ti3,ti4,tr1,tr2,tr3,tr4;

View file

@ -66,8 +66,8 @@ typedef struct {
int *lacing_vals; /* The values that will go to the segment table */
spx_ogg_int64_t *granule_vals; /* granulepos values for headers. Not compact
this way, but it is simple coupled to the
lacing fifo */
this way, but it is simple coupled to the
lacing fifo */
long lacing_storage;
long lacing_fill;
long lacing_packet;
@ -103,10 +103,10 @@ typedef struct {
spx_ogg_int64_t granulepos;
spx_ogg_int64_t packetno; /* sequence number for decode; the framing
knows where there's a hole in the data,
but we need coupling so that the codec
(which is in a seperate abstraction
layer) also knows about the gap */
knows where there's a hole in the data,
but we need coupling so that the codec
(which is in a seperate abstraction
layer) also knows about the gap */
} spx_ogg_packet;
typedef struct {
@ -169,7 +169,7 @@ extern int spx_ogg_stream_flush(spx_ogg_stream_state *os, spx_ogg_page *og)
extern int spx_ogg_sync_init(spx_ogg_sync_state *oy);
extern int spx_ogg_sync_clear(spx_ogg_sync_state *oy);
extern int spx_ogg_sync_reset(spx_ogg_sync_state *oy);
extern int spx_ogg_sync_destroy(spx_ogg_sync_state *oy);
extern int spx_ogg_sync_destroy(spx_ogg_sync_state *oy);
extern void spx_ogg_alloc_buffer(spx_ogg_sync_state *oy, long size);
extern char *spx_ogg_sync_buffer(spx_ogg_sync_state *oy, long size);

View file

@ -90,9 +90,9 @@ static void _analysis_output(char *base,int i,float *v,int n,int bark,int dB){
if(dB){
float val;
if(v[j]==0.)
val=-140.;
val=-140.;
else
val=todB(v[j]);
val=todB(v[j]);
fprintf(of,"%f\n",val);
}else{
fprintf(of,"%f\n",v[j]);
@ -254,19 +254,19 @@ static void bark_noise_hybridmp(int n,const long *b,
}
static void _vp_noisemask(VorbisPsy *p,
float *logfreq,
float *logmask){
float *logfreq,
float *logmask){
int i,n=p->n/2;
float *work=alloca(n*sizeof(*work));
bark_noise_hybridmp(n,p->bark,logfreq,logmask,
140.,-1);
140.,-1);
for(i=0;i<n;i++)work[i]=logfreq[i]-logmask[i];
bark_noise_hybridmp(n,p->bark,work,logmask,0.,
p->vi->noisewindowfixed);
p->vi->noisewindowfixed);
for(i=0;i<n;i++)work[i]=logfreq[i]-work[i];
@ -319,10 +319,10 @@ VorbisPsy *vorbis_psy_init(int rate, int n)
float bark=toBARK(rate/(2*n)*i);
for(;lo+p->vi->noisewindowlomin<i &&
toBARK(rate/(2*n)*lo)<(bark-p->vi->noisewindowlo);lo++);
toBARK(rate/(2*n)*lo)<(bark-p->vi->noisewindowlo);lo++);
for(;hi<=n && (hi<i+p->vi->noisewindowhimin ||
toBARK(rate/(2*n)*hi)<(bark+p->vi->noisewindowhi));hi++);
toBARK(rate/(2*n)*hi)<(bark+p->vi->noisewindowhi));hi++);
p->bark[i]=((lo-1)<<16)+(hi-1);

View file

@ -34,55 +34,55 @@ static inline ogg_int32_t MULT31(ogg_int32_t x, ogg_int32_t y) {
static inline ogg_int32_t MULT31_SHIFT15(ogg_int32_t x, ogg_int32_t y) {
int lo,hi;
asm volatile("smull %0, %1, %2, %3\n\t"
"movs %0, %0, lsr #15\n\t"
"adc %1, %0, %1, lsl #17\n\t"
asm volatile("smull %0, %1, %2, %3\n\t"
"movs %0, %0, lsr #15\n\t"
"adc %1, %0, %1, lsl #17\n\t"
: "=&r"(lo),"=&r"(hi)
: "%r"(x),"r"(y)
: "cc");
: "cc");
return(hi);
}
#define XPROD32(a, b, t, v, x, y) \
{ \
long l; \
asm( "smull %0, %1, %4, %6\n\t" \
"rsb %3, %4, #0\n\t" \
"smlal %0, %1, %5, %7\n\t" \
"smull %0, %2, %5, %6\n\t" \
"smlal %0, %2, %3, %7" \
: "=&r" (l), "=&r" (x), "=&r" (y), "=r" ((a)) \
: "3" ((a)), "r" ((b)), "r" ((t)), "r" ((v)) ); \
asm( "smull %0, %1, %4, %6\n\t" \
"rsb %3, %4, #0\n\t" \
"smlal %0, %1, %5, %7\n\t" \
"smull %0, %2, %5, %6\n\t" \
"smlal %0, %2, %3, %7" \
: "=&r" (l), "=&r" (x), "=&r" (y), "=r" ((a)) \
: "3" ((a)), "r" ((b)), "r" ((t)), "r" ((v)) ); \
}
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)
{
int x1, y1, l;
asm( "smull %0, %1, %4, %6\n\t"
"rsb %3, %4, #0\n\t"
"smlal %0, %1, %5, %7\n\t"
"smull %0, %2, %5, %6\n\t"
"smlal %0, %2, %3, %7"
: "=&r" (l), "=&r" (x1), "=&r" (y1), "=r" (a)
: "3" (a), "r" (b), "r" (t), "r" (v) );
asm( "smull %0, %1, %4, %6\n\t"
"rsb %3, %4, #0\n\t"
"smlal %0, %1, %5, %7\n\t"
"smull %0, %2, %5, %6\n\t"
"smlal %0, %2, %3, %7"
: "=&r" (l), "=&r" (x1), "=&r" (y1), "=r" (a)
: "3" (a), "r" (b), "r" (t), "r" (v) );
*x = x1 << 1;
*y = y1 << 1;
}
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)
{
int x1, y1, l;
asm( "smull %0, %1, %3, %5\n\t"
"rsb %2, %4, #0\n\t"
"smlal %0, %1, %2, %6\n\t"
"smull %0, %2, %4, %5\n\t"
"smlal %0, %2, %3, %6"
: "=&r" (l), "=&r" (x1), "=&r" (y1)
: "r" (a), "r" (b), "r" (t), "r" (v) );
asm( "smull %0, %1, %3, %5\n\t"
"rsb %2, %4, #0\n\t"
"smlal %0, %1, %2, %6\n\t"
"smull %0, %2, %4, %5\n\t"
"smlal %0, %2, %3, %6"
: "=&r" (l), "=&r" (x1), "=&r" (y1)
: "r" (a), "r" (b), "r" (t), "r" (v) );
*x = x1 << 1;
*y = y1 << 1;
}
@ -216,14 +216,14 @@ static inline void vect_copy(ogg_int32_t *x, const ogg_int32_t *y, int n)
static inline ogg_int32_t CLIP_TO_15(ogg_int32_t x) {
int tmp;
asm volatile("subs %1, %0, #32768\n\t"
"movpl %0, #0x7f00\n\t"
"orrpl %0, %0, #0xff\n"
"adds %1, %0, #32768\n\t"
"movmi %0, #0x8000"
: "+r"(x),"=r"(tmp)
:
: "cc");
asm volatile("subs %1, %0, #32768\n\t"
"movpl %0, #0x7f00\n\t"
"orrpl %0, %0, #0xff\n"
"adds %1, %0, #32768\n\t"
"movmi %0, #0x8000"
: "+r"(x),"=r"(tmp)
:
: "cc");
return(x);
}
@ -233,9 +233,9 @@ static inline ogg_int32_t CLIP_TO_15(ogg_int32_t x) {
#define _V_LSP_MATH_ASM
static inline void lsp_loop_asm(ogg_uint32_t *qip,ogg_uint32_t *pip,
ogg_int32_t *qexpp,
ogg_int32_t *ilsp,ogg_int32_t wi,
ogg_int32_t m){
ogg_int32_t *qexpp,
ogg_int32_t *ilsp,ogg_int32_t wi,
ogg_int32_t m){
ogg_uint32_t qi=*qip,pi=*pip;
ogg_int32_t qexp=*qexpp;
@ -291,7 +291,7 @@ static inline void lsp_loop_asm(ogg_uint32_t *qip,ogg_uint32_t *pip,
//qexp+=shift;
//}
/* normalize to max 16 sig figs */
"2:"
"mov r2,#0;"

View file

@ -34,12 +34,12 @@
typedef struct{
vorbis_info_floor *(*unpack)(vorbis_info *,oggpack_buffer *);
vorbis_look_floor *(*look) (vorbis_dsp_state *,vorbis_info_mode *,
vorbis_info_floor *);
vorbis_info_floor *);
void (*free_info) (vorbis_info_floor *);
void (*free_look) (vorbis_look_floor *);
void *(*inverse1) (struct vorbis_block *,vorbis_look_floor *);
int (*inverse2) (struct vorbis_block *,vorbis_look_floor *,
void *buffer,ogg_int32_t *);
void *buffer,ogg_int32_t *);
} vorbis_func_floor;
typedef struct{
@ -77,11 +77,11 @@ typedef struct{
typedef struct{
vorbis_info_residue *(*unpack)(vorbis_info *,oggpack_buffer *);
vorbis_look_residue *(*look) (vorbis_dsp_state *,vorbis_info_mode *,
vorbis_info_residue *);
vorbis_info_residue *);
void (*free_info) (vorbis_info_residue *);
void (*free_look) (vorbis_look_residue *);
int (*inverse) (struct vorbis_block *,vorbis_look_residue *,
ogg_int32_t **,int *,int);
ogg_int32_t **,int *,int);
} vorbis_func_residue;
typedef struct vorbis_info_residue0{
@ -101,7 +101,7 @@ typedef struct vorbis_info_residue0{
typedef struct{
vorbis_info_mapping *(*unpack)(vorbis_info *,oggpack_buffer *);
vorbis_look_mapping *(*look) (vorbis_dsp_state *,vorbis_info_mode *,
vorbis_info_mapping *);
vorbis_info_mapping *);
void (*free_info) (vorbis_info_mapping *);
void (*free_look) (vorbis_look_mapping *);
int (*inverse) (struct vorbis_block *vb,vorbis_look_mapping *);

View file

@ -49,19 +49,19 @@ int vorbis_staticbook_unpack(oggpack_buffer *opb,static_codebook *s){
/* yes, unused entries */
for(i=0;i<s->entries;i++){
if(oggpack_read(opb,1)){
long num=oggpack_read(opb,5);
if(num==-1)goto _eofout;
s->lengthlist[i]=num+1;
}else
s->lengthlist[i]=0;
if(oggpack_read(opb,1)){
long num=oggpack_read(opb,5);
if(num==-1)goto _eofout;
s->lengthlist[i]=num+1;
}else
s->lengthlist[i]=0;
}
}else{
/* all entries used; no tagging */
for(i=0;i<s->entries;i++){
long num=oggpack_read(opb,5);
if(num==-1)goto _eofout;
s->lengthlist[i]=num+1;
long num=oggpack_read(opb,5);
if(num==-1)goto _eofout;
s->lengthlist[i]=num+1;
}
}
@ -73,11 +73,11 @@ int vorbis_staticbook_unpack(oggpack_buffer *opb,static_codebook *s){
s->lengthlist=(long *)_ogg_malloc(sizeof(*s->lengthlist)*s->entries);
for(i=0;i<s->entries;){
long num=oggpack_read(opb,_ilog(s->entries-i));
if(num==-1)goto _eofout;
for(j=0;j<num && i<s->entries;j++,i++)
s->lengthlist[i]=length;
length++;
long num=oggpack_read(opb,_ilog(s->entries-i));
if(num==-1)goto _eofout;
for(j=0;j<num && i<s->entries;j++,i++)
s->lengthlist[i]=length;
length++;
}
}
break;
@ -104,17 +104,17 @@ int vorbis_staticbook_unpack(oggpack_buffer *opb,static_codebook *s){
int quantvals=0;
switch(s->maptype){
case 1:
quantvals=_book_maptype1_quantvals(s);
break;
quantvals=_book_maptype1_quantvals(s);
break;
case 2:
quantvals=s->entries*s->dim;
break;
quantvals=s->entries*s->dim;
break;
}
/* quantized values */
s->quantlist=(long *)_ogg_malloc(sizeof(*s->quantlist)*quantvals);
for(i=0;i<quantvals;i++)
s->quantlist[i]=oggpack_read(opb,s->q_quant);
s->quantlist[i]=oggpack_read(opb,s->q_quant);
if(quantvals&&s->quantlist[quantvals-1]==-1)goto _eofout;
}
@ -216,7 +216,7 @@ static inline ogg_uint32_t bitreverse(register ogg_uint32_t x)
}
STIN long decode_packed_entry_number(codebook *book,
oggpack_buffer *b){
oggpack_buffer *b){
int read=book->dec_maxlength;
long lo,hi;
long lok = oggpack_look(b,book->dec_firsttablen);
@ -284,25 +284,25 @@ static long decode_packed_block(codebook *book, oggpack_buffer *b,
ptr = (ogg_uint32_t *)(adr&~3);
bitend = ((adr&3)+b->headend)*8;
while (bufptr<bufend){
long entry, lo, hi;
if (UNLIKELY(cachesize<book->dec_maxlength)) {
if (bit-cachesize+32>=bitend)
break;
bit-=cachesize;
cache=letoh32(ptr[bit>>5]) >> (bit&31);
if (bit&31)
cache|=letoh32(ptr[(bit>>5)+1]) << (32-(bit&31));
cachesize=32;
bit+=32;
}
long entry, lo, hi;
if (UNLIKELY(cachesize<book->dec_maxlength)) {
if (bit-cachesize+32>=bitend)
break;
bit-=cachesize;
cache=letoh32(ptr[bit>>5]) >> (bit&31);
if (bit&31)
cache|=letoh32(ptr[(bit>>5)+1]) << (32-(bit&31));
cachesize=32;
bit+=32;
}
entry=book->dec_firsttable[cache&((1<<book->dec_firsttablen)-1)];
if(UNLIKELY(entry&0x80000000UL)){
lo=(entry>>15)&0x7fff;
hi=book->used_entries-(entry&0x7fff);
{
ogg_uint32_t testword=bitreverse((ogg_uint32_t)cache);
entry=book->dec_firsttable[cache&((1<<book->dec_firsttablen)-1)];
if(UNLIKELY(entry&0x80000000UL)){
lo=(entry>>15)&0x7fff;
hi=book->used_entries-(entry&0x7fff);
{
ogg_uint32_t testword=bitreverse((ogg_uint32_t)cache);
while(LIKELY(hi-lo>1)){
long p=(hi-lo)>>1;
if (book->codelist[lo+p]>testword)
@ -312,15 +312,15 @@ static long decode_packed_block(codebook *book, oggpack_buffer *b,
}
entry=lo;
}
}else
entry--;
}else
entry--;
*bufptr++=entry;
{
int l=book->dec_codelengths[entry];
cachesize-=l;
cache>>=l;
}
*bufptr++=entry;
{
int l=book->dec_codelengths[entry];
cachesize-=l;
cache>>=l;
}
}
adr=(unsigned long)b->headptr;
@ -366,7 +366,7 @@ long vorbis_book_decode(codebook *book, oggpack_buffer *b){
/* returns 0 on OK or -1 on eof *************************************/
long vorbis_book_decodevs_add(codebook *book,ogg_int32_t *a,
oggpack_buffer *b,int n,int point){
oggpack_buffer *b,int n,int point){
if(book->used_entries>0){
int step=n/book->dim;
long *entry = (long *)alloca(sizeof(*entry)*step);
@ -376,29 +376,29 @@ long vorbis_book_decodevs_add(codebook *book,ogg_int32_t *a,
if(shift>=0){
for (i = 0; i < step; i++) {
entry[i]=decode_packed_entry_number(book,b);
if(entry[i]==-1)return(-1);
t[i] = book->valuelist+entry[i]*book->dim;
entry[i]=decode_packed_entry_number(book,b);
if(entry[i]==-1)return(-1);
t[i] = book->valuelist+entry[i]*book->dim;
}
for(i=0,o=0;i<book->dim;i++,o+=step)
for (j=0;j<step;j++)
a[o+j]+=t[j][i]>>shift;
for (j=0;j<step;j++)
a[o+j]+=t[j][i]>>shift;
}else{
for (i = 0; i < step; i++) {
entry[i]=decode_packed_entry_number(book,b);
if(entry[i]==-1)return(-1);
t[i] = book->valuelist+entry[i]*book->dim;
entry[i]=decode_packed_entry_number(book,b);
if(entry[i]==-1)return(-1);
t[i] = book->valuelist+entry[i]*book->dim;
}
for(i=0,o=0;i<book->dim;i++,o+=step)
for (j=0;j<step;j++)
a[o+j]+=t[j][i]<<-shift;
for (j=0;j<step;j++)
a[o+j]+=t[j][i]<<-shift;
}
}
return(0);
}
long vorbis_book_decodev_add(codebook *book,ogg_int32_t *a,
oggpack_buffer *b,int n,int point){
oggpack_buffer *b,int n,int point){
if(book->used_entries>0){
int i,j,entry;
ogg_int32_t *t;
@ -406,20 +406,20 @@ long vorbis_book_decodev_add(codebook *book,ogg_int32_t *a,
if(shift>=0){
for(i=0;i<n;){
entry = decode_packed_entry_number(book,b);
if(entry==-1)return(-1);
t = book->valuelist+entry*book->dim;
for (j=0;j<book->dim;)
a[i++]+=t[j++]>>shift;
entry = decode_packed_entry_number(book,b);
if(entry==-1)return(-1);
t = book->valuelist+entry*book->dim;
for (j=0;j<book->dim;)
a[i++]+=t[j++]>>shift;
}
}else{
shift = -shift;
for(i=0;i<n;){
entry = decode_packed_entry_number(book,b);
if(entry==-1)return(-1);
t = book->valuelist+entry*book->dim;
for (j=0;j<book->dim;)
a[i++]+=t[j++]<<shift;
entry = decode_packed_entry_number(book,b);
if(entry==-1)return(-1);
t = book->valuelist+entry*book->dim;
for (j=0;j<book->dim;)
a[i++]+=t[j++]<<shift;
}
}
}
@ -427,7 +427,7 @@ long vorbis_book_decodev_add(codebook *book,ogg_int32_t *a,
}
long vorbis_book_decodev_set(codebook *book,ogg_int32_t *a,
oggpack_buffer *b,int n,int point){
oggpack_buffer *b,int n,int point){
if(book->used_entries>0){
int i,j,entry;
ogg_int32_t *t;
@ -436,22 +436,22 @@ long vorbis_book_decodev_set(codebook *book,ogg_int32_t *a,
if(shift>=0){
for(i=0;i<n;){
entry = decode_packed_entry_number(book,b);
if(entry==-1)return(-1);
t = book->valuelist+entry*book->dim;
for (j=0;j<book->dim;){
a[i++]=t[j++]>>shift;
}
entry = decode_packed_entry_number(book,b);
if(entry==-1)return(-1);
t = book->valuelist+entry*book->dim;
for (j=0;j<book->dim;){
a[i++]=t[j++]>>shift;
}
}
}else{
shift = -shift;
for(i=0;i<n;){
entry = decode_packed_entry_number(book,b);
if(entry==-1)return(-1);
t = book->valuelist+entry*book->dim;
for (j=0;j<book->dim;){
a[i++]=t[j++]<<shift;
}
entry = decode_packed_entry_number(book,b);
if(entry==-1)return(-1);
t = book->valuelist+entry*book->dim;
for (j=0;j<book->dim;){
a[i++]=t[j++]<<shift;
}
}
}
}else{
@ -459,7 +459,7 @@ long vorbis_book_decodev_set(codebook *book,ogg_int32_t *a,
int i,j;
for(i=0;i<n;){
for (j=0;j<book->dim;){
a[i++]=0;
a[i++]=0;
}
}
}
@ -516,8 +516,8 @@ static long vorbis_book_decodevv_add_2ch_even(codebook *book,ogg_int32_t **a,
}
long vorbis_book_decodevv_add(codebook *book,ogg_int32_t **a,
long offset,int ch,
oggpack_buffer *b,int n,int point){
long offset,int ch,
oggpack_buffer *b,int n,int point){
if(LIKELY(book->used_entries>0)){
long i,j,k,chunk,read;
int chptr=0;
@ -535,14 +535,14 @@ long vorbis_book_decodevv_add(codebook *book,ogg_int32_t **a,
chunk=((offset+n-i)*ch+book->dim-1)/book->dim;
read = decode_packed_block(book,b,entries,chunk);
for(k=0;k<read;k++){
const ogg_int32_t *t = book->valuelist+entries[k]*book->dim;
for (j=0;j<book->dim;j++){
a[chptr++][i]+=t[j]>>shift;
if(chptr==ch){
chptr=0;
i++;
}
}
const ogg_int32_t *t = book->valuelist+entries[k]*book->dim;
for (j=0;j<book->dim;j++){
a[chptr++][i]+=t[j]>>shift;
if(chptr==ch){
chptr=0;
i++;
}
}
}
if (read<chunk)return-1;
}
@ -554,14 +554,14 @@ long vorbis_book_decodevv_add(codebook *book,ogg_int32_t **a,
chunk=((offset+n-i)*ch+book->dim-1)/book->dim;
read = decode_packed_block(book,b,entries,chunk);
for(k=0;k<read;k++){
const ogg_int32_t *t = book->valuelist+entries[k]*book->dim;
for (j=0;j<book->dim;j++){
a[chptr++][i]+=t[j]<<shift;
if(chptr==ch){
chptr=0;
i++;
}
}
const ogg_int32_t *t = book->valuelist+entries[k]*book->dim;
for (j=0;j<book->dim;j++){
a[chptr++][i]+=t[j]<<shift;
if(chptr==ch){
chptr=0;
i++;
}
}
}
if (read<chunk)return-1;
}

View file

@ -40,8 +40,8 @@ typedef struct static_codebook{
/* mapping ***************************************************************/
int maptype; /* 0=none
1=implicitly populated values from map column
2=listed arbitrary values */
1=implicitly populated values from map column
2=listed arbitrary values */
/* The below does a linear, single monotonic sequence mapping. */
long q_min; /* packed 32 bit float; quant value 0 maps to minval */
@ -50,8 +50,8 @@ typedef struct static_codebook{
int q_sequencep; /* bitflag */
long *quantlist; /* map == 1: (int)(entries^(1/dim)) element column map
map == 2: list of dim*entries quantized entry vals
*/
map == 2: list of dim*entries quantized entry vals
*/
} static_codebook;
typedef struct codebook{
@ -87,14 +87,14 @@ extern int vorbis_staticbook_unpack(oggpack_buffer *b,static_codebook *c);
extern long vorbis_book_decode(codebook *book, oggpack_buffer *b);
extern long vorbis_book_decodevs_add(codebook *book, ogg_int32_t *a,
oggpack_buffer *b,int n,int point);
oggpack_buffer *b,int n,int point);
extern long vorbis_book_decodev_set(codebook *book, ogg_int32_t *a,
oggpack_buffer *b,int n,int point);
oggpack_buffer *b,int n,int point);
extern long vorbis_book_decodev_add(codebook *book, ogg_int32_t *a,
oggpack_buffer *b,int n,int point);
oggpack_buffer *b,int n,int point);
extern long vorbis_book_decodevv_add(codebook *book, ogg_int32_t **a,
long off,int ch,
oggpack_buffer *b,int n,int point);
long off,int ch,
oggpack_buffer *b,int n,int point);
extern int _ilog(unsigned int v);

View file

@ -74,7 +74,7 @@ static inline ogg_int32_t vorbis_coslook_i(long a){
int i=a>>COS_LOOKUP_I_SHIFT;
int d=a&COS_LOOKUP_I_MASK;
return COS_LOOKUP_I[i]- ((d*(COS_LOOKUP_I[i]-COS_LOOKUP_I[i+1]))>>
COS_LOOKUP_I_SHIFT);
COS_LOOKUP_I_SHIFT);
}
/* interpolated lookup based cos function */
@ -181,7 +181,7 @@ static void vorbis_lsp_to_curve(ogg_int32_t *curve,int *map,int n,int ln,
qi=((qi*qi)>>16);
if(m&1){
qexp= qexp*2-28*((m+1)>>1)+m;
qexp= qexp*2-28*((m+1)>>1)+m;
pi*=(1<<14)-((wi*wi)>>14);
qi+=pi>>14;
}else{
@ -205,15 +205,15 @@ static void vorbis_lsp_to_curve(ogg_int32_t *curve,int *map,int n,int ln,
for(j=3;j<m;j+=2){
if(!(shift=MLOOP_1[(pi|qi)>>25]))
if(!(shift=MLOOP_2[(pi|qi)>>19]))
shift=MLOOP_3[(pi|qi)>>16];
if(!(shift=MLOOP_2[(pi|qi)>>19]))
shift=MLOOP_3[(pi|qi)>>16];
qi=(qi>>shift)*labs(ilsp[j-1]-wi);
pi=(pi>>shift)*labs(ilsp[j]-wi);
qexp+=shift;
}
if(!(shift=MLOOP_1[(pi|qi)>>25]))
if(!(shift=MLOOP_2[(pi|qi)>>19]))
shift=MLOOP_3[(pi|qi)>>16];
shift=MLOOP_3[(pi|qi)>>16];
/* pi,qi normalized collectively, both tracked using qexp */
@ -225,8 +225,8 @@ static void vorbis_lsp_to_curve(ogg_int32_t *curve,int *map,int n,int ln,
qexp+=shift;
if(!(shift=MLOOP_1[(pi|qi)>>25]))
if(!(shift=MLOOP_2[(pi|qi)>>19]))
shift=MLOOP_3[(pi|qi)>>16];
if(!(shift=MLOOP_2[(pi|qi)>>19]))
shift=MLOOP_3[(pi|qi)>>16];
pi>>=shift;
qi>>=shift;
@ -243,7 +243,7 @@ static void vorbis_lsp_to_curve(ogg_int32_t *curve,int *map,int n,int ln,
/* even order filter; still symmetric */
/* p*=p(1-w), q*=q(1+w), let normalization drift because it isn't
worth tracking step by step */
worth tracking step by step */
pi>>=shift;
qi>>=shift;
@ -268,15 +268,15 @@ static void vorbis_lsp_to_curve(ogg_int32_t *curve,int *map,int n,int ln,
qi>>=1; qexp++;
}else
while(qi && !(qi&0x8000)){ /* checks for 0.0xxxxxxxxxxxxxxx or less*/
qi<<=1; qexp--;
qi<<=1; qexp--;
}
#endif
amp=vorbis_fromdBlook_i(ampi* /* n.4 */
vorbis_invsqlook_i(qi,qexp)-
/* m.8, m+n<=8 */
ampoffseti); /* 8.12[0] */
vorbis_invsqlook_i(qi,qexp)-
/* m.8, m+n<=8 */
ampoffseti); /* 8.12[0] */
#ifdef _LOW_ACCURACY_
amp>>=9;
@ -366,7 +366,7 @@ static vorbis_look_floor *floor0_look (vorbis_dsp_state *vd,vorbis_info_mode *mi
for(j=0;j<look->n;j++){
int val=(look->ln*
((toBARK(info->rate/2*j/look->n)<<11)/toBARK(info->rate/2)))>>11;
((toBARK(info->rate/2*j/look->n)<<11)/toBARK(info->rate/2)))>>11;
if(val>=look->ln)val=look->ln-1; /* guard against the approximation */
look->linearmap[j]=val;
@ -398,10 +398,10 @@ static void *floor0_inverse1(vorbis_block *vb,vorbis_look_floor *i){
ogg_int32_t *lsp=(ogg_int32_t *)_vorbis_block_alloc(vb,sizeof(*lsp)*(look->m+1));
for(j=0;j<look->m;j+=b->dim)
if(vorbis_book_decodev_set(b,lsp+j,&vb->opb,b->dim,-24)==-1)goto eop;
if(vorbis_book_decodev_set(b,lsp+j,&vb->opb,b->dim,-24)==-1)goto eop;
for(j=0;j<look->m;){
for(k=0;k<b->dim;k++,j++)lsp[j]+=last;
last=lsp[j-1];
for(k=0;k<b->dim;k++,j++)lsp[j]+=last;
last=lsp[j-1];
}
lsp[look->m]=amp;
@ -413,7 +413,7 @@ static void *floor0_inverse1(vorbis_block *vb,vorbis_look_floor *i){
}
static int floor0_inverse2(vorbis_block *vb,vorbis_look_floor *i,
void *memo,ogg_int32_t *out){
void *memo,ogg_int32_t *out){
vorbis_look_floor0 *look=(vorbis_look_floor0 *)i;
vorbis_info_floor0 *info=look->vi;
(void)vb;
@ -424,7 +424,7 @@ static int floor0_inverse2(vorbis_block *vb,vorbis_look_floor *i,
/* take the coefficients back to a spectral envelope curve */
vorbis_lsp_to_curve(out,look->linearmap,look->n,look->ln,
lsp,look->m,amp,info->ampdB,look->lsp_look);
lsp,look->m,amp,info->ampdB,look->lsp_look);
return(1);
}
memset(out,0,sizeof(*out)*look->n);

View file

@ -1003,11 +1003,11 @@ STATICIRAM_NOT_MDCT int _packetout(ogg_stream_state *os,ogg_packet *op,int adv){
/* split the body contents off */
if(op){
op->packet=ogg_buffer_split(&os->body_tail,&os->body_head,
os->body_fill&FINMASK);
os->body_fill&FINMASK);
op->bytes=os->body_fill&FINMASK;
}else{
os->body_tail=ogg_buffer_pretruncate(os->body_tail,
os->body_fill&FINMASK);
os->body_fill&FINMASK);
if(os->body_tail==0)os->body_head=0;
}

View file

@ -47,7 +47,7 @@ void vorbis_comment_clear(vorbis_comment *vc){
for(i=0;i<vc->comments;i++)
if(vc->user_comments[i])_ogg_free(vc->user_comments[i]);
if(vc->user_comments)_ogg_free(vc->user_comments);
if(vc->comment_lengths)_ogg_free(vc->comment_lengths);
if(vc->comment_lengths)_ogg_free(vc->comment_lengths);
if(vc->vendor)_ogg_free(vc->vendor);
memset(vc,0,sizeof(*vc));
}
@ -77,26 +77,26 @@ void vorbis_info_clear(vorbis_info *vi){
for(i=0;i<ci->maps;i++) /* unpack does the range checking */
if(ci->map_param[i])
_mapping_P[ci->map_type[i]]->free_info(ci->map_param[i]);
_mapping_P[ci->map_type[i]]->free_info(ci->map_param[i]);
for(i=0;i<ci->floors;i++) /* unpack does the range checking */
if(ci->floor_param[i])
_floor_P[ci->floor_type[i]]->free_info(ci->floor_param[i]);
_floor_P[ci->floor_type[i]]->free_info(ci->floor_param[i]);
for(i=0;i<ci->residues;i++) /* unpack does the range checking */
if(ci->residue_param[i])
_residue_P[ci->residue_type[i]]->free_info(ci->residue_param[i]);
_residue_P[ci->residue_type[i]]->free_info(ci->residue_param[i]);
for(i=0;i<ci->books;i++){
if(ci->book_param[i]){
/* knows if the book was not alloced */
vorbis_staticbook_destroy(ci->book_param[i]);
/* knows if the book was not alloced */
vorbis_staticbook_destroy(ci->book_param[i]);
}
if(ci->fullbooks)
vorbis_book_clear(ci->fullbooks+i);
vorbis_book_clear(ci->fullbooks+i);
}
if(ci->fullbooks)
_ogg_free(ci->fullbooks);
_ogg_free(ci->fullbooks);
_ogg_free(ci);
}
@ -278,42 +278,42 @@ int vorbis_synthesis_headerin(vorbis_info *vi,vorbis_comment *vc,ogg_packet *op)
memset(buffer,0,6);
_v_readstring(&opb,buffer,6);
if(memcmp(buffer,"vorbis",6)){
/* not a vorbis header */
return(OV_ENOTVORBIS);
/* not a vorbis header */
return(OV_ENOTVORBIS);
}
switch(packtype){
case 0x01: /* least significant *bit* is read first */
if(!op->b_o_s){
/* Not the initial packet */
return(OV_EBADHEADER);
}
if(vi->rate!=0){
/* previously initialized info header */
return(OV_EBADHEADER);
}
if(!op->b_o_s){
/* Not the initial packet */
return(OV_EBADHEADER);
}
if(vi->rate!=0){
/* previously initialized info header */
return(OV_EBADHEADER);
}
return(_vorbis_unpack_info(vi,&opb));
return(_vorbis_unpack_info(vi,&opb));
case 0x03: /* least significant *bit* is read first */
if(vi->rate==0){
/* um... we didn't get the initial header */
return(OV_EBADHEADER);
}
if(vi->rate==0){
/* um... we didn't get the initial header */
return(OV_EBADHEADER);
}
return(_vorbis_unpack_comment(vc,&opb));
return(_vorbis_unpack_comment(vc,&opb));
case 0x05: /* least significant *bit* is read first */
if(vi->rate==0 || vc->vendor==NULL){
/* um... we didn;t get the initial header or comments yet */
return(OV_EBADHEADER);
}
if(vi->rate==0 || vc->vendor==NULL){
/* um... we didn;t get the initial header or comments yet */
return(OV_EBADHEADER);
}
return(_vorbis_unpack_books(vi,&opb));
return(_vorbis_unpack_books(vi,&opb));
default:
/* Not a valid vorbis header type */
return(OV_EBADHEADER);
break;
/* Not a valid vorbis header type */
return(OV_EBADHEADER);
break;
}
}
}

View file

@ -157,7 +157,7 @@ extern int vorbis_info_blocksize(vorbis_info *vi,int zo);
extern void vorbis_comment_init(vorbis_comment *vc);
extern void vorbis_comment_add(vorbis_comment *vc, char *comment);
extern void vorbis_comment_add_tag(vorbis_comment *vc,
char *tag, char *contents);
char *tag, char *contents);
extern void vorbis_comment_clear(vorbis_comment *vc);
extern int vorbis_block_init(vorbis_dsp_state *v, vorbis_block *vb);
@ -167,7 +167,7 @@ extern void vorbis_dsp_clear(vorbis_dsp_state *v);
/* Vorbis PRIMITIVES: synthesis layer *******************************/
extern int vorbis_synthesis_idheader(ogg_packet *op);
extern int vorbis_synthesis_headerin(vorbis_info *vi,vorbis_comment *vc,
ogg_packet *op);
ogg_packet *op);
extern int vorbis_synthesis_init(vorbis_dsp_state *v,vorbis_info *vi);
extern int vorbis_synthesis_restart(vorbis_dsp_state *v);

View file

@ -89,11 +89,11 @@ typedef struct OggVorbis_File {
extern int ov_clear(OggVorbis_File *vf);
//extern int ov_open(FILE *f,OggVorbis_File *vf,char *initial,long ibytes);
extern int ov_open_callbacks(void *datasource, OggVorbis_File *vf,
char *initial, long ibytes, ov_callbacks callbacks);
char *initial, long ibytes, ov_callbacks callbacks);
//extern int ov_test(FILE *f,OggVorbis_File *vf,char *initial,long ibytes);
extern int ov_test_callbacks(void *datasource, OggVorbis_File *vf,
char *initial, long ibytes, ov_callbacks callbacks);
char *initial, long ibytes, ov_callbacks callbacks);
extern int ov_test_open(OggVorbis_File *vf);
extern long ov_bitrate(OggVorbis_File *vf,int i);
@ -120,7 +120,7 @@ extern vorbis_info *ov_info(OggVorbis_File *vf,int link);
extern vorbis_comment *ov_comment(OggVorbis_File *vf,int link);
extern long ov_read(OggVorbis_File *vf,char *buffer,int length,
int *bitstream);
int *bitstream);
extern long ov_read_fixed(OggVorbis_File *vf,ogg_int32_t ***pcm_channels,
int length,int *bitstream);

View file

@ -51,23 +51,23 @@ static const ogg_int32_t FROMdB2_LOOKUP[FROMdB2_LOOKUP_SZ] ={
#define INVSQ_LOOKUP_I_SHIFT 10
#define INVSQ_LOOKUP_I_MASK 1023
static const long INVSQ_LOOKUP_I[64+1] ={
92682, 91966, 91267, 90583,
89915, 89261, 88621, 87995,
87381, 86781, 86192, 85616,
85051, 84497, 83953, 83420,
82897, 82384, 81880, 81385,
80899, 80422, 79953, 79492,
79039, 78594, 78156, 77726,
77302, 76885, 76475, 76072,
75674, 75283, 74898, 74519,
74146, 73778, 73415, 73058,
72706, 72359, 72016, 71679,
71347, 71019, 70695, 70376,
70061, 69750, 69444, 69141,
68842, 68548, 68256, 67969,
67685, 67405, 67128, 66855,
66585, 66318, 66054, 65794,
65536,
92682, 91966, 91267, 90583,
89915, 89261, 88621, 87995,
87381, 86781, 86192, 85616,
85051, 84497, 83953, 83420,
82897, 82384, 81880, 81385,
80899, 80422, 79953, 79492,
79039, 78594, 78156, 77726,
77302, 76885, 76475, 76072,
75674, 75283, 74898, 74519,
74146, 73778, 73415, 73058,
72706, 72359, 72016, 71679,
71347, 71019, 70695, 70376,
70061, 69750, 69444, 69141,
68842, 68548, 68256, 67969,
67685, 67405, 67128, 66855,
66585, 66318, 66054, 65794,
65536,
};
static const long INVSQ_LOOKUP_IDel[64] ={
@ -93,39 +93,39 @@ static const long INVSQ_LOOKUP_IDel[64] ={
#define COS_LOOKUP_I_MASK 511
#define COS_LOOKUP_I_SZ 128
static const ogg_int32_t COS_LOOKUP_I[COS_LOOKUP_I_SZ+1] ={
16384, 16379, 16364, 16340,
16305, 16261, 16207, 16143,
16069, 15986, 15893, 15791,
15679, 15557, 15426, 15286,
15137, 14978, 14811, 14635,
14449, 14256, 14053, 13842,
13623, 13395, 13160, 12916,
12665, 12406, 12140, 11866,
11585, 11297, 11003, 10702,
10394, 10080, 9760, 9434,
9102, 8765, 8423, 8076,
7723, 7366, 7005, 6639,
6270, 5897, 5520, 5139,
4756, 4370, 3981, 3590,
3196, 2801, 2404, 2006,
1606, 1205, 804, 402,
0, -401, -803, -1204,
-1605, -2005, -2403, -2800,
-3195, -3589, -3980, -4369,
-4755, -5138, -5519, -5896,
-6269, -6638, -7004, -7365,
-7722, -8075, -8422, -8764,
-9101, -9433, -9759, -10079,
-10393, -10701, -11002, -11296,
-11584, -11865, -12139, -12405,
-12664, -12915, -13159, -13394,
-13622, -13841, -14052, -14255,
-14448, -14634, -14810, -14977,
-15136, -15285, -15425, -15556,
-15678, -15790, -15892, -15985,
-16068, -16142, -16206, -16260,
-16304, -16339, -16363, -16378,
-16383,
16384, 16379, 16364, 16340,
16305, 16261, 16207, 16143,
16069, 15986, 15893, 15791,
15679, 15557, 15426, 15286,
15137, 14978, 14811, 14635,
14449, 14256, 14053, 13842,
13623, 13395, 13160, 12916,
12665, 12406, 12140, 11866,
11585, 11297, 11003, 10702,
10394, 10080, 9760, 9434,
9102, 8765, 8423, 8076,
7723, 7366, 7005, 6639,
6270, 5897, 5520, 5139,
4756, 4370, 3981, 3590,
3196, 2801, 2404, 2006,
1606, 1205, 804, 402,
0, -401, -803, -1204,
-1605, -2005, -2403, -2800,
-3195, -3589, -3980, -4369,
-4755, -5138, -5519, -5896,
-6269, -6638, -7004, -7365,
-7722, -8075, -8422, -8764,
-9101, -9433, -9759, -10079,
-10393, -10701, -11002, -11296,
-11584, -11865, -12139, -12405,
-12664, -12915, -13159, -13394,
-13622, -13841, -14052, -14255,
-14448, -14634, -14810, -14977,
-15136, -15285, -15425, -15556,
-15678, -15790, -15892, -15985,
-16068, -16142, -16206, -16260,
-16304, -16339, -16363, -16378,
-16383,
};
#endif

View file

@ -119,33 +119,33 @@ static inline ogg_int32_t MULT31_SHIFT15(ogg_int32_t x, ogg_int32_t y) {
/* replaced XPROD32 with a macro to avoid memory reference
_x, _y are the results (must be l-values) */
#define XPROD32(_a, _b, _t, _v, _x, _y) \
{ (_x)=MULT32(_a,_t)+MULT32(_b,_v); \
#define XPROD32(_a, _b, _t, _v, _x, _y) \
{ (_x)=MULT32(_a,_t)+MULT32(_b,_v); \
(_y)=MULT32(_b,_t)-MULT32(_a,_v); }
#ifdef __i386__
#define XPROD31(_a, _b, _t, _v, _x, _y) \
{ *(_x)=MULT31(_a,_t)+MULT31(_b,_v); \
#define XPROD31(_a, _b, _t, _v, _x, _y) \
{ *(_x)=MULT31(_a,_t)+MULT31(_b,_v); \
*(_y)=MULT31(_b,_t)-MULT31(_a,_v); }
#define XNPROD31(_a, _b, _t, _v, _x, _y) \
{ *(_x)=MULT31(_a,_t)-MULT31(_b,_v); \
#define XNPROD31(_a, _b, _t, _v, _x, _y) \
{ *(_x)=MULT31(_a,_t)-MULT31(_b,_v); \
*(_y)=MULT31(_b,_t)+MULT31(_a,_v); }
#else
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)
{
*x = MULT31(a, t) + MULT31(b, v);
*y = MULT31(b, t) - MULT31(a, v);
}
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)
{
*x = MULT31(a, t) - MULT31(b, v);
*y = MULT31(b, t) + MULT31(a, v);
@ -217,8 +217,8 @@ static inline ogg_int32_t CLIP_TO_15(ogg_int32_t x) {
#endif
static inline ogg_int32_t VFLOAT_MULT(ogg_int32_t a,ogg_int32_t ap,
ogg_int32_t b,ogg_int32_t bp,
ogg_int32_t *p){
ogg_int32_t b,ogg_int32_t bp,
ogg_int32_t *p){
if(a && b){
#ifndef _LOW_ACCURACY_
*p=ap+bp+32;
@ -232,16 +232,16 @@ static inline ogg_int32_t VFLOAT_MULT(ogg_int32_t a,ogg_int32_t ap,
}
static inline ogg_int32_t VFLOAT_MULTI(ogg_int32_t a,ogg_int32_t ap,
ogg_int32_t i,
ogg_int32_t *p){
ogg_int32_t i,
ogg_int32_t *p){
int ip=_ilog(abs(i))-31;
return VFLOAT_MULT(a,ap,i<<-ip,ip,p);
}
static inline ogg_int32_t VFLOAT_ADD(ogg_int32_t a,ogg_int32_t ap,
ogg_int32_t b,ogg_int32_t bp,
ogg_int32_t *p){
ogg_int32_t b,ogg_int32_t bp,
ogg_int32_t *p){
if(!a){
*p=bp;

View file

@ -80,45 +80,45 @@ static ogg_uint32_t *_make_words(long *l,long n,long sparsecount){
ogg_uint32_t entry=marker[length];
/* when we claim a node for an entry, we also claim the nodes
below it (pruning off the imagined tree that may have dangled
from it) as well as blocking the use of any nodes directly
above for leaves */
below it (pruning off the imagined tree that may have dangled
from it) as well as blocking the use of any nodes directly
above for leaves */
/* update ourself */
if(length<32 && (entry>>length)){
/* error condition; the lengths must specify an overpopulated tree */
_ogg_free(r);
return(NULL);
/* error condition; the lengths must specify an overpopulated tree */
_ogg_free(r);
return(NULL);
}
r[count++]=entry;
/* Look to see if the next shorter marker points to the node
above. if so, update it and repeat. */
above. if so, update it and repeat. */
{
for(j=length;j>0;j--){
if(marker[j]&1){
/* have to jump branches */
if(j==1)
marker[1]++;
else
marker[j]=marker[j-1]<<1;
break; /* invariant says next upper marker would already
have been moved if it was on the same path */
}
marker[j]++;
}
for(j=length;j>0;j--){
if(marker[j]&1){
/* have to jump branches */
if(j==1)
marker[1]++;
else
marker[j]=marker[j-1]<<1;
break; /* invariant says next upper marker would already
have been moved if it was on the same path */
}
marker[j]++;
}
}
/* prune the tree; the implicit invariant says all the longer
markers were dangling from our just-taken node. Dangle them
from our *new* node. */
markers were dangling from our just-taken node. Dangle them
from our *new* node. */
for(j=length+1;j<33;j++)
if((marker[j]>>1) == entry){
entry=marker[j];
marker[j]=marker[j-1]<<1;
}else
break;
if((marker[j]>>1) == entry){
entry=marker[j];
marker[j]=marker[j-1]<<1;
}else
break;
}else
if(sparsecount==0)count++;
}
@ -134,7 +134,7 @@ static ogg_uint32_t *_make_words(long *l,long n,long sparsecount){
if(sparsecount){
if(l[i])
r[count++]=temp;
r[count++]=temp;
}else
r[count++]=temp;
}
@ -162,9 +162,9 @@ long _book_maptype1_quantvals(const static_codebook *b){
return(vals);
}else{
if(acc>b->entries){
vals--;
vals--;
}else{
vals++;
vals++;
}
}
}
@ -197,85 +197,85 @@ static ogg_int32_t *_book_unquantize(const static_codebook *b,int n,
switch(b->maptype){
case 1:
/* most of the time, entries%dimensions == 0, but we need to be
well defined. We define that the possible vales at each
scalar is values == entries/dim. If entries%dim != 0, we'll
have 'too few' values (values*dim<entries), which means that
we'll have 'left over' entries; left over entries use zeroed
values (and are wasted). So don't generate codebooks like
that */
well defined. We define that the possible vales at each
scalar is values == entries/dim. If entries%dim != 0, we'll
have 'too few' values (values*dim<entries), which means that
we'll have 'left over' entries; left over entries use zeroed
values (and are wasted). So don't generate codebooks like
that */
quantvals=_book_maptype1_quantvals(b);
for(j=0;j<b->entries;j++){
if((sparsemap && b->lengthlist[j]) || !sparsemap){
ogg_int32_t last=0;
int lastpoint=0;
int indexdiv=1;
for(k=0;k<b->dim;k++){
int index= (j/indexdiv)%quantvals;
int point=0;
int val=VFLOAT_MULTI(delta,delpoint,
abs(b->quantlist[index]),&point);
if((sparsemap && b->lengthlist[j]) || !sparsemap){
ogg_int32_t last=0;
int lastpoint=0;
int indexdiv=1;
for(k=0;k<b->dim;k++){
int index= (j/indexdiv)%quantvals;
int point=0;
int val=VFLOAT_MULTI(delta,delpoint,
abs(b->quantlist[index]),&point);
val=VFLOAT_ADD(mindel,minpoint,val,point,&point);
val=VFLOAT_ADD(last,lastpoint,val,point,&point);
if(b->q_sequencep){
last=val;
lastpoint=point;
}
if(sparsemap){
r[sparsemap[count]*b->dim+k]=val;
rp[sparsemap[count]*b->dim+k]=point;
}else{
r[count*b->dim+k]=val;
rp[count*b->dim+k]=point;
}
if(*maxpoint<point)*maxpoint=point;
indexdiv*=quantvals;
}
count++;
}
val=VFLOAT_ADD(mindel,minpoint,val,point,&point);
val=VFLOAT_ADD(last,lastpoint,val,point,&point);
if(b->q_sequencep){
last=val;
lastpoint=point;
}
if(sparsemap){
r[sparsemap[count]*b->dim+k]=val;
rp[sparsemap[count]*b->dim+k]=point;
}else{
r[count*b->dim+k]=val;
rp[count*b->dim+k]=point;
}
if(*maxpoint<point)*maxpoint=point;
indexdiv*=quantvals;
}
count++;
}
}
break;
case 2:
for(j=0;j<b->entries;j++){
if((sparsemap && b->lengthlist[j]) || !sparsemap){
ogg_int32_t last=0;
int lastpoint=0;
if((sparsemap && b->lengthlist[j]) || !sparsemap){
ogg_int32_t last=0;
int lastpoint=0;
for(k=0;k<b->dim;k++){
int point=0;
int val=VFLOAT_MULTI(delta,delpoint,
abs(b->quantlist[j*b->dim+k]),&point);
for(k=0;k<b->dim;k++){
int point=0;
int val=VFLOAT_MULTI(delta,delpoint,
abs(b->quantlist[j*b->dim+k]),&point);
val=VFLOAT_ADD(mindel,minpoint,val,point,&point);
val=VFLOAT_ADD(last,lastpoint,val,point,&point);
if(b->q_sequencep){
last=val;
lastpoint=point;
}
val=VFLOAT_ADD(mindel,minpoint,val,point,&point);
val=VFLOAT_ADD(last,lastpoint,val,point,&point);
if(b->q_sequencep){
last=val;
lastpoint=point;
}
if(sparsemap){
r[sparsemap[count]*b->dim+k]=val;
rp[sparsemap[count]*b->dim+k]=point;
}else{
r[count*b->dim+k]=val;
rp[count*b->dim+k]=point;
}
if(*maxpoint<point)*maxpoint=point;
}
count++;
}
if(sparsemap){
r[sparsemap[count]*b->dim+k]=val;
rp[sparsemap[count]*b->dim+k]=point;
}else{
r[count*b->dim+k]=val;
rp[count*b->dim+k]=point;
}
if(*maxpoint<point)*maxpoint=point;
}
count++;
}
}
break;
}
for(j=0;j<n*b->dim;j++)
if(rp[j]<*maxpoint)
r[j]>>=*maxpoint-rp[j];
r[j]>>=*maxpoint-rp[j];
_ogg_free(rp);
return(r);
}
@ -383,12 +383,12 @@ int vorbis_book_init_decode(codebook *c,const static_codebook *s){
for(n=0,i=0;i<s->entries;i++)
if(s->lengthlist[i]>0)
c->dec_index[sortindex[n++]]=i;
c->dec_index[sortindex[n++]]=i;
c->dec_codelengths=(char *)_ogg_malloc(n*sizeof(*c->dec_codelengths));
for(n=0,i=0;i<s->entries;i++)
if(s->lengthlist[i]>0)
c->dec_codelengths[sortindex[n++]]=s->lengthlist[i];
c->dec_codelengths[sortindex[n++]]=s->lengthlist[i];
_ogg_free(sortindex);
c->dec_firsttablen=_ilog(c->used_entries)-4; /* this is magic */
@ -401,11 +401,11 @@ int vorbis_book_init_decode(codebook *c,const static_codebook *s){
for(i=0;i<n;i++){
if(c->dec_maxlength<c->dec_codelengths[i])
c->dec_maxlength=c->dec_codelengths[i];
c->dec_maxlength=c->dec_codelengths[i];
if(c->dec_codelengths[i]<=c->dec_firsttablen){
ogg_uint32_t orig=bitreverse(c->codelist[i]);
for(j=0;j<(1<<(c->dec_firsttablen-c->dec_codelengths[i]));j++)
c->dec_firsttable[orig|(j<<c->dec_codelengths[i])]=i+1;
ogg_uint32_t orig=bitreverse(c->codelist[i]);
for(j=0;j<(1<<(c->dec_firsttablen-c->dec_codelengths[i]));j++)
c->dec_firsttable[orig|(j<<c->dec_codelengths[i])]=i+1;
}
}
@ -416,24 +416,24 @@ int vorbis_book_init_decode(codebook *c,const static_codebook *s){
long lo=0,hi=0;
for(i=0;i<tabn;i++){
ogg_uint32_t word=i<<(32-c->dec_firsttablen);
if(c->dec_firsttable[bitreverse(word)]==0){
while((lo+1)<n && c->codelist[lo+1]<=word)lo++;
while( hi<n && word>=(c->codelist[hi]&mask))hi++;
/* we only actually have 15 bits per hint to play with here.
In order to overflow gracefully (nothing breaks, efficiency
just drops), encode as the difference from the extremes. */
{
unsigned long loval=lo;
unsigned long hival=n-hi;
if(loval>0x7fff)loval=0x7fff;
if(hival>0x7fff)hival=0x7fff;
c->dec_firsttable[bitreverse(word)]=
0x80000000UL | (loval<<15) | hival;
}
}
ogg_uint32_t word=i<<(32-c->dec_firsttablen);
if(c->dec_firsttable[bitreverse(word)]==0){
while((lo+1)<n && c->codelist[lo+1]<=word)lo++;
while( hi<n && word>=(c->codelist[hi]&mask))hi++;
/* we only actually have 15 bits per hint to play with here.
In order to overflow gracefully (nothing breaks, efficiency
just drops), encode as the difference from the extremes. */
{
unsigned long loval=lo;
unsigned long hival=n-hi;
if(loval>0x7fff)loval=0x7fff;
if(hival>0x7fff)hival=0x7fff;
c->dec_firsttable[bitreverse(word)]=
0x80000000UL | (loval<<15) | hival;
}
}
}
}
}

View file

@ -20,8 +20,8 @@
extern const void *_vorbis_window(int type,int left);
extern void _vorbis_apply_window(ogg_int32_t *d,const void *window[2],
long *blocksizes,
int lW,int W,int nW);
long *blocksizes,
int lW,int W,int nW);
#endif

View file

@ -409,13 +409,13 @@ static void decorr_stereo_pass_17 (struct decorr_pass *dpp, int32_t *bptr, int32
int32_t sam;
while (bptr < eptr) {
sam = 2 * dpp->samples_A [0] - dpp->samples_A [1];
sam = 2 * dpp->samples_A [0] - dpp->samples_A [1];
dpp->samples_A [1] = dpp->samples_A [0];
dpp->samples_A [0] = bptr [0];
bptr [0] -= apply_weight_i (dpp->weight_A, sam);
update_weight (dpp->weight_A, 2, sam, bptr [0]);
bptr++;
sam = 2 * dpp->samples_B [0] - dpp->samples_B [1];
sam = 2 * dpp->samples_B [0] - dpp->samples_B [1];
dpp->samples_B [1] = dpp->samples_B [0];
dpp->samples_B [0] = bptr [0];
bptr [0] -= apply_weight_i (dpp->weight_B, sam);

View file

@ -10,14 +10,14 @@
struct asf_waveformatex_s {
uint32_t packet_size;
int audiostream;
uint16_t codec_id;
uint16_t channels;
uint32_t rate;
uint32_t bitrate;
uint16_t blockalign;
uint16_t bitspersample;
uint16_t datalen;
uint8_t data[6];
uint16_t codec_id;
uint16_t channels;
uint32_t rate;
uint32_t bitrate;
uint16_t blockalign;
uint16_t bitspersample;
uint16_t datalen;
uint8_t data[6];
};
typedef struct asf_waveformatex_s asf_waveformatex_t;