[vlc-commits] [Git][videolan/vlc][master] 3 commits: adjust: remove brightness threshold
Rémi Denis-Courmont (@Courmisch)
gitlab at videolan.org
Tue Feb 8 13:51:19 UTC 2022
Rémi Denis-Courmont pushed to branch master at VideoLAN / VLC
Commits:
2553ba0d by Rémi Denis-Courmont at 2022-02-08T12:26:47+00:00
adjust: remove brightness threshold
No matter how you look at it, this did not belong in the image adjust
filter. This could belong in a separate module, or as a submodule of
the colour threshold filter -- if somebody actually ever needs it.
This function was never implemented by the hardware-accelerated adjust
filters, as it is indeed not a standard part of HSL and HSV adjustment
functionality, or really at all a part of it. So this has actually
become a functional inconsistency.
- - - - -
ba55578f by Rémi Denis-Courmont at 2022-02-08T12:26:47+00:00
adjust: reindent
- - - - -
7418ccda by Rémi Denis-Courmont at 2022-02-08T12:26:47+00:00
macos: disable brightness threshold
- - - - -
2 changed files:
- modules/gui/macosx/panels/VLCVideoEffectsWindowController.m
- modules/video_filter/adjust.c
Changes:
=====================================
modules/gui/macosx/panels/VLCVideoEffectsWindowController.m
=====================================
@@ -182,7 +182,7 @@ NSString *VLCVideoEffectsProfileNamesKey = @"VideoEffectProfileNames";
[VLCVideoFilterHelper setVideoFilterProperty: "wall-cols" forFilter: "wall" withValue: getWidgetIntValue([items objectAtIndex:31])];
if ([items count] >= 33) { // version >=2 of profile string
- [VLCVideoFilterHelper setVideoFilterProperty: "brightness-threshold" forFilter: "adjust" withValue: (vlc_value_t){ .b_bool = [[items objectAtIndex:32] intValue] }];
+ /* "brightness-threshold" at 32 */
}
vlc_value_t hueValue;
@@ -571,7 +571,6 @@ NSString *VLCVideoEffectsProfileNamesKey = @"VideoEffectProfileNames";
[self setWidgetValue: _adjustContrastSlider forOption: "contrast" enabled: b_state];
[self setWidgetValue: _adjustBrightnessSlider forOption: "brightness" enabled: b_state];
[self setWidgetValue: _adjustSaturationSlider forOption: "saturation" enabled: b_state];
- [self setWidgetValue: _adjustBrightnessCheckbox forOption: "brightness-threshold" enabled: b_state];
[self setWidgetValue: _adjustGammaSlider forOption: "gamma" enabled: b_state];
[_adjustBrightnessLabel setEnabled: b_state];
[_adjustContrastLabel setEnabled: b_state];
@@ -704,7 +703,7 @@ NSString *VLCVideoEffectsProfileNamesKey = @"VideoEffectProfileNames";
var_InheritInteger(vout, "wall-rows"),
var_InheritInteger(vout, "wall-cols"),
// version 2 of profile string:
- (int64_t)var_InheritBool(vout, "brightness-threshold"), // index: 32
+ 0LL /* "brightness-threshold" */, // index: 32
// version 3 of profile string: (vlc-3.0.0)
var_InheritFloat(vout, "hue") // index: 33
];
@@ -927,7 +926,7 @@ NSString *VLCVideoEffectsProfileNamesKey = @"VideoEffectProfileNames";
[VLCVideoFilterHelper setVideoFilter: "adjust" on: b_state];
[_adjustBrightnessSlider setEnabled: b_state];
- [_adjustBrightnessCheckbox setEnabled: b_state];
+ [_adjustBrightnessCheckbox setEnabled: NO];
[_adjustBrightnessLabel setEnabled: b_state];
[_adjustContrastSlider setEnabled: b_state];
[_adjustContrastLabel setEnabled: b_state];
@@ -964,13 +963,6 @@ NSString *VLCVideoEffectsProfileNamesKey = @"VideoEffectProfileNames";
[sender setToolTip: [NSString stringWithFormat:@"%0.3f", [sender floatValue]]];
}
-- (IBAction)enableAdjustBrightnessThreshold:(id)sender
-{
- [VLCVideoFilterHelper setVideoFilterProperty: "brightness-threshold"
- forFilter: "adjust"
- withValue: getWidgetBoolValue(sender)];
-}
-
- (IBAction)enableSharpen:(id)sender
{
BOOL b_state = [_sharpenCheckbox state];
=====================================
modules/video_filter/adjust.c
=====================================
@@ -52,10 +52,6 @@ static picture_t *FilterPacked( filter_t *, picture_t * );
* Module descriptor
*****************************************************************************/
-#define THRES_TEXT N_("Brightness threshold")
-#define THRES_LONGTEXT N_("When this mode is enabled, pixels will be " \
- "shown as black or white. The threshold value will be the brightness " \
- "defined below." )
#define CONT_TEXT N_("Image contrast (0-2)")
#define CONT_LONGTEXT N_("Set the image contrast, between 0 and 2. Defaults to 1.")
#define HUE_TEXT N_("Image hue (-180..180)")
@@ -87,17 +83,14 @@ vlc_module_begin ()
add_float_with_range( "gamma", 1.0, 0.01, 10.0,
GAMMA_TEXT, GAMMA_LONGTEXT )
change_safe()
- add_bool( "brightness-threshold", false,
- THRES_TEXT, THRES_LONGTEXT )
- change_safe()
+ add_obsolete_bool("brightness-threshold") /* since 4.0.0 */
add_shortcut( "adjust" )
set_callback_video_filter( Create )
vlc_module_end ()
static const char *const ppsz_filter_options[] = {
- "contrast", "brightness", "hue", "saturation", "gamma",
- "brightness-threshold", NULL
+ "contrast", "brightness", "hue", "saturation", "gamma", NULL
};
/*****************************************************************************
@@ -110,7 +103,6 @@ typedef struct
_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 );
int (*pf_process_sat_hue_clip)( picture_t *, picture_t *, int, int,
@@ -206,8 +198,6 @@ static int Create( filter_t *p_filter )
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" ) );
var_AddCallback( p_filter, "contrast", FloatCallback, &p_sys->f_contrast );
var_AddCallback( p_filter, "brightness", FloatCallback,
@@ -216,8 +206,6 @@ static int Create( filter_t *p_filter )
var_AddCallback( p_filter, "saturation", FloatCallback,
&p_sys->f_saturation );
var_AddCallback( p_filter, "gamma", FloatCallback, &p_sys->f_gamma );
- var_AddCallback( p_filter, "brightness-threshold", BoolCallback,
- &p_sys->b_brightness_threshold );
return VLC_SUCCESS;
}
@@ -236,8 +224,6 @@ static void Destroy( filter_t *p_filter )
var_DelCallback( p_filter, "saturation", FloatCallback,
&p_sys->f_saturation );
var_DelCallback( p_filter, "gamma", FloatCallback, &p_sys->f_gamma );
- var_DelCallback( p_filter, "brightness-threshold", BoolCallback,
- &p_sys->b_brightness_threshold );
}
/*****************************************************************************
@@ -281,44 +267,20 @@ static void FilterPlanar( filter_t *p_filter, picture_t *p_pic, picture_t *p_out
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_explicit( &p_sys->b_brightness_threshold,
- memory_order_relaxed ) )
- {
-
- /* Contrast is a fast but kludged function, so I put this gap to be
- * cleaner :) */
- i_lum += i_mid - i_cont / 2;
-
- /* Fill the gamma lookup table */
- for( unsigned i = 0 ; i < i_size; i++ )
- {
- pi_gamma[ i ] = VLC_CLIP( powf(i / f_max, f_gamma) * f_max, 0, i_max );
- }
+ /* Contrast is a fast but kludged function, so I put this gap to be
+ * cleaner :) */
+ i_lum += i_mid - i_cont / 2;
- /* Fill the luma lookup table */
- for( unsigned i = 0 ; i < i_size; i++ )
- {
- pi_luma[ i ] = pi_gamma[VLC_CLIP( (int)(i_lum + i_cont * i / i_range), 0, (int) i_max )];
- }
- }
- else
+ /* Fill the gamma lookup table */
+ for( unsigned i = 0 ; i < i_size; i++ )
{
- /*
- * We get luma as threshold value: the higher it is, the darker is
- * the image. Should I reverse this?
- */
- for( int i = 0 ; i < i_range; i++ )
- {
- pi_luma[ i ] = (i < i_lum) ? 0 : i_max;
- }
+ pi_gamma[ i ] = VLC_CLIP( powf(i / f_max, f_gamma) * f_max, 0, i_max );
+ }
- /*
- * Desaturates image to avoid that strange yellow halo...
- */
- i_sat = 0;
+ /* Fill the luma lookup table */
+ for( unsigned i = 0 ; i < i_size; i++ )
+ {
+ pi_luma[ i ] = pi_gamma[VLC_CLIP( (int)(i_lum + i_cont * i / i_range), 0, (int) i_max )];
}
/*
@@ -477,43 +439,20 @@ static picture_t *FilterPacked( filter_t *p_filter, picture_t *p_pic )
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_explicit( &p_sys->b_brightness_threshold, memory_order_relaxed ) )
- {
-
- /* Contrast is a fast but kludged function, so I put this gap to be
- * cleaner :) */
- i_lum += 128 - i_cont / 2;
+ /* Contrast is a fast but kludged function, so I put this gap to be
+ * cleaner :) */
+ i_lum += 128 - i_cont / 2;
- /* Fill the gamma lookup table */
- for( int i = 0 ; i < 256 ; i++ )
- {
- pi_gamma[ i ] = clip_uint8_vlc( pow(i / 255.0, f_gamma) * 255.0);
- }
-
- /* Fill the luma lookup table */
- for( int i = 0 ; i < 256 ; i++ )
- {
- pi_luma[ i ] = pi_gamma[clip_uint8_vlc( i_lum + i_cont * i / 256)];
- }
- }
- else
+ /* Fill the gamma lookup table */
+ for( int i = 0 ; i < 256 ; i++ )
{
- /*
- * We get luma as threshold value: the higher it is, the darker is
- * the image. Should I reverse this?
- */
- for( int i = 0 ; i < 256 ; i++ )
- {
- pi_luma[ i ] = (i < i_lum) ? 0 : 255;
- }
+ pi_gamma[ i ] = clip_uint8_vlc( pow(i / 255.0, f_gamma) * 255.0);
+ }
- /*
- * Desaturates image to avoid that strange yellow halo...
- */
- i_sat = 0;
+ /* Fill the luma lookup table */
+ for( int i = 0 ; i < 256 ; i++ )
+ {
+ pi_luma[ i ] = pi_gamma[clip_uint8_vlc( i_lum + i_cont * i / 256)];
}
/*
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/ca13fe633e6ae017c850327a1d7b94b65b4f5f5b...7418ccda131ff21956ccb9a386fc42742ddd1d8e
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/ca13fe633e6ae017c850327a1d7b94b65b4f5f5b...7418ccda131ff21956ccb9a386fc42742ddd1d8e
You're receiving this email because of your account on code.videolan.org.
More information about the vlc-commits
mailing list