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 *****************************************************************************/
33 #include "filter_common.h"
35 // add by cedric.cocquebert@supelec.fr
39 // OS CODE DEPENDANT to get display dimensions
46 // #define PACKED_YUV 1
47 #define F2(a) ((a)*(a))
48 #define F4(a,b,x) ((a)*(F2(x))+((b)*(x)))
50 #define RATIO_MAX 2500
51 #define CLIP_01(a) (a < 0.0 ? 0.0 : (a > 1.0 ? 1.0 : a))
52 // #define CLIP_0A(a) (a < 0.0 ? 0.0 : (a > ACCURACY ? ACCURACY : a))
55 /*****************************************************************************
57 *****************************************************************************/
58 static int Create ( vlc_object_t * );
59 static void Destroy ( vlc_object_t * );
61 static int Init ( vout_thread_t * );
62 static void End ( vout_thread_t * );
64 static void RenderPackedYUV ( vout_thread_t *, picture_t * );
66 static void RenderPlanarYUV ( vout_thread_t *, picture_t * );
67 static void RenderPackedRGB ( vout_thread_t *, picture_t * );
69 static void RemoveAllVout ( vout_thread_t *p_vout );
71 static int SendEvents( vlc_object_t *, char const *,
72 vlc_value_t, vlc_value_t, void * );
74 /*****************************************************************************
76 *****************************************************************************/
77 #define COLS_TEXT N_("Number of columns")
78 #define COLS_LONGTEXT N_("Select the number of horizontal video windows in " \
79 "which to split the video")
81 #define ROWS_TEXT N_("Number of rows")
82 #define ROWS_LONGTEXT N_("Select the number of vertical video windows in " \
83 "which to split the video")
85 #define ACTIVE_TEXT N_("Active windows")
86 #define ACTIVE_LONGTEXT N_("Comma separated list of active windows, " \
89 #define CFG_PREFIX "panoramix-"
92 set_description( N_("Panoramix: wall with overlap video filter") );
93 set_shortname( _("Panoramix" ));
94 set_capability( "video filter", 0 );
95 set_category( CAT_VIDEO );
96 set_subcategory( SUBCAT_VIDEO_VFILTER );
98 add_integer( CFG_PREFIX "cols", -1, NULL,
99 COLS_TEXT, COLS_LONGTEXT, VLC_TRUE );
100 add_integer( CFG_PREFIX "rows", -1, NULL,
101 ROWS_TEXT, ROWS_LONGTEXT, VLC_TRUE );
104 #define OFFSET_X_TEXT N_("Offset X offset (automatic compensation)")
105 #define OFFSET_X_LONGTEXT N_("Select if you want an automatic offset in horizontal (in case of misalignment due to autoratio control)")
106 add_bool( CFG_PREFIX "offset-x", 1, NULL, OFFSET_X_TEXT, OFFSET_X_LONGTEXT, VLC_TRUE );
108 #define LENGTH_TEXT N_("length of the overlapping area (in %)")
109 #define LENGTH_LONGTEXT N_("Select in percent the length of the blended zone")
110 add_integer_with_range( CFG_PREFIX "bz-length", 100, 0, 100, NULL, LENGTH_TEXT, LENGTH_LONGTEXT, VLC_TRUE );
112 #define HEIGHT_TEXT N_("height of the overlapping area (in %)")
113 #define HEIGHT_LONGTEXT N_("Select in percent the height of the blended zone (case of 2x2 wall)")
114 add_integer_with_range( CFG_PREFIX "bz-height", 100, 0, 100, NULL, HEIGHT_TEXT, HEIGHT_LONGTEXT, VLC_TRUE );
116 #define ATTENUATION_TEXT N_("Attenuation")
117 #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)")
118 add_bool( CFG_PREFIX "attenuate", 1, NULL, ATTENUATION_TEXT, ATTENUATION_LONGTEXT, VLC_FALSE );
120 #define BEGIN_TEXT N_("Attenuation, begin (in %)")
121 #define BEGIN_LONGTEXT N_("Select in percent the Lagrange coeff of the beginning blended zone")
122 add_integer_with_range( CFG_PREFIX "bz-begin", 0, 0, 100, NULL, BEGIN_TEXT, BEGIN_LONGTEXT, VLC_TRUE );
124 #define MIDDLE_TEXT N_("Attenuation, middle (in %)")
125 #define MIDDLE_LONGTEXT N_("Select in percent the Lagrange coeff of the middle of blended zone")
126 add_integer_with_range( CFG_PREFIX "bz-middle", 50, 0, 100, NULL, MIDDLE_TEXT, MIDDLE_LONGTEXT, VLC_FALSE );
128 #define END_TEXT N_("Attenuation, end (in %)")
129 #define END_LONGTEXT N_("Select in percent the Lagrange coeff of the end of blended zone")
130 add_integer_with_range( CFG_PREFIX "bz-end", 100, 0, 100, NULL, END_TEXT, END_LONGTEXT, VLC_TRUE );
132 #define MIDDLE_POS_TEXT N_("middle position (in %)")
133 #define MIDDLE_POS_LONGTEXT N_("Select in percent (50 is center) the position of the middle point (Lagrange) of blended zone")
134 add_integer_with_range( CFG_PREFIX "bz-middle-pos", 50, 1, 99, NULL, MIDDLE_POS_TEXT, MIDDLE_POS_LONGTEXT, VLC_FALSE );
136 #define RGAMMA_TEXT N_("Gamma (Red) correction")
137 #define RGAMMA_LONGTEXT N_("Select the gamma for the correction of blended zone (Red or Y component)")
138 add_float_with_range( CFG_PREFIX "bz-gamma-red", 1, 0, 5, NULL, RGAMMA_TEXT, RGAMMA_LONGTEXT, VLC_TRUE );
140 #define GGAMMA_TEXT N_("Gamma (Green) correction")
141 #define GGAMMA_LONGTEXT N_("Select the gamma for the correction of blended zone (Green or U component)")
142 add_float_with_range( CFG_PREFIX "bz-gamma-green", 1, 0, 5, NULL, GGAMMA_TEXT, GGAMMA_LONGTEXT, VLC_TRUE );
144 #define BGAMMA_TEXT N_("Gamma (Blue) correction")
145 #define BGAMMA_LONGTEXT N_("Select the gamma for the correction of blended zone (Blue or V component)")
146 add_float_with_range( CFG_PREFIX "bz-gamma-blue", 1, 0, 5, NULL, BGAMMA_TEXT, BGAMMA_LONGTEXT, VLC_TRUE );
148 #define RGAMMA_BC_TEXT N_("Black Crush for Red")
149 #define RGAMMA_BC_LONGTEXT N_("Select the Black Crush of blended zone (Red or Y component)")
150 #define GGAMMA_BC_TEXT N_("Black Crush for Green")
151 #define GGAMMA_BC_LONGTEXT N_("Select the Black Crush of blended zone (Green or U component)")
152 #define BGAMMA_BC_TEXT N_("Black Crush for Blue")
153 #define BGAMMA_BC_LONGTEXT N_("Select the Black Crush of blended zone (Blue or V component)")
155 #define RGAMMA_WC_TEXT N_("White Crush for Red")
156 #define RGAMMA_WC_LONGTEXT N_("Select the White Crush of blended zone (Red or Y component)")
157 #define GGAMMA_WC_TEXT N_("White Crush for Green")
158 #define GGAMMA_WC_LONGTEXT N_("Select the White Crush of blended zone (Green or U component)")
159 #define BGAMMA_WC_TEXT N_("White Crush for Blue")
160 #define BGAMMA_WC_LONGTEXT N_("Select the White Crush of blended zone (Blue or V component)")
162 #define RGAMMA_BL_TEXT N_("Black Level for Red")
163 #define RGAMMA_BL_LONGTEXT N_("Select the Black Level of blended zone (Red or Y component)")
164 #define GGAMMA_BL_TEXT N_("Black Level for Green")
165 #define GGAMMA_BL_LONGTEXT N_("Select the Black Level of blended zone (Green or U component)")
166 #define BGAMMA_BL_TEXT N_("Black Level for Blue")
167 #define BGAMMA_BL_LONGTEXT N_("Select the Black Level of blended zone (Blue or V component)")
169 #define RGAMMA_WL_TEXT N_("White Level for Red")
170 #define RGAMMA_WL_LONGTEXT N_("Select the White Level of blended zone (Red or Y component)")
171 #define GGAMMA_WL_TEXT N_("White Level for Green")
172 #define GGAMMA_WL_LONGTEXT N_("Select the White Level of blended zone (Green or U component)")
173 #define BGAMMA_WL_TEXT N_("White Level for Blue")
174 #define BGAMMA_WL_LONGTEXT N_("Select the White Level of blended zone (Blue or V component)")
175 add_integer_with_range( CFG_PREFIX "bz-blackcrush-red", 140, 0, 255, NULL, RGAMMA_BC_TEXT, RGAMMA_BC_LONGTEXT, VLC_TRUE );
176 add_integer_with_range( CFG_PREFIX "bz-blackcrush-green", 140, 0, 255, NULL, GGAMMA_BC_TEXT, GGAMMA_BC_LONGTEXT, VLC_TRUE );
177 add_integer_with_range( CFG_PREFIX "bz-blackcrush-blue", 140, 0, 255, NULL, BGAMMA_BC_TEXT, BGAMMA_BC_LONGTEXT, VLC_TRUE );
178 add_integer_with_range( CFG_PREFIX "bz-whitecrush-red", 200, 0, 255, NULL, RGAMMA_WC_TEXT, RGAMMA_WC_LONGTEXT, VLC_TRUE );
179 add_integer_with_range( CFG_PREFIX "bz-whitecrush-green", 200, 0, 255, NULL, GGAMMA_WC_TEXT, GGAMMA_WC_LONGTEXT, VLC_TRUE );
180 add_integer_with_range( CFG_PREFIX "bz-whitecrush-blue", 200, 0, 255, NULL, BGAMMA_WC_TEXT, BGAMMA_WC_LONGTEXT, VLC_TRUE );
181 add_integer_with_range( CFG_PREFIX "bz-blacklevel-red", 150, 0, 255, NULL, RGAMMA_BL_TEXT, RGAMMA_BL_LONGTEXT, VLC_TRUE );
182 add_integer_with_range( CFG_PREFIX "bz-blacklevel-green", 150, 0, 255, NULL, GGAMMA_BL_TEXT, GGAMMA_BL_LONGTEXT, VLC_TRUE );
183 add_integer_with_range( CFG_PREFIX "bz-blacklevel-blue", 150, 0, 255, NULL, BGAMMA_BL_TEXT, BGAMMA_BL_LONGTEXT, VLC_TRUE );
184 add_integer_with_range( CFG_PREFIX "bz-whitelevel-red", 0, 0, 255, NULL, RGAMMA_WL_TEXT, RGAMMA_WL_LONGTEXT, VLC_TRUE );
185 add_integer_with_range( CFG_PREFIX "bz-whitelevel-green", 0, 0, 255, NULL, GGAMMA_WL_TEXT, GGAMMA_WL_LONGTEXT, VLC_TRUE );
186 add_integer_with_range( CFG_PREFIX "bz-whitelevel-blue", 0, 0, 255, NULL, BGAMMA_WL_TEXT, BGAMMA_WL_LONGTEXT, VLC_TRUE );
188 #define XINERAMA_TEXT N_("Xinerama option")
189 #define XINERAMA_LONGTEXT N_("Uncheck if you have not used xinerama")
190 add_bool( CFG_PREFIX "xinerama", 1, NULL, XINERAMA_TEXT, XINERAMA_LONGTEXT, VLC_TRUE );
194 add_string( CFG_PREFIX "active", NULL, NULL, ACTIVE_TEXT, ACTIVE_LONGTEXT, VLC_TRUE );
196 add_shortcut( "panoramix" );
197 set_callbacks( Create, Destroy );
200 static const char *ppsz_filter_options[] = {
201 "cols", "rows", "offset-x", "bz-length", "bz-height", "attenuate",
202 "bz-begin", "bz-middle", "bz-end", "bz-middle-pos", "bz-gamma-red",
203 "bz-gamma-green", "bz-gamma-blue", "bz-blackcrush-red",
204 "bz-blackcrush-green", "bz-blackcrush-blue", "bz-whitecrush-red",
205 "bz-whitecrush-green", "bz-whitecrush-blue", "bz-blacklevel-red",
206 "bz-blacklevel-green", "bz-blacklevel-blue", "bz-whitelevel-red",
207 "bz-whitelevel-green", "bz-whitelevel-blue", "xinerama", "active",
211 /*****************************************************************************
212 * vout_sys_t: Wall video output method descriptor
213 *****************************************************************************
214 * This structure is part of the video output thread descriptor.
215 * It describes the Wall specific properties of an output thread.
216 *****************************************************************************/
220 vlc_bool_t b_autocrop;
221 vlc_bool_t b_attenuate;
222 unsigned int bz_length, bz_height, bz_begin, bz_middle, bz_end, bz_middle_pos;
223 unsigned int i_ratio_max;
224 unsigned int i_ratio;
225 unsigned int a_0, a_1, a_2;
226 vlc_bool_t b_has_changed;
227 int lambda[2][VOUT_MAX_PLANES][500];
228 int cstYUV[2][VOUT_MAX_PLANES][500];
229 int lambda2[2][VOUT_MAX_PLANES][500];
230 int cstYUV2[2][VOUT_MAX_PLANES][500];
231 unsigned int i_halfLength;
232 unsigned int i_halfHeight;
236 float f_gamma_red, f_gamma_green, f_gamma_blue;
237 float f_gamma[VOUT_MAX_PLANES];
238 uint8_t LUT[VOUT_MAX_PLANES][ACCURACY + 1][256];
240 uint8_t LUT2[VOUT_MAX_PLANES][256][500];
244 vlc_bool_t b_xinerama;
255 vout_thread_t *p_vout;
261 /*****************************************************************************
262 * Control: control facility for the vout (forwards to child vout)
263 *****************************************************************************/
264 static int Control( vout_thread_t *p_vout, int i_query, va_list args )
266 int i_row, i_col, i_vout = 0;
268 for( i_row = 0; i_row < p_vout->p_sys->i_row; i_row++ )
270 for( i_col = 0; i_col < p_vout->p_sys->i_col; i_col++ )
272 vout_vaControl( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
280 /*****************************************************************************
281 * Create: allocates Wall video thread output method
282 *****************************************************************************
283 * This function allocates and initializes a Wall vout method.
284 *****************************************************************************/
285 static int Create( vlc_object_t *p_this )
287 vout_thread_t *p_vout = (vout_thread_t *)p_this;
288 char *psz_method, *psz_tmp, *psz_method_tmp;
291 /* Allocate structure */
292 p_vout->p_sys = malloc( sizeof( vout_sys_t ) );
293 if( p_vout->p_sys == NULL )
295 msg_Err( p_vout, "out of memory" );
299 p_vout->pf_init = Init;
300 p_vout->pf_end = End;
301 p_vout->pf_manage = NULL;
302 /* Color Format not supported
303 // Planar Y, packed UV
304 case VLC_FOURCC('Y','M','G','A'):
305 // Packed YUV 4:2:2, U:Y:V:Y, interlaced
306 case VLC_FOURCC('I','U','Y','V'): // packed by 2
307 // Packed YUV 2:1:1, Y:U:Y:V
308 case VLC_FOURCC('Y','2','1','1'): // packed by 4
309 // Packed YUV Reverted
310 case VLC_FOURCC('c','y','u','v'): // packed by 2
312 switch (p_vout->render.i_chroma)
315 case VLC_FOURCC('I','4','4','4'):
316 case VLC_FOURCC('I','4','2','2'):
317 case VLC_FOURCC('I','4','2','0'):
318 case VLC_FOURCC('Y','V','1','2'):
319 case VLC_FOURCC('I','Y','U','V'):
320 case VLC_FOURCC('I','4','1','1'):
321 case VLC_FOURCC('I','4','1','0'):
322 case VLC_FOURCC('Y','V','U','9'):
323 case VLC_FOURCC('Y','U','V','A'):
324 p_vout->pf_render = RenderPlanarYUV;
327 case VLC_FOURCC('R','G','B','2'): // packed by 1
328 case VLC_FOURCC('R','V','1','5'): // packed by 2
329 case VLC_FOURCC('R','V','1','6'): // packed by 2
330 case VLC_FOURCC('R','V','2','4'): // packed by 3
331 case VLC_FOURCC('R','V','3','2'): // packed by 4
332 p_vout->pf_render = RenderPackedRGB;
336 case VLC_FOURCC('Y','U','Y','2'): // packed by 2
337 case VLC_FOURCC('Y','U','N','V'): // packed by 2
338 case VLC_FOURCC('U','Y','V','Y'): // packed by 2
339 case VLC_FOURCC('U','Y','N','V'): // packed by 2
340 case VLC_FOURCC('Y','4','2','2'): // packed by 2
341 p_vout->pf_render = RenderPackedYUV;
345 msg_Err( p_vout, "colorspace not supported by plug-in !!!");
346 free( p_vout->p_sys );
349 p_vout->pf_display = NULL;
350 p_vout->pf_control = Control;
352 config_ChainParse( p_vout, CFG_PREFIX, ppsz_filter_options,
355 /* Look what method was requested */
356 p_vout->p_sys->i_col = var_CreateGetInteger( p_vout, CFG_PREFIX "cols" );
357 p_vout->p_sys->i_row = var_CreateGetInteger( p_vout, CFG_PREFIX "rows" );
359 // OS dependant code : Autodetect number of displays in wall
361 if ((p_vout->p_sys->i_col < 0) || (p_vout->p_sys->i_row < 0) )
363 int nbMonitors = GetSystemMetrics(SM_CMONITORS);
366 nbMonitors = 5; // 1 display => 5x1 simulation
367 p_vout->p_sys->i_col = nbMonitors;
368 p_vout->p_sys->i_row = 1;
372 p_vout->p_sys->i_col = GetSystemMetrics( SM_CXVIRTUALSCREEN ) / GetSystemMetrics( SM_CXSCREEN );
373 p_vout->p_sys->i_row = GetSystemMetrics( SM_CYVIRTUALSCREEN ) / GetSystemMetrics( SM_CYSCREEN );
374 if (p_vout->p_sys->i_col * p_vout->p_sys->i_row != nbMonitors)
376 p_vout->p_sys->i_col = nbMonitors;
377 p_vout->p_sys->i_row = 1;
380 var_SetInteger( p_vout, CFG_PREFIX "cols", p_vout->p_sys->i_col);
381 var_SetInteger( p_vout, CFG_PREFIX "rows", p_vout->p_sys->i_row);
386 p_vout->p_sys->i_offset_x = var_CreateGetInteger( p_vout, CFG_PREFIX "offset-x" );
387 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
388 p_vout->p_sys->b_autocrop = !(var_CreateGetInteger( p_vout, "crop-ratio" ) == 0);
389 if (!p_vout->p_sys->b_autocrop) p_vout->p_sys->b_autocrop = var_CreateGetInteger( p_vout, "autocrop" );
390 p_vout->p_sys->b_attenuate = var_CreateGetInteger( p_vout, CFG_PREFIX "attenuate");
391 p_vout->p_sys->bz_length = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-length" );
392 if (p_vout->p_sys->i_row > 1)
393 p_vout->p_sys->bz_height = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-height" );
395 p_vout->p_sys->bz_height = 100;
396 p_vout->p_sys->bz_begin = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-begin" );
397 p_vout->p_sys->bz_middle = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-middle" );
398 p_vout->p_sys->bz_end = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-end" );
399 p_vout->p_sys->bz_middle_pos = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-middle-pos" );
400 double d_p = 100.0 / p_vout->p_sys->bz_middle_pos;
401 p_vout->p_sys->i_ratio_max = var_CreateGetInteger( p_vout, "autocrop-ratio-max" ); // in crop module with autocrop ...
402 p_vout->p_sys->i_ratio = var_CreateGetInteger( p_vout, "crop-ratio" ); // in crop module with manual ratio ...
404 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;
405 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;
406 p_vout->p_sys->a_0 = p_vout->p_sys->bz_begin;
409 p_vout->p_sys->f_gamma_red = var_CreateGetFloat( p_vout, CFG_PREFIX "bz-gamma-red" );
410 p_vout->p_sys->f_gamma_green = var_CreateGetFloat( p_vout, CFG_PREFIX "bz-gamma-green" );
411 p_vout->p_sys->f_gamma_blue = var_CreateGetFloat( p_vout, CFG_PREFIX "bz-gamma-blue" );
414 p_vout->p_sys->b_xinerama= var_CreateGetInteger( p_vout, CFG_PREFIX "xinerama" );
417 p_vout->p_sys->i_col = __MAX( 1, __MIN( 15, p_vout->p_sys->i_col ) );
418 p_vout->p_sys->i_row = __MAX( 1, __MIN( 15, p_vout->p_sys->i_row ) );
421 msg_Dbg( p_vout, "opening a %i x %i wall",
422 p_vout->p_sys->i_col, p_vout->p_sys->i_row );
424 p_vout->p_sys->pp_vout = malloc( p_vout->p_sys->i_row *
425 p_vout->p_sys->i_col *
426 sizeof(struct vout_list_t) );
427 if( p_vout->p_sys->pp_vout == NULL )
429 msg_Err( p_vout, "out of memory" );
430 free( p_vout->p_sys );
435 psz_method = var_CreateGetNonEmptyString( p_vout, CFG_PREFIX "active" );
437 /* If no trailing vout are specified, take them all */
438 if( psz_method == NULL )
440 for( i_vout = p_vout->p_sys->i_row * p_vout->p_sys->i_col;
443 p_vout->p_sys->pp_vout[i_vout].b_active = 1;
446 /* If trailing vout are specified, activate only the requested ones */
449 for( i_vout = p_vout->p_sys->i_row * p_vout->p_sys->i_col;
452 p_vout->p_sys->pp_vout[i_vout].b_active = 0;
457 psz_tmp = psz_method;
458 while( *psz_tmp && *psz_tmp != ',' )
466 i_vout = atoi( psz_method );
467 psz_method = psz_tmp + 1;
471 i_vout = atoi( psz_method );
472 psz_method = psz_tmp;
476 i_vout < p_vout->p_sys->i_row * p_vout->p_sys->i_col )
478 p_vout->p_sys->pp_vout[i_vout].b_active = 1;
483 free( psz_method_tmp );
490 /*****************************************************************************
491 * CLIP_0A: clip between 0 and ACCURACY
492 *****************************************************************************/
493 inline static int CLIP_0A( int a )
495 return (a > ACCURACY) ? ACCURACY : (a < 0) ? 0 : a;
499 /*****************************************************************************
500 * Gamma: Gamma correction
501 *****************************************************************************/
502 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])
506 f_Input = (f_component * f_BlackLevel[i_plane]) / (f_BlackCrush[i_plane]) + (1.0 - f_BlackLevel[i_plane]);
507 if (f_component <= f_BlackCrush[i_plane])
508 return pow(f_Input, 1.0 / f_Gamma[i_plane]);
509 else if (f_component >= f_WhiteCrush[i_plane])
511 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);
512 return pow(f_Input, 1.0 / f_Gamma[i_plane]);
520 /*****************************************************************************
521 * F: Function to calculate Gamma correction
522 *****************************************************************************/
523 static uint8_t F(uint8_t i, float gamma)
525 double input = (double) i / 255.0;
527 // return clip(255 * pow(input, 1.0 / gamma));
530 return clip_uint8((255 * pow(2 * input, gamma)) / 2);
532 return clip_uint8(255 * (1 - pow(2 * (1 - input), gamma) / 2));
538 /*****************************************************************************
539 * AdjustHeight: ajust p_sys->i_height to have same BZ width for any ratio
540 *****************************************************************************/
541 static int AdjustHeight( vout_thread_t *p_vout )
543 vlc_bool_t b_fullscreen = var_CreateGetInteger( p_vout, "fullscreen" );
544 int i_window_width = p_vout->i_window_width;
545 int i_window_height = p_vout->i_window_height;
546 double d_halfLength = 0;
547 double d_halfLength_crop;
548 double d_halfLength_calculated;
551 // OS DEPENDANT CODE to get display dimensions
555 i_window_width = GetSystemMetrics(SM_CXSCREEN);
556 i_window_height = GetSystemMetrics(SM_CYSCREEN);
558 Display *p_display = XOpenDisplay( "" );
559 if (p_vout->p_sys->b_xinerama)
561 i_window_width = DisplayWidth(p_display, 0) / p_vout->p_sys->i_col;
562 i_window_height = DisplayHeight(p_display, 0) / p_vout->p_sys->i_row;
566 i_window_width = DisplayWidth(p_display, 0);
567 i_window_height = DisplayHeight(p_display, 0);
569 XCloseDisplay( p_display );
572 var_SetInteger( p_vout, "width", i_window_width);
573 var_SetInteger( p_vout, "height", i_window_height);
574 p_vout->i_window_width = i_window_width;
575 p_vout->i_window_height = i_window_height;
578 if (p_vout->p_sys->bz_length)
579 if ((!p_vout->p_sys->b_autocrop) && (!p_vout->p_sys->i_ratio))
581 if ((p_vout->p_sys->i_row > 1) || (p_vout->p_sys->i_col > 1))
583 while ((d_halfLength <= 0) || (d_halfLength > p_vout->render.i_width / (2 * p_vout->p_sys->i_col)))
585 if (p_vout->p_sys->bz_length >= 50)
586 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);
589 d_halfLength = (p_vout->render.i_width * p_vout->p_sys->bz_length) / (100.0 * p_vout->p_sys->i_col);
590 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);
592 if ((d_halfLength <= 0) || (d_halfLength > p_vout->render.i_width / (2 * p_vout->p_sys->i_col))) p_vout->p_sys->i_row--;
593 if (p_vout->p_sys->i_row < 1 )
595 p_vout->p_sys->i_row = 1;
599 p_vout->p_sys->i_halfLength = (d_halfLength + 0.5);
600 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;
601 var_SetInteger( p_vout, "bz-length", p_vout->p_sys->bz_length);
602 var_SetInteger( p_vout, "panoramix-rows", p_vout->p_sys->i_row);
607 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;
608 d_halfLength_crop = d_halfLength * VOUT_ASPECT_FACTOR * (double)p_vout->output.i_width
609 / (double)i_window_height / (double)p_vout->render.i_aspect;
610 p_vout->p_sys->i_halfLength = (d_halfLength_crop + 0.5);
611 d_halfLength_calculated = p_vout->p_sys->i_halfLength * (double)i_window_height *
612 (double)p_vout->render.i_aspect / VOUT_ASPECT_FACTOR / (double)p_vout->output.i_width;
614 if (!p_vout->p_sys->b_attenuate)
616 double d_bz_length = (p_vout->p_sys->i_halfLength * p_vout->p_sys->i_col * 100.0) / p_vout->render.i_width;
617 // F(2x) != 2F(x) in opengl module
618 if (p_vout->p_sys->i_col == 2) d_bz_length = (100.0 * d_bz_length) / (100.0 - d_bz_length) ;
619 var_SetInteger( p_vout, "bz-length", (int)(d_bz_length + 0.5));
621 i_offset = (int)d_halfLength - (int)
622 (p_vout->p_sys->i_halfLength * (double)i_window_height *
623 (double)p_vout->render.i_aspect / VOUT_ASPECT_FACTOR / (double)p_vout->output.i_width);
633 /*****************************************************************************
634 * Init: initialize Wall video thread output method
635 *****************************************************************************/
636 static int Init( vout_thread_t *p_vout )
638 int i_index, i_row, i_col, i_width, i_height;
641 I_OUTPUTPICTURES = 0;
643 /* Initialize the output structure */
644 p_vout->output.i_chroma = p_vout->render.i_chroma;
645 p_vout->output.i_width = p_vout->render.i_width;
646 p_vout->output.i_height = p_vout->render.i_height;
647 p_vout->output.i_aspect = p_vout->render.i_aspect;
649 p_vout->p_sys->b_has_changed = p_vout->p_sys->b_attenuate;
650 int i_video_x = var_GetInteger( p_vout, "video-x");
651 int i_video_y = var_GetInteger( p_vout, "video-y");
653 if (p_vout->p_sys->b_attenuate)
655 int i_index2, i_plane;
656 int constantYUV[3] = {0,128,128};
657 float f_BlackCrush[VOUT_MAX_PLANES];
658 float f_BlackLevel[VOUT_MAX_PLANES];
659 float f_WhiteCrush[VOUT_MAX_PLANES];
660 float f_WhiteLevel[VOUT_MAX_PLANES];
661 p_vout->p_sys->f_gamma[0] = var_CreateGetFloat( p_vout, CFG_PREFIX "bz-gamma-red" );
662 p_vout->p_sys->f_gamma[1] = var_CreateGetFloat( p_vout, CFG_PREFIX "bz-gamma-green" );
663 p_vout->p_sys->f_gamma[2] = var_CreateGetFloat( p_vout, CFG_PREFIX "bz-gamma-blue" );
664 f_BlackCrush[0] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-blackcrush-red" ) / 255.0;
665 f_BlackCrush[1] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-blackcrush-green" ) / 255.0;
666 f_BlackCrush[2] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-blackcrush-blue" ) / 255.0;
667 f_WhiteCrush[0] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-whitecrush-red" ) / 255.0;
668 f_WhiteCrush[1] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-whitecrush-green" ) / 255.0;
669 f_WhiteCrush[2] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-whitecrush-blue" ) / 255.0;
670 f_BlackLevel[0] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-blacklevel-red" ) / 255.0;
671 f_BlackLevel[1] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-blacklevel-green" ) / 255.0;
672 f_BlackLevel[2] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-blacklevel-blue" ) / 255.0;
673 f_WhiteLevel[0] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-whitelevel-red" ) / 255.0;
674 f_WhiteLevel[1] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-whitelevel-green" ) / 255.0;
675 f_WhiteLevel[2] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-whitelevel-blue" ) / 255.0;
676 switch (p_vout->render.i_chroma)
679 case VLC_FOURCC('Y','V','1','2'):
680 case VLC_FOURCC('Y','V','U','9'):
682 case VLC_FOURCC('U','Y','V','Y'): // packed by 2
683 case VLC_FOURCC('U','Y','N','V'): // packed by 2
684 case VLC_FOURCC('Y','4','2','2'): // packed by 2
685 // case VLC_FOURCC('c','y','u','v'): // packed by 2
686 p_vout->p_sys->f_gamma[2] = var_CreateGetFloat( p_vout, CFG_PREFIX "bz-gamma-green" );
687 p_vout->p_sys->f_gamma[1] = var_CreateGetFloat( p_vout, CFG_PREFIX "bz-gamma-blue" );
688 f_BlackCrush[2] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-blackcrush-green" ) / 255.0;
689 f_BlackCrush[1] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-blackcrush-blue" ) / 255.0;
690 f_WhiteCrush[2] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-whitecrush-green" ) / 255.0;
691 f_WhiteCrush[1] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-whitecrush-blue" ) / 255.0;
692 f_BlackLevel[2] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-blacklevel-green" ) / 255.0;
693 f_BlackLevel[1] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-blacklevel-blue" ) / 255.0;
694 f_WhiteLevel[2] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-whitelevel-green" ) / 255.0;
695 f_WhiteLevel[1] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-whitelevel-blue" ) / 255.0;
697 case VLC_FOURCC('I','4','4','4'):
698 case VLC_FOURCC('I','4','2','2'):
699 case VLC_FOURCC('I','4','2','0'):
700 case VLC_FOURCC('I','4','1','1'):
701 case VLC_FOURCC('I','4','1','0'):
702 case VLC_FOURCC('I','Y','U','V'):
703 case VLC_FOURCC('Y','U','V','A'):
705 case VLC_FOURCC('Y','U','Y','2'): // packed by 2
706 case VLC_FOURCC('Y','U','N','V'): // packed by 2
707 for (i_index = 0; i_index < 256; i_index++)
708 for (i_index2 = 0; i_index2 <= ACCURACY; i_index2++)
709 for (i_plane = 0; i_plane < VOUT_MAX_PLANES; i_plane++)
711 float f_lut = CLIP_01(1.0 -
712 ((ACCURACY - (float)i_index2)
713 * Gamma_Correction(i_plane, (float)i_index / 255.0, f_BlackCrush, f_WhiteCrush, f_BlackLevel, f_WhiteLevel, p_vout->p_sys->f_gamma)
715 p_vout->p_sys->LUT[i_plane][i_index2][i_index] = f_lut * i_index + (int)((1.0 - f_lut) * (float)constantYUV[i_plane]);
719 case VLC_FOURCC('R','G','B','2'): // packed by 1
720 case VLC_FOURCC('R','V','1','5'): // packed by 2
721 case VLC_FOURCC('R','V','1','6'): // packed by 2
722 case VLC_FOURCC('R','V','2','4'): // packed by 3
723 case VLC_FOURCC('R','V','3','2'): // packed by 4
724 for (i_index = 0; i_index < 256; i_index++)
725 for (i_index2 = 0; i_index2 <= ACCURACY; i_index2++)
726 for (i_plane = 0; i_plane < VOUT_MAX_PLANES; i_plane++)
728 float f_lut = CLIP_01(1.0 -
729 ((ACCURACY - (float)i_index2)
730 * Gamma_Correction(i_plane, (float)i_index / 255.0, f_BlackCrush, f_WhiteCrush, f_BlackLevel, f_WhiteLevel, p_vout->p_sys->f_gamma)
732 p_vout->p_sys->LUT[i_plane][i_index2][i_index] = f_lut * i_index;
736 msg_Err( p_vout, "colorspace not supported by plug-in !!!");
737 free( p_vout->p_sys );
742 if (p_vout->p_sys->i_offset_x)
743 p_vout->p_sys->i_offset_x = AdjustHeight(p_vout);
745 AdjustHeight(p_vout);
748 /* Try to open the real video output */
749 msg_Dbg( p_vout, "spawning the real video outputs" );
751 p_vout->p_sys->i_vout = 0;
753 /* FIXME: use bresenham instead of those ugly divisions */
754 for( i_row = 0; i_row < p_vout->p_sys->i_row; i_row++ )
756 for( i_col = 0; i_col < p_vout->p_sys->i_col; i_col++ )
760 memset( &fmt, 0, sizeof(video_format_t) );
762 if( i_col + 1 < p_vout->p_sys->i_col )
764 i_width = ( p_vout->render.i_width
765 / p_vout->p_sys->i_col ) & ~0x1;
769 i_width = p_vout->render.i_width
770 - ( ( p_vout->render.i_width
771 / p_vout->p_sys->i_col ) & ~0x1 ) * i_col;
775 i_width += p_vout->p_sys->i_halfLength;
776 if (p_vout->p_sys->i_col > 2 ) i_width += p_vout->p_sys->i_halfLength;
777 i_width -= i_width % 2;
779 if( i_row + 1 < p_vout->p_sys->i_row )
781 i_height = ( p_vout->render.i_height
782 / p_vout->p_sys->i_row ) & ~0x3;
786 i_height = p_vout->render.i_height
787 - ( ( p_vout->render.i_height
788 / p_vout->p_sys->i_row ) & ~0x3 ) * i_row;
792 if (p_vout->p_sys->i_row >= 2)
794 p_vout->p_sys->i_halfHeight = (p_vout->p_sys->i_halfLength * p_vout->p_sys->bz_height) / 100;
795 p_vout->p_sys->i_halfHeight -= (p_vout->p_sys->i_halfHeight % 2);
796 i_height += p_vout->p_sys->i_halfHeight;
797 if (p_vout->p_sys->i_row > 2) i_height += p_vout->p_sys->i_halfHeight;
799 i_height -= i_height % 2;
801 p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].i_width = i_width;
802 p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].i_height = i_height;
804 if( !p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].b_active )
806 p_vout->p_sys->i_vout++;
810 fmt.i_width = fmt.i_visible_width = p_vout->render.i_width;
811 fmt.i_height = fmt.i_visible_height = p_vout->render.i_height;
812 fmt.i_x_offset = fmt.i_y_offset = 0;
813 fmt.i_chroma = p_vout->render.i_chroma;
814 fmt.i_aspect = p_vout->render.i_aspect;
815 fmt.i_sar_num = p_vout->render.i_aspect * fmt.i_height / fmt.i_width;
816 fmt.i_sar_den = VOUT_ASPECT_FACTOR;
817 fmt.i_width = fmt.i_visible_width = i_width;
818 fmt.i_height = fmt.i_visible_height = i_height;
819 fmt.i_aspect = p_vout->render.i_aspect
820 * p_vout->render.i_height / i_height
821 * i_width / p_vout->render.i_width;
823 if (p_vout->p_sys->i_offset_x < 0)
825 var_SetInteger(p_vout, "video-x", -p_vout->p_sys->i_offset_x);
826 p_vout->p_sys->i_offset_x = 0;
829 p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].p_vout =
830 vout_Create( p_vout, &fmt);
832 if( p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].p_vout == NULL )
834 msg_Err( p_vout, "failed to get %ix%i vout threads",
835 p_vout->p_sys->i_col, p_vout->p_sys->i_row );
836 RemoveAllVout( p_vout );
840 p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].p_vout,
843 p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].p_vout->i_alignment = 0;
844 if (i_col == 0) p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].p_vout->i_alignment |= VOUT_ALIGN_RIGHT;
845 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;
846 if (p_vout->p_sys->i_row > 1)
848 if (i_row == 0) p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].p_vout->i_alignment |= VOUT_ALIGN_BOTTOM;
849 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;
851 // i_n : number of active pp_vout
852 int i_index, i_n = p_vout->p_sys->i_vout;
853 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;
854 var_SetInteger( p_vout, "align", p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].p_vout->i_alignment );
855 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);
856 var_SetInteger( p_vout, "video-y",i_video_y + ((i_n + 1) / p_vout->p_sys->i_col) * p_vout->i_window_height);
858 p_vout->p_sys->i_vout++;
862 ALLOCATE_DIRECTBUFFERS( VOUT_MAX_PICTURES );
864 ADD_PARENT_CALLBACKS( SendEventsToChild );
869 /*****************************************************************************
870 * End: terminate Wall video thread output method
871 *****************************************************************************/
872 static void End( vout_thread_t *p_vout )
877 var_SetInteger( p_vout, "bz-length", p_vout->p_sys->bz_length);
879 /* Free the fake output buffers we allocated */
880 for( i_index = I_OUTPUTPICTURES ; i_index ; )
883 free( PP_OUTPUTPICTURE[ i_index ]->p_data_orig );
887 /*****************************************************************************
888 * Destroy: destroy Wall video thread output method
889 *****************************************************************************
890 * Terminate an output method created by WallCreateOutputMethod
891 *****************************************************************************/
892 static void Destroy( vlc_object_t *p_this )
894 vout_thread_t *p_vout = (vout_thread_t *)p_this;
897 DEL_CALLBACKS( p_vout->p_sys->p_vout, SendEvents);
898 vlc_object_detach( p_vout->p_sys->p_vout );
899 vout_Destroy( p_vout->p_sys->p_vout );
900 DEL_PARENT_CALLBACKS( SendEventsToChild);
903 RemoveAllVout( p_vout );
904 DEL_PARENT_CALLBACKS( SendEventsToChild );
906 free( p_vout->p_sys->pp_vout );
907 free( p_vout->p_sys );
911 /*****************************************************************************
912 * RenderPlanarYUV: displays previously rendered output
913 *****************************************************************************
914 * This function send the currently rendered image to Wall image, waits
915 * until it is displayed and switch the two rendering buffers, preparing next
917 *****************************************************************************/
918 static void RenderPlanarYUV( vout_thread_t *p_vout, picture_t *p_pic )
920 picture_t *p_outpic = NULL;
921 int i_col, i_row, i_vout, i_plane;
922 int pi_left_skip[VOUT_MAX_PLANES], pi_top_skip[VOUT_MAX_PLANES];
924 int LeftOffset, TopOffset;
925 int constantYUV[3] = {0,128,128};
930 int i_index, i_index2;
936 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
938 pi_top_skip[i_plane] = 0;
941 for( i_row = 0; i_row < p_vout->p_sys->i_row; i_row++ )
943 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
945 pi_left_skip[i_plane] = 0;
948 for( i_col = 0; i_col < p_vout->p_sys->i_col; i_col++ )
950 if( !p_vout->p_sys->pp_vout[ i_vout ].b_active )
952 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
954 pi_left_skip[i_plane] +=
955 p_vout->p_sys->pp_vout[ i_vout ].i_width
956 * p_pic->p[i_plane].i_pitch / p_vout->output.i_width;
963 vout_CreatePicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
967 if( p_vout->b_die || p_vout->b_error )
970 p_vout->p_sys->pp_vout[ i_vout ].p_vout, p_outpic );
974 msleep( VOUT_OUTMEM_SLEEP );
977 vout_DatePicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
978 p_outpic, p_pic->date );
979 vout_LinkPicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
982 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
984 uint8_t *p_in, *p_in_end, *p_out;
985 int i_in_pitch = p_pic->p[i_plane].i_pitch;
986 int i_out_pitch = p_outpic->p[i_plane].i_pitch;
987 int i_copy_pitch = p_outpic->p[i_plane].i_visible_pitch;
988 int i_lines = p_outpic->p[i_plane].i_visible_lines;
990 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);
991 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);
992 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);
993 if ((!p_vout->p_sys->pp_vout[p_vout->p_sys->i_col].b_active))
994 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);
995 // i_n : previous inactive pp_vout
997 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++;
998 if ((i_col > 1) && i_n)
999 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);
1001 p_in = p_pic->p[i_plane].p_pixels
1002 /* Wall proprities */
1003 + pi_top_skip[i_plane] + pi_left_skip[i_plane];
1005 if ((p_vout->p_sys->i_row > 2) &&
1006 ((!i_row) || (i_row + 1 == p_vout->p_sys->i_row)))
1007 i_lines -= (2 * p_vout->p_sys->i_halfHeight) / (p_vout->p_sys->pp_vout[i_vout].i_width / i_copy_pitch);
1009 // 1088 lines bug in a mpeg2 stream of 1080 lines
1010 if ((p_vout->p_sys->i_row - 1 == i_row) &&
1011 (p_pic->p[i_plane].i_lines == 1088))
1012 i_lines -= 8 / (p_vout->p_sys->pp_vout[i_vout].i_width / i_copy_pitch);
1014 p_in_end = p_in + i_lines * p_pic->p[i_plane].i_pitch;
1016 p_in = p_pic->p[i_plane].p_pixels
1017 + pi_top_skip[i_plane] + pi_left_skip[i_plane];
1019 p_in_end = p_in + i_lines * p_pic->p[i_plane].i_pitch;
1021 p_out = p_outpic->p[i_plane].p_pixels;
1023 if ((p_vout->p_sys->i_row > 2) && (!i_row))
1024 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));
1028 length = 2 * p_vout->p_sys->i_halfLength / (p_vout->p_sys->pp_vout[i_vout].i_width / i_copy_pitch);
1030 if (p_vout->p_sys->b_has_changed)
1033 a_2 = p_vout->p_sys->a_2 * (ACCURACY / 100);
1034 a_1 = p_vout->p_sys->a_1 * length * (ACCURACY / 100);
1035 a_0 = p_vout->p_sys->a_0 * Denom * (ACCURACY / 100);
1036 for(i_col_mod = 0; i_col_mod < 2; i_col_mod++)
1037 for (i_index = 0; i_index < length; i_index++)
1039 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);
1040 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;
1044 while( p_in < p_in_end )
1047 p_vout->p_libvlc->pf_memcpy( p_out , p_in, i_copy_pitch);
1049 if (p_vout->p_sys->i_col > 2)
1053 p_vout->p_libvlc->pf_memcpy( p_out + length , p_in, i_copy_pitch - length);
1054 else if (i_col + 1 == p_vout->p_sys->i_col)
1055 p_vout->p_libvlc->pf_memcpy( p_out, p_in - length, i_copy_pitch - length);
1057 p_vout->p_libvlc->pf_memcpy( p_out, p_in - length, i_copy_pitch);
1063 p_out += LeftOffset;
1064 memset(p_out, constantYUV[i_plane], length);
1065 p_out -= LeftOffset;
1067 else if ((i_col + 1 == p_vout->p_sys->i_col ))
1070 LeftOffset = i_copy_pitch - length;
1071 p_out += LeftOffset;
1072 memset(p_out, constantYUV[i_plane], length);
1073 p_out -= LeftOffset;
1078 p_vout->p_libvlc->pf_memcpy( p_out , p_in, i_copy_pitch);
1080 if (p_vout->p_sys->b_attenuate)
1083 // first blended zone
1087 p_out += LeftOffset;
1088 for (i_index = 0; i_index < length; i_index++)
1091 *(p_out + i_index) = (p_vout->p_sys->lambda[1][i_plane][i_index] *
1092 (*(p_out + i_index))) / ACCURACY +
1093 p_vout->p_sys->cstYUV[1][i_plane][i_index];
1095 *(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)];
1098 p_out -= LeftOffset;
1100 // second blended zone
1101 if (i_col + 1 < p_vout->p_sys->i_col)
1103 LeftOffset = i_copy_pitch - length;
1104 p_out += LeftOffset;
1105 for (i_index = 0; i_index < length; i_index++)
1108 *(p_out + i_index) = (p_vout->p_sys->lambda[0][i_plane][i_index] *
1109 (*(p_out + i_index))) / ACCURACY +
1110 p_vout->p_sys->cstYUV[0][i_plane][i_index];
1113 *(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)];
1116 p_out -= LeftOffset;
1122 p_out += i_out_pitch;
1126 if (!p_vout->p_sys->b_attenuate)
1128 if ((i_row == 0) && (p_vout->p_sys->i_row > 2))
1131 int height = 2 * p_vout->p_sys->i_halfHeight / (p_vout->p_sys->pp_vout[i_vout].i_width / i_copy_pitch);
1132 TopOffset = i_lines + (2 * p_vout->p_sys->i_halfHeight) / (p_vout->p_sys->pp_vout[i_vout].i_width / i_copy_pitch);
1133 p_out -= TopOffset * p_outpic->p[i_plane].i_pitch;
1134 for (i_index = 0; i_index < height; i_index++)
1135 for (i_index2 = 0; i_index2 < i_copy_pitch; i_index2++)
1136 *(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2) = constantYUV[i_plane];
1137 p_out += TopOffset * p_outpic->p[i_plane].i_pitch;
1139 else if ((i_row + 1 == p_vout->p_sys->i_row) && (p_vout->p_sys->i_row > 2))
1142 int height = 2 * p_vout->p_sys->i_halfHeight / (p_vout->p_sys->pp_vout[i_vout].i_width / i_copy_pitch);
1143 TopOffset = height - (2 * p_vout->p_sys->i_halfHeight) / (p_vout->p_sys->pp_vout[i_vout].i_width / i_copy_pitch);
1144 p_out -= TopOffset * p_outpic->p[i_plane].i_pitch;
1145 for (i_index = 0; i_index < height; i_index++)
1146 for (i_index2 = 0; i_index2 < i_copy_pitch; i_index2++)
1147 *(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2) = constantYUV[i_plane];
1148 p_out += TopOffset * p_outpic->p[i_plane].i_pitch;
1153 if (p_vout->p_sys->i_row >= 2)
1155 length = 2 * p_vout->p_sys->i_halfHeight / (p_vout->p_sys->pp_vout[i_vout].i_width / i_copy_pitch);
1156 if (p_vout->p_sys->b_has_changed)
1159 a_2 = p_vout->p_sys->a_2 * (ACCURACY / 100);
1160 a_1 = p_vout->p_sys->a_1 * length * (ACCURACY / 100);
1161 a_0 = p_vout->p_sys->a_0 * Denom * (ACCURACY / 100);
1162 for(i_col_mod = 0; i_col_mod < 2; i_col_mod++)
1163 for (i_index = 0; i_index < length; i_index++)
1165 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);
1166 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;
1169 // first blended zone
1173 TopOffset = i_lines;
1174 p_out -= TopOffset * p_outpic->p[i_plane].i_pitch;
1175 for (i_index = 0; i_index < length; i_index++)
1176 for (i_index2 = 0; i_index2 < i_copy_pitch; i_index2++)
1178 *(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2) = (p_vout->p_sys->lambda2[1][i_plane][i_index] *
1179 (*(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2))) / ACCURACY +
1180 p_vout->p_sys->cstYUV2[1][i_plane][i_index];
1183 *(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)];
1185 p_out += TopOffset * p_outpic->p[i_plane].i_pitch;
1187 else if (p_vout->p_sys->i_row > 2)
1190 TopOffset = i_lines + (2 * p_vout->p_sys->i_halfHeight) / (p_vout->p_sys->pp_vout[i_vout].i_width / i_copy_pitch);
1191 p_out -= TopOffset * p_outpic->p[i_plane].i_pitch;
1192 for (i_index = 0; i_index < length; i_index++)
1193 for (i_index2 = 0; i_index2 < i_copy_pitch; i_index2++)
1194 *(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2) = constantYUV[i_plane];
1195 p_out += TopOffset * p_outpic->p[i_plane].i_pitch;
1198 // second blended zone
1200 if (i_row + 1 < p_vout->p_sys->i_row)
1203 p_out -= TopOffset * p_outpic->p[i_plane].i_pitch;
1204 for (i_index = 0; i_index < length; i_index++)
1205 for (i_index2 = 0; i_index2 < i_copy_pitch; i_index2++)
1207 *(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2) = (p_vout->p_sys->lambda2[0][i_plane][i_index] *
1208 (*(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2))) / ACCURACY +
1209 p_vout->p_sys->cstYUV2[0][i_plane][i_index];
1212 *(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)];
1215 p_out += TopOffset * p_outpic->p[i_plane].i_pitch;
1217 else if (p_vout->p_sys->i_row > 2)
1220 TopOffset = length - (2 * p_vout->p_sys->i_halfHeight) / (p_vout->p_sys->pp_vout[i_vout].i_width / i_copy_pitch);
1221 p_out -= TopOffset * p_outpic->p[i_plane].i_pitch;
1222 for (i_index = 0; i_index < length; i_index++)
1223 for (i_index2 = 0; i_index2 < i_copy_pitch; i_index2++)
1224 *(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2) = constantYUV[i_plane];
1225 p_out += TopOffset * p_outpic->p[i_plane].i_pitch;
1231 // bug for wall filter : fix by CC
1232 // pi_left_skip[i_plane] += i_out_pitch;
1233 pi_left_skip[i_plane] += i_copy_pitch;
1236 vout_UnlinkPicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
1238 vout_DisplayPicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
1243 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
1245 pi_top_skip[i_plane] += p_vout->p_sys->pp_vout[ i_vout ].i_height
1246 * p_pic->p[i_plane].i_lines
1247 / p_vout->output.i_height
1248 * p_pic->p[i_plane].i_pitch;
1253 if (p_vout->p_sys->b_has_changed) p_vout->p_sys->b_has_changed = VLC_FALSE;
1258 /*****************************************************************************
1259 * RenderPackedRGB: displays previously rendered output
1260 *****************************************************************************
1261 * This function send the currently rendered image to Wall image, waits
1262 * until it is displayed and switch the two rendering buffers, preparing next
1264 *****************************************************************************/
1265 static void RenderPackedRGB( vout_thread_t *p_vout, picture_t *p_pic )
1267 picture_t *p_outpic = NULL;
1268 int i_col, i_row, i_vout, i_plane;
1269 int pi_left_skip[VOUT_MAX_PLANES], pi_top_skip[VOUT_MAX_PLANES];
1271 int LeftOffset, TopOffset;
1276 int i_index, i_index2;
1281 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
1283 pi_top_skip[i_plane] = 0;
1286 for( i_row = 0; i_row < p_vout->p_sys->i_row; i_row++ )
1288 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
1290 pi_left_skip[i_plane] = 0;
1293 for( i_col = 0; i_col < p_vout->p_sys->i_col; i_col++ )
1295 if( !p_vout->p_sys->pp_vout[ i_vout ].b_active )
1297 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
1299 pi_left_skip[i_plane] +=
1300 p_vout->p_sys->pp_vout[ i_vout ].i_width * p_pic->p->i_pixel_pitch;
1307 vout_CreatePicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
1311 if( p_vout->b_die || p_vout->b_error )
1313 vout_DestroyPicture(
1314 p_vout->p_sys->pp_vout[ i_vout ].p_vout, p_outpic );
1318 msleep( VOUT_OUTMEM_SLEEP );
1321 vout_DatePicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
1322 p_outpic, p_pic->date );
1323 vout_LinkPicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
1326 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
1328 uint8_t *p_in, *p_in_end, *p_out;
1329 int i_in_pitch = p_pic->p[i_plane].i_pitch;
1330 int i_out_pitch = p_outpic->p[i_plane].i_pitch;
1331 int i_copy_pitch = p_outpic->p[i_plane].i_visible_pitch;
1334 if (i_col) pi_left_skip[i_plane] -= (2 * p_vout->p_sys->i_halfLength) * p_pic->p->i_pixel_pitch;
1335 if ((i_row) && (!i_col)) pi_top_skip[i_plane] -= (2 * p_vout->p_sys->i_halfHeight * p_pic->p[i_plane].i_pitch);
1336 if ((!p_vout->p_sys->pp_vout[p_vout->p_sys->i_col].b_active))
1337 pi_top_skip[i_plane] -= (2 * p_vout->p_sys->i_halfHeight * i_row * p_pic->p[i_plane].i_pitch);
1338 // i_n : previous inactive pp_vout
1340 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++;
1341 if ((i_col > 1) && i_n)
1342 pi_left_skip[i_plane] -= i_n*(2 * p_vout->p_sys->i_halfLength ) * p_pic->p->i_pixel_pitch;
1344 p_in = p_pic->p[i_plane].p_pixels
1345 /* Wall proprities */
1346 + pi_top_skip[i_plane] + pi_left_skip[i_plane];
1348 int i_lines = p_outpic->p[i_plane].i_visible_lines;
1349 // 1088 lines bug in a mpeg2 stream of 1080 lines
1350 if ((p_vout->p_sys->i_row - 1 == i_row) &&
1351 (p_pic->p[i_plane].i_lines == 1088))
1354 p_in_end = p_in + i_lines * p_pic->p[i_plane].i_pitch;
1356 p_in = p_pic->p[i_plane].p_pixels
1357 + pi_top_skip[i_plane] + pi_left_skip[i_plane];
1359 p_in_end = p_in + p_outpic->p[i_plane].i_visible_lines
1360 * p_pic->p[i_plane].i_pitch;
1363 p_out = p_outpic->p[i_plane].p_pixels;
1367 if ((p_vout->p_sys->i_row > 2) && (!i_row))
1368 p_out += (p_outpic->p[i_plane].i_pitch * (2 * p_vout->p_sys->i_halfHeight) * p_pic->p->i_pixel_pitch);
1371 length = 2 * p_vout->p_sys->i_halfLength * p_pic->p->i_pixel_pitch;
1373 if (p_vout->p_sys->b_has_changed)
1377 Denom = F2(length / p_pic->p->i_pixel_pitch);
1378 a_2 = p_vout->p_sys->a_2 * (ACCURACY / 100);
1379 a_1 = p_vout->p_sys->a_1 * 2 * p_vout->p_sys->i_halfLength * (ACCURACY / 100);
1380 a_0 = p_vout->p_sys->a_0 * Denom * (ACCURACY / 100);
1381 for(i_col_mod = 0; i_col_mod < 2; i_col_mod++)
1382 for (i_index = 0; i_index < length / p_pic->p->i_pixel_pitch; i_index++)
1383 for (i_plane_ = 0; i_plane_ < p_pic->p->i_pixel_pitch; i_plane_++)
1384 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);
1387 while( p_in < p_in_end )
1390 p_vout->p_libvlc->pf_memcpy( p_out, p_in, i_copy_pitch);
1392 if (p_vout->p_sys->i_col > 2)
1397 p_vout->p_libvlc->pf_memcpy( p_out + length, p_in, i_copy_pitch - length);
1398 else if (i_col + 1 == p_vout->p_sys->i_col)
1399 p_vout->p_libvlc->pf_memcpy( p_out, p_in - length, i_copy_pitch - length);
1401 p_vout->p_libvlc->pf_memcpy( p_out, p_in - length, i_copy_pitch);
1407 p_out += LeftOffset;
1409 for (i_index = 0; i_index < length; i_index++)
1410 *(p_out + i_index) = 0;
1411 p_out -= LeftOffset;
1414 else if ((i_col + 1 == p_vout->p_sys->i_col ))
1417 LeftOffset = i_copy_pitch - length;
1418 p_out += LeftOffset;
1420 for (i_index = 0; i_index < length; i_index++)
1421 *(p_out + i_index) = 0;
1422 p_out -= LeftOffset;
1428 p_vout->p_libvlc->pf_memcpy( p_out, p_in, i_copy_pitch);
1431 // first blended zone
1435 p_out += LeftOffset;
1436 for (i_index = 0; i_index < length; i_index++)
1438 *(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] *
1439 (*(p_out + i_index))) / ACCURACY;
1441 *(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)];
1443 p_out -= LeftOffset;
1445 // second blended zone
1446 if (i_col + 1 < p_vout->p_sys->i_col)
1448 LeftOffset = i_copy_pitch - length;
1449 p_out += LeftOffset;
1450 for (i_index = 0; i_index < length; i_index++)
1452 *(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] *
1453 (*(p_out + i_index))) / ACCURACY;
1455 *(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)];
1457 p_out -= LeftOffset;
1462 p_out += i_out_pitch;
1466 if (!p_vout->p_sys->b_attenuate)
1468 if ((i_row == 0) && (p_vout->p_sys->i_row > 2))
1471 TopOffset = i_lines + (2 * p_vout->p_sys->i_halfHeight);
1472 p_out -= TopOffset * p_outpic->p[i_plane].i_pitch;
1473 for (i_index = 0; i_index < length; i_index++)
1474 for (i_index2 = 0; i_index2 < i_copy_pitch; i_index2++)
1475 *(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2) = 0;
1476 p_out += TopOffset * p_outpic->p[i_plane].i_pitch;
1478 else if ((i_row + 1 == p_vout->p_sys->i_row) && (p_vout->p_sys->i_row > 2))
1481 TopOffset = length - (2 * p_vout->p_sys->i_halfHeight);
1482 p_out -= TopOffset * p_outpic->p[i_plane].i_pitch;
1483 for (i_index = 0; i_index < length; i_index++)
1484 for (i_index2 = 0; i_index2 < i_copy_pitch; i_index2++)
1485 *(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2) = 0;
1486 p_out += TopOffset * p_outpic->p[i_plane].i_pitch;
1491 if (p_vout->p_sys->i_row >= 2)
1493 length = 2 * p_vout->p_sys->i_halfHeight;
1494 if (p_vout->p_sys->b_has_changed)
1499 a_2 = p_vout->p_sys->a_2 * (ACCURACY / 100);
1500 a_1 = p_vout->p_sys->a_1 * length * (ACCURACY / 100);
1501 a_0 = p_vout->p_sys->a_0 * Denom * (ACCURACY / 100);
1502 for(i_row_mod = 0; i_row_mod < 2; i_row_mod++)
1503 for (i_index = 0; i_index < length; i_index++)
1504 for (i_plane_ = 0; i_plane_ < p_pic->p->i_pixel_pitch; i_plane_++)
1505 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);
1507 // first blended zone
1511 TopOffset = i_lines;
1512 p_out -= TopOffset * p_outpic->p[i_plane].i_pitch;
1513 for (i_index = 0; i_index < length; i_index++)
1514 for (i_index2 = 0; i_index2 < i_copy_pitch; i_index2++)
1516 *(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] *
1517 (*(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2))) / ACCURACY;
1519 *(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)];
1521 p_out += TopOffset * p_outpic->p[i_plane].i_pitch;
1523 else if (p_vout->p_sys->i_row > 2)
1526 TopOffset = i_lines + (2 * p_vout->p_sys->i_halfHeight);
1527 p_out -= TopOffset * p_outpic->p[i_plane].i_pitch;
1528 for (i_index = 0; i_index < length; i_index++)
1529 for (i_index2 = 0; i_index2 < i_copy_pitch; i_index2++)
1530 *(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2) = 0;
1531 p_out += TopOffset * p_outpic->p[i_plane].i_pitch;
1534 // second blended zone
1536 if (i_row + 1 < p_vout->p_sys->i_row)
1539 p_out -= TopOffset * p_outpic->p[i_plane].i_pitch;
1540 for (i_index = 0; i_index < length; i_index++)
1541 for (i_index2 = 0; i_index2 < i_copy_pitch; i_index2++)
1543 *(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] *
1544 (*(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2))) / ACCURACY;
1546 *(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)];
1549 p_out += TopOffset * p_outpic->p[i_plane].i_pitch;
1551 else if (p_vout->p_sys->i_row > 2)
1554 TopOffset = length - (2 * p_vout->p_sys->i_halfHeight);
1555 p_out -= TopOffset * p_outpic->p[i_plane].i_pitch;
1556 for (i_index = 0; i_index < length; i_index++)
1557 for (i_index2 = 0; i_index2 < i_copy_pitch; i_index2++)
1558 *(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2) = 0;
1559 p_out += TopOffset * p_outpic->p[i_plane].i_pitch;
1565 // bug for wall filter : fix by CC
1566 // pi_left_skip[i_plane] += i_out_pitch;
1567 pi_left_skip[i_plane] += i_copy_pitch;
1570 vout_UnlinkPicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
1572 vout_DisplayPicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
1577 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
1579 pi_top_skip[i_plane] += p_vout->p_sys->pp_vout[ i_vout ].i_height
1580 * p_pic->p[i_plane].i_lines
1581 / p_vout->output.i_height
1582 * p_pic->p[i_plane].i_pitch;
1586 if (p_vout->p_sys->b_has_changed) p_vout->p_sys->b_has_changed = VLC_FALSE;
1592 // WARNING : NO DEBUGGED
1593 /*****************************************************************************
1594 * RenderPackedYUV: displays previously rendered output
1595 *****************************************************************************
1596 * This function send the currently rendered image to Wall image, waits
1597 * until it is displayed and switch the two rendering buffers, preparing next
1599 *****************************************************************************/
1600 static void RenderPackedYUV( vout_thread_t *p_vout, picture_t *p_pic )
1602 picture_t *p_outpic = NULL;
1603 int i_col, i_row, i_vout, i_plane;
1604 int pi_left_skip[VOUT_MAX_PLANES], pi_top_skip[VOUT_MAX_PLANES];
1606 int LeftOffset, TopOffset;
1607 int constantYUV[3] = {0,128,128};
1612 int i_index, i_index2;
1618 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
1620 pi_top_skip[i_plane] = 0;
1623 for( i_row = 0; i_row < p_vout->p_sys->i_row; i_row++ )
1625 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
1627 pi_left_skip[i_plane] = 0;
1630 for( i_col = 0; i_col < p_vout->p_sys->i_col; i_col++ )
1632 if( !p_vout->p_sys->pp_vout[ i_vout ].b_active )
1634 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
1636 pi_left_skip[i_plane] +=
1637 p_vout->p_sys->pp_vout[ i_vout ].i_width
1638 * p_pic->p[i_plane].i_pitch / p_vout->output.i_width;
1645 vout_CreatePicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
1649 if( p_vout->b_die || p_vout->b_error )
1651 vout_DestroyPicture(
1652 p_vout->p_sys->pp_vout[ i_vout ].p_vout, p_outpic );
1656 msleep( VOUT_OUTMEM_SLEEP );
1659 vout_DatePicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
1660 p_outpic, p_pic->date );
1661 vout_LinkPicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
1664 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
1666 uint8_t *p_in, *p_in_end, *p_out;
1667 int i_in_pitch = p_pic->p[i_plane].i_pitch;
1668 int i_out_pitch = p_outpic->p[i_plane].i_pitch;
1669 int i_copy_pitch = p_outpic->p[i_plane].i_visible_pitch;
1672 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);
1673 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);
1674 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);
1675 if ((!p_vout->p_sys->pp_vout[p_vout->p_sys->i_col].b_active))
1676 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);
1677 // i_n : previous inactive pp_vout
1679 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++;
1680 if ((i_col > 1) && i_n)
1681 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);
1683 p_in = p_pic->p[i_plane].p_pixels
1684 /* Wall proprities */
1685 + pi_top_skip[i_plane] + pi_left_skip[i_plane];
1687 int i_lines = p_outpic->p[i_plane].i_visible_lines;
1688 // 1088 lines bug in a mpeg2 stream of 1080 lines
1689 if ((p_vout->p_sys->i_row - 1 == i_row) &&
1690 (p_pic->p[i_plane].i_lines == 1088))
1693 p_in_end = p_in + i_lines * p_pic->p[i_plane].i_pitch;
1695 p_in = p_pic->p[i_plane].p_pixels
1696 + pi_top_skip[i_plane] + pi_left_skip[i_plane];
1698 p_in_end = p_in + p_outpic->p[i_plane].i_visible_lines
1699 * p_pic->p[i_plane].i_pitch;
1701 p_out = p_outpic->p[i_plane].p_pixels;
1704 length = 2 * p_vout->p_sys->i_halfLength * p_pic->p->i_pixel_pitch;
1705 LeftOffset = (i_col ? 0 : i_copy_pitch - length);
1706 if (p_vout->p_sys->b_has_changed)
1710 for (i_index = 0; i_index < length / p_pic->p->i_pixel_pitch; i_index++)
1711 for (i_plane_ = 0; i_plane_ < p_pic->p->i_pixel_pitch; i_plane_++)
1712 for (i_index2 = 0; i_index2 < 256; i_index2++)
1713 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_]));
1715 switch (p_vout->output.i_chroma)
1717 case VLC_FOURCC('Y','U','Y','2'): // packed by 2
1718 case VLC_FOURCC('Y','U','N','V'): // packed by 2
1719 Denom = F2(length / p_pic->p->i_pixel_pitch);
1720 a_2 = p_vout->p_sys->a_2 * (ACCURACY / 100);
1721 a_1 = p_vout->p_sys->a_1 * 2 * p_vout->p_sys->i_halfLength * (ACCURACY / 100);
1722 a_0 = p_vout->p_sys->a_0 * Denom * (ACCURACY / 100);
1723 for (i_index = 0; i_index < length / p_pic->p->i_pixel_pitch; i_index+=p_pic->p->i_pixel_pitch)
1724 // for each macropixel
1726 // first image pixel
1727 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);
1728 p_vout->p_sys->cstYUV[i_col][0][i_index] = ((ACCURACY - p_vout->p_sys->lambda[i_col][0][i_index]) * constantYUV[0]) / ACCURACY;
1729 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);
1730 p_vout->p_sys->cstYUV[i_col][1][i_index] = ((ACCURACY - p_vout->p_sys->lambda[i_col][1][i_index]) * constantYUV[1]) / ACCURACY;
1731 // second image pixel
1732 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);
1733 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;
1734 p_vout->p_sys->lambda[i_col][1][i_index + 1] = p_vout->p_sys->lambda[i_col][1][i_index];
1735 p_vout->p_sys->cstYUV[i_col][1][i_index + 1] = p_vout->p_sys->cstYUV[i_col][1][i_index];
1738 case VLC_FOURCC('U','Y','V','Y'): // packed by 2
1739 case VLC_FOURCC('U','Y','N','V'): // packed by 2
1740 case VLC_FOURCC('Y','4','2','2'): // packed by 2
1741 Denom = F2(length / p_pic->p->i_pixel_pitch);
1742 a_2 = p_vout->p_sys->a_2 * (ACCURACY / 100);
1743 a_1 = p_vout->p_sys->a_1 * 2 * p_vout->p_sys->i_halfLength * (ACCURACY / 100);
1744 a_0 = p_vout->p_sys->a_0 * Denom * (ACCURACY / 100);
1745 for (i_index = 0; i_index < length / p_pic->p->i_pixel_pitch; i_index+=p_pic->p->i_pixel_pitch)
1746 // for each macropixel
1748 // first image pixel
1749 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);
1750 p_vout->p_sys->cstYUV[i_col][0][i_index] = ((ACCURACY - p_vout->p_sys->lambda[i_col][0][i_index]) * constantYUV[1]) / ACCURACY;
1751 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);
1752 p_vout->p_sys->cstYUV[i_col][1][i_index] = ((ACCURACY - p_vout->p_sys->lambda[i_col][1][i_index]) * constantYUV[0]) / ACCURACY;
1753 // second image pixel
1754 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);
1755 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;
1756 p_vout->p_sys->lambda[i_col][1][i_index + 1] = p_vout->p_sys->lambda[i_col][1][i_index];
1757 p_vout->p_sys->cstYUV[i_col][1][i_index + 1] = p_vout->p_sys->cstYUV[i_col][1][i_index];
1765 while( p_in < p_in_end )
1768 p_vout->p_libvlc->pf_memcpy( p_out, p_in, i_copy_pitch);
1770 p_vout->p_libvlc->pf_memcpy( p_out + i_col * length, p_in + i_col * length, i_copy_pitch - length);
1771 p_out += LeftOffset;
1774 for (i_index = 0; i_index < length; i_index++)
1775 *(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] *
1776 (*(p_in + i_index))) / ACCURACY +
1777 p_vout->p_sys->cstYUV[i_col][i_index % p_pic->p->i_pixel_pitch][i_index / p_pic->p->i_pixel_pitch];
1779 for (i_index = 0; i_index < length; i_index++)
1780 *(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] *
1781 (*(p_in + i_index))) / ACCURACY +
1782 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];
1784 p_out -= LeftOffset;
1788 p_out += i_out_pitch;
1791 if (p_vout->p_sys->i_row == 2)
1793 length = 2 * p_vout->p_sys->i_halfHeight * p_pic->p->i_pixel_pitch;
1794 TopOffset = (i_row ? i_lines : length / p_pic->p->i_pixel_pitch);
1795 if (p_vout->p_sys->b_has_changed)
1799 for (i_index = 0; i_index < length / p_pic->p->i_pixel_pitch; i_index++)
1800 for (i_plane_ = 0; i_plane_ < p_pic->p->i_pixel_pitch; i_plane_++)
1801 for (i_index2 = 0; i_index2 < 256; i_index2++)
1802 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_]));
1804 switch (p_vout->output.i_chroma)
1806 case VLC_FOURCC('Y','U','Y','2'): // packed by 2
1807 case VLC_FOURCC('Y','U','N','V'): // packed by 2
1808 Denom = F2(length / p_pic->p->i_pixel_pitch);
1809 a_2 = p_vout->p_sys->a_2 * (ACCURACY / 100);
1810 a_1 = p_vout->p_sys->a_1 * 2 * p_vout->p_sys->i_halfHeight * (ACCURACY / 100);
1811 a_0 = p_vout->p_sys->a_0 * Denom * (ACCURACY / 100);
1812 for (i_index = 0; i_index < length / p_pic->p->i_pixel_pitch; i_index+=p_pic->p->i_pixel_pitch)
1813 // for each macropixel
1815 // first image pixel
1816 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);
1817 p_vout->p_sys->cstYUV2[i_row][0][i_index] = ((ACCURACY - p_vout->p_sys->lambda2[i_row][0][i_index]) * constantYUV[0]) / ACCURACY;
1818 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);
1819 p_vout->p_sys->cstYUV2[i_row][1][i_index] = ((ACCURACY - p_vout->p_sys->lambda2[i_row][1][i_index]) * constantYUV[1]) / ACCURACY;
1820 // second image pixel
1821 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);
1822 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;
1823 p_vout->p_sys->lambda2[i_row][1][i_index + 1] = p_vout->p_sys->lambda2[i_row][1][i_index];
1824 p_vout->p_sys->cstYUV2[i_row][1][i_index + 1] = p_vout->p_sys->cstYUV2[i_row][1][i_index];
1827 case VLC_FOURCC('U','Y','V','Y'): // packed by 2
1828 case VLC_FOURCC('U','Y','N','V'): // packed by 2
1829 case VLC_FOURCC('Y','4','2','2'): // packed by 2
1830 Denom = F2(length / p_pic->p->i_pixel_pitch);
1831 a_2 = p_vout->p_sys->a_2 * (ACCURACY / 100);
1832 a_1 = p_vout->p_sys->a_1 * 2 * p_vout->p_sys->i_halfHeight * (ACCURACY / 100);
1833 a_0 = p_vout->p_sys->a_0 * Denom * (ACCURACY / 100);
1834 for (i_index = 0; i_index < length / p_pic->p->i_pixel_pitch; i_index+=p_pic->p->i_pixel_pitch)
1835 // for each macropixel
1837 // first image pixel
1838 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);
1839 p_vout->p_sys->cstYUV2[i_row][0][i_index] = ((ACCURACY - p_vout->p_sys->lambda2[i_col][0][i_index]) * constantYUV[1]) / ACCURACY;
1840 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);
1841 p_vout->p_sys->cstYUV2[i_row][1][i_index] = ((ACCURACY - p_vout->p_sys->lambda2[i_row][1][i_index]) * constantYUV[0]) / ACCURACY;
1842 // second image pixel
1843 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);
1844 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;
1845 p_vout->p_sys->lambda2[i_row][1][i_index + 1] = p_vout->p_sys->lambda2[i_row][1][i_index];
1846 p_vout->p_sys->cstYUV2[i_row][1][i_index + 1] = p_vout->p_sys->cstYUV2[i_row][1][i_index];
1853 p_out -= TopOffset * p_outpic->p[i_plane].i_pitch;
1855 for (i_index = 0; i_index < length / p_pic->p->i_pixel_pitch; i_index++)
1856 for (i_index2 = 0; i_index2 < i_copy_pitch; i_index2++)
1857 *(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] *
1858 (*(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2))) / ACCURACY +
1859 p_vout->p_sys->cstYUV2[i_row][i_index2 % p_pic->p->i_pixel_pitch][i_index];
1861 for (i_index = 0; i_index < length / p_pic->p->i_pixel_pitch; i_index++)
1862 for (i_index2 = 0; i_index2 < i_copy_pitch; i_index2++)
1863 *(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] *
1864 (*(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2))) / ACCURACY +
1865 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];
1868 p_out += TopOffset * p_outpic->p[i_plane].i_pitch;
1871 // bug for wall filter : fix by CC
1872 // pi_left_skip[i_plane] += i_out_pitch;
1873 pi_left_skip[i_plane] += i_copy_pitch;
1876 vout_UnlinkPicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
1878 vout_DisplayPicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
1883 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
1885 pi_top_skip[i_plane] += p_vout->p_sys->pp_vout[ i_vout ].i_height
1886 * p_pic->p[i_plane].i_lines
1887 / p_vout->output.i_height
1888 * p_pic->p[i_plane].i_pitch;
1892 if (p_vout->p_sys->b_has_changed) p_vout->p_sys->b_has_changed = VLC_FALSE;
1898 /*****************************************************************************
1899 * RemoveAllVout: destroy all the child video output threads
1900 *****************************************************************************/
1901 static void RemoveAllVout( vout_thread_t *p_vout )
1903 while( p_vout->p_sys->i_vout )
1905 --p_vout->p_sys->i_vout;
1906 if( p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].b_active )
1909 p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].p_vout,
1912 p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].p_vout );
1914 p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].p_vout );
1919 /*****************************************************************************
1920 * SendEvents: forward mouse and keyboard events to the parent p_vout
1921 *****************************************************************************/
1922 static int SendEvents( vlc_object_t *p_this, char const *psz_var,
1923 vlc_value_t oldval, vlc_value_t newval, void *_p_vout )
1925 vout_thread_t *p_vout = (vout_thread_t *)_p_vout;
1927 vlc_value_t sentval = newval;
1929 /* Find the video output index */
1930 for( i_vout = 0; i_vout < p_vout->p_sys->i_vout; i_vout++ )
1932 if( p_this == (vlc_object_t *)p_vout->p_sys->pp_vout[ i_vout ].p_vout )
1938 if( i_vout == p_vout->p_sys->i_vout )
1940 return VLC_EGENERIC;
1943 /* Translate the mouse coordinates */
1944 if( !strcmp( psz_var, "mouse-x" ) )
1947 int i_overlap = ((p_vout->p_sys->i_col > 2) ? 0 : 2 * p_vout->p_sys->i_halfLength);
1948 sentval.i_int += (p_vout->output.i_width - i_overlap)
1950 sentval.i_int += p_vout->output.i_width
1952 * (i_vout % p_vout->p_sys->i_col)
1953 / p_vout->p_sys->i_col;
1955 else if( !strcmp( psz_var, "mouse-y" ) )
1958 int i_overlap = ((p_vout->p_sys->i_row > 2) ? 0 : 2 * p_vout->p_sys->i_halfHeight);
1959 sentval.i_int += (p_vout->output.i_height - i_overlap)
1961 sentval.i_int += p_vout->output.i_height
1963 //bug fix in Wall plug-in
1964 // * (i_vout / p_vout->p_sys->i_row)
1965 * (i_vout / p_vout->p_sys->i_col)
1966 / p_vout->p_sys->i_row;
1969 var_Set( p_vout, psz_var, sentval );
1974 /*****************************************************************************
1975 * SendEventsToChild: forward events to the child/children vout
1976 *****************************************************************************/
1977 static int SendEventsToChild( vlc_object_t *p_this, char const *psz_var,
1978 vlc_value_t oldval, vlc_value_t newval, void *p_data )
1981 vout_thread_t *p_vout = (vout_thread_t *)p_this;
1982 int i_row, i_col, i_vout = 0;
1984 for( i_row = 0; i_row < p_vout->p_sys->i_row; i_row++ )
1986 for( i_col = 0; i_col < p_vout->p_sys->i_col; i_col++ )
1988 var_Set( p_vout->p_sys->pp_vout[ i_vout ].p_vout, psz_var, newval);
1989 if( !strcmp( psz_var, "fullscreen" ) ) break;