[FFmpeg-devel] [PATCH 1/2] avfilter/vf_gblur: fix divide by zero

Paul B Mahol onemda at gmail.com
Sat Jan 4 15:09:01 EET 2020


On 1/4/20, zhilizhao <quinkblack at foxmail.com> wrote:
>
>
>> On Jan 4, 2020, at 7:04 PM, Paul B Mahol <onemda at 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.

>
>>
>> On 1/4/20, quinkblack at foxmail.com <quinkblack at foxmail.com> wrote:
>>> From: Zhao Zhili <zhilizhao at 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 at ffmpeg.org
>>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>>
>>> To unsubscribe, visit link above, or email
>>> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
>> _______________________________________________
>> ffmpeg-devel mailing list
>> ffmpeg-devel at ffmpeg.org
>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>
>> To unsubscribe, visit link above, or email
>> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
>
>
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".


More information about the ffmpeg-devel mailing list