Mercurial > libavformat.hg
comparison mxfenc.c @ 4442:85f1c6887bef libavformat
fix partition offset when only one stream present
author | bcoudurier |
---|---|
date | Tue, 10 Feb 2009 23:25:23 +0000 |
parents | 0fd16041ac29 |
children | f38371d76e4e |
comparison
equal
deleted
inserted
replaced
4441:0fd16041ac29 | 4442:85f1c6887bef |
---|---|
1019 { | 1019 { |
1020 MXFContext *mxf = s->priv_data; | 1020 MXFContext *mxf = s->priv_data; |
1021 ByteIOContext *pb = s->pb; | 1021 ByteIOContext *pb = s->pb; |
1022 int64_t header_byte_count_offset; | 1022 int64_t header_byte_count_offset; |
1023 unsigned index_byte_count = 0; | 1023 unsigned index_byte_count = 0; |
1024 uint64_t partition_offset = url_ftell(pb); | |
1024 | 1025 |
1025 if (mxf->edit_units_count) { | 1026 if (mxf->edit_units_count) { |
1026 index_byte_count = 109 + (s->nb_streams+1)*6 + | 1027 index_byte_count = 109 + (s->nb_streams+1)*6 + |
1027 mxf->edit_units_count*(11+mxf->slice_count*4); | 1028 mxf->edit_units_count*(11+mxf->slice_count*4); |
1028 // add encoded ber length | 1029 // add encoded ber length |
1035 if (!memcmp(key, body_partition_key, 16)) { | 1036 if (!memcmp(key, body_partition_key, 16)) { |
1036 mxf->body_partition_offset = | 1037 mxf->body_partition_offset = |
1037 av_realloc(mxf->body_partition_offset, | 1038 av_realloc(mxf->body_partition_offset, |
1038 (mxf->body_partitions_count+1)* | 1039 (mxf->body_partitions_count+1)* |
1039 sizeof(*mxf->body_partition_offset)); | 1040 sizeof(*mxf->body_partition_offset)); |
1040 mxf->body_partition_offset[mxf->body_partitions_count++] = url_ftell(pb); | 1041 mxf->body_partition_offset[mxf->body_partitions_count++] = partition_offset; |
1041 } | 1042 } |
1042 | 1043 |
1043 // write klv | 1044 // write klv |
1044 put_buffer(pb, key, 16); | 1045 put_buffer(pb, key, 16); |
1045 | 1046 |
1048 // write partition value | 1049 // write partition value |
1049 put_be16(pb, 1); // majorVersion | 1050 put_be16(pb, 1); // majorVersion |
1050 put_be16(pb, 2); // minorVersion | 1051 put_be16(pb, 2); // minorVersion |
1051 put_be32(pb, KAG_SIZE); // KAGSize | 1052 put_be32(pb, KAG_SIZE); // KAGSize |
1052 | 1053 |
1053 put_be64(pb, url_ftell(pb) - 25); // thisPartition | 1054 put_be64(pb, partition_offset); // ThisPartition |
1054 | 1055 |
1055 if (!memcmp(key, body_partition_key, 16) && mxf->body_partitions_count > 1) | 1056 if (!memcmp(key, body_partition_key, 16) && mxf->body_partitions_count > 1) |
1056 put_be64(pb, mxf->body_partition_offset[mxf->body_partitions_count-2]); // PreviousPartition | 1057 put_be64(pb, mxf->body_partition_offset[mxf->body_partitions_count-2]); // PreviousPartition |
1057 else if (!memcmp(key, footer_partition_key, 16)) | 1058 else if (!memcmp(key, footer_partition_key, 16)) |
1058 put_be64(pb, mxf->body_partition_offset[mxf->body_partitions_count-1]); // PreviousPartition | 1059 put_be64(pb, mxf->body_partition_offset[mxf->body_partitions_count-1]); // PreviousPartition |