]> git.sesse.net Git - vlc/blob - modules/video_filter/mosaic.c
Add options to give a specific channel order in mosaic
[vlc] / modules / video_filter / mosaic.c
1 /*****************************************************************************
2 * mosaic.c : Mosaic video plugin for vlc
3 *****************************************************************************
4 * Copyright (C) 2004-2005 VideoLAN
5 * $Id$
6 *
7 * Authors: Antoine Cellerier <dionoea@via.ecp.fr>
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., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
22 *****************************************************************************/
23
24 /*****************************************************************************
25 * Preamble
26 *****************************************************************************/
27 #include <stdlib.h>                                      /* malloc(), free() */
28 #include <string.h>
29 #include <math.h>
30
31 #include <vlc/vlc.h>
32 #include <vlc/vout.h>
33
34 #include "vlc_filter.h"
35 #include "vlc_input.h"
36
37 #include "vlc_image.h"
38
39 /*****************************************************************************
40 * Local prototypes
41 *****************************************************************************/
42
43 static int  CreateFilter    ( vlc_object_t * );
44 static void DestroyFilter   ( vlc_object_t * );
45
46 static subpicture_t *Filter( filter_t *, mtime_t );
47
48 static int MosaicCallback( vlc_object_t *, char const *, vlc_value_t,
49                             vlc_value_t, void * );
50
51 /*****************************************************************************
52 * filter_sys_t : filter desriptor
53 *****************************************************************************/
54
55 #include "../video_output/picture.h"
56
57 struct filter_sys_t
58 {
59
60     image_handler_t *p_image;
61     image_handler_t *p_image2;
62     picture_t *p_pic;
63
64     int i_pos; /* mosaic positioning method */
65     int i_ar; /* do we keep aspect ratio ? */
66     int i_width, i_height; /* mosaic height and width */
67     int i_cols, i_rows; /* mosaic rows and cols */
68     int i_xoffset, i_yoffset; /* top left corner offset */
69     int i_vborder, i_hborder; /* border width/height between miniatures */
70     int i_alpha; /* subfilter alpha blending */
71
72     char **ppsz_order; /* list of picture-id */
73     int i_order_length;
74
75 };
76
77 /*****************************************************************************
78 * Module descriptor
79 *****************************************************************************/
80
81 #define ALPHA_TEXT N_("Mosaic alpha blending (0 -> 255)")
82 #define ALPHA_LONGTEXT N_("Mosaic alpha blending (0 -> 255). default is 255")
83
84 #define HEIGHT_TEXT N_("Mosaic height in pixels")
85 #define WIDTH_TEXT N_("Mosaic width in pixels")
86 #define XOFFSET_TEXT N_("Mosaic top left corner x coordinate")
87 #define YOFFSET_TEXT N_("Mosaic top left corner y coordinate")
88 #define VBORDER_TEXT N_("Mosaic vertical border width in pixels")
89 #define HBORDER_TEXT N_("Mosaic horizontal border width in pixels")
90
91 #define POS_TEXT N_("Mosaic positioning method")
92 #define POS_LONGTEXT N_("Mosaic positioning method. auto : automatically chose the best number of rows and columns. fixed : used the user defined number of rows and columns.")
93 #define ROWS_TEXT N_("Mosaic number of rows")
94 #define COLS_TEXT N_("Mosaic number of columns")
95 #define AR_TEXT N_("Keep aspect ratio when resizing")
96
97 #define ORDER_TEXT N_("Order as a comma separated list of picture-id(s)")
98
99 static int pi_pos_values[] = { 0, 1 };
100 static char * ppsz_pos_descriptions[] =
101 { N_("auto"), N_("fixed") };
102
103
104 vlc_module_begin();
105     set_description( _("Mosaic video sub filter") );
106     set_shortname( N_("Mosaic") );
107     set_capability( "sub filter", 0 );
108     set_category( CAT_VIDEO );
109     set_subcategory( SUBCAT_VIDEO_SUBPIC );
110     set_callbacks( CreateFilter, DestroyFilter );
111
112     add_integer( "mosaic-alpha", 255, NULL, ALPHA_TEXT, ALPHA_LONGTEXT, VLC_FALSE );
113     add_integer( "mosaic-height", 100, NULL, HEIGHT_TEXT, HEIGHT_TEXT, VLC_FALSE );
114     add_integer( "mosaic-width", 100, NULL, WIDTH_TEXT, WIDTH_TEXT, VLC_FALSE );
115     add_integer( "mosaic-xoffset", 0, NULL, XOFFSET_TEXT, XOFFSET_TEXT, VLC_TRUE );
116     add_integer( "mosaic-yoffset", 0, NULL, YOFFSET_TEXT, YOFFSET_TEXT, VLC_TRUE );
117     add_integer( "mosaic-vborder", 0, NULL, VBORDER_TEXT, VBORDER_TEXT, VLC_TRUE );
118     add_integer( "mosaic-hborder", 0, NULL, HBORDER_TEXT, HBORDER_TEXT, VLC_TRUE );
119
120     add_integer( "mosaic-position", 0, NULL, POS_TEXT, POS_LONGTEXT, VLC_FALSE );
121         change_integer_list( pi_pos_values, ppsz_pos_descriptions, 0 );
122     add_integer( "mosaic-rows", 2, NULL, ROWS_TEXT, ROWS_TEXT, VLC_FALSE );
123     add_integer( "mosaic-cols", 2, NULL, COLS_TEXT, COLS_TEXT, VLC_FALSE );
124     add_bool( "mosaic-keep-aspect-ratio", 0, NULL, AR_TEXT, AR_TEXT, VLC_FALSE );
125     add_string( "mosaic-order", "", NULL, ORDER_TEXT, ORDER_TEXT, VLC_FALSE );
126 vlc_module_end();
127
128
129 /*****************************************************************************
130 * CreateFiler: allocates mosaic video filter
131 *****************************************************************************/
132
133 static int CreateFilter( vlc_object_t *p_this )
134 {
135     filter_t *p_filter = (filter_t *)p_this;
136     filter_sys_t *p_sys;
137     char *psz_order;
138     int i_index;
139
140     /* Allocate structure */
141     p_sys = p_filter->p_sys = malloc( sizeof( filter_sys_t ) );
142     if( p_sys == NULL )
143     {
144         msg_Err( p_filter, "out of memory" );
145         return VLC_ENOMEM;
146     }
147     p_sys->p_image = image_HandlerCreate( p_filter );
148     p_sys->p_image2 = image_HandlerCreate( p_filter );
149
150     p_filter->pf_sub_filter = Filter;
151     p_sys->p_pic = NULL;
152
153     p_sys->i_width = __MAX( 0, var_CreateGetInteger( p_filter->p_libvlc, "mosaic-width" ) );
154     p_sys->i_height = __MAX( 0, var_CreateGetInteger( p_filter->p_libvlc, "mosaic-height" ) );
155
156     p_sys->i_xoffset = __MAX( 0, var_CreateGetInteger( p_filter->p_libvlc, "mosaic-xoffset" ) );
157     p_sys->i_yoffset = __MAX( 0, var_CreateGetInteger( p_filter->p_libvlc, "mosaic-yoffset" ) );
158
159     p_sys->i_vborder = __MAX( 0, var_CreateGetInteger( p_filter->p_libvlc, "mosaic-vborder" ) );
160     p_sys->i_hborder = __MAX( 0, var_CreateGetInteger( p_filter->p_libvlc, "mosaic-hborder" ) );
161
162     p_sys->i_rows = __MAX( 1, var_CreateGetInteger( p_filter->p_libvlc, "mosaic-rows") );
163     p_sys->i_cols = __MAX( 1, var_CreateGetInteger( p_filter->p_libvlc, "mosaic-cols") );
164
165     p_sys->i_alpha = var_CreateGetInteger( p_filter->p_libvlc, "mosaic-alpha" );
166     p_sys->i_alpha = __MIN( 255, __MAX( 0, p_sys->i_alpha ) );
167
168     p_sys->i_pos = var_CreateGetInteger( p_filter->p_libvlc, "mosaic-position" );
169     if( p_sys->i_pos > 1 || p_sys->i_pos < 0 ) p_sys->i_pos = 0;
170
171     p_sys->i_ar = var_CreateGetInteger( p_filter->p_libvlc, "mosaic-keep-aspect-ratio" );
172
173     p_sys->i_order_length = 0;
174     p_sys->ppsz_order = NULL;
175     psz_order = var_CreateGetString( p_filter->p_libvlc, "mosaic-order" );
176
177     fprintf( stderr, "psz_order : %s (%p)\n", psz_order, psz_order );
178     if( psz_order[0] != 0 )
179     {
180         i_index = 0;
181         char* psz_end=NULL;
182         do
183         { 
184             psz_end = strchr( psz_order, ',' );
185             i_index++;
186             p_sys->ppsz_order = realloc( p_sys->ppsz_order,
187                                          i_index * sizeof(char *) );
188             p_sys->ppsz_order[i_index - 1] = strndup( psz_order,
189                                            psz_end - psz_order );
190             psz_order = psz_end+1;
191         } while( NULL !=  psz_end );
192         p_sys->i_order_length = i_index;
193     }
194
195     for( i_index = 0; i_index < p_sys->i_order_length; i_index ++ )
196     {
197         fprintf( stderr, "%d/%d : %s\n", i_index, p_sys->i_order_length, p_sys->ppsz_order[i_index] );
198     }
199
200     var_AddCallback( p_filter->p_libvlc, "mosaic-alpha",
201                      MosaicCallback, p_sys );
202     var_AddCallback( p_filter->p_libvlc, "mosaic-height",
203                      MosaicCallback, p_sys );
204     var_AddCallback( p_filter->p_libvlc, "mosaic-width",
205                      MosaicCallback, p_sys );
206     var_AddCallback( p_filter->p_libvlc, "mosaic-xoffset",
207                      MosaicCallback, p_sys );
208     var_AddCallback( p_filter->p_libvlc, "mosaic-yoffset",
209                      MosaicCallback, p_sys );
210     var_AddCallback( p_filter->p_libvlc, "mosaic-vborder",
211                      MosaicCallback, p_sys );
212     var_AddCallback( p_filter->p_libvlc, "mosaic-hborder",
213                      MosaicCallback, p_sys );
214     var_AddCallback( p_filter->p_libvlc, "mosaic-position",
215                      MosaicCallback, p_sys );
216     var_AddCallback( p_filter->p_libvlc, "mosaic-rows",
217                      MosaicCallback, p_sys );
218     var_AddCallback( p_filter->p_libvlc, "mosaic-cols",
219                      MosaicCallback, p_sys );
220     var_AddCallback( p_filter->p_libvlc, "mosaic-keep-aspect-ratio",
221                      MosaicCallback, p_sys );
222
223     return VLC_SUCCESS;
224 }
225
226 /*****************************************************************************
227 * DestroyFilter: destroy mosaic video filter
228 *****************************************************************************/
229
230 static void DestroyFilter( vlc_object_t *p_this )
231 {
232     filter_t *p_filter = (filter_t*)p_this;
233     filter_sys_t *p_sys = p_filter->p_sys;
234
235     image_HandlerDelete( p_sys->p_image );
236     image_HandlerDelete( p_sys->p_image2 );
237
238     var_Destroy( p_filter->p_libvlc, "mosaic-alpha" );
239     var_Destroy( p_filter->p_libvlc, "mosaic-height" );
240     var_Destroy( p_filter->p_libvlc, "mosaic-width" );
241     var_Destroy( p_filter->p_libvlc, "mosaic-xoffset" );
242     var_Destroy( p_filter->p_libvlc, "mosaic-yoffset" );
243     var_Destroy( p_filter->p_libvlc, "mosaic-vborder" );
244     var_Destroy( p_filter->p_libvlc, "mosaic-hborder" );
245     var_Destroy( p_filter->p_libvlc, "mosaic-position" );
246     var_Destroy( p_filter->p_libvlc, "mosaic-rows" );
247     var_Destroy( p_filter->p_libvlc, "mosaic-cols" );
248     var_Destroy( p_filter->p_libvlc, "mosaic-keep-aspect-ratio" );
249     if( p_sys->p_pic ) p_sys->p_pic->pf_release( p_sys->p_pic );
250     free( p_sys );
251 }
252
253 /*****************************************************************************
254 * Filter
255 *****************************************************************************/
256
257 static subpicture_t *Filter( filter_t *p_filter, mtime_t date )
258 {
259
260     filter_sys_t *p_sys = p_filter->p_sys;
261     subpicture_t *p_spu;
262
263     libvlc_t *p_libvlc = p_filter->p_libvlc;
264     vlc_value_t val;
265     int i_index, i_real_index, i_row, i_col;
266     int i_greatest_real_index_used = p_sys->i_order_length - 1;
267
268     subpicture_region_t *p_region;
269     subpicture_region_t *p_region_prev = NULL;
270
271     struct picture_vout_t *p_picture_vout;
272
273     if( var_Get( p_libvlc, "p_picture_vout", &val ) )
274     {
275         return NULL;
276     }
277
278     p_picture_vout = val.p_address;
279
280     /* Allocate the subpicture internal data. */
281     p_spu = p_filter->pf_sub_buffer_new( p_filter );
282     if( !p_spu )
283     {
284         return NULL;
285     }
286
287     /* Initialize subpicture */
288     p_spu->i_channel = 0;
289     p_spu->i_start  = date;
290     p_spu->i_stop = 0;
291     p_spu->b_ephemer = VLC_TRUE;
292     p_spu->i_alpha = p_sys->i_alpha;
293
294     vlc_mutex_lock( &p_picture_vout->lock );
295
296     if( p_sys->i_pos == 0 ) /* use automatic positioning */
297     {
298         int i_numpics = 0;
299         for( i_index = 0 ;
300              i_index < p_picture_vout->i_picture_num ;
301              i_index ++ )
302         {
303             if( p_picture_vout->p_pic[i_index].i_status
304                            == PICTURE_VOUT_E_OCCUPIED ) {
305                 i_numpics ++;
306             }
307         }
308         p_sys->i_rows = ((int)ceil(sqrt( (float)i_numpics )));
309         p_sys->i_cols = ( i_numpics%p_sys->i_rows == 0 ?
310                             i_numpics/p_sys->i_rows :
311                             i_numpics/p_sys->i_rows + 1 );
312     }
313
314     i_real_index = 0;
315
316     for( i_index = 0 ; i_index < p_picture_vout->i_picture_num ; i_index ++ )
317     {
318
319         video_format_t fmt_in = {0}, fmt_middle = {0}, fmt_out = {0};
320
321         picture_t *p_converted, *p_middle;
322
323         if(  p_picture_vout->p_pic[i_index].p_picture == NULL )
324         {
325             break;
326         }
327
328         if(  p_picture_vout->p_pic[i_index].i_status
329                == PICTURE_VOUT_E_AVAILABLE )
330         {
331             msg_Dbg( p_filter, "Picture Vout Element is empty");
332             break;
333         }
334         if( p_sys->i_order_length == 0 )
335             i_real_index ++;
336         else
337         {
338             int i;
339             for( i =0; i <= p_sys->i_order_length; i++ )
340             {
341                 if( i == p_sys->i_order_length ) break;
342                 if( strcmp( p_picture_vout->p_pic[i_index].psz_id,
343                     p_sys->ppsz_order[ i ] ) == 0 )
344                 {
345                     i_real_index = i;
346                     break;
347                 }
348             }
349             if( i == p_sys->i_order_length )
350                 i_real_index = ++i_greatest_real_index_used;
351         }
352         i_row = ( i_real_index / p_sys->i_cols ) % p_sys->i_rows ;
353         i_col = i_real_index % p_sys->i_cols ;
354
355
356
357         /* Convert the images */
358 /*        fprintf (stderr, "Input image %ix%i %4.4s\n",
359                   p_picture_vout->p_pic[i_index].p_picture->format.i_width,
360                   p_picture_vout->p_pic[i_index].p_picture->format.i_height,
361                   (char *)&p_picture_vout->p_pic[i_index].p_picture->format.i_chroma );*/
362
363         fmt_in.i_chroma = p_picture_vout->p_pic[i_index].
364                                                 p_picture->format.i_chroma;
365         fmt_in.i_height = p_picture_vout->p_pic[i_index].
366                                                 p_picture->format.i_height;
367         fmt_in.i_width = p_picture_vout->p_pic[i_index].
368                                                 p_picture->format.i_width;
369
370
371         fmt_out.i_chroma = VLC_FOURCC('Y','U','V','A');
372         fmt_out.i_width = fmt_in.i_width *
373             ( ( p_sys->i_width - ( p_sys->i_cols - 1 ) * p_sys->i_vborder )
374               / p_sys->i_cols ) / fmt_in.i_width;
375         fmt_out.i_height = fmt_in.i_height *
376             ( ( p_sys->i_height - ( p_sys->i_rows - 1 ) * p_sys->i_hborder )
377               / p_sys->i_rows ) / fmt_in.i_height;
378         if( p_sys->i_ar ) /* keep aspect ratio */
379         {
380             if( (float)fmt_out.i_width/(float)fmt_out.i_height
381                 > (float)fmt_in.i_width/(float)fmt_in.i_height )
382             {
383                 fmt_out.i_width = ( fmt_out.i_height * fmt_in.i_width ) / fmt_in.i_height ;
384             } else {
385                 fmt_out.i_height = ( fmt_out.i_width * fmt_in.i_height ) / fmt_in.i_width ;
386             }
387          }
388
389         fmt_out.i_visible_width = fmt_out.i_width;
390         fmt_out.i_visible_height = fmt_out.i_height;
391
392         fmt_middle.i_chroma = fmt_in.i_chroma;
393         fmt_middle.i_visible_width = fmt_middle.i_width = fmt_out.i_width;
394         fmt_middle.i_visible_height = fmt_middle.i_height = fmt_out.i_height;
395
396         p_middle = image_Convert( p_sys->p_image,
397             p_picture_vout->p_pic[i_index].p_picture, &fmt_in, &fmt_middle );
398         if( !p_middle )
399         {
400             msg_Err( p_filter, "image resizing failed" );
401             p_filter->pf_sub_buffer_del( p_filter, p_spu );
402             vlc_mutex_unlock( &p_picture_vout->lock );
403             return NULL;
404         }
405
406         p_converted = image_Convert( p_sys->p_image2,
407                  p_middle, &fmt_middle, &fmt_out );
408         if( !p_converted )
409         {
410             msg_Err( p_filter, "image chroma convertion failed" );
411             p_filter->pf_sub_buffer_del( p_filter, p_spu );
412             vlc_mutex_unlock( &p_picture_vout->lock );
413             return NULL;
414         }
415
416 /*        fprintf( stderr, "Converted %ix%i %4.4s\n", p_converted->format.i_width, p_converted->format.i_height, (char *)&p_converted->format.i_chroma);*/
417
418
419         p_region = p_spu->pf_create_region( VLC_OBJECT(p_filter), &fmt_out);
420         if( !p_region )
421         {
422             msg_Err( p_filter, "cannot allocate SPU region" );
423             p_filter->pf_sub_buffer_del( p_filter, p_spu );
424             vlc_mutex_unlock( &p_picture_vout->lock );
425             return NULL;
426         }
427
428         if( p_sys->i_ar ) /* keep aspect ratio */
429         {
430             /* center the video in the dedicated rectangle */
431             p_region->i_x = p_sys->i_xoffset
432                             + i_col * ( p_sys->i_width / p_sys->i_cols )
433                             + ( i_col * p_sys->i_vborder ) / p_sys->i_cols
434                         + ( fmt_in.i_width *
435             ( ( p_sys->i_width - ( p_sys->i_cols - 1 ) * p_sys->i_vborder )
436               / p_sys->i_cols ) / fmt_in.i_width - fmt_out.i_width ) / 2;
437             p_region->i_y = p_sys->i_yoffset
438                         + i_row * ( p_sys->i_height / p_sys->i_rows )
439                         + ( i_row * p_sys->i_hborder ) / p_sys->i_rows
440                         + ( fmt_in.i_height *
441             ( ( p_sys->i_height - ( p_sys->i_rows - 1 ) * p_sys->i_hborder )
442               / p_sys->i_rows ) / fmt_in.i_height - fmt_out.i_height ) / 2;
443         } else {
444             /* we don't have to center the video since it takes the
445             whole rectangle area */
446             p_region->i_x = p_sys->i_xoffset
447                             + i_col * ( p_sys->i_width / p_sys->i_cols )
448                             + ( i_col * p_sys->i_vborder ) / p_sys->i_cols;
449             p_region->i_y = p_sys->i_yoffset
450                         + i_row * ( p_sys->i_height / p_sys->i_rows )
451                         + ( i_row * p_sys->i_hborder ) / p_sys->i_rows;
452         }
453
454         if( p_region_prev == NULL ){
455             p_spu->p_region = p_region;
456         } else {
457             p_region_prev->p_next = p_region;
458         }
459
460         p_region_prev = p_region;
461
462         vout_CopyPicture( p_filter, &p_region->picture, p_converted );
463
464         p_middle->pf_release( p_middle );
465         p_converted->pf_release( p_converted );
466     }
467
468     vlc_mutex_unlock( &p_picture_vout->lock );
469
470     return p_spu;
471 }
472
473 /*****************************************************************************
474 * Callback to update params on the fly
475 *****************************************************************************/
476
477 static int MosaicCallback( vlc_object_t *p_this, char const *psz_var,
478                             vlc_value_t oldval, vlc_value_t newval,
479                             void *p_data )
480 {
481     filter_sys_t *p_sys = (filter_sys_t *) p_data;
482     fprintf( stderr, "Callback" );
483     if( !strcmp( psz_var, "mosaic-alpha" ) )
484     {
485         msg_Dbg( p_this, "Changing alpha from %d/255 to %d/255",
486                          p_sys->i_alpha, newval.i_int);
487         p_sys->i_alpha = __MIN( __MAX( newval.i_int, 0 ), 255 );
488     }
489     else if( !strcmp( psz_var, "mosaic-height" ) )
490     {
491         msg_Dbg( p_this, "Changing height from %dpx to %dpx",
492                           p_sys->i_height, newval.i_int );
493         p_sys->i_height = __MAX( newval.i_int, 0 );
494     }
495     else if( !strcmp( psz_var, "mosaic-width" ) )
496     {
497         msg_Dbg( p_this, "Changing width from %dpx to %dpx",
498                          p_sys->i_width, newval.i_int );
499         p_sys->i_width = __MAX( newval.i_int, 0 );
500     }
501     else if( !strcmp( psz_var, "mosaic-xoffset" ) )
502     {
503         msg_Dbg( p_this, "Changing x offset from %dpx to %dpx",
504                          p_sys->i_xoffset, newval.i_int );
505         p_sys->i_xoffset = __MAX( newval.i_int, 0 );
506     }
507     else if( !strcmp( psz_var, "mosaic-yoffset" ) )
508     {
509         msg_Dbg( p_this, "Changing y offset from %dpx to %dpx",
510                          p_sys->i_yoffset, newval.i_int );
511         p_sys->i_yoffset = __MAX( newval.i_int, 0 );
512     }
513     else if( !strcmp( psz_var, "mosaic-vborder" ) )
514     {
515         msg_Dbg( p_this, "Changing vertical border from %dpx to %dpx",
516                          p_sys->i_vborder, newval.i_int );
517         p_sys->i_vborder = __MAX( newval.i_int, 0 );
518     }
519     else if( !strcmp( psz_var, "mosaic-hborder" ) )
520     {
521         msg_Dbg( p_this, "Changing horizontal border from %dpx to %dpx",
522                          p_sys->i_vborder, newval.i_int );
523         p_sys->i_hborder = __MAX( newval.i_int, 0 );
524     }
525     else if( !strcmp( psz_var, "mosaic-position" ) )
526     {
527         if( newval.i_int > 1 || newval.i_int < 0 )
528         {
529             msg_Err( p_this, "Position is either 0 (auto) or 1 (fixed)" );
530         }
531         else
532         {
533             msg_Dbg( p_this, "Changing position method from %d (%s) to %d (%s)",
534                              p_sys->i_pos, ppsz_pos_descriptions[p_sys->i_pos],
535                              newval.i_int, ppsz_pos_descriptions[newval.i_int]);
536             p_sys->i_pos = newval.i_int;
537         }
538     }
539     else if( !strcmp( psz_var, "mosaic-rows" ) )
540     {
541         msg_Dbg( p_this, "Changing number of rows from %d to %d",
542                          p_sys->i_rows, newval.i_int );
543         p_sys->i_rows = __MAX( newval.i_int, 1 );
544     }
545     else if( !strcmp( psz_var, "mosaic-cols" ) )
546     {
547         msg_Dbg( p_this, "Changing number of columns from %d to %d",
548                          p_sys->i_cols, newval.i_int );
549         p_sys->i_cols = __MAX( newval.i_int, 1 );
550     }
551     else if( !strcmp( psz_var, "mosaic-keep-aspect-ratio" ) )
552     {
553         if( newval.i_int )
554         {
555             msg_Dbg( p_this, "Keep aspect ratio" );
556             p_sys->i_ar = 1;
557         }
558         else
559         {
560             msg_Dbg( p_this, "Don't keep aspect ratio" );
561             p_sys->i_ar = 0;
562         }
563     }
564     return VLC_SUCCESS;
565 }