From fc1efc7b13674a6d3a6b21f634a1038197775a75 Mon Sep 17 00:00:00 2001 From: Magnus Holmgren Date: Tue, 30 Jan 2007 21:42:36 +0000 Subject: Fix a couple of MP4 demuxing problems, preventing playback in a few cases. All my test files now play properly. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12161 a1c6a512-1295-4272-9138-f99709370657 --- apps/codecs/aac.c | 6 ++++++ apps/codecs/libm4a/demux.c | 6 +++++- apps/codecs/libm4a/m4a.c | 5 +++-- 3 files changed, 14 insertions(+), 3 deletions(-) (limited to 'apps/codecs') diff --git a/apps/codecs/aac.c b/apps/codecs/aac.c index 4a9c7479f3..4695caab4a 100644 --- a/apps/codecs/aac.c +++ b/apps/codecs/aac.c @@ -157,6 +157,12 @@ next_track: { ci->advance_buffer(file_offset - ci->curpos); } + else if (file_offset == 0) + { + LOGF("AAC: get_sample_offset error\n"); + err = CODEC_ERROR; + goto done; + } /* Request the required number of bytes from the input buffer */ buffer=ci->request_buffer(&n,sample_byte_size); diff --git a/apps/codecs/libm4a/demux.c b/apps/codecs/libm4a/demux.c index 34bc07556b..10972f8b1f 100644 --- a/apps/codecs/libm4a/demux.c +++ b/apps/codecs/libm4a/demux.c @@ -762,7 +762,11 @@ int qtmovie_read(stream_t *file, demux_res_t *demux_res) read_chunk_mdat(&qtmovie, chunk_len); /* Keep track of start of stream in file - used for seeking */ qtmovie.res->mdat_offset=stream_tell(qtmovie.stream); - return 1; + /* There can be empty mdats before the real one. If so, skip them */ + if (qtmovie.res->mdat_len > 0) { + return 1; + } + break; /* these following atoms can be skipped !!!! */ case MAKEFOURCC('f','r','e','e'): diff --git a/apps/codecs/libm4a/m4a.c b/apps/codecs/libm4a/m4a.c index 0a87ec35ea..f5aaeca302 100644 --- a/apps/codecs/libm4a/m4a.c +++ b/apps/codecs/libm4a/m4a.c @@ -199,7 +199,7 @@ unsigned int get_sample_offset(demux_res_t *demux_res, uint32_t sample) prev_chunk_samples = demux_res->sample_to_chunk[i].num_samples; } - if (demux_res->num_sample_to_chunks > 1) + if (sample >= demux_res->sample_to_chunk[0].num_samples) { chunk = prev_chunk + (sample - total_samples) / prev_chunk_samples; } @@ -223,7 +223,8 @@ unsigned int get_sample_offset(demux_res_t *demux_res, uint32_t sample) file_offset = demux_res->chunk_offset[chunk - 1]; } - if (chunk_sample > sample) { + if (chunk_sample > sample) + { return 0; } -- cgit v1.2.3