Increase gm precision from 16 to 32 bit ints
Change-Id: I7117a6c14dc8438e4225b50bd2d3ebbaa7f850cc
This commit is contained in:
Родитель
deaff66955
Коммит
5f305854e6
|
@ -36,7 +36,7 @@ typedef struct mv32 {
|
|||
|
||||
#if CONFIG_GLOBAL_MOTION || CONFIG_WARPED_MOTION
|
||||
// Bits of precision used for the model
|
||||
#define WARPEDMODEL_PREC_BITS 8
|
||||
#define WARPEDMODEL_PREC_BITS 12
|
||||
#define WARPEDMODEL_ROW3HOMO_PREC_BITS 12
|
||||
|
||||
// Bits of subpel precision for warped interpolation
|
||||
|
@ -65,7 +65,7 @@ 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
|
||||
int32_t wmmat[8]; // For homography wmmat[9] is assumed to be 1
|
||||
} WarpedMotionParams;
|
||||
#endif // CONFIG_GLOBAL_MOTION || CONFIG_WARPED_MOTION
|
||||
|
||||
|
@ -94,16 +94,16 @@ typedef struct {
|
|||
//
|
||||
// XX_MIN, XX_MAX are also computed to avoid repeated computation
|
||||
|
||||
#define GM_TRANS_PREC_BITS 8
|
||||
#define GM_TRANS_PREC_BITS 3
|
||||
#define GM_TRANS_PREC_DIFF (WARPEDMODEL_PREC_BITS - GM_TRANS_PREC_BITS)
|
||||
#define GM_TRANS_DECODE_FACTOR (1 << GM_TRANS_PREC_DIFF)
|
||||
|
||||
#define GM_ALPHA_PREC_BITS 8
|
||||
#define GM_ALPHA_PREC_BITS 12
|
||||
#define GM_ALPHA_PREC_DIFF (WARPEDMODEL_PREC_BITS - GM_ALPHA_PREC_BITS)
|
||||
#define GM_ALPHA_DECODE_FACTOR (1 << GM_ALPHA_PREC_DIFF)
|
||||
|
||||
#define GM_ABS_ALPHA_BITS 8
|
||||
#define GM_ABS_TRANS_BITS 8
|
||||
#define GM_ABS_ALPHA_BITS 9
|
||||
#define GM_ABS_TRANS_BITS 9
|
||||
|
||||
#define GM_TRANS_MAX (1 << GM_ABS_TRANS_BITS)
|
||||
#define GM_ALPHA_MAX (1 << GM_ABS_ALPHA_BITS)
|
||||
|
@ -123,6 +123,17 @@ typedef struct {
|
|||
WarpedMotionParams motion_params;
|
||||
} Global_Motion_Params;
|
||||
|
||||
// Convert a global motion translation vector (which may have more bits than a
|
||||
// regular motion vector) into a motion vector
|
||||
static INLINE int_mv gm_get_motion_vector(const Global_Motion_Params *gm) {
|
||||
int_mv res;
|
||||
res.as_mv.row = (int16_t)ROUND_POWER_OF_TWO_SIGNED(gm->motion_params.wmmat[0],
|
||||
WARPEDMODEL_PREC_BITS - 3);
|
||||
res.as_mv.col = (int16_t)ROUND_POWER_OF_TWO_SIGNED(gm->motion_params.wmmat[1],
|
||||
WARPEDMODEL_PREC_BITS - 3);
|
||||
return res;
|
||||
}
|
||||
|
||||
static INLINE TransformationType gm_to_trans_type(GLOBAL_MOTION_TYPE gmtype) {
|
||||
switch (gmtype) {
|
||||
case GLOBAL_ZERO: return UNKNOWN_TRANSFORM; break;
|
||||
|
@ -135,10 +146,11 @@ static INLINE TransformationType gm_to_trans_type(GLOBAL_MOTION_TYPE gmtype) {
|
|||
}
|
||||
|
||||
static INLINE GLOBAL_MOTION_TYPE get_gmtype(const Global_Motion_Params *gm) {
|
||||
if (!gm->motion_params.wmmat[2].as_int) {
|
||||
if (!gm->motion_params.wmmat[1].as_int) {
|
||||
return (gm->motion_params.wmmat[0].as_int ? GLOBAL_TRANSLATION
|
||||
: GLOBAL_ZERO);
|
||||
if (!gm->motion_params.wmmat[5] && !gm->motion_params.wmmat[4]) {
|
||||
if (!gm->motion_params.wmmat[3] && !gm->motion_params.wmmat[2]) {
|
||||
return ((!gm->motion_params.wmmat[1] && !gm->motion_params.wmmat[0])
|
||||
? GLOBAL_ZERO
|
||||
: GLOBAL_TRANSLATION);
|
||||
} else {
|
||||
return GLOBAL_ROTZOOM;
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ static ProjectPointsFunc get_project_points_type(TransformationType type) {
|
|||
}
|
||||
}
|
||||
|
||||
void project_points_translation(int16_t *mat, int *points, int *proj,
|
||||
void project_points_translation(int32_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) {
|
||||
|
@ -52,7 +52,7 @@ void project_points_translation(int16_t *mat, int *points, int *proj,
|
|||
}
|
||||
}
|
||||
|
||||
void project_points_rotzoom(int16_t *mat, int *points, int *proj, const int n,
|
||||
void project_points_rotzoom(int32_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;
|
||||
|
@ -79,7 +79,7 @@ void project_points_rotzoom(int16_t *mat, int *points, int *proj, const int n,
|
|||
}
|
||||
}
|
||||
|
||||
void project_points_affine(int16_t *mat, int *points, int *proj, const int n,
|
||||
void project_points_affine(int32_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;
|
||||
|
@ -106,7 +106,7 @@ void project_points_affine(int16_t *mat, int *points, int *proj, const int n,
|
|||
}
|
||||
}
|
||||
|
||||
void project_points_homography(int16_t *mat, int *points, int *proj,
|
||||
void project_points_homography(int32_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) {
|
||||
|
@ -443,8 +443,7 @@ static double highbd_warp_erroradv(WarpedMotionParams *wm, uint8_t *ref8,
|
|||
int in[2], out[2];
|
||||
in[0] = j;
|
||||
in[1] = i;
|
||||
projectpoints((int16_t *)wm->wmmat, in, out, 1, 2, 2, subsampling_x,
|
||||
subsampling_y);
|
||||
projectpoints(wm->wmmat, in, out, 1, 2, 2, subsampling_x, subsampling_y);
|
||||
out[0] = ROUND_POWER_OF_TWO_SIGNED(out[0] * x_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] -
|
||||
|
@ -475,8 +474,7 @@ static void highbd_warp_plane(WarpedMotionParams *wm, uint8_t *ref8, int width,
|
|||
int in[2], out[2];
|
||||
in[0] = j;
|
||||
in[1] = i;
|
||||
projectpoints((int16_t *)wm->wmmat, in, out, 1, 2, 2, subsampling_x,
|
||||
subsampling_y);
|
||||
projectpoints(wm->wmmat, in, out, 1, 2, 2, subsampling_x, subsampling_y);
|
||||
out[0] = ROUND_POWER_OF_TWO_SIGNED(out[0] * x_scale, 4);
|
||||
out[1] = ROUND_POWER_OF_TWO_SIGNED(out[1] * y_scale, 4);
|
||||
if (ref_frm)
|
||||
|
@ -507,8 +505,7 @@ static double warp_erroradv(WarpedMotionParams *wm, uint8_t *ref, int width,
|
|||
int in[2], out[2];
|
||||
in[0] = j;
|
||||
in[1] = i;
|
||||
projectpoints((int16_t *)wm->wmmat, in, out, 1, 2, 2, subsampling_x,
|
||||
subsampling_y);
|
||||
projectpoints(wm->wmmat, in, out, 1, 2, 2, subsampling_x, subsampling_y);
|
||||
out[0] = ROUND_POWER_OF_TWO_SIGNED(out[0] * x_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] -
|
||||
|
@ -535,8 +532,7 @@ static void warp_plane(WarpedMotionParams *wm, uint8_t *ref, int width,
|
|||
int in[2], out[2];
|
||||
in[0] = j;
|
||||
in[1] = i;
|
||||
projectpoints((int16_t *)wm->wmmat, in, out, 1, 2, 2, subsampling_x,
|
||||
subsampling_y);
|
||||
projectpoints(wm->wmmat, in, out, 1, 2, 2, subsampling_x, subsampling_y);
|
||||
out[0] = ROUND_POWER_OF_TWO_SIGNED(out[0] * x_scale, 4);
|
||||
out[1] = ROUND_POWER_OF_TWO_SIGNED(out[1] * y_scale, 4);
|
||||
if (ref_frm)
|
||||
|
@ -596,28 +592,22 @@ void av1_integerize_model(const double *model, TransformationType wmtype,
|
|||
switch (wmtype) {
|
||||
case HOMOGRAPHY:
|
||||
assert(fabs(model[8] - 1.0) < 1e-12);
|
||||
wm->wmmat[3].as_mv.row =
|
||||
(int16_t)lrint(model[6] * (1 << WARPEDMODEL_ROW3HOMO_PREC_BITS));
|
||||
wm->wmmat[3].as_mv.col =
|
||||
(int16_t)lrint(model[7] * (1 << WARPEDMODEL_ROW3HOMO_PREC_BITS));
|
||||
wm->wmmat[6] =
|
||||
(int32_t)lrint(model[6] * (1 << WARPEDMODEL_ROW3HOMO_PREC_BITS));
|
||||
wm->wmmat[7] =
|
||||
(int32_t)lrint(model[7] * (1 << WARPEDMODEL_ROW3HOMO_PREC_BITS));
|
||||
/* fallthrough intended */
|
||||
case AFFINE:
|
||||
wm->wmmat[2].as_mv.row =
|
||||
(int16_t)lrint(model[4] * (1 << WARPEDMODEL_PREC_BITS));
|
||||
wm->wmmat[2].as_mv.col =
|
||||
(int16_t)lrint(model[5] * (1 << WARPEDMODEL_PREC_BITS));
|
||||
wm->wmmat[4] = (int32_t)lrint(model[4] * (1 << WARPEDMODEL_PREC_BITS));
|
||||
wm->wmmat[5] = (int32_t)lrint(model[5] * (1 << WARPEDMODEL_PREC_BITS));
|
||||
/* fallthrough intended */
|
||||
case ROTZOOM:
|
||||
wm->wmmat[1].as_mv.row =
|
||||
(int16_t)lrint(model[2] * (1 << WARPEDMODEL_PREC_BITS));
|
||||
wm->wmmat[1].as_mv.col =
|
||||
(int16_t)lrint(model[3] * (1 << WARPEDMODEL_PREC_BITS));
|
||||
wm->wmmat[2] = (int32_t)lrint(model[2] * (1 << WARPEDMODEL_PREC_BITS));
|
||||
wm->wmmat[3] = (int32_t)lrint(model[3] * (1 << WARPEDMODEL_PREC_BITS));
|
||||
/* fallthrough intended */
|
||||
case TRANSLATION:
|
||||
wm->wmmat[0].as_mv.row =
|
||||
(int16_t)lrint(model[0] * (1 << WARPEDMODEL_PREC_BITS));
|
||||
wm->wmmat[0].as_mv.col =
|
||||
(int16_t)lrint(model[1] * (1 << WARPEDMODEL_PREC_BITS));
|
||||
wm->wmmat[0] = (int32_t)lrint(model[0] * (1 << WARPEDMODEL_PREC_BITS));
|
||||
wm->wmmat[1] = (int32_t)lrint(model[1] * (1 << WARPEDMODEL_PREC_BITS));
|
||||
break;
|
||||
default: assert(0 && "Invalid TransformationType");
|
||||
}
|
||||
|
|
|
@ -24,26 +24,26 @@
|
|||
|
||||
#define MAX_PARAMDIM 9
|
||||
|
||||
typedef void (*ProjectPointsFunc)(int16_t *mat, int *points, int *proj,
|
||||
typedef void (*ProjectPointsFunc)(int32_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,
|
||||
void project_points_translation(int32_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,
|
||||
void project_points_rotzoom(int32_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,
|
||||
void project_points_affine(int32_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,
|
||||
void project_points_homography(int32_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);
|
||||
|
|
|
@ -3657,28 +3657,28 @@ static void read_global_motion_params(Global_Motion_Params *params,
|
|||
switch (gmtype) {
|
||||
case GLOBAL_ZERO: break;
|
||||
case GLOBAL_AFFINE:
|
||||
params->motion_params.wmmat[2].as_mv.row =
|
||||
params->motion_params.wmmat[4] =
|
||||
(aom_read_primitive_symmetric(r, GM_ABS_ALPHA_BITS) *
|
||||
GM_ALPHA_DECODE_FACTOR);
|
||||
params->motion_params.wmmat[2].as_mv.col =
|
||||
params->motion_params.wmmat[5] =
|
||||
aom_read_primitive_symmetric(r, GM_ABS_ALPHA_BITS) *
|
||||
GM_ALPHA_DECODE_FACTOR +
|
||||
(1 << WARPEDMODEL_PREC_BITS);
|
||||
// fallthrough intended
|
||||
case GLOBAL_ROTZOOM:
|
||||
params->motion_params.wmmat[1].as_mv.row =
|
||||
params->motion_params.wmmat[2] =
|
||||
aom_read_primitive_symmetric(r, GM_ABS_ALPHA_BITS) *
|
||||
GM_ALPHA_DECODE_FACTOR;
|
||||
params->motion_params.wmmat[1].as_mv.col =
|
||||
params->motion_params.wmmat[3] =
|
||||
(aom_read_primitive_symmetric(r, GM_ABS_ALPHA_BITS) *
|
||||
GM_ALPHA_DECODE_FACTOR) +
|
||||
(1 << WARPEDMODEL_PREC_BITS);
|
||||
// fallthrough intended
|
||||
case GLOBAL_TRANSLATION:
|
||||
params->motion_params.wmmat[0].as_mv.row =
|
||||
params->motion_params.wmmat[0] =
|
||||
aom_read_primitive_symmetric(r, GM_ABS_TRANS_BITS) *
|
||||
GM_TRANS_DECODE_FACTOR;
|
||||
params->motion_params.wmmat[0].as_mv.col =
|
||||
params->motion_params.wmmat[1] =
|
||||
aom_read_primitive_symmetric(r, GM_ABS_TRANS_BITS) *
|
||||
GM_TRANS_DECODE_FACTOR;
|
||||
break;
|
||||
|
|
|
@ -1184,10 +1184,10 @@ static INLINE int assign_mv(AV1_COMMON *cm, MACROBLOCKD *xd,
|
|||
case ZEROMV: {
|
||||
#if CONFIG_GLOBAL_MOTION
|
||||
mv[0].as_int =
|
||||
cm->global_motion[ref_frame[0]].motion_params.wmmat[0].as_int;
|
||||
gm_get_motion_vector(&cm->global_motion[ref_frame[0]]).as_int;
|
||||
if (is_compound)
|
||||
mv[1].as_int =
|
||||
cm->global_motion[ref_frame[1]].motion_params.wmmat[0].as_int;
|
||||
gm_get_motion_vector(&cm->global_motion[ref_frame[1]]).as_int;
|
||||
#else
|
||||
mv[0].as_int = 0;
|
||||
if (is_compound) mv[1].as_int = 0;
|
||||
|
|
|
@ -3658,28 +3658,28 @@ static void write_global_motion_params(Global_Motion_Params *params,
|
|||
case GLOBAL_ZERO: break;
|
||||
case GLOBAL_AFFINE:
|
||||
aom_write_primitive_symmetric(
|
||||
w, (params->motion_params.wmmat[2].as_mv.row >> GM_ALPHA_PREC_DIFF),
|
||||
w, (params->motion_params.wmmat[4] >> GM_ALPHA_PREC_DIFF),
|
||||
GM_ABS_ALPHA_BITS);
|
||||
aom_write_primitive_symmetric(
|
||||
w, (params->motion_params.wmmat[2].as_mv.col >> GM_ALPHA_PREC_DIFF) -
|
||||
w, (params->motion_params.wmmat[5] >> GM_ALPHA_PREC_DIFF) -
|
||||
(1 << GM_ALPHA_PREC_BITS),
|
||||
GM_ABS_ALPHA_BITS);
|
||||
// fallthrough intended
|
||||
case GLOBAL_ROTZOOM:
|
||||
aom_write_primitive_symmetric(
|
||||
w, (params->motion_params.wmmat[1].as_mv.row >> GM_ALPHA_PREC_DIFF),
|
||||
w, (params->motion_params.wmmat[2] >> GM_ALPHA_PREC_DIFF),
|
||||
GM_ABS_ALPHA_BITS);
|
||||
aom_write_primitive_symmetric(
|
||||
w, (params->motion_params.wmmat[1].as_mv.col >> GM_ALPHA_PREC_DIFF) -
|
||||
w, (params->motion_params.wmmat[3] >> GM_ALPHA_PREC_DIFF) -
|
||||
(1 << GM_ALPHA_PREC_BITS),
|
||||
GM_ABS_ALPHA_BITS);
|
||||
// fallthrough intended
|
||||
case GLOBAL_TRANSLATION:
|
||||
aom_write_primitive_symmetric(
|
||||
w, (params->motion_params.wmmat[0].as_mv.row >> GM_TRANS_PREC_DIFF),
|
||||
w, (params->motion_params.wmmat[0] >> GM_TRANS_PREC_DIFF),
|
||||
GM_ABS_TRANS_BITS);
|
||||
aom_write_primitive_symmetric(
|
||||
w, (params->motion_params.wmmat[0].as_mv.col >> GM_TRANS_PREC_DIFF),
|
||||
w, (params->motion_params.wmmat[1] >> GM_TRANS_PREC_DIFF),
|
||||
GM_ABS_TRANS_BITS);
|
||||
break;
|
||||
default: assert(0);
|
||||
|
|
|
@ -4498,8 +4498,8 @@ static int input_fpmb_stats(FIRSTPASS_MB_STATS *firstpass_mb_stats,
|
|||
// Adds some offset to a global motion parameter and handles
|
||||
// all of the necessary precision shifts, clamping, and
|
||||
// zero-centering.
|
||||
static int16_t add_param_offset(int param_index, int16_t param_value,
|
||||
int16_t offset) {
|
||||
static int32_t add_param_offset(int param_index, int32_t param_value,
|
||||
int32_t offset) {
|
||||
const int scale_vals[2] = { GM_ALPHA_PREC_DIFF, GM_TRANS_PREC_DIFF };
|
||||
const int clamp_vals[2] = { GM_ALPHA_MAX, GM_TRANS_MAX };
|
||||
const int is_trans_param = param_index < 2;
|
||||
|
@ -4513,7 +4513,7 @@ static int16_t add_param_offset(int param_index, int16_t param_value,
|
|||
param_value += offset;
|
||||
// Clamp the parameter so it does not overflow the number of bits allotted
|
||||
// to it in the bitstream
|
||||
param_value = (int16_t)clamp(param_value, -clamp_vals[is_trans_param],
|
||||
param_value = (int32_t)clamp(param_value, -clamp_vals[is_trans_param],
|
||||
clamp_vals[is_trans_param]);
|
||||
// Rescale the parameter to WARPEDMODEL_PRECISION_BITS so it is compatible
|
||||
// with the warped motion library
|
||||
|
@ -4533,12 +4533,12 @@ static void refine_integerized_param(WarpedMotionParams *wm,
|
|||
int n_refinements) {
|
||||
int i = 0, p;
|
||||
int n_params = n_trans_model_params[wm->wmtype];
|
||||
int16_t *param_mat = (int16_t *)wm->wmmat;
|
||||
int32_t *param_mat = wm->wmmat;
|
||||
double step_error;
|
||||
int16_t step;
|
||||
int16_t *param;
|
||||
int16_t curr_param;
|
||||
int16_t best_param;
|
||||
int32_t step;
|
||||
int32_t *param;
|
||||
int32_t curr_param;
|
||||
int32_t best_param;
|
||||
|
||||
double best_error =
|
||||
av1_warp_erroradv(wm,
|
||||
|
@ -4597,22 +4597,22 @@ static void refine_integerized_param(WarpedMotionParams *wm,
|
|||
}
|
||||
|
||||
static void convert_to_params(const double *params, TransformationType type,
|
||||
int16_t *model) {
|
||||
int32_t *model) {
|
||||
int i, diag_value;
|
||||
int alpha_present = 0;
|
||||
int n_params = n_trans_model_params[type];
|
||||
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) *
|
||||
model[0] = (int32_t)floor(params[0] * (1 << GM_TRANS_PREC_BITS) + 0.5);
|
||||
model[1] = (int32_t)floor(params[1] * (1 << GM_TRANS_PREC_BITS) + 0.5);
|
||||
model[0] = (int32_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) *
|
||||
model[1] = (int32_t)clamp(model[1], GM_TRANS_MIN, GM_TRANS_MAX) *
|
||||
GM_TRANS_DECODE_FACTOR;
|
||||
|
||||
for (i = 2; i < n_params; ++i) {
|
||||
diag_value = ((i & 1) ? (1 << GM_ALPHA_PREC_BITS) : 0);
|
||||
model[i] = (int16_t)floor(params[i] * (1 << GM_ALPHA_PREC_BITS) + 0.5);
|
||||
model[i] = (int32_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) +
|
||||
(int32_t)(clamp(model[i] - diag_value, GM_ALPHA_MIN, GM_ALPHA_MAX) +
|
||||
diag_value) *
|
||||
GM_ALPHA_DECODE_FACTOR;
|
||||
alpha_present |= (model[i] != 0);
|
||||
|
@ -4631,7 +4631,7 @@ static void convert_model_to_params(const double *params,
|
|||
Global_Motion_Params *model) {
|
||||
// TODO(sarahparker) implement for homography
|
||||
if (type > HOMOGRAPHY)
|
||||
convert_to_params(params, type, (int16_t *)model->motion_params.wmmat);
|
||||
convert_to_params(params, type, model->motion_params.wmmat);
|
||||
model->gmtype = get_gmtype(model);
|
||||
model->motion_params.wmtype = gm_to_trans_type(model->gmtype);
|
||||
}
|
||||
|
|
|
@ -4102,13 +4102,14 @@ static int get_gmbitcost(const Global_Motion_Params *gm,
|
|||
int gmtype_cost[GLOBAL_MOTION_TYPES];
|
||||
int bits;
|
||||
av1_cost_tokens(gmtype_cost, probs, av1_global_motion_types_tree);
|
||||
if (gm->motion_params.wmmat[2].as_int) {
|
||||
if (gm->motion_params.wmmat[5] || gm->motion_params.wmmat[4]) {
|
||||
bits = (GM_ABS_TRANS_BITS + 1) * 2 + 4 * GM_ABS_ALPHA_BITS + 4;
|
||||
} else if (gm->motion_params.wmmat[1].as_int) {
|
||||
} else if (gm->motion_params.wmmat[3] || gm->motion_params.wmmat[2]) {
|
||||
bits = (GM_ABS_TRANS_BITS + 1) * 2 + 2 * GM_ABS_ALPHA_BITS + 2;
|
||||
} else {
|
||||
bits =
|
||||
(gm->motion_params.wmmat[0].as_int ? ((GM_ABS_TRANS_BITS + 1) * 2) : 0);
|
||||
bits = ((gm->motion_params.wmmat[1] || gm->motion_params.wmmat[0])
|
||||
? ((GM_ABS_TRANS_BITS + 1) * 2)
|
||||
: 0);
|
||||
}
|
||||
return bits ? (bits << AV1_PROB_COST_SHIFT) + gmtype_cost[gm->gmtype] : 0;
|
||||
}
|
||||
|
@ -4186,14 +4187,14 @@ static int set_and_cost_bmi_mvs(const AV1_COMP *const cpi, MACROBLOCK *x,
|
|||
break;
|
||||
case ZEROMV:
|
||||
#if CONFIG_GLOBAL_MOTION
|
||||
this_mv[0].as_int = cpi->common.global_motion[mbmi->ref_frame[0]]
|
||||
.motion_params.wmmat[0]
|
||||
.as_int;
|
||||
this_mv[0].as_int =
|
||||
gm_get_motion_vector(&cpi->common.global_motion[mbmi->ref_frame[0]])
|
||||
.as_int;
|
||||
thismvcost += GLOBAL_MOTION_RATE(mbmi->ref_frame[0]);
|
||||
if (is_compound) {
|
||||
this_mv[1].as_int = cpi->common.global_motion[mbmi->ref_frame[1]]
|
||||
.motion_params.wmmat[0]
|
||||
.as_int;
|
||||
this_mv[1].as_int =
|
||||
gm_get_motion_vector(&cpi->common.global_motion[mbmi->ref_frame[1]])
|
||||
.as_int;
|
||||
thismvcost += GLOBAL_MOTION_RATE(mbmi->ref_frame[1]);
|
||||
}
|
||||
#else // CONFIG_GLOBAL_MOTION
|
||||
|
@ -4907,7 +4908,7 @@ static int64_t rd_pick_best_sub8x8_mode(
|
|||
#endif // CONFIG_EXT_INTER
|
||||
#if CONFIG_GLOBAL_MOTION
|
||||
frame_mv[ZEROMV][frame].as_int =
|
||||
cm->global_motion[frame].motion_params.wmmat[0].as_int;
|
||||
gm_get_motion_vector(&cm->global_motion[frame]).as_int;
|
||||
#else // CONFIG_GLOBAL_MOTION
|
||||
frame_mv[ZEROMV][frame].as_int = 0;
|
||||
#endif // CONFIG_GLOBAL_MOTION
|
||||
|
@ -8240,7 +8241,7 @@ void av1_rd_pick_inter_mode_sb(const AV1_COMP *cpi, TileDataEnc *tile_data,
|
|||
frame_mv[NEWMV][ref_frame].as_int = INVALID_MV;
|
||||
#if CONFIG_GLOBAL_MOTION
|
||||
frame_mv[ZEROMV][ref_frame].as_int =
|
||||
cm->global_motion[ref_frame].motion_params.wmmat[0].as_int;
|
||||
gm_get_motion_vector(&cm->global_motion[ref_frame]).as_int;
|
||||
#else // CONFIG_GLOBAL_MOTION
|
||||
frame_mv[ZEROMV][ref_frame].as_int = 0;
|
||||
#endif // CONFIG_GLOBAL_MOTION
|
||||
|
@ -8334,7 +8335,7 @@ void av1_rd_pick_inter_mode_sb(const AV1_COMP *cpi, TileDataEnc *tile_data,
|
|||
mode_skip_mask[ALTREF_FRAME] = ~INTER_NEAREST_NEAR_ZERO;
|
||||
#if CONFIG_GLOBAL_MOTION
|
||||
zeromv.as_int =
|
||||
cm->global_motion[ALTREF_FRAME].motion_params.wmmat[0].as_int;
|
||||
gm_get_motion_vector(&cm->global_motion[ALTREF_FRAME]).as_int;
|
||||
#else
|
||||
zeromv.as_int = 0;
|
||||
#endif // CONFIG_GLOBAL_MOTION
|
||||
|
@ -9429,10 +9430,10 @@ PALETTE_EXIT:
|
|||
const uint8_t rf_type = av1_ref_frame_type(best_mbmode.ref_frame);
|
||||
#endif // CONFIG_REF_MV
|
||||
#if CONFIG_GLOBAL_MOTION
|
||||
zeromv[0].as_int = cm->global_motion[refs[0]].motion_params.wmmat[0].as_int;
|
||||
zeromv[0].as_int = gm_get_motion_vector(&cm->global_motion[refs[0]]).as_int;
|
||||
zeromv[1].as_int =
|
||||
comp_pred_mode
|
||||
? cm->global_motion[refs[1]].motion_params.wmmat[0].as_int
|
||||
? gm_get_motion_vector(&cm->global_motion[refs[1]]).as_int
|
||||
: 0;
|
||||
#else
|
||||
zeromv[0].as_int = 0;
|
||||
|
@ -9693,7 +9694,7 @@ void av1_rd_pick_inter_mode_sb_seg_skip(const AV1_COMP *cpi,
|
|||
mbmi->ref_frame[1] = NONE;
|
||||
#if CONFIG_GLOBAL_MOTION
|
||||
mbmi->mv[0].as_int =
|
||||
cm->global_motion[mbmi->ref_frame[0]].motion_params.wmmat[0].as_int;
|
||||
gm_get_motion_vector(&cm->global_motion[mbmi->ref_frame[0]]).as_int;
|
||||
#else // CONFIG_GLOBAL_MOTION
|
||||
mbmi->mv[0].as_int = 0;
|
||||
#endif // CONFIG_GLOBAL_MOTION
|
||||
|
|
Загрузка…
Ссылка в новой задаче