From: Andre Noll Date: Sun, 13 May 2012 19:54:46 +0000 (+0200) Subject: oggdec: Realloc buffer to save memory. X-Git-Tag: v0.4.11~13^2~4 X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=commitdiff_plain;h=c7e2f73900021e5b3f655c91a7cc0fdda76bd0ec oggdec: Realloc buffer to save memory. 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. --- diff --git a/oggdec_filter.c b/oggdec_filter.c index 77356f32..16c8d907 100644 --- a/oggdec_filter.c +++ b/oggdec_filter.c @@ -241,9 +241,11 @@ static void ogg_post_select(__a_unused struct sched *s, struct task *t) 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;