summaryrefslogtreecommitdiff
path: root/lib/rbcodec/codecs/libm4a/m4a.c
diff options
context:
space:
mode:
authorroman.artiukhin <bahusdrive@gmail.com>2023-09-18 13:17:11 +0300
committerSolomon Peachy <pizza@shaftnet.org>2023-09-19 11:13:19 -0400
commitef7d6009b4f8b2e64d6ced27bc97aad0b520271e (patch)
tree76b3d5ddc1257223fd5dcbb7169028738b577656 /lib/rbcodec/codecs/libm4a/m4a.c
parentf96f7cd9419c5140bd00c85c9d3b81e1e07a1105 (diff)
downloadrockbox-ef7d6009b4f8b2e64d6ced27bc97aad0b520271e.tar.gz
rockbox-ef7d6009b4f8b2e64d6ced27bc97aad0b520271e.zip
Codecs: mp4: Optimize m4a_check_sample_offset
Make optimization from 2358fabb actually work. Fix potential out of bound access. Remove redundant zero offset check. Change-Id: I0a0ba04670b612d410ac17a761bd08c2915721b9
Diffstat (limited to 'lib/rbcodec/codecs/libm4a/m4a.c')
-rw-r--r--lib/rbcodec/codecs/libm4a/m4a.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/rbcodec/codecs/libm4a/m4a.c b/lib/rbcodec/codecs/libm4a/m4a.c
index 17af4cfece..958d0b1575 100644
--- a/lib/rbcodec/codecs/libm4a/m4a.c
+++ b/lib/rbcodec/codecs/libm4a/m4a.c
@@ -122,16 +122,19 @@ void stream_create(stream_t *stream,struct codec_api* ci)
122int m4a_check_sample_offset(demux_res_t *demux_res, uint32_t frame, uint32_t *start) 122int m4a_check_sample_offset(demux_res_t *demux_res, uint32_t frame, uint32_t *start)
123{ 123{
124 uint32_t i = *start; 124 uint32_t i = *start;
125 for (i=0; i<demux_res->num_lookup_table; ++i) 125 for (;i < demux_res->num_lookup_table; ++i)
126 { 126 {
127 if (demux_res->lookup_table[i].sample > frame || 127 if (demux_res->lookup_table[i].sample > frame)
128 demux_res->lookup_table[i].offset == 0)
129 return -1;
130 if (demux_res->lookup_table[i].sample == frame)
131 break; 128 break;
129
130 if (demux_res->lookup_table[i].sample == frame)
131 {
132 *start = i;
133 return demux_res->lookup_table[i].offset;
134 }
132 } 135 }
133 *start = i; 136 *start = i;
134 return demux_res->lookup_table[i].offset; 137 return -1;
135} 138}
136 139
137/* Seek to desired sound sample location. Return 1 on success (and modify 140/* Seek to desired sound sample location. Return 1 on success (and modify