#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')
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);
return 16;
}
-static char *get_tag(unsigned char *p, int size)
+static char *get_tag(char *p, int size)
{
char *buf;
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;
}
}
-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) {
}
}
-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);
}
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;
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;
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;
*
* \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')
* \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;
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;
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) {
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) {
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;
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;