Commit f9a961c5 authored by Sarah Parker's avatar Sarah Parker

Style fixes for global motion experiment

These are in response to a post-commit review in
Ib6664df44090e8cfa4db9f2f9e0556931ccfe5c8

Change-Id: I1e07ccab18558dfdd996547a72a396abe02ed23d
parent 67948d31
......@@ -16,20 +16,20 @@
#include "av1/common/warped_motion.h"
static ProjectPointsType get_project_points_type(TransformationType type) {
static ProjectPointsFunc get_project_points_type(TransformationType type) {
switch (type) {
case HOMOGRAPHY: return projectPointsHomography;
case AFFINE: return projectPointsAffine;
case ROTZOOM: return projectPointsRotZoom;
case TRANSLATION: return projectPointsTranslation;
case HOMOGRAPHY: return project_points_homography;
case AFFINE: return project_points_affine;
case ROTZOOM: return project_points_rotzoom;
case TRANSLATION: return project_points_translation;
default: assert(0); return NULL;
}
}
void projectPointsTranslation(int16_t *mat, int *points, int *proj, const int n,
const int stride_points, const int stride_proj,
const int subsampling_x,
const int subsampling_y) {
void project_points_translation(int16_t *mat, int *points, int *proj,
const int n, const int stride_points,
const int stride_proj, const int subsampling_x,
const int subsampling_y) {
int i;
for (i = 0; i < n; ++i) {
const int x = *(points++), y = *(points++);
......@@ -52,9 +52,9 @@ void projectPointsTranslation(int16_t *mat, int *points, int *proj, const int n,
}
}
void projectPointsRotZoom(int16_t *mat, int *points, int *proj, const int n,
const int stride_points, const int stride_proj,
const int subsampling_x, const int subsampling_y) {
void project_points_rotzoom(int16_t *mat, int *points, int *proj, const int n,
const int stride_points, const int stride_proj,
const int subsampling_x, const int subsampling_y) {
int i;
for (i = 0; i < n; ++i) {
const int x = *(points++), y = *(points++);
......@@ -79,9 +79,9 @@ void projectPointsRotZoom(int16_t *mat, int *points, int *proj, const int n,
}
}
void projectPointsAffine(int16_t *mat, int *points, int *proj, const int n,
const int stride_points, const int stride_proj,
const int subsampling_x, const int subsampling_y) {
void project_points_affine(int16_t *mat, int *points, int *proj, const int n,
const int stride_points, const int stride_proj,
const int subsampling_x, const int subsampling_y) {
int i;
for (i = 0; i < n; ++i) {
const int x = *(points++), y = *(points++);
......@@ -106,9 +106,10 @@ void projectPointsAffine(int16_t *mat, int *points, int *proj, const int n,
}
}
void projectPointsHomography(int16_t *mat, int *points, int *proj, const int n,
const int stride_points, const int stride_proj,
const int subsampling_x, const int subsampling_y) {
void project_points_homography(int16_t *mat, int *points, int *proj,
const int n, const int stride_points,
const int stride_proj, const int subsampling_x,
const int subsampling_y) {
int i;
int64_t x, y, Z;
int64_t xp, yp;
......@@ -226,24 +227,6 @@ static int32_t do_cubic_filter(int32_t *p, int x) {
}
}
/*
static int32_t do_linear_filter(int32_t *p, int x) {
int32_t sum = 0;
sum = p[0] * (WARPEDPIXEL_PREC_SHIFTS - x) + p[1] * x;
sum <<= (WARPEDPIXEL_FILTER_BITS - WARPEDPIXEL_PREC_BITS);
return sum;
}
static int32_t do_4tap_filter(int32_t *p, int x) {
int i;
int32_t sum = 0;
for (i = 0; i < 4; ++i) {
sum += p[i - 1] * filter_4tap[x][i];
}
return sum;
}
*/
static INLINE void get_subcolumn(int taps, uint8_t *ref, int32_t *col,
int stride, int x, int y_start) {
int i;
......@@ -473,7 +456,7 @@ static double highbd_warp_erroradv(WarpedMotionParams *wm, uint8_t *ref8,
int subsampling_x, int subsampling_y,
int x_scale, int y_scale, int bd) {
int i, j;
ProjectPointsType projectpoints = get_project_points_type(wm->wmtype);
ProjectPointsFunc projectpoints = get_project_points_type(wm->wmtype);
uint16_t *dst = CONVERT_TO_SHORTPTR(dst8);
uint16_t *ref = CONVERT_TO_SHORTPTR(ref8);
int gm_err = 0, no_gm_err = 0;
......@@ -506,7 +489,7 @@ static void highbd_warp_plane(WarpedMotionParams *wm, uint8_t *ref8, int width,
int subsampling_y, int x_scale, int y_scale,
int bd) {
int i, j;
ProjectPointsType projectpoints = get_project_points_type(wm->wmtype);
ProjectPointsFunc projectpoints = get_project_points_type(wm->wmtype);
uint16_t *pred = CONVERT_TO_SHORTPTR(pred8);
uint16_t *ref = CONVERT_TO_SHORTPTR(ref8);
if (projectpoints == NULL) return;
......@@ -534,7 +517,7 @@ static double warp_erroradv(WarpedMotionParams *wm, uint8_t *ref, int width,
int gm_err = 0, no_gm_err = 0;
int gm_sumerr = 0, no_gm_sumerr = 0;
int i, j;
ProjectPointsType projectpoints = get_project_points_type(wm->wmtype);
ProjectPointsFunc projectpoints = get_project_points_type(wm->wmtype);
for (i = p_row; i < p_row + p_height; ++i) {
for (j = p_col; j < p_col + p_width; ++j) {
int in[2], out[2];
......@@ -561,7 +544,7 @@ static void warp_plane(WarpedMotionParams *wm, uint8_t *ref, int width,
int subsampling_x, int subsampling_y, int x_scale,
int y_scale) {
int i, j;
ProjectPointsType projectpoints = get_project_points_type(wm->wmtype);
ProjectPointsFunc projectpoints = get_project_points_type(wm->wmtype);
if (projectpoints == NULL) return;
for (i = p_row; i < p_row + p_height; ++i) {
for (j = p_col; j < p_col + p_width; ++j) {
......@@ -591,11 +574,10 @@ double av1_warp_erroradv(WarpedMotionParams *wm,
return highbd_warp_erroradv(
wm, ref, width, height, stride, dst, p_col, p_row, p_width, p_height,
p_stride, subsampling_x, subsampling_y, x_scale, y_scale, bd);
else
#endif // CONFIG_AOM_HIGHBITDEPTH
return warp_erroradv(wm, ref, width, height, stride, dst, p_col, p_row,
p_width, p_height, p_stride, subsampling_x,
subsampling_y, x_scale, y_scale);
return warp_erroradv(wm, ref, width, height, stride, dst, p_col, p_row,
p_width, p_height, p_stride, subsampling_x,
subsampling_y, x_scale, y_scale);
}
void av1_warp_plane(WarpedMotionParams *wm,
......
......@@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef AV1_COMMON_WARPED_MOTION_H
#define AV1_COMMON_WARPED_MOTION_H
#ifndef AV1_COMMON_WARPED_MOTION_H_
#define AV1_COMMON_WARPED_MOTION_H_
#include <stdio.h>
#include <stdlib.h>
......@@ -22,43 +22,29 @@
#include "aom_dsp/aom_dsp_common.h"
#include "av1/common/mv.h"
// Bits of precision used for the model
#define WARPEDMODEL_PREC_BITS 8
#define WARPEDMODEL_ROW3HOMO_PREC_BITS 12
// Bits of subpel precision for warped interpolation
#define WARPEDPIXEL_PREC_BITS 6
#define WARPEDPIXEL_PREC_SHIFTS (1 << WARPEDPIXEL_PREC_BITS)
// Taps for ntap filter
#define WARPEDPIXEL_FILTER_TAPS 6
// Precision of filter taps
#define WARPEDPIXEL_FILTER_BITS 7
#define WARPEDDIFF_PREC_BITS (WARPEDMODEL_PREC_BITS - WARPEDPIXEL_PREC_BITS)
typedef void (*ProjectPointsType)(int16_t *mat, int *points, int *proj,
typedef void (*ProjectPointsFunc)(int16_t *mat, int *points, int *proj,
const int n, const int stride_points,
const int stride_proj,
const int subsampling_x,
const int subsampling_y);
void projectPointsHomography(int16_t *mat, int *points, int *proj, const int n,
const int stride_points, const int stride_proj,
const int subsampling_x, const int subsampling_y);
void project_points_translation(int16_t *mat, int *points, int *proj,
const int n, const int stride_points,
const int stride_proj, const int subsampling_x,
const int subsampling_y);
void projectPointsAffine(int16_t *mat, int *points, int *proj, const int n,
const int stride_points, const int stride_proj,
const int subsampling_x, const int subsampling_y);
void project_points_rotzoom(int16_t *mat, int *points, int *proj, const int n,
const int stride_points, const int stride_proj,
const int subsampling_x, const int subsampling_y);
void projectPointsRotZoom(int16_t *mat, int *points, int *proj, const int n,
const int stride_points, const int stride_proj,
const int subsampling_x, const int subsampling_y);
void project_points_affine(int16_t *mat, int *points, int *proj, const int n,
const int stride_points, const int stride_proj,
const int subsampling_x, const int subsampling_y);
void projectPointsTranslation(int16_t *mat, int *points, int *proj, const int n,
const int stride_points, const int stride_proj,
const int subsampling_x, const int subsampling_y);
void project_points_homography(int16_t *mat, int *points, int *proj,
const int n, const int stride_points,
const int stride_proj, const int subsampling_x,
const int subsampling_y);
double av1_warp_erroradv(WarpedMotionParams *wm,
#if CONFIG_AOM_HIGHBITDEPTH
......@@ -81,4 +67,4 @@ void av1_warp_plane(WarpedMotionParams *wm,
// Integerize model into the WarpedMotionParams structure
void av1_integerize_model(const double *model, TransformationType wmtype,
WarpedMotionParams *wm);
#endif // AV1_COMMON_WARPED_MOTION_H
#endif // AV1_COMMON_WARPED_MOTION_H_
/*
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
* Copyright (c) 2016 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
......@@ -14,22 +14,23 @@
#include <math.h>
#include <assert.h>
#include "av1/encoder/corner_detect.h"
#include "third_party/fastfeat/fast.h"
#include "av1/encoder/corner_detect.h"
// Fast_9 wrapper
#define FAST_BARRIER 40
int FastCornerDetect(unsigned char *buf, int width, int height, int stride,
int *points, int max_points) {
int fast_corner_detect(unsigned char *buf, int width, int height, int stride,
int *points, int max_points) {
int num_points;
xy *frm_corners_xy = fast9_detect_nonmax(buf, width, height, stride,
FAST_BARRIER, &num_points);
xy *const frm_corners_xy = fast9_detect_nonmax(buf, width, height, stride,
FAST_BARRIER, &num_points);
num_points = (num_points <= max_points ? num_points : max_points);
if (num_points > 0 && frm_corners_xy) {
memcpy(points, frm_corners_xy, sizeof(xy) * num_points);
memcpy(points, frm_corners_xy, sizeof(*frm_corners_xy) * num_points);
free(frm_corners_xy);
return num_points;
} else {
return 0;
}
free(frm_corners_xy);
return 0;
}
/*
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
* Copyright (c) 2016 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
......@@ -15,7 +15,7 @@
#include <stdlib.h>
#include <memory.h>
int FastCornerDetect(unsigned char *buf, int width, int height, int stride,
int *points, int max_points);
int fast_corner_detect(unsigned char *buf, int width, int height, int stride,
int *points, int max_points);
#endif // AV1_ENCODER_CORNER_DETECT_H
#endif // AV1_ENCODER_CORNER_DETECT_H_
/*
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
* Copyright (c) 2016 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
......@@ -76,7 +76,7 @@ static int is_eligible_distance(double point1x, double point1y, double point2x,
static void improve_correspondence(unsigned char *frm, unsigned char *ref,
int width, int height, int frm_stride,
int ref_stride,
correspondence *correspondences,
Correspondence *correspondences,
int num_correspondences) {
int i;
for (i = 0; i < num_correspondences; ++i) {
......@@ -161,7 +161,7 @@ int determine_correspondence(unsigned char *frm, int *frm_corners,
double *correspondence_pts) {
// TODO(sarahparker) Improve this to include 2-way match
int i, j;
correspondence *correspondences = (correspondence *)correspondence_pts;
Correspondence *correspondences = (Correspondence *)correspondence_pts;
int num_correspondences = 0;
for (i = 0; i < num_frm_corners; ++i) {
double best_match_ncc = 0.0;
......
/*
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
* Copyright (c) 2016 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
......@@ -18,7 +18,7 @@
typedef struct {
double x, y;
double rx, ry;
} correspondence;
} Correspondence;
int determine_correspondence(unsigned char *frm, int *frm_corners,
int num_frm_corners, unsigned char *ref,
......@@ -26,4 +26,4 @@ int determine_correspondence(unsigned char *frm, int *frm_corners,
int height, int frm_stride, int ref_stride,
double *correspondence_pts);
#endif // AV1_ENCODER_CORNER_MATCH_H
#endif // AV1_ENCODER_CORNER_MATCH_H_
......@@ -4481,13 +4481,13 @@ static void refine_integerized_param(WarpedMotionParams *wm,
}
}
static void convert_to_params(double *H, TransformationType type,
static void convert_to_params(const double *params, TransformationType type,
int16_t *model) {
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);
model[1] = (int16_t)floor(H[1] * (1 << GM_TRANS_PREC_BITS) + 0.5);
model[0] = (int16_t)floor(params[0] * (1 << GM_TRANS_PREC_BITS) + 0.5);
model[1] = (int16_t)floor(params[1] * (1 << GM_TRANS_PREC_BITS) + 0.5);
model[0] = (int16_t)clamp(model[0], GM_TRANS_MIN, GM_TRANS_MAX) *
GM_TRANS_DECODE_FACTOR;
model[1] = (int16_t)clamp(model[1], GM_TRANS_MIN, GM_TRANS_MAX) *
......@@ -4495,7 +4495,7 @@ static void convert_to_params(double *H, TransformationType type,
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)floor(params[i] * (1 << GM_ALPHA_PREC_BITS) + 0.5);
model[i] =
(int16_t)(clamp(model[i] - diag_value, GM_ALPHA_MIN, GM_ALPHA_MAX) +
diag_value) *
......@@ -4511,11 +4511,12 @@ static void convert_to_params(double *H, TransformationType type,
}
}
static void convert_model_to_params(double *H, TransformationType type,
static void convert_model_to_params(const double *params,
TransformationType type,
Global_Motion_Params *model) {
// TODO(sarahparker) implement for homography
if (type > HOMOGRAPHY)
convert_to_params(H, type, (int16_t *)model->motion_params.wmmat);
convert_to_params(params, type, (int16_t *)model->motion_params.wmmat);
model->gmtype = get_gmtype(model);
model->motion_params.wmtype = gm_to_trans_type(model->gmtype);
}
......@@ -4547,13 +4548,14 @@ static void encode_frame_internal(AV1_COMP *cpi) {
if (cpi->common.frame_type == INTER_FRAME && cpi->Source) {
YV12_BUFFER_CONFIG *ref_buf;
int frame;
double H[9] = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
double erroradvantage = 0;
double params[9] = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
for (frame = LAST_FRAME; frame <= ALTREF_FRAME; ++frame) {
ref_buf = get_ref_frame_buffer(cpi, frame);
if (ref_buf) {
if (compute_global_motion_feature_based(GLOBAL_MOTION_MODEL,
cpi->Source, ref_buf, H)) {
convert_model_to_params(H, GLOBAL_MOTION_MODEL,
cpi->Source, ref_buf, params)) {
convert_model_to_params(params, GLOBAL_MOTION_MODEL,
&cm->global_motion[frame]);
if (get_gmtype(&cm->global_motion[frame]) > GLOBAL_ZERO) {
refine_integerized_param(
......@@ -4565,7 +4567,7 @@ static void encode_frame_internal(AV1_COMP *cpi) {
ref_buf->y_stride, cpi->Source->y_buffer, cpi->Source->y_width,
cpi->Source->y_height, cpi->Source->y_stride, 3);
// compute the advantage of using gm parameters over 0 motion
double erroradvantage = av1_warp_erroradv(
erroradvantage = av1_warp_erroradv(
&cm->global_motion[frame].motion_params,
#if CONFIG_AOM_HIGHBITDEPTH
xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH, xd->bd,
......
......@@ -25,12 +25,12 @@
#define MAX_CORNERS 4096
#define MIN_INLIER_PROB 0.1
INLINE RansacType get_ransac_type(TransformationType type) {
INLINE RansacFunc get_ransac_type(TransformationType type) {
switch (type) {
case HOMOGRAPHY: return ransacHomography;
case AFFINE: return ransacAffine;
case ROTZOOM: return ransacRotZoom;
case TRANSLATION: return ransacTranslation;
case HOMOGRAPHY: return ransac_homography;
case AFFINE: return ransac_affine;
case ROTZOOM: return ransac_rotzoom;
case TRANSLATION: return ransac_translation;
default: assert(0); return NULL;
}
}
......@@ -42,7 +42,7 @@ static int compute_global_motion_params(TransformationType type,
int *inlier_map) {
int result;
int num_inliers = 0;
RansacType ransac = get_ransac_type(type);
RansacFunc ransac = get_ransac_type(type);
if (ransac == NULL) return 0;
result = ransac(correspondences, num_correspondences, &num_inliers,
......@@ -66,10 +66,12 @@ int compute_global_motion_feature_based(TransformationType type,
int *inlier_map = NULL;
// compute interest points in images using FAST features
num_frm_corners = FastCornerDetect(frm->y_buffer, frm->y_width, frm->y_height,
frm->y_stride, frm_corners, MAX_CORNERS);
num_ref_corners = FastCornerDetect(ref->y_buffer, ref->y_width, ref->y_height,
ref->y_stride, ref_corners, MAX_CORNERS);
num_frm_corners =
fast_corner_detect(frm->y_buffer, frm->y_width, frm->y_height,
frm->y_stride, frm_corners, MAX_CORNERS);
num_ref_corners =
fast_corner_detect(ref->y_buffer, ref->y_width, ref->y_height,
ref->y_stride, ref_corners, MAX_CORNERS);
// find correspondences between the two images
correspondences =
......
This diff is collapsed.
/*
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
* Copyright (c) 2016 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
......@@ -18,20 +18,20 @@
#include "av1/common/warped_motion.h"
typedef int (*RansacType)(double *matched_points, int npoints,
typedef int (*RansacFunc)(double *matched_points, int npoints,
int *number_of_inliers, int *best_inlier_mask,
double *bestH);
double *best_params);
/* Each of these functions fits a motion model from a set of
corresponding points in 2 frames using RANSAC.*/
int ransacHomography(double *matched_points, int npoints,
int *number_of_inliers, int *best_inlier_indices,
double *bestH);
int ransacAffine(double *matched_points, int npoints, int *number_of_inliers,
int *best_inlier_indices, double *bestH);
int ransacRotZoom(double *matched_points, int npoints, int *number_of_inliers,
int *best_inlier_indices, double *bestH);
int ransacTranslation(double *matched_points, int npoints,
int ransac_homography(double *matched_points, int npoints,
int *number_of_inliers, int *best_inlier_indices,
double *bestH);
#endif // AV1_ENCODER_RANSAC_H
double *best_params);
int ransac_affine(double *matched_points, int npoints, int *number_of_inliers,
int *best_inlier_indices, double *best_params);
int ransac_rotzoom(double *matched_points, int npoints, int *number_of_inliers,
int *best_inlier_indices, double *best_params);
int ransac_translation(double *matched_points, int npoints,
int *number_of_inliers, int *best_inlier_indices,
double *best_params);
#endif // AV1_ENCODER_RANSAC_H_
This code was taken from http://www.edwardrosten.com/work/fast.html. Fast 10, 11, and 12
have been deleted.
URL: https://github.com/edrosten/fast-C-src
Version: 391d5e939eb1545d24c10533d7de424db8d9c191
License: BSD
License File: LICENSE
FAST feature detectors in C Version 2.0
---------------------------------------
Description:
Library to compute FAST features with non-maximum suppression.
The files are valid C and C++ code, and have no special requirements for
compiling, and they do not depend on any libraries. Just compile them along with
......@@ -31,4 +33,6 @@ is the same as xsize.
The detection, scoring and nonmaximal suppression are available as individual
functions. To see how to use the individual functions, see fast.c
Local Modifications:
Add lines to turn off clang formatting for these files
Remove Fast 10, 11 and 12
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