Removes duplication of key frame mode probabilities

Key frame macrobock and block mode probabilities are constant.
Remove the allocation of tables for each codec instance and use
instead the default const prob tables.

Change-Id: I8361798ac491f9b3889e86925a494c58647c753f
This commit is contained in:
Attila Nagy 2012-04-23 12:53:30 +03:00
parent abf1784c31
commit f4126995b7
9 changed files with 19 additions and 39 deletions

View File

@ -160,9 +160,7 @@ const vp8_tree_index vp8_small_mvtree [14] =
void vp8_init_mbmode_probs(VP8_COMMON *x)
{
vpx_memcpy(x->fc.ymode_prob, vp8_ymode_prob, sizeof(vp8_ymode_prob));
vpx_memcpy(x->kf_ymode_prob, kf_ymode_prob, sizeof(kf_ymode_prob));
vpx_memcpy(x->fc.uv_mode_prob, vp8_uv_mode_prob, sizeof(vp8_uv_mode_prob));
vpx_memcpy(x->kf_uv_mode_prob, vp8_kf_uv_mode_prob, sizeof(vp8_kf_uv_mode_prob));
vpx_memcpy(x->fc.sub_mv_ref_prob, sub_mv_ref_prob, sizeof(sub_mv_ref_prob));
}
@ -171,7 +169,4 @@ void vp8_default_bmode_probs(vp8_prob p [VP8_BINTRAMODES-1])
vpx_memcpy(p, vp8_bmode_prob, sizeof(vp8_bmode_prob));
}
void vp8_kf_default_bmode_probs(vp8_prob p [VP8_BINTRAMODES] [VP8_BINTRAMODES] [VP8_BINTRAMODES-1])
{
vpx_memcpy(p, vp8_kf_bmode_prob, sizeof(vp8_kf_bmode_prob));
}

View File

@ -67,9 +67,15 @@ extern const vp8_tree_index vp8_small_mvtree[];
extern const struct vp8_token_struct vp8_small_mvencodings[8];
void vp8_init_mbmode_probs(VP8_COMMON *x);
/* Key frame default mode probs */
extern const vp8_prob vp8_kf_bmode_prob[VP8_BINTRAMODES][VP8_BINTRAMODES]
[VP8_BINTRAMODES-1];
extern const vp8_prob vp8_kf_uv_mode_prob[VP8_UV_MODES-1];
extern const vp8_prob vp8_kf_ymode_prob[VP8_YMODES-1];
void vp8_default_bmode_probs(vp8_prob dest [VP8_BINTRAMODES-1]);
void vp8_init_mbmode_probs(VP8_COMMON *x);
void vp8_default_bmode_probs(vp8_prob dest [VP8_BINTRAMODES-1]);
void vp8_kf_default_bmode_probs(vp8_prob dest [VP8_BINTRAMODES] [VP8_BINTRAMODES] [VP8_BINTRAMODES-1]);
#endif

View File

@ -158,14 +158,6 @@ typedef struct VP8Common
ENTROPY_CONTEXT_PLANES *above_context; /* row of context for each plane */
ENTROPY_CONTEXT_PLANES left_context; /* (up to) 4 contexts "" */
/* keyframe block modes are predicted by their above, left neighbors */
vp8_prob kf_bmode_prob [VP8_BINTRAMODES] [VP8_BINTRAMODES] [VP8_BINTRAMODES-1];
vp8_prob kf_ymode_prob [VP8_YMODES-1]; /* keyframe "" */
vp8_prob kf_uv_mode_prob [VP8_UV_MODES-1];
FRAME_CONTEXT lfc; /* last frame entropy */
FRAME_CONTEXT fc; /* this frame entropy */

View File

@ -94,7 +94,7 @@ const vp8_prob vp8_ymode_prob[VP8_YMODES-1] =
112, 86, 140, 37
};
const vp8_prob kf_ymode_prob[VP8_YMODES-1] =
const vp8_prob vp8_kf_ymode_prob[VP8_YMODES-1] =
{
145, 156, 163, 128
};

View File

@ -52,7 +52,7 @@ static void read_kf_modes(VP8D_COMP *pbi, MODE_INFO *mi)
const int mis = pbi->common.mode_info_stride;
mi->mbmi.ref_frame = INTRA_FRAME;
mi->mbmi.mode = read_kf_ymode(bc, pbi->common.kf_ymode_prob);
mi->mbmi.mode = read_kf_ymode(bc, vp8_kf_ymode_prob);
if (mi->mbmi.mode == B_PRED)
{
@ -65,12 +65,12 @@ static void read_kf_modes(VP8D_COMP *pbi, MODE_INFO *mi)
const B_PREDICTION_MODE L = left_block_mode(mi, i);
mi->bmi[i].as_mode =
read_bmode(bc, pbi->common.kf_bmode_prob [A] [L]);
read_bmode(bc, vp8_kf_bmode_prob [A] [L]);
}
while (++i < 16);
}
mi->mbmi.uv_mode = read_uv_mode(bc, pbi->common.kf_uv_mode_prob);
mi->mbmi.uv_mode = read_uv_mode(bc, vp8_kf_uv_mode_prob);
}
static int read_mvcomponent(vp8_reader *r, const MV_CONTEXT *mvc)

View File

