Extend SF fast_inter_tx_type_search to speed 6
Extended the SF fast_inter_tx_type_search to speed 6, based on
transform type probabilities. During mode evaluation of inter
blocks, the SF forces transform type to be DCT_DCT if its
probability is greater than a certain threshold(150), else forces
the tx type with maximum probability if it exceeds a higher
threshold(250).
This SF is enabled only for lowres and midres.
Instruction Count BD-Rate Loss(%)
cpu-used Reduction(%) avg.psnr ovr.psnr ssim
6 2.427 0.3735 0.3845 0.3878
STATS_CHANGED
Change-Id: Ia95c37fd0bbf63fb29583f822442d9dde8aefa17
diff --git a/av1/common/blockd.h b/av1/common/blockd.h
index 5e535ad..a4994d0 100644
--- a/av1/common/blockd.h
+++ b/av1/common/blockd.h
@@ -39,6 +39,8 @@
#define INTERINTRA_WEDGE_SIGN 0
+#define DEFAULT_INTER_TX_TYPE DCT_DCT
+
/*!\cond */
// DIFFWTD_MASK_TYPES should not surpass 1 << MAX_DIFFWTD_MASK_BITS
@@ -1177,7 +1179,7 @@
if (is_inter_block(mbmi) || plane_type != PLANE_TYPE_Y ||
xd->lossless[mbmi->segment_id] || tx_size >= TX_32X32 ||
use_screen_content_tools)
- return DCT_DCT;
+ return DEFAULT_INTER_TX_TYPE;
return intra_mode_to_tx_type(mbmi, plane_type);
}
diff --git a/av1/encoder/encodeframe.c b/av1/encoder/encodeframe.c
index fe25f73..e4f8366 100644
--- a/av1/encoder/encodeframe.c
+++ b/av1/encoder/encodeframe.c
@@ -1547,7 +1547,8 @@
}
#endif
- if (cpi->sf.tx_sf.tx_type_search.prune_tx_type_using_stats) {
+ if (cpi->sf.tx_sf.tx_type_search.prune_tx_type_using_stats ||
+ (cpi->sf.tx_sf.tx_type_search.fast_inter_tx_type_search == 1)) {
const FRAME_UPDATE_TYPE update_type =
get_frame_update_type(&cpi->ppi->gf_group, cpi->gf_frame_index);
for (i = 0; i < TX_SIZES_ALL; i++) {
diff --git a/av1/encoder/rdopt_utils.h b/av1/encoder/rdopt_utils.h
index f000379..4c0f81b 100644
--- a/av1/encoder/rdopt_utils.h
+++ b/av1/encoder/rdopt_utils.h
@@ -386,7 +386,7 @@
// TODO(any): Move block independent condition checks to frame level
if (is_inter_block(mbmi)) {
if (is_inter_mode(best_mode) &&
- sf->tx_sf.tx_type_search.fast_inter_tx_type_search &&
+ (sf->tx_sf.tx_type_search.fast_inter_tx_type_search != 0) &&
!cpi->oxcf.txfm_cfg.use_inter_dct_only)
return 1;
} else {
diff --git a/av1/encoder/speed_features.c b/av1/encoder/speed_features.c
index 3dc91a5..c69f89b 100644
--- a/av1/encoder/speed_features.c
+++ b/av1/encoder/speed_features.c
@@ -748,6 +748,10 @@
} else {
sf->inter_sf.prune_ref_mv_idx_search = 1;
}
+
+ if (!is_720p_or_larger) {
+ sf->tx_sf.tx_type_search.fast_inter_tx_type_search = 1;
+ }
}
}
@@ -1358,7 +1362,7 @@
sf->interp_sf.skip_sharp_interp_filter_search = 1;
- sf->tx_sf.tx_type_search.fast_inter_tx_type_search = 1;
+ sf->tx_sf.tx_type_search.fast_inter_tx_type_search = 2;
sf->tx_sf.tx_type_search.fast_intra_tx_type_search = 1;
sf->tx_sf.use_intra_txb_hash = 0;
diff --git a/av1/encoder/speed_features.h b/av1/encoder/speed_features.h
index a2eab3d..cfc383c 100644
--- a/av1/encoder/speed_features.h
+++ b/av1/encoder/speed_features.h
@@ -224,6 +224,10 @@
typedef struct {
TX_TYPE_PRUNE_MODE prune_2d_txfm_mode;
int fast_intra_tx_type_search;
+
+ // 1: Force tx type based on probability of the tx type, during mode search.
+ // 2: Force tx type to be DCT_DCT unconditionally, during mode search. (More
+ // aggressive).
int fast_inter_tx_type_search;
// Prune less likely chosen transforms for each intra mode. The speed
diff --git a/av1/encoder/tx_search.c b/av1/encoder/tx_search.c
index 563ed68..df724b6 100644
--- a/av1/encoder/tx_search.c
+++ b/av1/encoder/tx_search.c
@@ -21,6 +21,9 @@
#include "av1/encoder/tx_search.h"
#include "av1/encoder/txb_rdopt.h"
+#define PROB_THRESH_DCT_DCT_TX_TYPE 150
+#define PROB_THRESH_TX_TYPE 250
+
struct rdcost_block_args {
const AV1_COMP *cpi;
MACROBLOCK *x;
@@ -1964,8 +1967,36 @@
// TX_TYPES, only that specific tx type is allowed.
TX_TYPE txk_allowed = TX_TYPES;
- if ((!is_inter && txfm_params->use_default_intra_tx_type) ||
- (is_inter && txfm_params->use_default_inter_tx_type)) {
+ const FRAME_UPDATE_TYPE update_type =
+ get_frame_update_type(&cpi->ppi->gf_group, cpi->gf_frame_index);
+ int *tx_type_probs;
+#if CONFIG_FRAME_PARALLEL_ENCODE
+ tx_type_probs =
+ (int *)cpi->ppi->temp_frame_probs.tx_type_probs[update_type][tx_size];
+#else
+ tx_type_probs = (int *)cpi->frame_probs.tx_type_probs[update_type][tx_size];
+#endif
+
+ if (is_inter && txfm_params->use_default_inter_tx_type == 1) {
+ if (tx_type_probs[DEFAULT_INTER_TX_TYPE] > PROB_THRESH_DCT_DCT_TX_TYPE) {
+ txk_allowed = DEFAULT_INTER_TX_TYPE;
+ } else {
+ int force_tx_type = 0;
+ int max_prob = 0;
+ for (int i = 1; i < TX_TYPES; i++) { // find maximum probability.
+ if (tx_type_probs[i] > max_prob) {
+ max_prob = tx_type_probs[i];
+ force_tx_type = i;
+ }
+ }
+ if (max_prob > PROB_THRESH_TX_TYPE) // force tx type with max prob.
+ txk_allowed = force_tx_type;
+ else if (x->rd_model == LOW_TXFM_RD) {
+ if (plane == 0) txk_allowed = DCT_DCT;
+ }
+ }
+ } else if ((!is_inter && txfm_params->use_default_intra_tx_type) ||
+ (is_inter && txfm_params->use_default_inter_tx_type == 2)) {
txk_allowed =
get_default_tx_type(0, xd, tx_size, cpi->use_screen_content_tools);
} else if (x->rd_model == LOW_TXFM_RD) {
@@ -2016,15 +2047,6 @@
assert(plane == 0);
allowed_tx_mask = ext_tx_used_flag;
int num_allowed = 0;
- const FRAME_UPDATE_TYPE update_type =
- get_frame_update_type(&cpi->ppi->gf_group, cpi->gf_frame_index);
- int *tx_type_probs;
-#if CONFIG_FRAME_PARALLEL_ENCODE
- tx_type_probs =
- (int *)cpi->ppi->temp_frame_probs.tx_type_probs[update_type][tx_size];
-#else
- tx_type_probs = (int *)cpi->frame_probs.tx_type_probs[update_type][tx_size];
-#endif
int i;
if (cpi->sf.tx_sf.tx_type_search.prune_tx_type_using_stats) {