From patchwork Sun May 7 13:32:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41526 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:dca6:b0:f3:34fa:f187 with SMTP id ky38csp1708098pzb; Sun, 7 May 2023 06:35:07 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4Rd1P1gVpckouHzwnzDZwAvq3uryWn4IIqsxfYcAbqaTBAv2D8IbWwI36TbRJwnEcfpL2J X-Received: by 2002:a17:906:eecd:b0:965:8edf:8028 with SMTP id wu13-20020a170906eecd00b009658edf8028mr6390567ejb.42.1683466506735; Sun, 07 May 2023 06:35:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683466506; cv=none; d=google.com; s=arc-20160816; b=C7jQmGetY/pki/IJarpCPCzw6rixhrvN8vA8kuVwqNTlxni8yqgc6J5lA52iM6xVBW ZAS0YPkTp0UJN/CqMpMpPaJcHN9vvDx8RZIkjopRDKnGcm3HalNx3ErUsafD6C3fSTeD TFbK2+UxdHvpSDUANtttrylZd5bdFmEY4wQZWXhIo7sgan+TPBix999MPdb/Ov2UsvZP +31L7Wnf12oQ3o31v2MyTCydGrFMna8Me4eyfFuT3H6IimO5XGMErujeVPQ1HsU150li AWwPsceyp60qhYw4iAsJq8BAYMAv3uks1xVgJWiFFvkxtvUrDjjlSAp19PVdc1F9+mXy GxFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding: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=ofN8tTu040IG9zE5E0ptBvEFZHL1PVrhn672uIhNjU0=; b=kTFMlrq2VdgufC0cINsfhlsupJ7zwrjK0lElx8CVgtbEiVwYc3KHbVfaLXItlj7hpO CecZ8IejXoEZES3KPKYCuNww4BYGQA4t/ZfvtA+fyJ44E/CAbTLspHKamt6qcRtTN2b7 y6dvEf0r5koedKs1+mTaTzALmrt/e5d33iq7lmoVMobSpMQLo1A4nY+q22cZQXp4jz9g G67zcGhpSngoRnOTfQIhrK7bA20NlL5Nche3GbEemRe7LjJF0VlRbEEvBhuB0lv7XPsI PAQTjh+nXBZk7vjC3z+ghsjLY6Ci43CGXQveujKpium1LVMsAf61d61cOgIEMhc0x0OW x8DA== 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 s11-20020a1709067b8b00b009659a414142si4083002ejo.454.2023.05.07.06.35.06; Sun, 07 May 2023 06:35:06 -0700 (PDT) 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 815DF68C1A1; Sun, 7 May 2023 16:33:33 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A229F68C13D for ; Sun, 7 May 2023 16:33:21 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 19DF32406CA for ; Sun, 7 May 2023 15:33:21 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id U_STi1GKKR1c for ; Sun, 7 May 2023 15:33:20 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 233982404EC for ; Sun, 7 May 2023 15:33:15 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 3EF4B3A048F for ; Sun, 7 May 2023 15:33:05 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sun, 7 May 2023 15:32:44 +0200 Message-Id: <20230507133255.20881-2-anton@khirnov.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230507133255.20881-1-anton@khirnov.net> References: <20230507133255.20881-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 02/13] fftools/ffmpeg: fix computing video frame duration from repeat_pict 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: a44ONTfCJk45 This field contains the number of _field_ durations by which the standard frame duration should be extended. --- fftools/ffmpeg.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 8323c32ffd..4e45ab74b9 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -1008,10 +1008,10 @@ static int64_t video_duration_estimate(const InputStream *ist, const AVFrame *fr return frame->duration; if (ist->dec_ctx->framerate.den && ist->dec_ctx->framerate.num) { - int ticks = frame->repeat_pict >= 0 ? - frame->repeat_pict + 1 : - ist->dec_ctx->ticks_per_frame; - codec_duration = av_rescale_q(ticks, av_inv_q(ist->dec_ctx->framerate), + int fields = frame->repeat_pict + 2; + AVRational field_rate = av_mul_q(ist->dec_ctx->framerate, + (AVRational){ 2, 1 }); + codec_duration = av_rescale_q(fields, av_inv_q(field_rate), ist->st->time_base); }