/*****************************************************************************
* Preamble
*****************************************************************************/
-#include <stdlib.h> /* malloc(), free() */
-#include <string.h>
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
#include <vlc/vlc.h>
-#include <vlc/vout.h>
+#include <vlc_vout.h>
#include <math.h>
static int MouseEvent ( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * );
+static int PuzzleCallback( vlc_object_t *, char const *,
+ vlc_value_t, vlc_value_t, void * );
+
/*****************************************************************************
* Module descriptor
*****************************************************************************/
#define BLACKSLOT_TEXT N_("Make one tile a black slot")
#define BLACKSLOT_LONGTEXT N_("Make one slot black. Other tiles can only be swapped with the black slot.")
+#define CFG_PREFIX "puzzle-"
+
vlc_module_begin();
set_description( _("Puzzle interactive game video filter") );
set_shortname( _( "Puzzle" ));
set_category( CAT_VIDEO );
set_subcategory( SUBCAT_VIDEO_VFILTER );
- add_integer_with_range( "puzzle-rows", 4, 1, 128, NULL,
+ add_integer_with_range( CFG_PREFIX "rows", 4, 1, 128, NULL,
ROWS_TEXT, ROWS_LONGTEXT, VLC_FALSE );
- add_integer_with_range( "puzzle-cols", 4, 1, 128, NULL,
+ add_integer_with_range( CFG_PREFIX "cols", 4, 1, 128, NULL,
COLS_TEXT, COLS_LONGTEXT, VLC_FALSE );
- add_bool( "puzzle-black-slot", 0, NULL,
+ add_bool( CFG_PREFIX "black-slot", 0, NULL,
BLACKSLOT_TEXT, BLACKSLOT_LONGTEXT, VLC_FALSE );
set_callbacks( Create, Destroy );
vlc_module_end();
+static const char *ppsz_filter_options[] = {
+ "rows", "cols", "black-slot", NULL
+};
+
/*****************************************************************************
* vout_sys_t: Magnify video output method descriptor
*****************************************************************************/
p_vout->p_sys->p_image = image_HandlerCreate( p_vout );
- p_vout->p_sys->i_rows = config_GetInt( p_vout, "puzzle-rows" );
- p_vout->p_sys->i_cols = config_GetInt( p_vout, "puzzle-cols" );
- p_vout->p_sys->b_blackslot = config_GetInt( p_vout, "puzzle-black-slot" );
+ config_ChainParse( p_vout, CFG_PREFIX, ppsz_filter_options,
+ p_vout->p_cfg );
+
+ p_vout->p_sys->i_rows =
+ var_CreateGetIntegerCommand( p_vout, CFG_PREFIX "rows" );
+ p_vout->p_sys->i_cols =
+ var_CreateGetIntegerCommand( p_vout, CFG_PREFIX "cols" );
+ p_vout->p_sys->b_blackslot =
+ var_CreateGetBoolCommand( p_vout, CFG_PREFIX "black-slot" );
+ var_AddCallback( p_vout, CFG_PREFIX "rows",
+ PuzzleCallback, p_vout->p_sys );
+ var_AddCallback( p_vout, CFG_PREFIX "cols",
+ PuzzleCallback, p_vout->p_sys );
+ var_AddCallback( p_vout, CFG_PREFIX "black-slot",
+ PuzzleCallback, p_vout->p_sys );
p_vout->p_sys->pi_order = NULL;
shuffle( p_vout->p_sys );
{
int i_index;
picture_t *p_pic;
- video_format_t fmt = {0};
+ video_format_t fmt;
+ memset( &fmt, 0, sizeof( video_format_t ) );
I_OUTPUTPICTURES = 0;
#define SHUFFLE_WIDTH 81
#define SHUFFLE_HEIGHT 13
-static char *shuffle_button[] =
+static const char *shuffle_button[] =
{
".................................................................................",
".............. ............................ ........ ...... ...............",
{
picture_t *p_outpic;
- //video_format_t fmt_out = {0};
+ //video_format_t fmt_out;
+ // memset( &fmt_out, 0, sizeof(video_format_t) );
//picture_t *p_converted;
int i_plane;
uint8_t color = ( i_plane == Y_PLANE ? 0x0 : 0x80 );
for( ; i_row < i_last_row; i_row++, i_orow++ )
{
- memset( p_out->p_pixels + i_row * i_pitch
- + i_col * i_pitch / i_cols,
- color, i_pitch / i_cols );
+ p_vout->p_libvlc->
+ pf_memset( p_out->p_pixels + i_row * i_pitch
+ + i_col * i_pitch / i_cols,
+ color, i_pitch / i_cols );
}
}
else
{
for( ; i_row < i_last_row; i_row++, i_orow++ )
{
- memcpy( p_out->p_pixels + i_row * i_pitch
- + i_col * i_pitch / i_cols,
- p_in->p_pixels + i_orow * i_pitch
- + i_ocol * i_pitch / i_cols,
- i_pitch / i_cols );
+ p_vout->p_libvlc->
+ pf_memcpy( p_out->p_pixels + i_row * i_pitch
+ + i_col * i_pitch / i_cols,
+ p_in->p_pixels + i_orow * i_pitch
+ + i_ocol * i_pitch / i_cols,
+ i_pitch / i_cols );
}
}
}
int i_last_row = i_row + 1;
i_row *= p_in->i_lines / i_rows;
i_last_row *= p_in->i_lines / i_rows;
- memset( p_out->p_pixels + i_row * i_pitch
- + i_col * i_pitch / i_cols,
- 0xff, i_pitch / i_cols );
+ p_vout->p_libvlc->
+ pf_memset( p_out->p_pixels + i_row * i_pitch
+ + i_col * i_pitch / i_cols,
+ 0xff, i_pitch / i_cols );
for( ; i_row < i_last_row; i_row++ )
{
p_out->p_pixels[ i_row * i_pitch
+ (i_col+1) * i_pitch / i_cols - 1 ] = 0xff;
}
i_row--;
- memset( p_out->p_pixels + i_row * i_pitch
- + i_col * i_pitch / i_cols,
- 0xff, i_pitch / i_cols );
+ p_vout->p_libvlc->
+ pf_memset( p_out->p_pixels + i_row * i_pitch
+ + i_col * i_pitch / i_cols,
+ 0xff, i_pitch / i_cols );
}
if( p_vout->p_sys->b_finished == VLC_TRUE )
static int SendEvents( vlc_object_t *p_this, char const *psz_var,
vlc_value_t oldval, vlc_value_t newval, void *p_data )
{
+ VLC_UNUSED(p_this); VLC_UNUSED(oldval);
+
var_Set( (vlc_object_t *)p_data, psz_var, newval );
return VLC_SUCCESS;
static int SendEventsToChild( vlc_object_t *p_this, char const *psz_var,
vlc_value_t oldval, vlc_value_t newval, void *p_data )
{
+ VLC_UNUSED(p_data); VLC_UNUSED(oldval);
vout_thread_t *p_vout = (vout_thread_t *)p_this;
var_Set( p_vout->p_sys->p_vout, psz_var, newval );
return VLC_SUCCESS;
static int MouseEvent( vlc_object_t *p_this, char const *psz_var,
vlc_value_t oldval, vlc_value_t newval, void *p_data )
{
+ VLC_UNUSED(p_this); VLC_UNUSED(oldval); VLC_UNUSED(newval);
vout_thread_t *p_vout = (vout_thread_t*)p_data;
int i_x, i_y;
int i_v;
i_y = var_GetInteger( p_vout->p_sys->p_vout, "mouse-y" );
i_x = var_GetInteger( p_vout->p_sys->p_vout, "mouse-x" );
+ if( i_y < 0 || i_x < 0 || i_y >= v_h || i_x >= v_w )
+ return VLC_SUCCESS;
+
if( mouse & MOUSE_CLICKED )
{
i_pos = p_vout->p_sys->i_cols * ( ( p_vout->p_sys->i_rows * i_y ) / v_h ) + (p_vout->p_sys->i_cols * i_x ) / v_w;
}
return VLC_SUCCESS;
}
+
+static int PuzzleCallback( vlc_object_t *p_this, char const *psz_var,
+ vlc_value_t oldval, vlc_value_t newval,
+ void *p_data )
+{
+ VLC_UNUSED(p_this); VLC_UNUSED(oldval);
+ vout_sys_t *p_sys = (vout_sys_t *)p_data;
+ if( !strcmp( psz_var, CFG_PREFIX "rows" ) )
+ {
+ p_sys->i_rows = __MAX( 1, newval.i_int );
+ }
+ else if( !strcmp( psz_var, CFG_PREFIX "cols" ) )
+ {
+ p_sys->i_cols = __MAX( 1, newval.i_int );
+ }
+ else if( !strcmp( psz_var, CFG_PREFIX "black-slot" ) )
+ {
+ p_sys->b_blackslot = newval.b_bool;
+ }
+ shuffle( p_sys );
+ return VLC_SUCCESS;
+}