forked from len0rd/rockbox
Stop libmad from crashing on 64 bit simulators.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14636 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
b69556f3eb
commit
aebeabdade
3 changed files with 20 additions and 15 deletions
|
|
@ -82,14 +82,18 @@ unsigned short const crc_table[256] = {
|
||||||
|
|
||||||
# define CRC_POLY 0x8005
|
# define CRC_POLY 0x8005
|
||||||
|
|
||||||
|
#if INT_MAX != 0x7fffffff
|
||||||
|
#warning current libmad bit handling is optimized for architectures using 32 bit integers
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* NAME: bit->init()
|
* NAME: bit->init()
|
||||||
* DESCRIPTION: initialize bit pointer struct
|
* DESCRIPTION: initialize bit pointer struct
|
||||||
*/
|
*/
|
||||||
void mad_bit_init(struct mad_bitptr *bitptr, unsigned char const *byte)
|
void mad_bit_init(struct mad_bitptr *bitptr, unsigned char const *byte)
|
||||||
{
|
{
|
||||||
bitptr->ptr = (unsigned long*)((long)byte & ~3);
|
bitptr->ptr = (uint32_t*)((uintptr_t)byte & ~3);
|
||||||
bitptr->readbit = ((unsigned long)byte & 3) << 3;
|
bitptr->readbit = ((uintptr_t)byte & 3) << 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -129,14 +133,14 @@ void mad_bit_skip(struct mad_bitptr *bitptr, unsigned int len)
|
||||||
* DESCRIPTION: read an arbitrary number of bits and return their UIMSBF value
|
* DESCRIPTION: read an arbitrary number of bits and return their UIMSBF value
|
||||||
*/
|
*/
|
||||||
|
|
||||||
unsigned long mad_bit_read(struct mad_bitptr *bitptr, unsigned int len) ICODE_ATTR;
|
uint32_t mad_bit_read(struct mad_bitptr *bitptr, unsigned int len) ICODE_ATTR;
|
||||||
unsigned long mad_bit_read(struct mad_bitptr *bitptr, unsigned int len)
|
uint32_t mad_bit_read(struct mad_bitptr *bitptr, unsigned int len)
|
||||||
{
|
{
|
||||||
unsigned long *curr = &bitptr->ptr[bitptr->readbit>>5];
|
uint32_t *curr = &bitptr->ptr[bitptr->readbit>>5];
|
||||||
|
|
||||||
if(len)
|
if(len)
|
||||||
{
|
{
|
||||||
unsigned long r = betoh32(curr[0]) << (bitptr->readbit & 31);
|
uint32_t r = betoh32(curr[0]) << (bitptr->readbit & 31);
|
||||||
|
|
||||||
if((bitptr->readbit & 31) + len > 32)
|
if((bitptr->readbit & 31) + len > 32)
|
||||||
r += betoh32(curr[1]) >> (-bitptr->readbit & 31);
|
r += betoh32(curr[1]) >> (-bitptr->readbit & 31);
|
||||||
|
|
@ -154,7 +158,7 @@ unsigned long mad_bit_read(struct mad_bitptr *bitptr, unsigned int len)
|
||||||
* DESCRIPTION: write an arbitrary number of bits
|
* DESCRIPTION: write an arbitrary number of bits
|
||||||
*/
|
*/
|
||||||
void mad_bit_write(struct mad_bitptr *bitptr, unsigned int len,
|
void mad_bit_write(struct mad_bitptr *bitptr, unsigned int len,
|
||||||
unsigned long value)
|
uint32_t value)
|
||||||
{
|
{
|
||||||
unsigned char *ptr;
|
unsigned char *ptr;
|
||||||
|
|
||||||
|
|
@ -174,7 +178,7 @@ unsigned short mad_bit_crc(struct mad_bitptr bitptr, unsigned int len,
|
||||||
register unsigned int crc;
|
register unsigned int crc;
|
||||||
|
|
||||||
for (crc = init; len >= 32; len -= 32) {
|
for (crc = init; len >= 32; len -= 32) {
|
||||||
register unsigned long data;
|
register uint32_t data;
|
||||||
|
|
||||||
data = mad_bit_read(&bitptr, 32);
|
data = mad_bit_read(&bitptr, 32);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,8 +23,8 @@
|
||||||
# define LIBMAD_BIT_H
|
# define LIBMAD_BIT_H
|
||||||
|
|
||||||
struct mad_bitptr {
|
struct mad_bitptr {
|
||||||
unsigned long *ptr;
|
uint32_t *ptr;
|
||||||
unsigned long readbit;
|
uint32_t readbit;
|
||||||
};
|
};
|
||||||
|
|
||||||
void mad_bit_init(struct mad_bitptr *, unsigned char const *);
|
void mad_bit_init(struct mad_bitptr *, unsigned char const *);
|
||||||
|
|
@ -38,8 +38,8 @@ unsigned char mad_bit_bitsleft(struct mad_bitptr const *bitptr);
|
||||||
unsigned char const *mad_bit_nextbyte(struct mad_bitptr const *);
|
unsigned char const *mad_bit_nextbyte(struct mad_bitptr const *);
|
||||||
|
|
||||||
void mad_bit_skip(struct mad_bitptr *, unsigned int);
|
void mad_bit_skip(struct mad_bitptr *, unsigned int);
|
||||||
unsigned long mad_bit_read(struct mad_bitptr *, unsigned int);
|
uint32_t mad_bit_read(struct mad_bitptr *, unsigned int);
|
||||||
void mad_bit_write(struct mad_bitptr *, unsigned int, unsigned long);
|
void mad_bit_write(struct mad_bitptr *, unsigned int, uint32_t);
|
||||||
|
|
||||||
unsigned short mad_bit_crc(struct mad_bitptr, unsigned int, unsigned short);
|
unsigned short mad_bit_crc(struct mad_bitptr, unsigned int, unsigned short);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -589,7 +589,8 @@ static
|
||||||
void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
|
void synth_full(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, p;
|
int sb;
|
||||||
|
unsigned int phase, ch, s, p;
|
||||||
mad_fixed_t *pcm, (*filter)[2][2][16][8];
|
mad_fixed_t *pcm, (*filter)[2][2][16][8];
|
||||||
mad_fixed_t const (*sbsample)[36][32];
|
mad_fixed_t const (*sbsample)[36][32];
|
||||||
mad_fixed_t (*fe)[8], (*fx)[8], (*fo)[8];
|
mad_fixed_t (*fe)[8], (*fx)[8], (*fo)[8];
|
||||||
|
|
@ -1190,8 +1191,8 @@ static
|
||||||
void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
|
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;
|
int p, sb;
|
||||||
unsigned int phase, ch, s, sb;
|
unsigned int phase, ch, s;
|
||||||
mad_fixed_t *pcm, (*filter)[2][2][16][8];
|
mad_fixed_t *pcm, (*filter)[2][2][16][8];
|
||||||
mad_fixed_t const (*sbsample)[36][32];
|
mad_fixed_t const (*sbsample)[36][32];
|
||||||
mad_fixed_t (*fe)[8], (*fx)[8], (*fo)[8];
|
mad_fixed_t (*fe)[8], (*fx)[8], (*fo)[8];
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue