diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2006-05-13 18:45:29 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2006-05-13 18:45:29 +0000 |
commit | 08db8f1846ea5d4a256dee411bdf0186d1118dc1 (patch) | |
tree | 34854b172add9347f9a8f77287bd558c01d79839 | |
parent | 039627cf487a950f0c76d0d7a26aacae3ec3552d (diff) | |
download | ffmpeg-08db8f1846ea5d4a256dee411bdf0186d1118dc1.tar.gz |
simplify
Originally committed as revision 5374 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r-- | libavformat/movenc.c | 54 |
1 files changed, 9 insertions, 45 deletions
diff --git a/libavformat/movenc.c b/libavformat/movenc.c index b4d2267fac..4afb5e1317 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -226,54 +226,18 @@ static int mov_write_damr_tag(ByteIOContext *pb) static unsigned int descrLength(unsigned int len) { - if (len < 0x00000080) - return 2 + len; - else if (len < 0x00004000) - return 3 + len; - else if(len < 0x00200000) - return 4 + len; - else - return 5 + len; + int i; + for(i=1; len>>(7*i); i++); + return len + 1 + i; } -static void putDescr(ByteIOContext *pb, int tag, int size) +static void putDescr(ByteIOContext *pb, int tag, unsigned int size) { - uint32_t len; - uint8_t vals[4]; - - len = size; - vals[3] = (uint8_t)(len & 0x7f); - len >>= 7; - vals[2] = (uint8_t)((len & 0x7f) | 0x80); - len >>= 7; - vals[1] = (uint8_t)((len & 0x7f) | 0x80); - len >>= 7; - vals[0] = (uint8_t)((len & 0x7f) | 0x80); - - put_byte(pb, tag); // DescriptorTag - - if (size < 0x00000080) - { - put_byte(pb, vals[3]); - } - else if (size < 0x00004000) - { - put_byte(pb, vals[2]); - put_byte(pb, vals[3]); - } - else if (size < 0x00200000) - { - put_byte(pb, vals[1]); - put_byte(pb, vals[2]); - put_byte(pb, vals[3]); - } - else if (size < 0x10000000) - { - put_byte(pb, vals[0]); - put_byte(pb, vals[1]); - put_byte(pb, vals[2]); - put_byte(pb, vals[3]); - } + int i= descrLength(size) - size - 2; + put_byte(pb, tag); + for(; i>0; i--) + put_byte(pb, (size>>(7*i)) | 0x80); + put_byte(pb, size & 0x7F); } static int mov_write_esds_tag(ByteIOContext *pb, MOVTrack* track) // Basic |