diff --git a/libavcodec/i386/dsputil_mmx.c b/libavcodec/i386/dsputil_mmx.c index 86dd543e39..b863a2ce3e 100644 --- a/libavcodec/i386/dsputil_mmx.c +++ b/libavcodec/i386/dsputil_mmx.c @@ -651,6 +651,9 @@ static int hadamard8_diff_mmx(void *s, uint8_t *src1, uint8_t *src2, int stride) WARPER88_1616(hadamard8_diff_mmx, hadamard8_diff16_mmx) +#define put_no_rnd_pixels8_mmx(a,b,c,d) put_pixels8_mmx(a,b,c,d) +#define put_no_rnd_pixels16_mmx(a,b,c,d) put_pixels16_mmx(a,b,c,d) + #define QPEL_V_LOW(m3,m4,m5,m6, pw_20, pw_3, rnd, in0, in1, in2, in7, out, OP)\ "paddw " #m4 ", " #m3 " \n\t" /* x1 */\ "movq " #pw_20 ", %%mm4 \n\t" /* 20 */\ @@ -672,7 +675,7 @@ WARPER88_1616(hadamard8_diff_mmx, hadamard8_diff16_mmx) "packuswb %%mm5, %%mm5 \n\t"\ OP(%%mm5, out, %%mm7, d) -#define QPEL_BASE(OPNAME, ROUNDER, RND, OP)\ +#define QPEL_BASE(OPNAME, ROUNDER, RND, OP_MMX2, OP_3DNOW)\ void OPNAME ## mpeg4_qpel16_h_lowpass_mmx2(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){\ uint64_t temp;\ \ @@ -738,7 +741,7 @@ void OPNAME ## mpeg4_qpel16_h_lowpass_mmx2(uint8_t *dst, uint8_t *src, int dstSt "psraw $5, %%mm3 \n\t"\ "movq %7, %%mm1 \n\t"\ "packuswb %%mm3, %%mm1 \n\t"\ - OP(%%mm1, (%1),%%mm4, q)\ + OP_MMX2(%%mm1, (%1),%%mm4, q)\ /* mm0= GHIJ, mm2=FGHI, mm5=HIJK, mm6=IJKL, mm7=0 */\ \ "movq 9(%0), %%mm1 \n\t" /* JKLMNOPQ */\ @@ -784,7 +787,7 @@ void OPNAME ## mpeg4_qpel16_h_lowpass_mmx2(uint8_t *dst, uint8_t *src, int dstSt "paddw %%mm3, %%mm4 \n\t" /* 20a - 6b + 3c - d */\ "psraw $5, %%mm4 \n\t"\ "packuswb %%mm4, %%mm0 \n\t"\ - OP(%%mm0, 8(%1), %%mm4, q)\ + OP_MMX2(%%mm0, 8(%1), %%mm4, q)\ \ "addl %3, %0 \n\t"\ "addl %4, %1 \n\t"\ @@ -828,7 +831,7 @@ static void OPNAME ## mpeg4_qpel16_h_lowpass_3dnow(uint8_t *dst, uint8_t *src, i "psraw $5, %%mm0 \n\t"\ "psraw $5, %%mm1 \n\t"\ "packuswb %%mm1, %%mm0 \n\t"\ - OP(%%mm0, (%1), %%mm1, q)\ + OP_3DNOW(%%mm0, (%1), %%mm1, q)\ "movq 16(%0), %%mm0 \n\t"\ "movq 24(%0), %%mm1 \n\t"\ "paddw %2, %%mm0 \n\t"\ @@ -836,7 +839,7 @@ static void OPNAME ## mpeg4_qpel16_h_lowpass_3dnow(uint8_t *dst, uint8_t *src, i "psraw $5, %%mm0 \n\t"\ "psraw $5, %%mm1 \n\t"\ "packuswb %%mm1, %%mm0 \n\t"\ - OP(%%mm0, 8(%1), %%mm1, q)\ + OP_3DNOW(%%mm0, 8(%1), %%mm1, q)\ :: "r"(temp), "r"(dst), "m"(ROUNDER)\ );\ dst+=dstStride;\ @@ -844,7 +847,110 @@ static void OPNAME ## mpeg4_qpel16_h_lowpass_3dnow(uint8_t *dst, uint8_t *src, i }\ }\ \ -void OPNAME ## mpeg4_qpel16_v_lowpass_mmx(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\ +void OPNAME ## mpeg4_qpel8_h_lowpass_mmx2(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){\ + uint64_t temp;\ +\ + asm volatile(\ + "pushl %0 \n\t"\ + "pushl %1 \n\t"\ + "pushl %2 \n\t"\ + "pxor %%mm7, %%mm7 \n\t"\ + "1: \n\t"\ + "movq (%0), %%mm0 \n\t" /* ABCDEFGH */\ + "movq %%mm0, %%mm1 \n\t" /* ABCDEFGH */\ + "movq %%mm0, %%mm2 \n\t" /* ABCDEFGH */\ + "punpcklbw %%mm7, %%mm0 \n\t" /* 0A0B0C0D */\ + "punpckhbw %%mm7, %%mm1 \n\t" /* 0E0F0G0H */\ + "pshufw $0x90, %%mm0, %%mm5 \n\t" /* 0A0A0B0C */\ + "pshufw $0x41, %%mm0, %%mm6 \n\t" /* 0B0A0A0B */\ + "movq %%mm2, %%mm3 \n\t" /* ABCDEFGH */\ + "movq %%mm2, %%mm4 \n\t" /* ABCDEFGH */\ + "psllq $8, %%mm2 \n\t" /* 0ABCDEFG */\ + "psllq $16, %%mm3 \n\t" /* 00ABCDEF */\ + "psllq $24, %%mm4 \n\t" /* 000ABCDE */\ + "punpckhbw %%mm7, %%mm2 \n\t" /* 0D0E0F0G */\ + "punpckhbw %%mm7, %%mm3 \n\t" /* 0C0D0E0F */\ + "punpckhbw %%mm7, %%mm4 \n\t" /* 0B0C0D0E */\ + "paddw %%mm3, %%mm5 \n\t" /* b */\ + "paddw %%mm2, %%mm6 \n\t" /* c */\ + "paddw %%mm5, %%mm5 \n\t" /* 2b */\ + "psubw %%mm5, %%mm6 \n\t" /* c - 2b */\ + "pshufw $0x06, %%mm0, %%mm5 \n\t" /* 0C0B0A0A */\ + "pmullw %6, %%mm6 \n\t" /* 3c - 6b */\ + "paddw %%mm4, %%mm0 \n\t" /* a */\ + "paddw %%mm1, %%mm5 \n\t" /* d */\ + "pmullw %5, %%mm0 \n\t" /* 20a */\ + "psubw %%mm5, %%mm0 \n\t" /* 20a - d */\ + "paddw %8, %%mm6 \n\t"\ + "paddw %%mm6, %%mm0 \n\t" /* 20a - 6b + 3c - d */\ + "psraw $5, %%mm0 \n\t"\ + /* mm1=EFGH, mm2=DEFG, mm3=CDEF, mm4=BCDE, mm7=0 */\ + \ + "movd 5(%0), %%mm5 \n\t" /* FGHI */\ + "punpcklbw %%mm7, %%mm5 \n\t" /* 0F0G0H0I */\ + "pshufw $0xF9, %%mm5, %%mm6 \n\t" /* 0G0H0I0I */\ + "paddw %%mm5, %%mm1 \n\t" /* a */\ + "paddw %%mm6, %%mm2 \n\t" /* b */\ + "pshufw $0xBE, %%mm5, %%mm6 \n\t" /* 0H0I0I0H */\ + "pshufw $0x6F, %%mm5, %%mm5 \n\t" /* 0I0I0H0G */\ + "paddw %%mm6, %%mm3 \n\t" /* c */\ + "paddw %%mm5, %%mm4 \n\t" /* d */\ + "paddw %%mm2, %%mm2 \n\t" /* 2b */\ + "psubw %%mm2, %%mm3 \n\t" /* c - 2b */\ + "pmullw %5, %%mm1 \n\t" /* 20a */\ + "pmullw %6, %%mm3 \n\t" /* 3c - 6b */\ + "psubw %%mm4, %%mm3 \n\t" /* -6b + 3c - d */\ + "paddw %8, %%mm1 \n\t"\ + "paddw %%mm1, %%mm3 \n\t" /* 20a - 6b + 3c - d */\ + "psraw $5, %%mm3 \n\t"\ + "packuswb %%mm3, %%mm0 \n\t"\ + OP_MMX2(%%mm0, (%1), %%mm4, q)\ + \ + "addl %3, %0 \n\t"\ + "addl %4, %1 \n\t"\ + "decl %2 \n\t"\ + " jnz 1b \n\t"\ + "popl %2 \n\t"\ + "popl %1 \n\t"\ + "popl %0 \n\t"\ + :: "r"(src), "r"(dst), "r"(h),\ + "r"(srcStride), "r"(dstStride), "m"(ff_pw_20), "m"(ff_pw_3), "m"(temp), "m"(ROUNDER)\ + );\ +}\ +\ +static void OPNAME ## mpeg4_qpel8_h_lowpass_3dnow(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){\ + int i;\ + int16_t temp[8];\ + /* quick HACK, XXX FIXME MUST be optimized */\ + for(i=0; iavg_pixels_tab[1][1] = avg_pixels8_x2_mmx2; c->avg_pixels_tab[1][2] = avg_pixels8_y2_mmx2; c->avg_pixels_tab[1][3] = avg_pixels8_xy2_mmx2; + SET_QPEL_FUNC(qpel_pixels_tab[0][ 0], qpel16_mc00_mmx2) SET_QPEL_FUNC(qpel_pixels_tab[0][ 1], qpel16_mc10_mmx2) SET_QPEL_FUNC(qpel_pixels_tab[0][ 2], qpel16_mc20_mmx2) diff --git a/libavcodec/i386/dsputil_mmx_rnd.h b/libavcodec/i386/dsputil_mmx_rnd.h index f72ded1bcf..676282b663 100644 --- a/libavcodec/i386/dsputil_mmx_rnd.h +++ b/libavcodec/i386/dsputil_mmx_rnd.h @@ -657,7 +657,7 @@ static void DEF(avg, pixels8_l4)(uint8_t *dst, uint8_t *src1, uint8_t *src2, int "movq (%1), %%mm0 \n\t" "movq (%2), %%mm1 \n\t" "movq 64(%2), %%mm2 \n\t" - "movq 136(%4), %%mm4 \n\t" + "movq 136(%2), %%mm4 \n\t" "punpckhbw %%mm7, %%mm0 \n\t" "punpckhbw %%mm7, %%mm1 \n\t" "punpckhbw %%mm7, %%mm2 \n\t" @@ -670,7 +670,7 @@ static void DEF(avg, pixels8_l4)(uint8_t *dst, uint8_t *src1, uint8_t *src2, int "packuswb %%mm4, %%mm3 \n\t" "movq (%0), %%mm4 \n\t" PAVGB(%%mm3, %%mm4, %%mm0, %%mm5) - "movq %%mm3, (%0) \n\t" + "movq %%mm0, (%0) \n\t" "addl %4, %0 \n\t" "addl %4, %1 \n\t" "addl $8, %2 \n\t" @@ -705,7 +705,7 @@ static void DEF(avg, pixels16_l4)(uint8_t *dst, uint8_t *src1, uint8_t *src2, in "movq (%1), %%mm0 \n\t" "movq (%2), %%mm1 \n\t" "movq 256(%2), %%mm2 \n\t" - "movq 528(%4), %%mm4 \n\t" + "movq 528(%2), %%mm4 \n\t" "punpckhbw %%mm7, %%mm0 \n\t" "punpckhbw %%mm7, %%mm1 \n\t" "punpckhbw %%mm7, %%mm2 \n\t" @@ -718,7 +718,7 @@ static void DEF(avg, pixels16_l4)(uint8_t *dst, uint8_t *src1, uint8_t *src2, in "packuswb %%mm4, %%mm3 \n\t" "movq (%0), %%mm4 \n\t" PAVGB(%%mm3, %%mm4, %%mm0, %%mm5) - "movq %%mm3, (%0) \n\t" + "movq %%mm0, (%0) \n\t" "movq 8(%1), %%mm0 \n\t" "movq 8(%2), %%mm1 \n\t" "movq 264(%2), %%mm2 \n\t" @@ -735,7 +735,7 @@ static void DEF(avg, pixels16_l4)(uint8_t *dst, uint8_t *src1, uint8_t *src2, in "movq 8(%1), %%mm0 \n\t" "movq 8(%2), %%mm1 \n\t" "movq 264(%2), %%mm2 \n\t" - "movq 536(%4), %%mm4 \n\t" + "movq 536(%2), %%mm4 \n\t" "punpckhbw %%mm7, %%mm0 \n\t" "punpckhbw %%mm7, %%mm1 \n\t" "punpckhbw %%mm7, %%mm2 \n\t" @@ -748,7 +748,7 @@ static void DEF(avg, pixels16_l4)(uint8_t *dst, uint8_t *src1, uint8_t *src2, in "packuswb %%mm4, %%mm3 \n\t" "movq 8(%0), %%mm4 \n\t" PAVGB(%%mm3, %%mm4, %%mm0, %%mm5) - "movq %%mm3, 8(%0) \n\t" + "movq %%mm0, 8(%0) \n\t" "addl %4, %0 \n\t" "addl %4, %1 \n\t" "addl $16, %2 \n\t"