Avoid repeated motion search pattern assignment
This also avoids breaking the search pattern in higher speed
settings. Tested in speed 5 on BasketballDrill_832x480_50.y4m, the
ins count drops from 322490 M to 296797 M.
STATS_CHANGED
Change-Id: Id0ba41752ee710c385a58b5085c16e836b2e5de5
diff --git a/av1/encoder/encoder.c b/av1/encoder/encoder.c
index 9e85e2b..e412218 100644
--- a/av1/encoder/encoder.c
+++ b/av1/encoder/encoder.c
@@ -1045,15 +1045,13 @@
AV1_COMMON *cm = &cpi->common;
const SequenceHeader *const seq_params = &cm->seq_params;
const AV1EncoderConfig *oxcf = &cpi->oxcf;
- int is_scale = (oxcf->resize_mode || oxcf->superres_mode);
// TODO(agrange) Check if ARF is enabled and skip allocation if not.
// (yunqing)Here use same border as lookahead buffers.
if (aom_realloc_frame_buffer(
&cpi->alt_ref_buffer, oxcf->width, oxcf->height,
seq_params->subsampling_x, seq_params->subsampling_y,
- seq_params->use_highbitdepth,
- is_scale ? oxcf->border_in_pixels : AOM_ENC_LOOKAHEAD_BORDER,
+ seq_params->use_highbitdepth, AOM_ENC_NO_SCALE_BORDER,
cm->byte_alignment, NULL, NULL, NULL))
aom_internal_error(&cm->error, AOM_CODEC_MEM_ERROR,
"Failed to allocate altref buffer");
@@ -3183,7 +3181,7 @@
&cpi->tpl_stats_buffer[frame].rec_picture_buf, cm->width,
cm->height, cm->seq_params.subsampling_x,
cm->seq_params.subsampling_y, cm->seq_params.use_highbitdepth,
- cpi->oxcf.border_in_pixels, cm->byte_alignment))
+ AOM_ENC_NO_SCALE_BORDER, cm->byte_alignment))
aom_internal_error(&cm->error, AOM_CODEC_MEM_ERROR,
"Failed to allocate frame buffer");
}
diff --git a/av1/encoder/tpl_model.c b/av1/encoder/tpl_model.c
index 6ccfd77..11aa2da 100644
--- a/av1/encoder/tpl_model.c
+++ b/av1/encoder/tpl_model.c
@@ -135,12 +135,6 @@
uint32_t sse;
int cost_list[5];
const MvLimits tmp_mv_limits = x->mv_limits;
- // We hash the ss_cfgs based on the reference's stride to avoid having to to
- // compute ss_cfg everytime this function is called.
- // TODO(chiyotsai@google.com): Make this non-static to prepare for tpl
- // multi-threading.
- static search_site_config ss_cfgs[11];
-
MV best_ref_mv1_full; /* full-pixel value of best_ref_mv1 */
best_ref_mv1_full.col = center_mv.col >> 3;
@@ -157,10 +151,11 @@
av1_set_mv_search_range(&x->mv_limits, ¢er_mv);
- search_site_config *ss_cfg = &ss_cfgs[stride_ref % 11];
- if (ss_cfg->stride != stride_ref) {
- av1_init3smotion_compensation(ss_cfg, stride_ref);
- }
+ search_site_config *ss_cfg = &cpi->ss_cfg[SS_CFG_SRC];
+ if (ss_cfg->stride != stride_ref) ss_cfg = &cpi->ss_cfg[SS_CFG_LOOKAHEAD];
+
+ assert(ss_cfg->stride == stride_ref);
+
av1_full_pixel_search(cpi, x, bsize, &best_ref_mv1_full, step_param, 1,
search_method, 0, sadpb, cond_cost_list(cpi, cost_list),
¢er_mv, INT_MAX, 0, (MI_SIZE * mi_col),
@@ -1014,6 +1009,8 @@
int bottom_index, top_index;
EncodeFrameParams this_frame_params = *frame_params;
+ if (cpi->oxcf.superres_mode != SUPERRES_NONE) return;
+
cm->current_frame.frame_type = frame_params->frame_type;
for (int gf_index = gf_group->index; gf_index < gf_group->size; ++gf_index) {
av1_configure_buffer_updates(cpi, &this_frame_params,