Commit 53291fa1 authored by Debargha Mukherjee's avatar Debargha Mukherjee

Some minor changes for global motion.

Increases amortization blocks. Improves results a little.
Also adds aom_clear_system_state() calls correctly to avoid
some occasional crash issues.

Change-Id: Ib776ee5ec30c70c1cd4a1fae7e7f23c2acc58ef6
parent 554bd729
...@@ -4784,7 +4784,6 @@ static void encode_frame_internal(AV1_COMP *cpi) { ...@@ -4784,7 +4784,6 @@ static void encode_frame_internal(AV1_COMP *cpi) {
av1_zero(rdc->comp_pred_diff); av1_zero(rdc->comp_pred_diff);
#if CONFIG_GLOBAL_MOTION #if CONFIG_GLOBAL_MOTION
aom_clear_system_state();
av1_zero(cpi->global_motion_used); av1_zero(cpi->global_motion_used);
for (i = LAST_FRAME; i <= ALTREF_FRAME; ++i) { for (i = LAST_FRAME; i <= ALTREF_FRAME; ++i) {
set_default_gmparams(&cm->global_motion[i]); set_default_gmparams(&cm->global_motion[i]);
...@@ -4797,6 +4796,7 @@ static void encode_frame_internal(AV1_COMP *cpi) { ...@@ -4797,6 +4796,7 @@ static void encode_frame_internal(AV1_COMP *cpi) {
for (frame = LAST_FRAME; frame <= ALTREF_FRAME; ++frame) { for (frame = LAST_FRAME; frame <= ALTREF_FRAME; ++frame) {
ref_buf = get_ref_frame_buffer(cpi, frame); ref_buf = get_ref_frame_buffer(cpi, frame);
if (ref_buf) { if (ref_buf) {
aom_clear_system_state();
if (compute_global_motion_feature_based(GLOBAL_TRANS_TYPES - 1, if (compute_global_motion_feature_based(GLOBAL_TRANS_TYPES - 1,
cpi->Source, ref_buf, params)) { cpi->Source, ref_buf, params)) {
convert_model_to_params(params, &cm->global_motion[frame]); convert_model_to_params(params, &cm->global_motion[frame]);
...@@ -4824,6 +4824,7 @@ static void encode_frame_internal(AV1_COMP *cpi) { ...@@ -4824,6 +4824,7 @@ static void encode_frame_internal(AV1_COMP *cpi) {
set_default_gmparams(&cm->global_motion[frame]); set_default_gmparams(&cm->global_motion[frame]);
} }
} }
aom_clear_system_state();
} }
} }
} }
......
...@@ -4351,15 +4351,22 @@ static int get_gmbitcost(const WarpedMotionParams *gm, const aom_prob *probs) { ...@@ -4351,15 +4351,22 @@ static int get_gmbitcost(const WarpedMotionParams *gm, const aom_prob *probs) {
case IDENTITY: bits = 0; break; case IDENTITY: bits = 0; break;
default: assert(0); return 0; default: assert(0); return 0;
} }
assert(type < GLOBAL_TRANS_TYPES);
return bits ? (bits << AV1_PROB_COST_SHIFT) + gmtype_cost[type] : 0; return bits ? (bits << AV1_PROB_COST_SHIFT) + gmtype_cost[type] : 0;
} }
#define GLOBAL_MOTION_COST_AMORTIZATION_BLKS 8
#if GLOBAL_MOTION_COST_AMORTIZATION_BLKS > 0
#define GLOBAL_MOTION_RATE(ref) \ #define GLOBAL_MOTION_RATE(ref) \
(cpi->global_motion_used[ref] >= 2 \ (cpi->global_motion_used[ref] >= GLOBAL_MOTION_COST_AMORTIZATION_BLKS \
? 0 \ ? 0 \
: get_gmbitcost(&cm->global_motion[(ref)], \ : get_gmbitcost(&cm->global_motion[(ref)], \
cm->fc->global_motion_types_prob) / \ cm->fc->global_motion_types_prob) / \
2); GLOBAL_MOTION_COST_AMORTIZATION_BLKS);
#else
#define GLOBAL_MOTION_RATE(ref) 0
#endif // GLOBAL_MOTION_COST_AMORTIZATION_BLKS > 0
#endif // CONFIG_GLOBAL_MOTION #endif // CONFIG_GLOBAL_MOTION
static int set_and_cost_bmi_mvs(const AV1_COMP *const cpi, MACROBLOCK *x, static int set_and_cost_bmi_mvs(const AV1_COMP *const cpi, MACROBLOCK *x,
......
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