OSDN Git Service

avcodec/mpegvideo_enc: fix integer overflow with -skip_exp >= 2
authorMichael Niedermayer <michaelni@gmx.at>
Fri, 20 Dec 2013 12:35:39 +0000 (13:35 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Fri, 20 Dec 2013 13:10:34 +0000 (14:10 +0100)
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavcodec/mpegvideo_enc.c

index fb9f451..2153fda 100644 (file)
@@ -1148,9 +1148,9 @@ static int skip_check(MpegEncContext *s, Picture *p, Picture *ref)
                 switch (s->avctx->frame_skip_exp) {
                 case 0: score    =  FFMAX(score, v);          break;
                 case 1: score   += FFABS(v);                  break;
-                case 2: score   += v * v;                     break;
-                case 3: score64 += FFABS(v * v * (int64_t)v); break;
-                case 4: score64 += v * v * (int64_t)(v * v);  break;
+                case 2: score64 += v * (int64_t)v;                       break;
+                case 3: score64 += FFABS(v * (int64_t)v * v);            break;
+                case 4: score64 += (v * (int64_t)v) * (v * (int64_t)v);  break;
                 }
             }
         }