From patchwork Sun May 1 12:11:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 35530 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a885:b0:7f:4be2:bd17 with SMTP id ca5csp1303975pzb; Sun, 1 May 2022 05:12:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx15UKK07vaqlOHz1MTKDfNiwLY0wqMgtkeITEvLtLszUvRSG5ZSk2QctjN1Z4mgXbDEU3R X-Received: by 2002:a05:6402:ea8:b0:41d:78ca:b929 with SMTP id h40-20020a0564020ea800b0041d78cab929mr8479371eda.289.1651407134757; Sun, 01 May 2022 05:12:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651407134; cv=none; d=google.com; s=arc-20160816; b=W+o9jkcApL5IXhRudVkBbzU43tit/Wbw+RrckFwCabYneDCIk4M3xerZqa8Bdwywch 0HUnop23La7T8a20CvN1liXJ3ZNYohg64K70kaU7ioVlaReYw9KacPfwgSRJCuhOrken 2TK6eGyrCch+hG9Hv2UI2+AdkCEmhBtaUf4JT0AddkZrUOZ7FhKiSpDCSRMF60cxX16J P4RTqj3lmHxeewWCT9s7o3nI+QHtuwwLfeNy4sDk5twW9cSy3CIC5sj7WwuWzzPrwyat +HDnSDanMUhyGWIsXnnnIyrft9MxqkAcbOSf5UWpsfaDAK8YO7UPs9kXNqN3UpoBQON5 u6ow== 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:message-id:date:to:from :delivered-to; bh=oS1lqo7MiN5FWnG3IhLUJ5w68GTANttuNKLhKOcOvgs=; b=r043rxo9Qz8O/xiLKxhvc4aSuYlOygB2V20K9MHOqhh2liWu2lceoJuUT5lbnq3wFf K1Z/t8Y48mjpRp64b/3YKvd5HUWmguAUdgj3U2mM67H3+gNLNeARgYE/MNDAtM6IxuDE vn7c0cBJBBM5VdX1i7YmuLxk5Uu5zzNJ6lRbz0EbSXlH5byhZopptBHFKBpVPjQq0AsN YEguhqU2smTR5bpa7SXUusDKWOynbNvzAY6WH/iZDkZtZEWX6f7qeXLPv2Mzg2d6/eYo jlxClqUxp82KKr4fjti1XuWFrP0yrTcNA7IVDMdDeDLu/S78WD93ca6FdDK0oWbDv6Dw bqOA== 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 t16-20020a056402525000b0042629c14e41si8506846edd.597.2022.05.01.05.12.14; Sun, 01 May 2022 05:12:14 -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 E39DE68B2BC; Sun, 1 May 2022 15:12:09 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0F42C68B234 for ; Sun, 1 May 2022 15:12:03 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 9BF7AE7049; Sun, 1 May 2022 14:12:03 +0200 (CEST) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id P0n0BZnWMdd7; Sun, 1 May 2022 14:12:02 +0200 (CEST) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 342A5E7048; Sun, 1 May 2022 14:12:02 +0200 (CEST) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Sun, 1 May 2022 14:11:55 +0200 Message-Id: <20220501121155.21395-1-cus@passwd.hu> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avformat/mov: fix timecode with rounded down tmcd nb_frames 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: Marton Balint Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: yyXG4Ob0ADsl Regression since 8dd5bb728038f21d17ec789e21d65fe8f3f364a6. Fixes ticket #5978. Signed-off-by: Marton Balint --- libavformat/mov.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 0f63d997fc..dfd5720bf4 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -8038,12 +8038,13 @@ static int mov_read_timecode_track(AVFormatContext *s, AVStream *st) int64_t cur_pos = avio_tell(sc->pb); int64_t value; AVRational tc_rate = st->avg_frame_rate; + int tmcd_nb_frames = sc->tmcd_nb_frames; int rounded_tc_rate; if (!sti->nb_index_entries) return -1; - if (!tc_rate.num || !tc_rate.den || !sc->tmcd_nb_frames) + if (!tc_rate.num || !tc_rate.den || !tmcd_nb_frames) return -1; avio_seek(sc->pb, sti->index_entries->pos, SEEK_SET); @@ -8060,9 +8061,15 @@ static int mov_read_timecode_track(AVFormatContext *s, AVStream *st) * format). */ /* 60 fps content have tmcd_nb_frames set to 30 but tc_rate set to 60, so - * we multiply the frame number with the quotient. */ + * we multiply the frame number with the quotient. + * See tickets #9492, #9710. */ rounded_tc_rate = (tc_rate.num + tc_rate.den / 2) / tc_rate.den; - value = av_rescale(value, rounded_tc_rate, sc->tmcd_nb_frames); + /* Work around files where tmcd_nb_frames is rounded down from frame rate + * instead of up. See ticket #5978. */ + if (tmcd_nb_frames == tc_rate.num / tc_rate.den && + s->strict_std_compliance < FF_COMPLIANCE_STRICT) + tmcd_nb_frames = rounded_tc_rate; + value = av_rescale(value, rounded_tc_rate, tmcd_nb_frames); parse_timecode_in_framenum_format(s, st, value, flags);