[FFmpeg-devel] [PATCH] libavformat/mxfdec.c: export the full UMID as metadata
Mark Reid
mindmark at gmail.com
Mon Jan 5 21:41:28 CET 2015
---
libavformat/mxfdec.c | 39 ++++++++++++++++++++++++++++++++-------
1 file changed, 32 insertions(+), 7 deletions(-)
diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index 4715169..5ade23a 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -200,6 +200,7 @@ typedef struct {
UID uid;
enum MXFMetadataSetType type;
UID package_uid;
+ UID package_ul;
UID *tracks_refs;
int tracks_count;
MXFDescriptor *descriptor; /* only one */
@@ -840,8 +841,8 @@ static int mxf_read_package(void *arg, AVIOContext *pb, int tag, int size, UID u
avio_read(pb, (uint8_t *)package->tracks_refs, package->tracks_count * sizeof(UID));
break;
case 0x4401:
- /* UMID, only get last 16 bytes */
- avio_skip(pb, 16);
+ /* UMID */
+ avio_read(pb, package->package_ul, 16);
avio_read(pb, package->package_uid, 16);
break;
case 0x4701:
@@ -1488,11 +1489,35 @@ static int mxf_uid_to_str(UID uid, char **str)
return 0;
}
-static int mxf_add_uid_metadata(AVDictionary **pm, const char *key, UID uid)
+static int mxf_umid_to_str(UID ul, UID uid, char **str)
+{
+ int i;
+ char *p;
+ p = *str = av_mallocz(sizeof(UID) * 4 + 3 + 1);
+ if (!p)
+ return AVERROR(ENOMEM);
+ for (i = 0; i < sizeof(UID); i++) {
+ snprintf(p, 2 + 1, "%.2x", ul[i]);
+ p += 2;
+ if (i == 11 || i == 12 || i == 15) {
+ snprintf(p, 1 + 1, "-");
+ p++;
+ }
+ }
+ for (i = 0; i < sizeof(UID); i++) {
+ snprintf(p, 2 + 1, "%.2x", uid[i]);
+ p += 2;
+ }
+ return 0;
+}
+
+static int mxf_add_umid_metadata(AVDictionary **pm, const char *key, MXFPackage* package)
{
char *str;
int ret;
- if ((ret = mxf_uid_to_str(uid, &str)) < 0)
+ if (!package)
+ return 0;
+ if ((ret = mxf_umid_to_str(package->package_ul, package->package_uid, &str)) < 0)
return ret;
av_dict_set(pm, key, str, AV_DICT_DONT_STRDUP_VAL);
return 0;
@@ -1633,7 +1658,7 @@ static int mxf_parse_physical_source_package(MXFContext *mxf, MXFTrack *source_t
if (!(physical_package = mxf_resolve_source_package(mxf, sourceclip->source_package_uid)))
break;
- mxf_add_uid_metadata(&st->metadata, "reel_uid", physical_package->package_uid);
+ mxf_add_umid_metadata(&st->metadata, "reel_umid", physical_package);
/* the name of physical source package is name of the reel or tape */
if (physical_package->name && physical_package->name[0])
@@ -1690,7 +1715,7 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
return AVERROR_INVALIDDATA;
}
- mxf_add_uid_metadata(&mxf->fc->metadata, "material_package_uid", material_package->package_uid);
+ mxf_add_umid_metadata(&mxf->fc->metadata, "material_package_umid", material_package);
if (material_package->name && material_package->name[0])
av_dict_set(&mxf->fc->metadata, "material_package_name", material_package->name, 0);
@@ -1858,7 +1883,7 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
}
av_log(mxf->fc, AV_LOG_VERBOSE, "\n");
- mxf_add_uid_metadata(&st->metadata, "file_package_uid", source_package->package_uid);
+ mxf_add_umid_metadata(&st->metadata, "file_package_umid", source_package);
if (source_package->name && source_package->name[0])
av_dict_set(&st->metadata, "file_package_name", source_package->name, 0);
--
2.2.1
More information about the ffmpeg-devel
mailing list