summaryrefslogtreecommitdiff
path: root/libavformat/mxfdec.c
diff options
context:
space:
mode:
authorHarry Mallon <harry.mallon@codex.online>2020-09-09 15:56:39 +0100
committerTomas Härdin <tjoppen@acc.umu.se>2020-09-17 21:40:25 +0200
commitfe3a57f4caa221111cd0e42fe17302e0a21ca302 (patch)
treeb1b0642efbc4b4bc9c51745b0b898731cef41b43 /libavformat/mxfdec.c
parentbb2215f4dbc882c8850ac5858f901936b491cd6a (diff)
avformat/mxfdec: Read Apple private Content Light Level from MXF
* As embedded by Apple Compressor Signed-off-by: Harry Mallon <harry.mallon@codex.online>
Diffstat (limited to 'libavformat/mxfdec.c')
-rw-r--r--libavformat/mxfdec.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index 8d315620bc..d16a7af0df 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -216,6 +216,8 @@ typedef struct MXFDescriptor {
UID color_trc_ul;
UID color_space_ul;
AVMasteringDisplayMetadata *mastering;
+ AVContentLightMetadata *coll;
+ size_t coll_size;
} MXFDescriptor;
typedef struct MXFIndexTableSegment {
@@ -321,6 +323,7 @@ static const uint8_t mxf_canopus_essence_element_key[] = { 0x06,0x0e,0x2b,0x
static const uint8_t mxf_system_item_key_cp[] = { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x03,0x01,0x04 };
static const uint8_t mxf_system_item_key_gc[] = { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x03,0x01,0x14 };
static const uint8_t mxf_klv_key[] = { 0x06,0x0e,0x2b,0x34 };
+static const uint8_t mxf_apple_coll_prefix[] = { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x0e,0x20,0x04,0x01,0x05,0x03,0x01 };
/* complete keys to match */
static const uint8_t mxf_crypto_source_container_ul[] = { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x09,0x06,0x01,0x01,0x02,0x02,0x00,0x00,0x00 };
static const uint8_t mxf_encrypted_triplet_key[] = { 0x06,0x0e,0x2b,0x34,0x02,0x04,0x01,0x07,0x0d,0x01,0x03,0x01,0x02,0x7e,0x01,0x00 };
@@ -331,6 +334,8 @@ static const uint8_t mxf_avid_project_name[] = { 0xa5,0xfb,0x7b,0x
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_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_apple_coll_max_cll[] = { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x0e,0x20,0x04,0x01,0x05,0x03,0x01,0x01 };
+static const uint8_t mxf_apple_coll_max_fall[] = { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x0e,0x20,0x04,0x01,0x05,0x03,0x01,0x02 };
#define IS_KLV_KEY(x, y) (!memcmp(x, y, sizeof(y)))
@@ -341,6 +346,7 @@ static void mxf_free_metadataset(MXFMetadataSet **ctx, int freectx)
case Descriptor:
av_freep(&((MXFDescriptor *)*ctx)->extradata);
av_freep(&((MXFDescriptor *)*ctx)->mastering);
+ av_freep(&((MXFDescriptor *)*ctx)->coll);
break;
case MultipleDescriptor:
av_freep(&((MXFDescriptor *)*ctx)->sub_descriptors_refs);
@@ -1312,6 +1318,19 @@ static int mxf_read_generic_descriptor(void *arg, AVIOContext *pb, int tag, int
descriptor->mastering->has_luminance = 1;
}
}
+ if (IS_KLV_KEY(uid, mxf_apple_coll_prefix)) {
+ if (!descriptor->coll) {
+ descriptor->coll = av_content_light_metadata_alloc(&descriptor->coll_size);
+ if (!descriptor->coll)
+ return AVERROR(ENOMEM);
+ }
+ if (IS_KLV_KEY(uid, mxf_apple_coll_max_cll)) {
+ descriptor->coll->MaxCLL = avio_rb16(pb);
+ }
+ if (IS_KLV_KEY(uid, mxf_apple_coll_max_fall)) {
+ descriptor->coll->MaxFALL = avio_rb16(pb);
+ }
+ }
break;
}
return 0;
@@ -2580,6 +2599,14 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
goto fail_and_free;
descriptor->mastering = NULL;
}
+ if (descriptor->coll) {
+ ret = av_stream_add_side_data(st, AV_PKT_DATA_CONTENT_LIGHT_LEVEL,
+ (uint8_t *)descriptor->coll,
+ descriptor->coll_size);
+ if (ret < 0)
+ goto fail_and_free;
+ descriptor->coll = NULL;
+ }
} else if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
container_ul = mxf_get_codec_ul(mxf_sound_essence_container_uls, essence_container_ul);
/* Only overwrite existing codec ID if it is unset or A-law, which is the default according to SMPTE RP 224. */