History

avformat/tests: add test for ff_rescale_interval()

Pierre-Anthony Lemieux committed 4 years ago

Commit 8744b101 parent b172c0f4 files · +64 −0Browse files

Unified · Split

4 files
  1. libavformat/Makefile +1 −0
  2. libavformat/tests/.gitignore +1 −0
  3. libavformat/tests/seek_utils.c +57 −0
  4. tests/fate/libavformat.mak +5 −0
libavformat/Makefile+1−0
@@ -711,6 +711,7 @@ SKIPHEADERS-$(CONFIG_NETWORK) += network.h rtsp.h · 710 unmodified lines
711 711
712TESTPROGS = seek \712TESTPROGS = seek \
713 url \713 url \
714 seek_utils
714# async \715# async \
715 716
716FIFO-MUXER-TESTPROGS-$(CONFIG_NETWORK) += fifo_muxer717FIFO-MUXER-TESTPROGS-$(CONFIG_NETWORK) += fifo_muxer
libavformat/tests/.gitignore+1−0
@@ -6,3 +6,4 @@ · 5 unmodified lines
6/seek6/seek
7/srtp7/srtp
8/url8/url
9/seek_utils
libavformat/tests/seek_utils.c+57−0
@@ -0,0 +1,57 @@
1/*
2 * Copyright (c) 2022 Pierre-Anthony Lemieux <pal@palemieux.com>
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#include "libavformat/internal.h"
22
23int main(void)
24{
25 int64_t ts_min;
26 int64_t ts;
27 int64_t ts_max;
28
29 ts_min = 10;
30 ts = 20;
31 ts_max = 30;
32
33 ff_rescale_interval(av_make_q(1, 1), av_make_q(10, 1), &ts_min, &ts, &ts_max);
34
35 if (ts_min != 1 || ts != 2 || ts_max != 3)
36 return 1;
37
38 ts_min = 10;
39 ts = 32;
40 ts_max = 32;
41
42 ff_rescale_interval(av_make_q(1, 1), av_make_q(3, 1), &ts_min, &ts, &ts_max);
43
44 if (ts_min != 4 || ts != 11 || ts_max != 10)
45 return 1;
46
47 ts_min = 10;
48 ts = 10;
49 ts_max = 32;
50
51 ff_rescale_interval(av_make_q(1, 1), av_make_q(3, 1), &ts_min, &ts, &ts_max);
52
53 if (ts_min != 4 || ts != 3 || ts_max != 10)
54 return 1;
55
56 return 0;
57}
tests/fate/libavformat.mak+5−0
@@ -26,6 +26,11 @@ FATE_LIBAVFORMAT-$(CONFIG_IMF_DEMUXER) += fate-imf · 25 unmodified lines
26fate-imf: libavformat/tests/imf$(EXESUF)26fate-imf: libavformat/tests/imf$(EXESUF)
27fate-imf: CMD = run libavformat/tests/imf$(EXESUF)27fate-imf: CMD = run libavformat/tests/imf$(EXESUF)
28 28
29FATE_LIBAVFORMAT += fate-seek_utils
30fate-seek_utils: libavformat/tests/seek_utils$(EXESUF)
31fate-seek_utils: CMD = run libavformat/tests/seek_utils$(EXESUF)
32fate-seek_utils: CMP = null
33
29FATE_LIBAVFORMAT += $(FATE_LIBAVFORMAT-yes)34FATE_LIBAVFORMAT += $(FATE_LIBAVFORMAT-yes)
30FATE-$(CONFIG_AVFORMAT) += $(FATE_LIBAVFORMAT)35FATE-$(CONFIG_AVFORMAT) += $(FATE_LIBAVFORMAT)
31fate-libavformat: $(FATE_LIBAVFORMAT)36fate-libavformat: $(FATE_LIBAVFORMAT)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t