diff options
author | roman.artiukhin <bahusdrive@gmail.com> | 2023-09-05 01:19:38 +0300 |
---|---|---|
committer | Solomon Peachy <pizza@shaftnet.org> | 2023-09-15 09:08:18 -0400 |
commit | 27aa95afcb898d15cc6350946c3c4c337f7d17c7 (patch) | |
tree | 82d9d50537fb4d846fc488868f8e5b8f686b01e3 | |
parent | d2f7777f7a80267af38b29f1301c70fcf04df580 (diff) | |
download | rockbox-27aa95afcb.tar.gz rockbox-27aa95afcb.zip |
Codecs: mp4: Fix seek in very large files
Samples count requires 64 bit
Change-Id: Ia54be57d7d15b3db19dbc29ff8a06671594abb4b
-rw-r--r-- | lib/rbcodec/codecs/aac.c | 4 | ||||
-rw-r--r-- | lib/rbcodec/codecs/alac.c | 2 | ||||
-rw-r--r-- | lib/rbcodec/codecs/libm4a/m4a.c | 11 | ||||
-rw-r--r-- | lib/rbcodec/codecs/libm4a/m4a.h | 4 |
4 files changed, 11 insertions, 10 deletions
diff --git a/lib/rbcodec/codecs/aac.c b/lib/rbcodec/codecs/aac.c index b470fd9622..8b06f5aa0e 100644 --- a/lib/rbcodec/codecs/aac.c +++ b/lib/rbcodec/codecs/aac.c @@ -56,7 +56,7 @@ enum codec_status codec_run(void) size_t n; demux_res_t demux_res; stream_t input_stream; - uint32_t sound_samples_done; + uint64_t sound_samples_done; uint32_t elapsed_time; int file_offset; int framelength; @@ -172,7 +172,7 @@ enum codec_status codec_run(void) * m4a_seek and the resulting sound_samples_done must be expanded * by a factor 2. This is done via using sbr_fac. */ if (m4a_seek(&demux_res, &input_stream, - (param/10/sbr_fac)*(ci->id3->frequency/100), + (uint64_t) param * ci->id3->frequency / sbr_fac / 1000ULL, &sound_samples_done, (int*) &i)) { sound_samples_done *= sbr_fac; elapsed_time = sound_samples_done * 1000LL / ci->id3->frequency; diff --git a/lib/rbcodec/codecs/alac.c b/lib/rbcodec/codecs/alac.c index 052a44cd70..141c5d6f91 100644 --- a/lib/rbcodec/codecs/alac.c +++ b/lib/rbcodec/codecs/alac.c @@ -55,7 +55,7 @@ enum codec_status codec_run(void) size_t n; demux_res_t demux_res; stream_t input_stream; - uint32_t samplesdone; + uint64_t samplesdone; int samplesdecoded; unsigned int i; unsigned char* buffer; diff --git a/lib/rbcodec/codecs/libm4a/m4a.c b/lib/rbcodec/codecs/libm4a/m4a.c index b967e15e7a..17af4cfece 100644 --- a/lib/rbcodec/codecs/libm4a/m4a.c +++ b/lib/rbcodec/codecs/libm4a/m4a.c @@ -137,13 +137,14 @@ int m4a_check_sample_offset(demux_res_t *demux_res, uint32_t frame, uint32_t *st /* Seek to desired sound sample location. Return 1 on success (and modify * sound_samples_done and current_sample), 0 if failed. */ unsigned int m4a_seek(demux_res_t* demux_res, stream_t* stream, - uint32_t sound_sample_loc, uint32_t* sound_samples_done, + uint64_t sound_sample_loc, uint64_t* sound_samples_done, int* current_sample) { - uint32_t i, sample_i, sound_sample_i; + uint32_t i, sample_i; uint32_t time, time_cnt, time_dur; uint32_t chunk, chunk_first_sample; uint32_t offset; + uint64_t sound_sample_i; time_to_sample_t *tts_tab = demux_res->time_to_sample; sample_offset_t *tco_tab = demux_res->lookup_table; uint32_t *tsz_tab = demux_res->sample_byte_sizes; @@ -208,7 +209,7 @@ unsigned int m4a_seek(demux_res_t* demux_res, stream_t* stream, DEBUGF("seek chunk=%lu, sample=%lu, soundsample=%lu, offset=%lu\n", (unsigned long)chunk, (unsigned long)chunk_first_sample, - (unsigned long)sound_sample_i, (unsigned long)offset); + sound_sample_i, (unsigned long)offset); if (tsz_tab) { /* We have a sample-to-bytes table available so we can do accurate @@ -260,13 +261,13 @@ unsigned int m4a_seek(demux_res_t* demux_res, stream_t* stream, * calculate the sound_samples_done value. */ unsigned int m4a_seek_raw(demux_res_t* demux_res, stream_t* stream, - uint32_t file_loc, uint32_t* sound_samples_done, + uint32_t file_loc, uint64_t* sound_samples_done, int* current_sample) { uint32_t i; uint32_t chunk_sample = 0; uint32_t total_samples = 0; - uint32_t new_sound_sample = 0; + uint64_t new_sound_sample = 0; uint32_t tmp_dur; uint32_t tmp_cnt; uint32_t new_pos; diff --git a/lib/rbcodec/codecs/libm4a/m4a.h b/lib/rbcodec/codecs/libm4a/m4a.h index 81b10c3a27..9e159fe527 100644 --- a/lib/rbcodec/codecs/libm4a/m4a.h +++ b/lib/rbcodec/codecs/libm4a/m4a.h @@ -130,10 +130,10 @@ int stream_eof(stream_t *stream); void stream_create(stream_t *stream,struct codec_api* ci); unsigned int get_sample_offset(demux_res_t *demux_res, uint32_t sample); unsigned int m4a_seek (demux_res_t* demux_res, stream_t* stream, - uint32_t sound_sample_loc, uint32_t* sound_samples_done, + uint64_t sound_sample_loc, uint64_t* sound_samples_done, int* current_sample); unsigned int m4a_seek_raw (demux_res_t* demux_res, stream_t* stream, - uint32_t file_loc, uint32_t* sound_samples_done, int* current_sample); + uint32_t file_loc, uint64_t* sound_samples_done, int* current_sample); int m4a_check_sample_offset(demux_res_t *demux_res, uint32_t frame, uint32_t *start); #endif /* STREAM_H */ |