comparison movenc.c @ 1081:ee5aac70a7dc libavformat

simplify
author michael
date Sat, 13 May 2006 18:45:29 +0000
parents 3170bb428809
children 4239bc0dc05e
comparison
equal deleted inserted replaced
1080:3170bb428809 1081:ee5aac70a7dc
224 return 0x11; 224 return 0x11;
225 } 225 }
226 226
227 static unsigned int descrLength(unsigned int len) 227 static unsigned int descrLength(unsigned int len)
228 { 228 {
229 if (len < 0x00000080) 229 int i;
230 return 2 + len; 230 for(i=1; len>>(7*i); i++);
231 else if (len < 0x00004000) 231 return len + 1 + i;
232 return 3 + len; 232 }
233 else if(len < 0x00200000) 233
234 return 4 + len; 234 static void putDescr(ByteIOContext *pb, int tag, unsigned int size)
235 else 235 {
236 return 5 + len; 236 int i= descrLength(size) - size - 2;
237 } 237 put_byte(pb, tag);
238 238 for(; i>0; i--)
239 static void putDescr(ByteIOContext *pb, int tag, int size) 239 put_byte(pb, (size>>(7*i)) | 0x80);
240 { 240 put_byte(pb, size & 0x7F);
241 uint32_t len;
242 uint8_t vals[4];
243
244 len = size;
245 vals[3] = (uint8_t)(len & 0x7f);
246 len >>= 7;
247 vals[2] = (uint8_t)((len & 0x7f) | 0x80);
248 len >>= 7;
249 vals[1] = (uint8_t)((len & 0x7f) | 0x80);
250 len >>= 7;
251 vals[0] = (uint8_t)((len & 0x7f) | 0x80);
252
253 put_byte(pb, tag); // DescriptorTag
254
255 if (size < 0x00000080)
256 {
257 put_byte(pb, vals[3]);
258 }
259 else if (size < 0x00004000)
260 {
261 put_byte(pb, vals[2]);
262 put_byte(pb, vals[3]);
263 }
264 else if (size < 0x00200000)
265 {
266 put_byte(pb, vals[1]);
267 put_byte(pb, vals[2]);
268 put_byte(pb, vals[3]);
269 }
270 else if (size < 0x10000000)
271 {
272 put_byte(pb, vals[0]);
273 put_byte(pb, vals[1]);
274 put_byte(pb, vals[2]);
275 put_byte(pb, vals[3]);
276 }
277 } 241 }
278 242
279 static int mov_write_esds_tag(ByteIOContext *pb, MOVTrack* track) // Basic 243 static int mov_write_esds_tag(ByteIOContext *pb, MOVTrack* track) // Basic
280 { 244 {
281 int decoderSpecificInfoLen; 245 int decoderSpecificInfoLen;