Commit 7adcef146d for ffmpeg
commit 7adcef146dc9c8d3cd99d762a8c758371309ce92
Author: Romain Beauxis <romain.beauxis@gmail.com>
Date: Sun Oct 18 11:27:54 2026 +0200
libavformat/tests/seek_utils: print the rescaled intervals
Print each interval before and after ff_rescale_interval() and compare
them against a reference, so that a change in the rounding shows there.
The reference records the current output, where the rescaled target can
fall outside the rescaled range: 11 after an end of 10, and 3 before a
start of 4.
diff --git a/libavformat/tests/seek_utils.c b/libavformat/tests/seek_utils.c
index 4cb94ad685..dc979e274c 100644
--- a/libavformat/tests/seek_utils.c
+++ b/libavformat/tests/seek_utils.c
@@ -18,40 +18,24 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <inttypes.h>
+#include <stdio.h>
+
#include "libavformat/demux.h"
-int main(void)
+static void rescale(AVRational tb_in, AVRational tb_out,
+ int64_t ts_min, int64_t ts, int64_t ts_max)
{
- int64_t ts_min;
- int64_t ts;
- int64_t ts_max;
-
- ts_min = 10;
- ts = 20;
- ts_max = 30;
-
- ff_rescale_interval(av_make_q(1, 1), av_make_q(10, 1), &ts_min, &ts, &ts_max);
-
- if (ts_min != 1 || ts != 2 || ts_max != 3)
- return 1;
-
- ts_min = 10;
- ts = 32;
- ts_max = 32;
-
- ff_rescale_interval(av_make_q(1, 1), av_make_q(3, 1), &ts_min, &ts, &ts_max);
-
- if (ts_min != 4 || ts != 11 || ts_max != 10)
- return 1;
-
- ts_min = 10;
- ts = 10;
- ts_max = 32;
-
- ff_rescale_interval(av_make_q(1, 1), av_make_q(3, 1), &ts_min, &ts, &ts_max);
-
- if (ts_min != 4 || ts != 3 || ts_max != 10)
- return 1;
+ printf("%d/%d -> %d/%d: [%"PRId64", %"PRId64", %"PRId64"] -> ",
+ tb_in.num, tb_in.den, tb_out.num, tb_out.den, ts_min, ts, ts_max);
+ ff_rescale_interval(tb_in, tb_out, &ts_min, &ts, &ts_max);
+ printf("[%"PRId64", %"PRId64", %"PRId64"]\n", ts_min, ts, ts_max);
+}
- return 0;
+int main(void)
+{
+ rescale(av_make_q(1, 1), av_make_q(10, 1), 10, 20, 30);
+ rescale(av_make_q(1, 1), av_make_q(3, 1), 10, 32, 32);
+ rescale(av_make_q(1, 1), av_make_q(3, 1), 10, 10, 32);
+ return 0;
}
diff --git a/tests/fate/libavformat.mak b/tests/fate/libavformat.mak
index b8ab012334..68b5f6c101 100644
--- a/tests/fate/libavformat.mak
+++ b/tests/fate/libavformat.mak
@@ -118,7 +118,6 @@ fate-imf: CMD = run libavformat/tests/imf$(EXESUF)
FATE_LIBAVFORMAT += fate-seek_utils
fate-seek_utils: libavformat/tests/seek_utils$(EXESUF)
fate-seek_utils: CMD = run libavformat/tests/seek_utils$(EXESUF)
-fate-seek_utils: CMP = null
FATE_LIBAVFORMAT += $(FATE_LIBAVFORMAT-yes)
FATE-$(CONFIG_AVFORMAT) += $(FATE_LIBAVFORMAT)
diff --git a/tests/ref/fate/seek_utils b/tests/ref/fate/seek_utils
new file mode 100644
index 0000000000..ddb0517a45
--- /dev/null
+++ b/tests/ref/fate/seek_utils
@@ -0,0 +1,3 @@
+1/1 -> 10/1: [10, 20, 30] -> [1, 2, 3]
+1/1 -> 3/1: [10, 32, 32] -> [4, 11, 10]
+1/1 -> 3/1: [10, 10, 32] -> [4, 3, 10]