Swap order of affine parameters

This allows for a clean subtraction of 1 along the transform
matrix diagonal and also makes the order of the parameter list
a little more intuitive.

Change-Id: I6a5d754af41b8d1292f241f9b21473160517d24f
This commit is contained in:
Sarah Parker
2016-09-07 13:24:53 -07:00
parent 3410a88373
commit c4bcb50635
7 changed files with 30 additions and 18 deletions

View File

@@ -102,8 +102,8 @@ typedef struct {
#define GM_ALPHA_PREC_DIFF (WARPEDMODEL_PREC_BITS - GM_ALPHA_PREC_BITS)
#define GM_ALPHA_DECODE_FACTOR (1 << GM_ALPHA_PREC_DIFF)
#define GM_ABS_ALPHA_BITS 18
#define GM_ABS_TRANS_BITS 18
#define GM_ABS_ALPHA_BITS 8
#define GM_ABS_TRANS_BITS 8
#define GM_TRANS_MAX (1 << GM_ABS_TRANS_BITS)
#define GM_ALPHA_MAX (1 << GM_ABS_ALPHA_BITS)

View File

@@ -95,11 +95,11 @@ void projectPointsAffine(int16_t *mat, int *points, int *proj, const int n,
WARPEDDIFF_PREC_BITS);
if (subsampling_y)
*(proj++) = ROUND_POWER_OF_TWO_SIGNED(
mat[5] * 2 * x + mat[4] * 2 * y + mat[0] +
(mat[5] + mat[4] - (1 << WARPEDMODEL_PREC_BITS)) / 2,
mat[4] * 2 * x + mat[5] * 2 * y + mat[0] +
(mat[4] + mat[5] - (1 << WARPEDMODEL_PREC_BITS)) / 2,
WARPEDDIFF_PREC_BITS + 1);
else
*(proj++) = ROUND_POWER_OF_TWO_SIGNED(mat[5] * x + mat[4] * y + mat[0],
*(proj++) = ROUND_POWER_OF_TWO_SIGNED(mat[4] * x + mat[5] * y + mat[0],
WARPEDDIFF_PREC_BITS);
points += stride_points - 2;
proj += stride_proj - 2;

View File

@@ -3411,12 +3411,12 @@ static void read_global_motion_params(Global_Motion_Params *params,
case GLOBAL_ZERO: break;
case GLOBAL_AFFINE:
params->motion_params.wmmat[2].as_mv.row =
(aom_read_primitive_symmetric(r, GM_ABS_ALPHA_BITS) *
GM_ALPHA_DECODE_FACTOR);
params->motion_params.wmmat[2].as_mv.col =
aom_read_primitive_symmetric(r, GM_ABS_ALPHA_BITS) *
GM_ALPHA_DECODE_FACTOR +
(1 << WARPEDMODEL_PREC_BITS);
params->motion_params.wmmat[2].as_mv.col =
(aom_read_primitive_symmetric(r, GM_ABS_ALPHA_BITS) *
GM_ALPHA_DECODE_FACTOR);
// fallthrough intended
case GLOBAL_ROTZOOM:
params->motion_params.wmmat[1].as_mv.row =

View File

@@ -3213,11 +3213,11 @@ static void write_global_motion_params(Global_Motion_Params *params,
case GLOBAL_ZERO: break;
case GLOBAL_AFFINE:
aom_write_primitive_symmetric(
w, (params->motion_params.wmmat[2].as_mv.row >> GM_ALPHA_PREC_DIFF) -
(1 << GM_ALPHA_PREC_BITS),
w, (params->motion_params.wmmat[2].as_mv.row >> GM_ALPHA_PREC_DIFF),
GM_ABS_ALPHA_BITS);
aom_write_primitive_symmetric(
w, (params->motion_params.wmmat[2].as_mv.col >> GM_ALPHA_PREC_DIFF),
w, (params->motion_params.wmmat[2].as_mv.col >> GM_ALPHA_PREC_DIFF) -
(1 << GM_ALPHA_PREC_BITS),
GM_ABS_ALPHA_BITS);
// fallthrough intended
case GLOBAL_ROTZOOM:

View File

@@ -4479,7 +4479,7 @@ static void refine_integerized_param(WarpedMotionParams *wm,
static void convert_to_params(double *H, TransformationType type,
int16_t *model) {
int i;
int i, diag_value;
int alpha_present = 0;
int n_params = n_trans_model_params[type];
model[0] = (int16_t)floor(H[0] * (1 << GM_TRANS_PREC_BITS) + 0.5);
@@ -4489,10 +4489,12 @@ static void convert_to_params(double *H, TransformationType type,
model[1] = (int16_t)clamp(model[1], GM_TRANS_MIN, GM_TRANS_MAX) *
GM_TRANS_DECODE_FACTOR;
// TODO(sarahparker) 1 should be subtracted here
for (i = 2; i < n_params; ++i) {
diag_value = ((i && 1) ? (1 << GM_ALPHA_PREC_BITS) : 0);
model[i] = (int16_t)floor(H[i] * (1 << GM_ALPHA_PREC_BITS) + 0.5);
model[i] = (int16_t)clamp(model[i], GM_ALPHA_MIN, GM_ALPHA_MAX) *
model[i] =
(int16_t)(clamp(model[i] - diag_value, GM_ALPHA_MIN, GM_ALPHA_MAX) +
diag_value) *
GM_ALPHA_DECODE_FACTOR;
alpha_present |= (model[i] != 0);
}

View File

@@ -17,7 +17,17 @@
extern "C" {
#endif
// compute global motion parameters between two frames
/*
Computes global motion parameters between two frames. The array
"params" should be length 9, where the first 2 slots are translation
parameters in (row, col) order, and the remaining slots correspond
to values in the transformation matrix of the corresponding motion
model. They are arranged in "params" such that values on the tx-matrix
diagonal have odd numbered indices so the folowing matrix:
A | B
C | D
would produce params = [trans row, trans col, B, A, C, D]
*/
int compute_global_motion_feature_based(TransformationType type,
YV12_BUFFER_CONFIG *frm,
YV12_BUFFER_CONFIG *ref,

View File

@@ -615,8 +615,8 @@ static void denormalizeAffine(double *H, double *T1, double *T2) {
H[1] = Ha[2];
H[2] = Ha[1];
H[3] = Ha[0];
H[4] = Ha[4];
H[5] = Ha[3];
H[4] = Ha[3];
H[5] = Ha[4];
}
static void denormalizeRotZoom(double *H, double *T1, double *T2) {