Commit 98712c08 authored by Nathan E. Egge's avatar Nathan E. Egge Committed by Nathan Egge

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 924f7eea
...@@ -50,6 +50,9 @@ static const nmv_context default_nmv_context = { ...@@ -50,6 +50,9 @@ static const nmv_context default_nmv_context = {
// Vertical component // Vertical component
128, // sign 128, // sign
{ 224, 144, 192, 168, 192, 176, 192, 198, 198, 245 }, // class { 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 { 216 }, // class0
{ 136, 140, 148, 160, 176, 192, 224, 234, 234, 240 }, // bits { 136, 140, 148, 160, 176, 192, 224, 234, 234, 240 }, // bits
{ { 128, 128, 64 }, { 96, 112, 64 } }, // class0_fp { { 128, 128, 64 }, { 96, 112, 64 } }, // class0_fp
...@@ -61,6 +64,9 @@ static const nmv_context default_nmv_context = { ...@@ -61,6 +64,9 @@ static const nmv_context default_nmv_context = {
// Horizontal component // Horizontal component
128, // sign 128, // sign
{ 216, 128, 176, 160, 176, 176, 192, 198, 198, 208 }, // class { 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 { 208 }, // class0
{ 136, 140, 148, 160, 176, 192, 224, 234, 234, 240 }, // bits { 136, 140, 148, 160, 176, 192, 224, 234, 234, 240 }, // bits
{ { 128, 128, 64 }, { 96, 112, 64 } }, // class0_fp { { 128, 128, 64 }, { 96, 112, 64 } }, // class0_fp
...@@ -265,6 +271,10 @@ void av1_init_mv_probs(AV1_COMMON *cm) { ...@@ -265,6 +271,10 @@ void av1_init_mv_probs(AV1_COMMON *cm) {
#if CONFIG_DAALA_EC #if CONFIG_DAALA_EC
av1_tree_to_cdf(av1_mv_joint_tree, cm->fc->nmvc.joints, av1_tree_to_cdf(av1_mv_joint_tree, cm->fc->nmvc.joints,
cm->fc->nmvc.joint_cdf); 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
#endif #endif
} }
...@@ -85,6 +85,9 @@ extern const aom_tree_index av1_mv_fp_tree[]; ...@@ -85,6 +85,9 @@ extern const aom_tree_index av1_mv_fp_tree[];
typedef struct { typedef struct {
aom_prob sign; aom_prob sign;
aom_prob classes[MV_CLASSES - 1]; 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 class0[CLASS0_SIZE - 1];
aom_prob bits[MV_OFFSET_BITS]; aom_prob bits[MV_OFFSET_BITS];
aom_prob class0_fp[CLASS0_SIZE][MV_FP_SIZE - 1]; aom_prob class0_fp[CLASS0_SIZE][MV_FP_SIZE - 1];
......
...@@ -240,6 +240,9 @@ static void read_mv_probs(nmv_context *ctx, int allow_hp, aom_reader *r) { ...@@ -240,6 +240,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->classes, MV_CLASSES - 1, r);
update_mv_probs(comp_ctx->class0, CLASS0_SIZE - 1, r); update_mv_probs(comp_ctx->class0, CLASS0_SIZE - 1, r);
update_mv_probs(comp_ctx->bits, MV_OFFSET_BITS, 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) { for (i = 0; i < 2; ++i) {
......
...@@ -548,7 +548,11 @@ static int read_mv_component(aom_reader *r, const nmv_component *mvcomp, ...@@ -548,7 +548,11 @@ static int read_mv_component(aom_reader *r, const nmv_component *mvcomp,
int mag, d, fr, hp; int mag, d, fr, hp;
const int sign = aom_read(r, mvcomp->sign, ACCT_STR); const int sign = aom_read(r, mvcomp->sign, ACCT_STR);
const int mv_class = 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); aom_read_tree(r, av1_mv_class_tree, mvcomp->classes, ACCT_STR);
#endif
const int class0 = mv_class == MV_CLASS_0; const int class0 = mv_class == MV_CLASS_0;
// Integer part // Integer part
......
...@@ -46,8 +46,12 @@ static void encode_mv_component(aom_writer *w, int comp, ...@@ -46,8 +46,12 @@ static void encode_mv_component(aom_writer *w, int comp,
aom_write(w, sign, mvcomp->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, av1_write_token(w, av1_mv_class_tree, mvcomp->classes,
&mv_class_encodings[mv_class]); &mv_class_encodings[mv_class]);
#endif
// Integer bits // Integer bits
if (mv_class == MV_CLASS_0) { if (mv_class == MV_CLASS_0) {
...@@ -214,6 +218,9 @@ void av1_write_nmv_probs(AV1_COMMON *cm, int usehp, aom_writer *w, ...@@ -214,6 +218,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); update_mv(w, comp_counts->sign, &comp->sign, MV_UPDATE_PROB);
write_mv_update(av1_mv_class_tree, comp->classes, comp_counts->classes, write_mv_update(av1_mv_class_tree, comp->classes, comp_counts->classes,
MV_CLASSES, w); 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, write_mv_update(av1_mv_class0_tree, comp->class0, comp_counts->class0,
CLASS0_SIZE, w); CLASS0_SIZE, w);
for (j = 0; j < MV_OFFSET_BITS; ++j) 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