History

vorbisdec: replace div/mod in loop with a counter

2x speedup of surround decoding on Cortex-A9.

Mans Rullgard committed 14 years ago

Commit 9fcda251 parent 7457ebe1 file · +12 −5Browse files

Showing the changes to libavcodec (1 of 1 file). Show all

Unified · Split

libavcodec/vorbisdec.c+12−5
@@ -1409,17 +1409,24 @@ static av_always_inline int vorbis_residue_decode_internal(vorbis_context *vc, · 1408 unmodified lines
14091409 }
14101410
14111411 } else if (vr_type == 2) {
1412− voffs = voffset;
1412+ unsigned voffs_div = FASTDIV(voffset, ch);
1413+ unsigned voffs_mod = voffset - voffs_div * ch;
14131414
14141415 for (k = 0; k < step; ++k) {
14151416 coffs = get_vlc2(gb, codebook.vlc.table, codebook.nb_bits, 3) * dim;
1416− for (l = 0; l < dim; ++l, ++voffs) {
1417− vec[voffs / ch + (voffs % ch) * vlen] += codebook.codevectors[coffs + l]; // FPMATH FIXME use if and counter instead of / and %
1417+ for (l = 0; l < dim; ++l) {
1418+ vec[voffs_div + voffs_mod * vlen] +=
1419+ codebook.codevectors[coffs + l];
14181420
14191421 av_dlog(NULL, " pass %d offs: %d curr: %f change: %f cv offs.: %d+%d \n",
1420− pass, voffset / ch + (voffs % ch) * vlen,
1421− vec[voffset / ch + (voffs % ch) * vlen],
1422+ pass, voffs_div + voffs_mod * vlen,
1423+ vec[voffs_div + voffs_mod * vlen],
14221424 codebook.codevectors[coffs + l], coffs, l);
1425+
1426+ if (++voffs_mod == ch) {
1427+ voffs_div++;
1428+ voffs_mod = 0;
1429+ }
14231430 }
14241431 }
14251432 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t