RTC: Call av1_set_offset only once when bsize == sb_size
Performance:
| SPD_SET | TESTSET | AVG_PSNR | OVR_PSNR | SSIM | SPD |
|---------|---------|----------|----------|---------|-------|
| 7 |rtc_derf | +0.000% | +0.000% | +0.000% | +0.1% |
| 7 | rtc | +0.000% | +0.000% | +0.000% | +0.2% |
|---------|---------|----------|----------|---------|-------|
| 8 |rtc_derf | +0.000% | +0.000% | +0.000% | +0.1% |
| 8 | rtc | +0.000% | +0.000% | +0.000% | +0.2% |
|---------|---------|----------|----------|---------|-------|
| 9 |rtc_derf | +0.000% | +0.000% | +0.000% | +0.1% |
| 9 | rtc | +0.000% | +0.000% | +0.000% | +0.3% |
|---------|---------|----------|----------|---------|-------|
| 10 |rtc_derf | +0.000% | +0.000% | +0.000% | +0.1% |
| 10 | rtc | +0.000% | +0.000% | +0.000% | +0.4% |
Change-Id: I51ee4161b5137851dce69151c7a8ef648b38b63a
diff --git a/av1/encoder/block.h b/av1/encoder/block.h
index 4cece8c..5a7056a 100644
--- a/av1/encoder/block.h
+++ b/av1/encoder/block.h
@@ -793,6 +793,14 @@
int var;
} Block4x4VarInfo;
+#ifndef NDEBUG
+typedef struct SetOffsetsLoc {
+ int mi_row;
+ int mi_col;
+ BLOCK_SIZE bsize;
+} SetOffsetsLoc;
+#endif // NDEBUG
+
/*!\endcond */
/*! \brief Encoder's parameters related to the current coding block.
@@ -1238,6 +1246,10 @@
* store source variance and log of source variance of each 4x4 sub-block.
*/
Block4x4VarInfo *src_var_info_of_4x4_sub_blocks;
+#ifndef NDEBUG
+ /*! \brief A hash to make sure av1_set_offsets is called */
+ SetOffsetsLoc last_set_offsets_loc;
+#endif // NDEBUG
} MACROBLOCK;
#undef SINGLE_REF_MODES
diff --git a/av1/encoder/partition_search.c b/av1/encoder/partition_search.c
index 3809b7d..a0d071a 100644
--- a/av1/encoder/partition_search.c
+++ b/av1/encoder/partition_search.c
@@ -700,6 +700,11 @@
}
av1_init_plane_quantizers(cpi, x, mbmi->segment_id, 0);
}
+#ifndef NDEBUG
+ x->last_set_offsets_loc.mi_row = mi_row;
+ x->last_set_offsets_loc.mi_col = mi_col;
+ x->last_set_offsets_loc.bsize = bsize;
+#endif // NDEBUG
}
/*!\brief Hybrid intra mode search.
@@ -2173,7 +2178,14 @@
MACROBLOCK *const x, int mi_row, int mi_col,
RD_STATS *rd_cost, BLOCK_SIZE bsize,
PICK_MODE_CONTEXT *ctx) {
- av1_set_offsets(cpi, &tile_data->tile_info, x, mi_row, mi_col, bsize);
+ // For nonrd mode, av1_set_offsets is already called at the superblock level
+ // in encode_nonrd_sb when we determine the partitioning.
+ if (bsize != cpi->common.seq_params->sb_size) {
+ av1_set_offsets(cpi, &tile_data->tile_info, x, mi_row, mi_col, bsize);
+ }
+ assert(x->last_set_offsets_loc.mi_row == mi_row &&
+ x->last_set_offsets_loc.mi_col == mi_col &&
+ x->last_set_offsets_loc.bsize == bsize);
AV1_COMMON *const cm = &cpi->common;
const int num_planes = av1_num_planes(cm);
MACROBLOCKD *const xd = &x->e_mbd;