Expand range of global motion params Extend the range of the non-translational parameters, from [-1/8, +1/8] (including both endpoints) to [-1/4, +1/4) (excluding +1/4)
diff --git a/av1/common/mv.h b/av1/common/mv.h index 2878005..e04b45f 100644 --- a/av1/common/mv.h +++ b/av1/common/mv.h
@@ -379,7 +379,7 @@ #define SUBEXPFIN_K 3 -#if CONFIG_EXTENDED_WARP_PREDICTION +#if CONFIG_EXTENDED_WARP_PREDICTION || CONFIG_IMPROVED_GLOBAL_MOTION #define GM_TRANS_PREC_BITS 3 #define GM_ABS_TRANS_BITS 14 #define GM_ABS_TRANS_ONLY_BITS (GM_ABS_TRANS_BITS - GM_TRANS_PREC_BITS + 3) @@ -392,7 +392,11 @@ #if CONFIG_EXT_WARP_FILTER #define GM_ABS_ALPHA_BITS 9 #else +#if CONFIG_IMPROVED_GLOBAL_MOTION +#define GM_ABS_ALPHA_BITS 8 +#else #define GM_ABS_ALPHA_BITS 7 +#endif // CONFIG_IMPROVED_GLOBAL_MOTION #endif // CONFIG_EXT_WARP_FILTER #define GM_ALPHA_PREC_DIFF (WARPEDMODEL_PREC_BITS - GM_ALPHA_PREC_BITS) #define GM_ALPHA_DECODE_FACTOR (1 << GM_ALPHA_PREC_DIFF) @@ -409,7 +413,7 @@ #define GM_ABS_ALPHA_BITS 12 #define GM_ALPHA_PREC_DIFF (WARPEDMODEL_PREC_BITS - GM_ALPHA_PREC_BITS) #define GM_ALPHA_DECODE_FACTOR (1 << GM_ALPHA_PREC_DIFF) -#endif // CONFIG_EXTENDED_WARP_PREDICTION +#endif // CONFIG_EXTENDED_WARP_PREDICTION || CONFIG_IMPROVED_GLOBAL_MOTION #define GM_ROW3HOMO_PREC_BITS 16 #define GM_ABS_ROW3HOMO_BITS 11 @@ -417,7 +421,11 @@ (WARPEDMODEL_ROW3HOMO_PREC_BITS - GM_ROW3HOMO_PREC_BITS) #define GM_ROW3HOMO_DECODE_FACTOR (1 << GM_ROW3HOMO_PREC_DIFF) +#if CONFIG_IMPROVED_GLOBAL_MOTION +#define GM_TRANS_MAX ((1 << GM_ABS_TRANS_BITS) - 1) +#else #define GM_TRANS_MAX (1 << GM_ABS_TRANS_BITS) +#endif // CONFIG_IMPROVED_GLOBAL_MOTION #if CONFIG_EXT_WARP_FILTER #define GM_ALPHA_MAX ((1 << GM_ABS_ALPHA_BITS) - 1) #else
diff --git a/av1/decoder/decodeframe.c b/av1/decoder/decodeframe.c index 6836712..0a4a5ea 100644 --- a/av1/decoder/decodeframe.c +++ b/av1/decoder/decodeframe.c
@@ -6151,9 +6151,9 @@ if (type >= TRANSLATION) { #if CONFIG_IMPROVED_GLOBAL_MOTION - const int trans_bits = GM_ABS_TRANS_BITS; const int trans_dec_factor = GM_TRANS_DECODE_FACTOR; const int trans_prec_diff = GM_TRANS_PREC_DIFF; + const int trans_max = GM_TRANS_MAX; #else const int trans_bits = (type == TRANSLATION) #if CONFIG_FLEX_MVRES @@ -6177,14 +6177,15 @@ ? GM_TRANS_ONLY_PREC_DIFF + !allow_hp #endif : GM_TRANS_PREC_DIFF; + const int trans_max = (1 << trans_bits); #endif // CONFIG_IMPROVED_GLOBAL_MOTION params->wmmat[0] = aom_rb_read_signed_primitive_refsubexpfin( - rb, (1 << trans_bits) + 1, SUBEXPFIN_K, + rb, trans_max + 1, SUBEXPFIN_K, (ref_params->wmmat[0] >> trans_prec_diff)) * trans_dec_factor; params->wmmat[1] = aom_rb_read_signed_primitive_refsubexpfin( - rb, (1 << trans_bits) + 1, SUBEXPFIN_K, + rb, trans_max + 1, SUBEXPFIN_K, (ref_params->wmmat[1] >> trans_prec_diff)) * trans_dec_factor; }
diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c index afc3c26..eda9230 100644 --- a/av1/encoder/bitstream.c +++ b/av1/encoder/bitstream.c
@@ -4548,8 +4548,8 @@ if (type >= TRANSLATION) { #if CONFIG_IMPROVED_GLOBAL_MOTION - const int trans_bits = GM_ABS_TRANS_BITS; const int trans_prec_diff = GM_TRANS_PREC_DIFF; + const int trans_max = GM_TRANS_MAX; #else #if CONFIG_FLEX_MVRES const int trans_bits = (type == TRANSLATION) @@ -4566,14 +4566,15 @@ ? GM_TRANS_ONLY_PREC_DIFF + !allow_hp : GM_TRANS_PREC_DIFF; #endif // CONFIG_FLEX_MVRES + const int trans_max = (1 << trans_bits); #endif // CONFIG_IMPROVED_GLOBAL_MOTION aom_wb_write_signed_primitive_refsubexpfin( - wb, (1 << trans_bits) + 1, SUBEXPFIN_K, + wb, trans_max + 1, SUBEXPFIN_K, (ref_params->wmmat[0] >> trans_prec_diff), (params->wmmat[0] >> trans_prec_diff)); aom_wb_write_signed_primitive_refsubexpfin( - wb, (1 << trans_bits) + 1, SUBEXPFIN_K, + wb, trans_max + 1, SUBEXPFIN_K, (ref_params->wmmat[1] >> trans_prec_diff), (params->wmmat[1] >> trans_prec_diff)); }
diff --git a/av1/encoder/global_motion_facade.c b/av1/encoder/global_motion_facade.c index 648ca60..1728311 100644 --- a/av1/encoder/global_motion_facade.c +++ b/av1/encoder/global_motion_facade.c
@@ -45,6 +45,7 @@ #if CONFIG_IMPROVED_GLOBAL_MOTION const int trans_bits = GM_ABS_TRANS_BITS; const int trans_prec_diff = GM_TRANS_PREC_DIFF; + const int trans_max = (1 << trans_bits) - 1; #else const int trans_bits = (gm->wmtype == TRANSLATION) #if CONFIG_FLEX_MVRES @@ -60,6 +61,7 @@ ? GM_TRANS_ONLY_PREC_DIFF + !allow_hp #endif : GM_TRANS_PREC_DIFF; + const int trans_max = (1 << trans_bits); #endif // CONFIG_IMPROVED_GLOBAL_MOTION switch (gm->wmtype) { @@ -85,12 +87,10 @@ (gm->wmmat[5] >> GM_ALPHA_PREC_DIFF) - (1 << GM_ALPHA_PREC_BITS)); } params_cost += aom_count_signed_primitive_refsubexpfin( - (1 << trans_bits) + 1, SUBEXPFIN_K, - (ref_gm->wmmat[0] >> trans_prec_diff), + trans_max + 1, SUBEXPFIN_K, (ref_gm->wmmat[0] >> trans_prec_diff), (gm->wmmat[0] >> trans_prec_diff)); params_cost += aom_count_signed_primitive_refsubexpfin( - (1 << trans_bits) + 1, SUBEXPFIN_K, - (ref_gm->wmmat[1] >> trans_prec_diff), + trans_max + 1, SUBEXPFIN_K, (ref_gm->wmmat[1] >> trans_prec_diff), (gm->wmmat[1] >> trans_prec_diff)); AOM_FALLTHROUGH_INTENDED; case IDENTITY: break;