From 754bbcfdc80e15730b62a554baa7ac74af136066 Mon Sep 17 00:00:00 2001 From: Yaowu Xu Date: Wed, 25 Feb 2015 15:39:09 -0800 Subject: [PATCH] Fix the encoder to support profile change Change-Id: Iefb928ad1174e274409facfb44f80265ff0f7683 --- vp9/encoder/vp9_encoder.c | 17 ++++++++++++----- vp9/vp9_cx_iface.c | 2 ++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/vp9/encoder/vp9_encoder.c b/vp9/encoder/vp9_encoder.c index 9147c29e5..17eb75a9e 100644 --- a/vp9/encoder/vp9_encoder.c +++ b/vp9/encoder/vp9_encoder.c @@ -1963,11 +1963,13 @@ typedef struct { static void calc_psnr(const YV12_BUFFER_CONFIG *a, const YV12_BUFFER_CONFIG *b, PSNR_STATS *psnr) { static const double peak = 255.0; - const int widths[3] = {a->y_width, a->uv_width, a->uv_width }; - const int heights[3] = {a->y_height, a->uv_height, a->uv_height}; - const uint8_t *a_planes[3] = {a->y_buffer, a->u_buffer, a->v_buffer }; + const int widths[3] = { + a->y_crop_width, a->uv_crop_width, a->uv_crop_width}; + const int heights[3] = { + a->y_crop_height, a->uv_crop_height, a->uv_crop_height}; + const uint8_t *a_planes[3] = {a->y_buffer, a->u_buffer, a->v_buffer}; const int a_strides[3] = {a->y_stride, a->uv_stride, a->uv_stride}; - const uint8_t *b_planes[3] = {b->y_buffer, b->u_buffer, b->v_buffer }; + const uint8_t *b_planes[3] = {b->y_buffer, b->u_buffer, b->v_buffer}; const int b_strides[3] = {b->y_stride, b->uv_stride, b->uv_stride}; int i; uint64_t total_sse = 0; @@ -3451,7 +3453,12 @@ static void check_initial_width(VP9_COMP *cpi, int subsampling_x, int subsampling_y) { VP9_COMMON *const cm = &cpi->common; - if (!cpi->initial_width) { + if (!cpi->initial_width || +#if CONFIG_VP9_HIGHBITDEPTH + cm->use_highbitdepth != use_highbitdepth || +#endif + cm->subsampling_x != subsampling_x || + cm->subsampling_y != subsampling_y) { cm->subsampling_x = subsampling_x; cm->subsampling_y = subsampling_y; #if CONFIG_VP9_HIGHBITDEPTH diff --git a/vp9/vp9_cx_iface.c b/vp9/vp9_cx_iface.c index 8fd7b35e6..d0c4c6744 100644 --- a/vp9/vp9_cx_iface.c +++ b/vp9/vp9_cx_iface.c @@ -550,6 +550,8 @@ static vpx_codec_err_t encoder_set_config(vpx_codec_alg_priv_t *ctx, if (res == VPX_CODEC_OK) { ctx->cfg = *cfg; set_encoder_config(&ctx->oxcf, &ctx->cfg, &ctx->extra_cfg); + // On profile change, request a key frame + force_key |= ctx->cpi->common.profile != ctx->oxcf.profile; vp9_change_config(ctx->cpi, &ctx->oxcf); } -- 2.40.0