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