📄 i420_rgb.c
字号:
/***************************************************************************** * i420_rgb.c : YUV to bitmap RGB conversion module for vlc ***************************************************************************** * Copyright (C) 2000, 2001, 2004, 2008 the VideoLAN team * $Id$ * * Authors: Sam Hocevar <sam@zoy.org> * Damien Fouilleul <damienf@videolan.org> * * 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 * GNU 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. *****************************************************************************//***************************************************************************** * Preamble *****************************************************************************/#ifdef HAVE_CONFIG_H# include "config.h"#endif#include <math.h> /* exp(), pow() */#include <vlc_common.h>#include <vlc_plugin.h>#include <vlc_filter.h>#include <vlc_vout.h>#include "i420_rgb.h"#if defined (MODULE_NAME_IS_i420_rgb)# include "i420_rgb_c.h"#endif/***************************************************************************** * RGB2PIXEL: assemble RGB components to a pixel value, returns a uint32_t *****************************************************************************/#define RGB2PIXEL( p_filter, i_r, i_g, i_b ) \ (((((uint32_t)i_r) >> p_filter->fmt_out.video.i_rrshift) \ << p_filter->fmt_out.video.i_lrshift) \ | ((((uint32_t)i_g) >> p_filter->fmt_out.video.i_rgshift) \ << p_filter->fmt_out.video.i_lgshift) \ | ((((uint32_t)i_b) >> p_filter->fmt_out.video.i_rbshift) \ << p_filter->fmt_out.video.i_lbshift))/***************************************************************************** * Local and extern prototypes. *****************************************************************************/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) set_description( N_( "SSE2 I420,IYUV,YV12 to " "RV15,RV16,RV24,RV32 conversions") ); set_capability( "video filter2", 120 ); add_requirement( SSE2 );#endif set_callbacks( Activate, Deactivate );vlc_module_end();/***************************************************************************** * Activate: allocate a chroma function ***************************************************************************** * This function allocates and initializes a chroma function *****************************************************************************/static int Activate( vlc_object_t *p_this ){ filter_t *p_filter = (filter_t *)p_this;#if defined (MODULE_NAME_IS_i420_rgb) size_t i_tables_size;#endif if( p_filter->fmt_out.video.i_width & 1 || p_filter->fmt_out.video.i_height & 1 ) { 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'): 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) /* 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 && p_filter->fmt_out.video.i_bmask == 0x001f ) ) { /* R5G5B6 pixel format */ msg_Dbg(p_this, "RGB pixel format is R5G5B5"); p_filter->pf_video_filter = I420_R5G5B5_Filter; } else if( ( p_filter->fmt_out.video.i_rmask == 0xf800 && p_filter->fmt_out.video.i_gmask == 0x07e0 && p_filter->fmt_out.video.i_bmask == 0x001f ) ) { /* R5G6B5 pixel format */ msg_Dbg(p_this, "RGB pixel format is R5G6B5"); p_filter->pf_video_filter = I420_R5G6B5_Filter; } 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) /* 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 && p_filter->fmt_out.video.i_bmask == 0x000000ff ) { /* A8R8G8B8 pixel format */ msg_Dbg(p_this, "RGB pixel format is A8R8G8B8"); p_filter->pf_video_filter = I420_A8R8G8B8_Filter; } else if( p_filter->fmt_out.video.i_rmask == 0xff000000 && p_filter->fmt_out.video.i_gmask == 0x00ff0000 && p_filter->fmt_out.video.i_bmask == 0x0000ff00 ) { /* R8G8B8A8 pixel format */ msg_Dbg(p_this, "RGB pixel format is R8G8B8A8"); p_filter->pf_video_filter = I420_R8G8B8A8_Filter; } else if( p_filter->fmt_out.video.i_rmask == 0x0000ff00 && p_filter->fmt_out.video.i_gmask == 0x00ff0000 && p_filter->fmt_out.video.i_bmask == 0xff000000 ) { /* B8G8R8A8 pixel format */ msg_Dbg(p_this, "RGB pixel format is B8G8R8A8"); p_filter->pf_video_filter = I420_B8G8R8A8_Filter; } else if( p_filter->fmt_out.video.i_rmask == 0x000000ff && p_filter->fmt_out.video.i_gmask == 0x0000ff00 && p_filter->fmt_out.video.i_bmask == 0x00ff0000 ) { /* A8B8G8R8 pixel format */ msg_Dbg(p_this, "RGB pixel format is A8B8G8R8"); p_filter->pf_video_filter = I420_A8B8G8R8_Filter; } else return VLC_EGENERIC;#else /* generic C chroma converter */ p_filter->pf_video_filter = I420_RGB32_Filter;#endif break; default: return VLC_EGENERIC; } break; default: return VLC_EGENERIC; } p_filter->p_sys = malloc( sizeof( filter_sys_t ) ); if( p_filter->p_sys == NULL ) { return VLC_EGENERIC; } switch( p_filter->fmt_out.video.i_chroma ) {#if defined (MODULE_NAME_IS_i420_rgb) case VLC_FOURCC('R','G','B','2'): 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'): 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'): p_filter->p_sys->p_buffer = malloc( VOUT_MAX_WIDTH * 4 ); break; default: p_filter->p_sys->p_buffer = NULL; break; } if( p_filter->p_sys->p_buffer == NULL ) { free( p_filter->p_sys ); return VLC_EGENERIC; } 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 ) * sizeof( int ) ); if( p_filter->p_sys->p_offset == NULL ) { free( p_filter->p_sys->p_buffer ); free( p_filter->p_sys ); return VLC_EGENERIC; }#if defined (MODULE_NAME_IS_i420_rgb) switch( p_filter->fmt_out.video.i_chroma ) { case VLC_FOURCC('R','G','B','2'): i_tables_size = sizeof( uint8_t ) * PALETTE_TABLE_SIZE; break; case VLC_FOURCC('R','V','1','5'): case VLC_FOURCC('R','V','1','6'): i_tables_size = sizeof( uint16_t ) * RGB_TABLE_SIZE; break; default: /* RV24, RV32 */ i_tables_size = sizeof( uint32_t ) * RGB_TABLE_SIZE; break; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -