From patchwork Thu Aug 22 16:55:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Gaullier X-Patchwork-Id: 51113 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:4062:b0:48e:c0f8:d0de with SMTP id kz34csp1182455vqb; Thu, 22 Aug 2024 09:55:53 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVbDdu8StUHtEsvt9tMI+vA5M7cxdZdIVFiXtzKZzTTjbLrOU3k5EFEuoZEPZ+gaZ6Txg/xFW9goxkbrPxBVaYe@gmail.com X-Google-Smtp-Source: AGHT+IFirxRCF+MUucKFcWwAEAiAWqLezARPHxHxeCo4OdVNnxKD6jikUerEkv/2gRWS7VVtyfbn X-Received: by 2002:a05:6512:3f12:b0:52e:ccf5:7c40 with SMTP id 2adb3069b0e04-533485f69f9mr2305060e87.9.1724345753146; Thu, 22 Aug 2024 09:55:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1724345753; cv=none; d=google.com; s=arc-20240605; b=gJwSqYHAdd+ugz4THKBYcHv6LMPagh8JyU/nyf7ooLudrSfuQ6bEiTLMh5zzC4QBVH gxtZygvfIGfp3+PqiORKA1lGTmk9qqXaxx6gb9rxTZteKceKqUkALJY+vk6hwmivFz8a r8nlsTE1R08xVZA2K3ToyWASOY9aUeIEvNyqI8M70YciuhcHkK25EoHOrK3R5ySYaJ7Y /o31im7QHvuboeJBHZNUX/qlWHWoe0QsKSSU5whXLFKEu2YJ+wGB7/htLDgDbiDuzqtz BDVmsu3+m8TE8NClmNjii9mbf+mOAhbMI49LNhEK0+WIrvCilCa5pheEj/ucE9ijTerA 7VKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=FiA3rVJpwBNyGti7QQNslGVgadJ9EDx00Lyi2oNvLjY=; fh=zgMS+X4RExv2k7fU8QdWClnqVJdqO/9UbUuBS5xxJDs=; b=Mj5uO7wJMmTPfOttCb1hwOxbtte8gKH/aLt10YKfoWImYqzS6SVdQAyouoKE2IWdRQ ZWiMoQWSm1iw+p94tfFfszM8Pd4dywS6EqrcC5ra5aVdKtwNclafycbJJ3nBVcMkC40V KzKVUSe/ECb6IDVcajtdZWVm0lFz7giPlpCruKcW8HxfUKOvP6+Et4nbOpQVAdAaHYR4 6k+zt+sFR3L3QcF8iaNgnHxeCvaa00ZWUfVTJ05aoOSBLit19iy5wfZcuUeQNLckJT2w iEZqnmtcVOunEeKRj+cVPsigp4TlsEzVfEp4HH3FVdO8hyYXkxpLXD+i3628Ii7n5IXr YwjQ==; dara=google.com 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cji.paris Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 2adb3069b0e04-5334ea2b54bsi694826e87.130.2024.08.22.09.55.52; Thu, 22 Aug 2024 09:55:53 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cji.paris Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8C92F68DB88; Thu, 22 Aug 2024 19:55:48 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from srv-infra-2.infra.inf.glb.tvvideoms.com (www.inf.tvvideoms.com [213.205.126.156]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id EDD8268DB53 for ; Thu, 22 Aug 2024 19:55:40 +0300 (EEST) Received: from cji.paris (unknown [172.16.3.159]) by srv-infra-2.infra.inf.glb.tvvideoms.com (Postfix) with ESMTP id 151963FE62; Thu, 22 Aug 2024 16:55:40 +0000 (UTC) From: Nicolas Gaullier To: ffmpeg-devel@ffmpeg.org Date: Thu, 22 Aug 2024 18:55:32 +0200 Message-Id: <20240822165533.476916-1-nicolas.gaullier@cji.paris> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/2] avformat/mxfenc: Fix guess frame_rate 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: Nicolas Gaullier Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 8Tz0x1XS3mMA The input time_base was a bad guess. Currently, fate-time_base test data assumed that overriding the input time_base would affect the frame_rate, but this behaviour is not documented, so just fix the fate data now that this is fixed. Fix regression since 10185e2d4c1e9839bc58a1d6a63c861677b13fd0: previously, when streamcopying, the time_base was guessed from the frame_rate considering it is often constant, so guessing the frame_rate back from the time_base was often not a problem. To reproduce: ffmpeg -i fate-suite/mpeg2/dvd_still_frame.vob -an -c copy out.mxf Signed-off-by: Nicolas Gaullier --- libavformat/mxfenc.c | 9 +++++++-- tests/ref/fate/time_base | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c index 4ac6a2d715..a814f15609 100644 --- a/libavformat/mxfenc.c +++ b/libavformat/mxfenc.c @@ -2894,8 +2894,13 @@ static int mxf_init(AVFormatContext *s) if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) { const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(st->codecpar->format); - // TODO: should be avg_frame_rate - AVRational tbc = st->time_base; + AVRational frame_rate = (AVRational){ 0, 1 }; + if (st->avg_frame_rate.num > 0 && st->avg_frame_rate.den > 0) + frame_rate = st->avg_frame_rate; + else if (st->r_frame_rate.num > 0 && st->r_frame_rate.den > 0) + frame_rate = st->r_frame_rate; + AVRational tbc = av_inv_q(frame_rate); + // Default component depth to 8 sc->component_depth = 8; sc->h_chroma_sub_sample = 2; diff --git a/tests/ref/fate/time_base b/tests/ref/fate/time_base index fd6cac53fc..23875d1fb8 100644 --- a/tests/ref/fate/time_base +++ b/tests/ref/fate/time_base @@ -1 +1 @@ -d408aba82d62a90ed7f46a1999b014f1 +b28d4ca13029fdc80a114b56467be9d7