1
0
Fork 0
forked from len0rd/rockbox

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
This commit is contained in:
roman.artiukhin 2023-09-18 13:17:11 +03:00 committed by Solomon Peachy
parent f96f7cd941
commit ef7d6009b4
2 changed files with 10 additions and 12 deletions

View file

@ -202,11 +202,6 @@ enum codec_status codec_run(void)
{ {
ci->advance_buffer(file_offset - ci->curpos); ci->advance_buffer(file_offset - ci->curpos);
} }
else if (file_offset == 0)
{
LOGF("AAC: get_sample_offset error\n");
return CODEC_ERROR;
}
/* Request the required number of bytes from the input buffer */ /* Request the required number of bytes from the input buffer */
buffer=ci->request_buffer(&n, FAAD_BYTE_BUFFER_SIZE); buffer=ci->request_buffer(&n, FAAD_BYTE_BUFFER_SIZE);

View file

@ -122,16 +122,19 @@ void stream_create(stream_t *stream,struct codec_api* ci)
int m4a_check_sample_offset(demux_res_t *demux_res, uint32_t frame, uint32_t *start) int m4a_check_sample_offset(demux_res_t *demux_res, uint32_t frame, uint32_t *start)
{ {
uint32_t i = *start; uint32_t i = *start;
for (i=0; i<demux_res->num_lookup_table; ++i) for (;i < demux_res->num_lookup_table; ++i)
{ {
if (demux_res->lookup_table[i].sample > frame || if (demux_res->lookup_table[i].sample > frame)
demux_res->lookup_table[i].offset == 0)
return -1;
if (demux_res->lookup_table[i].sample == frame)
break; break;
}
if (demux_res->lookup_table[i].sample == frame)
{
*start = i; *start = i;
return demux_res->lookup_table[i].offset; return demux_res->lookup_table[i].offset;
}
}
*start = i;
return -1;
} }
/* Seek to desired sound sample location. Return 1 on success (and modify /* Seek to desired sound sample location. Return 1 on success (and modify