Commit d7b893c6 authored by Nathan E. Egge's avatar Nathan E. Egge Committed by Yaowu Xu

Update class_cdf table once per frame.

Move computing the class_cdf table per coded mv class symbol to
 computing it only when the probabilities are updated.

Change-Id: I6c4a9075817e8ba2e251f0e82436995f08f2ec5c
parent 5f7fd7ab
......@@ -50,6 +50,9 @@ static const nmv_context default_nmv_context = {
// Vertical component
128, // sign
{ 224, 144, 192, 168, 192, 176, 192, 198, 198, 245 }, // class
#if CONFIG_DAALA_EC
{ 0 }, // class_cdf is computed from class in av1_init_mv_probs()
#endif
{ 216 }, // class0
{ 136, 140, 148, 160, 176, 192, 224, 234, 234, 240 }, // bits
{ { 128, 128, 64 }, { 96, 112, 64 } }, // class0_fp
......@@ -61,6 +64,9 @@ static const nmv_context default_nmv_context = {
// Horizontal component
128, // sign
{ 216, 128, 176, 160, 176, 176, 192, 198, 198, 208 }, // class
#if CONFIG_DAALA_EC
{ 0 }, // class_cdf is computed from class in av1_init_mv_probs()
#endif
{ 208 }, // class0
{ 136, 140, 148, 160, 176, 192, 224, 234, 234, 240 }, // bits
{ { 128, 128, 64 }, { 96, 112, 64 } }, // class0_fp
......@@ -268,6 +274,10 @@ void av1_init_mv_probs(AV1_COMMON *cm) {
#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);
#endif
#endif
#if CONFIG_GLOBAL_MOTION
......
......@@ -85,6 +85,9 @@ extern const aom_tree_index av1_mv_fp_tree[];
typedef struct {
aom_prob sign;
aom_prob classes[MV_CLASSES - 1];
#if CONFIG_DAALA_EC
aom_cdf_prob class_cdf[MV_CLASSES];
#endif
aom_prob class0[CLASS0_SIZE - 1];
aom_prob bits[MV_OFFSET_BITS];
aom_prob class0_fp[CLASS0_SIZE][MV_FP_SIZE - 1];
......
......@@ -219,6 +219,9 @@ static void read_mv_probs(nmv_context *ctx, int allow_hp, aom_reader *r) {
update_mv_probs(comp_ctx->classes, MV_CLASSES - 1, r);
update_mv_probs(comp_ctx->class0, CLASS0_SIZE - 1, r);
update_mv_probs(comp_ctx->bits, MV_OFFSET_BITS, r);
#if CONFIG_DAALA_EC
av1_tree_to_cdf(av1_mv_class_tree, comp_ctx->classes, comp_ctx->class_cdf);
#endif
}
for (i = 0; i < 2; ++i) {
......
......@@ -784,7 +784,11 @@ static int read_mv_component(aom_reader *r, const nmv_component *mvcomp,
int mag, d, fr, hp;
const int sign = aom_read(r, mvcomp->sign, ACCT_STR);
const int mv_class =
#if CONFIG_DAALA_EC
aom_read_symbol(r, mvcomp->class_cdf, MV_CLASSES, ACCT_STR);
#else
aom_read_tree(r, av1_mv_class_tree, mvcomp->classes, ACCT_STR);
#endif
const int class0 = mv_class == MV_CLASS_0;
// Integer part
......
......@@ -45,9 +45,13 @@ static void encode_mv_component(aom_writer *w, int comp,
// Sign
aom_write(w, sign, mvcomp->sign);
// Class
// Class
#if CONFIG_DAALA_EC
aom_write_symbol(w, mv_class, mvcomp->class_cdf, MV_CLASSES);
#else
av1_write_token(w, av1_mv_class_tree, mvcomp->classes,
&mv_class_encodings[mv_class]);
#endif
// Integer bits
if (mv_class == MV_CLASS_0) {
......@@ -203,6 +207,9 @@ void av1_write_nmv_probs(AV1_COMMON *cm, int usehp, aom_writer *w,
update_mv(w, comp_counts->sign, &comp->sign, MV_UPDATE_PROB);
write_mv_update(av1_mv_class_tree, comp->classes, comp_counts->classes,
MV_CLASSES, w);
#if CONFIG_DAALA_EC
av1_tree_to_cdf(av1_mv_class_tree, comp->classes, comp->class_cdf);
#endif
write_mv_update(av1_mv_class0_tree, comp->class0, comp_counts->class0,
CLASS0_SIZE, w);
for (j = 0; j < MV_OFFSET_BITS; ++j)
......
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