avutil/rational: never return greater num/den than the maximum allowed in av_d2q

This reverts 887d74c47e, because it ignores the
maximum allowed numerator/denominator. Even if the result was rounded to zero
or infinity, it should not be cause to ignore the maximum allowed number, this
"feature" is unintuitive and undocumented.

Signed-off-by: Marton Balint <cus@passwd.hu>
This commit is contained in:
Marton Balint 2024-11-10 14:10:03 +01:00
parent 25efe34e6f
commit d884606ce0

View File

@ -118,8 +118,6 @@ AVRational av_d2q(double d, int max)
// (int64_t)rint() and llrint() do not work with gcc on ia64 and sparc64,
// see Ticket2713 for affected gcc/glibc versions
av_reduce(&a.num, &a.den, floor(d * den + 0.5), den, max);
if ((!a.num || !a.den) && d && max>0 && max<INT_MAX)
av_reduce(&a.num, &a.den, floor(d * den + 0.5), den, INT_MAX);
return a;
}