diff options
Diffstat (limited to 'lib/rbcodec')
-rw-r--r-- | lib/rbcodec/codecs/libm4a/demux.c | 10 | ||||
-rw-r--r-- | lib/rbcodec/codecs/libm4a/m4a.c | 6 |
2 files changed, 8 insertions, 8 deletions
diff --git a/lib/rbcodec/codecs/libm4a/demux.c b/lib/rbcodec/codecs/libm4a/demux.c index 8a424c5187..47cce9857f 100644 --- a/lib/rbcodec/codecs/libm4a/demux.c +++ b/lib/rbcodec/codecs/libm4a/demux.c | |||
@@ -524,7 +524,7 @@ static bool read_chunk_stco(qtmovie_t *qtmovie, size_t chunk_len) | |||
524 | stream_seek(qtmovie->stream, qtmovie->res->sample_to_chunk_offset); | 524 | stream_seek(qtmovie->stream, qtmovie->res->sample_to_chunk_offset); |
525 | stream_read_sample_to_chunk(qtmovie->stream, &old_first, &old_frame); | 525 | stream_read_sample_to_chunk(qtmovie->stream, &old_first, &old_frame); |
526 | stream_read_sample_to_chunk(qtmovie->stream, &new_first, &new_frame); | 526 | stream_read_sample_to_chunk(qtmovie->stream, &new_first, &new_frame); |
527 | for (k = 1; k < numentries; ++k) | 527 | for (k = 1; k < numentries + 1; ++k) |
528 | { | 528 | { |
529 | for (; i < qtmovie->res->num_sample_to_chunks; ++i) | 529 | for (; i < qtmovie->res->num_sample_to_chunks; ++i) |
530 | { | 530 | { |
@@ -548,9 +548,11 @@ static bool read_chunk_stco(qtmovie_t *qtmovie, size_t chunk_len) | |||
548 | qtmovie->res->lookup_table[idx++].sample = frame + (k - old_first) * old_frame; | 548 | qtmovie->res->lookup_table[idx++].sample = frame + (k - old_first) * old_frame; |
549 | } | 549 | } |
550 | } | 550 | } |
551 | /* zero-terminate the lookup table */ | 551 | /* zero-terminate sample if it wasn't calculated */ |
552 | qtmovie->res->lookup_table[idx].sample = 0; | 552 | if (idx < fit_numentries) |
553 | qtmovie->res->lookup_table[idx].offset = 0; | 553 | { |
554 | qtmovie->res->lookup_table[idx].sample = 0; | ||
555 | } | ||
554 | 556 | ||
555 | stream_seek(qtmovie->stream, current_offset); | 557 | stream_seek(qtmovie->stream, current_offset); |
556 | if (size_remaining) | 558 | if (size_remaining) |
diff --git a/lib/rbcodec/codecs/libm4a/m4a.c b/lib/rbcodec/codecs/libm4a/m4a.c index b63b8bad2c..1672cf300c 100644 --- a/lib/rbcodec/codecs/libm4a/m4a.c +++ b/lib/rbcodec/codecs/libm4a/m4a.c | |||
@@ -181,8 +181,6 @@ unsigned int m4a_seek(demux_res_t* demux_res, stream_t* stream, | |||
181 | /* Find the chunk after 'sample_i'. */ | 181 | /* Find the chunk after 'sample_i'. */ |
182 | for (chunk = 1; chunk < demux_res->num_lookup_table; ++chunk) | 182 | for (chunk = 1; chunk < demux_res->num_lookup_table; ++chunk) |
183 | { | 183 | { |
184 | if (tco_tab[chunk].offset == 0) | ||
185 | break; | ||
186 | if (tco_tab[chunk].sample > sample_i) | 184 | if (tco_tab[chunk].sample > sample_i) |
187 | break; | 185 | break; |
188 | } | 186 | } |
@@ -287,12 +285,12 @@ unsigned int m4a_seek_raw(demux_res_t* demux_res, stream_t* stream, | |||
287 | 285 | ||
288 | /* We know the desired byte offset, search for the chunk right before. | 286 | /* We know the desired byte offset, search for the chunk right before. |
289 | * Return the associated sample to this chunk as chunk_sample. */ | 287 | * Return the associated sample to this chunk as chunk_sample. */ |
290 | for (i=0; i < demux_res->num_lookup_table; ++i) | 288 | for (i = 1; i < demux_res->num_lookup_table; ++i) |
291 | { | 289 | { |
292 | if (demux_res->lookup_table[i].offset > file_loc) | 290 | if (demux_res->lookup_table[i].offset > file_loc) |
293 | break; | 291 | break; |
294 | } | 292 | } |
295 | i = (i>0) ? i-1 : 0; /* We want the last chunk _before_ file_loc. */ | 293 | --i; /* We want the last chunk _before_ file_loc. */ |
296 | *lookup_table_idx = i; | 294 | *lookup_table_idx = i; |
297 | chunk_sample = demux_res->lookup_table[i].sample; | 295 | chunk_sample = demux_res->lookup_table[i].sample; |
298 | new_pos = demux_res->lookup_table[i].offset; | 296 | new_pos = demux_res->lookup_table[i].offset; |