diff options
Diffstat (limited to 'lib/rbcodec')
-rw-r--r-- | lib/rbcodec/codecs/libm4a/demux.c | 11 | ||||
-rw-r--r-- | lib/rbcodec/codecs/libm4a/m4a.c | 19 | ||||
-rw-r--r-- | lib/rbcodec/codecs/libm4a/m4a.h | 1 |
3 files changed, 25 insertions, 6 deletions
diff --git a/lib/rbcodec/codecs/libm4a/demux.c b/lib/rbcodec/codecs/libm4a/demux.c index 25462db030..8a424c5187 100644 --- a/lib/rbcodec/codecs/libm4a/demux.c +++ b/lib/rbcodec/codecs/libm4a/demux.c | |||
@@ -400,7 +400,8 @@ static bool read_chunk_stsz(qtmovie_t *qtmovie, size_t chunk_len) | |||
400 | } | 400 | } |
401 | else | 401 | else |
402 | { | 402 | { |
403 | DEBUGF("stsz too large, ignoring it\n"); | 403 | qtmovie->res->sample_byte_sizes_offset = stream_tell(qtmovie->stream); |
404 | DEBUGF("stsz too large: %u, save sample_byte_sizes_offset\n", numsizes); | ||
404 | } | 405 | } |
405 | 406 | ||
406 | if (size_remaining) | 407 | if (size_remaining) |
@@ -481,6 +482,14 @@ static bool read_chunk_stco(qtmovie_t *qtmovie, size_t chunk_len) | |||
481 | return false; | 482 | return false; |
482 | } | 483 | } |
483 | 484 | ||
485 | // Reading sample_byte_sizes data on seek can lead to additional re-buffering. | ||
486 | // So skip it if we have good enough seek accuracy via lookup_table (3000 ms) | ||
487 | if (qtmovie->res->sample_byte_sizes_offset && ci->id3->length / fit_numentries <= 3000) | ||
488 | { | ||
489 | qtmovie->res->sample_byte_sizes_offset = 0; | ||
490 | DEBUGF("lookup_table seek accuracy %ld ms, ignoring sample_byte_sizes_offset \n", ci->id3->length / fit_numentries); | ||
491 | } | ||
492 | |||
484 | /* Build up lookup table. The lookup table contains the sample index and | 493 | /* Build up lookup table. The lookup table contains the sample index and |
485 | * byte position in the file for each chunk. This table is used to seek | 494 | * byte position in the file for each chunk. This table is used to seek |
486 | * and resume (see m4a_seek() and m4a_seek_raw() in libm4a/m4a.c) and | 495 | * and resume (see m4a_seek() and m4a_seek_raw() in libm4a/m4a.c) and |
diff --git a/lib/rbcodec/codecs/libm4a/m4a.c b/lib/rbcodec/codecs/libm4a/m4a.c index 295c39c5ff..b63b8bad2c 100644 --- a/lib/rbcodec/codecs/libm4a/m4a.c +++ b/lib/rbcodec/codecs/libm4a/m4a.c | |||
@@ -211,11 +211,13 @@ unsigned int m4a_seek(demux_res_t* demux_res, stream_t* stream, | |||
211 | sound_sample_i += time_cnt * time_dur; | 211 | sound_sample_i += time_cnt * time_dur; |
212 | } | 212 | } |
213 | 213 | ||
214 | DEBUGF("seek chunk=%lu, sample=%lu, soundsample=%lu, offset=%lu\n", | 214 | if (demux_res->sample_byte_sizes_offset) |
215 | (unsigned long)chunk, (unsigned long)chunk_first_sample, | 215 | { |
216 | sound_sample_i, (unsigned long)offset); | 216 | stream->ci->seek_buffer(demux_res->sample_byte_sizes_offset + chunk_first_sample * 4); |
217 | } | ||
217 | 218 | ||
218 | if (tsz_tab) { | 219 | if (tsz_tab || demux_res->sample_byte_sizes_offset) |
220 | { | ||
219 | /* We have a sample-to-bytes table available so we can do accurate | 221 | /* We have a sample-to-bytes table available so we can do accurate |
220 | * seeking. Move one sample at a time and update the file offset and | 222 | * seeking. Move one sample at a time and update the file offset and |
221 | * PCM sample offset as we go. */ | 223 | * PCM sample offset as we go. */ |
@@ -229,7 +231,7 @@ unsigned int m4a_seek(demux_res_t* demux_res, stream_t* stream, | |||
229 | time_dur = tts_tab[time].sample_duration; | 231 | time_dur = tts_tab[time].sample_duration; |
230 | } | 232 | } |
231 | 233 | ||
232 | offset += tsz_tab[i]; | 234 | offset += tsz_tab ? tsz_tab[i] : stream_read_uint32(stream); |
233 | sound_sample_i += time_dur; | 235 | sound_sample_i += time_dur; |
234 | time_cnt--; | 236 | time_cnt--; |
235 | } | 237 | } |
@@ -239,6 +241,13 @@ unsigned int m4a_seek(demux_res_t* demux_res, stream_t* stream, | |||
239 | sample_i = chunk_first_sample; | 241 | sample_i = chunk_first_sample; |
240 | } | 242 | } |
241 | 243 | ||
244 | DEBUGF("seek chunk=%lu, chunk_first_sample=%lu, sample_i=%u, soundsample=%lu, offset=%lu\n", | ||
245 | (unsigned long)chunk, | ||
246 | (unsigned long)chunk_first_sample, | ||
247 | sample_i, | ||
248 | (unsigned long)sound_sample_i, | ||
249 | (unsigned long)offset); | ||
250 | |||
242 | if (stream->ci->seek_buffer(offset)) | 251 | if (stream->ci->seek_buffer(offset)) |
243 | { | 252 | { |
244 | *sound_samples_done = sound_sample_i; | 253 | *sound_samples_done = sound_sample_i; |
diff --git a/lib/rbcodec/codecs/libm4a/m4a.h b/lib/rbcodec/codecs/libm4a/m4a.h index 7120f8b4c6..14b22f5dbf 100644 --- a/lib/rbcodec/codecs/libm4a/m4a.h +++ b/lib/rbcodec/codecs/libm4a/m4a.h | |||
@@ -82,6 +82,7 @@ typedef struct | |||
82 | 82 | ||
83 | uint32_t *sample_byte_sizes; | 83 | uint32_t *sample_byte_sizes; |
84 | uint32_t num_sample_byte_sizes; | 84 | uint32_t num_sample_byte_sizes; |
85 | int32_t sample_byte_sizes_offset; | ||
85 | 86 | ||
86 | uint32_t codecdata_len; | 87 | uint32_t codecdata_len; |
87 | uint8_t codecdata[MAX_CODECDATA_SIZE]; | 88 | uint8_t codecdata[MAX_CODECDATA_SIZE]; |