Commit 7aa5a4e6 authored by Guillaume Poirier's avatar Guillaume Poirier

Add AltiVec implementation of predict_8x8c_p. 2.6x faster than scalar C.

parent 8e485c6d
......@@ -23,6 +23,56 @@
#include "pixel.h"
#include "ppccommon.h"
static void predict_8x8c_p_altivec( uint8_t *src )
{
int i;
int a, b, c;
int H = 0;
int V = 0;
int i00;
for( i = 0; i < 4; i++ )
{
H += ( i + 1 ) * ( src[4+i - FDEC_STRIDE] - src[2 - i -FDEC_STRIDE] );
V += ( i + 1 ) * ( src[-1 +(i+4)*FDEC_STRIDE] - src[-1+(2-i)*FDEC_STRIDE] );
}
a = 16 * ( src[-1+7*FDEC_STRIDE] + src[7 - FDEC_STRIDE] );
b = ( 17 * H + 16 ) >> 5;
c = ( 17 * V + 16 ) >> 5;
i00 = a -3*b -3*c + 16;
vec_s16_u i00_u, b_u, c_u;
i00_u.s[0] = i00;
b_u.s[0] = b;
c_u.s[0] = c;
vec_u16_t val5_v = vec_splat_u16(5);
vec_s16_t i00_v, b_v, c_v;
i00_v = vec_splat(i00_u.v, 0);
b_v = vec_splat(b_u.v, 0);
c_v = vec_splat(c_u.v, 0);
vec_s16_t induc_v = (vec_s16_t) CV(0, 1, 2, 3, 4, 5, 6, 7);
vec_s32_t mule_b_v = vec_mule(induc_v, b_v);
vec_s32_t mulo_b_v = vec_mulo(induc_v, b_v);
vec_s16_t mul_b_induc0_v = vec_pack(vec_mergeh(mule_b_v, mulo_b_v), vec_mergel(mule_b_v, mulo_b_v));
vec_s16_t add_i0_b_0v = vec_adds(i00_v, mul_b_induc0_v);
PREP_STORE8;
for( i = 0; i < 8; ++i )
{
vec_s16_t shift_0_v = vec_sra(add_i0_b_0v, val5_v);
vec_u8_t com_sat_v = vec_packsu(shift_0_v, shift_0_v);
VEC_STORE8(com_sat_v, &src[0]);
src += FDEC_STRIDE;
add_i0_b_0v = vec_adds(add_i0_b_0v, c_v);
}
}
/****************************************************************************
* 16x16 prediction for intra luma block
****************************************************************************/
......@@ -72,7 +122,6 @@ static void predict_16x16_p_altivec( uint8_t *src )
vec_u8_t com_sat_v = vec_packsu(shift_0_v, shift_8_v);
vec_st( com_sat_v, 0, &src[0]);
src += FDEC_STRIDE;
i00 += c;
add_i0_b_0v = vec_adds(add_i0_b_0v, c_v);
add_i0_b_8v = vec_adds(add_i0_b_8v, c_v);
}
......@@ -187,3 +236,8 @@ void x264_predict_16x16_init_altivec( x264_predict_t pf[7] )
pf[I_PRED_16x16_DC_TOP ] = predict_16x16_dc_top_altivec;
pf[I_PRED_16x16_DC_128 ] = predict_16x16_dc_128_altivec;
}
void x264_predict_8x8c_init_altivec( x264_predict_t pf[7] )
{
pf[I_PRED_CHROMA_P] = predict_8x8c_p_altivec;
}
......@@ -22,5 +22,6 @@
#define X264_PPC_PREDICT_H
void x264_predict_16x16_init_altivec ( x264_predict_t pf[7] );
void x264_predict_8x8c_init_altivec( x264_predict_t pf[7] );
#endif /* X264_PPC_PREDICT_H */
......@@ -786,6 +786,13 @@ void x264_predict_8x8c_init( int cpu, x264_predict_t pf[7] )
#ifdef HAVE_MMX
x264_predict_8x8c_init_mmx( cpu, pf );
#endif
#ifdef ARCH_PPC
if( cpu&X264_CPU_ALTIVEC )
{
x264_predict_8x8c_init_altivec( pf );
}
#endif
}
void x264_predict_8x8_init( int cpu, x264_predict8x8_t pf[12] )
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment