summaryrefslogtreecommitdiff
path: root/vp9
diff options
context:
space:
mode:
authorMatthias Räncker <theonetruecamper@gmx.de>2018-09-21 14:23:44 +0200
committerMatthias Räncker <theonetruecamper@gmx.de>2018-09-21 14:47:51 +0200
commite376f1d5d4f1c3c39cb1f06cf17020300eac64ea (patch)
tree90418f790c4cb24c0ebd583b7ff4971cdc112049 /vp9
parente65f9e8bcef72711133b1ef7109856c9de05e8d1 (diff)
downloadlibvpx-e376f1d5d4f1c3c39cb1f06cf17020300eac64ea.tar
libvpx-e376f1d5d4f1c3c39cb1f06cf17020300eac64ea.tar.gz
libvpx-e376f1d5d4f1c3c39cb1f06cf17020300eac64ea.tar.bz2
libvpx-e376f1d5d4f1c3c39cb1f06cf17020300eac64ea.zip
internal stats: fix mem leak and initialize memory
Without calloc valgrind reports usuage of uninitialized data in vpx_get_ssim_metrics. Signed-off-by: Matthias Räncker <theonetruecamper@gmx.de> Change-Id: I9cd38b8031ea3f22c1436894ddaf9e0ccf5a654e
Diffstat (limited to 'vp9')
-rw-r--r--vp9/encoder/vp9_encoder.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/vp9/encoder/vp9_encoder.c b/vp9/encoder/vp9_encoder.c
index 7ba08f2d6..c9c5c1e9a 100644
--- a/vp9/encoder/vp9_encoder.c
+++ b/vp9/encoder/vp9_encoder.c
@@ -2236,9 +2236,11 @@ VP9_COMP *vp9_create_compressor(VP9EncoderConfig *oxcf,
if (cpi->b_calculate_consistency) {
CHECK_MEM_ERROR(cm, cpi->ssim_vars,
- vpx_malloc(sizeof(*cpi->ssim_vars) * 4 *
- cpi->common.mi_rows * cpi->common.mi_cols));
+ vpx_calloc(cpi->common.mi_rows * cpi->common.mi_cols,
+ sizeof(*cpi->ssim_vars) * 4));
cpi->worst_consistency = 100.0;
+ } else {
+ cpi->ssim_vars = NULL;
}
#endif
@@ -2466,6 +2468,10 @@ void vp9_remove_compressor(VP9_COMP *cpi) {
if (!cpi) return;
+#if CONFIG_INTERNAL_STATS
+ vpx_free(cpi->ssim_vars);
+#endif
+
cm = &cpi->common;
if (cm->current_video_frame > 0) {
#if CONFIG_INTERNAL_STATS
@@ -2537,7 +2543,6 @@ void vp9_remove_compressor(VP9_COMP *cpi) {
fclose(f);
}
-
#endif
#if 0