return 0;
}
+static int mxf_version_to_str(uint16_t major, uint16_t minor, uint16_t tertiary,
+ uint16_t patch, uint16_t release, char **str)
+{
+ *str = av_asprintf("%d.%d.%d.%d.%d", major, minor, tertiary, patch, release);
+ if (!*str)
+ return AVERROR(ENOMEM);
+ return 0;
+}
+
static int mxf_add_umid_metadata(AVDictionary **pm, const char *key, MXFPackage* package)
{
char *str;
av_dict_set(&s->metadata, name, str, AV_DICT_DONT_STRDUP_VAL); \
} while (0)
+#define SET_VERSION_METADATA(pb, name, major, minor, tertiary, patch, release, str) do { \
+ major = avio_rb16(pb); \
+ minor = avio_rb16(pb); \
+ tertiary = avio_rb16(pb); \
+ patch = avio_rb16(pb); \
+ release = avio_rb16(pb); \
+ if ((ret = mxf_version_to_str(major, minor, tertiary, patch, release, &str)) < 0) \
+ return ret; \
+ av_dict_set(&s->metadata, name, str, AV_DICT_DONT_STRDUP_VAL); \
+} while (0)
+
#define SET_UID_METADATA(pb, name, var, str) do { \
avio_read(pb, var, 16); \
if ((ret = mxf_uid_to_str(var, &str)) < 0) \
UID uid = { 0 };
char *str = NULL;
uint64_t ts;
+ uint16_t major, minor, tertiary, patch, release;
switch (tag) {
case 0x3C01:
SET_STR_METADATA(pb, "company_name", str);
case 0x3C02:
SET_STR_METADATA(pb, "product_name", str);
break;
+ case 0x3C03:
+ SET_VERSION_METADATA(pb, "product_version_num", major, minor, tertiary, patch, release, str);
+ break;
case 0x3C04:
SET_STR_METADATA(pb, "product_version", str);
break;
case 0x3C06:
SET_TS_METADATA(pb, "modification_date", ts, str);
break;
+ case 0x3C07:
+ SET_VERSION_METADATA(pb, "toolkit_version_num", major, minor, tertiary, patch, release, str);
+ break;
case 0x3C08:
SET_STR_METADATA(pb, "application_platform", str);
break;
static int mxf_read_local_tags(MXFContext *mxf, KLVPacket *klv, MXFMetadataReadFunc *read_child, int ctx_size, enum MXFMetadataSetType type)
{
AVIOContext *pb = mxf->fc->pb;
- MXFMetadataSet *ctx = ctx_size ? av_mallocz(ctx_size) : mxf;
uint64_t klv_end = avio_tell(pb) + klv->length;
+ MXFMetadataSet *meta;
+ void *ctx;
- if (!ctx)
- return AVERROR(ENOMEM);
- if (ctx_size)
- mxf_metadataset_init(ctx, type);
+ if (ctx_size) {
+ meta = av_mallocz(ctx_size);
+ if (!meta)
+ return AVERROR(ENOMEM);
+ ctx = meta;
+ mxf_metadataset_init(meta, type);
+ } else {
+ meta = NULL;
+ ctx = mxf;
+ }
while (avio_tell(pb) + 4 < klv_end && !avio_feof(pb)) {
int ret;
int tag = avio_rb16(pb);
int size = avio_rb16(pb); /* KLV specified by 0x53 */
int64_t next = avio_tell(pb);
UID uid = {0};
- if (next < 0 || next > INT64_MAX - size)
+ if (next < 0 || next > INT64_MAX - size) {
+ if (meta) {
+ mxf_free_metadataset(&meta, 1);
+ }
return next < 0 ? next : AVERROR_INVALIDDATA;
+ }
next += size;
av_log(mxf->fc, AV_LOG_TRACE, "local tag %#04x size %d\n", tag, size);
}
}
}
- if (ctx_size && tag == 0x3C0A) {
- avio_read(pb, ctx->uid, 16);
+ if (meta && tag == 0x3C0A) {
+ avio_read(pb, meta->uid, 16);
} else if ((ret = read_child(ctx, pb, tag, size, uid, -1)) < 0) {
- if (ctx_size)
- mxf_free_metadataset(&ctx, 1);
+ if (meta) {
+ mxf_free_metadataset(&meta, 1);
+ }
return ret;
}
/* Accept the 64k local set limit being exceeded (Avid). Don't accept
* it extending past the end of the KLV though (zzuf5.mxf). */
if (avio_tell(pb) > klv_end) {
- if (ctx_size) {
- mxf_free_metadataset(&ctx, 1);
+ if (meta) {
+ mxf_free_metadataset(&meta, 1);
}
av_log(mxf->fc, AV_LOG_ERROR,
} else if (avio_tell(pb) <= next) /* only seek forward, else this can loop for a long time */
avio_seek(pb, next, SEEK_SET);
}
- return ctx_size ? mxf_add_metadata_set(mxf, &ctx) : 0;
+ return meta ? mxf_add_metadata_set(mxf, &meta) : 0;
}
/**