From 2f4af9df225ddce911dce0c0fb388da4f4c7ac65 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Sat, 16 Mar 2002 23:03:19 +0000 Subject: [PATCH] * ./configure.in: more modules are plugins. * ./src/misc/configuration.c: changed ~/.VideoLan/vlc to ~/.videolan/vlcrc, and a few cosmetic changes (sorry Gildas for the butchery). * ./plugins/chroma/i420_rgb16.c: C version of the I420 to RV15/16 chroma. --- configure | 4 +- configure.in | 28 ++--- include/config.h | 4 + include/defs.h.in | 12 +- include/video.h | 32 +++-- plugins/beos/vout_beos.cpp | 10 +- plugins/chroma/i420_rgb.c | 258 ++++++++++++++++++++++++++++++++++++++- plugins/chroma/i420_rgb.h | 13 +- plugins/chroma/i420_rgb16.c | 44 ++++--- plugins/chroma/i420_ymga.c | 4 +- plugins/chroma/i420_yuy2.c | 8 +- plugins/chroma/i422_yuy2.c | 6 +- plugins/directx/vout_directx.c | 13 +- plugins/dummy/vout_dummy.c | 8 +- plugins/fb/fb.c | 18 +-- plugins/ggi/ggi.c | 12 +- plugins/glide/glide.c | 11 +- plugins/qnx/vout_qnx.c | 18 +-- plugins/sdl/vout_sdl.c | 21 ++-- plugins/x11/xcommon.c | 48 ++++---- src/misc/configuration.c | 122 +++++++++--------- src/video_output/video_output.c | 99 ++++++++++++++- src/video_output/vout_pictures.c | 20 +-- 23 files changed, 586 insertions(+), 227 deletions(-) diff --git a/configure b/configure index 892f640f1d..e7d0592442 100755 --- a/configure +++ b/configure @@ -5454,8 +5454,8 @@ case x"${target_cpu}" in ;; esac -BUILTINS="${BUILTINS} mpeg_es mpeg_ps mpeg_ts file udp http ipv4 memcpy idct idctclassic motion imdct downmix chroma_i420_rgb chroma_i420_yuy2 chroma_i422_yuy2 chroma_i420_ymga mpeg_adec ac3_adec mpeg_vdec" -PLUGINS="${PLUGINS} lpcm_adec ac3_spdif spudec filter_deinterlace filter_invert filter_wall filter_transform filter_distort fx_scope" +BUILTINS="${BUILTINS} idct idctclassic motion imdct downmix chroma_i420_rgb chroma_i420_yuy2 chroma_i422_yuy2 chroma_i420_ymga mpeg_adec ac3_adec mpeg_vdec" +PLUGINS="${PLUGINS} mpeg_es mpeg_ps mpeg_ts file udp http ipv4 memcpy lpcm_adec ac3_spdif spudec filter_deinterlace filter_invert filter_wall filter_transform filter_distort fx_scope" MMX_MODULES="memcpymmx idctmmx motionmmx chroma_i420_rgb_mmx chroma_i420_yuy2_mmx chroma_i422_yuy2_mmx chroma_i420_ymga_mmx" MMXEXT_MODULES="memcpymmxext idctmmxext motionmmxext" diff --git a/configure.in b/configure.in index c3e590f4fc..1ae14a7189 100644 --- a/configure.in +++ b/configure.in @@ -444,8 +444,8 @@ esac dnl dnl default modules dnl -BUILTINS="${BUILTINS} mpeg_es mpeg_ps mpeg_ts file udp http ipv4 memcpy idct idctclassic motion imdct downmix chroma_i420_rgb chroma_i420_yuy2 chroma_i422_yuy2 chroma_i420_ymga mpeg_adec ac3_adec mpeg_vdec" -PLUGINS="${PLUGINS} lpcm_adec ac3_spdif spudec filter_deinterlace filter_invert filter_wall filter_transform filter_distort fx_scope" +BUILTINS="${BUILTINS} idct idctclassic motion imdct downmix chroma_i420_rgb chroma_i420_yuy2 chroma_i422_yuy2 chroma_i420_ymga mpeg_adec ac3_adec mpeg_vdec" +PLUGINS="${PLUGINS} mpeg_es mpeg_ps mpeg_ts file udp http ipv4 memcpy lpcm_adec ac3_spdif spudec filter_deinterlace filter_invert filter_wall filter_transform filter_distort fx_scope" dnl dnl Accelerated modules @@ -810,7 +810,7 @@ AC_ARG_WITH(dvdcss, ;; xno) # don't use libdvdcss at all, build a DVD module that can dlopen() it - BUILTINS="${BUILTINS} dvd" + PLUGINS="${PLUGINS} dvd" DUMMY_LIBDVDCSS=1 SRC_DVD_EXTRA="${SRC_DVD_EXTRA} dummy_dvdcss.c" CFLAGS_DVD="${CFLAGS_DVD} -DGOD_DAMN_DMCA" @@ -838,7 +838,7 @@ AC_ARG_WITH(dvdcss, LIB_DVD="${LIB_DVD} lib/libdvdcss.a ${LIB_LIBDVDCSS}" else # XXX: no check for libdl is done, don't try this at home ! - BUILTINS="${BUILTINS} dvd" + PLUGINS="${PLUGINS} dvd" DUMMY_LIBDVDCSS=1 SRC_DVD_EXTRA="${SRC_DVD_EXTRA} dummy_dvdcss.c" CFLAGS_DVD="${CFLAGS_DVD} -DGOD_DAMN_DMCA" @@ -912,19 +912,19 @@ AC_ARG_ENABLE(vcd, if test x$enable_vcd != xno then AC_EGREP_HEADER(cdrom_msf0,linux/cdrom.h,[ - BUILTINS="${BUILTINS} vcd" + PLUGINS="${PLUGINS} vcd" ]) -fi -if test x$enable_vcd != xno -a "${SYS}" = "bsdi" -then - BUILTINS="${BUILTINS} vcd" -fi + if test "x${SYS}" = "xbsdi" + then + PLUGINS="${PLUGINS} vcd" + fi -if test x$enable_vcd != xno -a "${SYS}" = "darwin" -then - BUILTINS="${BUILTINS} vcd" - LIB_VCD="${LIB_VCD} -framework IOKit" + if test "x${SYS}" = "xdarwin" + then + PLUGINS="${PLUGINS} vcd" + LIB_VCD="${LIB_VCD} -framework IOKit" + fi fi dnl diff --git a/include/config.h b/include/config.h index c8dc180310..bc5bbac41e 100644 --- a/include/config.h +++ b/include/config.h @@ -47,6 +47,10 @@ * outputting an error message (in second) */ #define THREAD_COND_TIMEOUT 5 +/* The configuration file and directory */ +#define CONFIG_DIR ".videolan" +#define CONFIG_FILE "vlcrc" + /***************************************************************************** * Interface configuration *****************************************************************************/ diff --git a/include/defs.h.in b/include/defs.h.in index 2e8637a521..ddb70b9735 100644 --- a/include/defs.h.in +++ b/include/defs.h.in @@ -88,6 +88,12 @@ /* Define if you have the getpagesize function. */ #undef HAVE_GETPAGESIZE +/* Define if you have the getpwuid function. */ +#undef HAVE_GETPWUID + +/* Define if you have the getpwuid_r function. */ +#undef HAVE_GETPWUID_R + /* Define if you have the gettimeofday function. */ #undef HAVE_GETTIMEOFDAY @@ -121,12 +127,6 @@ /* Define if you have the sigrelse function. */ #undef HAVE_SIGRELSE -/* Define if you have the getpwuid_r function. */ -#undef HAVE_GETPWUID_R - -/* Define if you have the getpwuid function. */ -#undef HAVE_GETPWUID - /* Define if you have the stpcpy function. */ #undef HAVE_STPCPY diff --git a/include/video.h b/include/video.h index 6c94b5c542..e4c8590ab7 100644 --- a/include/video.h +++ b/include/video.h @@ -4,7 +4,7 @@ * includes all common video types and constants. ***************************************************************************** * Copyright (C) 1999, 2000 VideoLAN - * $Id: video.h,v 1.45 2002/03/15 04:41:54 sam Exp $ + * $Id: video.h,v 1.46 2002/03/16 23:03:19 sam Exp $ * * Authors: Vincent Seguin * @@ -44,11 +44,6 @@ typedef struct plane_s int i_visible_bytes; /* How many real pixels are there ? */ boolean_t b_hidden; /* Are we allowed to write to the margin ? */ - /* Variables used for RGB planes */ - int i_red_mask; - int i_green_mask; - int i_blue_mask; - } plane_t; /***************************************************************************** @@ -84,6 +79,9 @@ typedef struct picture_s boolean_t b_repeat_first_field; /* RFF bit */ boolean_t b_top_field_first; /* which field is first */ + /* The picture heap we are attached to */ + struct picture_heap_s* p_heap; + /* Private data - the video output plugin might want to put stuff here to * keep track of the picture */ struct picture_sys_s *p_sys; @@ -96,20 +94,31 @@ typedef struct picture_s *****************************************************************************/ typedef struct picture_heap_s { - int i_pictures; /* current heap size */ + int i_pictures; /* current heap size */ /* Picture static properties - those properties are fixed at initialization * and should NOT be modified */ - int i_width; /* picture width */ - int i_height; /* picture height */ - u32 i_chroma; /* picture chroma */ - int i_aspect; /* aspect ratio */ + int i_width; /* picture width */ + int i_height; /* picture height */ + u32 i_chroma; /* picture chroma */ + int i_aspect; /* aspect ratio */ + + /* Variables used for RGB planes */ + int i_rmask, i_rrshift, i_lrshift; + int i_gmask, i_rgshift, i_lgshift; + int i_bmask, i_rbshift, i_lbshift; /* Real pictures */ picture_t* pp_picture[VOUT_MAX_PICTURES]; /* pictures */ } picture_heap_t; +/* RGB2PIXEL: assemble RGB components to a pixel value, returns a u32 */ +#define RGB2PIXEL( p_vout, i_r, i_g, i_b ) \ + (((((u32)i_r) >> p_vout->output.i_rrshift) << p_vout->output.i_lrshift) | \ + ((((u32)i_g) >> p_vout->output.i_rgshift) << p_vout->output.i_lgshift) | \ + ((((u32)i_b) >> p_vout->output.i_rbshift) << p_vout->output.i_lbshift)) + /***************************************************************************** * Flags used to describe the status of a picture *****************************************************************************/ @@ -138,6 +147,7 @@ typedef struct picture_heap_s #define FOURCC_BI_BITFIELDS 0x00000003 /* RGB, for 16, 24, 32bpp */ #define FOURCC_RV15 0x35315652 /* RGB 15bpp, 0x1f, 0x7e0, 0xf800 */ #define FOURCC_RV16 0x36315652 /* RGB 16bpp, 0x1f, 0x3e0, 0x7c00 */ +#define FOURCC_RV24 0x34325652 /* RGB 24bpp, 0xff, 0xff00, 0xff0000 */ #define FOURCC_RV32 0x32335652 /* RGB 32bpp, 0xff, 0xff00, 0xff0000 */ /* Planar YUV formats */ diff --git a/plugins/beos/vout_beos.cpp b/plugins/beos/vout_beos.cpp index 2993785ccc..fc2a09abb3 100644 --- a/plugins/beos/vout_beos.cpp +++ b/plugins/beos/vout_beos.cpp @@ -2,7 +2,7 @@ * vout_beos.cpp: beos video output display method ***************************************************************************** * Copyright (C) 2000, 2001 VideoLAN - * $Id: vout_beos.cpp,v 1.44 2002/03/13 08:39:39 tcastley Exp $ + * $Id: vout_beos.cpp,v 1.45 2002/03/16 23:03:19 sam Exp $ * * Authors: Jean-Marc Dressler * Samuel Hocevar @@ -485,6 +485,10 @@ int vout_Init( vout_thread_t *p_vout ) * VOUT_ASPECT_FACTOR / p_vout->p_sys->i_height; p_vout->output.i_chroma = FOURCC_RV32; + p_vout->output.i_rmask = 0x00ff0000; + p_vout->output.i_gmask = 0x0000ff00; + p_vout->output.i_bmask = 0x000000ff; + p_pic = NULL; /* Find an empty picture slot */ @@ -509,10 +513,6 @@ int vout_Init( vout_thread_t *p_vout ) p_pic->p->b_margin = 0; p_pic->p->i_pitch = 4 * p_vout->p_sys->i_width; - p_pic->p->i_red_mask = 0x00ff0000; - p_pic->p->i_green_mask = 0x0000ff00; - p_pic->p->i_blue_mask = 0x000000ff; - p_pic->i_planes = 1; p_pic->i_status = DESTROYED_PICTURE; diff --git a/plugins/chroma/i420_rgb.c b/plugins/chroma/i420_rgb.c index a30fd5c015..22748244a6 100644 --- a/plugins/chroma/i420_rgb.c +++ b/plugins/chroma/i420_rgb.c @@ -2,7 +2,7 @@ * i420_rgb.c : YUV to bitmap RGB conversion module for vlc ***************************************************************************** * Copyright (C) 2000, 2001 VideoLAN - * $Id: i420_rgb.c,v 1.5 2002/02/15 13:32:53 sam Exp $ + * $Id: i420_rgb.c,v 1.6 2002/03/16 23:03:19 sam Exp $ * * Authors: Samuel Hocevar * @@ -35,6 +35,9 @@ #include "video_output.h" #include "i420_rgb.h" +#if defined (MODULE_NAME_IS_chroma_i420_rgb) +# include "i420_rgb_c.h" +#endif /***************************************************************************** * Local and extern prototypes. @@ -44,6 +47,11 @@ static void chroma_getfunctions ( function_list_t * p_function_list ); static int chroma_Init ( vout_thread_t *p_vout ); static void chroma_End ( vout_thread_t *p_vout ); +#if defined (MODULE_NAME_IS_chroma_i420_rgb) +static void SetGammaTable ( int *pi_table, double f_gamma ); +static void SetYUV ( vout_thread_t *p_vout ); +#endif + /***************************************************************************** * Build configuration tree. *****************************************************************************/ @@ -52,10 +60,10 @@ MODULE_CONFIG_STOP MODULE_INIT_START #if defined (MODULE_NAME_IS_chroma_i420_rgb) - SET_DESCRIPTION( "I420/IYUV/YV12 to RGB 8/15/16/24/32 conversions" ) + SET_DESCRIPTION( "I420,IYUV,YV12 to RGB,RV15,RV16,RV24,RV32 conversions" ) ADD_CAPABILITY( CHROMA, 80 ) #elif defined (MODULE_NAME_IS_chroma_i420_rgb_mmx) - SET_DESCRIPTION( "MMX I420/IYUV/YV12 to RGB 15/16/24/32 conversions" ) + SET_DESCRIPTION( "MMX I420,IYUV,YV12 to RV15,RV16,RV24,RV32 conversions" ) ADD_CAPABILITY( CHROMA, 100 ) ADD_REQUIREMENT( MMX ) #endif @@ -85,6 +93,10 @@ static void chroma_getfunctions( function_list_t * p_function_list ) *****************************************************************************/ static int chroma_Init( vout_thread_t *p_vout ) { +#if defined (MODULE_NAME_IS_chroma_i420_rgb) + size_t i_tables_size; +#endif + if( p_vout->render.i_width & 1 || p_vout->render.i_height & 1 ) { return -1; @@ -98,7 +110,7 @@ static int chroma_Init( vout_thread_t *p_vout ) switch( p_vout->output.i_chroma ) { #if defined (MODULE_NAME_IS_chroma_i420_rgb) - case FOURCC_BI_RGB: + case FOURCC_RGB: p_vout->chroma.pf_convert = _M( I420_RGB8 ); break; #endif @@ -132,7 +144,7 @@ static int chroma_Init( vout_thread_t *p_vout ) switch( p_vout->output.i_chroma ) { #if defined (MODULE_NAME_IS_chroma_i420_rgb) - case FOURCC_BI_RGB: + case FOURCC_RGB: p_vout->chroma.p_sys->p_buffer = malloc( VOUT_MAX_WIDTH ); break; #endif @@ -166,6 +178,33 @@ static int chroma_Init( vout_thread_t *p_vout ) return -1; } +#if defined (MODULE_NAME_IS_chroma_i420_rgb) + switch( p_vout->output.i_chroma ) + { + case FOURCC_RGB: + i_tables_size = sizeof( u8 ) * PALETTE_TABLE_SIZE; + break; + case FOURCC_RV15: + case FOURCC_RV16: + i_tables_size = sizeof( u16 ) * RGB_TABLE_SIZE; + break; + default: /* RV24, RV32 */ + i_tables_size = sizeof( u32 ) * RGB_TABLE_SIZE; + break; + } + + p_vout->chroma.p_sys->p_base = malloc( i_tables_size ); + if( p_vout->chroma.p_sys->p_base == NULL ) + { + free( p_vout->chroma.p_sys->p_offset ); + free( p_vout->chroma.p_sys->p_buffer ); + free( p_vout->chroma.p_sys ); + return -1; + } + + SetYUV( p_vout ); +#endif + return 0; } @@ -176,8 +215,217 @@ static int chroma_Init( vout_thread_t *p_vout ) *****************************************************************************/ static void chroma_End( vout_thread_t *p_vout ) { +#if defined (MODULE_NAME_IS_chroma_i420_rgb) + free( p_vout->chroma.p_sys->p_base ); +#endif free( p_vout->chroma.p_sys->p_offset ); free( p_vout->chroma.p_sys->p_buffer ); free( p_vout->chroma.p_sys ); } +#if defined (MODULE_NAME_IS_chroma_i420_rgb) +/***************************************************************************** + * SetGammaTable: return intensity table transformed by gamma curve. + ***************************************************************************** + * pi_table is a table of 256 entries from 0 to 255. + *****************************************************************************/ +static void SetGammaTable( int *pi_table, double f_gamma ) +{ + int i_y; /* base intensity */ + + /* Use exp(gamma) instead of gamma */ + f_gamma = exp( f_gamma ); + + /* Build gamma table */ + for( i_y = 0; i_y < 256; i_y++ ) + { + pi_table[ i_y ] = pow( (double)i_y / 256, f_gamma ) * 256; + } +} + +/***************************************************************************** + * SetYUV: compute tables and set function pointers + *****************************************************************************/ +static void SetYUV( vout_thread_t *p_vout ) +{ + int pi_gamma[256]; /* gamma table */ + int i_index; /* index in tables */ + + /* Build gamma table */ + SetGammaTable( pi_gamma, p_vout->f_gamma ); + + /* + * Set pointers and build YUV tables + */ + /* Color: build red, green and blue tables */ + switch( p_vout->output.i_chroma ) + { + case FOURCC_RGB: + { + #define RGB_MIN 0 + #define RGB_MAX 255 + #define CLIP( x ) ( ((x < 0) ? 0 : (x > 255) ? 255 : x) << 8 ) + + int y,u,v; + int r,g,b; + int uvr, uvg, uvb; + int i = 0, j = 0; + u16 red[256], green[256], blue[256], transp[256]; + unsigned char lookup[PALETTE_TABLE_SIZE]; + + p_vout->chroma.p_sys->yuv.p_rgb8 = (u8 *)p_vout->chroma.p_sys->p_base; + + /* this loop calculates the intersection of an YUV box + * and the RGB cube. */ + for ( y = 0; y <= 256; y += 16 ) + { + for ( u = 0; u <= 256; u += 32 ) + for ( v = 0; v <= 256; v += 32 ) + { + uvr = (V_RED_COEF*(v-128)) >> SHIFT; + uvg = (U_GREEN_COEF*(u-128) + V_GREEN_COEF*(v-128)) >> SHIFT; + uvb = (U_BLUE_COEF*(u-128)) >> SHIFT; + r = y + uvr; + g = y + uvg; + b = y + uvb; + + if( r >= RGB_MIN && g >= RGB_MIN && b >= RGB_MIN + && r <= RGB_MAX && g <= RGB_MAX && b <= RGB_MAX ) + { + /* this one should never happen unless someone fscked up my code */ + if(j == 256) { intf_ErrMsg( "vout error: no colors left to build palette" ); break; } + + /* clip the colors */ + red[j] = CLIP( r ); + green[j] = CLIP( g ); + blue[j] = CLIP( b ); + transp[j] = 0; + + /* allocate color */ + lookup[i] = 1; + p_vout->chroma.p_sys->yuv.p_rgb8[i++] = j; + j++; + } + else + { + lookup[i] = 0; + p_vout->chroma.p_sys->yuv.p_rgb8[i++] = 0; + } + } + i += 128-81; + } + + /* the colors have been allocated, we can set the palette */ + /* there will eventually be a way to know which colors + * couldn't be allocated and try to find a replacement */ +#if 0 + p_vout->pf_setpalette( p_vout, red, green, blue, transp ); + + p_vout->i_white_pixel = 0xff; + p_vout->i_black_pixel = 0x00; + p_vout->i_gray_pixel = 0x44; + p_vout->i_blue_pixel = 0x3b; +#endif + + i = 0; + /* this loop allocates colors that got outside + * the RGB cube */ + for ( y = 0; y <= 256; y += 16 ) + { + for ( u = 0; u <= 256; u += 32 ) + for ( v = 0; v <= 256; v += 32 ) + { + int u2, v2; + int dist, mindist = 100000000; + + if( lookup[i] || y==0) + { + i++; + continue; + } + + /* heavy. yeah. */ + for( u2 = 0; u2 <= 256; u2 += 32 ) + for( v2 = 0; v2 <= 256; v2 += 32 ) + { + j = ((y>>4)<<7) + (u2>>5)*9 + (v2>>5); + dist = (u-u2)*(u-u2) + (v-v2)*(v-v2); + if( lookup[j] ) + /* find the nearest color */ + if( dist < mindist ) + { + p_vout->chroma.p_sys->yuv.p_rgb8[i] = p_vout->chroma.p_sys->yuv.p_rgb8[j]; + mindist = dist; + } + j -= 128; + if( lookup[j] ) + /* find the nearest color */ + if( dist + 128 < mindist ) + { + p_vout->chroma.p_sys->yuv.p_rgb8[i] = p_vout->chroma.p_sys->yuv.p_rgb8[j]; + mindist = dist + 128; + } + } + i++; + } + i += 128-81; + } + + } + break; + + case FOURCC_RV15: + case FOURCC_RV16: + p_vout->chroma.p_sys->yuv.p_rgb16 = (u16 *)p_vout->chroma.p_sys->p_base; + for( i_index = 0; i_index < RED_MARGIN; i_index++ ) + { + p_vout->chroma.p_sys->yuv.p_rgb16[RED_OFFSET - RED_MARGIN + i_index] = RGB2PIXEL( p_vout, pi_gamma[0], 0, 0 ); + p_vout->chroma.p_sys->yuv.p_rgb16[RED_OFFSET + 256 + i_index] = RGB2PIXEL( p_vout, pi_gamma[255], 0, 0 ); + } + for( i_index = 0; i_index < GREEN_MARGIN; i_index++ ) + { + p_vout->chroma.p_sys->yuv.p_rgb16[GREEN_OFFSET - GREEN_MARGIN + i_index] = RGB2PIXEL( p_vout, 0, pi_gamma[0], 0 ); + p_vout->chroma.p_sys->yuv.p_rgb16[GREEN_OFFSET + 256 + i_index] = RGB2PIXEL( p_vout, 0, pi_gamma[255], 0 ); + } + for( i_index = 0; i_index < BLUE_MARGIN; i_index++ ) + { + p_vout->chroma.p_sys->yuv.p_rgb16[BLUE_OFFSET - BLUE_MARGIN + i_index] = RGB2PIXEL( p_vout, 0, 0, pi_gamma[0] ); + p_vout->chroma.p_sys->yuv.p_rgb16[BLUE_OFFSET + BLUE_MARGIN + i_index] = RGB2PIXEL( p_vout, 0, 0, pi_gamma[255] ); + } + for( i_index = 0; i_index < 256; i_index++ ) + { + p_vout->chroma.p_sys->yuv.p_rgb16[RED_OFFSET + i_index] = RGB2PIXEL( p_vout, pi_gamma[ i_index ], 0, 0 ); + p_vout->chroma.p_sys->yuv.p_rgb16[GREEN_OFFSET + i_index] = RGB2PIXEL( p_vout, 0, pi_gamma[ i_index ], 0 ); + p_vout->chroma.p_sys->yuv.p_rgb16[BLUE_OFFSET + i_index] = RGB2PIXEL( p_vout, 0, 0, pi_gamma[ i_index ] ); + } + break; + + case FOURCC_RV24: + case FOURCC_RV32: + p_vout->chroma.p_sys->yuv.p_rgb32 = (u32 *)p_vout->chroma.p_sys->p_base; + for( i_index = 0; i_index < RED_MARGIN; i_index++ ) + { + p_vout->chroma.p_sys->yuv.p_rgb32[RED_OFFSET - RED_MARGIN + i_index] = RGB2PIXEL( p_vout, pi_gamma[0], 0, 0 ); + p_vout->chroma.p_sys->yuv.p_rgb32[RED_OFFSET + 256 + i_index] = RGB2PIXEL( p_vout, pi_gamma[255], 0, 0 ); + } + for( i_index = 0; i_index < GREEN_MARGIN; i_index++ ) + { + p_vout->chroma.p_sys->yuv.p_rgb32[GREEN_OFFSET - GREEN_MARGIN + i_index] = RGB2PIXEL( p_vout, 0, pi_gamma[0], 0 ); + p_vout->chroma.p_sys->yuv.p_rgb32[GREEN_OFFSET + 256 + i_index] = RGB2PIXEL( p_vout, 0, pi_gamma[255], 0 ); + } + for( i_index = 0; i_index < BLUE_MARGIN; i_index++ ) + { + p_vout->chroma.p_sys->yuv.p_rgb32[BLUE_OFFSET - BLUE_MARGIN + i_index] = RGB2PIXEL( p_vout, 0, 0, pi_gamma[0] ); + p_vout->chroma.p_sys->yuv.p_rgb32[BLUE_OFFSET + BLUE_MARGIN + i_index] = RGB2PIXEL( p_vout, 0, 0, pi_gamma[255] ); + } + for( i_index = 0; i_index < 256; i_index++ ) + { + p_vout->chroma.p_sys->yuv.p_rgb32[RED_OFFSET + i_index] = RGB2PIXEL( p_vout, pi_gamma[ i_index ], 0, 0 ); + p_vout->chroma.p_sys->yuv.p_rgb32[GREEN_OFFSET + i_index] = RGB2PIXEL( p_vout, 0, pi_gamma[ i_index ], 0 ); + p_vout->chroma.p_sys->yuv.p_rgb32[BLUE_OFFSET + i_index] = RGB2PIXEL( p_vout, 0, 0, pi_gamma[ i_index ] ); + } + break; + } +} +#endif + diff --git a/plugins/chroma/i420_rgb.h b/plugins/chroma/i420_rgb.h index 4014b09ba9..7871ef9d9b 100644 --- a/plugins/chroma/i420_rgb.h +++ b/plugins/chroma/i420_rgb.h @@ -2,7 +2,7 @@ * i420_rgb.h : YUV to bitmap RGB conversion module for vlc ***************************************************************************** * Copyright (C) 2000 VideoLAN - * $Id: i420_rgb.h,v 1.3 2002/01/28 16:51:22 sam Exp $ + * $Id: i420_rgb.h,v 1.4 2002/03/16 23:03:19 sam Exp $ * * Authors: Samuel Hocevar * @@ -32,6 +32,17 @@ typedef struct chroma_sys_s u8 *p_buffer; int *p_offset; +#ifdef MODULE_NAME_IS_chroma_i420_rgb + /* Pre-calculated conversion tables */ + void * p_base; /* base for all conversion tables */ + union + { + u8 * p_rgb8; /* RGB 8 bits table */ + u16 * p_rgb16; /* RGB 16 bits table */ + u32 * p_rgb32; /* RGB 32 bits table */ + } yuv; +#endif + } chroma_sys_t; /***************************************************************************** diff --git a/plugins/chroma/i420_rgb16.c b/plugins/chroma/i420_rgb16.c index ab594aa869..afdc74c7c0 100644 --- a/plugins/chroma/i420_rgb16.c +++ b/plugins/chroma/i420_rgb16.c @@ -2,7 +2,7 @@ * i420_rgb16.c : YUV to bitmap RGB conversion module for vlc ***************************************************************************** * Copyright (C) 2000 VideoLAN - * $Id: i420_rgb16.c,v 1.3 2002/01/28 16:51:22 sam Exp $ + * $Id: i420_rgb16.c,v 1.4 2002/03/16 23:03:19 sam Exp $ * * Authors: Samuel Hocevar * @@ -70,6 +70,12 @@ void _M( I420_RGB15 )( vout_thread_t *p_vout, picture_t *p_src, int i_scale_count; /* scale modulo counter */ int i_chroma_width = p_vout->render.i_width / 2; /* chroma width */ u16 * p_pic_start; /* beginning of the current line for copy */ +#if defined (MODULE_NAME_IS_chroma_i420_rgb) + int i_uval, i_vval; /* U and V samples */ + int i_red, i_green, i_blue; /* U and V modified samples */ + u16 * p_yuv = p_vout->chroma.p_sys->yuv.p_rgb16; + u16 * p_ybase; /* Y dependant conversion table */ +#endif /* Conversion buffer pointer */ u16 * p_buffer_start = (u16*)p_vout->chroma.p_sys->p_buffer; @@ -104,11 +110,6 @@ void _M( I420_RGB15 )( vout_thread_t *p_vout, picture_t *p_src, p_vout->output.i_width, p_vout->output.i_height, &b_hscale, &i_vscale, p_offset_start ); -#if defined (MODULE_NAME_IS_chroma_i420_rgb) - intf_ErrMsg( "vout error: I420_RGB16 unimplemented, " - "please harass sam@zoy.org" ); -#endif - /* * Perform conversion */ @@ -122,7 +123,10 @@ void _M( I420_RGB15 )( vout_thread_t *p_vout, picture_t *p_src, for ( i_x = p_vout->render.i_width / 8; i_x--; ) { #if defined (MODULE_NAME_IS_chroma_i420_rgb) - /* FIXME: TODO */ + CONVERT_YUV_PIXEL(2); CONVERT_Y_PIXEL(2); + CONVERT_YUV_PIXEL(2); CONVERT_Y_PIXEL(2); + CONVERT_YUV_PIXEL(2); CONVERT_Y_PIXEL(2); + CONVERT_YUV_PIXEL(2); CONVERT_Y_PIXEL(2); #elif defined (MODULE_NAME_IS_chroma_i420_rgb_mmx) __asm__( MMX_INIT_16 : : "r" (p_y), "r" (p_u), "r" (p_v), "r" (p_buffer) ); @@ -149,7 +153,10 @@ void _M( I420_RGB15 )( vout_thread_t *p_vout, picture_t *p_src, p_v -= i_rewind >> 1; p_buffer -= i_rewind; #if defined (MODULE_NAME_IS_chroma_i420_rgb) - /* FIXME: TODO */ + CONVERT_YUV_PIXEL(2); CONVERT_Y_PIXEL(2); + CONVERT_YUV_PIXEL(2); CONVERT_Y_PIXEL(2); + CONVERT_YUV_PIXEL(2); CONVERT_Y_PIXEL(2); + CONVERT_YUV_PIXEL(2); CONVERT_Y_PIXEL(2); #elif defined (MODULE_NAME_IS_chroma_i420_rgb_mmx) __asm__( MMX_INIT_16 : : "r" (p_y), "r" (p_u), "r" (p_v), "r" (p_buffer) ); @@ -198,6 +205,12 @@ void _M( I420_RGB16 )( vout_thread_t *p_vout, picture_t *p_src, int i_scale_count; /* scale modulo counter */ int i_chroma_width = p_vout->render.i_width / 2; /* chroma width */ u16 * p_pic_start; /* beginning of the current line for copy */ +#if defined (MODULE_NAME_IS_chroma_i420_rgb) + int i_uval, i_vval; /* U and V samples */ + int i_red, i_green, i_blue; /* U and V modified samples */ + u16 * p_yuv = p_vout->chroma.p_sys->yuv.p_rgb16; + u16 * p_ybase; /* Y dependant conversion table */ +#endif /* Conversion buffer pointer */ u16 * p_buffer_start = (u16*)p_vout->chroma.p_sys->p_buffer; @@ -232,11 +245,6 @@ void _M( I420_RGB16 )( vout_thread_t *p_vout, picture_t *p_src, p_vout->output.i_width, p_vout->output.i_height, &b_hscale, &i_vscale, p_offset_start ); -#if defined (MODULE_NAME_IS_chroma_i420_rgb) - intf_ErrMsg( "vout error: I420_RGB16 unimplemented, " - "please harass sam@zoy.org" ); -#endif - /* * Perform conversion */ @@ -250,7 +258,10 @@ void _M( I420_RGB16 )( vout_thread_t *p_vout, picture_t *p_src, for ( i_x = p_vout->render.i_width / 8; i_x--; ) { #if defined (MODULE_NAME_IS_chroma_i420_rgb) - /* FIXME: TODO */ + CONVERT_YUV_PIXEL(2); CONVERT_Y_PIXEL(2); + CONVERT_YUV_PIXEL(2); CONVERT_Y_PIXEL(2); + CONVERT_YUV_PIXEL(2); CONVERT_Y_PIXEL(2); + CONVERT_YUV_PIXEL(2); CONVERT_Y_PIXEL(2); #elif defined (MODULE_NAME_IS_chroma_i420_rgb_mmx) __asm__( MMX_INIT_16 : : "r" (p_y), "r" (p_u), "r" (p_v), "r" (p_buffer) ); @@ -277,7 +288,10 @@ void _M( I420_RGB16 )( vout_thread_t *p_vout, picture_t *p_src, p_v -= i_rewind >> 1; p_buffer -= i_rewind; #if defined (MODULE_NAME_IS_chroma_i420_rgb) - /* FIXME: TODO */ + CONVERT_YUV_PIXEL(2); CONVERT_Y_PIXEL(2); + CONVERT_YUV_PIXEL(2); CONVERT_Y_PIXEL(2); + CONVERT_YUV_PIXEL(2); CONVERT_Y_PIXEL(2); + CONVERT_YUV_PIXEL(2); CONVERT_Y_PIXEL(2); #elif defined (MODULE_NAME_IS_chroma_i420_rgb_mmx) __asm__( MMX_INIT_16 : : "r" (p_y), "r" (p_u), "r" (p_v), "r" (p_buffer) ); diff --git a/plugins/chroma/i420_ymga.c b/plugins/chroma/i420_ymga.c index 5b938f1ee2..423e17857b 100644 --- a/plugins/chroma/i420_ymga.c +++ b/plugins/chroma/i420_ymga.c @@ -2,7 +2,7 @@ * i420_ymga.c : YUV to YUV conversion module for vlc ***************************************************************************** * Copyright (C) 2000, 2001 VideoLAN - * $Id: i420_ymga.c,v 1.2 2002/02/15 13:32:53 sam Exp $ + * $Id: i420_ymga.c,v 1.3 2002/03/16 23:03:19 sam Exp $ * * Authors: Samuel Hocevar * @@ -34,7 +34,7 @@ #include "video.h" #include "video_output.h" -#define SRC_FOURCC "I420/IYUV/YV12" +#define SRC_FOURCC "I420,IYUV,YV12" #define DEST_FOURCC "YMGA" /***************************************************************************** diff --git a/plugins/chroma/i420_yuy2.c b/plugins/chroma/i420_yuy2.c index db7c3bcadd..38ce9f8d8a 100644 --- a/plugins/chroma/i420_yuy2.c +++ b/plugins/chroma/i420_yuy2.c @@ -2,7 +2,7 @@ * i420_yuy2.c : YUV to YUV conversion module for vlc ***************************************************************************** * Copyright (C) 2000, 2001 VideoLAN - * $Id: i420_yuy2.c,v 1.2 2002/02/15 13:32:53 sam Exp $ + * $Id: i420_yuy2.c,v 1.3 2002/03/16 23:03:19 sam Exp $ * * Authors: Samuel Hocevar * @@ -36,12 +36,12 @@ #include "i420_yuy2.h" -#define SRC_FOURCC "I420/IYUV/YV12" +#define SRC_FOURCC "I420,IYUV,YV12" #if defined (MODULE_NAME_IS_chroma_i420_yuy2) -# define DEST_FOURCC "YUY2/YUNV/YVYU/UYVY/UYNV/Y422/IUYV/cyuv/Y211" +# define DEST_FOURCC "YUY2,YUNV,YVYU,UYVY,UYNV,Y422,IUYV,cyuv,Y211" #else -# define DEST_FOURCC "YUY2/YUNV/YVYU/UYVY/UYNV/Y422/IUYV/cyuv" +# define DEST_FOURCC "YUY2,YUNV,YVYU,UYVY,UYNV,Y422,IUYV,cyuv" #endif /***************************************************************************** diff --git a/plugins/chroma/i422_yuy2.c b/plugins/chroma/i422_yuy2.c index dd44d00aa3..9f84497870 100644 --- a/plugins/chroma/i422_yuy2.c +++ b/plugins/chroma/i422_yuy2.c @@ -2,7 +2,7 @@ * i422_yuy2.c : YUV to YUV conversion module for vlc ***************************************************************************** * Copyright (C) 2000, 2001 VideoLAN - * $Id: i422_yuy2.c,v 1.2 2002/02/15 13:32:53 sam Exp $ + * $Id: i422_yuy2.c,v 1.3 2002/03/16 23:03:19 sam Exp $ * * Authors: Samuel Hocevar * @@ -38,9 +38,9 @@ #define SRC_FOURCC "I422" #if defined (MODULE_NAME_IS_chroma_i422_yuy2) -# define DEST_FOURCC "YUY2/YUNV/YVYU/UYVY/UYNV/Y422/IUYV/cyuv/Y211" +# define DEST_FOURCC "YUY2,YUNV,YVYU,UYVY,UYNV,Y422,IUYV,cyuv,Y211" #else -# define DEST_FOURCC "YUY2/YUNV/YVYU/UYVY/UYNV/Y422/IUYV/cyuv" +# define DEST_FOURCC "YUY2,YUNV,YVYU,UYVY,UYNV,Y422,IUYV,cyuv" #endif /***************************************************************************** diff --git a/plugins/directx/vout_directx.c b/plugins/directx/vout_directx.c index c4a65b65b6..bd1dcec11e 100644 --- a/plugins/directx/vout_directx.c +++ b/plugins/directx/vout_directx.c @@ -2,7 +2,7 @@ * vout_directx.c: Windows DirectX video output display method ***************************************************************************** * Copyright (C) 2001 VideoLAN - * $Id: vout_directx.c,v 1.24 2002/03/11 07:23:09 gbazin Exp $ + * $Id: vout_directx.c,v 1.25 2002/03/16 23:03:19 sam Exp $ * * Authors: Gildas Bazin * @@ -1045,6 +1045,9 @@ static int NewPictureVec( vout_thread_t *p_vout, picture_t *p_pic, { /* FixMe */ p_vout->output.i_chroma = FOURCC_RV16; + p_vout->output.i_rmask = 0x001f; + p_vout->output.i_gmask = 0x03e0; + p_vout->output.i_bmask = 0x7c00; for( i = 0; i < i_num_pics; i++ ) { @@ -1176,10 +1179,6 @@ static int UpdatePictureStruct( vout_thread_t *p_vout, picture_t *p_pic, p_pic->p->i_pixel_bytes = 2; p_pic->p->b_margin = 0; - p_pic->p->i_red_mask = 0x001f; - p_pic->p->i_green_mask = 0x03e0; - p_pic->p->i_blue_mask = 0x7c00; - p_pic->i_planes = 1; break; @@ -1191,10 +1190,6 @@ static int UpdatePictureStruct( vout_thread_t *p_vout, picture_t *p_pic, p_pic->p->i_pixel_bytes = 2; p_pic->p->b_margin = 0; - p_pic->p->i_red_mask = 0x001f; - p_pic->p->i_green_mask = 0x07e0; - p_pic->p->i_blue_mask = 0xf800; - p_pic->i_planes = 1; break; diff --git a/plugins/dummy/vout_dummy.c b/plugins/dummy/vout_dummy.c index 803bf85829..de264a0af2 100644 --- a/plugins/dummy/vout_dummy.c +++ b/plugins/dummy/vout_dummy.c @@ -2,7 +2,7 @@ * vout_dummy.c: Dummy video output display method for testing purposes ***************************************************************************** * Copyright (C) 2000, 2001 VideoLAN - * $Id: vout_dummy.c,v 1.18 2002/02/15 13:32:53 sam Exp $ + * $Id: vout_dummy.c,v 1.19 2002/03/16 23:03:19 sam Exp $ * * Authors: Samuel Hocevar * @@ -119,6 +119,9 @@ static int vout_Init( vout_thread_t *p_vout ) default: p_vout->output.i_chroma = FOURCC_RV16; + p_vout->output.i_rmask = 0xf800; + p_vout->output.i_gmask = 0x07e0; + p_vout->output.i_bmask = 0x001f; p_vout->output.i_width = p_vout->render.i_width; p_vout->output.i_height = p_vout->render.i_height; p_vout->output.i_aspect = p_vout->render.i_aspect; @@ -270,9 +273,6 @@ static int DummyNewPicture( vout_thread_t *p_vout, picture_t *p_pic ) p_pic->p->i_pitch = i_width; p_pic->p->i_pixel_bytes = 2; p_pic->p->b_margin = 0; - p_pic->p->i_red_mask = 0xf800; - p_pic->p->i_green_mask = 0x07e0; - p_pic->p->i_blue_mask = 0x001f; /* We allocated 1 plane */ p_pic->i_planes = 1; diff --git a/plugins/fb/fb.c b/plugins/fb/fb.c index 14bb58817d..28b7a98bf9 100644 --- a/plugins/fb/fb.c +++ b/plugins/fb/fb.c @@ -2,7 +2,7 @@ * fb.c : framebuffer plugin for vlc ***************************************************************************** * Copyright (C) 2000, 2001 VideoLAN - * $Id: fb.c,v 1.14 2002/02/24 20:51:09 gbazin Exp $ + * $Id: fb.c,v 1.15 2002/03/16 23:03:19 sam Exp $ * * Authors: Samuel Hocevar * @@ -275,6 +275,14 @@ static int vout_Init( vout_thread_t *p_vout ) return 0; } + /* Only useful for p_vout->p_sys->var_info.bits_per_pixel != 8 */ + p_vout->output.i_rmask = ( (1 << p_vout->p_sys->var_info.red.length) - 1 ) + << p_vout->p_sys->var_info.red.offset; + p_vout->output.i_gmask = ( (1 << p_vout->p_sys->var_info.green.length) - 1 ) + << p_vout->p_sys->var_info.green.offset; + p_vout->output.i_bmask = ( (1 << p_vout->p_sys->var_info.blue.length) - 1 ) + << p_vout->p_sys->var_info.blue.offset; + p_vout->output.i_width = p_vout->p_sys->i_width; p_vout->output.i_height = p_vout->p_sys->i_height; @@ -326,14 +334,6 @@ static int vout_Init( vout_thread_t *p_vout ) * p_vout->p_sys->i_bytes_per_pixel; } - /* Only useful for p_vout->p_sys->var_info.bits_per_pixel != 8 */ - p_pic->p->i_red_mask = ( (1 << p_vout->p_sys->var_info.red.length) - 1 ) - << p_vout->p_sys->var_info.red.offset; - p_pic->p->i_green_mask = ( (1 << p_vout->p_sys->var_info.green.length) - 1 ) - << p_vout->p_sys->var_info.green.offset; - p_pic->p->i_blue_mask = ( (1 << p_vout->p_sys->var_info.blue.length) - 1 ) - << p_vout->p_sys->var_info.blue.offset; - p_pic->i_planes = 1; p_pic->i_status = DESTROYED_PICTURE; diff --git a/plugins/ggi/ggi.c b/plugins/ggi/ggi.c index 96ac8bb85b..3d75040ee2 100644 --- a/plugins/ggi/ggi.c +++ b/plugins/ggi/ggi.c @@ -2,7 +2,7 @@ * ggi.c : GGI plugin for vlc ***************************************************************************** * Copyright (C) 2000, 2001 VideoLAN - * $Id: ggi.c,v 1.16 2002/03/11 07:23:09 gbazin Exp $ + * $Id: ggi.c,v 1.17 2002/03/16 23:03:19 sam Exp $ * * Authors: Vincent Seguin * Samuel Hocevar @@ -173,6 +173,11 @@ int vout_Init( vout_thread_t *p_vout ) return 0; } + /* Only useful for bits_per_pixel != 8 */ + p_vout->output.i_rmask = p_b[ 0 ]->buffer.plb.pixelformat->red_mask; + p_vout->output.i_gmask = p_b[ 0 ]->buffer.plb.pixelformat->green_mask; + p_vout->output.i_bmask = p_b[ 0 ]->buffer.plb.pixelformat->blue_mask; + p_pic = NULL; /* Find an empty picture slot */ @@ -214,11 +219,6 @@ int vout_Init( vout_thread_t *p_vout ) p_pic->p->i_pitch = p_b[ 0 ]->buffer.plb.stride; } - /* Only useful for bits_per_pixel != 8 */ - p_pic->p->i_red_mask = p_b[ 0 ]->buffer.plb.pixelformat->red_mask; - p_pic->p->i_green_mask = p_b[ 0 ]->buffer.plb.pixelformat->green_mask; - p_pic->p->i_blue_mask = p_b[ 0 ]->buffer.plb.pixelformat->blue_mask; - p_pic->i_planes = 1; p_pic->i_status = DESTROYED_PICTURE; diff --git a/plugins/glide/glide.c b/plugins/glide/glide.c index 6be25a75c7..367c20277a 100644 --- a/plugins/glide/glide.c +++ b/plugins/glide/glide.c @@ -2,7 +2,7 @@ * glide.c : 3dfx Glide plugin for vlc ***************************************************************************** * Copyright (C) 2000, 2001 VideoLAN - * $Id: glide.c,v 1.12 2002/02/15 13:32:53 sam Exp $ + * $Id: glide.c,v 1.13 2002/03/16 23:03:19 sam Exp $ * * Authors: Samuel Hocevar * @@ -146,6 +146,11 @@ int vout_Init( vout_thread_t *p_vout ) int i_index; picture_t *p_pic; + /* FIXME: we don't set i_chroma !! */ + p_vout->output.i_rmask = 0xf800; + p_vout->output.i_gmask = 0x07e0; + p_vout->output.i_bmask = 0x001f; + I_OUTPUTPICTURES = 0; p_pic = NULL; @@ -179,10 +184,6 @@ int vout_Init( vout_thread_t *p_vout ) p_pic->p->i_pitch = p_vout->p_sys->p_buffer_info.strideInBytes; /*1024 * GLIDE_BYTES_PER_PIXEL*/ - p_pic->p->i_red_mask = 0xf800; - p_pic->p->i_green_mask = 0x07e0; - p_pic->p->i_blue_mask = 0x001f; - p_pic->i_status = DESTROYED_PICTURE; p_pic->i_type = DIRECT_PICTURE; diff --git a/plugins/qnx/vout_qnx.c b/plugins/qnx/vout_qnx.c index 20d0b96f66..eb42220275 100644 --- a/plugins/qnx/vout_qnx.c +++ b/plugins/qnx/vout_qnx.c @@ -686,23 +686,23 @@ static int QNXInitDisplay( p_vout_thread_t p_vout ) switch( p_vout->i_screen_depth ) { case 15: - p_vout->i_red_mask = 0x7c00; - p_vout->i_green_mask = 0x03e0; - p_vout->i_blue_mask = 0x001f; + p_vout->output.i_rmask = 0x7c00; + p_vout->output.i_gmask = 0x03e0; + p_vout->output.i_bmask = 0x001f; break; case 16: - p_vout->i_red_mask = 0xf800; - p_vout->i_green_mask = 0x07e0; - p_vout->i_blue_mask = 0x001f; + p_vout->output.i_rmask = 0xf800; + p_vout->output.i_gmask = 0x07e0; + p_vout->output.i_bmask = 0x001f; break; case 24: case 32: default: - p_vout->i_red_mask = 0xff0000; - p_vout->i_green_mask = 0x00ff00; - p_vout->i_blue_mask = 0x0000ff; + p_vout->output.i_rmask = 0xff0000; + p_vout->output.i_gmask = 0x00ff00; + p_vout->output.i_bmask = 0x0000ff; break; } diff --git a/plugins/sdl/vout_sdl.c b/plugins/sdl/vout_sdl.c index a6fa54f576..5399fd6d00 100644 --- a/plugins/sdl/vout_sdl.c +++ b/plugins/sdl/vout_sdl.c @@ -2,7 +2,7 @@ * vout_sdl.c: SDL video output display method ***************************************************************************** * Copyright (C) 1998-2001 VideoLAN - * $Id: vout_sdl.c,v 1.82 2002/02/19 00:50:19 sam Exp $ + * $Id: vout_sdl.c,v 1.83 2002/03/16 23:03:19 sam Exp $ * * Authors: Samuel Hocevar * Pierre Baillet @@ -70,9 +70,6 @@ typedef struct vout_sys_s /* For RGB output */ int i_surfaces; - int i_red_mask; - int i_green_mask; - int i_blue_mask; boolean_t b_cursor; boolean_t b_cursor_autohidden; @@ -648,7 +645,7 @@ static int SDLOpenDisplay( vout_thread_t *p_vout ) switch( p_vout->p_sys->p_display->format->BitsPerPixel ) { case 8: - p_vout->output.i_chroma = FOURCC_BI_RGB; + p_vout->output.i_chroma = FOURCC_RGB; break; case 15: p_vout->output.i_chroma = FOURCC_RV15; @@ -657,10 +654,10 @@ static int SDLOpenDisplay( vout_thread_t *p_vout ) p_vout->output.i_chroma = FOURCC_RV16; break; case 24: - p_vout->output.i_chroma = FOURCC_BI_BITFIELDS; + p_vout->output.i_chroma = FOURCC_RV24; break; case 32: - p_vout->output.i_chroma = FOURCC_BI_BITFIELDS; + p_vout->output.i_chroma = FOURCC_RV32; break; default: intf_ErrMsg( "vout error: unknown screen depth" ); @@ -669,9 +666,9 @@ static int SDLOpenDisplay( vout_thread_t *p_vout ) return( -1 ); } - p_vout->p_sys->i_red_mask = p_vout->p_sys->p_display->format->Rmask; - p_vout->p_sys->i_green_mask = p_vout->p_sys->p_display->format->Gmask; - p_vout->p_sys->i_blue_mask = p_vout->p_sys->p_display->format->Bmask; + p_vout->output.i_rmask = p_vout->p_sys->p_display->format->Rmask; + p_vout->output.i_gmask = p_vout->p_sys->p_display->format->Gmask; + p_vout->output.i_bmask = p_vout->p_sys->p_display->format->Bmask; SDL_WM_SetCaption( VOUT_TITLE " (software RGB SDL output)", VOUT_TITLE " (software RGB SDL output)" ); @@ -750,10 +747,6 @@ static int SDLNewPicture( vout_thread_t *p_vout, picture_t *p_pic ) p_pic->p->i_visible_bytes = 2 * p_vout->p_sys->p_display->w; } - p_pic->p->i_red_mask = p_vout->p_sys->p_display->format->Rmask; - p_pic->p->i_green_mask = p_vout->p_sys->p_display->format->Gmask; - p_pic->p->i_blue_mask = p_vout->p_sys->p_display->format->Bmask; - p_vout->p_sys->i_surfaces++; p_pic->i_planes = 1; diff --git a/plugins/x11/xcommon.c b/plugins/x11/xcommon.c index 6845b18659..997041e7c5 100644 --- a/plugins/x11/xcommon.c +++ b/plugins/x11/xcommon.c @@ -2,7 +2,7 @@ * xcommon.c: Functions common to the X11 and XVideo plugins ***************************************************************************** * Copyright (C) 1998-2001 VideoLAN - * $Id: xcommon.c,v 1.21 2002/03/11 07:23:09 gbazin Exp $ + * $Id: xcommon.c,v 1.22 2002/03/16 23:03:19 sam Exp $ * * Authors: Vincent Seguin * Samuel Hocevar @@ -155,9 +155,6 @@ typedef struct vout_sys_s int i_screen_depth; int i_bytes_per_pixel; int i_bytes_per_line; - int i_red_mask; - int i_green_mask; - int i_blue_mask; #endif /* X11 generic properties */ @@ -432,21 +429,35 @@ static int vout_Init( vout_thread_t *p_vout ) p_vout->output.i_height = p_vout->render.i_height; p_vout->output.i_aspect = p_vout->render.i_aspect; + switch( p_vout->output.i_chroma ) + { + case FOURCC_RV15: + p_vout->output.i_rmask = 0x001f; + p_vout->output.i_gmask = 0x07e0; + p_vout->output.i_bmask = 0xf800; + break; + case FOURCC_RV16: + p_vout->output.i_rmask = 0x001f; + p_vout->output.i_gmask = 0x03e0; + p_vout->output.i_bmask = 0x7c00; + break; + } + #else /* Initialize the output structure: RGB with square pixels, whatever * the input format is, since it's the only format we know */ switch( p_vout->p_sys->i_screen_depth ) { case 8: /* FIXME: set the palette */ - p_vout->output.i_chroma = FOURCC_BI_RGB; break; + p_vout->output.i_chroma = FOURCC_RGB; break; case 15: p_vout->output.i_chroma = FOURCC_RV15; break; case 16: p_vout->output.i_chroma = FOURCC_RV16; break; case 24: - p_vout->output.i_chroma = FOURCC_BI_BITFIELDS; break; + p_vout->output.i_chroma = FOURCC_RV24; break; case 32: - p_vout->output.i_chroma = FOURCC_BI_BITFIELDS; break; + p_vout->output.i_chroma = FOURCC_RV24; break; default: intf_ErrMsg( "vout error: unknown screen depth" ); return( 0 ); @@ -1276,10 +1287,6 @@ static int NewPicture( vout_thread_t *p_vout, picture_t *p_pic ) p_pic->p->i_pixel_bytes = 2; p_pic->p->b_margin = 0; - p_pic->p->i_red_mask = 0x001f; - p_pic->p->i_green_mask = 0x07e0; - p_pic->p->i_blue_mask = 0xf800; - p_pic->i_planes = 1; break; @@ -1292,10 +1299,6 @@ static int NewPicture( vout_thread_t *p_vout, picture_t *p_pic ) p_pic->p->i_pixel_bytes = 2; p_pic->p->b_margin = 0; - p_pic->p->i_red_mask = 0x001f; - p_pic->p->i_green_mask = 0x03e0; - p_pic->p->i_blue_mask = 0x7c00; - p_pic->i_planes = 1; break; @@ -1320,10 +1323,6 @@ static int NewPicture( vout_thread_t *p_vout, picture_t *p_pic ) p_pic->p->i_visible_bytes = 2 * p_pic->p_sys->p_image->width; } - p_pic->p->i_red_mask = p_pic->p_sys->p_image->red_mask; - p_pic->p->i_green_mask = p_pic->p_sys->p_image->green_mask; - p_pic->p->i_blue_mask = p_pic->p_sys->p_image->blue_mask; - p_pic->i_planes = 1; break; @@ -1347,10 +1346,6 @@ static int NewPicture( vout_thread_t *p_vout, picture_t *p_pic ) p_pic->p->i_visible_bytes = 4 * p_pic->p_sys->p_image->width; } - p_pic->p->i_red_mask = p_pic->p_sys->p_image->red_mask; - p_pic->p->i_green_mask = p_pic->p_sys->p_image->green_mask; - p_pic->p->i_blue_mask = p_pic->p_sys->p_image->blue_mask; - p_pic->i_planes = 1; break; @@ -2074,9 +2069,10 @@ static int InitDisplay( vout_thread_t *p_vout ) intf_ErrMsg( "vout error: no TrueColor visual available" ); return( 1 ); } - p_vout->p_sys->i_red_mask = p_xvisual->red_mask; - p_vout->p_sys->i_green_mask = p_xvisual->green_mask; - p_vout->p_sys->i_blue_mask = p_xvisual->blue_mask; + + p_vout->output.i_rmask = p_xvisual->red_mask; + p_vout->output.i_gmask = p_xvisual->green_mask; + p_vout->output.i_bmask = p_xvisual->blue_mask; /* There is no difference yet between 3 and 4 Bpp. The only way * to find the actual number of bytes per pixel is to list supported diff --git a/src/misc/configuration.c b/src/misc/configuration.c index 9afd420228..cf1e0ff74d 100644 --- a/src/misc/configuration.c +++ b/src/misc/configuration.c @@ -2,7 +2,7 @@ * configuration.c management of the modules configuration ***************************************************************************** * Copyright (C) 2001 VideoLAN - * $Id: configuration.c,v 1.4 2002/03/16 01:40:58 gbazin Exp $ + * $Id: configuration.c,v 1.5 2002/03/16 23:03:19 sam Exp $ * * Authors: Gildas Bazin * @@ -20,6 +20,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. *****************************************************************************/ + #include /* sprintf() */ #include /* free(), strtol() */ #include /* strdup() */ @@ -34,7 +35,10 @@ #include #include -static char *config_GetHomeDir(void); +/***************************************************************************** + * Local prototypes + *****************************************************************************/ +static char *GetHomeDir( void ); /***************************************************************************** * config_GetIntVariable: get the value of an int variable @@ -52,15 +56,14 @@ int config_GetIntVariable( const char *psz_name ) /* sanity checks */ if( !p_config ) { - intf_ErrMsg( "config_GetIntVariable: option %s doesn't exist", - psz_name ); + intf_ErrMsg( "config error: option %s doesn't exist", psz_name ); return -1; } if( (p_config->i_type!=MODULE_CONFIG_ITEM_INTEGER) && (p_config->i_type!=MODULE_CONFIG_ITEM_BOOL) ) { - intf_ErrMsg( "config_GetIntVariable: option %s doesn't refer to an int" - , psz_name ); + intf_ErrMsg( "config error: option %s doesn't refer to an int", + psz_name ); return -1; } @@ -88,16 +91,15 @@ char * config_GetPszVariable( const char *psz_name ) /* sanity checks */ if( !p_config ) { - intf_ErrMsg( "config_GetPszVariable: option %s doesn't exist", - psz_name ); + intf_ErrMsg( "config error: option %s doesn't exist", psz_name ); return NULL; } if( (p_config->i_type!=MODULE_CONFIG_ITEM_STRING) && (p_config->i_type!=MODULE_CONFIG_ITEM_FILE) && (p_config->i_type!=MODULE_CONFIG_ITEM_PLUGIN) ) { - intf_ErrMsg( "config_GetPszVariable: option %s doesn't refer to a " - "string", psz_name ); + intf_ErrMsg( "config error: option %s doesn't refer to a string", + psz_name ); return NULL; } @@ -125,16 +127,15 @@ void config_PutPszVariable( const char *psz_name, char *psz_value ) /* sanity checks */ if( !p_config ) { - intf_ErrMsg( "config_PutPszVariable: option %s doesn't exist", - psz_name ); + intf_ErrMsg( "config error: option %s doesn't exist", psz_name ); return; } if( (p_config->i_type!=MODULE_CONFIG_ITEM_STRING) && (p_config->i_type!=MODULE_CONFIG_ITEM_FILE) && (p_config->i_type!=MODULE_CONFIG_ITEM_PLUGIN) ) { - intf_ErrMsg( "config_PutPszVariable: option %s doesn't refer to a " - "string", psz_name ); + intf_ErrMsg( "config error: option %s doesn't refer to a string", + psz_name ); return; } @@ -166,15 +167,14 @@ void config_PutIntVariable( const char *psz_name, int i_value ) /* sanity checks */ if( !p_config ) { - intf_ErrMsg( "config_PutIntVariable: option %s doesn't exist", - psz_name ); + intf_ErrMsg( "config error: option %s doesn't exist", psz_name ); return; } if( (p_config->i_type!=MODULE_CONFIG_ITEM_INTEGER) && (p_config->i_type!=MODULE_CONFIG_ITEM_BOOL) ) { - intf_ErrMsg( "config_PutIntVariable: option %s doesn't refer to an int" - , psz_name ); + intf_ErrMsg( "config error: option %s doesn't refer to an int", + psz_name ); return; } @@ -227,7 +227,7 @@ module_config_t *config_Duplicate( module_t *p_module ) * p_module->i_config_lines ); if( p_config == NULL ) { - intf_ErrMsg( "config_Duplicate error: can't allocate p_config" ); + intf_ErrMsg( "config error: can't duplicate p_config" ); return( NULL ); } @@ -280,33 +280,32 @@ int config_LoadConfigFile( const char *psz_module_name ) /* Acquire config file lock */ vlc_mutex_lock( &p_main->config_lock ); - psz_homedir = config_GetHomeDir(); + psz_homedir = GetHomeDir(); if( !psz_homedir ) { - intf_ErrMsg( "config_LoadConfigFile: GetHomeDir failed" ); + intf_ErrMsg( "config error: GetHomeDir failed" ); vlc_mutex_unlock( &p_main->config_lock ); return -1; } - psz_filename = (char *)malloc( strlen("/.VideoLan/vlc") + + psz_filename = (char *)malloc( strlen("/" CONFIG_DIR "/" CONFIG_FILE) + strlen(psz_homedir) + 1 ); if( !psz_filename ) { - intf_ErrMsg( "config err: couldn't malloc psz_filename" ); + intf_ErrMsg( "config error: couldn't malloc psz_filename" ); free( psz_homedir ); vlc_mutex_unlock( &p_main->config_lock ); return -1; } - sprintf( psz_filename, "%s/.VideoLan/vlc", psz_homedir ); + sprintf( psz_filename, "%s/" CONFIG_DIR "/" CONFIG_FILE, psz_homedir ); free( psz_homedir ); - intf_WarnMsg( 5, "config_SaveConfigFile: opening config file %s", - psz_filename ); + intf_WarnMsg( 5, "config: opening config file %s", psz_filename ); file = fopen( psz_filename, "r" ); if( !file ) { - intf_WarnMsg( 1, "config_LoadConfigFile: couldn't open config file %s " - "for reading", psz_filename ); + intf_WarnMsg( 1, "config: couldn't open config file %s for reading", + psz_filename ); free( psz_filename ); vlc_mutex_unlock( &p_main->config_lock ); return -1; @@ -330,8 +329,8 @@ int config_LoadConfigFile( const char *psz_module_name ) !memcmp( &line[1], p_module->psz_name, strlen(p_module->psz_name) ) ) { - intf_WarnMsg( 5, "config_LoadConfigFile: loading config for " - "module <%s>", p_module->psz_name ); + intf_WarnMsg( 5, "config: loading config for module <%s>", + p_module->psz_name ); break; } @@ -375,8 +374,7 @@ int config_LoadConfigFile( const char *psz_module_name ) case MODULE_CONFIG_ITEM_INTEGER: p_module->p_config[i].i_value = atoi( psz_option_value); - intf_WarnMsg( 7, "config_LoadConfigFile: found <%s> " - "option %s=%i", + intf_WarnMsg( 7, "config: found <%s> option %s=%i", p_module->psz_name, p_module->p_config[i].psz_name, p_module->p_config[i].i_value ); @@ -394,8 +392,7 @@ int config_LoadConfigFile( const char *psz_module_name ) vlc_mutex_unlock( p_module->p_config[i].p_lock ); - intf_WarnMsg( 7, "config_LoadConfigFile: found <%s> " - "option %s=%s", + intf_WarnMsg( 7, "config: found <%s> option %s=%s", p_module->psz_name, p_module->p_config[i].psz_name, p_module->p_config[i].psz_value ); @@ -447,40 +444,39 @@ int config_SaveConfigFile( const char *psz_module_name ) /* Acquire config file lock */ vlc_mutex_lock( &p_main->config_lock ); - psz_homedir = config_GetHomeDir(); + psz_homedir = GetHomeDir(); if( !psz_homedir ) { - intf_ErrMsg( "config_SaveConfigFile: GetHomeDir failed" ); + intf_ErrMsg( "config error: GetHomeDir failed" ); vlc_mutex_unlock( &p_main->config_lock ); return -1; } - psz_filename = (char *)malloc( strlen("/.VideoLan/vlc") + + psz_filename = (char *)malloc( strlen("/" CONFIG_DIR "/" CONFIG_FILE) + strlen(psz_homedir) + 1 ); if( !psz_filename ) { - intf_ErrMsg( "config err: couldn't malloc psz_filename" ); + intf_ErrMsg( "config error: couldn't malloc psz_filename" ); free( psz_homedir ); vlc_mutex_unlock( &p_main->config_lock ); return -1; } - sprintf( psz_filename, "%s/.VideoLan", psz_homedir ); + sprintf( psz_filename, "%s/" CONFIG_DIR, psz_homedir ); free( psz_homedir ); #ifndef WIN32 mkdir( psz_filename, 0755 ); #else mkdir( psz_filename ); #endif - strcat( psz_filename, "/vlc" ); + strcat( psz_filename, "/" CONFIG_FILE ); - intf_WarnMsg( 5, "config_SaveConfigFile: opening config file %s", - psz_filename ); + intf_WarnMsg( 5, "config: opening config file %s", psz_filename ); file = fopen( psz_filename, "r" ); if( !file ) { - intf_WarnMsg( 1, "config_SaveConfigFile: couldn't open config file %s " - "for reading", psz_filename ); + intf_WarnMsg( 1, "config: couldn't open config file %s for reading", + psz_filename ); } else { @@ -493,7 +489,7 @@ int config_SaveConfigFile( const char *psz_module_name ) p_bigbuffer = p_index = malloc( i_sizebuf+1 ); if( !p_bigbuffer ) { - intf_ErrMsg( "config err: couldn't malloc bigbuffer" ); + intf_ErrMsg( "config error: couldn't malloc bigbuffer" ); if( file ) fclose( file ); free( psz_filename ); vlc_mutex_unlock( &p_main->config_lock ); @@ -528,8 +524,8 @@ int config_SaveConfigFile( const char *psz_module_name ) /* we don't have this section in our list so we need to back * it up */ *p_index2 = 0; - intf_WarnMsg( 5, "config_SaveConfigFile: backing up config for" - " unknown module <%s>", &p_line[1] ); + intf_WarnMsg( 5, "config: backing up config for " + "unknown module <%s>", &p_line[1] ); *p_index2 = ']'; b_backup = 1; @@ -559,14 +555,14 @@ int config_SaveConfigFile( const char *psz_module_name ) file = fopen( psz_filename, "w" ); if( !file ) { - intf_WarnMsg( 1, "config_SaveConfigFile: couldn't open config file %s " - "for writing", psz_filename ); + intf_WarnMsg( 1, "config: couldn't open config file %s for writing", + psz_filename ); free( psz_filename ); vlc_mutex_unlock( &p_main->config_lock ); return -1; } - fprintf( file, "#\n# "COPYRIGHT_MESSAGE"\n#\n\n" ); + fprintf( file, "###\n### " COPYRIGHT_MESSAGE "\n###\n\n" ); /* Look for the selected module, if NULL then save everything */ for( p_module = p_module_bank->first ; p_module != NULL ; @@ -579,12 +575,13 @@ int config_SaveConfigFile( const char *psz_module_name ) if( !p_module->i_config_items ) continue; - intf_WarnMsg( 5, "config_SaveConfigFile: saving config for " - "module <%s>", p_module->psz_name ); + intf_WarnMsg( 5, "config: saving config for module <%s>", + p_module->psz_name ); - fprintf( file, "[%s]\n", p_module->psz_name ); if( p_module->psz_longname ) - fprintf( file, "# %s\n#\n", p_module->psz_longname ); + fprintf( file, "###\n### %s\n###\n", p_module->psz_longname ); + + fprintf( file, "[%s]\n", p_module->psz_name ); for( i = 0; i < p_module->i_config_lines; i++ ) { @@ -631,12 +628,14 @@ int config_SaveConfigFile( const char *psz_module_name ) return 0; } +/* Following functions are local. */ + /***************************************************************************** - * config_GetHomeDir: find the user's home directory. + * GetHomeDir: find the user's home directory. ***************************************************************************** * This function will try by different ways to find the user's home path. *****************************************************************************/ -static char *config_GetHomeDir(void) +static char *GetHomeDir( void ) { char *p_tmp, *p_homedir = NULL; @@ -653,22 +652,19 @@ static char *config_GetHomeDir(void) p_buffer = (char *)malloc( bufsize ); if( ( ret = getpwuid_r( getuid(), &pwd, p_buffer, bufsize, &p_pw ) ) < 0 ) - { - #elif defined(HAVE_GETPWUID) if( ( p_pw = getpwuid( getuid() ) ) == NULL ) - { - #endif + { if( ( p_tmp = getenv( "HOME" ) ) == NULL ) { - intf_ErrMsg( "Unable to get home directory, set it to /tmp" ); + intf_ErrMsg( "config error: unable to get home directory, " + "using /tmp instead" ); p_homedir = strdup( "/tmp" ); } else p_homedir = strdup( p_tmp ); - -#if defined(HAVE_GETPWUID_R) || defined(HAVE_GETPWUID) } +#if defined(HAVE_GETPWUID_R) || defined(HAVE_GETPWUID) else { if( p_pw ) p_homedir = strdup( p_pw->pw_dir ); diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c index f01c734b46..f0754e22f5 100644 --- a/src/video_output/video_output.c +++ b/src/video_output/video_output.c @@ -5,7 +5,7 @@ * thread, and destroy a previously oppened video output thread. ***************************************************************************** * Copyright (C) 2000-2001 VideoLAN - * $Id: video_output.c,v 1.166 2002/03/15 04:41:54 sam Exp $ + * $Id: video_output.c,v 1.167 2002/03/16 23:03:19 sam Exp $ * * Authors: Vincent Seguin * @@ -49,7 +49,10 @@ static void RunThread ( vout_thread_t *p_vout ); static void ErrorThread ( vout_thread_t *p_vout ); static void EndThread ( vout_thread_t *p_vout ); static void DestroyThread ( vout_thread_t *p_vout, int i_status ); + static int ReduceHeight ( int ); +static int BinaryLog ( u32 ); +static void MaskToShift ( int *, int *, u32 ); /***************************************************************************** * vout_InitBank: initialize the video output bank. @@ -133,15 +136,31 @@ vout_thread_t * vout_CreateThread ( int *pi_status, p_vout->p_subpicture[i_index].i_type = EMPTY_SUBPICTURE; } - /* Initialize the rendering heap */ + /* No images in the heap */ p_vout->i_heap_size = 0; + /* Initialize the rendering heap */ I_RENDERPICTURES = 0; p_vout->render.i_width = i_width; p_vout->render.i_height = i_height; p_vout->render.i_chroma = i_chroma; p_vout->render.i_aspect = i_aspect; + p_vout->render.i_rmask = 0; + p_vout->render.i_gmask = 0; + p_vout->render.i_bmask = 0; + + /* Zero the output heap */ + I_OUTPUTPICTURES = 0; + p_vout->output.i_width = 0; + p_vout->output.i_height = 0; + p_vout->output.i_chroma = 0; + p_vout->output.i_aspect = 0; + + p_vout->output.i_rmask = 0; + p_vout->output.i_gmask = 0; + p_vout->output.i_bmask = 0; + /* Initialize misc stuff */ p_vout->i_changes = 0; p_vout->f_gamma = 0; @@ -260,7 +279,7 @@ static int InitThread( vout_thread_t *p_vout ) p_vout->c_loops = 0; #endif - /* Initialize output method, it issues its own error messages */ + /* Initialize output method, it allocates direct buffers for us */ if( p_vout->pf_init( p_vout ) ) { vlc_mutex_unlock( &p_vout->change_lock ); @@ -294,6 +313,14 @@ static int InitThread( vout_thread_t *p_vout ) p_vout->output.i_aspect / i_pgcd, VOUT_ASPECT_FACTOR / i_pgcd ); + /* Calculate shifts from system-updated masks */ + MaskToShift( &p_vout->output.i_lrshift, &p_vout->output.i_rrshift, + p_vout->output.i_rmask ); + MaskToShift( &p_vout->output.i_lgshift, &p_vout->output.i_rgshift, + p_vout->output.i_gmask ); + MaskToShift( &p_vout->output.i_lbshift, &p_vout->output.i_rbshift, + p_vout->output.i_bmask ); + /* Check whether we managed to create direct buffers similar to * the render buffers, ie same size, chroma and aspect ratio */ if( ( p_vout->output.i_width == p_vout->render.i_width ) @@ -316,7 +343,6 @@ static int InitThread( vout_thread_t *p_vout ) PP_RENDERPICTURE[ I_RENDERPICTURES ] = &p_vout->p_picture[ i ]; I_RENDERPICTURES++; } - } else { @@ -374,6 +400,17 @@ static int InitThread( vout_thread_t *p_vout ) } } + /* Link pictures back to their heap */ + for( i = 0 ; i < I_RENDERPICTURES ; i++ ) + { + PP_RENDERPICTURE[ i ]->p_heap = &p_vout->render; + } + + for( i = 0 ; i < I_OUTPUTPICTURES ; i++ ) + { + PP_OUTPUTPICTURE[ i ]->p_heap = &p_vout->output; + } + /* Mark thread as running and return */ p_vout->b_active = 1; *p_vout->pi_status = THREAD_READY; @@ -685,6 +722,8 @@ static void DestroyThread( vout_thread_t *p_vout, int i_status ) *pi_status = i_status; } +/* following functions are local */ + static int ReduceHeight( int i_ratio ) { int i_dummy = VOUT_ASPECT_FACTOR; @@ -720,3 +759,55 @@ static int ReduceHeight( int i_ratio ) return i_pgcd; } +/***************************************************************************** + * BinaryLog: computes the base 2 log of a binary value + ***************************************************************************** + * This functions is used by MaskToShift, to get a bit index from a binary + * value. + *****************************************************************************/ +static int BinaryLog(u32 i) +{ + int i_log = 0; + + if(i & 0xffff0000) i_log += 16; + if(i & 0xff00ff00) i_log += 8; + if(i & 0xf0f0f0f0) i_log += 4; + if(i & 0xcccccccc) i_log += 2; + if(i & 0xaaaaaaaa) i_log += 1; + + if (i != ((u32)1 << i_log)) + { + intf_ErrMsg( "vout error: binary log overflow for %i", i ); + } + + return( i_log ); +} + +/***************************************************************************** + * MaskToShift: transform a color mask into right and left shifts + ***************************************************************************** + * This function is used for obtaining color shifts from masks. + *****************************************************************************/ +static void MaskToShift( int *pi_left, int *pi_right, u32 i_mask ) +{ + u32 i_low, i_high; /* lower hand higher bits of the mask */ + + if( !i_mask ) + { + *pi_left = *pi_right = 0; + return; + } + + /* Get bits */ + i_low = i_mask & (- i_mask); /* lower bit of the mask */ + i_high = i_mask + i_low; /* higher bit of the mask */ + + /* Transform bits into an index */ + i_low = BinaryLog (i_low); + i_high = BinaryLog (i_high); + + /* Update pointers and return */ + *pi_left = i_low; + *pi_right = (8 - i_high + i_low); +} + diff --git a/src/video_output/vout_pictures.c b/src/video_output/vout_pictures.c index 5fa3fc0ddd..d142097293 100644 --- a/src/video_output/vout_pictures.c +++ b/src/video_output/vout_pictures.c @@ -2,7 +2,7 @@ * vout_pictures.c : picture management functions ***************************************************************************** * Copyright (C) 2000 VideoLAN - * $Id: vout_pictures.c,v 1.18 2002/02/27 18:19:21 sam Exp $ + * $Id: vout_pictures.c,v 1.19 2002/03/16 23:03:19 sam Exp $ * * Authors: Vincent Seguin * Samuel Hocevar @@ -465,9 +465,9 @@ void vout_AllocatePicture( picture_t *p_pic, p_pic->p->i_lines = i_height; p_pic->p->i_pitch = i_width * 2; p_pic->p->i_pixel_bytes = 2; - p_pic->p->i_red_mask = 0x001f; - p_pic->p->i_green_mask = 0x03e0; - p_pic->p->i_blue_mask = 0x7c00; + p_pic->p_heap->i_rmask = 0x001f; + p_pic->p_heap->i_gmask = 0x03e0; + p_pic->p_heap->i_bmask = 0x7c00; p_pic->i_planes = 1; break; @@ -475,9 +475,9 @@ void vout_AllocatePicture( picture_t *p_pic, p_pic->p->i_lines = i_height; p_pic->p->i_pitch = i_width * 2; p_pic->p->i_pixel_bytes = 2; - p_pic->p->i_red_mask = 0x001f; - p_pic->p->i_green_mask = 0x07e0; - p_pic->p->i_blue_mask = 0xf800; + p_pic->p_heap->i_rmask = 0x001f; + p_pic->p_heap->i_gmask = 0x07e0; + p_pic->p_heap->i_bmask = 0xf800; p_pic->i_planes = 1; break; @@ -485,9 +485,9 @@ void vout_AllocatePicture( picture_t *p_pic, p_pic->p->i_lines = i_height; p_pic->p->i_pitch = i_width * 4; p_pic->p->i_pixel_bytes = 4; - p_pic->p->i_red_mask = 0xff0000; - p_pic->p->i_green_mask = 0x00ff00; - p_pic->p->i_blue_mask = 0x0000ff; + p_pic->p_heap->i_rmask = 0xff0000; + p_pic->p_heap->i_gmask = 0x00ff00; + p_pic->p_heap->i_bmask = 0x0000ff; p_pic->i_planes = 1; break; -- 2.11.4.GIT