]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/error_resilience.c
Merge remote-tracking branch 'qatar/master'
[ffmpeg] / libavcodec / error_resilience.c
index 1c1420f93ce8f6bb6bcf35f940cb75bace323afe..c93cea58dce0a77436b62e8933eaabe62ec55a26 100644 (file)
@@ -174,7 +174,7 @@ static void guess_dc(MpegEncContext *s, int16_t *dc, int w,
 {
     int b_x, b_y;
     int16_t  (*col )[4] = av_malloc(stride*h*sizeof( int16_t)*4);
-    uint16_t (*dist)[4] = av_malloc(stride*h*sizeof(uint16_t)*4);
+    uint32_t (*dist)[4] = av_malloc(stride*h*sizeof(uint32_t)*4);
 
     for(b_y=0; b_y<h; b_y++){
         int color= 1024;
@@ -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;
             }