Commit 12da793d authored by Yaowu Xu's avatar Yaowu Xu
Browse files

removed redundant mode_context data structures

This commit removed a couple of redundant data structures in frame
coding contextsm, mode_context and mode_context_a, and changed to
use vp9_mode_contexts only. The switch of the context for different
frame type now relies on the switch of frame coding context between
lfc and lfc_a. This commit also removed a number of memcpy among
these redundant data structure.

Change-Id: I42e8174bd60f466b0860afc44c1263896471b0f3
parent fcccbcbb
......@@ -448,14 +448,6 @@ void vp9_entropy_mode_init() {
void vp9_init_mode_contexts(VP9_COMMON *pc) {
vpx_memset(pc->fc.mv_ref_ct, 0, sizeof(pc->fc.mv_ref_ct));
vpx_memcpy(pc->fc.mode_context,
vp9_default_mode_contexts,
sizeof(pc->fc.mode_context));
vpx_memcpy(pc->fc.mode_context_a,
vp9_default_mode_contexts_a,
sizeof(pc->fc.mode_context_a));
}
void vp9_accum_mv_refs(VP9_COMMON *pc,
......@@ -494,11 +486,8 @@ void vp9_update_mode_context(VP9_COMMON *pc) {
int (*mv_ref_ct)[4][2];
int (*mode_context)[4];
if (pc->refresh_alt_ref_frame) {
mode_context = pc->fc.mode_context_a;
} else {
mode_context = pc->fc.mode_context;
}
mode_context = pc->fc.vp9_mode_contexts;
mv_ref_ct = pc->fc.mv_ref_ct;
for (j = 0; j < INTER_MODE_CONTEXTS; j++) {
......
......@@ -119,8 +119,6 @@ typedef struct frame_contexts {
vp9_prob pre_interintra_prob;
#endif
int mode_context[INTER_MODE_CONTEXTS][4];
int mode_context_a[INTER_MODE_CONTEXTS][4];
int vp9_mode_contexts[INTER_MODE_CONTEXTS][4];
int mv_ref_ct[INTER_MODE_CONTEXTS][4][2];
} FRAME_CONTEXT;
......
......@@ -861,12 +861,17 @@ static void init_frame(VP9D_COMP *pbi) {
pc->ref_frame_sign_bias[ALTREF_FRAME] = 0;
vp9_init_mode_contexts(&pbi->common);
vpx_memcpy(pbi->common.fc.vp9_mode_contexts,
vp9_default_mode_contexts,
sizeof(vp9_default_mode_contexts));
vpx_memcpy(&pc->lfc, &pc->fc, sizeof(pc->fc));
vpx_memcpy(&pc->lfc_a, &pc->fc, sizeof(pc->fc));
vpx_memcpy(pbi->common.fc.vp9_mode_contexts,
pbi->common.fc.mode_context,
sizeof(pbi->common.fc.mode_context));
vpx_memcpy(pbi->common.lfc.vp9_mode_contexts,
vp9_default_mode_contexts_a,
sizeof(vp9_default_mode_contexts_a));
vpx_memset(pc->prev_mip, 0,
(pc->mb_cols + 1) * (pc->mb_rows + 1)* sizeof(MODE_INFO));
vpx_memset(pc->mip, 0,
......@@ -1251,14 +1256,8 @@ int vp9_decode_frame(VP9D_COMP *pbi, const unsigned char **p_data_end) {
if (pc->refresh_alt_ref_frame) {
vpx_memcpy(&pc->fc, &pc->lfc_a, sizeof(pc->fc));
vpx_memcpy(pc->fc.vp9_mode_contexts,
pc->fc.mode_context_a,
sizeof(pc->fc.vp9_mode_contexts));
} else {
vpx_memcpy(&pc->fc, &pc->lfc, sizeof(pc->fc));
vpx_memcpy(pc->fc.vp9_mode_contexts,
pc->fc.mode_context,
sizeof(pc->fc.vp9_mode_contexts));
}
/* Buffer to buffer copy flags. */
......
......@@ -3748,7 +3748,6 @@ static void encode_frame_to_data_rate
cpi->NMVcount.joints[2], cpi->NMVcount.joints[3]);
*/
vp9_adapt_nmv_probs(&cpi->common, cpi->mb.e_mbd.allow_high_precision_mv);
vp9_update_mode_context(&cpi->common);
}
#if CONFIG_COMP_INTERINTRA_PRED
if (cm->frame_type != KEY_FRAME)
......
......@@ -127,8 +127,7 @@ typedef struct {
#endif
int mv_ref_ct[INTER_MODE_CONTEXTS][4][2];
int mode_context[INTER_MODE_CONTEXTS][4];
int mode_context_a[INTER_MODE_CONTEXTS][4];
int vp9_mode_contexts[INTER_MODE_CONTEXTS][4];
} CODING_CONTEXT;
......
......@@ -17,6 +17,7 @@
#include "math.h"
#include "vp9/common/vp9_alloccommon.h"
#include "vp9/common/vp9_modecont.h"
#include "vp9/common/vp9_common.h"
#include "vp9_ratectrl.h"
#include "vp9/common/vp9_entropymode.h"
......@@ -135,8 +136,7 @@ void vp9_save_coding_context(VP9_COMP *cpi) {
vp9_copy(cc->nmvcosts, cpi->mb.nmvcosts);
vp9_copy(cc->nmvcosts_hp, cpi->mb.nmvcosts_hp);
vp9_copy(cc->mode_context, cm->fc.mode_context);
vp9_copy(cc->mode_context_a, cm->fc.mode_context_a);
vp9_copy(cc->vp9_mode_contexts, cm->fc.vp9_mode_contexts);
vp9_copy(cc->ymode_prob, cm->fc.ymode_prob);
#if CONFIG_SUPERBLOCKS
......@@ -194,8 +194,7 @@ void vp9_restore_coding_context(VP9_COMP *cpi) {
vp9_copy(cpi->mb.nmvcosts, cc->nmvcosts);
vp9_copy(cpi->mb.nmvcosts_hp, cc->nmvcosts_hp);
vp9_copy(cm->fc.mode_context, cc->mode_context);
vp9_copy(cm->fc.mode_context_a, cc->mode_context_a);
vp9_copy(cm->fc.vp9_mode_contexts, cc->vp9_mode_contexts);
vp9_copy(cm->fc.ymode_prob, cc->ymode_prob);
#if CONFIG_SUPERBLOCKS
......@@ -262,9 +261,16 @@ void vp9_setup_key_frame(VP9_COMP *cpi) {
cpi->common.refresh_alt_ref_frame = TRUE;
vp9_init_mode_contexts(&cpi->common);
vpx_memcpy(cpi->common.fc.vp9_mode_contexts,
vp9_default_mode_contexts,
sizeof(vp9_default_mode_contexts));
vpx_memcpy(&cpi->common.lfc, &cpi->common.fc, sizeof(cpi->common.fc));
vpx_memcpy(&cpi->common.lfc_a, &cpi->common.fc, sizeof(cpi->common.fc));
vpx_memcpy(cpi->common.lfc.vp9_mode_contexts,
vp9_default_mode_contexts_a,
sizeof(vp9_default_mode_contexts_a));
vpx_memset(cm->prev_mip, 0,
(cm->mb_cols + 1) * (cm->mb_rows + 1)* sizeof(MODE_INFO));
vpx_memset(cm->mip, 0,
......@@ -279,16 +285,10 @@ void vp9_setup_inter_frame(VP9_COMP *cpi) {
vpx_memcpy(&cpi->common.fc,
&cpi->common.lfc_a,
sizeof(cpi->common.fc));
vpx_memcpy(cpi->common.fc.vp9_mode_contexts,
cpi->common.fc.mode_context_a,
sizeof(cpi->common.fc.vp9_mode_contexts));
} else {
vpx_memcpy(&cpi->common.fc,
&cpi->common.lfc,
sizeof(cpi->common.fc));
vpx_memcpy(cpi->common.fc.vp9_mode_contexts,
cpi->common.fc.mode_context,
sizeof(cpi->common.fc.vp9_mode_contexts));
}
}
......
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