diff --git a/vp9/vp9_cx_iface.c b/vp9/vp9_cx_iface.c index 7007e3f7d383146692d34382d36fbce96e89ede5..0f0b7a5abbdecfa0c2475a84d9a7b22cfc6b67bf 100644 --- a/vp9/vp9_cx_iface.c +++ b/vp9/vp9_cx_iface.c @@ -836,18 +836,19 @@ static vpx_codec_err_t encoder_encode(vpx_codec_alg_priv_t *ctx, vpx_enc_frame_flags_t flags, unsigned long deadline) { vpx_codec_err_t res = VPX_CODEC_OK; + VP9_COMP *const cpi = ctx->cpi; const vpx_rational_t *const timebase = &ctx->cfg.g_timebase; if (img != NULL) { res = validate_img(ctx, img); // TODO(jzern) the checks related to cpi's validity should be treated as a // failure condition, encoder setup is done fully in init() currently. - if (res == VPX_CODEC_OK && ctx->cpi != NULL && ctx->cx_data == NULL) { + if (res == VPX_CODEC_OK && cpi != NULL && ctx->cx_data == NULL) { // There's no codec control for multiple alt-refs so check the encoder // instance for its status to determine the compressed data size. ctx->cx_data_sz = ctx->cfg.g_w * ctx->cfg.g_h * get_image_bps(img) / 8 * - (ctx->cpi->multi_arf_allowed ? 8 : 2); + (cpi->multi_arf_allowed ? 8 : 2); if (ctx->cx_data_sz < 4096) ctx->cx_data_sz = 4096; ctx->cx_data = (unsigned char *)malloc(ctx->cx_data_sz); @@ -867,7 +868,7 @@ static vpx_codec_err_t encoder_encode(vpx_codec_alg_priv_t *ctx, return VPX_CODEC_INVALID_PARAM; } - vp9_apply_encoding_flags(ctx->cpi, flags); + vp9_apply_encoding_flags(cpi, flags); // Handle fixed keyframe intervals if (ctx->cfg.kf_mode == VPX_KF_AUTO && @@ -879,7 +880,7 @@ static vpx_codec_err_t encoder_encode(vpx_codec_alg_priv_t *ctx, } // Initialize the encoder instance on the first frame. - if (res == VPX_CODEC_OK && ctx->cpi != NULL) { + if (res == VPX_CODEC_OK && cpi != NULL) { unsigned int lib_flags = 0; YV12_BUFFER_CONFIG sd; int64_t dst_time_stamp = timebase_units_to_ticks(timebase, pts); @@ -890,16 +891,15 @@ static vpx_codec_err_t encoder_encode(vpx_codec_alg_priv_t *ctx, // Set up internal flags if (ctx->base.init_flags & VPX_CODEC_USE_PSNR) - ((VP9_COMP *)ctx->cpi)->b_calculate_psnr = 1; + cpi->b_calculate_psnr = 1; if (img != NULL) { res = image2yuvconfig(img, &sd); // Store the original flags in to the frame buffer. Will extract the // key frame flag when we actually encode this frame. - if (vp9_receive_raw_frame(ctx->cpi, flags, + if (vp9_receive_raw_frame(cpi, flags, &sd, dst_time_stamp, dst_end_time_stamp)) { - VP9_COMP *cpi = (VP9_COMP *)ctx->cpi; res = update_error_state(ctx, &cpi->common.error); } } @@ -924,11 +924,10 @@ static vpx_codec_err_t encoder_encode(vpx_codec_alg_priv_t *ctx, } while (cx_data_sz >= ctx->cx_data_sz / 2 && - -1 != vp9_get_compressed_data(ctx->cpi, &lib_flags, &size, + -1 != vp9_get_compressed_data(cpi, &lib_flags, &size, cx_data, &dst_time_stamp, &dst_end_time_stamp, !img)) { if (size) { - VP9_COMP *const cpi = (VP9_COMP *)ctx->cpi; vpx_codec_cx_pkt_t pkt; #if CONFIG_SPATIAL_SVC