From patchwork Sun Aug 30 17:22:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?R=C3=A9mi_Achard?= X-Patchwork-Id: 22011 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 24E0F44A918 for ; Sun, 30 Aug 2020 20:28:40 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id EE3BC6880AB; Sun, 30 Aug 2020 20:28:39 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lj1-f180.google.com (mail-lj1-f180.google.com [209.85.208.180]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7F02F68028B for ; Sun, 30 Aug 2020 20:28:33 +0300 (EEST) Received: by mail-lj1-f180.google.com with SMTP id 185so4115150ljj.7 for ; Sun, 30 Aug 2020 10:28:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=wvx8A2+vjqfuz6HAKCT+xNNAPrOuuPn+oAflQ5WBg28=; b=r0pjwYNhyClu5y0uY3kT0XNpGC6F8yD+o1PNGADcrpmCVDEAMqPCFm2lPvbEaoN1jo ZLlG8vIozJjyOl8t9SBRZSItoGnRezZtcRnhMNLba3YghG7MEWWGVRlL72ZlbpOQz3M/ HoyX94EdFLo1lqIihMekuoIwbLYQ5n8MPtOCqLfsHZyhb9z/PfZPjEs7MFZmq8l9WCth F0zQR0OUNu1kFcegJ4ZCpCGm/tGmvPNiGePyKjloqUt/dMGFfYA9LlF80qGzdzZR6bXn WG3yYcRmfTAF3S/MnzBlfLe9PXbMp55a+OhSJe58FQK4LETFSfKecnuLkcm3EuYIX3F3 i9fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=wvx8A2+vjqfuz6HAKCT+xNNAPrOuuPn+oAflQ5WBg28=; b=Sp4PEboonXwQgVQ3NMs77SqtWJulRihG6QueEVNyW96dNghAuF5SsUtVHdrPBHsQBW fi91fAmUASCRadpM6yY0GZ65WyJWvT8USUF14+Udj9a5X9ypemQGWGrTJ5+UIS7IMrdM 9ZakNyCNk0fhH9URDE6dTJ1zxM1DjcmiUMKme82h9gRbq1+N/+J6qA195jEF+XcoLV0H YnOdNufX1hu6/uPL+TlxesjbcQIpyBlYs2mYbUuaXg64Vzu8A4xnuPtRTclMXTLCX5Z8 0gZOko0eBRJL4XGGAKlwqT/s+epWZ+Z31TdF4qgOy4yWmh54MiQeYBM+uf9xG+r1SHhp fbjQ== X-Gm-Message-State: AOAM531hu56AwbP4M/OoZ++8rT1CZ6JLH75bFkdnjYGi9FUo0Mw8FLzi wIWoFi7PdDwjlDfOhjloS1xfEyBrCGW/e5FVqxZP+mYfk/4EYA== X-Google-Smtp-Source: ABdhPJxMpqmdJfx6bmAtDmVFVRJR9jzh6O6VmhMUbaAC6ggfdTyzRuzOs3NmWUrli5PBhOdNnFh9lnzYI4C2buZwy+4= X-Received: by 2002:a2e:8945:: with SMTP id b5mr3350196ljk.381.1598808166146; Sun, 30 Aug 2020 10:22:46 -0700 (PDT) MIME-Version: 1.0 From: =?utf-8?q?R=C3=A9mi_Achard?= Date: Sun, 30 Aug 2020 18:22:35 +0100 Message-ID: To: FFmpeg development discussions and patches X-Content-Filtered-By: Mailman/MimeDel 2.1.20 Subject: [FFmpeg-devel] libopenjpeg decoder not correctly setting the pixel format for cinema JP2K wrapped MXF 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" Hi, As you are probably aware, the libopenjpeg decoder is not able to interpret cinema jp2k mxf correctly, the pixel format being assigned as rgb48 instead of xyz12 as it should. Note that ffmpeg native jp2k decoder parse the RSIZ descriptor from the jp2k bitstream and is able to correctly assign the pixel format, but libopenjpeg currently don't read the RSIZ marker so that ffmpeg wrapper has no simple mean of doing this at the moment (a pull request on libopenjpeg is still in progress to try to fix that). Someone recently pointed me to this commit from 2015 https://github.com/FFmpeg/FFmpeg/commit/2af260e3a85ef2a9fadcac4f4fa652cee53e591e . According to my tests, it doesn't work because of a wrong RSIZ key and missing JP2KEssenceSubDescriptor lookup group. I made a patch I made to fix that, mxfdec is now able to correctly assign the descriptor->pix_fmt field. Note that these keys can be found in SMPTE ST 429-4 or discovered through asdcplib with asdcp-info command line tool parsing a cinema mxf video track. Then, even with that patch, the pixel format detected by the demuxer is not communicated to the decoder, as far as I'm aware. Which makes me wonder, what was the original goal of that commit and what I'm missing to communicate this information to libopenjpeg decoder ? static const uint8_t mxf_avid_project_name[] = { 0xa5,0xfb,0x7b,0x25,0xf6,0x15,0x94,0xb9,0x62,0xfc,0x37,0x17,0x49,0x2d,0x42,0xbf }; -static const uint8_t mxf_jp2k_rsiz[] = { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x02,0x01,0x00 }; +static const uint8_t mxf_jp2k_rsiz[] = { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0a,0x04,0x01,0x06,0x03,0x01,0x00,0x00,0x00 }; static const uint8_t mxf_indirect_value_utf16le[] = { 0x4c,0x00,0x02,0x10,0x01,0x00,0x00,0x00,0x00,0x06,0x0e,0x2b,0x34,0x01,0x04,0x01,0x01 }; static const uint8_t mxf_indirect_value_utf16be[] = { 0x42,0x01,0x10,0x02,0x00,0x00,0x00,0x00,0x00,0x06,0x0e,0x2b,0x34,0x01,0x04,0x01,0x01 }; @@ -2746,6 +2746,7 @@ static const MXFMetadataReadTableEntry mxf_metadata_read_table[] = { { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x42,0x00 }, mxf_read_generic_descriptor, sizeof(MXFDescriptor), Descriptor }, /* Generic Sound */ { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x28,0x00 }, mxf_read_generic_descriptor, sizeof(MXFDescriptor), Descriptor }, /* CDCI */ { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x29,0x00 }, mxf_read_generic_descriptor, sizeof(MXFDescriptor), Descriptor }, /* RGBA */ + { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x5a,0x00 }, mxf_read_generic_descriptor, sizeof(MXFDescriptor), Descriptor }, /* JPEG2000PictureSubDescriptor */ { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x48,0x00 }, mxf_read_generic_descriptor, sizeof(MXFDescriptor), Descriptor }, /* Wave */ { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x47,0x00 }, mxf_read_generic_descriptor, sizeof(MXFDescriptor), Descriptor }, /* AES3 */ { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x51,0x00 }, mxf_read_generic_descriptor, sizeof(MXFDescriptor), Descriptor }, /* MPEG2VideoDescriptor */ diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index 6f6e8d586c..cd85fbedff 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -325,7 +325,7 @@ static const uint8_t mxf_encrypted_essence_container[] = { 0x06,0x0e,0x2b,0x static const uint8_t mxf_random_index_pack_key[] = { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x11,0x01,0x00 }; static const uint8_t mxf_sony_mpeg4_extradata[] = { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x01,0x0e,0x06,0x06,0x02,0x02,0x01,0x00,0x00 };