diff options
author | Mans Rullgard <mans@mansr.com> | 2011-07-21 09:48:29 +0100 |
---|---|---|
committer | Mans Rullgard <mans@mansr.com> | 2011-07-21 12:49:51 +0100 |
commit | a402f109599c589ba75f6d95cf071a205406d9d7 (patch) | |
tree | 9a99e2da8be04854449a9c8ae6a033a6842cbe46 | |
parent | 7df701a1925cc46cea5a01988cbabc1e6b3a49b1 (diff) | |
download | ffmpeg-a402f109599c589ba75f6d95cf071a205406d9d7.tar.gz |
simple_idct: make repeated code a macro
Signed-off-by: Mans Rullgard <mans@mansr.com>
-rw-r--r-- | libavcodec/simple_idct_template.c | 197 |
1 files changed, 53 insertions, 144 deletions
diff --git a/libavcodec/simple_idct_template.c b/libavcodec/simple_idct_template.c index 1b6115d41f..81845c962d 100644 --- a/libavcodec/simple_idct_template.c +++ b/libavcodec/simple_idct_template.c @@ -161,60 +161,63 @@ static inline void FUNC(idctRowCondDC)(DCTELEM *row) row[4] = (a3 - b3) >> ROW_SHIFT; } +#define IDCT_COLS do { \ + a0 = W4 * (col[8*0] + ((1<<(COL_SHIFT-1))/W4)); \ + a1 = a0; \ + a2 = a0; \ + a3 = a0; \ + \ + a0 += W2*col[8*2]; \ + a1 += W6*col[8*2]; \ + a2 += -W6*col[8*2]; \ + a3 += -W2*col[8*2]; \ + \ + b0 = MUL(W1, col[8*1]); \ + b1 = MUL(W3, col[8*1]); \ + b2 = MUL(W5, col[8*1]); \ + b3 = MUL(W7, col[8*1]); \ + \ + MAC(b0, W3, col[8*3]); \ + MAC(b1, -W7, col[8*3]); \ + MAC(b2, -W1, col[8*3]); \ + MAC(b3, -W5, col[8*3]); \ + \ + if (col[8*4]) { \ + a0 += W4*col[8*4]; \ + a1 += -W4*col[8*4]; \ + a2 += -W4*col[8*4]; \ + a3 += W4*col[8*4]; \ + } \ + \ + if (col[8*5]) { \ + MAC(b0, W5, col[8*5]); \ + MAC(b1, -W1, col[8*5]); \ + MAC(b2, W7, col[8*5]); \ + MAC(b3, W3, col[8*5]); \ + } \ + \ + if (col[8*6]) { \ + a0 += W6*col[8*6]; \ + a1 += -W2*col[8*6]; \ + a2 += W2*col[8*6]; \ + a3 += -W6*col[8*6]; \ + } \ + \ + if (col[8*7]) { \ + MAC(b0, W7, col[8*7]); \ + MAC(b1, -W5, col[8*7]); \ + MAC(b2, W3, col[8*7]); \ + MAC(b3, -W1, col[8*7]); \ + } \ + } while (0) + static inline void FUNC(idctSparseColPut)(pixel *dest, int line_size, DCTELEM *col) { int a0, a1, a2, a3, b0, b1, b2, b3; INIT_CLIP; - /* XXX: I did that only to give same values as previous code */ - a0 = W4 * (col[8*0] + ((1<<(COL_SHIFT-1))/W4)); - a1 = a0; - a2 = a0; - a3 = a0; - - a0 += + W2*col[8*2]; - a1 += + W6*col[8*2]; - a2 += - W6*col[8*2]; - a3 += - W2*col[8*2]; - - b0 = MUL(W1, col[8*1]); - b1 = MUL(W3, col[8*1]); - b2 = MUL(W5, col[8*1]); - b3 = MUL(W7, col[8*1]); - - MAC(b0, + W3, col[8*3]); - MAC(b1, - W7, col[8*3]); - MAC(b2, - W1, col[8*3]); - MAC(b3, - W5, col[8*3]); - - if(col[8*4]){ - a0 += + W4*col[8*4]; - a1 += - W4*col[8*4]; - a2 += - W4*col[8*4]; - a3 += + W4*col[8*4]; - } - - if (col[8*5]) { - MAC(b0, + W5, col[8*5]); - MAC(b1, - W1, col[8*5]); - MAC(b2, + W7, col[8*5]); - MAC(b3, + W3, col[8*5]); - } - - if(col[8*6]){ - a0 += + W6*col[8*6]; - a1 += - W2*col[8*6]; - a2 += + W2*col[8*6]; - a3 += - W6*col[8*6]; - } - - if (col[8*7]) { - MAC(b0, + W7, col[8*7]); - MAC(b1, - W5, col[8*7]); - MAC(b2, + W3, col[8*7]); - MAC(b3, - W1, col[8*7]); - } + IDCT_COLS; dest[0] = CLIP((a0 + b0) >> COL_SHIFT); dest += line_size; @@ -239,54 +242,7 @@ static inline void FUNC(idctSparseColAdd)(pixel *dest, int line_size, int a0, a1, a2, a3, b0, b1, b2, b3; INIT_CLIP; - /* XXX: I did that only to give same values as previous code */ - a0 = W4 * (col[8*0] + ((1<<(COL_SHIFT-1))/W4)); - a1 = a0; - a2 = a0; - a3 = a0; - - a0 += + W2*col[8*2]; - a1 += + W6*col[8*2]; - a2 += - W6*col[8*2]; - a3 += - W2*col[8*2]; - - b0 = MUL(W1, col[8*1]); - b1 = MUL(W3, col[8*1]); - b2 = MUL(W5, col[8*1]); - b3 = MUL(W7, col[8*1]); - - MAC(b0, + W3, col[8*3]); - MAC(b1, - W7, col[8*3]); - MAC(b2, - W1, col[8*3]); - MAC(b3, - W5, col[8*3]); - - if(col[8*4]){ - a0 += + W4*col[8*4]; - a1 += - W4*col[8*4]; - a2 += - W4*col[8*4]; - a3 += + W4*col[8*4]; - } - - if (col[8*5]) { - MAC(b0, + W5, col[8*5]); - MAC(b1, - W1, col[8*5]); - MAC(b2, + W7, col[8*5]); - MAC(b3, + W3, col[8*5]); - } - - if(col[8*6]){ - a0 += + W6*col[8*6]; - a1 += - W2*col[8*6]; - a2 += + W2*col[8*6]; - a3 += - W6*col[8*6]; - } - - if (col[8*7]) { - MAC(b0, + W7, col[8*7]); - MAC(b1, - W5, col[8*7]); - MAC(b2, + W3, col[8*7]); - MAC(b3, - W1, col[8*7]); - } + IDCT_COLS; dest[0] = CLIP(dest[0] + ((a0 + b0) >> COL_SHIFT)); dest += line_size; @@ -309,54 +265,7 @@ static inline void FUNC(idctSparseCol)(DCTELEM *col) { int a0, a1, a2, a3, b0, b1, b2, b3; - /* XXX: I did that only to give same values as previous code */ - a0 = W4 * (col[8*0] + ((1<<(COL_SHIFT-1))/W4)); - a1 = a0; - a2 = a0; - a3 = a0; - - a0 += + W2*col[8*2]; - a1 += + W6*col[8*2]; - a2 += - W6*col[8*2]; - a3 += - W2*col[8*2]; - - b0 = MUL(W1, col[8*1]); - b1 = MUL(W3, col[8*1]); - b2 = MUL(W5, col[8*1]); - b3 = MUL(W7, col[8*1]); - - MAC(b0, + W3, col[8*3]); - MAC(b1, - W7, col[8*3]); - MAC(b2, - W1, col[8*3]); - MAC(b3, - W5, col[8*3]); - - if(col[8*4]){ - a0 += + W4*col[8*4]; - a1 += - W4*col[8*4]; - a2 += - W4*col[8*4]; - a3 += + W4*col[8*4]; - } - - if (col[8*5]) { - MAC(b0, + W5, col[8*5]); - MAC(b1, - W1, col[8*5]); - MAC(b2, + W7, col[8*5]); - MAC(b3, + W3, col[8*5]); - } - - if(col[8*6]){ - a0 += + W6*col[8*6]; - a1 += - W2*col[8*6]; - a2 += + W2*col[8*6]; - a3 += - W6*col[8*6]; - } - - if (col[8*7]) { - MAC(b0, + W7, col[8*7]); - MAC(b1, - W5, col[8*7]); - MAC(b2, + W3, col[8*7]); - MAC(b3, - W1, col[8*7]); - } + IDCT_COLS; col[0 ] = ((a0 + b0) >> COL_SHIFT); col[8 ] = ((a1 + b1) >> COL_SHIFT); |