mc: add incompete get_ref assembly
authorKieran Kunhya <kierank@obe.tv>
Sat, 14 Mar 2015 21:54:00 +0000 (21:54 +0000)
committerKieran Kunhya <kierank@obe.tv>
Sat, 14 Mar 2015 21:54:00 +0000 (21:54 +0000)
common/mc.c
common/x86/mc-c.c
common/x86/mc.h

index 882d07c..77c0c63 100644 (file)
@@ -819,6 +819,10 @@ void x264_mc_init( int cpu, x264_mc_functions_t *pf, int cpu_independent, int b_
         pf->get_ref   = get_ref_mpeg2;
         pf->hpel_filter = NULL;
         pf->frame_init_lowres_core = frame_init_lowres_core_mpeg2;
+
+#if HAVE_MMX
+            x264_mc_init_mmx_mpeg2( cpu, pf );
+#endif
     }
 
     if( cpu_independent )
index 4ae0e9a..140deb4 100644 (file)
@@ -448,6 +448,53 @@ GET_REF(cache64_ssse3)
 GET_REF(cache64_ssse3_atom)
 #endif // !HIGH_BIT_DEPTH
 
+#define GET_REF_MPEG2(name)\
+static pixel *get_ref_mpeg2_##name( pixel *dst,   intptr_t *i_dst_stride,\
+                                    pixel *src[4], intptr_t i_src_stride,\
+                                    int mvx, int mvy,\
+                                    int i_width, int i_height, const x264_weight_t *weight )\
+{\
+    mvx >>= 1;\
+    mvy >>= 1;\
+    pixel *src1 = src[0] + (mvy>>1)*i_src_stride + (mvx>>1);\
+    pixel *srcp = src1 + i_src_stride;\
+    pixel *dst_bak = dst;\
+    if( !((mvx|mvy)&1) )\
+    {\
+        *i_dst_stride = i_src_stride;\
+        return src1;\
+    }\
+    else if( (mvx&mvy)&1 ) /* centre hpel positions */\
+    {\
+        for( int y = 0; y < i_height; y++ )\
+        {\
+            for( int x = 0; x < i_width; x++ )\
+                dst[x] = ( src1[x] + src1[x+1] + srcp[x] + srcp[x+1] + 2 ) >> 2;\
+            dst  += *i_dst_stride;\
+            src1  = srcp;\
+            srcp += i_src_stride;\
+        }\
+    }\
+    else if( mvx&1 ) /* horizontal hpel positions */\
+    {\
+        pixel *src2 = src1 + 1;\
+        x264_pixel_avg_wtab_##name[i_width>>2](\
+                dst, *i_dst_stride, src1, i_src_stride,\
+                src2, i_height );\
+    }\
+    else /* vertical hpel positions */\
+    {\
+        x264_pixel_avg_wtab_##name[i_width>>2](\
+                dst, *i_dst_stride, src1, i_src_stride,\
+                srcp, i_height );\
+    }\
+    return dst_bak;\
+}
+
+GET_REF_MPEG2(mmx2)
+GET_REF_MPEG2(sse2)
+GET_REF_MPEG2(avx2)
+
 #define HPEL(align, cpu, cpuv, cpuc, cpuh)\
 void x264_hpel_filter_v_##cpuv( pixel *dst, pixel *src, int16_t *buf, intptr_t stride, intptr_t width);\
 void x264_hpel_filter_c_##cpuc( pixel *dst, int16_t *buf, intptr_t width );\
@@ -945,3 +992,21 @@ void x264_mc_init_mmx( int cpu, x264_mc_functions_t *pf )
     if( cpu&X264_CPU_FMA3 )
         pf->mbtree_propagate_cost = x264_mbtree_propagate_cost_avx2_fma3;
 }
+
+void x264_mc_init_mmx_mpeg2( int cpu, x264_mc_functions_t *pf )
+{
+    if( !(cpu&X264_CPU_MMX) )
+        return;
+
+    pf->get_ref = get_ref_mpeg2_mmx2;
+
+    if( !(cpu&X264_CPU_SSE2) )
+        return;
+
+    pf->get_ref = get_ref_mpeg2_sse2;
+
+    if( !(cpu&X264_CPU_AVX2) )
+        return;
+
+    pf->get_ref = get_ref_mpeg2_avx2;
+}
index c9e5634..3e3a0ec 100644 (file)
@@ -28,5 +28,6 @@
 #define X264_I386_MC_H
 
 void x264_mc_init_mmx( int cpu, x264_mc_functions_t *pf );
+void x264_mc_init_mmx_mpeg2( int cpu, x264_mc_functions_t *pf );
 
 #endif