From patchwork Mon Feb 21 06:02:29 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: 34429 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6838:d078:0:0:0:0 with SMTP id x24csp3105963nkx; Sun, 20 Feb 2022 22:03:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJxp02L/BG5VN1q/hmyGxsunprbI+3bhloSB2/JcCXueDJlnzGZnc6HV9JYlob7M+LAYWX+I X-Received: by 2002:a17:906:3e84:b0:6cf:cd36:6316 with SMTP id a4-20020a1709063e8400b006cfcd366316mr14471555ejj.581.1645423434540; Sun, 20 Feb 2022 22:03:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645423434; cv=none; d=google.com; s=arc-20160816; b=YKpVNNsrmDI+nsei/WG0++M5wpRc0OFwSG9uxSz82yzL8flJE/Glu3IPx8CcRLh/V6 VSYjrw8aRjqknwvpkdKJrEwaQhyz1uS4ew7GUnTLPWcSR3zjVx6f96bJ4KoB0DmwaT1q 16lG2AMX7Yxjm+HnuCvaNU23rottD5BbZkyxgFW1B8mZcHvBLJm3z3oAY0m6AE01wkkA hScB2pyI5JKxCchRhe4zWgAWJsJTGI/Dc/L/khxTHhWg1Xes9yBFkH7TWzS4mC7B0DPs Z0LcUXXzS2/b20G8h2RouRUtAY1HhUC4qK25/Lt7KztdfNtaX1zv8K83p70wzWA1z2sO cekw== 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=mU4Dbrd1DBxLELwz3kn8Vs/FcN1Zyi57QhXkYaro3Yo=; b=K75hSXab5HLE3c6+Vhy2kzO1oZ1g7viCgcclsi0uHW75jG+RqsghrJ4V8MnCTnBjAI lghL6RGzQIYzVaP6LyafpeJFgSHrAfVtCIpAKCssn4v/bCX1KTkuEtUNk4xNzEILnUKL Wt5sHsHyku4q7V+/KgpJiQs4L1hSub9x7YchjCDreZ7zuN1ew2WIJLSL9Nl/5NQF5HaJ kBLVK/vCmwmCKJyEp/Cmtk4mRmPDa/zSaCqJ89Ww5m9ZHSf2k00DK6w47r5ni2cRXfnR z92zPojM+0NQtOB9gMPHGaBgfXZOWTKIHbek+1DPdL1lTaUia/cocT7/Hmk1fi7MwOn7 iGfg== 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 n8si12992501edx.400.2022.02.20.22.03.54; Sun, 20 Feb 2022 22:03:54 -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 C143A68A81B; Mon, 21 Feb 2022 08:03:08 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8E30168B13D for ; Mon, 21 Feb 2022 08:03:01 +0200 (EET) Received: by mail-pj1-f50.google.com with SMTP id m22so333017pja.0 for ; Sun, 20 Feb 2022 22:03:01 -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=9pvOn/n5aSCyCuMStVk9ge0QR6f3t/3nkGNqje/Yl24=; b=IHHh1ut73gvqii9Ax89xsQGLpmymfI1ft7WKNeokxh+GIz6tR5VtiyOg/mbFZqlnsn +iDoTvJvBGuGj+hUx4FogJQjgRT2U/1YPRjS05dO7nzS636rrVnVpFjw8dLsWdgBziim aJZEuuY/Qi+D96oqAeZNO2m+IhITJenIJbmkWkYbrPnfRo3l3yfAY1KcdCmjxalDyGL7 uef+aNT/dDJnvgO3+BYCWgiiLdVjIzcP9EeoB2NxJsJCVtawnHvwjTBD7y7wt5ytbpQI PK9pmmt/+I0oq8iGVCRdniweypJ0hQ1wDVHy+SWBZdAG17fqpwWRjPmd7p/Ma7HKem6c t9tg== X-Gm-Message-State: AOAM532UqVJiwxvlqEEEvkKzSwM1hoPueQnMdz472LBfsyUG7JN+bGwb 3tQLnDUVb0YFVlMOsFXqb1N2dskmK3c= X-Received: by 2002:a17:902:7c94:b0:14d:77d2:a72e with SMTP id y20-20020a1709027c9400b0014d77d2a72emr18348095pll.153.1645423379682; Sun, 20 Feb 2022 22:02:59 -0800 (PST) Received: from localhost (76-14-89-2.sf-cable.astound.net. [76.14.89.2]) by smtp.gmail.com with ESMTPSA id k21sm6050786pff.25.2022.02.20.22.02.58 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 20 Feb 2022 22:02:59 -0800 (PST) Received: by localhost (sSMTP sendmail emulation); Sun, 20 Feb 2022 22:02:46 -0800 From: pal@sandflow.com To: ffmpeg-devel@ffmpeg.org Date: Sun, 20 Feb 2022 22:02:29 -0800 Message-Id: <20220221060230.6665-6-pal@sandflow.com> X-Mailer: git-send-email 2.35.1.windows.2 In-Reply-To: <20220221060230.6665-1-pal@sandflow.com> References: <20220221060230.6665-1-pal@sandflow.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 6/7] avformat/imf: refactor to use av_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: S+/RWJSb20F3 From: Pierre-Anthony Lemieux --- libavformat/imfdec.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/libavformat/imfdec.c b/libavformat/imfdec.c index ac212b05e1..bc27e3cc2a 100644 --- a/libavformat/imfdec.c +++ b/libavformat/imfdec.c @@ -69,6 +69,7 @@ #include "libavutil/avstring.h" #include "libavutil/bprint.h" #include "libavutil/intreadwrite.h" +#include "libavutil/mathematics.h" #include "libavutil/opt.h" #include "mxf.h" #include "url.h" @@ -904,14 +905,6 @@ static int imf_probe(const AVProbeData *p) return AVPROBE_SCORE_MAX; } -static void rescale_interval(AVRational tb_in, AVRational tb_out, - int64_t *min_ts, int64_t *ts, int64_t *max_ts) -{ - *ts = av_rescale_q(*ts, tb_in, tb_out); - *min_ts = av_rescale_q_rnd(*min_ts, tb_in, tb_out, AV_ROUND_UP | AV_ROUND_PASS_MINMAX); - *max_ts = av_rescale_q_rnd(*max_ts, tb_in, tb_out, AV_ROUND_DOWN | AV_ROUND_PASS_MINMAX); -} - static int coherent_ts(int64_t ts, AVRational in_tb, AVRational out_tb) { int dst_num; @@ -937,13 +930,13 @@ static int imf_seek(AVFormatContext *s, int stream_index, int64_t min_ts, /* rescale timestamps to Composition edit units */ if (stream_index < 0) - rescale_interval(AV_TIME_BASE_Q, - av_make_q(c->cpl->edit_rate.den, c->cpl->edit_rate.num), - &min_ts, &ts, &max_ts); + av_rescale_interval(AV_TIME_BASE_Q, + av_make_q(c->cpl->edit_rate.den, c->cpl->edit_rate.num), + &min_ts, &ts, &max_ts); else - rescale_interval(s->streams[stream_index]->time_base, - av_make_q(c->cpl->edit_rate.den, c->cpl->edit_rate.num), - &min_ts, &ts, &max_ts); + av_rescale_interval(s->streams[stream_index]->time_base, + av_make_q(c->cpl->edit_rate.den, c->cpl->edit_rate.num), + &min_ts, &ts, &max_ts); /* requested timestamp bounds are too close */ if (max_ts < min_ts)