From 86219aa0fc2d60d0b1531a71d184a3dee6afca77 Mon Sep 17 00:00:00 2001 From: Ari Koivula Date: Thu, 3 Mar 2016 17:39:20 +0200 Subject: [PATCH] Fix non-determinism with tiles Earlier fix that fixed the supply side of the cu_array to take tile coordinates into account should have been accompanied with this one that does the same thing to demand side. --- src/search_inter.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/search_inter.c b/src/search_inter.c index 3388671b..13a7dd12 100644 --- a/src/search_inter.c +++ b/src/search_inter.c @@ -1091,9 +1091,17 @@ static void search_pu_inter_ref(const encoder_state_t * const state, // When temporal motion vector candidates are added, there is probably // no point to this anymore, but for now it helps. // TODO: Update this to work with SMP/AMP blocks. - int mid_x_cu = (x + (width >> 1)) / 8; - int mid_y_cu = (y + (height >> 1)) / 8; - cu_info_t *ref_cu = &state->global->ref->cu_arrays[ref_idx]->data[mid_x_cu + mid_y_cu * (frame->width_in_lcu << MAX_DEPTH)]; + const vector2d_t frame_px = { + (state->tile->lcu_offset_x << LOG2_LCU_WIDTH) + x, + (state->tile->lcu_offset_y << LOG2_LCU_WIDTH) + y + }; + const vector2d_t frame_cu = { + (frame_px.x + (width >> 1)) >> MIN_SIZE, + (frame_px.y + (width >> 1)) >> MIN_SIZE + }; + const cu_info_t *ref_cu_array = state->global->ref->cu_arrays[ref_idx]->data; + const int width_in_scu = frame->width_in_lcu << MAX_DEPTH; + const cu_info_t *ref_cu = &ref_cu_array[frame_cu.x + frame_cu.y * width_in_scu]; if (ref_cu->type == CU_INTER) { if (ref_cu->inter.mv_dir & 1) { mv.x = ref_cu->inter.mv[0][0];