]> git.sesse.net Git - vlc/blob - modules/video_filter/wall.c
Merge branch 'master' of git@git.videolan.org:vlc
[vlc] / modules / video_filter / wall.c
1 /*****************************************************************************
2  * wall.c : Wall video plugin for vlc
3  *****************************************************************************
4  * Copyright (C) 2000, 2001, 2002, 2003 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Samuel Hocevar <sam@zoy.org>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22  *****************************************************************************/
23
24 /*****************************************************************************
25  * Preamble
26  *****************************************************************************/
27
28 #ifdef HAVE_CONFIG_H
29 # include "config.h"
30 #endif
31
32 #include <vlc/vlc.h>
33 #include <vlc_vout.h>
34
35 #include "filter_common.h"
36
37 /*****************************************************************************
38  * Local prototypes
39  *****************************************************************************/
40 static int  Create    ( vlc_object_t * );
41 static void Destroy   ( vlc_object_t * );
42
43 static int  Init      ( vout_thread_t * );
44 static void End       ( vout_thread_t * );
45 static void Render    ( vout_thread_t *, picture_t * );
46
47 static void RemoveAllVout  ( vout_thread_t *p_vout );
48
49 static int  SendEvents( vlc_object_t *, char const *,
50                         vlc_value_t, vlc_value_t, void * );
51
52 /*****************************************************************************
53  * Module descriptor
54  *****************************************************************************/
55 #define COLS_TEXT N_("Number of columns")
56 #define COLS_LONGTEXT N_("Number of horizontal windows in " \
57     "which to split the video.")
58
59 #define ROWS_TEXT N_("Number of rows")
60 #define ROWS_LONGTEXT N_("Number of vertical windows in " \
61     "which to split the video.")
62
63 #define ACTIVE_TEXT N_("Active windows")
64 #define ACTIVE_LONGTEXT N_("Comma-separated list of active windows, " \
65     "defaults to all")
66
67 #define ASPECT_TEXT N_("Element aspect ratio")
68 #define ASPECT_LONGTEXT N_("Aspect ratio of the individual displays " \
69    "building the wall.")
70
71 #define CFG_PREFIX "wall-"
72
73 vlc_module_begin();
74     set_description( _("Wall video filter") );
75     set_shortname( _("Image wall" ));
76     set_capability( "video filter", 0 );
77     set_category( CAT_VIDEO );
78     set_subcategory( SUBCAT_VIDEO_VFILTER );
79
80     add_integer( CFG_PREFIX "cols", 3, NULL, COLS_TEXT, COLS_LONGTEXT, false );
81     add_integer( CFG_PREFIX "rows", 3, NULL, ROWS_TEXT, ROWS_LONGTEXT, false );
82     add_string( CFG_PREFIX "active", NULL, NULL, ACTIVE_TEXT, ACTIVE_LONGTEXT,
83                  true );
84     add_string( CFG_PREFIX "element-aspect", "4:3", NULL, ASPECT_TEXT, ASPECT_LONGTEXT, false );
85
86     add_shortcut( "wall" );
87     set_callbacks( Create, Destroy );
88 vlc_module_end();
89
90 static const char *ppsz_filter_options[] = {
91     "cols", "rows", "active", "element-aspect", NULL
92 };
93
94 /*****************************************************************************
95  * vout_sys_t: Wall video output method descriptor
96  *****************************************************************************
97  * This structure is part of the video output thread descriptor.
98  * It describes the Wall specific properties of an output thread.
99  *****************************************************************************/
100 struct vout_sys_t
101 {
102     int    i_col;
103     int    i_row;
104     int    i_vout;
105     struct vout_list_t
106     {
107         bool b_active;
108         int i_width;
109         int i_height;
110         int i_left;
111         int i_top;
112         vout_thread_t *p_vout;
113     } *pp_vout;
114 };
115
116 /*****************************************************************************
117  * Control: control facility for the vout (forwards to child vout)
118  *****************************************************************************/
119 static int Control( vout_thread_t *p_vout, int i_query, va_list args )
120 {
121     int i_row, i_col, i_vout = 0;
122
123     for( i_row = 0; i_row < p_vout->p_sys->i_row; i_row++ )
124     {
125         for( i_col = 0; i_col < p_vout->p_sys->i_col; i_col++ )
126         {
127             vout_vaControl( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
128                             i_query, args );
129             i_vout++;
130         }
131     }
132     return VLC_SUCCESS;
133 }
134
135 /*****************************************************************************
136  * Create: allocates Wall video thread output method
137  *****************************************************************************
138  * This function allocates and initializes a Wall vout method.
139  *****************************************************************************/
140 static int Create( vlc_object_t *p_this )
141 {
142     vout_thread_t *p_vout = (vout_thread_t *)p_this;
143     char *psz_method, *psz_tmp, *psz_method_tmp;
144     int i_vout;
145
146     /* Allocate structure */
147     p_vout->p_sys = malloc( sizeof( vout_sys_t ) );
148     if( p_vout->p_sys == NULL )
149     {
150         msg_Err( p_vout, "out of memory" );
151         return VLC_ENOMEM;
152     }
153
154     p_vout->pf_init = Init;
155     p_vout->pf_end = End;
156     p_vout->pf_manage = NULL;
157     p_vout->pf_render = Render;
158     p_vout->pf_display = NULL;
159     p_vout->pf_control = Control;
160
161     config_ChainParse( p_vout, CFG_PREFIX, ppsz_filter_options,
162                        p_vout->p_cfg );
163
164     /* Look what method was requested */
165     p_vout->p_sys->i_col = var_CreateGetInteger( p_vout, CFG_PREFIX "cols" );
166     p_vout->p_sys->i_row = var_CreateGetInteger( p_vout, CFG_PREFIX "rows" );
167
168     p_vout->p_sys->i_col = __MAX( 1, __MIN( 15, p_vout->p_sys->i_col ) );
169     p_vout->p_sys->i_row = __MAX( 1, __MIN( 15, p_vout->p_sys->i_row ) );
170
171     msg_Dbg( p_vout, "opening a %i x %i wall",
172              p_vout->p_sys->i_col, p_vout->p_sys->i_row );
173
174     p_vout->p_sys->pp_vout = malloc( p_vout->p_sys->i_row *
175                                      p_vout->p_sys->i_col *
176                                      sizeof(struct vout_list_t) );
177     if( p_vout->p_sys->pp_vout == NULL )
178     {
179         msg_Err( p_vout, "out of memory" );
180         free( p_vout->p_sys );
181         return VLC_ENOMEM;
182     }
183
184     psz_method_tmp =
185     psz_method = var_CreateGetNonEmptyString( p_vout, CFG_PREFIX "active" );
186
187     /* If no trailing vout are specified, take them all */
188     if( psz_method == NULL )
189     {
190         for( i_vout = p_vout->p_sys->i_row * p_vout->p_sys->i_col;
191              i_vout--; )
192         {
193             p_vout->p_sys->pp_vout[i_vout].b_active = 1;
194         }
195     }
196     /* If trailing vout are specified, activate only the requested ones */
197     else
198     {
199         for( i_vout = p_vout->p_sys->i_row * p_vout->p_sys->i_col;
200              i_vout--; )
201         {
202             p_vout->p_sys->pp_vout[i_vout].b_active = 0;
203         }
204
205         while( *psz_method )
206         {
207             psz_tmp = psz_method;
208             while( *psz_tmp && *psz_tmp != ',' )
209             {
210                 psz_tmp++;
211             }
212
213             if( *psz_tmp )
214             {
215                 *psz_tmp = '\0';
216                 i_vout = atoi( psz_method );
217                 psz_method = psz_tmp + 1;
218             }
219             else
220             {
221                 i_vout = atoi( psz_method );
222                 psz_method = psz_tmp;
223             }
224
225             if( i_vout >= 0 &&
226                 i_vout < p_vout->p_sys->i_row * p_vout->p_sys->i_col )
227             {
228                 p_vout->p_sys->pp_vout[i_vout].b_active = 1;
229             }
230         }
231     }
232
233     free( psz_method_tmp );
234
235     return VLC_SUCCESS;
236 }
237
238 /*****************************************************************************
239  * Init: initialize Wall video thread output method
240  *****************************************************************************/
241 static int Init( vout_thread_t *p_vout )
242 {
243     int i_index, i_row, i_col, i_width, i_height, i_left, i_top;
244     unsigned int i_target_width,i_target_height;
245     picture_t *p_pic;
246     video_format_t fmt;
247     int i_aspect = 4*VOUT_ASPECT_FACTOR/3;
248     int i_align = 0;
249     unsigned int i_hstart, i_hend, i_vstart, i_vend;
250     unsigned int w1,h1,w2,h2;
251     int i_xpos, i_ypos;
252     int i_vstart_rounded = 0, i_hstart_rounded = 0;
253     char *psz_aspect;
254
255     memset( &fmt, 0, sizeof(video_format_t) );
256
257     psz_aspect = var_CreateGetNonEmptyString( p_vout,
258                                               CFG_PREFIX "element-aspect" );
259     if( psz_aspect && *psz_aspect )
260     {
261         char *psz_parser = strchr( psz_aspect, ':' );
262         if( psz_parser )
263         {
264             *psz_parser++ = '\0';
265             i_aspect = atoi( psz_aspect ) * VOUT_ASPECT_FACTOR
266                 / atoi( psz_parser );
267         }
268         else
269         {
270             msg_Warn( p_vout, "invalid aspect ratio specification" );
271         }
272         free( psz_aspect );
273     }
274
275     i_xpos = var_CreateGetInteger( p_vout, "video-x" );
276     i_ypos = var_CreateGetInteger( p_vout, "video-y" );
277     if( i_xpos < 0 ) i_xpos = 0;
278     if( i_ypos < 0 ) i_ypos = 0;
279
280     I_OUTPUTPICTURES = 0;
281
282     /* Initialize the output structure */
283     p_vout->output.i_chroma = p_vout->render.i_chroma;
284     p_vout->output.i_width  = p_vout->render.i_width;
285     p_vout->output.i_height = p_vout->render.i_height;
286     p_vout->output.i_aspect = p_vout->render.i_aspect;
287     var_Create( p_vout, "align", VLC_VAR_INTEGER );
288
289     fmt.i_width = fmt.i_visible_width = p_vout->render.i_width;
290     fmt.i_height = fmt.i_visible_height = p_vout->render.i_height;
291     fmt.i_x_offset = fmt.i_y_offset = 0;
292     fmt.i_chroma = p_vout->render.i_chroma;
293     fmt.i_aspect = p_vout->render.i_aspect;
294     fmt.i_sar_num = p_vout->render.i_aspect * fmt.i_height / fmt.i_width;
295     fmt.i_sar_den = VOUT_ASPECT_FACTOR;
296
297     w1 = p_vout->output.i_width / p_vout->p_sys->i_col;
298     w1 &= ~1;
299     h1 = w1 * VOUT_ASPECT_FACTOR / i_aspect&~1;
300     h1 &= ~1;
301  
302     h2 = p_vout->output.i_height / p_vout->p_sys->i_row&~1;
303     h2 &= ~1;
304     w2 = h2 * i_aspect / VOUT_ASPECT_FACTOR&~1;
305     w2 &= ~1;
306  
307     if ( h1 * p_vout->p_sys->i_row < p_vout->output.i_height )
308     {
309         unsigned int i_tmp;
310         i_target_width = w2;
311         i_target_height = h2;
312         i_vstart = 0;
313         i_vend = p_vout->output.i_height;
314         i_tmp = i_target_width * p_vout->p_sys->i_col;
315         while( i_tmp < p_vout->output.i_width ) i_tmp += p_vout->p_sys->i_col;
316         i_hstart = (( i_tmp - p_vout->output.i_width ) / 2)&~1;
317         i_hstart_rounded  = ( ( i_tmp - p_vout->output.i_width ) % 2 ) ||
318             ( ( ( i_tmp - p_vout->output.i_width ) / 2 ) & 1 );
319         i_hend = i_hstart + p_vout->output.i_width;
320     }
321     else
322     {
323         unsigned int i_tmp;
324         i_target_height = h1;
325         i_target_width = w1;
326         i_hstart = 0;
327         i_hend = p_vout->output.i_width;
328         i_tmp = i_target_height * p_vout->p_sys->i_row;
329         while( i_tmp < p_vout->output.i_height ) i_tmp += p_vout->p_sys->i_row;
330         i_vstart = ( ( i_tmp - p_vout->output.i_height ) / 2 ) & ~1;
331         i_vstart_rounded  = ( ( i_tmp - p_vout->output.i_height ) % 2 ) ||
332             ( ( ( i_tmp - p_vout->output.i_height ) / 2 ) & 1 );
333         i_vend = i_vstart + p_vout->output.i_height;
334     }
335     msg_Dbg( p_vout, "target resolution %dx%d", i_target_width, i_target_height );
336
337     /* Try to open the real video output */
338     msg_Dbg( p_vout, "spawning the real video outputs" );
339
340     p_vout->p_sys->i_vout = 0;
341     msg_Dbg( p_vout, "target window (%d,%d)-(%d,%d)", i_hstart,i_vstart,i_hend,i_vend );
342  
343
344     i_top = 0;
345     i_height = 0;
346     for( i_row = 0; i_row < p_vout->p_sys->i_row; i_row++ )
347     {
348         i_left = 0;
349         i_top += i_height;
350         for( i_col = 0; i_col < p_vout->p_sys->i_col; i_col++ )
351         {
352             i_align = 0;
353
354             if( i_col*i_target_width >= i_hstart &&
355                 (i_col+1)*i_target_width <= i_hend )
356             {
357                 i_width = i_target_width;
358             }
359             else if( ( i_col + 1 ) * i_target_width < i_hstart ||
360                      ( i_col * i_target_width ) > i_hend )
361             {
362                 i_width = 0;
363             }
364             else
365             {
366                 i_width = ( i_target_width - i_hstart % i_target_width );
367                 if( i_col >= ( p_vout->p_sys->i_col / 2 ) )
368                 {
369                     i_align |= VOUT_ALIGN_LEFT;
370                     i_width -= i_hstart_rounded ? 2: 0;
371                 }
372                 else
373                 {
374                     i_align |= VOUT_ALIGN_RIGHT;
375                 }
376             }
377  
378             if( i_row * i_target_height >= i_vstart &&
379                 ( i_row + 1 ) * i_target_height <= i_vend )
380             {
381                 i_height = i_target_height;
382             }
383             else if( ( i_row + 1 ) * i_target_height < i_vstart ||
384                      ( i_row * i_target_height ) > i_vend )
385             {
386                 i_height = 0;
387             }
388             else
389             {
390                 i_height = ( i_target_height -
391                              i_vstart%i_target_height );
392                 if(  i_row >= ( p_vout->p_sys->i_row / 2 ) )
393                 {
394                     i_align |= VOUT_ALIGN_TOP;
395                     i_height -= i_vstart_rounded ? 2: 0;
396                 }
397                 else
398                 {
399                     i_align |= VOUT_ALIGN_BOTTOM;
400                 }
401             }
402             if( i_height == 0 || i_width == 0 )
403             {
404                 p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].b_active = false;
405             }
406
407             p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].i_width = i_width;
408             p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].i_height = i_height;
409             p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].i_left = i_left;
410             p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].i_top = i_top;
411             i_left += i_width;
412
413             if( !p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].b_active )
414             {
415                 p_vout->p_sys->i_vout++;
416                 continue;
417             }
418             var_SetInteger( p_vout, "align", i_align );
419             var_SetInteger( p_vout, "video-x", i_left + i_xpos - i_width);
420             var_SetInteger( p_vout, "video-y", i_top + i_ypos );
421
422             fmt.i_width = fmt.i_visible_width = i_width;
423             fmt.i_height = fmt.i_visible_height = i_height;
424             fmt.i_aspect = i_aspect * i_target_height / i_height *
425                 i_width / i_target_width;
426
427             p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].p_vout =
428                 vout_Create( p_vout, &fmt );
429             if( !p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].p_vout )
430             {
431                 msg_Err( p_vout, "failed to get %ix%i vout threads",
432                                  p_vout->p_sys->i_col, p_vout->p_sys->i_row );
433                 RemoveAllVout( p_vout );
434                 return VLC_EGENERIC;
435             }
436             ADD_CALLBACKS(
437                 p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].p_vout,
438                 SendEvents );
439             p_vout->p_sys->i_vout++;
440         }
441     }
442
443     ALLOCATE_DIRECTBUFFERS( VOUT_MAX_PICTURES );
444
445     ADD_PARENT_CALLBACKS( SendEventsToChild );
446
447     return VLC_SUCCESS;
448 }
449
450 /*****************************************************************************
451  * End: terminate Wall video thread output method
452  *****************************************************************************/
453 static void End( vout_thread_t *p_vout )
454 {
455     int i_index;
456
457     /* Free the fake output buffers we allocated */
458     for( i_index = I_OUTPUTPICTURES ; i_index ; )
459     {
460         i_index--;
461         free( PP_OUTPUTPICTURE[ i_index ]->p_data_orig );
462     }
463 }
464
465 /*****************************************************************************
466  * Destroy: destroy Wall video thread output method
467  *****************************************************************************
468  * Terminate an output method created by WallCreateOutputMethod
469  *****************************************************************************/
470 static void Destroy( vlc_object_t *p_this )
471 {
472     vout_thread_t *p_vout = (vout_thread_t *)p_this;
473
474     RemoveAllVout( p_vout );
475
476     DEL_PARENT_CALLBACKS( SendEventsToChild );
477
478     free( p_vout->p_sys->pp_vout );
479     free( p_vout->p_sys );
480 }
481
482 /*****************************************************************************
483  * Render: displays previously rendered output
484  *****************************************************************************
485  * This function send the currently rendered image to Wall image, waits
486  * until it is displayed and switch the two rendering buffers, preparing next
487  * frame.
488  *****************************************************************************/
489 static void Render( vout_thread_t *p_vout, picture_t *p_pic )
490 {
491     picture_t *p_outpic = NULL;
492     int i_col, i_row, i_vout, i_plane;
493     int pi_left_skip[VOUT_MAX_PLANES], pi_top_skip[VOUT_MAX_PLANES];
494
495     i_vout = 0;
496
497     for( i_row = 0; i_row < p_vout->p_sys->i_row; i_row++ )
498     {
499         for( i_col = 0; i_col < p_vout->p_sys->i_col; i_col++ )
500         {
501             for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
502             {
503                 pi_left_skip[i_plane] = p_vout->p_sys->pp_vout[ i_vout ].i_left * p_pic->p[ i_plane ].i_pitch / p_vout->output.i_width;
504                 pi_top_skip[i_plane] = (p_vout->p_sys->pp_vout[ i_vout ].i_top * p_pic->p[ i_plane ].i_lines / p_vout->output.i_height)*p_pic->p[i_plane].i_pitch;
505             }
506
507             if( !p_vout->p_sys->pp_vout[ i_vout ].b_active )
508             {
509                 i_vout++;
510                 continue;
511             }
512
513             while( ( p_outpic =
514                 vout_CreatePicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
515                                     0, 0, 0 )
516                    ) == NULL )
517             {
518                 if( p_vout->b_die || p_vout->b_error )
519                 {
520                     vout_DestroyPicture(
521                         p_vout->p_sys->pp_vout[ i_vout ].p_vout, p_outpic );
522                     return;
523                 }
524
525                 msleep( VOUT_OUTMEM_SLEEP );
526             }
527
528             vout_DatePicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
529                               p_outpic, p_pic->date );
530             vout_LinkPicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
531                               p_outpic );
532
533             for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
534             {
535                 uint8_t *p_in, *p_in_end, *p_out;
536                 int i_in_pitch = p_pic->p[i_plane].i_pitch;
537                 int i_out_pitch = p_outpic->p[i_plane].i_pitch;
538                 int i_copy_pitch = p_outpic->p[i_plane].i_visible_pitch;
539
540                 p_in = p_pic->p[i_plane].p_pixels
541                         + pi_top_skip[i_plane] + pi_left_skip[i_plane];
542
543                 p_in_end = p_in + p_outpic->p[i_plane].i_visible_lines
544                                    * p_pic->p[i_plane].i_pitch;
545
546                 p_out = p_outpic->p[i_plane].p_pixels;
547
548                 while( p_in < p_in_end )
549                 {
550                     p_vout->p_libvlc->pf_memcpy( p_out, p_in, i_copy_pitch );
551                     p_in += i_in_pitch;
552                     p_out += i_out_pitch;
553                 }
554
555 //                pi_left_skip[i_plane] += i_copy_pitch;
556             }
557
558             vout_UnlinkPicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
559                                 p_outpic );
560             vout_DisplayPicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
561                                  p_outpic );
562
563             i_vout++;
564         }
565
566 /*         for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ ) */
567 /*         { */
568 /*             pi_top_skip[i_plane] += p_vout->p_sys->pp_vout[ i_vout ].i_height */
569 /*                                      * p_pic->p[i_plane].i_visible_lines */
570 /*                                      / p_vout->output.i_height */
571 /*                                      * p_pic->p[i_plane].i_pitch; */
572 /*         } */
573     }
574 }
575
576 /*****************************************************************************
577  * RemoveAllVout: destroy all the child video output threads
578  *****************************************************************************/
579 static void RemoveAllVout( vout_thread_t *p_vout )
580 {
581     while( p_vout->p_sys->i_vout )
582     {
583          --p_vout->p_sys->i_vout;
584          if( p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].b_active )
585          {
586              DEL_CALLBACKS(
587                  p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].p_vout,
588                  SendEvents );
589              vlc_object_detach(
590                  p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].p_vout );
591              vout_Destroy(
592                  p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].p_vout );
593          }
594     }
595 }
596
597 /*****************************************************************************
598  * SendEvents: forward mouse and keyboard events to the parent p_vout
599  *****************************************************************************/
600 static int SendEvents( vlc_object_t *p_this, char const *psz_var,
601                        vlc_value_t oldval, vlc_value_t newval, void *_p_vout )
602 {
603     VLC_UNUSED(oldval);
604     vout_thread_t *p_vout = (vout_thread_t *)_p_vout;
605     int i_vout;
606     vlc_value_t sentval = newval;
607
608     /* Find the video output index */
609     for( i_vout = 0; i_vout < p_vout->p_sys->i_vout; i_vout++ )
610     {
611         if( p_this == (vlc_object_t *)p_vout->p_sys->pp_vout[ i_vout ].p_vout )
612         {
613             break;
614         }
615     }
616
617     if( i_vout == p_vout->p_sys->i_vout )
618     {
619         return VLC_EGENERIC;
620     }
621
622     /* Translate the mouse coordinates */
623     if( !strcmp( psz_var, "mouse-x" ) )
624     {
625         sentval.i_int += p_vout->output.i_width
626                           * (i_vout % p_vout->p_sys->i_col)
627                           / p_vout->p_sys->i_col;
628     }
629     else if( !strcmp( psz_var, "mouse-y" ) )
630     {
631         sentval.i_int += p_vout->output.i_height
632                           * (i_vout / p_vout->p_sys->i_row)
633                           / p_vout->p_sys->i_row;
634     }
635
636     var_Set( p_vout, psz_var, sentval );
637
638     return VLC_SUCCESS;
639 }
640
641 /*****************************************************************************
642  * SendEventsToChild: forward events to the child/children vout
643  *****************************************************************************/
644 static int SendEventsToChild( vlc_object_t *p_this, char const *psz_var,
645                        vlc_value_t oldval, vlc_value_t newval, void *p_data )
646 {
647     VLC_UNUSED(p_data); VLC_UNUSED(oldval);
648     vout_thread_t *p_vout = (vout_thread_t *)p_this;
649     int i_row, i_col, i_vout = 0;
650
651     for( i_row = 0; i_row < p_vout->p_sys->i_row; i_row++ )
652     {
653         for( i_col = 0; i_col < p_vout->p_sys->i_col; i_col++ )
654         {
655             var_Set( p_vout->p_sys->pp_vout[ i_vout ].p_vout, psz_var, newval);
656             if( !strcmp( psz_var, "fullscreen" ) ) break;
657             i_vout++;
658         }
659     }
660
661     return VLC_SUCCESS;
662 }