diff options
Diffstat (limited to 'libavcodec/dsputil_template.c')
-rw-r--r-- | libavcodec/dsputil_template.c | 248 |
1 files changed, 42 insertions, 206 deletions
diff --git a/libavcodec/dsputil_template.c b/libavcodec/dsputil_template.c index d232d51..349da7d 100644 --- a/libavcodec/dsputil_template.c +++ b/libavcodec/dsputil_template.c @@ -5,20 +5,20 @@ * * gmc & q-pel & 32/64 bit based MC by Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * - * Libav is distributed in the hope that it will be useful, + * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -29,28 +29,21 @@ #include "bit_depth_template.c" +#if BIT_DEPTH == 8 /* draw the edges of width 'w' of an image of size width, height */ //FIXME check that this is ok for mpeg4 interlaced -static void FUNCC(draw_edges)(uint8_t *_buf, int _wrap, int width, int height, int w, int h, int sides) +static void FUNCC(draw_edges)(uint8_t *p_buf, int p_wrap, int width, int height, int w, int h, int sides) { - pixel *buf = (pixel*)_buf; - int wrap = _wrap / sizeof(pixel); + pixel *buf = (pixel*)p_buf; + int wrap = p_wrap / sizeof(pixel); pixel *ptr, *last_line; int i; /* left and right */ ptr = buf; for(i=0;i<height;i++) { -#if BIT_DEPTH > 8 - int j; - for (j = 0; j < w; j++) { - ptr[j-w] = ptr[0]; - ptr[j+width] = ptr[width-1]; - } -#else memset(ptr - w, ptr[0], w); memset(ptr + width, ptr[width-1], w); -#endif ptr += wrap; } @@ -64,47 +57,43 @@ static void FUNCC(draw_edges)(uint8_t *_buf, int _wrap, int width, int height, i for (i = 0; i < h; i++) memcpy(last_line + (i + 1) * wrap, last_line, (width + w + w) * sizeof(pixel)); // bottom } +#endif + +static void FUNCC(get_pixels)(int16_t *av_restrict block, + const uint8_t *_pixels, + int line_size) +{ + const pixel *pixels = (const pixel *) _pixels; + int i; -#define DCTELEM_FUNCS(dctcoef, suffix) \ -static void FUNCC(get_pixels ## suffix)(int16_t *restrict _block, \ - const uint8_t *_pixels, \ - int line_size) \ -{ \ - const pixel *pixels = (const pixel *) _pixels; \ - dctcoef *restrict block = (dctcoef *) _block; \ - int i; \ - \ - /* read the pixels */ \ - for(i=0;i<8;i++) { \ - block[0] = pixels[0]; \ - block[1] = pixels[1]; \ - block[2] = pixels[2]; \ - block[3] = pixels[3]; \ - block[4] = pixels[4]; \ - block[5] = pixels[5]; \ - block[6] = pixels[6]; \ - block[7] = pixels[7]; \ - pixels += line_size / sizeof(pixel); \ - block += 8; \ - } \ -} \ - \ -static void FUNCC(clear_block ## suffix)(int16_t *block) \ -{ \ - memset(block, 0, sizeof(dctcoef)*64); \ -} \ - \ -/** \ - * memset(blocks, 0, sizeof(int16_t)*6*64) \ - */ \ -static void FUNCC(clear_blocks ## suffix)(int16_t *blocks) \ -{ \ - memset(blocks, 0, sizeof(dctcoef)*6*64); \ + /* read the pixels */ + for(i=0;i<8;i++) { + block[0] = pixels[0]; + block[1] = pixels[1]; + block[2] = pixels[2]; + block[3] = pixels[3]; + block[4] = pixels[4]; + block[5] = pixels[5]; + block[6] = pixels[6]; + block[7] = pixels[7]; + pixels += line_size / sizeof(pixel); + block += 8; + } } -DCTELEM_FUNCS(int16_t, _16) -#if BIT_DEPTH > 8 -DCTELEM_FUNCS(dctcoef, _32) +#if BIT_DEPTH == 8 +static void FUNCC(clear_block)(int16_t *block) +{ + memset(block, 0, sizeof(int16_t)*64); +} + +/** + * memset(blocks, 0, sizeof(int16_t)*6*64) + */ +static void FUNCC(clear_blocks)(int16_t *blocks) +{ + memset(blocks, 0, sizeof(int16_t)*6*64); +} #endif #if BIT_DEPTH == 8 @@ -132,22 +121,6 @@ static inline void FUNC(OPNAME ## _no_rnd_pixels16_l2)(uint8_t *dst, const uint8 FUNC(OPNAME ## _no_rnd_pixels8_l2)(dst+8*sizeof(pixel), src1+8*sizeof(pixel), src2+8*sizeof(pixel), dst_stride, src_stride1, src_stride2, h);\ }\ \ -static inline void FUNCC(OPNAME ## _no_rnd_pixels8_x2)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h){\ - FUNC(OPNAME ## _no_rnd_pixels8_l2)(block, pixels, pixels+sizeof(pixel), line_size, line_size, line_size, h);\ -}\ -\ -static inline void FUNCC(OPNAME ## _pixels8_x2)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h){\ - FUNC(OPNAME ## _pixels8_l2)(block, pixels, pixels+sizeof(pixel), line_size, line_size, line_size, h);\ -}\ -\ -static inline void FUNCC(OPNAME ## _no_rnd_pixels8_y2)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h){\ - FUNC(OPNAME ## _no_rnd_pixels8_l2)(block, pixels, pixels+line_size, line_size, line_size, line_size, h);\ -}\ -\ -static inline void FUNCC(OPNAME ## _pixels8_y2)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h){\ - FUNC(OPNAME ## _pixels8_l2)(block, pixels, pixels+line_size, line_size, line_size, line_size, h);\ -}\ -\ static inline void FUNC(OPNAME ## _pixels8_l4)(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, const uint8_t *src3, const uint8_t *src4,\ int dst_stride, int src_stride1, int src_stride2,int src_stride3,int src_stride4, int h){\ /* FIXME HIGH BIT DEPTH */\ @@ -185,22 +158,6 @@ static inline void FUNC(OPNAME ## _pixels8_l4)(uint8_t *dst, const uint8_t *src1 }\ }\ \ -static inline void FUNCC(OPNAME ## _pixels4_x2)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h){\ - FUNC(OPNAME ## _pixels4_l2)(block, pixels, pixels+sizeof(pixel), line_size, line_size, line_size, h);\ -}\ -\ -static inline void FUNCC(OPNAME ## _pixels4_y2)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h){\ - FUNC(OPNAME ## _pixels4_l2)(block, pixels, pixels+line_size, line_size, line_size, line_size, h);\ -}\ -\ -static inline void FUNCC(OPNAME ## _pixels2_x2)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h){\ - FUNC(OPNAME ## _pixels2_l2)(block, pixels, pixels+sizeof(pixel), line_size, line_size, line_size, h);\ -}\ -\ -static inline void FUNCC(OPNAME ## _pixels2_y2)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h){\ - FUNC(OPNAME ## _pixels2_l2)(block, pixels, pixels+line_size, line_size, line_size, line_size, h);\ -}\ -\ static inline void FUNC(OPNAME ## _no_rnd_pixels8_l4)(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, const uint8_t *src3, const uint8_t *src4,\ int dst_stride, int src_stride1, int src_stride2,int src_stride3,int src_stride4, int h){\ /* FIXME HIGH BIT DEPTH*/\ @@ -248,79 +205,6 @@ static inline void FUNC(OPNAME ## _no_rnd_pixels16_l4)(uint8_t *dst, const uint8 FUNC(OPNAME ## _no_rnd_pixels8_l4)(dst+8*sizeof(pixel), src1+8*sizeof(pixel), src2+8*sizeof(pixel), src3+8*sizeof(pixel), src4+8*sizeof(pixel), dst_stride, src_stride1, src_stride2, src_stride3, src_stride4, h);\ }\ \ -static inline void FUNCC(OPNAME ## _pixels2_xy2)(uint8_t *_block, const uint8_t *_pixels, ptrdiff_t line_size, int h)\ -{\ - int i, a0, b0, a1, b1;\ - pixel *block = (pixel*)_block;\ - const pixel *pixels = (const pixel*)_pixels;\ - line_size /= sizeof(pixel);\ - a0= pixels[0];\ - b0= pixels[1] + 2;\ - a0 += b0;\ - b0 += pixels[2];\ -\ - pixels+=line_size;\ - for(i=0; i<h; i+=2){\ - a1= pixels[0];\ - b1= pixels[1];\ - a1 += b1;\ - b1 += pixels[2];\ -\ - block[0]= (a1+a0)>>2; /* FIXME non put */\ - block[1]= (b1+b0)>>2;\ -\ - pixels+=line_size;\ - block +=line_size;\ -\ - a0= pixels[0];\ - b0= pixels[1] + 2;\ - a0 += b0;\ - b0 += pixels[2];\ -\ - block[0]= (a1+a0)>>2;\ - block[1]= (b1+b0)>>2;\ - pixels+=line_size;\ - block +=line_size;\ - }\ -}\ -\ -static inline void FUNCC(OPNAME ## _pixels4_xy2)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)\ -{\ - /* FIXME HIGH BIT DEPTH */\ - int i;\ - const uint32_t a= AV_RN32(pixels );\ - const uint32_t b= AV_RN32(pixels+1);\ - uint32_t l0= (a&0x03030303UL)\ - + (b&0x03030303UL)\ - + 0x02020202UL;\ - uint32_t h0= ((a&0xFCFCFCFCUL)>>2)\ - + ((b&0xFCFCFCFCUL)>>2);\ - uint32_t l1,h1;\ -\ - pixels+=line_size;\ - for(i=0; i<h; i+=2){\ - uint32_t a= AV_RN32(pixels );\ - uint32_t b= AV_RN32(pixels+1);\ - l1= (a&0x03030303UL)\ - + (b&0x03030303UL);\ - h1= ((a&0xFCFCFCFCUL)>>2)\ - + ((b&0xFCFCFCFCUL)>>2);\ - OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\ - pixels+=line_size;\ - block +=line_size;\ - a= AV_RN32(pixels );\ - b= AV_RN32(pixels+1);\ - l0= (a&0x03030303UL)\ - + (b&0x03030303UL)\ - + 0x02020202UL;\ - h0= ((a&0xFCFCFCFCUL)>>2)\ - + ((b&0xFCFCFCFCUL)>>2);\ - OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\ - pixels+=line_size;\ - block +=line_size;\ - }\ -}\ -\ static inline void FUNCC(OPNAME ## _pixels8_xy2)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)\ {\ /* FIXME HIGH BIT DEPTH */\ @@ -363,55 +247,7 @@ static inline void FUNCC(OPNAME ## _pixels8_xy2)(uint8_t *block, const uint8_t * }\ }\ \ -static inline void FUNCC(OPNAME ## _no_rnd_pixels8_xy2)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)\ -{\ - /* FIXME HIGH BIT DEPTH */\ - int j;\ - for(j=0; j<2; j++){\ - int i;\ - const uint32_t a= AV_RN32(pixels );\ - const uint32_t b= AV_RN32(pixels+1);\ - uint32_t l0= (a&0x03030303UL)\ - + (b&0x03030303UL)\ - + 0x01010101UL;\ - uint32_t h0= ((a&0xFCFCFCFCUL)>>2)\ - + ((b&0xFCFCFCFCUL)>>2);\ - uint32_t l1,h1;\ -\ - pixels+=line_size;\ - for(i=0; i<h; i+=2){\ - uint32_t a= AV_RN32(pixels );\ - uint32_t b= AV_RN32(pixels+1);\ - l1= (a&0x03030303UL)\ - + (b&0x03030303UL);\ - h1= ((a&0xFCFCFCFCUL)>>2)\ - + ((b&0xFCFCFCFCUL)>>2);\ - OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\ - pixels+=line_size;\ - block +=line_size;\ - a= AV_RN32(pixels );\ - b= AV_RN32(pixels+1);\ - l0= (a&0x03030303UL)\ - + (b&0x03030303UL)\ - + 0x01010101UL;\ - h0= ((a&0xFCFCFCFCUL)>>2)\ - + ((b&0xFCFCFCFCUL)>>2);\ - OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\ - pixels+=line_size;\ - block +=line_size;\ - }\ - pixels+=4-line_size*(h+1);\ - block +=4-line_size*h;\ - }\ -}\ -\ -CALL_2X_PIXELS(FUNCC(OPNAME ## _pixels16_x2) , FUNCC(OPNAME ## _pixels8_x2) , 8*sizeof(pixel))\ -CALL_2X_PIXELS(FUNCC(OPNAME ## _pixels16_y2) , FUNCC(OPNAME ## _pixels8_y2) , 8*sizeof(pixel))\ CALL_2X_PIXELS(FUNCC(OPNAME ## _pixels16_xy2), FUNCC(OPNAME ## _pixels8_xy2), 8*sizeof(pixel))\ -av_unused CALL_2X_PIXELS(FUNCC(OPNAME ## _no_rnd_pixels16) , FUNCC(OPNAME ## _pixels8) , 8*sizeof(pixel))\ -CALL_2X_PIXELS(FUNCC(OPNAME ## _no_rnd_pixels16_x2) , FUNCC(OPNAME ## _no_rnd_pixels8_x2) , 8*sizeof(pixel))\ -CALL_2X_PIXELS(FUNCC(OPNAME ## _no_rnd_pixels16_y2) , FUNCC(OPNAME ## _no_rnd_pixels8_y2) , 8*sizeof(pixel))\ -CALL_2X_PIXELS(FUNCC(OPNAME ## _no_rnd_pixels16_xy2), FUNCC(OPNAME ## _no_rnd_pixels8_xy2), 8*sizeof(pixel))\ #define op_avg(a, b) a = rnd_avg_pixel4(a, b) #define op_put(a, b) a = b |