From 241cdded0fc72102f32429cb3f8c0361c518f993 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Fri, 17 Jul 2020 13:45:16 +0200 Subject: [PATCH] avfilter/vf_bilateral: stop using sigmaS as percent of width/height --- doc/filters.texi | 2 +- libavfilter/vf_bilateral.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index 12d40029dc..74d1026bdf 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -6581,7 +6581,7 @@ The filter accepts the following options: @table @option @item sigmaS Set sigma of gaussian function to calculate spatial weight. -Allowed range is 0 to 10. Default is 0.1. +Allowed range is 0 to 512. Default is 0.1. @item sigmaR Set sigma of gaussian function to calculate range weight. diff --git a/libavfilter/vf_bilateral.c b/libavfilter/vf_bilateral.c index 3c9d8006d9..47959afdad 100644 --- a/libavfilter/vf_bilateral.c +++ b/libavfilter/vf_bilateral.c @@ -57,7 +57,7 @@ typedef struct BilateralContext { #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM static const AVOption bilateral_options[] = { - { "sigmaS", "set spatial sigma", OFFSET(sigmaS), AV_OPT_TYPE_FLOAT, {.dbl=0.1}, 0.0, 10, FLAGS }, + { "sigmaS", "set spatial sigma", OFFSET(sigmaS), AV_OPT_TYPE_FLOAT, {.dbl=0.1}, 0.0, 512, FLAGS }, { "sigmaR", "set range sigma", OFFSET(sigmaR), AV_OPT_TYPE_FLOAT, {.dbl=0.1}, 0.0, 1, FLAGS }, { "planes", "set planes to filter", OFFSET(planes), AV_OPT_TYPE_INT, {.i64=1}, 0, 0xF, FLAGS }, { NULL } @@ -145,7 +145,7 @@ static void bilateral_##name(BilateralContext *s, const uint8_t *ssrc, uint8_t * float *slice_factor_a = s->slice_factor_a, *slice_factor_b = s->slice_factor_b; \ float *line_factor_a = s->line_factor_a, *line_factor_b = s->line_factor_b; \ float *range_table = s->range_table; \ - float alpha = expf(-sqrtf(2.f) / (sigma_spatial * width)); \ + float alpha = expf(-sqrtf(2.f) / sigma_spatial); \ float ypr, ycr, *ycy, *ypy, *xcy, fp, fc; \ float inv_alpha_ = 1 - alpha; \ float *ycf, *ypf, *xcf, *in_factor; \ @@ -206,7 +206,7 @@ static void bilateral_##name(BilateralContext *s, const uint8_t *ssrc, uint8_t * } \ memcpy(img_out_f, img_temp, sizeof(float) * width); \ \ - alpha = expf(-sqrtf(2.f) / (sigma_spatial * height)); \ + alpha = expf(-sqrtf(2.f) / sigma_spatial); \ inv_alpha_ = 1 - alpha; \ in_factor = map_factor_a; \ memcpy(map_factor_b, in_factor, sizeof(float) * width); \