libavfilter/libmpcodecs: sync existing filters with mplayer HEAD (ebcacb8b3ca91ef90ac...
[ffmpeg.git] / libavfilter / libmpcodecs / vf_fspp.c
index af50c6b..b786917 100644 (file)
 #include "img_format.h"
 #include "mp_image.h"
 #include "vf.h"
-#include "vd_ffmpeg.h"
+#include "av_helpers.h"
 #include "libvo/fastmemcpy.h"
 
 #include "libavutil/internal.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/mem.h"
+#include "libavutil/x86/asm.h"
 #include "libavcodec/avcodec.h"
 #include "libavcodec/dsputil.h"
 
@@ -74,7 +75,7 @@ static const short custom_threshold[64]=
   20,  27,  26,  23,  20,  15,  11,   5
 };
 
-static const uint8_t  __attribute__((aligned(32))) dither[8][8]={
+DECLARE_ASM_CONST(32, uint8_t, dither)[8][8]={
     {  0,  48,  12,  60,   3,  51,  15,  63, },
     { 32,  16,  44,  28,  35,  19,  47,  31, },
     {  8,  56,   4,  52,  11,  59,   7,  55, },
@@ -164,10 +165,10 @@ static void mul_thrmat_c(struct vf_priv_s *p,int q)
         ((short*)p->threshold_mtx)[a]=q * ((short*)p->threshold_mtx_noq)[a];//ints faster in C
 }
 
-static void column_fidct_c(int16_t* thr_adr, DCTELEM *data, DCTELEM *output, int cnt);
-static void row_idct_c(DCTELEM* workspace,
+static void column_fidct_c(int16_t* thr_adr, int16_t *data, int16_t *output, int cnt);
+static void row_idct_c(int16_t* workspace,
                        int16_t* output_adr, int output_stride, int cnt);
-static void row_fdct_c(DCTELEM *data, const uint8_t *pixels, int line_size, int cnt);
+static void row_fdct_c(int16_t *data, const uint8_t *pixels, int line_size, int cnt);
 
 //this is rather ugly, but there is no need for function pointers
 #define store_slice_s store_slice_c
@@ -214,11 +215,11 @@ static void store_slice_mmx(uint8_t *dst, int16_t *src, long dst_stride, long sr
         "psraw %%mm5, %%mm3            \n\t"
         "psraw %%mm5, %%mm4            \n\t"
         "1:                        \n\t"
-        "movq %%mm7, (%%"REG_S",%%"REG_a",)     \n\t"
+        "movq %%mm7, (%%"REG_S",%%"REG_a")     \n\t"
         "movq (%%"REG_S"), %%mm0           \n\t"
         "movq 8(%%"REG_S"), %%mm1          \n\t"
 
-        "movq %%mm7, 8(%%"REG_S",%%"REG_a",)    \n\t"
+        "movq %%mm7, 8(%%"REG_S",%%"REG_a")    \n\t"
         "paddw %%mm3, %%mm0            \n\t"
         "paddw %%mm4, %%mm1            \n\t"
 
@@ -285,15 +286,15 @@ static void store_slice2_mmx(uint8_t *dst, int16_t *src, long dst_stride, long s
         "movq 8(%%"REG_S"), %%mm1          \n\t"
         "paddw %%mm3, %%mm0            \n\t"
 
-        "paddw (%%"REG_S",%%"REG_a",), %%mm0    \n\t"
+        "paddw (%%"REG_S",%%"REG_a"), %%mm0    \n\t"
         "paddw %%mm4, %%mm1            \n\t"
-        "movq 8(%%"REG_S",%%"REG_a",), %%mm6    \n\t"
+        "movq 8(%%"REG_S",%%"REG_a"), %%mm6    \n\t"
 
-        "movq %%mm7, (%%"REG_S",%%"REG_a",)     \n\t"
+        "movq %%mm7, (%%"REG_S",%%"REG_a")     \n\t"
         "psraw %%mm2, %%mm0            \n\t"
         "paddw %%mm6, %%mm1            \n\t"
 
-        "movq %%mm7, 8(%%"REG_S",%%"REG_a",)    \n\t"
+        "movq %%mm7, 8(%%"REG_S",%%"REG_a")    \n\t"
         "psraw %%mm2, %%mm1            \n\t"
         "packuswb %%mm1, %%mm0         \n\t"
 
@@ -393,10 +394,10 @@ static void mul_thrmat_mmx(struct vf_priv_s *p, int q)
         );
 }
 
-static void column_fidct_mmx(int16_t* thr_adr,  DCTELEM *data,  DCTELEM *output,  int cnt);
-static void row_idct_mmx(DCTELEM* workspace,
+static void column_fidct_mmx(int16_t* thr_adr,  int16_t *data,  int16_t *output,  int cnt);
+static void row_idct_mmx(int16_t* workspace,
                          int16_t* output_adr,  int output_stride,  int cnt);
-static void row_fdct_mmx(DCTELEM *data,  const uint8_t *pixels,  int line_size,  int cnt);
+static void row_fdct_mmx(int16_t *data,  const uint8_t *pixels,  int line_size,  int cnt);
 
 #define store_slice_s store_slice_mmx
 #define store_slice2_s store_slice2_mmx
@@ -415,9 +416,9 @@ static void filter(struct vf_priv_s *p, uint8_t *dst, uint8_t *src,
     const int stride= is_luma ? p->temp_stride : (width+16);//((width+16+15)&(~15))
     const int step=6-p->log2_count;
     const int qps= 3 + is_luma;
-    int32_t __attribute__((aligned(32))) block_align[4*8*BLOCKSZ+ 4*8*BLOCKSZ];
-    DCTELEM *block= (DCTELEM *)block_align;
-    DCTELEM *block3=(DCTELEM *)(block_align+4*8*BLOCKSZ);
+    DECLARE_ALIGNED(32, int32_t, block_align)[4*8*BLOCKSZ+ 4*8*BLOCKSZ];
+    int16_t *block= (int16_t *)block_align;
+    int16_t *block3=(int16_t *)(block_align+4*8*BLOCKSZ);
 
     memset(block3, 0, 4*8*BLOCKSZ);
 
@@ -460,8 +461,8 @@ static void filter(struct vf_priv_s *p, uint8_t *dst, uint8_t *src,
                     column_fidct_s((int16_t*)(&p->threshold_mtx[0]), block+x*8, block3+x*8, 8); //yes, this is a HOTSPOT
                 }
             row_idct_s(block3+0*8, p->temp + (y&15)*stride+x0+2-(y&1), stride, 2*(BLOCKSZ-1));
-            memmove(block, block+(BLOCKSZ-1)*64, 8*8*sizeof(DCTELEM)); //cycling
-            memmove(block3, block3+(BLOCKSZ-1)*64, 6*8*sizeof(DCTELEM));
+            memmove(block, block+(BLOCKSZ-1)*64, 8*8*sizeof(int16_t)); //cycling
+            memmove(block3, block3+(BLOCKSZ-1)*64, 6*8*sizeof(int16_t));
         }
         //
         es=width+8-x0; //  8, ...
@@ -497,14 +498,14 @@ static int config(struct vf_instance *vf,
     //this can also be avoided, see above
     vf->priv->src = (uint8_t*)av_malloc(vf->priv->temp_stride*h*sizeof(uint8_t));
 
-    return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt);
+    return ff_vf_next_config(vf,width,height,d_width,d_height,flags,outfmt);
 }
 
 static void get_image(struct vf_instance *vf, mp_image_t *mpi)
 {
     if(mpi->flags&MP_IMGFLAG_PRESERVE) return; // don't change
     // ok, we can do pp in-place (or pp disabled):
-    vf->dmpi=vf_get_image(vf->next,mpi->imgfmt,
+    vf->dmpi=ff_vf_get_image(vf->next,mpi->imgfmt,
                           mpi->type, mpi->flags, mpi->width, mpi->height);
     mpi->planes[0]=vf->dmpi->planes[0];
     mpi->stride[0]=vf->dmpi->stride[0];
@@ -523,11 +524,11 @@ static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts)
     mp_image_t *dmpi;
     if(!(mpi->flags&MP_IMGFLAG_DIRECT)){
         // no DR, so get a new image! hope we'll get DR buffer:
-        dmpi=vf_get_image(vf->next,mpi->imgfmt,
+        dmpi=ff_vf_get_image(vf->next,mpi->imgfmt,
                           MP_IMGTYPE_TEMP,
                           MP_IMGFLAG_ACCEPT_STRIDE|MP_IMGFLAG_PREFER_ALIGNED_STRIDE,
                           mpi->width,mpi->height);
-        vf_clone_mpi_attributes(dmpi, mpi);
+        ff_vf_clone_mpi_attributes(dmpi, mpi);
     }else{
         dmpi=vf->dmpi;
     }
@@ -564,12 +565,12 @@ static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts)
     }
 
 #if HAVE_MMX
-    if(gCpuCaps.hasMMX) __asm__ volatile ("emms\n\t");
+    if(ff_gCpuCaps.hasMMX) __asm__ volatile ("emms\n\t");
 #endif
 #if HAVE_MMX2
-    if(gCpuCaps.hasMMX2) __asm__ volatile ("sfence\n\t");
+    if(ff_gCpuCaps.hasMMX2) __asm__ volatile ("sfence\n\t");
 #endif
-    return vf_next_put_image(vf,dmpi, pts);
+    return ff_vf_next_put_image(vf,dmpi, pts);
 }
 
 static void uninit(struct vf_instance *vf)
@@ -605,7 +606,7 @@ static int query_format(struct vf_instance *vf, unsigned int fmt)
     case IMGFMT_444P:
     case IMGFMT_422P:
     case IMGFMT_411P:
-        return vf_next_query_format(vf,fmt);
+        return ff_vf_next_query_format(vf,fmt);
     }
     return 0;
 }
