From: Andre Noll Date: Sat, 7 Apr 2012 01:02:33 +0000 (+0200) Subject: wmadec: Only decode one superframe at a time. X-Git-Tag: v0.4.11~13^2 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=97dbfe66e1697640edcb987f17faed84536528e4;p=paraslash.git wmadec: Only decode one superframe at a time. Similar to the previous commit for the flac decoder, this commit removes the loop in wmadec_post_select(). This gives other tasks a chance to run and simplifies the code. Also, if the buffer was not filled completely, it is truncated to the proper size to reduce memory usage of the decoder. --- diff --git a/wmadec_filter.c b/wmadec_filter.c index 7d89d112..5106724d 100644 --- a/wmadec_filter.c +++ b/wmadec_filter.c @@ -1213,11 +1213,11 @@ static int wmadec_execute(struct btr_node *btrn, const char *cmd, char **result) static void wmadec_post_select(__a_unused struct sched *s, struct task *t) { struct filter_node *fn = container_of(t, struct filter_node, task); - int ret, converted; + int ret, converted, out_size; struct private_wmadec_data *pwd = fn->private_data; struct btr_node *btrn = fn->btrn; size_t len; - char *in; + char *in, *out; next_buffer: converted = 0; @@ -1246,22 +1246,20 @@ next_buffer: goto success; } fn->min_iqs = WMA_FRAME_SKIP + pwd->ahi.block_align; - for (;;) { - char *out; - int out_size = WMA_OUTPUT_BUFFER_SIZE; - if (converted + fn->min_iqs > len) - break; - out = para_malloc(WMA_OUTPUT_BUFFER_SIZE); - ret = wma_decode_superframe(pwd, out, - &out_size, (uint8_t *)in + converted + WMA_FRAME_SKIP, - len - WMA_FRAME_SKIP); - if (ret < 0) { - free(out); - goto err; - } - btr_add_output(out, out_size, btrn); - converted += ret + WMA_FRAME_SKIP; + if (fn->min_iqs > len) + goto success; + out_size = WMA_OUTPUT_BUFFER_SIZE; + out = para_malloc(out_size); + ret = wma_decode_superframe(pwd, out, &out_size, + (uint8_t *)in + WMA_FRAME_SKIP, len - WMA_FRAME_SKIP); + if (ret < 0) { + free(out); + goto err; } + out = para_realloc(out, out_size); + if (out_size > 0) + btr_add_output(out, out_size, btrn); + converted += ret + WMA_FRAME_SKIP; success: btr_consume(btrn, converted); return;