The ogg/vorbis decoder always allocates 32K buffers for the decoded
output data. If the buffer could not be filled completely due to
insufficient input data being available, the partially filled 32K
buffer is added to the output buffer tree.
This patch truncates (reallocates) the buffer if this has happened,
thereby reducing the memory footprint of the decoder.
have = 0;
}
pod->have_more = (ret > 0);
- if (have > 0)
+ if (have > 0) {
+ if (have < OGGDEC_OUTPUT_CHUNK_SIZE)
+ buf = para_realloc(buf, have);
btr_add_output(buf, have, btrn);
- else
+ } else
free(buf);
if (ret == OV_HOLE) /* avoid buffer underruns */
fn->min_iqs = 9000;