dsputil_h264_template_mmx.c
资源名称:tcpmp.rar [点击查看]
上传用户:wstnjxml
上传日期:2014-04-03
资源大小:7248k
文件大小:5k
源码类别:
Windows CE
开发平台:
C/C++
- /*
- * Copyright (c) 2005 Zoltan Hidvegi <hzoli -a- hzoli -d- com>
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
- /**
- * MMX optimized version of (put|avg)_h264_chroma_mc8.
- * H264_CHROMA_MC8_TMPL must be defined to the desired function name and
- * H264_CHROMA_OP must be defined to empty for put and pavgb/pavgusb for avg.
- */
- static void H264_CHROMA_MC8_TMPL(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y)
- {
- uint64_t AA __align8;
- uint64_t DD __align8;
- unsigned long srcos = (long)src & 7;
- uint64_t sh1 __align8 = srcos * 8;
- uint64_t sh2 __align8 = 56 - sh1;
- int i;
- assert(x<8 && y<8 && x>=0 && y>=0);
- asm volatile("movd %1, %%mm4nt"
- "movd %2, %%mm6nt"
- "punpcklwd %%mm4, %%mm4nt"
- "punpcklwd %%mm6, %%mm6nt"
- "punpckldq %%mm4, %%mm4nt" /* mm4 = x words */
- "punpckldq %%mm6, %%mm6nt" /* mm6 = y words */
- "movq %%mm4, %%mm5nt"
- "pmullw %%mm6, %%mm4nt" /* mm4 = x * y */
- "psllw $3, %%mm5nt"
- "psllw $3, %%mm6nt"
- "movq %%mm5, %%mm7nt"
- "paddw %%mm6, %%mm7nt"
- "movq %%mm4, %0nt" /* DD = x * y */
- "psubw %%mm4, %%mm5nt" /* mm5 = B = 8x - xy */
- "psubw %%mm4, %%mm6nt" /* mm6 = C = 8y - xy */
- "paddw %3, %%mm4nt"
- "psubw %%mm7, %%mm4nt" /* mm4 = A = xy - (8x+8y) + 64 */
- "pxor %%mm7, %%mm7nt"
- : "=m" (DD) : "rm" (x), "rm" (y), "m" (ff_pw_64));
- asm volatile("movq %%mm4, %0" : "=m" (AA));
- src -= srcos;
- asm volatile(
- /* mm0 = src[0..7], mm1 = src[1..8] */
- "movq %0, %%mm1nt"
- "movq %1, %%mm0nt"
- "psrlq %2, %%mm1nt"
- "psllq %3, %%mm0nt"
- "movq %%mm0, %%mm4nt"
- "psllq $8, %%mm0nt"
- "por %%mm1, %%mm0nt"
- "psrlq $8, %%mm1nt"
- "por %%mm4, %%mm1nt"
- : : "m" (src[0]), "m" (src[8]), "m" (sh1), "m" (sh2));
- for(i=0; i<h; i++) {
- asm volatile(
- /* [mm2,mm3] = A * src[0..7] */
- "movq %%mm0, %%mm2nt"
- "punpcklbw %%mm7, %%mm2nt"
- "pmullw %0, %%mm2nt"
- "movq %%mm0, %%mm3nt"
- "punpckhbw %%mm7, %%mm3nt"
- "pmullw %0, %%mm3nt"
- /* [mm2,mm3] += B * src[1..8] */
- "movq %%mm1, %%mm0nt"
- "punpcklbw %%mm7, %%mm0nt"
- "pmullw %%mm5, %%mm0nt"
- "punpckhbw %%mm7, %%mm1nt"
- "pmullw %%mm5, %%mm1nt"
- "paddw %%mm0, %%mm2nt"
- "paddw %%mm1, %%mm3nt"
- : : "m" (AA));
- src += stride;
- asm volatile(
- /* mm0 = src[0..7], mm1 = src[1..8] */
- "movq %0, %%mm1nt"
- "movq %1, %%mm0nt"
- "psrlq %2, %%mm1nt"
- "psllq %3, %%mm0nt"
- "movq %%mm0, %%mm4nt"
- "psllq $8, %%mm0nt"
- "por %%mm1, %%mm0nt"
- "psrlq $8, %%mm1nt"
- "por %%mm4, %%mm1nt"
- : : "m" (src[0]), "m" (src[8]), "m" (sh1), "m" (sh2));
- asm volatile(
- /* [mm2,mm3] += C * src[0..7] */
- "movq %mm0, %mm4nt"
- "punpcklbw %mm7, %mm4nt"
- "pmullw %mm6, %mm4nt"
- "paddw %mm4, %mm2nt"
- "movq %mm0, %mm4nt"
- "punpckhbw %mm7, %mm4nt"
- "pmullw %mm6, %mm4nt"
- "paddw %mm4, %mm3nt");
- asm volatile(
- /* [mm2,mm3] += D * src[1..8] */
- "movq %%mm1, %%mm4nt"
- "punpcklbw %%mm7, %%mm4nt"
- "pmullw %0, %%mm4nt"
- "paddw %%mm4, %%mm2nt"
- "movq %%mm1, %%mm4nt"
- "punpckhbw %%mm7, %%mm4nt"
- "pmullw %0, %%mm4nt"
- "paddw %%mm4, %%mm3nt"
- : : "m" (DD));
- asm volatile(
- /* dst[0..7] = pack(([mm2,mm3] + 32) >> 6) */
- "paddw %1, %%mm2nt"
- "paddw %1, %%mm3nt"
- "psrlw $6, %%mm2nt"
- "psrlw $6, %%mm3nt"
- "packuswb %%mm3, %%mm2nt"
- H264_CHROMA_OP(%0, %%mm2)
- "movq %%mm2, %0nt"
- : "=m" (dst[0]) : "m" (ff_pw_32));
- dst+= stride;
- }
- }