From 5c108092a34ea01dff4ff7f8764a904f238ef1f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= Date: Thu, 25 Oct 2012 10:23:59 +0200 Subject: [PATCH] mxfenc: Write MultipleDescriptor ref in Preface Reviewed-by: Matthieu Bouron Signed-off-by: Michael Niedermayer --- libavformat/mxfenc.c | 15 +++++++++++---- tests/ref/lavf/mxf | 6 +++--- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c index 7acc77940c..c583197a45 100644 --- a/libavformat/mxfenc.c +++ b/libavformat/mxfenc.c @@ -529,18 +529,25 @@ static const MXFCodecUL *mxf_get_data_definition_ul(int type) return uls; } +//one EC -> one descriptor. N ECs -> MultipleDescriptor + N descriptors +#define DESCRIPTOR_COUNT(essence_container_count) \ + (essence_container_count > 1 ? essence_container_count + 1 : essence_container_count) + static void mxf_write_essence_container_refs(AVFormatContext *s) { MXFContext *c = s->priv_data; AVIOContext *pb = s->pb; int i; - mxf_write_refs_count(pb, c->essence_container_count); + mxf_write_refs_count(pb, DESCRIPTOR_COUNT(c->essence_container_count)); av_log(s,AV_LOG_DEBUG, "essence container count:%d\n", c->essence_container_count); for (i = 0; i < c->essence_container_count; i++) { MXFStreamContext *sc = s->streams[i]->priv_data; avio_write(pb, mxf_essence_container_uls[sc->index].container_ul, 16); } + + if (c->essence_container_count > 1) + avio_write(pb, multiple_desc_ul, 16); } static void mxf_write_preface(AVFormatContext *s) @@ -550,7 +557,7 @@ static void mxf_write_preface(AVFormatContext *s) mxf_write_metadata_key(pb, 0x012f00); PRINT_KEY(s, "preface key", pb->buf_ptr - 16); - klv_encode_ber_length(pb, 130 + 16LL * mxf->essence_container_count); + klv_encode_ber_length(pb, 130 + 16LL * DESCRIPTOR_COUNT(mxf->essence_container_count)); // write preface set uid mxf_write_local_tag(pb, 16, 0x3C0A); @@ -579,7 +586,7 @@ static void mxf_write_preface(AVFormatContext *s) avio_write(pb, op1a_ul, 16); // write essence_container_refs - mxf_write_local_tag(pb, 8 + 16 * mxf->essence_container_count, 0x3B0A); + mxf_write_local_tag(pb, 8 + 16LL * DESCRIPTOR_COUNT(mxf->essence_container_count), 0x3B0A); mxf_write_essence_container_refs(s); // write dm_scheme_refs @@ -1326,7 +1333,7 @@ static void mxf_write_partition(AVFormatContext *s, int bodysid, // write klv avio_write(pb, key, 16); - klv_encode_ber_length(pb, 88 + 16LL * mxf->essence_container_count); + klv_encode_ber_length(pb, 88 + 16LL * DESCRIPTOR_COUNT(mxf->essence_container_count)); // write partition value avio_wb16(pb, 1); // majorVersion diff --git a/tests/ref/lavf/mxf b/tests/ref/lavf/mxf index d8aeb4ac20..3572bbeac0 100644 --- a/tests/ref/lavf/mxf +++ b/tests/ref/lavf/mxf @@ -1,9 +1,9 @@ -3fb5387504760db6ebbed106fcda5789 *./tests/data/lavf/lavf.mxf +c53c9f7ee2091405fbe50374f9055679 *./tests/data/lavf/lavf.mxf 525369 ./tests/data/lavf/lavf.mxf ./tests/data/lavf/lavf.mxf CRC=0x17ce1069 -830a8b9ee58781bf654c55905067cdae *./tests/data/lavf/lavf.mxf +14d0ac1513840b670a785daf4331aca8 *./tests/data/lavf/lavf.mxf 554553 ./tests/data/lavf/lavf.mxf ./tests/data/lavf/lavf.mxf CRC=0xa3c0dbc4 -10c6ae1bd97c851728c9abad9dddfa2e *./tests/data/lavf/lavf.mxf +5636cee18b0f34a5acb33a8efb9f80c6 *./tests/data/lavf/lavf.mxf 525369 ./tests/data/lavf/lavf.mxf ./tests/data/lavf/lavf.mxf CRC=0x17ce1069