Add txb_coeff_cost_map
The txb_coeff_cost_map is a 16x16 map which records each single
transform block's cost from the transform block's location in 4-pixel
unit in recursive transform experiment.
Change-Id: I6da97880c457680594bca56617084010891beaa2
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c
index d23a7ba..efd42c3 100644
--- a/av1/encoder/rdopt.c
+++ b/av1/encoder/rdopt.c
@@ -3041,7 +3041,19 @@
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;
+ {
+ int idx, idy;
+ rd_stats->txb_coeff_cost[plane] += txb_coeff_cost;
+
+ for (idy = 0; idy < txb_h; ++idy)
+ for (idx = 0; idx < txb_w; ++idx)
+ rd_stats->txb_coeff_cost_map[plane][blk_row + idy][blk_col + idx] = 0;
+
+ rd_stats->txb_coeff_cost_map[plane][blk_row][blk_col] = txb_coeff_cost;
+
+ assert(blk_row < 16);
+ assert(blk_col < 16);
+ }
#endif
}
diff --git a/av1/encoder/rdopt.h b/av1/encoder/rdopt.h
index cb9666a..18445e8 100644
--- a/av1/encoder/rdopt.h
+++ b/av1/encoder/rdopt.h
@@ -27,6 +27,8 @@
struct RD_COST;
#if CONFIG_VAR_TX
+#define TXB_COEFF_COST_MAP_SIZE (2 * MAX_MIB_SIZE)
+
// TODO(angiebird): Merge RD_COST and RD_STATS
typedef struct RD_STATS {
int rate;
@@ -35,6 +37,8 @@
int skip;
#if CONFIG_RD_DEBUG
int txb_coeff_cost[MAX_MB_PLANE];
+ int txb_coeff_cost_map[MAX_MB_PLANE][TXB_COEFF_COST_MAP_SIZE]
+ [TXB_COEFF_COST_MAP_SIZE];
#endif
} RD_STATS;
@@ -47,8 +51,13 @@
rd_stats->sse = 0;
rd_stats->skip = 1;
#if CONFIG_RD_DEBUG
- for (plane = 0; plane < MAX_MB_PLANE; ++plane)
+ for (plane = 0; plane < MAX_MB_PLANE; ++plane) {
+ int r, c;
rd_stats->txb_coeff_cost[plane] = 0;
+ for (r = 0; r < TXB_COEFF_COST_MAP_SIZE; ++r)
+ for (c = 0; c < TXB_COEFF_COST_MAP_SIZE; ++c)
+ rd_stats->txb_coeff_cost_map[plane][r][c] = 0;
+ }
#endif
}
@@ -61,8 +70,13 @@
rd_stats->sse = INT64_MAX;
rd_stats->skip = 0;
#if CONFIG_RD_DEBUG
- for (plane = 0; plane < MAX_MB_PLANE; ++plane)
+ for (plane = 0; plane < MAX_MB_PLANE; ++plane) {
+ int r, c;
rd_stats->txb_coeff_cost[plane] = INT_MAX;
+ for (r = 0; r < TXB_COEFF_COST_MAP_SIZE; ++r)
+ for (c = 0; c < TXB_COEFF_COST_MAP_SIZE; ++c)
+ rd_stats->txb_coeff_cost_map[plane][r][c] = INT_MAX;
+ }
#endif
}
@@ -76,8 +90,19 @@
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)
+ for (plane = 0; plane < MAX_MB_PLANE; ++plane) {
+ int r, c;
+ int ref_txb_coeff_cost = 0;
rd_stats_dst->txb_coeff_cost[plane] += rd_stats_src->txb_coeff_cost[plane];
+ // TODO(angiebird): optimize this part
+ for (r = 0; r < TXB_COEFF_COST_MAP_SIZE; ++r)
+ for (c = 0; c < TXB_COEFF_COST_MAP_SIZE; ++c) {
+ rd_stats_dst->txb_coeff_cost_map[plane][r][c] +=
+ rd_stats_src->txb_coeff_cost_map[plane][r][c];
+ ref_txb_coeff_cost += rd_stats_dst->txb_coeff_cost_map[plane][r][c];
+ }
+ assert(ref_txb_coeff_cost == rd_stats_dst->txb_coeff_cost[plane]);
+ }
#endif
}
#endif