[vlc-commits] adjust: avoid <vlc_atomic.h> and relax ordering
Rémi Denis-Courmont
git at videolan.org
Wed Feb 26 20:25:51 CET 2020
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Feb 26 20:48:00 2020 +0200| [8143eb5e518ee9c2ec2e9360188f3d9523599fc8] | committer: Rémi Denis-Courmont
adjust: avoid <vlc_atomic.h> and relax ordering
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=8143eb5e518ee9c2ec2e9360188f3d9523599fc8
---
modules/video_filter/adjust.c | 61 +++++++++++++++++++++----------------------
1 file changed, 30 insertions(+), 31 deletions(-)
diff --git a/modules/video_filter/adjust.c b/modules/video_filter/adjust.c
index 000f84386e..c48d9b5ec3 100644
--- a/modules/video_filter/adjust.c
+++ b/modules/video_filter/adjust.c
@@ -34,7 +34,6 @@
#include <stdatomic.h>
#include <vlc_common.h>
-#include <vlc_atomic.h>
#include <vlc_plugin.h>
#include <vlc_filter.h>
#include <vlc_picture.h>
@@ -110,11 +109,11 @@ static const char *const ppsz_filter_options[] = {
*****************************************************************************/
typedef struct
{
- vlc_atomic_float f_contrast;
- vlc_atomic_float f_brightness;
- vlc_atomic_float f_hue;
- vlc_atomic_float f_saturation;
- vlc_atomic_float f_gamma;
+ _Atomic float f_contrast;
+ _Atomic float f_brightness;
+ _Atomic float f_hue;
+ _Atomic float f_saturation;
+ _Atomic float f_gamma;
atomic_bool b_brightness_threshold;
int (*pf_process_sat_hue)( picture_t *, picture_t *, int, int, int,
int, int );
@@ -125,9 +124,9 @@ typedef struct
static int FloatCallback( vlc_object_t *obj, char const *varname,
vlc_value_t oldval, vlc_value_t newval, void *data )
{
- vlc_atomic_float *atom = data;
+ _Atomic float *atom = data;
- vlc_atomic_store_float( atom, newval.f_float );
+ atomic_store_explicit( atom, newval.f_float, memory_order_relaxed );
(void) obj; (void) varname; (void) oldval;
return VLC_SUCCESS;
}
@@ -137,7 +136,7 @@ static int BoolCallback( vlc_object_t *obj, char const *varname,
{
atomic_bool *atom = data;
- atomic_store( atom, newval.b_bool );
+ atomic_store_explicit( atom, newval.b_bool, memory_order_relaxed );
(void) obj; (void) varname; (void) oldval;
return VLC_SUCCESS;
}
@@ -198,16 +197,15 @@ static int Create( vlc_object_t *p_this )
* adjust{name=value} syntax */
config_ChainParse( p_filter, "", ppsz_filter_options, p_filter->p_cfg );
- vlc_atomic_init_float( &p_sys->f_contrast,
- var_CreateGetFloatCommand( p_filter, "contrast" ) );
- vlc_atomic_init_float( &p_sys->f_brightness,
- var_CreateGetFloatCommand( p_filter, "brightness" ) );
- vlc_atomic_init_float( &p_sys->f_hue,
- var_CreateGetFloatCommand( p_filter, "hue" ) );
- vlc_atomic_init_float( &p_sys->f_saturation,
- var_CreateGetFloatCommand( p_filter, "saturation" ) );
- vlc_atomic_init_float( &p_sys->f_gamma,
- var_CreateGetFloatCommand( p_filter, "gamma" ) );
+ atomic_init( &p_sys->f_contrast,
+ var_CreateGetFloatCommand( p_filter, "contrast" ) );
+ atomic_init( &p_sys->f_brightness,
+ var_CreateGetFloatCommand( p_filter, "brightness" ) );
+ atomic_init( &p_sys->f_hue, var_CreateGetFloatCommand( p_filter, "hue" ) );
+ atomic_init( &p_sys->f_saturation,
+ var_CreateGetFloatCommand( p_filter, "saturation" ) );
+ atomic_init( &p_sys->f_gamma,
+ var_CreateGetFloatCommand( p_filter, "gamma" ) );
atomic_init( &p_sys->b_brightness_threshold,
var_CreateGetBoolCommand( p_filter, "brightness-threshold" ) );
@@ -289,16 +287,17 @@ static picture_t *FilterPlanar( filter_t *p_filter, picture_t *p_pic )
const unsigned i_mid = i_range >> 1;
/* Get variables */
- int32_t i_cont = lroundf( vlc_atomic_load_float( &p_sys->f_contrast ) * f_max );
- int32_t i_lum = lroundf( (vlc_atomic_load_float( &p_sys->f_brightness ) - 1.f) * f_max );
- float f_hue = vlc_atomic_load_float( &p_sys->f_hue ) * (float)(M_PI / 180.);
- int i_sat = (int)( vlc_atomic_load_float( &p_sys->f_saturation ) * f_range );
- float f_gamma = 1.f / vlc_atomic_load_float( &p_sys->f_gamma );
+ int32_t i_cont = lroundf( atomic_load_explicit( &p_sys->f_contrast, memory_order_relaxed ) * f_max );
+ int32_t i_lum = lroundf( (atomic_load_explicit( &p_sys->f_brightness, memory_order_relaxed ) - 1.f) * f_max );
+ float f_hue = atomic_load_explicit( &p_sys->f_hue, memory_order_relaxed ) * (float)(M_PI / 180.);
+ int i_sat = (int)( atomic_load_explicit( &p_sys->f_saturation, memory_order_relaxed ) * f_range );
+ float f_gamma = 1.f / atomic_load_explicit( &p_sys->f_gamma, memory_order_relaxed );
/*
* Threshold mode drops out everything about luma, contrast and gamma.
*/
- if( !atomic_load( &p_sys->b_brightness_threshold ) )
+ if( !atomic_load_explicit( &p_sys->b_brightness_threshold,
+ memory_order_relaxed ) )
{
/* Contrast is a fast but kludged function, so I put this gap to be
@@ -486,16 +485,16 @@ static picture_t *FilterPacked( filter_t *p_filter, picture_t *p_pic )
}
/* Get variables */
- i_cont = (int)( vlc_atomic_load_float( &p_sys->f_contrast ) * 255 );
- i_lum = (int)( (vlc_atomic_load_float( &p_sys->f_brightness ) - 1.0)*255 );
- f_hue = vlc_atomic_load_float( &p_sys->f_hue ) * (float)(M_PI / 180.);
- i_sat = (int)( vlc_atomic_load_float( &p_sys->f_saturation ) * 256 );
- f_gamma = 1.0 / vlc_atomic_load_float( &p_sys->f_gamma );
+ i_cont = (int)( atomic_load_explicit( &p_sys->f_contrast, memory_order_relaxed ) * 255 );
+ i_lum = (int)( (atomic_load_explicit( &p_sys->f_brightness, memory_order_relaxed ) - 1.0)*255 );
+ f_hue = atomic_load_explicit( &p_sys->f_hue, memory_order_relaxed ) * (float)(M_PI / 180.);
+ i_sat = (int)( atomic_load_explicit( &p_sys->f_saturation, memory_order_relaxed ) * 256 );
+ f_gamma = 1.0 / atomic_load_explicit( &p_sys->f_gamma, memory_order_relaxed );
/*
* Threshold mode drops out everything about luma, contrast and gamma.
*/
- if( !atomic_load( &p_sys->b_brightness_threshold ) )
+ if( !atomic_load_explicit( &p_sys->b_brightness_threshold, memory_order_relaxed ) )
{
/* Contrast is a fast but kludged function, so I put this gap to be
More information about the vlc-commits
mailing list