X-Git-Url: http://git.tuebingen.mpg.de/?a=blobdiff_plain;f=mp4.c;h=d030d62d3e759c81ddfa440a6b47613e87f4d14e;hb=eb369edec255c992294a77b83f981e46c5de7906;hp=e2512db17de21c0fd20286860a0e6861f9542b2d;hpb=18ea2d87153bfcf386905b7c36b425d8e7bcc592;p=paraslash.git diff --git a/mp4.c b/mp4.c index e2512db1..d030d62d 100644 --- a/mp4.c +++ b/mp4.c @@ -712,18 +712,16 @@ static bool need_atom(uint8_t atom_type, bool meta_only) static int parse_sub_atoms(struct mp4 *f, uint64_t total_size, bool meta_only) { int ret; - uint64_t size; - uint8_t atom_type = 0; - uint64_t counted_size = 0; - uint8_t header_size = 0; + uint64_t dest, size, end = get_position(f) + total_size; - while (counted_size < total_size) { + for (dest = get_position(f); dest < end; set_position(f, dest)) { + uint8_t header_size, atom_type; ret = atom_read_header(f, &atom_type, &header_size, &size); if (ret <= 0) return ret; if (size == 0) return -1; - counted_size += size; + dest = get_position(f) + size - header_size; if (atom_type == ATOM_TRAK) { if (f->total_tracks >= MAX_TRACKS) return -1; @@ -734,10 +732,8 @@ static int parse_sub_atoms(struct mp4 *f, uint64_t total_size, bool meta_only) f->udta_offset = get_position(f) - header_size; f->udta_size = size; } - if (!need_atom(atom_type, meta_only)) { - set_position(f, get_position(f) + size - header_size); + if (!need_atom(atom_type, meta_only)) continue; - } if (atom_type < SUBATOMIC) /* atom contains subatoms */ ret = parse_sub_atoms(f, size - header_size, meta_only); else