summaryrefslogtreecommitdiff
path: root/apps/codecs
diff options
context:
space:
mode:
authorMagnus Holmgren <magnushol@gmail.com>2006-12-06 21:37:36 +0000
committerMagnus Holmgren <magnushol@gmail.com>2006-12-06 21:37:36 +0000
commit7aab5302accf8ba14ca05401a053f83da11479fe (patch)
treed6d86806eb0187670bf26255008d0a22cf969d4f /apps/codecs
parentb774bae5fdceb0a0357e8866b3c235626c94bfe9 (diff)
Make the AAC (and ALAC) codec more flexible when dealing with the MP4 file structure. Should fix some podcasts that don't play.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11680 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs')
-rw-r--r--apps/codecs/libm4a/demux.c65
1 files changed, 33 insertions, 32 deletions
diff --git a/apps/codecs/libm4a/demux.c b/apps/codecs/libm4a/demux.c
index f2e5149ef7..d560256cd9 100644
--- a/apps/codecs/libm4a/demux.c
+++ b/apps/codecs/libm4a/demux.c
@@ -525,8 +525,8 @@ static bool read_chunk_stbl(qtmovie_t *qtmovie, size_t chunk_len)
}
break;
default:
- DEBUGF("(stbl) unknown chunk id: %c%c%c%c\n",
- SPLITFOURCC(sub_chunk_id));
+ /*DEBUGF("(stbl) unknown chunk id: %c%c%c%c\n",
+ SPLITFOURCC(sub_chunk_id));*/
stream_skip(qtmovie->stream, sub_chunk_len - 8);
}
@@ -537,57 +537,58 @@ static bool read_chunk_stbl(qtmovie_t *qtmovie, size_t chunk_len)
static bool read_chunk_minf(qtmovie_t *qtmovie, size_t chunk_len)
{
- size_t dinf_size, stbl_size;
size_t size_remaining = chunk_len - 8;
uint32_t i;
- /**** SOUND HEADER CHUNK ****/
- if ((i=stream_read_uint32(qtmovie->stream)) != 16)
+ /* Check for smhd, only kind of minf we care about */
+
+ if ((i = stream_read_uint32(qtmovie->stream)) != 16)
{
DEBUGF("unexpected size in media info: %d\n",i);
stream_skip(qtmovie->stream, size_remaining-4);
return true;
}
+
if (stream_read_uint32(qtmovie->stream) != MAKEFOURCC('s','m','h','d'))
{
DEBUGF("not a sound header! can't handle this.\n");
return false;
}
- /* now skip the rest */
+
+ /* now skip the rest of the atom */
stream_skip(qtmovie->stream, 16 - 8);
size_remaining -= 16;
- /****/
- /**** DINF CHUNK ****/
- dinf_size = stream_read_uint32(qtmovie->stream);
- if (stream_read_uint32(qtmovie->stream) != MAKEFOURCC('d','i','n','f'))
+ while (size_remaining)
{
- DEBUGF("expected dinf, didn't get it.\n");
- return false;
- }
- /* skip it */
- stream_skip(qtmovie->stream, dinf_size - 8);
- size_remaining -= dinf_size;
- /****/
+ size_t sub_chunk_len;
+ fourcc_t sub_chunk_id;
+ sub_chunk_len = stream_read_uint32(qtmovie->stream);
- /**** SAMPLE TABLE ****/
- stbl_size = stream_read_uint32(qtmovie->stream);
- if (stream_read_uint32(qtmovie->stream) != MAKEFOURCC('s','t','b','l'))
- {
- DEBUGF("expected stbl, didn't get it.\n");
- return false;
- }
- if (!read_chunk_stbl(qtmovie, stbl_size)) {
- return false;
- }
+ if (sub_chunk_len <= 1 || sub_chunk_len > size_remaining)
+ {
+ DEBUGF("strange size (%u) for chunk inside minf\n", sub_chunk_len);
+ return false;
+ }
- size_remaining -= stbl_size;
+ sub_chunk_id = stream_read_uint32(qtmovie->stream);
+
+ switch (sub_chunk_id)
+ {
+ case MAKEFOURCC('s','t','b','l'):
+ if (!read_chunk_stbl(qtmovie, sub_chunk_len)) {
+ return false;
+ }
+ break;
+ default:
+ /*DEBUGF("(minf) unknown chunk id: %c%c%c%c\n",
+ SPLITFOURCC(sub_chunk_id));*/
+ stream_skip(qtmovie->stream, sub_chunk_len - 8);
+ break;
+ }
- if (size_remaining)
- {
- DEBUGF("oops\n");
- stream_skip(qtmovie->stream, size_remaining);
+ size_remaining -= sub_chunk_len;
}
return true;
}