]> git.tue.mpg.de Git - paraslash.git/commitdiff
aac: make find_stco() return the first offset
authorAndre <maan@p133.(none)>
Sat, 13 May 2006 04:07:22 +0000 (06:07 +0200)
committerAndre <maan@p133.(none)>
Sat, 13 May 2006 04:07:22 +0000 (06:07 +0200)
rather than the number of offsets which is rather uninteresting.
Also, rename this function to aac_find_entry() and return the
correct number of frames to para_server.

aac.h
aac_afh.c
aac_common.c
aacdec.c

diff --git a/aac.h b/aac.h
index d1c0e3ac7fdd1f926e98d5dcb161a902de0855b2..373872e756e3a80390d0507bebb4db4c982b3bac 100644 (file)
--- a/aac.h
+++ b/aac.h
@@ -3,6 +3,6 @@
 /* exported symbols from aac_common.c */
 NeAACDecHandle aac_open(void);
 int aac_find_esds(unsigned char *buf, unsigned buflen, int *skip);
-int aac_find_stco(unsigned char *buf, unsigned buflen, int *skip);
+int aac_find_entry(unsigned char *buf, unsigned buflen, int *skip);
 int aac_find_stsz(unsigned char *buf, unsigned buflen, unsigned *skip);
 unsigned aac_read_int32(unsigned char *buf);
index 9cab39205d9739736653fa359240aeebaf9508f9..93bcd427008e1ec088d9501394f5e1b5f108408f 100644 (file)
--- a/aac_afh.c
+++ b/aac_afh.c
@@ -128,8 +128,9 @@ static int aac_get_file_info(FILE *file, char *info_str, long unsigned *frames,
        ret = read_stsz(skip);
        if (ret < 0)
                return ret;
+       *frames = num_chunks;
        for (;;) {
-               ret = aac_find_stco(inbuf, inbuf_len, &skip);
+               ret = aac_find_entry(inbuf, inbuf_len, &skip);
                if (ret >= 0)
                        break;
                ret = read(fileno(infile), inbuf, inbuf_size);
@@ -137,8 +138,7 @@ static int aac_get_file_info(FILE *file, char *info_str, long unsigned *frames,
                        return -E_AAC_READ;
                PARA_INFO_LOG("next buffer: %d bytes\n", ret);
        }
-       *frames = ret;
-       entry = aac_read_int32(inbuf + skip);
+       entry = ret;
        PARA_INFO_LOG("offset table has %d entries\, entry: %zd\n", num_chunks,
                entry);
 #if 1
index 3739be9dfa450824f592ff7f5848a5377c3c038a..9edeb1c580b589229dec4aba14f0113c86d01bb2 100644 (file)
@@ -74,18 +74,18 @@ unsigned aac_read_int32(unsigned char *buf)
 }
 
 
-int aac_find_stco(unsigned char *buf, unsigned buflen, int *skip)
+int aac_find_entry(unsigned char *buf, unsigned buflen, int *skip)
 {
        int i, ret;
 
-       for (i = 0; i + 16 < buflen; i++) {
+       for (i = 0; i + 20 < buflen; i++) {
                unsigned char *p = buf + i;
 
                if (p[0] != 's' || p[1] != 't' || p[2] != 'c' || p[3] != 'o')
                        continue;
                PARA_INFO_LOG("found stco@%d\n", i);
-               i += 8;
-               ret = aac_read_int32(buf + i);
+               i += 12;
+               ret = aac_read_int32(buf + i); /* first offset */
                i += 4;
                PARA_INFO_LOG("num entries: %d\n", ret);
                *skip = i;
@@ -97,7 +97,7 @@ int aac_find_stco(unsigned char *buf, unsigned buflen, int *skip)
 
 int aac_find_stsz(unsigned char *buf, unsigned buflen, unsigned *skip)
 {
-       int i, ret;
+       int i;
 
        for (i = 0; i + 16 < buflen; i++) {
                unsigned char *p = buf + i;
index c7bec16479ae1373f05cfa0118da8af36eee0c72..54b422986d585e710531bd94726858a60a293e87 100644 (file)
--- a/aacdec.c
+++ b/aacdec.c
@@ -96,14 +96,14 @@ static ssize_t aacdec(char *input_buffer, size_t len, struct filter_node *fn)
        if (padd->decoder_length > 0) {
                consumed = 0;
                if (!padd->entry) {
-                       ret = aac_find_stco(inbuf + consumed, len - consumed,
+                       ret = aac_find_entry(inbuf + consumed, len - consumed,
                                &skip);
                        if (ret < 0) {
                                ret = len;
                                goto out;
                        }
                        consumed += skip;
-                       padd->entry = aac_read_int32(inbuf + consumed);
+                       padd->entry = ret;
                        PARA_INFO_LOG("entry: %lu\n", padd->entry);
                }
                ret = len;