Commit 8c357b20 authored by Eric Petit's avatar Eric Petit

deinterlace.c: added AltiVec optims for 16-bytes unaligned lines

parent 6a0e132d
...@@ -928,29 +928,64 @@ static void EndMMX( void ) ...@@ -928,29 +928,64 @@ static void EndMMX( void )
static void MergeAltivec( void *_p_dest, const void *_p_s1, static void MergeAltivec( void *_p_dest, const void *_p_s1,
const void *_p_s2, size_t i_bytes ) const void *_p_s2, size_t i_bytes )
{ {
uint8_t *p_dest = (uint8_t*)_p_dest; uint8_t *p_dest = (uint8_t *)_p_dest;
const uint8_t *p_s1 = (const uint8_t *)_p_s1; uint8_t *p_s1 = (uint8_t *)_p_s1;
const uint8_t *p_s2 = (const uint8_t *)_p_s2; uint8_t *p_s2 = (uint8_t *)_p_s2;
uint8_t *p_end = p_dest + i_bytes - 16; uint8_t *p_end = p_dest + i_bytes - 15;
if( ( (int)p_s1 & 0xF ) | ( (int)p_s2 & 0xF ) | /* Use C until the first 16-bytes aligned destination pixel */
( (int)p_dest & 0xF ) ) while( (int)p_dest & 0xF )
{ {
/* TODO Handle non 16-bytes aligned planes */ *p_dest++ = ( (uint16_t)(*p_s1++) + (uint16_t)(*p_s2++) ) >> 1;
MergeGeneric( _p_dest, _p_s1, _p_s2, i_bytes );
return;
} }
while( p_dest < p_end ) if( ( (int)p_s1 & 0xF ) | ( (int)p_s2 & 0xF ) )
{ {
vec_st( vec_avg( vec_ld( 0, p_s1 ), vec_ld( 0, p_s2 ) ), /* Unaligned source */
0, p_dest ); vector unsigned char s1v, s2v, destv;
p_s1 += 16; vector unsigned char s1oldv, s2oldv, s1newv, s2newv;
p_s2 += 16; vector unsigned char perm1v, perm2v;
p_dest += 16;
perm1v = vec_lvsl( 0, p_s1 );
perm2v = vec_lvsl( 0, p_s2 );
s1oldv = vec_ld( 0, p_s1 );
s2oldv = vec_ld( 0, p_s2 );
while( p_dest < p_end )
{
s1newv = vec_ld( 16, p_s1 );
s2newv = vec_ld( 16, p_s2 );
s1v = vec_perm( s1oldv, s1newv, perm1v );
s2v = vec_perm( s2oldv, s2newv, perm2v );
s1oldv = s1newv;
s2oldv = s2newv;
destv = vec_avg( s1v, s2v );
vec_st( destv, 0, p_dest );
p_s1 += 16;
p_s2 += 16;
p_dest += 16;
}
} }
else
{
/* Aligned source */
vector unsigned char s1v, s2v, destv;
p_end += 16; while( p_dest < p_end )
{
s1v = vec_ld( 0, p_s1 );
s2v = vec_ld( 0, p_s2 );
destv = vec_avg( s1v, s2v );
vec_st( destv, 0, p_dest );
p_s1 += 16;
p_s2 += 16;
p_dest += 16;
}
}
p_end += 15;
while( p_dest < p_end ) while( p_dest < p_end )
{ {
......
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