]> granicus.if.org Git - libx264/commitdiff
Altivec functions for MC using the cached halfpel planes.
authorLoren Merritt <pengvado@videolan.org>
Thu, 24 Feb 2005 13:09:55 +0000 (13:09 +0000)
committerLoren Merritt <pengvado@videolan.org>
Thu, 24 Feb 2005 13:09:55 +0000 (13:09 +0000)
Patch by Fredrik Pettersson <fredrik_pettersson at yahoo dot se>.

git-svn-id: svn://svn.videolan.org/x264/trunk@142 df754926-b1dd-0310-bc7b-ec298dee348c

common/mc.c
common/ppc/mc.c
common/ppc/mc.h

index 7e4e3ea0c23757f587d868bc8a0c32ea140a0c15..ea085daabdd781b5aac2f863411e8469edcfa49a 100644 (file)
@@ -393,12 +393,10 @@ void x264_mc_init( int cpu, x264_mc_functions_t *pf )
     if( cpu&X264_CPU_SSE2 )
         x264_mc_sse2_init( pf );
 #endif
-/*
 #ifdef ARCH_PPC
     if( cpu&X264_CPU_ALTIVEC )
         x264_mc_altivec_init( pf );
 #endif
-*/
 }
 
 void get_funcs_mmx(pf_mc_t*, pf_mc_t*, pf_mc_t*);
index 901d285e5840963db699913390c303876ebe55fb..14ea74be079eb016e7238f375220f68392e9b8f6 100644 (file)
@@ -680,7 +680,115 @@ static void motion_compensation_luma( uint8_t *src, int i_src,
     }
 }
 
-void x264_mc_altivec_init( x264_mc_function_t pf[2] )
+void mc_luma_altivec( uint8_t *src[4], int i_src_stride,
+                      uint8_t *dst,    int i_dst_stride,
+                      int mvx, int mvy,
+                      int i_width, int i_height )
+{
+    uint8_t *src1, *src2;
+    
+    /* todo : fixme... */
+    int correction = ((mvx&3) == 3 && (mvy&3) == 1 || (mvx&3) == 1 && (mvy&3) == 3) ? 1:0;
+    
+    int hpel1x = mvx>>1;
+    int hpel1y = (mvy+1-correction)>>1;
+    int filter1 = (hpel1x & 1) + ( (hpel1y & 1) << 1 );
+    
+    
+    src1 = src[filter1] + (hpel1y >> 1) * i_src_stride + (hpel1x >> 1);
+    
+    if ( (mvx|mvy) & 1 ) /* qpel interpolation needed */
+    {
+        int hpel2x = (mvx+1)>>1;
+        int hpel2y = (mvy+correction)>>1;
+        int filter2 = (hpel2x & 1) + ( (hpel2y & 1) <<1 );
+        
+        src2 = src[filter2] + (hpel2y >> 1) * i_src_stride + (hpel2x >> 1);
+        
+        switch(i_width) {
+        case 4:
+            pixel_avg_w4( dst, i_dst_stride, src1, i_src_stride,
+                          src2, i_src_stride, i_height );
+            break;
+        case 8:
+            pixel_avg_w8( dst, i_dst_stride, src1, i_src_stride,
+                          src2, i_src_stride, i_height );
+            break;
+        case 16:
+        default:
+            pixel_avg_w16( dst, i_dst_stride, src1, i_src_stride,
+                           src2, i_src_stride, i_height );
+        }
+        
+    }
+    else
+    {
+        switch(i_width) {
+        case 4:
+            mc_copy_w4( src1, i_src_stride, dst, i_dst_stride, i_height );
+            break;
+        case 8:
+            mc_copy_w8( src1, i_src_stride, dst, i_dst_stride, i_height );
+            break;
+        case 16:
+            mc_copy_w16( src1, i_src_stride, dst, i_dst_stride, i_height );
+            break;
+        }
+        
+    }
+}
+
+uint8_t *get_ref_altivec( uint8_t *src[4], int i_src_stride,
+                          uint8_t *dst,    int * i_dst_stride,
+                          int mvx, int mvy,
+                          int i_width, int i_height )
+{
+    uint8_t *src1, *src2;
+    
+    /* todo : fixme... */
+    int correction = ((mvx&3) == 3 && (mvy&3) == 1 || (mvx&3) == 1 && (mvy&3) == 3) ? 1:0;
+    
+    int hpel1x = mvx>>1;
+    int hpel1y = (mvy+1-correction)>>1;
+    int filter1 = (hpel1x & 1) + ( (hpel1y & 1) << 1 );
+    
+    
+    src1 = src[filter1] + (hpel1y >> 1) * i_src_stride + (hpel1x >> 1);
+    
+    if ( (mvx|mvy) & 1 ) /* qpel interpolation needed */
+    {
+        int hpel2x = (mvx+1)>>1;
+        int hpel2y = (mvy+correction)>>1;
+        int filter2 = (hpel2x & 1) + ( (hpel2y & 1) <<1 );
+        
+        src2 = src[filter2] + (hpel2y >> 1) * i_src_stride + (hpel2x >> 1);
+        
+        switch(i_width) {
+        case 4:
+            pixel_avg_w4( dst, *i_dst_stride, src1, i_src_stride,
+                          src2, i_src_stride, i_height );
+            break;
+        case 8:
+            pixel_avg_w8( dst, *i_dst_stride, src1, i_src_stride,
+                          src2, i_src_stride, i_height );
+            break;
+        case 16:
+        default:
+            pixel_avg_w16( dst, *i_dst_stride, src1, i_src_stride,
+                          src2, i_src_stride, i_height );
+        }
+        return dst;
+
+    }
+    else
+    {
+        *i_dst_stride = i_src_stride;
+        return src1;
+    }
+}
+
+void x264_mc_altivec_init( x264_mc_functions_t *pf )
 {
-    pf[MC_LUMA] = motion_compensation_luma;
+    pf->mc_luma   = mc_luma_altivec;
+    pf->get_ref   = get_ref_altivec;
 }
index cf006f2ba00cb3086785f7a3b9f62dff776b0b2d..e37792174b7a44d61818e5544b60744ecce58347 100644 (file)
@@ -24,6 +24,6 @@
 #ifndef _PPC_MC_H
 #define _PPC_MC_H 1
 
-void x264_mc_altivec_init( x264_mc_function_t pf[2] );
+void x264_mc_altivec_init( x264_mc_functions_t *pf );
 
 #endif