Add auto option to intra qp offset

This commit is contained in:
Jaakko Laitinen 2020-03-31 11:56:44 +03:00
parent 3eb07005a2
commit 740688c67d
3 changed files with 10 additions and 0 deletions

View file

@ -42,6 +42,7 @@ int kvz_config_init(kvz_config *cfg)
cfg->framerate_denom = 1;
cfg->qp = 22;
cfg->intra_qp_offset = 0;
cfg->intra_qp_offset_auto = false;
cfg->intra_period = 64;
cfg->vps_period = 0;
cfg->deblock_enable = 1;
@ -1024,6 +1025,10 @@ int kvz_config_parse(kvz_config *cfg, const char *name, const char *value)
}
else if OPT("intra-qp-offset") {
cfg->intra_qp_offset = atoi(value);
if( cfg->intra_qp_offset == 0 && !strcmp( value, "auto" ) )
{
cfg->intra_qp_offset_auto = true;
}
}
else if OPT("open-gop") {
cfg->open_gop = (bool)atobool(value);

View file

@ -243,6 +243,10 @@ encoder_control_t* kvz_encoder_control_init(const kvz_config *const cfg)
}
}
if( encoder->cfg.intra_qp_offset_auto ) {
encoder->cfg.intra_qp_offset = encoder->cfg.gop_len > 1 ? -kvz_math_ceil_log2( encoder->cfg.gop_len ) + 1 : 0;
}
// Disable GOP and QP offset for all-intra coding
if (encoder->cfg.intra_period == 1) {
encoder->cfg.gop_len = 0;

View file

@ -387,6 +387,7 @@ typedef struct kvz_config
/** \brief Offset to add to QP for intra frames */
int8_t intra_qp_offset;
uint8_t intra_qp_offset_auto;
/** \brief Minimum QP that uses CABAC for residual cost instead of a fast estimate. */
int8_t fast_residual_cost_limit;