summaryrefslogtreecommitdiff
path: root/lib/rbcodec/codecs/libm4a/demux.c
diff options
context:
space:
mode:
authorroman.artiukhin <bahusdrive@gmail.com>2023-09-05 00:45:32 +0300
committerroman.artiukhin <bahusdrive@gmail.com>2023-09-20 11:43:39 +0300
commit57409f52d5da3665a91c6cf2cbcef86ea1004ccf (patch)
tree7de9c0af2c15a7a6b5d6b36493e545b658d8a5cc /lib/rbcodec/codecs/libm4a/demux.c
parente01055a287500d8cc90cda3b4816d3dc2f07bde4 (diff)
downloadrockbox-57409f52d5da3665a91c6cf2cbcef86ea1004ccf.tar.gz
rockbox-57409f52d5da3665a91c6cf2cbcef86ea1004ccf.zip
Codecs: mp4: Accurate seek in large files with small lookup_table
Read sample_byte_sizes table on demand when it can't be cached Change-Id: I2191be63ceebfd8b16e1e973e13c5b51986b6564
Diffstat (limited to 'lib/rbcodec/codecs/libm4a/demux.c')
-rw-r--r--lib/rbcodec/codecs/libm4a/demux.c11
1 files changed, 10 insertions, 1 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