b3 = vec_sub( a0, a1 ); \
b3 = vec_sub( b3, a1 )
-void x264_sub4x4_dct_altivec( int16_t dct[4][4], uint8_t *pix1, uint8_t *pix2 )
+void x264_sub4x4_dct_altivec( int16_t dct[16], uint8_t *pix1, uint8_t *pix2 )
{
PREP_DIFF_8BYTEALIGNED;
vec_s16_t dct0v, dct1v, dct2v, dct3v;
permHighv = (vec_u8_t) CV(0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17);
VEC_DCT( dct0v, dct1v, dct2v, dct3v, tmp0v, tmp1v, tmp2v, tmp3v );
- vec_st(vec_perm(tmp0v, tmp1v, permHighv), 0, (int16_t*)dct);
- vec_st(vec_perm(tmp2v, tmp3v, permHighv), 16, (int16_t*)dct);
+ vec_st(vec_perm(tmp0v, tmp1v, permHighv), 0, dct);
+ vec_st(vec_perm(tmp2v, tmp3v, permHighv), 16, dct);
}
-void x264_sub8x8_dct_altivec( int16_t dct[4][4][4], uint8_t *pix1, uint8_t *pix2 )
+void x264_sub8x8_dct_altivec( int16_t dct[4][16], uint8_t *pix1, uint8_t *pix2 )
{
PREP_DIFF_8BYTEALIGNED;
vec_s16_t dct0v, dct1v, dct2v, dct3v, dct4v, dct5v, dct6v, dct7v;
VEC_DCT( dct0v, dct1v, dct2v, dct3v, tmp0v, tmp1v, tmp2v, tmp3v );
VEC_DCT( dct4v, dct5v, dct6v, dct7v, tmp4v, tmp5v, tmp6v, tmp7v );
- vec_st(vec_perm(tmp0v, tmp1v, permHighv), 0, (int16_t*)dct);
- vec_st(vec_perm(tmp2v, tmp3v, permHighv), 16, (int16_t*)dct);
- vec_st(vec_perm(tmp4v, tmp5v, permHighv), 32, (int16_t*)dct);
- vec_st(vec_perm(tmp6v, tmp7v, permHighv), 48, (int16_t*)dct);
- vec_st(vec_perm(tmp0v, tmp1v, permLowv), 64, (int16_t*)dct);
- vec_st(vec_perm(tmp2v, tmp3v, permLowv), 80, (int16_t*)dct);
- vec_st(vec_perm(tmp4v, tmp5v, permLowv), 96, (int16_t*)dct);
- vec_st(vec_perm(tmp6v, tmp7v, permLowv), 112, (int16_t*)dct);
+ vec_st(vec_perm(tmp0v, tmp1v, permHighv), 0, dct);
+ vec_st(vec_perm(tmp2v, tmp3v, permHighv), 16, dct);
+ vec_st(vec_perm(tmp4v, tmp5v, permHighv), 32, dct);
+ vec_st(vec_perm(tmp6v, tmp7v, permHighv), 48, dct);
+ vec_st(vec_perm(tmp0v, tmp1v, permLowv), 64, dct);
+ vec_st(vec_perm(tmp2v, tmp3v, permLowv), 80, dct);
+ vec_st(vec_perm(tmp4v, tmp5v, permLowv), 96, dct);
+ vec_st(vec_perm(tmp6v, tmp7v, permLowv), 112, dct);
}
-void x264_sub16x16_dct_altivec( int16_t dct[16][4][4], uint8_t *pix1, uint8_t *pix2 )
+void x264_sub16x16_dct_altivec( int16_t dct[16][16], uint8_t *pix1, uint8_t *pix2 )
{
x264_sub8x8_dct_altivec( &dct[ 0], &pix1[0], &pix2[0] );
x264_sub8x8_dct_altivec( &dct[ 4], &pix1[8], &pix2[8] );
}
-void x264_sub8x8_dct8_altivec( int16_t dct[8][8], uint8_t *pix1, uint8_t *pix2 )
+void x264_sub8x8_dct8_altivec( int16_t dct[64], uint8_t *pix1, uint8_t *pix2 )
{
vec_u16_t onev = vec_splat_u16(1);
vec_u16_t twov = vec_add( onev, onev );
DCT8_1D_ALTIVEC( dct_tr0v, dct_tr1v, dct_tr2v, dct_tr3v,
dct_tr4v, dct_tr5v, dct_tr6v, dct_tr7v );
- vec_st( dct_tr0v, 0, (signed short *)dct );
- vec_st( dct_tr1v, 16, (signed short *)dct );
- vec_st( dct_tr2v, 32, (signed short *)dct );
- vec_st( dct_tr3v, 48, (signed short *)dct );
+ vec_st( dct_tr0v, 0, dct );
+ vec_st( dct_tr1v, 16, dct );
+ vec_st( dct_tr2v, 32, dct );
+ vec_st( dct_tr3v, 48, dct );
- vec_st( dct_tr4v, 64, (signed short *)dct );
- vec_st( dct_tr5v, 80, (signed short *)dct );
- vec_st( dct_tr6v, 96, (signed short *)dct );
- vec_st( dct_tr7v, 112, (signed short *)dct );
+ vec_st( dct_tr4v, 64, dct );
+ vec_st( dct_tr5v, 80, dct );
+ vec_st( dct_tr6v, 96, dct );
+ vec_st( dct_tr7v, 112, dct );
}
-void x264_sub16x16_dct8_altivec( int16_t dct[4][8][8], uint8_t *pix1, uint8_t *pix2 )
+void x264_sub16x16_dct8_altivec( int16_t dct[4][64], uint8_t *pix1, uint8_t *pix2 )
{
x264_sub8x8_dct8_altivec( dct[0], &pix1[0], &pix2[0] );
x264_sub8x8_dct8_altivec( dct[1], &pix1[8], &pix2[8] );
vec_ste(bodyv, element, (uint32_t *)dest); \
}
-void x264_add4x4_idct_altivec( uint8_t *dst, int16_t dct[4][4] )
+void x264_add4x4_idct_altivec( uint8_t *dst, int16_t dct[16] )
{
vec_u16_t onev = vec_splat_u16(1);
- dct[0][0] += 32; // rounding for the >>6 at the end
+ dct[0] += 32; // rounding for the >>6 at the end
vec_s16_t s0, s1, s2, s3;
- s0 = vec_ld( 0x00, (int16_t*)dct );
+ s0 = vec_ld( 0x00, dct );
s1 = vec_sld( s0, s0, 8 );
- s2 = vec_ld( 0x10, (int16_t*)dct );
+ s2 = vec_ld( 0x10, dct );
s3 = vec_sld( s2, s2, 8 );
vec_s16_t d0, d1, d2, d3;
ALTIVEC_STORE4_SUM_CLIP( &dst[3*FDEC_STRIDE], idct3, perm_ldv );
}
-void x264_add8x8_idct_altivec( uint8_t *p_dst, int16_t dct[4][4][4] )
+void x264_add8x8_idct_altivec( uint8_t *p_dst, int16_t dct[4][16] )
{
x264_add4x4_idct_altivec( &p_dst[0], dct[0] );
x264_add4x4_idct_altivec( &p_dst[4], dct[1] );
x264_add4x4_idct_altivec( &p_dst[4*FDEC_STRIDE+4], dct[3] );
}
-void x264_add16x16_idct_altivec( uint8_t *p_dst, int16_t dct[16][4][4] )
+void x264_add16x16_idct_altivec( uint8_t *p_dst, int16_t dct[16][16] )
{
x264_add8x8_idct_altivec( &p_dst[0], &dct[0] );
x264_add8x8_idct_altivec( &p_dst[8], &dct[4] );
vec_st( hv, 0, dest ); \
}
-void x264_add8x8_idct8_altivec( uint8_t *dst, int16_t dct[8][8] )
+void x264_add8x8_idct8_altivec( uint8_t *dst, int16_t dct[64] )
{
vec_u16_t onev = vec_splat_u16(1);
vec_u16_t twov = vec_splat_u16(2);
- dct[0][0] += 32; // rounding for the >>6 at the end
+ dct[0] += 32; // rounding for the >>6 at the end
vec_s16_t s0, s1, s2, s3, s4, s5, s6, s7;
- s0 = vec_ld(0x00, (int16_t*)dct);
- s1 = vec_ld(0x10, (int16_t*)dct);
- s2 = vec_ld(0x20, (int16_t*)dct);
- s3 = vec_ld(0x30, (int16_t*)dct);
- s4 = vec_ld(0x40, (int16_t*)dct);
- s5 = vec_ld(0x50, (int16_t*)dct);
- s6 = vec_ld(0x60, (int16_t*)dct);
- s7 = vec_ld(0x70, (int16_t*)dct);
+ s0 = vec_ld(0x00, dct);
+ s1 = vec_ld(0x10, dct);
+ s2 = vec_ld(0x20, dct);
+ s3 = vec_ld(0x30, dct);
+ s4 = vec_ld(0x40, dct);
+ s5 = vec_ld(0x50, dct);
+ s6 = vec_ld(0x60, dct);
+ s7 = vec_ld(0x70, dct);
vec_s16_t d0, d1, d2, d3, d4, d5, d6, d7;
IDCT8_1D_ALTIVEC(s0, s1, s2, s3, s4, s5, s6, s7, d0, d1, d2, d3, d4, d5, d6, d7);
ALTIVEC_STORE_SUM_CLIP(&dst[7*FDEC_STRIDE], idct7, perm_ldv, perm_stv, sel);
}
-void x264_add16x16_idct8_altivec( uint8_t *dst, int16_t dct[4][8][8] )
+void x264_add16x16_idct8_altivec( uint8_t *dst, int16_t dct[4][64] )
{
x264_add8x8_idct8_altivec( &dst[0], dct[0] );
x264_add8x8_idct8_altivec( &dst[8], dct[1] );
x264_add8x8_idct8_altivec( &dst[8*FDEC_STRIDE+8], dct[3] );
}
-void x264_zigzag_scan_4x4_frame_altivec( int16_t level[16], int16_t dct[4][4] )
+void x264_zigzag_scan_4x4_frame_altivec( int16_t level[16], int16_t dct[16] )
{
vec_s16_t dct0v, dct1v;
vec_s16_t tmp0v, tmp1v;
- dct0v = vec_ld(0x00, (int16_t*)dct);
- dct1v = vec_ld(0x10, (int16_t*)dct);
+ dct0v = vec_ld(0x00, dct);
+ dct1v = vec_ld(0x10, dct);
const vec_u8_t sel0 = (vec_u8_t) CV(0,1,8,9,2,3,4,5,10,11,16,17,24,25,18,19);
const vec_u8_t sel1 = (vec_u8_t) CV(12,13,6,7,14,15,20,21,26,27,28,29,22,23,30,31);
vec_st( tmp1v, 0x10, level );
}
-void x264_zigzag_scan_4x4_field_altivec( int16_t level[16], int16_t dct[4][4] )
+void x264_zigzag_scan_4x4_field_altivec( int16_t level[16], int16_t dct[16] )
{
vec_s16_t dct0v, dct1v;
vec_s16_t tmp0v, tmp1v;
- dct0v = vec_ld(0x00, (int16_t*)dct);
- dct1v = vec_ld(0x10, (int16_t*)dct);
+ dct0v = vec_ld(0x00, dct);
+ dct1v = vec_ld(0x10, dct);
const vec_u8_t sel0 = (vec_u8_t) CV(0,1,2,3,8,9,4,5,6,7,10,11,12,13,14,15);
// quant of a whole 4x4 block, unrolled 2x and "pre-scheduled"
#define QUANT_16_U( idx0, idx1 ) \
{ \
- temp1v = vec_ld((idx0), *dct); \
- temp2v = vec_ld((idx1), *dct); \
+ temp1v = vec_ld((idx0), dct); \
+ temp2v = vec_ld((idx1), dct); \
mfvA = vec_ld((idx0), mf); \
mfvB = vec_ld((idx1), mf); \
biasvA = vec_ld((idx0), bias); \
temp1v = vec_xor(temp1v, mskA); \
temp2v = vec_xor(temp2v, mskB); \
temp1v = vec_adds(temp1v, vec_and(mskA, one)); \
- vec_st(temp1v, (idx0), (int16_t*)dct); \
+ vec_st(temp1v, (idx0), dct); \
temp2v = vec_adds(temp2v, vec_and(mskB, one)); \
nz = vec_or(nz, vec_or(temp1v, temp2v)); \
- vec_st(temp2v, (idx1), (int16_t*)dct); \
+ vec_st(temp2v, (idx1), dct); \
}
-int x264_quant_4x4_altivec( int16_t dct[4][4], uint16_t mf[16], uint16_t bias[16] )
+int x264_quant_4x4_altivec( int16_t dct[16], uint16_t mf[16], uint16_t bias[16] )
{
LOAD_ZERO;
vector bool short mskA;
// DC quant of a whole 4x4 block, unrolled 2x and "pre-scheduled"
#define QUANT_16_U_DC( idx0, idx1 ) \
{ \
- temp1v = vec_ld((idx0), *dct); \
- temp2v = vec_ld((idx1), *dct); \
+ temp1v = vec_ld((idx0), dct); \
+ temp2v = vec_ld((idx1), dct); \
mskA = vec_cmplt(temp1v, zero_s16v); \
mskB = vec_cmplt(temp2v, zero_s16v); \
coefvA = (vec_u16_t)vec_max(vec_sub(zero_s16v, temp1v), temp1v);\
temp1v = vec_xor(temp1v, mskA); \
temp2v = vec_xor(temp2v, mskB); \
temp1v = vec_add(temp1v, vec_and(mskA, one)); \
- vec_st(temp1v, (idx0), (int16_t*)dct); \
+ vec_st(temp1v, (idx0), dct); \
temp2v = vec_add(temp2v, vec_and(mskB, one)); \
nz = vec_or(nz, vec_or(temp1v, temp2v)); \
- vec_st(temp2v, (idx1), (int16_t*)dct); \
+ vec_st(temp2v, (idx1), dct); \
}
-int x264_quant_4x4_dc_altivec( int16_t dct[4][4], int mf, int bias )
+int x264_quant_4x4_dc_altivec( int16_t dct[16], int mf, int bias )
{
LOAD_ZERO;
vector bool short mskA;
#define QUANT_4_U_DC( idx0 ) \
{ \
const vec_u16_t sel = (vec_u16_t) CV(-1,-1,-1,-1,0,0,0,0); \
- temp1v = vec_ld((idx0), *dct); \
+ temp1v = vec_ld((idx0), dct); \
mskA = vec_cmplt(temp1v, zero_s16v); \
coefvA = (vec_u16_t)vec_max(vec_sub(zero_s16v, temp1v), temp1v);\
coefvA = vec_add(coefvA, biasv); \
temp2v = vec_add(temp2v, vec_and(mskA, one)); \
temp1v = vec_sel(temp1v, temp2v, sel); \
nz = vec_or(nz, temp1v); \
- vec_st(temp1v, (idx0), (int16_t*)dct); \
+ vec_st(temp1v, (idx0), dct); \
}
-int x264_quant_2x2_dc_altivec( int16_t dct[2][2], int mf, int bias )
+int x264_quant_2x2_dc_altivec( int16_t dct[4], int mf, int bias )
{
LOAD_ZERO;
vector bool short mskA;
return vec_any_ne(vec_and(nz, mask2), zero_s16v);
}
-int x264_quant_8x8_altivec( int16_t dct[8][8], uint16_t mf[64], uint16_t bias[64] )
+int x264_quant_8x8_altivec( int16_t dct[64], uint16_t mf[64], uint16_t bias[64] )
{
LOAD_ZERO;
vector bool short mskA;
#define DEQUANT_SHL() \
{ \
- dctv = vec_ld(0, dct[y]); \
- mf1v = vec_ld(0, dequant_mf[i_mf][y]); \
- mf2v = vec_ld(16, dequant_mf[i_mf][y]); \
+ dctv = vec_ld(8*y, dct); \
+ mf1v = vec_ld(16*y, dequant_mf[i_mf]); \
+ mf2v = vec_ld(16+16*y, dequant_mf[i_mf]); \
mfv = vec_packs(mf1v, mf2v); \
\
multEvenvA = vec_mule(dctv, mfv); \
dctv = (vec_s16_t) vec_packs(vec_mergeh(multEvenvA, multOddvA), \
vec_mergel(multEvenvA, multOddvA)); \
dctv = vec_sl(dctv, i_qbitsv); \
- vec_st(dctv, 0, dct[y]); \
+ vec_st(dctv, 8*y, dct); \
}
#define DEQUANT_SHR() \
{ \
- dctv = vec_ld(0, dct[y]); \
+ dctv = vec_ld(8*y, dct); \
dct1v = vec_mergeh(dctv, dctv); \
dct2v = vec_mergel(dctv, dctv); \
- mf1v = vec_ld(0, dequant_mf[i_mf][y]); \
- mf2v = vec_ld(16, dequant_mf[i_mf][y]); \
+ mf1v = vec_ld(16*y, dequant_mf[i_mf]); \
+ mf2v = vec_ld(16+16*y, dequant_mf[i_mf]); \
\
multEvenvA = vec_mule(dct1v, (vec_s16_t)mf1v); \
multOddvA = vec_mulo(dct1v, (vec_s16_t)mf1v); \
temp2v = vec_sra(temp2v, i_qbitsv); \
\
dctv = (vec_s16_t)vec_packs(temp1v, temp2v); \
- vec_st(dctv, 0, dct[y]); \
+ vec_st(dctv, y*8, dct); \
}
-void x264_dequant_4x4_altivec( int16_t dct[4][4], int dequant_mf[6][4][4], int i_qp )
+void x264_dequant_4x4_altivec( int16_t dct[16], int dequant_mf[6][16], int i_qp )
{
int i_mf = i_qp%6;
int i_qbits = i_qp/6 - 4;
}
}
-void x264_dequant_8x8_altivec( int16_t dct[8][8], int dequant_mf[6][8][8], int i_qp )
+void x264_dequant_8x8_altivec( int16_t dct[64], int dequant_mf[6][64], int i_qp )
{
int i_mf = i_qp%6;
int i_qbits = i_qp/6 - 6;
qbits_u.s[0]=i_qbits;
i_qbitsv = vec_splat(qbits_u.v, 0);
- for( int y = 0; y < 8; y++ )
+ for( int y = 0; y < 16; y+=2 )
DEQUANT_SHL();
}
else
sixteen_u.s[0]=16;
sixteenv = vec_splat(sixteen_u.v, 0);
- for( int y = 0; y < 8; y++ )
+ for( int y = 0; y < 16; y+=2 )
DEQUANT_SHR();
}
}