Commit 99e7daa2 authored by Sarah Parker's avatar Sarah Parker

Tokenize and write mrc mask

This allows a mask for mrc-tx to be sent in the bitstream for
inter or intra 32x32 transform blocks. The option to send the mask
vs build it from the prediction signal is currently controlled with
a macro. In the future, it is likely the macro will be removed and it
will be possible for a block to select either method. The mask building
functions are still placeholders and will be filled in in a followup.

Change-Id: Ie27643ff172cc2b1a9b389fd503fe6bf7c9e21e3
parent e29c9260
......@@ -1275,7 +1275,7 @@ void aom_idct32_c(const tran_low_t *input, tran_low_t *output) {
#if CONFIG_MRC_TX
void aom_imrc32x32_1024_add_c(const tran_low_t *input, uint8_t *dest,
int stride, int *mask) {
int stride, uint8_t *mask) {
tran_low_t out[32 * 32];
tran_low_t *outptr = out;
int i, j;
......@@ -1316,7 +1316,7 @@ void aom_imrc32x32_1024_add_c(const tran_low_t *input, uint8_t *dest,
}
void aom_imrc32x32_135_add_c(const tran_low_t *input, uint8_t *dest, int stride,
int *mask) {
uint8_t *mask) {
tran_low_t out[32 * 32] = { 0 };
tran_low_t *outptr = out;
int i, j;
......@@ -1346,7 +1346,7 @@ void aom_imrc32x32_135_add_c(const tran_low_t *input, uint8_t *dest, int stride,
}
void aom_imrc32x32_34_add_c(const tran_low_t *input, uint8_t *dest, int stride,
int *mask) {
uint8_t *mask) {
tran_low_t out[32 * 32] = { 0 };
tran_low_t *outptr = out;
int i, j;
......
......@@ -55,13 +55,13 @@ static INLINE tran_high_t check_range(tran_high_t input, int bd) {
#if CONFIG_MRC_TX
// These each perform dct but add coefficients based on a mask
void aom_imrc32x32_1024_add_c(const tran_low_t *input, uint8_t *dest,
int stride, int *mask);
int stride, uint8_t *mask);
void aom_imrc32x32_135_add_c(const tran_low_t *input, uint8_t *dest, int stride,
int *mask);
uint8_t *mask);
void aom_imrc32x32_34_add_c(const tran_low_t *input, uint8_t *dest, int stride,
int *mask);
uint8_t *mask);
#endif // CONFIG_MRC_TX
void aom_idct4_c(const tran_low_t *input, tran_low_t *output);
......
......@@ -36,6 +36,7 @@ typedef struct txfm_param {
#endif
#if CONFIG_MRC_TX
int *valid_mask;
uint8_t *mask;
#endif // CONFIG_MRC_TX
#endif // CONFIG_MRC_TX || CONFIG_LGT
// for inverse transforms only
......
......@@ -272,9 +272,24 @@ static INLINE int av1_rotate_tx_type(int tx_type) {
#endif // CONFIG_TXMG
#if CONFIG_MRC_TX
static INLINE int get_mrc_mask_inter(const uint8_t *pred, int pred_stride,
int *mask, int mask_stride, int width,
int height) {
static INLINE int get_mrc_diff_mask_inter(const int16_t *diff, int diff_stride,
uint8_t *mask, int mask_stride,
int width, int height) {
// placeholder mask generation function
assert(SIGNAL_MRC_MASK_INTER);
int n_masked_vals = 0;
for (int i = 0; i < height; ++i) {
for (int j = 0; j < width; ++j) {
mask[i * mask_stride + j] = diff[i * diff_stride + j] > 100 ? 1 : 0;
n_masked_vals += mask[i * mask_stride + j];
}
}
return n_masked_vals;
}
static INLINE int get_mrc_pred_mask_inter(const uint8_t *pred, int pred_stride,
uint8_t *mask, int mask_stride,
int width, int height) {
// placeholder mask generation function
int n_masked_vals = 0;
for (int i = 0; i < height; ++i) {
......@@ -286,9 +301,24 @@ static INLINE int get_mrc_mask_inter(const uint8_t *pred, int pred_stride,
return n_masked_vals;
}
static INLINE int get_mrc_mask_intra(const uint8_t *pred, int pred_stride,
int *mask, int mask_stride, int width,
int height) {
static INLINE int get_mrc_diff_mask_intra(const int16_t *diff, int diff_stride,
uint8_t *mask, int mask_stride,
int width, int height) {
// placeholder mask generation function
assert(SIGNAL_MRC_MASK_INTRA);
int n_masked_vals = 0;
for (int i = 0; i < height; ++i) {
for (int j = 0; j < width; ++j) {
mask[i * mask_stride + j] = diff[i * diff_stride + j] > 100 ? 1 : 0;
n_masked_vals += mask[i * mask_stride + j];
}
}
return n_masked_vals;
}
static INLINE int get_mrc_pred_mask_intra(const uint8_t *pred, int pred_stride,
uint8_t *mask, int mask_stride,
int width, int height) {
// placeholder mask generation function
int n_masked_vals = 0;
for (int i = 0; i < height; ++i) {
......@@ -300,17 +330,33 @@ static INLINE int get_mrc_mask_intra(const uint8_t *pred, int pred_stride,
return n_masked_vals;
}
static INLINE int get_mrc_mask(const uint8_t *pred, int pred_stride, int *mask,
int mask_stride, int width, int height,
int is_inter) {
static INLINE int get_mrc_diff_mask(const int16_t *diff, int diff_stride,
uint8_t *mask, int mask_stride, int width,
int height, int is_inter) {
if (is_inter) {
assert(USE_MRC_INTER && "MRC invalid for inter blocks");
assert(SIGNAL_MRC_MASK_INTER);
return get_mrc_diff_mask_inter(diff, diff_stride, mask, mask_stride, width,
height);
} else {
assert(USE_MRC_INTRA && "MRC invalid for intra blocks");
assert(SIGNAL_MRC_MASK_INTRA);
return get_mrc_diff_mask_intra(diff, diff_stride, mask, mask_stride, width,
height);
}
}
static INLINE int get_mrc_pred_mask(const uint8_t *pred, int pred_stride,
uint8_t *mask, int mask_stride, int width,
int height, int is_inter) {
if (is_inter) {
assert(USE_MRC_INTER && "MRC invalid for inter blocks");
return get_mrc_mask_inter(pred, pred_stride, mask, mask_stride, width,
height);
return get_mrc_pred_mask_inter(pred, pred_stride, mask, mask_stride, width,
height);
} else {
assert(USE_MRC_INTRA && "MRC invalid for intra blocks");
return get_mrc_mask_intra(pred, pred_stride, mask, mask_stride, width,
height);
return get_mrc_pred_mask_intra(pred, pred_stride, mask, mask_stride, width,
height);
}
}
......
......@@ -851,6 +851,9 @@ static INLINE int is_rect_tx(TX_SIZE tx_size) { return tx_size >= TX_SIZES; }
#if CONFIG_MRC_TX
#define USE_MRC_INTRA 0
#define USE_MRC_INTER 1
#define SIGNAL_MRC_MASK_INTRA (USE_MRC_INTRA && 0)
#define SIGNAL_MRC_MASK_INTER (USE_MRC_INTER && 1)
#define SIGNAL_ANY_MRC_MASK (SIGNAL_MRC_MASK_INTRA || SIGNAL_MRC_MASK_INTER)
#endif // CONFIG_MRC_TX
#if CONFIG_EXT_TX
......
......@@ -1556,15 +1556,23 @@ static void imrc32x32_add_c(const tran_low_t *input, uint8_t *dest, int stride,
#endif
const int eob = txfm_param->eob;
int n_masked_vals = 0;
uint8_t *mask;
uint8_t mask_tmp[32 * 32];
if (eob == 1) {
aom_idct32x32_1_add_c(input, dest, stride);
} else {
int mask[32 * 32];
int n_masked_vals = get_mrc_mask(txfm_param->dst, txfm_param->stride, mask,
32, 32, 32, txfm_param->is_inter);
if (!is_valid_mrc_mask(n_masked_vals, 32, 32))
assert(0 && "Invalid MRC mask");
if ((txfm_param->is_inter && SIGNAL_MRC_MASK_INTER) ||
(!txfm_param->is_inter && SIGNAL_MRC_MASK_INTRA)) {
mask = txfm_param->mask;
} else {
n_masked_vals =
get_mrc_pred_mask(txfm_param->dst, txfm_param->stride, mask_tmp, 32,
32, 32, txfm_param->is_inter);
if (!is_valid_mrc_mask(n_masked_vals, 32, 32))
assert(0 && "Invalid MRC mask");
mask = mask_tmp;
}
if (eob <= quarter)
// non-zero coeff only in upper-left 8x8
aom_imrc32x32_34_add_c(input, dest, stride, mask);
......@@ -2286,6 +2294,9 @@ void av1_inverse_transform_block(const MACROBLOCKD *xd,
#if CONFIG_LGT
PREDICTION_MODE mode,
#endif
#if CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK
uint8_t *mrc_mask,
#endif // CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK
TX_TYPE tx_type, TX_SIZE tx_size, uint8_t *dst,
int stride, int eob) {
if (!eob) return;
......@@ -2308,6 +2319,9 @@ void av1_inverse_transform_block(const MACROBLOCKD *xd,
txfm_param.is_inter = is_inter_block(&xd->mi[0]->mbmi);
txfm_param.dst = dst;
txfm_param.stride = stride;
#if CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK
txfm_param.mask = mrc_mask;
#endif // CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK
#if CONFIG_LGT
txfm_param.mode = mode;
#endif // CONFIG_LGT
......@@ -2346,6 +2360,9 @@ void av1_inverse_transform_block_facade(MACROBLOCKD *xd, int plane, int block,
int blk_row, int blk_col, int eob) {
struct macroblockd_plane *const pd = &xd->plane[plane];
tran_low_t *dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block);
#if CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK
uint8_t *mrc_mask = BLOCK_OFFSET(xd->mrc_mask, block);
#endif // CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK
const PLANE_TYPE plane_type = get_plane_type(plane);
const TX_SIZE tx_size = av1_get_tx_size(plane, xd);
const TX_TYPE tx_type =
......@@ -2357,6 +2374,9 @@ void av1_inverse_transform_block_facade(MACROBLOCKD *xd, int plane, int block,
#if CONFIG_LGT
xd->mi[0]->mbmi.mode,
#endif // CONFIG_LGT
#if CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK
mrc_mask,
#endif // CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK
tx_type, tx_size, dst, dst_stride, eob);
}
......
......@@ -62,6 +62,9 @@ void av1_inverse_transform_block(const MACROBLOCKD *xd,
#if CONFIG_LGT
PREDICTION_MODE mode,
#endif
#if CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK
uint8_t *mrc_mask,
#endif // CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK
TX_TYPE tx_type, TX_SIZE tx_size, uint8_t *dst,
int stride, int eob);
void av1_inverse_transform_block_facade(MACROBLOCKD *xd, int plane, int block,
......
......@@ -283,6 +283,9 @@ static void inverse_transform_block(MACROBLOCKD *xd, int plane,
#if CONFIG_LGT
mode,
#endif
#if CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK
xd->mrc_mask,
#endif // CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK
tx_type, tx_size, dst, stride, eob);
memset(dqcoeff, 0, (scan_line + 1) * sizeof(dqcoeff[0]));
}
......
......@@ -287,16 +287,21 @@ static void get_palette_params(const MACROBLOCKD *const xd, int plane,
&params->plane_height, &params->rows, &params->cols);
}
#if CONFIG_MRC_TX
static void get_mrc_params(const MACROBLOCKD *const xd, int plane,
BLOCK_SIZE bsize, Av1ColorMapParam *params) {
// TODO(sarahparker)
(void)xd;
(void)plane;
(void)bsize;
#if CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK
static void get_mrc_params(const MACROBLOCKD *const xd, TX_SIZE tx_size,
Av1ColorMapParam *params) {
memset(params, 0, sizeof(*params));
const MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
const int is_inter = is_inter_block(mbmi);
params->color_map = xd->mrc_mask;
params->map_cdf = is_inter ? xd->tile_ctx->mrc_mask_inter_cdf
: xd->tile_ctx->mrc_mask_intra_cdf;
params->n_colors = 2;
params->plane_width = tx_size_wide[tx_size];
params->rows = tx_size_high[tx_size];
params->cols = tx_size_wide[tx_size];
}
#endif // CONFIG_MRC_TX
#endif // CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK
void av1_decode_palette_tokens(MACROBLOCKD *const xd, int plane,
aom_reader *r) {
......@@ -309,14 +314,19 @@ void av1_decode_palette_tokens(MACROBLOCKD *const xd, int plane,
decode_color_map_tokens(&color_map_params, r);
}
#if CONFIG_MRC_TX
void av1_decode_mrc_tokens(MACROBLOCKD *const xd, int plane, aom_reader *r) {
#if CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK
static void decode_mrc_tokens(MACROBLOCKD *const xd, TX_TYPE tx_size,
aom_reader *r) {
const MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
const int is_inter = is_inter_block(mbmi);
if ((is_inter && !SIGNAL_MRC_MASK_INTER) ||
(!is_inter && !SIGNAL_MRC_MASK_INTRA))
return;
Av1ColorMapParam color_map_params;
get_mrc_params(xd, plane, mbmi->sb_type, &color_map_params);
get_mrc_params(xd, tx_size, &color_map_params);
decode_color_map_tokens(&color_map_params, r);
}
#endif // CONFIG_MRC_TX
#endif // CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK
#if !CONFIG_PVQ || CONFIG_VAR_TX
int av1_decode_block_tokens(AV1_COMMON *cm, MACROBLOCKD *const xd, int plane,
......@@ -333,6 +343,10 @@ int av1_decode_block_tokens(AV1_COMMON *cm, MACROBLOCKD *const xd, int plane,
get_dq_profile_from_ctx(xd->qindex[seg_id], ctx, ref, pd->plane_type);
#endif // CONFIG_NEW_QUANT
#if CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK
if (tx_type == MRC_DCT) decode_mrc_tokens(xd, tx_size, r);
#endif // CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK
const int eob =
decode_coefs(xd, pd->plane_type, pd->dqcoeff, tx_size, tx_type, dequant,
#if CONFIG_NEW_QUANT
......
......@@ -24,10 +24,6 @@ extern "C" {
void av1_decode_palette_tokens(MACROBLOCKD *const xd, int plane, aom_reader *r);
#if CONFIG_MRC_TX
void av1_decode_mrc_tokens(MACROBLOCKD *const xd, int plane, aom_reader *r);
#endif // CONFIG_MRC_TX
#if !CONFIG_PVQ || CONFIG_VAR_TX
int av1_decode_block_tokens(AV1_COMMON *cm, MACROBLOCKD *const xd, int plane,
const SCAN_ORDER *sc, int x, int y, TX_SIZE tx_size,
......
......@@ -592,8 +592,8 @@ static void update_skip_probs(AV1_COMMON *cm, aom_writer *w,
}
#endif
static void pack_palette_tokens(aom_writer *w, const TOKENEXTRA **tp, int n,
int num) {
static void pack_map_tokens(aom_writer *w, const TOKENEXTRA **tp, int n,
int num) {
const TOKENEXTRA *p = *tp;
write_uniform(w, n, p->token); // The first color index.
++p;
......@@ -664,6 +664,9 @@ static INLINE void write_coeff_extra(const aom_prob *pb, int value,
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,
#if CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK
TX_TYPE tx_type, int is_inter,
#endif // CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK
TOKEN_STATS *token_stats) {
const TOKENEXTRA *p = *tp;
#if CONFIG_VAR_TX
......@@ -671,6 +674,17 @@ static void pack_mb_tokens(aom_writer *w, const TOKENEXTRA **tp,
const int seg_eob = tx_size_2d[tx_size];
#endif
#if CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK
if (tx_type == MRC_DCT && ((is_inter && SIGNAL_MRC_MASK_INTER) ||
(!is_inter && SIGNAL_MRC_MASK_INTRA))) {
int rows = tx_size_high[tx_size];
int cols = tx_size_wide[tx_size];
assert(tx_size == TX_32X32);
assert(p < stop);
pack_map_tokens(w, &p, 2, rows * cols);
}
#endif // CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK
while (p < stop && p->token != EOSB_TOKEN) {
const int token = p->token;
const int eob_val = p->eob_val;
......@@ -914,6 +928,10 @@ static void pack_txb_tokens(aom_writer *w, const TOKENEXTRA **tp,
TX_SIZE plane_tx_size;
const int max_blocks_high = max_block_high(xd, plane_bsize, plane);
const int max_blocks_wide = max_block_wide(xd, plane_bsize, plane);
#if CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK
TX_TYPE tx_type = av1_get_tx_type(plane ? PLANE_TYPE_UV : PLANE_TYPE_Y, xd,
blk_row, blk_col, block, tx_size);
#endif // CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK
if (blk_row >= max_blocks_high || blk_col >= max_blocks_wide) return;
......@@ -925,7 +943,11 @@ static void pack_txb_tokens(aom_writer *w, const TOKENEXTRA **tp,
TOKEN_STATS tmp_token_stats;
init_token_stats(&tmp_token_stats);
#if !CONFIG_PVQ
pack_mb_tokens(w, tp, tok_end, bit_depth, tx_size, &tmp_token_stats);
pack_mb_tokens(w, tp, tok_end, bit_depth, tx_size,
#if CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK
tx_type, is_inter_block(mbmi),
#endif // CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK
&tmp_token_stats);
#else
pack_pvq_tokens(w, x, xd, plane, bsize, tx_size);
#endif
......@@ -2483,7 +2505,7 @@ static void write_tokens_b(AV1_COMP *cpi, const TileInfo *const tile,
av1_get_block_dimensions(mbmi->sb_type, plane, xd, NULL, NULL, &rows,
&cols);
assert(*tok < tok_end);
pack_palette_tokens(w, tok, palette_size_plane, rows * cols);
pack_map_tokens(w, tok, palette_size_plane, rows * cols);
#if !CONFIG_LV_MAP
assert(*tok < tok_end + mbmi->skip);
#endif // !CONFIG_LV_MAP
......@@ -2665,7 +2687,15 @@ static void write_tokens_b(AV1_COMP *cpi, const TileInfo *const tile,
for (blk_row = row; blk_row < unit_height; blk_row += bkh) {
for (blk_col = col; blk_col < unit_width; blk_col += bkw) {
#if !CONFIG_PVQ
#if CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK
TX_TYPE tx_type =
av1_get_tx_type(plane ? PLANE_TYPE_UV : PLANE_TYPE_Y, xd,
blk_row, blk_col, 0, tx);
#endif // CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK
pack_mb_tokens(w, tok, tok_end, cm->bit_depth, tx,
#if CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK
tx_type, is_inter_block(mbmi),
#endif // CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK
&token_stats);
#else
pack_pvq_tokens(w, x, xd, plane, bsize, tx);
......@@ -2684,8 +2714,16 @@ static void write_tokens_b(AV1_COMP *cpi, const TileInfo *const tile,
#if CONFIG_LV_MAP
(void)tx;
av1_write_coeffs_mb(cm, x, w, plane);
#else // CONFIG_LV_MAP
pack_mb_tokens(w, tok, tok_end, cm->bit_depth, tx, &token_stats);
#else // CONFIG_LV_MAP
#if CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK
TX_TYPE tx_type = av1_get_tx_type(plane ? PLANE_TYPE_UV : PLANE_TYPE_Y,
xd, blk_row, blk_col, 0, tx);
#endif // CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK
pack_mb_tokens(w, tok, tok_end, cm->bit_depth, tx,
#if CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK
tx_type, is_inter_block(mbmi),
#endif // CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK
&token_stats);
#endif // CONFIG_LV_MAP
#else
......@@ -3047,6 +3085,10 @@ static void write_modes_sb(AV1_COMP *const cpi, const TileInfo *const tile,
if (!skip) {
assert(*tok < tok_end);
for (plane = 0; plane < MAX_MB_PLANE; ++plane) {
#if CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK
TX_TYPE tx_type = av1_get_tx_type(plane ? PLANE_TYPE_UV : PLANE_TYPE_Y,
xd, blk_row, blk_col, block, tx_size);
#endif // CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK
const struct macroblockd_plane *const pd = &xd->plane[plane];
const int mbmi_txb_size = txsize_to_bsize[mbmi->tx_size];
const BLOCK_SIZE plane_bsize = get_plane_block_size(mbmi_txb_size, pd);
......@@ -3065,7 +3107,11 @@ static void write_modes_sb(AV1_COMP *const cpi, const TileInfo *const tile,
token_stats.cost = 0;
for (row = 0; row < max_blocks_high; row += stepr)
for (col = 0; col < max_blocks_wide; col += stepc)
pack_mb_tokens(w, tok, tok_end, cm->bit_depth, tx, &token_stats);
pack_mb_tokens(w, tok, tok_end, cm->bit_depth, tx,
#if CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK
tx_type, is_inter_block(mbmi),
#endif // CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK
&token_stats);
assert(*tok < tok_end && (*tok)->token == EOSB_TOKEN);
(*tok)++;
}
......
......@@ -101,7 +101,7 @@ static void free_mode_context(PICK_MODE_CONTEXT *ctx) {
}
#if CONFIG_MRC_TX
aom_free(ctx->mrc_mask);
ctx->mrc_mask[i] = 0;
ctx->mrc_mask = 0;
#endif // CONFIG_MRC_TX
}
......
......@@ -1144,14 +1144,25 @@ static void fhalfright32(const tran_low_t *input, tran_low_t *output) {
#if CONFIG_MRC_TX
static void get_masked_residual32(const int16_t **input, int *input_stride,
const uint8_t *pred, int pred_stride,
int16_t *masked_input, int *valid_mask,
int is_inter) {
int mrc_mask[32 * 32];
int n_masked_vals =
get_mrc_mask(pred, pred_stride, mrc_mask, 32, 32, 32, is_inter);
int16_t *masked_input,
TxfmParam *txfm_param) {
int n_masked_vals = 0;
uint8_t *mrc_mask;
uint8_t mask_tmp[32 * 32];
if ((txfm_param->is_inter && SIGNAL_MRC_MASK_INTER) ||
(!txfm_param->is_inter && SIGNAL_MRC_MASK_INTRA)) {
mrc_mask = txfm_param->mask;
n_masked_vals = get_mrc_diff_mask(*input, *input_stride, mrc_mask, 32, 32,
32, txfm_param->is_inter);
} else {
mrc_mask = mask_tmp;
n_masked_vals = get_mrc_pred_mask(pred, pred_stride, mrc_mask, 32, 32, 32,
txfm_param->is_inter);
}
// Do not use MRC_DCT if mask is invalid. DCT_DCT will be used instead.
if (!is_valid_mrc_mask(n_masked_vals, 32, 32)) {
*valid_mask = 0;
*txfm_param->valid_mask = 0;
return;
}
int32_t sum = 0;
......@@ -1172,7 +1183,7 @@ static void get_masked_residual32(const int16_t **input, int *input_stride,
}
*input = masked_input;
*input_stride = 32;
*valid_mask = 1;
*txfm_param->valid_mask = 1;
}
#endif // CONFIG_MRC_TX
......@@ -2494,8 +2505,7 @@ void av1_fht32x32_c(const int16_t *input, tran_low_t *output, int stride,
if (tx_type == MRC_DCT) {
int16_t masked_input[32 * 32];
get_masked_residual32(&input, &stride, txfm_param->dst, txfm_param->stride,
masked_input, txfm_param->valid_mask,
txfm_param->is_inter);
masked_input, txfm_param);
}
#endif // CONFIG_MRC_TX
......
......@@ -6170,9 +6170,11 @@ static void encode_superblock(const AV1_COMP *const cpi, ThreadData *td,
for (plane = 0; plane <= 1; ++plane) {
if (mbmi->palette_mode_info.palette_size[plane] > 0) {
if (!dry_run)
av1_tokenize_color_map(x, plane, t, bsize, PALETTE_MAP);
av1_tokenize_color_map(x, plane, 0, t, bsize, mbmi->tx_size,
PALETTE_MAP);
else if (dry_run == DRY_RUN_COSTCOEFFS)
rate += av1_cost_color_map(x, plane, bsize, PALETTE_MAP);
rate += av1_cost_color_map(x, plane, 0, bsize, mbmi->tx_size,
PALETTE_MAP);
}
}
}
......
......@@ -612,6 +612,9 @@ void av1_xform_quant(const AV1_COMMON *cm, MACROBLOCK *x, int plane, int block,
txfm_param.stride = dst_stride;
#if CONFIG_MRC_TX
txfm_param.valid_mask = &mbmi->valid_mrc_mask;
#if SIGNAL_ANY_MRC_MASK
txfm_param.mask = BLOCK_OFFSET(xd->mrc_mask, block);
#endif // SIGNAL_ANY_MRC_MASK
#endif // CONFIG_MRC_TX
#endif // CONFIG_MRC_TX || CONFIG_LGT
#if CONFIG_LGT
......@@ -689,6 +692,9 @@ static void encode_block(int plane, int block, int blk_row, int blk_col,
struct macroblock_plane *const p = &x->plane[plane];
struct macroblockd_plane *const pd = &xd->plane[plane];
tran_low_t *const dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block);
#if CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK
uint8_t *mrc_mask = BLOCK_OFFSET(xd->mrc_mask, block);
#endif // CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK
uint8_t *dst;
#if !CONFIG_PVQ
ENTROPY_CONTEXT *a, *l;
......@@ -742,16 +748,20 @@ static void encode_block(int plane, int block, int blk_row, int blk_col,
if (x->pvq_skip[plane]) return;
#endif
#if CONFIG_LGT
PREDICTION_MODE mode = xd->mi[0]->mbmi.mode;
#endif // CONFIG_LGT
TX_TYPE tx_type =
av1_get_tx_type(pd->plane_type, xd, blk_row, blk_col, block, tx_size);
av1_inverse_transform_block(xd, dqcoeff,
#if CONFIG_LGT
PREDICTION_MODE mode = xd->mi[0]->mbmi.mode;
av1_inverse_transform_block(xd, dqcoeff, mode, tx_type, tx_size, dst,
pd->dst.stride, p->eobs[block]);
#else
av1_inverse_transform_block(xd, dqcoeff, tx_type, tx_size, dst,
pd->dst.stride, p->eobs[block]);
#endif
mode,
#endif // CONFIG_LGT
#if CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK
mrc_mask,
#endif // CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK
tx_type, tx_size, dst, pd->dst.stride,
p->eobs[block]);
}
#if CONFIG_VAR_TX
......@@ -1054,6 +1064,9 @@ void av1_encode_block_intra(int plane, int block, int blk_row, int blk_col,
struct macroblock_plane *const p = &x->plane[plane];
struct macroblockd_plane *const pd = &xd->plane[plane];
tran_low_t *dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block);
#if CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK
uint8_t *mrc_mask = BLOCK_OFFSET(xd->mrc_mask, block);
#endif // CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK
PLANE_TYPE plane_type = get_plane_type(plane);
const TX_TYPE tx_type =
av1_get_tx_type(plane_type, xd, blk_row, blk_col, block, tx_size);
......@@ -1089,6 +1102,9 @@ void av1_encode_block_intra(int plane, int block, int blk_row, int blk_col,
#if CONFIG_LGT
xd->mi[0]->mbmi.mode,
#endif
#if CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK
mrc_mask,
#endif // CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK
tx_type, tx_size, dst, dst_stride, *eob);
#if !CONFIG_PVQ
if (*eob) *(args->skip) = 0;
......
......@@ -1625,6 +1625,21 @@ int av1_cost_coeffs(const AV1_COMP *const cpi, MACROBLOCK *x, int plane,
#if !CONFIG_LV_MAP
(void)blk_row;
(void)blk_col;
#if CONFIG_MRC_TX
const MACROBLOCKD *xd = &x->e_mbd;
const MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
const TX_TYPE tx_type = av1_get_tx_type(xd->plane[plane].plane_type, xd,
blk_row, blk_col, block, tx_size);
const int is_inter = is_inter_block(mbmi);
if (tx_type == MRC_DCT && ((is_inter && SIGNAL_MRC_MASK_INTER) ||
(!is_inter && SIGNAL_MRC_MASK_INTRA))) {
const int mrc_mask_cost =
av1_cost_color_map(x, plane, block, mbmi->sb_type, tx_size, MRC_MAP);
return cost_coeffs(cm, x, plane, block, tx_size, scan_order, a, l,
use_fast_coef_costing) +
mrc_mask_cost;
}
#endif
return cost_coeffs(cm, x, plane, block, tx_size, scan_order, a, l,
use_fast_coef_costing);
#else // !CONFIG_LV_MAP
......@@ -1911,6 +1926,9 @@ void av1_dist_block(const AV1_COMP *cpi, MACROBLOCK *x, int plane,
(void)dst;
#endif // !CONFIG_PVQ
#if CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK
uint8_t *mrc_mask = BLOCK_OFFSET(xd->mrc_mask, block);
#endif // CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK
const PLANE_TYPE plane_type = get_plane_type(plane);
TX_TYPE tx_type =
av1_get_tx_type(plane_type, xd, blk_row, blk_col, block, tx_size);
......@@ -1918,6 +1936,9 @@ void av1_dist_block(const AV1_COMP *cpi, MACROBLOCK *x, int plane,
#if CONFIG_LGT
xd->mi[0]->mbmi.mode,
#endif
#if CONFIG_MRC_TX && SIGNAL_ANY_MRC