From patchwork Wed Aug 12 12:25:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harry Mallon X-Patchwork-Id: 21605 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 E920B4488AD for ; Wed, 12 Aug 2020 15:25:30 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C110768B4E8; Wed, 12 Aug 2020 15:25:30 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qt1-f228.google.com (mail-qt1-f228.google.com [209.85.160.228]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2AB0968AE9A for ; Wed, 12 Aug 2020 15:25:24 +0300 (EEST) Received: by mail-qt1-f228.google.com with SMTP id b25so1286967qto.2 for ; Wed, 12 Aug 2020 05:25:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=codex.online; s=google; h=from:mime-version:subject:message-id:date:to; bh=/w/gvB+wuThpgdXmFKC+s6WIj5L1Jh/2Rq0eYXWU/m0=; b=CpAulh91NCJPBgR//0kPPuqSRHk9e8tFRODaBOCVRBQp4t0nZZI+OkbQihNJ4WQVe7 dQ0mPE5WWpJpKCa15YFtUQ8tBklsMYaoCSf+D02cdHA2eqFr/hLqeybE6pbQit2TMmX/ xci7Aq4R4cGbrS+ugz5kSxA4RR1QD4UrLTBGg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:mime-version:subject:message-id:date:to; bh=/w/gvB+wuThpgdXmFKC+s6WIj5L1Jh/2Rq0eYXWU/m0=; b=pS98L9DPn64L2zsh17dUmZtXBydO24HAohFeW4Mx+CN0u3tWDR0AnlbWu54dPZ7cKV 9G2NIbdWbv+KbSPJSIOHqQMDprCPlZ1JcSyfAKSDl99GB7aZAeSdjmQfIydBCRVdflBs soSx59wV3kDXl0UwvrUrCEIuhAbvbE7Awq3aBfYCYEs4lMzjZkmCc2Yu0TpP1YbOO4CX Z8nNuK50lJRoNC1VRxXvScTh+KSkqeXY3G/mhUZqkdokjnmWB6S8LmharPX7EDB1DQuU yp6c82ThrqTLklT3dJZ8aUGKD15VMEQKittmLD0ADUf/aYhzJ0pXE1Yn9LY1l9ejL32p KlfA== X-Gm-Message-State: AOAM5312p2u61lUjoHJ/NxTcI4OQQpxrTalAWpKVItETkMiocX31AsOo lfM2H15LCafVW67aY+UU4nlW/triGZKg+B/wPkWnPQPnM/GByw== X-Google-Smtp-Source: ABdhPJyJ3nJ3Ffjd6k1k012mRImi0ipcYRmgNAXsdg/zGv3uPs7O/jcPqFw3UMrEc7toV1i40YZ/VLp70iB9 X-Received: by 2002:aed:3e8e:: with SMTP id n14mr6262190qtf.67.1597235122301; Wed, 12 Aug 2020 05:25:22 -0700 (PDT) Received: from us2.smtp.exclaimer.net (us2.smtp.exclaimer.net. [104.209.35.28]) by smtp-relay.gmail.com with ESMTPS id i27sm222835qkl.2.2020.08.12.05.25.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Aug 2020 05:25:22 -0700 (PDT) X-Relaying-Domain: pixsystem.com Received: from mail-wr1-f72.google.com (209.85.221.72) by us2.smtp.exclaimer.net (104.209.35.28) with Exclaimer Signature Manager ESMTP Proxy us2.smtp.exclaimer.net (tlsversion=TLS12, tlscipher=TLS_ECDHE_WITH_AES256_SHA1); Wed, 12 Aug 2020 12:25:21 +0000 X-ExclaimerHostedSignatures-MessageProcessed: true X-ExclaimerProxyLatency: 20961141 X-ExclaimerImprintLatency: 2508906 X-ExclaimerImprintAction: bb3c3c91dae94d498845397c695f6ebf Received: by mail-wr1-f72.google.com with SMTP id o10so843249wrs.21 for ; Wed, 12 Aug 2020 05:25:19 -0700 (PDT) X-Received: by 2002:adf:b602:: with SMTP id f2mr32164189wre.186.1597235118224; Wed, 12 Aug 2020 05:25:18 -0700 (PDT) X-Received: by 2002:adf:b602:: with SMTP id f2mr32164169wre.186.1597235117973; Wed, 12 Aug 2020 05:25:17 -0700 (PDT) Received: from ?IPv6:2a01:4b00:8571:3800:40f8:ddf2:24e:8b9? ([2a01:4b00:8571:3800:40f8:ddf2:24e:8b9]) by smtp.gmail.com with ESMTPSA id n12sm4071257wrq.63.2020.08.12.05.25.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Aug 2020 05:25:17 -0700 (PDT) From: Harry Mallon Mime-Version: 1.0 Message-Id: Date: Wed, 12 Aug 2020 13:25:14 +0100 To: ffmpeg-devel@ffmpeg.org X-Mailer: Apple Mail (2.3608.120.23.2.1) X-Content-Filtered-By: Mailman/MimeDel 2.1.20 Subject: [FFmpeg-devel] [PATCH v2] avformat/mxfdec: Read video range from PictureDescriptor 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Rebased the patch on master (it didn't build before) and fixed FATE. From ac8d7884b036b504d07f38815de1c163c5e1691e Mon Sep 17 00:00:00 2001 From: Harry Mallon Date: Wed, 12 Aug 2020 10:26:23 +0100 Subject: [PATCH v2] avformat/mxfdec: Read video range from PictureDescriptor * Capture black_ref, white_ref and color_range and recognise full and narrow range. Signed-off-by: Harry Mallon --- libavformat/mxfdec.c | 22 ++++++++++++++++++++++ tests/ref/fate/mxf-probe-dnxhd | 2 +- tests/ref/fate/mxf-probe-dv25 | 2 +- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index 4b56984b77..7e77fbca10 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -199,6 +199,9 @@ typedef struct MXFDescriptor { int bits_per_sample; int64_t duration; /* ContainerDuration optional property */ unsigned int component_depth; + unsigned int black_ref_level; + unsigned int white_ref_level; + unsigned int color_range; unsigned int horiz_subsampling; unsigned int vert_subsampling; UID *sub_descriptors_refs; @@ -1222,6 +1225,15 @@ static int mxf_read_generic_descriptor(void *arg, AVIOContext *pb, int tag, int case 0x3302: descriptor->horiz_subsampling = avio_rb32(pb); break; + case 0x3304: + descriptor->black_ref_level = avio_rb32(pb); + break; + case 0x3305: + descriptor->white_ref_level = avio_rb32(pb); + break; + case 0x3306: + descriptor->color_range = avio_rb32(pb); + break; case 0x3308: descriptor->vert_subsampling = avio_rb32(pb); break; @@ -2492,6 +2504,16 @@ static int mxf_parse_structural_metadata(MXFContext *mxf) } if (descriptor->aspect_ratio.num && descriptor->aspect_ratio.den) st->display_aspect_ratio = descriptor->aspect_ratio; + if (descriptor->black_ref_level == 0 && + descriptor->white_ref_level == ((1<component_depth) - 1) && + descriptor->color_range == ((1<component_depth) - 1)) { + st->codecpar->color_range = AVCOL_RANGE_JPEG; + } + else if (descriptor->black_ref_level == (1 <<(descriptor->component_depth - 4)) && + descriptor->white_ref_level == (235<<(descriptor->component_depth - 8)) && + descriptor->color_range == ((14<<(descriptor->component_depth - 4)) + 1)) { + st->codecpar->color_range = AVCOL_RANGE_MPEG; + } st->codecpar->color_primaries = mxf_get_codec_ul(ff_mxf_color_primaries_uls, &descriptor->color_primaries_ul)->id; st->codecpar->color_trc = mxf_get_codec_ul(ff_mxf_color_trc_uls, &descriptor->color_trc_ul)->id; st->codecpar->color_space = mxf_get_codec_ul(ff_mxf_color_space_uls, &descriptor->color_space_ul)->id; diff --git a/tests/ref/fate/mxf-probe-dnxhd b/tests/ref/fate/mxf-probe-dnxhd index 012d3ea1d9..5a6221b1d5 100644 --- a/tests/ref/fate/mxf-probe-dnxhd +++ b/tests/ref/fate/mxf-probe-dnxhd @@ -124,7 +124,7 @@ sample_aspect_ratio=1:1 display_aspect_ratio=4:3 pix_fmt=yuv422p level=-99 -color_range=unknown +color_range=tv color_space=bt709 color_transfer=bt709 color_primaries=bt709 diff --git a/tests/ref/fate/mxf-probe-dv25 b/tests/ref/fate/mxf-probe-dv25 index 810f145f41..ffd26c4dfd 100644 --- a/tests/ref/fate/mxf-probe-dv25 +++ b/tests/ref/fate/mxf-probe-dv25 @@ -16,7 +16,7 @@ sample_aspect_ratio=16:15 display_aspect_ratio=4:3 pix_fmt=yuv420p level=-99 -color_range=unknown +color_range=tv color_space=unknown color_transfer=bt470m color_primaries=unknown