X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fvideo_chroma%2Fi420_rgb.c;h=194403b605311b2154a1171887d41b11fca44cae;hb=de52f56adc16506c59d535e15396f19b5ad42a5e;hp=4b884abb5e1b0b9034ab562b25f56e92a6b72f58;hpb=05492281965ed211badf7e1f4c2220be720d3356;p=vlc diff --git a/modules/video_chroma/i420_rgb.c b/modules/video_chroma/i420_rgb.c index 4b884abb5e..194403b605 100644 --- a/modules/video_chroma/i420_rgb.c +++ b/modules/video_chroma/i420_rgb.c @@ -1,25 +1,25 @@ /***************************************************************************** * i420_rgb.c : YUV to bitmap RGB conversion module for vlc ***************************************************************************** - * Copyright (C) 2000, 2001, 2004, 2008 the VideoLAN team + * Copyright (C) 2000, 2001, 2004, 2008 VLC authors and VideoLAN * $Id$ * * Authors: Sam 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 + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 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 - * GNU General Public License for more details. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. * - * 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/ /***************************************************************************** @@ -35,11 +35,25 @@ #include #include #include -#include +#include #include "i420_rgb.h" -#if defined (MODULE_NAME_IS_i420_rgb) -# include "i420_rgb_c.h" +#ifdef PLAIN +# include "i420_rgb_c.h" +static picture_t *I420_RGB8_Filter( filter_t *, picture_t * ); +static picture_t *I420_RGB16_Filter( filter_t *, picture_t * ); +static picture_t *I420_RGB32_Filter( filter_t *, picture_t * ); + +static void SetGammaTable( int *pi_table, double f_gamma ); +static void SetYUV( filter_t * ); +static void Set8bppPalette( filter_t *, uint8_t * ); +#else +static picture_t *I420_R5G5B5_Filter( filter_t *, picture_t * ); +static picture_t *I420_R5G6B5_Filter( filter_t *, picture_t * ); +static picture_t *I420_A8R8G8B8_Filter( filter_t *, picture_t * ); +static picture_t *I420_R8G8B8A8_Filter( filter_t *, picture_t * ); +static picture_t *I420_B8G8R8A8_Filter( filter_t *, picture_t * ); +static picture_t *I420_A8B8G8R8_Filter( filter_t *, picture_t * ); #endif /***************************************************************************** @@ -54,35 +68,27 @@ << p_filter->fmt_out.video.i_lbshift)) /***************************************************************************** - * Local and extern prototypes. + * Module descriptor. *****************************************************************************/ static int Activate ( vlc_object_t * ); static void Deactivate ( vlc_object_t * ); -#if defined (MODULE_NAME_IS_i420_rgb) -static void SetGammaTable ( int *pi_table, double f_gamma ); -static void SetYUV ( filter_t * ); -static void Set8bppPalette ( filter_t *, uint8_t * ); -#endif - -/***************************************************************************** - * Module descriptor. - *****************************************************************************/ vlc_module_begin () -#if defined (MODULE_NAME_IS_i420_rgb) - set_description( N_("I420,IYUV,YV12 to " - "RGB2,RV15,RV16,RV24,RV32 conversions") ); - set_capability( "video filter2", 80 ) -#elif defined (MODULE_NAME_IS_i420_rgb_mmx) - set_description( N_( "MMX I420,IYUV,YV12 to " - "RV15,RV16,RV24,RV32 conversions") ); - set_capability( "video filter2", 100 ) - add_requirement( MMX ) -#elif defined (MODULE_NAME_IS_i420_rgb_sse2) +#if defined (SSE2) set_description( N_( "SSE2 I420,IYUV,YV12 to " - "RV15,RV16,RV24,RV32 conversions") ); + "RV15,RV16,RV24,RV32 conversions") ) set_capability( "video filter2", 120 ) - add_requirement( SSE2 ) +# define vlc_CPU_capable() vlc_CPU_SSE2() +#elif defined (MMX) + set_description( N_( "MMX I420,IYUV,YV12 to " + "RV15,RV16,RV24,RV32 conversions") ) + set_capability( "video filter2", 100 ) +# define vlc_CPU_capable() vlc_CPU_MMX() +#else + set_description( N_("I420,IYUV,YV12 to " + "RGB2,RV15,RV16,RV24,RV32 conversions") ) + set_capability( "video filter2", 80 ) +# define vlc_CPU_capable() (true) #endif set_callbacks( Activate, Deactivate ) vlc_module_end () @@ -95,31 +101,32 @@ vlc_module_end () static int Activate( vlc_object_t *p_this ) { filter_t *p_filter = (filter_t *)p_this; -#if defined (MODULE_NAME_IS_i420_rgb) +#ifdef PLAIN size_t i_tables_size; #endif + if( !vlc_CPU_capable() ) + return VLC_EGENERIC; if( p_filter->fmt_out.video.i_width & 1 || p_filter->fmt_out.video.i_height & 1 ) { return VLC_EGENERIC; } + if( p_filter->fmt_in.video.orientation != p_filter->fmt_out.video.orientation ) + { + return VLC_EGENERIC; + } + switch( p_filter->fmt_in.video.i_chroma ) { - case VLC_FOURCC('Y','V','1','2'): - case VLC_FOURCC('I','4','2','0'): - case VLC_FOURCC('I','Y','U','V'): + case VLC_CODEC_YV12: + case VLC_CODEC_I420: switch( p_filter->fmt_out.video.i_chroma ) { -#if defined (MODULE_NAME_IS_i420_rgb) - case VLC_FOURCC('R','G','B','2'): - p_filter->pf_video_filter = I420_RGB8_Filter; - break; -#endif - case VLC_FOURCC('R','V','1','5'): - case VLC_FOURCC('R','V','1','6'): -#if ! defined (MODULE_NAME_IS_i420_rgb) +#ifndef PLAIN + case VLC_CODEC_RGB15: + case VLC_CODEC_RGB16: /* If we don't have support for the bitmasks, bail out */ if( ( p_filter->fmt_out.video.i_rmask == 0x7c00 && p_filter->fmt_out.video.i_gmask == 0x03e0 @@ -139,19 +146,8 @@ static int Activate( vlc_object_t *p_this ) } else return VLC_EGENERIC; -#else - // generic C chroma converter */ - p_filter->pf_video_filter = I420_RGB16_Filter; -#endif break; - -#if 0 - /* Hmmm, is there only X11 using 32bits per pixel for RV24 ? */ - case VLC_FOURCC('R','V','2','4'): -#endif - - case VLC_FOURCC('R','V','3','2'): -#if ! defined (MODULE_NAME_IS_i420_rgb) + case VLC_CODEC_RGB32: /* If we don't have support for the bitmasks, bail out */ if( p_filter->fmt_out.video.i_rmask == 0x00ff0000 && p_filter->fmt_out.video.i_gmask == 0x0000ff00 @@ -187,12 +183,19 @@ static int Activate( vlc_object_t *p_this ) } else return VLC_EGENERIC; + break; #else - /* generic C chroma converter */ + case VLC_CODEC_RGB8: + p_filter->pf_video_filter = I420_RGB8_Filter; + break; + case VLC_CODEC_RGB15: + case VLC_CODEC_RGB16: + p_filter->pf_video_filter = I420_RGB16_Filter; + break; + case VLC_CODEC_RGB32: p_filter->pf_video_filter = I420_RGB32_Filter; -#endif break; - +#endif default: return VLC_EGENERIC; } @@ -210,22 +213,19 @@ static int Activate( vlc_object_t *p_this ) switch( p_filter->fmt_out.video.i_chroma ) { -#if defined (MODULE_NAME_IS_i420_rgb) - case VLC_FOURCC('R','G','B','2'): +#ifdef PLAIN + case VLC_CODEC_RGB8: p_filter->p_sys->p_buffer = malloc( VOUT_MAX_WIDTH ); break; #endif - - case VLC_FOURCC('R','V','1','5'): - case VLC_FOURCC('R','V','1','6'): + case VLC_CODEC_RGB15: + case VLC_CODEC_RGB16: p_filter->p_sys->p_buffer = malloc( VOUT_MAX_WIDTH * 2 ); break; - - case VLC_FOURCC('R','V','2','4'): - case VLC_FOURCC('R','V','3','2'): + case VLC_CODEC_RGB24: + case VLC_CODEC_RGB32: p_filter->p_sys->p_buffer = malloc( VOUT_MAX_WIDTH * 4 ); break; - default: p_filter->p_sys->p_buffer = NULL; break; @@ -239,7 +239,7 @@ static int Activate( vlc_object_t *p_this ) p_filter->p_sys->p_offset = malloc( p_filter->fmt_out.video.i_width * ( ( p_filter->fmt_out.video.i_chroma - == VLC_FOURCC('R','G','B','2') ) ? 2 : 1 ) + == VLC_CODEC_RGB8 ) ? 2 : 1 ) * sizeof( int ) ); if( p_filter->p_sys->p_offset == NULL ) { @@ -248,14 +248,14 @@ static int Activate( vlc_object_t *p_this ) return VLC_EGENERIC; } -#if defined (MODULE_NAME_IS_i420_rgb) +#ifdef PLAIN switch( p_filter->fmt_out.video.i_chroma ) { - case VLC_FOURCC('R','G','B','2'): + case VLC_CODEC_RGB8: i_tables_size = sizeof( uint8_t ) * PALETTE_TABLE_SIZE; break; - case VLC_FOURCC('R','V','1','5'): - case VLC_FOURCC('R','V','1','6'): + case VLC_CODEC_RGB15: + case VLC_CODEC_RGB16: i_tables_size = sizeof( uint16_t ) * RGB_TABLE_SIZE; break; default: /* RV24, RV32 */ @@ -287,7 +287,7 @@ static void Deactivate( vlc_object_t *p_this ) { filter_t *p_filter = (filter_t *)p_this; -#if defined (MODULE_NAME_IS_i420_rgb) +#ifdef PLAIN free( p_filter->p_sys->p_base ); #endif free( p_filter->p_sys->p_offset ); @@ -295,20 +295,18 @@ static void Deactivate( vlc_object_t *p_this ) free( p_filter->p_sys ); } -#if defined (MODULE_NAME_IS_i420_rgb) -VIDEO_FILTER_WRAPPER( I420_RGB8 ) -VIDEO_FILTER_WRAPPER( I420_RGB16 ) -VIDEO_FILTER_WRAPPER( I420_RGB32 ) -#else +#ifndef PLAIN VIDEO_FILTER_WRAPPER( I420_R5G5B5 ) VIDEO_FILTER_WRAPPER( I420_R5G6B5 ) VIDEO_FILTER_WRAPPER( I420_A8R8G8B8 ) VIDEO_FILTER_WRAPPER( I420_R8G8B8A8 ) VIDEO_FILTER_WRAPPER( I420_B8G8R8A8 ) VIDEO_FILTER_WRAPPER( I420_A8B8G8R8 ) -#endif +#else +VIDEO_FILTER_WRAPPER( I420_RGB8 ) +VIDEO_FILTER_WRAPPER( I420_RGB16 ) +VIDEO_FILTER_WRAPPER( I420_RGB32 ) -#if defined (MODULE_NAME_IS_i420_rgb) /***************************************************************************** * SetGammaTable: return intensity table transformed by gamma curve. ***************************************************************************** @@ -348,13 +346,13 @@ static void SetYUV( filter_t *p_filter ) /* Color: build red, green and blue tables */ switch( p_filter->fmt_out.video.i_chroma ) { - case VLC_FOURCC('R','G','B','2'): + case VLC_CODEC_RGB8: p_filter->p_sys->p_rgb8 = (uint8_t *)p_filter->p_sys->p_base; Set8bppPalette( p_filter, p_filter->p_sys->p_rgb8 ); break; - case VLC_FOURCC('R','V','1','5'): - case VLC_FOURCC('R','V','1','6'): + case VLC_CODEC_RGB15: + case VLC_CODEC_RGB16: p_filter->p_sys->p_rgb16 = (uint16_t *)p_filter->p_sys->p_base; for( i_index = 0; i_index < RED_MARGIN; i_index++ ) { @@ -379,8 +377,8 @@ static void SetYUV( filter_t *p_filter ) } break; - case VLC_FOURCC('R','V','2','4'): - case VLC_FOURCC('R','V','3','2'): + case VLC_CODEC_RGB24: + case VLC_CODEC_RGB32: p_filter->p_sys->p_rgb32 = (uint32_t *)p_filter->p_sys->p_base; for( i_index = 0; i_index < RED_MARGIN; i_index++ ) { @@ -524,6 +522,4 @@ static void Set8bppPalette( filter_t *p_filter, uint8_t *p_rgb8 ) } } } - #endif -