summaryrefslogtreecommitdiff
path: root/vp9
diff options
context:
space:
mode:
authorAlex Converse <aconverse@google.com>2015-01-21 13:59:34 -0800
committerGerrit Code Review <gerrit@gerrit.golo.chromium.org>2015-01-21 13:59:34 -0800
commitaaa31a3164b912a86149627ca98e98fdfce6f441 (patch)
tree9eb4879a75259316e4019fd5ad45c5838b5db475 /vp9
parent13458362af8089df06d1534de928acfc93ac7cc5 (diff)
parent910ca857df5df679839c3ccdf4e5ca97159b1fd2 (diff)
downloadlibvpx-aaa31a3164b912a86149627ca98e98fdfce6f441.tar
libvpx-aaa31a3164b912a86149627ca98e98fdfce6f441.tar.gz
libvpx-aaa31a3164b912a86149627ca98e98fdfce6f441.tar.bz2
libvpx-aaa31a3164b912a86149627ca98e98fdfce6f441.zip
Merge "Allow external resize via vpx_codec_enc_config_set"
Diffstat (limited to 'vp9')
-rw-r--r--vp9/encoder/vp9_encoder.c2
-rw-r--r--vp9/vp9_cx_iface.c21
2 files changed, 19 insertions, 4 deletions
diff --git a/vp9/encoder/vp9_encoder.c b/vp9/encoder/vp9_encoder.c
index 35fea57f5..c85bf2a0e 100644
--- a/vp9/encoder/vp9_encoder.c
+++ b/vp9/encoder/vp9_encoder.c
@@ -1312,6 +1312,8 @@ void vp9_change_config(struct VP9_COMP *cpi, const VP9EncoderConfig *oxcf) {
cm->display_width = cpi->oxcf.width;
cm->display_height = cpi->oxcf.height;
+ cm->width = cpi->oxcf.width;
+ cm->height = cpi->oxcf.height;
if (cpi->initial_width) {
// Increasing the size of the frame beyond the first seen frame, or some
diff --git a/vp9/vp9_cx_iface.c b/vp9/vp9_cx_iface.c
index 46e6e919c..589f0b1bf 100644
--- a/vp9/vp9_cx_iface.c
+++ b/vp9/vp9_cx_iface.c
@@ -83,6 +83,7 @@ struct vpx_codec_alg_priv {
size_t pending_frame_sizes[8];
size_t pending_frame_magnitude;
vpx_image_t preview_img;
+ vpx_enc_frame_flags_t next_frame_flags;
vp8_postproc_cfg_t preview_ppcfg;
vpx_codec_pkt_list_decl(256) pkt_list;
unsigned int fixed_kf_cntr;
@@ -524,9 +525,17 @@ static vpx_codec_err_t set_encoder_config(
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;
-
- if (cfg->g_w != ctx->cfg.g_w || cfg->g_h != ctx->cfg.g_h)
- ERROR("Cannot change width or height after initialization");
+ 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 change width or height after initialization");
+ if ((ctx->cpi->initial_width && (int)cfg->g_w > ctx->cpi->initial_width) ||
+ (ctx->cpi->initial_height && (int)cfg->g_h > ctx->cpi->initial_height))
+ ERROR("Cannot increase width or height larger than their initial values");
+ if (!valid_ref_frame_size(ctx->cfg.g_w, ctx->cfg.g_h, cfg->g_w, cfg->g_h))
+ force_key = 1;
+ }
// Prevent increasing lag_in_frames. This check is stricter than it needs
// to be -- the limit is not increasing past the first lag_in_frames
@@ -543,6 +552,9 @@ static vpx_codec_err_t encoder_set_config(vpx_codec_alg_priv_t *ctx,
vp9_change_config(ctx->cpi, &ctx->oxcf);
}
+ if (force_key)
+ ctx->next_frame_flags |= VPX_EFLAG_FORCE_KF;
+
return res;
}
@@ -955,10 +967,11 @@ static vpx_codec_err_t encoder_encode(vpx_codec_alg_priv_t *ctx,
// 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(cpi, flags,
+ if (vp9_receive_raw_frame(cpi, flags | ctx->next_frame_flags,
&sd, dst_time_stamp, dst_end_time_stamp)) {
res = update_error_state(ctx, &cpi->common.error);
}
+ ctx->next_frame_flags = 0;
}
cx_data = ctx->cx_data;