diff options
-rw-r--r-- | apps/codecs/libmad/bit.c | 20 | ||||
-rw-r--r-- | apps/codecs/libmad/bit.h | 8 | ||||
-rw-r--r-- | apps/codecs/libmad/synth.c | 7 |
3 files changed, 20 insertions, 15 deletions
diff --git a/apps/codecs/libmad/bit.c b/apps/codecs/libmad/bit.c index 6c984ef078..f132347c25 100644 --- a/apps/codecs/libmad/bit.c +++ b/apps/codecs/libmad/bit.c | |||
@@ -82,14 +82,18 @@ unsigned short const crc_table[256] = { | |||
82 | 82 | ||
83 | # define CRC_POLY 0x8005 | 83 | # define CRC_POLY 0x8005 |
84 | 84 | ||
85 | #if INT_MAX != 0x7fffffff | ||
86 | #warning current libmad bit handling is optimized for architectures using 32 bit integers | ||
87 | #endif | ||
88 | |||
85 | /* | 89 | /* |
86 | * NAME: bit->init() | 90 | * NAME: bit->init() |
87 | * DESCRIPTION: initialize bit pointer struct | 91 | * DESCRIPTION: initialize bit pointer struct |
88 | */ | 92 | */ |
89 | void mad_bit_init(struct mad_bitptr *bitptr, unsigned char const *byte) | 93 | void mad_bit_init(struct mad_bitptr *bitptr, unsigned char const *byte) |
90 | { | 94 | { |
91 | bitptr->ptr = (unsigned long*)((long)byte & ~3); | 95 | bitptr->ptr = (uint32_t*)((uintptr_t)byte & ~3); |
92 | bitptr->readbit = ((unsigned long)byte & 3) << 3; | 96 | bitptr->readbit = ((uintptr_t)byte & 3) << 3; |
93 | } | 97 | } |
94 | 98 | ||
95 | /* | 99 | /* |
@@ -129,14 +133,14 @@ void mad_bit_skip(struct mad_bitptr *bitptr, unsigned int len) | |||
129 | * DESCRIPTION: read an arbitrary number of bits and return their UIMSBF value | 133 | * DESCRIPTION: read an arbitrary number of bits and return their UIMSBF value |
130 | */ | 134 | */ |
131 | 135 | ||
132 | unsigned long mad_bit_read(struct mad_bitptr *bitptr, unsigned int len) ICODE_ATTR; | 136 | uint32_t mad_bit_read(struct mad_bitptr *bitptr, unsigned int len) ICODE_ATTR; |
133 | unsigned long mad_bit_read(struct mad_bitptr *bitptr, unsigned int len) | 137 | uint32_t mad_bit_read(struct mad_bitptr *bitptr, unsigned int len) |
134 | { | 138 | { |
135 | unsigned long *curr = &bitptr->ptr[bitptr->readbit>>5]; | 139 | uint32_t *curr = &bitptr->ptr[bitptr->readbit>>5]; |
136 | 140 | ||
137 | if(len) | 141 | if(len) |
138 | { | 142 | { |
139 | unsigned long r = betoh32(curr[0]) << (bitptr->readbit & 31); | 143 | uint32_t r = betoh32(curr[0]) << (bitptr->readbit & 31); |
140 | 144 | ||
141 | if((bitptr->readbit & 31) + len > 32) | 145 | if((bitptr->readbit & 31) + len > 32) |
142 | r += betoh32(curr[1]) >> (-bitptr->readbit & 31); | 146 | r += betoh32(curr[1]) >> (-bitptr->readbit & 31); |
@@ -154,7 +158,7 @@ unsigned long mad_bit_read(struct mad_bitptr *bitptr, unsigned int len) | |||
154 | * DESCRIPTION: write an arbitrary number of bits | 158 | * DESCRIPTION: write an arbitrary number of bits |
155 | */ | 159 | */ |
156 | void mad_bit_write(struct mad_bitptr *bitptr, unsigned int len, | 160 | void mad_bit_write(struct mad_bitptr *bitptr, unsigned int len, |
157 | unsigned long value) | 161 | uint32_t value) |
158 | { | 162 | { |
159 | unsigned char *ptr; | 163 | unsigned char *ptr; |
160 | 164 | ||
@@ -174,7 +178,7 @@ unsigned short mad_bit_crc(struct mad_bitptr bitptr, unsigned int len, | |||
174 | register unsigned int crc; | 178 | register unsigned int crc; |
175 | 179 | ||
176 | for (crc = init; len >= 32; len -= 32) { | 180 | for (crc = init; len >= 32; len -= 32) { |
177 | register unsigned long data; | 181 | register uint32_t data; |
178 | 182 | ||
179 | data = mad_bit_read(&bitptr, 32); | 183 | data = mad_bit_read(&bitptr, 32); |
180 | 184 | ||
diff --git a/apps/codecs/libmad/bit.h b/apps/codecs/libmad/bit.h index 026b501b57..615cabee89 100644 --- a/apps/codecs/libmad/bit.h +++ b/apps/codecs/libmad/bit.h | |||
@@ -23,8 +23,8 @@ | |||
23 | # define LIBMAD_BIT_H | 23 | # define LIBMAD_BIT_H |
24 | 24 | ||
25 | struct mad_bitptr { | 25 | struct mad_bitptr { |
26 | unsigned long *ptr; | 26 | uint32_t *ptr; |
27 | unsigned long readbit; | 27 | uint32_t readbit; |
28 | }; | 28 | }; |
29 | 29 | ||
30 | void mad_bit_init(struct mad_bitptr *, unsigned char const *); | 30 | void mad_bit_init(struct mad_bitptr *, unsigned char const *); |
@@ -38,8 +38,8 @@ unsigned char mad_bit_bitsleft(struct mad_bitptr const *bitptr); | |||
38 | unsigned char const *mad_bit_nextbyte(struct mad_bitptr const *); | 38 | unsigned char const *mad_bit_nextbyte(struct mad_bitptr const *); |
39 | 39 | ||
40 | void mad_bit_skip(struct mad_bitptr *, unsigned int); | 40 | void mad_bit_skip(struct mad_bitptr *, unsigned int); |
41 | unsigned long mad_bit_read(struct mad_bitptr *, unsigned int); | 41 | uint32_t mad_bit_read(struct mad_bitptr *, unsigned int); |
42 | void mad_bit_write(struct mad_bitptr *, unsigned int, unsigned long); | 42 | void mad_bit_write(struct mad_bitptr *, unsigned int, uint32_t); |
43 | 43 | ||
44 | unsigned short mad_bit_crc(struct mad_bitptr, unsigned int, unsigned short); | 44 | unsigned short mad_bit_crc(struct mad_bitptr, unsigned int, unsigned short); |
45 | 45 | ||
diff --git a/apps/codecs/libmad/synth.c b/apps/codecs/libmad/synth.c index 6f5d2ec975..c023f01ae5 100644 --- a/apps/codecs/libmad/synth.c +++ b/apps/codecs/libmad/synth.c | |||
@@ -589,7 +589,8 @@ static | |||
589 | void synth_full(struct mad_synth *synth, struct mad_frame const *frame, | 589 | void synth_full(struct mad_synth *synth, struct mad_frame const *frame, |
590 | unsigned int nch, unsigned int ns) | 590 | unsigned int nch, unsigned int ns) |
591 | { | 591 | { |
592 | unsigned int phase, ch, s, sb, p; | 592 | int sb; |
593 | unsigned int phase, ch, s, p; | ||
593 | mad_fixed_t *pcm, (*filter)[2][2][16][8]; | 594 | mad_fixed_t *pcm, (*filter)[2][2][16][8]; |
594 | mad_fixed_t const (*sbsample)[36][32]; | 595 | mad_fixed_t const (*sbsample)[36][32]; |
595 | mad_fixed_t (*fe)[8], (*fx)[8], (*fo)[8]; | 596 | mad_fixed_t (*fe)[8], (*fx)[8], (*fo)[8]; |
@@ -1190,8 +1191,8 @@ static | |||
1190 | void synth_full(struct mad_synth *synth, struct mad_frame const *frame, | 1191 | void synth_full(struct mad_synth *synth, struct mad_frame const *frame, |
1191 | unsigned int nch, unsigned int ns) | 1192 | unsigned int nch, unsigned int ns) |
1192 | { | 1193 | { |
1193 | int p; | 1194 | int p, sb; |
1194 | unsigned int phase, ch, s, sb; | 1195 | unsigned int phase, ch, s; |
1195 | mad_fixed_t *pcm, (*filter)[2][2][16][8]; | 1196 | mad_fixed_t *pcm, (*filter)[2][2][16][8]; |
1196 | mad_fixed_t const (*sbsample)[36][32]; | 1197 | mad_fixed_t const (*sbsample)[36][32]; |
1197 | mad_fixed_t (*fe)[8], (*fx)[8], (*fo)[8]; | 1198 | mad_fixed_t (*fe)[8], (*fx)[8], (*fo)[8]; |