Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Xiph.Org
aom-rav1e
Commits
17f041a7
Commit
17f041a7
authored
May 24, 2017
by
Debargha Mukherjee
Browse files
Clean-up unused 3rd order least squares
Change-Id: Ia18f9f7034dafb9ac0108143d4f65f3f6b1a77d5
parent
056732f6
Changes
1
Hide whitespace changes
Inline
Side-by-side
av1/common/warped_motion.c
View file @
17f041a7
...
...
@@ -1508,7 +1508,6 @@ void av1_warp_plane(WarpedMotionParams *wm,
#define LS_PRODUCT2(a, b) \
(((a) * (b)*4 + ((a) + (b)) * 2 * LS_STEP + LS_STEP * LS_STEP * 2) >> 2)
#if LEAST_SQUARES_ORDER == 2
static
int
find_affine_int
(
int
np
,
int
*
pts1
,
int
*
pts2
,
BLOCK_SIZE
bsize
,
int
mvy
,
int
mvx
,
WarpedMotionParams
*
wm
,
int
mi_row
,
int
mi_col
)
{
...
...
@@ -1642,164 +1641,6 @@ static int find_affine_int(int np, int *pts1, int *pts2, BLOCK_SIZE bsize,
return
0
;
}
#else
static
int
find_affine_int
(
int
np
,
int
*
pts1
,
int
*
pts2
,
BLOCK_SIZE
bsize
,
int
mvy
,
int
mvx
,
WarpedMotionParams
*
wm
,
int
mi_row
,
int
mi_col
)
{
int32_t
A
[
3
][
3
]
=
{
{
0
,
0
,
0
},
{
0
,
0
,
0
},
{
0
,
0
,
0
}
};
int32_t
Bx
[
3
]
=
{
0
,
0
,
0
};
int32_t
By
[
3
]
=
{
0
,
0
,
0
};
int
i
,
n
=
0
,
off
;
int64_t
C00
,
C01
,
C02
,
C11
,
C12
,
C22
;
int64_t
Px
[
3
],
Py
[
3
];
int64_t
Det
,
v
;
const
int
bw
=
block_size_wide
[
bsize
];
const
int
bh
=
block_size_high
[
bsize
];
const
int
cy_offset
=
AOMMAX
(
bh
,
MI_SIZE
)
/
2
-
1
;
const
int
cx_offset
=
AOMMAX
(
bw
,
MI_SIZE
)
/
2
-
1
;
// Offsets to make the values in the arrays smaller
const
int
ux
=
mi_col
*
MI_SIZE
*
8
,
uy
=
mi_row
*
MI_SIZE
*
8
;
// Let source points (xi, yi) map to destimation points (xi', yi'),
// for i = 0, 1, 2, .... n-1
// Then if P = [x0, y0, 1,
// x1, y1, 1
// x2, y2, 1,
// ....
// ]
// q = [x0', x1', x2', ... ]'
// r = [y0', y1', y2', ... ]'
// the least squares problems that need to be solved are:
// [h1, h2, dx]' = inv(P'P)P'q and
// [h3, h4, dy]' = inv(P'P)P'r
// where the affine transformation is given by:
// x' = h1.x + h2.y + dx
// y' = h3.x + h4.y + dy
//
// The loop below computes: A = P'P, Bx = P'q, By = P'r
// We need to just compute inv(A).Bx and inv(A).By for the solutions.
//
int
sx
,
sy
,
dx
,
dy
;
// Contribution from sample in current block
sx
=
cx_offset
*
8
;
sy
=
cy_offset
*
8
;
dx
=
sx
+
mvx
;
dy
=
sy
+
mvy
;
if
(
abs
(
sx
-
dx
)
<
LS_MV_MAX
&&
abs
(
sy
-
dy
)
<
LS_MV_MAX
)
{
A
[
0
][
0
]
+=
LS_SQUARE
(
sx
);
A
[
0
][
1
]
+=
LS_PRODUCT1
(
sx
,
sy
);
A
[
0
][
2
]
+=
LS_SUM
(
sx
);
A
[
1
][
1
]
+=
LS_SQUARE
(
sy
);
A
[
1
][
2
]
+=
LS_SUM
(
sy
);
A
[
2
][
2
]
+=
4
;
Bx
[
0
]
+=
LS_PRODUCT2
(
sx
,
dx
);
Bx
[
1
]
+=
LS_PRODUCT1
(
sy
,
dx
);
Bx
[
2
]
+=
LS_SUM
(
dx
);
By
[
0
]
+=
LS_PRODUCT1
(
sx
,
dy
);
By
[
1
]
+=
LS_PRODUCT2
(
sy
,
dy
);
By
[
2
]
+=
LS_SUM
(
dy
);
n
++
;
}
// Contribution from neighbor block
for
(
i
=
0
;
i
<
np
&&
n
<
LEAST_SQUARES_SAMPLES_MAX
;
i
++
)
{
dx
=
pts2
[
i
*
2
]
-
ux
;
dy
=
pts2
[
i
*
2
+
1
]
-
uy
;
sx
=
pts1
[
i
*
2
]
-
ux
;
sy
=
pts1
[
i
*
2
+
1
]
-
uy
;
if
(
abs
(
sx
-
dx
)
<
LS_MV_MAX
&&
abs
(
sy
-
dy
)
<
LS_MV_MAX
)
{
A
[
0
][
0
]
+=
LS_SQUARE
(
sx
);
A
[
0
][
1
]
+=
LS_PRODUCT1
(
sx
,
sy
);
A
[
0
][
2
]
+=
LS_SUM
(
sx
);
A
[
1
][
1
]
+=
LS_SQUARE
(
sy
);
A
[
1
][
2
]
+=
LS_SUM
(
sy
);
A
[
2
][
2
]
+=
4
;
Bx
[
0
]
+=
LS_PRODUCT2
(
sx
,
dx
);
Bx
[
1
]
+=
LS_PRODUCT1
(
sy
,
dx
);
Bx
[
2
]
+=
LS_SUM
(
dx
);
By
[
0
]
+=
LS_PRODUCT1
(
sx
,
dy
);
By
[
1
]
+=
LS_PRODUCT2
(
sy
,
dy
);
By
[
2
]
+=
LS_SUM
(
dy
);
n
++
;
}
}
// Compute Cofactors of A
C00
=
(
int64_t
)
A
[
1
][
1
]
*
A
[
2
][
2
]
-
(
int64_t
)
A
[
1
][
2
]
*
A
[
1
][
2
];
C01
=
(
int64_t
)
A
[
1
][
2
]
*
A
[
0
][
2
]
-
(
int64_t
)
A
[
0
][
1
]
*
A
[
2
][
2
];
C02
=
(
int64_t
)
A
[
0
][
1
]
*
A
[
1
][
2
]
-
(
int64_t
)
A
[
0
][
2
]
*
A
[
1
][
1
];
C11
=
(
int64_t
)
A
[
0
][
0
]
*
A
[
2
][
2
]
-
(
int64_t
)
A
[
0
][
2
]
*
A
[
0
][
2
];
C12
=
(
int64_t
)
A
[
0
][
1
]
*
A
[
0
][
2
]
-
(
int64_t
)
A
[
0
][
0
]
*
A
[
1
][
2
];
C22
=
(
int64_t
)
A
[
0
][
0
]
*
A
[
1
][
1
]
-
(
int64_t
)
A
[
0
][
1
]
*
A
[
0
][
1
];
// Scale by 1/64
C00
=
ROUND_POWER_OF_TWO_SIGNED
(
C00
,
6
);
C01
=
ROUND_POWER_OF_TWO_SIGNED
(
C01
,
6
);
C02
=
ROUND_POWER_OF_TWO_SIGNED
(
C02
,
6
);
C11
=
ROUND_POWER_OF_TWO_SIGNED
(
C11
,
6
);
C12
=
ROUND_POWER_OF_TWO_SIGNED
(
C12
,
6
);
C22
=
ROUND_POWER_OF_TWO_SIGNED
(
C22
,
6
);
// Compute Determinant of A
Det
=
C00
*
A
[
0
][
0
]
+
C01
*
A
[
0
][
1
]
+
C02
*
A
[
0
][
2
];
if
(
Det
==
0
)
return
1
;
// These divided by the Det, are the least squares solutions
Px
[
0
]
=
C00
*
Bx
[
0
]
+
C01
*
Bx
[
1
]
+
C02
*
Bx
[
2
];
Px
[
1
]
=
C01
*
Bx
[
0
]
+
C11
*
Bx
[
1
]
+
C12
*
Bx
[
2
];
Px
[
2
]
=
C02
*
Bx
[
0
]
+
C12
*
Bx
[
1
]
+
C22
*
Bx
[
2
];
Py
[
0
]
=
C00
*
By
[
0
]
+
C01
*
By
[
1
]
+
C02
*
By
[
2
];
Py
[
1
]
=
C01
*
By
[
0
]
+
C11
*
By
[
1
]
+
C12
*
By
[
2
];
Py
[
2
]
=
C02
*
By
[
0
]
+
C12
*
By
[
1
]
+
C22
*
By
[
2
];
int16_t
shift
;
int64_t
iDet
;
iDet
=
resolve_divisor_64
(
llabs
(
Det
),
&
shift
)
*
(
Det
<
0
?
-
1
:
1
);
shift
-=
WARPEDMODEL_PREC_BITS
;
if
(
shift
<
0
)
{
iDet
<<=
(
-
shift
);
shift
=
0
;
}
v
=
Px
[
0
]
*
iDet
;
wm
->
wmmat
[
2
]
=
ROUND_POWER_OF_TWO_SIGNED_64
(
v
,
shift
);
v
=
Px
[
1
]
*
iDet
;
wm
->
wmmat
[
3
]
=
ROUND_POWER_OF_TWO_SIGNED_64
(
v
,
shift
);
v
=
Px
[
2
]
*
iDet
;
wm
->
wmmat
[
0
]
=
ROUND_POWER_OF_TWO_SIGNED_64
(
v
,
shift
+
3
);
// Adjust x displacement for the offset
off
=
(
ux
<<
WARPEDMODEL_PREC_BITS
)
-
ux
*
wm
->
wmmat
[
2
]
-
uy
*
wm
->
wmmat
[
3
];
wm
->
wmmat
[
0
]
+=
ROUND_POWER_OF_TWO_SIGNED
(
off
,
3
);
v
=
Py
[
0
]
*
iDet
;
wm
->
wmmat
[
4
]
=
ROUND_POWER_OF_TWO_SIGNED_64
(
v
,
shift
);
v
=
Py
[
1
]
*
iDet
;
wm
->
wmmat
[
5
]
=
ROUND_POWER_OF_TWO_SIGNED_64
(
v
,
shift
);
v
=
Py
[
2
]
*
iDet
;
wm
->
wmmat
[
1
]
=
ROUND_POWER_OF_TWO_SIGNED_64
(
v
,
shift
+
3
);
// Adjust y displacement for the offset
off
=
(
uy
<<
WARPEDMODEL_PREC_BITS
)
-
ux
*
wm
->
wmmat
[
4
]
-
uy
*
wm
->
wmmat
[
5
];
wm
->
wmmat
[
1
]
+=
ROUND_POWER_OF_TWO_SIGNED
(
off
,
3
);
wm
->
wmmat
[
6
]
=
wm
->
wmmat
[
7
]
=
0
;
// Clamp values
wm
->
wmmat
[
0
]
=
clamp
(
wm
->
wmmat
[
0
],
-
WARPEDMODEL_TRANS_CLAMP
,
WARPEDMODEL_TRANS_CLAMP
-
1
);
wm
->
wmmat
[
1
]
=
clamp
(
wm
->
wmmat
[
1
],
-
WARPEDMODEL_TRANS_CLAMP
,
WARPEDMODEL_TRANS_CLAMP
-
1
);
wm
->
wmmat
[
2
]
=
clamp
(
wm
->
wmmat
[
2
],
-
WARPEDMODEL_DIAGAFFINE_CLAMP
,
WARPEDMODEL_DIAGAFFINE_CLAMP
-
1
);
wm
->
wmmat
[
5
]
=
clamp
(
wm
->
wmmat
[
5
],
-
WARPEDMODEL_DIAGAFFINE_CLAMP
,
WARPEDMODEL_DIAGAFFINE_CLAMP
-
1
);
wm
->
wmmat
[
3
]
=
clamp
(
wm
->
wmmat
[
3
],
-
WARPEDMODEL_NONDIAGAFFINE_CLAMP
,
WARPEDMODEL_NONDIAGAFFINE_CLAMP
-
1
);
wm
->
wmmat
[
4
]
=
clamp
(
wm
->
wmmat
[
4
],
-
WARPEDMODEL_NONDIAGAFFINE_CLAMP
,
WARPEDMODEL_NONDIAGAFFINE_CLAMP
-
1
);
return
0
;
}
#endif // LEAST_SQUARES_ORDER == 2
int
find_projection
(
int
np
,
int
*
pts1
,
int
*
pts2
,
BLOCK_SIZE
bsize
,
int
mvy
,
int
mvx
,
WarpedMotionParams
*
wm_params
,
int
mi_row
,
int
mi_col
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment