/*****************************************************************************
* antiflicker.c : antiflicker video effect plugin for vlc
*****************************************************************************
- * Copyright (C) 2000-2011 the VideoLAN team
+ * Copyright (C) 2000-2011 VLC authors and VideoLAN
* $Id:
*
* Authors: Dharani Prabhu <dharani.prabhu.s@gmail.com>
*
- * 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_common.h>
#include <vlc_plugin.h>
#include <vlc_filter.h>
+#include <vlc_atomic.h>
#include "filter_picture.h"
/*****************************************************************************
*****************************************************************************/
struct filter_sys_t
{
+ atomic_int i_window_size;
+ atomic_int i_softening;
int ia_luminance_data[MAX_WINDOW_SZ];
- vlc_mutex_t lock;
- int i_window_size;
- int i_softening;
uint8_t *p_old_data;
};
p_filter->pf_video_filter = Filter;
/* Initialize the arguments */
- p_filter->p_sys->i_window_size = var_CreateGetIntegerCommand( p_filter,
- FILTER_PREFIX "window-size" );
- p_filter->p_sys->i_softening = var_CreateGetIntegerCommand( p_filter,
- FILTER_PREFIX "softening-size" );
+ atomic_init( &p_filter->p_sys->i_window_size,
+ var_CreateGetIntegerCommand( p_filter,
+ FILTER_PREFIX"window-size" ) );
+ atomic_init( &p_filter->p_sys->i_softening,
+ var_CreateGetIntegerCommand( p_filter,
+ FILTER_PREFIX"softening-size" ) );
p_filter->p_sys->p_old_data = calloc( p_filter->fmt_in.video.i_width *
(p_filter->fmt_in.video.i_height+1),sizeof(*p_filter->p_sys->p_old_data) );
if( p_filter->p_sys->p_old_data == NULL )
+ {
+ free( p_filter->p_sys );
return VLC_ENOMEM;
+ }
memset( p_filter->p_sys->ia_luminance_data, 0,
sizeof(p_filter->p_sys->ia_luminance_data) );
p_filter->p_sys->ia_luminance_data[p_filter->p_sys->i_window_size - 1] = 256;
- vlc_mutex_init( &p_filter->p_sys->lock );
var_AddCallback(p_filter,FILTER_PREFIX "window-size",
AntiFlickerCallback, p_filter->p_sys);
var_AddCallback(p_filter,FILTER_PREFIX "softening-size",
AntiFlickerCallback, p_filter->p_sys);
var_DelCallback(p_filter,FILTER_PREFIX "softening-size",
AntiFlickerCallback, p_filter->p_sys);
- vlc_mutex_destroy( &p_filter->p_sys->lock );
free(p_filter->p_sys->p_old_data);
free( p_filter->p_sys );
}
/****************** Get variables *************************/
- int i_window_size;
- int i_softening;
-
- vlc_mutex_lock( &p_filter->p_sys->lock );
- i_window_size = p_filter->p_sys->i_window_size;
- i_softening = p_filter->p_sys->i_softening;
- vlc_mutex_unlock( &p_filter->p_sys->lock );
+ int i_window_size = atomic_load( &p_filter->p_sys->i_window_size );
+ int i_softening = atomic_load( &p_filter->p_sys->i_softening );
uint8_t *p_yplane_in = p_pic->p[Y_PLANE].p_pixels;
uint8_t *p_yplane_out = p_outpic->p[Y_PLANE].p_pixels;
VLC_UNUSED(p_this); VLC_UNUSED(oldval);
filter_sys_t *p_sys = (filter_sys_t *)p_data;
- vlc_mutex_lock( &p_sys->lock );
if( !strcmp( psz_var, FILTER_PREFIX "window-size" ) )
- p_sys->i_window_size = newval.i_int;
+ atomic_store( &p_sys->i_window_size, newval.i_int );
else if( !strcmp( psz_var, FILTER_PREFIX "softening-size" ) )
- p_sys->i_softening = newval.i_int;
- vlc_mutex_unlock( &p_sys->lock );
+ atomic_store( &p_sys->i_softening, newval.i_int );
return VLC_SUCCESS;
}