From patchwork Sun Aug 28 15:31:23 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: 37518 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:139a:b0:8f:1db5:eae2 with SMTP id w26csp1459693pzh; Sun, 28 Aug 2022 08:32:13 -0700 (PDT) X-Google-Smtp-Source: AA6agR4xOKWmD5vUJU4GM1h87Kwfrhsxhahyan9ttSTnsKgYGNZmOwpHSkp1fKZcg/PVpnQNCltb X-Received: by 2002:a17:907:3e03:b0:722:e694:438 with SMTP id hp3-20020a1709073e0300b00722e6940438mr11192894ejc.755.1661700733572; Sun, 28 Aug 2022 08:32:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661700733; cv=none; d=google.com; s=arc-20160816; b=DWVNLQF5y5JZxnQx2Nj3MkbnfMvwP2I0U70hslCLOhOSJ4RWacnub4oZAAeudwmt0g pz+uSDboCYsqAsc0vtNlNE39EVIFuBJa4re3IMYmYJ6gmlSQxjJGDQZSmibwphnTCiQv w+UNwaUcNQbRw13K4nWVUGISDfAzY5qp4WbqJtzTALw/gn20wv5aBjwfH2RreC1gI3Px t76+S/BOZWO8u76WjVCAXED1v4EQ6bVPviq7TtlpjPA9mufoSi3o7OzJnnuFYBI+jExb XlietOP545HuoHQYvVmDSj1tTiCwhj39BPPV89ysjj/tXPs5Lf5/1EF1QvRjCz9l/H3I o0XQ== 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=pFlRqXzX9ZqFveASLTm4duRb9ZDa77yS2GAYGt87l8I=; b=S8dkIOiw7+QEjD86RnbJEf26gOr9qfqZJFroWG8pm7LCYG0ZrKosc884t77WMBaDBU lSpVtc3sKK5FF06Qqm4WEMzEYQ1H1NtPqZpBWFvOjvV1UqKqMC65nwKpG/9g3iVQOCrR qcT7tR+AB/88ty2j7jaFwakJMJ2VmsusWyhterW2NBa30gWwazfl5xjqOswoUXlzc+bX eYk4ig+yff2I/lLGR/mbyXfHErbh+yFrmWxLCR7VGKR6NKkY8jat05MEA+rKPzZsS12e emeyMQr8H178IxBY7zKWSPMabkc0lR6x58NVCd5AAp3LxeCOB1TgTNrCVXB87mI/+/td W55A== 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 nb9-20020a1709071c8900b0073d6b849d4fsi5461130ejc.731.2022.08.28.08.31.57; Sun, 28 Aug 2022 08:32:13 -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 9185368B987; Sun, 28 Aug 2022 18:31:53 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id BB08168B830 for ; Sun, 28 Aug 2022 18:31:47 +0300 (EEST) Received: by mail-pl1-f176.google.com with SMTP id j5so1896785plj.5 for ; Sun, 28 Aug 2022 08:31:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc; bh=Lrw5R/hNXKERm8GnKiYZEcShdcR708bJGSMLoP3u28s=; b=MYsLwnzJgWATbTjZDLvjxl1/u136r7H4xxGYSbHiOQSd8r9vKtsPsdRd+VrToW81D+ xOwgYCvegYtPCPqWJuO/afrw+EqdzZeRZ9tbUqU8dQrApeKptLdu7R62etwaYMQvP9zN pJ0aKu3c8RmzJl5T3/eAMmFIjbebGLb8hsq+jF964zLAzjGV1uek7fdA2G0vfHiPWrTW upSEJbakaSaxT7T17tfBSWC+xRb4EmubKyQZ3RO98ri9BtfIso0RufIWUhGXsIpwcsgK +nv6q+8j2//MDyKQMz0zEcs3p2nmyTYVaipR4Ekan72fm+Tde3rkjLtsxX9KNHPXBWR8 zA2Q== X-Gm-Message-State: ACgBeo2IAY1r0/wpzAqkeYIrdpKtiOSXp7Is5/7dae5biU9S8sgbJBQD nrY9bzNKkgkDNyx6cF8bwlgpg4SLTQ0= X-Received: by 2002:a17:90b:2243:b0:1f4:e8a4:8c38 with SMTP id hk3-20020a17090b224300b001f4e8a48c38mr14743183pjb.136.1661700705613; Sun, 28 Aug 2022 08:31:45 -0700 (PDT) Received: from localhost (76-14-89-2.sf-cable.astound.net. [76.14.89.2]) by smtp.gmail.com with ESMTPSA id x18-20020aa78f12000000b0053788e9f865sm5363205pfr.21.2022.08.28.08.31.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Aug 2022 08:31:45 -0700 (PDT) Received: by localhost (sSMTP sendmail emulation); Sun, 28 Aug 2022 08:31:28 -0700 From: pal@sandflow.com To: ffmpeg-devel@ffmpeg.org Date: Sun, 28 Aug 2022 08:31:23 -0700 Message-Id: <20220828153123.10813-1-pal@sandflow.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v1] avformat/mxf: set stream frame rates for ST 422 essence containers 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: T6FpGmsTQc6Z From: Pierre-Anthony Lemieux The MXF demuxer does not currently set AVStream::avg_frame_rate and ::r_frame_rate when J2K essence is wrapped according to SMPTE ST 422. --- libavformat/mxfdec.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index feebff67aa..043e2e06ec 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -2140,6 +2140,13 @@ finish_decoding_index: return ret; } +static int mxf_is_st_422(const UID *essence_container_ul) { + static const uint8_t st_422_essence_container_ul[] = { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x07,0x0d,0x01,0x03,0x01,0x02,0x0c }; + + return essence_container_ul && mxf_match_uid(*essence_container_ul, st_422_essence_container_ul, + sizeof(st_422_essence_container_ul)); +} + static int mxf_is_intra_only(MXFDescriptor *descriptor) { return mxf_get_codec_ul(mxf_intra_only_essence_container_uls, @@ -2892,6 +2899,24 @@ static int mxf_parse_structural_metadata(MXFContext *mxf) av_log(mxf->fc, AV_LOG_INFO, "Unknown frame layout type: %d\n", descriptor->frame_layout); } + if (mxf_is_st_422(essence_container_ul)) { + switch ((*essence_container_ul)[14]) { + case 2: /* Cn: Clip- wrapped Picture Element */ + case 3: /* I1: Interlaced Frame, 1 field/KLV */ + case 4: /* I2: Interlaced Frame, 2 fields/KLV */ + case 6: /* P1: Frame- wrapped Picture Element */ + st->avg_frame_rate = source_track->edit_rate; + st->r_frame_rate = st->avg_frame_rate; + break; + case 5: /* F1: Field-wrapped Picture Element */ + st->avg_frame_rate = av_mul_q(av_make_q(2, 1), source_track->edit_rate); + st->r_frame_rate = st->avg_frame_rate; + break; + default: + break; + } + } + if (st->codecpar->codec_id == AV_CODEC_ID_PRORES) { switch (descriptor->essence_codec_ul[14]) { case 1: st->codecpar->codec_tag = MKTAG('a','p','c','o'); break;