33 printf(
"Testing av_gcd()\n");
34 static const struct {
int64_t a,
b, expected; } gcd_tests[] = {
46 printf(
"gcd(%"PRId64
", %"PRId64
") = %"PRId64
" %s\n",
47 gcd_tests[
i].
a, gcd_tests[
i].
b,
49 av_gcd(gcd_tests[
i].
a, gcd_tests[
i].
b) == gcd_tests[
i].expected ?
"OK" :
"FAIL");
52 printf(
"\nTesting av_rescale()\n");
57 printf(
"rescale(90000, 1, 90000) = %"PRId64
"\n",
av_rescale(90000, 1, 90000));
60 printf(
"\nTesting av_rescale_rnd()\n");
79 rnd_tests[
i].
c, rnd_tests[
i].
rnd);
80 printf(
"rescale_rnd(%"PRId64
", %"PRId64
", %"PRId64
", %d) = %"PRId64
" %s\n",
81 rnd_tests[
i].
a, rnd_tests[
i].
b, rnd_tests[
i].
c,
83 r == rnd_tests[
i].expected ?
"OK" :
"FAIL");
87 printf(
"\nTesting AV_ROUND_PASS_MINMAX\n");
88 printf(
"INT64_MIN passthrough: %s\n",
91 printf(
"INT64_MAX passthrough: %s\n",
94 printf(
"normal with PASS_MINMAX: %"PRId64
"\n",
98 printf(
"\nTesting large value rescale\n");
99 printf(
"rescale(INT64_MAX/2, 2, 1) = %"PRId64
"\n",
101 printf(
"rescale(1000000007, 1000000009, 1000000007) = %"PRId64
"\n",
102 av_rescale(1000000007LL, 1000000009LL, 1000000007LL));
104 printf(
"rescale_rnd(10, INT_MAX+1, INT_MAX+1, ZERO) = %"PRId64
"\n",
106 printf(
"rescale_rnd(7, 3000000000, 2000000000, NEAR_INF) = %"PRId64
"\n",
110 printf(
"\nTesting av_rescale_q()\n");
111 printf(
"rescale_q(90000, 1/90000, 1/1000) = %"PRId64
"\n",
113 printf(
"rescale_q(48000, 1/48000, 1/44100) = %"PRId64
"\n",
117 printf(
"\nTesting av_compare_ts()\n");
118 printf(
"compare(1, 1/1, 1, 1/1) = %d\n",
120 printf(
"compare(1, 1/1, 2, 1/1) = %d\n",
122 printf(
"compare(2, 1/1, 1, 1/1) = %d\n",
124 printf(
"compare(1, 1/1000, 1, 1/90000) = %d\n",
127 printf(
"compare(INT64_MAX/2, 1/1, INT64_MAX/3, 1/1) = %d\n",
132 printf(
"\nTesting av_compare_mod()\n");
138 printf(
"\nTesting av_rescale_delta()\n");
140 for (
int i = 0;
i < 4;
i++)
141 printf(
"delta step %d: %"PRId64
"\n",
i,
147 for (
int i = 0;
i < 4;
i++)
148 printf(
"delta clip %d: %"PRId64
"\n",
i,
154 printf(
"\nTesting av_add_stable()\n");
155 printf(
"add_stable(0, 1/1, 1/1000, 500) = %"PRId64
"\n",
157 printf(
"add_stable(1000, 1/90000, 1/48000, 1024) = %"PRId64
"\n",
160 printf(
"add_stable(0, 1/48000, 1/90000, 90000) = %"PRId64
"\n",
162 printf(
"add_stable(100, 1/1000, 1/90000, 3000) = %"PRId64
"\n",
167 for (
int i = 0;
i < 10000;
i++)
169 printf(
"add_stable 10000x1024 at 1/48000: %"PRId64
" (expected %"PRId64
") %s\n",
171 ts == (
int64_t)10000 * 1024 ?
"OK" :
"FAIL");
Convenience header that includes libavutil's core.
#define i(width, name, range_min, range_max)
__device__ int printf(const char *,...)
int64_t av_add_stable(AVRational ts_tb, int64_t ts, AVRational inc_tb, int64_t inc)
Add a value to a timestamp.
int av_compare_ts(int64_t ts_a, AVRational tb_a, int64_t ts_b, AVRational tb_b)
Compare two timestamps each in its own time base.
int64_t av_rescale_delta(AVRational in_tb, int64_t in_ts, AVRational fs_tb, int duration, int64_t *last, AVRational out_tb)
Rescale a timestamp while preserving known durations.
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding rnd)
Rescale a 64-bit integer with specified rounding.
AVRounding
Rounding methods.
int64_t av_gcd(int64_t a, int64_t b)
Compute the greatest common divisor of two integer operands.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
int64_t av_compare_mod(uint64_t a, uint64_t b, uint64_t mod)
Compare the remainders of two integer operands divided by a common divisor.
@ AV_ROUND_INF
Round away from zero.
@ AV_ROUND_ZERO
Round toward zero.
@ AV_ROUND_DOWN
Round toward -infinity.
@ AV_ROUND_PASS_MINMAX
Flag telling rescaling functions to pass INT64_MIN/MAX through unchanged, avoiding special cases for ...
@ AV_ROUND_UP
Round toward +infinity.
@ AV_ROUND_NEAR_INF
Round to nearest and halfway cases away from zero.
#define AV_NOPTS_VALUE
Undefined timestamp value.
Utility Preprocessor macros.
Utilities for rational number calculation.
#define FF_ARRAY_ELEMS(a)
Rational number (pair of numerator and denominator).