@@ -620,7 +621,7 @@ static int control(struct vf_instance *vf, int request, void* data)
         if (vf->priv->log2_count < 4) vf->priv->log2_count=4;
         return CONTROL_TRUE;
     }
-    return vf_next_control(vf,request,data);
+    return ff_vf_next_control(vf,request,data);
 }
 
 static int vf_open(vf_instance_t *vf, char *args)
@@ -637,7 +638,7 @@ static int vf_open(vf_instance_t *vf, char *args)
     vf->control= control;
     vf->priv=av_mallocz(sizeof(struct vf_priv_s));//assumes align 16 !
 
-    init_avcodec();
+    ff_init_avcodec();
 
     //vf->priv->avctx= avcodec_alloc_context();
     //dsputil_init(&vf->priv->dsp, vf->priv->avctx);
@@ -679,7 +680,7 @@ static int vf_open(vf_instance_t *vf, char *args)
     return 1;
 }
 
-const vf_info_t vf_info_fspp = {
+const vf_info_t ff_vf_info_fspp = {
     "fast simple postprocess",
     "fspp",
     "Michael Niedermayer, Nikolaj Poroshin",
@@ -694,7 +695,7 @@ const vf_info_t vf_info_fspp = {
 
 //#define MANGLE(a) #a
 
-//typedef int16_t DCTELEM; //! only int16_t
+//typedef int16_t int16_t; //! only int16_t
 
 #define DCTSIZE 8
 #define DCTSIZE_S "8"
@@ -710,8 +711,8 @@ const vf_info_t vf_info_fspp = {
 #if HAVE_MMX
 
 DECLARE_ASM_CONST(8, uint64_t, MM_FIX_0_382683433)=FIX64(0.382683433, 14);
-DECLARE_ALIGNED(8, uint64_t, MM_FIX_0_541196100)=FIX64(0.541196100, 14);
-DECLARE_ALIGNED(8, uint64_t, MM_FIX_0_707106781)=FIX64(0.707106781, 14);
+DECLARE_ALIGNED(8, uint64_t, ff_MM_FIX_0_541196100)=FIX64(0.541196100, 14);
+DECLARE_ALIGNED(8, uint64_t, ff_MM_FIX_0_707106781)=FIX64(0.707106781, 14);
 DECLARE_ASM_CONST(8, uint64_t, MM_FIX_1_306562965)=FIX64(1.306562965, 14);
 
 DECLARE_ASM_CONST(8, uint64_t, MM_FIX_1_414213562_A)=FIX64(1.414213562, 14);
@@ -745,15 +746,15 @@ static const int16_t FIX_1_082392200=FIX(1.082392200, 13);
 
 #if !HAVE_MMX
 
-static void column_fidct_c(int16_t* thr_adr, DCTELEM *data, DCTELEM *output, int cnt)
+static void column_fidct_c(int16_t* thr_adr, int16_t *data, int16_t *output, int cnt)
 {
     int_simd16_t tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
     int_simd16_t tmp10, tmp11, tmp12, tmp13;
     int_simd16_t z1,z2,z3,z4,z5, z10, z11, z12, z13;
     int_simd16_t d0, d1, d2, d3, d4, d5, d6, d7;
 
-    DCTELEM* dataptr;
-    DCTELEM* wsptr;
+    int16_t* dataptr;
+    int16_t* wsptr;
     int16_t *threshold;
     int ctr;
 
@@ -870,9 +871,9 @@ static void column_fidct_c(int16_t* thr_adr, DCTELEM *data, DCTELEM *output, int
 
 #else /* HAVE_MMX */
 
-static void column_fidct_mmx(int16_t* thr_adr,  DCTELEM *data,  DCTELEM *output,  int cnt)
+static void column_fidct_mmx(int16_t* thr_adr,  int16_t *data,  int16_t *output,  int cnt)
 {
-    uint64_t __attribute__((aligned(8))) temps[4];
+    DECLARE_ALIGNED(8, uint64_t, temps)[4];
     __asm__ volatile(
         ASMALIGN(4)
         "1:                   \n\t"
@@ -917,7 +918,7 @@ static void column_fidct_mmx(int16_t* thr_adr,  DCTELEM *data,  DCTELEM *output,
         "paddusw 0*16(%%"REG_d"), %%mm5    \n\t"
         "paddusw %%mm6, %%mm2          \n\t"
 
-        "pmulhw "MANGLE(MM_FIX_0_707106781)", %%mm7 \n\t"
+        "pmulhw "MANGLE(ff_MM_FIX_0_707106781)", %%mm7 \n\t"
         //
         "paddw 0*16(%%"REG_d"), %%mm5      \n\t"
         "paddw %%mm6, %%mm2            \n\t"
@@ -997,13 +998,13 @@ static void column_fidct_mmx(int16_t* thr_adr,  DCTELEM *data,  DCTELEM *output,
         "pmulhw "MANGLE(MM_FIX_0_382683433)", %%mm3 \n\t"
         "psllw $2, %%mm4              \n\t"
 
-        "pmulhw "MANGLE(MM_FIX_0_541196100)", %%mm7 \n\t"
+        "pmulhw "MANGLE(ff_MM_FIX_0_541196100)", %%mm7 \n\t"
         "psllw $2, %%mm2              \n\t"
 
         "pmulhw "MANGLE(MM_FIX_1_306562965)", %%mm4 \n\t"
         "paddw %%mm1, %%mm5            \n\t" //'t1
 
-        "pmulhw "MANGLE(MM_FIX_0_707106781)", %%mm2 \n\t"
+        "pmulhw "MANGLE(ff_MM_FIX_0_707106781)", %%mm2 \n\t"
         "psubw %%mm1, %%mm6            \n\t" //'t2
         // t7 't12 't11 t4 t6 - 't13 't10   ---
 
@@ -1275,7 +1276,7 @@ static void column_fidct_mmx(int16_t* thr_adr,  DCTELEM *data,  DCTELEM *output,
         "paddusw 1*8+0*16(%%"REG_d"), %%mm5 \n\t"
         "paddusw %%mm6, %%mm2          \n\t"
 
-        "pmulhw "MANGLE(MM_FIX_0_707106781)", %%mm7 \n\t"
+        "pmulhw "MANGLE(ff_MM_FIX_0_707106781)", %%mm7 \n\t"
         //
         "paddw 1*8+0*16(%%"REG_d"), %%mm5  \n\t"
         "paddw %%mm6, %%mm2            \n\t"
@@ -1355,13 +1356,13 @@ static void column_fidct_mmx(int16_t* thr_adr,  DCTELEM *data,  DCTELEM *output,
         "pmulhw "MANGLE(MM_FIX_0_382683433)", %%mm3 \n\t"
         "psllw $2, %%mm4              \n\t"
 
-        "pmulhw "MANGLE(MM_FIX_0_541196100)", %%mm7 \n\t"
+        "pmulhw "MANGLE(ff_MM_FIX_0_541196100)", %%mm7 \n\t"
         "psllw $2, %%mm2              \n\t"
 
         "pmulhw "MANGLE(MM_FIX_1_306562965)", %%mm4 \n\t"
         "paddw %%mm1, %%mm5            \n\t" //'t1
 
-        "pmulhw "MANGLE(MM_FIX_0_707106781)", %%mm2 \n\t"
+        "pmulhw "MANGLE(ff_MM_FIX_0_707106781)", %%mm2 \n\t"
         "psubw %%mm1, %%mm6            \n\t" //'t2
         // t7 't12 't11 t4 t6 - 't13 't10   ---
 
@@ -1597,6 +1598,10 @@ static void column_fidct_mmx(int16_t* thr_adr,  DCTELEM *data,  DCTELEM *output,
 
         : "+S"(data), "+D"(output), "+c"(cnt), "=o"(temps)
         : "d"(thr_adr)
+          NAMED_CONSTRAINTS_ADD(ff_MM_FIX_0_707106781,MM_2,MM_FIX_1_414213562_A,MM_FIX_1_414213562,MM_FIX_0_382683433,
+          ff_MM_FIX_0_541196100,MM_FIX_1_306562965,MM_FIX_0_847759065)
+          NAMED_CONSTRAINTS_ADD(MM_FIX_0_566454497,MM_FIX_0_198912367,MM_FIX_2_613125930,MM_FIX_1_847759065,
+          MM_FIX_1_082392200,ff_MM_FIX_0_541196100,MM_FIX_1_306562965)
         : "%"REG_a
         );
 }
@@ -1605,14 +1610,14 @@ static void column_fidct_mmx(int16_t* thr_adr,  DCTELEM *data,  DCTELEM *output,
 
 #if !HAVE_MMX
 
-static void row_idct_c(DCTELEM* workspace,
+static void row_idct_c(int16_t* workspace,
                        int16_t* output_adr, int output_stride, int cnt)
 {
     int_simd16_t tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
     int_simd16_t tmp10, tmp11, tmp12, tmp13;
     int_simd16_t z5, z10, z11, z12, z13;
     int16_t* outptr;
-    DCTELEM* wsptr;
+    int16_t* wsptr;
 
     cnt*=4;
     wsptr = workspace;
@@ -1670,10 +1675,10 @@ static void row_idct_c(DCTELEM* workspace,
 
 #else /* HAVE_MMX */
 
-static void row_idct_mmx (DCTELEM* workspace,
+static void row_idct_mmx (int16_t* workspace,
                           int16_t* output_adr,  int output_stride,  int cnt)
 {
-    uint64_t __attribute__((aligned(8))) temps[4];
+    DECLARE_ALIGNED(8, uint64_t, temps)[4];
     __asm__ volatile(
         "lea (%%"REG_a",%%"REG_a",2), %%"REG_d"    \n\t"
         "1:                     \n\t"
@@ -1815,7 +1820,7 @@ static void row_idct_mmx (DCTELEM* workspace,
         "paddw (%%"REG_D"), %%mm5          \n\t"
         "psraw $3, %%mm7              \n\t"
 
-        "paddw (%%"REG_D",%%"REG_a",), %%mm1    \n\t"
+        "paddw (%%"REG_D",%%"REG_a"), %%mm1    \n\t"
         "paddw %%mm2, %%mm0            \n\t"
 
         "paddw (%%"REG_D",%%"REG_a",2), %%mm7   \n\t"
@@ -1824,7 +1829,7 @@ static void row_idct_mmx (DCTELEM* workspace,
         "movq %%mm5, (%%"REG_D")           \n\t"
         "paddw %%mm2, %%mm6            \n\t"
 
-        "movq %%mm1, (%%"REG_D",%%"REG_a",)     \n\t"
+        "movq %%mm1, (%%"REG_D",%%"REG_a")     \n\t"
         "psraw $3, %%mm0              \n\t"
 
         "movq %%mm7, (%%"REG_D",%%"REG_a",2)    \n\t"
@@ -1836,7 +1841,7 @@ static void row_idct_mmx (DCTELEM* workspace,
         "paddw (%%"REG_D",%%"REG_a",2), %%mm0   \n\t"
         "psubw %%mm4, %%mm5            \n\t" //d3
 
-        "paddw (%%"REG_D",%%"REG_d",), %%mm3    \n\t"
+        "paddw (%%"REG_D",%%"REG_d"), %%mm3    \n\t"
         "psraw $3, %%mm6              \n\t"
 
         "paddw 1*8+%3, %%mm4           \n\t" //d4
@@ -1851,13 +1856,13 @@ static void row_idct_mmx (DCTELEM* workspace,
         "paddw (%%"REG_D"), %%mm5          \n\t"
         "psraw $3, %%mm4              \n\t"
 
-        "paddw (%%"REG_D",%%"REG_a",), %%mm4    \n\t"
+        "paddw (%%"REG_D",%%"REG_a"), %%mm4    \n\t"
         "add $"DCTSIZE_S"*2*4, %%"REG_S"      \n\t" //4 rows
 
-        "movq %%mm3, (%%"REG_D",%%"REG_d",)     \n\t"
+        "movq %%mm3, (%%"REG_D",%%"REG_d")     \n\t"
         "movq %%mm6, (%%"REG_D",%%"REG_a",4)    \n\t"
         "movq %%mm5, (%%"REG_D")           \n\t"
-        "movq %%mm4, (%%"REG_D",%%"REG_a",)     \n\t"
+        "movq %%mm4, (%%"REG_D",%%"REG_a")     \n\t"
 
         "sub %%"REG_d", %%"REG_D"             \n\t"
         "add $8, %%"REG_D"               \n\t"
@@ -1866,6 +1871,8 @@ static void row_idct_mmx (DCTELEM* workspace,
 
         : "+S"(workspace), "+D"(output_adr), "+c"(cnt), "=o"(temps)
         : "a"(output_stride*sizeof(short))
+        NAMED_CONSTRAINTS_ADD(MM_FIX_1_414213562_A,MM_FIX_2_613125930,MM_FIX_1_847759065,MM_FIX_1_082392200,
+        MM_FIX_1_414213562,MM_DESCALE_RND)
         : "%"REG_d
         );
 }
@@ -1874,12 +1881,12 @@ static void row_idct_mmx (DCTELEM* workspace,
 
 #if !HAVE_MMX
 
-static void row_fdct_c(DCTELEM *data, const uint8_t *pixels, int line_size, int cnt)
+static void row_fdct_c(int16_t *data, const uint8_t *pixels, int line_size, int cnt)
 {
     int_simd16_t tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
     int_simd16_t tmp10, tmp11, tmp12, tmp13;
     int_simd16_t z1, z2, z3, z4, z5, z11, z13;
-    DCTELEM *dataptr;
+    int16_t *dataptr;
 
     cnt*=4;
     // Pass 1: process rows.
@@ -1937,16 +1944,16 @@ static void row_fdct_c(DCTELEM *data, const uint8_t *pixels, int line_size, int
 
 #else /* HAVE_MMX */
 
-static void row_fdct_mmx(DCTELEM *data,  const uint8_t *pixels,  int line_size,  int cnt)
+static void row_fdct_mmx(int16_t *data,  const uint8_t *pixels,  int line_size,  int cnt)
 {
-    uint64_t __attribute__((aligned(8))) temps[4];
+    DECLARE_ALIGNED(8, uint64_t, temps)[4];
     __asm__ volatile(
         "lea (%%"REG_a",%%"REG_a",2), %%"REG_d"    \n\t"
         "6:                     \n\t"
         "movd (%%"REG_S"), %%mm0           \n\t"
         "pxor %%mm7, %%mm7             \n\t"
 
-        "movd (%%"REG_S",%%"REG_a",), %%mm1     \n\t"
+        "movd (%%"REG_S",%%"REG_a"), %%mm1     \n\t"
         "punpcklbw %%mm7, %%mm0        \n\t"
 
         "movd (%%"REG_S",%%"REG_a",2), %%mm2    \n\t"
@@ -1961,7 +1968,7 @@ static void row_fdct_mmx(DCTELEM *data,  const uint8_t *pixels,  int line_size,
         "movd (%%"REG_S",%%"REG_a",4), %%mm3    \n\t" //7  ;prefetch!
         "movq %%mm1, %%mm6             \n\t"
 
-        "movd (%%"REG_S",%%"REG_d",), %%mm4     \n\t" //6
+        "movd (%%"REG_S",%%"REG_d"), %%mm4     \n\t" //6
         "punpcklbw %%mm7, %%mm3        \n\t"
 
         "psubw %%mm3, %%mm5            \n\t"
@@ -1973,16 +1980,16 @@ static void row_fdct_mmx(DCTELEM *data,  const uint8_t *pixels,  int line_size,
         "movd (%%"REG_S",%%"REG_a",2), %%mm3    \n\t" //5
         "paddw %%mm4, %%mm1            \n\t"
 
-        "movq %%mm5, 0*8+%3            \n\t" //t7
+        "movq %%mm5, %3                \n\t" //t7
         "punpcklbw %%mm7, %%mm3        \n\t"
 
-        "movq %%mm6, 1*8+%3            \n\t" //t6
+        "movq %%mm6, %4                \n\t" //t6
         "movq %%mm2, %%mm4             \n\t"
 
         "movd (%%"REG_S"), %%mm5           \n\t" //3
         "paddw %%mm3, %%mm2            \n\t"
 
-        "movd (%%"REG_S",%%"REG_a",), %%mm6     \n\t" //4
+        "movd (%%"REG_S",%%"REG_a"), %%mm6     \n\t" //4
         "punpcklbw %%mm7, %%mm5        \n\t"
 
         "psubw %%mm3, %%mm4            \n\t"
@@ -2006,7 +2013,7 @@ static void row_fdct_mmx(DCTELEM *data,  const uint8_t *pixels,  int line_size,
         "psllw $2, %%mm1              \n\t"
         "paddw %%mm5, %%mm6            \n\t" //t10
 
-        "pmulhw "MANGLE(MM_FIX_0_707106781)", %%mm1 \n\t"
+        "pmulhw "MANGLE(ff_MM_FIX_0_707106781)", %%mm1 \n\t"
         "paddw %%mm6, %%mm7            \n\t" //d2
 
         "psubw %%mm2, %%mm6            \n\t" //d3
@@ -2022,7 +2029,7 @@ static void row_fdct_mmx(DCTELEM *data,  const uint8_t *pixels,  int line_size,
         "psubw %%mm1, %%mm5            \n\t" //d1
         "movq %%mm0, %%mm6             \n\t"
 
-        "movq 1*8+%3, %%mm1            \n\t"
+        "movq %4, %%mm1                \n\t"
         "punpcklwd %%mm5, %%mm0        \n\t"
 
         "punpckhwd %%mm5, %%mm6        \n\t"
@@ -2046,16 +2053,16 @@ static void row_fdct_mmx(DCTELEM *data,  const uint8_t *pixels,  int line_size,
         "movq %%mm7, "DCTSIZE_S"*3*2(%%"REG_D") \n\t"
         "psllw $2, %%mm3              \n\t" //t10
 
-        "movq 0*8+%3, %%mm2           \n\t"
+        "movq %3, %%mm2               \n\t"
         "psllw $2, %%mm4              \n\t" //t11
 
-        "pmulhw "MANGLE(MM_FIX_0_707106781)", %%mm4 \n\t" //z3
+        "pmulhw "MANGLE(ff_MM_FIX_0_707106781)", %%mm4 \n\t" //z3
         "paddw %%mm2, %%mm1            \n\t"
 
         "psllw $2, %%mm1              \n\t" //t12
         "movq %%mm3, %%mm0             \n\t"
 
-        "pmulhw "MANGLE(MM_FIX_0_541196100)", %%mm0 \n\t"
+        "pmulhw "MANGLE(ff_MM_FIX_0_541196100)", %%mm0 \n\t"
         "psubw %%mm1, %%mm3            \n\t"
 
         "pmulhw "MANGLE(MM_FIX_0_382683433)", %%mm3 \n\t" //z5
@@ -2109,8 +2116,9 @@ static void row_fdct_mmx(DCTELEM *data,  const uint8_t *pixels,  int line_size,
         "dec %%"REG_c"                   \n\t"
         "jnz 6b                  \n\t"
 
-        : "+S"(pixels), "+D"(data), "+c"(cnt), "=o"(temps)
+        : "+S"(pixels), "+D"(data), "+c"(cnt), "=o"(temps), "=o"(temps[1])
         : "a"(line_size)
+        NAMED_CONSTRAINTS_ADD(ff_MM_FIX_0_707106781,ff_MM_FIX_0_541196100,MM_FIX_0_382683433,MM_FIX_1_306562965)
         : "%"REG_d);
 }