diff options
Diffstat (limited to 'libmpeg2/idct_alpha.c')
-rw-r--r-- | libmpeg2/idct_alpha.c | 75 |
1 files changed, 37 insertions, 38 deletions
diff --git a/libmpeg2/idct_alpha.c b/libmpeg2/idct_alpha.c index bc3ad479ae..bc8bd7b673 100644 --- a/libmpeg2/idct_alpha.c +++ b/libmpeg2/idct_alpha.c @@ -1,7 +1,7 @@ /* * idct_alpha.c - * Copyright (C) 2002 Falk Hueffner <falk@debian.org> - * Copyright (C) 2000-2002 Michel Lespinasse <walken@zoy.org> + * Copyright (C) 2002-2003 Falk Hueffner <falk@debian.org> + * Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org> * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca> * * This file is part of mpeg2dec, a free MPEG-2 video stream decoder. @@ -29,24 +29,26 @@ #include <stdlib.h> #include <inttypes.h> -#include "alpha_asm.h" +#include "mpeg2.h" #include "attributes.h" +#include "mpeg2_internal.h" +#include "alpha_asm.h" -#define W1 2841 /* 2048*sqrt (2)*cos (1*pi/16) */ -#define W2 2676 /* 2048*sqrt (2)*cos (2*pi/16) */ -#define W3 2408 /* 2048*sqrt (2)*cos (3*pi/16) */ -#define W5 1609 /* 2048*sqrt (2)*cos (5*pi/16) */ -#define W6 1108 /* 2048*sqrt (2)*cos (6*pi/16) */ -#define W7 565 /* 2048*sqrt (2)*cos (7*pi/16) */ +#define W1 2841 /* 2048 * sqrt (2) * cos (1 * pi / 16) */ +#define W2 2676 /* 2048 * sqrt (2) * cos (2 * pi / 16) */ +#define W3 2408 /* 2048 * sqrt (2) * cos (3 * pi / 16) */ +#define W5 1609 /* 2048 * sqrt (2) * cos (5 * pi / 16) */ +#define W6 1108 /* 2048 * sqrt (2) * cos (6 * pi / 16) */ +#define W7 565 /* 2048 * sqrt (2) * cos (7 * pi / 16) */ -static uint8_t clip_lut[1024]; -#define CLIP(i) ((clip_lut+384)[(i)]) +extern uint8_t mpeg2_clip[3840 * 2 + 256]; +#define CLIP(i) ((mpeg2_clip + 3840)[i]) #if 0 #define BUTTERFLY(t0,t1,W0,W1,d0,d1) \ do { \ - t0 = W0*d0 + W1*d1; \ - t1 = W0*d1 - W1*d0; \ + t0 = W0 * d0 + W1 * d1; \ + t1 = W0 * d1 - W1 * d0; \ } while (0) #else #define BUTTERFLY(t0,t1,W0,W1,d0,d1) \ @@ -69,7 +71,7 @@ static inline void idct_row (int16_t * const block) /* shortcut */ if (likely (!((l & ~0xffffUL) | r))) { - uint64_t tmp = (uint16_t) (l << 3); + uint64_t tmp = (uint16_t) (l >> 1); tmp |= tmp << 16; tmp |= tmp << 32; ((int32_t *)block)[0] = tmp; @@ -79,7 +81,7 @@ static inline void idct_row (int16_t * const block) return; } - d0 = (sextw (l) << 11) + 128; + d0 = (sextw (l) << 11) + 2048; d1 = sextw (extwl (l, 2)); d2 = sextw (extwl (l, 4)) << 11; d3 = sextw (extwl (l, 6)); @@ -101,17 +103,17 @@ static inline void idct_row (int16_t * const block) b3 = t1 + t3; t0 -= t2; t1 -= t3; - b1 = ((t0 + t1) * 181) >> 8; - b2 = ((t0 - t1) * 181) >> 8; - - block[0] = (a0 + b0) >> 8; - block[1] = (a1 + b1) >> 8; - block[2] = (a2 + b2) >> 8; - block[3] = (a3 + b3) >> 8; - block[4] = (a3 - b3) >> 8; - block[5] = (a2 - b2) >> 8; - block[6] = (a1 - b1) >> 8; - block[7] = (a0 - b0) >> 8; + b1 = ((t0 + t1) >> 8) * 181; + b2 = ((t0 - t1) >> 8) * 181; + + block[0] = (a0 + b0) >> 12; + block[1] = (a1 + b1) >> 12; + block[2] = (a2 + b2) >> 12; + block[3] = (a3 + b3) >> 12; + block[4] = (a3 - b3) >> 12; + block[5] = (a2 - b2) >> 12; + block[6] = (a1 - b1) >> 12; + block[7] = (a0 - b0) >> 12; } static inline void idct_col (int16_t * const block) @@ -140,10 +142,10 @@ static inline void idct_col (int16_t * const block) BUTTERFLY (t2, t3, W3, W5, d1, d2); b0 = t0 + t2; b3 = t1 + t3; - t0 = (t0 - t2) >> 8; - t1 = (t1 - t3) >> 8; - b1 = (t0 + t1) * 181; - b2 = (t0 - t1) * 181; + t0 -= t2; + t1 -= t3; + b1 = ((t0 + t1) >> 8) * 181; + b2 = ((t0 - t1) >> 8) * 181; block[8*0] = (a0 + b0) >> 17; block[8*1] = (a1 + b1) >> 17; @@ -196,7 +198,7 @@ void mpeg2_idct_add_mvi (const int last, int16_t * block, uint64_t signmask; int i; - if (last != 129 || (block[0] & 7) == 4) { + if (last != 129 || (block[0] & (7 << 4)) == (4 << 4)) { for (i = 0; i < 8; i++) idct_row (block + 8 * i); for (i = 0; i < 8; i++) @@ -244,7 +246,7 @@ void mpeg2_idct_add_mvi (const int last, int16_t * block, uint64_t p0, p1, p2, p3, p4, p5, p6, p7; uint64_t DCs; - DC = (block[0] + 4) >> 3; + DC = (block[0] + 64) >> 7; block[0] = block[63] = 0; p0 = ldq (dest + 0 * stride); @@ -321,7 +323,7 @@ void mpeg2_idct_add_alpha (const int last, int16_t * block, { int i; - if (last != 129 || (block[0] & 7) == 4) { + if (last != 129 || (block[0] & (7 << 4)) == (4 << 4)) { for (i = 0; i < 8; i++) idct_row (block + 8 * i); for (i = 0; i < 8; i++) @@ -345,7 +347,7 @@ void mpeg2_idct_add_alpha (const int last, int16_t * block, } else { int DC; - DC = (block[0] + 4) >> 3; + DC = (block[0] + 64) >> 7; block[0] = block[63] = 0; i = 8; do { @@ -362,15 +364,12 @@ void mpeg2_idct_add_alpha (const int last, int16_t * block, } } -void mpeg2_idct_alpha_init(int no_mvi) +void mpeg2_idct_alpha_init (void) { extern uint8_t mpeg2_scan_norm[64]; extern uint8_t mpeg2_scan_alt[64]; int i, j; - if (no_mvi) - for (i = -384; i < 640; i++) - clip_lut[i + 384] = (i < 0) ? 0 : ((i > 255) ? 255 : i); for (i = 0; i < 64; i++) { j = mpeg2_scan_norm[i]; mpeg2_scan_norm[i] = ((j & 0x36) >> 1) | ((j & 0x09) << 2); |