]> git.tue.mpg.de Git - paraslash.git/commitdiff
Minor aac cleanup
authorAndre <maan@p133.(none)>
Sat, 13 May 2006 17:19:28 +0000 (19:19 +0200)
committerAndre <maan@p133.(none)>
Sat, 13 May 2006 17:19:28 +0000 (19:19 +0200)
Use size_t and ssize_t rather than a mixture of several other types.
This also makes gcc on Darwin STFU.

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

diff --git a/aac.h b/aac.h
index 0cfa0105bef6c83c3e5f537a8aad617ab07ebb39..bad81f95e9ce451b5c9f3b5158e227ebe3556c05 100644 (file)
--- a/aac.h
+++ b/aac.h
 #include <neaacdec.h>
 
 NeAACDecHandle aac_open(void);
-int aac_find_esds(unsigned char *buf, unsigned buflen, int *skip);
-int aac_find_entry_point(unsigned char *buf, unsigned buflen, int *skip);
-unsigned aac_read_int32(unsigned char *buf);
+ssize_t aac_find_esds(unsigned char *buf, size_t buflen, size_t *skip);
+ssize_t aac_find_entry_point(unsigned char *buf, size_t buflen, size_t *skip);
+
+static inline unsigned aac_read_int32(unsigned char *buf)
+{
+       uint8_t *d = (uint8_t*)buf;
+       return (d[0] << 24) | (d[1] << 16) | (d[2] << 8) | d[3];
+}
index 92b70915621ce3fd4472d9595adb5b9fe5485636..b091db03df14212bdb3d91a36c737b24170cd64f 100644 (file)
--- a/aac_afh.c
+++ b/aac_afh.c
 static FILE *infile;
 static int inbuf_size;
 static unsigned char *inbuf;
-static unsigned inbuf_len;
+static size_t inbuf_len;
 struct audio_format *af;
-
-static unsigned num_chunks, entry;
+static size_t num_chunks;
+static size_t entry;
 
 static size_t *chunk_table;
 NeAACDecHandle handle;
@@ -48,7 +48,7 @@ static void aac_close_audio_file(void)
 {
 }
 
-static int aac_find_stsz(unsigned char *buf, unsigned buflen, unsigned *skip)
+static int aac_find_stsz(unsigned char *buf, unsigned buflen, size_t *skip)
 {
        int i;
 
@@ -73,10 +73,10 @@ static int aac_find_stsz(unsigned char *buf, unsigned buflen, unsigned *skip)
        return -E_STSZ;
 }
 
-static int read_chunk_table(unsigned skip)
+static int read_chunk_table(size_t skip)
 {
        int ret, i;
-       long unsigned sum = 0;
+       size_t sum = 0;
 
        for (;;) {
                ret = aac_find_stsz(inbuf, inbuf_len, &skip);
@@ -88,7 +88,7 @@ static int read_chunk_table(unsigned skip)
                PARA_INFO_LOG("next buffer: %d bytes\n", ret);
        }
        num_chunks = ret;
-       PARA_INFO_LOG("sz table has %d entries\n", num_chunks);
+       PARA_INFO_LOG("sz table has %zu entries\n", num_chunks);
        free(chunk_table);
        chunk_table = para_malloc(num_chunks * sizeof(size_t));
        for (i = 0; i < num_chunks; i++) {
@@ -100,13 +100,13 @@ static int read_chunk_table(unsigned skip)
                                return -E_AAC_READ;
                        inbuf_len = ret + skip;
                        skip = 0;
-                       PARA_INFO_LOG("next buffer: %d bytes\n", inbuf_len);
+                       PARA_INFO_LOG("next buffer: %zu bytes\n", inbuf_len);
                }
                sum += aac_read_int32(inbuf + skip);
                chunk_table[i] = sum;
                skip += 4;
                if (i < 10 || i > num_chunks - 10)
-                       PARA_DEBUG_LOG("offset #%d: %d\n", i, chunk_table[i]);
+                       PARA_DEBUG_LOG("offset #%d: %zu\n", i, chunk_table[i]);
        }
        return 1;
 
