Skip to content

Commit 6da82b4

Browse files
committed
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
1 parent 779a318 commit 6da82b4

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

libavfilter/vf_xpsnr.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,7 @@ static int config_input_ref(AVFilterLink *inlink)
552552
AVFilterContext *ctx = inlink->dst;
553553
XPSNRContext *const s = ctx->priv;
554554
FilterLink *il = ff_filter_link(inlink);
555+
FilterLink *ml = ff_filter_link(ctx->inputs[0]);
555556

556557
if ((ctx->inputs[0]->w != ctx->inputs[1]->w) ||
557558
(ctx->inputs[0]->h != ctx->inputs[1]->h)) {
@@ -568,7 +569,9 @@ static int config_input_ref(AVFilterLink *inlink)
568569
s->max_error_64 = (1 << s->depth) - 1; /* conventional limit */
569570
s->max_error_64 *= s->max_error_64;
570571

571-
s->frame_rate = il->frame_rate.num / il->frame_rate.den;
572+
// Avoid division by zero
573+
s->frame_rate = il->frame_rate.den ? (il->frame_rate.num / il->frame_rate.den) :
574+
ml->frame_rate.den ? (ml->frame_rate.num / ml->frame_rate.den) : 0;
572575

573576
s->num_comps = (desc->nb_components > 3 ? 3 : desc->nb_components);
574577

0 commit comments

Comments
 (0)