]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
aac: Switch from unsigned char to char.
authorAndre Noll <maan@systemlinux.org>
Mon, 16 Dec 2013 21:06:44 +0000 (22:06 +0100)
committerAndre Noll <maan@tuebingen.mpg.de>
Tue, 20 Dec 2016 15:53:52 +0000 (16:53 +0100)
The faad library functions take unsigned char pointers while most of
the paraslash code prefers plain char *. It's easier to use char *
in all paraslash functions and cast the arguments of the faad library
function calls than to have a mix of both types.

aac.h
aac_afh.c
aac_common.c
aacdec_filter.c

diff --git a/aac.h b/aac.h
index f31d723a315557acf0fe3dd80fde6e628eafe4ff..eb6e2bed29618952bd6ac0e15135e43eb8a7eccb 100644 (file)
--- a/aac.h
+++ b/aac.h
@@ -9,11 +9,11 @@
 #include <neaacdec.h>
 
 NeAACDecHandle aac_open(void);
-int aac_find_esds(unsigned char *buf, size_t buflen, size_t *skip,
+int aac_find_esds(char *buf, size_t buflen, size_t *skip,
                unsigned long *decoder_length);
-ssize_t aac_find_entry_point(unsigned char *buf, size_t buflen, size_t *skip);
+ssize_t aac_find_entry_point(char *buf, size_t buflen, size_t *skip);
 
-static inline unsigned aac_read_int32(unsigned char *buf)
+static inline unsigned aac_read_int32(char *buf)
 {
        uint8_t *d = (uint8_t*)buf;
        return (d[0] << 24) | (d[1] << 16) | (d[2] << 8) | d[3];
index c49f30dea858f05c627a820685fd6538b55eb07d..e94f5b421f848c02eca86a5061fa46878b07e587 100644 (file)
--- a/aac_afh.c
+++ b/aac_afh.c
 #include "aac.h"
 #include "fd.h"
 
-static int aac_find_stsz(unsigned char *buf, size_t buflen, off_t *skip)
+static int aac_find_stsz(char *buf, size_t buflen, off_t *skip)
 {
        int i;
 
        for (i = 0; i + 16 < buflen; i++) {
-               unsigned char *p = buf + i;
+               char *p = buf + i;
                unsigned sample_count, sample_size;
 
                if (p[0] != 's' || p[1] != 't' || p[2] != 's' || p[3] != 'z')
@@ -44,12 +44,12 @@ static int aac_find_stsz(unsigned char *buf, size_t buflen, off_t *skip)
        return -E_STSZ;
 }
 
-static int atom_cmp(const unsigned char *buf1, const char *buf2)
+static int atom_cmp(const char *buf1, const char *buf2)
 {
        return memcmp(buf1, buf2, 4)? 1 : 0;
 }
 
-static int read_atom_header(unsigned char *buf, uint64_t *subsize, unsigned char type[5])
+static int read_atom_header(char *buf, uint64_t *subsize, char type[5])
 {
        int i;
        uint64_t size = aac_read_int32(buf);
@@ -70,7 +70,7 @@ static int read_atom_header(unsigned char *buf, uint64_t *subsize, unsigned char
        return 16;
 }
 
-static char *get_tag(unsigned char *p, int size)
+static char *get_tag(char *p, int size)
 {
        char *buf;
 
@@ -83,12 +83,12 @@ static char *get_tag(unsigned char *p, int size)
        return buf;
 }
 
-static void read_tags(unsigned char *buf, size_t buflen, struct afh_info *afhi)
+static void read_tags(char *buf, size_t buflen, struct afh_info *afhi)
 {
-       unsigned char *p = buf;
+       char *p = buf;
 
        while (p + 32 < buf + buflen) {
-               unsigned char *q, type1[5], type2[5];
+               char *q, type1[5], type2[5];
                uint64_t size1, size2;
                int ret, ret2;
 
@@ -117,9 +117,9 @@ static void read_tags(unsigned char *buf, size_t buflen, struct afh_info *afhi)
        }
 }
 
-static void read_meta(unsigned char *buf, size_t buflen, struct afh_info *afhi)
+static void read_meta(char *buf, size_t buflen, struct afh_info *afhi)
 {
-       unsigned char *p = buf;
+       char *p = buf;
 
        while (p + 4 < buf + buflen) {
 
@@ -132,15 +132,14 @@ static void read_meta(unsigned char *buf, size_t buflen, struct afh_info *afhi)
        }
 }
 
-static void aac_get_taginfo(unsigned char *buf, size_t buflen,
-               struct afh_info *afhi)
+static void aac_get_taginfo(char *buf, size_t buflen, struct afh_info *afhi)
 {
        int i;
        uint64_t subsize;
-       unsigned char type[5];
+       char type[5];
 
        for (i = 0; i + 24 < buflen; i++) {
-               unsigned char *p = buf + i;
+               char *p = buf + i;
                if (p[0] != 'm' || p[1] != 'e' || p[2] != 't' || p[3] != 'a')
                        continue;
                PARA_INFO_LOG("found metadata at offset %d\n", i);
@@ -154,7 +153,7 @@ static void aac_get_taginfo(unsigned char *buf, size_t buflen,
 }
 
 static ssize_t aac_compute_chunk_table(struct afh_info *afhi,
-               unsigned char *map, size_t numbytes)
+               char *map, size_t numbytes)
 {
        int ret, i;
        size_t sum = 0;
@@ -212,32 +211,33 @@ static int aac_get_file_info(char *map, size_t numbytes, __a_unused int fd,
        unsigned char channels = 0;
        mp4AudioSpecificConfig mp4ASC;
        NeAACDecHandle handle = NULL;
-       unsigned char *umap = (unsigned char *) map;
 
-       ret = aac_find_esds(umap, numbytes, &skip, &decoder_len);
+       ret = aac_find_esds(map, numbytes, &skip, &decoder_len);
        if (ret < 0)
                goto out;
-       aac_get_taginfo(umap, numbytes, afhi);
+       aac_get_taginfo(map, numbytes, afhi);
        handle = aac_open();
        ret = -E_AAC_AFH_INIT;
-       if (NeAACDecInit(handle, umap + skip, decoder_len, &rate, &channels))
+       if (NeAACDecInit(handle, (unsigned char *)map + skip, decoder_len,
+                       &rate, &channels))
                goto out;
        if (!channels)
                goto out;
        PARA_DEBUG_LOG("rate: %lu, channels: %d\n", rate, channels);
        ret = -E_MP4ASC;
-       if (NeAACDecAudioSpecificConfig(umap + skip, numbytes - skip, &mp4ASC))
+       if (NeAACDecAudioSpecificConfig((unsigned char *)map + skip,
+                       numbytes - skip, &mp4ASC))
                goto out;
        if (!mp4ASC.samplingFrequency)
                goto out;
-       ret = aac_compute_chunk_table(afhi, umap, numbytes);
+       ret = aac_compute_chunk_table(afhi, map, numbytes);
        if (ret < 0)
                goto out;
        skip = ret;
        ret = aac_set_chunk_tv(afhi, &mp4ASC, &afhi->seconds_total);
        if (ret < 0)
                goto out;
-       ret = aac_find_entry_point(umap + skip, numbytes - skip, &skip);
+       ret = aac_find_entry_point(map + skip, numbytes - skip, &skip);
        if (ret < 0)
                goto out;
        afhi->chunk_table[0] = ret;
index fe9b7295f55cc7614278669c670f3bec39827347..8fc9523c28736e8e3b4add4551fff1ff38db23d3 100644 (file)
@@ -31,7 +31,7 @@ NeAACDecHandle aac_open(void)
        return h;
 }
 
-static unsigned long aac_read_decoder_length(unsigned char *buf, int *description_len)
+static unsigned long aac_read_decoder_length(char *buf, int *description_len)
 {
        uint8_t b;
        uint8_t numBytes = 0;
@@ -59,13 +59,13 @@ static unsigned long aac_read_decoder_length(unsigned char *buf, int *descriptio
  *
  * \return positive on success, negative on errors
  */
-int aac_find_esds(unsigned char *buf, size_t buflen, size_t *skip,
+int aac_find_esds(char *buf, size_t buflen, size_t *skip,
                unsigned long *decoder_length)
 {
        size_t i;
 
        for (i = 0; i + 4 < buflen; i++) {
-               unsigned char *p = buf + i;
+               char *p = buf + i;
                int description_len;
 
                if (p[0] != 'e' || p[1] != 's' || p[2] != 'd' || p[3] != 's')
@@ -108,13 +108,13 @@ int aac_find_esds(unsigned char *buf, size_t buflen, size_t *skip,
  * \return the position of the first entry in the table on success,
  * -E_STCO on errors.
  */
-ssize_t aac_find_entry_point(unsigned char *buf, size_t buflen, size_t *skip)
+ssize_t aac_find_entry_point(char *buf, size_t buflen, size_t *skip)
 {
        ssize_t ret;
        size_t i;
 
        for (i = 0; i + 20 < buflen; i++) {
-               unsigned char *p = buf + i;
+               char *p = buf + i;
 
                if (p[0] != 's' || p[1] != 't' || p[2] != 'c' || p[3] != 'o')
                        continue;
index ac8148e863d8568082dca4cb3aac68843e5893a6..9791175ecd72d6dcd22ee719f90d1e59481668b3 100644 (file)
@@ -86,7 +86,7 @@ static int aacdec_post_select(__a_unused struct sched *s, void *context)
        struct btr_node *btrn = fn->btrn;
        struct private_aacdec_data *padd = fn->private_data;
        int i, ret;
-       unsigned char *p, *inbuf, *outbuffer;
+       char *p, *inbuf, *outbuffer;
        char *btr_buf;
        size_t len, skip, consumed, loaded;
 
@@ -97,7 +97,7 @@ next_buffer:
        if (ret == 0)
                return 0;
        btr_merge(btrn, fn->min_iqs);
-       len = btr_next_buffer(btrn, (char **)&inbuf);
+       len = btr_next_buffer(btrn, &inbuf);
        len = PARA_MIN(len, (size_t)8192);
        consumed = 0;
        if (!padd->initialized) {
@@ -106,7 +106,7 @@ next_buffer:
                ret = aac_find_esds(inbuf, len, &skip, &padd->decoder_length);
                if (ret < 0) {
                        PARA_INFO_LOG("%s\n", para_strerror(-ret));
-                       ret = NeAACDecInit(padd->handle, inbuf,
+                       ret = NeAACDecInit(padd->handle, (unsigned char *)inbuf,
                                len, &rate, &channels);
                        PARA_INFO_LOG("decoder init: %d\n", ret);
                        if (ret < 0) {
@@ -120,7 +120,7 @@ next_buffer:
                        consumed += skip;
                        p = inbuf + consumed;
                        ret = -E_AACDEC_INIT;
-                       if (NeAACDecInit2(padd->handle, p,
+                       if (NeAACDecInit2(padd->handle, (unsigned char *)p,
                                        padd->decoder_length, &rate,
                                        &channels) != 0)
                                goto out;
@@ -158,8 +158,8 @@ next_buffer:
        p = inbuf + consumed;
        //PARA_CRIT_LOG("consumed: %zu (%zu + %zu), have: %zu\n", padd->consumed_total + consumed,
        //      padd->consumed_total, consumed, len - consumed);
-       outbuffer = NeAACDecDecode(padd->handle, &padd->frame_info, p,
-               len - consumed);
+       outbuffer = NeAACDecDecode(padd->handle, &padd->frame_info,
+               (unsigned char *)p, len - consumed);
        if (padd->frame_info.error) {
                int err = padd->frame_info.error;
                ret = -E_AAC_DECODE;