X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fvideo_filter%2Fmotionblur.c;h=4dedc12dabde93986e8ac0d887c828c31dd282f6;hb=98cea7a2a22ceedb3c6eebc4b4f3fb40d263ba09;hp=96feb11a814b43e5b9532e84a3127eb8947ebfce;hpb=9abcaacf83bd53b1f4b6569f7952e7025ddd0860;p=vlc diff --git a/modules/video_filter/motionblur.c b/modules/video_filter/motionblur.c index 96feb11a81..4dedc12dab 100644 --- a/modules/video_filter/motionblur.c +++ b/modules/video_filter/motionblur.c @@ -1,25 +1,25 @@ /***************************************************************************** * 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 * Antoine Cellerier * - * 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. *****************************************************************************/ /***************************************************************************** @@ -34,6 +34,7 @@ #include #include #include +#include #include "filter_picture.h" /***************************************************************************** @@ -80,9 +81,7 @@ struct filter_sys_t { picture_t *p_tmp; bool b_first; - - vlc_spinlock_t lock; - int i_factor; + atomic_int i_factor; }; /***************************************************************************** @@ -92,6 +91,11 @@ static int Create( vlc_object_t *p_this ) { 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 ) @@ -110,9 +114,8 @@ static int Create( vlc_object_t *p_this ) 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 ); @@ -129,7 +132,6 @@ static void Destroy( vlc_object_t *p_this ) 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 ); @@ -173,9 +175,7 @@ static void RenderBlur( filter_sys_t *p_sys, picture_t *p_newpic, 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++ ) @@ -209,14 +209,9 @@ static int MotionBlurCallback( vlc_object_t *p_this, char const *psz_var, 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 = VLC_CLIP( newval.i_int, 1, 127 ); - vlc_spin_unlock( &p_sys->lock ); - } + atomic_store( &p_sys->i_factor, VLC_CLIP( newval.i_int, 1, 127 ) ); return VLC_SUCCESS; }