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-27aa95afcb898d15cc6350946c3c4c337f7d17c7.tar.gz rockbox-27aa95afcb898d15cc6350946c3c4c337f7d17c7.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) | |||
56 | size_t n; | 56 | size_t n; |
57 | demux_res_t demux_res; | 57 | demux_res_t demux_res; |
58 | stream_t input_stream; | 58 | stream_t input_stream; |
59 | uint32_t sound_samples_done; | 59 | uint64_t sound_samples_done; |
60 | uint32_t elapsed_time; | 60 | uint32_t elapsed_time; |
61 | int file_offset; | 61 | int file_offset; |
62 | int framelength; | 62 | int framelength; |
@@ -172,7 +172,7 @@ enum codec_status codec_run(void) | |||
172 | * m4a_seek and the resulting sound_samples_done must be expanded | 172 | * m4a_seek and the resulting sound_samples_done must be expanded |
173 | * by a factor 2. This is done via using sbr_fac. */ | 173 | * by a factor 2. This is done via using sbr_fac. */ |
174 | if (m4a_seek(&demux_res, &input_stream, | 174 | if (m4a_seek(&demux_res, &input_stream, |
175 | (param/10/sbr_fac)*(ci->id3->frequency/100), | 175 | (uint64_t) param * ci->id3->frequency / sbr_fac / 1000ULL, |
176 | &sound_samples_done, (int*) &i)) { | 176 | &sound_samples_done, (int*) &i)) { |
177 | sound_samples_done *= sbr_fac; | 177 | sound_samples_done *= sbr_fac; |
178 | elapsed_time = sound_samples_done * 1000LL / ci->id3->frequency; | 178 | 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) | |||
55 | size_t n; | 55 | size_t n; |
56 | demux_res_t demux_res; | 56 | demux_res_t demux_res; |
57 | stream_t input_stream; | 57 | stream_t input_stream; |
58 | uint32_t samplesdone; | 58 | uint64_t samplesdone; |
59 | int samplesdecoded; | 59 | int samplesdecoded; |
60 | unsigned int i; | 60 | unsigned int i; |
61 | unsigned char* buffer; | 61 | 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 | |||
137 | /* Seek to desired sound sample location. Return 1 on success (and modify | 137 | /* Seek to desired sound sample location. Return 1 on success (and modify |
138 | * sound_samples_done and current_sample), 0 if failed. */ | 138 | * sound_samples_done and current_sample), 0 if failed. */ |
139 | unsigned int m4a_seek(demux_res_t* demux_res, stream_t* stream, | 139 | unsigned int m4a_seek(demux_res_t* demux_res, stream_t* stream, |
140 | uint32_t sound_sample_loc, uint32_t* sound_samples_done, | 140 | uint64_t sound_sample_loc, uint64_t* sound_samples_done, |
141 | int* current_sample) | 141 | int* current_sample) |
142 | { | 142 | { |
143 | uint32_t i, sample_i, sound_sample_i; | 143 | uint32_t i, sample_i; |
144 | uint32_t time, time_cnt, time_dur; | 144 | uint32_t time, time_cnt, time_dur; |
145 | uint32_t chunk, chunk_first_sample; | 145 | uint32_t chunk, chunk_first_sample; |
146 | uint32_t offset; | 146 | uint32_t offset; |
147 | uint64_t sound_sample_i; | ||
147 | time_to_sample_t *tts_tab = demux_res->time_to_sample; | 148 | time_to_sample_t *tts_tab = demux_res->time_to_sample; |
148 | sample_offset_t *tco_tab = demux_res->lookup_table; | 149 | sample_offset_t *tco_tab = demux_res->lookup_table; |
149 | uint32_t *tsz_tab = demux_res->sample_byte_sizes; | 150 | 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, | |||
208 | 209 | ||
209 | DEBUGF("seek chunk=%lu, sample=%lu, soundsample=%lu, offset=%lu\n", | 210 | DEBUGF("seek chunk=%lu, sample=%lu, soundsample=%lu, offset=%lu\n", |
210 | (unsigned long)chunk, (unsigned long)chunk_first_sample, | 211 | (unsigned long)chunk, (unsigned long)chunk_first_sample, |
211 | (unsigned long)sound_sample_i, (unsigned long)offset); | 212 | sound_sample_i, (unsigned long)offset); |
212 | 213 | ||
213 | if (tsz_tab) { | 214 | if (tsz_tab) { |
214 | /* We have a sample-to-bytes table available so we can do accurate | 215 | /* 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, | |||
260 | * calculate the sound_samples_done value. | 261 | * calculate the sound_samples_done value. |
261 | */ | 262 | */ |
262 | unsigned int m4a_seek_raw(demux_res_t* demux_res, stream_t* stream, | 263 | unsigned int m4a_seek_raw(demux_res_t* demux_res, stream_t* stream, |
263 | uint32_t file_loc, uint32_t* sound_samples_done, | 264 | uint32_t file_loc, uint64_t* sound_samples_done, |
264 | int* current_sample) | 265 | int* current_sample) |
265 | { | 266 | { |
266 | uint32_t i; | 267 | uint32_t i; |
267 | uint32_t chunk_sample = 0; | 268 | uint32_t chunk_sample = 0; |
268 | uint32_t total_samples = 0; | 269 | uint32_t total_samples = 0; |
269 | uint32_t new_sound_sample = 0; | 270 | uint64_t new_sound_sample = 0; |
270 | uint32_t tmp_dur; | 271 | uint32_t tmp_dur; |
271 | uint32_t tmp_cnt; | 272 | uint32_t tmp_cnt; |
272 | uint32_t new_pos; | 273 | 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); | |||
130 | void stream_create(stream_t *stream,struct codec_api* ci); | 130 | void stream_create(stream_t *stream,struct codec_api* ci); |
131 | unsigned int get_sample_offset(demux_res_t *demux_res, uint32_t sample); | 131 | unsigned int get_sample_offset(demux_res_t *demux_res, uint32_t sample); |
132 | unsigned int m4a_seek (demux_res_t* demux_res, stream_t* stream, | 132 | unsigned int m4a_seek (demux_res_t* demux_res, stream_t* stream, |
133 | uint32_t sound_sample_loc, uint32_t* sound_samples_done, | 133 | uint64_t sound_sample_loc, uint64_t* sound_samples_done, |
134 | int* current_sample); | 134 | int* current_sample); |
135 | unsigned int m4a_seek_raw (demux_res_t* demux_res, stream_t* stream, | 135 | unsigned int m4a_seek_raw (demux_res_t* demux_res, stream_t* stream, |
136 | uint32_t file_loc, uint32_t* sound_samples_done, int* current_sample); | 136 | uint32_t file_loc, uint64_t* sound_samples_done, int* current_sample); |
137 | int m4a_check_sample_offset(demux_res_t *demux_res, uint32_t frame, uint32_t *start); | 137 | int m4a_check_sample_offset(demux_res_t *demux_res, uint32_t frame, uint32_t *start); |
138 | 138 | ||
139 | #endif /* STREAM_H */ | 139 | #endif /* STREAM_H */ |