swscale/ops_optimizer: omit overflow check on SWS_OP_SCALE

1. This is currently impossible to trigger
2. We're about to switch to AVRational64, eliminating this concern
3. The AVRational64 API intentionally doesn't expose av_reduce64()

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
This commit is contained in:
Niklas Haas
2026-04-28 12:06:26 +02:00
parent 845a3bfcec
commit aff6d64ecd

View File

@@ -724,15 +724,11 @@ retry:
goto retry;
}
/* Merge consecutive scaling operations (that don't overflow) */
/* Merge consecutive scaling operations */
if (next->op == SWS_OP_SCALE) {
int64_t p = op->scale.factor.num * (int64_t) next->scale.factor.num;
int64_t q = op->scale.factor.den * (int64_t) next->scale.factor.den;
if (FFABS(p) <= INT_MAX && FFABS(q) <= INT_MAX) {
av_reduce(&op->scale.factor.num, &op->scale.factor.den, p, q, INT_MAX);
ff_sws_op_list_remove_at(ops, n + 1, 1);
goto retry;
}
op->scale.factor = av_mul_q(op->scale.factor, next->scale.factor);
ff_sws_op_list_remove_at(ops, n + 1, 1);
goto retry;
}
/* Scaling by exact power of two */