Add encoder options for global and local warp
Adds a command line flag and control for global motion usage.
Warped (local) motion already had a control, but it is now
exposed as a command line parameter.
Change-Id: I38db08362c56229fbb93fcc5568771056f7bd987
diff --git a/aom/aomcx.h b/aom/aomcx.h
index 9aa77bb..0c116be 100644
--- a/aom/aomcx.h
+++ b/aom/aomcx.h
@@ -747,6 +747,14 @@
*/
AV1E_SET_ALLOW_REF_FRAME_MVS,
+ /*!\brief Codec control function to turn on / off global motion usage
+ * for a sequence.
+ *
+ * This will enable or disable usage of global motion. The default value is 1.
+ *
+ */
+ AV1E_SET_ENABLE_GLOBAL_MOTION,
+
/*!\brief Codec control function to turn on / off warped motion usage
* at sequence level.
*
@@ -1044,6 +1052,9 @@
AOM_CTRL_USE_TYPE(AV1E_SET_ALLOW_REF_FRAME_MVS, unsigned int)
#define AOM_CTRL_AV1E_SET_ALLOW_REF_FRAME_MVS
+AOM_CTRL_USE_TYPE(AV1E_SET_ENABLE_GLOBAL_MOTION, unsigned int)
+#define AOM_CTRL_AV1E_SET_ENABLE_GLOBAL_MOTION
+
AOM_CTRL_USE_TYPE(AV1E_SET_ENABLE_WARPED_MOTION, unsigned int)
#define AOM_CTRL_AV1E_SET_ENABLE_WARPED_MOTION
diff --git a/apps/aomenc.c b/apps/aomenc.c
index 4680d3a..b69f788 100644
--- a/apps/aomenc.c
+++ b/apps/aomenc.c
@@ -437,6 +437,14 @@
ARG_DEF(NULL, "enable-restoration", 1,
"Enable the loop restoration filter (0: false, "
"1: true (default))");
+static const arg_def_t enable_global_motion =
+ ARG_DEF(NULL, "enable-global-motion", 1,
+ "Enable global motion "
+ "(0: false, 1: true (default))");
+static const arg_def_t enable_warped_motion =
+ ARG_DEF(NULL, "enable-warped-motion", 1,
+ "Enable local warped motion "
+ "(0: false, 1: true (default))");
static const arg_def_t disable_trellis_quant =
ARG_DEF(NULL, "disable-trellis-quant", 1,
"Disable trellis optimization of quantized coefficients (0: false ("
@@ -638,6 +646,8 @@
&lossless,
&enable_cdef,
&enable_restoration,
+ &enable_global_motion,
+ &enable_warped_motion,
&disable_trellis_quant,
&enable_qm,
&qm_min,
@@ -696,6 +706,8 @@
AV1E_SET_LOSSLESS,
AV1E_SET_ENABLE_CDEF,
AV1E_SET_ENABLE_RESTORATION,
+ AV1E_SET_ENABLE_GLOBAL_MOTION,
+ AV1E_SET_ENABLE_WARPED_MOTION,
AV1E_SET_DISABLE_TRELLIS_QUANT,
AV1E_SET_ENABLE_QM,
AV1E_SET_QM_MIN,
diff --git a/av1/av1_cx_iface.c b/av1/av1_cx_iface.c
index 6c8e7c8..b386cfc 100644
--- a/av1/av1_cx_iface.c
+++ b/av1/av1_cx_iface.c
@@ -97,6 +97,7 @@
int enable_jnt_comp;
int enable_ref_frame_mvs; // sequence level
int allow_ref_frame_mvs; // frame level
+ int enable_global_motion; // enable global motion usage for sequence
int enable_warped_motion; // sequence level
int allow_warped_motion; // frame level
int enable_superres;
@@ -171,6 +172,7 @@
1, // jnt_comp
1, // enable_ref_frame_mvs sequence level
1, // allow ref_frame_mvs frame level
+ 1, // enable_global_motion usage
1, // enable_warped_motion at sequence level
1, // allow_warped_motion at frame level
1, // superres
@@ -666,6 +668,7 @@
oxcf->enable_ref_frame_mvs =
extra_cfg->enable_ref_frame_mvs & extra_cfg->enable_order_hint;
+ oxcf->enable_global_motion = extra_cfg->enable_global_motion;
oxcf->enable_warped_motion = extra_cfg->enable_warped_motion;
oxcf->allow_warped_motion =
extra_cfg->allow_warped_motion & extra_cfg->enable_warped_motion;
@@ -1042,6 +1045,13 @@
return update_extra_cfg(ctx, &extra_cfg);
}
+static aom_codec_err_t ctrl_set_enable_global_motion(aom_codec_alg_priv_t *ctx,
+ va_list args) {
+ struct av1_extracfg extra_cfg = ctx->extra_cfg;
+ extra_cfg.enable_global_motion = CAST(AV1E_SET_ENABLE_GLOBAL_MOTION, args);
+ return update_extra_cfg(ctx, &extra_cfg);
+}
+
static aom_codec_err_t ctrl_set_enable_warped_motion(aom_codec_alg_priv_t *ctx,
va_list args) {
struct av1_extracfg extra_cfg = ctx->extra_cfg;
@@ -1788,6 +1798,7 @@
{ AV1E_SET_ENABLE_JNT_COMP, ctrl_set_enable_jnt_comp },
{ AV1E_SET_ENABLE_REF_FRAME_MVS, ctrl_set_enable_ref_frame_mvs },
{ AV1E_SET_ALLOW_REF_FRAME_MVS, ctrl_set_allow_ref_frame_mvs },
+ { AV1E_SET_ENABLE_GLOBAL_MOTION, ctrl_set_enable_global_motion },
{ AV1E_SET_ENABLE_WARPED_MOTION, ctrl_set_enable_warped_motion },
{ AV1E_SET_ALLOW_WARPED_MOTION, ctrl_set_allow_warped_motion },
{ AV1E_SET_ENABLE_SUPERRES, ctrl_set_enable_superres },
diff --git a/av1/encoder/encodeframe.c b/av1/encoder/encodeframe.c
index e50f213..b5ea46f 100644
--- a/av1/encoder/encodeframe.c
+++ b/av1/encoder/encodeframe.c
@@ -5851,7 +5851,7 @@
cpi->global_motion_search_done = 1;
#endif // !CONFIG_GLOBAL_MOTION_SEARCH
if (cpi->common.current_frame.frame_type == INTER_FRAME && cpi->source &&
- !cpi->global_motion_search_done) {
+ cpi->oxcf.enable_global_motion && !cpi->global_motion_search_done) {
YV12_BUFFER_CONFIG *ref_buf[REF_FRAMES];
int frame;
double params_by_motion[RANSAC_NUM_MOTIONS * (MAX_PARAMDIM - 1)];
diff --git a/av1/encoder/encoder.h b/av1/encoder/encoder.h
index d33695b..cb4559a 100644
--- a/av1/encoder/encoder.h
+++ b/av1/encoder/encoder.h
@@ -325,6 +325,7 @@
int enable_jnt_comp;
int enable_ref_frame_mvs;
unsigned int allow_ref_frame_mvs;
+ int enable_global_motion;
int enable_warped_motion;
int allow_warped_motion;
int enable_superres;