Use size_t and ssize_t rather than a mixture of several other types.
This also makes gcc on Darwin STFU.
#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];
+}
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;
{
}
-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;
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);
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++) {
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;
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;
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,
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;
* 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"
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;
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
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
*
* \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;
}
-
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;
}
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)
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(