avformat/mxf: Establish register of local tags
Tags can be marked "not used" upfront, saving some space in the primer. av_asserts0() is used to enforce that only tags that are in the primer can actually be written. Sharing of MasteringDisplay ULs is now done via macros.
This commit is contained in:
parent
5441699f83
commit
ff0618b5c4
@ -22,19 +22,8 @@
|
||||
#include "libavutil/common.h"
|
||||
#include "mxf.h"
|
||||
|
||||
const uint8_t ff_mxf_mastering_display_prefix[13] = { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x04,0x20,0x04,0x01,0x01 };
|
||||
|
||||
const 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 };
|
||||
|
||||
/* be careful to update references to this array if reordering */
|
||||
/* local tags are dynamic and must not clash with others in mxfenc.c */
|
||||
const MXFLocalTagPair ff_mxf_mastering_display_local_tags[4] = {
|
||||
{ 0x8301, { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x04,0x20,0x04,0x01,0x01,0x01,0x00,0x00 }}, /* Mastering Display Primaries */
|
||||
{ 0x8302, { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x04,0x20,0x04,0x01,0x01,0x02,0x00,0x00 }}, /* Mastering Display White Point Chromaticity */
|
||||
{ 0x8303, { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x04,0x20,0x04,0x01,0x01,0x03,0x00,0x00 }}, /* Mastering Display Maximum Luminance */
|
||||
{ 0x8304, { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x04,0x20,0x04,0x01,0x01,0x04,0x00,0x00 }} /* Mastering Display Minimum Luminance */
|
||||
};
|
||||
|
||||
/**
|
||||
* SMPTE RP224 http://www.smpte-ra.org/mdd/index.html
|
||||
*/
|
||||
|
@ -83,9 +83,13 @@ typedef struct MXFLocalTagPair {
|
||||
UID uid;
|
||||
} MXFLocalTagPair;
|
||||
|
||||
extern const uint8_t ff_mxf_mastering_display_prefix[13];
|
||||
extern const uint8_t ff_mxf_random_index_pack_key[16];
|
||||
extern const MXFLocalTagPair ff_mxf_mastering_display_local_tags[4];
|
||||
|
||||
#define FF_MXF_MasteringDisplay_PREFIX 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x04,0x20,0x04,0x01,0x01
|
||||
#define FF_MXF_MasteringDisplayPrimaries { FF_MXF_MasteringDisplay_PREFIX,0x01,0x00,0x00 }
|
||||
#define FF_MXF_MasteringDisplayWhitePointChromaticity { FF_MXF_MasteringDisplay_PREFIX,0x02,0x00,0x00 }
|
||||
#define FF_MXF_MasteringDisplayMaximumLuminance { FF_MXF_MasteringDisplay_PREFIX,0x03,0x00,0x00 }
|
||||
#define FF_MXF_MasteringDisplayMinimumLuminance { FF_MXF_MasteringDisplay_PREFIX,0x04,0x00,0x00 }
|
||||
|
||||
#define FF_MXF_MASTERING_CHROMA_DEN 50000
|
||||
#define FF_MXF_MASTERING_LUMA_DEN 10000
|
||||
|
@ -336,6 +336,14 @@ static const uint8_t mxf_indirect_value_utf16be[] = { 0x42,0x01,0x10,0x
|
||||
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 };
|
||||
|
||||
static uint8_t mxf_mastering_display_prefix[13] = { FF_MXF_MasteringDisplay_PREFIX };
|
||||
static uint8_t mxf_mastering_display_uls[4][16] = {
|
||||
FF_MXF_MasteringDisplayPrimaries,
|
||||
FF_MXF_MasteringDisplayWhitePointChromaticity,
|
||||
FF_MXF_MasteringDisplayMaximumLuminance,
|
||||
FF_MXF_MasteringDisplayMinimumLuminance,
|
||||
};
|
||||
|
||||
#define IS_KLV_KEY(x, y) (!memcmp(x, y, sizeof(y)))
|
||||
|
||||
static void mxf_free_metadataset(MXFMetadataSet **ctx, int freectx)
|
||||
@ -1280,13 +1288,13 @@ 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, ff_mxf_mastering_display_prefix)) {
|
||||
if (IS_KLV_KEY(uid, mxf_mastering_display_prefix)) {
|
||||
if (!descriptor->mastering) {
|
||||
descriptor->mastering = av_mastering_display_metadata_alloc();
|
||||
if (!descriptor->mastering)
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
if (IS_KLV_KEY(uid, ff_mxf_mastering_display_local_tags[0].uid)) {
|
||||
if (IS_KLV_KEY(uid, mxf_mastering_display_uls[0])) {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
/* Order: large x, large y, other (i.e. RGB) */
|
||||
descriptor->mastering->display_primaries[i][0] = av_make_q(avio_rb16(pb), FF_MXF_MASTERING_CHROMA_DEN);
|
||||
@ -1296,20 +1304,20 @@ static int mxf_read_generic_descriptor(void *arg, AVIOContext *pb, int tag, int
|
||||
if (descriptor->mastering->white_point[0].den != 0)
|
||||
descriptor->mastering->has_primaries = 1;
|
||||
}
|
||||
if (IS_KLV_KEY(uid, ff_mxf_mastering_display_local_tags[1].uid)) {
|
||||
if (IS_KLV_KEY(uid, mxf_mastering_display_uls[1])) {
|
||||
descriptor->mastering->white_point[0] = av_make_q(avio_rb16(pb), FF_MXF_MASTERING_CHROMA_DEN);
|
||||
descriptor->mastering->white_point[1] = av_make_q(avio_rb16(pb), FF_MXF_MASTERING_CHROMA_DEN);
|
||||
/* Check we have seen mxf_mastering_display_primaries */
|
||||
if (descriptor->mastering->display_primaries[0][0].den != 0)
|
||||
descriptor->mastering->has_primaries = 1;
|
||||
}
|
||||
if (IS_KLV_KEY(uid, ff_mxf_mastering_display_local_tags[2].uid)) {
|
||||
if (IS_KLV_KEY(uid, mxf_mastering_display_uls[2])) {
|
||||
descriptor->mastering->max_luminance = av_make_q(avio_rb32(pb), FF_MXF_MASTERING_LUMA_DEN);
|
||||
/* Check we have seen mxf_mastering_display_minimum_luminance */
|
||||
if (descriptor->mastering->min_luminance.den != 0)
|
||||
descriptor->mastering->has_luminance = 1;
|
||||
}
|
||||
if (IS_KLV_KEY(uid, ff_mxf_mastering_display_local_tags[3].uid)) {
|
||||
if (IS_KLV_KEY(uid, mxf_mastering_display_uls[3])) {
|
||||
descriptor->mastering->min_luminance = av_make_q(avio_rb32(pb), FF_MXF_MASTERING_LUMA_DEN);
|
||||
/* Check we have seen mxf_mastering_display_maximum_luminance */
|
||||
if (descriptor->mastering->max_luminance.den != 0)
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user