> On Jan 4, 2020, at 9:43 PM, zhilizhao <quinkbl...@foxmail.com> wrote: > > > >> On Jan 4, 2020, at 9:09 PM, Paul B Mahol <one...@gmail.com >> <mailto:one...@gmail.com>> wrote: >> >> On 1/4/20, zhilizhao <quinkbl...@foxmail.com >> <mailto:quinkbl...@foxmail.com>> wrote: >>> >>> >>>> On Jan 4, 2020, at 7:04 PM, Paul B Mahol <one...@gmail.com >>>> <mailto:one...@gmail.com>> wrote: >>>> >>>> I do not like this “fix" >>> >>> What do you suggest? It’s numerical unstable for small sigma. >> >> For small sigma return frames unchanged as it currently does. > > Then which valud should be selected as the threshold: > > 1. A value from which it becomes unstable (it’s not fun to figure it out). > > 2. A reasonable (and random) selected value like 0.25 >
For function set_params: static void set_params(float sigma, int steps, float *postscale, float *boundaryscale, float *nu) { double dnu, lambda; lambda = (sigma * sigma) / (2.0 * steps); dnu = (1.0 + 2.0 * lambda - sqrt(1.0 + 4.0 * lambda)) / (2.0 * lambda); *postscale = pow(dnu / lambda, steps); *boundaryscale = 1.0 / (1.0 - dnu); *nu = (float)dnu; } 1. Check sigma against 0 is not enough, since lambda can be 0 for non-zero sigma 2. Check lambda against 0 is not enough, we should avoid dividing by small value, like 'dnu / lambda’. So there should have a dead-zone for sigma. > >> >>> >>>> >>>> On 1/4/20, quinkbl...@foxmail.com <quinkbl...@foxmail.com> wrote: >>>>> From: Zhao Zhili <zhiliz...@tencent.com> >>>>> >>>>> ./ffmpeg -i ~/Pictures/test.jpg -vf 'gblur=sigma=0' -f null - >>>>> ... >>>>> src/libavfilter/vf_gblur.c:260:59: runtime error: division by zero >>>>> src/libavfilter/vf_gblur.c:261:26: runtime error: division by zero >>>>> --- >>>>> libavfilter/vf_gblur.c | 12 +++++++++--- >>>>> 1 file changed, 9 insertions(+), 3 deletions(-) >>>>> >>>>> diff --git a/libavfilter/vf_gblur.c b/libavfilter/vf_gblur.c >>>>> index 2e587f6a0a..e057937fb7 100644 >>>>> --- a/libavfilter/vf_gblur.c >>>>> +++ b/libavfilter/vf_gblur.c >>>>> @@ -37,11 +37,17 @@ >>>>> #define OFFSET(x) offsetof(GBlurContext, x) >>>>> #define FLAGS >>>>> AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM >>>>> >>>>> +/* Consider the three-sigma rule, for minimum radius of 1 sigma should >>>>> not >>>>> + * be smaller than 1/3. Relax it to 0.25 if the user want to try. >>>>> + */ >>>>> +#define SIGMA_MIN 0.25 >>>>> +#define SIGMA_MAX 1024.0 >>>>> + >>>>> static const AVOption gblur_options[] = { >>>>> - { "sigma", "set sigma", OFFSET(sigma), >>>>> AV_OPT_TYPE_FLOAT, >>>>> {.dbl=0.5}, 0.0, 1024, FLAGS }, >>>>> + { "sigma", "set sigma", OFFSET(sigma), >>>>> AV_OPT_TYPE_FLOAT, >>>>> {.dbl=0.5}, SIGMA_MIN, SIGMA_MAX, FLAGS }, >>>>> { "steps", "set number of steps", OFFSET(steps), AV_OPT_TYPE_INT, >>>>> {.i64=1}, 1, 6, FLAGS }, >>>>> { "planes", "set planes to filter", OFFSET(planes), AV_OPT_TYPE_INT, >>>>> {.i64=0xF}, 0, 0xF, FLAGS }, >>>>> - { "sigmaV", "set vertical sigma", OFFSET(sigmaV), >>>>> AV_OPT_TYPE_FLOAT, >>>>> {.dbl=-1}, -1, 1024, FLAGS }, >>>>> + { "sigmaV", "set vertical sigma", OFFSET(sigmaV), >>>>> AV_OPT_TYPE_FLOAT, >>>>> {.dbl=-1}, -1, SIGMA_MAX, FLAGS }, >>>>> { NULL } >>>>> }; >>>>> >>>>> @@ -244,7 +250,7 @@ static int config_input(AVFilterLink *inlink) >>>>> if (!s->buffer) >>>>> return AVERROR(ENOMEM); >>>>> >>>>> - if (s->sigmaV < 0) { >>>>> + if (s->sigmaV < SIGMA_MIN) { >>>>> s->sigmaV = s->sigma; >>>>> } >>>>> ff_gblur_init(s); >>>>> -- >>>>> 2.22.0 >>>>> >>>>> _______________________________________________ >>>>> ffmpeg-devel mailing list >>>>> ffmpeg-devel@ffmpeg.org >>>>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel >>>>> >>>>> To unsubscribe, visit link above, or email >>>>> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". >>>> _______________________________________________ >>>> ffmpeg-devel mailing list >>>> ffmpeg-devel@ffmpeg.org >>>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel >>>> >>>> To unsubscribe, visit link above, or email >>>> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". >>> >>> >>> >>> _______________________________________________ >>> ffmpeg-devel mailing list >>> ffmpeg-devel@ffmpeg.org >>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel >>> >>> To unsubscribe, visit link above, or email >>> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". >> _______________________________________________ >> ffmpeg-devel mailing list >> ffmpeg-devel@ffmpeg.org >> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel >> >> To unsubscribe, visit link above, or email >> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". > > > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org <mailto:ffmpeg-devel@ffmpeg.org> > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > <https://ffmpeg.org/mailman/listinfo/ffmpeg-devel> > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org <mailto:ffmpeg-devel-requ...@ffmpeg.org> with > subject "unsubscribe". _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".