From: Yaowu Xu Date: Tue, 27 Nov 2012 20:41:59 +0000 (-0800) Subject: removed redundant mode_context data structures X-Git-Tag: v1.3.0~1217^2~58 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=12da793d001b0be5855c7a5741909f08fe387fa0;p=libvpx 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 --- diff --git a/vp9/common/vp9_entropymode.c b/vp9/common/vp9_entropymode.c index 69acbab02..0eb21ca82 100644 --- a/vp9/common/vp9_entropymode.c +++ b/vp9/common/vp9_entropymode.c @@ -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++) { diff --git a/vp9/common/vp9_onyxc_int.h b/vp9/common/vp9_onyxc_int.h index 18750e767..4819833fb 100644 --- a/vp9/common/vp9_onyxc_int.h +++ b/vp9/common/vp9_onyxc_int.h @@ -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; diff --git a/vp9/decoder/vp9_decodframe.c b/vp9/decoder/vp9_decodframe.c index c08332351..2c456658d 100644 --- a/vp9/decoder/vp9_decodframe.c +++ b/vp9/decoder/vp9_decodframe.c @@ -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. */ diff --git a/vp9/encoder/vp9_onyx_if.c b/vp9/encoder/vp9_onyx_if.c index ec9f14e8a..4bf39105b 100644 --- a/vp9/encoder/vp9_onyx_if.c +++ b/vp9/encoder/vp9_onyx_if.c @@ -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) diff --git a/vp9/encoder/vp9_onyx_int.h b/vp9/encoder/vp9_onyx_int.h index 8cb77c352..b01cf2125 100644 --- a/vp9/encoder/vp9_onyx_int.h +++ b/vp9/encoder/vp9_onyx_int.h @@ -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; diff --git a/vp9/encoder/vp9_ratectrl.c b/vp9/encoder/vp9_ratectrl.c index ab9dc71c8..0ceb4f653 100644 --- a/vp9/encoder/vp9_ratectrl.c +++ b/vp9/encoder/vp9_ratectrl.c @@ -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)); } }