int consumed;
long unsigned consumed_total;
- unsigned noffsets;
- unsigned *offset;
- unsigned offset0;
- int offset_pos;
+ long unsigned entry;
};
-static int read_int32(struct private_mp4dec_data *padd, unsigned *result)
-{
- uint8_t *d = (uint8_t*)(padd->inbuf + padd->consumed);
- if (padd->consumed + 4 > padd->inbuf_len)
- return -1;
- padd->consumed += 4;
- *result = (d[0] << 24) | (d[1] << 16) | (d[2] << 8) | d[3];
- return 1;
-}
-
-static int fill_offset_table(struct private_mp4dec_data *padd)
-{
- int i, ret;
-
- for (i = padd->offset_pos; i < padd->noffsets; i++) {
- ret = read_int32(padd, &padd->offset[i]);
- if (ret < 0)
- return -1;
- PARA_DEBUG_LOG("offset #%d: %d\n", i, padd->offset[i]);
- padd->offset_pos++;
- }
- return 1;
-}
-
-static int find_stco(struct private_mp4dec_data *padd)
-{
- int ret;
-
- for (; padd->consumed < padd->inbuf_len; padd->consumed++) {
- unsigned char *p = padd->inbuf + padd->consumed;
-
- if (p[0] != 's' || p[1] != 't' || p[2] != 'c' || p[3] != 'o')
- continue;
- PARA_INFO_LOG("found stco: %d\n", padd->consumed);
- padd->consumed += 8;
- ret = read_int32(padd, &padd->noffsets);
- padd->offset = para_malloc(padd->noffsets * sizeof(int));
- PARA_INFO_LOG("num entries: %d\n", padd->noffsets);
- return 1;
- }
- return -E_STCO;
-}
-
static ssize_t mp4dec(char *inbuffer, size_t len, struct filter_node *fn)
{
struct private_mp4dec_data *padd = fn->private_data;
struct filter_chain_info *fci = fn->fci;
unsigned long rate = 0;
unsigned char channels = 0;
- int i, ret, nbytes, skip;
+ int i, ret, skip;
unsigned char *p, *outbuffer;
if (fn->loaded > fn->bufsize * 4 / 5)
}
if (padd->decoder_length > 0) {
padd->consumed = 0;
- if (!padd->offset_pos) {
+ if (!padd->entry) {
ret = aac_find_stco(padd->inbuf + padd->consumed,
padd->inbuf_len - padd->consumed, &skip);
if (ret < 0) {
ret = len;
goto out;
}
- padd->noffsets = ret;
- padd->offset = para_malloc(padd->noffsets * sizeof(int));
padd->consumed += skip;
+ padd->entry = aac_read_int32(padd->inbuf + padd->consumed);
+ PARA_INFO_LOG("entry: %lu\n", padd->entry);
}
- if (padd->offset_pos < padd->noffsets) {
- fill_offset_table(padd);
- ret = padd->consumed;
- goto out;
- }
-// PARA_INFO_LOG("consumed total: %lu, first_chunk: %d\n",
-// padd->consumed_total, padd->offset[0]);
ret = len;
- if (padd->consumed_total + len < padd->offset[0])
+ if (padd->consumed_total + len < padd->entry)
goto out;
- if (padd->consumed_total < padd->offset[0])
- padd->consumed = padd->offset[0] - padd->consumed_total;
+ if (padd->consumed_total < padd->entry)
+ padd->consumed = padd->entry - padd->consumed_total;
}
for (; padd->consumed < padd->inbuf_len; padd->consumed++)
if ((padd->inbuf[padd->consumed] & 0xfe) == 0x20)
if (padd->consumed >= padd->inbuf_len)
goto success;
p = padd->inbuf + padd->consumed;
-// PARA_NOTICE_LOG("p[0]: %lx\n", (long unsigned) *p);
outbuffer = NeAACDecDecode(padd->decoder, &padd->frame_info, p,
len - padd->consumed);
ret = -E_AAC_DECODE;
ret = padd->consumed;
if (!padd->frame_info.samples)
goto out;
- nbytes = padd->frame_info.samples;
for (i = 0; i < padd->frame_info.samples; i++) {
short *s = (short *)outbuffer;
fn->buf[fn->loaded++] = s[i] & 0xff;