| Index: source/libvpx/vp9/common/vp9_entropymv.c
|
| ===================================================================
|
| --- source/libvpx/vp9/common/vp9_entropymv.c (revision 223100)
|
| +++ source/libvpx/vp9/common/vp9_entropymv.c (working copy)
|
| @@ -79,20 +79,59 @@
|
|
|
| #define mv_class_base(c) ((c) ? (CLASS0_SIZE << (c + 2)) : 0)
|
|
|
| +static const uint8_t log_in_base_2[] = {
|
| + 0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4,
|
| + 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
|
| + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6,
|
| + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
|
| + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
|
| + 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
|
| + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
|
| + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
|
| + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
|
| + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
|
| + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7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9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
|
| + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
|
| + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
|
| + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
|
| + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
|
| + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10
|
| +};
|
| +
|
| MV_CLASS_TYPE vp9_get_mv_class(int z, int *offset) {
|
| MV_CLASS_TYPE c = MV_CLASS_0;
|
| - if (z < CLASS0_SIZE * 8) c = MV_CLASS_0;
|
| - else if (z < CLASS0_SIZE * 16) c = MV_CLASS_1;
|
| - else if (z < CLASS0_SIZE * 32) c = MV_CLASS_2;
|
| - else if (z < CLASS0_SIZE * 64) c = MV_CLASS_3;
|
| - else if (z < CLASS0_SIZE * 128) c = MV_CLASS_4;
|
| - else if (z < CLASS0_SIZE * 256) c = MV_CLASS_5;
|
| - else if (z < CLASS0_SIZE * 512) c = MV_CLASS_6;
|
| - else if (z < CLASS0_SIZE * 1024) c = MV_CLASS_7;
|
| - else if (z < CLASS0_SIZE * 2048) c = MV_CLASS_8;
|
| - else if (z < CLASS0_SIZE * 4096) c = MV_CLASS_9;
|
| - else if (z < CLASS0_SIZE * 8192) c = MV_CLASS_10;
|
| - else assert(0);
|
| + if (z >= CLASS0_SIZE * 4096)
|
| + c = MV_CLASS_10;
|
| + else
|
| + c = log_in_base_2[z >> 3];
|
| +
|
| if (offset)
|
| *offset = z - mv_class_base(c);
|
| return c;
|
| @@ -110,8 +149,6 @@
|
| static void inc_mv_component(int v, nmv_component_counts *comp_counts,
|
| int incr, int usehp) {
|
| int s, z, c, o, d, e, f;
|
| - if (!incr)
|
| - return;
|
| assert (v != 0); /* should not be zero */
|
| s = v < 0;
|
| comp_counts->sign[s] += incr;
|
| @@ -123,61 +160,39 @@
|
| d = (o >> 3); /* int mv data */
|
| f = (o >> 1) & 3; /* fractional pel mv data */
|
| e = (o & 1); /* high precision mv data */
|
| +
|
| if (c == MV_CLASS_0) {
|
| comp_counts->class0[d] += incr;
|
| + comp_counts->class0_fp[d][f] += incr;
|
| + comp_counts->class0_hp[e] += usehp * incr;
|
| } else {
|
| int i;
|
| int b = c + CLASS0_BITS - 1; // number of bits
|
| for (i = 0; i < b; ++i)
|
| comp_counts->bits[i][((d >> i) & 1)] += incr;
|
| - }
|
| -
|
| - /* Code the fractional pel bits */
|
| - if (c == MV_CLASS_0) {
|
| - comp_counts->class0_fp[d][f] += incr;
|
| - } else {
|
| comp_counts->fp[f] += incr;
|
| + comp_counts->hp[e] += usehp * incr;
|
| }
|
| -
|
| - /* Code the high precision bit */
|
| - if (usehp) {
|
| - if (c == MV_CLASS_0) {
|
| - comp_counts->class0_hp[e] += incr;
|
| - } else {
|
| - comp_counts->hp[e] += incr;
|
| - }
|
| - }
|
| }
|
|
|
| -static void counts_to_context(nmv_component_counts *mvcomp, int usehp) {
|
| - int v;
|
| - vpx_memset(mvcomp->sign, 0, sizeof(nmv_component_counts) - sizeof(mvcomp->mvcount));
|
| - for (v = 1; v <= MV_MAX; v++) {
|
| - inc_mv_component(-v, mvcomp, mvcomp->mvcount[MV_MAX - v], usehp);
|
| - inc_mv_component( v, mvcomp, mvcomp->mvcount[MV_MAX + v], usehp);
|
| - }
|
| -}
|
|
|
| void vp9_inc_mv(const MV *mv, nmv_context_counts *counts) {
|
| const MV_JOINT_TYPE j = vp9_get_mv_joint(mv);
|
| ++counts->joints[j];
|
|
|
| - if (mv_joint_vertical(j))
|
| - ++counts->comps[0].mvcount[MV_MAX + mv->row];
|
| + if (mv_joint_vertical(j)) {
|
| + inc_mv_component(mv->row, &counts->comps[0], 1, 1);
|
| + }
|
|
|
| - if (mv_joint_horizontal(j))
|
| - ++counts->comps[1].mvcount[MV_MAX + mv->col];
|
| + if (mv_joint_horizontal(j)) {
|
| + inc_mv_component(mv->col, &counts->comps[1], 1, 1);
|
| + }
|
| }
|
|
|
| static vp9_prob adapt_prob(vp9_prob prep, const unsigned int ct[2]) {
|
| return merge_probs2(prep, ct, MV_COUNT_SAT, MV_MAX_UPDATE_FACTOR);
|
| }
|
|
|
| -void vp9_counts_process(nmv_context_counts *nmv_count, int usehp) {
|
| - counts_to_context(&nmv_count->comps[0], usehp);
|
| - counts_to_context(&nmv_count->comps[1], usehp);
|
| -}
|
| -
|
| static unsigned int adapt_probs(unsigned int i,
|
| vp9_tree tree,
|
| vp9_prob this_probs[],
|
| @@ -207,8 +222,6 @@
|
| nmv_context *pre_ctx = &pre_fc->nmvc;
|
| nmv_context_counts *cts = &cm->counts.mv;
|
|
|
| - vp9_counts_process(cts, allow_hp);
|
| -
|
| adapt_probs(0, vp9_mv_joint_tree, ctx->joints, pre_ctx->joints, cts->joints);
|
|
|
| for (i = 0; i < 2; ++i) {
|
|
|