[FFmpeg-devel] [PATCH] avformat/mxfdec: fix pixel format extraction for cinema j2k
RĂ©mi Achard
remiachard at gmail.com
Sun Sep 13 21:45:10 EEST 2020
---
libavformat/mxf.h | 1 +
libavformat/mxfdec.c | 20 +++++++++++++++++++-
2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/libavformat/mxf.h b/libavformat/mxf.h
index fc587f19f0..3fb3c6d74d 100644
--- a/libavformat/mxf.h
+++ b/libavformat/mxf.h
@@ -49,6 +49,7 @@ enum MXFMetadataSetType {
TaggedValue,
TapeDescriptor,
AVCSubDescriptor,
+ JPEG2000PictureSubDescriptor,
};
enum MXFFrameLayout {
diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index 6f6e8d586c..8eac7fc944 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -325,9 +325,11 @@ 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 };
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 };
+static const uint8_t mxf_subdescriptor_array_smpte[] = { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x09,0x06,0x01,0x01,0x04,0x06,0x10,0x00,0x00 };
+static const uint8_t mxf_subdescriptor_array_interop[] = { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x02,0x06,0x01,0x01,0x04,0x06,0x10,0x00,0x00 };
#define IS_KLV_KEY(x, y) (!memcmp(x, y, sizeof(y)))
@@ -1272,6 +1274,11 @@ static int mxf_read_generic_descriptor(void *arg, AVIOContext *pb, int tag, int
rsiz == FF_PROFILE_JPEG2000_DCINEMA_4K)
descriptor->pix_fmt = AV_PIX_FMT_XYZ12;
}
+ if (IS_KLV_KEY(uid, mxf_subdescriptor_array_smpte)
+ || IS_KLV_KEY(uid, mxf_subdescriptor_array_interop)) {
+ mxf_read_strong_ref_array(pb, &descriptor->sub_descriptors_refs,
+ &descriptor->sub_descriptors_count);
+ }
break;
}
return 0;
@@ -2498,6 +2505,16 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
}
}
+ if (st->codecpar->codec_id == AV_CODEC_ID_JPEG2000) {
+ MXFDescriptor *desc = NULL;
+ for (k = 0; k < descriptor->sub_descriptors_count; k++) {
+ if ((desc = mxf_resolve_strong_ref(mxf, &descriptor->sub_descriptors_refs[k], JPEG2000PictureSubDescriptor))) {
+ st->codecpar->format = desc->pix_fmt;
+ break;
+ }
+ }
+ }
+
if (st->codecpar->codec_id == AV_CODEC_ID_RAWVIDEO) {
st->codecpar->format = descriptor->pix_fmt;
if (st->codecpar->format == AV_PIX_FMT_NONE) {
@@ -2753,6 +2770,7 @@ static const MXFMetadataReadTableEntry mxf_metadata_read_table[] = {
{ { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x5c,0x00 }, mxf_read_generic_descriptor, sizeof(MXFDescriptor), Descriptor }, /* VANC/VBI - SMPTE 436M */
{ { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x5e,0x00 }, mxf_read_generic_descriptor, sizeof(MXFDescriptor), Descriptor }, /* MPEG2AudioDescriptor */
{ { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x64,0x00 }, mxf_read_generic_descriptor, sizeof(MXFDescriptor), Descriptor }, /* DC Timed Text Descriptor */
+ { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x5a,0x00 }, mxf_read_generic_descriptor, sizeof(MXFDescriptor), JPEG2000PictureSubDescriptor }, /* JPEG2000PictureSubDescriptor */
{ { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x3A,0x00 }, mxf_read_track, sizeof(MXFTrack), Track }, /* Static Track */
{ { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x3B,0x00 }, mxf_read_track, sizeof(MXFTrack), Track }, /* Generic Track */
{ { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x14,0x00 }, mxf_read_timecode_component, sizeof(MXFTimecodeComponent), TimecodeComponent },
--
2.24.0
More information about the ffmpeg-devel
mailing list