]> git.sesse.net Git - ffmpeg/commitdiff
avfilter/vf_bilateral: stop using sigmaS as percent of width/height
authorPaul B Mahol <onemda@gmail.com>
Fri, 17 Jul 2020 11:45:16 +0000 (13:45 +0200)
committerPaul B Mahol <onemda@gmail.com>
Fri, 17 Jul 2020 11:53:22 +0000 (13:53 +0200)
doc/filters.texi
libavfilter/vf_bilateral.c

index 12d40029dc448202ee3365193c1f0e5ae853b5d0..74d1026bdf4467fd9662db6f16108fefb1c713c2 100644 (file)
@@ -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.
index 3c9d8006d90a91584798d7f207a4526c491b9b6e..47959afdad83d5f8fd2d109bf411b91bc1c3cff9 100644 (file)
@@ -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);                               \