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