summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYaowu Xu <yaowu@google.com>2016-07-12 11:11:26 -0700
committerJohann <johannkoenig@google.com>2016-07-20 15:02:13 -0700
commit297b2a12d628b9948a182917c0ef19ddbedd6b97 (patch)
treeead3c3b853be606a296f792b15a89db25c65fded
parent1c0a9f36f15a83816aebe5395e19c21f3d545aa2 (diff)
downloadlibvpx-297b2a12d628b9948a182917c0ef19ddbedd6b97.tar.gz
Fix encoder crashes for odd size input
(cherry picked from commit 98431cde070a33fe346f1316abd8437cd873dbfa) Change-Id: Id5c30c419282369cc8c3280d9a70b34a859a71d8
-rw-r--r--vp9/vp9_cx_iface.c5
-rw-r--r--vpx_dsp/psnrhvs.c2
2 files changed, 5 insertions, 2 deletions
diff --git a/vp9/vp9_cx_iface.c b/vp9/vp9_cx_iface.c
index 9ad86cbf8..10d68939d 100644
--- a/vp9/vp9_cx_iface.c
+++ b/vp9/vp9_cx_iface.c
@@ -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);
diff --git a/vpx_dsp/psnrhvs.c b/vpx_dsp/psnrhvs.c
index 300170579..0ffa1b251 100644
--- a/vpx_dsp/psnrhvs.c
+++ b/vpx_dsp/psnrhvs.c
@@ -200,6 +200,8 @@ static double calc_psnrhvs(const unsigned char *_src, int _systride,
}
}
}
+ if (pixels <=0)
+ return 0;
ret /= pixels;
return ret;
}