Mercurial > libavformat.hg
changeset 5947:8b59caee931c libavformat
Predicting the size of the hdlr, string data and trkn tags in the MOV muxer
author | thardin |
---|---|
date | Mon, 12 Apr 2010 07:24:30 +0000 |
parents | 28ca2d77f997 |
children | dc1a033edd9f |
files | movenc.c |
diffstat | 1 files changed, 8 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/movenc.c Sun Apr 11 21:44:23 2010 +0000 +++ b/movenc.c Mon Apr 12 07:24:30 2010 +0000 @@ -1330,8 +1330,7 @@ static int mov_write_itunes_hdlr_tag(ByteIOContext *pb, MOVMuxContext *mov, AVFormatContext *s) { - int64_t pos = url_ftell(pb); - put_be32(pb, 0); /* size */ + put_be32(pb, 33); /* size */ put_tag(pb, "hdlr"); put_be32(pb, 0); put_be32(pb, 0); @@ -1340,20 +1339,20 @@ put_be32(pb, 0); put_be32(pb, 0); put_byte(pb, 0); - return updateSize(pb, pos); + return 33; } /* helper function to write a data tag with the specified string as data */ static int mov_write_string_data_tag(ByteIOContext *pb, const char *data, int lang, int long_style) { if(long_style){ - int64_t pos = url_ftell(pb); - put_be32(pb, 0); /* size */ + int size = 16 + strlen(data); + put_be32(pb, size); /* size */ put_tag(pb, "data"); put_be32(pb, 1); put_be32(pb, 0); put_buffer(pb, data, strlen(data)); - return updateSize(pb, pos); + return size; }else{ if (!lang) lang = ff_mov_iso639_to_lang("und", 1); @@ -1407,12 +1406,9 @@ AVMetadataTag *t = av_metadata_get(s->metadata, "track", NULL, 0); int size = 0, track = t ? atoi(t->value) : 0; if (track) { - int64_t pos = url_ftell(pb); - put_be32(pb, 0); /* size */ + put_be32(pb, 32); /* size */ put_tag(pb, "trkn"); - { - int64_t pos = url_ftell(pb); - put_be32(pb, 0); /* size */ + put_be32(pb, 24); /* size */ put_tag(pb, "data"); put_be32(pb, 0); // 8 bytes empty put_be32(pb, 0); @@ -1420,9 +1416,7 @@ put_be16(pb, track); // track number put_be16(pb, 0); // total track number put_be16(pb, 0); // empty - updateSize(pb, pos); - } - size = updateSize(pb, pos); + size = 32; } return size; }