return 1;
}
-/* parse root atoms */
-static int parse_atoms(struct mp4 *f, int meta_only)
+static int parse_root_atoms(struct mp4 *f, int meta_only)
{
int ret;
uint64_t size;
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;
struct mp4 *f = para_calloc(sizeof(struct mp4));
f->cb = cb;
- ret = parse_atoms(f, 0);
+ ret = parse_root_atoms(f, 0);
if (ret < 0) {
free(f);
return NULL;
struct mp4 *f = para_calloc(sizeof(struct mp4));
f->cb = cb;
- ret = parse_atoms(f, 1);
+ ret = parse_root_atoms(f, 1);
if (ret < 0) {
free(f);
return NULL;