From 86c36a504dd7834e934707b86aa81ceb6384154c Mon Sep 17 00:00:00 2001 From: Minghai Shang Date: Tue, 4 Nov 2014 11:46:48 -0800 Subject: [PATCH] [spatial svc] Make spatial svc working for one pass rate control Change-Id: Ibd9114485c3d747f9d148f64f706bf873ea473ac --- examples/vp9_spatial_svc_encoder.c | 13 +++++++++++-- vp9/encoder/vp9_encoder.c | 4 ++-- vp9/encoder/vp9_encoder.h | 5 ++--- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/examples/vp9_spatial_svc_encoder.c b/examples/vp9_spatial_svc_encoder.c index 53ede94d8..a4a9edb2d 100644 --- a/examples/vp9_spatial_svc_encoder.c +++ b/examples/vp9_spatial_svc_encoder.c @@ -60,6 +60,11 @@ static const arg_def_t min_bitrate_arg = ARG_DEF(NULL, "min-bitrate", 1, "Minimum bitrate"); static const arg_def_t max_bitrate_arg = ARG_DEF(NULL, "max-bitrate", 1, "Maximum bitrate"); +static const arg_def_t lag_in_frame_arg = + ARG_DEF(NULL, "lag-in-frames", 1, "Number of frame to input before " + "generating any outputs"); +static const arg_def_t rc_end_usage_arg = + ARG_DEF(NULL, "rc-end-usage", 1, "0 - 3: VBR, CBR, CQ, Q"); #if CONFIG_VP9_HIGHBITDEPTH static const struct arg_enum_list bitdepth_enum[] = { @@ -80,11 +85,11 @@ static const arg_def_t *svc_args[] = { &timebase_arg, &bitrate_arg, &skip_frames_arg, &spatial_layers_arg, &kf_dist_arg, &scale_factors_arg, &passes_arg, &pass_arg, &fpf_name_arg, &min_q_arg, &max_q_arg, &min_bitrate_arg, - &max_bitrate_arg, &temporal_layers_arg, + &max_bitrate_arg, &temporal_layers_arg, &lag_in_frame_arg, #if CONFIG_VP9_HIGHBITDEPTH &bitdepth_arg, #endif - NULL + &rc_end_usage_arg, NULL }; static const uint32_t default_frames_to_skip = 0; @@ -207,6 +212,10 @@ static void parse_command_line(int argc, const char **argv_, min_bitrate = arg_parse_uint(&arg); } else if (arg_match(&arg, &max_bitrate_arg, argi)) { max_bitrate = arg_parse_uint(&arg); + } else if (arg_match(&arg, &lag_in_frame_arg, argi)) { + enc_cfg->g_lag_in_frames = arg_parse_uint(&arg); + } else if (arg_match(&arg, &rc_end_usage_arg, argi)) { + enc_cfg->rc_end_usage = arg_parse_uint(&arg); #if CONFIG_VP9_HIGHBITDEPTH } else if (arg_match(&arg, &bitdepth_arg, argi)) { enc_cfg->g_bit_depth = arg_parse_enum_or_int(&arg); diff --git a/vp9/encoder/vp9_encoder.c b/vp9/encoder/vp9_encoder.c index f8ff29993..8d37b8379 100644 --- a/vp9/encoder/vp9_encoder.c +++ b/vp9/encoder/vp9_encoder.c @@ -584,7 +584,7 @@ static void init_config(struct VP9_COMP *cpi, VP9EncoderConfig *oxcf) { if ((cpi->svc.number_temporal_layers > 1 && cpi->oxcf.rc_mode == VPX_CBR) || ((cpi->svc.number_temporal_layers > 1 || cpi->svc.number_spatial_layers > 1) && - cpi->oxcf.pass == 2)) { + cpi->oxcf.pass != 1)) { vp9_init_layer_context(cpi); } @@ -1285,7 +1285,7 @@ void vp9_change_config(struct VP9_COMP *cpi, const VP9EncoderConfig *oxcf) { cpi->oxcf.rc_mode == VPX_CBR) || ((cpi->svc.number_temporal_layers > 1 || cpi->svc.number_spatial_layers > 1) && - cpi->oxcf.pass == 2)) { + cpi->oxcf.pass != 1)) { vp9_update_layer_context_change_config(cpi, (int)cpi->oxcf.target_bandwidth); } diff --git a/vp9/encoder/vp9_encoder.h b/vp9/encoder/vp9_encoder.h index 0e112f2ff..f0c05430a 100644 --- a/vp9/encoder/vp9_encoder.h +++ b/vp9/encoder/vp9_encoder.h @@ -531,9 +531,8 @@ void vp9_apply_encoding_flags(VP9_COMP *cpi, vpx_enc_frame_flags_t flags); static INLINE int is_two_pass_svc(const struct VP9_COMP *const cpi) { return cpi->use_svc && - (cpi->svc.number_temporal_layers > 1 || - cpi->svc.number_spatial_layers > 1) && - (cpi->oxcf.pass == 1 || cpi->oxcf.pass == 2); + ((cpi->svc.number_spatial_layers > 1) || + (cpi->svc.number_temporal_layers > 1 && cpi->oxcf.pass != 0)); } static INLINE int is_altref_enabled(const VP9_COMP *const cpi) {