Correct scaled ref indices in compound motion search
Change-Id: I81621c1730ed1793398274de8ea61b694a5b3e4c
diff --git a/av1/encoder/motion_search_facade.c b/av1/encoder/motion_search_facade.c
index 2a2ad2e..d232f27 100644
--- a/av1/encoder/motion_search_facade.c
+++ b/av1/encoder/motion_search_facade.c
@@ -738,7 +738,11 @@
}
const int mi_row = xd->mi_row;
const int mi_col = xd->mi_col;
- av1_setup_pre_planes(xd, ref_idx, scaled_ref_frame, mi_row, mi_col, NULL,
+ // The index below needs to be 0 instead of ref_idx since we assume the
+ // 0th slot to be used for subsequent searches. Note that the ref_idx
+ // reference buffer has been copied to the 0th slot in the code above.
+ // Now we need to swap the reference frame for the 0th slot.
+ av1_setup_pre_planes(xd, 0, scaled_ref_frame, mi_row, mi_col, NULL,
num_planes);
}
@@ -767,9 +771,9 @@
&best_mv.as_fullmv, NULL);
if (scaled_ref_frame) {
- // Swap back the original buffers for subpel motion search.
+ // Swap back the original buffers for subpel motion search for the 0th slot.
for (int i = 0; i < num_planes; i++) {
- xd->plane[i].pre[ref_idx] = backup_yv12[i];
+ xd->plane[i].pre[0] = backup_yv12[i];
}
}