1 /*****************************************************************************
2 * panoramix.c : Wall panoramic video with edge blending plugin for vlc
3 *****************************************************************************
4 * Copyright (C) 2000, 2001, 2002, 2003 VideoLAN
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 <vlc_common.h>
34 #include <vlc_plugin.h>
38 #include "filter_common.h"
40 // add by cedric.cocquebert@supelec.fr
44 // OS CODE DEPENDENT to get display dimensions
51 // #define PACKED_YUV 1
52 #define F2(a) ((a)*(a))
53 #define F4(a,b,x) ((a)*(F2(x))+((b)*(x)))
55 #define RATIO_MAX 2500
56 #define CLIP_01(a) (a < 0.0 ? 0.0 : (a > 1.0 ? 1.0 : a))
57 // #define CLIP_0A(a) (a < 0.0 ? 0.0 : (a > ACCURACY ? ACCURACY : a))
60 /*****************************************************************************
62 *****************************************************************************/
63 static int Create ( vlc_object_t * );
64 static void Destroy ( vlc_object_t * );
66 static int Init ( vout_thread_t * );
67 static void End ( vout_thread_t * );
69 static void RenderPackedYUV ( vout_thread_t *, picture_t * );
71 static void RenderPlanarYUV ( vout_thread_t *, picture_t * );
72 static void RenderPackedRGB ( vout_thread_t *, picture_t * );
74 static void RemoveAllVout ( vout_thread_t *p_vout );
76 static int MouseEvent( vlc_object_t *, char const *,
77 vlc_value_t, vlc_value_t, void * );
78 static int FullscreenEventUp( vlc_object_t *, char const *,
79 vlc_value_t, vlc_value_t, void * );
80 static int FullscreenEventDown( vlc_object_t *, char const *,
81 vlc_value_t, vlc_value_t, void * );
83 /*****************************************************************************
85 *****************************************************************************/
86 #define COLS_TEXT N_("Number of columns")
87 #define COLS_LONGTEXT N_("Select the number of horizontal video windows in " \
88 "which to split the video")
90 #define ROWS_TEXT N_("Number of rows")
91 #define ROWS_LONGTEXT N_("Select the number of vertical video windows in " \
92 "which to split the video")
94 #define ACTIVE_TEXT N_("Active windows")
95 #define ACTIVE_LONGTEXT N_("Comma separated list of active windows, " \
98 #define CFG_PREFIX "panoramix-"
101 set_description( N_("Panoramix: wall with overlap video filter") )
102 set_shortname( N_("Panoramix" ))
103 set_capability( "video filter", 0 )
104 set_category( CAT_VIDEO )
105 set_subcategory( SUBCAT_VIDEO_VFILTER )
107 add_integer( CFG_PREFIX "cols", -1, NULL,
108 COLS_TEXT, COLS_LONGTEXT, true )
109 add_integer( CFG_PREFIX "rows", -1, NULL,
110 ROWS_TEXT, ROWS_LONGTEXT, true )
113 #define OFFSET_X_TEXT N_("Offset X offset (automatic compensation)")
114 #define OFFSET_X_LONGTEXT N_("Select if you want an automatic offset in horizontal (in case of misalignment due to autoratio control)")
115 add_bool( CFG_PREFIX "offset-x", 1, NULL, OFFSET_X_TEXT, OFFSET_X_LONGTEXT, true )
117 #define LENGTH_TEXT N_("length of the overlapping area (in %)")
118 #define LENGTH_LONGTEXT N_("Select in percent the length of the blended zone")
119 add_integer_with_range( CFG_PREFIX "bz-length", 100, 0, 100, NULL, LENGTH_TEXT, LENGTH_LONGTEXT, true )
121 #define HEIGHT_TEXT N_("height of the overlapping area (in %)")
122 #define HEIGHT_LONGTEXT N_("Select in percent the height of the blended zone (case of 2x2 wall)")
123 add_integer_with_range( CFG_PREFIX "bz-height", 100, 0, 100, NULL, HEIGHT_TEXT, HEIGHT_LONGTEXT, true )
125 #define ATTENUATION_TEXT N_("Attenuation")
126 #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)")
127 add_bool( CFG_PREFIX "attenuate", 1, NULL, ATTENUATION_TEXT, ATTENUATION_LONGTEXT, false )
129 #define BEGIN_TEXT N_("Attenuation, begin (in %)")
130 #define BEGIN_LONGTEXT N_("Select in percent the Lagrange coeff of the beginning blended zone")
131 add_integer_with_range( CFG_PREFIX "bz-begin", 0, 0, 100, NULL, BEGIN_TEXT, BEGIN_LONGTEXT, true )
133 #define MIDDLE_TEXT N_("Attenuation, middle (in %)")
134 #define MIDDLE_LONGTEXT N_("Select in percent the Lagrange coeff of the middle of blended zone")
135 add_integer_with_range( CFG_PREFIX "bz-middle", 50, 0, 100, NULL, MIDDLE_TEXT, MIDDLE_LONGTEXT, false )
137 #define END_TEXT N_("Attenuation, end (in %)")
138 #define END_LONGTEXT N_("Select in percent the Lagrange coeff of the end of blended zone")
139 add_integer_with_range( CFG_PREFIX "bz-end", 100, 0, 100, NULL, END_TEXT, END_LONGTEXT, true )
141 #define MIDDLE_POS_TEXT N_("middle position (in %)")
142 #define MIDDLE_POS_LONGTEXT N_("Select in percent (50 is center) the position of the middle point (Lagrange) of blended zone")
143 add_integer_with_range( CFG_PREFIX "bz-middle-pos", 50, 1, 99, NULL, MIDDLE_POS_TEXT, MIDDLE_POS_LONGTEXT, false )
145 #define RGAMMA_TEXT N_("Gamma (Red) correction")
146 #define RGAMMA_LONGTEXT N_("Select the gamma for the correction of blended zone (Red or Y component)")
147 add_float_with_range( CFG_PREFIX "bz-gamma-red", 1, 0, 5, NULL, RGAMMA_TEXT, RGAMMA_LONGTEXT, true )
149 #define GGAMMA_TEXT N_("Gamma (Green) correction")
150 #define GGAMMA_LONGTEXT N_("Select the gamma for the correction of blended zone (Green or U component)")
151 add_float_with_range( CFG_PREFIX "bz-gamma-green", 1, 0, 5, NULL, GGAMMA_TEXT, GGAMMA_LONGTEXT, true )
153 #define BGAMMA_TEXT N_("Gamma (Blue) correction")
154 #define BGAMMA_LONGTEXT N_("Select the gamma for the correction of blended zone (Blue or V component)")
155 add_float_with_range( CFG_PREFIX "bz-gamma-blue", 1, 0, 5, NULL, BGAMMA_TEXT, BGAMMA_LONGTEXT, true )
157 #define RGAMMA_BC_TEXT N_("Black Crush for Red")
158 #define RGAMMA_BC_LONGTEXT N_("Select the Black Crush of blended zone (Red or Y component)")
159 #define GGAMMA_BC_TEXT N_("Black Crush for Green")
160 #define GGAMMA_BC_LONGTEXT N_("Select the Black Crush of blended zone (Green or U component)")
161 #define BGAMMA_BC_TEXT N_("Black Crush for Blue")
162 #define BGAMMA_BC_LONGTEXT N_("Select the Black Crush of blended zone (Blue or V component)")
164 #define RGAMMA_WC_TEXT N_("White Crush for Red")
165 #define RGAMMA_WC_LONGTEXT N_("Select the White Crush of blended zone (Red or Y component)")
166 #define GGAMMA_WC_TEXT N_("White Crush for Green")
167 #define GGAMMA_WC_LONGTEXT N_("Select the White Crush of blended zone (Green or U component)")
168 #define BGAMMA_WC_TEXT N_("White Crush for Blue")
169 #define BGAMMA_WC_LONGTEXT N_("Select the White Crush of blended zone (Blue or V component)")
171 #define RGAMMA_BL_TEXT N_("Black Level for Red")
172 #define RGAMMA_BL_LONGTEXT N_("Select the Black Level of blended zone (Red or Y component)")
173 #define GGAMMA_BL_TEXT N_("Black Level for Green")
174 #define GGAMMA_BL_LONGTEXT N_("Select the Black Level of blended zone (Green or U component)")
175 #define BGAMMA_BL_TEXT N_("Black Level for Blue")
176 #define BGAMMA_BL_LONGTEXT N_("Select the Black Level of blended zone (Blue or V component)")
178 #define RGAMMA_WL_TEXT N_("White Level for Red")
179 #define RGAMMA_WL_LONGTEXT N_("Select the White Level of blended zone (Red or Y component)")
180 #define GGAMMA_WL_TEXT N_("White Level for Green")
181 #define GGAMMA_WL_LONGTEXT N_("Select the White Level of blended zone (Green or U component)")
182 #define BGAMMA_WL_TEXT N_("White Level for Blue")
183 #define BGAMMA_WL_LONGTEXT N_("Select the White Level of blended zone (Blue or V component)")
184 add_integer_with_range( CFG_PREFIX "bz-blackcrush-red", 140, 0, 255, NULL, RGAMMA_BC_TEXT, RGAMMA_BC_LONGTEXT, true )
185 add_integer_with_range( CFG_PREFIX "bz-blackcrush-green", 140, 0, 255, NULL, GGAMMA_BC_TEXT, GGAMMA_BC_LONGTEXT, true )
186 add_integer_with_range( CFG_PREFIX "bz-blackcrush-blue", 140, 0, 255, NULL, BGAMMA_BC_TEXT, BGAMMA_BC_LONGTEXT, true )
187 add_integer_with_range( CFG_PREFIX "bz-whitecrush-red", 200, 0, 255, NULL, RGAMMA_WC_TEXT, RGAMMA_WC_LONGTEXT, true )
188 add_integer_with_range( CFG_PREFIX "bz-whitecrush-green", 200, 0, 255, NULL, GGAMMA_WC_TEXT, GGAMMA_WC_LONGTEXT, true )
189 add_integer_with_range( CFG_PREFIX "bz-whitecrush-blue", 200, 0, 255, NULL, BGAMMA_WC_TEXT, BGAMMA_WC_LONGTEXT, true )
190 add_integer_with_range( CFG_PREFIX "bz-blacklevel-red", 150, 0, 255, NULL, RGAMMA_BL_TEXT, RGAMMA_BL_LONGTEXT, true )
191 add_integer_with_range( CFG_PREFIX "bz-blacklevel-green", 150, 0, 255, NULL, GGAMMA_BL_TEXT, GGAMMA_BL_LONGTEXT, true )
192 add_integer_with_range( CFG_PREFIX "bz-blacklevel-blue", 150, 0, 255, NULL, BGAMMA_BL_TEXT, BGAMMA_BL_LONGTEXT, true )
193 add_integer_with_range( CFG_PREFIX "bz-whitelevel-red", 0, 0, 255, NULL, RGAMMA_WL_TEXT, RGAMMA_WL_LONGTEXT, true )
194 add_integer_with_range( CFG_PREFIX "bz-whitelevel-green", 0, 0, 255, NULL, GGAMMA_WL_TEXT, GGAMMA_WL_LONGTEXT, true )
195 add_integer_with_range( CFG_PREFIX "bz-whitelevel-blue", 0, 0, 255, NULL, BGAMMA_WL_TEXT, BGAMMA_WL_LONGTEXT, true )
197 #define XINERAMA_TEXT N_("Xinerama option")
198 #define XINERAMA_LONGTEXT N_("Uncheck if you have not used xinerama")
199 add_bool( CFG_PREFIX "xinerama", 1, NULL, XINERAMA_TEXT, XINERAMA_LONGTEXT, true )
203 add_string( CFG_PREFIX "active", NULL, NULL, ACTIVE_TEXT, ACTIVE_LONGTEXT, true )
205 add_shortcut( "panoramix" )
206 set_callbacks( Create, Destroy )
209 static const char *const ppsz_filter_options[] = {
210 "cols", "rows", "offset-x", "bz-length", "bz-height", "attenuate",
211 "bz-begin", "bz-middle", "bz-end", "bz-middle-pos", "bz-gamma-red",
212 "bz-gamma-green", "bz-gamma-blue", "bz-blackcrush-red",
213 "bz-blackcrush-green", "bz-blackcrush-blue", "bz-whitecrush-red",
214 "bz-whitecrush-green", "bz-whitecrush-blue", "bz-blacklevel-red",
215 "bz-blacklevel-green", "bz-blacklevel-blue", "bz-whitelevel-red",
216 "bz-whitelevel-green", "bz-whitelevel-blue", "xinerama", "active",
220 /*****************************************************************************
221 * vout_sys_t: Wall video output method descriptor
222 *****************************************************************************
223 * This structure is part of the video output thread descriptor.
224 * It describes the Wall specific properties of an output thread.
225 *****************************************************************************/
231 unsigned int bz_length, bz_height, bz_begin, bz_middle, bz_end, bz_middle_pos;
232 unsigned int i_ratio_max;
233 unsigned int i_ratio;
234 unsigned int a_0, a_1, a_2;
236 int lambda[2][VOUT_MAX_PLANES][500];
237 int cstYUV[2][VOUT_MAX_PLANES][500];
238 int lambda2[2][VOUT_MAX_PLANES][500];
239 int cstYUV2[2][VOUT_MAX_PLANES][500];
240 unsigned int i_halfLength;
241 unsigned int i_halfHeight;
245 float f_gamma_red, f_gamma_green, f_gamma_blue;
246 float f_gamma[VOUT_MAX_PLANES];
247 uint8_t LUT[VOUT_MAX_PLANES][ACCURACY + 1][256];
249 uint8_t LUT2[VOUT_MAX_PLANES][256][500];
264 vout_thread_t *p_vout;
270 /*****************************************************************************
271 * Control: control facility for the vout (forwards to child vout)
272 *****************************************************************************/
273 static int Control( vout_thread_t *p_vout, int i_query, va_list args )
275 int i_row, i_col, i_vout = 0;
277 for( i_row = 0; i_row < p_vout->p_sys->i_row; i_row++ )
279 for( i_col = 0; i_col < p_vout->p_sys->i_col; i_col++ )
281 vout_vaControl( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
289 /*****************************************************************************
290 * Create: allocates Wall video thread output method
291 *****************************************************************************
292 * This function allocates and initializes a Wall vout method.
293 *****************************************************************************/
294 static int Create( vlc_object_t *p_this )
296 vout_thread_t *p_vout = (vout_thread_t *)p_this;
297 char *psz_method, *psz_tmp, *psz_method_tmp;
300 /* Allocate structure */
301 p_vout->p_sys = malloc( sizeof( vout_sys_t ) );
302 if( p_vout->p_sys == NULL )
305 p_vout->pf_init = Init;
306 p_vout->pf_end = End;
307 p_vout->pf_manage = NULL;
308 /* Color Format not supported
309 // Planar Y, packed UV
310 case VLC_FOURCC('Y','M','G','A'):
311 // Packed YUV 4:2:2, U:Y:V:Y, interlaced
312 case VLC_FOURCC('I','U','Y','V'): // packed by 2
313 // Packed YUV 2:1:1, Y:U:Y:V
314 case VLC_FOURCC('Y','2','1','1'): // packed by 4
315 // Packed YUV Reverted
316 case VLC_FOURCC('c','y','u','v'): // packed by 2
318 switch (p_vout->render.i_chroma)
321 case VLC_FOURCC('I','4','4','4'):
322 case VLC_FOURCC('I','4','2','2'):
323 case VLC_FOURCC('I','4','2','0'):
324 case VLC_FOURCC('Y','V','1','2'):
325 case VLC_FOURCC('I','Y','U','V'):
326 case VLC_FOURCC('I','4','1','1'):
327 case VLC_FOURCC('I','4','1','0'):
328 case VLC_FOURCC('Y','V','U','9'):
329 case VLC_FOURCC('Y','U','V','A'):
330 p_vout->pf_render = RenderPlanarYUV;
333 case VLC_FOURCC('R','G','B','2'): // packed by 1
334 case VLC_FOURCC('R','V','1','5'): // packed by 2
335 case VLC_FOURCC('R','V','1','6'): // packed by 2
336 case VLC_FOURCC('R','V','2','4'): // packed by 3
337 case VLC_FOURCC('R','V','3','2'): // packed by 4
338 p_vout->pf_render = RenderPackedRGB;
342 case VLC_FOURCC('Y','U','Y','2'): // packed by 2
343 case VLC_FOURCC('Y','U','N','V'): // packed by 2
344 case VLC_FOURCC('U','Y','V','Y'): // packed by 2
345 case VLC_FOURCC('U','Y','N','V'): // packed by 2
346 case VLC_FOURCC('Y','4','2','2'): // packed by 2
347 p_vout->pf_render = RenderPackedYUV;
351 msg_Err( p_vout, "colorspace not supported by plug-in !!!");
352 free( p_vout->p_sys );
355 p_vout->pf_display = NULL;
356 p_vout->pf_control = Control;
358 config_ChainParse( p_vout, CFG_PREFIX, ppsz_filter_options,
361 /* Look what method was requested */
362 p_vout->p_sys->i_col = var_CreateGetInteger( p_vout, CFG_PREFIX "cols" );
363 p_vout->p_sys->i_row = var_CreateGetInteger( p_vout, CFG_PREFIX "rows" );
365 // OS dependent code : Autodetect number of displays in wall
367 if ((p_vout->p_sys->i_col < 0) || (p_vout->p_sys->i_row < 0) )
369 int nbMonitors = GetSystemMetrics(SM_CMONITORS);
372 nbMonitors = 5; // 1 display => 5x1 simulation
373 p_vout->p_sys->i_col = nbMonitors;
374 p_vout->p_sys->i_row = 1;
378 p_vout->p_sys->i_col = GetSystemMetrics( SM_CXVIRTUALSCREEN ) / GetSystemMetrics( SM_CXSCREEN );
379 p_vout->p_sys->i_row = GetSystemMetrics( SM_CYVIRTUALSCREEN ) / GetSystemMetrics( SM_CYSCREEN );
380 if (p_vout->p_sys->i_col * p_vout->p_sys->i_row != nbMonitors)
382 p_vout->p_sys->i_col = nbMonitors;
383 p_vout->p_sys->i_row = 1;
386 var_SetInteger( p_vout, CFG_PREFIX "cols", p_vout->p_sys->i_col);
387 var_SetInteger( p_vout, CFG_PREFIX "rows", p_vout->p_sys->i_row);
392 p_vout->p_sys->i_offset_x = var_CreateGetBool( p_vout, CFG_PREFIX "offset-x" );
393 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
394 p_vout->p_sys->b_autocrop = !(var_CreateGetInteger( p_vout, "crop-ratio" ) == 0);
395 if (!p_vout->p_sys->b_autocrop) p_vout->p_sys->b_autocrop = var_CreateGetInteger( p_vout, "autocrop" );
396 p_vout->p_sys->b_attenuate = var_CreateGetBool( p_vout, CFG_PREFIX "attenuate");
397 p_vout->p_sys->bz_length = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-length" );
398 if (p_vout->p_sys->i_row > 1)
399 p_vout->p_sys->bz_height = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-height" );
401 p_vout->p_sys->bz_height = 100;
402 p_vout->p_sys->bz_begin = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-begin" );
403 p_vout->p_sys->bz_middle = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-middle" );
404 p_vout->p_sys->bz_end = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-end" );
405 p_vout->p_sys->bz_middle_pos = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-middle-pos" );
406 double d_p = 100.0 / p_vout->p_sys->bz_middle_pos;
407 p_vout->p_sys->i_ratio_max = var_CreateGetInteger( p_vout, "autocrop-ratio-max" ); // in crop module with autocrop ...
408 p_vout->p_sys->i_ratio = var_CreateGetInteger( p_vout, "crop-ratio" ); // in crop module with manual ratio ...
410 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;
411 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;
412 p_vout->p_sys->a_0 = p_vout->p_sys->bz_begin;
415 p_vout->p_sys->f_gamma_red = var_CreateGetFloat( p_vout, CFG_PREFIX "bz-gamma-red" );
416 p_vout->p_sys->f_gamma_green = var_CreateGetFloat( p_vout, CFG_PREFIX "bz-gamma-green" );
417 p_vout->p_sys->f_gamma_blue = var_CreateGetFloat( p_vout, CFG_PREFIX "bz-gamma-blue" );
420 p_vout->p_sys->b_xinerama = var_CreateGetBool( p_vout, CFG_PREFIX "xinerama" );
423 p_vout->p_sys->i_col = __MAX( 1, __MIN( 15, p_vout->p_sys->i_col ) );
424 p_vout->p_sys->i_row = __MAX( 1, __MIN( 15, p_vout->p_sys->i_row ) );
427 msg_Dbg( p_vout, "opening a %i x %i wall",
428 p_vout->p_sys->i_col, p_vout->p_sys->i_row );
430 p_vout->p_sys->pp_vout = calloc( p_vout->p_sys->i_row *
431 p_vout->p_sys->i_col,
432 sizeof(struct vout_list_t) );
433 if( p_vout->p_sys->pp_vout == NULL )
435 free( p_vout->p_sys );
440 psz_method = var_CreateGetNonEmptyString( p_vout, CFG_PREFIX "active" );
442 /* If no trailing vout are specified, take them all */
443 if( psz_method == NULL )
445 for( i_vout = p_vout->p_sys->i_row * p_vout->p_sys->i_col;
448 p_vout->p_sys->pp_vout[i_vout].b_active = 1;
451 /* If trailing vout are specified, activate only the requested ones */
454 for( i_vout = p_vout->p_sys->i_row * p_vout->p_sys->i_col;
457 p_vout->p_sys->pp_vout[i_vout].b_active = 0;
462 psz_tmp = psz_method;
463 while( *psz_tmp && *psz_tmp != ',' )
471 i_vout = atoi( psz_method );
472 psz_method = psz_tmp + 1;
476 i_vout = atoi( psz_method );
477 psz_method = psz_tmp;
481 i_vout < p_vout->p_sys->i_row * p_vout->p_sys->i_col )
483 p_vout->p_sys->pp_vout[i_vout].b_active = 1;
488 free( psz_method_tmp );
495 /*****************************************************************************
496 * CLIP_0A: clip between 0 and ACCURACY
497 *****************************************************************************/
498 inline static int CLIP_0A( int a )
500 return (a > ACCURACY) ? ACCURACY : (a < 0) ? 0 : a;
504 /*****************************************************************************
505 * Gamma: Gamma correction
506 *****************************************************************************/
507 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])
511 f_Input = (f_component * f_BlackLevel[i_plane]) / (f_BlackCrush[i_plane]) + (1.0 - f_BlackLevel[i_plane]);
512 if (f_component <= f_BlackCrush[i_plane])
514 return pow(f_Input, 1.0 / f_Gamma[i_plane]);
516 else if (f_component >= f_WhiteCrush[i_plane])
518 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);
519 return pow(f_Input, 1.0 / f_Gamma[i_plane]);
529 /*****************************************************************************
530 * F: Function to calculate Gamma correction
531 *****************************************************************************/
532 static uint8_t F(uint8_t i, float gamma)
534 double input = (double) i / 255.0;
536 // return clip(255 * pow(input, 1.0 / gamma));
539 return clip_uint8((255 * pow(2 * input, gamma)) / 2);
541 return clip_uint8(255 * (1 - pow(2 * (1 - input), gamma) / 2));
546 /*****************************************************************************
547 * AdjustHeight: ajust p_sys->i_height to have same BZ width for any ratio
548 *****************************************************************************/
549 static int AdjustHeight( vout_thread_t *p_vout )
551 bool b_fullscreen = p_vout->b_fullscreen;
552 int i_window_width = p_vout->i_window_width;
553 int i_window_height = p_vout->i_window_height;
554 double d_halfLength = 0;
555 double d_halfLength_crop;
556 double d_halfLength_calculated;
559 // OS DEPENDENT CODE to get display dimensions
563 i_window_width = GetSystemMetrics(SM_CXSCREEN);
564 i_window_height = GetSystemMetrics(SM_CYSCREEN);
566 char *psz_display = var_CreateGetNonEmptyString( p_vout,
568 Display *p_display = XOpenDisplay( psz_display );
570 if (p_vout->p_sys->b_xinerama)
572 i_window_width = DisplayWidth(p_display, 0) / p_vout->p_sys->i_col;
573 i_window_height = DisplayHeight(p_display, 0) / p_vout->p_sys->i_row;
577 i_window_width = DisplayWidth(p_display, 0);
578 i_window_height = DisplayHeight(p_display, 0);
580 XCloseDisplay( p_display );
582 var_SetInteger( p_vout, "width", i_window_width);
583 var_SetInteger( p_vout, "height", i_window_height);
584 p_vout->i_window_width = i_window_width;
585 p_vout->i_window_height = i_window_height;
588 if( p_vout->p_sys->bz_length)
589 if ((!p_vout->p_sys->b_autocrop) && (!p_vout->p_sys->i_ratio))
591 if ((p_vout->p_sys->i_row > 1) || (p_vout->p_sys->i_col > 1))
593 while ((d_halfLength <= 0) || (d_halfLength > p_vout->render.i_width / (2 * p_vout->p_sys->i_col)))
595 if (p_vout->p_sys->bz_length >= 50)
597 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);
601 d_halfLength = (p_vout->render.i_width * p_vout->p_sys->bz_length) / (100.0 * p_vout->p_sys->i_col);
602 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);
604 if ((d_halfLength <= 0) || (d_halfLength > p_vout->render.i_width / (2 * p_vout->p_sys->i_col)))
605 p_vout->p_sys->i_row--;
606 if (p_vout->p_sys->i_row < 1 )
608 p_vout->p_sys->i_row = 1;
612 p_vout->p_sys->i_halfLength = (d_halfLength + 0.5);
613 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;
614 var_SetInteger( p_vout, "bz-length", p_vout->p_sys->bz_length);
615 var_SetInteger( p_vout, "panoramix-rows", p_vout->p_sys->i_row);
620 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;
621 d_halfLength_crop = d_halfLength * VOUT_ASPECT_FACTOR * (double)p_vout->output.i_width
622 / (double)i_window_height / (double)p_vout->render.i_aspect;
623 p_vout->p_sys->i_halfLength = (d_halfLength_crop + 0.5);
624 d_halfLength_calculated = p_vout->p_sys->i_halfLength * (double)i_window_height *
625 (double)p_vout->render.i_aspect / VOUT_ASPECT_FACTOR / (double)p_vout->output.i_width;
627 if (!p_vout->p_sys->b_attenuate)
629 double d_bz_length = (p_vout->p_sys->i_halfLength * p_vout->p_sys->i_col * 100.0) / p_vout->render.i_width;
630 // F(2x) != 2F(x) in opengl module
631 if (p_vout->p_sys->i_col == 2) d_bz_length = (100.0 * d_bz_length) / (100.0 - d_bz_length) ;
632 var_SetInteger( p_vout, "bz-length", (int)(d_bz_length + 0.5));
634 i_offset = (int)d_halfLength - (int)
635 (p_vout->p_sys->i_halfLength * (double)i_window_height *
636 (double)p_vout->render.i_aspect / VOUT_ASPECT_FACTOR / (double)p_vout->output.i_width);
639 p_vout->p_sys->i_halfLength = 0;
646 /*****************************************************************************
647 * Init: initialize Wall video thread output method
648 *****************************************************************************/
649 #define VLC_XCHG( type, a, b ) do { type __tmp = (b); (b) = (a); (a) = __tmp; } while(0)
651 static int Init( vout_thread_t *p_vout )
653 int i_index, i_row, i_col;
655 I_OUTPUTPICTURES = 0;
657 /* Initialize the output structure */
658 p_vout->output.i_chroma = p_vout->render.i_chroma;
659 p_vout->output.i_width = p_vout->render.i_width;
660 p_vout->output.i_height = p_vout->render.i_height;
661 p_vout->output.i_aspect = p_vout->render.i_aspect;
663 p_vout->p_sys->b_has_changed = p_vout->p_sys->b_attenuate;
664 int i_video_x = var_GetInteger( p_vout, "video-x");
665 int i_video_y = var_GetInteger( p_vout, "video-y");
667 if (p_vout->p_sys->b_attenuate)
669 int i_index2, i_plane;
670 int constantYUV[3] = {0,128,128};
671 float f_BlackCrush[VOUT_MAX_PLANES];
672 float f_BlackLevel[VOUT_MAX_PLANES];
673 float f_WhiteCrush[VOUT_MAX_PLANES];
674 float f_WhiteLevel[VOUT_MAX_PLANES];
675 p_vout->p_sys->f_gamma[0] = var_CreateGetFloat( p_vout, CFG_PREFIX "bz-gamma-red" );
676 p_vout->p_sys->f_gamma[1] = var_CreateGetFloat( p_vout, CFG_PREFIX "bz-gamma-green" );
677 p_vout->p_sys->f_gamma[2] = var_CreateGetFloat( p_vout, CFG_PREFIX "bz-gamma-blue" );
678 f_BlackCrush[0] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-blackcrush-red" ) / 255.0;
679 f_BlackCrush[1] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-blackcrush-green" ) / 255.0;
680 f_BlackCrush[2] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-blackcrush-blue" ) / 255.0;
681 f_WhiteCrush[0] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-whitecrush-red" ) / 255.0;
682 f_WhiteCrush[1] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-whitecrush-green" ) / 255.0;
683 f_WhiteCrush[2] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-whitecrush-blue" ) / 255.0;
684 f_BlackLevel[0] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-blacklevel-red" ) / 255.0;
685 f_BlackLevel[1] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-blacklevel-green" ) / 255.0;
686 f_BlackLevel[2] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-blacklevel-blue" ) / 255.0;
687 f_WhiteLevel[0] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-whitelevel-red" ) / 255.0;
688 f_WhiteLevel[1] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-whitelevel-green" ) / 255.0;
689 f_WhiteLevel[2] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-whitelevel-blue" ) / 255.0;
690 for( int i = 3; i < VOUT_MAX_PLANES; i++ )
692 /* Initialize unsupported planes */
693 f_BlackCrush[i] = 140.0/255.0;
694 f_WhiteCrush[i] = 200.0/255.0;
695 f_BlackLevel[i] = 150.0/255.0;
696 f_WhiteLevel[i] = 0.0/255.0;
697 p_vout->p_sys->f_gamma[i] = 1.0;
700 switch (p_vout->render.i_chroma)
703 case VLC_FOURCC('Y','V','1','2'):
704 case VLC_FOURCC('Y','V','U','9'):
706 case VLC_FOURCC('U','Y','V','Y'): // packed by 2
707 case VLC_FOURCC('U','Y','N','V'): // packed by 2
708 case VLC_FOURCC('Y','4','2','2'): // packed by 2
709 // case VLC_FOURCC('c','y','u','v'): // packed by 2
710 VLC_XCHG( float, p_vout->p_sys->f_gamma[1], p_vout->p_sys->f_gamma[2] );
711 VLC_XCHG( float, f_BlackCrush[1], f_BlackCrush[2] );
712 VLC_XCHG( float, f_WhiteCrush[1], f_WhiteCrush[2] );
713 VLC_XCHG( float, f_BlackLevel[1], f_BlackLevel[2] );
714 VLC_XCHG( float, f_WhiteLevel[1], f_WhiteLevel[2] );
716 case VLC_FOURCC('I','4','4','4'):
717 case VLC_FOURCC('I','4','2','2'):
718 case VLC_FOURCC('I','4','2','0'):
719 case VLC_FOURCC('I','4','1','1'):
720 case VLC_FOURCC('I','4','1','0'):
721 case VLC_FOURCC('I','Y','U','V'):
722 case VLC_FOURCC('Y','U','V','A'):
724 case VLC_FOURCC('Y','U','Y','2'): // packed by 2
725 case VLC_FOURCC('Y','U','N','V'): // packed by 2
726 for (i_index = 0; i_index < 256; i_index++)
727 for (i_index2 = 0; i_index2 <= ACCURACY; i_index2++)
728 for (i_plane = 0; i_plane < VOUT_MAX_PLANES; i_plane++)
730 float f_lut = CLIP_01(1.0 -
731 ((ACCURACY - (float)i_index2)
732 * Gamma_Correction(i_plane, (float)i_index / 255.0, f_BlackCrush, f_WhiteCrush, f_BlackLevel, f_WhiteLevel, p_vout->p_sys->f_gamma)
734 p_vout->p_sys->LUT[i_plane][i_index2][i_index] = f_lut * i_index + (int)((1.0 - f_lut) * (float)constantYUV[i_plane]);
738 case VLC_FOURCC('R','G','B','2'): // packed by 1
739 case VLC_FOURCC('R','V','1','5'): // packed by 2
740 case VLC_FOURCC('R','V','1','6'): // packed by 2
741 case VLC_FOURCC('R','V','2','4'): // packed by 3
742 case VLC_FOURCC('R','V','3','2'): // packed by 4
743 for (i_index = 0; i_index < 256; i_index++)
744 for (i_index2 = 0; i_index2 <= ACCURACY; i_index2++)
745 for (i_plane = 0; i_plane < VOUT_MAX_PLANES; i_plane++)
747 float f_lut = CLIP_01(1.0 -
748 ((ACCURACY - (float)i_index2)
749 * Gamma_Correction(i_plane, (float)i_index / 255.0, f_BlackCrush, f_WhiteCrush, f_BlackLevel, f_WhiteLevel, p_vout->p_sys->f_gamma)
751 p_vout->p_sys->LUT[i_plane][i_index2][i_index] = f_lut * i_index;
755 msg_Err( p_vout, "colorspace not supported by plug-in !!!");
756 free( p_vout->p_sys );
761 if (p_vout->p_sys->i_offset_x)
762 p_vout->p_sys->i_offset_x = AdjustHeight(p_vout);
764 AdjustHeight(p_vout);
765 if (p_vout->p_sys->i_row >= 2)
767 p_vout->p_sys->i_halfHeight = (p_vout->p_sys->i_halfLength * p_vout->p_sys->bz_height) / 100;
768 p_vout->p_sys->i_halfHeight -= (p_vout->p_sys->i_halfHeight % 2);
772 /* Try to open the real video output */
773 msg_Dbg( p_vout, "spawning the real video outputs" );
775 /* FIXME: use bresenham instead of those ugly divisions */
776 p_vout->p_sys->i_vout = 0;
777 for( i_row = 0; i_row < p_vout->p_sys->i_row; i_row++ )
779 for( i_col = 0; i_col < p_vout->p_sys->i_col; i_col++, p_vout->p_sys->i_vout++ )
781 struct vout_list_t *p_entry = &p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ];
783 int i_width, i_height;
786 i_width = ( p_vout->render.i_width / p_vout->p_sys->i_col ) & ~0x1;
787 if( i_col + 1 == p_vout->p_sys->i_col )
788 i_width = p_vout->render.i_width - i_col * i_width;
791 i_width += p_vout->p_sys->i_halfLength;
792 if (p_vout->p_sys->i_col > 2 )
793 i_width += p_vout->p_sys->i_halfLength;
798 i_height = ( p_vout->render.i_height / p_vout->p_sys->i_row ) & ~0x3;
799 if( i_row + 1 == p_vout->p_sys->i_row )
800 i_height = p_vout->render.i_height - i_row * i_height;
802 if(p_vout->p_sys->i_row >= 2 )
804 i_height += p_vout->p_sys->i_halfHeight;
805 if( p_vout->p_sys->i_row > 2 )
806 i_height += p_vout->p_sys->i_halfHeight;
810 p_entry->i_width = i_width;
811 p_entry->i_height = i_height;
813 if( !p_entry->b_active )
817 memset( &fmt, 0, sizeof(video_format_t) );
818 fmt.i_width = fmt.i_visible_width = p_vout->render.i_width;
819 fmt.i_height = fmt.i_visible_height = p_vout->render.i_height;
820 fmt.i_x_offset = fmt.i_y_offset = 0;
821 fmt.i_chroma = p_vout->render.i_chroma;
822 fmt.i_aspect = p_vout->render.i_aspect;
823 fmt.i_sar_num = p_vout->render.i_aspect * fmt.i_height / fmt.i_width;
824 fmt.i_sar_den = VOUT_ASPECT_FACTOR;
825 fmt.i_width = fmt.i_visible_width = i_width;
826 fmt.i_height = fmt.i_visible_height = i_height;
827 fmt.i_aspect = p_vout->render.i_aspect
828 * p_vout->render.i_height / i_height
829 * i_width / p_vout->render.i_width;
831 if (p_vout->p_sys->i_offset_x < 0)
833 var_SetInteger(p_vout, "video-x", -p_vout->p_sys->i_offset_x);
834 p_vout->p_sys->i_offset_x = 0;
837 p_entry->p_vout = vout_Create( p_vout, &fmt);
839 if( p_entry->p_vout == NULL )
841 msg_Err( p_vout, "failed to get %ix%i vout threads",
842 p_vout->p_sys->i_col, p_vout->p_sys->i_row );
843 RemoveAllVout( p_vout );
846 vout_filter_SetupChild( p_vout, p_entry->p_vout,
847 MouseEvent, FullscreenEventUp, FullscreenEventDown, true );
850 p_entry->p_vout->i_alignment = 0;
852 p_entry->p_vout->i_alignment |= VOUT_ALIGN_RIGHT;
853 else if (i_col == p_vout->p_sys->i_col -1)
854 p_entry->p_vout->i_alignment |= VOUT_ALIGN_LEFT;
855 if (p_vout->p_sys->i_row > 1)
858 p_entry->p_vout->i_alignment |= VOUT_ALIGN_BOTTOM;
859 else if (i_row == p_vout->p_sys->i_row -1)
860 p_entry->p_vout->i_alignment |= VOUT_ALIGN_TOP;
862 // i_active : number of active pp_vout
864 for( int i = 0; i <= p_vout->p_sys->i_vout; i++ )
866 if( p_vout->p_sys->pp_vout[i].b_active )
869 var_SetInteger( p_vout, "align", p_entry->p_vout->i_alignment );
870 var_SetInteger( p_vout, "video-x", i_video_x + p_vout->p_sys->i_offset_x + (i_active % p_vout->p_sys->i_col) * p_vout->i_window_width);
871 var_SetInteger( p_vout, "video-y", i_video_y + (i_active / p_vout->p_sys->i_col) * p_vout->i_window_height);
876 vout_filter_AllocateDirectBuffers( p_vout, VOUT_MAX_PICTURES );
881 /*****************************************************************************
882 * End: terminate Wall video thread output method
883 *****************************************************************************/
884 static void End( vout_thread_t *p_vout )
886 RemoveAllVout( p_vout );
888 vout_filter_ReleaseDirectBuffers( p_vout );
891 var_SetInteger( p_vout, "bz-length", p_vout->p_sys->bz_length);
895 /*****************************************************************************
896 * Destroy: destroy Wall video thread output method
897 *****************************************************************************
898 * Terminate an output method created by WallCreateOutputMethod
899 *****************************************************************************/
900 static void Destroy( vlc_object_t *p_this )
902 vout_thread_t *p_vout = (vout_thread_t *)p_this;
904 free( p_vout->p_sys->pp_vout );
905 free( p_vout->p_sys );
909 /*****************************************************************************
910 * RenderPlanarYUV: displays previously rendered output
911 *****************************************************************************
912 * This function send the currently rendered image to Wall image, waits
913 * until it is displayed and switch the two rendering buffers, preparing next
915 *****************************************************************************/
916 static void RenderPlanarYUV( vout_thread_t *p_vout, picture_t *p_pic )
918 picture_t *p_outpic = NULL;
919 int i_col, i_row, i_vout, i_plane;
920 int pi_left_skip[VOUT_MAX_PLANES], pi_top_skip[VOUT_MAX_PLANES];
923 int constantYUV[3] = {0,128,128};
928 int i_index, i_index2;
931 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
932 pi_top_skip[i_plane] = 0;
934 for( i_vout = 0, i_row = 0; i_row < p_vout->p_sys->i_row; i_row++ )
936 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
937 pi_left_skip[i_plane] = 0;
939 for( i_col = 0; i_col < p_vout->p_sys->i_col; i_col++, i_vout++ )
941 struct vout_list_t *p_entry = &p_vout->p_sys->pp_vout[ i_vout ];
942 if( !p_entry->b_active )
944 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
946 pi_left_skip[i_plane] += p_entry->i_width * p_pic->p[i_plane].i_pitch / p_vout->output.i_width;
951 while( ( p_outpic = vout_CreatePicture( p_entry->p_vout, 0, 0, 0 )) == NULL )
953 if( !vlc_object_alive(p_vout) || p_vout->b_error )
955 vout_DestroyPicture( p_entry->p_vout, p_outpic );
958 msleep( VOUT_OUTMEM_SLEEP );
961 p_outpic->date = p_pic->date;
962 vout_LinkPicture( p_entry->p_vout, p_outpic );
964 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
966 uint8_t *p_in, *p_in_end, *p_out;
967 int i_in_pitch = p_pic->p[i_plane].i_pitch;
968 int i_out_pitch = p_outpic->p[i_plane].i_pitch;
969 int i_copy_pitch = p_outpic->p[i_plane].i_visible_pitch;
970 int i_lines = p_outpic->p[i_plane].i_visible_lines;
971 const int i_div = p_entry->i_width / i_copy_pitch;
973 const bool b_row_first = i_row == 0;
974 const bool b_row_last = i_row + 1 == p_vout->p_sys->i_row;
975 const bool b_col_first = i_col == 0;
976 const bool b_col_last = i_col + 1 == p_vout->p_sys->i_col;
980 pi_left_skip[i_plane] -= (2 * p_vout->p_sys->i_halfLength ) / i_div;
982 if( p_vout->p_sys->i_row >= 2 )
984 if( !b_row_first && b_col_first )
985 pi_top_skip[i_plane] -= (2 * p_vout->p_sys->i_halfHeight * p_pic->p[i_plane].i_pitch) / i_div;
986 if( p_vout->p_sys->i_row > 2 && i_row == 1 && b_col_first )
987 pi_top_skip[i_plane] -= (2 * p_vout->p_sys->i_halfHeight * p_pic->p[i_plane].i_pitch) / i_div;
988 if( !p_vout->p_sys->pp_vout[p_vout->p_sys->i_col-1].b_active )
989 pi_top_skip[i_plane] -= (2 * p_vout->p_sys->i_halfHeight * i_row * p_pic->p[i_plane].i_pitch) / i_div;
991 // i_n : previous inactive pp_vout
993 while( (i_col - i_n > 1) && (!p_vout->p_sys->pp_vout[i_row * p_vout->p_sys->i_col + i_col - 1 - i_n].b_active) ) i_n++;
994 if( i_col > 1 && i_n )
995 pi_left_skip[i_plane] -= i_n * (2 * p_vout->p_sys->i_halfLength ) / i_div;
998 if( p_vout->p_sys->i_row > 2 && ( b_row_first || b_row_last ) )
999 i_lines -= (2 * p_vout->p_sys->i_halfHeight) / i_div;
1001 // 1088 lines bug in a mpeg2 stream of 1080 lines
1002 if( b_row_last && p_pic->p[i_plane].i_lines == 1088 )
1003 i_lines -= 8 / i_div;
1006 p_in = &p_pic->p[i_plane].p_pixels[ pi_top_skip[i_plane] + pi_left_skip[i_plane] ]; /* Wall proprities */
1007 p_in_end = &p_in[i_lines * p_pic->p[i_plane].i_pitch];
1009 p_out = p_outpic->p[i_plane].p_pixels;
1011 if( p_vout->p_sys->i_row > 2 && b_row_first )
1012 p_out += p_outpic->p[i_plane].i_pitch * (2 * p_vout->p_sys->i_halfHeight) / i_div;
1015 int length = 2 * p_vout->p_sys->i_halfLength / i_div;
1017 if( p_vout->p_sys->b_has_changed )
1020 a_2 = p_vout->p_sys->a_2 * (ACCURACY / 100);
1021 a_1 = p_vout->p_sys->a_1 * length * (ACCURACY / 100);
1022 a_0 = p_vout->p_sys->a_0 * Denom * (ACCURACY / 100);
1023 for( i_col_mod = 0; i_col_mod < 2; i_col_mod++ )
1025 for( i_index = 0; i_index < length; i_index++ )
1027 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);
1028 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;
1033 while( p_in < p_in_end )
1036 vlc_memcpy( p_out, p_in, i_copy_pitch);
1038 if( p_vout->p_sys->i_col > 2 )
1040 const int halfl = length / 2;
1042 vlc_memcpy( &p_out[halfl], &p_in[0], i_copy_pitch - halfl );
1043 else if( b_col_last )
1044 vlc_memcpy( &p_out[ 0], &p_in[-halfl], i_copy_pitch - halfl );
1046 vlc_memcpy( &p_out[ 0], &p_in[-halfl], i_copy_pitch);
1050 memset( &p_out[0], constantYUV[i_plane], halfl);
1051 else if( b_col_last )
1052 memset( &p_out[i_copy_pitch - halfl], constantYUV[i_plane], halfl );
1056 vlc_memcpy( p_out , p_in, i_copy_pitch );
1059 if( p_vout->p_sys->b_attenuate )
1062 // first blended zone
1065 uint8_t *p_dst = &p_out[0];
1066 for (i_index = 0; i_index < length; i_index++)
1069 p_dst[i_index] = (p_vout->p_sys->lambda[1][i_plane][i_index] * p_dst[i_index]) / ACCURACY +
1070 p_vout->p_sys->cstYUV[1][i_plane][i_index];
1072 p_dst[i_index] = p_vout->p_sys->LUT[i_plane][p_vout->p_sys->lambda[1][i_plane][i_index]][p_dst[i_index]];
1076 // second blended zone
1079 uint8_t *p_dst = &p_out[i_copy_pitch - length];
1080 for (i_index = 0; i_index < length; i_index++)
1083 p_dst[i_index] = (p_vout->p_sys->lambda[0][i_plane][i_index] * p_dst[i_index]) / ACCURACY +
1084 p_vout->p_sys->cstYUV[0][i_plane][i_index];
1086 p_dst[i_index] = p_vout->p_sys->LUT[i_plane][p_vout->p_sys->lambda[0][i_plane][i_index]][p_dst[i_index]];
1094 p_out += i_out_pitch;
1098 if ( p_vout->p_sys->i_row >= 2 )
1101 if (( p_vout->p_sys->i_row > 2 ) && (( b_row_first ) || ( b_row_last )))
1104 int height = 2 * p_vout->p_sys->i_halfHeight / i_div;
1107 TopOffset = i_lines + (2 * p_vout->p_sys->i_halfHeight) / i_div;
1111 TopOffset = height - (2 * p_vout->p_sys->i_halfHeight) / i_div;
1113 uint8_t *p_dst = p_out - TopOffset * i_out_pitch;
1114 for (i_index = 0; i_index < height; i_index++)
1115 for (i_index2 = 0; i_index2 < i_copy_pitch; i_index2++)
1116 p_dst[i_index * i_out_pitch + i_index2] = constantYUV[i_plane];
1118 if( p_vout->p_sys->b_attenuate )
1120 length = 2 * p_vout->p_sys->i_halfHeight / (p_vout->p_sys->pp_vout[i_vout].i_width / i_copy_pitch);
1121 if (p_vout->p_sys->b_has_changed)
1124 a_2 = p_vout->p_sys->a_2 * (ACCURACY / 100);
1125 a_1 = p_vout->p_sys->a_1 * length * (ACCURACY / 100);
1126 a_0 = p_vout->p_sys->a_0 * Denom * (ACCURACY / 100);
1127 for(i_col_mod = 0; i_col_mod < 2; i_col_mod++)
1128 for (i_index = 0; i_index < length; i_index++)
1130 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);
1131 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;
1134 // first blended zone
1137 TopOffset = i_lines;
1138 uint8_t *p_dst = p_out - TopOffset * i_out_pitch;
1140 for (i_index = 0; i_index < length; i_index++)
1142 for (i_index2 = 0; i_index2 < i_copy_pitch; i_index2++)
1145 p_dst[i_index * i_out_pitch + i_index2] = ( p_vout->p_sys->lambda2[1][i_plane][i_index] *
1146 p_dst[i_index * i_out_pitch + i_index2] ) / ACCURACY +
1147 p_vout->p_sys->cstYUV2[1][i_plane][i_index];
1149 p_dst[i_index * i_out_pitch + i_index2] = p_vout->p_sys->LUT[i_plane][p_vout->p_sys->lambda2[1][i_plane][i_index]][p_dst[i_index * i_out_pitch + i_index2]];
1154 // second blended zone
1158 uint8_t *p_dst = p_out - TopOffset * p_outpic->p[i_plane].i_pitch;
1160 for (i_index = 0; i_index < length; i_index++)
1162 for (i_index2 = 0; i_index2 < i_copy_pitch; i_index2++)
1165 p_dst[i_index * i_out_pitch + i_index2] = (p_vout->p_sys->lambda2[0][i_plane][i_index] *
1166 p_dst[i_index * i_out_pitch + i_index2]) / ACCURACY +
1167 p_vout->p_sys->cstYUV2[0][i_plane][i_index];
1170 p_dst[i_index * i_out_pitch + i_index2] = p_vout->p_sys->LUT[i_plane][p_vout->p_sys->lambda2[0][i_plane][i_index]][p_dst[i_index * i_out_pitch + i_index2]];
1179 // bug for wall filter : fix by CC
1180 // pi_left_skip[i_plane] += i_out_pitch;
1181 pi_left_skip[i_plane] += i_copy_pitch;
1184 vout_UnlinkPicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
1186 vout_DisplayPicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
1190 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
1192 pi_top_skip[i_plane] += p_vout->p_sys->pp_vout[ i_vout-1 ].i_height
1193 * p_pic->p[i_plane].i_lines
1194 / p_vout->output.i_height
1195 * p_pic->p[i_plane].i_pitch;
1199 if (p_vout->p_sys->b_has_changed)
1200 p_vout->p_sys->b_has_changed = false;
1205 /*****************************************************************************
1206 * RenderPackedRGB: displays previously rendered output
1207 *****************************************************************************
1208 * This function send the currently rendered image to Wall image, waits
1209 * until it is displayed and switch the two rendering buffers, preparing next
1211 *****************************************************************************/
1212 static void RenderPackedRGB( vout_thread_t *p_vout, picture_t *p_pic )
1214 picture_t *p_outpic = NULL;
1215 int i_col, i_row, i_vout, i_plane;
1216 int pi_left_skip[VOUT_MAX_PLANES], pi_top_skip[VOUT_MAX_PLANES];
1218 int LeftOffset, TopOffset;
1223 int i_index, i_index2;
1226 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
1227 pi_top_skip[i_plane] = 0;
1229 for( i_vout = 0, i_row = 0; i_row < p_vout->p_sys->i_row; i_row++ )
1231 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
1232 pi_left_skip[i_plane] = 0;
1234 for( i_col = 0; i_col < p_vout->p_sys->i_col; i_col++, i_vout++ )
1236 if( !p_vout->p_sys->pp_vout[ i_vout ].b_active )
1238 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
1240 pi_left_skip[i_plane] +=
1241 p_vout->p_sys->pp_vout[ i_vout ].i_width * p_pic->p->i_pixel_pitch;
1247 vout_CreatePicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
1251 if( !vlc_object_alive (p_vout) || p_vout->b_error )
1253 vout_DestroyPicture(
1254 p_vout->p_sys->pp_vout[ i_vout ].p_vout, p_outpic );
1258 msleep( VOUT_OUTMEM_SLEEP );
1261 p_outpic->date = p_pic->date;
1262 vout_LinkPicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
1265 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
1267 uint8_t *p_in, *p_in_end, *p_out;
1268 int i_in_pitch = p_pic->p[i_plane].i_pitch;
1269 int i_out_pitch = p_outpic->p[i_plane].i_pitch;
1270 int i_copy_pitch = p_outpic->p[i_plane].i_visible_pitch;
1274 pi_left_skip[i_plane] -= (2 * p_vout->p_sys->i_halfLength) * p_pic->p->i_pixel_pitch;
1275 if( p_vout->p_sys->i_row >= 2 )
1277 if( (i_row) && (!i_col))
1278 pi_top_skip[i_plane] -= (2 * p_vout->p_sys->i_halfHeight * p_pic->p[i_plane].i_pitch);
1279 if( (p_vout->p_sys->i_row > 2) && (i_row == 1) && (!i_col) )
1280 pi_top_skip[i_plane] -= (2 * p_vout->p_sys->i_halfHeight * p_pic->p[i_plane].i_pitch);
1281 if( !p_vout->p_sys->pp_vout[p_vout->p_sys->i_col-1].b_active )
1282 pi_top_skip[i_plane] -= (2 * p_vout->p_sys->i_halfHeight * i_row * p_pic->p[i_plane].i_pitch);
1284 // i_n : previous inactive pp_vout
1286 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++;
1287 if ((i_col > 1) && i_n)
1288 pi_left_skip[i_plane] -= i_n*(2 * p_vout->p_sys->i_halfLength ) * p_pic->p->i_pixel_pitch;
1290 p_in = p_pic->p[i_plane].p_pixels
1291 /* Wall proprities */
1292 + pi_top_skip[i_plane] + pi_left_skip[i_plane];
1294 int i_lines = p_outpic->p[i_plane].i_visible_lines;
1295 // 1088 lines bug in a mpeg2 stream of 1080 lines
1296 if ((p_vout->p_sys->i_row - 1 == i_row) &&
1297 (p_pic->p[i_plane].i_lines == 1088))
1300 p_in_end = p_in + i_lines * p_pic->p[i_plane].i_pitch;
1302 p_in = p_pic->p[i_plane].p_pixels
1303 + pi_top_skip[i_plane] + pi_left_skip[i_plane];
1305 p_in_end = p_in + p_outpic->p[i_plane].i_visible_lines
1306 * p_pic->p[i_plane].i_pitch;
1309 p_out = p_outpic->p[i_plane].p_pixels;
1313 if ((p_vout->p_sys->i_row > 2) && (!i_row))
1314 p_out += (p_outpic->p[i_plane].i_pitch * (2 * p_vout->p_sys->i_halfHeight) * p_pic->p->i_pixel_pitch);
1317 length = 2 * p_vout->p_sys->i_halfLength * p_pic->p->i_pixel_pitch;
1319 if (p_vout->p_sys->b_has_changed)
1323 Denom = F2(length / p_pic->p->i_pixel_pitch);
1324 a_2 = p_vout->p_sys->a_2 * (ACCURACY / 100);
1325 a_1 = p_vout->p_sys->a_1 * 2 * p_vout->p_sys->i_halfLength * (ACCURACY / 100);
1326 a_0 = p_vout->p_sys->a_0 * Denom * (ACCURACY / 100);
1327 for(i_col_mod = 0; i_col_mod < 2; i_col_mod++)
1328 for (i_index = 0; i_index < length / p_pic->p->i_pixel_pitch; i_index++)
1329 for (i_plane_ = 0; i_plane_ < p_pic->p->i_pixel_pitch; i_plane_++)
1330 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);
1333 while( p_in < p_in_end )
1336 vlc_memcpy( p_out, p_in, i_copy_pitch );
1338 if (p_vout->p_sys->i_col > 2)
1343 vlc_memcpy( p_out + length, p_in, i_copy_pitch - length);
1344 else if (i_col + 1 == p_vout->p_sys->i_col)
1345 vlc_memcpy( p_out, p_in - length, i_copy_pitch - length);
1347 vlc_memcpy( p_out, p_in - length, i_copy_pitch);
1353 p_out += LeftOffset;
1355 for (i_index = 0; i_index < length; i_index++)
1356 *(p_out + i_index) = 0;
1357 p_out -= LeftOffset;
1360 else if ((i_col + 1 == p_vout->p_sys->i_col ))
1363 LeftOffset = i_copy_pitch - length;
1364 p_out += LeftOffset;
1366 for (i_index = 0; i_index < length; i_index++)
1367 *(p_out + i_index) = 0;
1368 p_out -= LeftOffset;
1374 vlc_memcpy( p_out, p_in, i_copy_pitch);
1377 // first blended zone
1381 p_out += LeftOffset;
1382 for (i_index = 0; i_index < length; i_index++)
1384 *(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] *
1385 (*(p_out + i_index))) / ACCURACY;
1387 *(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)];
1389 p_out -= LeftOffset;
1391 // second blended zone
1392 if (i_col + 1 < p_vout->p_sys->i_col)
1394 LeftOffset = i_copy_pitch - length;
1395 p_out += LeftOffset;
1396 for (i_index = 0; i_index < length; i_index++)
1398 *(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] *
1399 (*(p_out + i_index))) / ACCURACY;
1401 *(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)];
1403 p_out -= LeftOffset;
1408 p_out += i_out_pitch;
1412 if (!p_vout->p_sys->b_attenuate)
1414 if ((i_row == 0) && (p_vout->p_sys->i_row > 2))
1417 TopOffset = i_lines + (2 * p_vout->p_sys->i_halfHeight);
1418 p_out -= TopOffset * p_outpic->p[i_plane].i_pitch;
1419 for (i_index = 0; i_index < length; i_index++)
1420 for (i_index2 = 0; i_index2 < i_copy_pitch; i_index2++)
1421 *(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2) = 0;
1422 p_out += TopOffset * p_outpic->p[i_plane].i_pitch;
1424 else if ((i_row + 1 == p_vout->p_sys->i_row) && (p_vout->p_sys->i_row > 2))
1427 TopOffset = length - (2 * p_vout->p_sys->i_halfHeight);
1428 p_out -= TopOffset * p_outpic->p[i_plane].i_pitch;
1429 for (i_index = 0; i_index < length; i_index++)
1430 for (i_index2 = 0; i_index2 < i_copy_pitch; i_index2++)
1431 *(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2) = 0;
1432 p_out += TopOffset * p_outpic->p[i_plane].i_pitch;
1437 if (p_vout->p_sys->i_row >= 2)
1439 length = 2 * p_vout->p_sys->i_halfHeight;
1440 if (p_vout->p_sys->b_has_changed)
1445 a_2 = p_vout->p_sys->a_2 * (ACCURACY / 100);
1446 a_1 = p_vout->p_sys->a_1 * length * (ACCURACY / 100);
1447 a_0 = p_vout->p_sys->a_0 * Denom * (ACCURACY / 100);
1448 for(i_row_mod = 0; i_row_mod < 2; i_row_mod++)
1449 for (i_index = 0; i_index < length; i_index++)
1450 for (i_plane_ = 0; i_plane_ < p_pic->p->i_pixel_pitch; i_plane_++)
1451 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);
1453 // first blended zone
1457 TopOffset = i_lines;
1458 p_out -= TopOffset * p_outpic->p[i_plane].i_pitch;
1459 for (i_index = 0; i_index < length; i_index++)
1460 for (i_index2 = 0; i_index2 < i_copy_pitch; i_index2++)
1462 *(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] *
1463 (*(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2))) / ACCURACY;
1465 *(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)];
1467 p_out += TopOffset * p_outpic->p[i_plane].i_pitch;
1469 else if (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;
1480 // second blended zone
1482 if (i_row + 1 < p_vout->p_sys->i_row)
1485 p_out -= TopOffset * p_outpic->p[i_plane].i_pitch;
1486 for (i_index = 0; i_index < length; i_index++)
1487 for (i_index2 = 0; i_index2 < i_copy_pitch; i_index2++)
1489 *(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] *
1490 (*(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2))) / ACCURACY;
1492 *(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)];
1495 p_out += TopOffset * p_outpic->p[i_plane].i_pitch;
1497 else if (p_vout->p_sys->i_row > 2)
1500 TopOffset = length - (2 * p_vout->p_sys->i_halfHeight);
1501 p_out -= TopOffset * p_outpic->p[i_plane].i_pitch;
1502 for (i_index = 0; i_index < length; i_index++)
1503 for (i_index2 = 0; i_index2 < i_copy_pitch; i_index2++)
1504 *(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2) = 0;
1505 p_out += TopOffset * p_outpic->p[i_plane].i_pitch;
1511 // bug for wall filter : fix by CC
1512 // pi_left_skip[i_plane] += i_out_pitch;
1513 pi_left_skip[i_plane] += i_copy_pitch;
1516 vout_UnlinkPicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
1518 vout_DisplayPicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
1522 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
1524 pi_top_skip[i_plane] += p_vout->p_sys->pp_vout[ i_vout-1 ].i_height
1525 * p_pic->p[i_plane].i_lines
1526 / p_vout->output.i_height
1527 * p_pic->p[i_plane].i_pitch;
1531 if (p_vout->p_sys->b_has_changed) p_vout->p_sys->b_has_changed = false;
1537 // WARNING : NO DEBUGGED
1538 /*****************************************************************************
1539 * RenderPackedYUV: displays previously rendered output
1540 *****************************************************************************
1541 * This function send the currently rendered image to Wall image, waits
1542 * until it is displayed and switch the two rendering buffers, preparing next
1544 *****************************************************************************/
1545 static void RenderPackedYUV( vout_thread_t *p_vout, picture_t *p_pic )
1547 picture_t *p_outpic = NULL;
1548 int i_col, i_row, i_vout, i_plane;
1549 int pi_left_skip[VOUT_MAX_PLANES], pi_top_skip[VOUT_MAX_PLANES];
1551 int LeftOffset, TopOffset;
1552 int constantYUV[3] = {0,128,128};
1557 int i_index, i_index2;
1560 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
1561 pi_top_skip[i_plane] = 0;
1563 for( i_vout = 0;, i_row = 0; i_row < p_vout->p_sys->i_row; i_row++ )
1565 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
1566 pi_left_skip[i_plane] = 0;
1568 for( i_col = 0; i_col < p_vout->p_sys->i_col; i_col++, i_vout++ )
1570 if( !p_vout->p_sys->pp_vout[ i_vout ].b_active )
1572 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
1574 pi_left_skip[i_plane] +=
1575 p_vout->p_sys->pp_vout[ i_vout ].i_width
1576 * p_pic->p[i_plane].i_pitch / p_vout->output.i_width;
1582 vout_CreatePicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
1586 if( !vlc_object_alive (p_vout) || p_vout->b_error )
1588 vout_DestroyPicture(
1589 p_vout->p_sys->pp_vout[ i_vout ].p_vout, p_outpic );
1593 msleep( VOUT_OUTMEM_SLEEP );
1596 p_outpic->date = p_pic->date;
1597 vout_LinkPicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
1600 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
1602 uint8_t *p_in, *p_in_end, *p_out;
1603 int i_in_pitch = p_pic->p[i_plane].i_pitch;
1604 int i_out_pitch = p_outpic->p[i_plane].i_pitch;
1605 int i_copy_pitch = p_outpic->p[i_plane].i_visible_pitch;
1606 const int i_div = p_vout->p_sys->pp_vout[i_vout].i_width / i_copy_pitch;
1609 if (i_col) pi_left_skip[i_plane] -= (2 * p_vout->p_sys->i_halfLength ) / i_div;
1610 if ((p_vout->p_sys->i_row >= 2) && (i_row) && (!i_col)) pi_top_skip[i_plane] -= (2 * p_vout->p_sys->i_halfHeight * p_pic->p[i_plane].i_pitch) / i_div;
1611 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) / i_div;
1612 if( !p_vout->p_sys->pp_vout[p_vout->p_sys->i_col-1].b_active )
1613 pi_top_skip[i_plane] -= (2 * p_vout->p_sys->i_halfHeight * i_row * p_pic->p[i_plane].i_pitch) / i_div;
1614 // i_n : previous inactive pp_vout
1616 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++;
1617 if ((i_col > 1) && i_n)
1618 pi_left_skip[i_plane] -= i_n*(2 * p_vout->p_sys->i_halfLength ) / i_div;
1620 p_in = p_pic->p[i_plane].p_pixels
1621 /* Wall proprities */
1622 + pi_top_skip[i_plane] + pi_left_skip[i_plane];
1624 int i_lines = p_outpic->p[i_plane].i_visible_lines;
1625 // 1088 lines bug in a mpeg2 stream of 1080 lines
1626 if ((p_vout->p_sys->i_row - 1 == i_row) &&
1627 (p_pic->p[i_plane].i_lines == 1088))
1630 p_in_end = p_in + i_lines * p_pic->p[i_plane].i_pitch;
1632 p_in = p_pic->p[i_plane].p_pixels
1633 + pi_top_skip[i_plane] + pi_left_skip[i_plane];
1635 p_in_end = p_in + p_outpic->p[i_plane].i_visible_lines
1636 * p_pic->p[i_plane].i_pitch;
1638 p_out = p_outpic->p[i_plane].p_pixels;
1641 length = 2 * p_vout->p_sys->i_halfLength * p_pic->p->i_pixel_pitch;
1642 LeftOffset = (i_col ? 0 : i_copy_pitch - length);
1643 if (p_vout->p_sys->b_has_changed)
1647 for (i_index = 0; i_index < length / p_pic->p->i_pixel_pitch; i_index++)
1648 for (i_plane_ = 0; i_plane_ < p_pic->p->i_pixel_pitch; i_plane_++)
1649 for (i_index2 = 0; i_index2 < 256; i_index2++)
1650 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_]));
1652 switch (p_vout->output.i_chroma)
1654 case VLC_FOURCC('Y','U','Y','2'): // packed by 2
1655 case VLC_FOURCC('Y','U','N','V'): // packed by 2
1656 Denom = F2(length / p_pic->p->i_pixel_pitch);
1657 a_2 = p_vout->p_sys->a_2 * (ACCURACY / 100);
1658 a_1 = p_vout->p_sys->a_1 * 2 * p_vout->p_sys->i_halfLength * (ACCURACY / 100);
1659 a_0 = p_vout->p_sys->a_0 * Denom * (ACCURACY / 100);
1660 for (i_index = 0; i_index < length / p_pic->p->i_pixel_pitch; i_index+=p_pic->p->i_pixel_pitch)
1661 // for each macropixel
1663 // first image pixel
1664 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);
1665 p_vout->p_sys->cstYUV[i_col][0][i_index] = ((ACCURACY - p_vout->p_sys->lambda[i_col][0][i_index]) * constantYUV[0]) / ACCURACY;
1666 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);
1667 p_vout->p_sys->cstYUV[i_col][1][i_index] = ((ACCURACY - p_vout->p_sys->lambda[i_col][1][i_index]) * constantYUV[1]) / ACCURACY;
1668 // second image pixel
1669 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);
1670 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;
1671 p_vout->p_sys->lambda[i_col][1][i_index + 1] = p_vout->p_sys->lambda[i_col][1][i_index];
1672 p_vout->p_sys->cstYUV[i_col][1][i_index + 1] = p_vout->p_sys->cstYUV[i_col][1][i_index];
1675 case VLC_FOURCC('U','Y','V','Y'): // packed by 2
1676 case VLC_FOURCC('U','Y','N','V'): // packed by 2
1677 case VLC_FOURCC('Y','4','2','2'): // packed by 2
1678 Denom = F2(length / p_pic->p->i_pixel_pitch);
1679 a_2 = p_vout->p_sys->a_2 * (ACCURACY / 100);
1680 a_1 = p_vout->p_sys->a_1 * 2 * p_vout->p_sys->i_halfLength * (ACCURACY / 100);
1681 a_0 = p_vout->p_sys->a_0 * Denom * (ACCURACY / 100);
1682 for (i_index = 0; i_index < length / p_pic->p->i_pixel_pitch; i_index+=p_pic->p->i_pixel_pitch)
1683 // for each macropixel
1685 // first image pixel
1686 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);
1687 p_vout->p_sys->cstYUV[i_col][0][i_index] = ((ACCURACY - p_vout->p_sys->lambda[i_col][0][i_index]) * constantYUV[1]) / ACCURACY;
1688 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);
1689 p_vout->p_sys->cstYUV[i_col][1][i_index] = ((ACCURACY - p_vout->p_sys->lambda[i_col][1][i_index]) * constantYUV[0]) / ACCURACY;
1690 // second image pixel
1691 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);
1692 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;
1693 p_vout->p_sys->lambda[i_col][1][i_index + 1] = p_vout->p_sys->lambda[i_col][1][i_index];
1694 p_vout->p_sys->cstYUV[i_col][1][i_index + 1] = p_vout->p_sys->cstYUV[i_col][1][i_index];
1702 while( p_in < p_in_end )
1705 vlc_memcpy( p_out, p_in, i_copy_pitch);
1707 vlc_memcpy( p_out + i_col * length, p_in + i_col * length, i_copy_pitch - length);
1708 p_out += LeftOffset;
1711 for (i_index = 0; i_index < length; i_index++)
1712 *(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] *
1713 (*(p_in + i_index))) / ACCURACY +
1714 p_vout->p_sys->cstYUV[i_col][i_index % p_pic->p->i_pixel_pitch][i_index / p_pic->p->i_pixel_pitch];
1716 for (i_index = 0; i_index < length; i_index++)
1717 *(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] *
1718 (*(p_in + i_index))) / ACCURACY +
1719 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];
1721 p_out -= LeftOffset;
1725 p_out += i_out_pitch;
1728 if (p_vout->p_sys->i_row == 2)
1730 length = 2 * p_vout->p_sys->i_halfHeight * p_pic->p->i_pixel_pitch;
1731 TopOffset = (i_row ? i_lines : length / p_pic->p->i_pixel_pitch);
1732 if (p_vout->p_sys->b_has_changed)
1736 for (i_index = 0; i_index < length / p_pic->p->i_pixel_pitch; i_index++)
1737 for (i_plane_ = 0; i_plane_ < p_pic->p->i_pixel_pitch; i_plane_++)
1738 for (i_index2 = 0; i_index2 < 256; i_index2++)
1739 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_]));
1741 switch (p_vout->output.i_chroma)
1743 case VLC_FOURCC('Y','U','Y','2'): // packed by 2
1744 case VLC_FOURCC('Y','U','N','V'): // packed by 2
1745 Denom = F2(length / p_pic->p->i_pixel_pitch);
1746 a_2 = p_vout->p_sys->a_2 * (ACCURACY / 100);
1747 a_1 = p_vout->p_sys->a_1 * 2 * p_vout->p_sys->i_halfHeight * (ACCURACY / 100);
1748 a_0 = p_vout->p_sys->a_0 * Denom * (ACCURACY / 100);
1749 for (i_index = 0; i_index < length / p_pic->p->i_pixel_pitch; i_index+=p_pic->p->i_pixel_pitch)
1750 // for each macropixel
1752 // first image pixel
1753 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);
1754 p_vout->p_sys->cstYUV2[i_row][0][i_index] = ((ACCURACY - p_vout->p_sys->lambda2[i_row][0][i_index]) * constantYUV[0]) / ACCURACY;
1755 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);
1756 p_vout->p_sys->cstYUV2[i_row][1][i_index] = ((ACCURACY - p_vout->p_sys->lambda2[i_row][1][i_index]) * constantYUV[1]) / ACCURACY;
1757 // second image pixel
1758 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);
1759 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;
1760 p_vout->p_sys->lambda2[i_row][1][i_index + 1] = p_vout->p_sys->lambda2[i_row][1][i_index];
1761 p_vout->p_sys->cstYUV2[i_row][1][i_index + 1] = p_vout->p_sys->cstYUV2[i_row][1][i_index];
1764 case VLC_FOURCC('U','Y','V','Y'): // packed by 2
1765 case VLC_FOURCC('U','Y','N','V'): // packed by 2
1766 case VLC_FOURCC('Y','4','2','2'): // packed by 2
1767 Denom = F2(length / p_pic->p->i_pixel_pitch);
1768 a_2 = p_vout->p_sys->a_2 * (ACCURACY / 100);
1769 a_1 = p_vout->p_sys->a_1 * 2 * p_vout->p_sys->i_halfHeight * (ACCURACY / 100);
1770 a_0 = p_vout->p_sys->a_0 * Denom * (ACCURACY / 100);
1771 for (i_index = 0; i_index < length / p_pic->p->i_pixel_pitch; i_index+=p_pic->p->i_pixel_pitch)
1772 // for each macropixel
1774 // first image pixel
1775 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);
1776 p_vout->p_sys->cstYUV2[i_row][0][i_index] = ((ACCURACY - p_vout->p_sys->lambda2[i_col][0][i_index]) * constantYUV[1]) / ACCURACY;
1777 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);
1778 p_vout->p_sys->cstYUV2[i_row][1][i_index] = ((ACCURACY - p_vout->p_sys->lambda2[i_row][1][i_index]) * constantYUV[0]) / ACCURACY;
1779 // second image pixel
1780 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);
1781 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;
1782 p_vout->p_sys->lambda2[i_row][1][i_index + 1] = p_vout->p_sys->lambda2[i_row][1][i_index];
1783 p_vout->p_sys->cstYUV2[i_row][1][i_index + 1] = p_vout->p_sys->cstYUV2[i_row][1][i_index];
1790 p_out -= TopOffset * p_outpic->p[i_plane].i_pitch;
1792 for (i_index = 0; i_index < length / p_pic->p->i_pixel_pitch; i_index++)
1793 for (i_index2 = 0; i_index2 < i_copy_pitch; i_index2++)
1794 *(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] *
1795 (*(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2))) / ACCURACY +
1796 p_vout->p_sys->cstYUV2[i_row][i_index2 % p_pic->p->i_pixel_pitch][i_index];
1798 for (i_index = 0; i_index < length / p_pic->p->i_pixel_pitch; i_index++)
1799 for (i_index2 = 0; i_index2 < i_copy_pitch; i_index2++)
1800 *(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] *
1801 (*(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2))) / ACCURACY +
1802 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];
1805 p_out += TopOffset * p_outpic->p[i_plane].i_pitch;
1808 // bug for wall filter : fix by CC
1809 // pi_left_skip[i_plane] += i_out_pitch;
1810 pi_left_skip[i_plane] += i_copy_pitch;
1813 vout_UnlinkPicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
1815 vout_DisplayPicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
1819 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
1821 pi_top_skip[i_plane] += p_vout->p_sys->pp_vout[ i_vout-1 ].i_height
1822 * p_pic->p[i_plane].i_lines
1823 / p_vout->output.i_height
1824 * p_pic->p[i_plane].i_pitch;
1828 if (p_vout->p_sys->b_has_changed) p_vout->p_sys->b_has_changed = false;
1834 /*****************************************************************************
1835 * RemoveAllVout: destroy all the child video output threads
1836 *****************************************************************************/
1837 static void RemoveAllVout( vout_thread_t *p_vout )
1839 vout_sys_t *p_sys = p_vout->p_sys;
1841 for( int i = 0; i < p_vout->p_sys->i_vout; i++ )
1843 if( p_sys->pp_vout[i].b_active )
1845 vout_filter_SetupChild( p_vout, p_sys->pp_vout[i].p_vout,
1846 MouseEvent, FullscreenEventUp, FullscreenEventDown, true );
1847 vout_CloseAndRelease( p_sys->pp_vout[i].p_vout );
1848 p_sys->pp_vout[i].p_vout = NULL;
1853 /*****************************************************************************
1854 * SendEvents: forward mouse and keyboard events to the parent p_vout
1855 *****************************************************************************/
1856 static int MouseEvent( vlc_object_t *p_this, char const *psz_var,
1857 vlc_value_t oldval, vlc_value_t newval, void *p_data )
1859 vout_thread_t *p_vout = p_data;
1860 vout_sys_t *p_sys = p_vout->p_sys;
1864 /* Find the video output index */
1865 for( i_vout = 0; i_vout < p_sys->i_vout; i_vout++ )
1867 if( p_sys->pp_vout[i_vout].b_active &&
1868 p_this == VLC_OBJECT(p_sys->pp_vout[i_vout].p_vout) )
1871 assert( i_vout < p_vout->p_sys->i_vout );
1873 /* Translate the mouse coordinates */
1874 if( !strcmp( psz_var, "mouse-x" ) )
1877 int i_overlap = ((p_sys->i_col > 2) ? 0 : 2 * p_sys->i_halfLength);
1878 newval.i_int += (p_vout->output.i_width - i_overlap)
1880 newval.i_int += p_vout->output.i_width
1882 * (i_vout % p_sys->i_col)
1885 else if( !strcmp( psz_var, "mouse-y" ) )
1888 int i_overlap = ((p_sys->i_row > 2) ? 0 : 2 * p_sys->i_halfHeight);
1889 newval.i_int += (p_vout->output.i_height - i_overlap)
1891 newval.i_int += p_vout->output.i_height
1893 //bug fix in Wall plug-in
1894 // * (i_vout / p_vout->p_sys->i_row)
1895 * (i_vout / p_sys->i_col)
1899 return var_Set( p_vout, psz_var, newval );
1903 * Forward fullscreen event to/from the childrens.
1904 * FIXME pretty much duplicated from wall.c
1906 static bool IsFullscreenActive( vout_thread_t *p_vout )
1908 vout_sys_t *p_sys = p_vout->p_sys;
1909 for( int i = 0; i < p_sys->i_vout; i++ )
1911 if( p_sys->pp_vout[i].b_active &&
1912 var_GetBool( p_sys->pp_vout[i].p_vout, "fullscreen" ) )
1917 static int FullscreenEventUp( vlc_object_t *p_this, char const *psz_var,
1918 vlc_value_t oldval, vlc_value_t newval, void *p_data )
1920 vout_thread_t *p_vout = p_data;
1921 VLC_UNUSED(oldval); VLC_UNUSED(p_this); VLC_UNUSED(psz_var); VLC_UNUSED(newval);
1923 const bool b_fullscreen = IsFullscreenActive( p_vout );
1924 if( !var_GetBool( p_vout, "fullscreen" ) != !b_fullscreen )
1925 return var_SetBool( p_vout, "fullscreen", b_fullscreen );
1928 static int FullscreenEventDown( vlc_object_t *p_this, char const *psz_var,
1929 vlc_value_t oldval, vlc_value_t newval, void *p_data )
1931 vout_thread_t *p_vout = (vout_thread_t*)p_this;
1932 vout_sys_t *p_sys = p_vout->p_sys;
1933 VLC_UNUSED(oldval); VLC_UNUSED(p_data); VLC_UNUSED(psz_var);
1935 const bool b_fullscreen = IsFullscreenActive( p_vout );
1936 if( !b_fullscreen != !newval.b_bool )
1938 for( int i = 0; i < p_sys->i_vout; i++ )
1940 if( !p_sys->pp_vout[i].b_active )
1943 vout_thread_t *p_child = p_sys->pp_vout[i].p_vout;
1944 if( !var_GetBool( p_child, "fullscreen" ) != !newval.b_bool )
1946 var_SetBool( p_child, "fullscreen", newval.b_bool );