Early termination for warp error computation
This terminates the computation for the warp error once
the frame error exceeds the best frame error found
so far to avoid unneccessary computation.
Change-Id: I094a0b3e13f8b91610e051cb91d20a815879dd80
diff --git a/av1/encoder/encodeframe.c b/av1/encoder/encodeframe.c
index 36d09c0..b6e0f5d 100644
--- a/av1/encoder/encodeframe.c
+++ b/av1/encoder/encodeframe.c
@@ -4716,8 +4716,8 @@
xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH, xd->bd,
#endif // CONFIG_HIGHBITDEPTH
ref_buf[frame]->y_buffer, ref_buf[frame]->y_stride,
- cpi->source->y_buffer, 0, 0, cpi->source->y_width,
- cpi->source->y_height, cpi->source->y_stride);
+ cpi->source->y_buffer, cpi->source->y_width, cpi->source->y_height,
+ cpi->source->y_stride);
if (ref_frame_error == 0) continue;
@@ -4752,7 +4752,8 @@
ref_buf[frame]->y_buffer, ref_buf[frame]->y_width,
ref_buf[frame]->y_height, ref_buf[frame]->y_stride,
cpi->source->y_buffer, cpi->source->y_width,
- cpi->source->y_height, cpi->source->y_stride, 3);
+ cpi->source->y_height, cpi->source->y_stride, 3,
+ best_warp_error);
if (warp_error < best_warp_error) {
best_warp_error = warp_error;
// Save the wm_params modified by refine_integerized_param()
diff --git a/av1/encoder/global_motion.c b/av1/encoder/global_motion.c
index 74cbc8a..da1e403 100644
--- a/av1/encoder/global_motion.c
+++ b/av1/encoder/global_motion.c
@@ -131,8 +131,8 @@
#endif // CONFIG_HIGHBITDEPTH
uint8_t *ref, int r_width, int r_height,
int r_stride, uint8_t *dst, int d_width,
- int d_height, int d_stride,
- int n_refinements) {
+ int d_height, int d_stride, int n_refinements,
+ int64_t best_frame_error) {
static const int max_trans_model_params[TRANS_TYPES] = {
0, 2, 4, 6, 8, 8, 8
};
@@ -154,7 +154,8 @@
ref, r_width, r_height, r_stride,
dst + border * d_stride + border, border, border,
d_width - 2 * border, d_height - 2 * border,
- d_stride, 0, 0, 16, 16);
+ d_stride, 0, 0, 16, 16, best_frame_error);
+ best_error = AOMMIN(best_error, best_frame_error);
step = 1 << (n_refinements + 1);
for (i = 0; i < n_refinements; i++, step >>= 1) {
for (p = 0; p < n_params; ++p) {
@@ -174,7 +175,7 @@
#endif // CONFIG_HIGHBITDEPTH
ref, r_width, r_height, r_stride, dst + border * d_stride + border,
border, border, d_width - 2 * border, d_height - 2 * border, d_stride,
- 0, 0, 16, 16);
+ 0, 0, 16, 16, best_error);
if (step_error < best_error) {
best_error = step_error;
best_param = *param;
@@ -190,7 +191,7 @@
#endif // CONFIG_HIGHBITDEPTH
ref, r_width, r_height, r_stride, dst + border * d_stride + border,
border, border, d_width - 2 * border, d_height - 2 * border, d_stride,
- 0, 0, 16, 16);
+ 0, 0, 16, 16, best_error);
if (step_error < best_error) {
best_error = step_error;
best_param = *param;
@@ -209,7 +210,7 @@
#endif // CONFIG_HIGHBITDEPTH
ref, r_width, r_height, r_stride, dst + border * d_stride + border,
border, border, d_width - 2 * border, d_height - 2 * border,
- d_stride, 0, 0, 16, 16);
+ d_stride, 0, 0, 16, 16, best_error);
if (step_error < best_error) {
best_error = step_error;
best_param = *param;
diff --git a/av1/encoder/global_motion.h b/av1/encoder/global_motion.h
index 38509df..7fca532 100644
--- a/av1/encoder/global_motion.h
+++ b/av1/encoder/global_motion.h
@@ -36,7 +36,8 @@
#endif // CONFIG_HIGHBITDEPTH
uint8_t *ref, int r_width, int r_height,
int r_stride, uint8_t *dst, int d_width,
- int d_height, int d_stride, int n_refinements);
+ int d_height, int d_stride, int n_refinements,
+ int64_t best_frame_error);
/*
Computes "num_motions" candidate global motion parameters between two frames.