Use crop region for global motion estimation
Avoid using the pixels which were added to make y_width/y_height be
multiples of 8 pixels. These extra pixels are not part of the visible
image, so we should not consider them.
Also fix rounding during calculation of segment_map_{w,h}. The previous
code allocated one element too many along each axis if the frame width
or height was a multiple of 32 pixels.
Results (150 frames, speed 1):
lowres2: -0.015% BDRATE, -0.015% encode time
midres2: -0.011% BDRATE, -0.034% encode time
hdres2: 0.000% BDRATE, -0.013% encode time
STATS_CHANGED
Change-Id: I428ea6ad52a9931e2cc8775ce9bafe89f471094d
diff --git a/aom_dsp/pyramid.c b/aom_dsp/pyramid.c
index e7eca54..47c9390 100644
--- a/aom_dsp/pyramid.c
+++ b/aom_dsp/pyramid.c
@@ -253,8 +253,8 @@
static INLINE void fill_pyramid(const YV12_BUFFER_CONFIG *frm, int bit_depth,
ImagePyramid *frm_pyr) {
int n_levels = frm_pyr->n_levels;
- const int frm_width = frm->y_width;
- const int frm_height = frm->y_height;
+ const int frm_width = frm->y_crop_width;
+ const int frm_height = frm->y_crop_height;
const int frm_stride = frm->y_stride;
assert((frm_width >> n_levels) >= 0);
assert((frm_height >> n_levels) >= 0);
diff --git a/aom_scale/generic/yv12config.c b/aom_scale/generic/yv12config.c
index f4635c1..82376f4 100644
--- a/aom_scale/generic/yv12config.c
+++ b/aom_scale/generic/yv12config.c
@@ -82,7 +82,7 @@
// The size of ybf->y_pyramid
if (num_pyramid_levels > 0) {
alloc_size += aom_get_pyramid_alloc_size(
- aligned_width, aligned_height, num_pyramid_levels, use_highbitdepth);
+ width, height, num_pyramid_levels, use_highbitdepth);
alloc_size += av1_get_corner_list_size();
}
#endif // CONFIG_AV1_ENCODER && !CONFIG_REALTIME_ONLY
@@ -191,8 +191,8 @@
ybf->corners = NULL;
}
if (num_pyramid_levels > 0) {
- ybf->y_pyramid = aom_alloc_pyramid(aligned_width, aligned_height,
- num_pyramid_levels, use_highbitdepth);
+ ybf->y_pyramid = aom_alloc_pyramid(width, height, num_pyramid_levels,
+ use_highbitdepth);
ybf->corners = av1_alloc_corner_list();
}
#endif // CONFIG_AV1_ENCODER && !CONFIG_REALTIME_ONLY
diff --git a/av1/encoder/global_motion_facade.c b/av1/encoder/global_motion_facade.c
index 2859ae1..9c9f9f3 100644
--- a/av1/encoder/global_motion_facade.c
+++ b/av1/encoder/global_motion_facade.c
@@ -90,8 +90,8 @@
AV1_COMMON *const cm = &cpi->common;
MACROBLOCKD *const xd = &x->e_mbd;
int i;
- int src_width = cpi->source->y_width;
- int src_height = cpi->source->y_height;
+ int src_width = cpi->source->y_crop_width;
+ int src_height = cpi->source->y_crop_height;
int src_stride = cpi->source->y_stride;
// clang-format off
static const double kIdentityParams[MAX_PARAMDIM - 1] = {
@@ -160,8 +160,8 @@
const int64_t warp_error = av1_refine_integerized_param(
&tmp_wm_params, tmp_wm_params.wmtype, is_cur_buf_hbd(xd), xd->bd,
- ref_buf[frame]->y_buffer, ref_buf[frame]->y_width,
- ref_buf[frame]->y_height, ref_buf[frame]->y_stride,
+ ref_buf[frame]->y_buffer, ref_buf[frame]->y_crop_width,
+ ref_buf[frame]->y_crop_height, ref_buf[frame]->y_stride,
cpi->source->y_buffer, src_width, src_height, src_stride,
GM_REFINEMENT_COUNT, best_warp_error, segment_map, segment_map_w,
erroradv_threshold);
@@ -411,9 +411,9 @@
YV12_BUFFER_CONFIG *source = cpi->source;
gm_info->segment_map_w =
- (source->y_width + WARP_ERROR_BLOCK) >> WARP_ERROR_BLOCK_LOG;
+ (source->y_crop_width + WARP_ERROR_BLOCK - 1) >> WARP_ERROR_BLOCK_LOG;
gm_info->segment_map_h =
- (source->y_height + WARP_ERROR_BLOCK) >> WARP_ERROR_BLOCK_LOG;
+ (source->y_crop_height + WARP_ERROR_BLOCK - 1) >> WARP_ERROR_BLOCK_LOG;
memset(gm_info->reference_frames, -1,
sizeof(gm_info->reference_frames[0][0]) * MAX_DIRECTIONS *