@@ -118,7 +118,8 @@ static int read_chunk_table(unsigned skip)
 static int aac_get_file_info(FILE *file, char *info_str, long unsigned *frames,
        int *seconds)
 {
-       int ret, skip, decoder_len;
+       int ret, decoder_len;
+       size_t skip;
        unsigned long rate = 0;
        unsigned char channels = 0;
        mp4AudioSpecificConfig mp4ASC;
@@ -167,10 +168,10 @@ static int aac_get_file_info(FILE *file, char *info_str, long unsigned *frames,
                PARA_INFO_LOG("next buffer: %d bytes\n", ret);
        }
        entry = ret;
-       PARA_INFO_LOG("offset table has %d entries\, entry: %zd\n", num_chunks,
+       PARA_INFO_LOG("offset table has %zu entries, entry: %zu\n", num_chunks,
                entry);
 #if 1
-       sprintf(info_str, "audio_file_info1:%d x %lums\n"
+       sprintf(info_str, "audio_file_info1:%zu x %lums\n"
                "audio_file_info2:\n"
                "audio_file_info3:\n",
                num_chunks,
@@ -181,7 +182,7 @@ static int aac_get_file_info(FILE *file, char *info_str, long unsigned *frames,
        struct timeval total_tv;
        tv_scale(num_chunks, &af->chunk_tv, &total_tv);
        *seconds = tv2ms(&total_tv) / 1000;
-       PARA_INFO_LOG("%d seconds, %d chunks\n", *seconds, num_chunks);
+       PARA_INFO_LOG("%d seconds, %zu chunks\n", *seconds, num_chunks);
        }
 #endif
        return 1;
index 43e56000c4c4c1fab3746153dbb06a28a498f91d..7ccc668f55127727ec0161477bc3f2e2c7a6e980 100644 (file)
@@ -20,7 +20,7 @@
  * Ahead Software AG
  */
 
-/** \file aac_ccomon.c common functions of aac_afh and aadcec */
+/** \file aac_common.c common functions of aac_afh and aadcec */
 
 #include "para.h"
 #include "aac.h"
@@ -58,9 +58,19 @@ static int aac_read_decoder_length(unsigned char *buf, int *description_len)
        return length;
 }
 
-int aac_find_esds(unsigned char *buf, unsigned buflen, int *skip)
+/**
+ * search for the position and the length of the decoder configuration
+ *
+ * \param buf buffer to seach
+ * \param buflen length of \a buf
+ * \param skip Upon succesful return, this contains the offset in \a buf where
+ * the decoder config starts.
+ *
+ * \return The length of the decoder configuration
+ */
+ssize_t aac_find_esds(unsigned char *buf, size_t buflen, size_t *skip)
 {
-       int i;
+       size_t i;
 
        for (i = 0; i + 4 < buflen; i++) {
                unsigned char *p = buf + i;
@@ -70,7 +80,7 @@ int aac_find_esds(unsigned char *buf, unsigned buflen, int *skip)
                        continue;
                i += 8;
                p = buf + i;
-               PARA_INFO_LOG("found esds@%d, next: %x\n", i, *p);
+               PARA_INFO_LOG("found esds@%zu, next: %x\n", i, *p);
                if (*p == 3)
                        i += 8;
                else
@@ -95,12 +105,6 @@ int aac_find_esds(unsigned char *buf, unsigned buflen, int *skip)
        return -E_ESDS;
 }
 
-unsigned aac_read_int32(unsigned char *buf)
-{
-       uint8_t *d = (uint8_t*)buf;
-       return (d[0] << 24) | (d[1] << 16) | (d[2] << 8) | d[3];
-}
-
 /**
  * search for the first entry in the stco table
  *
@@ -112,25 +116,24 @@ unsigned aac_read_int32(unsigned char *buf)
  * \return the position of the first entry in the table on success,
  * -E_STCO on errors.
  */
-
-int aac_find_entry_point(unsigned char *buf, unsigned buflen, int *skip)
+ssize_t aac_find_entry_point(unsigned char *buf, size_t buflen, size_t *skip)
 {
-       int i, ret;
+       ssize_t ret;
+       size_t 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);
+               PARA_INFO_LOG("found stco@%zu\n", i);
                i += 12;
                ret = aac_read_int32(buf + i); /* first offset */
                i += 4;
-               PARA_INFO_LOG("num entries: %d\n", ret);
+               PARA_INFO_LOG("num entries: %zd\n", ret);
                *skip = i;
                return ret;
        }
-       PARA_WARNING_LOG("stco not found, buflen: %d\n", buflen);
+       PARA_WARNING_LOG("stco not found, buflen: %zu\n", buflen);
        return -E_STCO;
 }
-
index ce9c50da84efcd47b2c325743f5d1feb58d9b376..c36f6877c901c2a6e9bf9fdc41284147c627045d 100644 (file)
--- a/aacdec.c
+++ b/aacdec.c
@@ -45,18 +45,18 @@ struct private_aacdec_data {
 
        int initialized;
        int decoder_length;
-       long unsigned consumed_total;
-       long unsigned entry;
+       size_t consumed_total;
+       size_t entry;
 };
 
 static ssize_t aacdec(char *input_buffer, size_t len, struct filter_node *fn)
 {
        struct private_aacdec_data *padd = fn->private_data;
        struct filter_chain_info *fci = fn->fci;
-       int i, ret, skip;
+       int i, ret;
        unsigned char *p, *outbuffer;
        unsigned char *inbuf = (unsigned char*)input_buffer;
-       size_t consumed = 0;
+       size_t skip, consumed = 0;
 
        if (fn->loaded > fn->bufsize * 4 / 5)
                return 0;
@@ -103,7 +103,7 @@ static ssize_t aacdec(char *input_buffer, size_t len, struct filter_node *fn)
                        }
                        consumed += skip;
                        padd->entry = ret;
-                       PARA_INFO_LOG("entry: %lu\n", padd->entry);
+                       PARA_INFO_LOG("entry: %zu\n", padd->entry);
                }
                ret = len;
                if (padd->consumed_total + len < padd->entry)
@@ -121,7 +121,7 @@ static ssize_t aacdec(char *input_buffer, size_t len, struct filter_node *fn)
                len - consumed);
        ret = -E_AAC_DECODE;
        if (padd->frame_info.error != 0) {
-               PARA_ERROR_LOG("frame_error: %d, consumed: %lu + %d + %lu\n",
+               PARA_ERROR_LOG("frame_error: %d, consumed: %zu + %zd + %lu\n",
                        padd->frame_info.error, padd->consumed_total,
                        consumed, padd->frame_info.bytesconsumed);
                PARA_ERROR_LOG("%s\n", NeAACDecGetErrorMessage(