/*****************************************************************************
* ball.c : Augmented reality ball video filter module
*****************************************************************************
- * Copyright (C) 2000-2009 the VideoLAN team
+ * Copyright (C) 2000-2009 VLC authors and VideoLAN
*
* Author: Adrien Maglo <magsoft@videolan.org>
*
* Samuel Hocevar <sam@zoy.org>
* Antoine Cellerier <dionoea -at- videolan -dot- org>
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
enum { RED, GREEN, BLUE, WHITE };
-typedef struct
-{
- uint8_t comp1;
- uint8_t comp2;
- uint8_t comp3;
-}COLOR;
-
-static COLOR colorList[4];
-
#define COLORS_RGB \
- colorList[RED].comp1 = 255; colorList[RED].comp2 = 0; \
- colorList[RED].comp3 = 0; \
- colorList[GREEN].comp1 = 0; colorList[GREEN].comp2 = 255; \
- colorList[GREEN].comp3 = 0; \
- colorList[BLUE].comp1 = 0; colorList[BLUE].comp2 = 0; \
- colorList[BLUE].comp3 = 255; \
- colorList[WHITE].comp1 = 255; colorList[WHITE].comp2 = 255; \
- colorList[WHITE].comp3 = 255;
+ p_filter->p_sys->colorList[RED].comp1 = 255; p_filter->p_sys->colorList[RED].comp2 = 0; \
+ p_filter->p_sys->colorList[RED].comp3 = 0; \
+ p_filter->p_sys->colorList[GREEN].comp1 = 0; p_filter->p_sys->colorList[GREEN].comp2 = 255; \
+ p_filter->p_sys->colorList[GREEN].comp3 = 0; \
+ p_filter->p_sys->colorList[BLUE].comp1 = 0; p_filter->p_sys->colorList[BLUE].comp2 = 0; \
+ p_filter->p_sys->colorList[BLUE].comp3 = 255; \
+ p_filter->p_sys->colorList[WHITE].comp1 = 255; p_filter->p_sys->colorList[WHITE].comp2 = 255; \
+ p_filter->p_sys->colorList[WHITE].comp3 = 255;
#define COLORS_YUV \
- colorList[RED].comp1 = 82; colorList[RED].comp2 = 240; \
- colorList[RED].comp3 = 90; \
- colorList[GREEN].comp1 = 145; colorList[GREEN].comp2 = 34; \
- colorList[GREEN].comp3 = 54 ; \
- colorList[BLUE].comp1 = 41; colorList[BLUE].comp2 = 146; \
- colorList[BLUE].comp3 = 240; \
- colorList[WHITE].comp1 = 255; colorList[WHITE].comp2 = 128; \
- colorList[WHITE].comp3 = 128;
+ p_filter->p_sys->colorList[RED].comp1 = 82; p_filter->p_sys->colorList[RED].comp2 = 240; \
+ p_filter->p_sys->colorList[RED].comp3 = 90; \
+ p_filter->p_sys->colorList[GREEN].comp1 = 145; p_filter->p_sys->colorList[GREEN].comp2 = 34; \
+ p_filter->p_sys->colorList[GREEN].comp3 = 54 ; \
+ p_filter->p_sys->colorList[BLUE].comp1 = 41; p_filter->p_sys->colorList[BLUE].comp2 = 146; \
+ p_filter->p_sys->colorList[BLUE].comp3 = 240; \
+ p_filter->p_sys->colorList[WHITE].comp1 = 255; p_filter->p_sys->colorList[WHITE].comp2 = 128; \
+ p_filter->p_sys->colorList[WHITE].comp3 = 128;
/*****************************************************************************
* Module descriptor
*****************************************************************************/
#define BALL_COLOR_TEXT N_("Ball color")
-#define BALL_COLOR_LONGTEXT N_("Ball color, one of \"red\", \"blue\" and \"green\".")
#define EDGE_VISIBLE_TEXT N_("Edge visible")
#define EDGE_VISIBLE_LONGTEXT N_("Set edge visibility.")
set_category( CAT_VIDEO )
set_subcategory( SUBCAT_VIDEO_VFILTER )
- add_string( FILTER_PREFIX "color", "ball-color",
- BALL_COLOR_TEXT, BALL_COLOR_LONGTEXT, false )
- change_string_list( mode_list, mode_list_text, 0 )
+ add_string( FILTER_PREFIX "color", "red",
+ BALL_COLOR_TEXT, BALL_COLOR_TEXT, false )
+ change_string_list( mode_list, mode_list_text )
- add_integer_with_range( FILTER_PREFIX "speed", 4, 1, 15, NULL,
+ add_integer_with_range( FILTER_PREFIX "speed", 4, 1, 15,
BALL_SPEED_TEXT, BALL_SPEED_LONGTEXT, false )
- add_integer_with_range( FILTER_PREFIX "size", 10, 5, 30, NULL,
+ add_integer_with_range( FILTER_PREFIX "size", 10, 5, 30,
BALL_SIZE_TEXT, BALL_SIZE_LONGTEXT, false )
- add_integer_with_range( FILTER_PREFIX "gradient-threshold", 40, 1, 200, NULL,
+ add_integer_with_range( FILTER_PREFIX "gradient-threshold", 40, 1, 200,
GRAD_THRESH_TEXT, GRAD_THRESH_LONGTEXT, false )
- add_bool( FILTER_PREFIX "edge-visible", true, NULL,
+ add_bool( FILTER_PREFIX "edge-visible", true,
EDGE_VISIBLE_TEXT, EDGE_VISIBLE_LONGTEXT, true )
add_shortcut( "ball" )
vlc_module_end ()
static const char *const ppsz_filter_options[] = {
- "ball-color", "ball-speed", "ball-size",
+ "color", "speed", "size",
"gradient-threshold", "edge-visible", NULL
};
void ( *drawingPixelFunction )( filter_sys_t *, picture_t *,
uint8_t, uint8_t, uint8_t,
int, int, bool );
+ struct
+ {
+ uint8_t comp1;
+ uint8_t comp2;
+ uint8_t comp3;
+ } colorList[4];
};
&& j >= 0 && j < i_height )
{
( *p_sys->drawingPixelFunction )( p_sys, p_outpic,
- colorList[ p_sys->ballColor ].comp1,
- colorList[ p_sys->ballColor ].comp2,
- colorList[ p_sys->ballColor ].comp3,
+ p_sys->colorList[ p_sys->ballColor ].comp1,
+ p_sys->colorList[ p_sys->ballColor ].comp2,
+ p_sys->colorList[ p_sys->ballColor ].comp3,
i, j, b_skip );
}
b_skip = !b_skip;
picture_t *p_converted;
video_format_t fmt_comp;
+ memset( &fmt_comp, 0, sizeof(fmt_comp) );
switch( p_filter->fmt_in.video.i_chroma )
{
if( !p_smooth || !p_grad_x || !p_grad_y ) return;
- vlc_memcpy( p_outpic->p[0].p_pixels, p_inpic->p[0].p_pixels,
+ memcpy( p_outpic->p[0].p_pixels, p_inpic->p[0].p_pixels,
p_outpic->p[0].i_lines * p_outpic->p[0].i_pitch );
- vlc_memcpy( p_outpic->p[1].p_pixels, p_inpic->p[1].p_pixels,
+ memcpy( p_outpic->p[1].p_pixels, p_inpic->p[1].p_pixels,
p_outpic->p[1].i_lines * p_outpic->p[1].i_pitch );
- vlc_memcpy( p_outpic->p[2].p_pixels, p_inpic->p[2].p_pixels,
+ memcpy( p_outpic->p[2].p_pixels, p_inpic->p[2].p_pixels,
p_outpic->p[2].i_lines * p_outpic->p[2].i_pitch );
GaussianConvolution( p_converted, p_smooth );
> p_sys->i_gradThresh )
{
( *p_sys->drawingPixelFunction )( p_sys, p_outpic,
- colorList[ WHITE ].comp1,
- colorList[ WHITE ].comp2,
- colorList[ WHITE ].comp3,
+ p_filter->p_sys->colorList[ WHITE ].comp1,
+ p_filter->p_sys->colorList[ WHITE ].comp2,
+ p_filter->p_sys->colorList[ WHITE ].comp3,
x, y, 0 );
}
}