X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fvideo_filter%2Fcolorthres.c;h=a4e40a2c243a6b736a396f1fff416f8dad5f0c29;hb=f2b2e37c04b2921e29daa3260dc696646ad4f10c;hp=3c2d4d64f55316d14ab821da92ee6c17fd54006a;hpb=d3fe7f28797d4dba65ffcdd60bf932e758a48a9e;p=vlc diff --git a/modules/video_filter/colorthres.c b/modules/video_filter/colorthres.c index 3c2d4d64f5..a4e40a2c24 100644 --- a/modules/video_filter/colorthres.c +++ b/modules/video_filter/colorthres.c @@ -24,16 +24,21 @@ /***************************************************************************** * Preamble *****************************************************************************/ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + #include -#include /* malloc(), free() */ -#include #include -#include +#include +#include #include #include #include "vlc_filter.h" +#include "filter_picture.h" /***************************************************************************** * Local prototypes @@ -51,29 +56,34 @@ static picture_t *Filter( filter_t *, picture_t * ); "grayscaled. This must be an hexadecimal (like HTML colors). The first two "\ "chars are for red, then green, then blue. #000000 = black, #FF0000 = red,"\ " #00FF00 = green, #FFFF00 = yellow (red + green), #FFFFFF = white" ) -static int pi_color_values[] = { - 0x00FF0000, 0x00FF00FF, 0x00FFFF00, 0x0000FF00, 0x000000FF, 0x0000FFFF }; +static const int pi_color_values[] = { + 0x00FF0000, 0x00FF00FF, 0x00FFFF00, 0x0000FF00, 0x000000FF, 0x0000FFFF }; -static char *ppsz_color_descriptions[] = { +static const char *const ppsz_color_descriptions[] = { N_("Red"), N_("Fuchsia"), N_("Yellow"), N_("Lime"), N_("Blue"), N_("Aqua") }; +#define CFG_PREFIX "colorthres-" vlc_module_begin(); - set_description( _("Color threshold filter") ); - set_shortname( _("Color threshold" )); + set_description( N_("Color threshold filter") ); + set_shortname( N_("Color threshold" )); set_category( CAT_VIDEO ); set_subcategory( SUBCAT_VIDEO_VFILTER ); set_capability( "video filter2", 0 ); - add_integer( "colorthres-color", 0x00FF0000, NULL, COLOR_TEXT, - COLOR_LONGTEXT, VLC_FALSE ); + add_integer( CFG_PREFIX "color", 0x00FF0000, NULL, COLOR_TEXT, + COLOR_LONGTEXT, false ); change_integer_list( pi_color_values, ppsz_color_descriptions, 0 ); - add_integer( "colorthres-saturationthres", 20, NULL, "saturaton threshold", - "", VLC_FALSE ); - add_integer( "colorthres-similaritythres", 15, NULL, "similarity threshold", - "", VLC_FALSE ); + add_integer( CFG_PREFIX "saturationthres", 20, NULL, + _("Saturaton threshold"), "", false ); + add_integer( CFG_PREFIX "similaritythres", 15, NULL, + _("Similarity threshold"), "", false ); set_callbacks( Create, Destroy ); vlc_module_end(); +static const char *const ppsz_filter_options[] = { + "color", "saturationthes", "similaritythres", NULL +}; + /***************************************************************************** * filter_sys_t: adjust filter method descriptor *****************************************************************************/ @@ -90,12 +100,15 @@ static int Create( vlc_object_t *p_this ) { filter_t *p_filter = (filter_t *)p_this; - /* XXX: we might need to add/remove some FOURCCs ... */ - if( p_filter->fmt_in.video.i_chroma != VLC_FOURCC('I','4','2','0') ) + switch( p_filter->fmt_in.video.i_chroma ) { - msg_Err( p_filter, "Unsupported input chroma (%4s)", - (char*)&(p_filter->fmt_in.video.i_chroma) ); - return VLC_EGENERIC; + CASE_PLANAR_YUV + break; + + default: + msg_Err( p_filter, "Unsupported input chroma (%4s)", + (char*)&(p_filter->fmt_in.video.i_chroma) ); + return VLC_EGENERIC; } if( p_filter->fmt_in.video.i_chroma != p_filter->fmt_out.video.i_chroma ) @@ -104,16 +117,16 @@ static int Create( vlc_object_t *p_this ) return VLC_EGENERIC; } - var_Create( p_filter, "colorthres-color", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT ); - var_Create( p_filter, "colorthres-similaritythres", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT ); - var_Create( p_filter, "colorthres-saturationthres", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT ); + config_ChainParse( p_filter, CFG_PREFIX, ppsz_filter_options, + p_filter->p_cfg ); + var_CreateGetIntegerCommand( p_filter, CFG_PREFIX "color" ); + var_CreateGetIntegerCommand( p_filter, CFG_PREFIX "similaritythres" ); + var_CreateGetIntegerCommand( p_filter, CFG_PREFIX "saturationthres" ); + /* Allocate structure */ p_filter->p_sys = malloc( sizeof( filter_sys_t ) ); if( p_filter->p_sys == NULL ) - { - msg_Err( p_filter, "out of memory" ); return VLC_ENOMEM; - } p_filter->pf_video_filter = Filter; @@ -149,12 +162,10 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic ) if( !p_pic ) return NULL; - p_outpic = p_filter->pf_vout_buffer_new( p_filter ); + p_outpic = filter_NewPicture( p_filter ); if( !p_outpic ) { - msg_Warn( p_filter, "can't get output picture" ); - if( p_pic->pf_release ) - p_pic->pf_release( p_pic ); + picture_Release( p_pic ); return NULL; } @@ -169,14 +180,13 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic ) p_out_v = p_outpic->p[V_PLANE].p_pixels; /* Create grayscale version of input */ - memcpy( p_out_y, p_in_y, p_pic->p[Y_PLANE].i_visible_lines - * p_pic->p[Y_PLANE].i_pitch - 8 ); - memset( p_out_u, 0x80, p_pic->p[U_PLANE].i_visible_lines - * p_pic->p[U_PLANE].i_pitch - 8 ); - memset( p_out_v, 0x80, p_pic->p[U_PLANE].i_visible_lines - * p_pic->p[U_PLANE].i_pitch - 8 ); - - + vlc_memcpy( p_out_y, p_in_y, p_pic->p[Y_PLANE].i_visible_lines + * p_pic->p[Y_PLANE].i_pitch - 8 ); + vlc_memset( p_out_u, 0x80, p_pic->p[U_PLANE].i_visible_lines + * p_pic->p[U_PLANE].i_pitch - 8 ); + vlc_memset( p_out_v, 0x80, p_pic->p[U_PLANE].i_visible_lines + * p_pic->p[U_PLANE].i_pitch - 8 ); + /* * Do the U and V planes */ @@ -212,18 +222,7 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic ) p_in_v++; p_out_u++; p_out_v++; - - } - p_outpic->date = p_pic->date; - p_outpic->b_force = p_pic->b_force; - p_outpic->i_nb_fields = p_pic->i_nb_fields; - p_outpic->b_progressive = p_pic->b_progressive; - p_outpic->b_top_field_first = p_pic->b_top_field_first; - - if( p_pic->pf_release ) - p_pic->pf_release( p_pic ); - - return p_outpic; + return CopyInfoAndRelease( p_outpic, p_pic ); }