diff options
author | Baptiste Coudurier <baptiste.coudurier@gmail.com> | 2009-02-10 05:35:28 +0000 |
---|---|---|
committer | Baptiste Coudurier <baptiste.coudurier@gmail.com> | 2009-02-10 05:35:28 +0000 |
commit | b25ee3fb387e6abdb518bb7f3bc9611acb1388d7 (patch) | |
tree | 997ad9ef1af6c0b9e6ef24350bcd0072d4a66eff /libavformat | |
parent | bd5c94b54691f7187edcc6b47911341210226be4 (diff) | |
download | ffmpeg-b25ee3fb387e6abdb518bb7f3bc9611acb1388d7.tar.gz |
move up mxf_write_klv_fill and align index, rip and primer pack
Originally committed as revision 17118 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/mxfenc.c | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c index d8da129453..70d27e6168 100644 --- a/libavformat/mxfenc.c +++ b/libavformat/mxfenc.c @@ -973,6 +973,22 @@ static void mxf_write_index_table_segment(AVFormatContext *s) } } +static void mxf_write_klv_fill(AVFormatContext *s) +{ + unsigned pad = klv_fill_size(url_ftell(s->pb)); + if (pad) { + put_buffer(s->pb, klv_fill_key, 16); + pad -= 16; + pad -= klv_ber_length(pad); + klv_encode_ber_length(s->pb, pad); + for (; pad > 7; pad -= 8) + put_be64(s->pb, 0); + for (; pad; pad--) + put_byte(s->pb, 0); + assert(!(url_ftell(s->pb) & (KAG_SIZE-1))); + } +} + static void mxf_write_partition(AVFormatContext *s, int bodysid, int indexsid, unsigned index_byte_count, const uint8_t *key, int write_metadata) @@ -1023,6 +1039,8 @@ static void mxf_write_partition(AVFormatContext *s, int bodysid, int64_t pos, start = url_ftell(s->pb); unsigned header_byte_count; + mxf_write_klv_fill(s); + mxf_write_primer_pack(s); mxf_write_header_metadata_sets(s); pos = url_ftell(s->pb); @@ -1207,22 +1225,6 @@ static int mxf_write_header(AVFormatContext *s) return 0; } -static void mxf_write_klv_fill(AVFormatContext *s) -{ - unsigned pad = klv_fill_size(url_ftell(s->pb)); - if (pad) { - put_buffer(s->pb, klv_fill_key, 16); - pad -= 16; - pad -= klv_ber_length(pad); - klv_encode_ber_length(s->pb, pad); - for (; pad > 7; pad -= 8) - put_be64(s->pb, 0); - for (; pad; pad--) - put_byte(s->pb, 0); - assert(!(url_ftell(s->pb) & (KAG_SIZE-1))); - } -} - static const uint8_t system_metadata_pack_key[] = { 0x06,0x0E,0x2B,0x34,0x02,0x05,0x01,0x01,0x0D,0x01,0x03,0x01,0x04,0x01,0x01,0x00 }; static const uint8_t system_metadata_package_set_key[] = { 0x06,0x0E,0x2B,0x34,0x02,0x43,0x01,0x01,0x0D,0x01,0x03,0x01,0x04,0x01,0x02,0x01 }; @@ -1368,14 +1370,19 @@ static int mxf_write_footer(AVFormatContext *s) // add encoded ber length index_byte_count += 16 + klv_ber_length(index_byte_count); + index_byte_count += klv_fill_size(index_byte_count); mxf_write_klv_fill(s); mxf->footer_partition_offset = url_ftell(pb); mxf_write_partition(s, 0, 2, index_byte_count, footer_partition_key, 0); + mxf_write_klv_fill(s); + mxf_write_index_table_segment(s); + mxf_write_klv_fill(s); + mxf_write_random_index_pack(s); if (!url_is_streamed(s->pb)) { |