- p_sys->i_width = __MAX( 0, var_CreateGetInteger( p_filter->p_libvlc, "mosaic-width" ) );
- p_sys->i_height = __MAX( 0, var_CreateGetInteger( p_filter->p_libvlc, "mosaic-height" ) );
-
- p_sys->i_xoffset = __MAX( 0, var_CreateGetInteger( p_filter->p_libvlc, "mosaic-xoffset" ) );
- p_sys->i_yoffset = __MAX( 0, var_CreateGetInteger( p_filter->p_libvlc, "mosaic-yoffset" ) );
-
- p_sys->i_vborder = __MAX( 0, var_CreateGetInteger( p_filter->p_libvlc, "mosaic-vborder" ) );
- p_sys->i_hborder = __MAX( 0, var_CreateGetInteger( p_filter->p_libvlc, "mosaic-hborder" ) );
-
- p_sys->i_rows = __MAX( 1, var_CreateGetInteger( p_filter->p_libvlc, "mosaic-rows") );
- p_sys->i_cols = __MAX( 1, var_CreateGetInteger( p_filter->p_libvlc, "mosaic-cols") );
-
- p_sys->i_alpha = var_CreateGetInteger( p_filter->p_libvlc, "mosaic-alpha" );
- p_sys->i_alpha = __MIN( 255, __MAX( 0, p_sys->i_alpha ) );
-
- p_sys->i_pos = var_CreateGetInteger( p_filter->p_libvlc, "mosaic-position" );
- if( p_sys->i_pos > 1 || p_sys->i_pos < 0 ) p_sys->i_pos = 0;
-
- p_sys->i_ar = var_CreateGetInteger( p_filter->p_libvlc, "mosaic-keep-aspect-ratio" );
+#define GET_VAR( name, min, max ) \
+ p_sys->i_##name = __MIN( max, __MAX( min, \
+ var_CreateGetInteger( p_filter, "mosaic-" #name ) ) ); \
+ var_Destroy( p_filter, "mosaic-" #name ); \
+ var_Create( p_libvlc, "mosaic-" #name, VLC_VAR_INTEGER ); \
+ var_SetInteger( p_libvlc, "mosaic-" #name, p_sys->i_##name ); \
+ var_AddCallback( p_libvlc, "mosaic-" #name, MosaicCallback, p_sys );
+
+ GET_VAR( width, 0, INT32_MAX );
+ GET_VAR( height, 0, INT32_MAX );
+ GET_VAR( xoffset, 0, INT32_MAX );
+ GET_VAR( yoffset, 0, INT32_MAX );
+ GET_VAR( vborder, 0, INT32_MAX );
+ GET_VAR( hborder, 0, INT32_MAX );
+ GET_VAR( rows, 1, INT32_MAX );
+ GET_VAR( cols, 1, INT32_MAX );
+ GET_VAR( alpha, 0, 255 );
+ GET_VAR( position, 0, 1 );
+ GET_VAR( delay, 100, INT32_MAX );
+ p_sys->i_delay *= 1000;
+
+ p_sys->b_ar = var_CreateGetBool( p_filter, "mosaic-keep-aspect-ratio" );
+ var_Destroy( p_filter, "mosaic-keep-aspect-ratio" );
+ var_Create( p_libvlc, "mosaic-keep-aspect-ratio", VLC_VAR_INTEGER );
+ var_SetBool( p_libvlc, "mosaic-keep-aspect-ratio", p_sys->b_ar );
+ var_AddCallback( p_libvlc, "mosaic-keep-aspect-ratio", MosaicCallback,
+ p_sys );
+
+ p_sys->b_keep = var_CreateGetBool( p_filter, "mosaic-keep-picture" );
+ if ( !p_sys->b_keep )
+ {
+ p_sys->p_image = image_HandlerCreate( p_filter );
+#ifdef IMAGE_2PASSES
+ p_sys->p_image2 = image_HandlerCreate( p_filter );
+#endif
+ }