From eda995d5da0a91ab0c4fa6c3d30c5bcdf69d2828 Mon Sep 17 00:00:00 2001 From: Andre Date: Sat, 13 May 2006 06:07:22 +0200 Subject: [PATCH 1/1] aac: make find_stco() return the first offset 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 | 2 +- aac_afh.c | 6 +++--- aac_common.c | 10 +++++----- aacdec.c | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/aac.h b/aac.h index d1c0e3ac..373872e7 100644 --- 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); diff --git a/aac_afh.c b/aac_afh.c index 9cab3920..93bcd427 100644 --- 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 diff --git a/aac_common.c b/aac_common.c index 3739be9d..9edeb1c5 100644 --- a/aac_common.c +++ b/aac_common.c @@ -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; diff --git a/aacdec.c b/aacdec.c index c7bec164..54b42298 100644 --- 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; -- 2.39.2