]> git.sesse.net Git - vlc/blob - modules/video_filter/mosaic.c
remove debug messages, correct automatic positioning when an mosaic-order
[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     if( psz_order[0] != 0 )
178     {
179         i_index = 0;
180         char* psz_end=NULL;
181         do
182         { 
183             psz_end = strchr( psz_order, ',' );
184             i_index++;
185             p_sys->ppsz_order = realloc( p_sys->ppsz_order,
186                                          i_index * sizeof(char *) );
187             p_sys->ppsz_order[i_index - 1] = strndup( psz_order,
188                                            psz_end - psz_order );
189             psz_order = psz_end+1;
190         } while( NULL !=  psz_end );
191         p_sys->i_order_length = i_index;
192     }
193
194     var_AddCallback( p_filter->p_libvlc, "mosaic-alpha",
195                      MosaicCallback, p_sys );
196     var_AddCallback( p_filter->p_libvlc, "mosaic-height",
197                      MosaicCallback, p_sys );
198     var_AddCallback( p_filter->p_libvlc, "mosaic-width",
199                      MosaicCallback, p_sys );
200     var_AddCallback( p_filter->p_libvlc, "mosaic-xoffset",
201                      MosaicCallback, p_sys );
202     var_AddCallback( p_filter->p_libvlc, "mosaic-yoffset",
203                      MosaicCallback, p_sys );
204     var_AddCallback( p_filter->p_libvlc, "mosaic-vborder",
205                      MosaicCallback, p_sys );
206     var_AddCallback( p_filter->p_libvlc, "mosaic-hborder",
207                      MosaicCallback, p_sys );
208     var_AddCallback( p_filter->p_libvlc, "mosaic-position",
209                      MosaicCallback, p_sys );
210     var_AddCallback( p_filter->p_libvlc, "mosaic-rows",
211                      MosaicCallback, p_sys );
212     var_AddCallback( p_filter->p_libvlc, "mosaic-cols",
213                      MosaicCallback, p_sys );
214     var_AddCallback( p_filter->p_libvlc, "mosaic-keep-aspect-ratio",
215                      MosaicCallback, p_sys );
216
217     return VLC_SUCCESS;
218 }
219
220 /*****************************************************************************
221 * DestroyFilter: destroy mosaic video filter
222 *****************************************************************************/
223
224 static void DestroyFilter( vlc_object_t *p_this )
225 {
226     filter_t *p_filter = (filter_t*)p_this;
227     filter_sys_t *p_sys = p_filter->p_sys;
228     int i_index;
229
230     image_HandlerDelete( p_sys->p_image );
231     image_HandlerDelete( p_sys->p_image2 );
232
233     if( p_sys->i_order_length )
234     {
235         for( i_index = 0; i_index < p_sys->i_order_length; i_index++ )
236         {
237             free( p_sys->ppsz_order[i_index] );
238         }
239         free( p_sys->ppsz_order );
240     }
241
242     var_Destroy( p_filter->p_libvlc, "mosaic-alpha" );
243     var_Destroy( p_filter->p_libvlc, "mosaic-height" );
244     var_Destroy( p_filter->p_libvlc, "mosaic-width" );
245     var_Destroy( p_filter->p_libvlc, "mosaic-xoffset" );
246     var_Destroy( p_filter->p_libvlc, "mosaic-yoffset" );
247     var_Destroy( p_filter->p_libvlc, "mosaic-vborder" );
248     var_Destroy( p_filter->p_libvlc, "mosaic-hborder" );
249     var_Destroy( p_filter->p_libvlc, "mosaic-position" );
250     var_Destroy( p_filter->p_libvlc, "mosaic-rows" );
251     var_Destroy( p_filter->p_libvlc, "mosaic-cols" );
252     var_Destroy( p_filter->p_libvlc, "mosaic-keep-aspect-ratio" );
253     if( p_sys->p_pic ) p_sys->p_pic->pf_release( p_sys->p_pic );
254     free( p_sys );
255 }
256
257 /*****************************************************************************
258 * Filter
259 *****************************************************************************/
260
261 static subpicture_t *Filter( filter_t *p_filter, mtime_t date )
262 {
263
264     filter_sys_t *p_sys = p_filter->p_sys;
265     subpicture_t *p_spu;
266
267     libvlc_t *p_libvlc = p_filter->p_libvlc;
268     vlc_value_t val;
269     int i_index, i_real_index, i_row, i_col;
270     int i_greatest_real_index_used = p_sys->i_order_length - 1;
271
272     subpicture_region_t *p_region;
273     subpicture_region_t *p_region_prev = NULL;
274
275     struct picture_vout_t *p_picture_vout;
276
277     if( var_Get( p_libvlc, "p_picture_vout", &val ) )
278     {
279         return NULL;
280     }
281
282     p_picture_vout = val.p_address;
283
284     /* Allocate the subpicture internal data. */
285     p_spu = p_filter->pf_sub_buffer_new( p_filter );
286     if( !p_spu )
287     {
288         return NULL;
289     }
290
291     /* Initialize subpicture */
292     p_spu->i_channel = 0;
293     p_spu->i_start  = date;
294     p_spu->i_stop = 0;
295     p_spu->b_ephemer = VLC_TRUE;
296     p_spu->i_alpha = p_sys->i_alpha;
297
298     vlc_mutex_lock( &p_picture_vout->lock );
299
300     if( p_sys->i_pos == 0 ) /* use automatic positioning */
301     {
302         int i_numpics = p_sys->i_order_length; /* keep slots and all */
303         for( i_index = 0 ;
304              i_index < p_picture_vout->i_picture_num ;
305              i_index ++ )
306         {
307             if( p_picture_vout->p_pic[i_index].i_status
308                            == PICTURE_VOUT_E_OCCUPIED ) {
309                 i_numpics ++;
310                 if( p_sys->i_order_length
311                     && p_picture_vout->p_pic[i_index].psz_id != 0 ){
312                 /* we also want to leave slots for images given in mosaic-order
313                 that are not available in p_vout_picture */
314                     int i;
315                     for( i = 0; i < p_sys->i_order_length ; i++ )
316                     {
317                         if( ! strcmp( p_sys->ppsz_order[i],
318                                     p_picture_vout->p_pic[i_index].psz_id ) )
319                         {
320                             i_numpics --;
321                             break;
322                         }
323                     }
324
325                 }
326             }
327         }
328         p_sys->i_rows = ((int)ceil(sqrt( (float)i_numpics )));
329         p_sys->i_cols = ( i_numpics%p_sys->i_rows == 0 ?
330                             i_numpics/p_sys->i_rows :
331                             i_numpics/p_sys->i_rows + 1 );
332     }
333
334     i_real_index = 0;
335
336     for( i_index = 0 ; i_index < p_picture_vout->i_picture_num ; i_index ++ )
337     {
338
339         video_format_t fmt_in = {0}, fmt_middle = {0}, fmt_out = {0};
340
341         picture_t *p_converted, *p_middle;
342
343         if(  p_picture_vout->p_pic[i_index].p_picture == NULL )
344         {
345             break;
346         }
347
348         if(  p_picture_vout->p_pic[i_index].i_status
349                == PICTURE_VOUT_E_AVAILABLE )
350         {
351             msg_Dbg( p_filter, "Picture Vout Element is empty");
352             break;
353         }
354         if( p_sys->i_order_length == 0 )
355             i_real_index ++;
356         else
357         {
358             int i;
359             for( i =0; i <= p_sys->i_order_length; i++ )
360             {
361                 if( i == p_sys->i_order_length ) break;
362                 if( strcmp( p_picture_vout->p_pic[i_index].psz_id,
363                     p_sys->ppsz_order[ i ] ) == 0 )
364                 {
365                     i_real_index = i;
366                     break;
367                 }
368             }
369             if( i == p_sys->i_order_length )
370                 i_real_index = ++i_greatest_real_index_used;
371         }
372         i_row = ( i_real_index / p_sys->i_cols ) % p_sys->i_rows ;
373         i_col = i_real_index % p_sys->i_cols ;
374
375         /* Convert the images */
376 /*        fprintf (stderr, "Input image %ix%i %4.4s\n",
377                   p_picture_vout->p_pic[i_index].p_picture->format.i_width,
378                   p_picture_vout->p_pic[i_index].p_picture->format.i_height,
379                   (char *)&p_picture_vout->p_pic[i_index].p_picture->format.i_chroma );*/
380
381         fmt_in.i_chroma = p_picture_vout->p_pic[i_index].
382                                                 p_picture->format.i_chroma;
383         fmt_in.i_height = p_picture_vout->p_pic[i_index].
384                                                 p_picture->format.i_height;
385         fmt_in.i_width = p_picture_vout->p_pic[i_index].
386                                                 p_picture->format.i_width;
387
388
389         fmt_out.i_chroma = VLC_FOURCC('Y','U','V','A');
390         fmt_out.i_width = fmt_in.i_width *
391             ( ( p_sys->i_width - ( p_sys->i_cols - 1 ) * p_sys->i_vborder )
392               / p_sys->i_cols ) / fmt_in.i_width;
393         fmt_out.i_height = fmt_in.i_height *
394             ( ( p_sys->i_height - ( p_sys->i_rows - 1 ) * p_sys->i_hborder )
395               / p_sys->i_rows ) / fmt_in.i_height;
396         if( p_sys->i_ar ) /* keep aspect ratio */
397         {
398             if( (float)fmt_out.i_width/(float)fmt_out.i_height
399                 > (float)fmt_in.i_width/(float)fmt_in.i_height )
400             {
401                 fmt_out.i_width = ( fmt_out.i_height * fmt_in.i_width ) / fmt_in.i_height ;
402             } else {
403                 fmt_out.i_height = ( fmt_out.i_width * fmt_in.i_height ) / fmt_in.i_width ;
404             }
405          }
406
407         fmt_out.i_visible_width = fmt_out.i_width;
408         fmt_out.i_visible_height = fmt_out.i_height;
409
410         fmt_middle.i_chroma = fmt_in.i_chroma;
411         fmt_middle.i_visible_width = fmt_middle.i_width = fmt_out.i_width;
412         fmt_middle.i_visible_height = fmt_middle.i_height = fmt_out.i_height;
413
414         p_middle = image_Convert( p_sys->p_image,
415             p_picture_vout->p_pic[i_index].p_picture, &fmt_in, &fmt_middle );
416         if( !p_middle )
417         {
418             msg_Err( p_filter, "image resizing failed" );
419             p_filter->pf_sub_buffer_del( p_filter, p_spu );
420             vlc_mutex_unlock( &p_picture_vout->lock );
421             return NULL;
422         }
423
424         p_converted = image_Convert( p_sys->p_image2,
425                  p_middle, &fmt_middle, &fmt_out );
426         if( !p_converted )
427         {
428             msg_Err( p_filter, "image chroma convertion failed" );
429             p_filter->pf_sub_buffer_del( p_filter, p_spu );
430             vlc_mutex_unlock( &p_picture_vout->lock );
431             return NULL;
432         }
433
434 /*        fprintf( stderr, "Converted %ix%i %4.4s\n", p_converted->format.i_width, p_converted->format.i_height, (char *)&p_converted->format.i_chroma);*/
435
436
437         p_region = p_spu->pf_create_region( VLC_OBJECT(p_filter), &fmt_out);
438         if( !p_region )
439         {
440             msg_Err( p_filter, "cannot allocate SPU region" );
441             p_filter->pf_sub_buffer_del( p_filter, p_spu );
442             vlc_mutex_unlock( &p_picture_vout->lock );
443             return NULL;
444         }
445
446         if( p_sys->i_ar ) /* keep aspect ratio */
447         {
448             /* center the video in the dedicated rectangle */
449             p_region->i_x = p_sys->i_xoffset
450                             + i_col * ( p_sys->i_width / p_sys->i_cols )
451                             + ( i_col * p_sys->i_vborder ) / p_sys->i_cols
452                         + ( fmt_in.i_width *
453             ( ( p_sys->i_width - ( p_sys->i_cols - 1 ) * p_sys->i_vborder )
454               / p_sys->i_cols ) / fmt_in.i_width - fmt_out.i_width ) / 2;
455             p_region->i_y = p_sys->i_yoffset
456                         + i_row * ( p_sys->i_height / p_sys->i_rows )
457                         + ( i_row * p_sys->i_hborder ) / p_sys->i_rows
458                         + ( fmt_in.i_height *
459             ( ( p_sys->i_height - ( p_sys->i_rows - 1 ) * p_sys->i_hborder )
460               / p_sys->i_rows ) / fmt_in.i_height - fmt_out.i_height ) / 2;
461         } else {
462             /* we don't have to center the video since it takes the
463             whole rectangle area */
464             p_region->i_x = p_sys->i_xoffset
465                             + i_col * ( p_sys->i_width / p_sys->i_cols )
466                             + ( i_col * p_sys->i_vborder ) / p_sys->i_cols;
467             p_region->i_y = p_sys->i_yoffset
468                         + i_row * ( p_sys->i_height / p_sys->i_rows )
469                         + ( i_row * p_sys->i_hborder ) / p_sys->i_rows;
470         }
471
472         if( p_region_prev == NULL ){
473             p_spu->p_region = p_region;
474         } else {
475             p_region_prev->p_next = p_region;
476         }
477
478         p_region_prev = p_region;
479
480         vout_CopyPicture( p_filter, &p_region->picture, p_converted );
481
482         p_middle->pf_release( p_middle );
483         p_converted->pf_release( p_converted );
484     }
485
486     vlc_mutex_unlock( &p_picture_vout->lock );
487
488     return p_spu;
489 }
490
491 /*****************************************************************************
492 * Callback to update params on the fly
493 *****************************************************************************/
494
495 static int MosaicCallback( vlc_object_t *p_this, char const *psz_var,
496                             vlc_value_t oldval, vlc_value_t newval,
497                             void *p_data )
498 {
499     filter_sys_t *p_sys = (filter_sys_t *) p_data;
500     if( !strcmp( psz_var, "mosaic-alpha" ) )
501     {
502         msg_Dbg( p_this, "Changing alpha from %d/255 to %d/255",
503                          p_sys->i_alpha, newval.i_int);
504         p_sys->i_alpha = __MIN( __MAX( newval.i_int, 0 ), 255 );
505     }
506     else if( !strcmp( psz_var, "mosaic-height" ) )
507     {
508         msg_Dbg( p_this, "Changing height from %dpx to %dpx",
509                           p_sys->i_height, newval.i_int );
510         p_sys->i_height = __MAX( newval.i_int, 0 );
511     }
512     else if( !strcmp( psz_var, "mosaic-width" ) )
513     {
514         msg_Dbg( p_this, "Changing width from %dpx to %dpx",
515                          p_sys->i_width, newval.i_int );
516         p_sys->i_width = __MAX( newval.i_int, 0 );
517     }
518     else if( !strcmp( psz_var, "mosaic-xoffset" ) )
519     {
520         msg_Dbg( p_this, "Changing x offset from %dpx to %dpx",
521                          p_sys->i_xoffset, newval.i_int );
522         p_sys->i_xoffset = __MAX( newval.i_int, 0 );
523     }
524     else if( !strcmp( psz_var, "mosaic-yoffset" ) )
525     {
526         msg_Dbg( p_this, "Changing y offset from %dpx to %dpx",
527                          p_sys->i_yoffset, newval.i_int );
528         p_sys->i_yoffset = __MAX( newval.i_int, 0 );
529     }
530     else if( !strcmp( psz_var, "mosaic-vborder" ) )
531     {
532         msg_Dbg( p_this, "Changing vertical border from %dpx to %dpx",
533                          p_sys->i_vborder, newval.i_int );
534         p_sys->i_vborder = __MAX( newval.i_int, 0 );
535     }
536     else if( !strcmp( psz_var, "mosaic-hborder" ) )
537     {
538         msg_Dbg( p_this, "Changing horizontal border from %dpx to %dpx",
539                          p_sys->i_vborder, newval.i_int );
540         p_sys->i_hborder = __MAX( newval.i_int, 0 );
541     }
542     else if( !strcmp( psz_var, "mosaic-position" ) )
543     {
544         if( newval.i_int > 1 || newval.i_int < 0 )
545         {
546             msg_Err( p_this, "Position is either 0 (auto) or 1 (fixed)" );
547         }
548         else
549         {
550             msg_Dbg( p_this, "Changing position method from %d (%s) to %d (%s)",
551                              p_sys->i_pos, ppsz_pos_descriptions[p_sys->i_pos],
552                              newval.i_int, ppsz_pos_descriptions[newval.i_int]);
553             p_sys->i_pos = newval.i_int;
554         }
555     }
556     else if( !strcmp( psz_var, "mosaic-rows" ) )
557     {
558         msg_Dbg( p_this, "Changing number of rows from %d to %d",
559                          p_sys->i_rows, newval.i_int );
560         p_sys->i_rows = __MAX( newval.i_int, 1 );
561     }
562     else if( !strcmp( psz_var, "mosaic-cols" ) )
563     {
564         msg_Dbg( p_this, "Changing number of columns from %d to %d",
565                          p_sys->i_cols, newval.i_int );
566         p_sys->i_cols = __MAX( newval.i_int, 1 );
567     }
568     else if( !strcmp( psz_var, "mosaic-keep-aspect-ratio" ) )
569     {
570         if( newval.i_int )
571         {
572             msg_Dbg( p_this, "Keep aspect ratio" );
573             p_sys->i_ar = 1;
574         }
575         else
576         {
577             msg_Dbg( p_this, "Don't keep aspect ratio" );
578             p_sys->i_ar = 0;
579         }
580     }
581     return VLC_SUCCESS;
582 }