summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOded Shimon <ods15@ods15.dyndns.org>2006-10-02 06:09:39 +0000
committerOded Shimon <ods15@ods15.dyndns.org>2006-10-02 06:09:39 +0000
commitac0057f3a6dd6a06e6b47d95371f7e271f0cc9ae (patch)
tree1f02b3288a3b3f17579e2b517497892faa27286e
parent0c4630f244ab088cfc6facd104464f7f9affca21 (diff)
Original Commit: r108 | ods15 | 2006-10-01 18:46:06 +0200 (Sun, 01 Oct 2006) | 2 lines
prevent division/modulo Originally committed as revision 6512 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r--libavcodec/vorbis_enc.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/libavcodec/vorbis_enc.c b/libavcodec/vorbis_enc.c
index 94cd021d63..cff661dd6e 100644
--- a/libavcodec/vorbis_enc.c
+++ b/libavcodec/vorbis_enc.c
@@ -1292,14 +1292,22 @@ static void residue_encode(venc_context_t * venc, residue_t * rc, PutBitContext
for (l = 0; l < book->ndimentions; l++) buf[k + l] -= a[l];
}
} else {
+ int s = rc->begin + p * psize, a1, b1;
+ a1 = (s % real_ch) * samples;
+ b1 = s / real_ch;
+ s = real_ch * samples;
for (k = 0; k < psize; k += book->ndimentions) {
- int dim = book->ndimentions, s = rc->begin + p * psize + k, l;
- float vec[dim], * a = vec;
- for (l = s; l < s + dim; l++)
- *a++ = coeffs[(l % real_ch) * samples + l / real_ch];
- a = put_vector(book, pb, vec);
- for (l = s; l < s + dim; l++)
- coeffs[(l % real_ch) * samples + l / real_ch] -= *a++;
+ int dim, a2 = a1, b2 = b1;
+ float vec[book->ndimentions], * pv = vec;
+ for (dim = book->ndimentions; dim--; ) {
+ *pv++ = coeffs[a2 + b2];
+ if ((a2 += samples) == s) { a2=0; b2++; }
+ }
+ pv = put_vector(book, pb, vec);
+ for (dim = book->ndimentions; dim--; ) {
+ coeffs[a1 + b1] -= *pv++;
+ if ((a1 += samples) == s) { a1=0; b1++; }
+ }
}
}
}