Go to the documentation of this file.
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");
@ AV_ROUND_UP
Round toward +infinity.
__device__ int printf(const char *,...)
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_add_stable(AVRational ts_tb, int64_t ts, AVRational inc_tb, int64_t inc)
Add a value to a timestamp.
@ AV_ROUND_ZERO
Round toward zero.
AVRounding
Rounding methods.
int64_t av_gcd(int64_t a, int64_t b)
Compute the greatest common divisor of two integer operands.
#define FF_ARRAY_ELEMS(a)
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
@ AV_ROUND_NEAR_INF
Round to nearest and halfway cases away from zero.
@ AV_ROUND_PASS_MINMAX
Flag telling rescaling functions to pass INT64_MIN/MAX through unchanged, avoiding special cases for ...
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.
Rational number (pair of numerator and denominator).
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
@ AV_ROUND_DOWN
Round toward -infinity.
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.
#define i(width, name, range_min, range_max)
#define AV_NOPTS_VALUE
Undefined timestamp value.
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
@ AV_ROUND_INF
Round away from zero.
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_compare_mod(uint64_t a, uint64_t b, uint64_t mod)
Compare the remainders of two integer operands divided by a common divisor.