From c7e2f73900021e5b3f655c91a7cc0fdda76bd0ec Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Sun, 13 May 2012 21:54:46 +0200 Subject: [PATCH] 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. --- oggdec_filter.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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; -- 2.39.2