From 42b8f5443b279c5460dd59b5d6c8a5d3986c8d7d Mon Sep 17 00:00:00 2001
From: Ronald S. Bultje <rsbultje@gmail.com>
Date: Mon, 5 Dec 2011 20:35:13 -0800
Subject: [PATCH] swscale: fix overflows in RGB rounding constants.

---
 libswscale/swscale.c |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/libswscale/swscale.c b/libswscale/swscale.c
index 975a0bd..65e9cfd 100644
--- a/libswscale/swscale.c
+++ b/libswscale/swscale.c
@@ -1456,8 +1456,8 @@ rgb16_32ToY_c_template(uint8_t *dst, const uint8_t *src,
                        int maskr, int maskg, int maskb,
                        int rsh,   int gsh,   int bsh, int S)
 {
-    const int ry = RY << rsh, gy = GY << gsh, by = BY << bsh,
-              rnd = 33 << (S - 1);
+    const int ry = RY << rsh, gy = GY << gsh, by = BY << bsh;
+    const unsigned rnd = 33 << (S - 1);
     int i;
 
     for (i = 0; i < width; i++) {
@@ -1479,8 +1479,8 @@ rgb16_32ToUV_c_template(uint8_t *dstU, uint8_t *dstV,
                         int rsh,   int gsh,   int bsh, int S)
 {
     const int ru = RU << rsh, gu = GU << gsh, bu = BU << bsh,
-              rv = RV << rsh, gv = GV << gsh, bv = BV << bsh,
-              rnd = 257 << (S - 1);
+              rv = RV << rsh, gv = GV << gsh, bv = BV << bsh;
+    const unsigned rnd = 257 << (S - 1);
     int i;
 
     for (i = 0; i < width; i++) {
@@ -1504,7 +1504,8 @@ rgb16_32ToUV_half_c_template(uint8_t *dstU, uint8_t *dstV,
 {
     const int ru = RU << rsh, gu = GU << gsh, bu = BU << bsh,
               rv = RV << rsh, gv = GV << gsh, bv = BV << bsh,
-              rnd = 257 << S, maskgx = ~(maskr | maskb);
+              maskgx = ~(maskr | maskb);
+    const unsigned rnd = 257 << S;
     int i;
 
     maskr |= maskr << 1; maskb |= maskb << 1; maskg |= maskg << 1;
-- 
1.7.2.1

