changeset 3213:57d31bdbebe8 libavcodec

added mmx implementation of h264_chroma_mc2
author lorenm
date Wed, 22 Mar 2006 22:05:00 +0000
parents 5fb704618ec4
children 91f89a395b28
files i386/dsputil_h264_template_mmx.c i386/dsputil_mmx.c i386/h264dsp_mmx.c
diffstat 3 files changed, 70 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/i386/dsputil_h264_template_mmx.c	Wed Mar 22 12:41:02 2006 +0000
+++ b/i386/dsputil_h264_template_mmx.c	Wed Mar 22 22:05:00 2006 +0000
@@ -240,7 +240,7 @@
     }
 }
 
-static void H264_CHROMA_MC4_TMPL(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y)
+static void H264_CHROMA_MC4_TMPL(uint8_t *dst/*align 4*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y)
 {
     DECLARE_ALIGNED_8(uint64_t, AA);
     DECLARE_ALIGNED_8(uint64_t, DD);
@@ -319,3 +319,66 @@
         dst += stride;
     }
 }
+
+#ifdef H264_CHROMA_MC2_TMPL
+static void H264_CHROMA_MC2_TMPL(uint8_t *dst/*align 2*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y)
+{
+    int CD=((1<<16)-1)*x*y + 8*y;
+    int AB=((8<<16)-8)*x + 64 - CD;
+    int i;
+
+    asm volatile(
+        /* mm5 = {A,B,A,B} */
+        /* mm6 = {C,D,C,D} */
+        "movd %0, %%mm5\n\t"
+        "movd %1, %%mm6\n\t"
+        "punpckldq %%mm5, %%mm5\n\t"
+        "punpckldq %%mm6, %%mm6\n\t"
+        "pxor %%mm7, %%mm7\n\t"
+        :: "r"(AB), "r"(CD));
+
+    asm volatile(
+        /* mm0 = src[0,1,1,2] */
+        "movd %0, %%mm0\n\t"
+        "punpcklbw %%mm7, %%mm0\n\t"
+        "pshufw $0x94, %%mm0, %%mm0\n\t"
+        :: "m"(src[0]));
+
+    for(i=0; i<h; i++) {
+        asm volatile(
+            /* mm1 = A * src[0,1] + B * src[1,2] */
+            "movq    %%mm0, %%mm1\n\t"
+            "pmaddwd %%mm5, %%mm1\n\t"
+            ::);
+
+        src += stride;
+        asm volatile(
+            /* mm0 = src[0,1,1,2] */
+            "movd %0, %%mm0\n\t"
+            "punpcklbw %%mm7, %%mm0\n\t"
+            "pshufw $0x94, %%mm0, %%mm0\n\t"
+            :: "m"(src[0]));
+
+        asm volatile(
+            /* mm1 += C * src[0,1] + D * src[1,2] */
+            "movq    %%mm0, %%mm2\n\t"
+            "pmaddwd %%mm6, %%mm2\n\t"
+            "paddw   %%mm2, %%mm1\n\t"
+            ::);
+
+        asm volatile(
+            /* dst[0,1] = pack((mm1 + 32) >> 6) */
+            "paddw %1, %%mm1\n\t"
+            "psrlw $6, %%mm1\n\t"
+            "packssdw %%mm7, %%mm1\n\t"
+            "packuswb %%mm7, %%mm1\n\t"
+            /* writes garbage to the right of dst.
+             * ok because partitions are processed from left to right. */
+            H264_CHROMA_OP4(%0, %%mm1, %%mm3)
+            "movd %%mm1, %0\n\t"
+            : "=m" (dst[0]) : "m" (ff_pw_32) : "eax");
+        dst += stride;
+    }
+}
+#endif
+
--- a/i386/dsputil_mmx.c	Wed Mar 22 12:41:02 2006 +0000
+++ b/i386/dsputil_mmx.c	Wed Mar 22 22:05:00 2006 +0000
@@ -2848,6 +2848,8 @@
 
             c->avg_h264_chroma_pixels_tab[0]= avg_h264_chroma_mc8_mmx2;
             c->avg_h264_chroma_pixels_tab[1]= avg_h264_chroma_mc4_mmx2;
+            c->avg_h264_chroma_pixels_tab[2]= avg_h264_chroma_mc2_mmx2;
+            c->put_h264_chroma_pixels_tab[2]= put_h264_chroma_mc2_mmx2;
             c->h264_v_loop_filter_luma= h264_v_loop_filter_luma_mmx2;
             c->h264_h_loop_filter_luma= h264_h_loop_filter_luma_mmx2;
             c->h264_v_loop_filter_chroma= h264_v_loop_filter_chroma_mmx2;
--- a/i386/h264dsp_mmx.c	Wed Mar 22 12:41:02 2006 +0000
+++ b/i386/h264dsp_mmx.c	Wed Mar 22 22:05:00 2006 +0000
@@ -1296,12 +1296,14 @@
 #define H264_CHROMA_OP4(S,D,T)
 #define H264_CHROMA_MC8_TMPL put_h264_chroma_mc8_mmx
 #define H264_CHROMA_MC4_TMPL put_h264_chroma_mc4_mmx
+#define H264_CHROMA_MC2_TMPL put_h264_chroma_mc2_mmx2
 #define H264_CHROMA_MC8_MV0 put_pixels8_mmx
 #include "dsputil_h264_template_mmx.c"
 #undef H264_CHROMA_OP
 #undef H264_CHROMA_OP4
 #undef H264_CHROMA_MC8_TMPL
 #undef H264_CHROMA_MC4_TMPL
+#undef H264_CHROMA_MC2_TMPL
 #undef H264_CHROMA_MC8_MV0
 
 #define H264_CHROMA_OP(S,D) "pavgb " #S ", " #D " \n\t"
@@ -1309,12 +1311,14 @@
                                "pavgb " #T ", " #D " \n\t"
 #define H264_CHROMA_MC8_TMPL avg_h264_chroma_mc8_mmx2
 #define H264_CHROMA_MC4_TMPL avg_h264_chroma_mc4_mmx2
+#define H264_CHROMA_MC2_TMPL avg_h264_chroma_mc2_mmx2
 #define H264_CHROMA_MC8_MV0 avg_pixels8_mmx2
 #include "dsputil_h264_template_mmx.c"
 #undef H264_CHROMA_OP
 #undef H264_CHROMA_OP4
 #undef H264_CHROMA_MC8_TMPL
 #undef H264_CHROMA_MC4_TMPL
+#undef H264_CHROMA_MC2_TMPL
 #undef H264_CHROMA_MC8_MV0
 
 #define H264_CHROMA_OP(S,D) "pavgusb " #S ", " #D " \n\t"