Commit 13ea0195 authored by Angie Chiang's avatar Angie Chiang Committed by Gerrit Code Review
Browse files

Merge changes Ib9428dc9,Ide04717a,If1dba7d8,I6da97880 into nextgenv2

* changes:
  Merge rd_stats only when it is valid
  Let parentheses in handle_inter_mode be symmetric
  Add RD_STATS into MB_MODE_INFO
  Add txb_coeff_cost_map
parents f0481a59 616990d6
......@@ -211,6 +211,23 @@ typedef struct {
} FILTER_INTRA_MODE_INFO;
#endif // CONFIG_FILTER_INTRA
#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;
int64_t dist;
int64_t sse;
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;
#endif // CONFIG_VAR_TX
// This structure now relates to 8x8 block regions.
typedef struct {
// Common for both INTER and INTRA blocks
......@@ -283,7 +300,7 @@ typedef struct {
int current_q_index;
#endif
#if CONFIG_RD_DEBUG
int64_t txb_coeff_cost[MAX_MB_PLANE];
RD_STATS rd_stats;
int mi_row;
int mi_col;
#endif
......
......@@ -1929,7 +1929,7 @@ static void write_modes_b(AV1_COMP *cpi, const TileInfo *const tile,
}
#if CONFIG_RD_DEBUG
for (plane = 0; plane < MAX_MB_PLANE; ++plane) {
if (m->mbmi.txb_coeff_cost[plane] != txb_coeff_cost[plane]) {
if (m->mbmi.rd_stats.txb_coeff_cost[plane] != txb_coeff_cost[plane]) {
dump_mode_info(m);
assert(0);
}
......
......@@ -3217,7 +3217,19 @@ void av1_tx_block_rd_b(const AV1_COMP *cpi, MACROBLOCK *x, TX_SIZE tx_size,
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
}
......@@ -3595,7 +3607,7 @@ static void select_tx_type_yrd(const AV1_COMP *cpi, MACROBLOCK *x,
mbmi->tx_size = best_tx;
#if CONFIG_RD_DEBUG
// record plane y's transform block coefficient cost
mbmi->txb_coeff_cost[0] = rd_stats->txb_coeff_cost[0];
mbmi->rd_stats = *rd_stats;
#endif
memcpy(x->blk_skip[0], best_blk_skip, sizeof(best_blk_skip[0]) * n4);
}
......@@ -7084,11 +7096,14 @@ static int64_t handle_inter_mode(
#if CONFIG_REF_MV
#if CONFIG_EXT_INTER
if (this_mode == NEAREST_NEARESTMV) {
if (this_mode == NEAREST_NEARESTMV)
#else
if (this_mode == NEARESTMV && is_comp_pred) {
uint8_t ref_frame_type = av1_ref_frame_type(mbmi->ref_frame);
if (this_mode == NEARESTMV && is_comp_pred)
#endif // CONFIG_EXT_INTER
{
#if !CONFIG_EXT_INTER
uint8_t ref_frame_type = av1_ref_frame_type(mbmi->ref_frame);
#endif
if (mbmi_ext->ref_mv_count[ref_frame_type] > 0) {
cur_mv[0] = mbmi_ext->ref_mv_stack[ref_frame_type][0].this_mv;
cur_mv[1] = mbmi_ext->ref_mv_stack[ref_frame_type][0].comp_mv;
......@@ -7826,8 +7841,7 @@ static int64_t handle_inter_mode(
inter_block_uvrd(cpi, x, &rd_stats_uv, bsize, ref_best_rd - rdcosty);
#if CONFIG_RD_DEBUG
// record uv planes' transform block coefficient cost
mbmi->txb_coeff_cost[1] = rd_stats_uv.txb_coeff_cost[1];
mbmi->txb_coeff_cost[2] = rd_stats_uv.txb_coeff_cost[2];
if (is_cost_valid_uv) av1_merge_rd_stats(&mbmi->rd_stats, &rd_stats_uv);
#endif
*rate_uv = rd_stats_uv.rate;
distortion_uv = rd_stats_uv.dist;
......
......@@ -27,17 +27,6 @@ struct macroblock;
struct RD_COST;
#if CONFIG_VAR_TX
// TODO(angiebird): Merge RD_COST and RD_STATS
typedef struct RD_STATS {
int rate;
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 av1_init_rd_stats(RD_STATS *rd_stats) {
#if CONFIG_RD_DEBUG
int plane;
......@@ -47,8 +36,13 @@ static INLINE void av1_init_rd_stats(RD_STATS *rd_stats) {
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 +55,13 @@ static INLINE void av1_invalid_rd_stats(RD_STATS *rd_stats) {
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 +75,19 @@ static INLINE void av1_merge_rd_stats(RD_STATS *rd_stats_dst,
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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment