Commit 59526ead authored by Angie Chiang's avatar Angie Chiang Committed by Gerrit Code Review
Browse files

Merge changes I3bc782d6,I8359e849,Iae50d0b0,Id1704d88,Ia69f13c4, ... into nextgenv2

* changes:
  Add av1_ prefix on ###_rd_stats functions
  Use init_rd_stats() in encodeframe.c
  Add transform block coefficient cost in RD_STATS for debugging
  Add helper functions to modify RD_STATS
  Add mi_row and mi_col into mbmi to facilitate rd_debug process
  Add token cost comparison in write_modes_b()
parents 653fdd6d c0feea8a
......@@ -27,6 +27,10 @@
#endif
#include "aom_dsp/prob.h"
#if CONFIG_RD_DEBUG
#include "av1/encoder/cost.h"
#endif
#ifdef __cplusplus
extern "C" {
#endif
......@@ -39,6 +43,8 @@ typedef struct daala_writer aom_writer;
typedef struct aom_dk_writer aom_writer;
#endif
typedef struct TOKEN_STATS { int64_t cost; } TOKEN_STATS;
static INLINE void aom_start_encode(aom_writer *bc, uint8_t *buffer) {
#if CONFIG_ANS
(void)bc;
......@@ -72,10 +78,25 @@ static INLINE void aom_write(aom_writer *br, int bit, int probability) {
#endif
}
static INLINE void aom_write_record(aom_writer *br, int bit, int probability,
TOKEN_STATS *token_stats) {
aom_write(br, bit, probability);
#if CONFIG_RD_DEBUG
token_stats->cost += av1_cost_bit(probability, bit);
#else
(void)token_stats;
#endif
}
static INLINE void aom_write_bit(aom_writer *w, int bit) {
aom_write(w, bit, 128); // aom_prob_half
}
static INLINE void aom_write_bit_record(aom_writer *w, int bit,
TOKEN_STATS *token_stats) {
aom_write_record(w, bit, 128, token_stats); // aom_prob_half
}
static INLINE void aom_write_literal(aom_writer *w, int data, int bits) {
int bit;
......@@ -92,6 +113,18 @@ static INLINE void aom_write_tree_bits(aom_writer *w, const aom_tree_index *tr,
} while (len);
}
static INLINE void aom_write_tree_bits_record(aom_writer *w,
const aom_tree_index *tr,
const aom_prob *probs, int bits,
int len, aom_tree_index i,
TOKEN_STATS *token_stats) {
do {
const int bit = (bits >> --len) & 1;
aom_write_record(w, bit, probs[i >> 1], token_stats);
i = tr[i + bit];
} while (len);
}
static INLINE void aom_write_tree(aom_writer *w, const aom_tree_index *tree,
const aom_prob *probs, int bits, int len,
aom_tree_index i) {
......@@ -102,6 +135,19 @@ static INLINE void aom_write_tree(aom_writer *w, const aom_tree_index *tree,
#endif
}
static INLINE void aom_write_tree_record(aom_writer *w,
const aom_tree_index *tree,
const aom_prob *probs, int bits,
int len, aom_tree_index i,
TOKEN_STATS *token_stats) {
#if CONFIG_DAALA_EC
(void)token_stats;
daala_write_tree_bits(w, tree, probs, bits, len, i);
#else
aom_write_tree_bits_record(w, tree, probs, bits, len, i, token_stats);
#endif
}
#if CONFIG_EC_MULTISYMBOL
static INLINE void aom_write_symbol(aom_writer *w, int symb, aom_cdf_prob *cdf,
int nsymbs) {
......
......@@ -250,6 +250,12 @@ typedef struct {
#if CONFIG_DELTA_Q
int current_q_index;
#endif
#if CONFIG_RD_DEBUG
int64_t txb_cost_y;
int64_t txb_cost_uv;
int mi_row;
int mi_col;
#endif
} MB_MODE_INFO;
typedef struct MODE_INFO {
......
......@@ -442,6 +442,10 @@ static MB_MODE_INFO *set_offsets(AV1_COMMON *const cm, MACROBLOCKD *const xd,
// TODO(slavarnway): Generate sb_type based on bwl and bhl, instead of
// passing bsize from decode_partition().
xd->mi[0]->mbmi.sb_type = bsize;
#if CONFIG_RD_DEBUG
xd->mi[0]->mbmi.mi_row = mi_row;
xd->mi[0]->mbmi.mi_col = mi_col;
#endif
for (y = 0; y < y_mis; ++y)
for (x = !y; x < x_mis; ++x) xd->mi[y * cm->mi_stride + x] = xd->mi[0];
......
......@@ -717,7 +717,8 @@ static void update_supertx_probs(AV1_COMMON *cm, int probwt, aom_writer *w) {
static void pack_mb_tokens(aom_writer *w, const TOKENEXTRA **tp,
const TOKENEXTRA *const stop,
aom_bit_depth_t bit_depth, const TX_SIZE tx_size) {
aom_bit_depth_t bit_depth, const TX_SIZE tx_size,
TOKEN_STATS *token_stats) {
const TOKENEXTRA *p = *tp;
#if CONFIG_VAR_TX
int count = 0;
......@@ -745,10 +746,11 @@ static void pack_mb_tokens(aom_writer *w, const TOKENEXTRA **tp,
#if CONFIG_EC_MULTISYMBOL
/* skip one or two nodes */
if (!p->skip_eob_node) aom_write(w, token != EOB_TOKEN, p->context_tree[0]);
if (!p->skip_eob_node)
aom_write_record(w, token != EOB_TOKEN, p->context_tree[0], token_stats);
if (token != EOB_TOKEN) {
aom_write(w, token != ZERO_TOKEN, p->context_tree[1]);
aom_write_record(w, token != ZERO_TOKEN, p->context_tree[1], token_stats);
if (token != ZERO_TOKEN) {
aom_write_symbol(w, token - ONE_TOKEN, *p->token_cdf,
......@@ -760,19 +762,21 @@ static void pack_mb_tokens(aom_writer *w, const TOKENEXTRA **tp,
if (p->skip_eob_node)
coef_length -= p->skip_eob_node;
else
aom_write(w, token != EOB_TOKEN, p->context_tree[0]);
aom_write_record(w, token != EOB_TOKEN, p->context_tree[0], token_stats);
if (token != EOB_TOKEN) {
aom_write(w, token != ZERO_TOKEN, p->context_tree[1]);
aom_write_record(w, token != ZERO_TOKEN, p->context_tree[1], token_stats);
if (token != ZERO_TOKEN) {
aom_write(w, token != ONE_TOKEN, p->context_tree[2]);
aom_write_record(w, token != ONE_TOKEN, p->context_tree[2],
token_stats);
if (token != ONE_TOKEN) {
const int unconstrained_len = UNCONSTRAINED_NODES - p->skip_eob_node;
aom_write_tree(w, av1_coef_con_tree,
av1_pareto8_full[p->context_tree[PIVOT_NODE] - 1],
coef_value, coef_length - unconstrained_len, 0);
aom_write_tree_record(
w, av1_coef_con_tree,
av1_pareto8_full[p->context_tree[PIVOT_NODE] - 1], coef_value,
coef_length - unconstrained_len, 0, token_stats);
}
}
}
......@@ -800,12 +804,12 @@ static void pack_mb_tokens(aom_writer *w, const TOKENEXTRA **tp,
--skip_bits;
assert(!bb);
} else {
aom_write(w, bb, pb[index]);
aom_write_record(w, bb, pb[index], token_stats);
}
}
}
aom_write_bit(w, bit_string & 1);
aom_write_bit_record(w, bit_string & 1, token_stats);
}
++p;
......@@ -824,7 +828,7 @@ static void pack_txb_tokens(aom_writer *w, const TOKENEXTRA **tp,
MB_MODE_INFO *mbmi, int plane,
BLOCK_SIZE plane_bsize, aom_bit_depth_t bit_depth,
int block, int blk_row, int blk_col,
TX_SIZE tx_size) {
TX_SIZE tx_size, TOKEN_STATS *token_stats) {
const struct macroblockd_plane *const pd = &xd->plane[plane];
const BLOCK_SIZE bsize = txsize_to_bsize[tx_size];
const int tx_row = blk_row >> (1 - pd->subsampling_y);
......@@ -840,7 +844,7 @@ static void pack_txb_tokens(aom_writer *w, const TOKENEXTRA **tp,
: mbmi->inter_tx_size[tx_row][tx_col];
if (tx_size == plane_tx_size) {
pack_mb_tokens(w, tp, tok_end, bit_depth, tx_size);
pack_mb_tokens(w, tp, tok_end, bit_depth, tx_size, token_stats);
} else {
const int bsl = block_size_wide[bsize] >> (tx_size_wide_log2[0] + 1);
int i;
......@@ -856,7 +860,7 @@ static void pack_txb_tokens(aom_writer *w, const TOKENEXTRA **tp,
if (offsetr >= max_blocks_high || offsetc >= max_blocks_wide) continue;
pack_txb_tokens(w, tp, tok_end, xd, mbmi, plane, plane_bsize, bit_depth,
block, offsetr, offsetc, sub_txs);
block, offsetr, offsetc, sub_txs, token_stats);
block += step;
}
}
......@@ -1725,6 +1729,20 @@ static void write_mb_modes_kf(AV1_COMMON *cm, const MACROBLOCKD *xd,
write_modes_b(cpi, tile, w, tok, tok_end, mi_row, mi_col)
#endif // CONFIG_SUPERTX
#if CONFIG_RD_DEBUG
static void dump_mode_info(MODE_INFO *mi) {
printf("\nmi->mbmi.mi_row == %d\n", mi->mbmi.mi_row);
printf("&& mi->mbmi.mi_col == %d\n", mi->mbmi.mi_col);
printf("&& mi->mbmi.sb_type == %d\n", mi->mbmi.sb_type);
printf("&& mi->mbmi.tx_size == %d\n", mi->mbmi.tx_size);
if (mi->mbmi.sb_type >= BLOCK_8X8) {
printf("&& mi->mbmi.mode == %d\n", mi->mbmi.mode);
} else {
printf("&& mi->bmi[0].as_mode == %d\n", mi->bmi[0].as_mode);
}
}
#endif
static void write_modes_b(AV1_COMP *cpi, const TileInfo *const tile,
aom_writer *w, const TOKENEXTRA **tok,
const TOKENEXTRA *const tok_end,
......@@ -1737,6 +1755,10 @@ static void write_modes_b(AV1_COMP *cpi, const TileInfo *const tile,
MODE_INFO *m;
int plane;
int bh, bw;
#if CONFIG_RD_DEBUG
int64_t txb_cost_y = 0;
int64_t txb_cost_uv = 0;
#endif
#if CONFIG_RANS
(void)tok;
(void)tok_end;
......@@ -1836,11 +1858,18 @@ static void write_modes_b(AV1_COMP *cpi, const TileInfo *const tile,
#if CONFIG_EXT_TX && CONFIG_RECT_TX
TX_SIZE tx_size =
plane ? get_uv_tx_size(mbmi, &xd->plane[plane]) : mbmi->tx_size;
#endif
TOKEN_STATS token_stats;
token_stats.cost = 0;
#if CONFIG_EXT_TX && CONFIG_RECT_TX
if (is_inter_block(mbmi) && !is_rect_tx(tx_size)) {
if (is_inter_block(mbmi) && !is_rect_tx(tx_size))
#else
if (is_inter_block(mbmi)) {
if (is_inter_block(mbmi))
#endif
{
const TX_SIZE max_tx_size = max_txsize_lookup[plane_bsize];
int block = 0;
const int step =
......@@ -1850,7 +1879,8 @@ static void write_modes_b(AV1_COMP *cpi, const TileInfo *const tile,
for (row = 0; row < num_4x4_h; row += bkh) {
for (col = 0; col < num_4x4_w; col += bkw) {
pack_txb_tokens(w, tok, tok_end, xd, mbmi, plane, plane_bsize,
cm->bit_depth, block, row, col, max_tx_size);
cm->bit_depth, block, row, col, max_tx_size,
&token_stats);
block += step;
}
}
......@@ -1862,17 +1892,40 @@ static void write_modes_b(AV1_COMP *cpi, const TileInfo *const tile,
for (row = 0; row < num_4x4_h; row += bkh)
for (col = 0; col < num_4x4_w; col += bkw)
pack_mb_tokens(w, tok, tok_end, cm->bit_depth, tx);
pack_mb_tokens(w, tok, tok_end, cm->bit_depth, tx, &token_stats);
}
#else
TX_SIZE tx =
plane ? get_uv_tx_size(&m->mbmi, &xd->plane[plane]) : m->mbmi.tx_size;
pack_mb_tokens(w, tok, tok_end, cm->bit_depth, tx);
TOKEN_STATS token_stats;
token_stats.cost = 0;
pack_mb_tokens(w, tok, tok_end, cm->bit_depth, tx, &token_stats);
#endif // CONFIG_VAR_TX
#if CONFIG_RD_DEBUG
if (plane == 0)
txb_cost_y += token_stats.cost;
else
txb_cost_uv += token_stats.cost;
#else
(void)token_stats;
#endif
assert(*tok < tok_end && (*tok)->token == EOSB_TOKEN);
(*tok)++;
}
}
#if CONFIG_RD_DEBUG
if (m->mbmi.txb_cost_y != txb_cost_y) {
dump_mode_info(m);
assert(0);
}
if (m->mbmi.txb_cost_uv != txb_cost_uv) {
dump_mode_info(m);
assert(0);
}
#endif
}
static void write_partition(const AV1_COMMON *const cm,
......@@ -2070,9 +2123,11 @@ static void write_modes_sb(AV1_COMP *const cpi, const TileInfo *const tile,
BLOCK_SIZE txb_size = txsize_to_bsize[tx];
int bw = num_4x4_blocks_wide_lookup[txb_size];
TOKEN_STATS token_stats;
token_stats.cost = 0;
for (row = 0; row < num_4x4_h; row += bw)
for (col = 0; col < num_4x4_w; col += bw)
pack_mb_tokens(w, tok, tok_end, cm->bit_depth, tx);
pack_mb_tokens(w, tok, tok_end, cm->bit_depth, tx, &token_stats);
assert(*tok < tok_end && (*tok)->token == EOSB_TOKEN);
(*tok)++;
}
......
......@@ -1634,6 +1634,10 @@ static void rd_pick_sb_modes(const AV1_COMP *const cpi, TileDataEnc *tile_data,
set_offsets(cpi, tile_info, x, mi_row, mi_col, bsize);
mbmi = &xd->mi[0]->mbmi;
mbmi->sb_type = bsize;
#if CONFIG_RD_DEBUG
mbmi->mi_row = mi_row;
mbmi->mi_col = mi_col;
#endif
#if CONFIG_SUPERTX
// We set tx_size here as skip blocks would otherwise not set it.
// tx_size needs to be set at this point as supertx_enable in
......@@ -6181,11 +6185,7 @@ static void rd_supertx_sb(const AV1_COMP *const cpi, ThreadData *td,
const struct macroblockd_plane *const pd = &xd->plane[plane];
int coeff_ctx = 1;
RD_STATS this_rd_stats;
this_rd_stats.rate = 0;
this_rd_stats.dist = 0;
this_rd_stats.sse = 0;
this_rd_stats.skip = 1;
av1_init_rd_stats(&this_rd_stats);
tx_size = max_txsize_lookup[bsize];
tx_size =
......@@ -6240,10 +6240,7 @@ static void rd_supertx_sb(const AV1_COMP *const cpi, ThreadData *td,
mbmi->tx_type = tx_type;
#if CONFIG_VAR_TX
this_rd_stats.rate = 0;
this_rd_stats.dist = 0;
this_rd_stats.sse = 0;
this_rd_stats.skip = 1;
av1_init_rd_stats(&this_rd_stats);
av1_get_entropy_contexts(bsize, tx_size, pd, ctxa, ctxl);
coeff_ctx = combine_entropy_contexts(ctxa[0], ctxl[0]);
......
......@@ -2936,6 +2936,7 @@ void av1_tx_block_rd_b(const AV1_COMP *cpi, MACROBLOCK *x, TX_SIZE tx_size,
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 @@ void av1_tx_block_rd_b(const AV1_COMP *cpi, MACROBLOCK *x, TX_SIZE tx_size,
}
}
rd_stats->dist += tmp * 16;
rd_stats->rate += av1_cost_coeffs(cm, x, plane, block, coeff_ctx, tx_size,
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,
......@@ -3067,12 +3072,11 @@ static void select_tx_block(const AV1_COMP *cpi, MACROBLOCK *x, int blk_row,
txfm_partition_context(tx_above + (blk_col >> 1),
tx_left + (blk_row >> 1), mbmi->sb_type, tx_size);
int64_t sum_dist = 0, sum_bsse = 0;
int64_t sum_rd = INT64_MAX;
int sum_rate = 0;
int all_skip = 1;
int tmp_eob = 0;
int zero_blk_rate;
RD_STATS sum_rd_stats;
av1_init_rd_stats(&sum_rd_stats);
#if CONFIG_EXT_TX
assert(tx_size < TX_SIZES);
......@@ -3085,10 +3089,7 @@ static void select_tx_block(const AV1_COMP *cpi, MACROBLOCK *x, int blk_row,
coeff_ctx = get_entropy_context(tx_size, pta, ptl);
rd_stats->rate = 0;
rd_stats->dist = 0;
rd_stats->sse = 0;
rd_stats->skip = 1;
av1_init_rd_stats(rd_stats);
if (blk_row >= max_blocks_high || blk_col >= max_blocks_wide) return;
......@@ -3129,7 +3130,8 @@ static void select_tx_block(const AV1_COMP *cpi, MACROBLOCK *x, int blk_row,
int this_cost_valid = 1;
int64_t tmp_rd = 0;
sum_rate = av1_cost_bit(cpi->common.fc->txfm_partition_prob[ctx], 1);
sum_rd_stats.rate =
av1_cost_bit(cpi->common.fc->txfm_partition_prob[ctx], 1);
#if CONFIG_EXT_TX
assert(tx_size < TX_SIZES);
#endif // CONFIG_EXT_TX
......@@ -3143,12 +3145,10 @@ static void select_tx_block(const AV1_COMP *cpi, MACROBLOCK *x, int blk_row,
depth + 1, plane_bsize, ta, tl, tx_above, tx_left,
&this_rd_stats, ref_best_rd - tmp_rd, &this_cost_valid);
sum_rate += this_rd_stats.rate;
sum_dist += this_rd_stats.dist;
sum_bsse += this_rd_stats.sse;
all_skip &= this_rd_stats.skip;
av1_merge_rd_stats(&sum_rd_stats, &this_rd_stats);
tmp_rd = RDCOST(x->rdmult, x->rddiv, sum_rate, sum_dist);
tmp_rd =
RDCOST(x->rdmult, x->rddiv, sum_rd_stats.rate, sum_rd_stats.dist);
if (this_rd < tmp_rd) break;
block += sub_step;
}
......@@ -3169,10 +3169,7 @@ static void select_tx_block(const AV1_COMP *cpi, MACROBLOCK *x, int blk_row,
if (this_rd == INT64_MAX) *is_cost_valid = 0;
x->blk_skip[plane][blk_row * bw + blk_col] = rd_stats->skip;
} else {
rd_stats->rate = sum_rate;
rd_stats->dist = sum_dist;
rd_stats->sse = sum_bsse;
rd_stats->skip = all_skip;
*rd_stats = sum_rd_stats;
if (sum_rd == INT64_MAX) *is_cost_valid = 0;
}
}
......@@ -3186,10 +3183,7 @@ static void inter_block_yrd(const AV1_COMP *cpi, MACROBLOCK *x,
if (ref_best_rd < 0) is_cost_valid = 0;
rd_stats->rate = 0;
rd_stats->dist = 0;
rd_stats->sse = 0;
rd_stats->skip = 1;
av1_init_rd_stats(rd_stats);
if (is_cost_valid) {
const struct macroblockd_plane *const pd = &xd->plane[0];
......@@ -3208,10 +3202,7 @@ static void inter_block_yrd(const AV1_COMP *cpi, MACROBLOCK *x,
TXFM_CONTEXT tx_left[MAX_MIB_SIZE];
RD_STATS pn_rd_stats;
pn_rd_stats.rate = 0;
pn_rd_stats.skip = 1;
pn_rd_stats.dist = 0;
pn_rd_stats.sse = 0;
av1_init_rd_stats(&pn_rd_stats);
av1_get_entropy_contexts(bsize, TX_4X4, pd, ctxa, ctxl);
memcpy(tx_above, xd->above_txfm_context,
......@@ -3225,10 +3216,7 @@ static void inter_block_yrd(const AV1_COMP *cpi, MACROBLOCK *x,
mi_height != mi_width, plane_bsize, ctxa, ctxl,
tx_above, tx_left, &pn_rd_stats, ref_best_rd - this_rd,
&is_cost_valid);
rd_stats->rate += pn_rd_stats.rate;
rd_stats->dist += pn_rd_stats.dist;
rd_stats->sse += pn_rd_stats.sse;
rd_stats->skip &= pn_rd_stats.skip;
av1_merge_rd_stats(rd_stats, &pn_rd_stats);
this_rd += AOMMIN(
RDCOST(x->rdmult, x->rddiv, pn_rd_stats.rate, pn_rd_stats.dist),
RDCOST(x->rdmult, x->rddiv, 0, pn_rd_stats.sse));
......@@ -3243,10 +3231,7 @@ static void inter_block_yrd(const AV1_COMP *cpi, MACROBLOCK *x,
if (!is_cost_valid) {
// reset cost value
rd_stats->rate = INT_MAX;
rd_stats->dist = INT64_MAX;
rd_stats->sse = INT64_MAX;
rd_stats->skip = 0;
av1_invalid_rd_stats(rd_stats);
}
}
......@@ -3385,17 +3370,11 @@ static void select_tx_type_yrd(const AV1_COMP *cpi, MACROBLOCK *x,
prune = prune_tx_types(cpi, bsize, x, xd, 0);
#endif
rd_stats->dist = INT64_MAX;
rd_stats->rate = INT_MAX;
rd_stats->skip = 0;
rd_stats->sse = INT64_MAX;
av1_invalid_rd_stats(rd_stats);
for (tx_type = DCT_DCT; tx_type < TX_TYPES; ++tx_type) {
RD_STATS this_rd_stats;
this_rd_stats.rate = 0;
this_rd_stats.skip = 1;
this_rd_stats.dist = 0;
this_rd_stats.sse = 0;
av1_init_rd_stats(&this_rd_stats);
#if CONFIG_EXT_TX
if (is_inter) {
if (!ext_tx_used_inter[ext_tx_set][tx_type]) continue;
......@@ -3512,10 +3491,7 @@ static int inter_block_uvrd(const AV1_COMP *cpi, MACROBLOCK *x,
if (ref_best_rd < 0) is_cost_valid = 0;
rd_stats->rate = 0;
rd_stats->dist = 0;
rd_stats->sse = 0;
rd_stats->skip = 1;
av1_init_rd_stats(rd_stats);
#if CONFIG_EXT_TX && CONFIG_RECT_TX
if (is_rect_tx(mbmi->tx_size)) {
......@@ -3544,10 +3520,7 @@ static int inter_block_uvrd(const AV1_COMP *cpi, MACROBLOCK *x,
ENTROPY_CONTEXT ta[2 * MAX_MIB_SIZE];
ENTROPY_CONTEXT tl[2 * MAX_MIB_SIZE];
RD_STATS pn_rd_stats;
pn_rd_stats.rate = 0;
pn_rd_stats.skip = 1;
pn_rd_stats.dist = 0;
pn_rd_stats.sse = 0;
av1_init_rd_stats(&pn_rd_stats);
av1_get_entropy_contexts(bsize, TX_4X4, pd, ta, tl);
......@@ -3581,10 +3554,7 @@ static int inter_block_uvrd(const AV1_COMP *cpi, MACROBLOCK *x,
if (!is_cost_valid) {
// reset cost value
rd_stats->rate = INT_MAX;
rd_stats->dist = INT64_MAX;
rd_stats->sse = INT64_MAX;
rd_stats->skip = 0;
av1_invalid_rd_stats(rd_stats);
}
return is_cost_valid;
......
......@@ -33,7 +33,53 @@ typedef struct RD_STATS {
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;
#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 av1_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 av1_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
int av1_cost_coeffs(const AV1_COMMON *const cm, MACROBLOCK *x, int plane,
......
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