error_concealment: Prevent FPEs in case of corrupted input.
authorMichael Niedermayer <michaelni@gmx.at>
Fri, 23 Mar 2012 20:56:42 +0000 (21:56 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Fri, 23 Mar 2012 21:03:32 +0000 (22:03 +0100)
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavcodec/error_resilience.c

index cd6aa01..c93cea5 100644 (file)
@@ -248,7 +248,7 @@ static void guess_dc(MpegEncContext *s, int16_t *dc, int w,
             weight_sum = 0;
             guess      = 0;
             for (j = 0; j < 4; j++) {
-                int64_t weight  = 256 * 256 * 256 * 16 / dist[b_x + b_y*stride][j];
+                int64_t weight  = 256 * 256 * 256 * 16 / FFMAX(dist[b_x + b_y*stride][j], 1);
                 guess          += weight*(int64_t)col[b_x + b_y*stride][j];
                 weight_sum     += weight;
             }