add control flag to enable/disable deblocking filter
Change-Id: I94d8702adefacf563f42fc2c546cd376ad97a176
diff --git a/aom/aom_encoder.h b/aom/aom_encoder.h
index acf7295..8b845ea 100644
--- a/aom/aom_encoder.h
+++ b/aom/aom_encoder.h
@@ -238,6 +238,10 @@
*
*/
unsigned int enable_flip_idtx;
+ /*!\brief enable deblocking filter
+ *
+ */
+ unsigned int enable_deblocking;
/*!\brief enable CDEF filter
*
*/
diff --git a/aom/aomcx.h b/aom/aomcx.h
index e8b9f01..32bea52 100644
--- a/aom/aomcx.h
+++ b/aom/aomcx.h
@@ -1281,6 +1281,16 @@
/*!\brief Control to get baseline gf interval
*/
AV1E_GET_BASELINE_GF_INTERVAL = 160,
+
+ /*!\brief Codec control function to encode with deblocking, unsigned int
+ * parameter
+ *
+ * deblocking is the in-loop filter aiming to smooth blocky artifacts
+ *
+ * - 0 = disable
+ * - 1 = enable (default)
+ */
+ AV1E_SET_ENABLE_DEBLOCKING = 161,
};
/*!\brief aom 1-D scaling mode
@@ -1497,6 +1507,9 @@
AOM_CTRL_USE_TYPE(AV1E_SET_LOSSLESS, unsigned int)
#define AOM_CTRL_AV1E_SET_LOSSLESS
+AOM_CTRL_USE_TYPE(AV1E_SET_ENABLE_DEBLOCKING, unsigned int)
+#define AOM_CTRL_AV1E_SET_ENABLE_DEBLOCKING
+
AOM_CTRL_USE_TYPE(AV1E_SET_ENABLE_CDEF, unsigned int)
#define AOM_CTRL_AV1E_SET_ENABLE_CDEF
diff --git a/apps/aomenc.c b/apps/aomenc.c
index 867d2f6..845f74d 100644
--- a/apps/aomenc.c
+++ b/apps/aomenc.c
@@ -439,6 +439,9 @@
ARG_DEF(NULL, "tile-height", 1, "Tile heights (command separated)");
static const arg_def_t lossless =
ARG_DEF(NULL, "lossless", 1, "Lossless mode (0: false (default), 1: true)");
+static const arg_def_t enable_deblocking =
+ ARG_DEF(NULL, "enable-deblocking", 1,
+ "Enable the deblocking filter (0: false, 1: true (default))");
static const arg_def_t enable_cdef =
ARG_DEF(NULL, "enable-cdef", 1,
"Enable the constrained directional enhancement filter (0: false, "
@@ -865,6 +868,7 @@
&max_inter_rate_pct,
&gf_cbr_boost_pct,
&lossless,
+ &enable_deblocking,
&enable_cdef,
&enable_restoration,
&enable_rect_partitions,
@@ -971,6 +975,7 @@
AV1E_SET_MAX_INTER_BITRATE_PCT,
AV1E_SET_GF_CBR_BOOST_PCT,
AV1E_SET_LOSSLESS,
+ AV1E_SET_ENABLE_DEBLOCKING,
AV1E_SET_ENABLE_CDEF,
AV1E_SET_ENABLE_RESTORATION,
AV1E_SET_ENABLE_RECT_PARTITIONS,
@@ -1926,8 +1931,10 @@
encoder_cfg->enable_flip_idtx, encoder_cfg->enable_tx64);
fprintf(stdout,
- "Tool setting (Loop filter) : CDEF (%d), LoopRestortion (%d)\n",
- encoder_cfg->enable_cdef, encoder_cfg->enable_restoration);
+ "Tool setting (Loop filter) : Deblocking (%d), CDEF (%d), "
+ "LoopRestortion (%d)\n",
+ encoder_cfg->enable_deblocking, encoder_cfg->enable_cdef,
+ encoder_cfg->enable_restoration);
fprintf(stdout,
"Tool setting (Others) : Palette (%d), IntraBC (%d)\n",
diff --git a/av1/av1_cx_iface.c b/av1/av1_cx_iface.c
index 462bf8a..973b105 100644
--- a/av1/av1_cx_iface.c
+++ b/av1/av1_cx_iface.c
@@ -59,6 +59,7 @@
unsigned int rc_max_inter_bitrate_pct;
unsigned int gf_cbr_boost_pct;
unsigned int lossless;
+ unsigned int enable_deblocking;
unsigned int enable_cdef;
unsigned int enable_restoration;
unsigned int force_video_mode;
@@ -298,6 +299,7 @@
0, // rc_max_inter_bitrate_pct
0, // gf_cbr_boost_pct
0, // lossless
+ 1, // enable_deblocking
1, // enable_cdef
1, // enable_restoration
0, // force_video_mode
@@ -732,6 +734,7 @@
static void update_encoder_config(cfg_options_t *cfg,
struct av1_extracfg *extra_cfg) {
+ cfg->enable_deblocking = extra_cfg->enable_deblocking;
cfg->enable_cdef = extra_cfg->enable_cdef;
cfg->enable_restoration = extra_cfg->enable_restoration;
cfg->superblock_size =
@@ -779,6 +782,7 @@
static void update_default_encoder_config(const cfg_options_t *cfg,
struct av1_extracfg *extra_cfg) {
+ extra_cfg->enable_deblocking = cfg->enable_deblocking;
extra_cfg->enable_cdef = cfg->enable_cdef;
extra_cfg->enable_restoration = cfg->enable_restoration;
extra_cfg->superblock_size = (cfg->superblock_size == 64)
@@ -972,6 +976,7 @@
// Set Toolset related configuration.
tool_cfg->bit_depth = cfg->g_bit_depth;
+ tool_cfg->enable_deblocking = extra_cfg->enable_deblocking;
tool_cfg->enable_cdef = extra_cfg->enable_cdef;
tool_cfg->enable_restoration =
(cfg->g_usage == AOM_USAGE_REALTIME) ? 0 : extra_cfg->enable_restoration;
@@ -1476,6 +1481,13 @@
return update_extra_cfg(ctx, &extra_cfg);
}
+static aom_codec_err_t ctrl_set_enable_deblocking(aom_codec_alg_priv_t *ctx,
+ va_list args) {
+ struct av1_extracfg extra_cfg = ctx->extra_cfg;
+ extra_cfg.enable_deblocking = CAST(AV1E_SET_ENABLE_DEBLOCKING, args);
+ return update_extra_cfg(ctx, &extra_cfg);
+}
+
static aom_codec_err_t ctrl_set_enable_cdef(aom_codec_alg_priv_t *ctx,
va_list args) {
struct av1_extracfg extra_cfg = ctx->extra_cfg;
@@ -3040,6 +3052,7 @@
{ AV1E_SET_MAX_INTER_BITRATE_PCT, ctrl_set_rc_max_inter_bitrate_pct },
{ AV1E_SET_GF_CBR_BOOST_PCT, ctrl_set_rc_gf_cbr_boost_pct },
{ AV1E_SET_LOSSLESS, ctrl_set_lossless },
+ { AV1E_SET_ENABLE_DEBLOCKING, ctrl_set_enable_deblocking },
{ AV1E_SET_ENABLE_CDEF, ctrl_set_enable_cdef },
{ AV1E_SET_ENABLE_RESTORATION, ctrl_set_enable_restoration },
{ AV1E_SET_FORCE_VIDEO_MODE, ctrl_set_force_video_mode },
@@ -3221,7 +3234,7 @@
{ 0 }, // tile_heights
0, // use_fixed_qp_offsets
{ -1, -1, -1, -1, -1 }, // fixed_qp_offsets
- { 0, 128, 128, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ { 0, 128, 128, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
#if !CONFIG_REMOVE_DIST_WTD_COMP
1,
#endif // !CONFIG_REMOVE_DIST_WTD_COMP
@@ -3296,7 +3309,7 @@
{ 0 }, // tile_heights
0, // use_fixed_qp_offsets
{ -1, -1, -1, -1, -1 }, // fixed_qp_offsets
- { 0, 128, 128, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ { 0, 128, 128, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
#if !CONFIG_REMOVE_DIST_WTD_COMP
1,
#endif // !CONFIG_REMOVE_DIST_WTD_COMP
diff --git a/av1/encoder/encoder.c b/av1/encoder/encoder.c
index 3c5f959..0ee6c6a 100644
--- a/av1/encoder/encoder.c
+++ b/av1/encoder/encoder.c
@@ -2047,8 +2047,9 @@
assert(IMPLIES(is_lossless_requested(&cpi->oxcf.rc_cfg),
cm->features.coded_lossless && cm->features.all_lossless));
- const int use_loopfilter =
- !cm->features.coded_lossless && !cm->tiles.large_scale;
+ const int use_loopfilter = !cm->features.coded_lossless &&
+ !cm->tiles.large_scale &&
+ cpi->oxcf.tool_cfg.enable_deblocking;
const int use_cdef = cm->seq_params.enable_cdef &&
!cm->features.coded_lossless && !cm->tiles.large_scale;
const int use_restoration = cm->seq_params.enable_restoration &&
diff --git a/av1/encoder/encoder.h b/av1/encoder/encoder.h
index 43bc511..8f280b7 100644
--- a/av1/encoder/encoder.h
+++ b/av1/encoder/encoder.h
@@ -757,6 +757,8 @@
aom_superblock_size_t superblock_size;
// Indicates if loopfilter modulation should be enabled.
bool enable_deltalf_mode;
+ // Indicates if deblocking should be enabled.
+ bool enable_deblocking;
// Indicates if CDEF should be enabled.
bool enable_cdef;
// Indicates if loop restoration filter should be enabled.
diff --git a/common/args.c b/common/args.c
index 124e5f2..0ba7ebc 100644
--- a/common/args.c
+++ b/common/args.c
@@ -93,6 +93,7 @@
GET_PARAMS(enable_rect_partitions);
GET_PARAMS(enable_1to4_partitions);
GET_PARAMS(enable_flip_idtx);
+ GET_PARAMS(enable_deblocking);
GET_PARAMS(enable_cdef);
GET_PARAMS(enable_restoration);
GET_PARAMS(enable_obmc);