multi-res: force Key frame sychronization
In multi-resolution encoding, frame_type decision for each frame
is made by the lowest-resolution encoder. For all other higher-
resolution encoders, kf_mode is always set to VPX_KF_DISABLED,
and they are forced to use the same frame_type picked by the
lowest-resolution encoder.
Change-Id: Ic4d52ec65bbc012ca9c2d236210e28a295591eaf
diff --git a/vp8/vp8_cx_iface.c b/vp8/vp8_cx_iface.c
index f55a420..04d4d86 100644
--- a/vp8/vp8_cx_iface.c
+++ b/vp8/vp8_cx_iface.c
@@ -549,23 +549,28 @@
static vpx_codec_err_t vp8e_mr_alloc_mem(const vpx_codec_enc_cfg_t *cfg,
void **mem_loc)
{
- vpx_codec_err_t res = 0;
-
#if CONFIG_MULTI_RES_ENCODING
+ LOWER_RES_FRAME_INFO *shared_mem_loc;
int mb_rows = ((cfg->g_w + 15) >>4);
int mb_cols = ((cfg->g_h + 15) >>4);
- *mem_loc = calloc(mb_rows*mb_cols, sizeof(LOWER_RES_INFO));
- if(!(*mem_loc))
+ shared_mem_loc = calloc(1, sizeof(LOWER_RES_FRAME_INFO));
+ if(!shared_mem_loc)
{
- free(*mem_loc);
- res = VPX_CODEC_MEM_ERROR;
+ return VPX_CODEC_MEM_ERROR;
+ }
+
+ shared_mem_loc->mb_info = calloc(mb_rows*mb_cols, sizeof(LOWER_RES_MB_INFO));
+ if(!(shared_mem_loc->mb_info))
+ {
+ return VPX_CODEC_MEM_ERROR;
}
else
- res = VPX_CODEC_OK;
+ {
+ *mem_loc = (void *)shared_mem_loc;
+ return VPX_CODEC_OK;
+ }
#endif
-
- return res;
}
static vpx_codec_err_t vp8e_init(vpx_codec_ctx_t *ctx,
@@ -659,7 +664,11 @@
#if CONFIG_MULTI_RES_ENCODING
/* Free multi-encoder shared memory */
if (ctx->oxcf.mr_total_resolutions > 0 && (ctx->oxcf.mr_encoder_id == ctx->oxcf.mr_total_resolutions-1))
+ {
+ LOWER_RES_FRAME_INFO *shared_mem_loc = (LOWER_RES_FRAME_INFO *)ctx->oxcf.mr_low_res_mode_info;
+ free(shared_mem_loc->mb_info);
free(ctx->oxcf.mr_low_res_mode_info);
+ }
#endif
free(ctx->cx_data);