diff --git a/README.md b/README.md index fc928e8e..fb18b83d 100644 --- a/README.md +++ b/README.md @@ -119,7 +119,10 @@ Video structure: - 16: B-frame pyramid of length 16 - lp-: Low-delay P/B-frame GOP (e.g. lp-g8d4t2, see README) - --intra-qp-offset : QP offset for intra frames [-51..51] [0] + --intra-qp-offset : QP offset for intra frames [-51..51] [auto] + - N: Set QP offset to N. + - auto: Select offset automatically based + on GOP length. --(no-)open-gop : Use open GOP configuration. [enabled] --cqmfile : Read custom quantization matrices from a file. --scaling-list : Set scaling list mode. [off] @@ -335,7 +338,6 @@ where the names have been abbreviated to fit the layout in GitHub. | pu-depth-inter | 2-3 | 2-3 | 1-3 | 1-3 | 1-3 | 0-3 | 0-3 | 0-3 | 0-3 | 0-3 | | me | hexbs | hexbs | hexbs | hexbs | hexbs | hexbs | hexbs | hexbs | tz | tz | | gop | g4d4t1| g4d4t1| g4d4t1| g4d4t1| g4d4t1| 8 | 8 | 8 | 16 | 16 | -| intra-qp-offset | 0 | 0 | 0 | 0 | 0 | -2 | -2 | -2 | -3 | -3 | | ref | 1 | 1 | 1 | 1 | 2 | 4 | 4 | 4 | 4 | 4 | | bipred | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 1 | | deblock | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | diff --git a/configure.ac b/configure.ac index 9ff11d29..2e8e4e42 100644 --- a/configure.ac +++ b/configure.ac @@ -22,7 +22,7 @@ AC_CONFIG_SRCDIR([src/encmain.c]) # - Increment when making new releases and major or minor was not changed since last release. # # Here is a somewhat sane guide to lib versioning: http://apr.apache.org/versioning.html -ver_major=5 +ver_major=6 ver_minor=1 ver_release=0 diff --git a/doc/kvazaar.1 b/doc/kvazaar.1 index abb6c22f..06bc7c34 100644 --- a/doc/kvazaar.1 +++ b/doc/kvazaar.1 @@ -122,7 +122,10 @@ GOP structure [lp\-g4d3t1] \- lp\-: Low\-delay P/B\-frame GOP (e.g. lp\-g8d4t2, see README) .TP -\fB\-\-intra\-qp\-offset : QP offset for intra frames [\-51..51] [0] +\fB\-\-intra\-qp\-offset : QP offset for intra frames [\-51..51] [auto] + \- N: Set QP offset to N. + \- auto: Select offset automatically based + on GOP length. .TP \fB\-\-(no\-)open\-gop Use open GOP configuration. [enabled] diff --git a/src/cfg.c b/src/cfg.c index efc58db9..7434d7a0 100644 --- a/src/cfg.c +++ b/src/cfg.c @@ -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 = true; cfg->intra_period = 64; cfg->vps_period = 0; cfg->deblock_enable = 1; @@ -441,7 +442,7 @@ int kvz_config_parse(kvz_config *cfg, const char *name, const char *value) static const char * const scaling_list_names[] = { "off", "custom", "default", NULL }; static const char * const rc_algorithm_names[] = { "no-rc", "lambda", "oba", NULL }; - static const char * const preset_values[11][26*2] = { + static const char * const preset_values[11][25*2] = { { "ultrafast", @@ -450,7 +451,6 @@ int kvz_config_parse(kvz_config *cfg, const char *name, const char *value) "pu-depth-inter", "2-3", "me", "hexbs", "gop", "lp-g4d4t1", - "intra-qp-offset", "0", "ref", "1", "bipred", "0", "deblock", "0:0", @@ -479,7 +479,6 @@ int kvz_config_parse(kvz_config *cfg, const char *name, const char *value) "pu-depth-inter", "2-3", "me", "hexbs", "gop", "lp-g4d4t1", - "intra-qp-offset", "0", "ref", "1", "bipred", "0", "deblock", "0:0", @@ -508,7 +507,6 @@ int kvz_config_parse(kvz_config *cfg, const char *name, const char *value) "pu-depth-inter", "1-3", "me", "hexbs", "gop", "lp-g4d4t1", - "intra-qp-offset", "0", "ref", "1", "bipred", "0", "deblock", "0:0", @@ -537,7 +535,6 @@ int kvz_config_parse(kvz_config *cfg, const char *name, const char *value) "pu-depth-inter", "1-3", "me", "hexbs", "gop", "lp-g4d4t1", - "intra-qp-offset", "0", "ref", "1", "bipred", "0", "deblock", "0:0", @@ -566,7 +563,6 @@ int kvz_config_parse(kvz_config *cfg, const char *name, const char *value) "pu-depth-inter", "1-3", "me", "hexbs", "gop", "lp-g4d4t1", - "intra-qp-offset", "0", "ref", "2", "bipred", "0", "deblock", "0:0", @@ -595,7 +591,6 @@ int kvz_config_parse(kvz_config *cfg, const char *name, const char *value) "pu-depth-inter", "0-3", "me", "hexbs", "gop", "8", - "intra-qp-offset", "-2", "ref", "4", "bipred", "0", "deblock", "0:0", @@ -624,7 +619,6 @@ int kvz_config_parse(kvz_config *cfg, const char *name, const char *value) "pu-depth-inter", "0-3", "me", "hexbs", "gop", "8", - "intra-qp-offset", "-2", "ref", "4", "bipred", "1", "deblock", "0:0", @@ -653,7 +647,6 @@ int kvz_config_parse(kvz_config *cfg, const char *name, const char *value) "pu-depth-inter", "0-3", "me", "hexbs", "gop", "8", - "intra-qp-offset", "-2", "ref", "4", "bipred", "1", "deblock", "0:0", @@ -682,7 +675,6 @@ int kvz_config_parse(kvz_config *cfg, const char *name, const char *value) "pu-depth-inter", "0-3", "me", "tz", "gop", "16", - "intra-qp-offset", "-3", "ref", "4", "bipred", "1", "deblock", "0:0", @@ -711,7 +703,6 @@ int kvz_config_parse(kvz_config *cfg, const char *name, const char *value) "pu-depth-inter", "0-3", "me", "tz", "gop", "16", - "intra-qp-offset", "-3", "ref", "4", "bipred", "1", "deblock", "0:0", @@ -1024,6 +1015,12 @@ 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 { + cfg->intra_qp_offset_auto = false; + } } else if OPT("open-gop") { cfg->open_gop = (bool)atobool(value); diff --git a/src/cli.c b/src/cli.c index a628abc6..42bee56b 100644 --- a/src/cli.c +++ b/src/cli.c @@ -412,7 +412,10 @@ void print_help(void) " - 16: B-frame pyramid of length 16\n" " - lp-: Low-delay P/B-frame GOP\n" " (e.g. lp-g8d4t2, see README)\n" - " --intra-qp-offset : QP offset for intra frames [-51..51] [0]\n" + " --intra-qp-offset : QP offset for intra frames [-51..51] [auto]\n" + " - N: Set QP offset to N.\n" + " - auto: Select offset automatically based\n" + " on GOP length.\n" " --(no-)open-gop : Use open GOP configuration. [enabled]\n" " --cqmfile : Read custom quantization matrices from a file.\n" " --scaling-list : Set scaling list mode. [off]\n" diff --git a/src/encoder.c b/src/encoder.c index ffddfe02..b6c49a21 100644 --- a/src/encoder.c +++ b/src/encoder.c @@ -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; diff --git a/src/kvazaar.h b/src/kvazaar.h index 8792cbc6..0da5f1b6 100644 --- a/src/kvazaar.h +++ b/src/kvazaar.h @@ -387,6 +387,8 @@ typedef struct kvz_config /** \brief Offset to add to QP for intra frames */ int8_t intra_qp_offset; + /** \brief Select intra QP Offset based on GOP length */ + 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; diff --git a/tests/tsan_suppressions.txt b/tests/tsan_suppressions.txt index 96190e4b..d2f565b6 100644 --- a/tests/tsan_suppressions.txt +++ b/tests/tsan_suppressions.txt @@ -1 +1,3 @@ -race:kvz_eight_tap_filter_hor_8x1_avx2 \ No newline at end of file +race:kvz_eight_tap_filter_hor_8x1_avx2 +race:kvz_filter_hpel_blocks_hor_ver_luma_avx2 +race:kvz_eight_tap_filter_hor_avx2 \ No newline at end of file