]> rtime.felk.cvut.cz Git - frescor/ffmpeg.git/commitdiff
Original Commit: r108 | ods15 | 2006-10-01 18:46:06 +0200 (Sun, 01 Oct 2006) | 2...
authorods15 <ods15@9553f0bf-9b14-0410-a0b8-cfaf0461ba5b>
Mon, 2 Oct 2006 06:09:39 +0000 (06:09 +0000)
committerods15 <ods15@9553f0bf-9b14-0410-a0b8-cfaf0461ba5b>
Mon, 2 Oct 2006 06:09:39 +0000 (06:09 +0000)
prevent division/modulo

git-svn-id: file:///var/local/repositories/ffmpeg/trunk@6512 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b

libavcodec/vorbis_enc.c

index 94cd021d63dc6145269c760bbc39e6ea288f7bdc..cff661dd6e6fdff16a4ac0fa2a53d6b75c114dc8 100644 (file)
@@ -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++; }
+                            }
                         }
                     }
                 }