X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fvideo_filter%2Fpanoramix.c;h=1d4a8ba70aa53f0a111ec677d7e487638940d751;hb=ea93da268c6617a0c5c98a2125b9aa27eba19d6d;hp=a4536951d7e01b19ef728d08d11e702b7ece05fa;hpb=febe7d21213036cc670ff40a67b82c0e027d0a9b;p=vlc diff --git a/modules/video_filter/panoramix.c b/modules/video_filter/panoramix.c index a4536951d7..1d4a8ba70a 100644 --- a/modules/video_filter/panoramix.c +++ b/modules/video_filter/panoramix.c @@ -2,7 +2,7 @@ * panoramix.c : Wall panoramic video with edge blending plugin for vlc ***************************************************************************** * Copyright (C) 2000, 2001, 2002, 2003 VideoLAN - * $Id: panoramix.c 2006-08-29 16:20:15Z ced $ + * $Id$ * * Authors: Cedric Cocquebert * based on Samuel Hocevar @@ -25,11 +25,14 @@ /***************************************************************************** * Preamble *****************************************************************************/ -#include /* malloc(), free() */ -#include -#include -#include +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include +#include #include "filter_common.h" @@ -37,19 +40,17 @@ #define OVERLAP 2350 #ifdef OVERLAP #include - // OS CODE DEPENDANT to get display dimensions - #ifdef SYS_LINUX - #include - #else + // OS CODE DEPENDENT to get display dimensions #ifdef SYS_MINGW32 #include - #endif + #else + #include #endif #define GAMMA 1 // #define PACKED_YUV 1 #define F2(a) ((a)*(a)) #define F4(a,b,x) ((a)*(F2(x))+((b)*(x))) - #define ACCURACY 255 + #define ACCURACY 1000 #define RATIO_MAX 2500 #define CLIP_01(a) (a < 0.0 ? 0.0 : (a > 1.0 ? 1.0 : a)) // #define CLIP_0A(a) (a < 0.0 ? 0.0 : (a > ACCURACY ? ACCURACY : a)) @@ -89,60 +90,64 @@ static int SendEvents( vlc_object_t *, char const *, #define ACTIVE_LONGTEXT N_("Comma separated list of active windows, " \ "defaults to all") +#define CFG_PREFIX "panoramix-" + vlc_module_begin(); - set_description( _("Panoramix: wall with overlap video filter") ); + set_description( N_("Panoramix: wall with overlap video filter") ); set_shortname( N_("Panoramix" )); set_capability( "video filter", 0 ); set_category( CAT_VIDEO ); set_subcategory( SUBCAT_VIDEO_VFILTER ); - add_integer( "panoramix-cols", -1, NULL, COLS_TEXT, COLS_LONGTEXT, VLC_TRUE ); - add_integer( "panoramix-rows", -1, NULL, ROWS_TEXT, ROWS_LONGTEXT, VLC_TRUE ); + add_integer( CFG_PREFIX "cols", -1, NULL, + COLS_TEXT, COLS_LONGTEXT, true ); + add_integer( CFG_PREFIX "rows", -1, NULL, + ROWS_TEXT, ROWS_LONGTEXT, true ); #ifdef OVERLAP #define OFFSET_X_TEXT N_("Offset X offset (automatic compensation)") #define OFFSET_X_LONGTEXT N_("Select if you want an automatic offset in horizontal (in case of misalignment due to autoratio control)") - add_bool( "offset-x", 1, NULL, OFFSET_X_TEXT, OFFSET_X_LONGTEXT, VLC_TRUE ); + add_bool( CFG_PREFIX "offset-x", 1, NULL, OFFSET_X_TEXT, OFFSET_X_LONGTEXT, true ); #define LENGTH_TEXT N_("length of the overlapping area (in %)") #define LENGTH_LONGTEXT N_("Select in percent the length of the blended zone") - add_integer_with_range( "bz-length", 100, 0, 100, NULL, LENGTH_TEXT, LENGTH_LONGTEXT, VLC_TRUE ); + add_integer_with_range( CFG_PREFIX "bz-length", 100, 0, 100, NULL, LENGTH_TEXT, LENGTH_LONGTEXT, true ); #define HEIGHT_TEXT N_("height of the overlapping area (in %)") #define HEIGHT_LONGTEXT N_("Select in percent the height of the blended zone (case of 2x2 wall)") - add_integer_with_range( "bz-height", 100, 0, 100, NULL, HEIGHT_TEXT, HEIGHT_LONGTEXT, VLC_TRUE ); + add_integer_with_range( CFG_PREFIX "bz-height", 100, 0, 100, NULL, HEIGHT_TEXT, HEIGHT_LONGTEXT, true ); #define ATTENUATION_TEXT N_("Attenuation") #define ATTENUATION_LONGTEXT N_("Check this option if you want attenuate blended zone by this plug-in (if option is unchecked, attenuate is made by opengl)") - add_bool( "panoramix-attenuate", 1, NULL, ATTENUATION_TEXT, ATTENUATION_LONGTEXT, VLC_FALSE ); + add_bool( CFG_PREFIX "attenuate", 1, NULL, ATTENUATION_TEXT, ATTENUATION_LONGTEXT, false ); #define BEGIN_TEXT N_("Attenuation, begin (in %)") #define BEGIN_LONGTEXT N_("Select in percent the Lagrange coeff of the beginning blended zone") - add_integer_with_range( "bz-begin", 0, 0, 100, NULL, BEGIN_TEXT, BEGIN_LONGTEXT, VLC_TRUE ); + add_integer_with_range( CFG_PREFIX "bz-begin", 0, 0, 100, NULL, BEGIN_TEXT, BEGIN_LONGTEXT, true ); #define MIDDLE_TEXT N_("Attenuation, middle (in %)") #define MIDDLE_LONGTEXT N_("Select in percent the Lagrange coeff of the middle of blended zone") - add_integer_with_range( "bz-middle", 50, 0, 100, NULL, MIDDLE_TEXT, MIDDLE_LONGTEXT, VLC_FALSE ); + add_integer_with_range( CFG_PREFIX "bz-middle", 50, 0, 100, NULL, MIDDLE_TEXT, MIDDLE_LONGTEXT, false ); #define END_TEXT N_("Attenuation, end (in %)") #define END_LONGTEXT N_("Select in percent the Lagrange coeff of the end of blended zone") - add_integer_with_range( "bz-end", 100, 0, 100, NULL, END_TEXT, END_LONGTEXT, VLC_TRUE ); + add_integer_with_range( CFG_PREFIX "bz-end", 100, 0, 100, NULL, END_TEXT, END_LONGTEXT, true ); #define MIDDLE_POS_TEXT N_("middle position (in %)") #define MIDDLE_POS_LONGTEXT N_("Select in percent (50 is center) the position of the middle point (Lagrange) of blended zone") - add_integer_with_range( "bz-middle-pos", 50, 1, 99, NULL, MIDDLE_POS_TEXT, MIDDLE_POS_LONGTEXT, VLC_FALSE ); + add_integer_with_range( CFG_PREFIX "bz-middle-pos", 50, 1, 99, NULL, MIDDLE_POS_TEXT, MIDDLE_POS_LONGTEXT, false ); #ifdef GAMMA #define RGAMMA_TEXT N_("Gamma (Red) correction") #define RGAMMA_LONGTEXT N_("Select the gamma for the correction of blended zone (Red or Y component)") - add_float_with_range( "bz-gamma-red", 1, 0, 5, NULL, RGAMMA_TEXT, RGAMMA_LONGTEXT, VLC_TRUE ); + add_float_with_range( CFG_PREFIX "bz-gamma-red", 1, 0, 5, NULL, RGAMMA_TEXT, RGAMMA_LONGTEXT, true ); #define GGAMMA_TEXT N_("Gamma (Green) correction") #define GGAMMA_LONGTEXT N_("Select the gamma for the correction of blended zone (Green or U component)") - add_float_with_range( "bz-gamma-green", 1, 0, 5, NULL, GGAMMA_TEXT, GGAMMA_LONGTEXT, VLC_TRUE ); + add_float_with_range( CFG_PREFIX "bz-gamma-green", 1, 0, 5, NULL, GGAMMA_TEXT, GGAMMA_LONGTEXT, true ); #define BGAMMA_TEXT N_("Gamma (Blue) correction") #define BGAMMA_LONGTEXT N_("Select the gamma for the correction of blended zone (Blue or V component)") - add_float_with_range( "bz-gamma-blue", 1, 0, 5, NULL, BGAMMA_TEXT, BGAMMA_LONGTEXT, VLC_TRUE ); + add_float_with_range( CFG_PREFIX "bz-gamma-blue", 1, 0, 5, NULL, BGAMMA_TEXT, BGAMMA_LONGTEXT, true ); #endif #define RGAMMA_BC_TEXT N_("Black Crush for Red") #define RGAMMA_BC_LONGTEXT N_("Select the Black Crush of blended zone (Red or Y component)") @@ -171,31 +176,42 @@ vlc_module_begin(); #define GGAMMA_WL_LONGTEXT N_("Select the White Level of blended zone (Green or U component)") #define BGAMMA_WL_TEXT N_("White Level for Blue") #define BGAMMA_WL_LONGTEXT N_("Select the White Level of blended zone (Blue or V component)") - add_integer_with_range( "bz-blackcrush-red", 140, 0, 255, NULL, RGAMMA_BC_TEXT, RGAMMA_BC_LONGTEXT, VLC_TRUE ); - add_integer_with_range( "bz-blackcrush-green", 140, 0, 255, NULL, GGAMMA_BC_TEXT, GGAMMA_BC_LONGTEXT, VLC_TRUE ); - add_integer_with_range( "bz-blackcrush-blue", 140, 0, 255, NULL, BGAMMA_BC_TEXT, BGAMMA_BC_LONGTEXT, VLC_TRUE ); - add_integer_with_range( "bz-whitecrush-red", 200, 0, 255, NULL, RGAMMA_WC_TEXT, RGAMMA_WC_LONGTEXT, VLC_TRUE ); - add_integer_with_range( "bz-whitecrush-green", 200, 0, 255, NULL, GGAMMA_WC_TEXT, GGAMMA_WC_LONGTEXT, VLC_TRUE ); - add_integer_with_range( "bz-whitecrush-blue", 200, 0, 255, NULL, BGAMMA_WC_TEXT, BGAMMA_WC_LONGTEXT, VLC_TRUE ); - add_integer_with_range( "bz-blacklevel-red", 150, 0, 255, NULL, RGAMMA_BL_TEXT, RGAMMA_BL_LONGTEXT, VLC_TRUE ); - add_integer_with_range( "bz-blacklevel-green", 150, 0, 255, NULL, GGAMMA_BL_TEXT, GGAMMA_BL_LONGTEXT, VLC_TRUE ); - add_integer_with_range( "bz-blacklevel-blue", 150, 0, 255, NULL, BGAMMA_BL_TEXT, BGAMMA_BL_LONGTEXT, VLC_TRUE ); - add_integer_with_range( "bz-whitelevel-red", 0, 0, 255, NULL, RGAMMA_WL_TEXT, RGAMMA_WL_LONGTEXT, VLC_TRUE ); - add_integer_with_range( "bz-whitelevel-green", 0, 0, 255, NULL, GGAMMA_WL_TEXT, GGAMMA_WL_LONGTEXT, VLC_TRUE ); - add_integer_with_range( "bz-whitelevel-blue", 0, 0, 255, NULL, BGAMMA_WL_TEXT, BGAMMA_WL_LONGTEXT, VLC_TRUE ); -#ifdef SYS_LINUX + add_integer_with_range( CFG_PREFIX "bz-blackcrush-red", 140, 0, 255, NULL, RGAMMA_BC_TEXT, RGAMMA_BC_LONGTEXT, true ); + add_integer_with_range( CFG_PREFIX "bz-blackcrush-green", 140, 0, 255, NULL, GGAMMA_BC_TEXT, GGAMMA_BC_LONGTEXT, true ); + add_integer_with_range( CFG_PREFIX "bz-blackcrush-blue", 140, 0, 255, NULL, BGAMMA_BC_TEXT, BGAMMA_BC_LONGTEXT, true ); + add_integer_with_range( CFG_PREFIX "bz-whitecrush-red", 200, 0, 255, NULL, RGAMMA_WC_TEXT, RGAMMA_WC_LONGTEXT, true ); + add_integer_with_range( CFG_PREFIX "bz-whitecrush-green", 200, 0, 255, NULL, GGAMMA_WC_TEXT, GGAMMA_WC_LONGTEXT, true ); + add_integer_with_range( CFG_PREFIX "bz-whitecrush-blue", 200, 0, 255, NULL, BGAMMA_WC_TEXT, BGAMMA_WC_LONGTEXT, true ); + add_integer_with_range( CFG_PREFIX "bz-blacklevel-red", 150, 0, 255, NULL, RGAMMA_BL_TEXT, RGAMMA_BL_LONGTEXT, true ); + add_integer_with_range( CFG_PREFIX "bz-blacklevel-green", 150, 0, 255, NULL, GGAMMA_BL_TEXT, GGAMMA_BL_LONGTEXT, true ); + add_integer_with_range( CFG_PREFIX "bz-blacklevel-blue", 150, 0, 255, NULL, BGAMMA_BL_TEXT, BGAMMA_BL_LONGTEXT, true ); + add_integer_with_range( CFG_PREFIX "bz-whitelevel-red", 0, 0, 255, NULL, RGAMMA_WL_TEXT, RGAMMA_WL_LONGTEXT, true ); + add_integer_with_range( CFG_PREFIX "bz-whitelevel-green", 0, 0, 255, NULL, GGAMMA_WL_TEXT, GGAMMA_WL_LONGTEXT, true ); + add_integer_with_range( CFG_PREFIX "bz-whitelevel-blue", 0, 0, 255, NULL, BGAMMA_WL_TEXT, BGAMMA_WL_LONGTEXT, true ); +#ifndef SYS_MINGW32 #define XINERAMA_TEXT N_("Xinerama option") #define XINERAMA_LONGTEXT N_("Uncheck if you have not used xinerama") - add_bool( "xinerama", 1, NULL, XINERAMA_TEXT, XINERAMA_LONGTEXT, VLC_TRUE ); + add_bool( CFG_PREFIX "xinerama", 1, NULL, XINERAMA_TEXT, XINERAMA_LONGTEXT, true ); #endif #endif - add_string( "wall-active", NULL, NULL, ACTIVE_TEXT, ACTIVE_LONGTEXT, VLC_TRUE ); + add_string( CFG_PREFIX "active", NULL, NULL, ACTIVE_TEXT, ACTIVE_LONGTEXT, true ); add_shortcut( "panoramix" ); set_callbacks( Create, Destroy ); vlc_module_end(); +static const char *const ppsz_filter_options[] = { + "cols", "rows", "offset-x", "bz-length", "bz-height", "attenuate", + "bz-begin", "bz-middle", "bz-end", "bz-middle-pos", "bz-gamma-red", + "bz-gamma-green", "bz-gamma-blue", "bz-blackcrush-red", + "bz-blackcrush-green", "bz-blackcrush-blue", "bz-whitecrush-red", + "bz-whitecrush-green", "bz-whitecrush-blue", "bz-blacklevel-red", + "bz-blacklevel-green", "bz-blacklevel-blue", "bz-whitelevel-red", + "bz-whitelevel-green", "bz-whitelevel-blue", "xinerama", "active", + NULL +}; + /***************************************************************************** * vout_sys_t: Wall video output method descriptor ***************************************************************************** @@ -205,13 +221,13 @@ vlc_module_end(); struct vout_sys_t { #ifdef OVERLAP - vlc_bool_t b_autocrop; - vlc_bool_t b_attenuate; + bool b_autocrop; + bool b_attenuate; unsigned int bz_length, bz_height, bz_begin, bz_middle, bz_end, bz_middle_pos; unsigned int i_ratio_max; unsigned int i_ratio; unsigned int a_0, a_1, a_2; - vlc_bool_t b_has_changed; + bool b_has_changed; int lambda[2][VOUT_MAX_PLANES][500]; int cstYUV[2][VOUT_MAX_PLANES][500]; int lambda2[2][VOUT_MAX_PLANES][500]; @@ -228,8 +244,8 @@ struct vout_sys_t uint8_t LUT2[VOUT_MAX_PLANES][256][500]; #endif #endif -#ifdef SYS_LINUX - vlc_bool_t b_xinerama; +#ifndef SYS_MINGW32 + bool b_xinerama; #endif #endif int i_col; @@ -237,7 +253,7 @@ struct vout_sys_t int i_vout; struct vout_list_t { - vlc_bool_t b_active; + bool b_active; int i_width; int i_height; vout_thread_t *p_vout; @@ -279,10 +295,7 @@ static int Create( vlc_object_t *p_this ) /* Allocate structure */ p_vout->p_sys = malloc( sizeof( vout_sys_t ) ); if( p_vout->p_sys == NULL ) - { - msg_Err( p_vout, "out of memory" ); return VLC_ENOMEM; - } p_vout->pf_init = Init; p_vout->pf_end = End; @@ -337,11 +350,14 @@ case VLC_FOURCC('c','y','u','v'): // packed by 2 p_vout->pf_display = NULL; p_vout->pf_control = Control; + config_ChainParse( p_vout, CFG_PREFIX, ppsz_filter_options, + p_vout->p_cfg ); + /* Look what method was requested */ - p_vout->p_sys->i_col = config_GetInt( p_vout, "panoramix-cols" ); - p_vout->p_sys->i_row = config_GetInt( p_vout, "panoramix-rows" ); + p_vout->p_sys->i_col = var_CreateGetInteger( p_vout, CFG_PREFIX "cols" ); + p_vout->p_sys->i_row = var_CreateGetInteger( p_vout, CFG_PREFIX "rows" ); -// OS dependant code : Autodetect number of displays in wall +// OS dependent code : Autodetect number of displays in wall #ifdef SYS_MINGW32 if ((p_vout->p_sys->i_col < 0) || (p_vout->p_sys->i_row < 0) ) { @@ -362,40 +378,41 @@ case VLC_FOURCC('c','y','u','v'): // packed by 2 p_vout->p_sys->i_row = 1; } } - config_PutInt( p_vout, "panoramix-cols", p_vout->p_sys->i_col); - config_PutInt( p_vout, "panoramix-rows", p_vout->p_sys->i_row); + var_SetInteger( p_vout, CFG_PREFIX "cols", p_vout->p_sys->i_col); + var_SetInteger( p_vout, CFG_PREFIX "rows", p_vout->p_sys->i_row); } #endif #ifdef OVERLAP - p_vout->p_sys->i_offset_x = config_GetInt( p_vout, "offset-x" ); + p_vout->p_sys->i_offset_x = var_CreateGetInteger( p_vout, CFG_PREFIX "offset-x" ); if (p_vout->p_sys->i_col > 2) p_vout->p_sys->i_offset_x = 0; // offset-x is used in case of 2x1 wall & autocrop - p_vout->p_sys->b_autocrop = !(config_GetInt( p_vout, "ratio" ) == 0); - if (!p_vout->p_sys->b_autocrop) p_vout->p_sys->b_autocrop = config_GetInt( p_vout, "autocrop" ); - p_vout->p_sys->b_attenuate = config_GetInt( p_vout, "panoramix-attenuate"); - p_vout->p_sys->bz_length = config_GetInt( p_vout, "bz-length" ); + p_vout->p_sys->b_autocrop = !(var_CreateGetInteger( p_vout, "crop-ratio" ) == 0); + if (!p_vout->p_sys->b_autocrop) p_vout->p_sys->b_autocrop = var_CreateGetInteger( p_vout, "autocrop" ); + p_vout->p_sys->b_attenuate = var_CreateGetInteger( p_vout, CFG_PREFIX "attenuate"); + p_vout->p_sys->bz_length = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-length" ); if (p_vout->p_sys->i_row > 1) - p_vout->p_sys->bz_height = config_GetInt( p_vout, "bz-height" ); + p_vout->p_sys->bz_height = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-height" ); else p_vout->p_sys->bz_height = 100; - p_vout->p_sys->bz_begin = config_GetInt( p_vout, "bz-begin" ); - p_vout->p_sys->bz_middle = config_GetInt( p_vout, "bz-middle" ); - p_vout->p_sys->bz_end = config_GetInt( p_vout, "bz-end" ); - p_vout->p_sys->bz_middle_pos = config_GetInt( p_vout, "bz-middle-pos" ); + p_vout->p_sys->bz_begin = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-begin" ); + p_vout->p_sys->bz_middle = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-middle" ); + p_vout->p_sys->bz_end = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-end" ); + p_vout->p_sys->bz_middle_pos = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-middle-pos" ); double d_p = 100.0 / p_vout->p_sys->bz_middle_pos; - p_vout->p_sys->i_ratio_max = config_GetInt( p_vout, "ratio-max" ); // in crop module with autocrop ... - p_vout->p_sys->i_ratio = config_GetInt( p_vout, "ratio" ); // in crop module with manual ratio ... + p_vout->p_sys->i_ratio_max = var_CreateGetInteger( p_vout, "autocrop-ratio-max" ); // in crop module with autocrop ... + p_vout->p_sys->i_ratio = var_CreateGetInteger( p_vout, "crop-ratio" ); // in crop module with manual ratio ... + p_vout->p_sys->a_2 = d_p * p_vout->p_sys->bz_begin - (double)(d_p * d_p / (d_p - 1)) * p_vout->p_sys->bz_middle + (double)(d_p / (d_p - 1)) * p_vout->p_sys->bz_end; p_vout->p_sys->a_1 = -(d_p + 1) * p_vout->p_sys->bz_begin + (double)(d_p * d_p / (d_p - 1)) * p_vout->p_sys->bz_middle - (double)(1 / (d_p - 1)) * p_vout->p_sys->bz_end; p_vout->p_sys->a_0 = p_vout->p_sys->bz_begin; #ifdef GAMMA - p_vout->p_sys->f_gamma_red = config_GetFloat( p_vout, "bz-gamma-red" ); - p_vout->p_sys->f_gamma_green = config_GetFloat( p_vout, "bz-gamma-green" ); - p_vout->p_sys->f_gamma_blue = config_GetFloat( p_vout, "bz-gamma-blue" ); + p_vout->p_sys->f_gamma_red = var_CreateGetFloat( p_vout, CFG_PREFIX "bz-gamma-red" ); + p_vout->p_sys->f_gamma_green = var_CreateGetFloat( p_vout, CFG_PREFIX "bz-gamma-green" ); + p_vout->p_sys->f_gamma_blue = var_CreateGetFloat( p_vout, CFG_PREFIX "bz-gamma-blue" ); #endif -#ifdef SYS_LINUX - p_vout->p_sys->b_xinerama= config_GetInt( p_vout, "xinerama" ); +#ifndef SYS_MINGW32 + p_vout->p_sys->b_xinerama= var_CreateGetInteger( p_vout, CFG_PREFIX "xinerama" ); #endif #else p_vout->p_sys->i_col = __MAX( 1, __MIN( 15, p_vout->p_sys->i_col ) ); @@ -410,12 +427,12 @@ case VLC_FOURCC('c','y','u','v'): // packed by 2 sizeof(struct vout_list_t) ); if( p_vout->p_sys->pp_vout == NULL ) { - msg_Err( p_vout, "out of memory" ); free( p_vout->p_sys ); return VLC_ENOMEM; } - psz_method_tmp = psz_method = config_GetPsz( p_vout, "wall-active" ); + psz_method_tmp = + psz_method = var_CreateGetNonEmptyString( p_vout, CFG_PREFIX "active" ); /* If no trailing vout are specified, take them all */ if( psz_method == NULL ) @@ -470,10 +487,19 @@ case VLC_FOURCC('c','y','u','v'): // packed by 2 #ifdef OVERLAP +/***************************************************************************** + * CLIP_0A: clip between 0 and ACCURACY + *****************************************************************************/ +inline static int CLIP_0A( int a ) +{ + return (a > ACCURACY) ? ACCURACY : (a < 0) ? 0 : a; +} + +#ifdef GAMMA /***************************************************************************** * Gamma: Gamma correction *****************************************************************************/ -double Gamma_Correction(int i_plane, float f_component, float f_BlackCrush[VOUT_MAX_PLANES], float f_WhiteCrush[VOUT_MAX_PLANES], float f_BlackLevel[VOUT_MAX_PLANES], float f_WhiteLevel[VOUT_MAX_PLANES], float f_Gamma[VOUT_MAX_PLANES]) +static double Gamma_Correction(int i_plane, float f_component, float f_BlackCrush[VOUT_MAX_PLANES], float f_WhiteCrush[VOUT_MAX_PLANES], float f_BlackLevel[VOUT_MAX_PLANES], float f_WhiteLevel[VOUT_MAX_PLANES], float f_Gamma[VOUT_MAX_PLANES]) { float f_Input; @@ -489,23 +515,7 @@ double Gamma_Correction(int i_plane, float f_component, float f_BlackCrush[VOUT_ return 1.0; } -#ifdef GAMMA -/***************************************************************************** - * CLIP_0A: clip between 0 and ACCURACY - *****************************************************************************/ -inline static int CLIP_0A( int a ) -{ - return (a > ACCURACY) ? ACCURACY : (a < 0) ? 0 : a; -} - #ifdef PACKED_YUV -/***************************************************************************** - * Clip: clip an 32 bits int in 8 bits - *****************************************************************************/ -inline static int32_t clip( int32_t a ) -{ - return (a > 255) ? 255 : (a < 0) ? 0 : a; -} /***************************************************************************** * F: Function to calculate Gamma correction @@ -517,9 +527,9 @@ static uint8_t F(uint8_t i, float gamma) // return clip(255 * pow(input, 1.0 / gamma)); if (input < 0.5) - return clip((255 * pow(2 * input, gamma)) / 2); + return clip_uint8((255 * pow(2 * input, gamma)) / 2); else - return clip(255 * (1 - pow(2 * (1 - input), gamma) / 2)); + return clip_uint8(255 * (1 - pow(2 * (1 - input), gamma) / 2)); } #endif @@ -530,7 +540,7 @@ static uint8_t F(uint8_t i, float gamma) *****************************************************************************/ static int AdjustHeight( vout_thread_t *p_vout ) { - vlc_bool_t b_fullscreen = config_GetInt( p_vout, "fullscreen" ); + bool b_fullscreen = var_CreateGetInteger( p_vout, "fullscreen" ); int i_window_width = p_vout->i_window_width; int i_window_height = p_vout->i_window_height; double d_halfLength = 0; @@ -538,33 +548,27 @@ static int AdjustHeight( vout_thread_t *p_vout ) double d_halfLength_calculated; int i_offset = 0; -// OS DEPENDANT CODE to get display dimensions +// OS DEPENDENT CODE to get display dimensions if (b_fullscreen) { -#ifdef SYS_LINUX - Display *p_display = XOpenDisplay( "" ); - if (p_vout->p_sys->b_xinerama) - if (p_vout->p_sys->i_row == 2) - { - i_window_width = DisplayWidth(p_display, 0) / 2; - i_window_height = DisplayHeight(p_display, 0) /2; - } - else // p_vout->p_sys->i_row == 1 - { - i_window_width = DisplayWidth(p_display, 0) / 2; - i_window_height = DisplayHeight(p_display, 0); - } - else - { - i_window_width = DisplayWidth(p_display, 0); - i_window_height = DisplayHeight(p_display, 0); - } -#elif SYS_MINGW32 +#ifdef SYS_MINGW32 i_window_width = GetSystemMetrics(SM_CXSCREEN); i_window_height = GetSystemMetrics(SM_CYSCREEN); +#else + Display *p_display = XOpenDisplay( "" ); + if (p_vout->p_sys->b_xinerama) + { + i_window_width = DisplayWidth(p_display, 0) / p_vout->p_sys->i_col; + i_window_height = DisplayHeight(p_display, 0) / p_vout->p_sys->i_row; + } + else + { + i_window_width = DisplayWidth(p_display, 0); + i_window_height = DisplayHeight(p_display, 0); + } + XCloseDisplay( p_display ); + free(p_display); #endif - config_PutInt( p_vout, "width", i_window_width); - config_PutInt( p_vout, "height", i_window_height); var_SetInteger( p_vout, "width", i_window_width); var_SetInteger( p_vout, "height", i_window_height); p_vout->i_window_width = i_window_width; @@ -594,8 +598,8 @@ static int AdjustHeight( vout_thread_t *p_vout ) } p_vout->p_sys->i_halfLength = (d_halfLength + 0.5); p_vout->p_sys->bz_length = (p_vout->p_sys->i_halfLength * 100.0 * p_vout->p_sys->i_col) / p_vout->render.i_width; - config_PutInt( p_vout, "bz-length", p_vout->p_sys->bz_length); - config_PutInt( p_vout, "panoramix-rows", p_vout->p_sys->i_row); + var_SetInteger( p_vout, "bz-length", p_vout->p_sys->bz_length); + var_SetInteger( p_vout, "panoramix-rows", p_vout->p_sys->i_row); } } else @@ -612,7 +616,7 @@ static int AdjustHeight( vout_thread_t *p_vout ) double d_bz_length = (p_vout->p_sys->i_halfLength * p_vout->p_sys->i_col * 100.0) / p_vout->render.i_width; // F(2x) != 2F(x) in opengl module if (p_vout->p_sys->i_col == 2) d_bz_length = (100.0 * d_bz_length) / (100.0 - d_bz_length) ; - config_PutInt( p_vout, "bz-length", (int)(d_bz_length + 0.5)); + var_SetInteger( p_vout, "bz-length", (int)(d_bz_length + 0.5)); } i_offset = (int)d_halfLength - (int) (p_vout->p_sys->i_halfLength * (double)i_window_height * @@ -643,6 +647,8 @@ static int Init( vout_thread_t *p_vout ) p_vout->output.i_aspect = p_vout->render.i_aspect; #ifdef OVERLAP p_vout->p_sys->b_has_changed = p_vout->p_sys->b_attenuate; + int i_video_x = var_GetInteger( p_vout, "video-x"); + int i_video_y = var_GetInteger( p_vout, "video-y"); #ifdef GAMMA if (p_vout->p_sys->b_attenuate) { @@ -652,21 +658,21 @@ static int Init( vout_thread_t *p_vout ) float f_BlackLevel[VOUT_MAX_PLANES]; float f_WhiteCrush[VOUT_MAX_PLANES]; float f_WhiteLevel[VOUT_MAX_PLANES]; - p_vout->p_sys->f_gamma[0] = config_GetFloat( p_vout, "bz-gamma-red" ); - p_vout->p_sys->f_gamma[1] = config_GetFloat( p_vout, "bz-gamma-green" ); - p_vout->p_sys->f_gamma[2] = config_GetFloat( p_vout, "bz-gamma-blue" ); - f_BlackCrush[0] = (float)config_GetInt( p_vout, "bz-blackcrush-red" ) / 255.0; - f_BlackCrush[1] = (float)config_GetInt( p_vout, "bz-blackcrush-green" ) / 255.0; - f_BlackCrush[2] = (float)config_GetInt( p_vout, "bz-blackcrush-blue" ) / 255.0; - f_WhiteCrush[0] = (float)config_GetInt( p_vout, "bz-whitecrush-red" ) / 255.0; - f_WhiteCrush[1] = (float)config_GetInt( p_vout, "bz-whitecrush-green" ) / 255.0; - f_WhiteCrush[2] = (float)config_GetInt( p_vout, "bz-whitecrush-blue" ) / 255.0; - f_BlackLevel[0] = (float)config_GetInt( p_vout, "bz-blacklevel-red" ) / 255.0; - f_BlackLevel[1] = (float)config_GetInt( p_vout, "bz-blacklevel-green" ) / 255.0; - f_BlackLevel[2] = (float)config_GetInt( p_vout, "bz-blacklevel-blue" ) / 255.0; - f_WhiteLevel[0] = (float)config_GetInt( p_vout, "bz-whitelevel-red" ) / 255.0; - f_WhiteLevel[1] = (float)config_GetInt( p_vout, "bz-whitelevel-green" ) / 255.0; - f_WhiteLevel[2] = (float)config_GetInt( p_vout, "bz-whitelevel-blue" ) / 255.0; + p_vout->p_sys->f_gamma[0] = var_CreateGetFloat( p_vout, CFG_PREFIX "bz-gamma-red" ); + p_vout->p_sys->f_gamma[1] = var_CreateGetFloat( p_vout, CFG_PREFIX "bz-gamma-green" ); + p_vout->p_sys->f_gamma[2] = var_CreateGetFloat( p_vout, CFG_PREFIX "bz-gamma-blue" ); + f_BlackCrush[0] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-blackcrush-red" ) / 255.0; + f_BlackCrush[1] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-blackcrush-green" ) / 255.0; + f_BlackCrush[2] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-blackcrush-blue" ) / 255.0; + f_WhiteCrush[0] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-whitecrush-red" ) / 255.0; + f_WhiteCrush[1] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-whitecrush-green" ) / 255.0; + f_WhiteCrush[2] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-whitecrush-blue" ) / 255.0; + f_BlackLevel[0] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-blacklevel-red" ) / 255.0; + f_BlackLevel[1] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-blacklevel-green" ) / 255.0; + f_BlackLevel[2] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-blacklevel-blue" ) / 255.0; + f_WhiteLevel[0] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-whitelevel-red" ) / 255.0; + f_WhiteLevel[1] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-whitelevel-green" ) / 255.0; + f_WhiteLevel[2] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-whitelevel-blue" ) / 255.0; switch (p_vout->render.i_chroma) { // planar YVU @@ -677,16 +683,16 @@ static int Init( vout_thread_t *p_vout ) case VLC_FOURCC('U','Y','N','V'): // packed by 2 case VLC_FOURCC('Y','4','2','2'): // packed by 2 // case VLC_FOURCC('c','y','u','v'): // packed by 2 - p_vout->p_sys->f_gamma[2] = config_GetFloat( p_vout, "bz-gamma-green" ); - p_vout->p_sys->f_gamma[1] = config_GetFloat( p_vout, "bz-gamma-blue" ); - f_BlackCrush[2] = (float)config_GetInt( p_vout, "bz-blackcrush-green" ) / 255.0; - f_BlackCrush[1] = (float)config_GetInt( p_vout, "bz-blackcrush-blue" ) / 255.0; - f_WhiteCrush[2] = (float)config_GetInt( p_vout, "bz-whitecrush-green" ) / 255.0; - f_WhiteCrush[1] = (float)config_GetInt( p_vout, "bz-whitecrush-blue" ) / 255.0; - f_BlackLevel[2] = (float)config_GetInt( p_vout, "bz-blacklevel-green" ) / 255.0; - f_BlackLevel[1] = (float)config_GetInt( p_vout, "bz-blacklevel-blue" ) / 255.0; - f_WhiteLevel[2] = (float)config_GetInt( p_vout, "bz-whitelevel-green" ) / 255.0; - f_WhiteLevel[1] = (float)config_GetInt( p_vout, "bz-whitelevel-blue" ) / 255.0; + p_vout->p_sys->f_gamma[2] = var_CreateGetFloat( p_vout, CFG_PREFIX "bz-gamma-green" ); + p_vout->p_sys->f_gamma[1] = var_CreateGetFloat( p_vout, CFG_PREFIX "bz-gamma-blue" ); + f_BlackCrush[2] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-blackcrush-green" ) / 255.0; + f_BlackCrush[1] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-blackcrush-blue" ) / 255.0; + f_WhiteCrush[2] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-whitecrush-green" ) / 255.0; + f_WhiteCrush[1] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-whitecrush-blue" ) / 255.0; + f_BlackLevel[2] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-blacklevel-green" ) / 255.0; + f_BlackLevel[1] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-blacklevel-blue" ) / 255.0; + f_WhiteLevel[2] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-whitelevel-green" ) / 255.0; + f_WhiteLevel[1] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-whitelevel-blue" ) / 255.0; // planar YUV case VLC_FOURCC('I','4','4','4'): case VLC_FOURCC('I','4','2','2'): @@ -749,6 +755,10 @@ static int Init( vout_thread_t *p_vout ) { for( i_col = 0; i_col < p_vout->p_sys->i_col; i_col++ ) { + video_format_t fmt; + + memset( &fmt, 0, sizeof(video_format_t) ); + if( i_col + 1 < p_vout->p_sys->i_col ) { i_width = ( p_vout->render.i_width @@ -797,8 +807,6 @@ static int Init( vout_thread_t *p_vout ) continue; } - video_format_t fmt = {0}; - fmt.i_width = fmt.i_visible_width = p_vout->render.i_width; fmt.i_height = fmt.i_visible_height = p_vout->render.i_height; fmt.i_x_offset = fmt.i_y_offset = 0; @@ -814,7 +822,6 @@ static int Init( vout_thread_t *p_vout ) #ifdef OVERLAP if (p_vout->p_sys->i_offset_x < 0) { - config_PutInt(p_vout, "video-x", -p_vout->p_sys->i_offset_x); var_SetInteger(p_vout, "video-x", -p_vout->p_sys->i_offset_x); p_vout->p_sys->i_offset_x = 0; } @@ -845,8 +852,8 @@ static int Init( vout_thread_t *p_vout ) int i_index, i_n = p_vout->p_sys->i_vout; for (i_index = p_vout->p_sys->i_vout; i_index >= 0; i_index--) if (!p_vout->p_sys->pp_vout[i_index].b_active) i_n -= 1; var_SetInteger( p_vout, "align", p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].p_vout->i_alignment ); - var_SetInteger( p_vout, "video-x", p_vout->p_sys->i_offset_x + ((i_n + 1) % p_vout->p_sys->i_col) * p_vout->i_window_width); - var_SetInteger( p_vout, "video-y", ((i_n + 1) / p_vout->p_sys->i_col) * p_vout->i_window_height); + var_SetInteger( p_vout, "video-x",i_video_x + p_vout->p_sys->i_offset_x + ((i_n + 1) % p_vout->p_sys->i_col) * p_vout->i_window_width); + var_SetInteger( p_vout, "video-y",i_video_y + ((i_n + 1) / p_vout->p_sys->i_col) * p_vout->i_window_height); #endif p_vout->p_sys->i_vout++; } @@ -866,15 +873,20 @@ static void End( vout_thread_t *p_vout ) { int i_index; -#ifdef OVERLAP - config_PutInt( p_vout, "bz-length", p_vout->p_sys->bz_length); -#endif + DEL_PARENT_CALLBACKS( SendEventsToChild ); + /* Free the fake output buffers we allocated */ for( i_index = I_OUTPUTPICTURES ; i_index ; ) { i_index--; free( PP_OUTPUTPICTURE[ i_index ]->p_data_orig ); } + + RemoveAllVout( p_vout ); + +#ifdef OVERLAP + var_SetInteger( p_vout, "bz-length", p_vout->p_sys->bz_length); +#endif } /***************************************************************************** @@ -886,16 +898,6 @@ static void Destroy( vlc_object_t *p_this ) { vout_thread_t *p_vout = (vout_thread_t *)p_this; -#ifdef GLOBAL_OUTPUT - DEL_CALLBACKS( p_vout->p_sys->p_vout, SendEvents); - vlc_object_detach( p_vout->p_sys->p_vout ); - vout_Destroy( p_vout->p_sys->p_vout ); - DEL_PARENT_CALLBACKS( SendEventsToChild); -#endif - - RemoveAllVout( p_vout ); - DEL_PARENT_CALLBACKS( SendEventsToChild ); - free( p_vout->p_sys->pp_vout ); free( p_vout->p_sys ); @@ -957,7 +959,7 @@ static void RenderPlanarYUV( vout_thread_t *p_vout, picture_t *p_pic ) 0, 0, 0 ) ) == NULL ) { - if( p_vout->b_die || p_vout->b_error ) + if( !vlc_object_alive (p_vout) || p_vout->b_error ) { vout_DestroyPicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout, p_outpic ); @@ -1037,17 +1039,17 @@ static void RenderPlanarYUV( vout_thread_t *p_vout, picture_t *p_pic ) while( p_in < p_in_end ) { #ifndef OVERLAP - p_vout->p_libvlc->pf_memcpy( p_out , p_in, i_copy_pitch); + vlc_memcpy( p_out, p_in, i_copy_pitch); #else if (p_vout->p_sys->i_col > 2) { length /= 2; if (i_col == 0) - p_vout->p_libvlc->pf_memcpy( p_out + length , p_in, i_copy_pitch - length); + vlc_memcpy( p_out + length , p_in, i_copy_pitch - length); else if (i_col + 1 == p_vout->p_sys->i_col) - p_vout->p_libvlc->pf_memcpy( p_out, p_in - length, i_copy_pitch - length); - else - p_vout->p_libvlc->pf_memcpy( p_out, p_in - length, i_copy_pitch); + vlc_memcpy( p_out, p_in - length, i_copy_pitch - length); + else + vlc_memcpy( p_out, p_in - length, i_copy_pitch); if ((i_col == 0)) // black bar @@ -1068,7 +1070,7 @@ static void RenderPlanarYUV( vout_thread_t *p_vout, picture_t *p_pic ) length *= 2; } else - p_vout->p_libvlc->pf_memcpy( p_out , p_in, i_copy_pitch); + vlc_memcpy( p_out , p_in, i_copy_pitch); if (p_vout->p_sys->b_attenuate) { @@ -1243,7 +1245,7 @@ static void RenderPlanarYUV( vout_thread_t *p_vout, picture_t *p_pic ) } #ifdef OVERLAP - if (p_vout->p_sys->b_has_changed) p_vout->p_sys->b_has_changed = VLC_FALSE; + if (p_vout->p_sys->b_has_changed) p_vout->p_sys->b_has_changed = false; #endif } @@ -1301,7 +1303,7 @@ static void RenderPackedRGB( vout_thread_t *p_vout, picture_t *p_pic ) 0, 0, 0 ) ) == NULL ) { - if( p_vout->b_die || p_vout->b_error ) + if( !vlc_object_alive (p_vout) || p_vout->b_error ) { vout_DestroyPicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout, p_outpic ); @@ -1380,18 +1382,18 @@ static void RenderPackedRGB( vout_thread_t *p_vout, picture_t *p_pic ) while( p_in < p_in_end ) { #ifndef OVERLAP - p_vout->p_libvlc->pf_memcpy( p_out, p_in, i_copy_pitch); + vlc_memcpy( p_out, p_in, i_copy_pitch ); #else if (p_vout->p_sys->i_col > 2) { // vertical blend length /= 2; if (i_col == 0) - p_vout->p_libvlc->pf_memcpy( p_out + length, p_in, i_copy_pitch - length); + vlc_memcpy( p_out + length, p_in, i_copy_pitch - length); else if (i_col + 1 == p_vout->p_sys->i_col) - p_vout->p_libvlc->pf_memcpy( p_out, p_in - length, i_copy_pitch - length); - else - p_vout->p_libvlc->pf_memcpy( p_out, p_in - length, i_copy_pitch); + vlc_memcpy( p_out, p_in - length, i_copy_pitch - length); + else + vlc_memcpy( p_out, p_in - length, i_copy_pitch); if ((i_col == 0)) // black bar @@ -1418,7 +1420,7 @@ static void RenderPackedRGB( vout_thread_t *p_vout, picture_t *p_pic ) length *= 2; } else - p_vout->p_libvlc->pf_memcpy( p_out, p_in, i_copy_pitch); + vlc_memcpy( p_out, p_in, i_copy_pitch); // vertical blend // first blended zone @@ -1576,7 +1578,7 @@ static void RenderPackedRGB( vout_thread_t *p_vout, picture_t *p_pic ) } } #ifdef OVERLAP - if (p_vout->p_sys->b_has_changed) p_vout->p_sys->b_has_changed = VLC_FALSE; + if (p_vout->p_sys->b_has_changed) p_vout->p_sys->b_has_changed = false; #endif } @@ -1639,7 +1641,7 @@ static void RenderPackedYUV( vout_thread_t *p_vout, picture_t *p_pic ) 0, 0, 0 ) ) == NULL ) { - if( p_vout->b_die || p_vout->b_error ) + if( !vlc_object_alive (p_vout) || p_vout->b_error ) { vout_DestroyPicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout, p_outpic ); @@ -1758,9 +1760,9 @@ static void RenderPackedYUV( vout_thread_t *p_vout, picture_t *p_pic ) while( p_in < p_in_end ) { #ifndef OVERLAP - p_vout->p_libvlc->pf_memcpy( p_out, p_in, i_copy_pitch); + vlc_memcpy( p_out, p_in, i_copy_pitch); #else - p_vout->p_libvlc->pf_memcpy( p_out + i_col * length, p_in + i_col * length, i_copy_pitch - length); + vlc_memcpy( p_out + i_col * length, p_in + i_col * length, i_copy_pitch - length); p_out += LeftOffset; p_in += LeftOffset; #ifndef GAMMA @@ -1882,7 +1884,7 @@ static void RenderPackedYUV( vout_thread_t *p_vout, picture_t *p_pic ) } } #ifdef OVERLAP - if (p_vout->p_sys->b_has_changed) p_vout->p_sys->b_has_changed = VLC_FALSE; + if (p_vout->p_sys->b_has_changed) p_vout->p_sys->b_has_changed = false; #endif } #endif @@ -1901,10 +1903,7 @@ static void RemoveAllVout( vout_thread_t *p_vout ) DEL_CALLBACKS( p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].p_vout, SendEvents ); - vlc_object_detach( - p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].p_vout ); - vout_Destroy( - p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].p_vout ); + vout_CloseAndRelease( p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].p_vout ); } } } @@ -1915,6 +1914,7 @@ static void RemoveAllVout( vout_thread_t *p_vout ) static int SendEvents( vlc_object_t *p_this, char const *psz_var, vlc_value_t oldval, vlc_value_t newval, void *_p_vout ) { + VLC_UNUSED(oldval); vout_thread_t *p_vout = (vout_thread_t *)_p_vout; int i_vout; vlc_value_t sentval = newval; @@ -1970,7 +1970,7 @@ static int SendEvents( vlc_object_t *p_this, char const *psz_var, static int SendEventsToChild( vlc_object_t *p_this, char const *psz_var, vlc_value_t oldval, vlc_value_t newval, void *p_data ) { - + VLC_UNUSED(oldval); VLC_UNUSED(p_data); vout_thread_t *p_vout = (vout_thread_t *)p_this; int i_row, i_col, i_vout = 0;