[FFmpeg-cvslog] libavformat/mxfdec.c: export the full UMID as metadata
Mark Reid
git at videolan.org
Tue Jan 13 02:13:45 CET 2015
ffmpeg | branch: master | Mark Reid <mindmark at gmail.com> | Fri Jan 9 18:05:27 2015 -0800| [b23a8668448d99b4c59daad3d485f17e182f43a3] | committer: Michael Niedermayer
libavformat/mxfdec.c: export the full UMID as metadata
Previous version reviewed-by: tim nicholson
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b23a8668448d99b4c59daad3d485f17e182f43a3
---
libavformat/mxfdec.c | 38 +++++++++++++++++++++++++++++++-------
1 file changed, 31 insertions(+), 7 deletions(-)
diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index 23d9c73..646a3ea 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 */
@@ -841,8 +842,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:
@@ -1489,11 +1490,34 @@ 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 + 2 + 1);
+ if (!p)
+ return AVERROR(ENOMEM);
+ snprintf(p, 2 + 1, "0x");
+ p += 2;
+ for (i = 0; i < sizeof(UID); i++) {
+ snprintf(p, 2 + 1, "%.2X", ul[i]);
+ p += 2;
+
+ }
+ 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;
@@ -1634,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])
@@ -1691,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);
@@ -1859,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);
More information about the ffmpeg-cvslog
mailing list