Extend --auto-alt-ref so it can enable multi-alt ref.

Extend --auto-alt-ref from parameter so we can use it to
turn multi-arf on and off from the command line.

For now the range is 0-off, 1-on, 2-multi-arf on.

Rename play_alternate to enable_auto_arf

Change-Id: Id7b64407cfbe76ba0090a83b588a03e22a240386
This commit is contained in:
Paul Wilkins 2014-10-20 12:05:17 +01:00
Родитель 9626a0cb62
Коммит 6f0ae3a2d1
5 изменённых файлов: 24 добавлений и 34 удалений

Просмотреть файл

@ -29,7 +29,7 @@ static INLINE int vp9_preserve_existing_gf(VP9_COMP *cpi) {
(is_two_pass_svc(cpi) && (is_two_pass_svc(cpi) &&
cpi->svc.spatial_layer_id == 0 && cpi->svc.spatial_layer_id == 0 &&
cpi->svc.layer_context[0].gold_ref_idx >=0 && cpi->svc.layer_context[0].gold_ref_idx >=0 &&
cpi->oxcf.ss_play_alternate[0])); cpi->oxcf.ss_enable_auto_arf[0]));
} }
#ifdef __cplusplus #ifdef __cplusplus

Просмотреть файл

@ -1436,25 +1436,6 @@ VP9_COMP *vp9_create_compressor(VP9EncoderConfig *oxcf) {
cpi->refresh_alt_ref_frame = 0; cpi->refresh_alt_ref_frame = 0;
// Note that at the moment multi_arf will not work with svc.
// For the current check in all the execution paths are defaulted to 0
// pending further tuning and testing. The code is left in place here
// as a place holder in regard to the required paths.
cpi->multi_arf_last_grp_enabled = 0;
if (oxcf->pass == 2) {
if (cpi->use_svc) {
cpi->multi_arf_allowed = 0;
cpi->multi_arf_enabled = 0;
} else {
// Disable by default for now.
cpi->multi_arf_allowed = 0;
cpi->multi_arf_enabled = 0;
}
} else {
cpi->multi_arf_allowed = 0;
cpi->multi_arf_enabled = 0;
}
cpi->b_calculate_psnr = CONFIG_INTERNAL_STATS; cpi->b_calculate_psnr = CONFIG_INTERNAL_STATS;
#if CONFIG_INTERNAL_STATS #if CONFIG_INTERNAL_STATS
cpi->b_calculate_ssimg = 0; cpi->b_calculate_ssimg = 0;
@ -3431,6 +3412,16 @@ int vp9_get_compressed_data(VP9_COMP *cpi, unsigned int *frame_flags,
vp9_set_high_precision_mv(cpi, ALTREF_HIGH_PRECISION_MV); vp9_set_high_precision_mv(cpi, ALTREF_HIGH_PRECISION_MV);
// Is multi-arf enabled.
// Note that at the moment multi_arf is only configured for 2 pass VBR and
// will not work properly with svc.
if ((oxcf->pass == 2) && !cpi->use_svc &&
(cpi->oxcf.enable_auto_arf > 1) && (cpi->oxcf.rc_mode == VPX_VBR))
cpi->multi_arf_allowed = 1;
else
cpi->multi_arf_allowed = 0;
cpi->multi_arf_last_grp_enabled = 0;
// Normal defaults // Normal defaults
cm->reset_frame_context = 0; cm->reset_frame_context = 0;
cm->refresh_frame_context = 1; cm->refresh_frame_context = 1;
@ -3456,7 +3447,7 @@ int vp9_get_compressed_data(VP9_COMP *cpi, unsigned int *frame_flags,
int i; int i;
// Reference a hidden frame from a lower layer // Reference a hidden frame from a lower layer
for (i = cpi->svc.spatial_layer_id - 1; i >= 0; --i) { for (i = cpi->svc.spatial_layer_id - 1; i >= 0; --i) {
if (oxcf->ss_play_alternate[i]) { if (oxcf->ss_enable_auto_arf[i]) {
cpi->gld_fb_idx = cpi->svc.layer_context[i].alt_ref_idx; cpi->gld_fb_idx = cpi->svc.layer_context[i].alt_ref_idx;
break; break;
} }

Просмотреть файл

@ -178,13 +178,12 @@ typedef struct VP9EncoderConfig {
int ts_number_layers; // Number of temporal layers. int ts_number_layers; // Number of temporal layers.
// Bitrate allocation for spatial layers. // Bitrate allocation for spatial layers.
int ss_target_bitrate[VPX_SS_MAX_LAYERS]; int ss_target_bitrate[VPX_SS_MAX_LAYERS];
int ss_play_alternate[VPX_SS_MAX_LAYERS]; int ss_enable_auto_arf[VPX_SS_MAX_LAYERS];
// Bitrate allocation (CBR mode) and framerate factor, for temporal layers. // Bitrate allocation (CBR mode) and framerate factor, for temporal layers.
int ts_target_bitrate[VPX_TS_MAX_LAYERS]; int ts_target_bitrate[VPX_TS_MAX_LAYERS];
int ts_rate_decimator[VPX_TS_MAX_LAYERS]; int ts_rate_decimator[VPX_TS_MAX_LAYERS];
// these parameters aren't to be used in final build don't use!!! int enable_auto_arf;
int play_alternate;
int encode_breakout; // early breakout : for video conf recommend 800 int encode_breakout; // early breakout : for video conf recommend 800
@ -511,9 +510,9 @@ static INLINE int is_two_pass_svc(const struct VP9_COMP *const cpi) {
static INLINE int is_altref_enabled(const VP9_COMP *const cpi) { static INLINE int is_altref_enabled(const VP9_COMP *const cpi) {
return cpi->oxcf.mode != REALTIME && cpi->oxcf.lag_in_frames > 0 && return cpi->oxcf.mode != REALTIME && cpi->oxcf.lag_in_frames > 0 &&
(cpi->oxcf.play_alternate && (cpi->oxcf.enable_auto_arf &&
(!is_two_pass_svc(cpi) || (!is_two_pass_svc(cpi) ||
cpi->oxcf.ss_play_alternate[cpi->svc.spatial_layer_id])); cpi->oxcf.ss_enable_auto_arf[cpi->svc.spatial_layer_id]));
} }
static INLINE void set_ref_ptrs(VP9_COMMON *cm, MACROBLOCKD *xd, static INLINE void set_ref_ptrs(VP9_COMMON *cm, MACROBLOCKD *xd,

Просмотреть файл

@ -85,7 +85,7 @@ void vp9_init_layer_context(VP9_COMP *const cpi) {
oxcf->best_allowed_q) / 2; oxcf->best_allowed_q) / 2;
lrc->avg_frame_qindex[INTER_FRAME] = (oxcf->worst_allowed_q + lrc->avg_frame_qindex[INTER_FRAME] = (oxcf->worst_allowed_q +
oxcf->best_allowed_q) / 2; oxcf->best_allowed_q) / 2;
if (oxcf->ss_play_alternate[layer]) if (oxcf->ss_enable_auto_arf[layer])
lc->alt_ref_idx = alt_ref_idx++; lc->alt_ref_idx = alt_ref_idx++;
else else
lc->alt_ref_idx = -1; lc->alt_ref_idx = -1;
@ -305,7 +305,7 @@ int vp9_svc_start_frame(VP9_COMP *const cpi) {
cpi->ref_frame_flags &= (~VP9_LAST_FLAG & ~VP9_ALT_FLAG); cpi->ref_frame_flags &= (~VP9_LAST_FLAG & ~VP9_ALT_FLAG);
} }
} else { } else {
if (cpi->oxcf.ss_play_alternate[cpi->svc.spatial_layer_id]) { if (cpi->oxcf.ss_enable_auto_arf[cpi->svc.spatial_layer_id]) {
cpi->alt_fb_idx = lc->alt_ref_idx; cpi->alt_fb_idx = lc->alt_ref_idx;
if (!lc->has_alt_frame) if (!lc->has_alt_frame)
cpi->ref_frame_flags &= (~VP9_ALT_FLAG); cpi->ref_frame_flags &= (~VP9_ALT_FLAG);
@ -317,7 +317,7 @@ int vp9_svc_start_frame(VP9_COMP *const cpi) {
LAYER_CONTEXT *lc_lower = LAYER_CONTEXT *lc_lower =
&cpi->svc.layer_context[cpi->svc.spatial_layer_id - 1]; &cpi->svc.layer_context[cpi->svc.spatial_layer_id - 1];
if (cpi->oxcf.ss_play_alternate[cpi->svc.spatial_layer_id - 1] && if (cpi->oxcf.ss_enable_auto_arf[cpi->svc.spatial_layer_id - 1] &&
lc_lower->alt_ref_source != NULL) lc_lower->alt_ref_source != NULL)
cpi->alt_fb_idx = lc_lower->alt_ref_idx; cpi->alt_fb_idx = lc_lower->alt_ref_idx;
else if (cpi->svc.spatial_layer_id >= 2) else if (cpi->svc.spatial_layer_id >= 2)

Просмотреть файл

@ -202,7 +202,7 @@ static vpx_codec_err_t validate_config(vpx_codec_alg_priv_t *ctx,
ERROR("kf_min_dist not supported in auto mode, use 0 " ERROR("kf_min_dist not supported in auto mode, use 0 "
"or kf_max_dist instead."); "or kf_max_dist instead.");
RANGE_CHECK_BOOL(extra_cfg, enable_auto_alt_ref); RANGE_CHECK(extra_cfg, enable_auto_alt_ref, 0, 2);
RANGE_CHECK(extra_cfg, cpu_used, -16, 16); RANGE_CHECK(extra_cfg, cpu_used, -16, 16);
RANGE_CHECK_HI(extra_cfg, noise_sensitivity, 6); RANGE_CHECK_HI(extra_cfg, noise_sensitivity, 6);
RANGE_CHECK(extra_cfg, tile_columns, 0, 6); RANGE_CHECK(extra_cfg, tile_columns, 0, 6);
@ -412,7 +412,7 @@ static vpx_codec_err_t set_encoder_config(
oxcf->speed = abs(extra_cfg->cpu_used); oxcf->speed = abs(extra_cfg->cpu_used);
oxcf->encode_breakout = extra_cfg->static_thresh; oxcf->encode_breakout = extra_cfg->static_thresh;
oxcf->play_alternate = extra_cfg->enable_auto_alt_ref; oxcf->enable_auto_arf = extra_cfg->enable_auto_alt_ref;
oxcf->noise_sensitivity = extra_cfg->noise_sensitivity; oxcf->noise_sensitivity = extra_cfg->noise_sensitivity;
oxcf->sharpness = extra_cfg->sharpness; oxcf->sharpness = extra_cfg->sharpness;
@ -445,13 +445,13 @@ static vpx_codec_err_t set_encoder_config(
for (i = 0; i < VPX_SS_MAX_LAYERS; ++i) { for (i = 0; i < VPX_SS_MAX_LAYERS; ++i) {
oxcf->ss_target_bitrate[i] = 1000 * cfg->ss_target_bitrate[i]; oxcf->ss_target_bitrate[i] = 1000 * cfg->ss_target_bitrate[i];
#if CONFIG_SPATIAL_SVC #if CONFIG_SPATIAL_SVC
oxcf->ss_play_alternate[i] = cfg->ss_enable_auto_alt_ref[i]; oxcf->ss_enable_auto_arf[i] = cfg->ss_enable_auto_alt_ref[i];
#endif #endif
} }
} else if (oxcf->ss_number_layers == 1) { } else if (oxcf->ss_number_layers == 1) {
oxcf->ss_target_bitrate[0] = (int)oxcf->target_bandwidth; oxcf->ss_target_bitrate[0] = (int)oxcf->target_bandwidth;
#if CONFIG_SPATIAL_SVC #if CONFIG_SPATIAL_SVC
oxcf->ss_play_alternate[0] = extra_cfg->enable_auto_alt_ref; oxcf->ss_enable_auto_arf[0] = extra_cfg->enable_auto_alt_ref;
#endif #endif
} }
@ -493,7 +493,7 @@ static vpx_codec_err_t set_encoder_config(
printf("two_pass_vbrmin_section: %d\n", oxcf->two_pass_vbrmin_section); printf("two_pass_vbrmin_section: %d\n", oxcf->two_pass_vbrmin_section);
printf("two_pass_vbrmax_section: %d\n", oxcf->two_pass_vbrmax_section); printf("two_pass_vbrmax_section: %d\n", oxcf->two_pass_vbrmax_section);
printf("lag_in_frames: %d\n", oxcf->lag_in_frames); printf("lag_in_frames: %d\n", oxcf->lag_in_frames);
printf("play_alternate: %d\n", oxcf->play_alternate); printf("enable_auto_arf: %d\n", oxcf->enable_auto_arf);
printf("Version: %d\n", oxcf->Version); printf("Version: %d\n", oxcf->Version);
printf("encode_breakout: %d\n", oxcf->encode_breakout); printf("encode_breakout: %d\n", oxcf->encode_breakout);
printf("error resilient: %d\n", oxcf->error_resilient_mode); printf("error resilient: %d\n", oxcf->error_resilient_mode);