ATOM_MVHD = 131,
ATOM_TKHD = 132,
ATOM_TREF = 133,
- ATOM_MDHD = 134,
+ ATOM_MDHD = 134, /* track header */
ATOM_VMHD = 135,
ATOM_SMHD = 136,
ATOM_HMHD = 137,
- ATOM_STSD = 138,
- ATOM_STTS = 139,
- ATOM_STSZ = 140,
+ ATOM_STSD = 138, /* sample description box */
+ ATOM_STTS = 139, /* time to sample box */
+ ATOM_STSZ = 140, /* sample size box */
ATOM_STZ2 = 141,
- ATOM_STCO = 142,
- ATOM_STSC = 143,
+ ATOM_STCO = 142, /* chunk offset box */
+ ATOM_STSC = 143, /* sample to chunk box */
ATOM_MP4A = 144,
ATOM_MP4V = 145,
ATOM_MP4S = 146,
return 1;
}
-static int32_t atom_read(struct mp4 *f, int32_t size, uint8_t atom_type)
+static int atom_read(struct mp4 *f, uint64_t size, uint8_t atom_type)
{
uint64_t dest_position = get_position(f) + size - 8;
- if (atom_type == ATOM_STSZ) {
- /* sample size box */
- read_stsz(f);
- } else if (atom_type == ATOM_STTS) {
- /* time to sample box */
- read_stts(f);
- } else if (atom_type == ATOM_STSC) {
- /* sample to chunk box */
- read_stsc(f);
- } else if (atom_type == ATOM_STCO) {
- /* chunk offset box */
- read_stco(f);
- } else if (atom_type == ATOM_STSD) {
- /* sample description box */
- read_stsd(f);
- } else if (atom_type == ATOM_MDHD) {
- /* track header */
- read_mdhd(f);
- } else if (atom_type == ATOM_META) {
- /* iTunes Metadata box */
- read_meta(f, size);
- }
+ int ret = 1; /* return success for atoms we don't care about */
+ switch (atom_type) {
+ case ATOM_STSZ: ret = read_stsz(f); break;
+ case ATOM_STTS: ret = read_stts(f); break;
+ case ATOM_STSC: ret = read_stsc(f); break;
+ case ATOM_STCO: ret = read_stco(f); break;
+ case ATOM_STSD: ret = read_stsd(f); break;
+ case ATOM_MDHD: ret = read_mdhd(f); break;
+ case ATOM_META: ret = read_meta(f, size); break;
+ }
set_position(f, dest_position);
- return 0;
+ return ret;
}
/* parse atoms that are sub atoms of other atoms */
} else if (atom_type < SUBATOMIC) {
parse_sub_atoms(f, size - header_size, meta_only);
} else {
- atom_read(f, (uint32_t) size, atom_type);
+ ret = atom_read(f, size, atom_type);
+ if (ret <= 0)
+ return ret;
}
}
return 1;