summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndree Buschmann <AndreeBuschmann@t-online.de>2011-04-19 05:55:54 +0000
committerAndree Buschmann <AndreeBuschmann@t-online.de>2011-04-19 05:55:54 +0000
commit2358fabb709bcadd300c46e11e74d48f2b115d8e (patch)
tree343ac99ac5ffe713319a878ce6fb624973efc7c7
parent8d1d2f8982a8c68a7572a82ebc8409e257e77994 (diff)
downloadrockbox-2358fabb709bcadd300c46e11e74d48f2b115d8e.tar.gz
rockbox-2358fabb709bcadd300c46e11e74d48f2b115d8e.zip
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
-rw-r--r--apps/codecs/aac.c8
-rw-r--r--apps/codecs/libm4a/m4a.c11
-rw-r--r--apps/codecs/libm4a/m4a.h2
3 files changed, 14 insertions, 7 deletions
diff --git a/apps/codecs/aac.c b/apps/codecs/aac.c
index 6bb5ac50ae..8eb2dfd8ce 100644
--- a/apps/codecs/aac.c
+++ b/apps/codecs/aac.c
@@ -61,6 +61,7 @@ enum codec_status codec_main(void)
61 NeAACDecFrameInfo frame_info; 61 NeAACDecFrameInfo frame_info;
62 NeAACDecHandle decoder; 62 NeAACDecHandle decoder;
63 int err; 63 int err;
64 uint32_t seek_idx = 0;
64 uint32_t s = 0; 65 uint32_t s = 0;
65 uint32_t sbr_fac = 1; 66 uint32_t sbr_fac = 1;
66 unsigned char c = 0; 67 unsigned char c = 0;
@@ -201,7 +202,8 @@ next_track:
201 sound_samples_done *= sbr_fac; 202 sound_samples_done *= sbr_fac;
202 elapsed_time = (sound_samples_done * 10) / (ci->id3->frequency / 100); 203 elapsed_time = (sound_samples_done * 10) / (ci->id3->frequency / 100);
203 ci->set_elapsed(elapsed_time); 204 ci->set_elapsed(elapsed_time);
204 205 seek_idx = 0;
206
205 if (i == 0) 207 if (i == 0)
206 { 208 {
207 lead_trim = ci->id3->lead_trim; 209 lead_trim = ci->id3->lead_trim;
@@ -215,8 +217,8 @@ next_track:
215 * "proper" file can have chunks out of order. Why one would want 217 * "proper" file can have chunks out of order. Why one would want
216 * that an good question (but files with gaps do exist, so who 218 * that an good question (but files with gaps do exist, so who
217 * knows?), so we don't support that - for now, at least. 219 * knows?), so we don't support that - for now, at least.
218 */ 220 */
219 file_offset = m4a_check_sample_offset(&demux_res, i); 221 file_offset = m4a_check_sample_offset(&demux_res, i, &seek_idx);
220 222
221 if (file_offset > ci->curpos) 223 if (file_offset > ci->curpos)
222 { 224 {
diff --git a/apps/codecs/libm4a/m4a.c b/apps/codecs/libm4a/m4a.c
index 836cdafda3..84144ea76c 100644
--- a/apps/codecs/libm4a/m4a.c
+++ b/apps/codecs/libm4a/m4a.c
@@ -124,10 +124,14 @@ void stream_create(stream_t *stream,struct codec_api* ci)
124 124
125/* Check if there is a dedicated byte position contained for the given frame. 125/* Check if there is a dedicated byte position contained for the given frame.
126 * Return this byte position in case of success or return -1. This allows to 126 * Return this byte position in case of success or return -1. This allows to
127 * skip empty samples. */ 127 * skip empty samples.
128int m4a_check_sample_offset(demux_res_t *demux_res, uint32_t frame) 128 * During standard playback the search result (index i) will always increase.
129 * Therefor we save this index and let the caller set this value again as start
130 * index when calling m4a_check_sample_offset() for the next frame. This
131 * reduces the overall loop count significantly. */
132int m4a_check_sample_offset(demux_res_t *demux_res, uint32_t frame, uint32_t *start)
129{ 133{
130 uint32_t i = 0; 134 uint32_t i = *start;
131 for (i=0; i<demux_res->num_lookup_table; ++i) 135 for (i=0; i<demux_res->num_lookup_table; ++i)
132 { 136 {
133 if (demux_res->lookup_table[i].sample > frame || 137 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)
136 if (demux_res->lookup_table[i].sample == frame) 140 if (demux_res->lookup_table[i].sample == frame)
137 break; 141 break;
138 } 142 }
143 *start = i;
139 return demux_res->lookup_table[i].offset; 144 return demux_res->lookup_table[i].offset;
140} 145}
141 146
diff --git a/apps/codecs/libm4a/m4a.h b/apps/codecs/libm4a/m4a.h
index e49d14b832..da5401dba4 100644
--- a/apps/codecs/libm4a/m4a.h
+++ b/apps/codecs/libm4a/m4a.h
@@ -137,6 +137,6 @@ unsigned int m4a_seek (demux_res_t* demux_res, stream_t* stream,
137 int* current_sample); 137 int* current_sample);
138unsigned int m4a_seek_raw (demux_res_t* demux_res, stream_t* stream, 138unsigned int m4a_seek_raw (demux_res_t* demux_res, stream_t* stream,
139 uint32_t file_loc, uint32_t* sound_samples_done, int* current_sample); 139 uint32_t file_loc, uint32_t* sound_samples_done, int* current_sample);
140int m4a_check_sample_offset(demux_res_t *demux_res, uint32_t frame); 140int m4a_check_sample_offset(demux_res_t *demux_res, uint32_t frame, uint32_t *start);
141 141
142#endif /* STREAM_H */ 142#endif /* STREAM_H */