Commit b6724815 authored by Nathan E. Egge's avatar Nathan E. Egge Committed by Nathan Egge

Update class0_fp_cdf and fp_cdf tables once per frame.

Move computing the class0_fp_cdf and fp_cdf tables per coded mv
 symbol to computing it only when the probabilities are updated.

Change-Id: Ib4957c8ab21e6189bcc3817a07b7681dfb343223
parent 98712c08
......@@ -57,6 +57,10 @@ static const nmv_context default_nmv_context = {
{ 136, 140, 148, 160, 176, 192, 224, 234, 234, 240 }, // bits
{ { 128, 128, 64 }, { 96, 112, 64 } }, // class0_fp
{ 64, 96, 64 }, // fp
#if CONFIG_DAALA_EC
{ { 0 }, { 0 } }, // class0_fp_cdf is computed in av1_init_mv_probs()
{ 0 }, // fp_cdf is computed from fp in av1_init_mv_probs()
#endif
160, // class0_hp bit
128, // hp
},
......@@ -71,6 +75,10 @@ static const nmv_context default_nmv_context = {
{ 136, 140, 148, 160, 176, 192, 224, 234, 234, 240 }, // bits
{ { 128, 128, 64 }, { 96, 112, 64 } }, // class0_fp
{ 64, 96, 64 }, // fp
#if CONFIG_DAALA_EC
{ { 0 }, { 0 } }, // class0_fp_cdf is computed in av1_init_mv_probs()
{ 0 }, // fp_cdf is computed from fp in av1_init_mv_probs()
#endif
160, // class0_hp bit
128, // hp
} },
......@@ -269,12 +277,21 @@ void av1_init_mv_probs(AV1_COMMON *cm) {
#else
cm->fc->nmvc = default_nmv_context;
#if CONFIG_DAALA_EC
av1_tree_to_cdf(av1_mv_joint_tree, cm->fc->nmvc.joints,
cm->fc->nmvc.joint_cdf);
av1_tree_to_cdf(av1_mv_class_tree, cm->fc->nmvc.comps[0].classes,
cm->fc->nmvc.comps[0].class_cdf);
av1_tree_to_cdf(av1_mv_class_tree, cm->fc->nmvc.comps[1].classes,
cm->fc->nmvc.comps[1].class_cdf);
{
int i, j;
av1_tree_to_cdf(av1_mv_joint_tree, cm->fc->nmvc.joints,
cm->fc->nmvc.joint_cdf);
for (i = 0; i < 2; i++) {
av1_tree_to_cdf(av1_mv_class_tree, cm->fc->nmvc.comps[i].classes,
cm->fc->nmvc.comps[i].class_cdf);
av1_tree_to_cdf(av1_mv_fp_tree, cm->fc->nmvc.comps[i].fp,
cm->fc->nmvc.comps[i].fp_cdf);
for (j = 0; j < CLASS0_SIZE; j++) {
av1_tree_to_cdf(av1_mv_fp_tree, cm->fc->nmvc.comps[i].class0_fp[j],
cm->fc->nmvc.comps[i].class0_fp_cdf[j]);
}
}
}
#endif
#endif
}
......@@ -92,6 +92,10 @@ typedef struct {
aom_prob bits[MV_OFFSET_BITS];
aom_prob class0_fp[CLASS0_SIZE][MV_FP_SIZE - 1];
aom_prob fp[MV_FP_SIZE - 1];
#if CONFIG_DAALA_EC
aom_cdf_prob class0_fp_cdf[CLASS0_SIZE][MV_FP_SIZE];
aom_cdf_prob fp_cdf[MV_FP_SIZE];
#endif
aom_prob class0_hp;
aom_prob hp;
} nmv_component;
......
......@@ -247,9 +247,17 @@ static void read_mv_probs(nmv_context *ctx, int allow_hp, aom_reader *r) {
for (i = 0; i < 2; ++i) {
nmv_component *const comp_ctx = &ctx->comps[i];
for (j = 0; j < CLASS0_SIZE; ++j)
for (j = 0; j < CLASS0_SIZE; ++j) {
update_mv_probs(comp_ctx->class0_fp[j], MV_FP_SIZE - 1, r);
#if CONFIG_DAALA_EC
av1_tree_to_cdf(av1_mv_fp_tree, comp_ctx->class0_fp[j],
comp_ctx->class0_fp_cdf[j]);
#endif
}
update_mv_probs(comp_ctx->fp, MV_FP_SIZE - 1, r);
#if CONFIG_DAALA_EC
av1_tree_to_cdf(av1_mv_fp_tree, comp_ctx->fp, comp_ctx->fp_cdf);
#endif
}
if (allow_hp) {
......
......@@ -569,8 +569,13 @@ static int read_mv_component(aom_reader *r, const nmv_component *mvcomp,
}
// Fractional part
#if CONFIG_DAALA_EC
fr = aom_read_symbol(r, class0 ? mvcomp->class0_fp_cdf[d] : mvcomp->fp_cdf,
MV_FP_SIZE, ACCT_STR);
#else
fr = aom_read_tree(r, av1_mv_fp_tree,
class0 ? mvcomp->class0_fp[d] : mvcomp->fp, ACCT_STR);
#endif
// High precision part (if hp is not used, the default value of the hp is 1)
hp = usehp ? aom_read(r, class0 ? mvcomp->class0_hp : mvcomp->hp, ACCT_STR)
......
......@@ -63,9 +63,15 @@ static void encode_mv_component(aom_writer *w, int comp,
}
// Fractional bits
#if CONFIG_DAALA_EC
aom_write_symbol(
w, fr, mv_class == MV_CLASS_0 ? mvcomp->class0_fp_cdf[d] : mvcomp->fp_cdf,
MV_FP_SIZE);
#else
av1_write_token(w, av1_mv_fp_tree,
mv_class == MV_CLASS_0 ? mvcomp->class0_fp[d] : mvcomp->fp,
&mv_fp_encodings[fr]);
#endif
// High precision bit
if (usehp)
......@@ -228,12 +234,19 @@ void av1_write_nmv_probs(AV1_COMMON *cm, int usehp, aom_writer *w,
}
for (i = 0; i < 2; ++i) {
for (j = 0; j < CLASS0_SIZE; ++j)
for (j = 0; j < CLASS0_SIZE; ++j) {
write_mv_update(av1_mv_fp_tree, mvc->comps[i].class0_fp[j],
counts->comps[i].class0_fp[j], MV_FP_SIZE, w);
#if CONFIG_DAALA_EC
av1_tree_to_cdf(av1_mv_fp_tree, mvc->comps[i].class0_fp[j],
mvc->comps[i].class0_fp_cdf[j]);
#endif
}
write_mv_update(av1_mv_fp_tree, mvc->comps[i].fp, counts->comps[i].fp,
MV_FP_SIZE, w);
#if CONFIG_DAALA_EC
av1_tree_to_cdf(av1_mv_fp_tree, mvc->comps[i].fp, mvc->comps[i].fp_cdf);
#endif
}
if (usehp) {
......
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