Specialize split_only_threshold for lowres on speed 1-2
Performance on Speed 1:
AVG_PSNR | OVR_PSNR | SSIM | AVG_SPDUP | OVR_SPDUP |
-0.001% | -0.004% | +0.025% | +1.551% | +1.405% |
STATS_CHANGED
Change-Id: I20f86677db06447fe4991255130cd5aac7ec5bcc
diff --git a/av1/encoder/partition_model_weights.h b/av1/encoder/partition_model_weights.h
index 873c7c3..ac2890c 100644
--- a/av1/encoder/partition_model_weights.h
+++ b/av1/encoder/partition_model_weights.h
@@ -2702,27 +2702,34 @@
#undef NUM_LOGITS_16
// Slower higher quality split model
-static const float av1_simple_motion_search_split_thresh_128 =
- 5.839480f; // p = 0.997098
-static const float av1_simple_motion_search_split_thresh_64 =
- 1.877167f; // p = 0.867285
-static const float av1_simple_motion_search_split_thresh_32 =
- 3.073499f; // p = 0.955783
-static const float av1_simple_motion_search_split_thresh_16 =
- 1.405601f; // p = 0.803071
-static const float av1_simple_motion_search_split_thresh_8 =
- 2.555636f; // p = 0.927951
+// Threshold from BLOCK_128X128 to BLOCK_8X88
+static const float av1_simple_motion_search_split_midres_thresh[5] = {
+ 5.839480f, // p = 0.997098
+ 1.877167f, // p = 0.867285
+ 3.073499f, // p = 0.955783
+ 1.405601f, // p = 0.803071
+ 2.555636f, // p = 0.927951
+};
-static const float av1_simple_motion_search_no_split_thresh_128 =
- -3.38168078f; // p = 0.032872917
-static const float av1_simple_motion_search_no_split_thresh_64 =
- -4.08610739f; // p = 0.14393017
-static const float av1_simple_motion_search_no_split_thresh_32 =
- -1.7830237f; // p = 0.15270848
-static const float av1_simple_motion_search_no_split_thresh_16 =
- -10.0f; // p = 0
-static const float av1_simple_motion_search_no_split_thresh_8 =
- -10.0f; // p = 0
+static const float av1_simple_motion_search_split_midres_no_thresh[5] = {
+ -3.38168078f, // p = 0.032872917
+ -4.08610739f, // p = 0.14393017
+ -1.7830237f, // p = 0.15270848
+ -100.0f, // p = 0
+ -100.0f, // p = 0
+};
+
+static const float av1_simple_motion_search_split_lowres_thresh[5] = {
+ 1.40402595879f, // 0.8028197
+ 4.72845183649f, // 0.99123732
+ 1.86517797783f, // 0.86589934
+ 1.58715223005f, // 0.83021506
+ 7.22695596987f, // 0.9992738
+};
+
+static const float av1_simple_motion_search_split_lowres_no_thresh[5] = {
+ -100.0f, -100.0f, -100.0f, -100.0f, -100.0f,
+};
static const float av1_simple_motion_search_split_mean_128[17] = {
14.119120f, 14.087010f, 12.016185f, 11.966075f, 12.042454f, 11.994805f,
@@ -2784,6 +2791,20 @@
0.759407f, 0.759684f, 0.089830f, 0.742797f, 0.730632f,
};
+static const float *const av1_simple_motion_search_split_mean[5] = {
+ av1_simple_motion_search_split_mean_128,
+ av1_simple_motion_search_split_mean_64,
+ av1_simple_motion_search_split_mean_32,
+ av1_simple_motion_search_split_mean_16,
+ av1_simple_motion_search_split_mean_8,
+};
+
+static const float *const av1_simple_motion_search_split_std[5] = {
+ av1_simple_motion_search_split_std_128, av1_simple_motion_search_split_std_64,
+ av1_simple_motion_search_split_std_32, av1_simple_motion_search_split_std_16,
+ av1_simple_motion_search_split_std_8,
+};
+
#define NUM_HIDDEN_LAYERS_128 1
#define NUM_FEATURES_128 17
#define NUM_LAYER_0_UNITS_128 20
@@ -3366,6 +3387,14 @@
#undef NUM_LAYER_0_UNITS_8
#undef NUM_LOGITS_8
+static const NN_CONFIG *const av1_simple_motion_search_split_nn_config[5] = {
+ &av1_simple_motion_search_split_nn_config_128,
+ &av1_simple_motion_search_split_nn_config_64,
+ &av1_simple_motion_search_split_nn_config_32,
+ &av1_simple_motion_search_split_nn_config_16,
+ &av1_simple_motion_search_split_nn_config_8,
+};
+
// Model based on simple_motion_search
// Thresholds for doing a single type of partition
diff --git a/av1/encoder/partition_strategy.c b/av1/encoder/partition_strategy.c
index 0a96914..695a80e 100644
--- a/av1/encoder/partition_strategy.c
+++ b/av1/encoder/partition_strategy.c
@@ -132,6 +132,17 @@
}
}
+static int convert_bsize_to_idx(BLOCK_SIZE bsize) {
+ switch (bsize) {
+ case BLOCK_128X128: return 0;
+ case BLOCK_64X64: return 1;
+ case BLOCK_32X32: return 2;
+ case BLOCK_16X16: return 3;
+ case BLOCK_8X8: return 4;
+ default: assert(0 && "Invalid bsize"); return -1;
+ }
+}
+
void av1_simple_motion_search_based_split(
AV1_COMP *const cpi, MACROBLOCK *x, PC_TREE *pc_tree, int mi_row,
int mi_col, BLOCK_SIZE bsize, int *partition_none_allowed,
@@ -147,42 +158,28 @@
}
aom_clear_system_state();
- const NN_CONFIG *nn_config = NULL;
- const float *ml_mean = NULL, *ml_std = NULL;
- float split_only_thresh = 10.0f, no_split_thresh = -10.0f;
- if (bsize == BLOCK_128X128) {
- ml_mean = av1_simple_motion_search_split_mean_128;
- ml_std = av1_simple_motion_search_split_std_128;
- nn_config = &av1_simple_motion_search_split_nn_config_128;
- split_only_thresh = av1_simple_motion_search_split_thresh_128;
- no_split_thresh = av1_simple_motion_search_no_split_thresh_128;
- } else if (bsize == BLOCK_64X64) {
- ml_mean = av1_simple_motion_search_split_mean_64;
- ml_std = av1_simple_motion_search_split_std_64;
- nn_config = &av1_simple_motion_search_split_nn_config_64;
- split_only_thresh = av1_simple_motion_search_split_thresh_64;
- no_split_thresh = av1_simple_motion_search_no_split_thresh_64;
- } else if (bsize == BLOCK_32X32) {
- ml_mean = av1_simple_motion_search_split_mean_32;
- ml_std = av1_simple_motion_search_split_std_32;
- nn_config = &av1_simple_motion_search_split_nn_config_32;
- split_only_thresh = av1_simple_motion_search_split_thresh_32;
- no_split_thresh = av1_simple_motion_search_no_split_thresh_32;
- } else if (bsize == BLOCK_16X16) {
- ml_mean = av1_simple_motion_search_split_mean_16;
- ml_std = av1_simple_motion_search_split_std_16;
- nn_config = &av1_simple_motion_search_split_nn_config_16;
- split_only_thresh = av1_simple_motion_search_split_thresh_16;
- no_split_thresh = av1_simple_motion_search_no_split_thresh_16;
- } else if (bsize == BLOCK_8X8) {
- ml_mean = av1_simple_motion_search_split_mean_8;
- ml_std = av1_simple_motion_search_split_std_8;
- nn_config = &av1_simple_motion_search_split_nn_config_8;
- split_only_thresh = av1_simple_motion_search_split_thresh_8;
- no_split_thresh = av1_simple_motion_search_no_split_thresh_8;
+
+ const AV1_COMMON *const cm = &cpi->common;
+ const int is_480p_or_larger = AOMMIN(cm->width, cm->height) >= 480;
+ const int bsize_idx = convert_bsize_to_idx(bsize);
+
+ assert(bsize_idx >= 0 && bsize_idx <= 4 &&
+ "Invalid bsize in simple_motion_search_based_split");
+
+ float split_only_thresh = 100.0f, no_split_thresh = -100.0f;
+
+ const float *ml_mean = av1_simple_motion_search_split_mean[bsize_idx];
+ const float *ml_std = av1_simple_motion_search_split_std[bsize_idx];
+ const NN_CONFIG *nn_config =
+ av1_simple_motion_search_split_nn_config[bsize_idx];
+ if (is_480p_or_larger) {
+ split_only_thresh = av1_simple_motion_search_split_midres_thresh[bsize_idx];
+ no_split_thresh =
+ av1_simple_motion_search_split_midres_no_thresh[bsize_idx];
} else {
- assert(0 && "Unexpected block size in simple_motion_based_split");
- return;
+ split_only_thresh = av1_simple_motion_search_split_lowres_thresh[bsize_idx];
+ no_split_thresh =
+ av1_simple_motion_search_split_lowres_no_thresh[bsize_idx];
}
float features[FEATURE_SIZE_SMS_SPLIT] = { 0.0f };