From patchwork Mon Feb 21 06:02:30 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: 34430 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6838:d078:0:0:0:0 with SMTP id x24csp3106046nkx; Sun, 20 Feb 2022 22:04:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJzfQhjyiAGPtC74XEfOR3cnuNXXlgM2+YdeEXJspz+xIxPS7kP22G96+2mWZww/6UrMIIZm X-Received: by 2002:a50:e08c:0:b0:407:cdc6:809e with SMTP id f12-20020a50e08c000000b00407cdc6809emr19510028edl.162.1645423444057; Sun, 20 Feb 2022 22:04:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645423444; cv=none; d=google.com; s=arc-20160816; b=JatZQLrdKh/ANQtqIEyzU7eEPAA+KaQ1gKPvZrKYF9QhGWYEo8xbqqvbGHRbZohogb ZF/4fTTiMql1oCDHxDY7U89lNTAk5nRGAh8NTgimURTDDb7AArhPkaeqmOpyr0Q8dpoP rJ2nMYrvChYTfvQCBQpCU+8b0NCEhYgZhm/KKd5CeHb3P7lk+ZxbnWz79nJ6tCydwUxU +3nr8eYNhmV+7J7eJWFwjh2k9W3v90j6LBpXAITVhVCks8ifsYYbY62QiQyVkwreTy5y MvX2cuiINRciR78tSs2iQgA66PZbmwbaH5AQWGfn8uzfGP1oiQVJun7sdY8cImoLpEBW kNEg== 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=A7BlkH/uFogLoqlhKySf+kPRbPscLODBelC3cd6lWM4=; b=kZsFryB2nWL8BpBaxmisGgTOEvMnlKceyyxTw/Fp/a5/Zm7tja7GQaRAvFIs9ot8rI SpS4GSaNPR5fXTkpZd8wiMd/9/rrTEcLTs+GncAwR4SsJLi7eGHG3aFfsL/VwrwraPfs UydbDW8Ig7gyJbxDy2qGMcGlyFBKiRl50s+lxW8a2yoWueWzle4M3kPzuV1m9rx8yt9b J5YlqFgRF6BsKKepGnspwGeONpNSEBvV7o+9zX3aPszY+Rz6lgwtz6FuYo34RQ9T23Cu grMfualtRrBcRwRxjajzYmA9+cViNJOb9kPQjQW0K8QU7mvCFsQNCY/UE9YWeVmrz3iu KL6g== 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 o3si10411630edi.560.2022.02.20.22.04.03; Sun, 20 Feb 2022 22:04:04 -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 B3D9768B161; Mon, 21 Feb 2022 08:03:10 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E98DA68B148 for ; Mon, 21 Feb 2022 08:03:03 +0200 (EET) Received: by mail-pl1-f174.google.com with SMTP id u12so12016306plf.13 for ; Sun, 20 Feb 2022 22:03:03 -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=jroqvSxaCglERAn03KjWSCqKytpoF/lZZOCVm82M1L8=; b=0MGoIMRY36T3EWlzGPpwAzGcOIgpdkX0xDtjz2mtxGC1N5IFPGU0Z07QdWzJZetWRy wtVRgNxd9/AWoz0bTSSWkEYpVIjZ8/ZfkeYI1pYelfLF6zAKylTXoyXseEVh1Ax7oQcs 977UVTc2+hOxw9tLhesIOt5BkTiqwbnCM6yxWt0MBnQ7crtQ3E+H2A8oNgvzMPjUeFqv NTDvt9VF4btCqVauWptL0FxH63PDQJ9I6my+yijJSTbhnN/x8H0qV+OJ80jrLSU9YwEj zfzSggw/gQ+SxEwS/N2h1dcsWdhXVFwIl+wTvgPONYjKAZwkY6sK08hvWBPxM7zNGVHs fX3A== X-Gm-Message-State: AOAM5316vLs5OOxS09LUmAqHfvYKRsYAR/OZme5XZwwLnAy0+9yrBvXp Sqt2HROfqcnglDLiy/S018ebE/8kLjA= X-Received: by 2002:a17:902:9a0a:b0:14a:199:bc5c with SMTP id v10-20020a1709029a0a00b0014a0199bc5cmr17268578plp.10.1645423382049; Sun, 20 Feb 2022 22:03:02 -0800 (PST) Received: from localhost (76-14-89-2.sf-cable.astound.net. [76.14.89.2]) by smtp.gmail.com with ESMTPSA id e20sm9610626pfv.42.2022.02.20.22.03.00 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 20 Feb 2022 22:03:01 -0800 (PST) Received: by localhost (sSMTP sendmail emulation); Sun, 20 Feb 2022 22:02:48 -0800 From: pal@sandflow.com To: ffmpeg-devel@ffmpeg.org Date: Sun, 20 Feb 2022 22:02:30 -0800 Message-Id: <20220221060230.6665-7-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 7/7] avformat/concat: 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: t3R9kYpkJafi From: Pierre-Anthony Lemieux --- libavformat/concatdec.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/libavformat/concatdec.c b/libavformat/concatdec.c index 0603c6e254..3ddbe833c9 100644 --- a/libavformat/concatdec.c +++ b/libavformat/concatdec.c @@ -22,6 +22,7 @@ #include "libavutil/avassert.h" #include "libavutil/bprint.h" #include "libavutil/intreadwrite.h" +#include "libavutil/mathematics.h" #include "libavutil/opt.h" #include "libavutil/parseutils.h" #include "libavutil/timestamp.h" @@ -816,16 +817,6 @@ static int concat_read_packet(AVFormatContext *avf, AVPacket *pkt) return 0; } -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 try_seek(AVFormatContext *avf, int stream, int64_t min_ts, int64_t ts, int64_t max_ts, int flags) { @@ -838,8 +829,8 @@ static int try_seek(AVFormatContext *avf, int stream, if (stream >= 0) { if (stream >= cat->avf->nb_streams) return AVERROR(EIO); - rescale_interval(AV_TIME_BASE_Q, cat->avf->streams[stream]->time_base, - &min_ts, &ts, &max_ts); + av_rescale_interval(AV_TIME_BASE_Q, cat->avf->streams[stream]->time_base, + &min_ts, &ts, &max_ts); } return avformat_seek_file(cat->avf, stream, min_ts, ts, max_ts, flags); } @@ -853,8 +844,8 @@ static int real_seek(AVFormatContext *avf, int stream, if (stream >= 0) { if (stream >= avf->nb_streams) return AVERROR(EINVAL); - rescale_interval(avf->streams[stream]->time_base, AV_TIME_BASE_Q, - &min_ts, &ts, &max_ts); + av_rescale_interval(avf->streams[stream]->time_base, AV_TIME_BASE_Q, + &min_ts, &ts, &max_ts); } left = 0;