Avoid useless computations when determinant is 0 Change-Id: I8b9fcb995116068fdaed26f3a7b084b154ea3bc1
diff --git a/av1/common/warped_motion.c b/av1/common/warped_motion.c index 8be9e71..f9b5cf7 100644 --- a/av1/common/warped_motion.c +++ b/av1/common/warped_motion.c
@@ -1166,15 +1166,9 @@ 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 @@ 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);