ref: 98431cde070a33fe346f1316abd8437cd873dbfa
parent: 5adb43b8bea52f308c2a8c113cffcf840672dfda
author: Yaowu Xu <yaowu@google.com>
date: Tue Jul 12 07:11:26 EDT 2016
Fix encoder crashes for odd size input Change-Id: Id5c30c419282369cc8c3280d9a70b34a859a71d8
--- a/vp9/vp9_cx_iface.c
+++ b/vp9/vp9_cx_iface.c
@@ -992,6 +992,7 @@
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,
@@ -1013,8 +1014,8 @@
// 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);
--- a/vpx_dsp/psnrhvs.c
+++ b/vpx_dsp/psnrhvs.c
@@ -245,6 +245,8 @@
}
}
}
+ if (pixels <=0)
+ return 0;
ret /= pixels;
return ret;
}