diff options
author | Mark Reid <mindmark@gmail.com> | 2017-12-04 20:46:22 -0800 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2017-12-08 20:02:16 +0100 |
commit | 901d87aa83aa1686f02bb4750c74d4d7cb6086db (patch) | |
tree | a2cfe247f7085f70d7b2140eee5901fe1091b4d3 /libavformat/mxfenc.c | |
parent | ad2641c36bf65d4fc8bfea4c14e282bb0ed5db27 (diff) | |
download | ffmpeg-901d87aa83aa1686f02bb4750c74d4d7cb6086db.tar.gz |
avformat/mxfenc: write reel_name if metadata key is present
Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavformat/mxfenc.c')
-rw-r--r-- | libavformat/mxfenc.c | 42 |
1 files changed, 35 insertions, 7 deletions
diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c index c9694f2a4e..3bb70326fe 100644 --- a/libavformat/mxfenc.c +++ b/libavformat/mxfenc.c @@ -105,6 +105,7 @@ typedef struct MXFPackage { char *name; enum MXFMetadataSetType type; int instance; + struct MXFPackage *ref; } MXFPackage; enum ULIndex { @@ -991,20 +992,33 @@ static void mxf_write_structural_component(AVFormatContext *s, AVStream *st, MXF // write source package uid, end of the reference mxf_write_local_tag(pb, 32, 0x1101); - if (package->type == SourcePackage) { + if (!package->ref) { for (i = 0; i < 4; i++) avio_wb64(pb, 0); } else - mxf_write_umid(s, 1); + mxf_write_umid(s, package->ref->instance); // write source track id mxf_write_local_tag(pb, 4, 0x1102); - if (package->type == SourcePackage) + if (package->type == SourcePackage && !package->ref) avio_wb32(pb, 0); else avio_wb32(pb, st->index+2); } +static void mxf_write_tape_descriptor(AVFormatContext *s) +{ + AVIOContext *pb = s->pb; + + mxf_write_metadata_key(pb, 0x012e00); + PRINT_KEY(s, "tape descriptor key", pb->buf_ptr - 16); + klv_encode_ber_length(pb, 20); + mxf_write_local_tag(pb, 16, 0x3C0A); + mxf_write_uuid(pb, TapeDescriptor, 0); + PRINT_KEY(s, "tape_desc uid", pb->buf_ptr - 16); +} + + static void mxf_write_multi_descriptor(AVFormatContext *s) { MXFContext *mxf = s->priv_data; @@ -1388,13 +1402,17 @@ static void mxf_write_package(AVFormatContext *s, MXFPackage *package) } // write multiple descriptor reference - if (package->type == SourcePackage) { + if (package->type == SourcePackage && package->instance == 1) { mxf_write_local_tag(pb, 16, 0x4701); if (s->nb_streams > 1) { mxf_write_uuid(pb, MultipleDescriptor, 0); mxf_write_multi_descriptor(s); } else mxf_write_uuid(pb, SubDescriptor, 0); + } else if (package->type == SourcePackage && package->instance == 2) { + mxf_write_local_tag(pb, 16, 0x4701); + mxf_write_uuid(pb, TapeDescriptor, 0); + mxf_write_tape_descriptor(s); } /* @@ -1418,7 +1436,7 @@ static void mxf_write_package(AVFormatContext *s, MXFPackage *package) mxf_write_structural_component(s, st, package); mxf->track_instance_count++; - if (package->type == SourcePackage) { + if (package->type == SourcePackage && package->instance == 1) { MXFStreamContext *sc = st->priv_data; mxf_essence_container_uls[sc->index].write_desc(s, st); } @@ -1453,12 +1471,13 @@ static int mxf_write_header_metadata_sets(AVFormatContext *s) AVDictionaryEntry *entry = NULL; AVStream *st = NULL; int i; - - MXFPackage packages[2] = {{0}}; + MXFPackage packages[3] = {{0}}; int package_count = 2; packages[0].type = MaterialPackage; packages[1].type = SourcePackage; packages[1].instance = 1; + packages[0].ref = &packages[1]; + if (entry = av_dict_get(s->metadata, "material_package_name", NULL, 0)) packages[0].name = entry->value; @@ -1476,6 +1495,15 @@ static int mxf_write_header_metadata_sets(AVFormatContext *s) } } + entry = av_dict_get(s->metadata, "reel_name", NULL, 0); + if (entry) { + packages[2].name = entry->value; + packages[2].type = SourcePackage; + packages[2].instance = 2; + packages[1].ref = &packages[2]; + package_count = 3; + } + mxf_write_preface(s); mxf_write_identification(s); mxf_write_content_storage(s, packages, package_count); |