[FFmpeg-cvslog] vorbisdec: replace div/mod in loop with a counter
Mans Rullgard
git at videolan.org
Mon Jun 18 20:25:44 CEST 2012
ffmpeg | branch: master | Mans Rullgard <mans at mansr.com> | Sat Jun 16 18:08:03 2012 +0100| [9fcda25e35bc012ee9a434faf0fb00bece85be6d] | committer: Mans Rullgard
vorbisdec: replace div/mod in loop with a counter
2x speedup of surround decoding on Cortex-A9.
Signed-off-by: Mans Rullgard <mans at mansr.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9fcda25e35bc012ee9a434faf0fb00bece85be6d
---
libavcodec/vorbisdec.c | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/libavcodec/vorbisdec.c b/libavcodec/vorbisdec.c
index 08198d7..deaaaa2 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;
+ }
}
}
}
More information about the ffmpeg-cvslog
mailing list