Add cli option for forcing inter

This commit is contained in:
Joose Sainio 2022-03-17 14:48:08 +02:00
parent f1f0033bf5
commit 85d1a54adc
5 changed files with 17 additions and 4 deletions

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
ver_major=6
ver_minor=6
ver_minor=7
ver_release=0
# Prevents configure from adding a lot of defines to the CFLAGS

View file

@ -185,6 +185,7 @@ int kvz_config_init(kvz_config *cfg)
cfg->fastrd_learning_outdir_fn = NULL;
cfg->combine_intra_cus = 1;
cfg->force_inter = 0;
return 1;
}
@ -1426,6 +1427,9 @@ int kvz_config_parse(kvz_config *cfg, const char *name, const char *value)
else if OPT("combine-intra-cus") {
cfg->combine_intra_cus = atobool(value);
}
else if OPT("force-inter") {
cfg->force_inter = atobool(value);
}
else {
return 0;
}

View file

@ -169,6 +169,8 @@ static const struct option long_options[] = {
{ "fastrd-outdir", required_argument, NULL, 0 },
{ "combine-intra-cus", no_argument, NULL, 0 },
{ "no-combine-intra-cus", no_argument, NULL, 0 },
{ "force-inter", no_argument, NULL, 0 },
{ "no-force-inter", no_argument, NULL, 0 },
{0, 0, 0, 0}
};
@ -586,6 +588,10 @@ void print_help(void)
" be disabled if cus absolutely must not\n"
" be larger than limited by the search.\n"
" [enabled]"
" --force-inter : Force the encoder to use inter always.\n"
" This is mostly for debugging and is not\n"
" guaranteed to produce sensible bitstream or\n"
" work at all. [disabled]"
" --tr-depth-intra <int> : Transform split depth for intra blocks [0]\n"
" --(no-)bipred : Bi-prediction [disabled]\n"
" --cu-split-termination <string> : CU split search termination [zero]\n"

View file

@ -482,6 +482,8 @@ typedef struct kvz_config
/** \brief whether to try combining intra cus at the lower depth when search
* is not performed at said depth*/
uint8_t combine_intra_cus;
uint8_t force_inter;
} kvz_config;
/**

View file

@ -577,12 +577,13 @@ static double search_cu(encoder_state_t * const state, int x, int y, int depth,
int32_t cu_width_intra_min = LCU_WIDTH >> pu_depth_intra.max;
bool can_use_intra =
WITHIN(depth, pu_depth_intra.min, pu_depth_intra.max) ||
(WITHIN(depth, pu_depth_intra.min, pu_depth_intra.max) ||
// When the split was forced because the CTU is partially outside
// the frame, we permit intra coding even if pu_depth_intra would
// otherwise forbid it.
(x & ~(cu_width_intra_min - 1)) + cu_width_intra_min > frame->width ||
(y & ~(cu_width_intra_min - 1)) + cu_width_intra_min > frame->height;
(y & ~(cu_width_intra_min - 1)) + cu_width_intra_min > frame->height) &&
!(state->encoder_control->cfg.force_inter && state->frame->slicetype != KVZ_SLICE_I);
if (can_use_intra && !skip_intra) {
int8_t intra_mode;
@ -710,7 +711,7 @@ static double search_cu(encoder_state_t * const state, int x, int y, int depth,
// If the CU is partially outside the frame, we need to split it even
// if pu_depth_intra and pu_depth_inter would not permit it.
cur_cu->type == CU_NOTSET ||
depth < pu_depth_intra.max ||
(depth < pu_depth_intra.max && !(state->encoder_control->cfg.force_inter&& state->frame->slicetype != KVZ_SLICE_I)) ||
(state->frame->slicetype != KVZ_SLICE_I &&
depth < pu_depth_inter.max);