EC_MULTISYMBOL: Include EOB in multisymbol encoding.
RD search and trellis encoding are still sub-optimal. Change-Id: I233979909118241a0c78761c1d5c2cd6857915e0
This commit is contained in:
Родитель
19e7aa82bd
Коммит
fc1598ad3b
|
@ -4398,21 +4398,76 @@ void av1_model_to_full_probs(const aom_prob *model, aom_prob *full) {
|
|||
|
||||
#if CONFIG_EC_MULTISYMBOL
|
||||
static void build_token_cdfs(const aom_prob *pdf_model,
|
||||
const aom_prob *blockz_model,
|
||||
aom_cdf_prob cdf_tail[ENTROPY_TOKENS],
|
||||
aom_cdf_prob cdf_head[ENTROPY_TOKENS]) {
|
||||
int i, p, scale, sum = 0;
|
||||
int i, p, p1, p2, phead[6], prob_NZ, prob_EOB_1, prob_EOB_2p, prob_NEOB_1,
|
||||
prob_NEOB_2p, sum = 0;
|
||||
int prob8_blocknz;
|
||||
|
||||
assert(pdf_model[2] != 0);
|
||||
|
||||
// Do the head (ZERO, ONE, TWO or more)
|
||||
cdf_head[ZERO_TOKEN] = sum = (pdf_model[1] << (CDF_PROB_BITS - 8));
|
||||
assert(cdf_head[ZERO_TOKEN] < CDF_PROB_TOP);
|
||||
scale = CDF_PROB_TOP - cdf_head[ZERO_TOKEN];
|
||||
p = ROUND_POWER_OF_TWO(scale * (pdf_model[2] << (CDF_PROB_BITS - 8)),
|
||||
CDF_PROB_BITS);
|
||||
cdf_head[ONE_TOKEN] = cdf_head[ZERO_TOKEN] + AOMMIN(AOMMAX(1, p), scale - 1);
|
||||
assert(cdf_head[ONE_TOKEN] < CDF_PROB_TOP);
|
||||
cdf_head[TWO_TOKEN] = CDF_PROB_TOP;
|
||||
/* FIXME: maintain true CDF counts. */
|
||||
|
||||
/* Values are 0=BLOCK_ZERO 1=ZERO_TOKEN, 2=ONE_TOKEN_EOB
|
||||
3=ONE_TOKEN_NEOB, 4=TWO_TOKEN_PLUS_EOB, 5=TWO_TOKEN_PLUS_NEOB
|
||||
*/
|
||||
// Block zero probability
|
||||
phead[0] =
|
||||
blockz_model == NULL ? 0 : ((*blockz_model) << (CDF_PROB_BITS - 8)) +
|
||||
(1 << (CDF_PROB_BITS - 9));
|
||||
phead[0] = AOMMIN(CDF_PROB_TOP - 6, AOMMAX(1, phead[0]));
|
||||
cdf_head[0] = phead[0];
|
||||
|
||||
// Will scale the remaining probabilities by the probability of the block
|
||||
// being non-zero
|
||||
prob8_blocknz = blockz_model == NULL ? 256 : (256 - *blockz_model);
|
||||
|
||||
// Probability of zero
|
||||
phead[1 + ZERO_TOKEN] =
|
||||
(pdf_model[1] << (CDF_PROB_BITS - 8)) + (1 << (CDF_PROB_BITS - 9));
|
||||
|
||||
// Will scale the non-zero values
|
||||
prob_NZ = CDF_PROB_TOP - phead[1 + ZERO_TOKEN];
|
||||
|
||||
// Will scale the EOBs by the probability of and EOB_TOKEN ..
|
||||
prob_EOB_1 =
|
||||
(pdf_model[0] << (CDF_PROB_BITS - 8)) + (1 << (CDF_PROB_BITS - 9));
|
||||
// .. use a lower probability of EOB for larger values
|
||||
prob_EOB_2p = prob_EOB_1 / 2;
|
||||
|
||||
prob_NEOB_1 = CDF_PROB_TOP - prob_EOB_1;
|
||||
prob_NEOB_2p = CDF_PROB_TOP - prob_EOB_2p;
|
||||
if (prob_NZ == 0 || prob_NZ == CDF_PROB_TOP) abort();
|
||||
if (prob_EOB_1 == 0 || prob_EOB_1 == CDF_PROB_TOP) abort();
|
||||
if (prob_EOB_2p == 0 || prob_EOB_2p == CDF_PROB_TOP) abort();
|
||||
|
||||
// ONE_CONTEXT_NODE prob
|
||||
p = (pdf_model[2] << (CDF_PROB_BITS - 8)) + (1 << (CDF_PROB_BITS - 9));
|
||||
// Scale by the non-zero factor to get the probability of token = 1
|
||||
p1 = ROUND_POWER_OF_TWO(prob_NZ * p, 15);
|
||||
|
||||
// Scale by the EOB factors
|
||||
phead[1 + ONE_TOKEN_EOB] = ROUND_POWER_OF_TWO(p1 * prob_EOB_1, 15);
|
||||
phead[1 + ONE_TOKEN_NEOB] = ROUND_POWER_OF_TWO(p1 * prob_NEOB_1, 15);
|
||||
|
||||
// Probability token is 2 or more
|
||||
p2 = CDF_PROB_TOP - p1 - phead[1 + ZERO_TOKEN];
|
||||
|
||||
phead[1 + TWO_TOKEN_PLUS_EOB] = ROUND_POWER_OF_TWO(p2 * prob_EOB_2p, 15);
|
||||
phead[1 + TWO_TOKEN_PLUS_NEOB] = ROUND_POWER_OF_TWO(p2 * prob_NEOB_2p, 15);
|
||||
|
||||
// Now use block non-zerp prob to scale the values
|
||||
for (i = 1; i < 5; ++i) {
|
||||
phead[i] = (prob8_blocknz * phead[i] + 128) >> 8;
|
||||
}
|
||||
|
||||
sum = phead[0];
|
||||
for (i = 1; i < 5; ++i) {
|
||||
p = AOMMAX(1, AOMMIN(CDF_PROB_TOP - (5 - i) - cdf_head[i - 1], phead[i]));
|
||||
cdf_head[i] = cdf_head[i - 1] + p;
|
||||
}
|
||||
cdf_head[5] = CDF_PROB_TOP;
|
||||
|
||||
// Do the tail
|
||||
sum = 0;
|
||||
|
@ -4431,6 +4486,7 @@ void av1_coef_pareto_cdfs(FRAME_CONTEXT *fc) {
|
|||
for (k = 0; k < COEF_BANDS; ++k)
|
||||
for (l = 0; l < BAND_COEFF_CONTEXTS(k); ++l)
|
||||
build_token_cdfs(fc->coef_probs[t][i][j][k][l],
|
||||
k == 0 ? &fc->blockzero_probs[t][i][j][l] : NULL,
|
||||
fc->coef_tail_cdfs[t][i][j][k][l],
|
||||
fc->coef_head_cdfs[t][i][j][k][l]);
|
||||
}
|
||||
|
|
|
@ -45,7 +45,13 @@ extern "C" {
|
|||
#define CATEGORY5_TOKEN 9 // 35-66 Extra Bits 5+1
|
||||
#define CATEGORY6_TOKEN 10 // 67+ Extra Bits 14+1
|
||||
#define EOB_TOKEN 11 // EOB Extra Bits 0+0
|
||||
|
||||
#if CONFIG_EC_MULTISYMBOL
|
||||
#define BLOCK_Z_TOKEN 255 // block zero
|
||||
#define ONE_TOKEN_EOB 1
|
||||
#define ONE_TOKEN_NEOB 2
|
||||
#define TWO_TOKEN_PLUS_EOB 3
|
||||
#define TWO_TOKEN_PLUS_NEOB 4
|
||||
#endif
|
||||
#define ENTROPY_TOKENS 12
|
||||
|
||||
#define ENTROPY_NODES 11
|
||||
|
|
|
@ -2399,15 +2399,11 @@ static void setup_bool_decoder(const uint8_t *data, const uint8_t *data_end,
|
|||
"Failed to allocate bool decoder %d", 1);
|
||||
}
|
||||
|
||||
#if !CONFIG_PVQ
|
||||
#if !CONFIG_PVQ && !CONFIG_EC_ADAPT
|
||||
static void read_coef_probs_common(av1_coeff_probs_model *coef_probs,
|
||||
aom_reader *r) {
|
||||
int i, j, k, l, m;
|
||||
#if CONFIG_EC_ADAPT
|
||||
const int node_limit = UNCONSTRAINED_NODES - 2;
|
||||
#else
|
||||
const int node_limit = UNCONSTRAINED_NODES;
|
||||
#endif
|
||||
|
||||
if (aom_read_bit(r, ACCT_STR))
|
||||
for (i = 0; i < PLANE_TYPES; ++i)
|
||||
|
@ -4448,7 +4444,9 @@ static int read_compressed_header(AV1Decoder *pbi, const uint8_t *data,
|
|||
if (cm->tx_mode == TX_MODE_SELECT) read_tx_size_probs(fc, &r);
|
||||
|
||||
#if !CONFIG_PVQ
|
||||
#if !CONFIG_EC_ADAPT
|
||||
read_coef_probs(fc, cm->tx_mode, &r);
|
||||
#endif
|
||||
|
||||
#if CONFIG_VAR_TX
|
||||
for (k = 0; k < TXFM_PARTITION_CONTEXTS; ++k)
|
||||
|
|
|
@ -69,7 +69,11 @@ static int decode_coefs(MACROBLOCKD *xd, PLANE_TYPE type, tran_low_t *dqcoeff,
|
|||
#endif // CONFIG_AOM_QM
|
||||
{
|
||||
FRAME_COUNTS *counts = xd->counts;
|
||||
FRAME_CONTEXT *const fc = xd->fc;
|
||||
#if CONFIG_EC_ADAPT
|
||||
FRAME_CONTEXT *ec_ctx = xd->tile_ctx;
|
||||
#else
|
||||
FRAME_CONTEXT *const ec_ctx = xd->fc;
|
||||
#endif
|
||||
const int max_eob = tx_size_2d[tx_size];
|
||||
const int ref = is_inter_block(&xd->mi[0]->mbmi);
|
||||
#if CONFIG_AOM_QM
|
||||
|
@ -77,25 +81,21 @@ static int decode_coefs(MACROBLOCKD *xd, PLANE_TYPE type, tran_low_t *dqcoeff,
|
|||
#endif // CONFIG_AOM_QM
|
||||
int band, c = 0;
|
||||
const int tx_size_ctx = txsize_sqr_map[tx_size];
|
||||
#if CONFIG_EC_MULTISYMBOL
|
||||
aom_cdf_prob(*coef_head_cdfs)[COEFF_CONTEXTS][ENTROPY_TOKENS] =
|
||||
ec_ctx->coef_head_cdfs[tx_size_ctx][type][ref];
|
||||
aom_cdf_prob(*coef_tail_cdfs)[COEFF_CONTEXTS][ENTROPY_TOKENS] =
|
||||
ec_ctx->coef_tail_cdfs[tx_size_ctx][type][ref];
|
||||
#else
|
||||
aom_prob(*coef_probs)[COEFF_CONTEXTS][UNCONSTRAINED_NODES] =
|
||||
fc->coef_probs[tx_size_ctx][type][ref];
|
||||
ec_ctx->coef_probs[tx_size_ctx][type][ref];
|
||||
const aom_prob *prob;
|
||||
#if CONFIG_EC_ADAPT
|
||||
aom_cdf_prob(*coef_head_cdfs)[COEFF_CONTEXTS][ENTROPY_TOKENS] =
|
||||
xd->tile_ctx->coef_head_cdfs[tx_size][type][ref];
|
||||
aom_cdf_prob(*coef_tail_cdfs)[COEFF_CONTEXTS][ENTROPY_TOKENS] =
|
||||
xd->tile_ctx->coef_tail_cdfs[tx_size][type][ref];
|
||||
#elif CONFIG_EC_MULTISYMBOL
|
||||
aom_cdf_prob(*coef_head_cdfs)[COEFF_CONTEXTS][ENTROPY_TOKENS] =
|
||||
fc->coef_head_cdfs[tx_size_ctx][type][ref];
|
||||
aom_cdf_prob(*coef_tail_cdfs)[COEFF_CONTEXTS][ENTROPY_TOKENS] =
|
||||
fc->coef_tail_cdfs[tx_size_ctx][type][ref];
|
||||
#endif
|
||||
#if CONFIG_EC_MULTISYMBOL
|
||||
aom_cdf_prob(*cdf_head)[ENTROPY_TOKENS];
|
||||
aom_cdf_prob(*cdf_tail)[ENTROPY_TOKENS];
|
||||
int ctx_eob, band_eob = 0;
|
||||
const aom_prob *prob_eob;
|
||||
int val = 0;
|
||||
unsigned int *blockz_count;
|
||||
#endif
|
||||
unsigned int(*coef_counts)[COEFF_CONTEXTS][UNCONSTRAINED_NODES + 1] = NULL;
|
||||
unsigned int(*eob_branch_count)[COEFF_CONTEXTS] = NULL;
|
||||
|
@ -121,6 +121,9 @@ static int decode_coefs(MACROBLOCKD *xd, PLANE_TYPE type, tran_low_t *dqcoeff,
|
|||
if (counts) {
|
||||
coef_counts = counts->coef[tx_size_ctx][type][ref];
|
||||
eob_branch_count = counts->eob_branch[tx_size_ctx][type][ref];
|
||||
#if CONFIG_EC_MULTISYMBOL
|
||||
blockz_count = counts->blockz_count[tx_size_ctx][type][ref][ctx];
|
||||
#endif
|
||||
}
|
||||
|
||||
#if CONFIG_AOM_HIGHBITDEPTH
|
||||
|
@ -161,18 +164,10 @@ static int decode_coefs(MACROBLOCKD *xd, PLANE_TYPE type, tran_low_t *dqcoeff,
|
|||
|
||||
#if CONFIG_EC_MULTISYMBOL
|
||||
band = *band_translate++;
|
||||
prob = coef_probs[band][ctx];
|
||||
|
||||
// Read the first EOB as if it is a CBP
|
||||
if (counts) ++eob_branch_count[band][ctx];
|
||||
if (!aom_read(r, prob[EOB_CONTEXT_NODE], ACCT_STR)) {
|
||||
INCREMENT_COUNT(EOB_MODEL_TOKEN);
|
||||
return 0;
|
||||
}
|
||||
|
||||
while (c < max_eob) {
|
||||
int val = -1;
|
||||
int more_data = 1;
|
||||
int more_data;
|
||||
int comb_token;
|
||||
|
||||
#if CONFIG_NEW_QUANT
|
||||
dqv_val = &dq_val[band][0];
|
||||
|
@ -180,7 +175,14 @@ static int decode_coefs(MACROBLOCKD *xd, PLANE_TYPE type, tran_low_t *dqcoeff,
|
|||
|
||||
cdf_head = &coef_head_cdfs[band][ctx];
|
||||
cdf_tail = &coef_tail_cdfs[band][ctx];
|
||||
token = aom_read_symbol(r, *cdf_head, 3, ACCT_STR);
|
||||
comb_token = aom_read_symbol(r, *cdf_head, 6, ACCT_STR);
|
||||
if (c == 0) {
|
||||
if (counts) ++blockz_count[comb_token != 0];
|
||||
if (comb_token == 0) return 0;
|
||||
}
|
||||
token = comb_token >> 1;
|
||||
more_data = !token || ((comb_token & 1) == 1);
|
||||
|
||||
if (token > ONE_TOKEN)
|
||||
token += aom_read_symbol(r, *cdf_tail, CATEGORY6_TOKEN + 1 - 2, ACCT_STR);
|
||||
INCREMENT_COUNT(ZERO_TOKEN + (token > ZERO_TOKEN) + (token > ONE_TOKEN));
|
||||
|
@ -190,10 +192,13 @@ static int decode_coefs(MACROBLOCKD *xd, PLANE_TYPE type, tran_low_t *dqcoeff,
|
|||
|
||||
*max_scan_line = AOMMAX(*max_scan_line, scan[c]);
|
||||
|
||||
if (token) {
|
||||
if (counts) ++eob_branch_count[band][ctx];
|
||||
if (!more_data) {
|
||||
if (counts) ++coef_counts[band][ctx][EOB_MODEL_TOKEN];
|
||||
}
|
||||
}
|
||||
token_cache[scan[c]] = av1_pt_energy_class[token];
|
||||
ctx_eob = get_coef_context(nb, token_cache, AOMMIN(c + 1, max_eob - 1));
|
||||
band_eob = c < max_eob - 1 ? *band_translate : band_eob;
|
||||
prob_eob = coef_probs[band_eob][ctx_eob];
|
||||
|
||||
switch (token) {
|
||||
case ZERO_TOKEN:
|
||||
|
@ -260,20 +265,12 @@ static int decode_coefs(MACROBLOCKD *xd, PLANE_TYPE type, tran_low_t *dqcoeff,
|
|||
if (v) dqcoeff[scan[c]] = aom_read_bit(r, ACCT_STR) ? -v : v;
|
||||
#endif // CONFIG_COEFFICIENT_RANGE_CHECKING
|
||||
|
||||
if (token) {
|
||||
if (counts) ++eob_branch_count[band_eob][ctx_eob];
|
||||
if (!aom_read(r, prob_eob[EOB_CONTEXT_NODE], ACCT_STR)) {
|
||||
// INCREMENT_COUNT(EOB_MODEL_TOKEN);
|
||||
if (counts) ++coef_counts[band_eob][ctx_eob][EOB_MODEL_TOKEN];
|
||||
more_data = 0;
|
||||
}
|
||||
}
|
||||
++c;
|
||||
more_data &= (c < max_eob);
|
||||
if (!more_data) break;
|
||||
dqv = dq[1];
|
||||
ctx = get_coef_context(nb, token_cache, c);
|
||||
band = c < max_eob - 1 ? *band_translate++ : band;
|
||||
prob = coef_probs[band][ctx];
|
||||
if (!more_data) break;
|
||||
band = *band_translate++;
|
||||
|
||||
#else // CONFIG_EC_MULTISYMBOL
|
||||
while (c < max_eob) {
|
||||
|
|
|
@ -787,22 +787,24 @@ static void pack_mb_tokens(aom_writer *w, const TOKENEXTRA **tp,
|
|||
aom_tree_index index = 0;
|
||||
const av1_extra_bit *const extra_bits = &extra_bits_table[token];
|
||||
|
||||
if (!p->skip_eob_node)
|
||||
aom_write_record(w, token != EOB_TOKEN, p->context_tree[0], token_stats);
|
||||
if (token == BLOCK_Z_TOKEN) {
|
||||
aom_write_symbol(w, 0, *p->head_cdf, 6);
|
||||
p++;
|
||||
continue;
|
||||
}
|
||||
int comb_symb = 2 * AOMMIN(token, TWO_TOKEN) - p->is_eob + 1;
|
||||
|
||||
if (token != EOB_TOKEN) {
|
||||
aom_write_symbol(w, AOMMIN(token, TWO_TOKEN), *p->head_cdf, 3);
|
||||
if (token > ONE_TOKEN) {
|
||||
aom_write_symbol(w, token - TWO_TOKEN, *p->tail_cdf,
|
||||
CATEGORY6_TOKEN + 1 - 2);
|
||||
}
|
||||
aom_write_symbol(w, comb_symb, *p->head_cdf, 6);
|
||||
if (token > ONE_TOKEN) {
|
||||
aom_write_symbol(w, token - TWO_TOKEN, *p->tail_cdf,
|
||||
CATEGORY6_TOKEN + 1 - 2);
|
||||
}
|
||||
|
||||
if (extra_bits->base_val) {
|
||||
const int bit_string = p->extra;
|
||||
const int bit_string_length = extra_bits->len; // Length of extra bits to
|
||||
// be written excluding
|
||||
// the sign bit.
|
||||
// be written excluding
|
||||
// the sign bit.
|
||||
int skip_bits = (extra_bits->base_val == CAT6_MIN_VAL)
|
||||
? TX_SIZES - 1 - txsize_sqr_up_map[tx_size]
|
||||
: 0;
|
||||
|
@ -2765,7 +2767,7 @@ static void write_modes(AV1_COMP *const cpi, const TileInfo *const tile,
|
|||
#endif
|
||||
}
|
||||
|
||||
#if !CONFIG_PVQ
|
||||
#if !CONFIG_PVQ && !CONFIG_EC_ADAPT
|
||||
static void build_tree_distribution(AV1_COMP *cpi, TX_SIZE tx_size,
|
||||
av1_coeff_stats *coef_branch_ct,
|
||||
av1_coeff_probs_model *coef_probs) {
|
||||
|
@ -2796,17 +2798,14 @@ static void build_tree_distribution(AV1_COMP *cpi, TX_SIZE tx_size,
|
|||
}
|
||||
}
|
||||
|
||||
#if !CONFIG_EC_ADAPT
|
||||
static void update_coef_probs_common(aom_writer *const bc, AV1_COMP *cpi,
|
||||
TX_SIZE tx_size,
|
||||
av1_coeff_stats *frame_branch_ct,
|
||||
av1_coeff_probs_model *new_coef_probs) {
|
||||
av1_coeff_probs_model *old_coef_probs = cpi->common.fc->coef_probs[tx_size];
|
||||
const aom_prob upd = DIFF_UPDATE_PROB;
|
||||
#if CONFIG_EC_ADAPT
|
||||
const int entropy_nodes_update = UNCONSTRAINED_NODES - 2;
|
||||
#else
|
||||
const int entropy_nodes_update = UNCONSTRAINED_NODES;
|
||||
#endif
|
||||
int i, j, k, l, t;
|
||||
int stepsize = cpi->sf.coeff_prob_appx_step;
|
||||
#if CONFIG_TILE_GROUPS
|
||||
|
@ -2946,7 +2945,7 @@ static void update_coef_probs_common(aom_writer *const bc, AV1_COMP *cpi,
|
|||
default: assert(0);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#if CONFIG_ENTROPY
|
||||
// Calculate the token counts between subsequent subframe updates.
|
||||
static void get_coef_counts_diff(AV1_COMP *cpi, int index,
|
||||
|
@ -3156,6 +3155,7 @@ static void update_coef_probs_subframe(
|
|||
}
|
||||
#endif // CONFIG_ENTROPY
|
||||
|
||||
#if !CONFIG_EC_ADAPT
|
||||
static void update_coef_probs(AV1_COMP *cpi, aom_writer *w) {
|
||||
const TX_MODE tx_mode = cpi->common.tx_mode;
|
||||
const TX_SIZE max_tx_size = tx_mode_to_biggest_tx_size[tx_mode];
|
||||
|
@ -3253,6 +3253,7 @@ static void update_coef_probs(AV1_COMP *cpi, aom_writer *w) {
|
|||
#endif // CONFIG_EC_MULTISYMBOL
|
||||
}
|
||||
#endif
|
||||
#endif // !CONFIG_EC_ADAPT
|
||||
|
||||
#if CONFIG_LOOP_RESTORATION
|
||||
static void encode_restoration_mode(AV1_COMMON *cm,
|
||||
|
@ -4517,8 +4518,10 @@ static uint32_t write_compressed_header(AV1_COMP *cpi, uint8_t *data) {
|
|||
#endif // CONFIG_LOOP_RESTORATION
|
||||
update_txfm_probs(cm, header_bc, counts);
|
||||
#if !CONFIG_PVQ
|
||||
#if !CONFIG_EC_ADAPT
|
||||
update_coef_probs(cpi, header_bc);
|
||||
#endif
|
||||
#endif // CONFIG_EC_ADAPT
|
||||
#endif // CONFIG_PVQ
|
||||
#if CONFIG_VAR_TX
|
||||
update_txfm_partition_probs(cm, header_bc, counts, probwt);
|
||||
#endif
|
||||
|
|
|
@ -360,30 +360,39 @@ static void set_entropy_context_b(int plane, int block, int blk_row,
|
|||
blk_row);
|
||||
}
|
||||
|
||||
static INLINE void add_token(TOKENEXTRA **t, const aom_prob *context_tree,
|
||||
#if CONFIG_EC_MULTISYMBOL
|
||||
static INLINE void add_token(TOKENEXTRA **t,
|
||||
aom_cdf_prob (*tail_cdf)[ENTROPY_TOKENS],
|
||||
aom_cdf_prob (*head_cdf)[ENTROPY_TOKENS],
|
||||
#endif // CONFIG_EC_MULTISYMBOL
|
||||
int is_eob, int32_t extra, uint8_t token) {
|
||||
(*t)->token = token;
|
||||
(*t)->extra = extra;
|
||||
(*t)->tail_cdf = tail_cdf;
|
||||
(*t)->head_cdf = head_cdf;
|
||||
(*t)->is_eob = is_eob;
|
||||
(*t)++;
|
||||
}
|
||||
|
||||
#else
|
||||
static INLINE void add_token(TOKENEXTRA **t, const aom_prob *context_tree,
|
||||
int32_t extra, uint8_t token,
|
||||
uint8_t skip_eob_node, unsigned int *counts) {
|
||||
(*t)->token = token;
|
||||
(*t)->extra = extra;
|
||||
(*t)->context_tree = context_tree;
|
||||
#if CONFIG_EC_MULTISYMBOL
|
||||
(*t)->tail_cdf = tail_cdf;
|
||||
(*t)->head_cdf = head_cdf;
|
||||
#endif // CONFIG_EC_MULTISYMBOL
|
||||
(*t)->skip_eob_node = skip_eob_node;
|
||||
(*t)++;
|
||||
++counts[token];
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !CONFIG_EC_MULTISYMBOL
|
||||
static INLINE int get_tx_eob(const struct segmentation *seg, int segment_id,
|
||||
TX_SIZE tx_size) {
|
||||
const int eob_max = tx_size_2d[tx_size];
|
||||
return segfeature_active(seg, segment_id, SEG_LVL_SKIP) ? 0 : eob_max;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if CONFIG_PALETTE
|
||||
void av1_tokenize_palette_sb(const AV1_COMP *cpi,
|
||||
|
@ -446,11 +455,13 @@ static void tokenize_b(int plane, int block, int blk_row, int blk_col,
|
|||
const int eob = p->eobs[block];
|
||||
const PLANE_TYPE type = pd->plane_type;
|
||||
const tran_low_t *qcoeff = BLOCK_OFFSET(p->qcoeff, block);
|
||||
#if !CONFIG_EC_MULTISYMBOL
|
||||
#if CONFIG_SUPERTX
|
||||
const int segment_id = AOMMIN(mbmi->segment_id, mbmi->segment_id_supertx);
|
||||
#else
|
||||
const int segment_id = mbmi->segment_id;
|
||||
#endif // CONFIG_SUEPRTX
|
||||
#endif
|
||||
const int16_t *scan, *nb;
|
||||
const int block_raster_idx = av1_block_index_to_raster_order(tx_size, block);
|
||||
const TX_TYPE tx_type = get_tx_type(type, xd, block_raster_idx, tx_size);
|
||||
|
@ -459,17 +470,17 @@ static void tokenize_b(int plane, int block, int blk_row, int blk_col,
|
|||
const int ref = is_inter_block(mbmi);
|
||||
unsigned int(*const counts)[COEFF_CONTEXTS][ENTROPY_TOKENS] =
|
||||
td->rd_counts.coef_counts[txsize_sqr_map[tx_size]][type][ref];
|
||||
#if !CONFIG_EC_MULTISYMBOL
|
||||
#if CONFIG_ENTROPY
|
||||
const aom_prob(*coef_probs)[COEFF_CONTEXTS][UNCONSTRAINED_NODES] =
|
||||
cpi->subframe_stats.coef_probs_buf[cpi->common.coef_probs_update_idx]
|
||||
[txsize_sqr_map[tx_size]][type][ref];
|
||||
#else
|
||||
aom_prob(*const coef_probs)[COEFF_CONTEXTS][UNCONSTRAINED_NODES] =
|
||||
cpi->common.fc->coef_probs[txsize_sqr_map[tx_size]][type][ref];
|
||||
#endif // CONFIG_ENTROPY
|
||||
|
||||
#endif
|
||||
#if CONFIG_EC_ADAPT
|
||||
FRAME_CONTEXT *ec_ctx = xd->tile_ctx;
|
||||
FRAME_CONTEXT *ec_ctx = xd->tile_ctx;
|
||||
#elif CONFIG_EC_MULTISYMBOL
|
||||
FRAME_CONTEXT *ec_ctx = cpi->common.fc;
|
||||
#endif
|
||||
|
@ -480,13 +491,14 @@ static void tokenize_b(int plane, int block, int blk_row, int blk_col,
|
|||
ec_ctx->coef_tail_cdfs[tx_size][type][ref];
|
||||
unsigned int(*const blockz_count)[2] =
|
||||
td->counts->blockz_count[txsize_sqr_map[tx_size]][type][ref];
|
||||
int c2;
|
||||
#endif
|
||||
int is_eob;
|
||||
#else
|
||||
int skip_eob = 0;
|
||||
const int seg_eob = get_tx_eob(&cpi->common.seg, segment_id, tx_size);
|
||||
#endif
|
||||
unsigned int(*const eob_branch)[COEFF_CONTEXTS] =
|
||||
td->counts->eob_branch[txsize_sqr_map[tx_size]][type][ref];
|
||||
const uint8_t *const band = get_band_translate(tx_size);
|
||||
int skip_eob = 0;
|
||||
int16_t token;
|
||||
EXTRABIT extra;
|
||||
(void)plane_bsize;
|
||||
|
@ -497,26 +509,37 @@ static void tokenize_b(int plane, int block, int blk_row, int blk_col,
|
|||
c = 0;
|
||||
|
||||
#if CONFIG_EC_MULTISYMBOL
|
||||
if (eob == 0)
|
||||
add_token(&t, &coef_tail_cdfs[band[c]][pt], &coef_head_cdfs[band[c]][pt], 0,
|
||||
0, BLOCK_Z_TOKEN);
|
||||
|
||||
++blockz_count[pt][eob != 0];
|
||||
|
||||
while (c < eob) {
|
||||
const int v = qcoeff[scan[c]];
|
||||
eob_branch[band[c]][pt] += !skip_eob;
|
||||
int v = qcoeff[scan[c]];
|
||||
|
||||
av1_get_token_extra(v, &token, &extra);
|
||||
if (!v) {
|
||||
add_token(&t, &coef_tail_cdfs[band[c]][pt], &coef_head_cdfs[band[c]][pt],
|
||||
0, 0, ZERO_TOKEN);
|
||||
++counts[band[c]][pt][ZERO_TOKEN];
|
||||
token_cache[scan[c]] = 0;
|
||||
} else {
|
||||
is_eob = (c + 1 == eob);
|
||||
|
||||
add_token(&t, coef_probs[band[c]][pt], &coef_tail_cdfs[band[c]][pt],
|
||||
&coef_head_cdfs[band[c]][pt], extra, (uint8_t)token,
|
||||
(uint8_t)skip_eob, counts[band[c]][pt]);
|
||||
av1_get_token_extra(v, &token, &extra);
|
||||
|
||||
token_cache[scan[c]] = av1_pt_energy_class[token];
|
||||
add_token(&t, &coef_tail_cdfs[band[c]][pt], &coef_head_cdfs[band[c]][pt],
|
||||
is_eob, extra, (uint8_t)token);
|
||||
|
||||
++counts[band[c]][pt][token];
|
||||
++eob_branch[band[c]][pt];
|
||||
counts[band[c]][pt][EOB_TOKEN] += is_eob;
|
||||
|
||||
token_cache[scan[c]] = av1_pt_energy_class[token];
|
||||
}
|
||||
++c;
|
||||
pt = get_coef_context(nb, token_cache, AOMMIN(c, seg_eob - 1));
|
||||
skip_eob = (token == ZERO_TOKEN);
|
||||
pt = get_coef_context(nb, token_cache, AOMMIN(c, eob - 1));
|
||||
}
|
||||
c2 = AOMMIN(c, seg_eob - 1);
|
||||
add_token(&t, coef_probs[band[c2]][pt], NULL, NULL, 0, EOB_TOKEN, 0,
|
||||
counts[band[c2]][pt]);
|
||||
++eob_branch[band[c2]][pt];
|
||||
#else
|
||||
while (c < eob) {
|
||||
const int v = qcoeff[scan[c]];
|
||||
|
|
|
@ -35,11 +35,12 @@ typedef struct {
|
|||
} TOKENVALUE;
|
||||
|
||||
typedef struct {
|
||||
const aom_prob *context_tree;
|
||||
#if CONFIG_EC_MULTISYMBOL
|
||||
aom_cdf_prob (*tail_cdf)[ENTROPY_TOKENS];
|
||||
aom_cdf_prob (*head_cdf)[ENTROPY_TOKENS];
|
||||
int is_eob;
|
||||
#endif
|
||||
const aom_prob *context_tree;
|
||||
EXTRABIT extra;
|
||||
uint8_t token;
|
||||
uint8_t skip_eob_node;
|
||||
|
|
Загрузка…
Ссылка в новой задаче