vp9 svc: Enable different speed setting for each spatial layer.

This change only affects 1 pass cbr svc mode.

Change-Id: If0da87bb200f7e7762755340c40c8157cc7a16ca
This commit is contained in:
jackychen 2016-07-13 15:58:11 -07:00 committed by JackyChen
parent 82070ae939
commit 8ce67d714a
6 changed files with 18 additions and 2 deletions

View File

@ -795,7 +795,9 @@ TEST_P(DatarateTestVP9Large, DenoiserOffOn) {
class DatarateOnePassCbrSvc : public ::libvpx_test::EncoderTest, class DatarateOnePassCbrSvc : public ::libvpx_test::EncoderTest,
public ::libvpx_test::CodecTestWith2Params<libvpx_test::TestMode, int> { public ::libvpx_test::CodecTestWith2Params<libvpx_test::TestMode, int> {
public: public:
DatarateOnePassCbrSvc() : EncoderTest(GET_PARAM(0)) {} DatarateOnePassCbrSvc() : EncoderTest(GET_PARAM(0)) {
memset(&svc_params_, 0, sizeof(svc_params_));
}
virtual ~DatarateOnePassCbrSvc() {} virtual ~DatarateOnePassCbrSvc() {}
protected: protected:
virtual void SetUp() { virtual void SetUp() {
@ -824,6 +826,10 @@ class DatarateOnePassCbrSvc : public ::libvpx_test::EncoderTest,
svc_params_.max_quantizers[i] = 63; svc_params_.max_quantizers[i] = 63;
svc_params_.min_quantizers[i] = 0; svc_params_.min_quantizers[i] = 0;
} }
svc_params_.speed_per_layer[0] = 5;
for (i = 1; i < VPX_SS_MAX_LAYERS; ++i) {
svc_params_.speed_per_layer[i] = 7;
}
encoder->Control(VP9E_SET_SVC, 1); encoder->Control(VP9E_SET_SVC, 1);
encoder->Control(VP9E_SET_SVC_PARAMETERS, &svc_params_); encoder->Control(VP9E_SET_SVC_PARAMETERS, &svc_params_);
encoder->Control(VP8E_SET_CPUUSED, speed_setting_); encoder->Control(VP8E_SET_CPUUSED, speed_setting_);

View File

@ -135,7 +135,7 @@ void vp9_init_layer_context(VP9_COMP *const cpi) {
CHECK_MEM_ERROR(cm, lc->consec_zero_mv, CHECK_MEM_ERROR(cm, lc->consec_zero_mv,
vpx_malloc(consec_zero_mv_size)); vpx_malloc(consec_zero_mv_size));
memset(lc->consec_zero_mv, 0, consec_zero_mv_size); memset(lc->consec_zero_mv, 0, consec_zero_mv_size);
} }
} }
} }
@ -293,6 +293,11 @@ void vp9_restore_layer_context(VP9_COMP *const cpi) {
cpi->twopass = lc->twopass; cpi->twopass = lc->twopass;
cpi->oxcf.target_bandwidth = lc->target_bandwidth; cpi->oxcf.target_bandwidth = lc->target_bandwidth;
cpi->alt_ref_source = lc->alt_ref_source; cpi->alt_ref_source = lc->alt_ref_source;
// Check if it is one_pass_cbr_svc mode and lc->speed > 0 (real-time mode
// does not use speed = 0).
if (is_one_pass_cbr_svc(cpi) && lc->speed > 0) {
cpi->oxcf.speed = lc->speed;
}
// Reset the frames_since_key and frames_to_key counters to their values // Reset the frames_since_key and frames_to_key counters to their values
// before the layer restore. Keep these defined for the stream (not layer). // before the layer restore. Keep these defined for the stream (not layer).
if (cpi->svc.number_temporal_layers > 1 || if (cpi->svc.number_temporal_layers > 1 ||

View File

@ -46,6 +46,7 @@ typedef struct {
signed char *map; signed char *map;
uint8_t *last_coded_q_map; uint8_t *last_coded_q_map;
uint8_t *consec_zero_mv; uint8_t *consec_zero_mv;
uint8_t speed;
} LAYER_CONTEXT; } LAYER_CONTEXT;
typedef struct { typedef struct {

View File

@ -1437,6 +1437,7 @@ static vpx_codec_err_t ctrl_set_svc_parameters(vpx_codec_alg_priv_t *ctx,
lc->min_q = params->min_quantizers[layer]; lc->min_q = params->min_quantizers[layer];
lc->scaling_factor_num = params->scaling_factor_num[sl]; lc->scaling_factor_num = params->scaling_factor_num[sl];
lc->scaling_factor_den = params->scaling_factor_den[sl]; lc->scaling_factor_den = params->scaling_factor_den[sl];
lc->speed = params->speed_per_layer[sl];
} }
} }

View File

@ -410,7 +410,9 @@ vpx_codec_err_t vpx_svc_init(SvcContext *svc_ctx, vpx_codec_ctx_t *codec_ctx,
for (sl = 0; sl < VPX_SS_MAX_LAYERS; ++sl) { for (sl = 0; sl < VPX_SS_MAX_LAYERS; ++sl) {
si->svc_params.scaling_factor_num[sl] = DEFAULT_SCALE_FACTORS_NUM[sl]; si->svc_params.scaling_factor_num[sl] = DEFAULT_SCALE_FACTORS_NUM[sl];
si->svc_params.scaling_factor_den[sl] = DEFAULT_SCALE_FACTORS_DEN[sl]; si->svc_params.scaling_factor_den[sl] = DEFAULT_SCALE_FACTORS_DEN[sl];
si->svc_params.speed_per_layer[sl] = svc_ctx->speed;
} }
for (tl = 0; tl < svc_ctx->temporal_layers; ++tl) { for (tl = 0; tl < svc_ctx->temporal_layers; ++tl) {
for (sl = 0; sl < svc_ctx->spatial_layers; ++sl) { for (sl = 0; sl < svc_ctx->spatial_layers; ++sl) {
i = sl * svc_ctx->temporal_layers + tl; i = sl * svc_ctx->temporal_layers + tl;

View File

@ -715,6 +715,7 @@ typedef struct vpx_svc_parameters {
int min_quantizers[VPX_MAX_LAYERS]; /**< Min Q for each layer */ int min_quantizers[VPX_MAX_LAYERS]; /**< Min Q for each layer */
int scaling_factor_num[VPX_MAX_LAYERS]; /**< Scaling factor-numerator */ int scaling_factor_num[VPX_MAX_LAYERS]; /**< Scaling factor-numerator */
int scaling_factor_den[VPX_MAX_LAYERS]; /**< Scaling factor-denominator */ int scaling_factor_den[VPX_MAX_LAYERS]; /**< Scaling factor-denominator */
int speed_per_layer[VPX_MAX_LAYERS]; /**< Speed setting for each sl */
int temporal_layering_mode; /**< Temporal layering mode */ int temporal_layering_mode; /**< Temporal layering mode */
} vpx_svc_extra_cfg_t; } vpx_svc_extra_cfg_t;