/*****************************************************************************
- * motion_blur.c : motion blur filter for vlc
+ * motionblur.c : motion blur filter for vlc
*****************************************************************************
- * Copyright (C) 2000, 2001, 2002, 2003 the VideoLAN team
+ * Copyright (C) 2000, 2001, 2002, 2003 VLC authors and VideoLAN
* $Id$
*
* Authors: Sigmund Augdal Helberg <dnumgis@videolan.org>
* Antoine Cellerier <dionoea &t videolan d.t 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.
*****************************************************************************/
/*****************************************************************************
#include <vlc_plugin.h>
#include <vlc_sout.h>
#include <vlc_filter.h>
+#include <vlc_atomic.h>
#include "filter_picture.h"
/*****************************************************************************
set_category( CAT_VIDEO )
set_subcategory( SUBCAT_VIDEO_VFILTER )
- add_integer_with_range( FILTER_PREFIX "factor", 80, 1, 127, NULL,
+ add_integer_with_range( FILTER_PREFIX "factor", 80, 1, 127,
FACTOR_TEXT, FACTOR_LONGTEXT, false )
add_shortcut( "blur" )
{
picture_t *p_tmp;
bool b_first;
-
- vlc_spinlock_t lock;
- int i_factor;
+ atomic_int i_factor;
};
/*****************************************************************************
{
filter_t *p_filter = (filter_t *)p_this;
+ const vlc_chroma_description_t *p_chroma =
+ vlc_fourcc_GetChromaDescription( p_filter->fmt_in.video.i_chroma );
+ if( p_chroma == NULL || p_chroma->plane_count == 0 )
+ return VLC_EGENERIC;
+
/* Allocate structure */
p_filter->p_sys = malloc( sizeof( filter_sys_t ) );
if( p_filter->p_sys == NULL )
config_ChainParse( p_filter, FILTER_PREFIX, ppsz_filter_options,
p_filter->p_cfg );
- p_filter->p_sys->i_factor =
- var_CreateGetIntegerCommand( p_filter, FILTER_PREFIX "factor" );
- vlc_spin_init( &p_filter->p_sys->lock );
+ atomic_init( &p_filter->p_sys->i_factor,
+ var_CreateGetIntegerCommand( p_filter, FILTER_PREFIX "factor" ) );
var_AddCallback( p_filter, FILTER_PREFIX "factor",
MotionBlurCallback, p_filter->p_sys );
var_DelCallback( p_filter, FILTER_PREFIX "factor",
MotionBlurCallback, p_filter->p_sys );
- vlc_spin_destroy( &p_filter->p_sys->lock );
picture_Release( p_filter->p_sys->p_tmp );
free( p_filter->p_sys );
picture_t *p_outpic )
{
int i_plane;
- vlc_spin_lock( &p_sys->lock );
- const int i_oldfactor = p_sys->i_factor;
- vlc_spin_unlock( &p_sys->lock );
+ const int i_oldfactor = atomic_load( &p_sys->i_factor );
int i_newfactor = 128 - i_oldfactor;
for( i_plane = 0; i_plane < p_outpic->i_planes; i_plane++ )
vlc_value_t oldval, vlc_value_t newval,
void *p_data )
{
- VLC_UNUSED(p_this); VLC_UNUSED(oldval);
+ VLC_UNUSED(p_this); VLC_UNUSED(psz_var); VLC_UNUSED(oldval);
filter_sys_t *p_sys = (filter_sys_t *)p_data;
- if( !strcmp( psz_var, FILTER_PREFIX "factor" ) )
- {
- vlc_spin_lock( &p_sys->lock );
- p_sys->i_factor = __MIN( 127, __MAX( 1, newval.i_int ) );
- vlc_spin_unlock( &p_sys->lock );
- }
+ atomic_store( &p_sys->i_factor, VLC_CLIP( newval.i_int, 1, 127 ) );
return VLC_SUCCESS;
}