openbsd-ports/audio/mpg123/patches/patch-layer3_c
2006-05-29 19:34:59 +00:00

98 lines
3.1 KiB
Plaintext

$OpenBSD: patch-layer3_c,v 1.4 2006/05/29 19:34:59 bernd Exp $
--- layer3.c.orig Wed Apr 21 17:25:18 1999
+++ layer3.c Mon May 29 10:55:42 2006
@@ -608,12 +608,21 @@ static int pretab2[22] = {0,0,0,0,0,0,0,
* Dequantize samples (includes huffman decoding)
*/
/* 24 is enough because tab13 has max. a 19 bit huffvector */
+#if defined(__LP64__)
+#define BITSHIFT ((sizeof(int)-1)*8)
+#define REFRESH_MASK \
+ while(num < BITSHIFT) { \
+ mask |= getbyte()<<(BITSHIFT-num); \
+ num += 8; \
+ part2remain -= 8; }
+#else
#define BITSHIFT ((sizeof(long)-1)*8)
#define REFRESH_MASK \
while(num < BITSHIFT) { \
mask |= getbyte()<<(BITSHIFT-num); \
num += 8; \
part2remain -= 8; }
+#endif
static int III_dequantize_sample(real xr[SBLIMIT][SSLIMIT],int *scf,
struct gr_info_s *gr_info,int sfreq,int part2bits)
@@ -625,7 +634,11 @@ static int III_dequantize_sample(real xr
int *me;
int num=getbitoffset();
+#if defined(__LP64__)
+ int mask = (int) getbits(num)<<(BITSHIFT+8-num);
+#else
long mask = (long) getbits(num)<<(BITSHIFT+8-num);
+#endif
part2remain -= num;
{
@@ -709,7 +722,11 @@ static int III_dequantize_sample(real xr
if(x == 15 && h->linbits) {
max[lwin] = cb;
REFRESH_MASK;
+#if defined(__LP64__)
+ x += ((unsigned int) mask) >> (BITSHIFT+8-h->linbits);
+#else
x += ((unsigned long) mask) >> (BITSHIFT+8-h->linbits);
+#endif
num -= h->linbits+1;
mask <<= h->linbits;
if(mask < 0)
@@ -733,7 +750,11 @@ static int III_dequantize_sample(real xr
if(y == 15 && h->linbits) {
max[lwin] = cb;
REFRESH_MASK;
+#if defined(__LP64__)
+ y += ((unsigned int) mask) >> (BITSHIFT+8-h->linbits);
+#else
y += ((unsigned long) mask) >> (BITSHIFT+8-h->linbits);
+#endif
num -= h->linbits+1;
mask <<= h->linbits;
if(mask < 0)
@@ -883,7 +904,11 @@ static int III_dequantize_sample(real xr
if (x == 15 && h->linbits) {
max = cb;
REFRESH_MASK;
+#if defined(__LP64__)
+ x += ((unsigned int) mask) >> (BITSHIFT+8-h->linbits);
+#else
x += ((unsigned long) mask) >> (BITSHIFT+8-h->linbits);
+#endif
num -= h->linbits+1;
mask <<= h->linbits;
if(mask < 0)
@@ -907,7 +932,11 @@ static int III_dequantize_sample(real xr
if (y == 15 && h->linbits) {
max = cb;
REFRESH_MASK;
+#if defined(__LP64__)
+ y += ((unsigned int) mask) >> (BITSHIFT+8-h->linbits);
+#else
y += ((unsigned long) mask) >> (BITSHIFT+8-h->linbits);
+#endif
num -= h->linbits+1;
mask <<= h->linbits;
if(mask < 0)
@@ -1119,7 +1148,10 @@ maybe still wrong??? (copy 12 to 13?) */
}
else { /* ((gr_info->block_type != 2)) */
int sfb = gr_info->maxbandl;
- int is_p,idx = bi->longIdx[sfb];
+ int is_p,idx;
+ if (sfb > 21)
+ return;
+ idx = bi->longIdx[sfb];
for ( ; sfb<21; sfb++) {
int sb = bi->longDiff[sfb];
is_p = scalefac[sfb]; /* scale: 0-15 */