Merge "Add global motion experiment to rdopt" into nextgenv2

This commit is contained in:
Sarah Parker
2016-09-06 18:07:31 +00:00
committed by Gerrit Code Review
9 changed files with 298 additions and 151 deletions

View File

@@ -41,6 +41,7 @@
#include "av1/encoder/cost.h"
#endif
#if CONFIG_GLOBAL_MOTION
#include "av1/common/warped_motion.h"
#include "av1/encoder/global_motion.h"
#endif
#include "av1/encoder/encodeframe.h"
@@ -4402,37 +4403,30 @@ static int input_fpmb_stats(FIRSTPASS_MB_STATS *firstpass_mb_stats,
#if CONFIG_GLOBAL_MOTION
#define MIN_TRANS_THRESH 8
#define GLOBAL_MOTION_ADVANTAGE_THRESH 0.60
#define GLOBAL_MOTION_MODEL ROTZOOM
#define GLOBAL_MOTION_MODEL TRANSLATION
static void convert_to_params(double *H, TransformationType type,
Global_Motion_Params *model) {
int16_t *model) {
int i;
int alpha_present = 0;
int n_params = n_trans_model_params[type];
model->motion_params.wmmat[0] =
(int)floor(H[0] * (1 << GM_TRANS_PREC_BITS) + 0.5);
model->motion_params.wmmat[1] =
(int)floor(H[1] * (1 << GM_TRANS_PREC_BITS) + 0.5);
model->motion_params.wmmat[0] =
clamp(model->motion_params.wmmat[0], GM_TRANS_MIN, GM_TRANS_MAX) *
GM_TRANS_DECODE_FACTOR;
model->motion_params.wmmat[1] =
clamp(model->motion_params.wmmat[1], GM_TRANS_MIN, GM_TRANS_MAX) *
GM_TRANS_DECODE_FACTOR;
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)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) *
GM_TRANS_DECODE_FACTOR;
for (i = 2; i < n_params; ++i) {
model->motion_params.wmmat[i] =
(int)floor(H[i] * (1 << GM_ALPHA_PREC_BITS) + 0.5);
model->motion_params.wmmat[i] =
clamp(model->motion_params.wmmat[i], GM_ALPHA_MIN, GM_ALPHA_MAX) *
GM_ALPHA_DECODE_FACTOR;
alpha_present |= (model->motion_params.wmmat[i] != 0);
model[i] = (int16_t)floor(H[i] * (1 << GM_ALPHA_PREC_BITS) + 0.5);
model[i] = (int16_t)clamp(model[i], GM_ALPHA_MIN, GM_ALPHA_MAX) *
GM_ALPHA_DECODE_FACTOR;
alpha_present |= (model[i] != 0);
}
if (!alpha_present) {
if (abs(model->motion_params.wmmat[0]) < MIN_TRANS_THRESH &&
abs(model->motion_params.wmmat[1]) < MIN_TRANS_THRESH) {
model->motion_params.wmmat[0] = 0;
model->motion_params.wmmat[1] = 0;
if (abs(model[0]) < MIN_TRANS_THRESH && abs(model[1]) < MIN_TRANS_THRESH) {
model[0] = 0;
model[1] = 0;
}
}
}
@@ -4440,7 +4434,8 @@ static void convert_to_params(double *H, TransformationType type,
static void convert_model_to_params(double *H, TransformationType type,
Global_Motion_Params *model) {
// TODO(sarahparker) implement for homography
if (type > HOMOGRAPHY) convert_to_params(H, type, model);
if (type > HOMOGRAPHY)
convert_to_params(H, type, (int16_t *)model->motion_params.wmmat);
model->gmtype = get_gmtype(model);
model->motion_params.wmtype = gm_to_trans_type(model->gmtype);
}