Add encoder control to turn on/off keyframe filter
By default is on.
To turn off:
--enable-keyframe-filtering=0
Change-Id: Ie0e53e2f81cdedcfddcc4788d40a6483e8aa4e70
diff --git a/aom/aomcx.h b/aom/aomcx.h
index 1724ea9..b566d24 100644
--- a/aom/aomcx.h
+++ b/aom/aomcx.h
@@ -328,6 +328,12 @@
*/
AV1E_SET_ENABLE_TPL_MODEL,
+ /*!\brief Codec control function to enable temporal filtering on key frame.
+ *
+ * By default, this feature is on.
+ */
+ AV1E_SET_ENABLE_KEYFRAME_FILTERING,
+
/*!\brief Codec control function to enable frame parallel decoding feature.
*
* AV1 has a bitstream feature to reduce decoding dependency between frames
@@ -1334,6 +1340,9 @@
AOM_CTRL_USE_TYPE(AV1E_SET_ENABLE_TPL_MODEL, unsigned int)
#define AOM_CTRL_AV1E_SET_ENABLE_TPL_MODEL
+AOM_CTRL_USE_TYPE(AV1E_SET_ENABLE_KEYFRAME_FILTERING, unsigned int)
+#define AOM_CTRL_AV1E_SET_ENABLE_KEYFRAME_FILTERING
+
AOM_CTRL_USE_TYPE(AOME_GET_LAST_QUANTIZER, int *)
#define AOM_CTRL_AOME_GET_LAST_QUANTIZER
AOM_CTRL_USE_TYPE(AOME_GET_LAST_QUANTIZER_64, int *)
diff --git a/apps/aomenc.c b/apps/aomenc.c
index bd767c6..4630157 100644
--- a/apps/aomenc.c
+++ b/apps/aomenc.c
@@ -423,6 +423,10 @@
ARG_DEF(NULL, "enable-tpl-model", 1,
"RDO based on frame temporal dependency "
"(0: off, 1: backward source based, 2: forward 2-pass");
+static const arg_def_t enable_keyframe_filtering =
+ ARG_DEF(NULL, "enable-keyframe-filtering", 1,
+ "Apply temporal filtering on key frame "
+ "(0: false, 1: true (default)");
static const arg_def_t tile_width =
ARG_DEF(NULL, "tile-width", 1, "Tile widths (comma separated)");
static const arg_def_t tile_height =
@@ -808,6 +812,7 @@
&tile_cols,
&tile_rows,
&enable_tpl_model,
+ &enable_keyframe_filtering,
&arnr_maxframes,
&arnr_strength,
&tune_metric,
@@ -913,6 +918,7 @@
AV1E_SET_TILE_COLUMNS,
AV1E_SET_TILE_ROWS,
AV1E_SET_ENABLE_TPL_MODEL,
+ AV1E_SET_ENABLE_KEYFRAME_FILTERING,
AOME_SET_ARNR_MAXFRAMES,
AOME_SET_ARNR_STRENGTH,
AOME_SET_TUNING,
diff --git a/av1/av1_cx_iface.c b/av1/av1_cx_iface.c
index 45a090a..ecd15dd 100644
--- a/av1/av1_cx_iface.c
+++ b/av1/av1_cx_iface.c
@@ -40,6 +40,7 @@
unsigned int tile_columns; // log2 number of tile columns
unsigned int tile_rows; // log2 number of tile rows
unsigned int enable_tpl_model;
+ unsigned int enable_keyframe_filtering;
unsigned int arnr_max_frames;
unsigned int arnr_strength;
unsigned int min_gf_interval;
@@ -162,6 +163,7 @@
0, // tile_columns
0, // tile_rows
1, // enable_tpl_model
+ 1, // enable_keyframe_filtering
7, // arnr_max_frames
5, // arnr_strength
0, // min_gf_interval; 0 -> default decision
@@ -881,6 +883,7 @@
}
oxcf->enable_tpl_model = extra_cfg->enable_tpl_model;
+ oxcf->enable_keyframe_filtering = extra_cfg->enable_keyframe_filtering;
oxcf->enable_chroma_deltaq = extra_cfg->enable_chroma_deltaq;
oxcf->aq_mode = extra_cfg->aq_mode;
@@ -1049,6 +1052,14 @@
return update_extra_cfg(ctx, &extra_cfg);
}
+static aom_codec_err_t ctrl_set_enable_keyframe_filtering(
+ aom_codec_alg_priv_t *ctx, va_list args) {
+ struct av1_extracfg extra_cfg = ctx->extra_cfg;
+ extra_cfg.enable_keyframe_filtering =
+ CAST(AV1E_SET_ENABLE_KEYFRAME_FILTERING, args);
+ return update_extra_cfg(ctx, &extra_cfg);
+}
+
static aom_codec_err_t ctrl_set_arnr_max_frames(aom_codec_alg_priv_t *ctx,
va_list args) {
struct av1_extracfg extra_cfg = ctx->extra_cfg;
@@ -2348,6 +2359,7 @@
{ AV1E_SET_TILE_COLUMNS, ctrl_set_tile_columns },
{ AV1E_SET_TILE_ROWS, ctrl_set_tile_rows },
{ AV1E_SET_ENABLE_TPL_MODEL, ctrl_set_enable_tpl_model },
+ { AV1E_SET_ENABLE_KEYFRAME_FILTERING, ctrl_set_enable_keyframe_filtering },
{ AOME_SET_ARNR_MAXFRAMES, ctrl_set_arnr_max_frames },
{ AOME_SET_ARNR_STRENGTH, ctrl_set_arnr_strength },
{ AOME_SET_TUNING, ctrl_set_tuning },
diff --git a/av1/encoder/encode_strategy.c b/av1/encoder/encode_strategy.c
index 268110c..d2732cd 100644
--- a/av1/encoder/encode_strategy.c
+++ b/av1/encoder/encode_strategy.c
@@ -893,7 +893,8 @@
EncodeFrameParams *const frame_params,
EncodeFrameResults *const frame_results,
int *temporal_filtered) {
- if (frame_params->frame_type != KEY_FRAME) {
+ if (frame_params->frame_type != KEY_FRAME ||
+ !cpi->oxcf.enable_keyframe_filtering) {
if (av1_encode(cpi, dest, frame_input, frame_params, frame_results) !=
AOM_CODEC_OK) {
return AOM_CODEC_ERROR;
@@ -1281,17 +1282,17 @@
#endif
}
-#if TEMPORAL_FILTER_KEY_FRAME
- if (denoise_and_encode(cpi, dest, &frame_input, &frame_params, &frame_results,
- &code_arf) != AOM_CODEC_OK) {
- return AOM_CODEC_ERROR;
- }
-#else // !TEMPORAL_FILTER_KEY_FRAME
+#if CONFIG_REALTIME_ONLY
if (av1_encode(cpi, dest, &frame_input, &frame_params, &frame_results) !=
AOM_CODEC_OK) {
return AOM_CODEC_ERROR;
}
-#endif // TEMPORAL_FILTER_KEY_FRAME
+#else
+ if (denoise_and_encode(cpi, dest, &frame_input, &frame_params, &frame_results,
+ &code_arf) != AOM_CODEC_OK) {
+ return AOM_CODEC_ERROR;
+ }
+#endif // CONFIG_REALTIME_ONLY
if (oxcf->pass != 1) cpi->num_gf_group_show_frames += frame_params.show_frame;
if (oxcf->pass == 0 || oxcf->pass == 2) {
diff --git a/av1/encoder/encoder.h b/av1/encoder/encoder.h
index d587b40..3bd9ad8 100644
--- a/av1/encoder/encoder.h
+++ b/av1/encoder/encoder.h
@@ -336,6 +336,7 @@
int tile_heights[MAX_TILE_ROWS];
int enable_tpl_model;
+ int enable_keyframe_filtering;
int max_threads;