diff --git a/README.md b/README.md index 72bd5e5e..6b6a8e82 100644 --- a/README.md +++ b/README.md @@ -194,6 +194,8 @@ Compression tools: - off: Don't terminate early. - on: Terminate early. - sensitive: Terminate even earlier. + --(no-)intra-rdo-et : Check intra modes in rdo stage only until + a zero coefficient CU is found. [disabled] --(no-)implicit-rdpcm : Implicit residual DPCM. Currently only supported with lossless coding. [disabled] --(no-)tmvp : Temporal motion vector prediction [enabled] @@ -300,6 +302,7 @@ where the names have been abbreviated to fit the layout in GitHub. | amp | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | | cu-split-termination | zero | zero | zero | zero | zero | zero | zero | zero | zero | off | | me-early-termination | sens. | sens. | sens. | sens. | sens. | on | on | off | off | off | +| intra-rdo-et | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | ## Kvazaar library diff --git a/configure.ac b/configure.ac index 78791a32..30ed62fb 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=0 +ver_minor=1 ver_release=0 # Prevents configure from adding a lot of defines to the CFLAGS diff --git a/src/cfg.c b/src/cfg.c index cfc2b88d..6ae668d4 100644 --- a/src/cfg.c +++ b/src/cfg.c @@ -109,6 +109,7 @@ int kvz_config_init(kvz_config *cfg) cfg->crypto_features = KVZ_CRYPTO_OFF; cfg->me_early_termination = 1; + cfg->intra_rdo_et = 0; cfg->input_format = KVZ_FORMAT_P420; cfg->input_bitdepth = 8; @@ -375,7 +376,7 @@ int kvz_config_parse(kvz_config *cfg, const char *name, const char *value) static const char * const sao_names[] = { "off", "edge", "band", "full", NULL }; - static const char * const preset_values[11][21*2] = { + static const char * const preset_values[11][22*2] = { { "ultrafast", "rd", "0", @@ -398,6 +399,7 @@ int kvz_config_parse(kvz_config *cfg, const char *name, const char *value) "amp", "0", "cu-split-termination", "zero", "me-early-termination", "sensitive", + "intra-rdo-et", "0", NULL }, { @@ -422,6 +424,7 @@ int kvz_config_parse(kvz_config *cfg, const char *name, const char *value) "amp", "0", "cu-split-termination", "zero", "me-early-termination", "sensitive", + "intra-rdo-et", "0", NULL }, { @@ -446,6 +449,7 @@ int kvz_config_parse(kvz_config *cfg, const char *name, const char *value) "amp", "0", "cu-split-termination", "zero", "me-early-termination", "sensitive", + "intra-rdo-et", "0", NULL }, { @@ -470,6 +474,7 @@ int kvz_config_parse(kvz_config *cfg, const char *name, const char *value) "amp", "0", "cu-split-termination", "zero", "me-early-termination", "sensitive", + "intra-rdo-et", "0", NULL }, { @@ -494,6 +499,7 @@ int kvz_config_parse(kvz_config *cfg, const char *name, const char *value) "amp", "0", "cu-split-termination", "zero", "me-early-termination", "sensitive", + "intra-rdo-et", "0", NULL }, { @@ -518,6 +524,7 @@ int kvz_config_parse(kvz_config *cfg, const char *name, const char *value) "amp", "0", "cu-split-termination", "zero", "me-early-termination", "on", + "intra-rdo-et", "0", NULL }, { @@ -542,6 +549,7 @@ int kvz_config_parse(kvz_config *cfg, const char *name, const char *value) "amp", "0", "cu-split-termination", "zero", "me-early-termination", "on", + "intra-rdo-et", "0", NULL }, { @@ -566,6 +574,7 @@ int kvz_config_parse(kvz_config *cfg, const char *name, const char *value) "amp", "0", "cu-split-termination", "zero", "me-early-termination", "off", + "intra-rdo-et", "0", NULL }, { @@ -590,6 +599,7 @@ int kvz_config_parse(kvz_config *cfg, const char *name, const char *value) "amp", "0", "cu-split-termination", "zero", "me-early-termination", "off", + "intra-rdo-et", "0", NULL }, { @@ -614,6 +624,7 @@ int kvz_config_parse(kvz_config *cfg, const char *name, const char *value) "amp", "1", "cu-split-termination", "off", "me-early-termination", "off", + "intra-rdo-et", "0", NULL }, { NULL } @@ -1032,6 +1043,8 @@ int kvz_config_parse(kvz_config *cfg, const char *name, const char *value) cfg->me_early_termination = mode; return result; } + else if OPT("intra-rdo-et") + cfg->intra_rdo_et = (bool)atobool(value); else if OPT("lossless") cfg->lossless = (bool)atobool(value); else if OPT("tmvp") { diff --git a/src/cli.c b/src/cli.c index deb5ba8d..f5435c96 100644 --- a/src/cli.c +++ b/src/cli.c @@ -110,6 +110,8 @@ static const struct option long_options[] = { { "crypto", required_argument, NULL, 0 }, { "key", required_argument, NULL, 0 }, { "me-early-termination",required_argument, NULL, 0 }, + { "intra-rdo-et", no_argument, NULL, 0 }, + { "no-intra-rdo-et", no_argument, NULL, 0 }, { "lossless", no_argument, NULL, 0 }, { "no-lossless", no_argument, NULL, 0 }, { "tmvp", no_argument, NULL, 0 }, @@ -469,6 +471,8 @@ void print_help(void) " - off: Don't terminate early.\n" " - on: Terminate early.\n" " - sensitive: Terminate even earlier.\n" + " --(no-)intra-rdo-et : Check intra modes in rdo stage only until\n" + " a zero coefficient CU is found. [disabled]\n" " --(no-)implicit-rdpcm : Implicit residual DPCM. Currently only supported\n" " with lossless coding. [disabled]\n" " --(no-)tmvp : Temporal motion vector prediction [enabled]\n" diff --git a/src/kvazaar.h b/src/kvazaar.h index b7f5e445..acc0a37d 100644 --- a/src/kvazaar.h +++ b/src/kvazaar.h @@ -323,6 +323,7 @@ typedef struct kvz_config uint8_t *optional_key; enum kvz_me_early_termination me_early_termination; /*!< \since 3.8.0 \brief Mode of me early termination. */ + int32_t intra_rdo_et; /*!< \since 4.1.0 \brief Use early termination in intra rdo. */ int32_t lossless; /*!< \brief Use lossless coding. */ diff --git a/src/search_intra.c b/src/search_intra.c index 46db40b6..9c31d95c 100644 --- a/src/search_intra.c +++ b/src/search_intra.c @@ -621,6 +621,12 @@ static int8_t search_intra_rdo(encoder_state_t * const state, double mode_cost = search_intra_trdepth(state, x_px, y_px, depth, tr_depth, modes[rdo_mode], MAX_INT, &pred_cu, lcu); costs[rdo_mode] += mode_cost; + + // Early termination if no coefficients has to be coded + if (state->encoder_control->cfg.intra_rdo_et && !cbf_is_set_any(pred_cu.cbf, depth)) { + modes_to_check = rdo_mode + 1; + break; + } } // Update order according to new costs