1 /*****************************************************************************
2 * panoramix.c : Wall panoramic video with edge blending plugin for vlc
3 *****************************************************************************
4 * Copyright (C) 2000, 2001, 2002, 2003 VideoLAN
5 * $Id: panoramix.c 2006-08-29 16:20:15Z ced $
7 * Authors: Cedric Cocquebert <cedric.cocquebert@supelec.fr>
8 * based on Samuel Hocevar <sam@zoy.org>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
23 *****************************************************************************/
25 /*****************************************************************************
27 *****************************************************************************/
32 #include "filter_common.h"
34 // add by cedric.cocquebert@supelec.fr
38 // OS CODE DEPENDANT to get display dimensions
45 // #define PACKED_YUV 1
46 #define F2(a) ((a)*(a))
47 #define F4(a,b,x) ((a)*(F2(x))+((b)*(x)))
49 #define RATIO_MAX 2500
50 #define CLIP_01(a) (a < 0.0 ? 0.0 : (a > 1.0 ? 1.0 : a))
51 // #define CLIP_0A(a) (a < 0.0 ? 0.0 : (a > ACCURACY ? ACCURACY : a))
54 /*****************************************************************************
56 *****************************************************************************/
57 static int Create ( vlc_object_t * );
58 static void Destroy ( vlc_object_t * );
60 static int Init ( vout_thread_t * );
61 static void End ( vout_thread_t * );
63 static void RenderPackedYUV ( vout_thread_t *, picture_t * );
65 static void RenderPlanarYUV ( vout_thread_t *, picture_t * );
66 static void RenderPackedRGB ( vout_thread_t *, picture_t * );
68 static void RemoveAllVout ( vout_thread_t *p_vout );
70 static int SendEvents( vlc_object_t *, char const *,
71 vlc_value_t, vlc_value_t, void * );
73 /*****************************************************************************
75 *****************************************************************************/
76 #define COLS_TEXT N_("Number of columns")
77 #define COLS_LONGTEXT N_("Select the number of horizontal video windows in " \
78 "which to split the video")
80 #define ROWS_TEXT N_("Number of rows")
81 #define ROWS_LONGTEXT N_("Select the number of vertical video windows in " \
82 "which to split the video")
84 #define ACTIVE_TEXT N_("Active windows")
85 #define ACTIVE_LONGTEXT N_("Comma separated list of active windows, " \
88 #define CFG_PREFIX "panoramix-"
91 set_description( N_("Panoramix: wall with overlap video filter") );
92 set_shortname( _("Panoramix" ));
93 set_capability( "video filter", 0 );
94 set_category( CAT_VIDEO );
95 set_subcategory( SUBCAT_VIDEO_VFILTER );
97 add_integer( CFG_PREFIX "cols", -1, NULL,
98 COLS_TEXT, COLS_LONGTEXT, VLC_TRUE );
99 add_integer( CFG_PREFIX "rows", -1, NULL,
100 ROWS_TEXT, ROWS_LONGTEXT, VLC_TRUE );
103 #define OFFSET_X_TEXT N_("Offset X offset (automatic compensation)")
104 #define OFFSET_X_LONGTEXT N_("Select if you want an automatic offset in horizontal (in case of misalignment due to autoratio control)")
105 add_bool( CFG_PREFIX "offset-x", 1, NULL, OFFSET_X_TEXT, OFFSET_X_LONGTEXT, VLC_TRUE );
107 #define LENGTH_TEXT N_("length of the overlapping area (in %)")
108 #define LENGTH_LONGTEXT N_("Select in percent the length of the blended zone")
109 add_integer_with_range( CFG_PREFIX "bz-length", 100, 0, 100, NULL, LENGTH_TEXT, LENGTH_LONGTEXT, VLC_TRUE );
111 #define HEIGHT_TEXT N_("height of the overlapping area (in %)")
112 #define HEIGHT_LONGTEXT N_("Select in percent the height of the blended zone (case of 2x2 wall)")
113 add_integer_with_range( CFG_PREFIX "bz-height", 100, 0, 100, NULL, HEIGHT_TEXT, HEIGHT_LONGTEXT, VLC_TRUE );
115 #define ATTENUATION_TEXT N_("Attenuation")
116 #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)")
117 add_bool( CFG_PREFIX "attenuate", 1, NULL, ATTENUATION_TEXT, ATTENUATION_LONGTEXT, VLC_FALSE );
119 #define BEGIN_TEXT N_("Attenuation, begin (in %)")
120 #define BEGIN_LONGTEXT N_("Select in percent the Lagrange coeff of the beginning blended zone")
121 add_integer_with_range( CFG_PREFIX "bz-begin", 0, 0, 100, NULL, BEGIN_TEXT, BEGIN_LONGTEXT, VLC_TRUE );
123 #define MIDDLE_TEXT N_("Attenuation, middle (in %)")
124 #define MIDDLE_LONGTEXT N_("Select in percent the Lagrange coeff of the middle of blended zone")
125 add_integer_with_range( CFG_PREFIX "bz-middle", 50, 0, 100, NULL, MIDDLE_TEXT, MIDDLE_LONGTEXT, VLC_FALSE );
127 #define END_TEXT N_("Attenuation, end (in %)")
128 #define END_LONGTEXT N_("Select in percent the Lagrange coeff of the end of blended zone")
129 add_integer_with_range( CFG_PREFIX "bz-end", 100, 0, 100, NULL, END_TEXT, END_LONGTEXT, VLC_TRUE );
131 #define MIDDLE_POS_TEXT N_("middle position (in %)")
132 #define MIDDLE_POS_LONGTEXT N_("Select in percent (50 is center) the position of the middle point (Lagrange) of blended zone")
133 add_integer_with_range( CFG_PREFIX "bz-middle-pos", 50, 1, 99, NULL, MIDDLE_POS_TEXT, MIDDLE_POS_LONGTEXT, VLC_FALSE );
135 #define RGAMMA_TEXT N_("Gamma (Red) correction")
136 #define RGAMMA_LONGTEXT N_("Select the gamma for the correction of blended zone (Red or Y component)")
137 add_float_with_range( CFG_PREFIX "bz-gamma-red", 1, 0, 5, NULL, RGAMMA_TEXT, RGAMMA_LONGTEXT, VLC_TRUE );
139 #define GGAMMA_TEXT N_("Gamma (Green) correction")
140 #define GGAMMA_LONGTEXT N_("Select the gamma for the correction of blended zone (Green or U component)")
141 add_float_with_range( CFG_PREFIX "bz-gamma-green", 1, 0, 5, NULL, GGAMMA_TEXT, GGAMMA_LONGTEXT, VLC_TRUE );
143 #define BGAMMA_TEXT N_("Gamma (Blue) correction")
144 #define BGAMMA_LONGTEXT N_("Select the gamma for the correction of blended zone (Blue or V component)")
145 add_float_with_range( CFG_PREFIX "bz-gamma-blue", 1, 0, 5, NULL, BGAMMA_TEXT, BGAMMA_LONGTEXT, VLC_TRUE );
147 #define RGAMMA_BC_TEXT N_("Black Crush for Red")
148 #define RGAMMA_BC_LONGTEXT N_("Select the Black Crush of blended zone (Red or Y component)")
149 #define GGAMMA_BC_TEXT N_("Black Crush for Green")
150 #define GGAMMA_BC_LONGTEXT N_("Select the Black Crush of blended zone (Green or U component)")
151 #define BGAMMA_BC_TEXT N_("Black Crush for Blue")
152 #define BGAMMA_BC_LONGTEXT N_("Select the Black Crush of blended zone (Blue or V component)")
154 #define RGAMMA_WC_TEXT N_("White Crush for Red")
155 #define RGAMMA_WC_LONGTEXT N_("Select the White Crush of blended zone (Red or Y component)")
156 #define GGAMMA_WC_TEXT N_("White Crush for Green")
157 #define GGAMMA_WC_LONGTEXT N_("Select the White Crush of blended zone (Green or U component)")
158 #define BGAMMA_WC_TEXT N_("White Crush for Blue")
159 #define BGAMMA_WC_LONGTEXT N_("Select the White Crush of blended zone (Blue or V component)")
161 #define RGAMMA_BL_TEXT N_("Black Level for Red")
162 #define RGAMMA_BL_LONGTEXT N_("Select the Black Level of blended zone (Red or Y component)")
163 #define GGAMMA_BL_TEXT N_("Black Level for Green")
164 #define GGAMMA_BL_LONGTEXT N_("Select the Black Level of blended zone (Green or U component)")
165 #define BGAMMA_BL_TEXT N_("Black Level for Blue")
166 #define BGAMMA_BL_LONGTEXT N_("Select the Black Level of blended zone (Blue or V component)")
168 #define RGAMMA_WL_TEXT N_("White Level for Red")
169 #define RGAMMA_WL_LONGTEXT N_("Select the White Level of blended zone (Red or Y component)")
170 #define GGAMMA_WL_TEXT N_("White Level for Green")
171 #define GGAMMA_WL_LONGTEXT N_("Select the White Level of blended zone (Green or U component)")
172 #define BGAMMA_WL_TEXT N_("White Level for Blue")
173 #define BGAMMA_WL_LONGTEXT N_("Select the White Level of blended zone (Blue or V component)")
174 add_integer_with_range( CFG_PREFIX "bz-blackcrush-red", 140, 0, 255, NULL, RGAMMA_BC_TEXT, RGAMMA_BC_LONGTEXT, VLC_TRUE );
175 add_integer_with_range( CFG_PREFIX "bz-blackcrush-green", 140, 0, 255, NULL, GGAMMA_BC_TEXT, GGAMMA_BC_LONGTEXT, VLC_TRUE );
176 add_integer_with_range( CFG_PREFIX "bz-blackcrush-blue", 140, 0, 255, NULL, BGAMMA_BC_TEXT, BGAMMA_BC_LONGTEXT, VLC_TRUE );
177 add_integer_with_range( CFG_PREFIX "bz-whitecrush-red", 200, 0, 255, NULL, RGAMMA_WC_TEXT, RGAMMA_WC_LONGTEXT, VLC_TRUE );
178 add_integer_with_range( CFG_PREFIX "bz-whitecrush-green", 200, 0, 255, NULL, GGAMMA_WC_TEXT, GGAMMA_WC_LONGTEXT, VLC_TRUE );
179 add_integer_with_range( CFG_PREFIX "bz-whitecrush-blue", 200, 0, 255, NULL, BGAMMA_WC_TEXT, BGAMMA_WC_LONGTEXT, VLC_TRUE );
180 add_integer_with_range( CFG_PREFIX "bz-blacklevel-red", 150, 0, 255, NULL, RGAMMA_BL_TEXT, RGAMMA_BL_LONGTEXT, VLC_TRUE );
181 add_integer_with_range( CFG_PREFIX "bz-blacklevel-green", 150, 0, 255, NULL, GGAMMA_BL_TEXT, GGAMMA_BL_LONGTEXT, VLC_TRUE );
182 add_integer_with_range( CFG_PREFIX "bz-blacklevel-blue", 150, 0, 255, NULL, BGAMMA_BL_TEXT, BGAMMA_BL_LONGTEXT, VLC_TRUE );
183 add_integer_with_range( CFG_PREFIX "bz-whitelevel-red", 0, 0, 255, NULL, RGAMMA_WL_TEXT, RGAMMA_WL_LONGTEXT, VLC_TRUE );
184 add_integer_with_range( CFG_PREFIX "bz-whitelevel-green", 0, 0, 255, NULL, GGAMMA_WL_TEXT, GGAMMA_WL_LONGTEXT, VLC_TRUE );
185 add_integer_with_range( CFG_PREFIX "bz-whitelevel-blue", 0, 0, 255, NULL, BGAMMA_WL_TEXT, BGAMMA_WL_LONGTEXT, VLC_TRUE );
187 #define XINERAMA_TEXT N_("Xinerama option")
188 #define XINERAMA_LONGTEXT N_("Uncheck if you have not used xinerama")
189 add_bool( CFG_PREFIX "xinerama", 1, NULL, XINERAMA_TEXT, XINERAMA_LONGTEXT, VLC_TRUE );
193 add_string( CFG_PREFIX "active", NULL, NULL, ACTIVE_TEXT, ACTIVE_LONGTEXT, VLC_TRUE );
195 add_shortcut( "panoramix" );
196 set_callbacks( Create, Destroy );
199 static const char *ppsz_filter_options[] = {
200 "cols", "rows", "offset-x", "bz-length", "bz-height", "attenuate",
201 "bz-begin", "bz-middle", "bz-end", "bz-middle-pos", "bz-gamma-red",
202 "bz-gamma-green", "bz-gamma-blue", "bz-blackcrush-red",
203 "bz-blackcrush-green", "bz-blackcrush-blue", "bz-whitecrush-red",
204 "bz-whitecrush-green", "bz-whitecrush-blue", "bz-blacklevel-red",
205 "bz-blacklevel-green", "bz-blacklevel-blue", "bz-whitelevel-red",
206 "bz-whitelevel-green", "bz-whitelevel-blue", "xinerama", "active",
210 /*****************************************************************************
211 * vout_sys_t: Wall video output method descriptor
212 *****************************************************************************
213 * This structure is part of the video output thread descriptor.
214 * It describes the Wall specific properties of an output thread.
215 *****************************************************************************/
219 vlc_bool_t b_autocrop;
220 vlc_bool_t b_attenuate;
221 unsigned int bz_length, bz_height, bz_begin, bz_middle, bz_end, bz_middle_pos;
222 unsigned int i_ratio_max;
223 unsigned int i_ratio;
224 unsigned int a_0, a_1, a_2;
225 vlc_bool_t b_has_changed;
226 int lambda[2][VOUT_MAX_PLANES][500];
227 int cstYUV[2][VOUT_MAX_PLANES][500];
228 int lambda2[2][VOUT_MAX_PLANES][500];
229 int cstYUV2[2][VOUT_MAX_PLANES][500];
230 unsigned int i_halfLength;
231 unsigned int i_halfHeight;
235 float f_gamma_red, f_gamma_green, f_gamma_blue;
236 float f_gamma[VOUT_MAX_PLANES];
237 uint8_t LUT[VOUT_MAX_PLANES][ACCURACY + 1][256];
239 uint8_t LUT2[VOUT_MAX_PLANES][256][500];
243 vlc_bool_t b_xinerama;
254 vout_thread_t *p_vout;
260 /*****************************************************************************
261 * Control: control facility for the vout (forwards to child vout)
262 *****************************************************************************/
263 static int Control( vout_thread_t *p_vout, int i_query, va_list args )
265 int i_row, i_col, i_vout = 0;
267 for( i_row = 0; i_row < p_vout->p_sys->i_row; i_row++ )
269 for( i_col = 0; i_col < p_vout->p_sys->i_col; i_col++ )
271 vout_vaControl( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
279 /*****************************************************************************
280 * Create: allocates Wall video thread output method
281 *****************************************************************************
282 * This function allocates and initializes a Wall vout method.
283 *****************************************************************************/
284 static int Create( vlc_object_t *p_this )
286 vout_thread_t *p_vout = (vout_thread_t *)p_this;
287 char *psz_method, *psz_tmp, *psz_method_tmp;
290 /* Allocate structure */
291 p_vout->p_sys = malloc( sizeof( vout_sys_t ) );
292 if( p_vout->p_sys == NULL )
294 msg_Err( p_vout, "out of memory" );
298 p_vout->pf_init = Init;
299 p_vout->pf_end = End;
300 p_vout->pf_manage = NULL;
301 /* Color Format not supported
302 // Planar Y, packed UV
303 case VLC_FOURCC('Y','M','G','A'):
304 // Packed YUV 4:2:2, U:Y:V:Y, interlaced
305 case VLC_FOURCC('I','U','Y','V'): // packed by 2
306 // Packed YUV 2:1:1, Y:U:Y:V
307 case VLC_FOURCC('Y','2','1','1'): // packed by 4
308 // Packed YUV Reverted
309 case VLC_FOURCC('c','y','u','v'): // packed by 2
311 switch (p_vout->render.i_chroma)
314 case VLC_FOURCC('I','4','4','4'):
315 case VLC_FOURCC('I','4','2','2'):
316 case VLC_FOURCC('I','4','2','0'):
317 case VLC_FOURCC('Y','V','1','2'):
318 case VLC_FOURCC('I','Y','U','V'):
319 case VLC_FOURCC('I','4','1','1'):
320 case VLC_FOURCC('I','4','1','0'):
321 case VLC_FOURCC('Y','V','U','9'):
322 case VLC_FOURCC('Y','U','V','A'):
323 p_vout->pf_render = RenderPlanarYUV;
326 case VLC_FOURCC('R','G','B','2'): // packed by 1
327 case VLC_FOURCC('R','V','1','5'): // packed by 2
328 case VLC_FOURCC('R','V','1','6'): // packed by 2
329 case VLC_FOURCC('R','V','2','4'): // packed by 3
330 case VLC_FOURCC('R','V','3','2'): // packed by 4
331 p_vout->pf_render = RenderPackedRGB;
335 case VLC_FOURCC('Y','U','Y','2'): // packed by 2
336 case VLC_FOURCC('Y','U','N','V'): // packed by 2
337 case VLC_FOURCC('U','Y','V','Y'): // packed by 2
338 case VLC_FOURCC('U','Y','N','V'): // packed by 2
339 case VLC_FOURCC('Y','4','2','2'): // packed by 2
340 p_vout->pf_render = RenderPackedYUV;
344 msg_Err( p_vout, "colorspace not supported by plug-in !!!");
345 free( p_vout->p_sys );
348 p_vout->pf_display = NULL;
349 p_vout->pf_control = Control;
351 config_ChainParse( p_vout, CFG_PREFIX, ppsz_filter_options,
354 /* Look what method was requested */
355 p_vout->p_sys->i_col = var_CreateGetInteger( p_vout, CFG_PREFIX "cols" );
356 p_vout->p_sys->i_row = var_CreateGetInteger( p_vout, CFG_PREFIX "rows" );
358 // OS dependant code : Autodetect number of displays in wall
360 if ((p_vout->p_sys->i_col < 0) || (p_vout->p_sys->i_row < 0) )
362 int nbMonitors = GetSystemMetrics(SM_CMONITORS);
365 nbMonitors = 5; // 1 display => 5x1 simulation
366 p_vout->p_sys->i_col = nbMonitors;
367 p_vout->p_sys->i_row = 1;
371 p_vout->p_sys->i_col = GetSystemMetrics( SM_CXVIRTUALSCREEN ) / GetSystemMetrics( SM_CXSCREEN );
372 p_vout->p_sys->i_row = GetSystemMetrics( SM_CYVIRTUALSCREEN ) / GetSystemMetrics( SM_CYSCREEN );
373 if (p_vout->p_sys->i_col * p_vout->p_sys->i_row != nbMonitors)
375 p_vout->p_sys->i_col = nbMonitors;
376 p_vout->p_sys->i_row = 1;
379 var_SetInteger( p_vout, CFG_PREFIX "cols", p_vout->p_sys->i_col);
380 var_SetInteger( p_vout, CFG_PREFIX "rows", p_vout->p_sys->i_row);
385 p_vout->p_sys->i_offset_x = var_CreateGetInteger( p_vout, CFG_PREFIX "offset-x" );
386 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
387 p_vout->p_sys->b_autocrop = !(var_CreateGetInteger( p_vout, "crop-ratio" ) == 0);
388 if (!p_vout->p_sys->b_autocrop) p_vout->p_sys->b_autocrop = var_CreateGetInteger( p_vout, "autocrop" );
389 p_vout->p_sys->b_attenuate = var_CreateGetInteger( p_vout, CFG_PREFIX "attenuate");
390 p_vout->p_sys->bz_length = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-length" );
391 if (p_vout->p_sys->i_row > 1)
392 p_vout->p_sys->bz_height = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-height" );
394 p_vout->p_sys->bz_height = 100;
395 p_vout->p_sys->bz_begin = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-begin" );
396 p_vout->p_sys->bz_middle = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-middle" );
397 p_vout->p_sys->bz_end = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-end" );
398 p_vout->p_sys->bz_middle_pos = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-middle-pos" );
399 double d_p = 100.0 / p_vout->p_sys->bz_middle_pos;
400 p_vout->p_sys->i_ratio_max = var_CreateGetInteger( p_vout, "autocrop-ratio-max" ); // in crop module with autocrop ...
401 p_vout->p_sys->i_ratio = var_CreateGetInteger( p_vout, "crop-ratio" ); // in crop module with manual ratio ...
403 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;
404 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;
405 p_vout->p_sys->a_0 = p_vout->p_sys->bz_begin;
408 p_vout->p_sys->f_gamma_red = var_CreateGetFloat( p_vout, CFG_PREFIX "bz-gamma-red" );
409 p_vout->p_sys->f_gamma_green = var_CreateGetFloat( p_vout, CFG_PREFIX "bz-gamma-green" );
410 p_vout->p_sys->f_gamma_blue = var_CreateGetFloat( p_vout, CFG_PREFIX "bz-gamma-blue" );
413 p_vout->p_sys->b_xinerama= var_CreateGetInteger( p_vout, CFG_PREFIX "xinerama" );
416 p_vout->p_sys->i_col = __MAX( 1, __MIN( 15, p_vout->p_sys->i_col ) );
417 p_vout->p_sys->i_row = __MAX( 1, __MIN( 15, p_vout->p_sys->i_row ) );
420 msg_Dbg( p_vout, "opening a %i x %i wall",
421 p_vout->p_sys->i_col, p_vout->p_sys->i_row );
423 p_vout->p_sys->pp_vout = malloc( p_vout->p_sys->i_row *
424 p_vout->p_sys->i_col *
425 sizeof(struct vout_list_t) );
426 if( p_vout->p_sys->pp_vout == NULL )
428 msg_Err( p_vout, "out of memory" );
429 free( p_vout->p_sys );
434 psz_method = var_CreateGetNonEmptyString( p_vout, CFG_PREFIX "active" );
436 /* If no trailing vout are specified, take them all */
437 if( psz_method == NULL )
439 for( i_vout = p_vout->p_sys->i_row * p_vout->p_sys->i_col;
442 p_vout->p_sys->pp_vout[i_vout].b_active = 1;
445 /* If trailing vout are specified, activate only the requested ones */
448 for( i_vout = p_vout->p_sys->i_row * p_vout->p_sys->i_col;
451 p_vout->p_sys->pp_vout[i_vout].b_active = 0;
456 psz_tmp = psz_method;
457 while( *psz_tmp && *psz_tmp != ',' )
465 i_vout = atoi( psz_method );
466 psz_method = psz_tmp + 1;
470 i_vout = atoi( psz_method );
471 psz_method = psz_tmp;
475 i_vout < p_vout->p_sys->i_row * p_vout->p_sys->i_col )
477 p_vout->p_sys->pp_vout[i_vout].b_active = 1;
482 free( psz_method_tmp );
489 /*****************************************************************************
490 * CLIP_0A: clip between 0 and ACCURACY
491 *****************************************************************************/
492 inline static int CLIP_0A( int a )
494 return (a > ACCURACY) ? ACCURACY : (a < 0) ? 0 : a;
498 /*****************************************************************************
499 * Gamma: Gamma correction
500 *****************************************************************************/
501 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])
505 f_Input = (f_component * f_BlackLevel[i_plane]) / (f_BlackCrush[i_plane]) + (1.0 - f_BlackLevel[i_plane]);
506 if (f_component <= f_BlackCrush[i_plane])
507 return pow(f_Input, 1.0 / f_Gamma[i_plane]);
508 else if (f_component >= f_WhiteCrush[i_plane])
510 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);
511 return pow(f_Input, 1.0 / f_Gamma[i_plane]);
519 /*****************************************************************************
520 * F: Function to calculate Gamma correction
521 *****************************************************************************/
522 static uint8_t F(uint8_t i, float gamma)
524 double input = (double) i / 255.0;
526 // return clip(255 * pow(input, 1.0 / gamma));
529 return clip_uint8((255 * pow(2 * input, gamma)) / 2);
531 return clip_uint8(255 * (1 - pow(2 * (1 - input), gamma) / 2));
537 /*****************************************************************************
538 * AdjustHeight: ajust p_sys->i_height to have same BZ width for any ratio
539 *****************************************************************************/
540 static int AdjustHeight( vout_thread_t *p_vout )
542 vlc_bool_t b_fullscreen = var_CreateGetInteger( p_vout, "fullscreen" );
543 int i_window_width = p_vout->i_window_width;
544 int i_window_height = p_vout->i_window_height;
545 double d_halfLength = 0;
546 double d_halfLength_crop;
547 double d_halfLength_calculated;
550 // OS DEPENDANT CODE to get display dimensions
554 i_window_width = GetSystemMetrics(SM_CXSCREEN);
555 i_window_height = GetSystemMetrics(SM_CYSCREEN);
557 Display *p_display = XOpenDisplay( "" );
558 if (p_vout->p_sys->b_xinerama)
560 i_window_width = DisplayWidth(p_display, 0) / p_vout->p_sys->i_col;
561 i_window_height = DisplayHeight(p_display, 0) / p_vout->p_sys->i_row;
565 i_window_width = DisplayWidth(p_display, 0);
566 i_window_height = DisplayHeight(p_display, 0);
568 XCloseDisplay( p_display );
571 var_SetInteger( p_vout, "width", i_window_width);
572 var_SetInteger( p_vout, "height", i_window_height);
573 p_vout->i_window_width = i_window_width;
574 p_vout->i_window_height = i_window_height;
577 if (p_vout->p_sys->bz_length)
578 if ((!p_vout->p_sys->b_autocrop) && (!p_vout->p_sys->i_ratio))
580 if ((p_vout->p_sys->i_row > 1) || (p_vout->p_sys->i_col > 1))
582 while ((d_halfLength <= 0) || (d_halfLength > p_vout->render.i_width / (2 * p_vout->p_sys->i_col)))
584 if (p_vout->p_sys->bz_length >= 50)
585 d_halfLength = i_window_width * p_vout->render.i_height / (2 * i_window_height * p_vout->p_sys->i_row) - p_vout->render.i_width / (2 * p_vout->p_sys->i_col);
588 d_halfLength = (p_vout->render.i_width * p_vout->p_sys->bz_length) / (100.0 * p_vout->p_sys->i_col);
589 d_halfLength = __MAX(i_window_width * p_vout->render.i_height / (2 * i_window_height * p_vout->p_sys->i_row) - p_vout->render.i_width / (2 * p_vout->p_sys->i_col), d_halfLength);
591 if ((d_halfLength <= 0) || (d_halfLength > p_vout->render.i_width / (2 * p_vout->p_sys->i_col))) p_vout->p_sys->i_row--;
592 if (p_vout->p_sys->i_row < 1 )
594 p_vout->p_sys->i_row = 1;
598 p_vout->p_sys->i_halfLength = (d_halfLength + 0.5);
599 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;
600 var_SetInteger( p_vout, "bz-length", p_vout->p_sys->bz_length);
601 var_SetInteger( p_vout, "panoramix-rows", p_vout->p_sys->i_row);
606 d_halfLength = ((2 * (double)i_window_width - (double)(p_vout->p_sys->i_ratio_max * i_window_height) / 1000.0 ) * (double)p_vout->p_sys->bz_length) / 200.0;
607 d_halfLength_crop = d_halfLength * VOUT_ASPECT_FACTOR * (double)p_vout->output.i_width
608 / (double)i_window_height / (double)p_vout->render.i_aspect;
609 p_vout->p_sys->i_halfLength = (d_halfLength_crop + 0.5);
610 d_halfLength_calculated = p_vout->p_sys->i_halfLength * (double)i_window_height *
611 (double)p_vout->render.i_aspect / VOUT_ASPECT_FACTOR / (double)p_vout->output.i_width;
613 if (!p_vout->p_sys->b_attenuate)
615 double d_bz_length = (p_vout->p_sys->i_halfLength * p_vout->p_sys->i_col * 100.0) / p_vout->render.i_width;
616 // F(2x) != 2F(x) in opengl module
617 if (p_vout->p_sys->i_col == 2) d_bz_length = (100.0 * d_bz_length) / (100.0 - d_bz_length) ;
618 var_SetInteger( p_vout, "bz-length", (int)(d_bz_length + 0.5));
620 i_offset = (int)d_halfLength - (int)
621 (p_vout->p_sys->i_halfLength * (double)i_window_height *
622 (double)p_vout->render.i_aspect / VOUT_ASPECT_FACTOR / (double)p_vout->output.i_width);
632 /*****************************************************************************
633 * Init: initialize Wall video thread output method
634 *****************************************************************************/
635 static int Init( vout_thread_t *p_vout )
637 int i_index, i_row, i_col, i_width, i_height;
640 I_OUTPUTPICTURES = 0;
642 /* Initialize the output structure */
643 p_vout->output.i_chroma = p_vout->render.i_chroma;
644 p_vout->output.i_width = p_vout->render.i_width;
645 p_vout->output.i_height = p_vout->render.i_height;
646 p_vout->output.i_aspect = p_vout->render.i_aspect;
648 p_vout->p_sys->b_has_changed = p_vout->p_sys->b_attenuate;
649 int i_video_x = var_GetInteger( p_vout, "video-x");
650 int i_video_y = var_GetInteger( p_vout, "video-y");
652 if (p_vout->p_sys->b_attenuate)
654 int i_index2, i_plane;
655 int constantYUV[3] = {0,128,128};
656 float f_BlackCrush[VOUT_MAX_PLANES];
657 float f_BlackLevel[VOUT_MAX_PLANES];
658 float f_WhiteCrush[VOUT_MAX_PLANES];
659 float f_WhiteLevel[VOUT_MAX_PLANES];
660 p_vout->p_sys->f_gamma[0] = var_CreateGetFloat( p_vout, CFG_PREFIX "bz-gamma-red" );
661 p_vout->p_sys->f_gamma[1] = var_CreateGetFloat( p_vout, CFG_PREFIX "bz-gamma-green" );
662 p_vout->p_sys->f_gamma[2] = var_CreateGetFloat( p_vout, CFG_PREFIX "bz-gamma-blue" );
663 f_BlackCrush[0] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-blackcrush-red" ) / 255.0;
664 f_BlackCrush[1] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-blackcrush-green" ) / 255.0;
665 f_BlackCrush[2] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-blackcrush-blue" ) / 255.0;
666 f_WhiteCrush[0] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-whitecrush-red" ) / 255.0;
667 f_WhiteCrush[1] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-whitecrush-green" ) / 255.0;
668 f_WhiteCrush[2] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-whitecrush-blue" ) / 255.0;
669 f_BlackLevel[0] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-blacklevel-red" ) / 255.0;
670 f_BlackLevel[1] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-blacklevel-green" ) / 255.0;
671 f_BlackLevel[2] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-blacklevel-blue" ) / 255.0;
672 f_WhiteLevel[0] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-whitelevel-red" ) / 255.0;
673 f_WhiteLevel[1] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-whitelevel-green" ) / 255.0;
674 f_WhiteLevel[2] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-whitelevel-blue" ) / 255.0;
675 switch (p_vout->render.i_chroma)
678 case VLC_FOURCC('Y','V','1','2'):
679 case VLC_FOURCC('Y','V','U','9'):
681 case VLC_FOURCC('U','Y','V','Y'): // packed by 2
682 case VLC_FOURCC('U','Y','N','V'): // packed by 2
683 case VLC_FOURCC('Y','4','2','2'): // packed by 2
684 // case VLC_FOURCC('c','y','u','v'): // packed by 2
685 p_vout->p_sys->f_gamma[2] = var_CreateGetFloat( p_vout, CFG_PREFIX "bz-gamma-green" );
686 p_vout->p_sys->f_gamma[1] = var_CreateGetFloat( p_vout, CFG_PREFIX "bz-gamma-blue" );
687 f_BlackCrush[2] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-blackcrush-green" ) / 255.0;
688 f_BlackCrush[1] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-blackcrush-blue" ) / 255.0;
689 f_WhiteCrush[2] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-whitecrush-green" ) / 255.0;
690 f_WhiteCrush[1] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-whitecrush-blue" ) / 255.0;
691 f_BlackLevel[2] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-blacklevel-green" ) / 255.0;
692 f_BlackLevel[1] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-blacklevel-blue" ) / 255.0;
693 f_WhiteLevel[2] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-whitelevel-green" ) / 255.0;
694 f_WhiteLevel[1] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-whitelevel-blue" ) / 255.0;
696 case VLC_FOURCC('I','4','4','4'):
697 case VLC_FOURCC('I','4','2','2'):
698 case VLC_FOURCC('I','4','2','0'):
699 case VLC_FOURCC('I','4','1','1'):
700 case VLC_FOURCC('I','4','1','0'):
701 case VLC_FOURCC('I','Y','U','V'):
702 case VLC_FOURCC('Y','U','V','A'):
704 case VLC_FOURCC('Y','U','Y','2'): // packed by 2
705 case VLC_FOURCC('Y','U','N','V'): // packed by 2
706 for (i_index = 0; i_index < 256; i_index++)
707 for (i_index2 = 0; i_index2 <= ACCURACY; i_index2++)
708 for (i_plane = 0; i_plane < VOUT_MAX_PLANES; i_plane++)
710 float f_lut = CLIP_01(1.0 -
711 ((ACCURACY - (float)i_index2)
712 * Gamma_Correction(i_plane, (float)i_index / 255.0, f_BlackCrush, f_WhiteCrush, f_BlackLevel, f_WhiteLevel, p_vout->p_sys->f_gamma)
714 p_vout->p_sys->LUT[i_plane][i_index2][i_index] = f_lut * i_index + (int)((1.0 - f_lut) * (float)constantYUV[i_plane]);
718 case VLC_FOURCC('R','G','B','2'): // packed by 1
719 case VLC_FOURCC('R','V','1','5'): // packed by 2
720 case VLC_FOURCC('R','V','1','6'): // packed by 2
721 case VLC_FOURCC('R','V','2','4'): // packed by 3
722 case VLC_FOURCC('R','V','3','2'): // packed by 4
723 for (i_index = 0; i_index < 256; i_index++)
724 for (i_index2 = 0; i_index2 <= ACCURACY; i_index2++)
725 for (i_plane = 0; i_plane < VOUT_MAX_PLANES; i_plane++)
727 float f_lut = CLIP_01(1.0 -
728 ((ACCURACY - (float)i_index2)
729 * Gamma_Correction(i_plane, (float)i_index / 255.0, f_BlackCrush, f_WhiteCrush, f_BlackLevel, f_WhiteLevel, p_vout->p_sys->f_gamma)
731 p_vout->p_sys->LUT[i_plane][i_index2][i_index] = f_lut * i_index;
735 msg_Err( p_vout, "colorspace not supported by plug-in !!!");
736 free( p_vout->p_sys );
741 if (p_vout->p_sys->i_offset_x)
742 p_vout->p_sys->i_offset_x = AdjustHeight(p_vout);
744 AdjustHeight(p_vout);
747 /* Try to open the real video output */
748 msg_Dbg( p_vout, "spawning the real video outputs" );
750 p_vout->p_sys->i_vout = 0;
752 /* FIXME: use bresenham instead of those ugly divisions */
753 for( i_row = 0; i_row < p_vout->p_sys->i_row; i_row++ )
755 for( i_col = 0; i_col < p_vout->p_sys->i_col; i_col++ )
759 memset( &fmt, 0, sizeof(video_format_t) );
761 if( i_col + 1 < p_vout->p_sys->i_col )
763 i_width = ( p_vout->render.i_width
764 / p_vout->p_sys->i_col ) & ~0x1;
768 i_width = p_vout->render.i_width
769 - ( ( p_vout->render.i_width
770 / p_vout->p_sys->i_col ) & ~0x1 ) * i_col;
774 i_width += p_vout->p_sys->i_halfLength;
775 if (p_vout->p_sys->i_col > 2 ) i_width += p_vout->p_sys->i_halfLength;
776 i_width -= i_width % 2;
778 if( i_row + 1 < p_vout->p_sys->i_row )
780 i_height = ( p_vout->render.i_height
781 / p_vout->p_sys->i_row ) & ~0x3;
785 i_height = p_vout->render.i_height
786 - ( ( p_vout->render.i_height
787 / p_vout->p_sys->i_row ) & ~0x3 ) * i_row;
791 if (p_vout->p_sys->i_row >= 2)
793 p_vout->p_sys->i_halfHeight = (p_vout->p_sys->i_halfLength * p_vout->p_sys->bz_height) / 100;
794 p_vout->p_sys->i_halfHeight -= (p_vout->p_sys->i_halfHeight % 2);
795 i_height += p_vout->p_sys->i_halfHeight;
796 if (p_vout->p_sys->i_row > 2) i_height += p_vout->p_sys->i_halfHeight;
798 i_height -= i_height % 2;
800 p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].i_width = i_width;
801 p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].i_height = i_height;
803 if( !p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].b_active )
805 p_vout->p_sys->i_vout++;
809 fmt.i_width = fmt.i_visible_width = p_vout->render.i_width;
810 fmt.i_height = fmt.i_visible_height = p_vout->render.i_height;
811 fmt.i_x_offset = fmt.i_y_offset = 0;
812 fmt.i_chroma = p_vout->render.i_chroma;
813 fmt.i_aspect = p_vout->render.i_aspect;
814 fmt.i_sar_num = p_vout->render.i_aspect * fmt.i_height / fmt.i_width;
815 fmt.i_sar_den = VOUT_ASPECT_FACTOR;
816 fmt.i_width = fmt.i_visible_width = i_width;
817 fmt.i_height = fmt.i_visible_height = i_height;
818 fmt.i_aspect = p_vout->render.i_aspect
819 * p_vout->render.i_height / i_height
820 * i_width / p_vout->render.i_width;
822 if (p_vout->p_sys->i_offset_x < 0)
824 var_SetInteger(p_vout, "video-x", -p_vout->p_sys->i_offset_x);
825 p_vout->p_sys->i_offset_x = 0;
828 p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].p_vout =
829 vout_Create( p_vout, &fmt);
831 if( p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].p_vout == NULL )
833 msg_Err( p_vout, "failed to get %ix%i vout threads",
834 p_vout->p_sys->i_col, p_vout->p_sys->i_row );
835 RemoveAllVout( p_vout );
839 p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].p_vout,
842 p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].p_vout->i_alignment = 0;
843 if (i_col == 0) p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].p_vout->i_alignment |= VOUT_ALIGN_RIGHT;
844 else if (i_col == p_vout->p_sys->i_col -1) p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].p_vout->i_alignment |= VOUT_ALIGN_LEFT;
845 if (p_vout->p_sys->i_row > 1)
847 if (i_row == 0) p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].p_vout->i_alignment |= VOUT_ALIGN_BOTTOM;
848 else if (i_row == p_vout->p_sys->i_row -1) p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].p_vout->i_alignment |= VOUT_ALIGN_TOP;
850 // i_n : number of active pp_vout
851 int i_index, i_n = p_vout->p_sys->i_vout;
852 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;
853 var_SetInteger( p_vout, "align", p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].p_vout->i_alignment );
854 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);
855 var_SetInteger( p_vout, "video-y",i_video_y + ((i_n + 1) / p_vout->p_sys->i_col) * p_vout->i_window_height);
857 p_vout->p_sys->i_vout++;
861 ALLOCATE_DIRECTBUFFERS( VOUT_MAX_PICTURES );
863 ADD_PARENT_CALLBACKS( SendEventsToChild );
868 /*****************************************************************************
869 * End: terminate Wall video thread output method
870 *****************************************************************************/
871 static void End( vout_thread_t *p_vout )
876 var_SetInteger( p_vout, "bz-length", p_vout->p_sys->bz_length);
878 /* Free the fake output buffers we allocated */
879 for( i_index = I_OUTPUTPICTURES ; i_index ; )
882 free( PP_OUTPUTPICTURE[ i_index ]->p_data_orig );
886 /*****************************************************************************
887 * Destroy: destroy Wall video thread output method
888 *****************************************************************************
889 * Terminate an output method created by WallCreateOutputMethod
890 *****************************************************************************/
891 static void Destroy( vlc_object_t *p_this )
893 vout_thread_t *p_vout = (vout_thread_t *)p_this;
896 DEL_CALLBACKS( p_vout->p_sys->p_vout, SendEvents);
897 vlc_object_detach( p_vout->p_sys->p_vout );
898 vout_Destroy( p_vout->p_sys->p_vout );
899 DEL_PARENT_CALLBACKS( SendEventsToChild);
902 RemoveAllVout( p_vout );
903 DEL_PARENT_CALLBACKS( SendEventsToChild );
905 free( p_vout->p_sys->pp_vout );
906 free( p_vout->p_sys );
910 /*****************************************************************************
911 * RenderPlanarYUV: displays previously rendered output
912 *****************************************************************************
913 * This function send the currently rendered image to Wall image, waits
914 * until it is displayed and switch the two rendering buffers, preparing next
916 *****************************************************************************/
917 static void RenderPlanarYUV( vout_thread_t *p_vout, picture_t *p_pic )
919 picture_t *p_outpic = NULL;
920 int i_col, i_row, i_vout, i_plane;
921 int pi_left_skip[VOUT_MAX_PLANES], pi_top_skip[VOUT_MAX_PLANES];
923 int LeftOffset, TopOffset;
924 int constantYUV[3] = {0,128,128};
929 int i_index, i_index2;
935 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
937 pi_top_skip[i_plane] = 0;
940 for( i_row = 0; i_row < p_vout->p_sys->i_row; i_row++ )
942 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
944 pi_left_skip[i_plane] = 0;
947 for( i_col = 0; i_col < p_vout->p_sys->i_col; i_col++ )
949 if( !p_vout->p_sys->pp_vout[ i_vout ].b_active )
951 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
953 pi_left_skip[i_plane] +=
954 p_vout->p_sys->pp_vout[ i_vout ].i_width
955 * p_pic->p[i_plane].i_pitch / p_vout->output.i_width;
962 vout_CreatePicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
966 if( p_vout->b_die || p_vout->b_error )
969 p_vout->p_sys->pp_vout[ i_vout ].p_vout, p_outpic );
973 msleep( VOUT_OUTMEM_SLEEP );
976 vout_DatePicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
977 p_outpic, p_pic->date );
978 vout_LinkPicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
981 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
983 uint8_t *p_in, *p_in_end, *p_out;
984 int i_in_pitch = p_pic->p[i_plane].i_pitch;
985 int i_out_pitch = p_outpic->p[i_plane].i_pitch;
986 int i_copy_pitch = p_outpic->p[i_plane].i_visible_pitch;
987 int i_lines = p_outpic->p[i_plane].i_visible_lines;
989 if (i_col) pi_left_skip[i_plane] -= (2 * p_vout->p_sys->i_halfLength ) / (p_vout->p_sys->pp_vout[i_vout].i_width / i_copy_pitch);
990 if ((i_row) && (!i_col)) pi_top_skip[i_plane] -= (2 * p_vout->p_sys->i_halfHeight * p_pic->p[i_plane].i_pitch) / (p_vout->p_sys->pp_vout[i_vout].i_width / i_copy_pitch);
991 if ((p_vout->p_sys->i_row > 2) && (i_row == 1) && (!i_col)) pi_top_skip[i_plane] -= (2 * p_vout->p_sys->i_halfHeight * p_pic->p[i_plane].i_pitch) / (p_vout->p_sys->pp_vout[i_vout].i_width / i_copy_pitch);
992 if ((!p_vout->p_sys->pp_vout[p_vout->p_sys->i_col].b_active))
993 pi_top_skip[i_plane] -= (2 * p_vout->p_sys->i_halfHeight * i_row * p_pic->p[i_plane].i_pitch) / (p_vout->p_sys->pp_vout[i_vout].i_width / i_copy_pitch);
994 // i_n : previous inactive pp_vout
996 while ((!p_vout->p_sys->pp_vout[i_row * p_vout->p_sys->i_col + i_col - 1 - i_n].b_active) && (i_col - i_n > 1)) i_n++;
997 if ((i_col > 1) && i_n)
998 pi_left_skip[i_plane] -= i_n*(2 * p_vout->p_sys->i_halfLength ) / (p_vout->p_sys->pp_vout[i_vout].i_width / i_copy_pitch);
1000 p_in = p_pic->p[i_plane].p_pixels
1001 /* Wall proprities */
1002 + pi_top_skip[i_plane] + pi_left_skip[i_plane];
1004 if ((p_vout->p_sys->i_row > 2) &&
1005 ((!i_row) || (i_row + 1 == p_vout->p_sys->i_row)))
1006 i_lines -= (2 * p_vout->p_sys->i_halfHeight) / (p_vout->p_sys->pp_vout[i_vout].i_width / i_copy_pitch);
1008 // 1088 lines bug in a mpeg2 stream of 1080 lines
1009 if ((p_vout->p_sys->i_row - 1 == i_row) &&
1010 (p_pic->p[i_plane].i_lines == 1088))
1011 i_lines -= 8 / (p_vout->p_sys->pp_vout[i_vout].i_width / i_copy_pitch);
1013 p_in_end = p_in + i_lines * p_pic->p[i_plane].i_pitch;
1015 p_in = p_pic->p[i_plane].p_pixels
1016 + pi_top_skip[i_plane] + pi_left_skip[i_plane];
1018 p_in_end = p_in + i_lines * p_pic->p[i_plane].i_pitch;
1020 p_out = p_outpic->p[i_plane].p_pixels;
1022 if ((p_vout->p_sys->i_row > 2) && (!i_row))
1023 p_out += (p_outpic->p[i_plane].i_pitch * (2 * p_vout->p_sys->i_halfHeight) / (p_vout->p_sys->pp_vout[i_vout].i_width / i_copy_pitch));
1027 length = 2 * p_vout->p_sys->i_halfLength / (p_vout->p_sys->pp_vout[i_vout].i_width / i_copy_pitch);
1029 if (p_vout->p_sys->b_has_changed)
1032 a_2 = p_vout->p_sys->a_2 * (ACCURACY / 100);
1033 a_1 = p_vout->p_sys->a_1 * length * (ACCURACY / 100);
1034 a_0 = p_vout->p_sys->a_0 * Denom * (ACCURACY / 100);
1035 for(i_col_mod = 0; i_col_mod < 2; i_col_mod++)
1036 for (i_index = 0; i_index < length; i_index++)
1038 p_vout->p_sys->lambda[i_col_mod][i_plane][i_index] = CLIP_0A(!i_col_mod ? ACCURACY - (F4(a_2, a_1, i_index) + a_0) / Denom : ACCURACY - (F4(a_2, a_1,length - i_index) + a_0) / Denom);
1039 p_vout->p_sys->cstYUV[i_col_mod][i_plane][i_index] = ((ACCURACY - p_vout->p_sys->lambda[i_col_mod][i_plane][i_index]) * constantYUV[i_plane]) / ACCURACY;
1043 while( p_in < p_in_end )
1046 p_vout->p_libvlc->pf_memcpy( p_out , p_in, i_copy_pitch);
1048 if (p_vout->p_sys->i_col > 2)
1052 p_vout->p_libvlc->pf_memcpy( p_out + length , p_in, i_copy_pitch - length);
1053 else if (i_col + 1 == p_vout->p_sys->i_col)
1054 p_vout->p_libvlc->pf_memcpy( p_out, p_in - length, i_copy_pitch - length);
1056 p_vout->p_libvlc->pf_memcpy( p_out, p_in - length, i_copy_pitch);
1062 p_out += LeftOffset;
1063 memset(p_out, constantYUV[i_plane], length);
1064 p_out -= LeftOffset;
1066 else if ((i_col + 1 == p_vout->p_sys->i_col ))
1069 LeftOffset = i_copy_pitch - length;
1070 p_out += LeftOffset;
1071 memset(p_out, constantYUV[i_plane], length);
1072 p_out -= LeftOffset;
1077 p_vout->p_libvlc->pf_memcpy( p_out , p_in, i_copy_pitch);
1079 if (p_vout->p_sys->b_attenuate)
1082 // first blended zone
1086 p_out += LeftOffset;
1087 for (i_index = 0; i_index < length; i_index++)
1090 *(p_out + i_index) = (p_vout->p_sys->lambda[1][i_plane][i_index] *
1091 (*(p_out + i_index))) / ACCURACY +
1092 p_vout->p_sys->cstYUV[1][i_plane][i_index];
1094 *(p_out + i_index) = p_vout->p_sys->LUT[i_plane][p_vout->p_sys->lambda[1][i_plane][i_index]][*(p_out + i_index)];
1097 p_out -= LeftOffset;
1099 // second blended zone
1100 if (i_col + 1 < p_vout->p_sys->i_col)
1102 LeftOffset = i_copy_pitch - length;
1103 p_out += LeftOffset;
1104 for (i_index = 0; i_index < length; i_index++)
1107 *(p_out + i_index) = (p_vout->p_sys->lambda[0][i_plane][i_index] *
1108 (*(p_out + i_index))) / ACCURACY +
1109 p_vout->p_sys->cstYUV[0][i_plane][i_index];
1112 *(p_out + i_index) = p_vout->p_sys->LUT[i_plane][p_vout->p_sys->lambda[0][i_plane][i_index]][*(p_out + i_index)];
1115 p_out -= LeftOffset;
1121 p_out += i_out_pitch;
1125 if (!p_vout->p_sys->b_attenuate)
1127 if ((i_row == 0) && (p_vout->p_sys->i_row > 2))
1130 int height = 2 * p_vout->p_sys->i_halfHeight / (p_vout->p_sys->pp_vout[i_vout].i_width / i_copy_pitch);
1131 TopOffset = i_lines + (2 * p_vout->p_sys->i_halfHeight) / (p_vout->p_sys->pp_vout[i_vout].i_width / i_copy_pitch);
1132 p_out -= TopOffset * p_outpic->p[i_plane].i_pitch;
1133 for (i_index = 0; i_index < height; i_index++)
1134 for (i_index2 = 0; i_index2 < i_copy_pitch; i_index2++)
1135 *(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2) = constantYUV[i_plane];
1136 p_out += TopOffset * p_outpic->p[i_plane].i_pitch;
1138 else if ((i_row + 1 == p_vout->p_sys->i_row) && (p_vout->p_sys->i_row > 2))
1141 int height = 2 * p_vout->p_sys->i_halfHeight / (p_vout->p_sys->pp_vout[i_vout].i_width / i_copy_pitch);
1142 TopOffset = height - (2 * p_vout->p_sys->i_halfHeight) / (p_vout->p_sys->pp_vout[i_vout].i_width / i_copy_pitch);
1143 p_out -= TopOffset * p_outpic->p[i_plane].i_pitch;
1144 for (i_index = 0; i_index < height; i_index++)
1145 for (i_index2 = 0; i_index2 < i_copy_pitch; i_index2++)
1146 *(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2) = constantYUV[i_plane];
1147 p_out += TopOffset * p_outpic->p[i_plane].i_pitch;
1152 if (p_vout->p_sys->i_row >= 2)
1154 length = 2 * p_vout->p_sys->i_halfHeight / (p_vout->p_sys->pp_vout[i_vout].i_width / i_copy_pitch);
1155 if (p_vout->p_sys->b_has_changed)
1158 a_2 = p_vout->p_sys->a_2 * (ACCURACY / 100);
1159 a_1 = p_vout->p_sys->a_1 * length * (ACCURACY / 100);
1160 a_0 = p_vout->p_sys->a_0 * Denom * (ACCURACY / 100);
1161 for(i_col_mod = 0; i_col_mod < 2; i_col_mod++)
1162 for (i_index = 0; i_index < length; i_index++)
1164 p_vout->p_sys->lambda2[i_col_mod][i_plane][i_index] = CLIP_0A(!i_col_mod ? ACCURACY - (F4(a_2, a_1, i_index) + a_0) / Denom : ACCURACY - (F4(a_2, a_1,length - i_index) + a_0) / Denom);
1165 p_vout->p_sys->cstYUV2[i_col_mod][i_plane][i_index] = ((ACCURACY - p_vout->p_sys->lambda2[i_col_mod][i_plane][i_index]) * constantYUV[i_plane]) / ACCURACY;
1168 // first blended zone
1172 TopOffset = i_lines;
1173 p_out -= TopOffset * p_outpic->p[i_plane].i_pitch;
1174 for (i_index = 0; i_index < length; i_index++)
1175 for (i_index2 = 0; i_index2 < i_copy_pitch; i_index2++)
1177 *(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2) = (p_vout->p_sys->lambda2[1][i_plane][i_index] *
1178 (*(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2))) / ACCURACY +
1179 p_vout->p_sys->cstYUV2[1][i_plane][i_index];
1182 *(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2) = p_vout->p_sys->LUT[i_plane][p_vout->p_sys->lambda2[1][i_plane][i_index]][*(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2)];
1184 p_out += TopOffset * p_outpic->p[i_plane].i_pitch;
1186 else if (p_vout->p_sys->i_row > 2)
1189 TopOffset = i_lines + (2 * p_vout->p_sys->i_halfHeight) / (p_vout->p_sys->pp_vout[i_vout].i_width / i_copy_pitch);
1190 p_out -= TopOffset * p_outpic->p[i_plane].i_pitch;
1191 for (i_index = 0; i_index < length; i_index++)
1192 for (i_index2 = 0; i_index2 < i_copy_pitch; i_index2++)
1193 *(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2) = constantYUV[i_plane];
1194 p_out += TopOffset * p_outpic->p[i_plane].i_pitch;
1197 // second blended zone
1199 if (i_row + 1 < p_vout->p_sys->i_row)
1202 p_out -= TopOffset * p_outpic->p[i_plane].i_pitch;
1203 for (i_index = 0; i_index < length; i_index++)
1204 for (i_index2 = 0; i_index2 < i_copy_pitch; i_index2++)
1206 *(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2) = (p_vout->p_sys->lambda2[0][i_plane][i_index] *
1207 (*(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2))) / ACCURACY +
1208 p_vout->p_sys->cstYUV2[0][i_plane][i_index];
1211 *(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2) = p_vout->p_sys->LUT[i_plane][p_vout->p_sys->lambda2[0][i_plane][i_index]][*(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2)];
1214 p_out += TopOffset * p_outpic->p[i_plane].i_pitch;
1216 else if (p_vout->p_sys->i_row > 2)
1219 TopOffset = length - (2 * p_vout->p_sys->i_halfHeight) / (p_vout->p_sys->pp_vout[i_vout].i_width / i_copy_pitch);
1220 p_out -= TopOffset * p_outpic->p[i_plane].i_pitch;
1221 for (i_index = 0; i_index < length; i_index++)
1222 for (i_index2 = 0; i_index2 < i_copy_pitch; i_index2++)
1223 *(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2) = constantYUV[i_plane];
1224 p_out += TopOffset * p_outpic->p[i_plane].i_pitch;
1230 // bug for wall filter : fix by CC
1231 // pi_left_skip[i_plane] += i_out_pitch;
1232 pi_left_skip[i_plane] += i_copy_pitch;
1235 vout_UnlinkPicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
1237 vout_DisplayPicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
1242 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
1244 pi_top_skip[i_plane] += p_vout->p_sys->pp_vout[ i_vout ].i_height
1245 * p_pic->p[i_plane].i_lines
1246 / p_vout->output.i_height
1247 * p_pic->p[i_plane].i_pitch;
1252 if (p_vout->p_sys->b_has_changed) p_vout->p_sys->b_has_changed = VLC_FALSE;
1257 /*****************************************************************************
1258 * RenderPackedRGB: displays previously rendered output
1259 *****************************************************************************
1260 * This function send the currently rendered image to Wall image, waits
1261 * until it is displayed and switch the two rendering buffers, preparing next
1263 *****************************************************************************/
1264 static void RenderPackedRGB( vout_thread_t *p_vout, picture_t *p_pic )
1266 picture_t *p_outpic = NULL;
1267 int i_col, i_row, i_vout, i_plane;
1268 int pi_left_skip[VOUT_MAX_PLANES], pi_top_skip[VOUT_MAX_PLANES];
1270 int LeftOffset, TopOffset;
1275 int i_index, i_index2;
1280 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
1282 pi_top_skip[i_plane] = 0;
1285 for( i_row = 0; i_row < p_vout->p_sys->i_row; i_row++ )
1287 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
1289 pi_left_skip[i_plane] = 0;
1292 for( i_col = 0; i_col < p_vout->p_sys->i_col; i_col++ )
1294 if( !p_vout->p_sys->pp_vout[ i_vout ].b_active )
1296 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
1298 pi_left_skip[i_plane] +=
1299 p_vout->p_sys->pp_vout[ i_vout ].i_width * p_pic->p->i_pixel_pitch;
1306 vout_CreatePicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
1310 if( p_vout->b_die || p_vout->b_error )
1312 vout_DestroyPicture(
1313 p_vout->p_sys->pp_vout[ i_vout ].p_vout, p_outpic );
1317 msleep( VOUT_OUTMEM_SLEEP );
1320 vout_DatePicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
1321 p_outpic, p_pic->date );
1322 vout_LinkPicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
1325 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
1327 uint8_t *p_in, *p_in_end, *p_out;
1328 int i_in_pitch = p_pic->p[i_plane].i_pitch;
1329 int i_out_pitch = p_outpic->p[i_plane].i_pitch;
1330 int i_copy_pitch = p_outpic->p[i_plane].i_visible_pitch;
1333 if (i_col) pi_left_skip[i_plane] -= (2 * p_vout->p_sys->i_halfLength) * p_pic->p->i_pixel_pitch;
1334 if ((i_row) && (!i_col)) pi_top_skip[i_plane] -= (2 * p_vout->p_sys->i_halfHeight * p_pic->p[i_plane].i_pitch);
1335 if ((!p_vout->p_sys->pp_vout[p_vout->p_sys->i_col].b_active))
1336 pi_top_skip[i_plane] -= (2 * p_vout->p_sys->i_halfHeight * i_row * p_pic->p[i_plane].i_pitch);
1337 // i_n : previous inactive pp_vout
1339 while ((!p_vout->p_sys->pp_vout[i_row * p_vout->p_sys->i_col + i_col - 1 - i_n].b_active) && (i_col - i_n > 1)) i_n++;
1340 if ((i_col > 1) && i_n)
1341 pi_left_skip[i_plane] -= i_n*(2 * p_vout->p_sys->i_halfLength ) * p_pic->p->i_pixel_pitch;
1343 p_in = p_pic->p[i_plane].p_pixels
1344 /* Wall proprities */
1345 + pi_top_skip[i_plane] + pi_left_skip[i_plane];
1347 int i_lines = p_outpic->p[i_plane].i_visible_lines;
1348 // 1088 lines bug in a mpeg2 stream of 1080 lines
1349 if ((p_vout->p_sys->i_row - 1 == i_row) &&
1350 (p_pic->p[i_plane].i_lines == 1088))
1353 p_in_end = p_in + i_lines * p_pic->p[i_plane].i_pitch;
1355 p_in = p_pic->p[i_plane].p_pixels
1356 + pi_top_skip[i_plane] + pi_left_skip[i_plane];
1358 p_in_end = p_in + p_outpic->p[i_plane].i_visible_lines
1359 * p_pic->p[i_plane].i_pitch;
1362 p_out = p_outpic->p[i_plane].p_pixels;
1366 if ((p_vout->p_sys->i_row > 2) && (!i_row))
1367 p_out += (p_outpic->p[i_plane].i_pitch * (2 * p_vout->p_sys->i_halfHeight) * p_pic->p->i_pixel_pitch);
1370 length = 2 * p_vout->p_sys->i_halfLength * p_pic->p->i_pixel_pitch;
1372 if (p_vout->p_sys->b_has_changed)
1376 Denom = F2(length / p_pic->p->i_pixel_pitch);
1377 a_2 = p_vout->p_sys->a_2 * (ACCURACY / 100);
1378 a_1 = p_vout->p_sys->a_1 * 2 * p_vout->p_sys->i_halfLength * (ACCURACY / 100);
1379 a_0 = p_vout->p_sys->a_0 * Denom * (ACCURACY / 100);
1380 for(i_col_mod = 0; i_col_mod < 2; i_col_mod++)
1381 for (i_index = 0; i_index < length / p_pic->p->i_pixel_pitch; i_index++)
1382 for (i_plane_ = 0; i_plane_ < p_pic->p->i_pixel_pitch; i_plane_++)
1383 p_vout->p_sys->lambda[i_col_mod][i_plane_][i_index] = CLIP_0A(!i_col_mod ? ACCURACY - (F4(a_2, a_1, i_index) + a_0) / Denom : ACCURACY - (F4(a_2, a_1,(length / p_pic->p->i_pixel_pitch) - i_index) + a_0) / Denom);
1386 while( p_in < p_in_end )
1389 p_vout->p_libvlc->pf_memcpy( p_out, p_in, i_copy_pitch);
1391 if (p_vout->p_sys->i_col > 2)
1396 p_vout->p_libvlc->pf_memcpy( p_out + length, p_in, i_copy_pitch - length);
1397 else if (i_col + 1 == p_vout->p_sys->i_col)
1398 p_vout->p_libvlc->pf_memcpy( p_out, p_in - length, i_copy_pitch - length);
1400 p_vout->p_libvlc->pf_memcpy( p_out, p_in - length, i_copy_pitch);
1406 p_out += LeftOffset;
1408 for (i_index = 0; i_index < length; i_index++)
1409 *(p_out + i_index) = 0;
1410 p_out -= LeftOffset;
1413 else if ((i_col + 1 == p_vout->p_sys->i_col ))
1416 LeftOffset = i_copy_pitch - length;
1417 p_out += LeftOffset;
1419 for (i_index = 0; i_index < length; i_index++)
1420 *(p_out + i_index) = 0;
1421 p_out -= LeftOffset;
1427 p_vout->p_libvlc->pf_memcpy( p_out, p_in, i_copy_pitch);
1430 // first blended zone
1434 p_out += LeftOffset;
1435 for (i_index = 0; i_index < length; i_index++)
1437 *(p_out + i_index) = (p_vout->p_sys->lambda[1][i_index % p_pic->p->i_pixel_pitch][i_index / p_pic->p->i_pixel_pitch] *
1438 (*(p_out + i_index))) / ACCURACY;
1440 *(p_out + i_index) = p_vout->p_sys->LUT[i_index % p_pic->p->i_pixel_pitch][p_vout->p_sys->lambda[1][i_index % p_pic->p->i_pixel_pitch][i_index / p_pic->p->i_pixel_pitch]][*(p_out + i_index)];
1442 p_out -= LeftOffset;
1444 // second blended zone
1445 if (i_col + 1 < p_vout->p_sys->i_col)
1447 LeftOffset = i_copy_pitch - length;
1448 p_out += LeftOffset;
1449 for (i_index = 0; i_index < length; i_index++)
1451 *(p_out + i_index) = (p_vout->p_sys->lambda[0][i_index % p_pic->p->i_pixel_pitch][i_index / p_pic->p->i_pixel_pitch] *
1452 (*(p_out + i_index))) / ACCURACY;
1454 *(p_out + i_index) = p_vout->p_sys->LUT[i_index % p_pic->p->i_pixel_pitch][p_vout->p_sys->lambda[0][i_index % p_pic->p->i_pixel_pitch][i_index / p_pic->p->i_pixel_pitch]][*(p_out + i_index)];
1456 p_out -= LeftOffset;
1461 p_out += i_out_pitch;
1465 if (!p_vout->p_sys->b_attenuate)
1467 if ((i_row == 0) && (p_vout->p_sys->i_row > 2))
1470 TopOffset = i_lines + (2 * p_vout->p_sys->i_halfHeight);
1471 p_out -= TopOffset * p_outpic->p[i_plane].i_pitch;
1472 for (i_index = 0; i_index < length; i_index++)
1473 for (i_index2 = 0; i_index2 < i_copy_pitch; i_index2++)
1474 *(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2) = 0;
1475 p_out += TopOffset * p_outpic->p[i_plane].i_pitch;
1477 else if ((i_row + 1 == p_vout->p_sys->i_row) && (p_vout->p_sys->i_row > 2))
1480 TopOffset = length - (2 * p_vout->p_sys->i_halfHeight);
1481 p_out -= TopOffset * p_outpic->p[i_plane].i_pitch;
1482 for (i_index = 0; i_index < length; i_index++)
1483 for (i_index2 = 0; i_index2 < i_copy_pitch; i_index2++)
1484 *(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2) = 0;
1485 p_out += TopOffset * p_outpic->p[i_plane].i_pitch;
1490 if (p_vout->p_sys->i_row >= 2)
1492 length = 2 * p_vout->p_sys->i_halfHeight;
1493 if (p_vout->p_sys->b_has_changed)
1498 a_2 = p_vout->p_sys->a_2 * (ACCURACY / 100);
1499 a_1 = p_vout->p_sys->a_1 * length * (ACCURACY / 100);
1500 a_0 = p_vout->p_sys->a_0 * Denom * (ACCURACY / 100);
1501 for(i_row_mod = 0; i_row_mod < 2; i_row_mod++)
1502 for (i_index = 0; i_index < length; i_index++)
1503 for (i_plane_ = 0; i_plane_ < p_pic->p->i_pixel_pitch; i_plane_++)
1504 p_vout->p_sys->lambda2[i_row_mod][i_plane_][i_index] = CLIP_0A(!i_row_mod ? ACCURACY - (F4(a_2, a_1, i_index) + a_0) / Denom : ACCURACY - (F4(a_2, a_1,(length) - i_index) + a_0) / Denom);
1506 // first blended zone
1510 TopOffset = i_lines;
1511 p_out -= TopOffset * p_outpic->p[i_plane].i_pitch;
1512 for (i_index = 0; i_index < length; i_index++)
1513 for (i_index2 = 0; i_index2 < i_copy_pitch; i_index2++)
1515 *(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2) = (p_vout->p_sys->lambda2[1][i_index2 % p_pic->p->i_pixel_pitch][i_index] *
1516 (*(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2))) / ACCURACY;
1518 *(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2) = p_vout->p_sys->LUT[i_index2 % p_pic->p->i_pixel_pitch][p_vout->p_sys->lambda2[1][i_index2 % p_pic->p->i_pixel_pitch][i_index]][*(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2)];
1520 p_out += TopOffset * p_outpic->p[i_plane].i_pitch;
1522 else if (p_vout->p_sys->i_row > 2)
1525 TopOffset = i_lines + (2 * p_vout->p_sys->i_halfHeight);
1526 p_out -= TopOffset * p_outpic->p[i_plane].i_pitch;
1527 for (i_index = 0; i_index < length; i_index++)
1528 for (i_index2 = 0; i_index2 < i_copy_pitch; i_index2++)
1529 *(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2) = 0;
1530 p_out += TopOffset * p_outpic->p[i_plane].i_pitch;
1533 // second blended zone
1535 if (i_row + 1 < p_vout->p_sys->i_row)
1538 p_out -= TopOffset * p_outpic->p[i_plane].i_pitch;
1539 for (i_index = 0; i_index < length; i_index++)
1540 for (i_index2 = 0; i_index2 < i_copy_pitch; i_index2++)
1542 *(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2) = (p_vout->p_sys->lambda2[0][i_index2 % p_pic->p->i_pixel_pitch][i_index] *
1543 (*(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2))) / ACCURACY;
1545 *(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2) = p_vout->p_sys->LUT[i_index2 % p_pic->p->i_pixel_pitch][p_vout->p_sys->lambda2[0][i_index2 % p_pic->p->i_pixel_pitch][i_index]][*(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2)];
1548 p_out += TopOffset * p_outpic->p[i_plane].i_pitch;
1550 else if (p_vout->p_sys->i_row > 2)
1553 TopOffset = length - (2 * p_vout->p_sys->i_halfHeight);
1554 p_out -= TopOffset * p_outpic->p[i_plane].i_pitch;
1555 for (i_index = 0; i_index < length; i_index++)
1556 for (i_index2 = 0; i_index2 < i_copy_pitch; i_index2++)
1557 *(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2) = 0;
1558 p_out += TopOffset * p_outpic->p[i_plane].i_pitch;
1564 // bug for wall filter : fix by CC
1565 // pi_left_skip[i_plane] += i_out_pitch;
1566 pi_left_skip[i_plane] += i_copy_pitch;
1569 vout_UnlinkPicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
1571 vout_DisplayPicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
1576 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
1578 pi_top_skip[i_plane] += p_vout->p_sys->pp_vout[ i_vout ].i_height
1579 * p_pic->p[i_plane].i_lines
1580 / p_vout->output.i_height
1581 * p_pic->p[i_plane].i_pitch;
1585 if (p_vout->p_sys->b_has_changed) p_vout->p_sys->b_has_changed = VLC_FALSE;
1591 // WARNING : NO DEBUGGED
1592 /*****************************************************************************
1593 * RenderPackedYUV: displays previously rendered output
1594 *****************************************************************************
1595 * This function send the currently rendered image to Wall image, waits
1596 * until it is displayed and switch the two rendering buffers, preparing next
1598 *****************************************************************************/
1599 static void RenderPackedYUV( vout_thread_t *p_vout, picture_t *p_pic )
1601 picture_t *p_outpic = NULL;
1602 int i_col, i_row, i_vout, i_plane;
1603 int pi_left_skip[VOUT_MAX_PLANES], pi_top_skip[VOUT_MAX_PLANES];
1605 int LeftOffset, TopOffset;
1606 int constantYUV[3] = {0,128,128};
1611 int i_index, i_index2;
1617 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
1619 pi_top_skip[i_plane] = 0;
1622 for( i_row = 0; i_row < p_vout->p_sys->i_row; i_row++ )
1624 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
1626 pi_left_skip[i_plane] = 0;
1629 for( i_col = 0; i_col < p_vout->p_sys->i_col; i_col++ )
1631 if( !p_vout->p_sys->pp_vout[ i_vout ].b_active )
1633 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
1635 pi_left_skip[i_plane] +=
1636 p_vout->p_sys->pp_vout[ i_vout ].i_width
1637 * p_pic->p[i_plane].i_pitch / p_vout->output.i_width;
1644 vout_CreatePicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
1648 if( p_vout->b_die || p_vout->b_error )
1650 vout_DestroyPicture(
1651 p_vout->p_sys->pp_vout[ i_vout ].p_vout, p_outpic );
1655 msleep( VOUT_OUTMEM_SLEEP );
1658 vout_DatePicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
1659 p_outpic, p_pic->date );
1660 vout_LinkPicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
1663 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
1665 uint8_t *p_in, *p_in_end, *p_out;
1666 int i_in_pitch = p_pic->p[i_plane].i_pitch;
1667 int i_out_pitch = p_outpic->p[i_plane].i_pitch;
1668 int i_copy_pitch = p_outpic->p[i_plane].i_visible_pitch;
1671 if (i_col) pi_left_skip[i_plane] -= (2 * p_vout->p_sys->i_halfLength ) / (p_vout->p_sys->pp_vout[i_vout].i_width / i_copy_pitch);
1672 if ((i_row) && (!i_col)) pi_top_skip[i_plane] -= (2 * p_vout->p_sys->i_halfHeight * p_pic->p[i_plane].i_pitch) / (p_vout->p_sys->pp_vout[i_vout].i_width / i_copy_pitch);
1673 if ((p_vout->p_sys->i_row > 2) && (i_row == 1) && (!i_col)) pi_top_skip[i_plane] -= (2 * p_vout->p_sys->i_halfHeight * p_pic->p[i_plane].i_pitch) / (p_vout->p_sys->pp_vout[i_vout].i_width / i_copy_pitch);
1674 if ((!p_vout->p_sys->pp_vout[p_vout->p_sys->i_col].b_active))
1675 pi_top_skip[i_plane] -= (2 * p_vout->p_sys->i_halfHeight * i_row * p_pic->p[i_plane].i_pitch) / (p_vout->p_sys->pp_vout[i_vout].i_width / i_copy_pitch);
1676 // i_n : previous inactive pp_vout
1678 while ((!p_vout->p_sys->pp_vout[i_row * p_vout->p_sys->i_col + i_col - 1 - i_n].b_active) && (i_col - i_n > 1)) i_n++;
1679 if ((i_col > 1) && i_n)
1680 pi_left_skip[i_plane] -= i_n*(2 * p_vout->p_sys->i_halfLength ) / (p_vout->p_sys->pp_vout[i_vout].i_width / i_copy_pitch);
1682 p_in = p_pic->p[i_plane].p_pixels
1683 /* Wall proprities */
1684 + pi_top_skip[i_plane] + pi_left_skip[i_plane];
1686 int i_lines = p_outpic->p[i_plane].i_visible_lines;
1687 // 1088 lines bug in a mpeg2 stream of 1080 lines
1688 if ((p_vout->p_sys->i_row - 1 == i_row) &&
1689 (p_pic->p[i_plane].i_lines == 1088))
1692 p_in_end = p_in + i_lines * p_pic->p[i_plane].i_pitch;
1694 p_in = p_pic->p[i_plane].p_pixels
1695 + pi_top_skip[i_plane] + pi_left_skip[i_plane];
1697 p_in_end = p_in + p_outpic->p[i_plane].i_visible_lines
1698 * p_pic->p[i_plane].i_pitch;
1700 p_out = p_outpic->p[i_plane].p_pixels;
1703 length = 2 * p_vout->p_sys->i_halfLength * p_pic->p->i_pixel_pitch;
1704 LeftOffset = (i_col ? 0 : i_copy_pitch - length);
1705 if (p_vout->p_sys->b_has_changed)
1709 for (i_index = 0; i_index < length / p_pic->p->i_pixel_pitch; i_index++)
1710 for (i_plane_ = 0; i_plane_ < p_pic->p->i_pixel_pitch; i_plane_++)
1711 for (i_index2 = 0; i_index2 < 256; i_index2++)
1712 p_vout->p_sys->LUT[i_plane_][i_index2][i_index] = F(i_index2, (length / p_pic->p->i_pixel_pitch, i_index, p_vout->p_sys->f_gamma[i_plane_]));
1714 switch (p_vout->output.i_chroma)
1716 case VLC_FOURCC('Y','U','Y','2'): // packed by 2
1717 case VLC_FOURCC('Y','U','N','V'): // packed by 2
1718 Denom = F2(length / p_pic->p->i_pixel_pitch);
1719 a_2 = p_vout->p_sys->a_2 * (ACCURACY / 100);
1720 a_1 = p_vout->p_sys->a_1 * 2 * p_vout->p_sys->i_halfLength * (ACCURACY / 100);
1721 a_0 = p_vout->p_sys->a_0 * Denom * (ACCURACY / 100);
1722 for (i_index = 0; i_index < length / p_pic->p->i_pixel_pitch; i_index+=p_pic->p->i_pixel_pitch)
1723 // for each macropixel
1725 // first image pixel
1726 p_vout->p_sys->lambda[i_col][0][i_index] = CLIP_0A(!i_col ? ACCURACY - (F4(a_2, a_1, i_index) + a_0) / Denom : ACCURACY - (F4(a_2, a_1,(length / p_pic->p->i_pixel_pitch) - i_index) + a_0) / Denom);
1727 p_vout->p_sys->cstYUV[i_col][0][i_index] = ((ACCURACY - p_vout->p_sys->lambda[i_col][0][i_index]) * constantYUV[0]) / ACCURACY;
1728 p_vout->p_sys->lambda[i_col][1][i_index] = CLIP_0A(!i_col ? ACCURACY - (F4(a_2, a_1, i_index) + a_0) / Denom : ACCURACY - (F4(a_2, a_1,(length / p_pic->p->i_pixel_pitch) - i_index) + a_0) / Denom);
1729 p_vout->p_sys->cstYUV[i_col][1][i_index] = ((ACCURACY - p_vout->p_sys->lambda[i_col][1][i_index]) * constantYUV[1]) / ACCURACY;
1730 // second image pixel
1731 p_vout->p_sys->lambda[i_col][0][i_index + 1] = CLIP_0A(!i_col ? ACCURACY - (F4(a_2, a_1, i_index + 1) + a_0) / Denom : ACCURACY - (F4(a_2, a_1,(length / p_pic->p->i_pixel_pitch) - (i_index + 1)) + a_0) / Denom);
1732 p_vout->p_sys->cstYUV[i_col][0][i_index + 1] = ((ACCURACY - p_vout->p_sys->lambda[i_col][0][i_index]) * constantYUV[0]) / ACCURACY;
1733 p_vout->p_sys->lambda[i_col][1][i_index + 1] = p_vout->p_sys->lambda[i_col][1][i_index];
1734 p_vout->p_sys->cstYUV[i_col][1][i_index + 1] = p_vout->p_sys->cstYUV[i_col][1][i_index];
1737 case VLC_FOURCC('U','Y','V','Y'): // packed by 2
1738 case VLC_FOURCC('U','Y','N','V'): // packed by 2
1739 case VLC_FOURCC('Y','4','2','2'): // packed by 2
1740 Denom = F2(length / p_pic->p->i_pixel_pitch);
1741 a_2 = p_vout->p_sys->a_2 * (ACCURACY / 100);
1742 a_1 = p_vout->p_sys->a_1 * 2 * p_vout->p_sys->i_halfLength * (ACCURACY / 100);
1743 a_0 = p_vout->p_sys->a_0 * Denom * (ACCURACY / 100);
1744 for (i_index = 0; i_index < length / p_pic->p->i_pixel_pitch; i_index+=p_pic->p->i_pixel_pitch)
1745 // for each macropixel
1747 // first image pixel
1748 p_vout->p_sys->lambda[i_col][0][i_index] = CLIP_0A(!i_col ? ACCURACY - (F4(a_2, a_1, i_index) + a_0) / Denom : ACCURACY - (F4(a_2, a_1,(length / p_pic->p->i_pixel_pitch) - i_index) + a_0) / Denom);
1749 p_vout->p_sys->cstYUV[i_col][0][i_index] = ((ACCURACY - p_vout->p_sys->lambda[i_col][0][i_index]) * constantYUV[1]) / ACCURACY;
1750 p_vout->p_sys->lambda[i_col][1][i_index] = CLIP_0A(!i_col ? ACCURACY - (F4(a_2, a_1, i_index) + a_0) / Denom : ACCURACY - (F4(a_2, a_1,(length / p_pic->p->i_pixel_pitch) - i_index) + a_0) / Denom);
1751 p_vout->p_sys->cstYUV[i_col][1][i_index] = ((ACCURACY - p_vout->p_sys->lambda[i_col][1][i_index]) * constantYUV[0]) / ACCURACY;
1752 // second image pixel
1753 p_vout->p_sys->lambda[i_col][0][i_index + 1] = CLIP_0A(!i_col ? ACCURACY - (F4(a_2, a_1, i_index + 1) + a_0) / Denom : ACCURACY - (F4(a_2, a_1,(length / p_pic->p->i_pixel_pitch) - (i_index + 1)) + a_0) / Denom);
1754 p_vout->p_sys->cstYUV[i_col][0][i_index + 1] = ((ACCURACY - p_vout->p_sys->lambda[i_col][0][i_index]) * constantYUV[1]) / ACCURACY;
1755 p_vout->p_sys->lambda[i_col][1][i_index + 1] = p_vout->p_sys->lambda[i_col][1][i_index];
1756 p_vout->p_sys->cstYUV[i_col][1][i_index + 1] = p_vout->p_sys->cstYUV[i_col][1][i_index];
1764 while( p_in < p_in_end )
1767 p_vout->p_libvlc->pf_memcpy( p_out, p_in, i_copy_pitch);
1769 p_vout->p_libvlc->pf_memcpy( p_out + i_col * length, p_in + i_col * length, i_copy_pitch - length);
1770 p_out += LeftOffset;
1773 for (i_index = 0; i_index < length; i_index++)
1774 *(p_out + i_index) = (p_vout->p_sys->lambda[i_col][i_index % p_pic->p->i_pixel_pitch][i_index / p_pic->p->i_pixel_pitch] *
1775 (*(p_in + i_index))) / ACCURACY +
1776 p_vout->p_sys->cstYUV[i_col][i_index % p_pic->p->i_pixel_pitch][i_index / p_pic->p->i_pixel_pitch];
1778 for (i_index = 0; i_index < length; i_index++)
1779 *(p_out + i_index) = p_vout->p_sys->LUT[i_index % p_pic->p->i_pixel_pitch][(p_vout->p_sys->lambda[i_col][i_index % p_pic->p->i_pixel_pitch][i_index / p_pic->p->i_pixel_pitch] *
1780 (*(p_in + i_index))) / ACCURACY +
1781 p_vout->p_sys->cstYUV[i_col][i_index % p_pic->p->i_pixel_pitch][i_index / p_pic->p->i_pixel_pitch]][i_index / p_pic->p->i_pixel_pitch];
1783 p_out -= LeftOffset;
1787 p_out += i_out_pitch;
1790 if (p_vout->p_sys->i_row == 2)
1792 length = 2 * p_vout->p_sys->i_halfHeight * p_pic->p->i_pixel_pitch;
1793 TopOffset = (i_row ? i_lines : length / p_pic->p->i_pixel_pitch);
1794 if (p_vout->p_sys->b_has_changed)
1798 for (i_index = 0; i_index < length / p_pic->p->i_pixel_pitch; i_index++)
1799 for (i_plane_ = 0; i_plane_ < p_pic->p->i_pixel_pitch; i_plane_++)
1800 for (i_index2 = 0; i_index2 < 256; i_index2++)
1801 p_vout->p_sys->LUT2[i_plane_][i_index2][i_index] = F(i_index2, (length / p_pic->p->i_pixel_pitch, i_index, p_vout->p_sys->f_gamma[i_plane_]));
1803 switch (p_vout->output.i_chroma)
1805 case VLC_FOURCC('Y','U','Y','2'): // packed by 2
1806 case VLC_FOURCC('Y','U','N','V'): // packed by 2
1807 Denom = F2(length / p_pic->p->i_pixel_pitch);
1808 a_2 = p_vout->p_sys->a_2 * (ACCURACY / 100);
1809 a_1 = p_vout->p_sys->a_1 * 2 * p_vout->p_sys->i_halfHeight * (ACCURACY / 100);
1810 a_0 = p_vout->p_sys->a_0 * Denom * (ACCURACY / 100);
1811 for (i_index = 0; i_index < length / p_pic->p->i_pixel_pitch; i_index+=p_pic->p->i_pixel_pitch)
1812 // for each macropixel
1814 // first image pixel
1815 p_vout->p_sys->lambda2[i_row][0][i_index] = CLIP_0A(!i_row ? ACCURACY - (F4(a_2, a_1, i_index) + a_0) / Denom : ACCURACY - (F4(a_2, a_1,(length / p_pic->p->i_pixel_pitch) - i_index) + a_0) / Denom);
1816 p_vout->p_sys->cstYUV2[i_row][0][i_index] = ((ACCURACY - p_vout->p_sys->lambda2[i_row][0][i_index]) * constantYUV[0]) / ACCURACY;
1817 p_vout->p_sys->lambda2[i_row][1][i_index] = CLIP_0A(!i_row ? ACCURACY - (F4(a_2, a_1, i_index) + a_0) / Denom : ACCURACY - (F4(a_2, a_1,(length / p_pic->p->i_pixel_pitch) - i_index) + a_0) / Denom);
1818 p_vout->p_sys->cstYUV2[i_row][1][i_index] = ((ACCURACY - p_vout->p_sys->lambda2[i_row][1][i_index]) * constantYUV[1]) / ACCURACY;
1819 // second image pixel
1820 p_vout->p_sys->lambda2[i_row][0][i_index + 1] = CLIP_0A(!i_row ? ACCURACY - (F4(a_2, a_1, i_index + 1) + a_0) / Denom : ACCURACY - (F4(a_2, a_1,(length / p_pic->p->i_pixel_pitch) - (i_index + 1)) + a_0) / Denom);
1821 p_vout->p_sys->cstYUV2[i_row][0][i_index + 1] = ((ACCURACY - p_vout->p_sys->lambda2[i_row][0][i_index]) * constantYUV[0]) / ACCURACY;
1822 p_vout->p_sys->lambda2[i_row][1][i_index + 1] = p_vout->p_sys->lambda2[i_row][1][i_index];
1823 p_vout->p_sys->cstYUV2[i_row][1][i_index + 1] = p_vout->p_sys->cstYUV2[i_row][1][i_index];
1826 case VLC_FOURCC('U','Y','V','Y'): // packed by 2
1827 case VLC_FOURCC('U','Y','N','V'): // packed by 2
1828 case VLC_FOURCC('Y','4','2','2'): // packed by 2
1829 Denom = F2(length / p_pic->p->i_pixel_pitch);
1830 a_2 = p_vout->p_sys->a_2 * (ACCURACY / 100);
1831 a_1 = p_vout->p_sys->a_1 * 2 * p_vout->p_sys->i_halfHeight * (ACCURACY / 100);
1832 a_0 = p_vout->p_sys->a_0 * Denom * (ACCURACY / 100);
1833 for (i_index = 0; i_index < length / p_pic->p->i_pixel_pitch; i_index+=p_pic->p->i_pixel_pitch)
1834 // for each macropixel
1836 // first image pixel
1837 p_vout->p_sys->lambda2[i_row][0][i_index] = CLIP_0A(!i_row ? ACCURACY - (F4(a_2, a_1, i_index) + a_0) / Denom : ACCURACY - (F4(a_2, a_1,(length / p_pic->p->i_pixel_pitch) - i_index) + a_0) / Denom);
1838 p_vout->p_sys->cstYUV2[i_row][0][i_index] = ((ACCURACY - p_vout->p_sys->lambda2[i_col][0][i_index]) * constantYUV[1]) / ACCURACY;
1839 p_vout->p_sys->lambda2[i_row][1][i_index] = CLIP_0A(!i_row ? ACCURACY - (F4(a_2, a_1, i_index) + a_0) / Denom : ACCURACY - (F4(a_2, a_1,(length / p_pic->p->i_pixel_pitch) - i_index) + a_0) / Denom);
1840 p_vout->p_sys->cstYUV2[i_row][1][i_index] = ((ACCURACY - p_vout->p_sys->lambda2[i_row][1][i_index]) * constantYUV[0]) / ACCURACY;
1841 // second image pixel
1842 p_vout->p_sys->lambda2[i_row][0][i_index + 1] = CLIP_0A(!i_row ? ACCURACY - (F4(a_2, a_1, i_index + 1) + a_0) / Denom : ACCURACY - (F4(a_2, a_1,(length / p_pic->p->i_pixel_pitch) - (i_index + 1)) + a_0) / Denom);
1843 p_vout->p_sys->cstYUV2[i_row][0][i_index + 1] = ((ACCURACY - p_vout->p_sys->lambda2[i_row][0][i_index]) * constantYUV[1]) / ACCURACY;
1844 p_vout->p_sys->lambda2[i_row][1][i_index + 1] = p_vout->p_sys->lambda2[i_row][1][i_index];
1845 p_vout->p_sys->cstYUV2[i_row][1][i_index + 1] = p_vout->p_sys->cstYUV2[i_row][1][i_index];
1852 p_out -= TopOffset * p_outpic->p[i_plane].i_pitch;
1854 for (i_index = 0; i_index < length / p_pic->p->i_pixel_pitch; i_index++)
1855 for (i_index2 = 0; i_index2 < i_copy_pitch; i_index2++)
1856 *(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2) = (p_vout->p_sys->lambda2[i_row][i_index2 % p_pic->p->i_pixel_pitch][i_index] *
1857 (*(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2))) / ACCURACY +
1858 p_vout->p_sys->cstYUV2[i_row][i_index2 % p_pic->p->i_pixel_pitch][i_index];
1860 for (i_index = 0; i_index < length / p_pic->p->i_pixel_pitch; i_index++)
1861 for (i_index2 = 0; i_index2 < i_copy_pitch; i_index2++)
1862 *(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2) = p_vout->p_sys->LUT[i_index % p_pic->p->i_pixel_pitch][(p_vout->p_sys->lambda2[i_row][i_index2 % p_pic->p->i_pixel_pitch][i_index] *
1863 (*(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2))) / ACCURACY +
1864 p_vout->p_sys->cstYUV2[i_row][i_index2 % p_pic->p->i_pixel_pitch][i_index]][i_index / p_pic->p->i_pixel_pitch];
1867 p_out += TopOffset * p_outpic->p[i_plane].i_pitch;
1870 // bug for wall filter : fix by CC
1871 // pi_left_skip[i_plane] += i_out_pitch;
1872 pi_left_skip[i_plane] += i_copy_pitch;
1875 vout_UnlinkPicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
1877 vout_DisplayPicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
1882 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
1884 pi_top_skip[i_plane] += p_vout->p_sys->pp_vout[ i_vout ].i_height
1885 * p_pic->p[i_plane].i_lines
1886 / p_vout->output.i_height
1887 * p_pic->p[i_plane].i_pitch;
1891 if (p_vout->p_sys->b_has_changed) p_vout->p_sys->b_has_changed = VLC_FALSE;
1897 /*****************************************************************************
1898 * RemoveAllVout: destroy all the child video output threads
1899 *****************************************************************************/
1900 static void RemoveAllVout( vout_thread_t *p_vout )
1902 while( p_vout->p_sys->i_vout )
1904 --p_vout->p_sys->i_vout;
1905 if( p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].b_active )
1908 p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].p_vout,
1911 p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].p_vout );
1913 p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].p_vout );
1918 /*****************************************************************************
1919 * SendEvents: forward mouse and keyboard events to the parent p_vout
1920 *****************************************************************************/
1921 static int SendEvents( vlc_object_t *p_this, char const *psz_var,
1922 vlc_value_t oldval, vlc_value_t newval, void *_p_vout )
1924 vout_thread_t *p_vout = (vout_thread_t *)_p_vout;
1926 vlc_value_t sentval = newval;
1928 /* Find the video output index */
1929 for( i_vout = 0; i_vout < p_vout->p_sys->i_vout; i_vout++ )
1931 if( p_this == (vlc_object_t *)p_vout->p_sys->pp_vout[ i_vout ].p_vout )
1937 if( i_vout == p_vout->p_sys->i_vout )
1939 return VLC_EGENERIC;
1942 /* Translate the mouse coordinates */
1943 if( !strcmp( psz_var, "mouse-x" ) )
1946 int i_overlap = ((p_vout->p_sys->i_col > 2) ? 0 : 2 * p_vout->p_sys->i_halfLength);
1947 sentval.i_int += (p_vout->output.i_width - i_overlap)
1949 sentval.i_int += p_vout->output.i_width
1951 * (i_vout % p_vout->p_sys->i_col)
1952 / p_vout->p_sys->i_col;
1954 else if( !strcmp( psz_var, "mouse-y" ) )
1957 int i_overlap = ((p_vout->p_sys->i_row > 2) ? 0 : 2 * p_vout->p_sys->i_halfHeight);
1958 sentval.i_int += (p_vout->output.i_height - i_overlap)
1960 sentval.i_int += p_vout->output.i_height
1962 //bug fix in Wall plug-in
1963 // * (i_vout / p_vout->p_sys->i_row)
1964 * (i_vout / p_vout->p_sys->i_col)
1965 / p_vout->p_sys->i_row;
1968 var_Set( p_vout, psz_var, sentval );
1973 /*****************************************************************************
1974 * SendEventsToChild: forward events to the child/children vout
1975 *****************************************************************************/
1976 static int SendEventsToChild( vlc_object_t *p_this, char const *psz_var,
1977 vlc_value_t oldval, vlc_value_t newval, void *p_data )
1980 vout_thread_t *p_vout = (vout_thread_t *)p_this;
1981 int i_row, i_col, i_vout = 0;
1983 for( i_row = 0; i_row < p_vout->p_sys->i_row; i_row++ )
1985 for( i_col = 0; i_col < p_vout->p_sys->i_col; i_col++ )
1987 var_Set( p_vout->p_sys->pp_vout[ i_vout ].p_vout, psz_var, newval);
1988 if( !strcmp( psz_var, "fullscreen" ) ) break;