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
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_CODEC_Y211: // packed by 4
315 // Packed YUV Reverted
316 case VLC_CODEC_CYUV: // packed by 2
318 switch (p_vout->render.i_chroma)
328 p_vout->pf_render = RenderPlanarYUV;
331 case VLC_CODEC_RGB8: // packed by 1
332 case VLC_CODEC_RGB15: // packed by 2
333 case VLC_CODEC_RGB16: // packed by 2
334 case VLC_CODEC_RGB24: // packed by 3
335 case VLC_CODEC_RGB32: // packed by 4
336 p_vout->pf_render = RenderPackedRGB;
340 case VLC_CODEC_YUYV: // packed by 2
341 case VLC_CODEC_UYVY: // 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 dependent 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_CreateGetBool( 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_CreateGetBool( 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_CreateGetBool( 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 = calloc( 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 free( p_vout->p_sys );
435 psz_method = var_CreateGetNonEmptyString( p_vout, CFG_PREFIX "active" );
437 /* If no trailing vout are specified, take them all */
438 if( psz_method == NULL )
440 for( i_vout = p_vout->p_sys->i_row * p_vout->p_sys->i_col;
443 p_vout->p_sys->pp_vout[i_vout].b_active = 1;
446 /* If trailing vout are specified, activate only the requested ones */
449 for( i_vout = p_vout->p_sys->i_row * p_vout->p_sys->i_col;
452 p_vout->p_sys->pp_vout[i_vout].b_active = 0;
457 psz_tmp = psz_method;
458 while( *psz_tmp && *psz_tmp != ',' )
466 i_vout = atoi( psz_method );
467 psz_method = psz_tmp + 1;
471 i_vout = atoi( psz_method );
472 psz_method = psz_tmp;
476 i_vout < p_vout->p_sys->i_row * p_vout->p_sys->i_col )
478 p_vout->p_sys->pp_vout[i_vout].b_active = 1;
483 free( psz_method_tmp );
490 /*****************************************************************************
491 * CLIP_0A: clip between 0 and ACCURACY
492 *****************************************************************************/
493 inline static int CLIP_0A( int a )
495 return (a > ACCURACY) ? ACCURACY : (a < 0) ? 0 : a;
499 /*****************************************************************************
500 * Gamma: Gamma correction
501 *****************************************************************************/
502 static double Gamma_Correction(int i_plane, float f_component, float f_BlackCrush[VOUT_MAX_PLANES], float f_WhiteCrush[VOUT_MAX_PLANES], float f_BlackLevel[VOUT_MAX_PLANES], float f_WhiteLevel[VOUT_MAX_PLANES], float f_Gamma[VOUT_MAX_PLANES])
506 f_Input = (f_component * f_BlackLevel[i_plane]) / (f_BlackCrush[i_plane]) + (1.0 - f_BlackLevel[i_plane]);
507 if (f_component <= f_BlackCrush[i_plane])
509 return pow(f_Input, 1.0 / f_Gamma[i_plane]);
511 else if (f_component >= f_WhiteCrush[i_plane])
513 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);
514 return pow(f_Input, 1.0 / f_Gamma[i_plane]);
524 /*****************************************************************************
525 * F: Function to calculate Gamma correction
526 *****************************************************************************/
527 static uint8_t F(uint8_t i, float gamma)
529 double input = (double) i / 255.0;
531 // return clip(255 * pow(input, 1.0 / gamma));
534 return clip_uint8((255 * pow(2 * input, gamma)) / 2);
536 return clip_uint8(255 * (1 - pow(2 * (1 - input), gamma) / 2));
541 /*****************************************************************************
542 * AdjustHeight: ajust p_sys->i_height to have same BZ width for any ratio
543 *****************************************************************************/
544 static int AdjustHeight( vout_thread_t *p_vout )
546 bool b_fullscreen = p_vout->b_fullscreen;
547 int i_window_width = p_vout->i_window_width;
548 int i_window_height = p_vout->i_window_height;
549 double d_halfLength = 0;
550 double d_halfLength_crop;
551 double d_halfLength_calculated;
554 // OS DEPENDENT CODE to get display dimensions
558 i_window_width = GetSystemMetrics(SM_CXSCREEN);
559 i_window_height = GetSystemMetrics(SM_CYSCREEN);
561 char *psz_display = var_CreateGetNonEmptyString( p_vout,
563 Display *p_display = XOpenDisplay( psz_display );
565 if (p_vout->p_sys->b_xinerama)
567 i_window_width = DisplayWidth(p_display, 0) / p_vout->p_sys->i_col;
568 i_window_height = DisplayHeight(p_display, 0) / p_vout->p_sys->i_row;
572 i_window_width = DisplayWidth(p_display, 0);
573 i_window_height = DisplayHeight(p_display, 0);
575 XCloseDisplay( p_display );
577 var_SetInteger( p_vout, "width", i_window_width);
578 var_SetInteger( p_vout, "height", i_window_height);
579 p_vout->i_window_width = i_window_width;
580 p_vout->i_window_height = i_window_height;
583 if( p_vout->p_sys->bz_length)
584 if ((!p_vout->p_sys->b_autocrop) && (!p_vout->p_sys->i_ratio))
586 if ((p_vout->p_sys->i_row > 1) || (p_vout->p_sys->i_col > 1))
588 while ((d_halfLength <= 0) || (d_halfLength > p_vout->render.i_width / (2 * p_vout->p_sys->i_col)))
590 if (p_vout->p_sys->bz_length >= 50)
592 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);
596 d_halfLength = (p_vout->render.i_width * p_vout->p_sys->bz_length) / (100.0 * p_vout->p_sys->i_col);
597 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);
599 if ((d_halfLength <= 0) || (d_halfLength > p_vout->render.i_width / (2 * p_vout->p_sys->i_col)))
600 p_vout->p_sys->i_row--;
601 if (p_vout->p_sys->i_row < 1 )
603 p_vout->p_sys->i_row = 1;
607 p_vout->p_sys->i_halfLength = (d_halfLength + 0.5);
608 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;
609 var_SetInteger( p_vout, "bz-length", p_vout->p_sys->bz_length);
610 var_SetInteger( p_vout, "panoramix-rows", p_vout->p_sys->i_row);
615 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;
616 d_halfLength_crop = d_halfLength * VOUT_ASPECT_FACTOR * (double)p_vout->output.i_width
617 / (double)i_window_height / (double)p_vout->render.i_aspect;
618 p_vout->p_sys->i_halfLength = (d_halfLength_crop + 0.5);
619 d_halfLength_calculated = p_vout->p_sys->i_halfLength * (double)i_window_height *
620 (double)p_vout->render.i_aspect / VOUT_ASPECT_FACTOR / (double)p_vout->output.i_width;
622 if (!p_vout->p_sys->b_attenuate)
624 double d_bz_length = (p_vout->p_sys->i_halfLength * p_vout->p_sys->i_col * 100.0) / p_vout->render.i_width;
625 // F(2x) != 2F(x) in opengl module
626 if (p_vout->p_sys->i_col == 2) d_bz_length = (100.0 * d_bz_length) / (100.0 - d_bz_length) ;
627 var_SetInteger( p_vout, "bz-length", (int)(d_bz_length + 0.5));
629 i_offset = (int)d_halfLength - (int)
630 (p_vout->p_sys->i_halfLength * (double)i_window_height *
631 (double)p_vout->render.i_aspect / VOUT_ASPECT_FACTOR / (double)p_vout->output.i_width);
634 p_vout->p_sys->i_halfLength = 0;
641 /*****************************************************************************
642 * Init: initialize Wall video thread output method
643 *****************************************************************************/
644 #define VLC_XCHG( type, a, b ) do { type __tmp = (b); (b) = (a); (a) = __tmp; } while(0)
646 static int Init( vout_thread_t *p_vout )
648 int i_index, i_row, i_col;
650 I_OUTPUTPICTURES = 0;
652 /* Initialize the output structure */
653 p_vout->output.i_chroma = p_vout->render.i_chroma;
654 p_vout->output.i_width = p_vout->render.i_width;
655 p_vout->output.i_height = p_vout->render.i_height;
656 p_vout->output.i_aspect = p_vout->render.i_aspect;
658 p_vout->p_sys->b_has_changed = p_vout->p_sys->b_attenuate;
659 int i_video_x = var_GetInteger( p_vout, "video-x");
660 int i_video_y = var_GetInteger( p_vout, "video-y");
662 if (p_vout->p_sys->b_attenuate)
664 int i_index2, i_plane;
665 int constantYUV[3] = {0,128,128};
666 float f_BlackCrush[VOUT_MAX_PLANES];
667 float f_BlackLevel[VOUT_MAX_PLANES];
668 float f_WhiteCrush[VOUT_MAX_PLANES];
669 float f_WhiteLevel[VOUT_MAX_PLANES];
670 p_vout->p_sys->f_gamma[0] = var_CreateGetFloat( p_vout, CFG_PREFIX "bz-gamma-red" );
671 p_vout->p_sys->f_gamma[1] = var_CreateGetFloat( p_vout, CFG_PREFIX "bz-gamma-green" );
672 p_vout->p_sys->f_gamma[2] = var_CreateGetFloat( p_vout, CFG_PREFIX "bz-gamma-blue" );
673 f_BlackCrush[0] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-blackcrush-red" ) / 255.0;
674 f_BlackCrush[1] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-blackcrush-green" ) / 255.0;
675 f_BlackCrush[2] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-blackcrush-blue" ) / 255.0;
676 f_WhiteCrush[0] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-whitecrush-red" ) / 255.0;
677 f_WhiteCrush[1] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-whitecrush-green" ) / 255.0;
678 f_WhiteCrush[2] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-whitecrush-blue" ) / 255.0;
679 f_BlackLevel[0] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-blacklevel-red" ) / 255.0;
680 f_BlackLevel[1] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-blacklevel-green" ) / 255.0;
681 f_BlackLevel[2] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-blacklevel-blue" ) / 255.0;
682 f_WhiteLevel[0] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-whitelevel-red" ) / 255.0;
683 f_WhiteLevel[1] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-whitelevel-green" ) / 255.0;
684 f_WhiteLevel[2] = var_CreateGetInteger( p_vout, CFG_PREFIX "bz-whitelevel-blue" ) / 255.0;
685 for( int i = 3; i < VOUT_MAX_PLANES; i++ )
687 /* Initialize unsupported planes */
688 f_BlackCrush[i] = 140.0/255.0;
689 f_WhiteCrush[i] = 200.0/255.0;
690 f_BlackLevel[i] = 150.0/255.0;
691 f_WhiteLevel[i] = 0.0/255.0;
692 p_vout->p_sys->f_gamma[i] = 1.0;
695 switch (p_vout->render.i_chroma)
700 case VLC_CODEC_UYVY: // packed by 2
701 // case VLC_CODEC_CYUV: // packed by 2
702 VLC_XCHG( float, p_vout->p_sys->f_gamma[1], p_vout->p_sys->f_gamma[2] );
703 VLC_XCHG( float, f_BlackCrush[1], f_BlackCrush[2] );
704 VLC_XCHG( float, f_WhiteCrush[1], f_WhiteCrush[2] );
705 VLC_XCHG( float, f_BlackLevel[1], f_BlackLevel[2] );
706 VLC_XCHG( float, f_WhiteLevel[1], f_WhiteLevel[2] );
715 case VLC_CODEC_YUYV: // packed by 2
716 for (i_index = 0; i_index < 256; i_index++)
717 for (i_index2 = 0; i_index2 <= ACCURACY; i_index2++)
718 for (i_plane = 0; i_plane < VOUT_MAX_PLANES; i_plane++)
720 float f_lut = CLIP_01(1.0 -
721 ((ACCURACY - (float)i_index2)
722 * Gamma_Correction(i_plane, (float)i_index / 255.0, f_BlackCrush, f_WhiteCrush, f_BlackLevel, f_WhiteLevel, p_vout->p_sys->f_gamma)
724 p_vout->p_sys->LUT[i_plane][i_index2][i_index] = f_lut * i_index + (int)((1.0 - f_lut) * (float)constantYUV[i_plane]);
728 case VLC_CODEC_RGB8: // packed by 1
729 case VLC_CODEC_RGB15: // packed by 2
730 case VLC_CODEC_RGB16: // packed by 2
731 case VLC_CODEC_RGB24: // packed by 3
732 case VLC_CODEC_RGB32: // packed by 4
733 for (i_index = 0; i_index < 256; i_index++)
734 for (i_index2 = 0; i_index2 <= ACCURACY; i_index2++)
735 for (i_plane = 0; i_plane < VOUT_MAX_PLANES; i_plane++)
737 float f_lut = CLIP_01(1.0 -
738 ((ACCURACY - (float)i_index2)
739 * Gamma_Correction(i_plane, (float)i_index / 255.0, f_BlackCrush, f_WhiteCrush, f_BlackLevel, f_WhiteLevel, p_vout->p_sys->f_gamma)
741 p_vout->p_sys->LUT[i_plane][i_index2][i_index] = f_lut * i_index;
745 msg_Err( p_vout, "colorspace not supported by plug-in !!!");
746 free( p_vout->p_sys );
751 if (p_vout->p_sys->i_offset_x)
752 p_vout->p_sys->i_offset_x = AdjustHeight(p_vout);
754 AdjustHeight(p_vout);
755 if (p_vout->p_sys->i_row >= 2)
757 p_vout->p_sys->i_halfHeight = (p_vout->p_sys->i_halfLength * p_vout->p_sys->bz_height) / 100;
758 p_vout->p_sys->i_halfHeight -= (p_vout->p_sys->i_halfHeight % 2);
762 /* Try to open the real video output */
763 msg_Dbg( p_vout, "spawning the real video outputs" );
765 /* FIXME: use bresenham instead of those ugly divisions */
766 p_vout->p_sys->i_vout = 0;
767 for( i_row = 0; i_row < p_vout->p_sys->i_row; i_row++ )
769 for( i_col = 0; i_col < p_vout->p_sys->i_col; i_col++, p_vout->p_sys->i_vout++ )
771 struct vout_list_t *p_entry = &p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ];
773 int i_width, i_height;
776 i_width = ( p_vout->render.i_width / p_vout->p_sys->i_col ) & ~0x1;
777 if( i_col + 1 == p_vout->p_sys->i_col )
778 i_width = p_vout->render.i_width - i_col * i_width;
781 i_width += p_vout->p_sys->i_halfLength;
782 if (p_vout->p_sys->i_col > 2 )
783 i_width += p_vout->p_sys->i_halfLength;
788 i_height = ( p_vout->render.i_height / p_vout->p_sys->i_row ) & ~0x3;
789 if( i_row + 1 == p_vout->p_sys->i_row )
790 i_height = p_vout->render.i_height - i_row * i_height;
792 if(p_vout->p_sys->i_row >= 2 )
794 i_height += p_vout->p_sys->i_halfHeight;
795 if( p_vout->p_sys->i_row > 2 )
796 i_height += p_vout->p_sys->i_halfHeight;
800 p_entry->i_width = i_width;
801 p_entry->i_height = i_height;
803 if( !p_entry->b_active )
807 memset( &fmt, 0, sizeof(video_format_t) );
808 fmt.i_width = fmt.i_visible_width = p_vout->render.i_width;
809 fmt.i_height = fmt.i_visible_height = p_vout->render.i_height;
810 fmt.i_x_offset = fmt.i_y_offset = 0;
811 fmt.i_chroma = p_vout->render.i_chroma;
812 fmt.i_aspect = p_vout->render.i_aspect;
813 fmt.i_sar_num = p_vout->render.i_aspect * fmt.i_height / fmt.i_width;
814 fmt.i_sar_den = VOUT_ASPECT_FACTOR;
815 fmt.i_width = fmt.i_visible_width = i_width;
816 fmt.i_height = fmt.i_visible_height = i_height;
817 fmt.i_aspect = p_vout->render.i_aspect
818 * p_vout->render.i_height / i_height
819 * i_width / p_vout->render.i_width;
821 if (p_vout->p_sys->i_offset_x < 0)
823 var_SetInteger(p_vout, "video-x", -p_vout->p_sys->i_offset_x);
824 p_vout->p_sys->i_offset_x = 0;
827 p_entry->p_vout = vout_Create( p_vout, &fmt);
829 if( p_entry->p_vout == NULL )
831 msg_Err( p_vout, "failed to get %ix%i vout threads",
832 p_vout->p_sys->i_col, p_vout->p_sys->i_row );
833 RemoveAllVout( p_vout );
836 vout_filter_SetupChild( p_vout, p_entry->p_vout,
837 MouseEvent, FullscreenEventUp, FullscreenEventDown, true );
840 p_entry->p_vout->i_alignment = 0;
842 p_entry->p_vout->i_alignment |= VOUT_ALIGN_RIGHT;
843 else if (i_col == p_vout->p_sys->i_col -1)
844 p_entry->p_vout->i_alignment |= VOUT_ALIGN_LEFT;
845 if (p_vout->p_sys->i_row > 1)
848 p_entry->p_vout->i_alignment |= VOUT_ALIGN_BOTTOM;
849 else if (i_row == p_vout->p_sys->i_row -1)
850 p_entry->p_vout->i_alignment |= VOUT_ALIGN_TOP;
852 // i_active : number of active pp_vout
854 for( int i = 0; i <= p_vout->p_sys->i_vout; i++ )
856 if( p_vout->p_sys->pp_vout[i].b_active )
859 var_SetInteger( p_vout, "align", p_entry->p_vout->i_alignment );
860 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);
861 var_SetInteger( p_vout, "video-y", i_video_y + (i_active / p_vout->p_sys->i_col) * p_vout->i_window_height);
866 vout_filter_AllocateDirectBuffers( p_vout, VOUT_MAX_PICTURES );
871 /*****************************************************************************
872 * End: terminate Wall video thread output method
873 *****************************************************************************/
874 static void End( vout_thread_t *p_vout )
876 RemoveAllVout( p_vout );
878 vout_filter_ReleaseDirectBuffers( p_vout );
881 var_SetInteger( p_vout, "bz-length", p_vout->p_sys->bz_length);
885 /*****************************************************************************
886 * Destroy: destroy Wall video thread output method
887 *****************************************************************************
888 * Terminate an output method created by WallCreateOutputMethod
889 *****************************************************************************/
890 static void Destroy( vlc_object_t *p_this )
892 vout_thread_t *p_vout = (vout_thread_t *)p_this;
894 free( p_vout->p_sys->pp_vout );
895 free( p_vout->p_sys );
899 /*****************************************************************************
900 * RenderPlanarYUV: displays previously rendered output
901 *****************************************************************************
902 * This function send the currently rendered image to Wall image, waits
903 * until it is displayed and switch the two rendering buffers, preparing next
905 *****************************************************************************/
906 static void RenderPlanarYUV( vout_thread_t *p_vout, picture_t *p_pic )
908 picture_t *p_outpic = NULL;
909 int i_col, i_row, i_vout, i_plane;
910 int pi_left_skip[VOUT_MAX_PLANES], pi_top_skip[VOUT_MAX_PLANES];
913 int constantYUV[3] = {0,128,128};
918 int i_index, i_index2;
921 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
922 pi_top_skip[i_plane] = 0;
924 for( i_vout = 0, i_row = 0; i_row < p_vout->p_sys->i_row; i_row++ )
926 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
927 pi_left_skip[i_plane] = 0;
929 for( i_col = 0; i_col < p_vout->p_sys->i_col; i_col++, i_vout++ )
931 struct vout_list_t *p_entry = &p_vout->p_sys->pp_vout[ i_vout ];
932 if( !p_entry->b_active )
934 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
936 pi_left_skip[i_plane] += p_entry->i_width * p_pic->p[i_plane].i_pitch / p_vout->output.i_width;
941 while( ( p_outpic = vout_CreatePicture( p_entry->p_vout, 0, 0, 0 )) == NULL )
943 if( !vlc_object_alive(p_vout) || p_vout->b_error )
945 vout_DestroyPicture( p_entry->p_vout, p_outpic );
948 msleep( VOUT_OUTMEM_SLEEP );
951 p_outpic->date = p_pic->date;
952 vout_LinkPicture( p_entry->p_vout, p_outpic );
954 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
956 uint8_t *p_in, *p_in_end, *p_out;
957 int i_in_pitch = p_pic->p[i_plane].i_pitch;
958 int i_out_pitch = p_outpic->p[i_plane].i_pitch;
959 int i_copy_pitch = p_outpic->p[i_plane].i_visible_pitch;
960 int i_lines = p_outpic->p[i_plane].i_visible_lines;
961 const int i_div = p_entry->i_width / i_copy_pitch;
963 const bool b_row_first = i_row == 0;
964 const bool b_row_last = i_row + 1 == p_vout->p_sys->i_row;
965 const bool b_col_first = i_col == 0;
966 const bool b_col_last = i_col + 1 == p_vout->p_sys->i_col;
970 pi_left_skip[i_plane] -= (2 * p_vout->p_sys->i_halfLength ) / i_div;
972 if( p_vout->p_sys->i_row >= 2 )
974 if( !b_row_first && b_col_first )
975 pi_top_skip[i_plane] -= (2 * p_vout->p_sys->i_halfHeight * p_pic->p[i_plane].i_pitch) / i_div;
976 if( p_vout->p_sys->i_row > 2 && i_row == 1 && b_col_first )
977 pi_top_skip[i_plane] -= (2 * p_vout->p_sys->i_halfHeight * p_pic->p[i_plane].i_pitch) / i_div;
978 if( !p_vout->p_sys->pp_vout[p_vout->p_sys->i_col-1].b_active )
979 pi_top_skip[i_plane] -= (2 * p_vout->p_sys->i_halfHeight * i_row * p_pic->p[i_plane].i_pitch) / i_div;
981 // i_n : previous inactive pp_vout
983 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++;
984 if( i_col > 1 && i_n )
985 pi_left_skip[i_plane] -= i_n * (2 * p_vout->p_sys->i_halfLength ) / i_div;
988 if( p_vout->p_sys->i_row > 2 && ( b_row_first || b_row_last ) )
989 i_lines -= (2 * p_vout->p_sys->i_halfHeight) / i_div;
991 // 1088 lines bug in a mpeg2 stream of 1080 lines
992 if( b_row_last && p_pic->p[i_plane].i_lines == 1088 )
993 i_lines -= 8 / i_div;
996 p_in = &p_pic->p[i_plane].p_pixels[ pi_top_skip[i_plane] + pi_left_skip[i_plane] ]; /* Wall proprities */
997 p_in_end = &p_in[i_lines * p_pic->p[i_plane].i_pitch];
999 p_out = p_outpic->p[i_plane].p_pixels;
1001 if( p_vout->p_sys->i_row > 2 && b_row_first )
1002 p_out += p_outpic->p[i_plane].i_pitch * (2 * p_vout->p_sys->i_halfHeight) / i_div;
1005 int length = 2 * p_vout->p_sys->i_halfLength / i_div;
1007 if( p_vout->p_sys->b_has_changed )
1010 a_2 = p_vout->p_sys->a_2 * (ACCURACY / 100);
1011 a_1 = p_vout->p_sys->a_1 * length * (ACCURACY / 100);
1012 a_0 = p_vout->p_sys->a_0 * Denom * (ACCURACY / 100);
1013 for( i_col_mod = 0; i_col_mod < 2; i_col_mod++ )
1015 for( i_index = 0; i_index < length; i_index++ )
1017 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);
1018 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;
1023 while( p_in < p_in_end )
1026 vlc_memcpy( p_out, p_in, i_copy_pitch);
1028 if( p_vout->p_sys->i_col > 2 )
1030 const int halfl = length / 2;
1032 vlc_memcpy( &p_out[halfl], &p_in[0], i_copy_pitch - halfl );
1033 else if( b_col_last )
1034 vlc_memcpy( &p_out[ 0], &p_in[-halfl], i_copy_pitch - halfl );
1036 vlc_memcpy( &p_out[ 0], &p_in[-halfl], i_copy_pitch);
1040 memset( &p_out[0], constantYUV[i_plane], halfl);
1041 else if( b_col_last )
1042 memset( &p_out[i_copy_pitch - halfl], constantYUV[i_plane], halfl );
1046 vlc_memcpy( p_out , p_in, i_copy_pitch );
1049 if( p_vout->p_sys->b_attenuate )
1052 // first blended zone
1055 uint8_t *p_dst = &p_out[0];
1056 for (i_index = 0; i_index < length; i_index++)
1059 p_dst[i_index] = (p_vout->p_sys->lambda[1][i_plane][i_index] * p_dst[i_index]) / ACCURACY +
1060 p_vout->p_sys->cstYUV[1][i_plane][i_index];
1062 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]];
1066 // second blended zone
1069 uint8_t *p_dst = &p_out[i_copy_pitch - length];
1070 for (i_index = 0; i_index < length; i_index++)
1073 p_dst[i_index] = (p_vout->p_sys->lambda[0][i_plane][i_index] * p_dst[i_index]) / ACCURACY +
1074 p_vout->p_sys->cstYUV[0][i_plane][i_index];
1076 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]];
1084 p_out += i_out_pitch;
1088 if ( p_vout->p_sys->i_row >= 2 )
1091 if (( p_vout->p_sys->i_row > 2 ) && (( b_row_first ) || ( b_row_last )))
1094 int height = 2 * p_vout->p_sys->i_halfHeight / i_div;
1097 TopOffset = i_lines + (2 * p_vout->p_sys->i_halfHeight) / i_div;
1101 TopOffset = height - (2 * p_vout->p_sys->i_halfHeight) / i_div;
1103 uint8_t *p_dst = p_out - TopOffset * i_out_pitch;
1104 for (i_index = 0; i_index < height; i_index++)
1105 for (i_index2 = 0; i_index2 < i_copy_pitch; i_index2++)
1106 p_dst[i_index * i_out_pitch + i_index2] = constantYUV[i_plane];
1108 if( p_vout->p_sys->b_attenuate )
1110 length = 2 * p_vout->p_sys->i_halfHeight / (p_vout->p_sys->pp_vout[i_vout].i_width / i_copy_pitch);
1111 if (p_vout->p_sys->b_has_changed)
1114 a_2 = p_vout->p_sys->a_2 * (ACCURACY / 100);
1115 a_1 = p_vout->p_sys->a_1 * length * (ACCURACY / 100);
1116 a_0 = p_vout->p_sys->a_0 * Denom * (ACCURACY / 100);
1117 for(i_col_mod = 0; i_col_mod < 2; i_col_mod++)
1118 for (i_index = 0; i_index < length; i_index++)
1120 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);
1121 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;
1124 // first blended zone
1127 TopOffset = i_lines;
1128 uint8_t *p_dst = p_out - TopOffset * i_out_pitch;
1130 for (i_index = 0; i_index < length; i_index++)
1132 for (i_index2 = 0; i_index2 < i_copy_pitch; i_index2++)
1135 p_dst[i_index * i_out_pitch + i_index2] = ( p_vout->p_sys->lambda2[1][i_plane][i_index] *
1136 p_dst[i_index * i_out_pitch + i_index2] ) / ACCURACY +
1137 p_vout->p_sys->cstYUV2[1][i_plane][i_index];
1139 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]];
1144 // second blended zone
1148 uint8_t *p_dst = p_out - TopOffset * p_outpic->p[i_plane].i_pitch;
1150 for (i_index = 0; i_index < length; i_index++)
1152 for (i_index2 = 0; i_index2 < i_copy_pitch; i_index2++)
1155 p_dst[i_index * i_out_pitch + i_index2] = (p_vout->p_sys->lambda2[0][i_plane][i_index] *
1156 p_dst[i_index * i_out_pitch + i_index2]) / ACCURACY +
1157 p_vout->p_sys->cstYUV2[0][i_plane][i_index];
1160 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]];
1169 // bug for wall filter : fix by CC
1170 // pi_left_skip[i_plane] += i_out_pitch;
1171 pi_left_skip[i_plane] += i_copy_pitch;
1174 vout_UnlinkPicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
1176 vout_DisplayPicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
1180 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
1182 pi_top_skip[i_plane] += p_vout->p_sys->pp_vout[ i_vout-1 ].i_height
1183 * p_pic->p[i_plane].i_lines
1184 / p_vout->output.i_height
1185 * p_pic->p[i_plane].i_pitch;
1189 if (p_vout->p_sys->b_has_changed)
1190 p_vout->p_sys->b_has_changed = false;
1195 /*****************************************************************************
1196 * RenderPackedRGB: displays previously rendered output
1197 *****************************************************************************
1198 * This function send the currently rendered image to Wall image, waits
1199 * until it is displayed and switch the two rendering buffers, preparing next
1201 *****************************************************************************/
1202 static void RenderPackedRGB( vout_thread_t *p_vout, picture_t *p_pic )
1204 picture_t *p_outpic = NULL;
1205 int i_col, i_row, i_vout, i_plane;
1206 int pi_left_skip[VOUT_MAX_PLANES], pi_top_skip[VOUT_MAX_PLANES];
1208 int LeftOffset, TopOffset;
1213 int i_index, i_index2;
1216 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
1217 pi_top_skip[i_plane] = 0;
1219 for( i_vout = 0, i_row = 0; i_row < p_vout->p_sys->i_row; i_row++ )
1221 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
1222 pi_left_skip[i_plane] = 0;
1224 for( i_col = 0; i_col < p_vout->p_sys->i_col; i_col++, i_vout++ )
1226 if( !p_vout->p_sys->pp_vout[ i_vout ].b_active )
1228 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
1230 pi_left_skip[i_plane] +=
1231 p_vout->p_sys->pp_vout[ i_vout ].i_width * p_pic->p->i_pixel_pitch;
1237 vout_CreatePicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
1241 if( !vlc_object_alive (p_vout) || p_vout->b_error )
1243 vout_DestroyPicture(
1244 p_vout->p_sys->pp_vout[ i_vout ].p_vout, p_outpic );
1248 msleep( VOUT_OUTMEM_SLEEP );
1251 p_outpic->date = p_pic->date;
1252 vout_LinkPicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
1255 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
1257 uint8_t *p_in, *p_in_end, *p_out;
1258 int i_in_pitch = p_pic->p[i_plane].i_pitch;
1259 int i_out_pitch = p_outpic->p[i_plane].i_pitch;
1260 int i_copy_pitch = p_outpic->p[i_plane].i_visible_pitch;
1264 pi_left_skip[i_plane] -= (2 * p_vout->p_sys->i_halfLength) * p_pic->p->i_pixel_pitch;
1265 if( p_vout->p_sys->i_row >= 2 )
1267 if( (i_row) && (!i_col))
1268 pi_top_skip[i_plane] -= (2 * p_vout->p_sys->i_halfHeight * p_pic->p[i_plane].i_pitch);
1269 if( (p_vout->p_sys->i_row > 2) && (i_row == 1) && (!i_col) )
1270 pi_top_skip[i_plane] -= (2 * p_vout->p_sys->i_halfHeight * p_pic->p[i_plane].i_pitch);
1271 if( !p_vout->p_sys->pp_vout[p_vout->p_sys->i_col-1].b_active )
1272 pi_top_skip[i_plane] -= (2 * p_vout->p_sys->i_halfHeight * i_row * p_pic->p[i_plane].i_pitch);
1274 // i_n : previous inactive pp_vout
1276 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++;
1277 if ((i_col > 1) && i_n)
1278 pi_left_skip[i_plane] -= i_n*(2 * p_vout->p_sys->i_halfLength ) * p_pic->p->i_pixel_pitch;
1280 p_in = p_pic->p[i_plane].p_pixels
1281 /* Wall proprities */
1282 + pi_top_skip[i_plane] + pi_left_skip[i_plane];
1284 int i_lines = p_outpic->p[i_plane].i_visible_lines;
1285 // 1088 lines bug in a mpeg2 stream of 1080 lines
1286 if ((p_vout->p_sys->i_row - 1 == i_row) &&
1287 (p_pic->p[i_plane].i_lines == 1088))
1290 p_in_end = p_in + i_lines * p_pic->p[i_plane].i_pitch;
1292 p_in = p_pic->p[i_plane].p_pixels
1293 + pi_top_skip[i_plane] + pi_left_skip[i_plane];
1295 p_in_end = p_in + p_outpic->p[i_plane].i_visible_lines
1296 * p_pic->p[i_plane].i_pitch;
1299 p_out = p_outpic->p[i_plane].p_pixels;
1303 if ((p_vout->p_sys->i_row > 2) && (!i_row))
1304 p_out += (p_outpic->p[i_plane].i_pitch * (2 * p_vout->p_sys->i_halfHeight) * p_pic->p->i_pixel_pitch);
1307 length = 2 * p_vout->p_sys->i_halfLength * p_pic->p->i_pixel_pitch;
1309 if (p_vout->p_sys->b_has_changed)
1313 Denom = F2(length / p_pic->p->i_pixel_pitch);
1314 a_2 = p_vout->p_sys->a_2 * (ACCURACY / 100);
1315 a_1 = p_vout->p_sys->a_1 * 2 * p_vout->p_sys->i_halfLength * (ACCURACY / 100);
1316 a_0 = p_vout->p_sys->a_0 * Denom * (ACCURACY / 100);
1317 for(i_col_mod = 0; i_col_mod < 2; i_col_mod++)
1318 for (i_index = 0; i_index < length / p_pic->p->i_pixel_pitch; i_index++)
1319 for (i_plane_ = 0; i_plane_ < p_pic->p->i_pixel_pitch; i_plane_++)
1320 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);
1323 while( p_in < p_in_end )
1326 vlc_memcpy( p_out, p_in, i_copy_pitch );
1328 if (p_vout->p_sys->i_col > 2)
1333 vlc_memcpy( p_out + length, p_in, i_copy_pitch - length);
1334 else if (i_col + 1 == p_vout->p_sys->i_col)
1335 vlc_memcpy( p_out, p_in - length, i_copy_pitch - length);
1337 vlc_memcpy( p_out, p_in - length, i_copy_pitch);
1343 p_out += LeftOffset;
1345 for (i_index = 0; i_index < length; i_index++)
1346 *(p_out + i_index) = 0;
1347 p_out -= LeftOffset;
1350 else if ((i_col + 1 == p_vout->p_sys->i_col ))
1353 LeftOffset = i_copy_pitch - length;
1354 p_out += LeftOffset;
1356 for (i_index = 0; i_index < length; i_index++)
1357 *(p_out + i_index) = 0;
1358 p_out -= LeftOffset;
1364 vlc_memcpy( p_out, p_in, i_copy_pitch);
1367 // first blended zone
1371 p_out += LeftOffset;
1372 for (i_index = 0; i_index < length; i_index++)
1374 *(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] *
1375 (*(p_out + i_index))) / ACCURACY;
1377 *(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)];
1379 p_out -= LeftOffset;
1381 // second blended zone
1382 if (i_col + 1 < p_vout->p_sys->i_col)
1384 LeftOffset = i_copy_pitch - length;
1385 p_out += LeftOffset;
1386 for (i_index = 0; i_index < length; i_index++)
1388 *(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] *
1389 (*(p_out + i_index))) / ACCURACY;
1391 *(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)];
1393 p_out -= LeftOffset;
1398 p_out += i_out_pitch;
1402 if (!p_vout->p_sys->b_attenuate)
1404 if ((i_row == 0) && (p_vout->p_sys->i_row > 2))
1407 TopOffset = i_lines + (2 * p_vout->p_sys->i_halfHeight);
1408 p_out -= TopOffset * p_outpic->p[i_plane].i_pitch;
1409 for (i_index = 0; i_index < length; i_index++)
1410 for (i_index2 = 0; i_index2 < i_copy_pitch; i_index2++)
1411 *(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2) = 0;
1412 p_out += TopOffset * p_outpic->p[i_plane].i_pitch;
1414 else if ((i_row + 1 == p_vout->p_sys->i_row) && (p_vout->p_sys->i_row > 2))
1417 TopOffset = length - (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;
1427 if (p_vout->p_sys->i_row >= 2)
1429 length = 2 * p_vout->p_sys->i_halfHeight;
1430 if (p_vout->p_sys->b_has_changed)
1435 a_2 = p_vout->p_sys->a_2 * (ACCURACY / 100);
1436 a_1 = p_vout->p_sys->a_1 * length * (ACCURACY / 100);
1437 a_0 = p_vout->p_sys->a_0 * Denom * (ACCURACY / 100);
1438 for(i_row_mod = 0; i_row_mod < 2; i_row_mod++)
1439 for (i_index = 0; i_index < length; i_index++)
1440 for (i_plane_ = 0; i_plane_ < p_pic->p->i_pixel_pitch; i_plane_++)
1441 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);
1443 // first blended zone
1447 TopOffset = i_lines;
1448 p_out -= TopOffset * p_outpic->p[i_plane].i_pitch;
1449 for (i_index = 0; i_index < length; i_index++)
1450 for (i_index2 = 0; i_index2 < i_copy_pitch; i_index2++)
1452 *(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] *
1453 (*(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2))) / ACCURACY;
1455 *(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)];
1457 p_out += TopOffset * p_outpic->p[i_plane].i_pitch;
1459 else if (p_vout->p_sys->i_row > 2)
1462 TopOffset = i_lines + (2 * p_vout->p_sys->i_halfHeight);
1463 p_out -= TopOffset * p_outpic->p[i_plane].i_pitch;
1464 for (i_index = 0; i_index < length; i_index++)
1465 for (i_index2 = 0; i_index2 < i_copy_pitch; i_index2++)
1466 *(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2) = 0;
1467 p_out += TopOffset * p_outpic->p[i_plane].i_pitch;
1470 // second blended zone
1472 if (i_row + 1 < p_vout->p_sys->i_row)
1475 p_out -= TopOffset * p_outpic->p[i_plane].i_pitch;
1476 for (i_index = 0; i_index < length; i_index++)
1477 for (i_index2 = 0; i_index2 < i_copy_pitch; i_index2++)
1479 *(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] *
1480 (*(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2))) / ACCURACY;
1482 *(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)];
1485 p_out += TopOffset * p_outpic->p[i_plane].i_pitch;
1487 else if (p_vout->p_sys->i_row > 2)
1490 TopOffset = length - (2 * p_vout->p_sys->i_halfHeight);
1491 p_out -= TopOffset * p_outpic->p[i_plane].i_pitch;
1492 for (i_index = 0; i_index < length; i_index++)
1493 for (i_index2 = 0; i_index2 < i_copy_pitch; i_index2++)
1494 *(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2) = 0;
1495 p_out += TopOffset * p_outpic->p[i_plane].i_pitch;
1501 // bug for wall filter : fix by CC
1502 // pi_left_skip[i_plane] += i_out_pitch;
1503 pi_left_skip[i_plane] += i_copy_pitch;
1506 vout_UnlinkPicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
1508 vout_DisplayPicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
1512 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
1514 pi_top_skip[i_plane] += p_vout->p_sys->pp_vout[ i_vout-1 ].i_height
1515 * p_pic->p[i_plane].i_lines
1516 / p_vout->output.i_height
1517 * p_pic->p[i_plane].i_pitch;
1521 if (p_vout->p_sys->b_has_changed) p_vout->p_sys->b_has_changed = false;
1527 // WARNING : NO DEBUGGED
1528 /*****************************************************************************
1529 * RenderPackedYUV: displays previously rendered output
1530 *****************************************************************************
1531 * This function send the currently rendered image to Wall image, waits
1532 * until it is displayed and switch the two rendering buffers, preparing next
1534 *****************************************************************************/
1535 static void RenderPackedYUV( vout_thread_t *p_vout, picture_t *p_pic )
1537 picture_t *p_outpic = NULL;
1538 int i_col, i_row, i_vout, i_plane;
1539 int pi_left_skip[VOUT_MAX_PLANES], pi_top_skip[VOUT_MAX_PLANES];
1541 int LeftOffset, TopOffset;
1542 int constantYUV[3] = {0,128,128};
1547 int i_index, i_index2;
1550 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
1551 pi_top_skip[i_plane] = 0;
1553 for( i_vout = 0;, i_row = 0; i_row < p_vout->p_sys->i_row; i_row++ )
1555 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
1556 pi_left_skip[i_plane] = 0;
1558 for( i_col = 0; i_col < p_vout->p_sys->i_col; i_col++, i_vout++ )
1560 if( !p_vout->p_sys->pp_vout[ i_vout ].b_active )
1562 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
1564 pi_left_skip[i_plane] +=
1565 p_vout->p_sys->pp_vout[ i_vout ].i_width
1566 * p_pic->p[i_plane].i_pitch / p_vout->output.i_width;
1572 vout_CreatePicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
1576 if( !vlc_object_alive (p_vout) || p_vout->b_error )
1578 vout_DestroyPicture(
1579 p_vout->p_sys->pp_vout[ i_vout ].p_vout, p_outpic );
1583 msleep( VOUT_OUTMEM_SLEEP );
1586 p_outpic->date = p_pic->date;
1587 vout_LinkPicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
1590 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
1592 uint8_t *p_in, *p_in_end, *p_out;
1593 int i_in_pitch = p_pic->p[i_plane].i_pitch;
1594 int i_out_pitch = p_outpic->p[i_plane].i_pitch;
1595 int i_copy_pitch = p_outpic->p[i_plane].i_visible_pitch;
1596 const int i_div = p_vout->p_sys->pp_vout[i_vout].i_width / i_copy_pitch;
1599 if (i_col) pi_left_skip[i_plane] -= (2 * p_vout->p_sys->i_halfLength ) / i_div;
1600 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;
1601 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;
1602 if( !p_vout->p_sys->pp_vout[p_vout->p_sys->i_col-1].b_active )
1603 pi_top_skip[i_plane] -= (2 * p_vout->p_sys->i_halfHeight * i_row * p_pic->p[i_plane].i_pitch) / i_div;
1604 // i_n : previous inactive pp_vout
1606 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++;
1607 if ((i_col > 1) && i_n)
1608 pi_left_skip[i_plane] -= i_n*(2 * p_vout->p_sys->i_halfLength ) / i_div;
1610 p_in = p_pic->p[i_plane].p_pixels
1611 /* Wall proprities */
1612 + pi_top_skip[i_plane] + pi_left_skip[i_plane];
1614 int i_lines = p_outpic->p[i_plane].i_visible_lines;
1615 // 1088 lines bug in a mpeg2 stream of 1080 lines
1616 if ((p_vout->p_sys->i_row - 1 == i_row) &&
1617 (p_pic->p[i_plane].i_lines == 1088))
1620 p_in_end = p_in + i_lines * p_pic->p[i_plane].i_pitch;
1622 p_in = p_pic->p[i_plane].p_pixels
1623 + pi_top_skip[i_plane] + pi_left_skip[i_plane];
1625 p_in_end = p_in + p_outpic->p[i_plane].i_visible_lines
1626 * p_pic->p[i_plane].i_pitch;
1628 p_out = p_outpic->p[i_plane].p_pixels;
1631 length = 2 * p_vout->p_sys->i_halfLength * p_pic->p->i_pixel_pitch;
1632 LeftOffset = (i_col ? 0 : i_copy_pitch - length);
1633 if (p_vout->p_sys->b_has_changed)
1637 for (i_index = 0; i_index < length / p_pic->p->i_pixel_pitch; i_index++)
1638 for (i_plane_ = 0; i_plane_ < p_pic->p->i_pixel_pitch; i_plane_++)
1639 for (i_index2 = 0; i_index2 < 256; i_index2++)
1640 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_]));
1642 switch (p_vout->output.i_chroma)
1644 case VLC_CODEC_YUYV: // packed by 2
1645 Denom = F2(length / p_pic->p->i_pixel_pitch);
1646 a_2 = p_vout->p_sys->a_2 * (ACCURACY / 100);
1647 a_1 = p_vout->p_sys->a_1 * 2 * p_vout->p_sys->i_halfLength * (ACCURACY / 100);
1648 a_0 = p_vout->p_sys->a_0 * Denom * (ACCURACY / 100);
1649 for (i_index = 0; i_index < length / p_pic->p->i_pixel_pitch; i_index+=p_pic->p->i_pixel_pitch)
1650 // for each macropixel
1652 // first image pixel
1653 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);
1654 p_vout->p_sys->cstYUV[i_col][0][i_index] = ((ACCURACY - p_vout->p_sys->lambda[i_col][0][i_index]) * constantYUV[0]) / ACCURACY;
1655 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);
1656 p_vout->p_sys->cstYUV[i_col][1][i_index] = ((ACCURACY - p_vout->p_sys->lambda[i_col][1][i_index]) * constantYUV[1]) / ACCURACY;
1657 // second image pixel
1658 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);
1659 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;
1660 p_vout->p_sys->lambda[i_col][1][i_index + 1] = p_vout->p_sys->lambda[i_col][1][i_index];
1661 p_vout->p_sys->cstYUV[i_col][1][i_index + 1] = p_vout->p_sys->cstYUV[i_col][1][i_index];
1664 case VLC_CODEC_UYVY: // packed by 2
1665 Denom = F2(length / p_pic->p->i_pixel_pitch);
1666 a_2 = p_vout->p_sys->a_2 * (ACCURACY / 100);
1667 a_1 = p_vout->p_sys->a_1 * 2 * p_vout->p_sys->i_halfLength * (ACCURACY / 100);
1668 a_0 = p_vout->p_sys->a_0 * Denom * (ACCURACY / 100);
1669 for (i_index = 0; i_index < length / p_pic->p->i_pixel_pitch; i_index+=p_pic->p->i_pixel_pitch)
1670 // for each macropixel
1672 // first image pixel
1673 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);
1674 p_vout->p_sys->cstYUV[i_col][0][i_index] = ((ACCURACY - p_vout->p_sys->lambda[i_col][0][i_index]) * constantYUV[1]) / ACCURACY;
1675 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);
1676 p_vout->p_sys->cstYUV[i_col][1][i_index] = ((ACCURACY - p_vout->p_sys->lambda[i_col][1][i_index]) * constantYUV[0]) / ACCURACY;
1677 // second image pixel
1678 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);
1679 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;
1680 p_vout->p_sys->lambda[i_col][1][i_index + 1] = p_vout->p_sys->lambda[i_col][1][i_index];
1681 p_vout->p_sys->cstYUV[i_col][1][i_index + 1] = p_vout->p_sys->cstYUV[i_col][1][i_index];
1689 while( p_in < p_in_end )
1692 vlc_memcpy( p_out, p_in, i_copy_pitch);
1694 vlc_memcpy( p_out + i_col * length, p_in + i_col * length, i_copy_pitch - length);
1695 p_out += LeftOffset;
1698 for (i_index = 0; i_index < length; i_index++)
1699 *(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] *
1700 (*(p_in + i_index))) / ACCURACY +
1701 p_vout->p_sys->cstYUV[i_col][i_index % p_pic->p->i_pixel_pitch][i_index / p_pic->p->i_pixel_pitch];
1703 for (i_index = 0; i_index < length; i_index++)
1704 *(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] *
1705 (*(p_in + i_index))) / ACCURACY +
1706 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];
1708 p_out -= LeftOffset;
1712 p_out += i_out_pitch;
1715 if (p_vout->p_sys->i_row == 2)
1717 length = 2 * p_vout->p_sys->i_halfHeight * p_pic->p->i_pixel_pitch;
1718 TopOffset = (i_row ? i_lines : length / p_pic->p->i_pixel_pitch);
1719 if (p_vout->p_sys->b_has_changed)
1723 for (i_index = 0; i_index < length / p_pic->p->i_pixel_pitch; i_index++)
1724 for (i_plane_ = 0; i_plane_ < p_pic->p->i_pixel_pitch; i_plane_++)
1725 for (i_index2 = 0; i_index2 < 256; i_index2++)
1726 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_]));
1728 switch (p_vout->output.i_chroma)
1730 case VLC_CODEC_YUYV: // packed by 2
1731 Denom = F2(length / p_pic->p->i_pixel_pitch);
1732 a_2 = p_vout->p_sys->a_2 * (ACCURACY / 100);
1733 a_1 = p_vout->p_sys->a_1 * 2 * p_vout->p_sys->i_halfHeight * (ACCURACY / 100);
1734 a_0 = p_vout->p_sys->a_0 * Denom * (ACCURACY / 100);
1735 for (i_index = 0; i_index < length / p_pic->p->i_pixel_pitch; i_index+=p_pic->p->i_pixel_pitch)
1736 // for each macropixel
1738 // first image pixel
1739 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);
1740 p_vout->p_sys->cstYUV2[i_row][0][i_index] = ((ACCURACY - p_vout->p_sys->lambda2[i_row][0][i_index]) * constantYUV[0]) / ACCURACY;
1741 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);
1742 p_vout->p_sys->cstYUV2[i_row][1][i_index] = ((ACCURACY - p_vout->p_sys->lambda2[i_row][1][i_index]) * constantYUV[1]) / ACCURACY;
1743 // second image pixel
1744 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);
1745 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;
1746 p_vout->p_sys->lambda2[i_row][1][i_index + 1] = p_vout->p_sys->lambda2[i_row][1][i_index];
1747 p_vout->p_sys->cstYUV2[i_row][1][i_index + 1] = p_vout->p_sys->cstYUV2[i_row][1][i_index];
1750 case VLC_CODEC_UYVY: // packed by 2
1751 Denom = F2(length / p_pic->p->i_pixel_pitch);
1752 a_2 = p_vout->p_sys->a_2 * (ACCURACY / 100);
1753 a_1 = p_vout->p_sys->a_1 * 2 * p_vout->p_sys->i_halfHeight * (ACCURACY / 100);
1754 a_0 = p_vout->p_sys->a_0 * Denom * (ACCURACY / 100);
1755 for (i_index = 0; i_index < length / p_pic->p->i_pixel_pitch; i_index+=p_pic->p->i_pixel_pitch)
1756 // for each macropixel
1758 // first image pixel
1759 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);
1760 p_vout->p_sys->cstYUV2[i_row][0][i_index] = ((ACCURACY - p_vout->p_sys->lambda2[i_col][0][i_index]) * constantYUV[1]) / ACCURACY;
1761 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);
1762 p_vout->p_sys->cstYUV2[i_row][1][i_index] = ((ACCURACY - p_vout->p_sys->lambda2[i_row][1][i_index]) * constantYUV[0]) / ACCURACY;
1763 // second image pixel
1764 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);
1765 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;
1766 p_vout->p_sys->lambda2[i_row][1][i_index + 1] = p_vout->p_sys->lambda2[i_row][1][i_index];
1767 p_vout->p_sys->cstYUV2[i_row][1][i_index + 1] = p_vout->p_sys->cstYUV2[i_row][1][i_index];
1774 p_out -= TopOffset * p_outpic->p[i_plane].i_pitch;
1776 for (i_index = 0; i_index < length / p_pic->p->i_pixel_pitch; i_index++)
1777 for (i_index2 = 0; i_index2 < i_copy_pitch; i_index2++)
1778 *(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] *
1779 (*(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2))) / ACCURACY +
1780 p_vout->p_sys->cstYUV2[i_row][i_index2 % p_pic->p->i_pixel_pitch][i_index];
1782 for (i_index = 0; i_index < length / p_pic->p->i_pixel_pitch; i_index++)
1783 for (i_index2 = 0; i_index2 < i_copy_pitch; i_index2++)
1784 *(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] *
1785 (*(p_out + (i_index * p_outpic->p[i_plane].i_pitch) + i_index2))) / ACCURACY +
1786 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];
1789 p_out += TopOffset * p_outpic->p[i_plane].i_pitch;
1792 // bug for wall filter : fix by CC
1793 // pi_left_skip[i_plane] += i_out_pitch;
1794 pi_left_skip[i_plane] += i_copy_pitch;
1797 vout_UnlinkPicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
1799 vout_DisplayPicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
1803 for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
1805 pi_top_skip[i_plane] += p_vout->p_sys->pp_vout[ i_vout-1 ].i_height
1806 * p_pic->p[i_plane].i_lines
1807 / p_vout->output.i_height
1808 * p_pic->p[i_plane].i_pitch;
1812 if (p_vout->p_sys->b_has_changed) p_vout->p_sys->b_has_changed = false;
1818 /*****************************************************************************
1819 * RemoveAllVout: destroy all the child video output threads
1820 *****************************************************************************/
1821 static void RemoveAllVout( vout_thread_t *p_vout )
1823 vout_sys_t *p_sys = p_vout->p_sys;
1825 for( int i = 0; i < p_vout->p_sys->i_vout; i++ )
1827 if( p_sys->pp_vout[i].b_active )
1829 vout_filter_SetupChild( p_vout, p_sys->pp_vout[i].p_vout,
1830 MouseEvent, FullscreenEventUp, FullscreenEventDown, true );
1831 vout_CloseAndRelease( p_sys->pp_vout[i].p_vout );
1832 p_sys->pp_vout[i].p_vout = NULL;
1837 /*****************************************************************************
1838 * SendEvents: forward mouse and keyboard events to the parent p_vout
1839 *****************************************************************************/
1840 static int MouseEvent( vlc_object_t *p_this, char const *psz_var,
1841 vlc_value_t oldval, vlc_value_t newval, void *p_data )
1843 vout_thread_t *p_vout = p_data;
1844 vout_sys_t *p_sys = p_vout->p_sys;
1848 /* Find the video output index */
1849 for( i_vout = 0; i_vout < p_sys->i_vout; i_vout++ )
1851 if( p_sys->pp_vout[i_vout].b_active &&
1852 p_this == VLC_OBJECT(p_sys->pp_vout[i_vout].p_vout) )
1855 assert( i_vout < p_vout->p_sys->i_vout );
1857 /* Translate the mouse coordinates */
1858 if( !strcmp( psz_var, "mouse-x" ) )
1861 int i_overlap = ((p_sys->i_col > 2) ? 0 : 2 * p_sys->i_halfLength);
1862 newval.i_int += (p_vout->output.i_width - i_overlap)
1864 newval.i_int += p_vout->output.i_width
1866 * (i_vout % p_sys->i_col)
1869 else if( !strcmp( psz_var, "mouse-y" ) )
1872 int i_overlap = ((p_sys->i_row > 2) ? 0 : 2 * p_sys->i_halfHeight);
1873 newval.i_int += (p_vout->output.i_height - i_overlap)
1875 newval.i_int += p_vout->output.i_height
1877 //bug fix in Wall plug-in
1878 // * (i_vout / p_vout->p_sys->i_row)
1879 * (i_vout / p_sys->i_col)
1883 return var_Set( p_vout, psz_var, newval );
1887 * Forward fullscreen event to/from the childrens.
1888 * FIXME pretty much duplicated from wall.c
1890 static bool IsFullscreenActive( vout_thread_t *p_vout )
1892 vout_sys_t *p_sys = p_vout->p_sys;
1893 for( int i = 0; i < p_sys->i_vout; i++ )
1895 if( p_sys->pp_vout[i].b_active &&
1896 var_GetBool( p_sys->pp_vout[i].p_vout, "fullscreen" ) )
1901 static int FullscreenEventUp( vlc_object_t *p_this, char const *psz_var,
1902 vlc_value_t oldval, vlc_value_t newval, void *p_data )
1904 vout_thread_t *p_vout = p_data;
1905 VLC_UNUSED(oldval); VLC_UNUSED(p_this); VLC_UNUSED(psz_var); VLC_UNUSED(newval);
1907 const bool b_fullscreen = IsFullscreenActive( p_vout );
1908 if( !var_GetBool( p_vout, "fullscreen" ) != !b_fullscreen )
1909 return var_SetBool( p_vout, "fullscreen", b_fullscreen );
1912 static int FullscreenEventDown( vlc_object_t *p_this, char const *psz_var,
1913 vlc_value_t oldval, vlc_value_t newval, void *p_data )
1915 vout_thread_t *p_vout = (vout_thread_t*)p_this;
1916 vout_sys_t *p_sys = p_vout->p_sys;
1917 VLC_UNUSED(oldval); VLC_UNUSED(p_data); VLC_UNUSED(psz_var);
1919 const bool b_fullscreen = IsFullscreenActive( p_vout );
1920 if( !b_fullscreen != !newval.b_bool )
1922 for( int i = 0; i < p_sys->i_vout; i++ )
1924 if( !p_sys->pp_vout[i].b_active )
1927 vout_thread_t *p_child = p_sys->pp_vout[i].p_vout;
1928 if( !var_GetBool( p_child, "fullscreen" ) != !newval.b_bool )
1930 var_SetBool( p_child, "fullscreen", newval.b_bool );