mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-14 02:27:39 -04:00
Optimization to latest aac decoder changes. Significantly reduce loop count in m4a_check_sample_offset() during standard playback. Before this change the loop count increased with each decoded chunk and for each frame.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29750 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
8d1d2f8982
commit
2358fabb70
3 changed files with 14 additions and 7 deletions
|
@ -61,6 +61,7 @@ enum codec_status codec_main(void)
|
||||||
NeAACDecFrameInfo frame_info;
|
NeAACDecFrameInfo frame_info;
|
||||||
NeAACDecHandle decoder;
|
NeAACDecHandle decoder;
|
||||||
int err;
|
int err;
|
||||||
|
uint32_t seek_idx = 0;
|
||||||
uint32_t s = 0;
|
uint32_t s = 0;
|
||||||
uint32_t sbr_fac = 1;
|
uint32_t sbr_fac = 1;
|
||||||
unsigned char c = 0;
|
unsigned char c = 0;
|
||||||
|
@ -201,7 +202,8 @@ next_track:
|
||||||
sound_samples_done *= sbr_fac;
|
sound_samples_done *= sbr_fac;
|
||||||
elapsed_time = (sound_samples_done * 10) / (ci->id3->frequency / 100);
|
elapsed_time = (sound_samples_done * 10) / (ci->id3->frequency / 100);
|
||||||
ci->set_elapsed(elapsed_time);
|
ci->set_elapsed(elapsed_time);
|
||||||
|
seek_idx = 0;
|
||||||
|
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
{
|
{
|
||||||
lead_trim = ci->id3->lead_trim;
|
lead_trim = ci->id3->lead_trim;
|
||||||
|
@ -215,8 +217,8 @@ next_track:
|
||||||
* "proper" file can have chunks out of order. Why one would want
|
* "proper" file can have chunks out of order. Why one would want
|
||||||
* that an good question (but files with gaps do exist, so who
|
* that an good question (but files with gaps do exist, so who
|
||||||
* knows?), so we don't support that - for now, at least.
|
* knows?), so we don't support that - for now, at least.
|
||||||
*/
|
*/
|
||||||
file_offset = m4a_check_sample_offset(&demux_res, i);
|
file_offset = m4a_check_sample_offset(&demux_res, i, &seek_idx);
|
||||||
|
|
||||||
if (file_offset > ci->curpos)
|
if (file_offset > ci->curpos)
|
||||||
{
|
{
|
||||||
|
|
|
@ -124,10 +124,14 @@ void stream_create(stream_t *stream,struct codec_api* ci)
|
||||||
|
|
||||||
/* Check if there is a dedicated byte position contained for the given frame.
|
/* Check if there is a dedicated byte position contained for the given frame.
|
||||||
* Return this byte position in case of success or return -1. This allows to
|
* Return this byte position in case of success or return -1. This allows to
|
||||||
* skip empty samples. */
|
* skip empty samples.
|
||||||
int m4a_check_sample_offset(demux_res_t *demux_res, uint32_t frame)
|
* During standard playback the search result (index i) will always increase.
|
||||||
|
* Therefor we save this index and let the caller set this value again as start
|
||||||
|
* index when calling m4a_check_sample_offset() for the next frame. This
|
||||||
|
* reduces the overall loop count significantly. */
|
||||||
|
int m4a_check_sample_offset(demux_res_t *demux_res, uint32_t frame, uint32_t *start)
|
||||||
{
|
{
|
||||||
uint32_t i = 0;
|
uint32_t i = *start;
|
||||||
for (i=0; i<demux_res->num_lookup_table; ++i)
|
for (i=0; i<demux_res->num_lookup_table; ++i)
|
||||||
{
|
{
|
||||||
if (demux_res->lookup_table[i].sample > frame ||
|
if (demux_res->lookup_table[i].sample > frame ||
|
||||||
|
@ -136,6 +140,7 @@ int m4a_check_sample_offset(demux_res_t *demux_res, uint32_t frame)
|
||||||
if (demux_res->lookup_table[i].sample == frame)
|
if (demux_res->lookup_table[i].sample == frame)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
*start = i;
|
||||||
return demux_res->lookup_table[i].offset;
|
return demux_res->lookup_table[i].offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -137,6 +137,6 @@ unsigned int m4a_seek (demux_res_t* demux_res, stream_t* stream,
|
||||||
int* current_sample);
|
int* current_sample);
|
||||||
unsigned int m4a_seek_raw (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, uint32_t* sound_samples_done, int* current_sample);
|
uint32_t file_loc, uint32_t* sound_samples_done, int* current_sample);
|
||||||
int m4a_check_sample_offset(demux_res_t *demux_res, uint32_t frame);
|
int m4a_check_sample_offset(demux_res_t *demux_res, uint32_t frame, uint32_t *start);
|
||||||
|
|
||||||
#endif /* STREAM_H */
|
#endif /* STREAM_H */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue