X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fvideo_chroma%2Fi422_yuy2.c;h=f7a73686ecfa1143472c0f54f22ed475f791f828;hb=13ae40b0efc4f1b1ce205d9a057537047fcab3f4;hp=91f90102a906b0cb1dde58f83fcbdde1db827e4d;hpb=fe087a38282e93addb25fa9598393e40ea233b09;p=vlc diff --git a/modules/video_chroma/i422_yuy2.c b/modules/video_chroma/i422_yuy2.c index 91f90102a9..f7a73686ec 100644 --- a/modules/video_chroma/i422_yuy2.c +++ b/modules/video_chroma/i422_yuy2.c @@ -1,16 +1,17 @@ /***************************************************************************** - * i422_yuy2.c : YUV to YUV conversion module for vlc + * i422_yuy2.c : Planar YUV 4:2:2 to Packed YUV conversion module for vlc ***************************************************************************** * Copyright (C) 2000, 2001 the VideoLAN team * $Id$ * * Authors: Samuel Hocevar + * Damien Fouilleul * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -18,17 +19,20 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/ /***************************************************************************** * Preamble *****************************************************************************/ -#include /* strerror() */ -#include /* malloc(), free() */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif #include -#include +#include +#include #include "i422_yuy2.h" @@ -52,7 +56,6 @@ static void I422_cyuv ( vout_thread_t *, picture_t *, picture_t * ); #if defined (MODULE_NAME_IS_i422_yuy2) static void I422_Y211 ( vout_thread_t *, picture_t *, picture_t * ); static void I422_Y211 ( vout_thread_t *, picture_t *, picture_t * ); -static void I422_YV12 ( vout_thread_t *, picture_t *, picture_t * ); #endif /***************************************************************************** @@ -60,12 +63,16 @@ static void I422_YV12 ( vout_thread_t *, picture_t *, picture_t * ); *****************************************************************************/ vlc_module_begin(); #if defined (MODULE_NAME_IS_i422_yuy2) - set_description( _("Conversions from " SRC_FOURCC " to " DEST_FOURCC) ); + set_description( N_("Conversions from " SRC_FOURCC " to " DEST_FOURCC) ); set_capability( "chroma", 80 ); #elif defined (MODULE_NAME_IS_i422_yuy2_mmx) - set_description( _("MMX conversions from " SRC_FOURCC " to " DEST_FOURCC) ); + set_description( N_("MMX conversions from " SRC_FOURCC " to " DEST_FOURCC) ); set_capability( "chroma", 100 ); add_requirement( MMX ); +#elif defined (MODULE_NAME_IS_i422_yuy2_sse2) + set_description( N_("SSE2 conversions from " SRC_FOURCC " to " DEST_FOURCC) ); + set_capability( "chroma", 120 ); + add_requirement( SSE2 ); #endif set_callbacks( Activate, NULL ); vlc_module_end(); @@ -116,10 +123,6 @@ static int Activate( vlc_object_t *p_this ) case VLC_FOURCC('Y','2','1','1'): p_vout->chroma.pf_convert = I422_Y211; break; - - case VLC_FOURCC('Y','V','1','2'): - p_vout->chroma.pf_convert = I422_YV12; - break; #endif default: @@ -130,8 +133,7 @@ static int Activate( vlc_object_t *p_this ) default: return -1; } - - return 0; + return 0; } /* Following functions are local */ @@ -149,6 +151,57 @@ static void I422_YUY2( vout_thread_t *p_vout, picture_t *p_source, int i_x, i_y; + const int i_source_margin = p_source->p[0].i_pitch + - p_source->p[0].i_visible_pitch; + const int i_source_margin_c = p_source->p[1].i_pitch + - p_source->p[1].i_visible_pitch; + const int i_dest_margin = p_dest->p->i_pitch + - p_dest->p->i_visible_pitch; + +#if defined (MODULE_NAME_IS_i422_yuy2_sse2) + + if( 0 == (15 & (p_source->p[Y_PLANE].i_pitch|p_dest->p->i_pitch| + ((intptr_t)p_line|(intptr_t)p_y))) ) + { + /* use faster SSE2 aligned fetch and store */ + for( i_y = p_vout->render.i_height ; i_y-- ; ) + { + for( i_x = p_vout->render.i_width / 16 ; i_x-- ; ) + { + SSE2_CALL( SSE2_YUV422_YUYV_ALIGNED ); + } + for( i_x = ( p_vout->render.i_width % 16 ) / 2; i_x-- ; ) + { + C_YUV422_YUYV( p_line, p_y, p_u, p_v ); + } + p_y += i_source_margin; + p_u += i_source_margin_c; + p_v += i_source_margin_c; + p_line += i_dest_margin; + } + } + else { + /* use slower SSE2 unaligned fetch and store */ + for( i_y = p_vout->render.i_height ; i_y-- ; ) + { + for( i_x = p_vout->render.i_width / 16 ; i_x-- ; ) + { + SSE2_CALL( SSE2_YUV422_YUYV_UNALIGNED ); + } + for( i_x = ( p_vout->render.i_width % 16 ) / 2; i_x-- ; ) + { + C_YUV422_YUYV( p_line, p_y, p_u, p_v ); + } + p_y += i_source_margin; + p_u += i_source_margin_c; + p_v += i_source_margin_c; + p_line += i_dest_margin; + } + } + SSE2_END; + +#else + for( i_y = p_vout->render.i_height ; i_y-- ; ) { for( i_x = p_vout->render.i_width / 8 ; i_x-- ; ) @@ -158,14 +211,24 @@ static void I422_YUY2( vout_thread_t *p_vout, picture_t *p_source, C_YUV422_YUYV( p_line, p_y, p_u, p_v ); C_YUV422_YUYV( p_line, p_y, p_u, p_v ); C_YUV422_YUYV( p_line, p_y, p_u, p_v ); -#else - __asm__( ".align 8" MMX_YUV422_YUYV - : : "r" (p_line), "r" (p_y), "r" (p_u), "r" (p_v) ); - - p_line += 16; p_y += 8; p_u += 4; p_v += 4; +#elif defined (MODULE_NAME_IS_i422_yuy2_mmx) + MMX_CALL( MMX_YUV422_YUYV ); #endif } + for( i_x = ( p_vout->render.i_width % 8 ) / 2; i_x-- ; ) + { + C_YUV422_YUYV( p_line, p_y, p_u, p_v ); + } + p_y += i_source_margin; + p_u += i_source_margin_c; + p_v += i_source_margin_c; + p_line += i_dest_margin; } +#if defined (MODULE_NAME_IS_i422_yuy2_mmx) + MMX_END; +#endif + +#endif } /***************************************************************************** @@ -181,6 +244,57 @@ static void I422_YVYU( vout_thread_t *p_vout, picture_t *p_source, int i_x, i_y; + const int i_source_margin = p_source->p[0].i_pitch + - p_source->p[0].i_visible_pitch; + const int i_source_margin_c = p_source->p[1].i_pitch + - p_source->p[1].i_visible_pitch; + const int i_dest_margin = p_dest->p->i_pitch + - p_dest->p->i_visible_pitch; + +#if defined (MODULE_NAME_IS_i422_yuy2_sse2) + + if( 0 == (15 & (p_source->p[Y_PLANE].i_pitch|p_dest->p->i_pitch| + ((intptr_t)p_line|(intptr_t)p_y))) ) + { + /* use faster SSE2 aligned fetch and store */ + for( i_y = p_vout->render.i_height ; i_y-- ; ) + { + for( i_x = p_vout->render.i_width / 16 ; i_x-- ; ) + { + SSE2_CALL( SSE2_YUV422_YVYU_ALIGNED ); + } + for( i_x = ( p_vout->render.i_width % 16 ) / 2; i_x-- ; ) + { + C_YUV422_YVYU( p_line, p_y, p_u, p_v ); + } + p_y += i_source_margin; + p_u += i_source_margin_c; + p_v += i_source_margin_c; + p_line += i_dest_margin; + } + } + else { + /* use slower SSE2 unaligned fetch and store */ + for( i_y = p_vout->render.i_height ; i_y-- ; ) + { + for( i_x = p_vout->render.i_width / 16 ; i_x-- ; ) + { + SSE2_CALL( SSE2_YUV422_YVYU_UNALIGNED ); + } + for( i_x = ( p_vout->render.i_width % 16 ) / 2; i_x-- ; ) + { + C_YUV422_YVYU( p_line, p_y, p_u, p_v ); + } + p_y += i_source_margin; + p_u += i_source_margin_c; + p_v += i_source_margin_c; + p_line += i_dest_margin; + } + } + SSE2_END; + +#else + for( i_y = p_vout->render.i_height ; i_y-- ; ) { for( i_x = p_vout->render.i_width / 8 ; i_x-- ; ) @@ -190,14 +304,24 @@ static void I422_YVYU( vout_thread_t *p_vout, picture_t *p_source, C_YUV422_YVYU( p_line, p_y, p_u, p_v ); C_YUV422_YVYU( p_line, p_y, p_u, p_v ); C_YUV422_YVYU( p_line, p_y, p_u, p_v ); -#else - __asm__( ".align 8" MMX_YUV422_YVYU - : : "r" (p_line), "r" (p_y), "r" (p_u), "r" (p_v) ); - - p_line += 16; p_y += 8; p_u += 4; p_v += 4; +#elif defined (MODULE_NAME_IS_i422_yuy2_mmx) + MMX_CALL( MMX_YUV422_YVYU ); #endif } + for( i_x = ( p_vout->render.i_width % 8 ) / 2; i_x-- ; ) + { + C_YUV422_YVYU( p_line, p_y, p_u, p_v ); + } + p_y += i_source_margin; + p_u += i_source_margin_c; + p_v += i_source_margin_c; + p_line += i_dest_margin; } +#if defined (MODULE_NAME_IS_i422_yuy2_mmx) + MMX_END; +#endif + +#endif } /***************************************************************************** @@ -213,6 +337,57 @@ static void I422_UYVY( vout_thread_t *p_vout, picture_t *p_source, int i_x, i_y; + const int i_source_margin = p_source->p[0].i_pitch + - p_source->p[0].i_visible_pitch; + const int i_source_margin_c = p_source->p[1].i_pitch + - p_source->p[1].i_visible_pitch; + const int i_dest_margin = p_dest->p->i_pitch + - p_dest->p->i_visible_pitch; + +#if defined (MODULE_NAME_IS_i422_yuy2_sse2) + + if( 0 == (15 & (p_source->p[Y_PLANE].i_pitch|p_dest->p->i_pitch| + ((intptr_t)p_line|(intptr_t)p_y))) ) + { + /* use faster SSE2 aligned fetch and store */ + for( i_y = p_vout->render.i_height ; i_y-- ; ) + { + for( i_x = p_vout->render.i_width / 16 ; i_x-- ; ) + { + SSE2_CALL( SSE2_YUV422_UYVY_ALIGNED ); + } + for( i_x = ( p_vout->render.i_width % 16 ) / 2; i_x-- ; ) + { + C_YUV422_UYVY( p_line, p_y, p_u, p_v ); + } + p_y += i_source_margin; + p_u += i_source_margin_c; + p_v += i_source_margin_c; + p_line += i_dest_margin; + } + } + else { + /* use slower SSE2 unaligned fetch and store */ + for( i_y = p_vout->render.i_height ; i_y-- ; ) + { + for( i_x = p_vout->render.i_width / 16 ; i_x-- ; ) + { + SSE2_CALL( SSE2_YUV422_UYVY_UNALIGNED ); + } + for( i_x = ( p_vout->render.i_width % 16 ) / 2; i_x-- ; ) + { + C_YUV422_UYVY( p_line, p_y, p_u, p_v ); + } + p_y += i_source_margin; + p_u += i_source_margin_c; + p_v += i_source_margin_c; + p_line += i_dest_margin; + } + } + SSE2_END; + +#else + for( i_y = p_vout->render.i_height ; i_y-- ; ) { for( i_x = p_vout->render.i_width / 8 ; i_x-- ; ) @@ -222,14 +397,24 @@ static void I422_UYVY( vout_thread_t *p_vout, picture_t *p_source, C_YUV422_UYVY( p_line, p_y, p_u, p_v ); C_YUV422_UYVY( p_line, p_y, p_u, p_v ); C_YUV422_UYVY( p_line, p_y, p_u, p_v ); -#else - __asm__( ".align 8" MMX_YUV422_UYVY - : : "r" (p_line), "r" (p_y), "r" (p_u), "r" (p_v) ); - - p_line += 16; p_y += 8; p_u += 4; p_v += 4; +#elif defined (MODULE_NAME_IS_i422_yuy2_mmx) + MMX_CALL( MMX_YUV422_UYVY ); #endif } + for( i_x = ( p_vout->render.i_width % 8 ) / 2; i_x-- ; ) + { + C_YUV422_UYVY( p_line, p_y, p_u, p_v ); + } + p_y += i_source_margin; + p_u += i_source_margin_c; + p_v += i_source_margin_c; + p_line += i_dest_margin; } +#if defined (MODULE_NAME_IS_i422_yuy2_mmx) + MMX_END; +#endif + +#endif } /***************************************************************************** @@ -238,6 +423,7 @@ static void I422_UYVY( vout_thread_t *p_vout, picture_t *p_source, static void I422_IUYV( vout_thread_t *p_vout, picture_t *p_source, picture_t *p_dest ) { + VLC_UNUSED(p_source); VLC_UNUSED(p_dest); /* FIXME: TODO ! */ msg_Err( p_vout, "I422_IUYV unimplemented, please harass " ); } @@ -255,6 +441,61 @@ static void I422_cyuv( vout_thread_t *p_vout, picture_t *p_source, int i_x, i_y; + const int i_source_margin = p_source->p[0].i_pitch + - p_source->p[0].i_visible_pitch; + const int i_source_margin_c = p_source->p[1].i_pitch + - p_source->p[1].i_visible_pitch; + const int i_dest_margin = p_dest->p->i_pitch + - p_dest->p->i_visible_pitch; + +#if defined (MODULE_NAME_IS_i422_yuy2_sse2) + + if( 0 == (15 & (p_source->p[Y_PLANE].i_pitch|p_dest->p->i_pitch| + ((intptr_t)p_line|(intptr_t)p_y))) ) + { + /* use faster SSE2 aligned fetch and store */ + for( i_y = p_vout->render.i_height ; i_y-- ; ) + { + p_line -= 2 * p_dest->p->i_pitch; + + for( i_x = p_vout->render.i_width / 16 ; i_x-- ; ) + { + SSE2_CALL( SSE2_YUV422_UYVY_ALIGNED ); + } + for( i_x = ( p_vout->render.i_width % 16 ) / 2; i_x-- ; ) + { + C_YUV422_UYVY( p_line, p_y, p_u, p_v ); + } + p_y += i_source_margin; + p_u += i_source_margin_c; + p_v += i_source_margin_c; + p_line += i_dest_margin; + } + } + else { + /* use slower SSE2 unaligned fetch and store */ + for( i_y = p_vout->render.i_height ; i_y-- ; ) + { + p_line -= 2 * p_dest->p->i_pitch; + + for( i_x = p_vout->render.i_width / 16 ; i_x-- ; ) + { + SSE2_CALL( SSE2_YUV422_UYVY_UNALIGNED ); + } + for( i_x = ( p_vout->render.i_width % 16 ) / 2; i_x-- ; ) + { + C_YUV422_UYVY( p_line, p_y, p_u, p_v ); + } + p_y += i_source_margin; + p_u += i_source_margin_c; + p_v += i_source_margin_c; + p_line += i_dest_margin; + } + } + SSE2_END; + +#else + for( i_y = p_vout->render.i_height ; i_y-- ; ) { for( i_x = p_vout->render.i_width / 8 ; i_x-- ; ) @@ -266,14 +507,22 @@ static void I422_cyuv( vout_thread_t *p_vout, picture_t *p_source, C_YUV422_UYVY( p_line, p_y, p_u, p_v ); C_YUV422_UYVY( p_line, p_y, p_u, p_v ); C_YUV422_UYVY( p_line, p_y, p_u, p_v ); -#else - __asm__( ".align 8" MMX_YUV422_UYVY - : : "r" (p_line), "r" (p_y), "r" (p_u), "r" (p_v) ); - - p_line += 16; p_y += 8; p_u += 4; p_v += 4; +#elif defined (MODULE_NAME_IS_i422_yuy2_mmx) + MMX_CALL( MMX_YUV422_UYVY ); #endif } + p_y += i_source_margin; + p_u += i_source_margin_c; + p_v += i_source_margin_c; + p_line += i_dest_margin; } +#if defined (MODULE_NAME_IS_i422_yuy2_mmx) + MMX_END; +#elif defined (MODULE_NAME_IS_i422_yuy2_sse2) + SSE2_END; +#endif + +#endif } /***************************************************************************** @@ -300,36 +549,3 @@ static void I422_Y211( vout_thread_t *p_vout, picture_t *p_source, } } #endif - - -/***************************************************************************** - * I422_YV12: planar YUV 4:2:2 to planar YV12 - *****************************************************************************/ -#if defined (MODULE_NAME_IS_i422_yuy2) -static void I422_YV12( vout_thread_t *p_vout, picture_t *p_source, - picture_t *p_dest ) -{ - uint16_t i_dpy = p_dest->p[Y_PLANE].i_pitch; - uint16_t i_spy = p_source->p[Y_PLANE].i_pitch; - uint16_t i_dpuv = p_dest->p[U_PLANE].i_pitch; - uint16_t i_spuv = p_source->p[U_PLANE].i_pitch; - uint16_t i_width = p_vout->render.i_width; - uint16_t i_y = p_vout->render.i_height; - uint8_t *p_dy = p_dest->Y_PIXELS + (i_y-1)*i_dpy; - uint8_t *p_y = p_source->Y_PIXELS + (i_y-1)*i_spy; - uint8_t *p_du = p_dest->U_PIXELS + (i_y/2-1)*i_dpuv; - uint8_t *p_u = p_source->U_PIXELS + (i_y-1)*i_spuv; - uint8_t *p_dv = p_dest->V_PIXELS + (i_y/2-1)*i_dpuv; - uint8_t *p_v = p_source->V_PIXELS + (i_y-1)*i_spuv; - i_y /= 2; - - for ( ; i_y--; ) - { - memcpy(p_dy, p_y, i_width); p_dy -= i_dpy; p_y -= i_spy; - memcpy(p_dy, p_y, i_width); p_dy -= i_dpy; p_y -= i_spy; - memcpy(p_du, p_u, i_width/2); p_du -= i_dpuv; p_u -= 2*i_spuv; - memcpy(p_dv, p_v, i_width/2); p_dv -= i_dpuv; p_v -= 2*i_spuv; - } - -} -#endif