]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/mss2.c
swscale: Provide the right alignment for external mmx asm
[ffmpeg] / libavcodec / mss2.c
index e4c854a01e9ac224175c74e653030eb4da865662..fbdc72c5c7f1646bd11f347b9ac28d90531fc537 100644 (file)
@@ -106,7 +106,7 @@ static int arith2_get_number(ArithCoder *c, int n)
     return val;
 }
 
-static int arith2_get_prob(ArithCoder *c, int *probs)
+static int arith2_get_prob(ArithCoder *c, int16_t *probs)
 {
     int range = c->high - c->low + 1, n = *probs;
     int scale = av_log2(range) - av_log2(n);
@@ -161,7 +161,7 @@ static int decode_pal_v2(MSS12Context *ctx, const uint8_t *buf, int buf_size)
         return 0;
 
     ncol = *buf++;
-    if (buf_size < 2 + ncol * 3)
+    if (ncol > ctx->free_colours || buf_size < 2 + ncol * 3)
         return -1;
     for (i = 0; i < ncol; i++)
         *pal++ = AV_RB24(buf + 3 * i);
@@ -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);