From: Fabrice Bellard Date: Wed, 5 Jun 2002 18:46:25 +0000 (+0000) Subject: added inlined put/add functions X-Git-Tag: v0.5~17627 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d36a2466753fc18f3143837a56aa7123f8991f33;p=platform%2Fupstream%2Flibav.git added inlined put/add functions Originally committed as revision 671 to svn://svn.ffmpeg.org/ffmpeg/trunk --- diff --git a/libavcodec/simple_idct.c b/libavcodec/simple_idct.c index a4d4486..0665f66 100644 --- a/libavcodec/simple_idct.c +++ b/libavcodec/simple_idct.c @@ -22,7 +22,7 @@ written by Aaron Holtzman ) */ #include "avcodec.h" - +#include "dsputil.h" #include "simple_idct.h" #if 0 @@ -261,9 +261,83 @@ static inline void idctRowCondDC (int16_t * row) } #endif /* not ARCH_ALPHA */ -static inline void idctSparseCol (int16_t * col) +static inline void idctSparseColPut (UINT8 *dest, int line_size, + int16_t * col) +{ + int a0, a1, a2, a3, b0, b1, b2, b3; + UINT8 *cm = cropTbl + MAX_NEG_CROP; + + /* 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]; + + MUL16(b0, W1, col[8*1]); + MUL16(b1, W3, col[8*1]); + MUL16(b2, W5, col[8*1]); + MUL16(b3, W7, col[8*1]); + + MAC16(b0, + W3, col[8*3]); + MAC16(b1, - W7, col[8*3]); + MAC16(b2, - W1, col[8*3]); + MAC16(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]) { + MAC16(b0, + W5, col[8*5]); + MAC16(b1, - W1, col[8*5]); + MAC16(b2, + W7, col[8*5]); + MAC16(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]) { + MAC16(b0, + W7, col[8*7]); + MAC16(b1, - W5, col[8*7]); + MAC16(b2, + W3, col[8*7]); + MAC16(b3, - W1, col[8*7]); + } + + dest[0] = cm[(a0 + b0) >> COL_SHIFT]; + dest += line_size; + dest[0] = cm[(a1 + b1) >> COL_SHIFT]; + dest += line_size; + dest[0] = cm[(a2 + b2) >> COL_SHIFT]; + dest += line_size; + dest[0] = cm[(a3 + b3) >> COL_SHIFT]; + dest += line_size; + dest[0] = cm[(a3 - b3) >> COL_SHIFT]; + dest += line_size; + dest[0] = cm[(a2 - b2) >> COL_SHIFT]; + dest += line_size; + dest[0] = cm[(a1 - b1) >> COL_SHIFT]; + dest += line_size; + dest[0] = cm[(a0 - b0) >> COL_SHIFT]; +} + +static inline void idctSparseColAdd (UINT8 *dest, int line_size, + int16_t * col) { int a0, a1, a2, a3, b0, b1, b2, b3; + UINT8 *cm = cropTbl + MAX_NEG_CROP; /* XXX: I did that only to give same values as previous code */ a0 = W4 * (col[8*0] + ((1<<(COL_SHIFT-1))/W4)); @@ -314,14 +388,21 @@ static inline void idctSparseCol (int16_t * col) MAC16(b3, - W1, col[8*7]); } - col[8*0] = (a0 + b0) >> COL_SHIFT; - col[8*7] = (a0 - b0) >> COL_SHIFT; - col[8*1] = (a1 + b1) >> COL_SHIFT; - col[8*6] = (a1 - b1) >> COL_SHIFT; - col[8*2] = (a2 + b2) >> COL_SHIFT; - col[8*5] = (a2 - b2) >> COL_SHIFT; - col[8*3] = (a3 + b3) >> COL_SHIFT; - col[8*4] = (a3 - b3) >> COL_SHIFT; + dest[0] = cm[dest[0] + ((a0 + b0) >> COL_SHIFT)]; + dest += line_size; + dest[0] = cm[dest[0] + ((a1 + b1) >> COL_SHIFT)]; + dest += line_size; + dest[0] = cm[dest[0] + ((a2 + b2) >> COL_SHIFT)]; + dest += line_size; + dest[0] = cm[dest[0] + ((a3 + b3) >> COL_SHIFT)]; + dest += line_size; + dest[0] = cm[dest[0] + ((a3 - b3) >> COL_SHIFT)]; + dest += line_size; + dest[0] = cm[dest[0] + ((a2 - b2) >> COL_SHIFT)]; + dest += line_size; + dest[0] = cm[dest[0] + ((a1 - b1) >> COL_SHIFT)]; + dest += line_size; + dest[0] = cm[dest[0] + ((a0 - b0) >> COL_SHIFT)]; } #ifdef ARCH_ALPHA @@ -389,16 +470,39 @@ void simple_idct (short *block) } } +/* XXX: suppress this mess */ +void simple_idct_put(UINT8 *dest, int line_size, DCTELEM *block) +{ + simple_idct(block); + put_pixels_clamped(block, dest, line_size); +} + +void simple_idct_add(UINT8 *dest, int line_size, DCTELEM *block) +{ + simple_idct(block); + add_pixels_clamped(block, dest, line_size); +} + #else -void simple_idct (short *block) +void simple_idct_put(UINT8 *dest, int line_size, INT16 *block) +{ + int i; + for(i=0; i<8; i++) + idctRowCondDC(block + i*8); + + for(i=0; i<8; i++) + idctSparseColPut(dest + i, line_size, block + i); +} + +void simple_idct_add(UINT8 *dest, int line_size, INT16 *block) { int i; for(i=0; i<8; i++) idctRowCondDC(block + i*8); for(i=0; i<8; i++) - idctSparseCol(block + i); + idctSparseColAdd(dest + i, line_size, block + i); } #endif diff --git a/libavcodec/simple_idct.h b/libavcodec/simple_idct.h index 5c7da02..233a7b8 100644 --- a/libavcodec/simple_idct.h +++ b/libavcodec/simple_idct.h @@ -18,5 +18,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -void simple_idct(short *block); +void simple_idct_put(UINT8 *dest, int line_size, INT16 *block); +void simple_idct_add(UINT8 *dest, int line_size, INT16 *block); void simple_idct_mmx(short *block);