Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Gyan Doshi <ffmpeg@gyani.pro>
To: ffmpeg-devel@ffmpeg.org
Subject: Re: [FFmpeg-devel] [PATCH v2] avfilter/xpsnr: avoid division by zero
Date: Wed, 5 Feb 2025 12:09:37 +0530
Message-ID: <9654deca-aa9e-43e2-a069-93fe8d62ec3e@gyani.pro> (raw)
In-Reply-To: <20250202175707.773-1-ffmpeg@gyani.pro>



On 2025-02-02 11:27 pm, Gyan Doshi wrote:
> The ref input may have its frame rate unset, which would then lead to
> SIGFPE. So fall back to the main link frame rate. If that too is unset,
> default to 0.
>
> Related to #11428

Plan to push tomorrow.

Regards,
Gyan


> ---
>   libavfilter/vf_xpsnr.c | 5 ++++-
>   1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/libavfilter/vf_xpsnr.c b/libavfilter/vf_xpsnr.c
> index 1b2c2a7c2c..3097db0878 100644
> --- a/libavfilter/vf_xpsnr.c
> +++ b/libavfilter/vf_xpsnr.c
> @@ -552,6 +552,7 @@ static int config_input_ref(AVFilterLink *inlink)
>       AVFilterContext  *ctx = inlink->dst;
>       XPSNRContext *const s = ctx->priv;
>       FilterLink *il = ff_filter_link(inlink);
> +    FilterLink *ml = ff_filter_link(ctx->inputs[0]);
>   
>       if ((ctx->inputs[0]->w != ctx->inputs[1]->w) ||
>           (ctx->inputs[0]->h != ctx->inputs[1]->h)) {
> @@ -568,7 +569,9 @@ 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) :
> +                    ml->frame_rate.den ? (ml->frame_rate.num / ml->frame_rate.den) : 0;
>   
>       s->num_comps = (desc->nb_components > 3 ? 3 : desc->nb_components);
>   

_______________________________________________
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".

  reply	other threads:[~2025-02-05  6:39 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-02 17:57 Gyan Doshi
2025-02-05  6:39 ` Gyan Doshi [this message]
2025-02-06 10:39   ` Gyan Doshi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9654deca-aa9e-43e2-a069-93fe8d62ec3e@gyani.pro \
    --to=ffmpeg@gyani.pro \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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