1cabdff1aSopenharmony_ci/* 2cabdff1aSopenharmony_ci * MXF 3cabdff1aSopenharmony_ci * Copyright (c) 2006 SmartJog S.A., Baptiste Coudurier <baptiste dot coudurier at smartjog dot com> 4cabdff1aSopenharmony_ci * 5cabdff1aSopenharmony_ci * This file is part of FFmpeg. 6cabdff1aSopenharmony_ci * 7cabdff1aSopenharmony_ci * FFmpeg is free software; you can redistribute it and/or 8cabdff1aSopenharmony_ci * modify it under the terms of the GNU Lesser General Public 9cabdff1aSopenharmony_ci * License as published by the Free Software Foundation; either 10cabdff1aSopenharmony_ci * version 2.1 of the License, or (at your option) any later version. 11cabdff1aSopenharmony_ci * 12cabdff1aSopenharmony_ci * FFmpeg is distributed in the hope that it will be useful, 13cabdff1aSopenharmony_ci * but WITHOUT ANY WARRANTY; without even the implied warranty of 14cabdff1aSopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15cabdff1aSopenharmony_ci * Lesser General Public License for more details. 16cabdff1aSopenharmony_ci * 17cabdff1aSopenharmony_ci * You should have received a copy of the GNU Lesser General Public 18cabdff1aSopenharmony_ci * License along with FFmpeg; if not, write to the Free Software 19cabdff1aSopenharmony_ci * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20cabdff1aSopenharmony_ci */ 21cabdff1aSopenharmony_ci 22cabdff1aSopenharmony_ci#include "libavutil/common.h" 23cabdff1aSopenharmony_ci#include "libavcodec/codec_id.h" 24cabdff1aSopenharmony_ci#include "mxf.h" 25cabdff1aSopenharmony_ci 26cabdff1aSopenharmony_ciconst uint8_t ff_mxf_random_index_pack_key[16] = { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x11,0x01,0x00 }; 27cabdff1aSopenharmony_ci 28cabdff1aSopenharmony_ci/** 29cabdff1aSopenharmony_ci * SMPTE RP224 http://www.smpte-ra.org/mdd/index.html 30cabdff1aSopenharmony_ci */ 31cabdff1aSopenharmony_ciconst MXFCodecUL ff_mxf_data_definition_uls[] = { 32cabdff1aSopenharmony_ci { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x01,0x03,0x02,0x02,0x01,0x00,0x00,0x00 }, 13, AVMEDIA_TYPE_VIDEO }, 33cabdff1aSopenharmony_ci { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x01,0x03,0x02,0x02,0x02,0x00,0x00,0x00 }, 13, AVMEDIA_TYPE_AUDIO }, 34cabdff1aSopenharmony_ci { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x01,0x03,0x02,0x02,0x03,0x00,0x00,0x00 }, 13, AVMEDIA_TYPE_DATA }, 35cabdff1aSopenharmony_ci { { 0x80,0x7D,0x00,0x60,0x08,0x14,0x3E,0x6F,0x6F,0x3C,0x8C,0xE1,0x6C,0xEF,0x11,0xD2 }, 16, AVMEDIA_TYPE_VIDEO }, /* LegacyPicture Avid Media Composer MXF */ 36cabdff1aSopenharmony_ci { { 0x80,0x7D,0x00,0x60,0x08,0x14,0x3E,0x6F,0x78,0xE1,0xEB,0xE1,0x6C,0xEF,0x11,0xD2 }, 16, AVMEDIA_TYPE_AUDIO }, /* LegacySound Avid Media Composer MXF */ 37cabdff1aSopenharmony_ci { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0, AVMEDIA_TYPE_DATA }, 38cabdff1aSopenharmony_ci}; 39cabdff1aSopenharmony_ci 40cabdff1aSopenharmony_ciconst MXFCodecUL ff_mxf_codec_uls[] = { 41cabdff1aSopenharmony_ci /* PictureEssenceCoding */ 42cabdff1aSopenharmony_ci { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x03,0x04,0x01,0x02,0x02,0x01,0x01,0x11,0x00 }, 14, AV_CODEC_ID_MPEG2VIDEO }, /* MP@ML Long GoP */ 43cabdff1aSopenharmony_ci { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x02,0x02,0x01,0x02,0x01,0x01 }, 14, AV_CODEC_ID_MPEG2VIDEO }, /* D-10 50Mbps PAL */ 44cabdff1aSopenharmony_ci { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x03,0x04,0x01,0x02,0x02,0x01,0x03,0x03,0x00 }, 14, AV_CODEC_ID_MPEG2VIDEO }, /* MP@HL Long GoP */ 45cabdff1aSopenharmony_ci { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x03,0x04,0x01,0x02,0x02,0x01,0x04,0x02,0x00 }, 14, AV_CODEC_ID_MPEG2VIDEO }, /* 422P@HL I-Frame */ 46cabdff1aSopenharmony_ci { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x03,0x04,0x01,0x02,0x02,0x01,0x20,0x02,0x03 }, 14, AV_CODEC_ID_MPEG4 }, /* XDCAM proxy_pal030926.mxf */ 47cabdff1aSopenharmony_ci { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x02,0x02,0x02,0x01,0x02,0x00 }, 13, AV_CODEC_ID_DVVIDEO }, /* DV25 IEC PAL */ 48cabdff1aSopenharmony_ci { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x07,0x04,0x01,0x02,0x02,0x03,0x01,0x01,0x00 }, 14, AV_CODEC_ID_JPEG2000 }, /* JPEG 2000 code stream */ 49cabdff1aSopenharmony_ci { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0A,0x04,0x01,0x02,0x02,0x04,0x01,0x00,0x00 }, 14, AV_CODEC_ID_VC1 }, /* VC1 SP@LL */ 50cabdff1aSopenharmony_ci { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0A,0x04,0x01,0x02,0x02,0x04,0x02,0x00,0x00 }, 14, AV_CODEC_ID_VC1 }, /* VC1 SP@ML */ 51cabdff1aSopenharmony_ci { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0A,0x04,0x01,0x02,0x02,0x04,0x03,0x00,0x00 }, 14, AV_CODEC_ID_VC1 }, /* VC1 MP@LL */ 52cabdff1aSopenharmony_ci { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0A,0x04,0x01,0x02,0x02,0x04,0x04,0x00,0x00 }, 14, AV_CODEC_ID_VC1 }, /* VC1 MP@ML */ 53cabdff1aSopenharmony_ci { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0A,0x04,0x01,0x02,0x02,0x04,0x05,0x00,0x00 }, 14, AV_CODEC_ID_VC1 }, /* VC1 MP@HL */ 54cabdff1aSopenharmony_ci { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0A,0x04,0x01,0x02,0x02,0x04,0x06,0x00,0x00 }, 14, AV_CODEC_ID_VC1 }, /* VC1 AP@L0 */ 55cabdff1aSopenharmony_ci { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0A,0x04,0x01,0x02,0x02,0x04,0x07,0x00,0x00 }, 14, AV_CODEC_ID_VC1 }, /* VC1 AP@L1 */ 56cabdff1aSopenharmony_ci { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0A,0x04,0x01,0x02,0x02,0x04,0x08,0x00,0x00 }, 14, AV_CODEC_ID_VC1 }, /* VC1 AP@L2 */ 57cabdff1aSopenharmony_ci { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0A,0x04,0x01,0x02,0x02,0x04,0x09,0x00,0x00 }, 14, AV_CODEC_ID_VC1 }, /* VC1 AP@L3 */ 58cabdff1aSopenharmony_ci { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0A,0x04,0x01,0x02,0x02,0x04,0x0A,0x00,0x00 }, 14, AV_CODEC_ID_VC1 }, /* VC1 AP@L4 */ 59cabdff1aSopenharmony_ci { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x02,0x01,0x7F,0x00,0x00,0x00 }, 13, AV_CODEC_ID_RAWVIDEO }, /* uncompressed */ 60cabdff1aSopenharmony_ci { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0A,0x04,0x01,0x02,0x01,0x01,0x02,0x01,0x00 }, 15, AV_CODEC_ID_RAWVIDEO }, /* uncompressed 422 8-bit */ 61cabdff1aSopenharmony_ci { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x02,0x02,0x71,0x00,0x00,0x00 }, 13, AV_CODEC_ID_DNXHD }, /* SMPTE VC-3/DNxHD */ 62cabdff1aSopenharmony_ci { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x02,0x02,0x03,0x02,0x00,0x00 }, 14, AV_CODEC_ID_DNXHD }, /* SMPTE VC-3/DNxHD */ 63cabdff1aSopenharmony_ci { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0E,0x04,0x02,0x01,0x02,0x04,0x01,0x00 }, 16, AV_CODEC_ID_DNXHD }, /* SMPTE VC-3/DNxHD Legacy Avid Media Composer MXF */ 64cabdff1aSopenharmony_ci { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0A,0x04,0x01,0x02,0x02,0x01,0x32,0x00,0x00 }, 14, AV_CODEC_ID_H264 }, /* H.264/MPEG-4 AVC Intra */ 65cabdff1aSopenharmony_ci { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0A,0x04,0x01,0x02,0x02,0x01,0x31,0x11,0x01 }, 14, AV_CODEC_ID_H264 }, /* H.264/MPEG-4 AVC SPS/PPS in-band */ 66cabdff1aSopenharmony_ci { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0A,0x04,0x01,0x02,0x01,0x01,0x02,0x02,0x01 }, 16, AV_CODEC_ID_V210 }, /* V210 */ 67cabdff1aSopenharmony_ci { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0E,0x04,0x02,0x01,0x02,0x11,0x00,0x00 }, 14, AV_CODEC_ID_PRORES }, /* Avid MC7 ProRes */ 68cabdff1aSopenharmony_ci { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0D,0x04,0x01,0x02,0x02,0x03,0x06,0x00,0x00 }, 14, AV_CODEC_ID_PRORES }, /* Apple ProRes */ 69cabdff1aSopenharmony_ci /* SoundEssenceCompression */ 70cabdff1aSopenharmony_ci { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x03,0x04,0x02,0x02,0x02,0x03,0x03,0x01,0x00 }, 14, AV_CODEC_ID_AAC }, /* MPEG-2 AAC ADTS (legacy) */ 71cabdff1aSopenharmony_ci { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x02,0x02,0x01,0x00,0x00,0x00,0x00 }, 13, AV_CODEC_ID_PCM_S16LE }, /* uncompressed */ 72cabdff1aSopenharmony_ci { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x02,0x02,0x01,0x7F,0x00,0x00,0x00 }, 13, AV_CODEC_ID_PCM_S16LE }, 73cabdff1aSopenharmony_ci { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x07,0x04,0x02,0x02,0x01,0x7E,0x00,0x00,0x00 }, 13, AV_CODEC_ID_PCM_S16BE }, /* From Omneon MXF file */ 74cabdff1aSopenharmony_ci { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x04,0x04,0x02,0x02,0x02,0x03,0x01,0x01,0x00 }, 15, AV_CODEC_ID_PCM_ALAW }, /* XDCAM Proxy C0023S01.mxf */ 75cabdff1aSopenharmony_ci { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x02,0x02,0x02,0x03,0x02,0x01,0x00 }, 15, AV_CODEC_ID_AC3 }, 76cabdff1aSopenharmony_ci { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x02,0x02,0x02,0x03,0x02,0x05,0x00 }, 15, AV_CODEC_ID_MP2 }, /* MP2 or MP3 */ 77cabdff1aSopenharmony_ci //{ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x02,0x02,0x02,0x03,0x02,0x1C,0x00 }, 15, AV_CODEC_ID_DOLBY_E }, /* Dolby-E */ 78cabdff1aSopenharmony_ci { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0, AV_CODEC_ID_NONE }, 79cabdff1aSopenharmony_ci}; 80cabdff1aSopenharmony_ci 81cabdff1aSopenharmony_ciconst MXFCodecUL ff_mxf_pixel_format_uls[] = { 82cabdff1aSopenharmony_ci { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0A,0x04,0x01,0x02,0x01,0x01,0x02,0x01,0x01 }, 16, AV_PIX_FMT_UYVY422 }, 83cabdff1aSopenharmony_ci { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0A,0x04,0x01,0x02,0x01,0x01,0x02,0x01,0x02 }, 16, AV_PIX_FMT_YUYV422 }, 84cabdff1aSopenharmony_ci { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0, AV_PIX_FMT_NONE }, 85cabdff1aSopenharmony_ci}; 86cabdff1aSopenharmony_ci 87cabdff1aSopenharmony_ciconst MXFCodecUL ff_mxf_codec_tag_uls[] = { 88cabdff1aSopenharmony_ci { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0E,0x04,0x03,0x01,0x01,0x03,0x01,0x00 }, 15, MKTAG('A', 'V', 'u', 'p') }, /* Avid 1:1 */ 89cabdff1aSopenharmony_ci { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0, 0 }, 90cabdff1aSopenharmony_ci}; 91cabdff1aSopenharmony_ci 92cabdff1aSopenharmony_ciconst MXFCodecUL ff_mxf_color_primaries_uls[] = { 93cabdff1aSopenharmony_ci { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x06,0x04,0x01,0x01,0x01,0x03,0x01,0x00,0x00 }, 14, AVCOL_PRI_SMPTE170M }, /* SMPTE 170M */ 94cabdff1aSopenharmony_ci { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x06,0x04,0x01,0x01,0x01,0x03,0x02,0x00,0x00 }, 14, AVCOL_PRI_BT470BG }, /* ITU-R BT.470 PAL */ 95cabdff1aSopenharmony_ci { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x06,0x04,0x01,0x01,0x01,0x03,0x03,0x00,0x00 }, 14, AVCOL_PRI_BT709 }, /* ITU-R BT.709 */ 96cabdff1aSopenharmony_ci { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0D,0x04,0x01,0x01,0x01,0x03,0x04,0x00,0x00 }, 14, AVCOL_PRI_BT2020 }, /* ITU-R BT.2020 */ 97cabdff1aSopenharmony_ci { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0D,0x04,0x01,0x01,0x01,0x03,0x05,0x00,0x00 }, 14, AVCOL_PRI_SMPTE428 }, /* SMPTE-DC28 DCDM */ 98cabdff1aSopenharmony_ci { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0D,0x04,0x01,0x01,0x01,0x03,0x06,0x00,0x00 }, 14, AVCOL_PRI_SMPTE432 }, /* P3D65 */ 99cabdff1aSopenharmony_ci { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0D,0x04,0x01,0x01,0x01,0x03,0x08,0x00,0x00 }, 14, AVCOL_PRI_SMPTE428 }, /* Cinema Mezzanine */ 100cabdff1aSopenharmony_ci { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0D,0x04,0x01,0x01,0x01,0x03,0x0a,0x00,0x00 }, 14, AVCOL_PRI_SMPTE431 }, /* P3DCI */ 101cabdff1aSopenharmony_ci /* alternate mappings for encoding */ 102cabdff1aSopenharmony_ci { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x06,0x04,0x01,0x01,0x01,0x03,0x01,0x00,0x00 }, 14, AVCOL_PRI_SMPTE240M }, /* = AVCOL_PRI_SMPTE170M */ 103cabdff1aSopenharmony_ci 104cabdff1aSopenharmony_ci { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0, AVCOL_PRI_UNSPECIFIED }, 105cabdff1aSopenharmony_ci}; 106cabdff1aSopenharmony_ci 107cabdff1aSopenharmony_ciconst MXFCodecUL ff_mxf_color_trc_uls[] = { 108cabdff1aSopenharmony_ci { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x01,0x01,0x01,0x01,0x00,0x00 }, 14, AVCOL_TRC_GAMMA22 }, /* ITU-R BT.470 */ 109cabdff1aSopenharmony_ci { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x01,0x01,0x01,0x02,0x00,0x00 }, 14, AVCOL_TRC_BT709 }, /* ITU-R BT.709 */ 110cabdff1aSopenharmony_ci { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x01,0x01,0x01,0x03,0x00,0x00 }, 14, AVCOL_TRC_SMPTE240M }, /* SMPTE 240M */ 111cabdff1aSopenharmony_ci { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x01,0x01,0x01,0x04,0x00,0x00 }, 14, AVCOL_TRC_BT709 }, /* SMPTE 274/296M (must appear after ITU-R BT.709) */ 112cabdff1aSopenharmony_ci { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x06,0x04,0x01,0x01,0x01,0x01,0x05,0x00,0x00 }, 14, AVCOL_TRC_BT1361_ECG }, /* ITU-R BT.1361 */ 113cabdff1aSopenharmony_ci { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x06,0x04,0x01,0x01,0x01,0x01,0x06,0x00,0x00 }, 14, AVCOL_TRC_LINEAR }, /* Linear */ 114cabdff1aSopenharmony_ci { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x08,0x04,0x01,0x01,0x01,0x01,0x07,0x00,0x00 }, 14, AVCOL_TRC_SMPTE428 }, /* SMPTE-DC28 DCDM */ 115cabdff1aSopenharmony_ci { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0D,0x04,0x01,0x01,0x01,0x01,0x08,0x00,0x00 }, 14, AVCOL_TRC_IEC61966_2_4 }, /* IEC 61966-2-4 xvYCC */ 116cabdff1aSopenharmony_ci { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0E,0x04,0x01,0x01,0x01,0x01,0x09,0x00,0x00 }, 14, AVCOL_TRC_BT2020_10 }, /* ITU-R BT.2020 */ 117cabdff1aSopenharmony_ci { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0D,0x04,0x01,0x01,0x01,0x01,0x0A,0x00,0x00 }, 14, AVCOL_TRC_SMPTE2084 }, /* SMPTE ST 2084 */ 118cabdff1aSopenharmony_ci { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0D,0x04,0x01,0x01,0x01,0x01,0x0B,0x00,0x00 }, 14, AVCOL_TRC_ARIB_STD_B67 }, /* Hybrid Log-Gamma OETF */ 119cabdff1aSopenharmony_ci /* alternate mappings for encoding */ 120cabdff1aSopenharmony_ci { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x01,0x01,0x01,0x01,0x00,0x00 }, 14, AVCOL_TRC_GAMMA28 }, /* = AVCOL_TRC_GAMMA22 */ 121cabdff1aSopenharmony_ci { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x01,0x01,0x01,0x02,0x00,0x00 }, 14, AVCOL_TRC_SMPTE170M }, /* = AVCOL_TRC_BT709 */ 122cabdff1aSopenharmony_ci { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0E,0x04,0x01,0x01,0x01,0x01,0x09,0x00,0x00 }, 14, AVCOL_TRC_BT2020_12 }, /* = AVCOL_TRC_BT2020_10 */ 123cabdff1aSopenharmony_ci 124cabdff1aSopenharmony_ci { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0, AVCOL_TRC_UNSPECIFIED }, 125cabdff1aSopenharmony_ci}; 126cabdff1aSopenharmony_ci 127cabdff1aSopenharmony_ci/* aka Coding Equations */ 128cabdff1aSopenharmony_ciconst MXFCodecUL ff_mxf_color_space_uls[] = { 129cabdff1aSopenharmony_ci { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x01,0x01,0x02,0x01,0x00,0x00 }, 14, AVCOL_SPC_BT470BG }, /* ITU-R BT.601 */ 130cabdff1aSopenharmony_ci { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x01,0x01,0x02,0x02,0x00,0x00 }, 14, AVCOL_SPC_BT709 }, /* ITU-R BT.709 */ 131cabdff1aSopenharmony_ci { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x06,0x04,0x01,0x01,0x01,0x02,0x03,0x00,0x00 }, 14, AVCOL_SPC_SMPTE240M }, /* SMPTE 240M */ 132cabdff1aSopenharmony_ci { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0D,0x04,0x01,0x01,0x01,0x02,0x04,0x00,0x00 }, 14, AVCOL_SPC_YCGCO }, /* YCgCo */ 133cabdff1aSopenharmony_ci { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0D,0x04,0x01,0x01,0x01,0x02,0x05,0x00,0x00 }, 14, AVCOL_SPC_RGB }, /* GBR */ 134cabdff1aSopenharmony_ci { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0D,0x04,0x01,0x01,0x01,0x02,0x06,0x00,0x00 }, 14, AVCOL_SPC_BT2020_NCL }, /* ITU-R BT.2020 Non-Constant Luminance */ 135cabdff1aSopenharmony_ci /* alternate mappings for encoding */ 136cabdff1aSopenharmony_ci { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x01,0x01,0x02,0x01,0x00,0x00 }, 14, AVCOL_SPC_SMPTE170M }, /* = AVCOL_SPC_BT470BG */ 137cabdff1aSopenharmony_ci 138cabdff1aSopenharmony_ci { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0, AVCOL_SPC_UNSPECIFIED }, 139cabdff1aSopenharmony_ci}; 140cabdff1aSopenharmony_ci 141cabdff1aSopenharmony_cistatic const struct { 142cabdff1aSopenharmony_ci enum AVPixelFormat pix_fmt; 143cabdff1aSopenharmony_ci const char data[16]; 144cabdff1aSopenharmony_ci} ff_mxf_pixel_layouts[] = { 145cabdff1aSopenharmony_ci /** 146cabdff1aSopenharmony_ci * See SMPTE 377M E.2.46 147cabdff1aSopenharmony_ci * 148cabdff1aSopenharmony_ci * Note: Only RGB, palette based and "abnormal" YUV pixel formats like 4:2:2:4 go here. 149cabdff1aSopenharmony_ci * For regular YUV, use CDCIPictureEssenceDescriptor. 150cabdff1aSopenharmony_ci * 151cabdff1aSopenharmony_ci * Note: Do not use these for encoding descriptors for little-endian formats until we 152cabdff1aSopenharmony_ci * get samples or official word from SMPTE on how/if those can be encoded. 153cabdff1aSopenharmony_ci */ 154cabdff1aSopenharmony_ci {AV_PIX_FMT_ABGR, {'A', 8, 'B', 8, 'G', 8, 'R', 8 }}, 155cabdff1aSopenharmony_ci {AV_PIX_FMT_ARGB, {'A', 8, 'R', 8, 'G', 8, 'B', 8 }}, 156cabdff1aSopenharmony_ci {AV_PIX_FMT_BGR24, {'B', 8, 'G', 8, 'R', 8 }}, 157cabdff1aSopenharmony_ci {AV_PIX_FMT_BGRA, {'B', 8, 'G', 8, 'R', 8, 'A', 8 }}, 158cabdff1aSopenharmony_ci {AV_PIX_FMT_RGB24, {'R', 8, 'G', 8, 'B', 8 }}, 159cabdff1aSopenharmony_ci {AV_PIX_FMT_RGB444BE,{'F', 4, 'R', 4, 'G', 4, 'B', 4 }}, 160cabdff1aSopenharmony_ci {AV_PIX_FMT_RGB48BE, {'R', 8, 'r', 8, 'G', 8, 'g', 8, 'B', 8, 'b', 8 }}, 161cabdff1aSopenharmony_ci {AV_PIX_FMT_RGB48BE, {'R', 16, 'G', 16, 'B', 16 }}, 162cabdff1aSopenharmony_ci {AV_PIX_FMT_RGB48LE, {'r', 8, 'R', 8, 'g', 8, 'G', 8, 'b', 8, 'B', 8 }}, 163cabdff1aSopenharmony_ci {AV_PIX_FMT_RGB555BE,{'F', 1, 'R', 5, 'G', 5, 'B', 5 }}, 164cabdff1aSopenharmony_ci {AV_PIX_FMT_RGB565BE,{'R', 5, 'G', 6, 'B', 5 }}, 165cabdff1aSopenharmony_ci {AV_PIX_FMT_RGBA, {'R', 8, 'G', 8, 'B', 8, 'A', 8 }}, 166cabdff1aSopenharmony_ci {AV_PIX_FMT_PAL8, {'P', 8 }}, 167cabdff1aSopenharmony_ci {AV_PIX_FMT_GRAY8, {'A', 8 }}, 168cabdff1aSopenharmony_ci}; 169cabdff1aSopenharmony_ci 170cabdff1aSopenharmony_cistatic const int num_pixel_layouts = FF_ARRAY_ELEMS(ff_mxf_pixel_layouts); 171cabdff1aSopenharmony_ci 172cabdff1aSopenharmony_ciint ff_mxf_decode_pixel_layout(const char pixel_layout[16], enum AVPixelFormat *pix_fmt) 173cabdff1aSopenharmony_ci{ 174cabdff1aSopenharmony_ci int x; 175cabdff1aSopenharmony_ci 176cabdff1aSopenharmony_ci for(x = 0; x < num_pixel_layouts; x++) { 177cabdff1aSopenharmony_ci if (!memcmp(pixel_layout, ff_mxf_pixel_layouts[x].data, 16)) { 178cabdff1aSopenharmony_ci *pix_fmt = ff_mxf_pixel_layouts[x].pix_fmt; 179cabdff1aSopenharmony_ci return 0; 180cabdff1aSopenharmony_ci } 181cabdff1aSopenharmony_ci } 182cabdff1aSopenharmony_ci 183cabdff1aSopenharmony_ci return -1; 184cabdff1aSopenharmony_ci} 185cabdff1aSopenharmony_ci 186cabdff1aSopenharmony_ci/** 187cabdff1aSopenharmony_ci * See SMPTE 326M-2000 Section 7.2 Content package rate 188cabdff1aSopenharmony_ci * MXFContentPackageRate->rate is bits b5..b0. 189cabdff1aSopenharmony_ci */ 190cabdff1aSopenharmony_cistatic const MXFContentPackageRate mxf_content_package_rates[] = { 191cabdff1aSopenharmony_ci { 2, { 1, 24 } }, 192cabdff1aSopenharmony_ci { 3, { 1001, 24000 } }, 193cabdff1aSopenharmony_ci { 4, { 1, 25 } }, 194cabdff1aSopenharmony_ci { 6, { 1, 30 } }, 195cabdff1aSopenharmony_ci { 7, { 1001, 30000 } }, 196cabdff1aSopenharmony_ci { 8, { 1 , 48 } }, 197cabdff1aSopenharmony_ci { 9, { 1001, 48000 } }, 198cabdff1aSopenharmony_ci { 10, { 1, 50 } }, 199cabdff1aSopenharmony_ci { 12, { 1, 60 } }, 200cabdff1aSopenharmony_ci { 13, { 1001, 60000 } }, 201cabdff1aSopenharmony_ci { 14, { 1, 72 } }, 202cabdff1aSopenharmony_ci { 15, { 1001, 72000 } }, 203cabdff1aSopenharmony_ci { 16, { 1, 75 } }, 204cabdff1aSopenharmony_ci { 18, { 1, 90 } }, 205cabdff1aSopenharmony_ci { 19, { 1001, 90000 } }, 206cabdff1aSopenharmony_ci { 20, { 1, 96 } }, 207cabdff1aSopenharmony_ci { 21, { 1001, 96000 } }, 208cabdff1aSopenharmony_ci { 22, { 1, 100 } }, 209cabdff1aSopenharmony_ci { 24, { 1, 120 } }, 210cabdff1aSopenharmony_ci { 25, { 1001, 120000} }, 211cabdff1aSopenharmony_ci {0} 212cabdff1aSopenharmony_ci}; 213cabdff1aSopenharmony_ci 214cabdff1aSopenharmony_ciint ff_mxf_get_content_package_rate(AVRational time_base) 215cabdff1aSopenharmony_ci{ 216cabdff1aSopenharmony_ci for (int i = 0; mxf_content_package_rates[i].rate; i++) 217cabdff1aSopenharmony_ci if (!av_cmp_q(time_base, mxf_content_package_rates[i].tb)) 218cabdff1aSopenharmony_ci return mxf_content_package_rates[i].rate; 219cabdff1aSopenharmony_ci return 0; 220cabdff1aSopenharmony_ci} 221