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 *****************************************************************************/
28 #include <stdlib.h> /* malloc(), free() */
34 #include "filter_common.h"
36 // add by cedric.cocquebert@supelec.fr
40 // OS CODE DEPENDANT to get display dimensions
47 // #define PACKED_YUV 1
48 #define F2(a) ((a)*(a))
49 #define F4(a,b,x) ((a)*(F2(x))+((b)*(x)))
51 #define RATIO_MAX 2500
52 #define CLIP_01(a) (a < 0.0 ? 0.0 : (a > 1.0 ? 1.0 : a))
53 // #define CLIP_0A(a) (a < 0.0 ? 0.0 : (a > ACCURACY ? ACCURACY : a))
56 /*****************************************************************************
58 *****************************************************************************/
59 static int Create ( vlc_object_t * );
60 static void Destroy ( vlc_object_t * );
62 static int Init ( vout_thread_t * );
63 static void End ( vout_thread_t * );
65 static void RenderPackedYUV ( vout_thread_t *, picture_t * );
67 static void RenderPlanarYUV ( vout_thread_t *, picture_t * );
68 static void RenderPackedRGB ( vout_thread_t *, picture_t * );
70 static void RemoveAllVout ( vout_thread_t *p_vout );
72 static int SendEvents( vlc_object_t *, char const *,
73 vlc_value_t, vlc_value_t, void * );
75 /*****************************************************************************
77 *****************************************************************************/
78 #define COLS_TEXT N_("Number of columns")
79 #define COLS_LONGTEXT N_("Select the number of horizontal video windows in " \
80 "which to split the video")
82 #define ROWS_TEXT N_("Number of rows")
83 #define ROWS_LONGTEXT N_("Select the number of vertical video windows in " \
84 "which to split the video")
86 #define ACTIVE_TEXT N_("Active windows")
87 #define ACTIVE_LONGTEXT N_("Comma separated list of active windows, " \
90 #define CFG_PREFIX "panoramix-"
93 set_description( N_("Panoramix: wall with overlap video filter") );
94 set_shortname( _("Panoramix" ));
95 set_capability( "video filter", 0 );
96 set_category( CAT_VIDEO );
97 set_subcategory( SUBCAT_VIDEO_VFILTER );
99 add_integer( CFG_PREFIX "cols", -1, NULL,
100 COLS_TEXT, COLS_LONGTEXT, VLC_TRUE );
101 add_integer( CFG_PREFIX "rows", -1, NULL,
102 ROWS_TEXT, ROWS_LONGTEXT, VLC_TRUE );
105 #define OFFSET_X_TEXT N_("Offset X offset (automatic compensation)")
106 #define OFFSET_X_LONGTEXT N_("Select if you want an automatic offset in horizontal (in case of misalignment due to autoratio control)")
107 add_bool( CFG_PREFIX "offset-x", 1, NULL, OFFSET_X_TEXT, OFFSET_X_LONGTEXT, VLC_TRUE );
109 #define LENGTH_TEXT N_("length of the overlapping area (in %)")
110 #define LENGTH_LONGTEXT N_("Select in percent the length of the blended zone")
111 add_integer_with_range( CFG_PREFIX "bz-length", 100, 0, 100, NULL, LENGTH_TEXT, LENGTH_LONGTEXT, VLC_TRUE );
113 #define HEIGHT_TEXT N_("height of the overlapping area (in %)")
114 #define HEIGHT_LONGTEXT N_("Select in percent the height of the blended zone (case of 2x2 wall)")
115 add_integer_with_range( CFG_PREFIX "bz-height", 100, 0, 100, NULL, HEIGHT_TEXT, HEIGHT_LONGTEXT, VLC_TRUE );
117 #define ATTENUATION_TEXT N_("Attenuation")
118 #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)")
119 add_bool( CFG_PREFIX "attenuate", 1, NULL, ATTENUATION_TEXT, ATTENUATION_LONGTEXT, VLC_FALSE );
121 #define BEGIN_TEXT N_("Attenuation, begin (in %)")
122 #define BEGIN_LONGTEXT N_("Select in percent the Lagrange coeff of the beginning blended zone")
123 add_integer_with_range( CFG_PREFIX "bz-begin", 0, 0, 100, NULL, BEGIN_TEXT, BEGIN_LONGTEXT, VLC_TRUE );
125 #define MIDDLE_TEXT N_("Attenuation, middle (in %)")
126 #define MIDDLE_LONGTEXT N_("Select in percent the Lagrange coeff of the middle of blended zone")
127 add_integer_with_range( CFG_PREFIX "bz-middle", 50, 0, 100, NULL, MIDDLE_TEXT, MIDDLE_LONGTEXT, VLC_FALSE );
129 #define END_TEXT N_("Attenuation, end (in %)")
130 #define END_LONGTEXT N_("Select in percent the Lagrange coeff of the end of blended zone")
131 add_integer_with_range( CFG_PREFIX "bz-end", 100, 0, 100, NULL, END_TEXT, END_LONGTEXT, VLC_TRUE );
133 #define MIDDLE_POS_TEXT N_("middle position (in %)")
134 #define MIDDLE_POS_LONGTEXT N_("Select in percent (50 is center) the position of the middle point (Lagrange) of blended zone")
135 add_integer_with_range( CFG_PREFIX "bz-middle-pos", 50, 1, 99, NULL, MIDDLE_POS_TEXT, MIDDLE_POS_LONGTEXT, VLC_FALSE );
137 #define RGAMMA_TEXT N_("Gamma (Red) correction")
138 #define RGAMMA_LONGTEXT N_("Select the gamma for the correction of blended zone (Red or Y component)")
139 add_float_with_range( CFG_PREFIX "bz-gamma-red", 1, 0, 5, NULL, RGAMMA_TEXT, RGAMMA_LONGTEXT, VLC_TRUE );
141 #define GGAMMA_TEXT N_("Gamma (Green) correction")
142 #define GGAMMA_LONGTEXT N_("Select the gamma for the correction of blended zone (Green or U component)")
143 add_float_with_range( CFG_PREFIX "bz-gamma-green", 1, 0, 5, NULL, GGAMMA_TEXT, GGAMMA_LONGTEXT, VLC_TRUE );
145 #define BGAMMA_TEXT N_("Gamma (Blue) correction")
146 #define BGAMMA_LONGTEXT N_("Select the gamma for the correction of blended zone (Blue or V component)")
147 add_float_with_range( CFG_PREFIX "bz-gamma-blue", 1, 0, 5, NULL, BGAMMA_TEXT, BGAMMA_LONGTEXT, VLC_TRUE );
149 #define RGAMMA_BC_TEXT N_("Black Crush for Red")
150 #define RGAMMA_BC_LONGTEXT N_("Select the Black Crush of blended zone (Red or Y component)")
151 #define GGAMMA_BC_TEXT N_("Black Crush for Green")
152 #define GGAMMA_BC_LONGTEXT N_("Select the Black Crush of blended zone (Green or U component)")
153 #define BGAMMA_BC_TEXT N_("Black Crush for Blue")
154 #define BGAMMA_BC_LONGTEXT N_("Select the Black Crush of blended zone (Blue or V component)")
156 #define RGAMMA_WC_TEXT N_("White Crush for Red")
157 #define RGAMMA_WC_LONGTEXT N_("Select the White Crush of blended zone (Red or Y component)")
158 #define GGAMMA_WC_TEXT N_("White Crush for Green")
159 #define GGAMMA_WC_LONGTEXT N_("Select the White Crush of blended zone (Green or U component)")
160 #define BGAMMA_WC_TEXT N_("White Crush for Blue")
161 #define BGAMMA_WC_LONGTEXT N_("Select the White Crush of blended zone (Blue or V component)")
163 #define RGAMMA_BL_TEXT N_("Black Level for Red")
164 #define RGAMMA_BL_LONGTEXT N_("Select the Black Level of blended zone (Red or Y component)")
165 #define GGAMMA_BL_TEXT N_("Black Level for Green")
166 #define GGAMMA_BL_LONGTEXT N_("Select the Black Level of blended zone (Green or U component)")
167 #define BGAMMA_BL_TEXT N_("Black Level for Blue")
168 #define BGAMMA_BL_LONGTEXT N_("Select the Black Level of blended zone (Blue or V component)")
170 #define RGAMMA_WL_TEXT N_("White Level for Red")
171 #define RGAMMA_WL_LONGTEXT N_("Select the White Level of blended zone (Red or Y component)")
172 #define GGAMMA_WL_TEXT N_("White Level for Green")
173 #define GGAMMA_WL_LONGTEXT N_("Select the White Level of blended zone (Green or U component)")
174 #define BGAMMA_WL_TEXT N_("White Level for Blue")
175 #define BGAMMA_WL_LONGTEXT N_("Select the White Level of blended zone (Blue or V component)")
176 add_integer_with_range( CFG_PREFIX "bz-blackcrush-red", 140, 0, 255, NULL, RGAMMA_BC_TEXT, RGAMMA_BC_LONGTEXT, VLC_TRUE );
177 add_integer_with_range( CFG_PREFIX "bz-blackcrush-green", 140, 0, 255, NULL, GGAMMA_BC_TEXT, GGAMMA_BC_LONGTEXT, VLC_TRUE );
178 add_integer_with_range( CFG_PREFIX "bz-blackcrush-blue", 140, 0, 255, NULL, BGAMMA_BC_TEXT, BGAMMA_BC_LONGTEXT, VLC_TRUE );
179 add_integer_with_range( CFG_PREFIX "bz-whitecrush-red", 200, 0, 255, NULL, RGAMMA_WC_TEXT, RGAMMA_WC_LONGTEXT, VLC_TRUE );
180 add_integer_with_range( CFG_PREFIX "bz-whitecrush-green", 200, 0, 255, NULL, GGAMMA_WC_TEXT, GGAMMA_WC_LONGTEXT, VLC_TRUE );
181 add_integer_with_range( CFG_PREFIX "bz-whitecrush-blue", 200, 0, 255, NULL, BGAMMA_WC_TEXT, BGAMMA_WC_LONGTEXT, VLC_TRUE );
182 add_integer_with_range( CFG_PREFIX "bz-blacklevel-red", 150, 0, 255, NULL, RGAMMA_BL_TEXT, RGAMMA_BL_LONGTEXT, VLC_TRUE );
183 add_integer_with_range( CFG_PREFIX "bz-blacklevel-green", 150, 0, 255, NULL, GGAMMA_BL_TEXT, GGAMMA_BL_LONGTEXT, VLC_TRUE );
184 add_integer_with_range( CFG_PREFIX "bz-blacklevel-blue", 150, 0, 255, NULL, BGAMMA_BL_TEXT, BGAMMA_BL_LONGTEXT, VLC_TRUE );
185 add_integer_with_range( CFG_PREFIX "bz-whitelevel-red", 0, 0, 255, NULL, RGAMMA_WL_TEXT, RGAMMA_WL_LONGTEXT, VLC_TRUE );
186 add_integer_with_range( CFG_PREFIX "bz-whitelevel-green", 0, 0, 255, NULL, GGAMMA_WL_TEXT, GGAMMA_WL_LONGTEXT, VLC_TRUE );
187 add_integer_with_range( CFG_PREFIX "bz-whitelevel-blue", 0, 0, 255, NULL, BGAMMA_WL_TEXT, BGAMMA_WL_LONGTEXT, VLC_TRUE );
189 #define XINERAMA_TEXT N_("Xinerama option")
190 #define XINERAMA_LONGTEXT N_("Uncheck if you have not used xinerama")
191 add_bool( CFG_PREFIX "xinerama", 1, NULL, XINERAMA_TEXT, XINERAMA_LONGTEXT, VLC_TRUE );
195 add_string( CFG_PREFIX "active", NULL, NULL, ACTIVE_TEXT, ACTIVE_LONGTEXT, VLC_TRUE );
197 add_shortcut( "panoramix" );
198 set_callbacks( Create, Destroy );
201 static const char *ppsz_filter_options[] = {
202 "cols", "rows", "offset-x", "bz-length", "bz-height", "attenuate",
203 "bz-begin", "bz-middle", "bz-end", "bz-middle-pos", "bz-gamma-red",
204 "bz-gamma-green", "bz-gamma-blue", "bz-blackcrush-red",
205 "bz-blackcrush-green", "bz-blackcrush-blue", "bz-whitecrush-red",
206 "bz-whitecrush-green", "bz-whitecrush-blue", "bz-blacklevel-red",
207 "bz-blacklevel-green", "bz-blacklevel-blue", "bz-whitelevel-red",
208 "bz-whitelevel-green", "bz-whitelevel-blue", "xinerama", "active",
212 /*****************************************************************************
213 * vout_sys_t: Wall video output method descriptor
214 *****************************************************************************
215 * This structure is part of the video output thread descriptor.
216 * It describes the Wall specific properties of an output thread.
217 *****************************************************************************/
221 vlc_bool_t b_autocrop;
222 vlc_bool_t b_attenuate;
223 unsigned int bz_length, bz_height, bz_begin, bz_middle, bz_end, bz_middle_pos;
224 unsigned int i_ratio_max;
225 unsigned int i_ratio;
226 unsigned int a_0, a_1, a_2;
227 vlc_bool_t b_has_changed;
228 int lambda[2][VOUT_MAX_PLANES][500];
229 int cstYUV[2][VOUT_MAX_PLANES][500];
230 int lambda2[2][VOUT_MAX_PLANES][500];
231 int cstYUV2[2][VOUT_MAX_PLANES][500];
232 unsigned int i_halfLength;
233 unsigned int i_halfHeight;
237 float f_gamma_red, f_gamma_green, f_gamma_blue;
238 float f_gamma[VOUT_MAX_PLANES];
239 uint8_t LUT[VOUT_MAX_PLANES][ACCURACY + 1][256];
241 uint8_t LUT2[VOUT_MAX_PLANES][256][500];
245 vlc_bool_t b_xinerama;
256 vout_thread_t *p_vout;
262 /*****************************************************************************
263 * Control: control facility for the vout (forwards to child vout)
264 *****************************************************************************/
265 static int Control( vout_thread_t *p_vout, int i_query, va_list args )
267 int i_row, i_col, i_vout = 0;
269 for( i_row = 0; i_row < p_vout->p_sys->i_row; i_row++ )
271 for( i_col = 0; i_col < p_vout->p_sys->i_col; i_col++ )
273 vout_vaControl( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
281 /*****************************************************************************
282 * Create: allocates Wall video thread output method
283 *****************************************************************************
284 * This function allocates and initializes a Wall vout method.
285 *****************************************************************************/
286 static int Create( vlc_object_t *p_this )
288 vout_thread_t *p_vout = (vout_thread_t *)p_this;
289 char *psz_method, *psz_tmp, *psz_method_tmp;
292 /* Allocate structure */
293 p_vout->p_sys = malloc( sizeof( vout_sys_t ) );
294 if( p_vout->p_sys == NULL )
296 msg_Err( p_vout, "out of memory" );
300 p_vout->pf_init = Init;
301 p_vout->pf_end = End;
302 p_vout->pf_manage = NULL;
303 /* Color Format not supported
304 // Planar Y, packed UV
305 case VLC_FOURCC('Y','M','G','A'):
306 // Packed YUV 4:2:2, U:Y:V:Y, interlaced
307 case VLC_FOURCC('I','U','Y','V'): // packed by 2
308 // Packed YUV 2:1:1, Y:U:Y:V
309 case VLC_FOURCC('Y','2','1','1'): // packed by 4
310 // Packed YUV Reverted
311 case VLC_FOURCC('c','y','u','v'): // packed by 2
313 switch (p_vout->render.i_chroma)
316 case VLC_FOURCC('I','4','4','4'):
317 case VLC_FOURCC('I','4','2','2'):
318 case VLC_FOURCC('I','4','2','0'):
319 case VLC_FOURCC('Y','V','1','2'):
320 case VLC_FOURCC('I','Y','U','V'):
321 case VLC_FOURCC('I','4','1','1'):
322 case VLC_FOURCC('I','4','1','0'):
323 case VLC_FOURCC('Y','V','U','9'):
324 case VLC_FOURCC('Y','U','V','A'):
325 p_vout->pf_render = RenderPlanarYUV;
328 case VLC_FOURCC('R','G','B','2'): // packed by 1
329 case VLC_FOURCC('R','V','1','5'): // packed by 2
330 case VLC_FOURCC('R','V','1','6'): // packed by 2
331 case VLC_FOURCC('R','V','2','4'): // packed by 3
332 case VLC_FOURCC('R','V','3','2'): // packed by 4
333 p_vout->pf_render = RenderPackedRGB;
337 case VLC_FOURCC('Y','U','Y','2'): // packed by 2
338 case VLC_FOURCC('Y','U','N','V'): // packed by 2
339 case VLC_FOURCC('U','Y','V','Y'): // packed by 2
340 case VLC_FOURCC('U','Y','N','V'): // packed by 2
341 case VLC_FOURCC('Y','4','2','2'): // packed by 2
342 p_vout->pf_render = RenderPackedYUV;
346 msg_Err( p_vout, "colorspace not supported by plug-in !!!");
347 free( p_vout->p_sys );
350 p_vout->pf_display = NULL;
351 p_vout->pf_control = Control;
353 config_ChainParse( p_vout, CFG_PREFIX, ppsz_filter_options,
356 /* Look what method was requested */
357 p_vout->p_sys->i_col = var_CreateGetInteger( p_vout, CFG_PREFIX "cols" );
358 p_vout->p_sys->i_row = var_CreateGetInteger( p_vout, CFG_PREFIX "rows" );
360 // OS dependant code : Autodetect number of displays in wall
362 if ((p_vout->p_sys->i_col < 0) || (p_vout->p_sys->i_row < 0) )
364 int nbMonitors = GetSystemMetrics(SM_CMONITORS);
367 nbMonitors = 5; // 1 display => 5x1 simulation
368 p_vout->p_sys->i_col = nbMonitors;
369 p_vout->p_sys->i_row = 1;
373 p_vout->p_sys->i_col = GetSystemMetrics( SM_CXVIRTUALSCREEN ) / GetSystemMetrics( SM_CXSCREEN );
374 p_vout->p_sys->i_row = GetSystemMetrics( SM_CYVIRTUALSCREEN ) / GetSystemMetrics( SM_CYSCREEN );
375 if (p_vout->p_sys->i_col * p_vout->p_sys->i_row != nbMonitors)
377 p_vout->p_sys->i_col = nbMonitors;
378 p_vout->p_sys->i_row = 1;
381 var_SetInteger( p_vout, CFG_PREFIX "cols", p_vout->p_sys->i_col);
382 var_SetInteger( p_vout, CFG_PREFIX "rows", p_vout->p_sys->i_row);
387 p_vout->p_sys->i_offset_x = var_CreateGetInteger( p_vout, CFG_PREFIX "offset-x" );
388 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
389 p_vout->p_sys->b_autocrop = !(var_CreateGetInteger( p_vout, "crop-ratio" ) == 0);
390 if (!p_vout->p_sys->b_autocrop) p_vout->p_sys->b_autocrop = var_CreateGetInteger( p_vout, "autocrop" );
391 p_vout->p_sys->b_attenuate = var_CreateGetInteger( p_vout, CFG_PREFIX "attenuate");
392 p_vout->p_sys->bz_length = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-length" );
393 if (p_vout->p_sys->i_row > 1)
394 p_vout->p_sys->bz_height = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-height" );
396 p_vout->p_sys->bz_height = 100;
397 p_vout->p_sys->bz_begin = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-begin" );
398 p_vout->p_sys->bz_middle = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-middle" );
399 p_vout->p_sys->bz_end = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-end" );
400 p_vout->p_sys->bz_middle_pos = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-middle-pos" );
401 double d_p = 100.0 / p_vout->p_sys->bz_middle_pos;
402 p_vout->p_sys->i_ratio_max = var_CreateGetInteger( p_vout, "autocrop-ratio-max" ); // in crop module with autocrop ...
403 p_vout->p_sys->i_ratio = var_CreateGetInteger( p_vout, "crop-ratio" ); // in crop module with manual ratio ...
405 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;
406 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;
407 p_vout->p_sys->a_0 = p_vout->p_sys->bz_begin;
410 p_vout->p_sys->f_gamma_red = var_CreateGetFloat( p_vout, CFG_PREFIX "bz-gamma-red" );
411 p_vout->p_sys->f_gamma_green = var_CreateGetFloat( p_vout, CFG_PREFIX "bz-gamma-green" );
412 p_vout->p_sys->f_gamma_blue = var_CreateGetFloat( p_vout, CFG_PREFIX "bz-gamma-blue" );
415 p_vout->p_sys->b_xinerama= var_CreateGetInteger( p_vout, CFG_PREFIX "xinerama" );
418 p_vout->p_sys->i_col = __MAX( 1, __MIN( 15, p_vout->p_sys->i_col ) );
419 p_vout->p_sys->i_row = __MAX( 1, __MIN( 15, p_vout->p_sys->i_row ) );
422 msg_Dbg( p_vout, "opening a %i x %i wall",
423 p_vout->p_sys->i_col, p_vout->p_sys->i_row );
425 p_vout->p_sys->pp_vout = malloc( p_vout->p_sys->i_row *
426 p_vout->p_sys->i_col *
427 sizeof(struct vout_list_t) );
428 if( p_vout->p_sys->pp_vout == NULL )
430 msg_Err( p_vout, "out of memory" );
431 free( p_vout->p_sys );
436 psz_method = var_CreateGetNonEmptyString( p_vout, CFG_PREFIX "active" );
438 /* If no trailing vout are specified, take them all */
439 if( psz_method == NULL )
441 for( i_vout = p_vout->p_sys->i_row * p_vout->p_sys->i_col;
444 p_vout->p_sys->pp_vout[i_vout].b_active = 1;
447 /* If trailing vout are specified, activate only the requested ones */
450 for( i_vout = p_vout->p_sys->i_row * p_vout->p_sys->i_col;
453 p_vout->p_sys->pp_vout[i_vout].b_active = 0;
458 psz_tmp = psz_method;
459 while( *psz_tmp && *psz_tmp != ',' )
467 i_vout = atoi( psz_method );
468 psz_method = psz_tmp + 1;
472 i_vout = atoi( psz_method );
473 psz_method = psz_tmp;
477 i_vout < p_vout->p_sys->i_row * p_vout->p_sys->i_col )
479 p_vout->p_sys->pp_vout[i_vout].b_active = 1;
484 free( psz_method_tmp );
491 /*****************************************************************************
492 * CLIP_0A: clip between 0 and ACCURACY
493 *****************************************************************************/
494 inline static int CLIP_0A( int a )
496 return (a > ACCURACY) ? ACCURACY : (a < 0) ? 0 : a;
500 /*****************************************************************************
501 * Gamma: Gamma correction
502 *****************************************************************************/
503 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])
507 f_Input = (f_component * f_BlackLevel[i_plane]) / (f_BlackCrush[i_plane]) + (1.0 - f_BlackLevel[i_plane]);
508 if (f_component <= f_BlackCrush[i_plane])
509 return pow(f_Input, 1.0 / f_Gamma[i_plane]);
510 else if (f_component >= f_WhiteCrush[i_plane])
512 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);
513 return pow(f_Input, 1.0 / f_Gamma[i_plane]);
521 /*****************************************************************************
522 * F: Function to calculate Gamma correction
523 *****************************************************************************/
524 static uint8_t F(uint8_t i, float gamma)
526 double input = (double) i / 255.0;
528 // return clip(255 * pow(input, 1.0 / gamma));
531 return clip_uint8((255 * pow(2 * input, gamma)) / 2);
533 return clip_uint8(255 * (1 - pow(2 * (1 - input), gamma) / 2));
539 /*****************************************************************************
540 * AdjustHeight: ajust p_sys->i_height to have same BZ width for any ratio
541 *****************************************************************************/
542 static int AdjustHeight( vout_thread_t *p_vout )
544 vlc_bool_t b_fullscreen = var_CreateGetInteger( p_vout, "fullscreen" );
545 int i_window_width = p_vout->i_window_width;
546 int i_window_height = p_vout->i_window_height;
547 double d_halfLength = 0;
548 double d_halfLength_crop;
549 double d_halfLength_calculated;
552 // OS DEPENDANT CODE to get display dimensions
556 i_window_width = GetSystemMetrics(SM_CXSCREEN);
557 i_window_height = GetSystemMetrics(SM_CYSCREEN);
559 Display *p_display = XOpenDisplay( "" );
560 if (p_vout->p_sys->b_xinerama)
562 i_window_width = DisplayWidth(p_display, 0) / p_vout->p_sys->i_col;
563 i_window_height = DisplayHeight(p_display, 0) / p_vout->p_sys->i_row;
567 i_window_width = DisplayWidth(p_display, 0);
568 i_window_height = DisplayHeight(p_display, 0);
570 XCloseDisplay( p_display );
573 var_SetInteger( p_vout, "width", i_window_width);
574 var_SetInteger( p_vout, "height", i_window_height);
575 p_vout->i_window_width = i_window_width;
576 p_vout->i_window_height = i_window_height;
579 if (p_vout->p_sys->bz_length)
580 if ((!p_vout->p_sys->b_autocrop) && (!p_vout->p_sys->i_ratio))
582 if ((p_vout->p_sys->i_row > 1) || (p_vout->p_sys->i_col > 1))
584 while ((d_halfLength <= 0) || (d_halfLength > p_vout->render.i_width / (2 * p_vout->p_sys->i_col)))
586 if (p_vout->p_sys->bz_length >= 50)
587 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);
590 d_halfLength = (p_vout->render.i_width * p_vout->p_sys->bz_length) / (100.0 * p_vout->p_sys->i_col);
591 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);
593 if ((d_halfLength <= 0) || (d_halfLength > p_vout->render.i_width / (2 * p_vout->p_sys->i_col))) p_vout->p_sys->i_row--;
594 if (p_vout->p_sys->i_row < 1 )
596 p_vout->p_sys->i_row = 1;
600 p_vout->p_sys->i_halfLength = (d_halfLength + 0.5);
601 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;
602 var_SetInteger( p_vout, "bz-length", p_vout->p_sys->bz_length);
603 var_SetInteger( p_vout, "panoramix-rows", p_vout->p_sys->i_row);
608 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;
609 d_halfLength_crop = d_halfLength * VOUT_ASPECT_FACTOR * (double)p_vout->output.i_width
610 / (double)i_window_height / (double)p_vout->render.i_aspect;
611 p_vout->p_sys->i_halfLength = (d_halfLength_crop + 0.5);
612 d_halfLength_calculated = p_vout->p_sys->i_halfLength * (double)i_window_height *
613 (double)p_vout->render.i_aspect / VOUT_ASPECT_FACTOR / (double)p_vout->output.i_width;
615 if (!p_vout->p_sys->b_attenuate)
617 double d_bz_length = (p_vout->p_sys->i_halfLength * p_vout->p_sys->i_col * 100.0) / p_vout->render.i_width;
618 // F(2x) != 2F(x) in opengl module
619 if (p_vout->p_sys->i_col == 2) d_bz_length = (100.0 * d_bz_length) / (100.0 - d_bz_length) ;
620 var_SetInteger( p_vout, "bz-length", (int)(d_bz_length + 0.5));
622 i_offset = (int)d_halfLength - (int)
623 (p_vout->p_sys->i_halfLength * (double)i_window_height *
624 (double)p_vout->render.i_aspect / VOUT_ASPECT_FACTOR / (double)p_vout->output.i_width);
634 /*****************************************************************************
635 * Init: initialize Wall video thread output method
636 *****************************************************************************/
637 static int Init( vout_thread_t *p_vout )
639 int i_index, i_row, i_col, i_width, i_height;
642 I_OUTPUTPICTURES = 0;
644 /* Initialize the output structure */
645 p_vout->output.i_chroma = p_vout->render.i_chroma;
646 p_vout->output.i_width = p_vout->render.i_width;
647 p_vout->output.i_height = p_vout->render.i_height;
648 p_vout->output.i_aspect = p_vout->render.i_aspect;
650 p_vout->p_sys->b_has_changed = p_vout->p_sys->b_attenuate;
651 int i_video_x = var_GetInteger( p_vout, "video-x");
652 int i_video_y = var_GetInteger( p_vout, "video-y");
654 if (p_vout->p_sys->b_attenuate)
656 int i_index2, i_plane;
657 int constantYUV[3] = {0,128,128};
658 float f_BlackCrush[VOUT_MAX_PLANES];
659 float f_BlackLevel[VOUT_MAX_PLANES];
660 float f_WhiteCrush[VOUT_MAX_PLANES];
661 float f_WhiteLevel[VOUT_MAX_PLANES];
662 p_vout->p_sys->f_gamma[0] = var_CreateGetFloat( p_vout, CFG_PREFIX "bz-gamma-red" );
663 p_vout->p_sys->f_gamma[1] = var_CreateGetFloat( p_vout, CFG_PREFIX "bz-gamma-green" );
664 p_vout->p_sys->f_gamma[2] = var_CreateGetFloat( p_vout, CFG_PREFIX "bz-gamma-blue" );
665 f_BlackCrush[0] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-blackcrush-red" ) / 255.0;
666 f_BlackCrush[1] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-blackcrush-green" ) / 255.0;
667 f_BlackCrush[2] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-blackcrush-blue" ) / 255.0;
668 f_WhiteCrush[0] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-whitecrush-red" ) / 255.0;
669 f_WhiteCrush[1] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-whitecrush-green" ) / 255.0;
670 f_WhiteCrush[2] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-whitecrush-blue" ) / 255.0;
671 f_BlackLevel[0] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-blacklevel-red" ) / 255.0;
672 f_BlackLevel[1] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-blacklevel-green" ) / 255.0;
673 f_BlackLevel[2] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-blacklevel-blue" ) / 255.0;
674 f_WhiteLevel[0] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-whitelevel-red" ) / 255.0;
675 f_WhiteLevel[1] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-whitelevel-green" ) / 255.0;
676 f_WhiteLevel[2] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-whitelevel-blue" ) / 255.0;
677 switch (p_vout->render.i_chroma)
680 case VLC_FOURCC('Y','V','1','2'):
681 case VLC_FOURCC('Y','V','U','9'):
683 case VLC_FOURCC('U','Y','V','Y'): // packed by 2
684 case VLC_FOURCC('U','Y','N','V'): // packed by 2
685 case VLC_FOURCC('Y','4','2','2'): // packed by 2
686 // case VLC_FOURCC('c','y','u','v'): // packed by 2
687 p_vout->p_sys->f_gamma[2] = var_CreateGetFloat( p_vout, CFG_PREFIX "bz-gamma-green" );
688 p_vout->p_sys->f_gamma[1] = var_CreateGetFloat( p_vout, CFG_PREFIX "bz-gamma-blue" );
689 f_BlackCrush[2] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-blackcrush-green" ) / 255.0;
690 f_BlackCrush[1] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-blackcrush-blue" ) / 255.0;
691 f_WhiteCrush[2] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-whitecrush-green" ) / 255.0;
692 f_WhiteCrush[1] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-whitecrush-blue" ) / 255.0;
693 f_BlackLevel[2] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-blacklevel-green" ) / 255.0;
694 f_BlackLevel[1] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-blacklevel-blue" ) / 255.0;
695 f_WhiteLevel[2] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-whitelevel-green" ) / 255.0;
696 f_WhiteLevel[1] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-whitelevel-blue" ) / 255.0;
698 case VLC_FOURCC('I','4','4','4'):
699 case VLC_FOURCC('I','4','2','2'):
700 case VLC_FOURCC('I','4','2','0'):
701 case VLC_FOURCC('I','4','1','1'):
702 case VLC_FOURCC('I','4','1','0'):
703 case VLC_FOURCC('I','Y','U','V'):
704 case VLC_FOURCC('Y','U','V','A'):
706 case VLC_FOURCC('Y','U','Y','2'): // packed by 2
707 case VLC_FOURCC('Y','U','N','V'): // packed by 2
708 for (i_index = 0; i_index < 256; i_index++)
709 for (i_index2 = 0; i_index2 <= ACCURACY; i_index2++)
710 for (i_plane = 0; i_plane < VOUT_MAX_PLANES; i_plane++)
712 float f_lut = CLIP_01(1.0 -
713 ((ACCURACY - (float)i_index2)
714 * Gamma_Correction(i_plane, (float)i_index / 255.0, f_BlackCrush, f_WhiteCrush, f_BlackLevel, f_WhiteLevel, p_vout->p_sys->f_gamma)
716 p_vout->p_sys->LUT[i_plane][i_index2][i_index] = f_lut * i_index + (int)((1.0 - f_lut) * (float)constantYUV[i_plane]);
720 case VLC_FOURCC('R','G','B','2'): // packed by 1
721 case VLC_FOURCC('R','V','1','5'): // packed by 2
722 case VLC_FOURCC('R','V','1','6'): // packed by 2
723 case VLC_FOURCC('R','V','2','4'): // packed by 3
724 case VLC_FOURCC('R','V','3','2'): // packed by 4
725 for (i_index = 0; i_index < 256; i_index++)
726 for (i_index2 = 0; i_index2 <= ACCURACY; i_index2++)
727 for (i_plane = 0; i_plane < VOUT_MAX_PLANES; i_plane++)
729 float f_lut = CLIP_01(1.0 -
730 ((ACCURACY - (float)i_index2)
731 * Gamma_Correction(i_plane, (float)i_index / 255.0, f_BlackCrush, f_WhiteCrush, f_BlackLevel, f_WhiteLevel, p_vout->p_sys->f_gamma)
733 p_vout->p_sys->LUT[i_plane][i_index2][i_index] = f_lut * i_index;
737 msg_Err( p_vout, "colorspace not supported by plug-in !!!");
738 free( p_vout->p_sys );
743 if (p_vout->p_sys->i_offset_x)
744 p_vout->p_sys->i_offset_x = AdjustHeight(p_vout);
746 AdjustHeight(p_vout);
749 /* Try to open the real video output */
750 msg_Dbg( p_vout, "spawning the real video outputs" );
752 p_vout->p_sys->i_vout = 0;
754 /* FIXME: use bresenham instead of those ugly divisions */
755 for( i_row = 0; i_row < p_vout->p_sys->i_row; i_row++ )
757 for( i_col = 0; i_col < p_vout->p_sys->i_col; i_col++ )
761 memset( &fmt, 0, sizeof(video_format_t) );
763 if( i_col + 1 < p_vout->p_sys->i_col )
765 i_width = ( p_vout->render.i_width
766 / p_vout->p_sys->i_col ) & ~0x1;
770 i_width = p_vout->render.i_width
771 - ( ( p_vout->render.i_width
772 / p_vout->p_sys->i_col ) & ~0x1 ) * i_col;
776 i_width += p_vout->p_sys->i_halfLength;
777 if (p_vout->p_sys->i_col > 2 ) i_width += p_vout->p_sys->i_halfLength;
778 i_width -= i_width % 2;
780 if( i_row + 1 < p_vout->p_sys->i_row )
782 i_height = ( p_vout->render.i_height
783 / p_vout->p_sys->i_row ) & ~0x3;
787 i_height = p_vout->render.i_height
788 - ( ( p_vout->render.i_height
789 / p_vout->p_sys->i_row ) & ~0x3 ) * i_row;
793 if (p_vout->p_sys->i_row >= 2)
795 p_vout->p_sys->i_halfHeight = (p_vout->p_sys->i_halfLength * p_vout->p_sys->bz_height) / 100;
796 p_vout->p_sys->i_halfHeight -= (p_vout->p_sys->i_halfHeight % 2);
797 i_height += p_vout->p_sys->i_halfHeight;
798 if (p_vout->p_sys->i_row > 2) i_height += p_vout->p_sys->i_halfHeight;
800 i_height -= i_height % 2;
802 p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].i_width = i_width;
803 p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].i_height = i_height;
805 if( !p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].b_active )
807 p_vout->p_sys->i_vout++;
811 fmt.i_width = fmt.i_visible_width = p_vout->render.i_width;
812 fmt.i_height = fmt.i_visible_height = p_vout->render.i_height;
813 fmt.i_x_offset = fmt.i_y_offset = 0;
814 fmt.i_chroma = p_vout->render.i_chroma;
815 fmt.i_aspect = p_vout->render.i_aspect;
816 fmt.i_sar_num = p_vout->render.i_aspect * fmt.i_height / fmt.i_width;
817 fmt.i_sar_den = VOUT_ASPECT_FACTOR;
818 fmt.i_width = fmt.i_visible_width = i_width;
819 fmt.i_height = fmt.i_visible_height = i_height;
820 fmt.i_aspect = p_vout->render.i_aspect
821 * p_vout->render.i_height / i_height
822 * i_width / p_vout->render.i_width;
824 if (p_vout->p_sys->i_offset_x < 0)
826 var_SetInteger(p_vout, "video-x", -p_vout->p_sys->i_offset_x);
827 p_vout->p_sys->i_offset_x = 0;
830 p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].p_vout =
831 vout_Create( p_vout, &fmt);
833 if( p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].p_vout == NULL )
835 msg_Err( p_vout, "failed to get %ix%i vout threads",
836 p_vout->p_sys->i_col, p_vout->p_sys->i_row );
837 RemoveAllVout( p_vout );
841 p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].p_vout,
844 p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].p_vout->i_alignment = 0;
845 if (i_col == 0) p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].p_vout->i_alignment |= VOUT_ALIGN_RIGHT;
846 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;
847 if (p_vout->p_sys->i_row > 1)
849 if (i_row == 0) p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].p_vout->i_alignment |= VOUT_ALIGN_BOTTOM;
850 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;
852 // i_n : number of active pp_vout
853 int i_index, i_n = p_vout->p_sys->i_vout;
854 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;
855 var_SetInteger( p_vout, "align", p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].p_vout->i_alignment );
856 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);
857 var_SetInteger( p_vout, "video-y",i_video_y + ((i_n + 1) / p_vout->p_sys->i_col) * p_vout->i_window_height);
859 p_vout->p_sys->i_vout++;
863 ALLOCATE_DIRECTBUFFERS( VOUT_MAX_PICTURES );
865 ADD_PARENT_CALLBACKS( SendEventsToChild );
870 /*****************************************************************************
871 * End: terminate Wall video thread output method
872 *****************************************************************************/
873 static void End( vout_thread_t *p_vout )
878 var_SetInteger( p_vout, "bz-length", p_vout->p_sys->bz_length);
880 /* Free the fake output buffers we allocated */
881 for( i_index = I_OUTPUTPICTURES ; i_index ; )
884 free( PP_OUTPUTPICTURE[ i_index ]->p_data_orig );
888 /*****************************************************************************
889 * Destroy: destroy Wall video thread output method
890 *****************************************************************************
891 * Terminate an output method created by WallCreateOutputMethod
892 *****************************************************************************/
893 static void Destroy( vlc_object_t *p_this )
895 vout_thread_t *p_vout = (vout_thread_t *)p_this;
898 DEL_CALLBACKS( p_vout->p_sys->p_vout, SendEvents);
899 vlc_object_detach( p_vout->p_sys->p_vout );
900 vout_Destroy( p_vout->p_sys->p_vout );
901 DEL_PARENT_CALLBACKS( SendEventsToChild);
904 RemoveAllVout( p_vout );
905 DEL_PARENT_CALLBACKS( SendEventsToChild );
907 free( p_vout->p_sys->pp_vout );
908 free( p_vout->p_sys );
912 /*****************************************************************************
913 * RenderPlanarYUV: displays previously rendered output
914 *****************************************************************************
915 * This function send the currently rendered image to Wall image, waits
916 * until it is displayed and switch the two rendering buffers, preparing next
918 *****************************************************************************/
919 static void RenderPlanarYUV( vout_thread_t *p_vout, picture_t *p_pic )
921 picture_t *p_outpic = NULL;
922 int i_col, i_row, i_vout, i_plane;
923 int pi_left_skip[VOUT_MAX_PLANES], pi_top_skip[VOUT_MAX_PLANES];
925 int LeftOffset, TopOffset;
926 int constantYUV[3] = {0,128,128};
931 int i_index, i_index2;
937 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
939 pi_top_skip[i_plane] = 0;
942 for( i_row = 0; i_row < p_vout->p_sys->i_row; i_row++ )
944 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
946 pi_left_skip[i_plane] = 0;
949 for( i_col = 0; i_col < p_vout->p_sys->i_col; i_col++ )
951 if( !p_vout->p_sys->pp_vout[ i_vout ].b_active )
953 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
955 pi_left_skip[i_plane] +=
956 p_vout->p_sys->pp_vout[ i_vout ].i_width
957 * p_pic->p[i_plane].i_pitch / p_vout->output.i_width;
964 vout_CreatePicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
968 if( p_vout->b_die || p_vout->b_error )
971 p_vout->p_sys->pp_vout[ i_vout ].p_vout, p_outpic );
975 msleep( VOUT_OUTMEM_SLEEP );
978 vout_DatePicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
979 p_outpic, p_pic->date );
980 vout_LinkPicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
983 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
985 uint8_t *p_in, *p_in_end, *p_out;
986 int i_in_pitch = p_pic->p[i_plane].i_pitch;
987 int i_out_pitch = p_outpic->p[i_plane].i_pitch;
988 int i_copy_pitch = p_outpic->p[i_plane].i_visible_pitch;
989 int i_lines = p_outpic->p[i_plane].i_visible_lines;
991 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);
992 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);
993 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);
994 if ((!p_vout->p_sys->pp_vout[p_vout->p_sys->i_col].b_active))
995 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);
996 // i_n : previous inactive pp_vout
998 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++;
999 if ((i_col > 1) && i_n)
1000 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);
1002 p_in = p_pic->p[i_plane].p_pixels
1003 /* Wall proprities */
1004 + pi_top_skip[i_plane] + pi_left_skip[i_plane];
1006 if ((p_vout->p_sys->i_row > 2) &&
1007 ((!i_row) || (i_row + 1 == p_vout->p_sys->i_row)))
1008 i_lines -= (2 * p_vout->p_sys->i_halfHeight) / (p_vout->p_sys->pp_vout[i_vout].i_width / i_copy_pitch);
1010 // 1088 lines bug in a mpeg2 stream of 1080 lines
1011 if ((p_vout->p_sys->i_row - 1 == i_row) &&
1012 (p_pic->p[i_plane].i_lines == 1088))
1013 i_lines -= 8 / (p_vout->p_sys->pp_vout[i_vout].i_width / i_copy_pitch);
1015 p_in_end = p_in + i_lines * p_pic->p[i_plane].i_pitch;
1017 p_in = p_pic->p[i_plane].p_pixels
1018 + pi_top_skip[i_plane] + pi_left_skip[i_plane];
1020 p_in_end = p_in + i_lines * p_pic->p[i_plane].i_pitch;
1022 p_out = p_outpic->p[i_plane].p_pixels;
1024 if ((p_vout->p_sys->i_row > 2) && (!i_row))
1025 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));
1029 length = 2 * p_vout->p_sys->i_halfLength / (p_vout->p_sys->pp_vout[i_vout].i_width / i_copy_pitch);
1031 if (p_vout->p_sys->b_has_changed)
1034 a_2 = p_vout->p_sys->a_2 * (ACCURACY / 100);
1035 a_1 = p_vout->p_sys->a_1 * length * (ACCURACY / 100);
1036 a_0 = p_vout->p_sys->a_0 * Denom * (ACCURACY / 100);
1037 for(i_col_mod = 0; i_col_mod < 2; i_col_mod++)
1038 for (i_index = 0; i_index < length; i_index++)
1040 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);
1041 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;
1045 while( p_in < p_in_end )
1048 p_vout->p_libvlc->pf_memcpy( p_out , p_in, i_copy_pitch);
1050 if (p_vout->p_sys->i_col > 2)
1054 p_vout->p_libvlc->pf_memcpy( p_out + length , p_in, i_copy_pitch - length);
1055 else if (i_col + 1 == p_vout->p_sys->i_col)
1056 p_vout->p_libvlc->pf_memcpy( p_out, p_in - length, i_copy_pitch - length);
1058 p_vout->p_libvlc->pf_memcpy( p_out, p_in - length, i_copy_pitch);
1064 p_out += LeftOffset;
1065 memset(p_out, constantYUV[i_plane], length);
1066 p_out -= LeftOffset;
1068 else if ((i_col + 1 == p_vout->p_sys->i_col ))
1071 LeftOffset = i_copy_pitch - length;
1072 p_out += LeftOffset;
1073 memset(p_out, constantYUV[i_plane], length);
1074 p_out -= LeftOffset;
1079 p_vout->p_libvlc->pf_memcpy( p_out , p_in, i_copy_pitch);
1081 if (p_vout->p_sys->b_attenuate)
1084 // first blended zone
1088 p_out += LeftOffset;
1089 for (i_index = 0; i_index < length; i_index++)
1092 *(p_out + i_index) = (p_vout->p_sys->lambda[1][i_plane][i_index] *
1093 (*(p_out + i_index))) / ACCURACY +
1094 p_vout->p_sys->cstYUV[1][i_plane][i_index];
1096 *(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)];
1099 p_out -= LeftOffset;
1101 // second blended zone
1102 if (i_col + 1 < p_vout->p_sys->i_col)
1104 LeftOffset = i_copy_pitch - length;
1105 p_out += LeftOffset;
1106 for (i_index = 0; i_index < length; i_index++)
1109 *(p_out + i_index) = (p_vout->p_sys->lambda[0][i_plane][i_index] *
1110 (*(p_out + i_index))) / ACCURACY +
1111 p_vout->p_sys->cstYUV[0][i_plane][i_index];
1114 *(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)];
1117 p_out -= LeftOffset;
1123 p_out += i_out_pitch;
1127 if (!p_vout->p_sys->b_attenuate)
1129 if ((i_row == 0) && (p_vout->p_sys->i_row > 2))
1132 int height = 2 * p_vout->p_sys->i_halfHeight / (p_vout->p_sys->pp_vout[i_vout].i_width / i_copy_pitch);
1133 TopOffset = i_lines + (2 * p_vout->p_sys->i_halfHeight) / (p_vout->p_sys->pp_vout[i_vout].i_width / i_copy_pitch);
1134 p_out -= TopOffset * p_outpic->p[i_plane].i_pitch;
1135 for (i_index = 0; i_index < height; i_index++)
1136 for (i_index2 = 0; i_index2 < i_copy_pitch; i_index2++)
1137 *(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2) = constantYUV[i_plane];
1138 p_out += TopOffset * p_outpic->p[i_plane].i_pitch;
1140 else if ((i_row + 1 == p_vout->p_sys->i_row) && (p_vout->p_sys->i_row > 2))
1143 int height = 2 * p_vout->p_sys->i_halfHeight / (p_vout->p_sys->pp_vout[i_vout].i_width / i_copy_pitch);
1144 TopOffset = height - (2 * p_vout->p_sys->i_halfHeight) / (p_vout->p_sys->pp_vout[i_vout].i_width / i_copy_pitch);
1145 p_out -= TopOffset * p_outpic->p[i_plane].i_pitch;
1146 for (i_index = 0; i_index < height; i_index++)
1147 for (i_index2 = 0; i_index2 < i_copy_pitch; i_index2++)
1148 *(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2) = constantYUV[i_plane];
1149 p_out += TopOffset * p_outpic->p[i_plane].i_pitch;
1154 if (p_vout->p_sys->i_row >= 2)
1156 length = 2 * p_vout->p_sys->i_halfHeight / (p_vout->p_sys->pp_vout[i_vout].i_width / i_copy_pitch);
1157 if (p_vout->p_sys->b_has_changed)
1160 a_2 = p_vout->p_sys->a_2 * (ACCURACY / 100);
1161 a_1 = p_vout->p_sys->a_1 * length * (ACCURACY / 100);
1162 a_0 = p_vout->p_sys->a_0 * Denom * (ACCURACY / 100);
1163 for(i_col_mod = 0; i_col_mod < 2; i_col_mod++)
1164 for (i_index = 0; i_index < length; i_index++)
1166 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);
1167 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;
1170 // first blended zone
1174 TopOffset = i_lines;
1175 p_out -= TopOffset * p_outpic->p[i_plane].i_pitch;
1176 for (i_index = 0; i_index < length; i_index++)
1177 for (i_index2 = 0; i_index2 < i_copy_pitch; i_index2++)
1179 *(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2) = (p_vout->p_sys->lambda2[1][i_plane][i_index] *
1180 (*(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2))) / ACCURACY +
1181 p_vout->p_sys->cstYUV2[1][i_plane][i_index];
1184 *(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)];
1186 p_out += TopOffset * p_outpic->p[i_plane].i_pitch;
1188 else if (p_vout->p_sys->i_row > 2)
1191 TopOffset = i_lines + (2 * p_vout->p_sys->i_halfHeight) / (p_vout->p_sys->pp_vout[i_vout].i_width / i_copy_pitch);
1192 p_out -= TopOffset * p_outpic->p[i_plane].i_pitch;
1193 for (i_index = 0; i_index < length; i_index++)
1194 for (i_index2 = 0; i_index2 < i_copy_pitch; i_index2++)
1195 *(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2) = constantYUV[i_plane];
1196 p_out += TopOffset * p_outpic->p[i_plane].i_pitch;
1199 // second blended zone
1201 if (i_row + 1 < p_vout->p_sys->i_row)
1204 p_out -= TopOffset * p_outpic->p[i_plane].i_pitch;
1205 for (i_index = 0; i_index < length; i_index++)
1206 for (i_index2 = 0; i_index2 < i_copy_pitch; i_index2++)
1208 *(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2) = (p_vout->p_sys->lambda2[0][i_plane][i_index] *
1209 (*(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2))) / ACCURACY +
1210 p_vout->p_sys->cstYUV2[0][i_plane][i_index];
1213 *(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)];
1216 p_out += TopOffset * p_outpic->p[i_plane].i_pitch;
1218 else if (p_vout->p_sys->i_row > 2)
1221 TopOffset = length - (2 * p_vout->p_sys->i_halfHeight) / (p_vout->p_sys->pp_vout[i_vout].i_width / i_copy_pitch);
1222 p_out -= TopOffset * p_outpic->p[i_plane].i_pitch;
1223 for (i_index = 0; i_index < length; i_index++)
1224 for (i_index2 = 0; i_index2 < i_copy_pitch; i_index2++)
1225 *(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2) = constantYUV[i_plane];
1226 p_out += TopOffset * p_outpic->p[i_plane].i_pitch;
1232 // bug for wall filter : fix by CC
1233 // pi_left_skip[i_plane] += i_out_pitch;
1234 pi_left_skip[i_plane] += i_copy_pitch;
1237 vout_UnlinkPicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
1239 vout_DisplayPicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
1244 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
1246 pi_top_skip[i_plane] += p_vout->p_sys->pp_vout[ i_vout ].i_height
1247 * p_pic->p[i_plane].i_lines
1248 / p_vout->output.i_height
1249 * p_pic->p[i_plane].i_pitch;
1254 if (p_vout->p_sys->b_has_changed) p_vout->p_sys->b_has_changed = VLC_FALSE;
1259 /*****************************************************************************
1260 * RenderPackedRGB: displays previously rendered output
1261 *****************************************************************************
1262 * This function send the currently rendered image to Wall image, waits
1263 * until it is displayed and switch the two rendering buffers, preparing next
1265 *****************************************************************************/
1266 static void RenderPackedRGB( vout_thread_t *p_vout, picture_t *p_pic )
1268 picture_t *p_outpic = NULL;
1269 int i_col, i_row, i_vout, i_plane;
1270 int pi_left_skip[VOUT_MAX_PLANES], pi_top_skip[VOUT_MAX_PLANES];
1272 int LeftOffset, TopOffset;
1277 int i_index, i_index2;
1282 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
1284 pi_top_skip[i_plane] = 0;
1287 for( i_row = 0; i_row < p_vout->p_sys->i_row; i_row++ )
1289 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
1291 pi_left_skip[i_plane] = 0;
1294 for( i_col = 0; i_col < p_vout->p_sys->i_col; i_col++ )
1296 if( !p_vout->p_sys->pp_vout[ i_vout ].b_active )
1298 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
1300 pi_left_skip[i_plane] +=
1301 p_vout->p_sys->pp_vout[ i_vout ].i_width * p_pic->p->i_pixel_pitch;
1308 vout_CreatePicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
1312 if( p_vout->b_die || p_vout->b_error )
1314 vout_DestroyPicture(
1315 p_vout->p_sys->pp_vout[ i_vout ].p_vout, p_outpic );
1319 msleep( VOUT_OUTMEM_SLEEP );
1322 vout_DatePicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
1323 p_outpic, p_pic->date );
1324 vout_LinkPicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
1327 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
1329 uint8_t *p_in, *p_in_end, *p_out;
1330 int i_in_pitch = p_pic->p[i_plane].i_pitch;
1331 int i_out_pitch = p_outpic->p[i_plane].i_pitch;
1332 int i_copy_pitch = p_outpic->p[i_plane].i_visible_pitch;
1335 if (i_col) pi_left_skip[i_plane] -= (2 * p_vout->p_sys->i_halfLength) * p_pic->p->i_pixel_pitch;
1336 if ((i_row) && (!i_col)) pi_top_skip[i_plane] -= (2 * p_vout->p_sys->i_halfHeight * p_pic->p[i_plane].i_pitch);
1337 if ((!p_vout->p_sys->pp_vout[p_vout->p_sys->i_col].b_active))
1338 pi_top_skip[i_plane] -= (2 * p_vout->p_sys->i_halfHeight * i_row * p_pic->p[i_plane].i_pitch);
1339 // i_n : previous inactive pp_vout
1341 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++;
1342 if ((i_col > 1) && i_n)
1343 pi_left_skip[i_plane] -= i_n*(2 * p_vout->p_sys->i_halfLength ) * p_pic->p->i_pixel_pitch;
1345 p_in = p_pic->p[i_plane].p_pixels
1346 /* Wall proprities */
1347 + pi_top_skip[i_plane] + pi_left_skip[i_plane];
1349 int i_lines = p_outpic->p[i_plane].i_visible_lines;
1350 // 1088 lines bug in a mpeg2 stream of 1080 lines
1351 if ((p_vout->p_sys->i_row - 1 == i_row) &&
1352 (p_pic->p[i_plane].i_lines == 1088))
1355 p_in_end = p_in + i_lines * p_pic->p[i_plane].i_pitch;
1357 p_in = p_pic->p[i_plane].p_pixels
1358 + pi_top_skip[i_plane] + pi_left_skip[i_plane];
1360 p_in_end = p_in + p_outpic->p[i_plane].i_visible_lines
1361 * p_pic->p[i_plane].i_pitch;
1364 p_out = p_outpic->p[i_plane].p_pixels;
1368 if ((p_vout->p_sys->i_row > 2) && (!i_row))
1369 p_out += (p_outpic->p[i_plane].i_pitch * (2 * p_vout->p_sys->i_halfHeight) * p_pic->p->i_pixel_pitch);
1372 length = 2 * p_vout->p_sys->i_halfLength * p_pic->p->i_pixel_pitch;
1374 if (p_vout->p_sys->b_has_changed)
1378 Denom = F2(length / p_pic->p->i_pixel_pitch);
1379 a_2 = p_vout->p_sys->a_2 * (ACCURACY / 100);
1380 a_1 = p_vout->p_sys->a_1 * 2 * p_vout->p_sys->i_halfLength * (ACCURACY / 100);
1381 a_0 = p_vout->p_sys->a_0 * Denom * (ACCURACY / 100);
1382 for(i_col_mod = 0; i_col_mod < 2; i_col_mod++)
1383 for (i_index = 0; i_index < length / p_pic->p->i_pixel_pitch; i_index++)
1384 for (i_plane_ = 0; i_plane_ < p_pic->p->i_pixel_pitch; i_plane_++)
1385 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);
1388 while( p_in < p_in_end )
1391 p_vout->p_libvlc->pf_memcpy( p_out, p_in, i_copy_pitch);
1393 if (p_vout->p_sys->i_col > 2)
1398 p_vout->p_libvlc->pf_memcpy( p_out + length, p_in, i_copy_pitch - length);
1399 else if (i_col + 1 == p_vout->p_sys->i_col)
1400 p_vout->p_libvlc->pf_memcpy( p_out, p_in - length, i_copy_pitch - length);
1402 p_vout->p_libvlc->pf_memcpy( p_out, p_in - length, i_copy_pitch);
1408 p_out += LeftOffset;
1410 for (i_index = 0; i_index < length; i_index++)
1411 *(p_out + i_index) = 0;
1412 p_out -= LeftOffset;
1415 else if ((i_col + 1 == p_vout->p_sys->i_col ))
1418 LeftOffset = i_copy_pitch - length;
1419 p_out += LeftOffset;
1421 for (i_index = 0; i_index < length; i_index++)
1422 *(p_out + i_index) = 0;
1423 p_out -= LeftOffset;
1429 p_vout->p_libvlc->pf_memcpy( p_out, p_in, i_copy_pitch);
1432 // first blended zone
1436 p_out += LeftOffset;
1437 for (i_index = 0; i_index < length; i_index++)
1439 *(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] *
1440 (*(p_out + i_index))) / ACCURACY;
1442 *(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)];
1444 p_out -= LeftOffset;
1446 // second blended zone
1447 if (i_col + 1 < p_vout->p_sys->i_col)
1449 LeftOffset = i_copy_pitch - length;
1450 p_out += LeftOffset;
1451 for (i_index = 0; i_index < length; i_index++)
1453 *(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] *
1454 (*(p_out + i_index))) / ACCURACY;
1456 *(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)];
1458 p_out -= LeftOffset;
1463 p_out += i_out_pitch;
1467 if (!p_vout->p_sys->b_attenuate)
1469 if ((i_row == 0) && (p_vout->p_sys->i_row > 2))
1472 TopOffset = i_lines + (2 * p_vout->p_sys->i_halfHeight);
1473 p_out -= TopOffset * p_outpic->p[i_plane].i_pitch;
1474 for (i_index = 0; i_index < length; i_index++)
1475 for (i_index2 = 0; i_index2 < i_copy_pitch; i_index2++)
1476 *(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2) = 0;
1477 p_out += TopOffset * p_outpic->p[i_plane].i_pitch;
1479 else if ((i_row + 1 == p_vout->p_sys->i_row) && (p_vout->p_sys->i_row > 2))
1482 TopOffset = length - (2 * p_vout->p_sys->i_halfHeight);
1483 p_out -= TopOffset * p_outpic->p[i_plane].i_pitch;
1484 for (i_index = 0; i_index < length; i_index++)
1485 for (i_index2 = 0; i_index2 < i_copy_pitch; i_index2++)
1486 *(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2) = 0;
1487 p_out += TopOffset * p_outpic->p[i_plane].i_pitch;
1492 if (p_vout->p_sys->i_row >= 2)
1494 length = 2 * p_vout->p_sys->i_halfHeight;
1495 if (p_vout->p_sys->b_has_changed)
1500 a_2 = p_vout->p_sys->a_2 * (ACCURACY / 100);
1501 a_1 = p_vout->p_sys->a_1 * length * (ACCURACY / 100);
1502 a_0 = p_vout->p_sys->a_0 * Denom * (ACCURACY / 100);
1503 for(i_row_mod = 0; i_row_mod < 2; i_row_mod++)
1504 for (i_index = 0; i_index < length; i_index++)
1505 for (i_plane_ = 0; i_plane_ < p_pic->p->i_pixel_pitch; i_plane_++)
1506 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);
1508 // first blended zone
1512 TopOffset = i_lines;
1513 p_out -= TopOffset * p_outpic->p[i_plane].i_pitch;
1514 for (i_index = 0; i_index < length; i_index++)
1515 for (i_index2 = 0; i_index2 < i_copy_pitch; i_index2++)
1517 *(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] *
1518 (*(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2))) / ACCURACY;
1520 *(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)];
1522 p_out += TopOffset * p_outpic->p[i_plane].i_pitch;
1524 else if (p_vout->p_sys->i_row > 2)
1527 TopOffset = i_lines + (2 * p_vout->p_sys->i_halfHeight);
1528 p_out -= TopOffset * p_outpic->p[i_plane].i_pitch;
1529 for (i_index = 0; i_index < length; i_index++)
1530 for (i_index2 = 0; i_index2 < i_copy_pitch; i_index2++)
1531 *(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2) = 0;
1532 p_out += TopOffset * p_outpic->p[i_plane].i_pitch;
1535 // second blended zone
1537 if (i_row + 1 < p_vout->p_sys->i_row)
1540 p_out -= TopOffset * p_outpic->p[i_plane].i_pitch;
1541 for (i_index = 0; i_index < length; i_index++)
1542 for (i_index2 = 0; i_index2 < i_copy_pitch; i_index2++)
1544 *(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] *
1545 (*(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2))) / ACCURACY;
1547 *(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)];
1550 p_out += TopOffset * p_outpic->p[i_plane].i_pitch;
1552 else if (p_vout->p_sys->i_row > 2)
1555 TopOffset = length - (2 * p_vout->p_sys->i_halfHeight);
1556 p_out -= TopOffset * p_outpic->p[i_plane].i_pitch;
1557 for (i_index = 0; i_index < length; i_index++)
1558 for (i_index2 = 0; i_index2 < i_copy_pitch; i_index2++)
1559 *(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2) = 0;
1560 p_out += TopOffset * p_outpic->p[i_plane].i_pitch;
1566 // bug for wall filter : fix by CC
1567 // pi_left_skip[i_plane] += i_out_pitch;
1568 pi_left_skip[i_plane] += i_copy_pitch;
1571 vout_UnlinkPicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
1573 vout_DisplayPicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
1578 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
1580 pi_top_skip[i_plane] += p_vout->p_sys->pp_vout[ i_vout ].i_height
1581 * p_pic->p[i_plane].i_lines
1582 / p_vout->output.i_height
1583 * p_pic->p[i_plane].i_pitch;
1587 if (p_vout->p_sys->b_has_changed) p_vout->p_sys->b_has_changed = VLC_FALSE;
1593 // WARNING : NO DEBUGGED
1594 /*****************************************************************************
1595 * RenderPackedYUV: displays previously rendered output
1596 *****************************************************************************
1597 * This function send the currently rendered image to Wall image, waits
1598 * until it is displayed and switch the two rendering buffers, preparing next
1600 *****************************************************************************/
1601 static void RenderPackedYUV( vout_thread_t *p_vout, picture_t *p_pic )
1603 picture_t *p_outpic = NULL;
1604 int i_col, i_row, i_vout, i_plane;
1605 int pi_left_skip[VOUT_MAX_PLANES], pi_top_skip[VOUT_MAX_PLANES];
1607 int LeftOffset, TopOffset;
1608 int constantYUV[3] = {0,128,128};
1613 int i_index, i_index2;
1619 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
1621 pi_top_skip[i_plane] = 0;
1624 for( i_row = 0; i_row < p_vout->p_sys->i_row; i_row++ )
1626 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
1628 pi_left_skip[i_plane] = 0;
1631 for( i_col = 0; i_col < p_vout->p_sys->i_col; i_col++ )
1633 if( !p_vout->p_sys->pp_vout[ i_vout ].b_active )
1635 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
1637 pi_left_skip[i_plane] +=
1638 p_vout->p_sys->pp_vout[ i_vout ].i_width
1639 * p_pic->p[i_plane].i_pitch / p_vout->output.i_width;
1646 vout_CreatePicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
1650 if( p_vout->b_die || p_vout->b_error )
1652 vout_DestroyPicture(
1653 p_vout->p_sys->pp_vout[ i_vout ].p_vout, p_outpic );
1657 msleep( VOUT_OUTMEM_SLEEP );
1660 vout_DatePicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
1661 p_outpic, p_pic->date );
1662 vout_LinkPicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
1665 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
1667 uint8_t *p_in, *p_in_end, *p_out;
1668 int i_in_pitch = p_pic->p[i_plane].i_pitch;
1669 int i_out_pitch = p_outpic->p[i_plane].i_pitch;
1670 int i_copy_pitch = p_outpic->p[i_plane].i_visible_pitch;
1673 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);
1674 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);
1675 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);
1676 if ((!p_vout->p_sys->pp_vout[p_vout->p_sys->i_col].b_active))
1677 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);
1678 // i_n : previous inactive pp_vout
1680 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++;
1681 if ((i_col > 1) && i_n)
1682 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);
1684 p_in = p_pic->p[i_plane].p_pixels
1685 /* Wall proprities */
1686 + pi_top_skip[i_plane] + pi_left_skip[i_plane];
1688 int i_lines = p_outpic->p[i_plane].i_visible_lines;
1689 // 1088 lines bug in a mpeg2 stream of 1080 lines
1690 if ((p_vout->p_sys->i_row - 1 == i_row) &&
1691 (p_pic->p[i_plane].i_lines == 1088))
1694 p_in_end = p_in + i_lines * p_pic->p[i_plane].i_pitch;
1696 p_in = p_pic->p[i_plane].p_pixels
1697 + pi_top_skip[i_plane] + pi_left_skip[i_plane];
1699 p_in_end = p_in + p_outpic->p[i_plane].i_visible_lines
1700 * p_pic->p[i_plane].i_pitch;
1702 p_out = p_outpic->p[i_plane].p_pixels;
1705 length = 2 * p_vout->p_sys->i_halfLength * p_pic->p->i_pixel_pitch;
1706 LeftOffset = (i_col ? 0 : i_copy_pitch - length);
1707 if (p_vout->p_sys->b_has_changed)
1711 for (i_index = 0; i_index < length / p_pic->p->i_pixel_pitch; i_index++)
1712 for (i_plane_ = 0; i_plane_ < p_pic->p->i_pixel_pitch; i_plane_++)
1713 for (i_index2 = 0; i_index2 < 256; i_index2++)
1714 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_]));
1716 switch (p_vout->output.i_chroma)
1718 case VLC_FOURCC('Y','U','Y','2'): // packed by 2
1719 case VLC_FOURCC('Y','U','N','V'): // packed by 2
1720 Denom = F2(length / p_pic->p->i_pixel_pitch);
1721 a_2 = p_vout->p_sys->a_2 * (ACCURACY / 100);
1722 a_1 = p_vout->p_sys->a_1 * 2 * p_vout->p_sys->i_halfLength * (ACCURACY / 100);
1723 a_0 = p_vout->p_sys->a_0 * Denom * (ACCURACY / 100);
1724 for (i_index = 0; i_index < length / p_pic->p->i_pixel_pitch; i_index+=p_pic->p->i_pixel_pitch)
1725 // for each macropixel
1727 // first image pixel
1728 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);
1729 p_vout->p_sys->cstYUV[i_col][0][i_index] = ((ACCURACY - p_vout->p_sys->lambda[i_col][0][i_index]) * constantYUV[0]) / ACCURACY;
1730 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);
1731 p_vout->p_sys->cstYUV[i_col][1][i_index] = ((ACCURACY - p_vout->p_sys->lambda[i_col][1][i_index]) * constantYUV[1]) / ACCURACY;
1732 // second image pixel
1733 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);
1734 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;
1735 p_vout->p_sys->lambda[i_col][1][i_index + 1] = p_vout->p_sys->lambda[i_col][1][i_index];
1736 p_vout->p_sys->cstYUV[i_col][1][i_index + 1] = p_vout->p_sys->cstYUV[i_col][1][i_index];
1739 case VLC_FOURCC('U','Y','V','Y'): // packed by 2
1740 case VLC_FOURCC('U','Y','N','V'): // packed by 2
1741 case VLC_FOURCC('Y','4','2','2'): // packed by 2
1742 Denom = F2(length / p_pic->p->i_pixel_pitch);
1743 a_2 = p_vout->p_sys->a_2 * (ACCURACY / 100);
1744 a_1 = p_vout->p_sys->a_1 * 2 * p_vout->p_sys->i_halfLength * (ACCURACY / 100);
1745 a_0 = p_vout->p_sys->a_0 * Denom * (ACCURACY / 100);
1746 for (i_index = 0; i_index < length / p_pic->p->i_pixel_pitch; i_index+=p_pic->p->i_pixel_pitch)
1747 // for each macropixel
1749 // first image pixel
1750 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);
1751 p_vout->p_sys->cstYUV[i_col][0][i_index] = ((ACCURACY - p_vout->p_sys->lambda[i_col][0][i_index]) * constantYUV[1]) / ACCURACY;
1752 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);
1753 p_vout->p_sys->cstYUV[i_col][1][i_index] = ((ACCURACY - p_vout->p_sys->lambda[i_col][1][i_index]) * constantYUV[0]) / ACCURACY;
1754 // second image pixel
1755 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);
1756 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;
1757 p_vout->p_sys->lambda[i_col][1][i_index + 1] = p_vout->p_sys->lambda[i_col][1][i_index];
1758 p_vout->p_sys->cstYUV[i_col][1][i_index + 1] = p_vout->p_sys->cstYUV[i_col][1][i_index];
1766 while( p_in < p_in_end )
1769 p_vout->p_libvlc->pf_memcpy( p_out, p_in, i_copy_pitch);
1771 p_vout->p_libvlc->pf_memcpy( p_out + i_col * length, p_in + i_col * length, i_copy_pitch - length);
1772 p_out += LeftOffset;
1775 for (i_index = 0; i_index < length; i_index++)
1776 *(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] *
1777 (*(p_in + i_index))) / ACCURACY +
1778 p_vout->p_sys->cstYUV[i_col][i_index % p_pic->p->i_pixel_pitch][i_index / p_pic->p->i_pixel_pitch];
1780 for (i_index = 0; i_index < length; i_index++)
1781 *(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] *
1782 (*(p_in + i_index))) / ACCURACY +
1783 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];
1785 p_out -= LeftOffset;
1789 p_out += i_out_pitch;
1792 if (p_vout->p_sys->i_row == 2)
1794 length = 2 * p_vout->p_sys->i_halfHeight * p_pic->p->i_pixel_pitch;
1795 TopOffset = (i_row ? i_lines : length / p_pic->p->i_pixel_pitch);
1796 if (p_vout->p_sys->b_has_changed)
1800 for (i_index = 0; i_index < length / p_pic->p->i_pixel_pitch; i_index++)
1801 for (i_plane_ = 0; i_plane_ < p_pic->p->i_pixel_pitch; i_plane_++)
1802 for (i_index2 = 0; i_index2 < 256; i_index2++)
1803 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_]));
1805 switch (p_vout->output.i_chroma)
1807 case VLC_FOURCC('Y','U','Y','2'): // packed by 2
1808 case VLC_FOURCC('Y','U','N','V'): // packed by 2
1809 Denom = F2(length / p_pic->p->i_pixel_pitch);
1810 a_2 = p_vout->p_sys->a_2 * (ACCURACY / 100);
1811 a_1 = p_vout->p_sys->a_1 * 2 * p_vout->p_sys->i_halfHeight * (ACCURACY / 100);
1812 a_0 = p_vout->p_sys->a_0 * Denom * (ACCURACY / 100);
1813 for (i_index = 0; i_index < length / p_pic->p->i_pixel_pitch; i_index+=p_pic->p->i_pixel_pitch)
1814 // for each macropixel
1816 // first image pixel
1817 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);
1818 p_vout->p_sys->cstYUV2[i_row][0][i_index] = ((ACCURACY - p_vout->p_sys->lambda2[i_row][0][i_index]) * constantYUV[0]) / ACCURACY;
1819 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);
1820 p_vout->p_sys->cstYUV2[i_row][1][i_index] = ((ACCURACY - p_vout->p_sys->lambda2[i_row][1][i_index]) * constantYUV[1]) / ACCURACY;
1821 // second image pixel
1822 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);
1823 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;
1824 p_vout->p_sys->lambda2[i_row][1][i_index + 1] = p_vout->p_sys->lambda2[i_row][1][i_index];
1825 p_vout->p_sys->cstYUV2[i_row][1][i_index + 1] = p_vout->p_sys->cstYUV2[i_row][1][i_index];
1828 case VLC_FOURCC('U','Y','V','Y'): // packed by 2
1829 case VLC_FOURCC('U','Y','N','V'): // packed by 2
1830 case VLC_FOURCC('Y','4','2','2'): // packed by 2
1831 Denom = F2(length / p_pic->p->i_pixel_pitch);
1832 a_2 = p_vout->p_sys->a_2 * (ACCURACY / 100);
1833 a_1 = p_vout->p_sys->a_1 * 2 * p_vout->p_sys->i_halfHeight * (ACCURACY / 100);
1834 a_0 = p_vout->p_sys->a_0 * Denom * (ACCURACY / 100);
1835 for (i_index = 0; i_index < length / p_pic->p->i_pixel_pitch; i_index+=p_pic->p->i_pixel_pitch)
1836 // for each macropixel
1838 // first image pixel
1839 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);
1840 p_vout->p_sys->cstYUV2[i_row][0][i_index] = ((ACCURACY - p_vout->p_sys->lambda2[i_col][0][i_index]) * constantYUV[1]) / ACCURACY;
1841 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);
1842 p_vout->p_sys->cstYUV2[i_row][1][i_index] = ((ACCURACY - p_vout->p_sys->lambda2[i_row][1][i_index]) * constantYUV[0]) / ACCURACY;
1843 // second image pixel
1844 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);
1845 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;
1846 p_vout->p_sys->lambda2[i_row][1][i_index + 1] = p_vout->p_sys->lambda2[i_row][1][i_index];
1847 p_vout->p_sys->cstYUV2[i_row][1][i_index + 1] = p_vout->p_sys->cstYUV2[i_row][1][i_index];
1854 p_out -= TopOffset * p_outpic->p[i_plane].i_pitch;
1856 for (i_index = 0; i_index < length / p_pic->p->i_pixel_pitch; i_index++)
1857 for (i_index2 = 0; i_index2 < i_copy_pitch; i_index2++)
1858 *(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] *
1859 (*(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2))) / ACCURACY +
1860 p_vout->p_sys->cstYUV2[i_row][i_index2 % p_pic->p->i_pixel_pitch][i_index];
1862 for (i_index = 0; i_index < length / p_pic->p->i_pixel_pitch; i_index++)
1863 for (i_index2 = 0; i_index2 < i_copy_pitch; i_index2++)
1864 *(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] *
1865 (*(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2))) / ACCURACY +
1866 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];
1869 p_out += TopOffset * p_outpic->p[i_plane].i_pitch;
1872 // bug for wall filter : fix by CC
1873 // pi_left_skip[i_plane] += i_out_pitch;
1874 pi_left_skip[i_plane] += i_copy_pitch;
1877 vout_UnlinkPicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
1879 vout_DisplayPicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
1884 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
1886 pi_top_skip[i_plane] += p_vout->p_sys->pp_vout[ i_vout ].i_height
1887 * p_pic->p[i_plane].i_lines
1888 / p_vout->output.i_height
1889 * p_pic->p[i_plane].i_pitch;
1893 if (p_vout->p_sys->b_has_changed) p_vout->p_sys->b_has_changed = VLC_FALSE;
1899 /*****************************************************************************
1900 * RemoveAllVout: destroy all the child video output threads
1901 *****************************************************************************/
1902 static void RemoveAllVout( vout_thread_t *p_vout )
1904 while( p_vout->p_sys->i_vout )
1906 --p_vout->p_sys->i_vout;
1907 if( p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].b_active )
1910 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 );
1915 p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].p_vout );
1920 /*****************************************************************************
1921 * SendEvents: forward mouse and keyboard events to the parent p_vout
1922 *****************************************************************************/
1923 static int SendEvents( vlc_object_t *p_this, char const *psz_var,
1924 vlc_value_t oldval, vlc_value_t newval, void *_p_vout )
1926 vout_thread_t *p_vout = (vout_thread_t *)_p_vout;
1928 vlc_value_t sentval = newval;
1930 /* Find the video output index */
1931 for( i_vout = 0; i_vout < p_vout->p_sys->i_vout; i_vout++ )
1933 if( p_this == (vlc_object_t *)p_vout->p_sys->pp_vout[ i_vout ].p_vout )
1939 if( i_vout == p_vout->p_sys->i_vout )
1941 return VLC_EGENERIC;
1944 /* Translate the mouse coordinates */
1945 if( !strcmp( psz_var, "mouse-x" ) )
1948 int i_overlap = ((p_vout->p_sys->i_col > 2) ? 0 : 2 * p_vout->p_sys->i_halfLength);
1949 sentval.i_int += (p_vout->output.i_width - i_overlap)
1951 sentval.i_int += p_vout->output.i_width
1953 * (i_vout % p_vout->p_sys->i_col)
1954 / p_vout->p_sys->i_col;
1956 else if( !strcmp( psz_var, "mouse-y" ) )
1959 int i_overlap = ((p_vout->p_sys->i_row > 2) ? 0 : 2 * p_vout->p_sys->i_halfHeight);
1960 sentval.i_int += (p_vout->output.i_height - i_overlap)
1962 sentval.i_int += p_vout->output.i_height
1964 //bug fix in Wall plug-in
1965 // * (i_vout / p_vout->p_sys->i_row)
1966 * (i_vout / p_vout->p_sys->i_col)
1967 / p_vout->p_sys->i_row;
1970 var_Set( p_vout, psz_var, sentval );
1975 /*****************************************************************************
1976 * SendEventsToChild: forward events to the child/children vout
1977 *****************************************************************************/
1978 static int SendEventsToChild( vlc_object_t *p_this, char const *psz_var,
1979 vlc_value_t oldval, vlc_value_t newval, void *p_data )
1982 vout_thread_t *p_vout = (vout_thread_t *)p_this;
1983 int i_row, i_col, i_vout = 0;
1985 for( i_row = 0; i_row < p_vout->p_sys->i_row; i_row++ )
1987 for( i_col = 0; i_col < p_vout->p_sys->i_col; i_col++ )
1989 var_Set( p_vout->p_sys->pp_vout[ i_vout ].p_vout, psz_var, newval);
1990 if( !strcmp( psz_var, "fullscreen" ) ) break;