X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=aacdec.c;h=7ea7856fc899f3433e38acb52f5c4a82f25deb62;hp=0eab773a16a024a693d40728d41aa9ea87b8dd49;hb=55f0f9461990455656bef7a36b0f963e3d676653;hpb=67cc91aedd748c8b6dee29b5203e17e68530fd21 diff --git a/aacdec.c b/aacdec.c index 0eab773a..7ea7856f 100644 --- a/aacdec.c +++ b/aacdec.c @@ -28,10 +28,8 @@ #include "list.h" #include "filter.h" #include "error.h" -#include #include "string.h" - -#include +#include "aac.h" /** the output buffer size */ #define MAX_CHANNELS 6 @@ -44,9 +42,7 @@ */ struct private_mp4dec_data { NeAACDecHandle decoder; - NeAACDecConfigurationPtr config; NeAACDecFrameInfo frame_info; - mp4AudioSpecificConfig mp4ASC; int initialized; int decoder_length; @@ -57,61 +53,10 @@ struct private_mp4dec_data { unsigned noffsets; unsigned *offset; + unsigned offset0; int offset_pos; }; -static int read_mp4_descr_length(struct private_mp4dec_data *padd) -{ - uint8_t b; - uint8_t numBytes = 0; - uint32_t length = 0; - - do { - b = padd->inbuf[padd->consumed + numBytes]; - numBytes++; - length = (length << 7) | (b & 0x7F); - } while - ((b & 0x80) && numBytes < 4); - padd->consumed += numBytes; - return length; -} - -static int find_esds(struct private_mp4dec_data *padd) -{ - for (; padd->consumed < padd->inbuf_len; padd->consumed++) { - unsigned char *p = padd->inbuf + padd->consumed; - int decoder_length; - - if (p[0] != 'e' || p[1] != 's' || p[2] != 'd' || p[3] != 's') - continue; - padd->consumed += 8; - p = padd->inbuf + padd->consumed; - PARA_INFO_LOG("found esds: %d, next: %x\n", padd->consumed, *p); - if (*p == 3) - padd->consumed += 8; - else - padd->consumed += 6; - p = padd->inbuf + padd->consumed; - PARA_INFO_LOG("next: %x\n", *p); - if (*p != 4) - continue; - padd->consumed += 18; - p = padd->inbuf + padd->consumed; - PARA_INFO_LOG("next: %x\n", *p); - if (*p != 5) - continue; - padd->consumed++; - decoder_length = read_mp4_descr_length(padd); - PARA_INFO_LOG("decoder length: %d\n", decoder_length); - p = padd->inbuf + padd->consumed; - PARA_INFO_LOG("decoder data0: %x\n", *p & 0xff); - p++; - PARA_INFO_LOG("decoder data1: %x\n", *p & 0xff); - return decoder_length; - } - return -E_ESDS; -} - static int read_int32(struct private_mp4dec_data *padd, unsigned *result) { uint8_t *d = (uint8_t*)(padd->inbuf + padd->consumed); @@ -173,7 +118,9 @@ static ssize_t mp4dec(char *inbuffer, size_t len, struct filter_node *fn) padd->inbuf_len = len; if (!padd->initialized) { - padd->decoder_length = find_esds(padd); + int skip; + padd->decoder_length = aac_find_esds(padd->inbuf, padd->inbuf_len, + &skip); if (padd->decoder_length < 0) { ret = NeAACDecInit(padd->decoder, padd->inbuf, padd->inbuf_len, &rate, &channels); @@ -183,6 +130,7 @@ static ssize_t mp4dec(char *inbuffer, size_t len, struct filter_node *fn) } padd->consumed = ret; } else { + padd->consumed += skip; p = padd->inbuf + padd->consumed; ret = E_AACDEC_INIT; if (NeAACDecInit2(padd->decoder, p, @@ -260,13 +208,7 @@ static void mp4dec_open(struct filter_node *fn) fn->bufsize = AAC_OUTBUF_SIZE; fn->buf = para_calloc(fn->bufsize); - - padd->decoder = NeAACDecOpen(); - padd->config = NeAACDecGetCurrentConfiguration(padd->decoder); - padd->config->defObjectType = LC; - padd->config->outputFormat = FAAD_FMT_16BIT; - padd->config->downMatrix = 0; - NeAACDecSetConfiguration(padd->decoder, padd->config); + padd->decoder = aac_open(); } static void mp4dec_close(struct filter_node *fn)