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 41CE842314 for ; Fri, 4 Mar 2022 20:40:45 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3191768B1A3; Fri, 4 Mar 2022 22:40:43 +0200 (EET) Received: from mail-io1-f50.google.com (mail-io1-f50.google.com [209.85.166.50]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0D00068B0A4 for ; Fri, 4 Mar 2022 22:40:37 +0200 (EET) Received: by mail-io1-f50.google.com with SMTP id c18so10852204ioc.6 for ; Fri, 04 Mar 2022 12:40:36 -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=mOPp/q89Q/IPgvFHErSJ3FFHg5FZT/CPQIadcNNJMTA=; b=Jwq/y5th784p7GDpLM9+BFz3CwQUC5dIetRhIMdrlncdJNI7liu65cCtvwZVQJsqrN CGtGkZM856ld4+6RrBngaQ4T0wWTUY1+MMyubWtVvMBkviFfUMiM3FaS+WvWqkIyAxUA o77Vn+9n3z80zSFYebFpd7kC52AWnnx99sIi4qkWX0G1G2eHqDl8A1jKSOYvhTwSeySv rhTeh2HW9tM/uh9pDxQDLSSUIat7PTrr1zVPk1wF/gMDRvk/axTobp/fJgKGtaqUeR7z maOCDF/GBsdeUOlm8cvcBE5tKY+Aol1lQ30Jen4MUVrh1dytDik9gomh2+paDe7I+XMq jv4Q== 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=mOPp/q89Q/IPgvFHErSJ3FFHg5FZT/CPQIadcNNJMTA=; b=BCbmrG26ZkiGa6QWBA0yf9aQ+GhJh+8oXSWJGXAb678RxhvDvzV2sDZTK/Cw4Vr21S nGVLzPyf8YS1FrhfhkkezRn7VNHHqqtc5ve0ouCccIyDZxV0Z3Fex6JM0XfVNWD/G1LC dJ41x6zJ0OilI94PzjShkyco/ys6ZXq0CfnBLLU5mSUjlnT9HZzC0Zif2xQsChTYgnFj DDoB1DDkU/UMCTENTXZa6vEPh4owxtz+QCXHC+wDl2PpJQzXMNxL6FybCG30gkL/R4Ug 59RMlBS6S6UNLHBmQMaP3lxx3F+YPO403aTN+4vjEHnvYJCkWNkfWGdlT5Ni0pRso54E 8auA== X-Gm-Message-State: AOAM530pfJRR4htzPwP1gQELEAOHsKgG/hu3mlSapELmd4JF5ZryWF30 DeQILGXmOnFbprryeRWTbNluch60yHhwnQ== X-Google-Smtp-Source: ABdhPJyOLeYa6PfX25rfHC3e3MzVJKNxzytaHEdU00Ta6uUTg1FVzQdF1jQkmZX1QQ1fFX8ISQk2Jg== X-Received: by 2002:a05:6638:398:b0:309:58bf:f50f with SMTP id y24-20020a056638039800b0030958bff50fmr272360jap.147.1646426435388; Fri, 04 Mar 2022 12:40:35 -0800 (PST) Received: from mail-io1-f54.google.com (mail-io1-f54.google.com. [209.85.166.54]) by smtp.gmail.com with ESMTPSA id k11-20020a926f0b000000b002c2756f7e90sm5389788ilc.17.2022.03.04.12.40.34 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Mar 2022 12:40:35 -0800 (PST) Received: by mail-io1-f54.google.com with SMTP id u2so8815844ioc.11 for ; Fri, 04 Mar 2022 12:40:34 -0800 (PST) X-Received: by 2002:a05:6638:33a3:b0:317:920a:8745 with SMTP id h35-20020a05663833a300b00317920a8745mr309969jav.18.1646426434495; Fri, 04 Mar 2022 12:40:34 -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: Fri, 4 Mar 2022 12:40:22 -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: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(). > > - 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".