aac: make the input buffer static
Allocate the input buffer within the AacBuffer struct.
This commit is contained in:
parent
487e05c67d
commit
432da18e44
|
@ -33,7 +33,7 @@ typedef struct {
|
||||||
size_t bytesIntoBuffer;
|
size_t bytesIntoBuffer;
|
||||||
size_t bytesConsumed;
|
size_t bytesConsumed;
|
||||||
off_t fileOffset;
|
off_t fileOffset;
|
||||||
unsigned char *buffer;
|
unsigned char buffer[FAAD_MIN_STREAMSIZE * AAC_MAX_CHANNELS];
|
||||||
} AacBuffer;
|
} AacBuffer;
|
||||||
|
|
||||||
static void aac_buffer_shift(AacBuffer * b, size_t length)
|
static void aac_buffer_shift(AacBuffer * b, size_t length)
|
||||||
|
@ -53,13 +53,13 @@ static void fillAacBuffer(AacBuffer * b)
|
||||||
{
|
{
|
||||||
size_t rest, bread;
|
size_t rest, bread;
|
||||||
|
|
||||||
if (b->bytesIntoBuffer >= FAAD_MIN_STREAMSIZE * AAC_MAX_CHANNELS)
|
if (b->bytesIntoBuffer >= sizeof(b->buffer))
|
||||||
/* buffer already full */
|
/* buffer already full */
|
||||||
return;
|
return;
|
||||||
|
|
||||||
aac_buffer_shift(b, b->bytesConsumed);
|
aac_buffer_shift(b, b->bytesConsumed);
|
||||||
|
|
||||||
rest = FAAD_MIN_STREAMSIZE * AAC_MAX_CHANNELS - b->bytesIntoBuffer;
|
rest = sizeof(b->buffer) - b->bytesIntoBuffer;
|
||||||
bread = decoder_read(b->decoder, b->inStream,
|
bread = decoder_read(b->decoder, b->inStream,
|
||||||
(void *)(b->buffer + b->bytesIntoBuffer),
|
(void *)(b->buffer + b->bytesIntoBuffer),
|
||||||
rest);
|
rest);
|
||||||
|
@ -175,9 +175,6 @@ initAacBuffer(AacBuffer * b, struct decoder *decoder,
|
||||||
|
|
||||||
b->decoder = decoder;
|
b->decoder = decoder;
|
||||||
b->inStream = inStream;
|
b->inStream = inStream;
|
||||||
|
|
||||||
b->buffer = xmalloc(FAAD_MIN_STREAMSIZE * AAC_MAX_CHANNELS);
|
|
||||||
memset(b->buffer, 0, FAAD_MIN_STREAMSIZE * AAC_MAX_CHANNELS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void aac_parse_header(AacBuffer * b, float *length)
|
static void aac_parse_header(AacBuffer * b, float *length)
|
||||||
|
@ -336,7 +333,7 @@ aac_stream_decode(struct decoder *mpd_decoder, struct input_stream *inStream)
|
||||||
#endif
|
#endif
|
||||||
faacDecSetConfiguration(decoder, config);
|
faacDecSetConfiguration(decoder, config);
|
||||||
|
|
||||||
while (b.bytesIntoBuffer < FAAD_MIN_STREAMSIZE * AAC_MAX_CHANNELS &&
|
while (b.bytesIntoBuffer < sizeof(b.buffer) &&
|
||||||
!input_stream_eof(b.inStream) &&
|
!input_stream_eof(b.inStream) &&
|
||||||
decoder_get_command(mpd_decoder) == DECODE_COMMAND_NONE) {
|
decoder_get_command(mpd_decoder) == DECODE_COMMAND_NONE) {
|
||||||
fillAacBuffer(&b);
|
fillAacBuffer(&b);
|
||||||
|
@ -423,8 +420,6 @@ aac_stream_decode(struct decoder *mpd_decoder, struct input_stream *inStream)
|
||||||
} while (cmd != DECODE_COMMAND_STOP);
|
} while (cmd != DECODE_COMMAND_STOP);
|
||||||
|
|
||||||
faacDecClose(decoder);
|
faacDecClose(decoder);
|
||||||
if (b.buffer)
|
|
||||||
free(b.buffer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct tag *aacTagDup(const char *file)
|
static struct tag *aacTagDup(const char *file)
|
||||||
|
|
Loading…
Reference in New Issue