uint8_t last_atom;
uint64_t file_size;
- uint32_t error;
-
/* incremental track index while reading the file */
int32_t total_tracks;
-
/* track data */
struct mp4_track *track[MAX_TRACKS];
return 0;
}
-static void track_add(struct mp4 *f)
-{
- f->total_tracks++;
-
- if (f->total_tracks > MAX_TRACKS) {
- f->total_tracks = 0;
- f->error++;
- return;
- }
- f->track[f->total_tracks - 1] = para_calloc(sizeof(struct mp4_track));
-}
-
static int read_stsz(struct mp4 *f)
{
int ret;
if (size == 0)
return -1;
counted_size += size;
- /* we're starting to read a new track, update index,
- * so that all data and tables get written in the right place
- */
- if (atom_type == ATOM_TRAK)
- track_add(f);
+ if (atom_type == ATOM_TRAK) {
+ if (f->total_tracks >= MAX_TRACKS)
+ return -1;
+ f->total_tracks++;
+ f->track[f->total_tracks - 1] = para_calloc(
+ sizeof(struct mp4_track));
+ }
/* parse subatoms */
if (meta_only && !need_parse_when_meta_only(atom_type)) {
set_position(f, get_position(f) + size - header_size);
f->cb = cb;
ret = parse_atoms(f, 0);
- if (ret < 0 || f->error) {
+ if (ret < 0) {
free(f);
return NULL;
}
f->cb = cb;
ret = parse_atoms(f, 1);
- if (ret < 0 || f->error) {
+ if (ret < 0) {
free(f);
return NULL;
}