From patchwork Tue Sep 6 21:51:44 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: 37735 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:139a:b0:8f:1db5:eae2 with SMTP id w26csp3527544pzh; Tue, 6 Sep 2022 14:52:02 -0700 (PDT) X-Google-Smtp-Source: AA6agR6gs+yuvg8qVaZ3Zl0cw7PzmC5mKszDojfMPsURf/SMLJFNIqvw0oKnIEerJWcFCN63iQan X-Received: by 2002:a17:907:a0c6:b0:73d:bb3c:328b with SMTP id hw6-20020a170907a0c600b0073dbb3c328bmr330279ejc.354.1662501122184; Tue, 06 Sep 2022 14:52:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662501122; cv=none; d=google.com; s=arc-20160816; b=DhxHWpsdygz/qBfVGZ3z0fvvO1pbWN0Aik+MCQWHoBFeF7EG4QUc6mxHHVBylFq2+H tijYY2SIhtlY05NrY39KNDfXciKqoQBGstzj8UKRNdQHTLu+D6VahJe6lhFXU5HzLhbz Y1VlxNUFaPhD+u55fhE8RACyUAM7/gsykERDBk/evtzLhYXkWY+s+YGRCsIhqoY8S/Dd XvBkYvHv6GzYzQoUsUQlhFEpBstd+DbYKP+HzNnxxGGgWPND5mbpbt42KTbKA/mUTQLB YS7qfkKebGO5OT5QEV94Fd0VqXUDH+GNJLe2g/1Gdf9FHDLSpFAX1fDJtJjacm16NyO9 WcAA== 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=b6Py9W9vpSi1MXq/gacJRYfmAluVmV3K9c4P0KUaEivXbRJxEH9LFukFbMMNJC2MW9 4BHHfThd9q7zGcrPVk0GzXO/tsCkoqBdhuwa8XMzLQXdzWhjhsL5c8Xnrs+P6Bl0EPy3 vNPLZi8dWajZFgwf6DYb05qvak7lI5+BnkeUhu3DatAO6KgzciufgKgbI433myAsrsB1 wMfP2/VMNJpd88PErDoyy8ZvLPVd4RS193tS63sKLDZrL6/SKzNp80JOS58yz3Ww0QJb Dm5uNnzFjS9K6EHb6pRP6HgpW4gMtnjEZW3va03s7JQeh+EHKzYJoUi2Rn29oM+N/FUV R7fQ== 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 dd5-20020a1709069b8500b0076fb816dae6si1863025ejc.592.2022.09.06.14.52.01; Tue, 06 Sep 2022 14:52:02 -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 45ED468BB51; Wed, 7 Sep 2022 00:51:59 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E508168BA44 for ; Wed, 7 Sep 2022 00:51:52 +0300 (EEST) Received: by mail-pl1-f182.google.com with SMTP id u22so12556233plq.12 for ; Tue, 06 Sep 2022 14:51:52 -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:subject:date; bh=Lrw5R/hNXKERm8GnKiYZEcShdcR708bJGSMLoP3u28s=; b=FDjhccAPecB092yTLOqMtoAkE2W0QVY1hShcWqCTGQGPu+LPxNip01oDGsED3zvpbV adcr8t+w5o/KMXuZc4jdtpNGoC+X6nf3KwN1ETmljAl9xweArcMBpLOd47wGe13EIVqv bISZTvFuHybFZbZBz1od5YiFGNG3xLwWgex34HwpF0qZ3/kjlsCv6nxk/vNoy181nczO SSfvyDOgDd40EkHB4/iqLtZLMYuniY25bzq3ImJdd+nVi17t/PU4hFezcK/xOYryUZ2G SV0xQBp/OtunhlhJBbswJ1jbodaAzqL6jqc9PI5RiZsxx6A89HM3N/CVc0I0dkPaoF3+ LC4w== X-Gm-Message-State: ACgBeo24v7UjmS5hRV7OKIYwXg30Ub5dBV2J3q9CWlJQJpuTx0qw5F4N j3oZGA5173Cny0Ida5Vu7yVvLBOH/gs= X-Received: by 2002:a17:902:694a:b0:172:bd15:3ece with SMTP id k10-20020a170902694a00b00172bd153ecemr548870plt.116.1662501110661; Tue, 06 Sep 2022 14:51:50 -0700 (PDT) Received: from localhost (76-14-89-2.sf-cable.astound.net. [76.14.89.2]) by smtp.gmail.com with ESMTPSA id o22-20020a63f156000000b00434acf7a05fsm1967722pgk.45.2022.09.06.14.51.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 14:51:50 -0700 (PDT) Received: by localhost (sSMTP sendmail emulation); Tue, 06 Sep 2022 14:51:46 -0700 From: pal@sandflow.com To: ffmpeg-devel@ffmpeg.org Date: Tue, 6 Sep 2022 14:51:44 -0700 Message-Id: <20220906215145.6607-1-pal@sandflow.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v3 1/2] 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: JAp+k/p3Pw8C 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;