X-Git-Url: http://git.tuebingen.mpg.de/?a=blobdiff_plain;f=mp4.c;h=e5ec9dd13ecd6ab71ef00e3657a7eb5a598a60eb;hb=13273bf45126e8254dabce13bbdcfdfc396868ef;hp=c77cedd2bd2fb586a715b12c5808f7691bc35c57;hpb=8e2a58f85f68077944bb5739f2327353a502ed70;p=paraslash.git diff --git a/mp4.c b/mp4.c index c77cedd2..e5ec9dd1 100644 --- a/mp4.c +++ b/mp4.c @@ -865,7 +865,7 @@ static int atom_read(struct mp4 *f, uint64_t size, uint8_t atom_type) } /* parse atoms that are sub atoms of other atoms */ -static int parse_sub_atoms(struct mp4 *f, uint64_t total_size, int meta_only) +static int parse_sub_atoms(struct mp4 *f, uint64_t total_size, bool meta_only) { int ret; uint64_t size; @@ -903,8 +903,7 @@ static int parse_sub_atoms(struct mp4 *f, uint64_t total_size, int meta_only) return 1; } -/* parse root atoms */ -static int parse_atoms(struct mp4 *f, int meta_only) +static int parse_root_atoms(struct mp4 *f, bool meta_only) { int ret; uint64_t size; @@ -916,23 +915,15 @@ static int parse_atoms(struct mp4 *f, int meta_only) while ((ret = atom_read_header(f, &atom_type, &header_size, &size)) > 0) { f->file_size += size; f->last_atom = atom_type; - - if (atom_type == ATOM_MOOV && size > header_size) { - f->moov_offset = get_position(f) - header_size; - f->moov_size = size; - } - - /* parse subatoms */ - if (meta_only && !need_parse_when_meta_only(atom_type)) { - set_position(f, get_position(f) + size - header_size); - } else if (atom_type < SUBATOMIC) { - ret = parse_sub_atoms(f, size - header_size, meta_only); - if (ret <= 0) - break; - } else { - /* skip this atom */ + if (atom_type != ATOM_MOOV || size <= header_size) { /* skip */ set_position(f, get_position(f) + size - header_size); + continue; } + f->moov_offset = get_position(f) - header_size; + f->moov_size = size; + ret = parse_sub_atoms(f, size - header_size, meta_only); + if (ret <= 0) + break; } if (ret < 0) return ret; @@ -947,7 +938,7 @@ struct mp4 *mp4_open_read(const struct mp4_callback *cb) struct mp4 *f = para_calloc(sizeof(struct mp4)); f->cb = cb; - ret = parse_atoms(f, 0); + ret = parse_root_atoms(f, false); if (ret < 0) { free(f); return NULL; @@ -1073,7 +1064,7 @@ struct mp4 *mp4_open_meta(const struct mp4_callback *cb) struct mp4 *f = para_calloc(sizeof(struct mp4)); f->cb = cb; - ret = parse_atoms(f, 1); + ret = parse_root_atoms(f, true); if (ret < 0) { free(f); return NULL;