Commit 1a2b35f9 authored by Debargha Mukherjee's avatar Debargha Mukherjee

Remove code for homography models

Change-Id: Ib93f090f395e52bd69c59e1229e2e035a8772af5
parent 945176aa
......@@ -71,10 +71,7 @@ typedef enum {
TRANSLATION = 1, // translational motion 2-parameter
ROTZOOM = 2, // simplified affine with rotation + zoom only, 4-parameter
AFFINE = 3, // affine, 6-parameter
HORTRAPEZOID = 4, // constrained homography, hor trapezoid, 6-parameter
VERTRAPEZOID = 5, // constrained homography, ver trapezoid, 6-parameter
HOMOGRAPHY = 6, // homography, 8-parameter
TRANS_TYPES = 7,
TRANS_TYPES,
} TransformationType;
/* clang-format on */
......@@ -103,7 +100,7 @@ typedef struct {
} WarpTypesAllowed;
// number of parameters used by each transformation in TransformationTypes
static const int trans_model_params[TRANS_TYPES] = { 0, 2, 4, 6, 6, 6, 8 };
static const int trans_model_params[TRANS_TYPES] = { 0, 2, 4, 6 };
// The order of values in the wmmat matrix below is best described
// by the homography:
......@@ -308,11 +305,6 @@ static INLINE int_mv gm_get_motion_vector(const WarpedMotionParams *gm,
}
static INLINE TransformationType get_gmtype(const WarpedMotionParams *gm) {
if (gm->wmmat[6] != 0 || gm->wmmat[7] != 0) {
if (!gm->wmmat[6] && !gm->wmmat[4]) return HORTRAPEZOID;
if (!gm->wmmat[7] && !gm->wmmat[3]) return VERTRAPEZOID;
return HOMOGRAPHY;
}
if (gm->wmmat[5] == (1 << WARPEDMODEL_PREC_BITS) && !gm->wmmat[4] &&
gm->wmmat[2] == (1 << WARPEDMODEL_PREC_BITS) && !gm->wmmat[3]) {
return ((!gm->wmmat[1] && !gm->wmmat[0]) ? IDENTITY : TRANSLATION);
......
......@@ -93,9 +93,6 @@ static const int error_measure_lut[512] = {
static ProjectPointsFunc get_project_points_type(TransformationType type) {
switch (type) {
case VERTRAPEZOID: return project_points_vertrapezoid;
case HORTRAPEZOID: return project_points_hortrapezoid;
case HOMOGRAPHY: return project_points_homography;
case AFFINE: return project_points_affine;
case ROTZOOM: return project_points_rotzoom;
case TRANSLATION: return project_points_translation;
......
......@@ -2829,21 +2829,6 @@ static int read_global_motion_params(WarpedMotionParams *params,
*params = default_warp_params;
params->wmtype = type;
switch (type) {
case HOMOGRAPHY:
case HORTRAPEZOID:
case VERTRAPEZOID:
if (type != HORTRAPEZOID)
params->wmmat[6] =
aom_rb_read_signed_primitive_refsubexpfin(
rb, GM_ROW3HOMO_MAX + 1, SUBEXPFIN_K,
(ref_params->wmmat[6] >> GM_ROW3HOMO_PREC_DIFF)) *
GM_ROW3HOMO_DECODE_FACTOR;
if (type != VERTRAPEZOID)
params->wmmat[7] =
aom_rb_read_signed_primitive_refsubexpfin(
rb, GM_ROW3HOMO_MAX + 1, SUBEXPFIN_K,
(ref_params->wmmat[7] >> GM_ROW3HOMO_PREC_DIFF)) *
GM_ROW3HOMO_DECODE_FACTOR;
case AFFINE:
case ROTZOOM:
params->wmmat[2] = aom_rb_read_signed_primitive_refsubexpfin(
......@@ -2852,17 +2837,15 @@ static int read_global_motion_params(WarpedMotionParams *params,
(1 << GM_ALPHA_PREC_BITS)) *
GM_ALPHA_DECODE_FACTOR +
(1 << WARPEDMODEL_PREC_BITS);
if (type != VERTRAPEZOID)
params->wmmat[3] = aom_rb_read_signed_primitive_refsubexpfin(
params->wmmat[3] = aom_rb_read_signed_primitive_refsubexpfin(
rb, GM_ALPHA_MAX + 1, SUBEXPFIN_K,
(ref_params->wmmat[3] >> GM_ALPHA_PREC_DIFF)) *
GM_ALPHA_DECODE_FACTOR;
if (type >= AFFINE) {
params->wmmat[4] = aom_rb_read_signed_primitive_refsubexpfin(
rb, GM_ALPHA_MAX + 1, SUBEXPFIN_K,
(ref_params->wmmat[3] >> GM_ALPHA_PREC_DIFF)) *
(ref_params->wmmat[4] >> GM_ALPHA_PREC_DIFF)) *
GM_ALPHA_DECODE_FACTOR;
if (type >= AFFINE) {
if (type != HORTRAPEZOID)
params->wmmat[4] = aom_rb_read_signed_primitive_refsubexpfin(
rb, GM_ALPHA_MAX + 1, SUBEXPFIN_K,
(ref_params->wmmat[4] >> GM_ALPHA_PREC_DIFF)) *
GM_ALPHA_DECODE_FACTOR;
params->wmmat[5] = aom_rb_read_signed_primitive_refsubexpfin(
rb, GM_ALPHA_MAX + 1, SUBEXPFIN_K,
(ref_params->wmmat[5] >> GM_ALPHA_PREC_DIFF) -
......
......@@ -3914,20 +3914,6 @@ static void write_global_motion_params(const WarpedMotionParams *params,
}
switch (type) {
case HOMOGRAPHY:
case HORTRAPEZOID:
case VERTRAPEZOID:
if (type != HORTRAPEZOID)
aom_wb_write_signed_primitive_refsubexpfin(
wb, GM_ROW3HOMO_MAX + 1, SUBEXPFIN_K,
(ref_params->wmmat[6] >> GM_ROW3HOMO_PREC_DIFF),
(params->wmmat[6] >> GM_ROW3HOMO_PREC_DIFF));
if (type != VERTRAPEZOID)
aom_wb_write_signed_primitive_refsubexpfin(
wb, GM_ROW3HOMO_MAX + 1, SUBEXPFIN_K,
(ref_params->wmmat[7] >> GM_ROW3HOMO_PREC_DIFF),
(params->wmmat[7] >> GM_ROW3HOMO_PREC_DIFF));
// fallthrough intended
case AFFINE:
case ROTZOOM:
aom_wb_write_signed_primitive_refsubexpfin(
......@@ -3935,17 +3921,15 @@ static void write_global_motion_params(const WarpedMotionParams *params,
(ref_params->wmmat[2] >> GM_ALPHA_PREC_DIFF) -
(1 << GM_ALPHA_PREC_BITS),
(params->wmmat[2] >> GM_ALPHA_PREC_DIFF) - (1 << GM_ALPHA_PREC_BITS));
if (type != VERTRAPEZOID)
aom_wb_write_signed_primitive_refsubexpfin(
wb, GM_ALPHA_MAX + 1, SUBEXPFIN_K,
(ref_params->wmmat[3] >> GM_ALPHA_PREC_DIFF),
(params->wmmat[3] >> GM_ALPHA_PREC_DIFF));
if (type >= AFFINE) {
aom_wb_write_signed_primitive_refsubexpfin(
wb, GM_ALPHA_MAX + 1, SUBEXPFIN_K,
(ref_params->wmmat[3] >> GM_ALPHA_PREC_DIFF),
(params->wmmat[3] >> GM_ALPHA_PREC_DIFF));
if (type >= AFFINE) {
if (type != HORTRAPEZOID)
aom_wb_write_signed_primitive_refsubexpfin(
wb, GM_ALPHA_MAX + 1, SUBEXPFIN_K,
(ref_params->wmmat[4] >> GM_ALPHA_PREC_DIFF),
(params->wmmat[4] >> GM_ALPHA_PREC_DIFF));
(ref_params->wmmat[4] >> GM_ALPHA_PREC_DIFF),
(params->wmmat[4] >> GM_ALPHA_PREC_DIFF));
aom_wb_write_signed_primitive_refsubexpfin(
wb, GM_ALPHA_MAX + 1, SUBEXPFIN_K,
(ref_params->wmmat[5] >> GM_ALPHA_PREC_DIFF) -
......
......@@ -3654,37 +3654,21 @@ static int gm_get_params_cost(const WarpedMotionParams *gm,
int params_cost = 0;
int trans_bits, trans_prec_diff;
switch (gm->wmtype) {
case HOMOGRAPHY:
case HORTRAPEZOID:
case VERTRAPEZOID:
if (gm->wmtype != HORTRAPEZOID)
params_cost += aom_count_signed_primitive_refsubexpfin(
GM_ROW3HOMO_MAX + 1, SUBEXPFIN_K,
(ref_gm->wmmat[6] >> GM_ROW3HOMO_PREC_DIFF),
(gm->wmmat[6] >> GM_ROW3HOMO_PREC_DIFF));
if (gm->wmtype != VERTRAPEZOID)
params_cost += aom_count_signed_primitive_refsubexpfin(
GM_ROW3HOMO_MAX + 1, SUBEXPFIN_K,
(ref_gm->wmmat[7] >> GM_ROW3HOMO_PREC_DIFF),
(gm->wmmat[7] >> GM_ROW3HOMO_PREC_DIFF));
// Fallthrough intended
case AFFINE:
case ROTZOOM:
params_cost += aom_count_signed_primitive_refsubexpfin(
GM_ALPHA_MAX + 1, SUBEXPFIN_K,
(ref_gm->wmmat[2] >> GM_ALPHA_PREC_DIFF) - (1 << GM_ALPHA_PREC_BITS),
(gm->wmmat[2] >> GM_ALPHA_PREC_DIFF) - (1 << GM_ALPHA_PREC_BITS));
if (gm->wmtype != VERTRAPEZOID)
params_cost += aom_count_signed_primitive_refsubexpfin(
GM_ALPHA_MAX + 1, SUBEXPFIN_K,
(ref_gm->wmmat[3] >> GM_ALPHA_PREC_DIFF),
(gm->wmmat[3] >> GM_ALPHA_PREC_DIFF));
if (gm->wmtype >= AFFINE) {
params_cost += aom_count_signed_primitive_refsubexpfin(
GM_ALPHA_MAX + 1, SUBEXPFIN_K,
(ref_gm->wmmat[3] >> GM_ALPHA_PREC_DIFF),
(gm->wmmat[3] >> GM_ALPHA_PREC_DIFF));
if (gm->wmtype >= AFFINE) {
if (gm->wmtype != HORTRAPEZOID)
params_cost += aom_count_signed_primitive_refsubexpfin(
GM_ALPHA_MAX + 1, SUBEXPFIN_K,
(ref_gm->wmmat[4] >> GM_ALPHA_PREC_DIFF),
(gm->wmmat[4] >> GM_ALPHA_PREC_DIFF));
(ref_gm->wmmat[4] >> GM_ALPHA_PREC_DIFF),
(gm->wmmat[4] >> GM_ALPHA_PREC_DIFF));
params_cost += aom_count_signed_primitive_refsubexpfin(
GM_ALPHA_MAX + 1, SUBEXPFIN_K,
(ref_gm->wmmat[5] >> GM_ALPHA_PREC_DIFF) -
......
......@@ -116,9 +116,6 @@ static void force_wmtype(WarpedMotionParams *wm, TransformationType wmtype) {
wm->wmmat[3] = 0;
case ROTZOOM: wm->wmmat[4] = -wm->wmmat[3]; wm->wmmat[5] = wm->wmmat[2];
case AFFINE: wm->wmmat[6] = wm->wmmat[7] = 0; break;
case HORTRAPEZOID: wm->wmmat[6] = wm->wmmat[4] = 0; break;
case VERTRAPEZOID: wm->wmmat[7] = wm->wmmat[3] = 0; break;
case HOMOGRAPHY: break;
default: assert(0);
}
wm->wmtype = wmtype;
......@@ -134,7 +131,7 @@ int64_t refine_integerized_param(WarpedMotionParams *wm,
int d_height, int d_stride, int n_refinements,
int64_t best_frame_error) {
static const int max_trans_model_params[TRANS_TYPES] = {
0, 2, 4, 6, 8, 8, 8
0, 2, 4, 6,
};
const int border = ERRORADV_BORDER;
int i = 0, p;
......@@ -161,8 +158,6 @@ int64_t refine_integerized_param(WarpedMotionParams *wm,
for (p = 0; p < n_params; ++p) {
int step_dir = 0;
// Skip searches for parameters that are forced to be 0
if (wmtype == HORTRAPEZOID && (p == 4 || p == 6)) continue;
if (wmtype == VERTRAPEZOID && (p == 3 || p == 7)) continue;
param = param_mat + p;
curr_param = *param;
best_param = curr_param;
......@@ -229,9 +224,6 @@ int64_t refine_integerized_param(WarpedMotionParams *wm,
static INLINE RansacFunc get_ransac_type(TransformationType type) {
switch (type) {
case HOMOGRAPHY: return ransac_homography;
case HORTRAPEZOID: return ransac_hortrapezoid;
case VERTRAPEZOID: return ransac_vertrapezoid;
case AFFINE: return ransac_affine;
case ROTZOOM: return ransac_rotzoom;
case TRANSLATION: return ransac_translation;
......
This diff is collapsed.
......@@ -25,17 +25,8 @@ typedef int (*RansacFunc)(int *matched_points, int npoints,
/* Each of these functions fits a motion model from a set of
corresponding points in 2 frames using RANSAC. */
int ransac_homography(int *matched_points, int npoints,
int *num_inliers_by_motion, double *params_by_motion,
int num_motions);
int ransac_affine(int *matched_points, int npoints, int *num_inliers_by_motion,
double *params_by_motion, int num_motions);
int ransac_hortrapezoid(int *matched_points, int npoints,
int *num_inliers_by_motion, double *params_by_motion,
int num_motions);
int ransac_vertrapezoid(int *matched_points, int npoints,
int *num_inliers_by_motion, double *params_by_motion,
int num_motions);
int ransac_rotzoom(int *matched_points, int npoints, int *num_inliers_by_motion,
double *params_by_motion, int num_motions);
int ransac_translation(int *matched_points, int npoints,
......
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