diff options
author | Jerome Jiang <jianj@google.com> | 2018-01-17 11:23:55 -0800 |
---|---|---|
committer | Jerome Jiang <jianj@google.com> | 2018-01-22 20:30:45 -0800 |
commit | 5b6ae020b6a972b67b59b3dbf7cf9cbd3140a80d (patch) | |
tree | b4f57449cd68eace9ddb882834b9e02aa4319783 /vpx | |
parent | f915e6d4afafabed8281b172f93502acbe101f3a (diff) | |
download | libvpx-5b6ae020b6a972b67b59b3dbf7cf9cbd3140a80d.tar libvpx-5b6ae020b6a972b67b59b3dbf7cf9cbd3140a80d.tar.gz libvpx-5b6ae020b6a972b67b59b3dbf7cf9cbd3140a80d.tar.bz2 libvpx-5b6ae020b6a972b67b59b3dbf7cf9cbd3140a80d.zip |
Fix crash invalid params for vp8 multres. Add test.
Fix is from the patch in the issue.
Release memories allocated before early exit.
BUG=webm:1482
Change-Id: I64952af99c58241496e03fa55da09fd129a07c77
Diffstat (limited to 'vpx')
-rw-r--r-- | vpx/src/vpx_encoder.c | 50 |
1 files changed, 28 insertions, 22 deletions
diff --git a/vpx/src/vpx_encoder.c b/vpx/src/vpx_encoder.c index 4390cf7c8..a26204bc4 100644 --- a/vpx/src/vpx_encoder.c +++ b/vpx/src/vpx_encoder.c @@ -12,8 +12,11 @@ * \brief Provides the high level interface to wrap encoder algorithms. * */ +#include <assert.h> #include <limits.h> +#include <stdlib.h> #include <string.h> +#include "vp8/common/blockd.h" #include "vpx_config.h" #include "vpx/internal/vpx_codec_internal.h" @@ -89,28 +92,27 @@ vpx_codec_err_t vpx_codec_enc_init_multi_ver( if (dsf->num < 1 || dsf->num > 4096 || dsf->den < 1 || dsf->den > dsf->num) { res = VPX_CODEC_INVALID_PARAM; - break; + } else { + mr_cfg.mr_low_res_mode_info = mem_loc; + mr_cfg.mr_total_resolutions = num_enc; + mr_cfg.mr_encoder_id = num_enc - 1 - i; + mr_cfg.mr_down_sampling_factor.num = dsf->num; + mr_cfg.mr_down_sampling_factor.den = dsf->den; + + /* Force Key-frame synchronization. Namely, encoder at higher + * resolution always use the same frame_type chosen by the + * lowest-resolution encoder. + */ + if (mr_cfg.mr_encoder_id) cfg->kf_mode = VPX_KF_DISABLED; + + ctx->iface = iface; + ctx->name = iface->name; + ctx->priv = NULL; + ctx->init_flags = flags; + ctx->config.enc = cfg; + res = ctx->iface->init(ctx, &mr_cfg); } - mr_cfg.mr_low_res_mode_info = mem_loc; - mr_cfg.mr_total_resolutions = num_enc; - mr_cfg.mr_encoder_id = num_enc - 1 - i; - mr_cfg.mr_down_sampling_factor.num = dsf->num; - mr_cfg.mr_down_sampling_factor.den = dsf->den; - - /* Force Key-frame synchronization. Namely, encoder at higher - * resolution always use the same frame_type chosen by the - * lowest-resolution encoder. - */ - if (mr_cfg.mr_encoder_id) cfg->kf_mode = VPX_KF_DISABLED; - - ctx->iface = iface; - ctx->name = iface->name; - ctx->priv = NULL; - ctx->init_flags = flags; - ctx->config.enc = cfg; - res = ctx->iface->init(ctx, &mr_cfg); - if (res) { const char *error_detail = ctx->priv ? ctx->priv->err_detail : NULL; /* Destroy current ctx */ @@ -124,10 +126,14 @@ vpx_codec_err_t vpx_codec_enc_init_multi_ver( vpx_codec_destroy(ctx); i--; } +#if CONFIG_MULTI_RES_ENCODING + assert(mem_loc); + free(((LOWER_RES_FRAME_INFO *)mem_loc)->mb_info); + free(mem_loc); +#endif + return SAVE_STATUS(ctx, res); } - if (res) break; - ctx++; cfg++; dsf++; |