]> git.tue.mpg.de Git - paraslash.git/commitdiff
aacdec: Try do decode raw packets if header was not found
authorAndre <maan@p133.(none)>
Sat, 6 May 2006 13:33:20 +0000 (15:33 +0200)
committerAndre <maan@p133.(none)>
Sat, 6 May 2006 13:33:20 +0000 (15:33 +0200)
aacdec.c

index 3dbb99fdca6e83ff6cf1b0625c34b4c3e45f7f5a..e69840cd1df2202464d3b2f48d0618c36ac8d11a 100644 (file)
--- a/aacdec.c
+++ b/aacdec.c
@@ -49,6 +49,7 @@ struct private_mp4dec_data {
        mp4AudioSpecificConfig mp4ASC;
 
        int initialized;
+       int decoder_length;
        unsigned char *inbuf;
        int inbuf_len;
        int consumed;
@@ -172,16 +173,22 @@ static ssize_t mp4dec(char *inbuffer, size_t len, struct filter_node *fn)
        padd->inbuf_len = len;
 
        if (!padd->initialized) {
-               ret = find_esds(padd);
-               if (ret < 0)
-                       goto out;
-
-               p = padd->inbuf + padd->consumed;
-               ret = E_AACDEC_INIT;
-               if (NeAACDecInit2(padd->decoder, p, ret, &rate, &channels) < 0) {
-                       PARA_INFO_LOG("header not found, consumed: %d\n",
-                               padd->consumed);
-                       goto out;
+               padd->decoder_length = find_esds(padd);
+               if (padd->decoder_length < 0) {
+                       ret = NeAACDecInit(padd->decoder, padd->inbuf,
+                               padd->inbuf_len, &rate, &channels);
+                       if (ret < 0) {
+                               ret = E_AACDEC_INIT;
+                               goto out;
+                       }
+                       padd->consumed = ret;
+               } else {
+                       p = padd->inbuf + padd->consumed;
+                       ret = E_AACDEC_INIT;
+                       if (NeAACDecInit2(padd->decoder, p,
+                                       padd->decoder_length, &rate,
+                                       &channels) < 0)
+                               goto out;
                }
                fci->samplerate = rate;
                fci->channels = channels;
@@ -189,24 +196,26 @@ static ssize_t mp4dec(char *inbuffer, size_t len, struct filter_node *fn)
                        fci->channels);
                padd->initialized = 1;
        }
-       padd->consumed = 0;
-       if (!padd->offset_pos) {
+       if (padd->decoder_length > 0) {
+               padd->consumed = 0;
+               if (!padd->offset_pos) {
+                       ret = len;
+                       if (find_stco(padd) < 0)
+                               goto out;
+               }
+               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 (find_stco(padd) < 0)
+               if (padd->consumed_total + len < padd->offset[0])
                        goto out;
+               if (padd->consumed_total < padd->offset[0])
+                       padd->consumed = padd->offset[0] - padd->consumed_total;
        }
-       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])
-               goto out;
-       if (padd->consumed_total < padd->offset[0])
-               padd->consumed = padd->offset[0] - padd->consumed_total;
        p = padd->inbuf + padd->consumed;
        outbuffer = NeAACDecDecode(padd->decoder, &padd->frame_info, p,
                len - padd->consumed);