Commit 7e703de7 authored by Dmitry Kovalev's avatar Dmitry Kovalev
Browse files

Removing pre probabilities from FRAME_CONTEXT.

Using cm->frame_contexts[cm->frame_context_idx] as source of previous
probabilities.

Change-Id: Ie03778acf0e7bebdc3a1f6a51854d4a0712f24a1
parent f00a237a
......@@ -625,8 +625,10 @@ void vp9_coef_tree_initialize() {
static void adapt_coef_probs(VP9_COMMON *cm, TX_SIZE txfm_size,
int count_sat, int update_factor) {
FRAME_CONTEXT *pre_fc = &cm->frame_contexts[cm->frame_context_idx];
vp9_coeff_probs_model *dst_coef_probs = cm->fc.coef_probs[txfm_size];
vp9_coeff_probs_model *pre_coef_probs = cm->fc.pre_coef_probs[txfm_size];
vp9_coeff_probs_model *pre_coef_probs = pre_fc->coef_probs[txfm_size];
vp9_coeff_count_model *coef_counts = cm->fc.coef_counts[txfm_size];
unsigned int (*eob_branch_count)[REF_TYPES][COEF_BANDS][PREV_COEF_CONTEXTS] =
cm->fc.eob_branch_counts[txfm_size];
......
......@@ -392,6 +392,8 @@ void vp9_accum_mv_refs(VP9_COMMON *pc,
#define MVREF_MAX_UPDATE_FACTOR 128
void vp9_adapt_mode_context(VP9_COMMON *pc) {
int i, j;
FRAME_CONTEXT *pre_fc = &pc->frame_contexts[pc->frame_context_idx];
unsigned int (*inter_mode_counts)[VP9_INTER_MODES - 1][2] =
pc->fc.inter_mode_counts;
vp9_prob (*mode_context)[VP9_INTER_MODES - 1] = pc->fc.inter_mode_probs;
......@@ -403,7 +405,7 @@ void vp9_adapt_mode_context(VP9_COMMON *pc) {
count = count > MVREF_COUNT_SAT ? MVREF_COUNT_SAT : count;
factor = (MVREF_MAX_UPDATE_FACTOR * count / MVREF_COUNT_SAT);
mode_context[j][i] = weighted_prob(
pc->fc.pre_inter_mode_probs[j][i],
pre_fc->inter_mode_probs[j][i],
get_binary_prob(inter_mode_counts[j][i][0],
inter_mode_counts[j][i][1]),
factor);
......@@ -450,6 +452,8 @@ static void update_mode_probs(int n_modes,
void vp9_adapt_mode_probs(VP9_COMMON *cm) {
int i, j;
FRAME_CONTEXT *fc = &cm->fc;
FRAME_CONTEXT *pre_fc = &cm->frame_contexts[cm->frame_context_idx];
#ifdef MODE_COUNT_TESTING
int t;
......@@ -485,39 +489,40 @@ void vp9_adapt_mode_probs(VP9_COMMON *cm) {
#endif
for (i = 0; i < INTRA_INTER_CONTEXTS; i++)
fc->intra_inter_prob[i] = update_mode_ct2(fc->pre_intra_inter_prob[i],
fc->intra_inter_prob[i] = update_mode_ct2(pre_fc->intra_inter_prob[i],
fc->intra_inter_count[i]);
for (i = 0; i < COMP_INTER_CONTEXTS; i++)
fc->comp_inter_prob[i] = update_mode_ct2(fc->pre_comp_inter_prob[i],
fc->comp_inter_prob[i] = update_mode_ct2(pre_fc->comp_inter_prob[i],
fc->comp_inter_count[i]);
for (i = 0; i < REF_CONTEXTS; i++)
fc->comp_ref_prob[i] = update_mode_ct2(fc->pre_comp_ref_prob[i],
fc->comp_ref_prob[i] = update_mode_ct2(pre_fc->comp_ref_prob[i],
fc->comp_ref_count[i]);
for (i = 0; i < REF_CONTEXTS; i++)
for (j = 0; j < 2; j++)
fc->single_ref_prob[i][j] = update_mode_ct2(fc->pre_single_ref_prob[i][j],
fc->single_ref_prob[i][j] = update_mode_ct2(pre_fc->single_ref_prob[i][j],
fc->single_ref_count[i][j]);
for (i = 0; i < BLOCK_SIZE_GROUPS; i++)
update_mode_probs(VP9_INTRA_MODES, vp9_intra_mode_tree,
fc->y_mode_counts[i], fc->pre_y_mode_prob[i],
fc->y_mode_counts[i], pre_fc->y_mode_prob[i],
fc->y_mode_prob[i], 0);
for (i = 0; i < VP9_INTRA_MODES; ++i)
update_mode_probs(VP9_INTRA_MODES, vp9_intra_mode_tree,
fc->uv_mode_counts[i], fc->pre_uv_mode_prob[i],
fc->uv_mode_counts[i], pre_fc->uv_mode_prob[i],
fc->uv_mode_prob[i], 0);
for (i = 0; i < NUM_PARTITION_CONTEXTS; i++)
update_mode_probs(PARTITION_TYPES, vp9_partition_tree,
fc->partition_counts[i], fc->pre_partition_prob[i],
fc->partition_counts[i],
pre_fc->partition_prob[INTER_FRAME][i],
fc->partition_prob[INTER_FRAME][i], 0);
if (cm->mcomp_filter_type == SWITCHABLE) {
for (i = 0; i <= VP9_SWITCHABLE_FILTERS; i++)
update_mode_probs(VP9_SWITCHABLE_FILTERS, vp9_switchable_interp_tree,
fc->switchable_interp_count[i],
fc->pre_switchable_interp_prob[i],
pre_fc->switchable_interp_prob[i],
fc->switchable_interp_prob[i], 0);
}
......@@ -530,25 +535,25 @@ void vp9_adapt_mode_probs(VP9_COMMON *cm) {
for (i = 0; i < TX_SIZE_CONTEXTS; ++i) {
tx_counts_to_branch_counts_8x8(fc->tx_counts.p8x8[i], branch_ct_8x8p);
for (j = 0; j < TX_SIZE_MAX_SB - 3; ++j)
fc->tx_probs.p8x8[i][j] = update_tx_ct(fc->pre_tx_probs.p8x8[i][j],
fc->tx_probs.p8x8[i][j] = update_tx_ct(pre_fc->tx_probs.p8x8[i][j],
branch_ct_8x8p[j]);
tx_counts_to_branch_counts_16x16(fc->tx_counts.p16x16[i],
branch_ct_16x16p);
for (j = 0; j < TX_SIZE_MAX_SB - 2; ++j)
fc->tx_probs.p16x16[i][j] = update_tx_ct(fc->pre_tx_probs.p16x16[i][j],
fc->tx_probs.p16x16[i][j] = update_tx_ct(pre_fc->tx_probs.p16x16[i][j],
branch_ct_16x16p[j]);
tx_counts_to_branch_counts_32x32(fc->tx_counts.p32x32[i],
branch_ct_32x32p);
for (j = 0; j < TX_SIZE_MAX_SB - 1; ++j)
fc->tx_probs.p32x32[i][j] = update_tx_ct(fc->pre_tx_probs.p32x32[i][j],
fc->tx_probs.p32x32[i][j] = update_tx_ct(pre_fc->tx_probs.p32x32[i][j],
branch_ct_32x32p[j]);
}
}
for (i = 0; i < MBSKIP_CONTEXTS; ++i)
fc->mbskip_probs[i] = update_mode_ct2(fc->pre_mbskip_probs[i],
fc->mbskip_probs[i] = update_mode_ct2(pre_fc->mbskip_probs[i],
fc->mbskip_count[i]);
}
......
......@@ -222,8 +222,10 @@ static unsigned int adapt_probs(unsigned int i,
void vp9_adapt_mv_probs(VP9_COMMON *cm, int usehp) {
int i, j;
FRAME_CONTEXT *pre_fc = &cm->frame_contexts[cm->frame_context_idx];
nmv_context *ctx = &cm->fc.nmvc;
nmv_context *pre_ctx = &cm->fc.pre_nmvc;
nmv_context *pre_ctx = &pre_fc->nmvc;
nmv_context_counts *cts = &cm->fc.NMVcount;
vp9_counts_process(cts, usehp);
......
......@@ -43,16 +43,13 @@ typedef struct frame_contexts {
vp9_prob uv_mode_prob[VP9_INTRA_MODES][VP9_INTRA_MODES - 1];
vp9_prob partition_prob[NUM_FRAME_TYPES][NUM_PARTITION_CONTEXTS]
[PARTITION_TYPES - 1];
vp9_prob pre_y_mode_prob[BLOCK_SIZE_GROUPS][VP9_INTRA_MODES - 1];
vp9_prob pre_uv_mode_prob[VP9_INTRA_MODES][VP9_INTRA_MODES - 1];
vp9_prob pre_partition_prob[NUM_PARTITION_CONTEXTS][PARTITION_TYPES - 1];
unsigned int y_mode_counts[BLOCK_SIZE_GROUPS][VP9_INTRA_MODES];
unsigned int uv_mode_counts[VP9_INTRA_MODES][VP9_INTRA_MODES];
unsigned int partition_counts[NUM_PARTITION_CONTEXTS][PARTITION_TYPES];
// coeff
vp9_coeff_probs_model coef_probs[TX_SIZE_MAX_SB][BLOCK_TYPES];
vp9_coeff_probs_model pre_coef_probs[TX_SIZE_MAX_SB][BLOCK_TYPES];
vp9_coeff_count_model coef_counts[TX_SIZE_MAX_SB][BLOCK_TYPES];
unsigned int eob_branch_counts[TX_SIZE_MAX_SB][BLOCK_TYPES][REF_TYPES]
[COEF_BANDS][PREV_COEF_CONTEXTS];
......@@ -60,13 +57,10 @@ typedef struct frame_contexts {
// switchable_interp
vp9_prob switchable_interp_prob[VP9_SWITCHABLE_FILTERS + 1]
[VP9_SWITCHABLE_FILTERS - 1];
vp9_prob pre_switchable_interp_prob[VP9_SWITCHABLE_FILTERS + 1]
[VP9_SWITCHABLE_FILTERS - 1];
unsigned int switchable_interp_count[VP9_SWITCHABLE_FILTERS + 1]
[VP9_SWITCHABLE_FILTERS];
// inter_mode
vp9_prob inter_mode_probs[INTER_MODE_CONTEXTS][VP9_INTER_MODES - 1];
vp9_prob pre_inter_mode_probs[INTER_MODE_CONTEXTS][VP9_INTER_MODES - 1];
unsigned int inter_mode_counts[INTER_MODE_CONTEXTS][VP9_INTER_MODES - 1][2];
// intra_inter, comp_inter, single_ref, comp_ref
......@@ -74,10 +68,7 @@ typedef struct frame_contexts {
vp9_prob comp_inter_prob[COMP_INTER_CONTEXTS];
vp9_prob single_ref_prob[REF_CONTEXTS][2];
vp9_prob comp_ref_prob[REF_CONTEXTS];
vp9_prob pre_intra_inter_prob[INTRA_INTER_CONTEXTS];
vp9_prob pre_comp_inter_prob[COMP_INTER_CONTEXTS];
vp9_prob pre_single_ref_prob[REF_CONTEXTS][2];
vp9_prob pre_comp_ref_prob[REF_CONTEXTS];
unsigned int intra_inter_count[INTRA_INTER_CONTEXTS][2];
unsigned int comp_inter_count[COMP_INTER_CONTEXTS][2];
unsigned int single_ref_count[REF_CONTEXTS][2][2];
......@@ -85,17 +76,14 @@ typedef struct frame_contexts {
// tx_probs
struct tx_probs tx_probs;
struct tx_probs pre_tx_probs;
struct tx_counts tx_counts;
// mbskip
vp9_prob mbskip_probs[MBSKIP_CONTEXTS];
vp9_prob pre_mbskip_probs[MBSKIP_CONTEXTS];
unsigned int mbskip_count[MBSKIP_CONTEXTS][2];
// mv
nmv_context nmvc;
nmv_context pre_nmvc;
nmv_context_counts NMVcount;
} FRAME_CONTEXT;
......
......@@ -583,21 +583,7 @@ static void setup_frame_size_with_refs(VP9D_COMP *pbi,
apply_frame_size(pbi, width, height);
}
static void update_frame_context(FRAME_CONTEXT *fc) {
vp9_copy(fc->pre_coef_probs, fc->coef_probs);
vp9_copy(fc->pre_y_mode_prob, fc->y_mode_prob);
vp9_copy(fc->pre_uv_mode_prob, fc->uv_mode_prob);
vp9_copy(fc->pre_partition_prob, fc->partition_prob[1]);
vp9_copy(fc->pre_intra_inter_prob, fc->intra_inter_prob);
vp9_copy(fc->pre_comp_inter_prob, fc->comp_inter_prob);
vp9_copy(fc->pre_single_ref_prob, fc->single_ref_prob);
vp9_copy(fc->pre_comp_ref_prob, fc->comp_ref_prob);
fc->pre_nmvc = fc->nmvc;
vp9_copy(fc->pre_switchable_interp_prob, fc->switchable_interp_prob);
vp9_copy(fc->pre_inter_mode_probs, fc->inter_mode_probs);
fc->pre_tx_probs = fc->tx_probs;
vp9_copy(fc->pre_mbskip_probs, fc->mbskip_probs);
static void zero_counts(FRAME_CONTEXT *fc) {
vp9_zero(fc->coef_counts);
vp9_zero(fc->eob_branch_counts);
vp9_zero(fc->y_mode_counts);
......@@ -964,7 +950,7 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) {
pc->fc = pc->frame_contexts[pc->frame_context_idx];
update_frame_context(&pc->fc);
zero_counts(&pc->fc);
// Initialize xd pointers. Any reference should do for xd->pre, so use 0.
setup_pre_planes(xd, 0, &pc->yv12_fb[pc->active_ref_idx[0]], 0, 0, NULL);
......
......@@ -1471,7 +1471,6 @@ static size_t write_compressed_header(VP9_COMP *cpi, uint8_t *data) {
}
void vp9_pack_bitstream(VP9_COMP *cpi, uint8_t *dest, unsigned long *size) {
FRAME_CONTEXT *const fc = &cpi->common.fc;
uint8_t *data = dest;
size_t first_part_size;
struct vp9_write_bit_buffer wb = {data, 0};
......@@ -1494,20 +1493,6 @@ void vp9_pack_bitstream(VP9_COMP *cpi, uint8_t *dest, unsigned long *size) {
vp9_clear_system_state(); // __asm emms;
vp9_copy(fc->pre_coef_probs, fc->coef_probs);
vp9_copy(fc->pre_y_mode_prob, fc->y_mode_prob);
vp9_copy(fc->pre_uv_mode_prob, fc->uv_mode_prob);
vp9_copy(fc->pre_partition_prob, fc->partition_prob[INTER_FRAME]);
fc->pre_nmvc = fc->nmvc;
vp9_copy(fc->pre_switchable_interp_prob, fc->switchable_interp_prob);
vp9_copy(fc->pre_inter_mode_probs, fc->inter_mode_probs);
vp9_copy(fc->pre_intra_inter_prob, fc->intra_inter_prob);
vp9_copy(fc->pre_comp_inter_prob, fc->comp_inter_prob);
vp9_copy(fc->pre_comp_ref_prob, fc->comp_ref_prob);
vp9_copy(fc->pre_single_ref_prob, fc->single_ref_prob);
fc->pre_tx_probs = fc->tx_probs;
vp9_copy(fc->pre_mbskip_probs, fc->mbskip_probs);
first_part_size = write_compressed_header(cpi, data);
data += first_part_size;
vp9_wb_write_literal(&saved_wb, first_part_size, 16);
......
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