Changeset 9ab737d74a7e958f0c1d46b65e456cfa45c93e24

Show
Ignore:
Timestamp:
01/27/04 04:22:03 (5 years ago)
Author:
Eric Petit <titer@videolan.org>
git-committer:
Eric Petit <titer@videolan.org> 1075173723 +0000
git-parent:

[b29cf1057e4fdc6179ee7ce50af6269d82ece22c]

git-author:
Eric Petit <titer@videolan.org> 1075173723 +0000
Message:

i420_yuy2.c: made the altivec optim a bit nicer (probably a bit faster, too)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/video_chroma/i420_yuy2.c

    rb3e689d r9ab737d  
    33 ***************************************************************************** 
    44 * Copyright (C) 2000, 2001 VideoLAN 
    5  * $Id: i420_yuy2.c,v 1.6 2004/01/26 16:54:56 titer Exp $ 
     5 * $Id: i420_yuy2.c,v 1.7 2004/01/27 03:22:03 titer Exp $ 
    66 * 
    77 * Authors: Samuel Hocevar <sam@zoy.org> 
     
    166166    int i_x, i_y; 
    167167 
     168#if !defined (MODULE_NAME_IS_i420_yuy2_altivec) 
    168169    const int i_source_margin = p_source->p->i_pitch 
    169170                                 - p_source->p->i_visible_pitch; 
     
    171172                               - p_dest->p->i_visible_pitch; 
    172173 
    173 #if defined (MODULE_NAME_IS_i420_yuy2_altivec) 
    174     vector unsigned char u_vec; 
    175     vector unsigned char v_vec; 
    176     vector unsigned char uv_vec; 
    177     vector unsigned char y_vec; 
    178     int high = 1; 
    179 #endif 
    180  
    181174    for( i_y = p_vout->render.i_height / 2 ; i_y-- ; ) 
    182175    { 
     
    187180        p_y2 += p_source->p[Y_PLANE].i_pitch; 
    188181 
    189 #if defined (MODULE_NAME_IS_i420_yuy2_altivec) 
    190         /* FIXME Thats only works for sizes multiple of 16 */ 
    191         for( i_x = p_vout->render.i_width / 16 ; i_x-- ; ) 
    192         { 
    193             if( high ) 
    194             { 
    195                 u_vec = vec_ld( 0, p_u ); p_u += 16; 
    196                 v_vec = vec_ld( 0, p_v ); p_v += 16; 
    197                 uv_vec = vec_mergeh( u_vec, v_vec ); 
    198             } 
    199             else 
    200             { 
    201                 uv_vec = vec_mergel( u_vec, v_vec ); 
    202             } 
    203             y_vec = vec_ld( 0, p_y1 ); p_y1 += 16; 
    204             vec_st( vec_mergeh( y_vec, uv_vec ), 0, p_line1 ); p_line1 += 16; 
    205             vec_st( vec_mergel( y_vec, uv_vec ), 0, p_line1 ); p_line1 += 16; 
    206             y_vec = vec_ld( 0, p_y2 ); p_y2 += 16; 
    207             vec_st( vec_mergeh( y_vec, uv_vec ), 0, p_line2 ); p_line2 += 16; 
    208             vec_st( vec_mergel( y_vec, uv_vec ), 0, p_line2 ); p_line2 += 16; 
    209             high = !high; 
    210         } 
    211 #else 
    212182        for( i_x = p_vout->render.i_width / 8 ; i_x-- ; ) 
    213183        { 
     
    221191#endif 
    222192        } 
    223 #endif 
    224193 
    225194        p_y1 += i_source_margin; 
     
    228197        p_line2 += i_dest_margin; 
    229198    } 
     199#else 
     200#define VEC_NEXT_LINES( ) \ 
     201    p_line1  = p_line2; \ 
     202    p_line2 += p_dest->p->i_pitch; \ 
     203    p_y1     = p_y2; \ 
     204    p_y2    += p_source->p[Y_PLANE].i_pitch; 
     205 
     206#define VEC_LOAD_UV( ) \ 
     207    u_vec = vec_ld( 0, p_u ); p_u += 16; \ 
     208    v_vec = vec_ld( 0, p_v ); p_v += 16; 
     209 
     210#define VEC_MERGE( a ) \ 
     211    uv_vec = a( u_vec, v_vec ); \ 
     212    y_vec = vec_ld( 0, p_y1 ); p_y1 += 16; \ 
     213    vec_st( vec_mergeh( y_vec, uv_vec ), 0, p_line1 ); p_line1 += 16; \ 
     214    vec_st( vec_mergel( y_vec, uv_vec ), 0, p_line1 ); p_line1 += 16; \ 
     215    y_vec = vec_ld( 0, p_y2 ); p_y2 += 16; \ 
     216    vec_st( vec_mergeh( y_vec, uv_vec ), 0, p_line2 ); p_line2 += 16; \ 
     217    vec_st( vec_mergel( y_vec, uv_vec ), 0, p_line2 ); p_line2 += 16; 
     218 
     219    vector unsigned char u_vec; 
     220    vector unsigned char v_vec; 
     221    vector unsigned char uv_vec; 
     222    vector unsigned char y_vec; 
     223 
     224    if( !( p_vout->render.i_width % 32 ) ) 
     225    { 
     226        /* Width is a multiple of 32, we take 2 lines at a time */ 
     227        for( i_y = p_vout->render.i_height / 2 ; i_y-- ; ) 
     228        { 
     229            VEC_NEXT_LINES( ); 
     230            for( i_x = p_vout->render.i_width / 32 ; i_x-- ; ) 
     231            { 
     232                VEC_LOAD_UV( ); 
     233                VEC_MERGE( vec_mergeh ); 
     234                VEC_MERGE( vec_mergel ); 
     235            } 
     236        } 
     237    } 
     238    else 
     239    { 
     240        /* Width is only a multiple of 16, we take 4 lines at a time */ 
     241        for( i_y = p_vout->render.i_height / 4 ; i_y-- ; ) 
     242        { 
     243            /* Line 1 and 2, pixels 0 to ( width - 16 ) */ 
     244            VEC_NEXT_LINES( ); 
     245            for( i_x = p_vout->render.i_width / 32 ; i_x-- ; ) 
     246            { 
     247                VEC_LOAD_UV( ); 
     248                VEC_MERGE( vec_mergeh ); 
     249                VEC_MERGE( vec_mergel ); 
     250            } 
     251 
     252            /* Line 1 and 2, pixels ( width - 16 ) to ( width ) */ 
     253            VEC_LOAD_UV( ); 
     254            VEC_MERGE( vec_mergeh ); 
     255 
     256            /* Line 3 and 4, pixels 0 to 16 */ 
     257            VEC_NEXT_LINES( ); 
     258            VEC_MERGE( vec_mergel ); 
     259 
     260            /* Line 3 and 4, pixels 16 to ( width ) */ 
     261            for( i_x = p_vout->render.i_width / 32 ; i_x-- ; ) 
     262            { 
     263                VEC_LOAD_UV( ); 
     264                VEC_MERGE( vec_mergeh ); 
     265                VEC_MERGE( vec_mergel ); 
     266            } 
     267        } 
     268    } 
     269#undef VEC_NEXT_LINES 
     270#undef VEC_LOAD_UV 
     271#undef VEC_MERGE 
     272#endif 
    230273} 
    231274