comparison mov.c @ 3166:c082ee7573b2 libavformat

simplify, and only stop parsing when non streamable
author bcoudurier
date Fri, 21 Mar 2008 11:04:54 +0000
parents 31447ec2ae2e
children 125b08d2ad59
comparison
equal deleted inserted replaced
3165:2e6b97015947 3166:c082ee7573b2
189 url_fskip(pb, a.size); 189 url_fskip(pb, a.size);
190 } else { 190 } else {
191 offset_t start_pos = url_ftell(pb); 191 offset_t start_pos = url_ftell(pb);
192 int64_t left; 192 int64_t left;
193 err = mov_default_parse_table[i].parse(c, pb, a); 193 err = mov_default_parse_table[i].parse(c, pb, a);
194 if (c->found_moov && c->found_mdat) 194 if (url_is_streamed(pb) && c->found_moov && c->found_mdat)
195 break; 195 break;
196 left = a.size - url_ftell(pb) + start_pos; 196 left = a.size - url_ftell(pb) + start_pos;
197 if (left > 0) /* skip garbage at atom end */ 197 if (left > 0) /* skip garbage at atom end */
198 url_fskip(pb, left); 198 url_fskip(pb, left);
199 } 199 }
388 static int mov_read_mdat(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) 388 static int mov_read_mdat(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
389 { 389 {
390 if(atom.size == 0) /* wrong one (MP4) */ 390 if(atom.size == 0) /* wrong one (MP4) */
391 return 0; 391 return 0;
392 c->found_mdat=1; 392 c->found_mdat=1;
393 if(c->found_moov)
394 return 1; /* found both, just go */
395 url_fskip(pb, atom.size);
396 return 0; /* now go for moov */ 393 return 0; /* now go for moov */
397 } 394 }
398 395
399 static int mov_read_ftyp(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) 396 static int mov_read_ftyp(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
400 { 397 {
414 if (mov_read_default(c, pb, atom) < 0) 411 if (mov_read_default(c, pb, atom) < 0)
415 return -1; 412 return -1;
416 /* we parsed the 'moov' atom, we can terminate the parsing as soon as we find the 'mdat' */ 413 /* we parsed the 'moov' atom, we can terminate the parsing as soon as we find the 'mdat' */
417 /* so we don't parse the whole file if over a network */ 414 /* so we don't parse the whole file if over a network */
418 c->found_moov=1; 415 c->found_moov=1;
419 if(c->found_mdat)
420 return 1; /* found both, just go */
421 return 0; /* now go for mdat */ 416 return 0; /* now go for mdat */
422 } 417 }
423 418
424 419
425 static int mov_read_mdhd(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) 420 static int mov_read_mdhd(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)