From: pal@sandflow.com To: ffmpeg-devel@ffmpeg.org Cc: Pierre-Anthony Lemieux <pal@palemieux.com> Subject: [FFmpeg-devel] [PATCH v2 5/7] avutil/tests: add test for avutil/mathematics Date: Sun, 20 Feb 2022 22:02:28 -0800 Message-ID: <20220221060230.6665-5-pal@sandflow.com> (raw) In-Reply-To: <20220221060230.6665-1-pal@sandflow.com> From: Pierre-Anthony Lemieux <pal@palemieux.com> --- libavutil/Makefile | 1 + libavutil/tests/.gitignore | 1 + libavutil/tests/mathematics.c | 57 +++++++++++++++++++++++++++++++++++ tests/fate/libavutil.mak | 5 +++ 4 files changed, 64 insertions(+) create mode 100644 libavutil/tests/mathematics.c diff --git a/libavutil/Makefile b/libavutil/Makefile index d17876df1a..d1c002e43f 100644 --- a/libavutil/Makefile +++ b/libavutil/Makefile @@ -239,6 +239,7 @@ TESTPROGS = adler32 \ lfg \ lls \ log \ + mathematics \ md5 \ murmur3 \ opt \ diff --git a/libavutil/tests/.gitignore b/libavutil/tests/.gitignore index 9d90827954..aba94af388 100644 --- a/libavutil/tests/.gitignore +++ b/libavutil/tests/.gitignore @@ -30,6 +30,7 @@ /lls /log /lzo +/mathematics /md5 /murmur3 /opt diff --git a/libavutil/tests/mathematics.c b/libavutil/tests/mathematics.c new file mode 100644 index 0000000000..45a82617aa --- /dev/null +++ b/libavutil/tests/mathematics.c @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2022 Pierre-Anthony Lemieux <pal@palemieux.com> + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/mathematics.h" + +int main(void) +{ + int64_t ts_min; + int64_t ts; + int64_t ts_max; + + ts_min = 10; + ts = 20; + ts_max = 30; + + av_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; + + av_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; + + av_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; + + return 0; +} diff --git a/tests/fate/libavutil.mak b/tests/fate/libavutil.mak index 1ec9ed00ad..92b9b82aa8 100644 --- a/tests/fate/libavutil.mak +++ b/tests/fate/libavutil.mak @@ -166,6 +166,11 @@ FATE_LIBAVUTIL += fate-opt fate-opt: libavutil/tests/opt$(EXESUF) fate-opt: CMD = run libavutil/tests/opt$(EXESUF) +FATE_LIBAVUTIL += fate-mathematics +fate-mathematics: libavutil/tests/mathematics$(EXESUF) +fate-mathematics: CMD = run libavutil/tests/mathematics$(EXESUF) +fate-mathematics: CMP = null + FATE_LIBAVUTIL += $(FATE_LIBAVUTIL-yes) FATE-$(CONFIG_AVUTIL) += $(FATE_LIBAVUTIL) fate-libavutil: $(FATE_LIBAVUTIL) -- 2.17.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next prev parent reply other threads:[~2022-02-21 6:03 UTC|newest] Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-02-21 6:02 [FFmpeg-devel] [PATCH v2 1/7] avformat/imf: relocate static function imf_time_to_ts() pal 2022-02-21 6:02 ` [FFmpeg-devel] [PATCH v2 2/7] avformat/imf: add support for input seeking pal 2022-02-21 6:02 ` [FFmpeg-devel] [PATCH v2 3/7] avformat/imf: clean-up and reduce logging pal 2022-02-21 6:02 ` [FFmpeg-devel] [PATCH v2 4/7] avutil/mathematics: add av_rescale_interval() function pal 2022-03-04 20:13 ` Andreas Rheinhardt 2022-03-04 20:40 ` Pierre-Anthony Lemieux 2022-03-07 22:17 ` Pierre-Anthony Lemieux 2022-02-21 6:02 ` pal [this message] 2022-02-21 6:02 ` [FFmpeg-devel] [PATCH v2 6/7] avformat/imf: refactor to use av_rescale_interval() pal 2022-02-21 6:02 ` [FFmpeg-devel] [PATCH v2 7/7] avformat/concat: " pal 2022-02-21 10:30 ` Nicolas George 2022-03-04 16:20 ` [FFmpeg-devel] Ping " Pierre-Anthony Lemieux
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220221060230.6665-5-pal@sandflow.com \ --to=pal@sandflow.com \ --cc=ffmpeg-devel@ffmpeg.org \ --cc=pal@palemieux.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git