[FFmpeg-devel] [PATCH] support encrypted asf

Uoti Urpala uoti.urpala
Tue Oct 9 21:05:38 CEST 2007

```On Tue, 2007-10-09 at 19:53 +0200, Reimar D?ffinger wrote:
+static uint32_t inverse(uint32_t v) {
+    // this initialization reduces the number of iterations
+    // to 3 compared to 4 for = 2 - v and 5 for = 1
+    uint32_t inverse = v * v * v;

What matters is the number of correct lowest bits. 2-v is just the
result of the first iteration starting from i=1. A more useful comment
would be something like

// v * v^3 = v^4 = 1 mod 16 for all odd v, so v^3 is the inverse mod 16
// and this initialization gives 4 correct lowest bits.

v*v*v saves 2 subtractions compared to 2-v and one iteration, but that's
probably not worth explaining separately.

+    // uses a fixpoint-iteration to find the inverse very quickly

Explicitly mentioning that it's fixed point is not useful IMO.

// Each iteration doubles the number of correct lowest bits

+    int i = 3;
+    do {
+        inverse *= 2 - v * inverse;
+    } while (--i);

I'd just repeat the line 3 times instead of using a loop.
If you do want to use a loop using "for" would be clearer (any compiler
should be able to optimize that loop to equal code).

```