Commit b53682f5 authored by hui su's avatar hui su Committed by Sebastien Alaiwan

Remove probablity model for coeffecient tokens

Remove the token prob tables and counters.

Change-Id: Ic63d52d80bb922fc10b586c27a20f2378618168c
parent 55f1ef00
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -191,21 +191,15 @@ static INLINE int av1_get_cat6_extrabits_size(TX_SIZE tx_size,
#define BAND_COEFF_CONTEXTS(band) \
((band) == 0 ? COEFF_CONTEXTS0 : COEFF_CONTEXTS)
// #define ENTROPY_STATS
typedef unsigned int av1_coeff_count[REF_TYPES][COEF_BANDS][COEFF_CONTEXTS]
[ENTROPY_TOKENS];
typedef unsigned int av1_coeff_stats[REF_TYPES][COEF_BANDS][COEFF_CONTEXTS]
[ENTROPY_NODES][2];
#define SUBEXP_PARAM 4 /* Subexponential code parameter */
#define MODULUS_PARAM 13 /* Modulus parameter */
struct AV1Common;
struct frame_contexts;
void av1_default_coef_probs(struct AV1Common *cm);
#if CONFIG_LV_MAP
void av1_adapt_coef_probs(struct AV1Common *cm);
void av1_adapt_coef_cdfs(struct AV1Common *cm, struct frame_contexts *pre_fc);
#endif // CONFIG_LV_MAP
// This is the index in the scan order beyond which all coefficients for
// 8x8 transform and above are in the top band.
......@@ -238,22 +232,11 @@ static INLINE const uint8_t *get_band_translate(TX_SIZE tx_size) {
#define UNCONSTRAINED_NODES 3
#define PIVOT_NODE 2 // which node is pivot
#define MODEL_NODES (ENTROPY_NODES - UNCONSTRAINED_NODES)
#define TAIL_NODES (MODEL_NODES + 1)
extern const aom_tree_index av1_coef_con_tree[TREE_SIZE(ENTROPY_TOKENS)];
extern const aom_prob av1_pareto8_full[COEFF_PROB_MODELS][MODEL_NODES];
typedef aom_prob av1_coeff_probs_model[REF_TYPES][COEF_BANDS][COEFF_CONTEXTS]
[UNCONSTRAINED_NODES];
typedef unsigned int av1_coeff_count_model[REF_TYPES][COEF_BANDS]
[COEFF_CONTEXTS]
[UNCONSTRAINED_NODES + 1];
void av1_model_to_full_probs(const aom_prob *model, aom_prob *full);
typedef aom_cdf_prob coeff_cdf_model[REF_TYPES][COEF_BANDS][COEFF_CONTEXTS]
[CDF_SIZE(ENTROPY_TOKENS)];
typedef aom_prob av1_blockz_probs_model[REF_TYPES][BLOCKZ_CONTEXTS];
......
......@@ -96,10 +96,8 @@ typedef struct frame_contexts {
#else
aom_prob partition_prob[PARTITION_CONTEXTS][PARTITION_TYPES - 1];
#endif
av1_coeff_probs_model coef_probs[TX_SIZES][PLANE_TYPES];
coeff_cdf_model coef_tail_cdfs[TX_SIZES][PLANE_TYPES];
coeff_cdf_model coef_head_cdfs[TX_SIZES][PLANE_TYPES];
aom_prob blockzero_probs[TX_SIZES][PLANE_TYPES][REF_TYPES][BLOCKZ_CONTEXTS];
aom_prob switchable_interp_prob[SWITCHABLE_FILTER_CONTEXTS]
[SWITCHABLE_FILTERS - 1];
#if CONFIG_ADAPT_SCAN
......@@ -401,9 +399,6 @@ typedef struct FRAME_COUNTS {
#else
unsigned int partition[PARTITION_CONTEXTS][PARTITION_TYPES];
#endif
av1_coeff_count_model coef[TX_SIZES][PLANE_TYPES];
unsigned int eob_branch[TX_SIZES][PLANE_TYPES][REF_TYPES][COEF_BANDS]
[COEFF_CONTEXTS];
unsigned int switchable_interp[SWITCHABLE_FILTER_CONTEXTS]
[SWITCHABLE_FILTERS];
#if CONFIG_ADAPT_SCAN
......
......@@ -5032,9 +5032,6 @@ static void debug_check_frame_counts(const AV1_COMMON *const cm) {
#endif
assert(!memcmp(cm->counts.partition, zero_counts.partition,
sizeof(cm->counts.partition)));
assert(!memcmp(cm->counts.coef, zero_counts.coef, sizeof(cm->counts.coef)));
assert(!memcmp(cm->counts.eob_branch, zero_counts.eob_branch,
sizeof(cm->counts.eob_branch)));
assert(!memcmp(cm->counts.blockz_count, zero_counts.blockz_count,
sizeof(cm->counts.blockz_count)));
assert(!memcmp(cm->counts.switchable_interp, zero_counts.switchable_interp,
......@@ -5409,7 +5406,9 @@ void av1_decode_frame(AV1Decoder *pbi, const uint8_t *data,
aom_malloc(cm->tile_rows * cm->tile_cols *
sizeof(&pbi->tile_data[0].tctx.partition_cdf[0][0]));
make_update_tile_list_dec(pbi, cm->tile_rows, cm->tile_cols, tile_ctxs);
#if CONFIG_LV_MAP
av1_adapt_coef_probs(cm);
#endif // CONFIG_LV_MAP
av1_adapt_intra_frame_probs(cm);
av1_average_tile_coef_cdfs(pbi->common.fc, tile_ctxs, cdf_ptrs,
cm->tile_rows * cm->tile_cols);
......
......@@ -5078,7 +5078,6 @@ static void encode_frame_internal(AV1_COMP *cpi) {
xd->mi[0] = cm->mi;
av1_zero(*td->counts);
av1_zero(rdc->coef_counts);
av1_zero(rdc->comp_pred_diff);
if (frame_is_intra_only(cm)) {
......
......@@ -3767,28 +3767,6 @@ static void release_scaled_references(AV1_COMP *cpi) {
}
}
static void full_to_model_count(unsigned int *model_count,
unsigned int *full_count) {
int n;
model_count[ZERO_TOKEN] = full_count[ZERO_TOKEN];
model_count[ONE_TOKEN] = full_count[ONE_TOKEN];
model_count[TWO_TOKEN] = full_count[TWO_TOKEN];
for (n = THREE_TOKEN; n < EOB_TOKEN; ++n)
model_count[TWO_TOKEN] += full_count[n];
model_count[EOB_MODEL_TOKEN] = full_count[EOB_TOKEN];
}
void av1_full_to_model_counts(av1_coeff_count_model *model_count,
av1_coeff_count *full_count) {
int i, j, k, l;
for (i = 0; i < PLANE_TYPES; ++i)
for (j = 0; j < REF_TYPES; ++j)
for (k = 0; k < COEF_BANDS; ++k)
for (l = 0; l < BAND_COEFF_CONTEXTS(k); ++l)
full_to_model_count(model_count[i][j][k][l], full_count[i][j][k][l]);
}
#if 0 && CONFIG_INTERNAL_STATS
static void output_frame_level_debug_stats(AV1_COMP *cpi) {
AV1_COMMON *const cm = &cpi->common;
......@@ -4851,7 +4829,6 @@ static void encode_frame_to_data_rate(AV1_COMP *cpi, size_t *size,
AV1_COMMON *const cm = &cpi->common;
const AV1EncoderConfig *const oxcf = &cpi->oxcf;
struct segmentation *const seg = &cm->seg;
TX_SIZE t;
FRAME_CONTEXT **tile_ctxs = aom_malloc(cm->tile_rows * cm->tile_cols *
sizeof(&cpi->tile_data[0].tctx));
aom_cdf_prob **cdf_ptrs =
......@@ -5158,9 +5135,6 @@ static void encode_frame_to_data_rate(AV1_COMP *cpi, size_t *size,
av1_update_reference_frames(cpi);
for (t = 0; t < TX_SIZES; t++)
av1_full_to_model_counts(cpi->td.counts->coef[t],
cpi->td.rd_counts.coef_counts[t]);
#if CONFIG_ENTROPY_STATS
av1_accumulate_frame_counts(&aggregate_fc, &cm->counts);
assert(cm->frame_context_idx < FRAME_CONTEXTS);
......@@ -5168,7 +5142,9 @@ static void encode_frame_to_data_rate(AV1_COMP *cpi, size_t *size,
&cm->counts);
#endif // CONFIG_ENTROPY_STATS
if (cm->refresh_frame_context == REFRESH_FRAME_CONTEXT_BACKWARD) {
#if CONFIG_LV_MAP
av1_adapt_coef_probs(cm);
#endif // CONFIG_LV_MAP
av1_adapt_intra_frame_probs(cm);
make_update_tile_list_enc(cpi, cm->tile_rows, cm->tile_cols, tile_ctxs);
av1_average_tile_coef_cdfs(cpi->common.fc, tile_ctxs, cdf_ptrs,
......
......@@ -326,7 +326,6 @@ typedef struct TileDataEnc {
} TileDataEnc;
typedef struct RD_COUNTS {
av1_coeff_count coef_counts[TX_SIZES][PLANE_TYPES];
int64_t comp_pred_diff[REFERENCE_MODES];
#if CONFIG_GLOBAL_MOTION
// Stores number of 4x4 blocks using global motion per reference frame.
......@@ -659,9 +658,6 @@ int av1_set_size_literal(AV1_COMP *cpi, int width, int height);
int av1_get_quantizer(struct AV1_COMP *cpi);
void av1_full_to_model_counts(av1_coeff_count_model *model_count,
av1_coeff_count *full_count);
static INLINE int frame_is_kf_gf_arf(const AV1_COMP *cpi) {
return frame_is_intra_only(&cpi->common) || cpi->refresh_alt_ref_frame ||
(cpi->refresh_golden_frame && !cpi->rc.is_src_frame_alt_ref);
......
......@@ -15,13 +15,11 @@
#include "aom_dsp/aom_dsp_common.h"
static void accumulate_rd_opt(ThreadData *td, ThreadData *td_t) {
int i, j, k, l, m, n;
for (i = 0; i < REFERENCE_MODES; i++)
for (int i = 0; i < REFERENCE_MODES; i++)
td->rd_counts.comp_pred_diff[i] += td_t->rd_counts.comp_pred_diff[i];
#if CONFIG_GLOBAL_MOTION
for (i = 0; i < TOTAL_REFS_PER_FRAME; i++)
for (int i = 0; i < TOTAL_REFS_PER_FRAME; i++)
td->rd_counts.global_motion_used[i] +=
td_t->rd_counts.global_motion_used[i];
#endif // CONFIG_GLOBAL_MOTION
......@@ -29,15 +27,6 @@ static void accumulate_rd_opt(ThreadData *td, ThreadData *td_t) {
td->rd_counts.compound_ref_used_flag |=
td_t->rd_counts.compound_ref_used_flag;
td->rd_counts.single_ref_used_flag |= td_t->rd_counts.single_ref_used_flag;
for (i = 0; i < TX_SIZES; i++)
for (j = 0; j < PLANE_TYPES; j++)
for (k = 0; k < REF_TYPES; k++)
for (l = 0; l < COEF_BANDS; l++)
for (m = 0; m < COEFF_CONTEXTS; m++)
for (n = 0; n < ENTROPY_TOKENS; n++)
td->rd_counts.coef_counts[i][j][k][l][m][n] +=
td_t->rd_counts.coef_counts[i][j][k][l][m][n];
}
static int enc_worker_hook(EncWorkerData *const thread_data, void *unused) {
......
......@@ -138,47 +138,6 @@ int av1_prob_diff_update_savings_search(const unsigned int *ct, aom_prob oldp,
return bestsavings;
}
int av1_prob_diff_update_savings_search_model(const unsigned int *ct,
const aom_prob oldp,
aom_prob *bestp, aom_prob upd,
int stepsize, int probwt) {
int i, old_b, new_b, update_b, savings, bestsavings;
int newp;
const int step_sign = *bestp > oldp ? -1 : 1;
const int step = stepsize * step_sign;
const int upd_cost = av1_cost_one(upd) - av1_cost_zero(upd);
const aom_prob *newplist, *oldplist;
aom_prob bestnewp;
oldplist = av1_pareto8_full[oldp - 1];
old_b = cost_branch256(ct + 2 * PIVOT_NODE, oldp);
for (i = UNCONSTRAINED_NODES; i < ENTROPY_NODES; ++i)
old_b += cost_branch256(ct + 2 * i, oldplist[i - UNCONSTRAINED_NODES]);
bestsavings = 0;
bestnewp = oldp;
assert(stepsize > 0);
if (old_b > upd_cost + (MIN_DELP_BITS << AV1_PROB_COST_SHIFT)) {
for (newp = *bestp; (newp - oldp) * step_sign < 0; newp += step) {
if (newp < 1 || newp > 255) continue;
newplist = av1_pareto8_full[newp - 1];
new_b = cost_branch256(ct + 2 * PIVOT_NODE, newp);
for (i = UNCONSTRAINED_NODES; i < ENTROPY_NODES; ++i)
new_b += cost_branch256(ct + 2 * i, newplist[i - UNCONSTRAINED_NODES]);
update_b = prob_diff_update_cost(newp, oldp) + upd_cost;
savings = old_b - new_b - update_b * probwt;
if (savings > bestsavings) {
bestsavings = savings;
bestnewp = newp;
}
}
}
*bestp = bestnewp;
return bestsavings;
}
void av1_cond_prob_diff_update(aom_writer *w, aom_prob *oldp,
const unsigned int ct[2], int probwt) {
const aom_prob upd = DIFF_UPDATE_PROB;
......
......@@ -498,8 +498,6 @@ static void tokenize_b(int plane, int block, int blk_row, int blk_col,
av1_get_tx_type(type, xd, blk_row, blk_col, block, tx_size);
const SCAN_ORDER *const scan_order = get_scan(cm, tx_size, tx_type, mbmi);
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];
FRAME_CONTEXT *ec_ctx = xd->tile_ctx;
aom_cdf_prob(
*const coef_head_cdfs)[COEFF_CONTEXTS][CDF_SIZE(ENTROPY_TOKENS)] =
......@@ -512,8 +510,6 @@ static void tokenize_b(int plane, int block, int blk_row, int blk_col,
int eob_val;
int first_val = 1;
const int seg_eob = av1_get_tx_eob(&cpi->common.seg, segment_id, tx_size);
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);
int16_t token;
EXTRABIT extra;
......@@ -537,23 +533,13 @@ static void tokenize_b(int plane, int block, int blk_row, int blk_col,
if (!v) {
add_token(&t, &coef_tail_cdfs[band[c]][pt], &coef_head_cdfs[band[c]][pt],
0, first_val, 0, ZERO_TOKEN);
++counts[band[c]][pt][ZERO_TOKEN];
token_cache[scan[c]] = 0;
} else {
eob_val =
(c + 1 == eob) ? (c + 1 == seg_eob ? LAST_EOB : EARLY_EOB) : NO_EOB;
av1_get_token_extra(v, &token, &extra);
add_token(&t, &coef_tail_cdfs[band[c]][pt], &coef_head_cdfs[band[c]][pt],
eob_val, first_val, extra, (uint8_t)token);
if (eob_val != LAST_EOB) {
++counts[band[c]][pt][token];
++eob_branch[band[c]][pt];
counts[band[c]][pt][EOB_TOKEN] += eob_val != NO_EOB;
}
token_cache[scan[c]] = av1_pt_energy_class[token];
}
++c;
......
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