# include "config.h"
#endif
-#include <vlc/vlc.h>
+#include <vlc_common.h>
+#include <vlc_plugin.h>
#include <vlc_vout.h>
#include <vlc_interface.h>
#endif
vlc_module_begin();
- set_description( _("Crop video filter") );
- set_shortname( _("Crop" ));
+ set_description( N_("Crop video filter") );
+ set_shortname( N_("Crop" ));
set_category( CAT_VIDEO );
set_subcategory( SUBCAT_VIDEO_VFILTER );
set_capability( "video filter", 0 );
add_string( "crop-geometry", NULL, NULL, GEOMETRY_TEXT,
- GEOMETRY_LONGTEXT, VLC_FALSE );
+ GEOMETRY_LONGTEXT, false );
add_bool( "autocrop", 0, NULL, AUTOCROP_TEXT,
- AUTOCROP_LONGTEXT, VLC_FALSE );
+ AUTOCROP_LONGTEXT, false );
#ifdef BEST_AUTOCROP
add_integer_with_range( "autocrop-ratio-max", 2405, 0, RATIO_MAX, NULL,
- RATIOMAX_TEXT, RATIOMAX_LONGTEXT, VLC_TRUE );
+ RATIOMAX_TEXT, RATIOMAX_LONGTEXT, true );
add_integer_with_range( "crop-ratio", 0, 0, RATIO_MAX, NULL, RATIO_TEXT,
- RATIO_LONGTEXT, VLC_FALSE );
+ RATIO_LONGTEXT, false );
add_integer( "autocrop-time", 25, NULL, TIME_TEXT,
- TIME_LONGTEXT, VLC_TRUE );
+ TIME_LONGTEXT, true );
add_integer( "autocrop-diff", 16, NULL, DIFF_TEXT,
- DIFF_LONGTEXT, VLC_TRUE );
+ DIFF_LONGTEXT, true );
add_integer( "autocrop-non-black-pixels", 3, NULL,
- NBP_TEXT, NBP_LONGTEXT, VLC_TRUE );
+ NBP_TEXT, NBP_LONGTEXT, true );
add_integer_with_range( "autocrop-skip-percent", 17, 0, 100, NULL,
- SKIP_TEXT, SKIP_LONGTEXT, VLC_TRUE );
+ SKIP_TEXT, SKIP_LONGTEXT, true );
add_integer_with_range( "autocrop-luminance-threshold", 40, 0, 128, NULL,
- LUM_TEXT, LUM_LONGTEXT, VLC_TRUE );
+ LUM_TEXT, LUM_LONGTEXT, true );
#endif //BEST_AUTOCROP
add_shortcut( "crop" );
unsigned int i_x, i_y;
unsigned int i_width, i_height, i_aspect;
- vlc_bool_t b_autocrop;
+ bool b_autocrop;
/* Autocrop specific variables */
unsigned int i_lastchange;
- vlc_bool_t b_changed;
+ bool b_changed;
#ifdef BEST_AUTOCROP
unsigned int i_ratio_max;
unsigned int i_threshold, i_skipPercent, i_nonBlackPixel, i_diff, i_time;
/* Allocate structure */
p_vout->p_sys = malloc( sizeof( vout_sys_t ) );
if( p_vout->p_sys == NULL )
- {
- msg_Err( p_vout, "out of memory" );
return VLC_ENOMEM;
- }
p_vout->pf_init = Init;
p_vout->pf_end = End;
memset( &fmt, 0, sizeof(video_format_t) );
p_vout->p_sys->i_lastchange = 0;
- p_vout->p_sys->b_changed = VLC_FALSE;
+ p_vout->p_sys->b_changed = false;
/* Initialize the output structure */
p_vout->output.i_chroma = p_vout->render.i_chroma;
if( p_vout->p_sys->p_vout == NULL )
{
msg_Err( p_vout, "failed to create vout" );
- intf_UserFatal( p_vout, VLC_FALSE, _("Cropping failed"),
+ intf_UserFatal( p_vout, false, _("Cropping failed"),
_("VLC could not open the video output module.") );
return VLC_EGENERIC;
}
- ALLOCATE_DIRECTBUFFERS( VOUT_MAX_PICTURES );
-
- ADD_CALLBACKS( p_vout->p_sys->p_vout, SendEvents );
-
#ifdef BEST_AUTOCROP
var_AddCallback( p_vout, "ratio-crop", FilterCallback, NULL );
#endif
+ ALLOCATE_DIRECTBUFFERS( VOUT_MAX_PICTURES );
+
+ ADD_CALLBACKS( p_vout->p_sys->p_vout, SendEvents );
+
ADD_PARENT_CALLBACKS( SendEventsToChild );
return VLC_SUCCESS;
{
int i_index;
+ DEL_PARENT_CALLBACKS( SendEventsToChild );
+ if( p_vout->p_sys->p_vout )
+ DEL_CALLBACKS( p_vout->p_sys->p_vout, SendEvents );
+
/* Free the fake output buffers we allocated */
for( i_index = I_OUTPUTPICTURES ; i_index ; )
{
i_index--;
free( PP_OUTPUTPICTURE[ i_index ]->p_data_orig );
}
+
+ if( p_vout->p_sys->p_vout )
+ vout_CloseAndRelease( p_vout->p_sys->p_vout );
}
/*****************************************************************************
{
vout_thread_t *p_vout = (vout_thread_t *)p_this;
- if( p_vout->p_sys->p_vout )
- {
- DEL_CALLBACKS( p_vout->p_sys->p_vout, SendEvents );
- vlc_object_detach( p_vout->p_sys->p_vout );
- vout_Destroy( p_vout->p_sys->p_vout );
- }
-
- DEL_PARENT_CALLBACKS( SendEventsToChild );
-
free( p_vout->p_sys );
}
msg_Info( p_vout, "ratio %d", p_vout->p_sys->i_aspect / 432);
#endif
- vout_Destroy( p_vout->p_sys->p_vout );
+ if( p_vout->p_sys->p_vout )
+ {
+ DEL_CALLBACKS( p_vout->p_sys->p_vout, SendEvents );
+ vout_CloseAndRelease( p_vout->p_sys->p_vout );
+ }
fmt.i_width = fmt.i_visible_width = p_vout->p_sys->i_width;
fmt.i_height = fmt.i_visible_height = p_vout->p_sys->i_height;
if( p_vout->p_sys->p_vout == NULL )
{
msg_Err( p_vout, "failed to create vout" );
- intf_UserFatal( p_vout, VLC_FALSE, _("Cropping failed"),
+ intf_UserFatal( p_vout, false, _("Cropping failed"),
_("VLC could not open the video output module.") );
return VLC_EGENERIC;
}
+ ADD_CALLBACKS( p_vout->p_sys->p_vout, SendEvents );
- p_vout->p_sys->b_changed = VLC_FALSE;
+ p_vout->p_sys->b_changed = false;
p_vout->p_sys->i_lastchange = 0;
return VLC_SUCCESS;
vout_CreatePicture( p_vout->p_sys->p_vout, 0, 0, 0 )
) == NULL )
{
- if( p_vout->b_die || p_vout->b_error )
+ if( !vlc_object_alive (p_vout) || p_vout->b_error )
{
vout_DestroyPicture( p_vout->p_sys->p_vout, p_outpic );
return;
while( p_out < p_out_end )
{
- p_vout->p_libvlc->pf_memcpy( p_out, p_in, i_copy_pitch );
+ vlc_memcpy( p_out, p_in, i_copy_pitch );
p_in += i_in_pitch;
p_out += i_out_pitch;
}
}
#ifdef BEST_AUTOCROP
-static vlc_bool_t NonBlackLine(uint8_t *p_in, int i_line, int i_pitch,
+static bool NonBlackLine(uint8_t *p_in, int i_line, int i_pitch,
int i_visible_pitch, int i_lines,
int i_lumThreshold, int i_skipCountPercent,
int i_nonBlackPixel, int i_chroma)
* p_vout->output.i_height / p_vout->p_sys->i_height
* p_vout->p_sys->i_width / p_vout->output.i_width;
- p_vout->p_sys->b_changed = VLC_TRUE;
+ p_vout->p_sys->b_changed = true;
}
/*****************************************************************************
static int SendEvents( vlc_object_t *p_this, char const *psz_var,
vlc_value_t oldval, vlc_value_t newval, void *_p_vout )
{
+ VLC_UNUSED(p_this); VLC_UNUSED(oldval);
vout_thread_t *p_vout = (vout_thread_t *)_p_vout;
vlc_value_t sentval = newval;
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;
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;
if( !strcmp( psz_var, "ratio-crop" ) )
{
p_vout->p_sys->i_ratio = (unsigned int)atoi(newval.psz_string);
p_vout->p_sys->i_lastchange = p_vout->p_sys->i_time;
- p_vout->p_sys->b_autocrop = VLC_TRUE;
+ p_vout->p_sys->b_autocrop = true;
}
if (p_vout->p_sys->i_ratio)
{