diff options
author | roman.artiukhin <bahusdrive@gmail.com> | 2023-09-18 13:14:47 +0300 |
---|---|---|
committer | Solomon Peachy <pizza@shaftnet.org> | 2023-09-19 11:13:19 -0400 |
commit | 001a338e5126cbec422867481ef7485b1b3c8eea (patch) | |
tree | 6593e544ee074ca86f79df7d9f04814ce21c323d | |
parent | ef7d6009b4f8b2e64d6ced27bc97aad0b520271e (diff) | |
download | rockbox-001a338e51.tar.gz rockbox-001a338e51.zip |
Codecs: mp4: Reuse lookup_table index from seek in m4a_check_sample_offset
Change-Id: If2fc3038ce8db8ddf2991406a5cce294a857eadc
-rw-r--r-- | lib/rbcodec/codecs/aac.c | 5 | ||||
-rw-r--r-- | lib/rbcodec/codecs/alac.c | 7 | ||||
-rw-r--r-- | lib/rbcodec/codecs/libm4a/m4a.c | 6 | ||||
-rw-r--r-- | lib/rbcodec/codecs/libm4a/m4a.h | 4 |
4 files changed, 12 insertions, 10 deletions
diff --git a/lib/rbcodec/codecs/aac.c b/lib/rbcodec/codecs/aac.c index 0a4313e69e..11a84cfa24 100644 --- a/lib/rbcodec/codecs/aac.c +++ b/lib/rbcodec/codecs/aac.c @@ -138,7 +138,7 @@ enum codec_status codec_run(void) * upsampling files the resulting sound_samples_done must be expanded * by a factor of 2. This is done via using sbr_fac. */ if (m4a_seek_raw(&demux_res, &input_stream, file_offset, - &sound_samples_done, (int*) &i)) { + &sound_samples_done, (int*) &i, &seek_idx)) { sound_samples_done *= sbr_fac; } else { sound_samples_done = 0; @@ -173,11 +173,10 @@ enum codec_status codec_run(void) * by a factor 2. This is done via using sbr_fac. */ if (m4a_seek(&demux_res, &input_stream, (uint64_t) param * ci->id3->frequency / sbr_fac / 1000ULL, - &sound_samples_done, (int*) &i)) { + &sound_samples_done, (int*) &i, &seek_idx)) { sound_samples_done *= sbr_fac; elapsed_time = sound_samples_done * 1000LL / ci->id3->frequency; ci->set_elapsed(elapsed_time); - seek_idx = 0; if (i == 0) { diff --git a/lib/rbcodec/codecs/alac.c b/lib/rbcodec/codecs/alac.c index 141c5d6f91..7139b629b8 100644 --- a/lib/rbcodec/codecs/alac.c +++ b/lib/rbcodec/codecs/alac.c @@ -64,6 +64,7 @@ enum codec_status codec_run(void) unsigned long resume_time; uint32_t resume_offset; unsigned int did_resume; + int lookup_table_idx = 0; /* Clean and initialize decoder structures */ memset(&demux_res , 0, sizeof(demux_res)); @@ -96,10 +97,10 @@ enum codec_status codec_run(void) if (resume_time) did_resume = m4a_seek(&demux_res, &input_stream, (uint64_t)resume_time * ci->id3->frequency / 1000ULL, - &samplesdone, (int *) &i); + &samplesdone, (int *) &i, &lookup_table_idx); else if (resume_offset) did_resume = m4a_seek_raw(&demux_res, &input_stream, resume_offset, - &samplesdone, (int *) &i); + &samplesdone, (int *) &i, &lookup_table_idx); else did_resume = 0; @@ -122,7 +123,7 @@ enum codec_status codec_run(void) if (action == CODEC_ACTION_SEEK_TIME) { if (m4a_seek(&demux_res, &input_stream, (uint64_t)param * ci->id3->frequency / 1000ULL, - &samplesdone, (int *) &i)) + &samplesdone, (int *) &i, &lookup_table_idx)) set_elapsed_samples(samplesdone); ci->seek_complete(); diff --git a/lib/rbcodec/codecs/libm4a/m4a.c b/lib/rbcodec/codecs/libm4a/m4a.c index 958d0b1575..6adc58dab0 100644 --- a/lib/rbcodec/codecs/libm4a/m4a.c +++ b/lib/rbcodec/codecs/libm4a/m4a.c @@ -141,7 +141,7 @@ int m4a_check_sample_offset(demux_res_t *demux_res, uint32_t frame, uint32_t *st * sound_samples_done and current_sample), 0 if failed. */ unsigned int m4a_seek(demux_res_t* demux_res, stream_t* stream, uint64_t sound_sample_loc, uint64_t* sound_samples_done, - int* current_sample) + int* current_sample, int* lookup_table_idx) { uint32_t i, sample_i; uint32_t time, time_cnt, time_dur; @@ -189,6 +189,7 @@ unsigned int m4a_seek(demux_res_t* demux_res, stream_t* stream, /* The preceding chunk is the one that contains 'sample_i'. */ chunk--; + *lookup_table_idx = chunk; chunk_first_sample = tco_tab[chunk].sample; offset = tco_tab[chunk].offset; @@ -265,7 +266,7 @@ unsigned int m4a_seek(demux_res_t* demux_res, stream_t* stream, */ unsigned int m4a_seek_raw(demux_res_t* demux_res, stream_t* stream, uint32_t file_loc, uint64_t* sound_samples_done, - int* current_sample) + int* current_sample, int* lookup_table_idx) { uint32_t i; uint32_t chunk_sample = 0; @@ -283,6 +284,7 @@ unsigned int m4a_seek_raw(demux_res_t* demux_res, stream_t* stream, break; } i = (i>0) ? i-1 : 0; /* We want the last chunk _before_ file_loc. */ + *lookup_table_idx = i; chunk_sample = demux_res->lookup_table[i].sample; new_pos = demux_res->lookup_table[i].offset; diff --git a/lib/rbcodec/codecs/libm4a/m4a.h b/lib/rbcodec/codecs/libm4a/m4a.h index 475773834c..bcc32f53bb 100644 --- a/lib/rbcodec/codecs/libm4a/m4a.h +++ b/lib/rbcodec/codecs/libm4a/m4a.h @@ -131,9 +131,9 @@ 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, uint64_t sound_sample_loc, uint64_t* sound_samples_done, - int* current_sample); + int* current_sample, int* lookup_table_idx); unsigned int m4a_seek_raw (demux_res_t* demux_res, stream_t* stream, - uint32_t file_loc, uint64_t* sound_samples_done, int* current_sample); + uint32_t file_loc, uint64_t* sound_samples_done, int* current_sample, int* lookup_table_idx); int m4a_check_sample_offset(demux_res_t *demux_res, uint32_t frame, uint32_t *start); #endif /* STREAM_H */ |