Skip to content

Commit

Permalink
Support decoding MP4 when IAMF is not the first track
Browse files Browse the repository at this point in the history
  • Loading branch information
yilun-zhangs committed Sep 14, 2024
1 parent 76e5d96 commit 3da4c44
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions code/test/tools/iamfdec/src/mp4demux.c
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,6 @@ int mov_read_stbl(mp4r_t *mp4r, int size) {

int64_t apos = ftell(mp4r->fin);
avio_context *list[] = {
atoms_stsd,
atoms_stts,
atoms_stsc,
atoms_stsz,
Expand All @@ -429,9 +428,12 @@ int mov_read_stbl(mp4r_t *mp4r, int size) {
atoms_sgpd
#endif
};

STASH_ATOM();
for (int i = 0; i < sizeof(list) / sizeof(avio_context *); ++i)
atom_seek_parse(mp4r, apos, size, list[i]);
if (atom_seek_parse(mp4r, apos, size, atoms_stsd) == ERR_OK) {
for (int i = 0; i < sizeof(list) / sizeof(avio_context *); ++i)
atom_seek_parse(mp4r, apos, size, list[i]);
}
RESTORE_ATOM();
return size;
}
Expand Down Expand Up @@ -504,6 +506,7 @@ int mov_read_stsd(mp4r_t *mp4r, int size) {
#endif

int n;
int ret = size;

// version/flags
avio_rb32();
Expand All @@ -513,10 +516,14 @@ int mov_read_stsd(mp4r_t *mp4r, int size) {

for (int i = 0; i < n; ++i) {
mp4r->atom = atoms_iamf;
parse(mp4r, &size);
ret = parse(mp4r, &size);
if (ret == ERR_OK) {
ret = size;
break;
}
}
RESTORE_ATOM();
return size;
return ret;
}

int mov_read_edts(mp4r_t *mp4r, int size) {
Expand Down

0 comments on commit 3da4c44

Please sign in to comment.