[CFL] Replace Magic Numbers with Constants
Added CFL_SUB8X8_VAL_MI_SIZE and CFL_SUB8X8_VAL_MI_SQUARE to replace the
magic numbers previously used. Also, CFL_SUB8X8_VAL_MI_SIZE goes from 2
to 4 to support the upcoming EXT_PARTITION_TYPE experiment.
Change-Id: I5c812af3366f80345a749451415660024e41ea3c
diff --git a/av1/common/blockd.h b/av1/common/blockd.h
index f9dccc0..23ea3b1 100644
--- a/av1/common/blockd.h
+++ b/av1/common/blockd.h
@@ -685,6 +685,11 @@
#endif // CONFIG_LOOP_RESTORATION
#if CONFIG_CFL
+#if CONFIG_CHROMA_SUB8X8 && CONFIG_DEBUG
+#define CFL_SUB8X8_VAL_MI_SIZE (4)
+#define CFL_SUB8X8_VAL_MI_SQUARE \
+ (CFL_SUB8X8_VAL_MI_SIZE * CFL_SUB8X8_VAL_MI_SIZE)
+#endif // CONFIG_CHROMA_SUB8X8 && CONFIG_DEBUG
typedef struct cfl_ctx {
// Pixel buffer containing the luma pixels used as prediction for chroma
// TODO(ltrudeau) Convert to uint16 for HBD support
@@ -731,7 +736,7 @@
// The prediction used for sub8x8 blocks originates from multiple luma blocks,
// this array is used to validate that cfl_store() is called only once for
// each luma block
- uint8_t sub8x8_val[4];
+ uint8_t sub8x8_val[CFL_SUB8X8_VAL_MI_SQUARE];
#endif // CONFIG_CHROMA_SUB8X8 && CONFIG_DEBUG
#endif // CONFIG_CB4X4
} CFL_CTX;
diff --git a/av1/common/cfl.c b/av1/common/cfl.c
index d16cd2c..39c36f5 100644
--- a/av1/common/cfl.c
+++ b/av1/common/cfl.c
@@ -314,10 +314,10 @@
}
#if CONFIG_DEBUG
for (int unit_r = 0; unit_r < tx_size_high_unit[tx_size]; unit_r++) {
- assert(row + unit_r < 2);
- int row_off = (row + unit_r) * 2;
+ assert(row + unit_r < CFL_SUB8X8_VAL_MI_SIZE);
+ int row_off = (row + unit_r) * CFL_SUB8X8_VAL_MI_SIZE;
for (int unit_c = 0; unit_c < tx_size_wide_unit[tx_size]; unit_c++) {
- assert(col + unit_c < 2);
+ assert(col + unit_c < CFL_SUB8X8_VAL_MI_SIZE);
assert(cfl->sub8x8_val[row_off + col + unit_c] == 0);
cfl->sub8x8_val[row_off + col + unit_c] = 1;
}
@@ -371,13 +371,9 @@
BLOCK_4X4, get_plane_block_size(mbmi->sb_type, &xd->plane[AOM_PLANE_U]));
#if CONFIG_DEBUG
if (mbmi->sb_type < BLOCK_8X8) {
- const int val_high =
- block_size_high[BLOCK_8X8] / block_size_high[BLOCK_4X4];
- const int val_wide =
- block_size_wide[BLOCK_8X8] / block_size_wide[BLOCK_4X4];
- for (int val_r = 0; val_r < val_high; val_r++) {
- for (int val_c = 0; val_c < val_wide; val_c++) {
- assert(cfl->sub8x8_val[(val_r * val_wide) + val_c] == 1);
+ for (int val_r = 0; val_r < mi_size_high[mbmi->sb_type]; val_r++) {
+ for (int val_c = 0; val_c < mi_size_wide[mbmi->sb_type]; val_c++) {
+ assert(cfl->sub8x8_val[val_r * CFL_SUB8X8_VAL_MI_SIZE + val_c] == 1);
}
}
cfl_clear_sub8x8_val(cfl);