[FFmpeg-cvslog] mss2: simplify loop in decode_rle()

Alberto Delmás git at videolan.org
Fri Sep 7 13:50:45 CEST 2012


ffmpeg | branch: master | Alberto Delmás <adelmas at gmail.com> | Mon Sep  3 17:32:01 2012 +0200| [290d1022b2d90503735728d7feed35a53a69f631] | committer: Kostya Shishkov

mss2: simplify loop in decode_rle()

It calculates the sum of power of two series, which can be done in one step.

Suggested by Michael Niedermayer <michaelni at gmx.at>

Signed-off-by: Kostya Shishkov <kostya.shishkov at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=290d1022b2d90503735728d7feed35a53a69f631
---

 libavcodec/mss2.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/libavcodec/mss2.c b/libavcodec/mss2.c
index 9914562..fbdc72c 100644
--- a/libavcodec/mss2.c
+++ b/libavcodec/mss2.c
@@ -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);



More information about the ffmpeg-cvslog mailing list