Commit fd9e5fcb authored by Frederic Barbier's avatar Frederic Barbier Committed by Sebastien Alaiwan
Browse files

Avoid useless computations when determinant is 0

Change-Id: I8b9fcb995116068fdaed26f3a7b084b154ea3bc1
parent 316a6235
......@@ -1166,15 +1166,9 @@ static int find_affine_int(int np, const int *pts1, const int *pts2,
assert(By[0] >= LS_MAT_MIN && By[0] <= LS_MAT_MAX);
assert(By[1] >= LS_MAT_MIN && By[1] <= LS_MAT_MAX);
int64_t Px[2], Py[2], Det;
int64_t Det;
int16_t iDet, shift;
// These divided by the Det, are the least squares solutions
Px[0] = (int64_t)A[1][1] * Bx[0] - (int64_t)A[0][1] * Bx[1];
Px[1] = -(int64_t)A[0][1] * Bx[0] + (int64_t)A[0][0] * Bx[1];
Py[0] = (int64_t)A[1][1] * By[0] - (int64_t)A[0][1] * By[1];
Py[1] = -(int64_t)A[0][1] * By[0] + (int64_t)A[0][0] * By[1];
// Compute Determinant of A
Det = (int64_t)A[0][0] * A[1][1] - (int64_t)A[0][1] * A[0][1];
if (Det == 0) return 1;
......@@ -1185,6 +1179,14 @@ static int find_affine_int(int np, const int *pts1, const int *pts2,
shift = 0;
}
int64_t Px[2], Py[2];
// These divided by the Det, are the least squares solutions
Px[0] = (int64_t)A[1][1] * Bx[0] - (int64_t)A[0][1] * Bx[1];
Px[1] = -(int64_t)A[0][1] * Bx[0] + (int64_t)A[0][0] * Bx[1];
Py[0] = (int64_t)A[1][1] * By[0] - (int64_t)A[0][1] * By[1];
Py[1] = -(int64_t)A[0][1] * By[0] + (int64_t)A[0][0] * By[1];
wm->wmmat[2] = get_mult_shift_diag(Px[0], iDet, shift);
wm->wmmat[3] = get_mult_shift_ndiag(Px[1], iDet, shift);
wm->wmmat[4] = get_mult_shift_ndiag(Py[0], iDet, shift);
......
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