forked from len0rd/rockbox
Change liba52 and libmad to the original 8-spaced tabbing.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@24863 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
398b37124e
commit
3f5f3524d4
30 changed files with 2784 additions and 2784 deletions
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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; \
|
||||
#define UPDATE_LEAK() \
|
||||
do { \
|
||||
fastleak += fdecay; \
|
||||
if (fastleak > psd + fgain) \
|
||||
fastleak = psd + fgain; \
|
||||
slowleak += sdecay; \
|
||||
fastleak = psd + fgain; \
|
||||
slowleak += sdecay; \
|
||||
if (slowleak > psd + sgain) \
|
||||
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;
|
||||
|
|
@ -141,17 +141,17 @@ void a52_bit_allocate (a52_state_t * state, ba_t * ba, int bndstart,
|
|||
|
||||
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 */
|
||||
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;
|
||||
|
||||
|
|
@ -161,105 +161,105 @@ 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;
|
||||
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;
|
||||
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++;
|
||||
}
|
||||
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;
|
||||
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);
|
||||
|
||||
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++;
|
||||
}
|
||||
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;
|
||||
|
||||
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;
|
||||
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;
|
||||
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);
|
||||
/* 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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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,153 +177,153 @@ 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 */
|
||||
|
|
@ -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)
|
||||
if (slev == 0)
|
||||
break;
|
||||
mix21to2 (samples, samples + 256);
|
||||
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)
|
||||
if (slev == 0)
|
||||
break;
|
||||
mix2to1 (samples, samples + 512);
|
||||
mix2to1 (samples + 256, samples + 768);
|
||||
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)
|
||||
if (slev == 0)
|
||||
break;
|
||||
mix21to2 (samples, samples + 512);
|
||||
break;
|
||||
mix21to2 (samples, samples + 512);
|
||||
break;
|
||||
|
||||
case CONVERT (A52_3F2R, A52_3F):
|
||||
if (slev == 0)
|
||||
if (slev == 0)
|
||||
break;
|
||||
mix2to1 (samples, samples + 768);
|
||||
mix2to1 (samples + 512, samples + 1024);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 { \
|
||||
#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 { \
|
||||
#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; \
|
||||
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;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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};
|
||||
|
|
|
|||
|
|
@ -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
|
|
@ -87,7 +87,7 @@ unsigned short const crc_table[256] = {
|
|||
#endif
|
||||
|
||||
/*
|
||||
* NAME: bit->init()
|
||||
* 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()
|
||||
* 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,7 +111,7 @@ unsigned char mad_bit_bitsleft(struct mad_bitptr const *bitptr)
|
|||
return 8 - (bitptr->readbit & 7);
|
||||
}
|
||||
/*
|
||||
* NAME: bit->nextbyte()
|
||||
* NAME: bit->nextbyte()
|
||||
* DESCRIPTION: return pointer to next unprocessed byte
|
||||
*/
|
||||
unsigned char const *mad_bit_nextbyte(struct mad_bitptr const *bitptr)
|
||||
|
|
@ -120,7 +120,7 @@ unsigned char const *mad_bit_nextbyte(struct mad_bitptr const *bitptr)
|
|||
}
|
||||
|
||||
/*
|
||||
* NAME: bit->skip()
|
||||
* NAME: bit->skip()
|
||||
* DESCRIPTION: advance bit pointer
|
||||
*/
|
||||
void mad_bit_skip(struct mad_bitptr *bitptr, unsigned int len)
|
||||
|
|
@ -129,7 +129,7 @@ void mad_bit_skip(struct mad_bitptr *bitptr, unsigned int len)
|
|||
}
|
||||
|
||||
/*
|
||||
* NAME: bit->read()
|
||||
* NAME: bit->read()
|
||||
* DESCRIPTION: read an arbitrary number of bits and return their UIMSBF value
|
||||
*/
|
||||
|
||||
|
|
@ -154,11 +154,11 @@ uint32_t mad_bit_read(struct mad_bitptr *bitptr, unsigned int len)
|
|||
|
||||
# if 0
|
||||
/*
|
||||
* NAME: bit->write()
|
||||
* 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()
|
||||
* 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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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 *);
|
||||
|
|
|
|||
|
|
@ -51,25 +51,25 @@
|
|||
# include "decoder.h"
|
||||
|
||||
/*
|
||||
* NAME: decoder->init()
|
||||
* 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,7 +528,7 @@ int run_async(struct mad_decoder *decoder)
|
|||
# endif
|
||||
|
||||
/*
|
||||
* NAME: decoder->run()
|
||||
* 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()
|
||||
* 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 ||
|
||||
|
|
|
|||
|
|
@ -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) \
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
# include "fixed.h"
|
||||
|
||||
/*
|
||||
* NAME: fixed->abs()
|
||||
* NAME: fixed->abs()
|
||||
* DESCRIPTION: return absolute value of a fixed-point number
|
||||
*/
|
||||
mad_fixed_t mad_f_abs(mad_fixed_t x)
|
||||
|
|
@ -37,7 +37,7 @@ mad_fixed_t mad_f_abs(mad_fixed_t x)
|
|||
}
|
||||
|
||||
/*
|
||||
* NAME: fixed->div()
|
||||
* NAME: fixed->div()
|
||||
* DESCRIPTION: perform division using fixed-point math
|
||||
*/
|
||||
mad_fixed_t mad_f_div(mad_fixed_t x, mad_fixed_t y)
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
: "=&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))
|
||||
: "+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")
|
||||
"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; \
|
||||
})
|
||||
|
||||
|
|
@ -300,14 +300,14 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
|
|||
*/
|
||||
# define MAD_F_MLX(hi, lo, x, y) \
|
||||
asm ("mult %2,%3" \
|
||||
: "=l" (lo), "=h" (hi) \
|
||||
: "%r" (x), "r" (y))
|
||||
: "=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))
|
||||
: "+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
|
||||
|
|
@ -315,12 +315,12 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
|
|||
*/
|
||||
# define MAD_F_ML0(hi, lo, x, y) \
|
||||
asm ("mult %2,%3" \
|
||||
: "=l" (lo), "=h" (hi) \
|
||||
: "%r" ((x) >> 12), "r" ((y) >> 16))
|
||||
: "=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) \
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ int (*const decoder_table[3])(struct mad_stream *, struct mad_frame *) = {
|
|||
};
|
||||
|
||||
/*
|
||||
* NAME: header->init()
|
||||
* NAME: header->init()
|
||||
* DESCRIPTION: initialize header struct
|
||||
*/
|
||||
void mad_header_init(struct mad_header *header)
|
||||
|
|
@ -84,7 +84,7 @@ void mad_header_init(struct mad_header *header)
|
|||
}
|
||||
|
||||
/*
|
||||
* NAME: frame->init()
|
||||
* NAME: frame->init()
|
||||
* DESCRIPTION: initialize frame struct
|
||||
*/
|
||||
void mad_frame_init(struct mad_frame *frame)
|
||||
|
|
@ -98,7 +98,7 @@ void mad_frame_init(struct mad_frame *frame)
|
|||
}
|
||||
|
||||
/*
|
||||
* NAME: frame->finish()
|
||||
* NAME: frame->finish()
|
||||
* DESCRIPTION: deallocate any dynamic memory associated with frame
|
||||
*/
|
||||
void mad_frame_finish(struct mad_frame *frame)
|
||||
|
|
@ -112,7 +112,7 @@ void mad_frame_finish(struct mad_frame *frame)
|
|||
}
|
||||
|
||||
/*
|
||||
* NAME: decode_header()
|
||||
* NAME: decode_header()
|
||||
* DESCRIPTION: read header data and following CRC word
|
||||
*/
|
||||
static
|
||||
|
|
@ -231,7 +231,7 @@ int decode_header(struct mad_header *header, struct mad_stream *stream)
|
|||
}
|
||||
|
||||
/*
|
||||
* NAME: free_bitrate()
|
||||
* NAME: free_bitrate()
|
||||
* DESCRIPTION: attempt to discover the bitstream's free bitrate
|
||||
*/
|
||||
static
|
||||
|
|
@ -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,7 +293,7 @@ int free_bitrate(struct mad_stream *stream, struct mad_header const *header)
|
|||
}
|
||||
|
||||
/*
|
||||
* NAME: header->decode()
|
||||
* 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,7 +431,7 @@ int mad_header_decode(struct mad_header *header, struct mad_stream *stream)
|
|||
}
|
||||
|
||||
/*
|
||||
* NAME: frame->decode()
|
||||
* NAME: frame->decode()
|
||||
* DESCRIPTION: decode a single frame from a bitstream
|
||||
*/
|
||||
int mad_frame_decode(struct mad_frame *frame, struct mad_stream *stream)
|
||||
|
|
@ -479,7 +479,7 @@ int mad_frame_decode(struct mad_frame *frame, struct mad_stream *stream)
|
|||
}
|
||||
|
||||
/*
|
||||
* NAME: frame->mute()
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 *);
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -69,7 +69,7 @@ mad_fixed_t const linear_table[14] ICONST_ATTR = {
|
|||
};
|
||||
|
||||
/*
|
||||
* NAME: I_sample()
|
||||
* NAME: I_sample()
|
||||
* DESCRIPTION: decode one requantized Layer I sample from a bitstream
|
||||
*/
|
||||
static inline
|
||||
|
|
@ -99,7 +99,7 @@ mad_fixed_t I_sample(struct mad_bitptr *ptr, unsigned int nb)
|
|||
}
|
||||
|
||||
/*
|
||||
* NAME: layer->I()
|
||||
* 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()
|
||||
* 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,7 +326,7 @@ void II_samples(struct mad_bitptr *ptr,
|
|||
}
|
||||
|
||||
/*
|
||||
* NAME: layer->II()
|
||||
* 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
|
|
@ -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))
|
||||
: "=&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))
|
||||
: "+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")
|
||||
"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; \
|
||||
})
|
||||
|
||||
|
|
@ -338,14 +338,14 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
|
|||
*/
|
||||
# define MAD_F_MLX(hi, lo, x, y) \
|
||||
asm ("mult %2,%3" \
|
||||
: "=l" (lo), "=h" (hi) \
|
||||
: "%r" (x), "r" (y))
|
||||
: "=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))
|
||||
: "+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
|
||||
|
|
@ -353,12 +353,12 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
|
|||
*/
|
||||
# define MAD_F_ML0(hi, lo, x, y) \
|
||||
asm ("mult %2,%3" \
|
||||
: "=l" (lo), "=h" (hi) \
|
||||
: "%r" ((x) >> 12), "r" ((y) >> 16))
|
||||
: "=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,8 +566,8 @@ 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;
|
||||
|
|
@ -575,9 +575,9 @@ extern mad_timer_t const mad_timer_zero;
|
|||
# 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 */
|
||||
|
||||
|
|
@ -587,7 +587,7 @@ enum mad_units {
|
|||
|
||||
/* audio sample units */
|
||||
|
||||
MAD_UNITS_8000_HZ = 8000,
|
||||
MAD_UNITS_8000_HZ = 8000,
|
||||
MAD_UNITS_11025_HZ = 11025,
|
||||
MAD_UNITS_12000_HZ = 12000,
|
||||
|
||||
|
|
@ -601,16 +601,16 @@ enum mad_units {
|
|||
|
||||
/* 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 */
|
||||
|
||||
|
|
@ -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,16 +648,16 @@ 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 */
|
||||
|
|
@ -665,7 +665,7 @@ enum mad_error {
|
|||
MAD_ERROR_BADSAMPLERATE = 0x0104, /* reserved sample frequency value */
|
||||
MAD_ERROR_BADEMPHASIS = 0x0105, /* reserved emphasis value */
|
||||
|
||||
MAD_ERROR_BADCRC = 0x0201, /* CRC check failed */
|
||||
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 */
|
||||
|
|
@ -677,32 +677,32 @@ enum mad_error {
|
|||
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_BADSTEREO = 0x0239 /* incompatible block_type for JS */
|
||||
};
|
||||
|
||||
# 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 {
|
||||
|
|
@ -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,46 +738,46 @@ 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_prev)[2][36][32]; /* synthesis subband filter samples
|
||||
|
|
@ -787,33 +787,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 *);
|
||||
|
|
@ -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] */
|
||||
/* [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 */
|
||||
|
|
@ -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) \
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
# include "stream.h"
|
||||
|
||||
/*
|
||||
* NAME: stream->init()
|
||||
* NAME: stream->init()
|
||||
* DESCRIPTION: initialize stream struct
|
||||
*/
|
||||
void mad_stream_init(struct mad_stream *stream)
|
||||
|
|
@ -56,7 +56,7 @@ void mad_stream_init(struct mad_stream *stream)
|
|||
}
|
||||
|
||||
/*
|
||||
* NAME: stream->finish()
|
||||
* 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()
|
||||
* 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,7 +89,7 @@ void mad_stream_buffer(struct mad_stream *stream,
|
|||
}
|
||||
|
||||
/*
|
||||
* NAME: stream->skip()
|
||||
* NAME: stream->skip()
|
||||
* DESCRIPTION: arrange to skip bytes before the next frame
|
||||
*/
|
||||
void mad_stream_skip(struct mad_stream *stream, unsigned long length)
|
||||
|
|
@ -98,7 +98,7 @@ void mad_stream_skip(struct mad_stream *stream, unsigned long length)
|
|||
}
|
||||
|
||||
/*
|
||||
* NAME: stream->sync()
|
||||
* 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()
|
||||
* 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_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_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_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_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_BADSTEREO: return "incompatible block_type for JS";
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -24,16 +24,16 @@
|
|||
|
||||
# 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 */
|
||||
|
|
@ -41,7 +41,7 @@ enum mad_error {
|
|||
MAD_ERROR_BADSAMPLERATE = 0x0104, /* reserved sample frequency value */
|
||||
MAD_ERROR_BADEMPHASIS = 0x0105, /* reserved emphasis value */
|
||||
|
||||
MAD_ERROR_BADCRC = 0x0201, /* CRC check failed */
|
||||
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 */
|
||||
|
|
@ -53,32 +53,32 @@ enum mad_error {
|
|||
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_BADSTEREO = 0x0239 /* incompatible block_type for JS */
|
||||
};
|
||||
|
||||
# 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 {
|
||||
|
|
@ -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 *);
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@
|
|||
# include "synth.h"
|
||||
|
||||
/*
|
||||
* NAME: synth->init()
|
||||
* NAME: synth->init()
|
||||
* DESCRIPTION: initialize synth struct
|
||||
*/
|
||||
void mad_synth_init(struct mad_synth *synth)
|
||||
|
|
@ -50,7 +50,7 @@ void mad_synth_init(struct mad_synth *synth)
|
|||
}
|
||||
|
||||
/*
|
||||
* NAME: synth->mute()
|
||||
* 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()
|
||||
* 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,10 +576,10 @@ 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()
|
||||
* NAME: synth->full()
|
||||
* DESCRIPTION: perform full frequency PCM synthesis
|
||||
*/
|
||||
|
||||
|
|
@ -587,7 +587,7 @@ void synth_full(struct mad_synth *, struct mad_frame const *,
|
|||
# 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()
|
||||
* 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()
|
||||
* 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);
|
||||
|
|
|
|||
|
|
@ -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] */
|
||||
/* [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 */
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@
|
|||
mad_timer_t const mad_timer_zero = { 0, 0 };
|
||||
|
||||
/*
|
||||
* NAME: timer->compare()
|
||||
* NAME: timer->compare()
|
||||
* DESCRIPTION: indicate relative order of two timers
|
||||
*/
|
||||
int mad_timer_compare(mad_timer_t timer1, mad_timer_t timer2)
|
||||
|
|
@ -59,7 +59,7 @@ int mad_timer_compare(mad_timer_t timer1, mad_timer_t timer2)
|
|||
}
|
||||
|
||||
/*
|
||||
* NAME: timer->negate()
|
||||
* NAME: timer->negate()
|
||||
* DESCRIPTION: invert the sign of a timer
|
||||
*/
|
||||
void mad_timer_negate(mad_timer_t *timer)
|
||||
|
|
@ -73,7 +73,7 @@ void mad_timer_negate(mad_timer_t *timer)
|
|||
}
|
||||
|
||||
/*
|
||||
* NAME: timer->abs()
|
||||
* NAME: timer->abs()
|
||||
* DESCRIPTION: return the absolute value of a timer
|
||||
*/
|
||||
mad_timer_t mad_timer_abs(mad_timer_t timer)
|
||||
|
|
@ -85,7 +85,7 @@ mad_timer_t mad_timer_abs(mad_timer_t timer)
|
|||
}
|
||||
|
||||
/*
|
||||
* NAME: reduce_timer()
|
||||
* NAME: reduce_timer()
|
||||
* DESCRIPTION: carry timer fraction into seconds
|
||||
*/
|
||||
static
|
||||
|
|
@ -96,7 +96,7 @@ void reduce_timer(mad_timer_t *timer)
|
|||
}
|
||||
|
||||
/*
|
||||
* NAME: gcd()
|
||||
* NAME: gcd()
|
||||
* DESCRIPTION: compute greatest common denominator
|
||||
*/
|
||||
static
|
||||
|
|
@ -114,7 +114,7 @@ unsigned long gcd(unsigned long num1, unsigned long num2)
|
|||
}
|
||||
|
||||
/*
|
||||
* NAME: reduce_rational()
|
||||
* NAME: reduce_rational()
|
||||
* DESCRIPTION: convert rational expression to lowest terms
|
||||
*/
|
||||
static
|
||||
|
|
@ -131,12 +131,12 @@ void reduce_rational(unsigned long *numer, unsigned long *denom)
|
|||
}
|
||||
|
||||
/*
|
||||
* NAME: scale_rational()
|
||||
* 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()
|
||||
* 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,7 +224,7 @@ void mad_timer_set(mad_timer_t *timer, unsigned long seconds,
|
|||
}
|
||||
|
||||
/*
|
||||
* NAME: timer->add()
|
||||
* NAME: timer->add()
|
||||
* DESCRIPTION: add one timer to another
|
||||
*/
|
||||
void mad_timer_add(mad_timer_t *timer, mad_timer_t incr)
|
||||
|
|
@ -237,7 +237,7 @@ void mad_timer_add(mad_timer_t *timer, mad_timer_t incr)
|
|||
}
|
||||
|
||||
/*
|
||||
* NAME: timer->multiply()
|
||||
* NAME: timer->multiply()
|
||||
* DESCRIPTION: multiply a timer by a scalar value
|
||||
*/
|
||||
void mad_timer_multiply(mad_timer_t *timer, signed long scalar)
|
||||
|
|
@ -264,7 +264,7 @@ void mad_timer_multiply(mad_timer_t *timer, signed long scalar)
|
|||
}
|
||||
|
||||
/*
|
||||
* NAME: timer->count()
|
||||
* 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,7 +318,7 @@ signed long mad_timer_count(mad_timer_t timer, enum mad_units units)
|
|||
}
|
||||
|
||||
/*
|
||||
* NAME: timer->fraction()
|
||||
* 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()
|
||||
* 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:
|
||||
|
|
|
|||
|
|
@ -23,8 +23,8 @@
|
|||
# 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;
|
||||
|
|
@ -32,9 +32,9 @@ extern mad_timer_t const mad_timer_zero;
|
|||
# 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 */
|
||||
|
||||
|
|
@ -44,7 +44,7 @@ enum mad_units {
|
|||
|
||||
/* audio sample units */
|
||||
|
||||
MAD_UNITS_8000_HZ = 8000,
|
||||
MAD_UNITS_8000_HZ = 8000,
|
||||
MAD_UNITS_11025_HZ = 11025,
|
||||
MAD_UNITS_12000_HZ = 12000,
|
||||
|
||||
|
|
@ -58,16 +58,16 @@ enum mad_units {
|
|||
|
||||
/* 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 */
|
||||
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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[];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue