From 9fcda25e35bc012ee9a434faf0fb00bece85be6d Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sat, 16 Jun 2012 18:08:03 +0100 Subject: [PATCH] vorbisdec: replace div/mod in loop with a counter 2x speedup of surround decoding on Cortex-A9. Signed-off-by: Mans Rullgard --- libavcodec/vorbisdec.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/libavcodec/vorbisdec.c b/libavcodec/vorbisdec.c index 08198d732a..deaaaa21c2 100644 --- a/libavcodec/vorbisdec.c +++ b/libavcodec/vorbisdec.c @@ -1409,17 +1409,24 @@ static av_always_inline int vorbis_residue_decode_internal(vorbis_context *vc, } } else if (vr_type == 2) { - voffs = voffset; + unsigned voffs_div = FASTDIV(voffset, ch); + unsigned voffs_mod = voffset - voffs_div * ch; for (k = 0; k < step; ++k) { coffs = get_vlc2(gb, codebook.vlc.table, codebook.nb_bits, 3) * dim; - for (l = 0; l < dim; ++l, ++voffs) { - vec[voffs / ch + (voffs % ch) * vlen] += codebook.codevectors[coffs + l]; // FPMATH FIXME use if and counter instead of / and % + for (l = 0; l < dim; ++l) { + vec[voffs_div + voffs_mod * vlen] += + codebook.codevectors[coffs + l]; av_dlog(NULL, " pass %d offs: %d curr: %f change: %f cv offs.: %d+%d \n", - pass, voffset / ch + (voffs % ch) * vlen, - vec[voffset / ch + (voffs % ch) * vlen], + pass, voffs_div + voffs_mod * vlen, + vec[voffs_div + voffs_mod * vlen], codebook.codevectors[coffs + l], coffs, l); + + if (++voffs_mod == ch) { + voffs_div++; + voffs_mod = 0; + } } } }