mss2: simplify loop in decode_rle()
authorAlberto Delmás <adelmas@gmail.com>
Mon, 3 Sep 2012 15:32:01 +0000 (17:32 +0200)
committerKostya Shishkov <kostya.shishkov@gmail.com>
Thu, 6 Sep 2012 18:48:07 +0000 (20:48 +0200)
It calculates the sum of power of two series, which can be done in one step.

Suggested by Michael Niedermayer <michaelni@gmx.at>

Signed-off-by: Kostya Shishkov <kostya.shishkov@gmail.com>
libavcodec/mss2.c

index 9914562..fbdc72c 100644 (file)
@@ -335,8 +335,7 @@ static int decode_rle(GetBitContext *gb, uint8_t *pal_dst, int pal_stride,
                     else
                         repeat = get_bits(gb, b);
 
-                    while (b--)
-                        repeat += 1 << b;
+                    repeat += (1 << b) - 1;
 
                     if (last_symbol == -2) {
                         int skip = FFMIN(repeat, pal_dst + w - pp);