Rockbox open source high quality audio player as a Music Player Daemon
mpris rockbox mpd libadwaita audio rust zig deno
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

authored by

roman.artiukhin and committed by
Solomon Peachy
ef7d6009 f96f7cd9

+10 -12
+1 -6
lib/rbcodec/codecs/aac.c
··· 202 202 { 203 203 ci->advance_buffer(file_offset - ci->curpos); 204 204 } 205 - else if (file_offset == 0) 206 - { 207 - LOGF("AAC: get_sample_offset error\n"); 208 - return CODEC_ERROR; 209 - } 210 - 205 + 211 206 /* Request the required number of bytes from the input buffer */ 212 207 buffer=ci->request_buffer(&n, FAAD_BYTE_BUFFER_SIZE); 213 208
+9 -6
lib/rbcodec/codecs/libm4a/m4a.c
··· 122 122 int m4a_check_sample_offset(demux_res_t *demux_res, uint32_t frame, uint32_t *start) 123 123 { 124 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 || 128 - demux_res->lookup_table[i].offset == 0) 129 - return -1; 127 + if (demux_res->lookup_table[i].sample > frame) 128 + break; 129 + 130 130 if (demux_res->lookup_table[i].sample == frame) 131 - break; 131 + { 132 + *start = i; 133 + return demux_res->lookup_table[i].offset; 134 + } 132 135 } 133 136 *start = i; 134 - return demux_res->lookup_table[i].offset; 137 + return -1; 135 138 } 136 139 137 140 /* Seek to desired sound sample location. Return 1 on success (and modify