From patchwork Thu Mar 5 21:56:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 18058 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 256D144AB1F for ; Thu, 5 Mar 2020 23:56:46 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0836A68ABF7; Thu, 5 Mar 2020 23:56:46 +0200 (EET) 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 9654868ABE7 for ; Thu, 5 Mar 2020 23:56:39 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 5CACEE333E; Thu, 5 Mar 2020 22:56:39 +0100 (CET) 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 xEMZuRGMg0JM; Thu, 5 Mar 2020 22:56:38 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 11884E3953; Thu, 5 Mar 2020 22:56:37 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Thu, 5 Mar 2020 22:56:24 +0100 Message-Id: <20200305215628.19514-3-cus@passwd.hu> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20200305215628.19514-1-cus@passwd.hu> References: <20200305215628.19514-1-cus@passwd.hu> Subject: [FFmpeg-devel] [PATCH v2 3/7] avformat/mxfenc: move content package rates and timebase combinations to a separate struct X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Marton Balint --- libavformat/mxf.c | 32 ++++++++++++++++---------------- libavformat/mxf.h | 5 +++++ 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/libavformat/mxf.c b/libavformat/mxf.c index 10ccd770e3..80626e2a16 100644 --- a/libavformat/mxf.c +++ b/libavformat/mxf.c @@ -131,25 +131,25 @@ int ff_mxf_decode_pixel_layout(const char pixel_layout[16], enum AVPixelFormat * return -1; } -static const AVRational mxf_time_base[] = { - { 1001, 24000 }, - { 1, 24}, - { 1001, 30000 }, - { 1001, 60000 }, - { 1, 25 }, - { 1, 50 }, - { 1, 60 }, - { 0, 0} -}; - -static const int mxf_content_package_rates[] = { - 3, 2, 7, 13, 4, 10, 12, +/** + * See SMPTE 326M-2000 Section 7.2 Content package rate + * MXFContentPackageRate->rate is bits b5..b0. + */ +static const MXFContentPackageRate mxf_content_package_rates[] = { + { 2, { 1, 24 } }, + { 3, { 1001, 24000 } }, + { 4, { 1, 25 } }, + { 7, { 1001, 30000 } }, + { 10, { 1, 50 } }, + { 12, { 1, 60 } }, + { 13, { 1001, 60000 } }, + {0} }; int ff_mxf_get_content_package_rate(AVRational time_base) { - for (int i = 0; mxf_time_base[i].num; i++) - if (!av_cmp_q(time_base, mxf_time_base[i])) - return mxf_content_package_rates[i]; + for (int i = 0; mxf_content_package_rates[i].rate; i++) + if (!av_cmp_q(time_base, mxf_content_package_rates[i].tb)) + return mxf_content_package_rates[i].rate; return 0; } diff --git a/libavformat/mxf.h b/libavformat/mxf.h index 2669269830..f2fff2781e 100644 --- a/libavformat/mxf.h +++ b/libavformat/mxf.h @@ -59,6 +59,11 @@ enum MXFFrameLayout { SegmentedFrame, }; +typedef struct MXFContentPackageRate { + int rate; + AVRational tb; +} MXFContentPackageRate; + typedef struct KLVPacket { UID key; int64_t offset;