]> rtime.felk.cvut.cz Git - frescor/ffmpeg.git/commitdiff
add MMX version for put_no_rnd_h264_chroma_mc8_c, used in VC-1 decoding.
authorgpoirier <gpoirier@9553f0bf-9b14-0410-a0b8-cfaf0461ba5b>
Fri, 21 Dec 2007 23:11:22 +0000 (23:11 +0000)
committergpoirier <gpoirier@9553f0bf-9b14-0410-a0b8-cfaf0461ba5b>
Fri, 21 Dec 2007 23:11:22 +0000 (23:11 +0000)
patch by Christophe GISQUET %christophe P gisquet A free P fr%
original thread:
date: Nov 25, 2007 12:35 AM
subject: Re: [FFmpeg-devel] MMX version for put_no_rnd_h264_chroma_mc8_c

git-svn-id: file:///var/local/repositories/ffmpeg/trunk@11298 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b

libavcodec/i386/dsputil_h264_template_mmx.c
libavcodec/i386/dsputil_mmx.c
libavcodec/i386/h264dsp_mmx.c

index e3da92fc195aaf89d94f573990e3d5c52b366640..a66f51e6b944a44caa494ea2deff4b8e3d68fc1f 100644 (file)
  * H264_CHROMA_OP must be defined to empty for put and pavgb/pavgusb for avg
  * H264_CHROMA_MC8_MV0 must be defined to a (put|avg)_pixels8 function
  */
-static void H264_CHROMA_MC8_TMPL(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y)
+static void H264_CHROMA_MC8_TMPL(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y, int rnd)
 {
+    DECLARE_ALIGNED_8(static const uint64_t, ff_pw_28) = 0x001C001C001C001CULL;
+    const uint64_t *rnd_reg;
     DECLARE_ALIGNED_8(uint64_t, AA);
     DECLARE_ALIGNED_8(uint64_t, DD);
     int i;
@@ -44,16 +46,17 @@ static void H264_CHROMA_MC8_TMPL(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*
         /* 1 dimensional filter only */
         const int dxy = x ? 1 : stride;
 
+        rnd_reg = rnd ? &ff_pw_4 : &ff_pw_3;
+
         asm volatile(
             "movd %0, %%mm5\n\t"
             "movq %1, %%mm4\n\t"
+            "movq %2, %%mm6\n\t"         /* mm6 = rnd */
             "punpcklwd %%mm5, %%mm5\n\t"
             "punpckldq %%mm5, %%mm5\n\t" /* mm5 = B = x */
-            "movq %%mm4, %%mm6\n\t"
             "pxor %%mm7, %%mm7\n\t"
             "psubw %%mm5, %%mm4\n\t"     /* mm4 = A = 8-x */
-            "psrlw $1, %%mm6\n\t"        /* mm6 = 4 */
-            :: "rm"(x+y), "m"(ff_pw_8));
+            :: "rm"(x+y), "m"(ff_pw_8), "m"(*rnd_reg));
 
         for(i=0; i<h; i++) {
             asm volatile(
@@ -95,6 +98,7 @@ static void H264_CHROMA_MC8_TMPL(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*
     }
 
     /* general case, bilinear */
+    rnd_reg = rnd ? &ff_pw_32 : &ff_pw_28;
     asm volatile("movd %2, %%mm4\n\t"
                  "movd %3, %%mm6\n\t"
                  "punpcklwd %%mm4, %%mm4\n\t"
@@ -177,7 +181,7 @@ static void H264_CHROMA_MC8_TMPL(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*
             "packuswb %%mm3, %%mm2\n\t"
             H264_CHROMA_OP(%0, %%mm2)
             "movq %%mm2, %0\n\t"
-            : "=m" (dst[0]) : "m" (ff_pw_32));
+            : "=m" (dst[0]) : "m" (*rnd_reg));
         dst+= stride;
     }
 }
index 9be90d9069ac8317a366732e7f7a3cbe128f1463..8328c28114a3df769abbceea989c5878bae385fa 100644 (file)
@@ -3371,8 +3371,9 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx)
             c->h263_v_loop_filter= h263_v_loop_filter_mmx;
             c->h263_h_loop_filter= h263_h_loop_filter_mmx;
         }
-        c->put_h264_chroma_pixels_tab[0]= put_h264_chroma_mc8_mmx;
+        c->put_h264_chroma_pixels_tab[0]= put_h264_chroma_mc8_mmx_rnd;
         c->put_h264_chroma_pixels_tab[1]= put_h264_chroma_mc4_mmx;
+        c->put_no_rnd_h264_chroma_pixels_tab[0]= put_h264_chroma_mc8_mmx_nornd;
 
         c->h264_idct_dc_add=
         c->h264_idct_add= ff_h264_idct_add_mmx;
@@ -3485,7 +3486,7 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx)
             dspfunc(avg_2tap_qpel, 1, 8);
 #undef dspfunc
 
-            c->avg_h264_chroma_pixels_tab[0]= avg_h264_chroma_mc8_mmx2;
+            c->avg_h264_chroma_pixels_tab[0]= avg_h264_chroma_mc8_mmx2_rnd;
             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;
@@ -3613,7 +3614,7 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx)
             dspfunc(avg_2tap_qpel, 0, 16);
             dspfunc(avg_2tap_qpel, 1, 8);
 
-            c->avg_h264_chroma_pixels_tab[0]= avg_h264_chroma_mc8_3dnow;
+            c->avg_h264_chroma_pixels_tab[0]= avg_h264_chroma_mc8_3dnow_rnd;
             c->avg_h264_chroma_pixels_tab[1]= avg_h264_chroma_mc4_3dnow;
         }
 
index 7d15b58159f28b97127581196018c0a1a11f24b1..14511db1e789b40b46e6ec41ceb481a1322292cc 100644 (file)
@@ -1378,6 +1378,16 @@ H264_MC(avg_, 16,mmx2)
 #define H264_CHROMA_MC2_TMPL put_h264_chroma_mc2_mmx2
 #define H264_CHROMA_MC8_MV0 put_pixels8_mmx
 #include "dsputil_h264_template_mmx.c"
+
+static void put_h264_chroma_mc8_mmx_rnd(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y)
+{
+    put_h264_chroma_mc8_mmx(dst, src, stride, h, x, y, 1);
+}
+static void put_h264_chroma_mc8_mmx_nornd(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y)
+{
+    put_h264_chroma_mc8_mmx(dst, src, stride, h, x, y, 0);
+}
+
 #undef H264_CHROMA_OP
 #undef H264_CHROMA_OP4
 #undef H264_CHROMA_MC8_TMPL
@@ -1393,6 +1403,10 @@ H264_MC(avg_, 16,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"
+static void avg_h264_chroma_mc8_mmx2_rnd(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y)
+{
+    avg_h264_chroma_mc8_mmx2(dst, src, stride, h, x, y, 1);
+}
 #undef H264_CHROMA_OP
 #undef H264_CHROMA_OP4
 #undef H264_CHROMA_MC8_TMPL
@@ -1407,6 +1421,10 @@ H264_MC(avg_, 16,mmx2)
 #define H264_CHROMA_MC4_TMPL avg_h264_chroma_mc4_3dnow
 #define H264_CHROMA_MC8_MV0 avg_pixels8_3dnow
 #include "dsputil_h264_template_mmx.c"
+static void avg_h264_chroma_mc8_3dnow_rnd(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y)
+{
+    avg_h264_chroma_mc8_3dnow(dst, src, stride, h, x, y, 1);
+}
 #undef H264_CHROMA_OP
 #undef H264_CHROMA_OP4
 #undef H264_CHROMA_MC8_TMPL