From patchwork Fri Mar 11 17:16:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Anthony Lemieux X-Patchwork-Id: 34709 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6838:3486:0:0:0:0 with SMTP id ek6csp1887512nkb; Fri, 11 Mar 2022 09:18:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJxA0qmDw7gBYqf7pgp0HbvSZawZQVJGzdYgWDQULUPLUI31GksPriAq7uDhfHJ0E4ERlEMK X-Received: by 2002:a17:907:2d24:b0:6db:aec7:fbad with SMTP id gs36-20020a1709072d2400b006dbaec7fbadmr2547304ejc.663.1647019082274; Fri, 11 Mar 2022 09:18:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1647019082; cv=none; d=google.com; s=arc-20160816; b=qYW884VTRGYjJ6INlmaKxjWZtxn4VmmMPhiT35+hwU1wxkoa0O+oiMiXGnVVO3vE7a KWBLcmticf8eleeqkOiDJkoj4kbYv4NQl45gn6y8CZguEK9AXPljcXMUOKjrmuSS28e7 mllYD2CKqBr6gt7AaHy/s31kTvx5XiTd2DWnYaxo4UB3KBqa3spiyS1ln78lXdoxc4PV KraOA6puFJZN16aWje9LFMtPPqoCgbd17rSeEED4qbcvkT46LVvK05gOevnDcsof2jHd oa+XHBj7EE1K+X1zuUmsYtNIUrnN8PSIicaLgTjxiWYQhGBe1k1szFFFQynrJx8Vxhj4 CN5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:delivered-to; bh=cK45xeLfTlIjEHoeKpqv+kB5sCbvPYTVZnkOR7woHeQ=; b=yD1PghRqUJVoCOQEoTVDEHEXfsfaQgE0/9VzMVNKsAsPdI69fWmnumhlPe6QvNb9+b mdVs0hgvIPqiqW/tB2r4kZzbkrQmUw8eR07Xci+dA++6U1mqSuZDOYahcU7JpPVi9BRR WZoh+MbhRy+3ALBGRZAPuQjxGtd5AmK8ZhdpmcjHDRVPE/7nYFHAYYIykGxaICTNEUbn DV7ozwMCNSGCqIttWDWo230mzncTo5UL3aVKG2zOy36jSxT5iSaARG6j1ty5FFABAOWp i80icvssdpYRfAG6bWUBcA0WCw+sDmp/5Id4ArEUWPmgK5FQghaX+YzAI2VQQKuHT4Wq snRw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id y9-20020a056402270900b00416a367fdf3si5008117edd.218.2022.03.11.09.18.01; Fri, 11 Mar 2022 09:18:02 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6107F68B212; Fri, 11 Mar 2022 19:17:39 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DF6B468B1AD for ; Fri, 11 Mar 2022 19:17:32 +0200 (EET) Received: by mail-pf1-f171.google.com with SMTP id s42so8419582pfg.0 for ; Fri, 11 Mar 2022 09:17:32 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LvwfvNlGVHZuhVtg+lmT5bw4ndoYln0ZV2ufauG2Ems=; b=vm7iTSSTlJwRR10OE7Y+E7kYXgC8A4/rKaUNjzxGYBunpmkH/Q2TrapqQnV7EPy/49 /MenFi8sneltxaVnSqJi70g1o/EJa5J6/DT1pfE9Ni5KI3VEqIy7Fu1jYLUyblca9QeH OPMNG0JC+CKsKp60ucS2OMVN5PBqgB4XnklADeksoVMWAwKJjijy5kY5haG/JWMritqM 8D4C4G+r93GANeDmrNdUyushrP8x64io0QR6O8DIRTX7FF+96HBZT/5lVEwv84uw/4Pt Of3kLQlIAl6EHGTYOp1GN+JMIEDJzCYTexU2S/MiTnVJZ2wfDp2+KNyyssPEDZotaY10 us/w== X-Gm-Message-State: AOAM530uU21nmkd4kDjfTtxWOHJZGkC2g7PAxD05BXCxCuKRKGwqzVpi yXcH/WQI6CwBSeTKD1Pl40t3bnOdfEU= X-Received: by 2002:a05:6a00:a2a:b0:4f7:68db:5e60 with SMTP id p42-20020a056a000a2a00b004f768db5e60mr11249941pfh.58.1647019050550; Fri, 11 Mar 2022 09:17:30 -0800 (PST) Received: from localhost (76-14-89-2.sf-cable.astound.net. [76.14.89.2]) by smtp.gmail.com with ESMTPSA id m8-20020a17090a158800b001bf2cec0377sm14952851pja.3.2022.03.11.09.17.28 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 11 Mar 2022 09:17:30 -0800 (PST) Received: by localhost (sSMTP sendmail emulation); Fri, 11 Mar 2022 09:17:26 -0800 From: pal@sandflow.com To: ffmpeg-devel@ffmpeg.org Date: Fri, 11 Mar 2022 09:16:51 -0800 Message-Id: <20220311171653.17420-5-pal@sandflow.com> X-Mailer: git-send-email 2.35.1.windows.2 In-Reply-To: <20220311171653.17420-1-pal@sandflow.com> References: <20220311171653.17420-1-pal@sandflow.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v4 5/7] avformat/tests: add test for ff_rescale_interval() X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Pierre-Anthony Lemieux Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: dD7igyE7SzKH From: Pierre-Anthony Lemieux --- libavformat/Makefile | 1 + libavformat/tests/.gitignore | 1 + libavformat/tests/seek_utils.c | 57 ++++++++++++++++++++++++++++++++++ tests/fate/libavformat.mak | 5 +++ 4 files changed, 64 insertions(+) create mode 100644 libavformat/tests/seek_utils.c diff --git a/libavformat/Makefile b/libavformat/Makefile index 6566e40cac..3acc939551 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -707,6 +707,7 @@ SKIPHEADERS-$(CONFIG_NETWORK) += network.h rtsp.h TESTPROGS = seek \ url \ + seek_utils # async \ FIFO-MUXER-TESTPROGS-$(CONFIG_NETWORK) += fifo_muxer diff --git a/libavformat/tests/.gitignore b/libavformat/tests/.gitignore index aabf76345e..cdd0cce061 100644 --- a/libavformat/tests/.gitignore +++ b/libavformat/tests/.gitignore @@ -6,3 +6,4 @@ /seek /srtp /url +/seek_utils diff --git a/libavformat/tests/seek_utils.c b/libavformat/tests/seek_utils.c new file mode 100644 index 0000000000..cc679dca05 --- /dev/null +++ b/libavformat/tests/seek_utils.c @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2022 Pierre-Anthony Lemieux + * + * 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 "libavformat/internal.h" + +int main(void) +{ + 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; + + return 0; +} diff --git a/tests/fate/libavformat.mak b/tests/fate/libavformat.mak index 59ff0ebc8d..d2acb4c9e0 100644 --- a/tests/fate/libavformat.mak +++ b/tests/fate/libavformat.mak @@ -26,6 +26,11 @@ FATE_LIBAVFORMAT-$(CONFIG_IMF_DEMUXER) += fate-imf fate-imf: libavformat/tests/imf$(EXESUF) 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) fate-libavformat: $(FATE_LIBAVFORMAT)