diff --git a/README.md b/README.md index bc1c90d6..d5f40c6a 100644 --- a/README.md +++ b/README.md @@ -173,6 +173,8 @@ Compression tools: chroma mode search. --(no-)mv-rdo : Rate-distortion optimized motion vector costs [disabled] + --(no-)zero-coeff-rdo : If a CU is set inter, check if forcing zero + residual improves the RD cost. [enabled] --(no-)full-intra-search : Try all intra modes during rough search. [disabled] --(no-)transform-skip : Try transform skip [disabled] diff --git a/configure.ac b/configure.ac index d3a17856..3ab33012 100644 --- a/configure.ac +++ b/configure.ac @@ -23,7 +23,7 @@ AC_CONFIG_SRCDIR([src/encmain.c]) # # Here is a somewhat sane guide to lib versioning: http://apr.apache.org/versioning.html ver_major=4 -ver_minor=2 +ver_minor=3 ver_release=0 # Prevents configure from adding a lot of defines to the CFLAGS diff --git a/doc/kvazaar.1 b/doc/kvazaar.1 index 09c4135f..285c2b83 100644 --- a/doc/kvazaar.1 +++ b/doc/kvazaar.1 @@ -1,4 +1,4 @@ -.TH KVAZAAR "1" "January 2020" "kvazaar v1.3.0" "User Commands" +.TH KVAZAAR "1" "February 2020" "kvazaar v1.3.0" "User Commands" .SH NAME kvazaar \- open source HEVC encoder .SH SYNOPSIS @@ -217,6 +217,10 @@ Intra mode search complexity [0] Rate\-distortion optimized motion vector costs [disabled] .TP +\fB\-\-(no\-)zero\-coeff\-rdo +If a CU is set inter, check if forcing zero +residual improves the RD cost. [enabled] +.TP \fB\-\-(no\-)full\-intra\-search Try all intra modes during rough search. [disabled] diff --git a/src/cfg.c b/src/cfg.c index 3fa28477..d044a124 100644 --- a/src/cfg.c +++ b/src/cfg.c @@ -147,6 +147,8 @@ int kvz_config_init(kvz_config *cfg) cfg->partial_coding.startCTU_y = 0; cfg->partial_coding.fullWidth = 0; cfg->partial_coding.fullHeight = 0; + + cfg->zero_coeff_rdo = true; return 1; } @@ -1284,6 +1286,9 @@ int kvz_config_parse(kvz_config *cfg, const char *name, const char *value) cfg->partial_coding.fullWidth = fullWidth; cfg->partial_coding.fullHeight = fullHeight; } + else if OPT("zero-coeff-rdo") { + cfg->zero_coeff_rdo = (bool)atobool(value); + } else { return 0; } diff --git a/src/cli.c b/src/cli.c index 00f4ed24..ffbdf3c8 100644 --- a/src/cli.c +++ b/src/cli.c @@ -139,6 +139,8 @@ static const struct option long_options[] = { { "no-early-skip", no_argument, NULL, 0 }, { "ml-pu-depth-intra", no_argument, NULL, 0 }, { "partial-coding", required_argument, NULL, 0 }, + { "zero-coeff-rdo", no_argument, NULL, 0 }, + { "no-zero-coeff-rdo", no_argument, NULL, 0 }, {0, 0, 0, 0} }; @@ -459,6 +461,8 @@ void print_help(void) " chroma mode search.\n" " --(no-)mv-rdo : Rate-distortion optimized motion vector costs\n" " [disabled]\n" + " --(no-)zero-coeff-rdo : If a CU is set inter, check if forcing zero\n" + " residual is improves the RD cost. [enabled]\n" " --(no-)full-intra-search : Try all intra modes during rough search.\n" " [disabled]\n" " --(no-)transform-skip : Try transform skip [disabled]\n" diff --git a/src/kvazaar.h b/src/kvazaar.h index 18d04cad..7d529846 100644 --- a/src/kvazaar.h +++ b/src/kvazaar.h @@ -401,6 +401,9 @@ typedef struct kvz_config uint16_t fullHeight; } partial_coding; + /** \brief Always consider CU without any quantized residual */ + uint8_t zero_coeff_rdo; + } kvz_config; /** diff --git a/src/search.c b/src/search.c index eccd6239..4673b3a6 100644 --- a/src/search.c +++ b/src/search.c @@ -625,7 +625,7 @@ static double search_cu(encoder_state_t * const state, int x, int y, int depth, const bool has_chroma = state->encoder_control->chroma_format != KVZ_CSP_400; kvz_inter_recon_cu(state, lcu, x, y, cu_width, true, has_chroma); - if (!ctrl->cfg.lossless && !ctrl->cfg.rdoq_enable) { + if (ctrl->cfg.zero_coeff_rdo && !ctrl->cfg.lossless && !ctrl->cfg.rdoq_enable) { //Calculate cost for zero coeffs inter_zero_coeff_cost = cu_zero_coeff_cost(state, work_tree, x, y, depth) + inter_bitcost * state->lambda; @@ -668,7 +668,7 @@ static double search_cu(encoder_state_t * const state, int x, int y, int depth, cost += mode_bits * state->lambda; - if (inter_zero_coeff_cost <= cost) { + if (ctrl->cfg.zero_coeff_rdo && inter_zero_coeff_cost <= cost) { cost = inter_zero_coeff_cost; // Restore saved pixels from lower level of the working tree.