diff options
author | Gyan Doshi <ffmpeg@gyani.pro> | 2025-01-27 10:54:07 +0530 |
---|---|---|
committer | Gyan Doshi <ffmpeg@gyani.pro> | 2025-02-06 16:06:20 +0530 |
commit | 6da82b448568a1875b32a7135fe30b7da8d197e7 (patch) | |
tree | 96b431b57fcc8c545a321c52fbe1beb383b64034 | |
parent | 779a3187a8002aa7c375b3882d8010926656558e (diff) | |
download | ffmpeg-6da82b448568a1875b32a7135fe30b7da8d197e7.tar.gz |
avfilter/xpsnr: avoid division by zero
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
-rw-r--r-- | libavfilter/vf_xpsnr.c | 5 |
1 files changed, 4 insertions, 1 deletions
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); |