Skip to content

Commit

Permalink
Add early termination for intra rdo when a zero coefficient block is …
Browse files Browse the repository at this point in the history
…found.
  • Loading branch information
Arizer committed Jun 8, 2018
1 parent 492529f commit 4fb1c16
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 2 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 14 additions & 1 deletion src/cfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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",
Expand All @@ -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
},
{
Expand All @@ -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
},
{
Expand All @@ -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
},
{
Expand All @@ -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
},
{
Expand All @@ -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
},
{
Expand All @@ -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
},
{
Expand All @@ -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
},
{
Expand All @@ -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
},
{
Expand All @@ -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
},
{
Expand All @@ -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 }
Expand Down Expand Up @@ -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") {
Expand Down
4 changes: 4 additions & 0 deletions src/cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions src/kvazaar.h
Original file line number Diff line number Diff line change
Expand Up @@ -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. */

Expand Down
6 changes: 6 additions & 0 deletions src/search_intra.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4fb1c16

Please sign in to comment.