@ -661,7 +661,6 @@ static void init_frame(VP8D_COMP *pbi)
vp8_init_mbmode_probs(pc);
vp8_default_coef_probs(pc);
vp8_kf_default_bmode_probs(pc->kf_bmode_prob);
/* reset the segment feature data to 0 with delta coding (Default state). */
vpx_memset(xd->segment_feature_data, 0, sizeof(xd->segment_feature_data));

View File

@ -755,7 +755,7 @@ static void write_kfmodes(VP8_COMP *cpi)
if (c->mb_no_coeff_skip)
vp8_encode_bool(bc, m->mbmi.mb_skip_coeff, prob_skip_false);
kfwrite_ymode(bc, ym, c->kf_ymode_prob);
kfwrite_ymode(bc, ym, vp8_kf_ymode_prob);
if (ym == B_PRED)
{
@ -772,12 +772,12 @@ static void write_kfmodes(VP8_COMP *cpi)
++intra_mode_stats [A] [L] [bm];
#endif
write_bmode(bc, bm, c->kf_bmode_prob [A] [L]);
write_bmode(bc, bm, vp8_kf_bmode_prob [A] [L]);
}
while (++i < 16);
}
write_uv_mode(bc, (m++)->mbmi.uv_mode, c->kf_uv_mode_prob);
write_uv_mode(bc, (m++)->mbmi.uv_mode, vp8_kf_uv_mode_prob);
}
m++; // skip L prediction border
@ -1296,11 +1296,6 @@ void vp8_pack_bitstream(VP8_COMP *cpi, unsigned char *dest, unsigned char * dest
Sectionbits[active_section = 1] += sizeof(VP8_HEADER) * 8 * 256;
#endif
//vp8_kf_default_bmode_probs() is called in vp8_setup_key_frame() once for each
//K frame before encode frame. pc->kf_bmode_prob doesn't get changed anywhere
//else. No need to call it again here. --yw
//vp8_kf_default_bmode_probs( pc->kf_bmode_prob);
// every keyframe send startcode, width, height, scale factor, clamp and color type
if (oh.type == KEY_FRAME)
{

View File

@ -29,7 +29,7 @@ void vp8_init_mode_costs(VP8_COMP *c)
do
{
vp8_cost_tokens((int *)c->mb.bmode_costs[i][j], x->kf_bmode_prob[i][j], T);
vp8_cost_tokens((int *)c->mb.bmode_costs[i][j], vp8_kf_bmode_prob[i][j], T);
}
while (++j < VP8_BINTRAMODES);
}
@ -40,8 +40,8 @@ void vp8_init_mode_costs(VP8_COMP *c)
vp8_cost_tokens((int *)c->mb.inter_bmode_costs, x->fc.sub_mv_ref_prob, vp8_sub_mv_ref_tree);
vp8_cost_tokens(c->mb.mbmode_cost[1], x->fc.ymode_prob, vp8_ymode_tree);
vp8_cost_tokens(c->mb.mbmode_cost[0], x->kf_ymode_prob, vp8_kf_ymode_tree);
vp8_cost_tokens(c->mb.mbmode_cost[0], vp8_kf_ymode_prob, vp8_kf_ymode_tree);
vp8_cost_tokens(c->mb.intra_uv_mode_cost[1], x->fc.uv_mode_prob, vp8_uv_mode_tree);
vp8_cost_tokens(c->mb.intra_uv_mode_cost[0], x->kf_uv_mode_prob, vp8_uv_mode_tree);
vp8_cost_tokens(c->mb.intra_uv_mode_cost[0], vp8_kf_uv_mode_prob, vp8_uv_mode_tree);
}

View File

@ -237,9 +237,7 @@ void vp8_save_coding_context(VP8_COMP *cpi)
vp8_copy(cc->mvc, cpi->common.fc.mvc);
vp8_copy(cc->mvcosts, cpi->mb.mvcosts);
vp8_copy(cc->kf_ymode_prob, cpi->common.kf_ymode_prob);
vp8_copy(cc->ymode_prob, cpi->common.fc.ymode_prob);
vp8_copy(cc->kf_uv_mode_prob, cpi->common.kf_uv_mode_prob);
vp8_copy(cc->uv_mode_prob, cpi->common.fc.uv_mode_prob);
vp8_copy(cc->ymode_count, cpi->ymode_count);
@ -276,9 +274,7 @@ void vp8_restore_coding_context(VP8_COMP *cpi)
vp8_copy(cpi->mb.mvcosts, cc->mvcosts);
vp8_copy(cpi->common.kf_ymode_prob, cc->kf_ymode_prob);
vp8_copy(cpi->common.fc.ymode_prob, cc->ymode_prob);
vp8_copy(cpi->common.kf_uv_mode_prob, cc->kf_uv_mode_prob);
vp8_copy(cpi->common.fc.uv_mode_prob, cc->uv_mode_prob);
vp8_copy(cpi->ymode_count, cc->ymode_count);
@ -305,9 +301,6 @@ void vp8_setup_key_frame(VP8_COMP *cpi)
vp8_default_coef_probs(& cpi->common);
vp8_kf_default_bmode_probs(cpi->common.kf_bmode_prob);
vpx_memcpy(cpi->common.fc.mvc, vp8_default_mv_context, sizeof(vp8_default_mv_context));
{
int flag[2] = {1, 1};