Add transform block coefficient cost in RD_STATS for debugging
Change-Id: Iae50d0b0c4f8f383ab4f91d2c1c2fa4e799c7250
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c
index 3382b51..4fa4ff0 100644
--- a/av1/encoder/rdopt.c
+++ b/av1/encoder/rdopt.c
@@ -2936,6 +2936,7 @@
int max_blocks_wide = block_size_wide[plane_bsize];
const int diff_stride = max_blocks_wide;
const int16_t *diff = &p->src_diff[4 * (blk_row * diff_stride + blk_col)];
+ int txb_coeff_cost;
#if CONFIG_EXT_TX
assert(tx_size < TX_SIZES);
#endif // CONFIG_EXT_TX
@@ -3035,9 +3036,13 @@
}
}
rd_stats->dist += tmp * 16;
- rd_stats->rate += av1_cost_coeffs(cm, x, plane, block, coeff_ctx, tx_size,
- scan_order->scan, scan_order->neighbors, 0);
+ txb_coeff_cost = av1_cost_coeffs(cm, x, plane, block, coeff_ctx, tx_size,
+ scan_order->scan, scan_order->neighbors, 0);
+ rd_stats->rate += txb_coeff_cost;
rd_stats->skip &= (p->eobs[block] == 0);
+#if CONFIG_RD_DEBUG
+ rd_stats->txb_coeff_cost[plane] += txb_coeff_cost;
+#endif
}
static void select_tx_block(const AV1_COMP *cpi, MACROBLOCK *x, int blk_row,
diff --git a/av1/encoder/rdopt.h b/av1/encoder/rdopt.h
index cecb46b..bbed9de 100644
--- a/av1/encoder/rdopt.h
+++ b/av1/encoder/rdopt.h
@@ -33,28 +33,52 @@
int64_t dist;
int64_t sse;
int skip;
+#if CONFIG_RD_DEBUG
+ int txb_coeff_cost[MAX_MB_PLANE];
+#endif
} RD_STATS;
static INLINE void init_rd_stats(RD_STATS *rd_stats) {
+#if CONFIG_RD_DEBUG
+ int plane;
+#endif
rd_stats->rate = 0;
rd_stats->dist = 0;
rd_stats->sse = 0;
rd_stats->skip = 1;
+#if CONFIG_RD_DEBUG
+ for (plane = 0; plane < MAX_MB_PLANE; ++plane)
+ rd_stats->txb_coeff_cost[plane] = 0;
+#endif
}
static INLINE void invalid_rd_stats(RD_STATS *rd_stats) {
+#if CONFIG_RD_DEBUG
+ int plane;
+#endif
rd_stats->rate = INT_MAX;
rd_stats->dist = INT64_MAX;
rd_stats->sse = INT64_MAX;
rd_stats->skip = 0;
+#if CONFIG_RD_DEBUG
+ for (plane = 0; plane < MAX_MB_PLANE; ++plane)
+ rd_stats->txb_coeff_cost[plane] = INT_MAX;
+#endif
}
static INLINE void merge_rd_stats(RD_STATS *rd_stats_dst,
const RD_STATS *rd_stats_src) {
+#if CONFIG_RD_DEBUG
+ int plane;
+#endif
rd_stats_dst->rate += rd_stats_src->rate;
rd_stats_dst->dist += rd_stats_src->dist;
rd_stats_dst->sse += rd_stats_src->sse;
rd_stats_dst->skip &= rd_stats_src->skip;
+#if CONFIG_RD_DEBUG
+ for (plane = 0; plane < MAX_MB_PLANE; ++plane)
+ rd_stats_dst->txb_coeff_cost[plane] += rd_stats_src->txb_coeff_cost[plane];
+#endif
}
#endif