Add early termination for intra rdo when a zero coefficient block is found.

This commit is contained in:
Ari Lemmetti 2018-04-13 17:54:11 +03:00
parent 492529fb7a
commit 4fb1c16c61
6 changed files with 29 additions and 2 deletions

View file

@ -194,6 +194,8 @@ Compression tools:
- off: Don't terminate early. - off: Don't terminate early.
- on: Terminate early. - on: Terminate early.
- sensitive: Terminate even earlier. - 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 --(no-)implicit-rdpcm : Implicit residual DPCM. Currently only supported
with lossless coding. [disabled] with lossless coding. [disabled]
--(no-)tmvp : Temporal motion vector prediction [enabled] --(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 | | amp | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 |
| cu-split-termination | zero | zero | zero | zero | zero | zero | zero | zero | zero | off | | 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 | | 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 ## Kvazaar library

View file

@ -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 # Here is a somewhat sane guide to lib versioning: http://apr.apache.org/versioning.html
ver_major=4 ver_major=4
ver_minor=0 ver_minor=1
ver_release=0 ver_release=0
# Prevents configure from adding a lot of defines to the CFLAGS # Prevents configure from adding a lot of defines to the CFLAGS

View file

@ -109,6 +109,7 @@ int kvz_config_init(kvz_config *cfg)
cfg->crypto_features = KVZ_CRYPTO_OFF; cfg->crypto_features = KVZ_CRYPTO_OFF;
cfg->me_early_termination = 1; cfg->me_early_termination = 1;
cfg->intra_rdo_et = 0;
cfg->input_format = KVZ_FORMAT_P420; cfg->input_format = KVZ_FORMAT_P420;
cfg->input_bitdepth = 8; 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 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", "ultrafast",
"rd", "0", "rd", "0",
@ -398,6 +399,7 @@ int kvz_config_parse(kvz_config *cfg, const char *name, const char *value)
"amp", "0", "amp", "0",
"cu-split-termination", "zero", "cu-split-termination", "zero",
"me-early-termination", "sensitive", "me-early-termination", "sensitive",
"intra-rdo-et", "0",
NULL NULL
}, },
{ {
@ -422,6 +424,7 @@ int kvz_config_parse(kvz_config *cfg, const char *name, const char *value)
"amp", "0", "amp", "0",
"cu-split-termination", "zero", "cu-split-termination", "zero",
"me-early-termination", "sensitive", "me-early-termination", "sensitive",
"intra-rdo-et", "0",
NULL NULL
}, },
{ {
@ -446,6 +449,7 @@ int kvz_config_parse(kvz_config *cfg, const char *name, const char *value)
"amp", "0", "amp", "0",
"cu-split-termination", "zero", "cu-split-termination", "zero",
"me-early-termination", "sensitive", "me-early-termination", "sensitive",
"intra-rdo-et", "0",
NULL NULL
}, },
{ {
@ -470,6 +474,7 @@ int kvz_config_parse(kvz_config *cfg, const char *name, const char *value)
"amp", "0", "amp", "0",
"cu-split-termination", "zero", "cu-split-termination", "zero",
"me-early-termination", "sensitive", "me-early-termination", "sensitive",
"intra-rdo-et", "0",
NULL NULL
}, },
{ {
@ -494,6 +499,7 @@ int kvz_config_parse(kvz_config *cfg, const char *name, const char *value)
"amp", "0", "amp", "0",
"cu-split-termination", "zero", "cu-split-termination", "zero",
"me-early-termination", "sensitive", "me-early-termination", "sensitive",
"intra-rdo-et", "0",
NULL NULL
}, },
{ {
@ -518,6 +524,7 @@ int kvz_config_parse(kvz_config *cfg, const char *name, const char *value)
"amp", "0", "amp", "0",
"cu-split-termination", "zero", "cu-split-termination", "zero",
"me-early-termination", "on", "me-early-termination", "on",
"intra-rdo-et", "0",
NULL NULL
}, },
{ {
@ -542,6 +549,7 @@ int kvz_config_parse(kvz_config *cfg, const char *name, const char *value)
"amp", "0", "amp", "0",
"cu-split-termination", "zero", "cu-split-termination", "zero",
"me-early-termination", "on", "me-early-termination", "on",
"intra-rdo-et", "0",
NULL NULL
}, },
{ {
@ -566,6 +574,7 @@ int kvz_config_parse(kvz_config *cfg, const char *name, const char *value)
"amp", "0", "amp", "0",
"cu-split-termination", "zero", "cu-split-termination", "zero",
"me-early-termination", "off", "me-early-termination", "off",
"intra-rdo-et", "0",
NULL NULL
}, },
{ {
@ -590,6 +599,7 @@ int kvz_config_parse(kvz_config *cfg, const char *name, const char *value)
"amp", "0", "amp", "0",
"cu-split-termination", "zero", "cu-split-termination", "zero",
"me-early-termination", "off", "me-early-termination", "off",
"intra-rdo-et", "0",
NULL NULL
}, },
{ {
@ -614,6 +624,7 @@ int kvz_config_parse(kvz_config *cfg, const char *name, const char *value)
"amp", "1", "amp", "1",
"cu-split-termination", "off", "cu-split-termination", "off",
"me-early-termination", "off", "me-early-termination", "off",
"intra-rdo-et", "0",
NULL NULL
}, },
{ NULL } { NULL }
@ -1032,6 +1043,8 @@ int kvz_config_parse(kvz_config *cfg, const char *name, const char *value)
cfg->me_early_termination = mode; cfg->me_early_termination = mode;
return result; return result;
} }
else if OPT("intra-rdo-et")
cfg->intra_rdo_et = (bool)atobool(value);
else if OPT("lossless") else if OPT("lossless")
cfg->lossless = (bool)atobool(value); cfg->lossless = (bool)atobool(value);
else if OPT("tmvp") { else if OPT("tmvp") {

View file

@ -110,6 +110,8 @@ static const struct option long_options[] = {
{ "crypto", required_argument, NULL, 0 }, { "crypto", required_argument, NULL, 0 },
{ "key", required_argument, NULL, 0 }, { "key", required_argument, NULL, 0 },
{ "me-early-termination",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 }, { "lossless", no_argument, NULL, 0 },
{ "no-lossless", no_argument, NULL, 0 }, { "no-lossless", no_argument, NULL, 0 },
{ "tmvp", no_argument, NULL, 0 }, { "tmvp", no_argument, NULL, 0 },
@ -469,6 +471,8 @@ void print_help(void)
" - off: Don't terminate early.\n" " - off: Don't terminate early.\n"
" - on: Terminate early.\n" " - on: Terminate early.\n"
" - sensitive: Terminate even earlier.\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" " --(no-)implicit-rdpcm : Implicit residual DPCM. Currently only supported\n"
" with lossless coding. [disabled]\n" " with lossless coding. [disabled]\n"
" --(no-)tmvp : Temporal motion vector prediction [enabled]\n" " --(no-)tmvp : Temporal motion vector prediction [enabled]\n"

View file

@ -323,6 +323,7 @@ typedef struct kvz_config
uint8_t *optional_key; uint8_t *optional_key;
enum kvz_me_early_termination me_early_termination; /*!< \since 3.8.0 \brief Mode of me early termination. */ 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. */ int32_t lossless; /*!< \brief Use lossless coding. */

View file

@ -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); 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; 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 // Update order according to new costs