Commit febe7d21 authored by zorglub's avatar zorglub
Browse files

Panoramix video filter by Cédric Cocquebert.

+ temporarily re-enable vout-filter until video-filter is updated

I include this so that it can get some testing and debugging, but it has some issues:
* Several coding style / indentation problems that make the code quite hard to read
* Use of config_Get/config_Put instead of vars
* In my tests, it crashes as soon as bz-length is not == 0, which basically makes the attenuation effect inoperant
parent 64220f44
......@@ -34,7 +34,7 @@ Brieuc Jeunhomme <bbp at via.ecp.fr> - bug fixes
Bruno Vella <allevb at tin.it> - Italian localization
Carlo Calabrò <murray at via.ecp.fr> - Italian localization
Carsten Gottbehüt <gottbehuet at active-elements dot de> - v4l hotplug fix
Cédric Cocquebert - Misc opengl effects for the OpenGL Video Output
Cédric Cocquebert - Misc opengl effects for the OpenGL Video Output. "Panoramix" video filter for image walls with automatic attenuation
Chris Clepper - OpenGL fix
Christian Henz - libupnp service discovery plugin, CyberLink UPnP fixes
Christof Baumgaertner - dbox web intf
......
......@@ -561,7 +561,7 @@ AM_CONDITIONAL(BUILD_GETOPT, ${need_getopt})
if test "${SYS}" != "mingw32" -a "${SYS}" != "mingwce"; then
AC_TYPE_SIGNAL
AC_CHECK_LIB(m,cos,[
VLC_ADD_LDFLAGS([adjust wave ripple psychedelic gradient a52tofloat32 dtstofloat32 x264 goom visual],[-lm])
VLC_ADD_LDFLAGS([adjust wave ripple psychedelic gradient a52tofloat32 dtstofloat32 x264 goom visual panoramix],[-lm])
])
AC_CHECK_LIB(m,pow,[
VLC_ADD_LDFLAGS([ffmpeg ffmpegaltivec stream_out_transrate i420_rgb faad twolame equalizer param_eq vlc freetype mpc dmo quicktime realaudio galaktos],[-lm])
......@@ -3594,9 +3594,9 @@ if test "${enable_x11}" != "no" &&
test "${enable_x11}" = "yes"); then
CPPFLAGS="${CPPFLAGS_save} ${X_FLAGS}"
AC_CHECK_HEADERS(X11/Xlib.h, [
VLC_ADD_PLUGINS([x11])
VLC_ADD_LDFLAGS([x11],[${X_LIBS} ${X_PRE_LIBS} -lX11 -lXext])
VLC_ADD_CPPFLAGS([x11],[${X_CFLAGS}])
VLC_ADD_PLUGINS([x11 panoramix])
VLC_ADD_LDFLAGS([x11 panoramix],[${X_LIBS} ${X_PRE_LIBS} -lX11 -lXext])
VLC_ADD_CPPFLAGS([x11 panoramix],[${X_CFLAGS}])
])
CPPFLAGS="${CPPFLAGS_save}"
fi
......@@ -4032,6 +4032,12 @@ fi
dnl
dnl Windows DirectX module
dnl
if test "${SYS}" = "mingw32" -o "${SYS}" = "mingwce" -o "${SYS}" = "cygwin"
then
VLC_ADD_PLUGINS([panoramix])
fi
AC_ARG_ENABLE(directx,
[ --enable-directx Win32 DirectX support (default enabled on Win32)])
if test "${enable_directx}" != "no"
......
......@@ -20,6 +20,7 @@ SOURCES_wave = wave.c
SOURCES_ripple = ripple.c
SOURCES_psychedelic = psychedelic.c
SOURCES_gradient = gradient.c
SOURCES_panoramix = panoramix.c
SOURCES_opencv_wrapper = opencv_wrapper.c
SOURCES_opencv_example = opencv_example.cpp filter_event_info.h
noinst_HEADERS = filter_common.h
/*****************************************************************************
* 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 $
*
* Authors: Cedric Cocquebert <cedric.cocquebert@supelec.fr>
* based on Samuel Hocevar <sam@zoy.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <stdlib.h> /* malloc(), free() */
#include <string.h>
#include <vlc/vlc.h>
#include <vlc/vout.h>
#include "filter_common.h"
// add by cedric.cocquebert@supelec.fr
#define OVERLAP 2350
#ifdef OVERLAP
#include <math.h>
// OS CODE DEPENDANT to get display dimensions
#ifdef SYS_LINUX
#include <X11/Xlib.h>
#else
#ifdef SYS_MINGW32
#include <windows.h>
#endif
#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 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))
#endif
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static int Create ( vlc_object_t * );
static void Destroy ( vlc_object_t * );
static int Init ( vout_thread_t * );
static void End ( vout_thread_t * );
#ifdef PACKED_YUV
static void RenderPackedYUV ( vout_thread_t *, picture_t * );
#endif
static void RenderPlanarYUV ( vout_thread_t *, picture_t * );
static void RenderPackedRGB ( vout_thread_t *, picture_t * );
static void RemoveAllVout ( vout_thread_t *p_vout );
static int SendEvents( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * );
/*****************************************************************************
* Module descriptor
*****************************************************************************/
#define COLS_TEXT N_("Number of columns")
#define COLS_LONGTEXT N_("Select the number of horizontal video windows in " \
"which to split the video")
#define ROWS_TEXT N_("Number of rows")
#define ROWS_LONGTEXT N_("Select the number of vertical video windows in " \
"which to split the video")
#define ACTIVE_TEXT N_("Active windows")
#define ACTIVE_LONGTEXT N_("Comma separated list of active windows, " \
"defaults to all")
vlc_module_begin();
set_description( _("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 );
#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 );
#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 );
#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 );
#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 );
#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 );
#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 );
#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 );
#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 );
#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 );
#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 );
#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 );
#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)")
#define GGAMMA_BC_TEXT N_("Black Crush for Green")
#define GGAMMA_BC_LONGTEXT N_("Select the Black Crush of blended zone (Green or U component)")
#define BGAMMA_BC_TEXT N_("Black Crush for Blue")
#define BGAMMA_BC_LONGTEXT N_("Select the Black Crush of blended zone (Blue or V component)")
#define RGAMMA_WC_TEXT N_("White Crush for Red")
#define RGAMMA_WC_LONGTEXT N_("Select the White Crush of blended zone (Red or Y component)")
#define GGAMMA_WC_TEXT N_("White Crush for Green")
#define GGAMMA_WC_LONGTEXT N_("Select the White Crush of blended zone (Green or U component)")
#define BGAMMA_WC_TEXT N_("White Crush for Blue")
#define BGAMMA_WC_LONGTEXT N_("Select the White Crush of blended zone (Blue or V component)")
#define RGAMMA_BL_TEXT N_("Black Level for Red")
#define RGAMMA_BL_LONGTEXT N_("Select the Black Level of blended zone (Red or Y component)")
#define GGAMMA_BL_TEXT N_("Black Level for Green")
#define GGAMMA_BL_LONGTEXT N_("Select the Black Level of blended zone (Green or U component)")
#define BGAMMA_BL_TEXT N_("Black Level for Blue")
#define BGAMMA_BL_LONGTEXT N_("Select the Black Level of blended zone (Blue or V component)")
#define RGAMMA_WL_TEXT N_("White Level for Red")
#define RGAMMA_WL_LONGTEXT N_("Select the White Level of blended zone (Red or Y component)")
#define GGAMMA_WL_TEXT N_("White Level for Green")
#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
#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 );
#endif
#endif
add_string( "wall-active", NULL, NULL, ACTIVE_TEXT, ACTIVE_LONGTEXT, VLC_TRUE );
add_shortcut( "panoramix" );
set_callbacks( Create, Destroy );
vlc_module_end();
/*****************************************************************************
* vout_sys_t: Wall video output method descriptor
*****************************************************************************
* This structure is part of the video output thread descriptor.
* It describes the Wall specific properties of an output thread.
*****************************************************************************/
struct vout_sys_t
{
#ifdef OVERLAP
vlc_bool_t b_autocrop;
vlc_bool_t 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;
int lambda[2][VOUT_MAX_PLANES][500];
int cstYUV[2][VOUT_MAX_PLANES][500];
int lambda2[2][VOUT_MAX_PLANES][500];
int cstYUV2[2][VOUT_MAX_PLANES][500];
unsigned int i_halfLength;
unsigned int i_halfHeight;
int i_offset_x;
int i_offset_y;
#ifdef GAMMA
float f_gamma_red, f_gamma_green, f_gamma_blue;
float f_gamma[VOUT_MAX_PLANES];
uint8_t LUT[VOUT_MAX_PLANES][ACCURACY + 1][256];
#ifdef PACKED_YUV
uint8_t LUT2[VOUT_MAX_PLANES][256][500];
#endif
#endif
#ifdef SYS_LINUX
vlc_bool_t b_xinerama;
#endif
#endif
int i_col;
int i_row;
int i_vout;
struct vout_list_t
{
vlc_bool_t b_active;
int i_width;
int i_height;
vout_thread_t *p_vout;
} *pp_vout;
};
/*****************************************************************************
* Control: control facility for the vout (forwards to child vout)
*****************************************************************************/
static int Control( vout_thread_t *p_vout, int i_query, va_list args )
{
int i_row, i_col, i_vout = 0;
for( i_row = 0; i_row < p_vout->p_sys->i_row; i_row++ )
{
for( i_col = 0; i_col < p_vout->p_sys->i_col; i_col++ )
{
vout_vaControl( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
i_query, args );
i_vout++;
}
}
return VLC_SUCCESS;
}
/*****************************************************************************
* Create: allocates Wall video thread output method
*****************************************************************************
* This function allocates and initializes a Wall vout method.
*****************************************************************************/
static int Create( vlc_object_t *p_this )
{
vout_thread_t *p_vout = (vout_thread_t *)p_this;
char *psz_method, *psz_tmp, *psz_method_tmp;
int i_vout;
/* 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;
p_vout->pf_manage = NULL;
/* Color Format not supported
// Planar Y, packed UV
case VLC_FOURCC('Y','M','G','A'):
// Packed YUV 4:2:2, U:Y:V:Y, interlaced
case VLC_FOURCC('I','U','Y','V'): // packed by 2
// Packed YUV 2:1:1, Y:U:Y:V
case VLC_FOURCC('Y','2','1','1'): // packed by 4
// Packed YUV Reverted
case VLC_FOURCC('c','y','u','v'): // packed by 2
*/
switch (p_vout->render.i_chroma)
{
// planar YUV
case VLC_FOURCC('I','4','4','4'):
case VLC_FOURCC('I','4','2','2'):
case VLC_FOURCC('I','4','2','0'):
case VLC_FOURCC('Y','V','1','2'):
case VLC_FOURCC('I','Y','U','V'):
case VLC_FOURCC('I','4','1','1'):
case VLC_FOURCC('I','4','1','0'):
case VLC_FOURCC('Y','V','U','9'):
case VLC_FOURCC('Y','U','V','A'):
p_vout->pf_render = RenderPlanarYUV;
break;
// packed RGB
case VLC_FOURCC('R','G','B','2'): // packed by 1
case VLC_FOURCC('R','V','1','5'): // packed by 2
case VLC_FOURCC('R','V','1','6'): // packed by 2
case VLC_FOURCC('R','V','2','4'): // packed by 3
case VLC_FOURCC('R','V','3','2'): // packed by 4
p_vout->pf_render = RenderPackedRGB;
break;
#ifdef PACKED_YUV
// packed YUV
case VLC_FOURCC('Y','U','Y','2'): // packed by 2
case VLC_FOURCC('Y','U','N','V'): // packed by 2
case VLC_FOURCC('U','Y','V','Y'): // packed by 2
case VLC_FOURCC('U','Y','N','V'): // packed by 2
case VLC_FOURCC('Y','4','2','2'): // packed by 2
p_vout->pf_render = RenderPackedYUV;
break;
#endif
default:
msg_Err( p_vout, "colorspace not supported by plug-in !!!");
free( p_vout->p_sys );
return VLC_ENOMEM;
}
p_vout->pf_display = NULL;
p_vout->pf_control = Control;
/* 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" );
// OS dependant 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) )
{
int nbMonitors = GetSystemMetrics(SM_CMONITORS);
if (nbMonitors == 1)
{
nbMonitors = 5; // 1 display => 5x1 simulation
p_vout->p_sys->i_col = nbMonitors;
p_vout->p_sys->i_row = 1;
}
else
{
p_vout->p_sys->i_col = GetSystemMetrics( SM_CXVIRTUALSCREEN ) / GetSystemMetrics( SM_CXSCREEN );
p_vout->p_sys->i_row = GetSystemMetrics( SM_CYVIRTUALSCREEN ) / GetSystemMetrics( SM_CYSCREEN );
if (p_vout->p_sys->i_col * p_vout->p_sys->i_row != nbMonitors)
{
p_vout->p_sys->i_col = nbMonitors;
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);
}
#endif
#ifdef OVERLAP
p_vout->p_sys->i_offset_x = config_GetInt( p_vout, "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" );
if (p_vout->p_sys->i_row > 1)
p_vout->p_sys->bz_height = config_GetInt( p_vout, "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" );
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->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" );
#endif
#ifdef SYS_LINUX
p_vout->p_sys->b_xinerama= config_GetInt( p_vout, "xinerama" );
#endif
#else
p_vout->p_sys->i_col = __MAX( 1, __MIN( 15, p_vout->p_sys->i_col ) );
p_vout->p_sys->i_row = __MAX( 1, __MIN( 15, p_vout->p_sys->i_row ) );
#endif
msg_Dbg( p_vout, "opening a %i x %i wall",
p_vout->p_sys->i_col, p_vout->p_sys->i_row );
p_vout->p_sys->pp_vout = malloc( p_vout->p_sys->i_row *
p_vout->p_sys->i_col *
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" );
/* If no trailing vout are specified, take them all */
if( psz_method == NULL )
{
for( i_vout = p_vout->p_sys->i_row * p_vout->p_sys->i_col;
i_vout--; )
{
p_vout->p_sys->pp_vout[i_vout].b_active = 1;
}
}
/* If trailing vout are specified, activate only the requested ones */
else
{
for( i_vout = p_vout->p_sys->i_row * p_vout->p_sys->i_col;
i_vout--; )
{
p_vout->p_sys->pp_vout[i_vout].b_active = 0;
}
while( *psz_method )
{
psz_tmp = psz_method;
while( *psz_tmp && *psz_tmp != ',' )
{
psz_tmp++;
}
if( *psz_tmp )
{
*psz_tmp = '\0';
i_vout = atoi( psz_method );
psz_method = psz_tmp + 1;
}
else
{
i_vout = atoi( psz_method );
psz_method = psz_tmp;
}
if( i_vout >= 0 &&
i_vout < p_vout->p_sys->i_row * p_vout->p_sys->i_col )
{
p_vout->p_sys->pp_vout[i_vout].b_active = 1;
}
}
}
free( psz_method_tmp );
return VLC_SUCCESS;
}
#ifdef OVERLAP
/*****************************************************************************
* 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])
{
float f_Input;
f_Input = (f_component * f_BlackLevel[i_plane]) / (f_BlackCrush[i_plane]) + (1.0 - f_BlackLevel[i_plane]);
if (f_component <= f_BlackCrush[i_plane])
return pow(f_Input, 1.0 / f_Gamma[i_plane]);
else if (f_component >= f_WhiteCrush[i_plane])
{
f_Input = (f_component * (1.0 - (f_WhiteLevel[i_plane] + 1.0)) + (f_WhiteLevel[i_plane] + 1.0) * f_WhiteCrush[i_plane] - 1.0) / (f_WhiteCrush[i_plane] - 1.0);
return pow(f_Input, 1.0 / f_Gamma[i_plane]);
}
else
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
*****************************************************************************/
static uint8_t F(uint8_t i, float gamma)
{
double input = (double) i / 255.0;
// return clip(255 * pow(input, 1.0 / gamma));
if (input < 0.5)
return clip((255 * pow(2 * input, gamma)) / 2);
else
return clip(255 * (1 - pow(2 * (1 - input), gamma) / 2));
}
#endif
#endif
/*****************************************************************************
* AdjustHeight: ajust p_sys->i_height to have same BZ width for any ratio
*****************************************************************************/
static int AdjustHeight( vout_thread_t *p_vout )
{
vlc_bool_t b_fullscreen = config_GetInt( 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;
double d_halfLength_crop;
double d_halfLength_calculated;
int i_offset = 0;
// OS DEPENDANT 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;