Change GOP QP offset handling to match HM

Adds fields qp_model_scale and qp_model_offset to kvz_gop_config and
intra_qp_offset to kvz_config.
This commit is contained in:
Arttu Ylä-Outinen 2018-02-14 15:57:38 +02:00 committed by Ari Lemmetti
parent f37dcd5879
commit d757a832c2
3 changed files with 12 additions and 2 deletions

View file

@ -41,6 +41,7 @@ int kvz_config_init(kvz_config *cfg)
cfg->framerate_num = 25;
cfg->framerate_denom = 1;
cfg->qp = 22;
cfg->intra_qp_offset = -3;
cfg->intra_period = 64;
cfg->vps_period = 0;
cfg->deblock_enable = 1;

View file

@ -229,6 +229,8 @@ typedef struct kvz_gop_config {
int8_t ref_pos[16]; /*!< \brief reference picture offset list */
int8_t ref_neg_count;/*!< \brief Reference picture count */
int8_t ref_neg[16]; /*!< \brief reference picture offset list */
double qp_model_offset;
double qp_model_scale;
} kvz_gop_config;
/**
@ -372,6 +374,9 @@ typedef struct kvz_config
/** \brief Maximum steps that hexagonal and diagonal motion estimation can use. -1 to disable */
uint32_t me_max_steps;
/** \brief Offset to add to QP for intra frames */
int8_t intra_qp_offset;
/** \brief Minimum QP that uses CABAC for residual cost instead of a fast estimate. */
int8_t fast_residual_cost_limit;

View file

@ -241,9 +241,13 @@ void kvz_set_picture_lambda_and_qp(encoder_state_t * const state)
const int gop_len = ctrl->cfg.gop_len;
if (gop_len > 0 && state->frame->slicetype != KVZ_SLICE_I) {
state->frame->QP = CLIP_TO_QP(ctrl->cfg.qp + gop->qp_offset);
double qp = ctrl->cfg.qp;
qp += gop->qp_offset;
qp += CLIP(0.0, 3.0, qp * gop->qp_model_scale + gop->qp_model_offset);
state->frame->QP = CLIP_TO_QP((int)(qp + 0.5));
} else {
state->frame->QP = ctrl->cfg.qp;
state->frame->QP = CLIP_TO_QP(ctrl->cfg.qp + ctrl->cfg.intra_qp_offset);
}
state->frame->lambda = qp_to_lambda(state, state->frame->QP);