mxfenc: Write MultipleDescriptor ref in Preface

Reviewed-by: Matthieu Bouron <matthieu.bouron@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Tomas Härdin 2012-10-25 10:23:59 +02:00 committed by Michael Niedermayer
parent da4e4d65f4
commit 5c108092a3
2 changed files with 14 additions and 7 deletions

View File

@ -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

View File

@ -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