Refactor VAR_BASED_PARTITION variables in AV1_COMP
This CL groups variables related to variance based partitioning
from AV1_COMP into new struct VarBasedPartitionInfo, and adds
relevant documentation.
BUG=aomedia:2610
Change-Id: I55b4f079dd4dd7052ad9c211e1bdee549898e3e4
diff --git a/av1/encoder/encoder.h b/av1/encoder/encoder.h
index c6aef6e..0de8b2b 100644
--- a/av1/encoder/encoder.h
+++ b/av1/encoder/encoder.h
@@ -669,6 +669,21 @@
VP64x64 *split;
} VP128x128;
+typedef struct {
+ // Thresholds for variance based partitioning. If block variance > threshold,
+ // then that block is forced to split.
+ // thresholds[0] - threshold for 128x128;
+ // thresholds[1] - threshold for 64x64;
+ // thresholds[2] - threshold for 32x32;
+ // thresholds[3] - threshold for 16x16;
+ // thresholds[4] - threshold for 8x8;
+ int64_t thresholds[5];
+
+ // MinMax variance threshold for 8x8 sub blocks of a 16x16 block. If actual
+ // minmax > threshold_minmax, the 16x16 is forced to split.
+ int64_t threshold_minmax;
+} VarBasedPartitionInfo;
+
// TODO(jingning) All spatially adaptive variables should go to TileDataEnc.
typedef struct TileDataEnc {
TileInfo tile_info;
@@ -1199,12 +1214,8 @@
// VARIANCE_AQ segment map refresh
int vaq_refresh;
- // VAR_BASED_PARTITION thresholds
- // 0 - threshold_128x128; 1 - threshold_64x64;
- // 2 - threshold_32x32; 3 - threshold_16x16;
- // 4 - vbp_threshold_8x8;
- int64_t vbp_thresholds[5];
- int64_t vbp_threshold_minmax;
+ // Thresholds for variance based partitioning.
+ VarBasedPartitionInfo vbp_info;
// Probabilities for pruning of various AV1 tools.
FrameProbInfo frame_probs;
diff --git a/av1/encoder/var_based_part.c b/av1/encoder/var_based_part.c
index c6b0042..504833e 100644
--- a/av1/encoder/var_based_part.c
+++ b/av1/encoder/var_based_part.c
@@ -569,9 +569,9 @@
if (sf->part_sf.partition_search_type != VAR_BASED_PARTITION) {
return;
} else {
- set_vbp_thresholds(cpi, cpi->vbp_thresholds, q, content_state);
+ set_vbp_thresholds(cpi, cpi->vbp_info.thresholds, q, content_state);
// The threshold below is not changed locally.
- cpi->vbp_threshold_minmax = 15 + (q >> 3);
+ cpi->vbp_info.threshold_minmax = 15 + (q >> 3);
}
}
@@ -607,6 +607,7 @@
int mi_col) {
AV1_COMMON *const cm = &cpi->common;
MACROBLOCKD *xd = &x->e_mbd;
+ const int64_t *const vbp_thresholds = cpi->vbp_info.thresholds;
int i, j, k, m;
VP128x128 *vt;
@@ -648,9 +649,9 @@
vt->split = td->vt64x64;
- int64_t thresholds[5] = { cpi->vbp_thresholds[0], cpi->vbp_thresholds[1],
- cpi->vbp_thresholds[2], cpi->vbp_thresholds[3],
- cpi->vbp_thresholds[4] };
+ int64_t thresholds[5] = { vbp_thresholds[0], vbp_thresholds[1],
+ vbp_thresholds[2], vbp_thresholds[3],
+ vbp_thresholds[4] };
const int low_res = (cm->width <= 352 && cm->height <= 288);
int variance4x4downsample[64];
@@ -827,7 +828,7 @@
xd->cur_buf->flags,
#endif
pixels_wide, pixels_high);
- int thresh_minmax = (int)cpi->vbp_threshold_minmax;
+ int thresh_minmax = (int)cpi->vbp_info.threshold_minmax;
if (minmax > thresh_minmax) {
force_split[split_index] = 1;
force_split[5 + m2 + i] = 1;