[vlc-commits] d3d11_adjust: fix possible missing config
Steve Lhomme
git at videolan.org
Sun Jul 2 14:24:19 CEST 2017
vlc | branch: master | Steve Lhomme <robUx4 at videolabs.io> | Sun Jul 2 10:09:24 2017 +0200| [8876ce7529bc610b2fd305d3764a8305ecb1685d] | committer: Jean-Baptiste Kempf
d3d11_adjust: fix possible missing config
ref CID #1449020
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=8876ce7529bc610b2fd305d3764a8305ecb1685d
---
modules/video_output/win32/d3d11_adjust.c | 35 ++++++++++++++++++-------------
1 file changed, 21 insertions(+), 14 deletions(-)
diff --git a/modules/video_output/win32/d3d11_adjust.c b/modules/video_output/win32/d3d11_adjust.c
index 1371b52895..e0fd4c5c10 100644
--- a/modules/video_output/win32/d3d11_adjust.c
+++ b/modules/video_output/win32/d3d11_adjust.c
@@ -178,23 +178,30 @@ static void SetLevel(struct filter_level *range, float val)
static void InitLevel(filter_t *filter, struct filter_level *range, const char *p_name, float def)
{
- int level;
+ int level = 0;
module_config_t *cfg = config_FindConfig( VLC_OBJECT(filter), p_name);
- range->min = cfg->min.f;
- range->max = cfg->max.f;
- range->default_val = def;
-
- float val = var_CreateGetFloatCommand( filter, p_name );
-
- if (val > range->default_val)
- level = (range->Range.Maximum - range->Range.Default) * (val - range->default_val) /
- (range->max - range->default_val);
- else if (val < range->default_val)
- level = (range->Range.Minimum - range->Range.Default) * (val - range->default_val) /
- (range->min - range->default_val);
+ if (unlikely(cfg == NULL))
+ {
+ range->min = 0.;
+ range->max = 2.;
+ range->default_val = 1.;
+ }
else
- level = 0;
+ {
+ range->min = cfg->min.f;
+ range->max = cfg->max.f;
+ range->default_val = def;
+
+ float val = var_CreateGetFloatCommand( filter, p_name );
+
+ if (val > range->default_val)
+ level = (range->Range.Maximum - range->Range.Default) * (val - range->default_val) /
+ (range->max - range->default_val);
+ else if (val < range->default_val)
+ level = (range->Range.Minimum - range->Range.Default) * (val - range->default_val) /
+ (range->min - range->default_val);
+ }
atomic_init( &range->level, range->Range.Default + level );
}
More information about the vlc-commits
mailing list