static vpx_codec_err_t encoder_set_config(vpx_codec_alg_priv_t *ctx,
const vpx_codec_enc_cfg_t *cfg) {
vpx_codec_err_t res;
- int force_key = 0;
+ volatile int force_key = 0;
if (cfg->g_w != ctx->cfg.g_w || cfg->g_h != ctx->cfg.g_h) {
if (cfg->g_lag_in_frames > 1 || cfg->g_pass != VPX_RC_ONE_PASS)
ERROR("Cannot increase lag_in_frames");
res = validate_config(ctx, cfg, &ctx->extra_cfg);
+ if (res != VPX_CODEC_OK) return res;
- if (res == VPX_CODEC_OK) {
- ctx->cfg = *cfg;
- set_encoder_config(&ctx->oxcf, &ctx->cfg, &ctx->extra_cfg);
- set_twopass_params_from_config(&ctx->cfg, ctx->cpi);
- // On profile change, request a key frame
- force_key |= ctx->cpi->common.profile != ctx->oxcf.profile;
- vp9_change_config(ctx->cpi, &ctx->oxcf);
+ if (setjmp(ctx->cpi->common.error.jmp)) {
+ const vpx_codec_err_t codec_err =
+ update_error_state(ctx, &ctx->cpi->common.error);
+ ctx->cpi->common.error.setjmp = 0;
+ vpx_clear_system_state();
+ assert(codec_err != VPX_CODEC_OK);
+ return codec_err;
}
+ ctx->cfg = *cfg;
+ set_encoder_config(&ctx->oxcf, &ctx->cfg, &ctx->extra_cfg);
+ set_twopass_params_from_config(&ctx->cfg, ctx->cpi);
+ // On profile change, request a key frame
+ force_key |= ctx->cpi->common.profile != ctx->oxcf.profile;
+ vp9_change_config(ctx->cpi, &ctx->oxcf);
+
if (force_key) ctx->next_frame_flags |= VPX_EFLAG_FORCE_KF;
- return res;
+ ctx->cpi->common.error.setjmp = 0;
+ return VPX_CODEC_OK;
}
static vpx_codec_err_t ctrl_get_quantizer(vpx_codec_alg_priv_t *ctx,