diff --git a/av1/common/entropymv.c b/av1/common/entropymv.c index 803f241e2d4f2f3447b4b2e9c3e63a9e2031a825..28cc4a4923298745bae8dceb93ea3248781fa1d5 100644 --- a/av1/common/entropymv.c +++ b/av1/common/entropymv.c @@ -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 @@ -265,6 +271,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 } diff --git a/av1/common/entropymv.h b/av1/common/entropymv.h index 4023d6216f4f4aa7dad169da10b82be63eea0058..4679101c0249d483f42bd0a5f59d98e98b3ce333 100644 --- a/av1/common/entropymv.h +++ b/av1/common/entropymv.h @@ -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]; diff --git a/av1/decoder/decodeframe.c b/av1/decoder/decodeframe.c index be7b6d530e9aaa4887254ce5f0bd37e1a6c5a033..bd420cf820b063611e94633252aff2ff1ad6603f 100644 --- a/av1/decoder/decodeframe.c +++ b/av1/decoder/decodeframe.c @@ -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->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) { diff --git a/av1/decoder/decodemv.c b/av1/decoder/decodemv.c index b4d641dbf125c87531fb85891c9339032d6b08f6..eab46210c2fead2a945342347099f501cb34d3ba 100644 --- a/av1/decoder/decodemv.c +++ b/av1/decoder/decodemv.c @@ -548,7 +548,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 diff --git a/av1/encoder/encodemv.c b/av1/encoder/encodemv.c index dd00e400348e8b964245a55396873db7e9841aad..cc2da763b56ee6f26f4161a04d20436930d75440 100644 --- a/av1/encoder/encodemv.c +++ b/av1/encoder/encodemv.c @@ -46,8 +46,12 @@ static void encode_mv_component(aom_writer *w, int comp, aom_write(w, sign, mvcomp->sign); // 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) { @@ -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); 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)