Simplify ref_yv12[2] in av1_joint_motion_search() A careful analysis shows that the ref_yv12[2] array in av1_joint_motion_search() can be replaced by a single variable orig_yv12, like the orig_yv12 variable in av1_compound_single_motion_search(). Only xd->plane[plane].pre[0] needs to be backed up and restored, so a single variable (orig_yv12) suffices. Change-Id: I46a0ac488678ce617f74580ed12eddc1e56b6f39
diff --git a/av1/encoder/motion_search_facade.c b/av1/encoder/motion_search_facade.c index 63bfe79..5d60d9c 100644 --- a/av1/encoder/motion_search_facade.c +++ b/av1/encoder/motion_search_facade.c
@@ -588,7 +588,6 @@ // Allow joint search multiple times iteratively for each reference frame // and break out of the search loop if it couldn't find a better mv. for (ite = 0; ite < (2 * joint_me_num_refine_iter); ite++) { - struct buf_2d ref_yv12[2]; int bestsme = INT_MAX; int id = ite % 2; // Even iterations search in the first reference frame, // odd iterations search in the second. The predictor @@ -628,13 +627,10 @@ cm->width == scaled_ref_frame[1]->y_crop_width && cm->height == scaled_ref_frame[1]->y_crop_height)); - // Initialize based on (possibly scaled) prediction buffers. - ref_yv12[0] = xd->plane[plane].pre[0]; - ref_yv12[1] = xd->plane[plane].pre[1]; - av1_init_inter_params(&inter_pred_params, pw, ph, mi_row * MI_SIZE, mi_col * MI_SIZE, 0, 0, xd->bd, is_cur_buf_hbd(xd), 0, - &cm->sf_identity, &ref_yv12[!id], interp_filters); + &cm->sf_identity, &xd->plane[plane].pre[!id], + interp_filters); inter_pred_params.conv_params = get_conv_params(0, 0, xd->bd); // Since we have scaled the reference frames to match the size of the @@ -643,7 +639,11 @@ &inter_pred_params); // Do full-pixel compound motion search on the current reference frame. - if (id) xd->plane[plane].pre[0] = ref_yv12[id]; + struct buf_2d orig_yv12; + if (id) { + orig_yv12 = xd->plane[plane].pre[0]; + xd->plane[plane].pre[0] = xd->plane[plane].pre[id]; + } // Make motion search params FULLPEL_MOTION_SEARCH_PARAMS full_ms_params; @@ -680,7 +680,7 @@ allow_second_mv; // Restore the pointer to the first (possibly scaled) prediction buffer. - if (id) xd->plane[plane].pre[0] = ref_yv12[0]; + if (id) xd->plane[plane].pre[0] = orig_yv12; for (ref = 0; ref < 2; ++ref) { if (scaled_ref_frame[ref]) { @@ -688,13 +688,14 @@ for (int i = 0; i < num_planes; i++) { xd->plane[i].pre[ref] = backup_yv12[ref][i]; } - // Re-initialize based on unscaled prediction buffers. - ref_yv12[ref] = xd->plane[plane].pre[ref]; } } // Do sub-pixel compound motion search on the current reference frame. - if (id) xd->plane[plane].pre[0] = ref_yv12[id]; + if (id) { + orig_yv12 = xd->plane[plane].pre[0]; + xd->plane[plane].pre[0] = xd->plane[plane].pre[id]; + } if (cpi->common.features.cur_frame_force_integer_mv) { convert_fullmv_to_mv(&best_mv); @@ -733,7 +734,7 @@ } // Restore the pointer to the first prediction buffer. - if (id) xd->plane[plane].pre[0] = ref_yv12[0]; + if (id) xd->plane[plane].pre[0] = orig_yv12; if (bestsme < last_besterr[id]) { cur_mv[id] = best_mv; last_besterr[id] = bestsme;