From 5f7fd7ab5e88ffd22f289cab4fb8cbf1f71b1ca9 Mon Sep 17 00:00:00 2001 From: "Nathan E. Egge" Date: Thu, 8 Sep 2016 11:22:03 -0400 Subject: [PATCH] Update joint_cdf table once per frame. Move computing the joint_cdf table per coded mv joint symbol to computing it only when the probabilities are updated. Change-Id: If5d195f70e6fad7b60f69606c8386ad5e69657d2 --- av1/common/entropymv.c | 9 ++++++++- av1/common/entropymv.h | 3 +++ av1/decoder/decodeframe.c | 3 +++ av1/decoder/decodemv.c | 4 ++++ av1/encoder/bitstream.c | 4 ++++ av1/encoder/encodemv.c | 4 ++++ 6 files changed, 26 insertions(+), 1 deletion(-) diff --git a/av1/common/entropymv.c b/av1/common/entropymv.c index 34918b3c1..b46f2da01 100644 --- a/av1/common/entropymv.c +++ b/av1/common/entropymv.c @@ -42,7 +42,10 @@ const aom_tree_index av1_mv_fp_tree[TREE_SIZE(MV_FP_SIZE)] = { -0, 2, -1, 4, -2, -3 }; static const nmv_context default_nmv_context = { - { 32, 64, 96 }, + { 32, 64, 96 }, // joints +#if CONFIG_DAALA_EC + { 0, 0, 0, 0 }, // joint_cdf is computed from joints in av1_init_mv_probs() +#endif { { // Vertical component 128, // sign @@ -262,6 +265,10 @@ void av1_init_mv_probs(AV1_COMMON *cm) { for (i = 0; i < NMV_CONTEXTS; ++i) cm->fc->nmvc[i] = default_nmv_context; #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); +#endif #endif #if CONFIG_GLOBAL_MOTION av1_copy(cm->fc->global_motion_types_prob, default_global_motion_types_prob); diff --git a/av1/common/entropymv.h b/av1/common/entropymv.h index f97dd85c3..803a44459 100644 --- a/av1/common/entropymv.h +++ b/av1/common/entropymv.h @@ -95,6 +95,9 @@ typedef struct { typedef struct { aom_prob joints[MV_JOINTS - 1]; +#if CONFIG_DAALA_EC + aom_cdf_prob joint_cdf[MV_JOINTS]; +#endif nmv_component comps[2]; } nmv_context; diff --git a/av1/decoder/decodeframe.c b/av1/decoder/decodeframe.c index fb36f35be..dec37f867 100644 --- a/av1/decoder/decodeframe.c +++ b/av1/decoder/decodeframe.c @@ -209,6 +209,9 @@ static void read_mv_probs(nmv_context *ctx, int allow_hp, aom_reader *r) { int i, j; update_mv_probs(ctx->joints, MV_JOINTS - 1, r); +#if CONFIG_DAALA_EC + av1_tree_to_cdf(av1_mv_joint_tree, ctx->joints, ctx->joint_cdf); +#endif for (i = 0; i < 2; ++i) { nmv_component *const comp_ctx = &ctx->comps[i]; diff --git a/av1/decoder/decodemv.c b/av1/decoder/decodemv.c index 3cfec4779..eb909f6ba 100644 --- a/av1/decoder/decodemv.c +++ b/av1/decoder/decodemv.c @@ -820,7 +820,11 @@ static INLINE void read_mv(aom_reader *r, MV *mv, const MV *ref, const int use_hp = allow_hp && av1_use_mv_hp(ref); MV diff = { 0, 0 }; joint_type = +#if CONFIG_DAALA_EC + (MV_JOINT_TYPE)aom_read_symbol(r, ctx->joint_cdf, MV_JOINTS, ACCT_STR); +#else (MV_JOINT_TYPE)aom_read_tree(r, av1_mv_joint_tree, ctx->joints, ACCT_STR); +#endif if (mv_joint_vertical(joint_type)) diff.row = read_mv_component(r, &ctx->comps[0], use_hp); diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c index 131cf79fd..5ae920b6f 100644 --- a/av1/encoder/bitstream.c +++ b/av1/encoder/bitstream.c @@ -3789,6 +3789,10 @@ static uint32_t write_compressed_header(AV1_COMP *cpi, uint8_t *data) { counts->mv); #else &counts->mv); +#endif +#if CONFIG_DAALA_EC + av1_tree_to_cdf(av1_mv_joint_tree, cm->fc->nmvc.joints, + cm->fc->nmvc.joint_cdf); #endif update_ext_tx_probs(cm, header_bc); #if CONFIG_SUPERTX diff --git a/av1/encoder/encodemv.c b/av1/encoder/encodemv.c index 7276fee68..5385d6b8d 100644 --- a/av1/encoder/encodemv.c +++ b/av1/encoder/encodemv.c @@ -239,7 +239,11 @@ void av1_encode_mv(AV1_COMP *cpi, aom_writer *w, const MV *mv, const MV *ref, #if CONFIG_REF_MV (void)is_compound; #endif +#if CONFIG_DAALA_EC + aom_write_symbol(w, j, mvctx->joint_cdf, MV_JOINTS); +#else av1_write_token(w, av1_mv_joint_tree, mvctx->joints, &mv_joint_encodings[j]); +#endif if (mv_joint_vertical(j)) encode_mv_component(w, diff.row, &mvctx->comps[0], usehp);