37 int64_t num, int64_t den, int64_t max)
40 int sign = (num < 0) ^ (den < 0);
47 if (num <= max && den <= max) {
53 uint64_t x = num / den;
54 int64_t next_den = num - den * x;
55 int64_t a2n = x *
a1.num + a0.
num;
56 int64_t a2d = x *
a1.den + a0.
den;
58 if (a2n > max || a2d > max) {
59 if (
a1.num) x = (max - a0.
num) /
a1.num;
62 if (den * (2 * x *
a1.den + a0.
den) > num *
a1.den)
74 *dst_num = sign ? -
a1.num :
a1.num;
84 b.
den * (int64_t) c.
den, INT_MAX);
97 b.
den * (int64_t) c.
den, INT_MAX);
109 #define LOG2 0.69314718055994530941723212145817656807550013436025
116 exponent =
FFMAX( (
int)(log(fabs(d) + 1e-20)/
LOG2), 0);
117 den = 1LL << (61 - exponent);
126 int64_t
a = q1.
num * (int64_t)q2.
den + q2.
num * (int64_t)q1.
den;
127 int64_t
b = 2 * (int64_t)q1.
den * q2.
den;
140 int i, nearest_q_idx = 0;
141 for (i = 0; q_list[i].
den; i++)
142 if (
av_nearer_q(q, q_list[i], q_list[nearest_q_idx]) > 0)
145 return nearest_q_idx;
160 else if (d < 0) d = -1;
161 else if (d != d) d = INT_MIN;