From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 7923A40B6B for ; Mon, 7 Mar 2022 22:17:30 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2344368B190; Tue, 8 Mar 2022 00:17:28 +0200 (EET) Received: from mail-il1-f176.google.com (mail-il1-f176.google.com [209.85.166.176]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9496068B0F9 for ; Tue, 8 Mar 2022 00:17:25 +0200 (EET) Received: by mail-il1-f176.google.com with SMTP id b5so10028069ilj.9 for ; Mon, 07 Mar 2022 14:17:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sandflow-com.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=buL5c3ddcS7VFOqlhdArwlvbUlMhdztIA1MdVjIwH4Q=; b=ajjQxDcA/Re3inzosFdANnXphumNZwie0H1zIsu+lcnYVQxWULLpArT4sACqrKRR0Q ljXF7ING3Dgw1dIA3V/IU0H7YVMjWPf1xK9PDGGxw58eRPwqXXDJzPNSel/qdq+qUwMV TELUsPR7w+SuPkQeghMsttsaHMBWt9smjRSupzgQxH0VOhTiCittL7RwiSrilZynUiWn yeLSQrAjZiDcZaA1Ruel/k+/alUFKia2czFRyxM55QoapEiltZuJzbOaNJ+pWH/O7lz1 hYZrdrk016vtw5AasYPaC45ESlXbKmsFlujYjiyugqVM8FfFWd2cqiFWTkixI5lKiCtd Rg0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=buL5c3ddcS7VFOqlhdArwlvbUlMhdztIA1MdVjIwH4Q=; b=fV8S1X5bLAYQhtCH0DjB9NQmx1gsvnGODzdfek3Wda1OItb42HMBG3Gka0HBFvC1ME s+F4FwcPO1neJY0O2Z10+4iUFAvHNRVSe2AyXi4MfmCuOcS6pADBzUwGbtKcs7HM4DtT MrgJKIyb9Fc3rKAndN52X7Vu71kSUXg1LwjMcqDyL00Jhp/hnKvGNWBectg6gfOsTKbI o9mDYu3twGT6pL+31pp2MnU21MNGVBCEXEVUx5rfcCs49tHiBjRDP17Tjk1pPP3F2lRe Yo/Tv4cnbrhiGGoGthZ/88mAZLtboHyWMCzR0YuQLsi+56ExLYZDgTCe9z4H11M2Z6o8 JLLQ== X-Gm-Message-State: AOAM531DHgzkmLuGbreiU8QaMeVBBn1zqgS25M99Y9Jqlrrk1vjB/cPW G62KxAnvBjOx1Znc6quDSYhxD2hbdPnGtQ== X-Google-Smtp-Source: ABdhPJwhCDamc6XIeMFCkEZoXAUf3/uQ7OOcsttC/0dEoIAe8ZzvqjFyLk6+j0WcOjhXqLU832VbAg== X-Received: by 2002:a05:6e02:1948:b0:2c2:bbe2:2d6d with SMTP id x8-20020a056e02194800b002c2bbe22d6dmr12076803ilu.128.1646691443809; Mon, 07 Mar 2022 14:17:23 -0800 (PST) Received: from mail-io1-f42.google.com (mail-io1-f42.google.com. [209.85.166.42]) by smtp.gmail.com with ESMTPSA id m9-20020a923f09000000b002c2a1a3a888sm11152853ila.50.2022.03.07.14.17.23 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 07 Mar 2022 14:17:23 -0800 (PST) Received: by mail-io1-f42.google.com with SMTP id 195so18932391iou.0 for ; Mon, 07 Mar 2022 14:17:23 -0800 (PST) X-Received: by 2002:a02:2406:0:b0:317:1aea:c8a4 with SMTP id f6-20020a022406000000b003171aeac8a4mr12527454jaa.65.1646691442855; Mon, 07 Mar 2022 14:17:22 -0800 (PST) MIME-Version: 1.0 References: <20220221060230.6665-1-pal@sandflow.com> <20220221060230.6665-4-pal@sandflow.com> In-Reply-To: From: Pierre-Anthony Lemieux Date: Mon, 7 Mar 2022 14:17:10 -0800 X-Gmail-Original-Message-ID: Message-ID: To: FFmpeg development discussions and patches Subject: Re: [FFmpeg-devel] [PATCH v2 4/7] avutil/mathematics: add av_rescale_interval() function 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On Fri, Mar 4, 2022 at 12:40 PM Pierre-Anthony Lemieux wrote: > > On Fri, Mar 4, 2022 at 12:13 PM Andreas Rheinhardt > wrote: > > > > pal@sandflow.com: > > > From: Pierre-Anthony Lemieux > > > > > > Refactors a function used by avformat/concat and avformat/imf. > > > > > > --- > > > libavutil/mathematics.c | 10 ++++++++++ > > > libavutil/mathematics.h | 21 +++++++++++++++++++++ > > > 2 files changed, 31 insertions(+) > > > > > > diff --git a/libavutil/mathematics.c b/libavutil/mathematics.c > > > index f4e541fa24..2c7f57b950 100644 > > > --- a/libavutil/mathematics.c > > > +++ b/libavutil/mathematics.c > > > @@ -212,3 +212,13 @@ int64_t av_add_stable(AVRational ts_tb, int64_t ts, AVRational inc_tb, int64_t i > > > return av_sat_add64(av_rescale_q(old + 1, inc_tb, ts_tb), ts - old_ts); > > > } > > > } > > > + > > > +void av_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); > > > +} > > > diff --git a/libavutil/mathematics.h b/libavutil/mathematics.h > > > index 64d4137a60..eb8a3f4002 100644 > > > --- a/libavutil/mathematics.h > > > +++ b/libavutil/mathematics.h > > > @@ -161,6 +161,27 @@ int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq) av_const; > > > int64_t av_rescale_q_rnd(int64_t a, AVRational bq, AVRational cq, > > > enum AVRounding rnd) av_const; > > > > > > +/** > > > + * Rescales a timestamp and the endpoints of an interval to which the temstamp > > > + * belongs, from a timebase `tb_in` to a timebase `tb_out`. > > > + * > > > + * The upper (lower) bound of the output interval is rounded up (down) such that > > > + * the output interval always falls within the intput interval. The timestamp is > > > + * rounded to the nearest integer and halfway cases away from zero, and can > > > + * therefore fall outside of the output interval. > > > + * > > > + * Useful to simplify the rescaling of the arguments of AVInputFormat::read_seek2() > > > + * > > > + * @param[in] tb_in Timebase of the input `min_ts`, `ts` and `max_ts` > > > + * @param[in] tb_out Timebase of the ouput `min_ts`, `ts` and `max_ts` > > > + * @param[in,out] min_ts Lower bound of the interval > > > + * @param[in,out] ts Timestamp > > > + * @param[in,out] max_ts Upper bound of the interval > > > + */ > > > +void av_rescale_interval(AVRational tb_in, AVRational tb_out, > > > + int64_t *min_ts, int64_t *ts, int64_t *max_ts); > > > + > > > + > > > /** > > > * Compare two timestamps each in its own time base. > > > * > > > > I don't see why this function should be public at all. It seems very > > specific to a usecase in lavf. > > Ok. Unless someone objects/has a better idea, I cam move it to seek.c > as ff_rescale_interval() since it is primarily useful (today) with > seek_file(). Addressed by v3 at http://ffmpeg.org/pipermail/ffmpeg-devel/2022-March/293795.html > > > > > - Andreas > > _______________________________________________ > > 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". _______________________________________________ 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".