]> granicus.if.org Git - libvpx/commitdiff
Fix encoder crashes for odd size input
authorYaowu Xu <yaowu@google.com>
Tue, 12 Jul 2016 18:11:26 +0000 (11:11 -0700)
committerJohann <johannkoenig@google.com>
Wed, 20 Jul 2016 22:02:13 +0000 (15:02 -0700)
(cherry picked from commit 98431cde070a33fe346f1316abd8437cd873dbfa)

Change-Id: Id5c30c419282369cc8c3280d9a70b34a859a71d8

vp9/vp9_cx_iface.c
vpx_dsp/psnrhvs.c

index 9ad86cbf84d1cb4ff2d60d822f6f6d03da985841..10d68939d22afb56b13271721138c5b069e277ad 100644 (file)
@@ -1005,6 +1005,7 @@ static vpx_codec_frame_flags_t get_frame_pkt_flags(const VP9_COMP *cpi,
   return flags;
 }
 
+const size_t kMinCompressedSize = 8192;
 static vpx_codec_err_t encoder_encode(vpx_codec_alg_priv_t  *ctx,
                                       const vpx_image_t *img,
                                       vpx_codec_pts_t pts,
@@ -1026,8 +1027,8 @@ static vpx_codec_err_t encoder_encode(vpx_codec_alg_priv_t  *ctx,
       // instance for its status to determine the compressed data size.
       data_sz = ctx->cfg.g_w * ctx->cfg.g_h * get_image_bps(img) / 8 *
                 (cpi->multi_arf_allowed ? 8 : 2);
-      if (data_sz < 4096)
-        data_sz = 4096;
+      if (data_sz < kMinCompressedSize)
+        data_sz = kMinCompressedSize;
       if (ctx->cx_data == NULL || ctx->cx_data_sz < data_sz) {
         ctx->cx_data_sz = data_sz;
         free(ctx->cx_data);
index 300170579121bd9b8a36a53b21c8421fb3d1bfc4..0ffa1b2519d64aadd1d21c72fbb907676b57a35e 100644 (file)
@@ -200,6 +200,8 @@ static double calc_psnrhvs(const unsigned char *_src, int _systride,
       }
     }
   }
+  if (pixels <=0)
+      return 0;
   ret /= pixels;
   return ret;
 }