Commit e44c6224 authored by Steinar Midtskogen's avatar Steinar Midtskogen Committed by Fred BARBIER

Add command-line -enable-cdef option

Change-Id: Ic061eeab1563c249fd9d3738025aac40bc3ee542
parent 5c99f4e4
......@@ -427,6 +427,19 @@ enum aome_enc_control_id {
*/
AOME_SET_ENABLEAUTOBWDREF,
/*!\brief Codec control function to encode with CDEF.
*
* CDEF is the constrained directional enhancement filter which is an
* in-loop filter aiming to remove coding artifacts
* 0 = do not apply CDEF
* 1 = apply CDEF
*
* By default, the encoder applies CDEF.
*
* Experiment: AOM_CDEF
*/
AV1E_SET_ENABLE_CDEF,
/*!\brief Codec control function to encode with quantisation matrices.
*
* AOM can operate with default quantisation matrices dependent on
......@@ -726,6 +739,9 @@ AOM_CTRL_USE_TYPE(AV1E_SET_GF_CBR_BOOST_PCT, unsigned int)
AOM_CTRL_USE_TYPE(AV1E_SET_LOSSLESS, unsigned int)
#define AOM_CTRL_AV1E_SET_LOSSLESS
AOM_CTRL_USE_TYPE(AV1E_SET_ENABLE_CDEF, unsigned int)
#define AOM_CTRL_AV1E_SET_ENABLE_CDEF
AOM_CTRL_USE_TYPE(AV1E_SET_ENABLE_QM, unsigned int)
#define AOM_CTRL_AV1E_SET_ENABLE_QM
......
......@@ -428,6 +428,12 @@ static const arg_def_t tile_loopfilter = ARG_DEF(
#endif // CONFIG_LOOPFILTERING_ACROSS_TILES
static const arg_def_t lossless =
ARG_DEF(NULL, "lossless", 1, "Lossless mode (0: false (default), 1: true)");
#if CONFIG_CDEF
static const arg_def_t enable_cdef =
ARG_DEF(NULL, "enable-cdef", 1,
"Enable the constrained directional enhancement filter (0: false, "
"1: true (default))");
#endif
#if CONFIG_AOM_QM
static const arg_def_t enable_qm =
ARG_DEF(NULL, "enable-qm", 1,
......@@ -567,6 +573,9 @@ static const arg_def_t *av1_args[] = { &cpu_used_av1,
&max_inter_rate_pct,
&gf_cbr_boost_pct,
&lossless,
#if CONFIG_CDEF
&enable_cdef,
#endif
#if CONFIG_AOM_QM
&enable_qm,
&qm_min,
......@@ -624,6 +633,9 @@ static const int av1_arg_ctrl_map[] = { AOME_SET_CPUUSED,
AV1E_SET_MAX_INTER_BITRATE_PCT,
AV1E_SET_GF_CBR_BOOST_PCT,
AV1E_SET_LOSSLESS,
#if CONFIG_CDEF
AV1E_SET_ENABLE_CDEF,
#endif
#if CONFIG_AOM_QM
AV1E_SET_ENABLE_QM,
AV1E_SET_QM_MIN,
......
......@@ -54,6 +54,9 @@ struct av1_extracfg {
unsigned int rc_max_inter_bitrate_pct;
unsigned int gf_cbr_boost_pct;
unsigned int lossless;
#if CONFIG_CDEF
unsigned int enable_cdef;
#endif
#if CONFIG_AOM_QM
unsigned int enable_qm;
unsigned int qm_min;
......@@ -117,6 +120,9 @@ static struct av1_extracfg default_extra_cfg = {
0, // rc_max_inter_bitrate_pct
0, // gf_cbr_boost_pct
0, // lossless
#if CONFIG_CDEF
1, // enable_cdef
#endif
#if CONFIG_AOM_QM
0, // enable_qm
DEFAULT_QM_FIRST, // qm_min
......@@ -495,6 +501,9 @@ static aom_codec_err_t set_encoder_config(
oxcf->cq_level = av1_quantizer_to_qindex(extra_cfg->cq_level);
oxcf->fixed_q = -1;
#if CONFIG_CDEF
oxcf->using_cdef = extra_cfg->enable_cdef;
#endif
#if CONFIG_AOM_QM
oxcf->using_qm = extra_cfg->enable_qm;
oxcf->qm_minlevel = extra_cfg->qm_min;
......@@ -864,6 +873,15 @@ static aom_codec_err_t ctrl_set_lossless(aom_codec_alg_priv_t *ctx,
return update_extra_cfg(ctx, &extra_cfg);
}
#if CONFIG_CDEF
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;
extra_cfg.enable_cdef = CAST(AV1E_SET_ENABLE_CDEF, args);
return update_extra_cfg(ctx, &extra_cfg);
}
#endif
#if CONFIG_AOM_QM
static aom_codec_err_t ctrl_set_enable_qm(aom_codec_alg_priv_t *ctx,
va_list args) {
......@@ -1589,6 +1607,9 @@ static aom_codec_ctrl_fn_map_t encoder_ctrl_maps[] = {
{ 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 },
#if CONFIG_CDEF
{ AV1E_SET_ENABLE_CDEF, ctrl_set_enable_cdef },
#endif
#if CONFIG_AOM_QM
{ AV1E_SET_ENABLE_QM, ctrl_set_enable_qm },
{ AV1E_SET_QM_MIN, ctrl_set_qm_min },
......
......@@ -4615,20 +4615,25 @@ static void loopfilter_frame(AV1_COMP *cpi, AV1_COMMON *cm) {
#endif
#if CONFIG_LOOP_RESTORATION
int no_restoration = 0;
#endif
if (is_lossless_requested(&cpi->oxcf)
#if CONFIG_EXT_TILE
|| cm->single_tile_decoding
#endif
) {
no_loopfilter = 1;
#if CONFIG_CDEF
no_cdef = 1;
#endif
#if CONFIG_LOOP_RESTORATION
no_restoration = 1;
}
#endif
#if CONFIG_CDEF
if (is_lossless_requested(&cpi->oxcf) || !cpi->oxcf.using_cdef
#if CONFIG_EXT_TILE
|| cm->single_tile_decoding
#endif
) {
no_cdef = 1;
}
#endif
if (no_loopfilter) {
#if CONFIG_LOOPFILTER_LEVEL
......
......@@ -196,6 +196,9 @@ typedef struct AV1EncoderConfig {
#if CONFIG_EXT_DELTA_Q
DELTAQ_MODE deltaq_mode;
#endif
#if CONFIG_CDEF
int using_cdef;
#endif
#if CONFIG_AOM_QM
int using_qm;
int qm_minlevel;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment