Commit b7ad3e41 authored by Max Kellermann's avatar Max Kellermann

aac: moved code to aac_buffer_shift()

Shifting from the buffer queue is a common operation, and should be provided as a separate function. Move code to aac_buffer_shift() and add a bunch of assertions.
parent a3cc928c
......@@ -37,6 +37,19 @@ typedef struct {
int atEof;
} AacBuffer;
static void aac_buffer_shift(AacBuffer * b, size_t length)
{
assert(length >= b->bytesConsumed);
assert(length <= b->bytesConsumed + b->bytesIntoBuffer);
memmove(b->buffer, b->buffer + length,
b->bytesConsumed + b->bytesIntoBuffer - length);
length -= b->bytesConsumed;
b->bytesConsumed = 0;
b->bytesIntoBuffer -= length;
}
static void fillAacBuffer(AacBuffer * b)
{
size_t bread;
......@@ -45,13 +58,7 @@ static void fillAacBuffer(AacBuffer * b)
/* buffer already full */
return;
if (b->bytesConsumed > 0 && b->bytesIntoBuffer > 0) {
memmove((void *)b->buffer, (void *)(b->buffer +
b->bytesConsumed),
b->bytesIntoBuffer);
}
b->bytesConsumed = 0;
aac_buffer_shift(b, b->bytesConsumed);
if (!b->atEof) {
size_t rest = FAAD_MIN_STREAMSIZE * AAC_MAX_CHANNELS -
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment