Commit e5299865 authored by Sarah Parker's avatar Sarah Parker
Browse files

Add global motion experiment to rdopt

This patch completes the global motion experiment
implementation. It modifies the format of the motion
parameters to use the mv union to facilitate faster
copying and checks for parameters equal to 0 that occur
frequently in rdopt. The rd decisions for the global motion experiment
have also been added to rdopt.
Change-Id: Idfb9f0c6d23e538221763881099c5a2a3891f5a9
parent 9c323bc2
...@@ -13,9 +13,6 @@ ...@@ -13,9 +13,6 @@
#include "av1/common/common.h" #include "av1/common/common.h"
#include "aom_dsp/aom_filter.h" #include "aom_dsp/aom_filter.h"
#if CONFIG_GLOBAL_MOTION
#include "av1/common/warped_motion.h"
#endif // CONFIG_GLOBAL_MOTION
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
...@@ -36,6 +33,41 @@ typedef struct mv32 { ...@@ -36,6 +33,41 @@ typedef struct mv32 {
int32_t col; int32_t col;
} MV32; } MV32;
#if CONFIG_GLOBAL_MOTION || CONFIG_WARPED_MOTION
// 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 enum {
UNKNOWN_TRANSFORM = -1,
HOMOGRAPHY, // homography, 8-parameter
AFFINE, // affine, 6-parameter
ROTZOOM, // simplified affine with rotation and zoom only, 4-parameter
TRANSLATION, // translational motion 2-parameter
TRANS_TYPES
} TransformationType;
// number of parameters used by each transformation in TransformationTypes
static const int n_trans_model_params[TRANS_TYPES] = { 9, 6, 4, 2 };
typedef struct {
TransformationType wmtype;
int_mv wmmat[4]; // For homography wmmat[9] is assumed to be 1
} WarpedMotionParams;
#endif // CONFIG_GLOBAL_MOTION || CONFIG_WARPED_MOTION
#if CONFIG_GLOBAL_MOTION #if CONFIG_GLOBAL_MOTION
// ALPHA here refers to parameters a and b in rotzoom model: // ALPHA here refers to parameters a and b in rotzoom model:
// | a b| // | a b|
...@@ -61,16 +93,16 @@ typedef struct mv32 { ...@@ -61,16 +93,16 @@ typedef struct mv32 {
// //
// XX_MIN, XX_MAX are also computed to avoid repeated computation // XX_MIN, XX_MAX are also computed to avoid repeated computation
#define GM_TRANS_PREC_BITS 5 #define GM_TRANS_PREC_BITS 8
#define GM_TRANS_PREC_DIFF (WARPEDMODEL_PREC_BITS - GM_TRANS_PREC_BITS) #define GM_TRANS_PREC_DIFF (WARPEDMODEL_PREC_BITS - GM_TRANS_PREC_BITS)
#define GM_TRANS_DECODE_FACTOR (1 << GM_TRANS_PREC_DIFF) #define GM_TRANS_DECODE_FACTOR (1 << GM_TRANS_PREC_DIFF)
#define GM_ALPHA_PREC_BITS 5 #define GM_ALPHA_PREC_BITS 8
#define GM_ALPHA_PREC_DIFF (WARPEDMODEL_PREC_BITS - GM_ALPHA_PREC_BITS) #define GM_ALPHA_PREC_DIFF (WARPEDMODEL_PREC_BITS - GM_ALPHA_PREC_BITS)
#define GM_ALPHA_DECODE_FACTOR (1 << GM_ALPHA_PREC_DIFF) #define GM_ALPHA_DECODE_FACTOR (1 << GM_ALPHA_PREC_DIFF)
#define GM_ABS_ALPHA_BITS 8 #define GM_ABS_ALPHA_BITS 18
#define GM_ABS_TRANS_BITS 8 #define GM_ABS_TRANS_BITS 18
#define GM_TRANS_MAX (1 << GM_ABS_TRANS_BITS) #define GM_TRANS_MAX (1 << GM_ABS_TRANS_BITS)
#define GM_ALPHA_MAX (1 << GM_ABS_ALPHA_BITS) #define GM_ALPHA_MAX (1 << GM_ABS_ALPHA_BITS)
...@@ -102,11 +134,10 @@ static INLINE TransformationType gm_to_trans_type(GLOBAL_MOTION_TYPE gmtype) { ...@@ -102,11 +134,10 @@ static INLINE TransformationType gm_to_trans_type(GLOBAL_MOTION_TYPE gmtype) {
} }
static INLINE GLOBAL_MOTION_TYPE get_gmtype(const Global_Motion_Params *gm) { static INLINE GLOBAL_MOTION_TYPE get_gmtype(const Global_Motion_Params *gm) {
if (gm->motion_params.wmmat[4] == 0 && gm->motion_params.wmmat[5] == 0) { if (!gm->motion_params.wmmat[2].as_int) {
if (gm->motion_params.wmmat[2] == 0 && gm->motion_params.wmmat[3] == 0) { if (!gm->motion_params.wmmat[1].as_int) {
return ((gm->motion_params.wmmat[0] | gm->motion_params.wmmat[1]) return (gm->motion_params.wmmat[0].as_int ? GLOBAL_TRANSLATION
? GLOBAL_TRANSLATION : GLOBAL_ZERO);
: GLOBAL_ZERO);
} else { } else {
return GLOBAL_ROTZOOM; return GLOBAL_ROTZOOM;
} }
......
...@@ -26,7 +26,7 @@ static ProjectPointsType get_project_points_type(TransformationType type) { ...@@ -26,7 +26,7 @@ static ProjectPointsType get_project_points_type(TransformationType type) {
} }
} }
void projectPointsTranslation(int *mat, int *points, int *proj, const int n, void projectPointsTranslation(int16_t *mat, int *points, int *proj, const int n,
const int stride_points, const int stride_proj, const int stride_points, const int stride_proj,
const int subsampling_x, const int subsampling_x,
const int subsampling_y) { const int subsampling_y) {
...@@ -35,24 +35,24 @@ void projectPointsTranslation(int *mat, int *points, int *proj, const int n, ...@@ -35,24 +35,24 @@ void projectPointsTranslation(int *mat, int *points, int *proj, const int n,
const int x = *(points++), y = *(points++); const int x = *(points++), y = *(points++);
if (subsampling_x) if (subsampling_x)
*(proj++) = ROUND_POWER_OF_TWO_SIGNED( *(proj++) = ROUND_POWER_OF_TWO_SIGNED(
((x << (WARPEDMODEL_PREC_BITS + 1)) + mat[0]), ((x << (WARPEDMODEL_PREC_BITS + 1)) + mat[1]),
WARPEDDIFF_PREC_BITS + 1); WARPEDDIFF_PREC_BITS + 1);
else else
*(proj++) = ROUND_POWER_OF_TWO_SIGNED( *(proj++) = ROUND_POWER_OF_TWO_SIGNED(
((x << WARPEDMODEL_PREC_BITS)) + mat[0], WARPEDDIFF_PREC_BITS); ((x << WARPEDMODEL_PREC_BITS) + mat[1]), WARPEDDIFF_PREC_BITS);
if (subsampling_y) if (subsampling_y)
*(proj++) = ROUND_POWER_OF_TWO_SIGNED( *(proj++) = ROUND_POWER_OF_TWO_SIGNED(
((y << (WARPEDMODEL_PREC_BITS + 1)) + mat[1]), ((y << (WARPEDMODEL_PREC_BITS + 1)) + mat[0]),
WARPEDDIFF_PREC_BITS + 1); WARPEDDIFF_PREC_BITS + 1);
else else
*(proj++) = ROUND_POWER_OF_TWO_SIGNED( *(proj++) = ROUND_POWER_OF_TWO_SIGNED(
((y << WARPEDMODEL_PREC_BITS)) + mat[1], WARPEDDIFF_PREC_BITS); ((y << WARPEDMODEL_PREC_BITS)) + mat[0], WARPEDDIFF_PREC_BITS);
points += stride_points - 2; points += stride_points - 2;
proj += stride_proj - 2; proj += stride_proj - 2;
} }
} }
void projectPointsRotZoom(int *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 stride_points, const int stride_proj,
const int subsampling_x, const int subsampling_y) { const int subsampling_x, const int subsampling_y) {
int i; int i;
...@@ -60,26 +60,26 @@ void projectPointsRotZoom(int *mat, int *points, int *proj, const int n, ...@@ -60,26 +60,26 @@ void projectPointsRotZoom(int *mat, int *points, int *proj, const int n,
const int x = *(points++), y = *(points++); const int x = *(points++), y = *(points++);
if (subsampling_x) if (subsampling_x)
*(proj++) = ROUND_POWER_OF_TWO_SIGNED( *(proj++) = ROUND_POWER_OF_TWO_SIGNED(
mat[2] * 2 * x + mat[3] * 2 * y + mat[0] + mat[3] * 2 * x + mat[2] * 2 * y + mat[1] +
(mat[2] + mat[3] - (1 << WARPEDMODEL_PREC_BITS)) / 2, (mat[3] + mat[2] - (1 << WARPEDMODEL_PREC_BITS)) / 2,
WARPEDDIFF_PREC_BITS + 1); WARPEDDIFF_PREC_BITS + 1);
else else
*(proj++) = ROUND_POWER_OF_TWO_SIGNED(mat[2] * x + mat[3] * y + mat[0], *(proj++) = ROUND_POWER_OF_TWO_SIGNED(mat[3] * x + mat[2] * y + mat[1],
WARPEDDIFF_PREC_BITS); WARPEDDIFF_PREC_BITS);
if (subsampling_y) if (subsampling_y)
*(proj++) = ROUND_POWER_OF_TWO_SIGNED( *(proj++) = ROUND_POWER_OF_TWO_SIGNED(
-mat[3] * 2 * x + mat[2] * 2 * y + mat[1] + -mat[2] * 2 * x + mat[3] * 2 * y + mat[0] +
(-mat[3] + mat[2] - (1 << WARPEDMODEL_PREC_BITS)) / 2, (-mat[2] + mat[3] - (1 << WARPEDMODEL_PREC_BITS)) / 2,
WARPEDDIFF_PREC_BITS + 1); WARPEDDIFF_PREC_BITS + 1);
else else
*(proj++) = ROUND_POWER_OF_TWO_SIGNED(-mat[3] * x + mat[2] * y + mat[1], *(proj++) = ROUND_POWER_OF_TWO_SIGNED(-mat[2] * x + mat[3] * y + mat[0],
WARPEDDIFF_PREC_BITS); WARPEDDIFF_PREC_BITS);
points += stride_points - 2; points += stride_points - 2;
proj += stride_proj - 2; proj += stride_proj - 2;
} }
} }
void projectPointsAffine(int *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 stride_points, const int stride_proj,
const int subsampling_x, const int subsampling_y) { const int subsampling_x, const int subsampling_y) {
int i; int i;
...@@ -87,26 +87,26 @@ void projectPointsAffine(int *mat, int *points, int *proj, const int n, ...@@ -87,26 +87,26 @@ void projectPointsAffine(int *mat, int *points, int *proj, const int n,
const int x = *(points++), y = *(points++); const int x = *(points++), y = *(points++);
if (subsampling_x) if (subsampling_x)
*(proj++) = ROUND_POWER_OF_TWO_SIGNED( *(proj++) = ROUND_POWER_OF_TWO_SIGNED(
mat[2] * 2 * x + mat[3] * 2 * y + mat[0] + mat[3] * 2 * x + mat[2] * 2 * y + mat[1] +
(mat[2] + mat[3] - (1 << WARPEDMODEL_PREC_BITS)) / 2, (mat[3] + mat[2] - (1 << WARPEDMODEL_PREC_BITS)) / 2,
WARPEDDIFF_PREC_BITS + 1); WARPEDDIFF_PREC_BITS + 1);
else else
*(proj++) = ROUND_POWER_OF_TWO_SIGNED(mat[2] * x + mat[3] * y + mat[0], *(proj++) = ROUND_POWER_OF_TWO_SIGNED(mat[3] * x + mat[2] * y + mat[1],
WARPEDDIFF_PREC_BITS); WARPEDDIFF_PREC_BITS);
if (subsampling_y) if (subsampling_y)
*(proj++) = ROUND_POWER_OF_TWO_SIGNED( *(proj++) = ROUND_POWER_OF_TWO_SIGNED(
mat[4] * 2 * x + mat[5] * 2 * y + mat[1] + mat[5] * 2 * x + mat[4] * 2 * y + mat[0] +
(mat[4] + mat[5] - (1 << WARPEDMODEL_PREC_BITS)) / 2, (mat[5] + mat[4] - (1 << WARPEDMODEL_PREC_BITS)) / 2,
WARPEDDIFF_PREC_BITS + 1); WARPEDDIFF_PREC_BITS + 1);
else else
*(proj++) = ROUND_POWER_OF_TWO_SIGNED(mat[4] * x + mat[5] * y + mat[1], *(proj++) = ROUND_POWER_OF_TWO_SIGNED(mat[5] * x + mat[4] * y + mat[0],
WARPEDDIFF_PREC_BITS); WARPEDDIFF_PREC_BITS);
points += stride_points - 2; points += stride_points - 2;
proj += stride_proj - 2; proj += stride_proj - 2;
} }
} }
void projectPointsHomography(int *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 stride_points, const int stride_proj,
const int subsampling_x, const int subsampling_y) { const int subsampling_x, const int subsampling_y) {
int i; int i;
...@@ -117,11 +117,11 @@ void projectPointsHomography(int *mat, int *points, int *proj, const int n, ...@@ -117,11 +117,11 @@ void projectPointsHomography(int *mat, int *points, int *proj, const int n,
x = (subsampling_x ? 4 * x + 1 : 2 * x); x = (subsampling_x ? 4 * x + 1 : 2 * x);
y = (subsampling_y ? 4 * y + 1 : 2 * y); y = (subsampling_y ? 4 * y + 1 : 2 * y);
Z = (mat[6] * x + mat[7] * y + (1 << (WARPEDMODEL_ROW3HOMO_PREC_BITS + 1))); Z = (mat[7] * x + mat[6] * y + (1 << (WARPEDMODEL_ROW3HOMO_PREC_BITS + 1)));
xp = (mat[0] * x + mat[1] * y + 2 * mat[2]) xp = (mat[1] * x + mat[0] * y + 2 * mat[3])
<< (WARPEDPIXEL_PREC_BITS + WARPEDMODEL_ROW3HOMO_PREC_BITS - << (WARPEDPIXEL_PREC_BITS + WARPEDMODEL_ROW3HOMO_PREC_BITS -
WARPEDMODEL_PREC_BITS); WARPEDMODEL_PREC_BITS);
yp = (mat[3] * x + mat[4] * y + 2 * mat[5]) yp = (mat[2] * x + mat[5] * y + 2 * mat[4])
<< (WARPEDPIXEL_PREC_BITS + WARPEDMODEL_ROW3HOMO_PREC_BITS - << (WARPEDPIXEL_PREC_BITS + WARPEDMODEL_ROW3HOMO_PREC_BITS -
WARPEDMODEL_PREC_BITS); WARPEDMODEL_PREC_BITS);
...@@ -483,7 +483,8 @@ static double highbd_warp_erroradv(WarpedMotionParams *wm, uint8_t *ref8, ...@@ -483,7 +483,8 @@ static double highbd_warp_erroradv(WarpedMotionParams *wm, uint8_t *ref8,
int in[2], out[2]; int in[2], out[2];
in[0] = j; in[0] = j;
in[1] = i; in[1] = i;
projectpoints(wm->wmmat, in, out, 1, 2, 2, subsampling_x, subsampling_y); projectpoints((int16_t *)wm->wmmat, in, out, 1, 2, 2, subsampling_x,
subsampling_y);
out[0] = ROUND_POWER_OF_TWO_SIGNED(out[0] * x_scale, 4); out[0] = ROUND_POWER_OF_TWO_SIGNED(out[0] * x_scale, 4);
out[1] = ROUND_POWER_OF_TWO_SIGNED(out[1] * y_scale, 4); out[1] = ROUND_POWER_OF_TWO_SIGNED(out[1] * y_scale, 4);
gm_err = dst[(j - p_col) + (i - p_row) * p_stride] - gm_err = dst[(j - p_col) + (i - p_row) * p_stride] -
...@@ -514,7 +515,8 @@ static void highbd_warp_plane(WarpedMotionParams *wm, uint8_t *ref8, int width, ...@@ -514,7 +515,8 @@ static void highbd_warp_plane(WarpedMotionParams *wm, uint8_t *ref8, int width,
int in[2], out[2]; int in[2], out[2];
in[0] = j; in[0] = j;
in[1] = i; in[1] = i;
projectpoints(wm->wmmat, in, out, 1, 2, 2, subsampling_x, subsampling_y); projectpoints((int16_t *)wm->wmmat, in, out, 1, 2, 2, subsampling_x,
subsampling_y);
out[0] = ROUND_POWER_OF_TWO_SIGNED(out[0] * x_scale, 4); out[0] = ROUND_POWER_OF_TWO_SIGNED(out[0] * x_scale, 4);
out[1] = ROUND_POWER_OF_TWO_SIGNED(out[1] * y_scale, 4); out[1] = ROUND_POWER_OF_TWO_SIGNED(out[1] * y_scale, 4);
pred[(j - p_col) + (i - p_row) * p_stride] = highbd_warp_interpolate( pred[(j - p_col) + (i - p_row) * p_stride] = highbd_warp_interpolate(
...@@ -538,7 +540,8 @@ static double warp_erroradv(WarpedMotionParams *wm, uint8_t *ref, int width, ...@@ -538,7 +540,8 @@ static double warp_erroradv(WarpedMotionParams *wm, uint8_t *ref, int width,
int in[2], out[2]; int in[2], out[2];
in[0] = j; in[0] = j;
in[1] = i; in[1] = i;
projectpoints(wm->wmmat, in, out, 1, 2, 2, subsampling_x, subsampling_y); projectpoints((int16_t *)wm->wmmat, in, out, 1, 2, 2, subsampling_x,
subsampling_y);
out[0] = ROUND_POWER_OF_TWO_SIGNED(out[0] * x_scale, 4); out[0] = ROUND_POWER_OF_TWO_SIGNED(out[0] * x_scale, 4);
out[1] = ROUND_POWER_OF_TWO_SIGNED(out[1] * y_scale, 4); out[1] = ROUND_POWER_OF_TWO_SIGNED(out[1] * y_scale, 4);
gm_err = dst[(j - p_col) + (i - p_row) * p_stride] - gm_err = dst[(j - p_col) + (i - p_row) * p_stride] -
...@@ -565,7 +568,8 @@ static void warp_plane(WarpedMotionParams *wm, uint8_t *ref, int width, ...@@ -565,7 +568,8 @@ static void warp_plane(WarpedMotionParams *wm, uint8_t *ref, int width,
int in[2], out[2]; int in[2], out[2];
in[0] = j; in[0] = j;
in[1] = i; in[1] = i;
projectpoints(wm->wmmat, in, out, 1, 2, 2, subsampling_x, subsampling_y); projectpoints((int16_t *)wm->wmmat, in, out, 1, 2, 2, subsampling_x,
subsampling_y);
out[0] = ROUND_POWER_OF_TWO_SIGNED(out[0] * x_scale, 4); out[0] = ROUND_POWER_OF_TWO_SIGNED(out[0] * x_scale, 4);
out[1] = ROUND_POWER_OF_TWO_SIGNED(out[1] * y_scale, 4); out[1] = ROUND_POWER_OF_TWO_SIGNED(out[1] * y_scale, 4);
pred[(j - p_col) + (i - p_row) * p_stride] = pred[(j - p_col) + (i - p_row) * p_stride] =
...@@ -620,22 +624,28 @@ void av1_integerize_model(const double *model, TransformationType wmtype, ...@@ -620,22 +624,28 @@ void av1_integerize_model(const double *model, TransformationType wmtype,
switch (wmtype) { switch (wmtype) {
case HOMOGRAPHY: case HOMOGRAPHY:
assert(fabs(model[8] - 1.0) < 1e-12); assert(fabs(model[8] - 1.0) < 1e-12);
wm->wmmat[7] = wm->wmmat[3].as_mv.row =
(int)lrint(model[7] * (1 << WARPEDMODEL_ROW3HOMO_PREC_BITS)); (int16_t)lrint(model[6] * (1 << WARPEDMODEL_ROW3HOMO_PREC_BITS));
wm->wmmat[6] = wm->wmmat[3].as_mv.col =
(int)lrint(model[6] * (1 << WARPEDMODEL_ROW3HOMO_PREC_BITS)); (int16_t)lrint(model[7] * (1 << WARPEDMODEL_ROW3HOMO_PREC_BITS));
/* fallthrough intended */ /* fallthrough intended */
case AFFINE: case AFFINE:
wm->wmmat[5] = (int)lrint(model[5] * (1 << WARPEDMODEL_PREC_BITS)); wm->wmmat[2].as_mv.row =
wm->wmmat[4] = (int)lrint(model[4] * (1 << WARPEDMODEL_PREC_BITS)); (int16_t)lrint(model[4] * (1 << WARPEDMODEL_PREC_BITS));
wm->wmmat[2].as_mv.col =
(int16_t)lrint(model[5] * (1 << WARPEDMODEL_PREC_BITS));
/* fallthrough intended */ /* fallthrough intended */
case ROTZOOM: case ROTZOOM:
wm->wmmat[3] = (int)lrint(model[3] * (1 << WARPEDMODEL_PREC_BITS)); wm->wmmat[1].as_mv.row =
wm->wmmat[2] = (int)lrint(model[2] * (1 << WARPEDMODEL_PREC_BITS)); (int16_t)lrint(model[2] * (1 << WARPEDMODEL_PREC_BITS));
wm->wmmat[1].as_mv.col =
(int16_t)lrint(model[3] * (1 << WARPEDMODEL_PREC_BITS));
/* fallthrough intended */ /* fallthrough intended */
case TRANSLATION: case TRANSLATION:
wm->wmmat[1] = (int)lrint(model[1] * (1 << WARPEDMODEL_PREC_BITS)); wm->wmmat[0].as_mv.row =
wm->wmmat[0] = (int)lrint(model[0] * (1 << WARPEDMODEL_PREC_BITS)); (int16_t)lrint(model[0] * (1 << WARPEDMODEL_PREC_BITS));
wm->wmmat[0].as_mv.col =
(int16_t)lrint(model[1] * (1 << WARPEDMODEL_PREC_BITS));
break; break;
default: assert(0 && "Invalid TransformationType"); default: assert(0 && "Invalid TransformationType");
} }
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "./aom_config.h" #include "./aom_config.h"
#include "aom_ports/mem.h" #include "aom_ports/mem.h"
#include "aom_dsp/aom_dsp_common.h" #include "aom_dsp/aom_dsp_common.h"
#include "av1/common/mv.h"
// Bits of precision used for the model // Bits of precision used for the model
#define WARPEDMODEL_PREC_BITS 8 #define WARPEDMODEL_PREC_BITS 8
...@@ -37,49 +38,36 @@ ...@@ -37,49 +38,36 @@
#define WARPEDDIFF_PREC_BITS (WARPEDMODEL_PREC_BITS - WARPEDPIXEL_PREC_BITS) #define WARPEDDIFF_PREC_BITS (WARPEDMODEL_PREC_BITS - WARPEDPIXEL_PREC_BITS)
typedef void (*ProjectPointsType)(int *mat, int *points, int *proj, const int n, typedef void (*ProjectPointsType)(int16_t *mat, int *points, int *proj,
const int stride_points, const int n, const int stride_points,
const int stride_proj, const int stride_proj,
const int subsampling_x, const int subsampling_x,
const int subsampling_y); const int subsampling_y);
void projectPointsHomography(int *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 stride_points, const int stride_proj,
const int subsampling_x, const int subsampling_y); const int subsampling_x, const int subsampling_y);
void projectPointsAffine(int *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 stride_points, const int stride_proj,
const int subsampling_x, const int subsampling_y); const int subsampling_x, const int subsampling_y);
void projectPointsRotZoom(int *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 stride_points, const int stride_proj,
const int subsampling_x, const int subsampling_y); const int subsampling_x, const int subsampling_y);
void projectPointsTranslation(int *mat, int *points, int *proj, const int n,
void projectPointsTranslation(int16_t *mat, int *points, int *proj, const int n,
const int stride_points, const int stride_proj, const int stride_points, const int stride_proj,
const int subsampling_x, const int subsampling_y); const int subsampling_x, const int subsampling_y);
typedef enum {
UNKNOWN_TRANSFORM = -1,
HOMOGRAPHY, // homography, 8-parameter
AFFINE, // affine, 6-parameter
ROTZOOM, // simplified affine with rotation and zoom only, 4-parameter
TRANSLATION, // translational motion 2-parameter
TRANS_TYPES
} TransformationType;
// number of parameters used by each transformation in TransformationTypes
static const int n_trans_model_params[TRANS_TYPES] = { 9, 6, 4, 2 };
typedef struct {
TransformationType wmtype;
int wmmat[8]; // For homography wmmat[9] is assumed to be 1
} WarpedMotionParams;
double av1_warp_erroradv(WarpedMotionParams *wm, double av1_warp_erroradv(WarpedMotionParams *wm,
#if CONFIG_AOM_HIGHBITDEPTH #if CONFIG_VP9_HIGHBITDEPTH
int use_hbd, int bd, int use_hbd, int bd,
#endif // CONFIG_AOM_HIGHBITDEPTH #endif // CONFIG_VP9_HIGHBITDEPTH
uint8_t *ref, int width, int height, int stride, uint8_t *ref, int width, int height, int stride,
uint8_t *dst, int p_col, int p_row, int p_width, uint8_t *dst, int p_col, int p_row, int p_width,
int p_height, int p_stride, int subsampling_x, int p_height, int p_stride, int subsampling_x,
int subsampling_y, int x_scale, int y_scale); int subsampling_y, int x_scale, int y_scale);
void av1_warp_plane(WarpedMotionParams *wm, void av1_warp_plane(WarpedMotionParams *wm,
#if CONFIG_AOM_HIGHBITDEPTH #if CONFIG_AOM_HIGHBITDEPTH
......
...@@ -3423,28 +3423,28 @@ static void read_global_motion_params(Global_Motion_Params *params, ...@@ -3423,28 +3423,28 @@ static void read_global_motion_params(Global_Motion_Params *params,
switch (gmtype) { switch (gmtype) {
case GLOBAL_ZERO: break; case GLOBAL_ZERO: break;
case GLOBAL_AFFINE: case GLOBAL_AFFINE:
params->motion_params.wmmat[4] = params->motion_params.wmmat[2].as_mv.row =
(aom_read_primitive_symmetric(r, GM_ABS_ALPHA_BITS) *
GM_ALPHA_DECODE_FACTOR);
params->motion_params.wmmat[5] =
aom_read_primitive_symmetric(r, GM_ABS_ALPHA_BITS) * aom_read_primitive_symmetric(r, GM_ABS_ALPHA_BITS) *
GM_ALPHA_DECODE_FACTOR + GM_ALPHA_DECODE_FACTOR +
(1 << WARPEDMODEL_PREC_BITS); (1 << WARPEDMODEL_PREC_BITS);
params->motion_params.wmmat[2].as_mv.col =
(aom_read_primitive_symmetric(r, GM_ABS_ALPHA_BITS) *
GM_ALPHA_DECODE_FACTOR);
// fallthrough intended // fallthrough intended
case GLOBAL_ROTZOOM: case GLOBAL_ROTZOOM:
params->motion_params.wmmat[2] = params->motion_params.wmmat[1].as_mv.row =
aom_read_primitive_symmetric(r, GM_ABS_ALPHA_BITS) *
GM_ALPHA_DECODE_FACTOR;
params->motion_params.wmmat[1].as_mv.col =
(aom_read_primitive_symmetric(r, GM_ABS_ALPHA_BITS) * (aom_read_primitive_symmetric(r, GM_ABS_ALPHA_BITS) *
GM_ALPHA_DECODE_FACTOR) + GM_ALPHA_DECODE_FACTOR) +
(1 << WARPEDMODEL_PREC_BITS); (1 << WARPEDMODEL_PREC_BITS);
params->motion_params.wmmat[3] =
aom_read_primitive_symmetric(r, GM_ABS_ALPHA_BITS) *
GM_ALPHA_DECODE_FACTOR;
// fallthrough intended // fallthrough intended
case GLOBAL_TRANSLATION: case GLOBAL_TRANSLATION:
params->motion_params.wmmat[0] = params->motion_params.wmmat[0].as_mv.row =
aom_read_primitive_symmetric(r, GM_ABS_TRANS_BITS) * aom_read_primitive_symmetric(r, GM_ABS_TRANS_BITS) *
GM_TRANS_DECODE_FACTOR; GM_TRANS_DECODE_FACTOR;
params->motion_params.wmmat[1] = params->motion_params.wmmat[0].as_mv.col =
aom_read_primitive_symmetric(r, GM_ABS_TRANS_BITS) * aom_read_primitive_symmetric(r, GM_ABS_TRANS_BITS) *
GM_TRANS_DECODE_FACTOR; GM_TRANS_DECODE_FACTOR;
break; break;
...@@ -3458,6 +3458,14 @@ static void read_global_motion(AV1_COMMON *cm, aom_reader *r) { ...@@ -3458,6 +3458,14 @@ static void read_global_motion(AV1_COMMON *cm, aom_reader *r) {
for (frame = LAST_FRAME; frame <= ALTREF_FRAME; ++frame) { for (frame = LAST_FRAME; frame <= ALTREF_FRAME; ++frame) {
read_global_motion_params(&cm->global_motion[frame], read_global_motion_params(&cm->global_motion[frame],
cm->fc->global_motion_types_prob, r); cm->fc->global_motion_types_prob, r);
/*
printf("Dec Ref %d [%d]: %d %d %d %d\n",
frame, cm->current_video_frame,
cm->global_motion[frame].motion_params.wmmat[0].as_mv.row,
cm->global_motion[frame].motion_params.wmmat[0].as_mv.col,
cm->global_motion[frame].motion_params.wmmat[1].as_mv.row,
cm->global_motion[frame].motion_params.wmmat[1].as_mv.col);
*/
} }
} }
#endif // CONFIG_GLOBAL_MOTION #endif // CONFIG_GLOBAL_MOTION
......
...@@ -938,6 +938,7 @@ static INLINE int is_mv_valid(const MV *mv) { ...@@ -938,6 +938,7 @@ static INLINE int is_mv_valid(const MV *mv) {
static INLINE int assign_mv(AV1_COMMON *cm, MACROBLOCKD *xd, static INLINE int assign_mv(AV1_COMMON *cm, MACROBLOCKD *xd,
PREDICTION_MODE mode, PREDICTION_MODE mode,
MV_REFERENCE_FRAME ref_frame[2],
#if CONFIG_REF_MV #if CONFIG_REF_MV
int block, int block,
#endif #endif
...@@ -952,6 +953,7 @@ static INLINE int assign_mv(AV1_COMMON *cm, MACROBLOCKD *xd, ...@@ -952,6 +953,7 @@ static INLINE int assign_mv(AV1_COMMON *cm, MACROBLOCKD *xd,
int_mv *pred_mv = int_mv *pred_mv =
(bsize >= BLOCK_8X8) ? mbmi->pred_mv : xd->mi[0]->bmi[block].pred_mv_s8; (bsize >= BLOCK_8X8) ? mbmi->pred_mv : xd->mi[0]->bmi[block].pred_mv_s8;
#endif #endif
(void)ref_frame;
switch (mode) { switch (mode) {
#if CONFIG_EXT_INTER #if CONFIG_EXT_INTER
...@@ -1006,8 +1008,16 @@ static INLINE int assign_mv(AV1_COMMON *cm, MACROBLOCKD *xd, ...@@ -1006,8 +1008,16 @@ static INLINE int assign_mv(AV1_COMMON *cm, MACROBLOCKD *xd,
break; break;
} }
case ZEROMV: { case ZEROMV: {
#if CONFIG_GLOBAL_MOTION
mv[0].as_int =