Mercurial > libavcodec.hg
diff x86/h264dsp_mmx.c @ 8510:cea216e44ee3 libavcodec
Add x264 SSE2 iDCT functions to H.264 decoder.
author | darkshikari |
---|---|
date | Sat, 03 Jan 2009 00:46:17 +0000 |
parents | 7768bdfd4f7b |
children | cc64e1343397 |
line wrap: on
line diff
--- a/x86/h264dsp_mmx.c Fri Jan 02 16:21:22 2009 +0000 +++ b/x86/h264dsp_mmx.c Sat Jan 03 00:46:17 2009 +0000 @@ -472,6 +472,78 @@ } } +#if defined(CONFIG_GPL) && defined(HAVE_YASM) +static void ff_h264_idct_dc_add8_mmx2(uint8_t *dst, int16_t *block, int stride) +{ + __asm__ volatile( + "movd %0, %%mm0 \n\t" // 0 0 X D + "punpcklwd %1, %%mm0 \n\t" // x X d D + "paddsw %2, %%mm0 \n\t" + "psraw $6, %%mm0 \n\t" + "punpcklwd %%mm0, %%mm0 \n\t" // d d D D + "pxor %%mm1, %%mm1 \n\t" // 0 0 0 0 + "psubw %%mm0, %%mm1 \n\t" // -d-d-D-D + "packuswb %%mm1, %%mm0 \n\t" // -d-d-D-D d d D D + "pshufw $0xFA, %%mm0, %%mm1 \n\t" // -d-d-d-d-D-D-D-D + "punpcklwd %%mm0, %%mm0 \n\t" // d d d d D D D D + ::"m"(block[ 0]), + "m"(block[16]), + "m"(ff_pw_32) + ); + __asm__ volatile( + "movq %0, %%mm2 \n\t" + "movq %1, %%mm3 \n\t" + "movq %2, %%mm4 \n\t" + "movq %3, %%mm5 \n\t" + "paddusb %%mm0, %%mm2 \n\t" + "paddusb %%mm0, %%mm3 \n\t" + "paddusb %%mm0, %%mm4 \n\t" + "paddusb %%mm0, %%mm5 \n\t" + "psubusb %%mm1, %%mm2 \n\t" + "psubusb %%mm1, %%mm3 \n\t" + "psubusb %%mm1, %%mm4 \n\t" + "psubusb %%mm1, %%mm5 \n\t" + "movq %%mm2, %0 \n\t" + "movq %%mm3, %1 \n\t" + "movq %%mm4, %2 \n\t" + "movq %%mm5, %3 \n\t" + :"+m"(*(uint64_t*)(dst+0*stride)), + "+m"(*(uint64_t*)(dst+1*stride)), + "+m"(*(uint64_t*)(dst+2*stride)), + "+m"(*(uint64_t*)(dst+3*stride)) + ); +} + +extern void ff_x264_add8x4_idct_sse2(uint8_t *dst, int16_t *block, int stride); + +static void ff_h264_idct_add16_sse2(uint8_t *dst, const int *block_offset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]){ + int i; + for(i=0; i<16; i+=2) + if(nnzc[ scan8[i+0] ]|nnzc[ scan8[i+1] ]) + ff_x264_add8x4_idct_sse2 (dst + block_offset[i], block + i*16, stride); +} + +static void ff_h264_idct_add16intra_sse2(uint8_t *dst, const int *block_offset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]){ + int i; + for(i=0; i<16; i+=2){ + if(nnzc[ scan8[i+0] ]|nnzc[ scan8[i+1] ]) + ff_x264_add8x4_idct_sse2 (dst + block_offset[i], block + i*16, stride); + else if(block[i*16]|block[i*16+16]) + ff_h264_idct_dc_add8_mmx2(dst + block_offset[i], block + i*16, stride); + } +} + +static void ff_h264_idct_add8_sse2(uint8_t **dest, const int *block_offset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]){ + int i; + for(i=16; i<16+8; i++){ + if(nnzc[ scan8[i+0] ]|nnzc[ scan8[i+1] ]) + ff_x264_add8x4_idct_sse2 (dest[(i&4)>>2] + block_offset[i], block + i*16, stride); + else if(block[i*16]|block[i*16+16]) + ff_h264_idct_dc_add8_mmx2(dest[(i&4)>>2] + block_offset[i], block + i*16, stride); + } +} +#endif + /***********************************/ /* deblocking */