From patchwork Mon Mar 7 22:15:40 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: 34635 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6838:d078:0:0:0:0 with SMTP id x24csp1905671nkx; Mon, 7 Mar 2022 14:17:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJz4VH8d9caEyt1k1wrWSbrj6+9K1yiRr0YbiWVEPILa4z/PmySaz84KMPgtJ0lQbsRMAiDH X-Received: by 2002:a50:f68b:0:b0:415:a36c:5c0b with SMTP id d11-20020a50f68b000000b00415a36c5c0bmr12941540edn.272.1646691420783; Mon, 07 Mar 2022 14:17:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646691420; cv=none; d=google.com; s=arc-20160816; b=fKB4chCsb9jPI7fIufVepyqeeRv1WmMveXciEn3Sg0trl/71t87UPGXHkYMqzdd3kh +brIpT8r4MWkN5zhj32sNdbRC3gSjXn5mMFjy8f0JtQy7MQj+mdABrrIobYwOlMN0xNS DOPa0zkO4eyVtm+ge87K69K1RwElj7QSIhsSqpjPRpMkwB3ZVQFL3rjntHgCbQUsTNaB RgBl/HiiFj0L58u3yJyamPCqosrg1aUGLl+AH+oCKUVN0Ox0tkAA2lfZSTMtwNFJW5da /OIXnxeFhQiIPw+hBA5CmMOc0HPZGxCMggBbQzqYLo44ZSgWZ65b2g0Nh05AE+4UjSPY u/6Q== 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=2bLUrieanKKB1N6rWACGhMIzs5WgrGmWp1vWqWsVzCQ=; b=NnIVHFOnUfl5CLarltjKOWIZxhTVo0pbC82pVMnUFHNjS1PjGgfC3FeFASHIIhLsc4 XyJLjis2odm9T2wnGOuU0FASGvTn9xmtmW34jKpP/YO58qaFB6vn8oD5F/4pOTTm/Vjm Txg3zn9QnziuDmLKOdt9EtS/jh6GSoKcQXB0YKYFGzlY5IjvyMG1zH2i6M8Ue6QmeAgT up5dDTtAp2pTZAsDq2JgHwMxgAhMjAiSi9cCjVnY3TRCIhLaollIL92bY00MXc+BuV++ K1fqqTn91wATAUtlPN1uhT7tlzT5k3QbZIIew598FCGII7hcJ37CWeNq41pkIlNmN+fr L7cA== 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 hc44-20020a17090716ac00b006d8d52ba7easi10324905ejc.239.2022.03.07.14.17.00; Mon, 07 Mar 2022 14:17:00 -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 4C12368B1A8; Tue, 8 Mar 2022 00:16:28 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 25C9C68A7A1 for ; Tue, 8 Mar 2022 00:16:21 +0200 (EET) Received: by mail-pl1-f171.google.com with SMTP id t19so11738257plr.5 for ; Mon, 07 Mar 2022 14:16:21 -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=Mhh/yKibK1ghoBoKp4Q8Ihtw/ZH51lTXqJpqVMCtAGQ=; b=CkIPYXpcLVpO2ao+xyAdXHUEDDdio4cOuj2ecmL+RbhFKJ14xDc0MAFXrlpiDvFHuL 9+nzdzC2/qlyRWrUsDMicsTLwhGYXMB3YnVCor5XIlXSsWh0qNorxrXr1cauTj9FpT5U zBwQK+ArJYdUSyao4mbOF7ryNeQv7tHz9S/BD2vdAmO/2suPkpai9owaYyciwM45x8rO Ik29ErrL7ClOjqVwArs5DhqKAP7b30cp4+dF3+1AJqyTVj2Lr+M4naOVUlk5Xa9xB3SF sP+Ra5vsYKwrBD/oOp36xSYWiP5++Bdidifxzu8Sn10XRpUancON1rk2n/Nw3bP8dZrt WKUQ== X-Gm-Message-State: AOAM531gDz+ugu9uweocxaz8ysmH62CCsqmPk/dBKNKLX1zdoO9Z8MlI yFx8a2FFtKw5B3V8wXaUjz2t77t8WG8= X-Received: by 2002:a17:902:e808:b0:151:f87f:3749 with SMTP id u8-20020a170902e80800b00151f87f3749mr2861049plg.24.1646691379100; Mon, 07 Mar 2022 14:16:19 -0800 (PST) Received: from localhost (76-14-89-2.sf-cable.astound.net. [76.14.89.2]) by smtp.gmail.com with ESMTPSA id pj13-20020a17090b4f4d00b001bf2ff56430sm318595pjb.30.2022.03.07.14.16.17 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 07 Mar 2022 14:16:18 -0800 (PST) Received: by localhost (sSMTP sendmail emulation); Mon, 07 Mar 2022 14:15:54 -0800 From: pal@sandflow.com To: ffmpeg-devel@ffmpeg.org Date: Mon, 7 Mar 2022 14:15:40 -0800 Message-Id: <20220307221542.3265-5-pal@sandflow.com> X-Mailer: git-send-email 2.35.1.windows.2 In-Reply-To: <20220307221542.3265-1-pal@sandflow.com> References: <20220307221542.3265-1-pal@sandflow.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v3 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: tVPBNmmON1S/ 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..f368578fc4 --- /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/avio_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)