Deal correctly with 16x4/4x16 blocks in mvref_common.c
The logic that searches for motion vectors in scan_row_mbmi and
scan_col_mbmi steps in 4x4 units when the block size is less than
8x8. That test (bsize < BLOCK_8X8) doesn't work when you have 16X4 or
4X16 blocks, because they appear higher up in the enum.
Change-Id: Idb1a97f8a43b675fd78dbc76ae501fcdff7adbcd
diff --git a/av1/common/mvref_common.c b/av1/common/mvref_common.c
index 7666000..9c72612 100644
--- a/av1/common/mvref_common.c
+++ b/av1/common/mvref_common.c
@@ -162,9 +162,11 @@
int col_offset = 0;
#if CONFIG_CB4X4
const int bsize = xd->mi[0]->mbmi.sb_type;
- const int mi_offset = bsize < BLOCK_8X8 || abs(row_offset) > 1
- ? mi_size_wide[BLOCK_4X4]
- : mi_size_wide[BLOCK_8X8];
+ const int mi_width = mi_size_wide[bsize];
+ const int mi_col_offset =
+ ((abs(row_offset) > 1) || (mi_width < mi_size_wide[BLOCK_8X8]))
+ ? mi_size_wide[BLOCK_4X4]
+ : mi_size_wide[BLOCK_8X8];
// TODO(jingning): Revisit this part after cb4x4 is stable.
if (abs(row_offset) > 1) {
row_offset *= 2;
@@ -172,13 +174,12 @@
col_offset = 1;
- if (bsize < BLOCK_8X8) {
- if (mi_row & 0x01) row_offset += 1;
- if (mi_col & 0x01) col_offset -= 1;
- }
+ if (mi_row & 0x01 && mi_size_high[bsize] < mi_size_high[BLOCK_8X8])
+ ++row_offset;
+ if (mi_col & 0x01 && mi_width < mi_size_wide[BLOCK_8X8]) --col_offset;
}
#else
- const int mi_offset = mi_size_wide[BLOCK_8X8];
+ const int mi_col_offset = mi_size_wide[BLOCK_8X8];
#endif
for (i = 0; i < xd->n8_w && *refmv_count < MAX_REF_MV_STACK_SIZE;) {
@@ -204,9 +205,9 @@
i += len;
} else {
if (use_step_16)
- i += (mi_offset << 1);
+ i += (mi_col_offset << 1);
else
- i += mi_offset;
+ i += mi_col_offset;
}
}
@@ -223,22 +224,23 @@
int row_offset = 0;
#if CONFIG_CB4X4
const BLOCK_SIZE bsize = xd->mi[0]->mbmi.sb_type;
- const int mi_offset = (bsize < BLOCK_8X8) || (abs(col_offset) > 1)
- ? mi_size_high[BLOCK_4X4]
- : mi_size_high[BLOCK_8X8];
+ const int mi_height = mi_size_high[bsize];
+ const int mi_row_offset =
+ ((abs(col_offset) > 1) || (mi_height < mi_size_high[BLOCK_8X8]))
+ ? mi_size_high[BLOCK_4X4]
+ : mi_size_high[BLOCK_8X8];
if (abs(col_offset) > 1) {
col_offset *= 2;
col_offset += 1;
row_offset = 1;
- if (bsize < BLOCK_8X8) {
- if (mi_row & 0x01) row_offset -= 1;
- if (mi_col & 0x01) col_offset += 1;
- }
+ if (mi_row & 0x01 && mi_height < mi_size_high[BLOCK_8X8]) --row_offset;
+ if (mi_col & 0x01 && mi_size_wide[bsize] < mi_size_wide[BLOCK_8X8])
+ ++col_offset;
}
#else
- const int mi_offset = mi_size_wide[BLOCK_8X8];
+ const int mi_row_offset = mi_size_wide[BLOCK_8X8];
#endif
for (i = 0; i < xd->n8_h && *refmv_count < MAX_REF_MV_STACK_SIZE;) {
@@ -264,9 +266,9 @@
i += len;
} else {
if (use_step_16)
- i += (mi_offset << 1);
+ i += (mi_row_offset << 1);
else
- i += mi_offset;
+ i += mi_row_offset;
}
}