* [FFmpeg-devel] [PATCH] avfilter/xpsnr: avoid division by zero @ 2025-01-27 5:28 Gyan Doshi 2025-01-27 19:24 ` Marton Balint 0 siblings, 1 reply; 5+ messages in thread From: Gyan Doshi @ 2025-01-27 5:28 UTC (permalink / raw) To: ffmpeg-devel The ref input may have its frame rate unset, which would then lead to SIGFPE. Related to #11428 --- libavfilter/vf_xpsnr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavfilter/vf_xpsnr.c b/libavfilter/vf_xpsnr.c index 1b2c2a7c2c..8f86c188c5 100644 --- a/libavfilter/vf_xpsnr.c +++ b/libavfilter/vf_xpsnr.c @@ -568,7 +568,8 @@ static int config_input_ref(AVFilterLink *inlink) s->max_error_64 = (1 << s->depth) - 1; /* conventional limit */ s->max_error_64 *= s->max_error_64; - s->frame_rate = il->frame_rate.num / il->frame_rate.den; + // Avoid division by zero + s->frame_rate = il->frame_rate.den ? (il->frame_rate.num / il->frame_rate.den) : 25; s->num_comps = (desc->nb_components > 3 ? 3 : desc->nb_components); -- 2.46.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avfilter/xpsnr: avoid division by zero 2025-01-27 5:28 [FFmpeg-devel] [PATCH] avfilter/xpsnr: avoid division by zero Gyan Doshi @ 2025-01-27 19:24 ` Marton Balint 2025-01-27 20:14 ` Jan Ekström 0 siblings, 1 reply; 5+ messages in thread From: Marton Balint @ 2025-01-27 19:24 UTC (permalink / raw) To: FFmpeg development discussions and patches On Mon, 27 Jan 2025, Gyan Doshi wrote: > The ref input may have its frame rate unset, which would then lead to > SIGFPE. > > Related to #11428 > --- > libavfilter/vf_xpsnr.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/libavfilter/vf_xpsnr.c b/libavfilter/vf_xpsnr.c > index 1b2c2a7c2c..8f86c188c5 100644 > --- a/libavfilter/vf_xpsnr.c > +++ b/libavfilter/vf_xpsnr.c > @@ -568,7 +568,8 @@ static int config_input_ref(AVFilterLink *inlink) > s->max_error_64 = (1 << s->depth) - 1; /* conventional limit */ > s->max_error_64 *= s->max_error_64; > > - s->frame_rate = il->frame_rate.num / il->frame_rate.den; > + // Avoid division by zero > + s->frame_rate = il->frame_rate.den ? (il->frame_rate.num / il->frame_rate.den) : 25; I kind of prefer 0 instead of 25, as far as I see the code does not care, and 0 is better than an arbitrary value. Thanks, Marton > > s->num_comps = (desc->nb_components > 3 ? 3 : desc->nb_components); > > -- > 2.46.1 > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-request@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-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avfilter/xpsnr: avoid division by zero 2025-01-27 19:24 ` Marton Balint @ 2025-01-27 20:14 ` Jan Ekström 2025-01-28 9:48 ` Gyan Doshi 0 siblings, 1 reply; 5+ messages in thread From: Jan Ekström @ 2025-01-27 20:14 UTC (permalink / raw) To: FFmpeg development discussions and patches On Mon, Jan 27, 2025 at 9:23 PM Marton Balint <cus@passwd.hu> wrote: > > > > On Mon, 27 Jan 2025, Gyan Doshi wrote: > > > The ref input may have its frame rate unset, which would then lead to > > SIGFPE. > > > > Related to #11428 > > --- > > libavfilter/vf_xpsnr.c | 3 ++- > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > diff --git a/libavfilter/vf_xpsnr.c b/libavfilter/vf_xpsnr.c > > index 1b2c2a7c2c..8f86c188c5 100644 > > --- a/libavfilter/vf_xpsnr.c > > +++ b/libavfilter/vf_xpsnr.c > > @@ -568,7 +568,8 @@ static int config_input_ref(AVFilterLink *inlink) > > s->max_error_64 = (1 << s->depth) - 1; /* conventional limit */ > > s->max_error_64 *= s->max_error_64; > > > > - s->frame_rate = il->frame_rate.num / il->frame_rate.den; > > + // Avoid division by zero > > + s->frame_rate = il->frame_rate.den ? (il->frame_rate.num / il->frame_rate.den) : 25; > > I kind of prefer 0 instead of 25, as far as I see the code does not care, > and 0 is better than an arbitrary value. I do agree with the sentiment, but I think at least for myself the real question is whether we should attempt to get "correct results" or not, and thus either fail if a frame rate is not properly set, or at the very least warn loudly that the results may be incorrect (interpreted as less than 32fps) if the fps value is left unset. Also I do wonder if we should utilize time base if frame rate is not set, as I see that 1/0 is utilized for "undefined/variable rate". Best regards, Jan _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avfilter/xpsnr: avoid division by zero 2025-01-27 20:14 ` Jan Ekström @ 2025-01-28 9:48 ` Gyan Doshi 2025-02-01 14:26 ` Gyan Doshi 0 siblings, 1 reply; 5+ messages in thread From: Gyan Doshi @ 2025-01-28 9:48 UTC (permalink / raw) To: ffmpeg-devel On 2025-01-28 01:44 am, Jan Ekström wrote: > On Mon, Jan 27, 2025 at 9:23 PM Marton Balint <cus@passwd.hu> wrote: >> >> >> On Mon, 27 Jan 2025, Gyan Doshi wrote: >> >>> The ref input may have its frame rate unset, which would then lead to >>> SIGFPE. >>> >>> Related to #11428 >>> --- >>> libavfilter/vf_xpsnr.c | 3 ++- >>> 1 file changed, 2 insertions(+), 1 deletion(-) >>> >>> diff --git a/libavfilter/vf_xpsnr.c b/libavfilter/vf_xpsnr.c >>> index 1b2c2a7c2c..8f86c188c5 100644 >>> --- a/libavfilter/vf_xpsnr.c >>> +++ b/libavfilter/vf_xpsnr.c >>> @@ -568,7 +568,8 @@ static int config_input_ref(AVFilterLink *inlink) >>> s->max_error_64 = (1 << s->depth) - 1; /* conventional limit */ >>> s->max_error_64 *= s->max_error_64; >>> >>> - s->frame_rate = il->frame_rate.num / il->frame_rate.den; >>> + // Avoid division by zero >>> + s->frame_rate = il->frame_rate.den ? (il->frame_rate.num / il->frame_rate.den) : 25; >> I kind of prefer 0 instead of 25, as far as I see the code does not care, >> and 0 is better than an arbitrary value. > I do agree with the sentiment, but I think at least for myself the > real question is whether we should attempt to get "correct results" or > not, and thus either fail if a frame rate is not properly set, or at > the very least warn loudly that the results may be incorrect > (interpreted as less than 32fps) if the fps value is left unset. Also > I do wonder if we should utilize time base if frame rate is not set, > as I see that 1/0 is utilized for "undefined/variable rate". Does PSNR expect an attributes match between the two inputs - resolution, framerate... ? If yes, then can we set it to the main input framerate. If that is unset, then we assume <32 and log a warning. Regards, Gyan _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avfilter/xpsnr: avoid division by zero 2025-01-28 9:48 ` Gyan Doshi @ 2025-02-01 14:26 ` Gyan Doshi 0 siblings, 0 replies; 5+ messages in thread From: Gyan Doshi @ 2025-02-01 14:26 UTC (permalink / raw) To: ffmpeg-devel On 2025-01-28 03:18 pm, Gyan Doshi wrote: > > > On 2025-01-28 01:44 am, Jan Ekström wrote: >> On Mon, Jan 27, 2025 at 9:23 PM Marton Balint <cus@passwd.hu> wrote: >>> >>> >>> On Mon, 27 Jan 2025, Gyan Doshi wrote: >>> >>>> The ref input may have its frame rate unset, which would then lead to >>>> SIGFPE. >>>> >>>> Related to #11428 >>>> --- >>>> libavfilter/vf_xpsnr.c | 3 ++- >>>> 1 file changed, 2 insertions(+), 1 deletion(-) >>>> >>>> diff --git a/libavfilter/vf_xpsnr.c b/libavfilter/vf_xpsnr.c >>>> index 1b2c2a7c2c..8f86c188c5 100644 >>>> --- a/libavfilter/vf_xpsnr.c >>>> +++ b/libavfilter/vf_xpsnr.c >>>> @@ -568,7 +568,8 @@ static int config_input_ref(AVFilterLink *inlink) >>>> s->max_error_64 = (1 << s->depth) - 1; /* conventional limit */ >>>> s->max_error_64 *= s->max_error_64; >>>> >>>> - s->frame_rate = il->frame_rate.num / il->frame_rate.den; >>>> + // Avoid division by zero >>>> + s->frame_rate = il->frame_rate.den ? (il->frame_rate.num / >>>> il->frame_rate.den) : 25; >>> I kind of prefer 0 instead of 25, as far as I see the code does not >>> care, >>> and 0 is better than an arbitrary value. >> I do agree with the sentiment, but I think at least for myself the >> real question is whether we should attempt to get "correct results" or >> not, and thus either fail if a frame rate is not properly set, or at >> the very least warn loudly that the results may be incorrect >> (interpreted as less than 32fps) if the fps value is left unset. Also >> I do wonder if we should utilize time base if frame rate is not set, >> as I see that 1/0 is utilized for "undefined/variable rate". > > Does PSNR expect an attributes match between the two inputs - > resolution, framerate... ? If yes, then can we set it to the main > input framerate. If that is unset, then we assume <32 and log a warning. I'll send a patch soon using the other inlink's rate unless someone has a better idea. Regards, Gyan _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-02-01 14:26 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2025-01-27 5:28 [FFmpeg-devel] [PATCH] avfilter/xpsnr: avoid division by zero Gyan Doshi 2025-01-27 19:24 ` Marton Balint 2025-01-27 20:14 ` Jan Ekström 2025-01-28 9:48 ` Gyan Doshi 2025-02-01 14:26 ` Gyan Doshi
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git