Index: source/libvpx/vp9/vp9_cx_iface.c |
=================================================================== |
--- source/libvpx/vp9/vp9_cx_iface.c (revision 281795) |
+++ source/libvpx/vp9/vp9_cx_iface.c (working copy) |
@@ -88,8 +88,8 @@ |
size_t pending_frame_magnitude; |
vpx_image_t preview_img; |
vp8_postproc_cfg_t preview_ppcfg; |
- vpx_codec_pkt_list_decl(64) pkt_list; |
- unsigned int fixed_kf_cntr; |
+ vpx_codec_pkt_list_decl(128) pkt_list; |
+ unsigned int fixed_kf_cntr; |
}; |
static VP9_REFFRAME ref_frame_to_vp9_reframe(vpx_ref_frame_type_t frame) { |
@@ -795,43 +795,8 @@ |
return VPX_CODEC_INVALID_PARAM; |
} |
- if (flags & (VP8_EFLAG_NO_REF_LAST | VP8_EFLAG_NO_REF_GF | |
- VP8_EFLAG_NO_REF_ARF)) { |
- int ref = 7; |
+ vp9_apply_encoding_flags(ctx->cpi, flags); |
- if (flags & VP8_EFLAG_NO_REF_LAST) |
- ref ^= VP9_LAST_FLAG; |
- |
- if (flags & VP8_EFLAG_NO_REF_GF) |
- ref ^= VP9_GOLD_FLAG; |
- |
- if (flags & VP8_EFLAG_NO_REF_ARF) |
- ref ^= VP9_ALT_FLAG; |
- |
- vp9_use_as_reference(ctx->cpi, ref); |
- } |
- |
- if (flags & (VP8_EFLAG_NO_UPD_LAST | VP8_EFLAG_NO_UPD_GF | |
- VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_FORCE_GF | |
- VP8_EFLAG_FORCE_ARF)) { |
- int upd = 7; |
- |
- if (flags & VP8_EFLAG_NO_UPD_LAST) |
- upd ^= VP9_LAST_FLAG; |
- |
- if (flags & VP8_EFLAG_NO_UPD_GF) |
- upd ^= VP9_GOLD_FLAG; |
- |
- if (flags & VP8_EFLAG_NO_UPD_ARF) |
- upd ^= VP9_ALT_FLAG; |
- |
- vp9_update_reference(ctx->cpi, upd); |
- } |
- |
- if (flags & VP8_EFLAG_NO_UPD_ENTROPY) { |
- vp9_update_entropy(ctx->cpi, 0); |
- } |
- |
// Handle fixed keyframe intervals |
if (ctx->cfg.kf_mode == VPX_KF_AUTO && |
ctx->cfg.kf_min_dist == ctx->cfg.kf_max_dist) { |
@@ -843,7 +808,7 @@ |
// Initialize the encoder instance on the first frame. |
if (res == VPX_CODEC_OK && ctx->cpi != NULL) { |
- unsigned int lib_flags; |
+ unsigned int lib_flags = 0; |
YV12_BUFFER_CONFIG sd; |
int64_t dst_time_stamp, dst_end_time_stamp; |
size_t size, cx_data_sz; |
@@ -853,9 +818,6 @@ |
if (ctx->base.init_flags & VPX_CODEC_USE_PSNR) |
((VP9_COMP *)ctx->cpi)->b_calculate_psnr = 1; |
- // Convert API flags to internal codec lib flags |
- lib_flags = (flags & VPX_EFLAG_FORCE_KF) ? FRAMEFLAGS_KEY : 0; |
- |
/* vp9 use 10,000,000 ticks/second as time stamp */ |
dst_time_stamp = (pts * 10000000 * ctx->cfg.g_timebase.num) |
/ ctx->cfg.g_timebase.den; |
@@ -865,7 +827,9 @@ |
if (img != NULL) { |
res = image2yuvconfig(img, &sd); |
- if (vp9_receive_raw_frame(ctx->cpi, lib_flags, |
+ // 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, |
&sd, dst_time_stamp, dst_end_time_stamp)) { |
VP9_COMP *cpi = (VP9_COMP *)ctx->cpi; |
res = update_error_state(ctx, &cpi->common.error); |
@@ -874,7 +838,6 @@ |
cx_data = ctx->cx_data; |
cx_data_sz = ctx->cx_data_sz; |
- lib_flags = 0; |
/* Any pending invisible frames? */ |
if (ctx->pending_cx_data) { |
@@ -902,7 +865,12 @@ |
VP9_COMP *const cpi = (VP9_COMP *)ctx->cpi; |
// Pack invisible frames with the next visible frame |
- if (cpi->common.show_frame == 0) { |
+ if (cpi->common.show_frame == 0 |
+#ifdef CONFIG_SPATIAL_SVC |
+ || (cpi->use_svc && cpi->svc.number_temporal_layers == 1 && |
+ cpi->svc.spatial_layer_id < cpi->svc.number_spatial_layers - 1) |
+#endif |
+ ) { |
if (ctx->pending_cx_data == 0) |
ctx->pending_cx_data = cx_data; |
ctx->pending_cx_data_sz += size; |
@@ -925,7 +893,12 @@ |
/ ctx->cfg.g_timebase.num / 10000000); |
pkt.data.frame.flags = lib_flags << 16; |
- if (lib_flags & FRAMEFLAGS_KEY) |
+ if (lib_flags & FRAMEFLAGS_KEY |
+#ifdef CONFIG_SPATIAL_SVC |
+ || (cpi->use_svc && cpi->svc.number_temporal_layers == 1 && |
+ cpi->svc.layer_context[0].is_key_frame) |
+#endif |
+ ) |
pkt.data.frame.flags |= VPX_FRAME_IS_KEY; |
if (cpi->common.show_frame == 0) { |
@@ -1165,25 +1138,20 @@ |
VP9_COMP *const cpi = ctx->cpi; |
vpx_svc_parameters_t *const params = va_arg(args, vpx_svc_parameters_t *); |
- if (params == NULL) |
+ if (params == NULL || params->spatial_layer < 0 || |
+ params->spatial_layer >= cpi->svc.number_spatial_layers) |
return VPX_CODEC_INVALID_PARAM; |
- cpi->svc.spatial_layer_id = params->spatial_layer; |
- cpi->svc.temporal_layer_id = params->temporal_layer; |
+ if (params->spatial_layer == 0) { |
+ int i; |
+ for (i = 0; i < cpi->svc.number_spatial_layers; ++i) { |
+ cpi->svc.layer_context[i].svc_params_received.spatial_layer = -1; |
+ } |
+ } |
- cpi->lst_fb_idx = params->lst_fb_idx; |
- cpi->gld_fb_idx = params->gld_fb_idx; |
- cpi->alt_fb_idx = params->alt_fb_idx; |
+ cpi->svc.layer_context[params->spatial_layer].svc_params_received = |
+ *params; |
- if (vp9_set_size_literal(ctx->cpi, params->width, params->height) != 0) |
- return VPX_CODEC_INVALID_PARAM; |
- |
- ctx->cfg.rc_max_quantizer = params->max_quantizer; |
- ctx->cfg.rc_min_quantizer = params->min_quantizer; |
- |
- set_encoder_config(&ctx->oxcf, &ctx->cfg, &ctx->extra_cfg); |
- vp9_change_config(ctx->cpi, &ctx->oxcf); |
- |
return VPX_CODEC_OK; |
} |