2010-05-18 17:58:33 +02:00
|
|
|
/*
|
2010-09-09 14:16:39 +02:00
|
|
|
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
2010-05-18 17:58:33 +02:00
|
|
|
*
|
2010-06-18 18:39:21 +02:00
|
|
|
* Use of this source code is governed by a BSD-style license
|
2010-06-04 22:19:40 +02:00
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
2010-06-18 18:39:21 +02:00
|
|
|
* in the file PATENTS. All contributing project authors may
|
2010-06-04 22:19:40 +02:00
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
2010-05-18 17:58:33 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2012-11-28 19:41:40 +01:00
|
|
|
#include "vp9/common/vp9_onyxc_int.h"
|
|
|
|
#include "vp9/common/vp9_entropymv.h"
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-07-26 22:42:07 +02:00
|
|
|
//#define MV_COUNT_TESTING
|
|
|
|
|
2013-06-10 21:00:43 +02:00
|
|
|
#define MV_COUNT_SAT 20
|
|
|
|
#define MV_MAX_UPDATE_FACTOR 128
|
2012-07-26 22:42:07 +02:00
|
|
|
|
2012-09-06 18:07:42 +02:00
|
|
|
/* Integer pel reference mv threshold for use of high-precision 1/8 mv */
|
|
|
|
#define COMPANDED_MVREF_THRESH 8
|
|
|
|
|
2012-07-26 22:42:07 +02:00
|
|
|
/* Smooth or bias the mv-counts before prob computation */
|
|
|
|
/* #define SMOOTH_MV_COUNTS */
|
|
|
|
|
2012-10-31 22:40:53 +01:00
|
|
|
const vp9_tree_index vp9_mv_joint_tree[2 * MV_JOINTS - 2] = {
|
2012-07-26 22:42:07 +02:00
|
|
|
-MV_JOINT_ZERO, 2,
|
|
|
|
-MV_JOINT_HNZVZ, 4,
|
|
|
|
-MV_JOINT_HZVNZ, -MV_JOINT_HNZVNZ
|
|
|
|
};
|
2013-04-11 22:01:52 +02:00
|
|
|
struct vp9_token vp9_mv_joint_encodings[MV_JOINTS];
|
2012-07-26 22:42:07 +02:00
|
|
|
|
2012-10-31 22:40:53 +01:00
|
|
|
const vp9_tree_index vp9_mv_class_tree[2 * MV_CLASSES - 2] = {
|
2012-07-26 22:42:07 +02:00
|
|
|
-MV_CLASS_0, 2,
|
|
|
|
-MV_CLASS_1, 4,
|
|
|
|
6, 8,
|
|
|
|
-MV_CLASS_2, -MV_CLASS_3,
|
|
|
|
10, 12,
|
|
|
|
-MV_CLASS_4, -MV_CLASS_5,
|
2013-03-12 05:51:00 +01:00
|
|
|
-MV_CLASS_6, 14,
|
|
|
|
16, 18,
|
|
|
|
-MV_CLASS_7, -MV_CLASS_8,
|
|
|
|
-MV_CLASS_9, -MV_CLASS_10,
|
2012-07-26 22:42:07 +02:00
|
|
|
};
|
2013-04-11 22:01:52 +02:00
|
|
|
struct vp9_token vp9_mv_class_encodings[MV_CLASSES];
|
2012-07-26 22:42:07 +02:00
|
|
|
|
2012-10-31 22:40:53 +01:00
|
|
|
const vp9_tree_index vp9_mv_class0_tree [2 * CLASS0_SIZE - 2] = {
|
2012-07-26 22:42:07 +02:00
|
|
|
-0, -1,
|
|
|
|
};
|
2013-04-11 22:01:52 +02:00
|
|
|
struct vp9_token vp9_mv_class0_encodings[CLASS0_SIZE];
|
2012-07-26 22:42:07 +02:00
|
|
|
|
2012-10-31 22:40:53 +01:00
|
|
|
const vp9_tree_index vp9_mv_fp_tree [2 * 4 - 2] = {
|
2012-07-26 22:42:07 +02:00
|
|
|
-0, 2,
|
|
|
|
-1, 4,
|
|
|
|
-2, -3
|
|
|
|
};
|
2013-04-11 22:01:52 +02:00
|
|
|
struct vp9_token vp9_mv_fp_encodings[4];
|
2012-07-26 22:42:07 +02:00
|
|
|
|
2012-10-31 01:12:12 +01:00
|
|
|
const nmv_context vp9_default_nmv_context = {
|
2012-07-26 22:42:07 +02:00
|
|
|
{32, 64, 96},
|
|
|
|
{
|
|
|
|
{ /* vert component */
|
2013-03-12 05:51:00 +01:00
|
|
|
128, /* sign */
|
|
|
|
{224, 144, 192, 168, 192, 176, 192, 198, 198, 245}, /* class */
|
|
|
|
{216}, /* class0 */
|
|
|
|
{136, 140, 148, 160, 176, 192, 224, 234, 234, 240}, /* bits */
|
|
|
|
{{128, 128, 64}, {96, 112, 64}}, /* class0_fp */
|
|
|
|
{64, 96, 64}, /* fp */
|
|
|
|
160, /* class0_hp bit */
|
|
|
|
128, /* hp */
|
2012-07-26 22:42:07 +02:00
|
|
|
},
|
|
|
|
{ /* hor component */
|
2013-03-12 05:51:00 +01:00
|
|
|
128, /* sign */
|
|
|
|
{216, 128, 176, 160, 176, 176, 192, 198, 198, 208}, /* class */
|
|
|
|
{208}, /* class0 */
|
|
|
|
{136, 140, 148, 160, 176, 192, 224, 234, 234, 240}, /* bits */
|
|
|
|
{{128, 128, 64}, {96, 112, 64}}, /* class0_fp */
|
|
|
|
{64, 96, 64}, /* fp */
|
|
|
|
160, /* class0_hp bit */
|
|
|
|
128, /* hp */
|
2012-07-26 22:42:07 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2013-04-17 20:21:28 +02:00
|
|
|
MV_JOINT_TYPE vp9_get_mv_joint(const MV *mv) {
|
|
|
|
if (mv->row == 0 && mv->col == 0)
|
2013-04-02 03:23:04 +02:00
|
|
|
return MV_JOINT_ZERO;
|
2013-04-17 20:21:28 +02:00
|
|
|
else if (mv->row == 0 && mv->col != 0)
|
2013-04-02 03:23:04 +02:00
|
|
|
return MV_JOINT_HNZVZ;
|
2013-04-17 20:21:28 +02:00
|
|
|
else if (mv->row != 0 && mv->col == 0)
|
2013-04-02 03:23:04 +02:00
|
|
|
return MV_JOINT_HZVNZ;
|
|
|
|
else
|
|
|
|
return MV_JOINT_HNZVNZ;
|
2012-07-26 22:42:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#define mv_class_base(c) ((c) ? (CLASS0_SIZE << (c + 2)) : 0)
|
|
|
|
|
2012-10-31 00:25:53 +01:00
|
|
|
MV_CLASS_TYPE vp9_get_mv_class(int z, int *offset) {
|
2012-07-26 22:42:07 +02:00
|
|
|
MV_CLASS_TYPE c;
|
|
|
|
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;
|
2013-03-06 21:02:15 +01:00
|
|
|
else if (z < CLASS0_SIZE * 2048) c = MV_CLASS_8;
|
|
|
|
else if (z < CLASS0_SIZE * 4096) c = MV_CLASS_9;
|
2013-03-12 05:51:00 +01:00
|
|
|
else if (z < CLASS0_SIZE * 8192) c = MV_CLASS_10;
|
2012-07-26 22:42:07 +02:00
|
|
|
else assert(0);
|
|
|
|
if (offset)
|
|
|
|
*offset = z - mv_class_base(c);
|
|
|
|
return c;
|
|
|
|
}
|
|
|
|
|
2013-06-19 03:28:10 +02:00
|
|
|
int vp9_use_mv_hp(const MV *ref) {
|
2013-03-27 22:22:30 +01:00
|
|
|
return (abs(ref->row) >> 3) < COMPANDED_MVREF_THRESH &&
|
|
|
|
(abs(ref->col) >> 3) < COMPANDED_MVREF_THRESH;
|
2012-09-06 18:07:42 +02:00
|
|
|
}
|
|
|
|
|
2012-10-31 00:25:53 +01:00
|
|
|
int vp9_get_mv_mag(MV_CLASS_TYPE c, int offset) {
|
2012-07-26 22:42:07 +02:00
|
|
|
return mv_class_base(c) + offset;
|
|
|
|
}
|
|
|
|
|
2013-06-19 03:28:10 +02:00
|
|
|
static void inc_mv_component_count(int v, nmv_component_counts *comp_counts,
|
|
|
|
int incr) {
|
|
|
|
assert (v != 0);
|
|
|
|
comp_counts->mvcount[MV_MAX + v] += incr;
|
2012-07-26 22:42:07 +02:00
|
|
|
}
|
|
|
|
|
2013-06-19 03:28:10 +02:00
|
|
|
static void inc_mv_component(int v, nmv_component_counts *comp_counts,
|
|
|
|
int incr, int usehp) {
|
2012-07-26 22:42:07 +02:00
|
|
|
int s, z, c, o, d, e, f;
|
2013-04-02 03:23:04 +02:00
|
|
|
if (!incr)
|
|
|
|
return;
|
2012-07-26 22:42:07 +02:00
|
|
|
assert (v != 0); /* should not be zero */
|
|
|
|
s = v < 0;
|
2013-06-19 03:28:10 +02:00
|
|
|
comp_counts->sign[s] += incr;
|
2012-07-26 22:42:07 +02:00
|
|
|
z = (s ? -v : v) - 1; /* magnitude - 1 */
|
|
|
|
|
2012-10-31 00:25:53 +01:00
|
|
|
c = vp9_get_mv_class(z, &o);
|
2013-06-19 03:28:10 +02:00
|
|
|
comp_counts->classes[c] += incr;
|
2012-07-26 22:42:07 +02:00
|
|
|
|
|
|
|
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) {
|
2013-06-19 03:28:10 +02:00
|
|
|
comp_counts->class0[d] += incr;
|
2012-07-26 22:42:07 +02:00
|
|
|
} else {
|
2013-04-02 03:23:04 +02:00
|
|
|
int i;
|
|
|
|
int b = c + CLASS0_BITS - 1; // number of bits
|
2012-07-26 22:42:07 +02:00
|
|
|
for (i = 0; i < b; ++i)
|
2013-06-19 03:28:10 +02:00
|
|
|
comp_counts->bits[i][((d >> i) & 1)] += incr;
|
2012-07-26 22:42:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Code the fractional pel bits */
|
|
|
|
if (c == MV_CLASS_0) {
|
2013-06-19 03:28:10 +02:00
|
|
|
comp_counts->class0_fp[d][f] += incr;
|
2012-07-26 22:42:07 +02:00
|
|
|
} else {
|
2013-06-19 03:28:10 +02:00
|
|
|
comp_counts->fp[f] += incr;
|
2012-07-26 22:42:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Code the high precision bit */
|
|
|
|
if (usehp) {
|
|
|
|
if (c == MV_CLASS_0) {
|
2013-06-19 03:28:10 +02:00
|
|
|
comp_counts->class0_hp[e] += incr;
|
2012-07-26 22:42:07 +02:00
|
|
|
} else {
|
2013-06-19 03:28:10 +02:00
|
|
|
comp_counts->hp[e] += incr;
|
2012-07-26 22:42:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef SMOOTH_MV_COUNTS
|
|
|
|
static void smooth_counts(nmv_component_counts *mvcomp) {
|
|
|
|
static const int flen = 3; // (filter_length + 1) / 2
|
|
|
|
static const int fval[] = {8, 3, 1};
|
|
|
|
static const int fvalbits = 4;
|
|
|
|
int i;
|
|
|
|
unsigned int smvcount[MV_VALS];
|
|
|
|
vpx_memcpy(smvcount, mvcomp->mvcount, sizeof(smvcount));
|
|
|
|
smvcount[MV_MAX] = (smvcount[MV_MAX - 1] + smvcount[MV_MAX + 1]) >> 1;
|
|
|
|
for (i = flen - 1; i <= MV_VALS - flen; ++i) {
|
|
|
|
int j, s = smvcount[i] * fval[0];
|
|
|
|
for (j = 1; j < flen; ++j)
|
|
|
|
s += (smvcount[i - j] + smvcount[i + j]) * fval[j];
|
|
|
|
mvcomp->mvcount[i] = (s + (1 << (fvalbits - 1))) >> fvalbits;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
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++) {
|
2013-06-19 03:28:10 +02:00
|
|
|
inc_mv_component(-v, mvcomp, mvcomp->mvcount[MV_MAX - v], usehp);
|
|
|
|
inc_mv_component( v, mvcomp, mvcomp->mvcount[MV_MAX + v], usehp);
|
2012-07-26 22:42:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-26 00:19:18 +02:00
|
|
|
void vp9_inc_mv(const MV *mv, const MV *ref, nmv_context_counts *mvctx,
|
2012-07-26 22:42:07 +02:00
|
|
|
int usehp) {
|
2013-04-17 20:21:28 +02:00
|
|
|
const MV_JOINT_TYPE j = vp9_get_mv_joint(mv);
|
|
|
|
mvctx->joints[j]++;
|
2013-06-19 03:28:10 +02:00
|
|
|
usehp = usehp && vp9_use_mv_hp(ref);
|
2013-04-17 20:21:28 +02:00
|
|
|
if (mv_joint_vertical(j))
|
2013-06-19 03:28:10 +02:00
|
|
|
inc_mv_component_count(mv->row, &mvctx->comps[0], 1);
|
2013-04-02 03:23:04 +02:00
|
|
|
|
2013-04-17 20:21:28 +02:00
|
|
|
if (mv_joint_horizontal(j))
|
2013-06-19 03:28:10 +02:00
|
|
|
inc_mv_component_count(mv->col, &mvctx->comps[1], 1);
|
2012-07-26 22:42:07 +02:00
|
|
|
}
|
|
|
|
|
2013-04-02 03:23:04 +02:00
|
|
|
static void adapt_prob(vp9_prob *dest, vp9_prob prep, unsigned int ct[2]) {
|
|
|
|
const int count = MIN(ct[0] + ct[1], MV_COUNT_SAT);
|
2012-07-26 22:42:07 +02:00
|
|
|
if (count) {
|
2013-04-02 03:23:04 +02:00
|
|
|
const vp9_prob newp = get_binary_prob(ct[0], ct[1]);
|
|
|
|
const int factor = MV_MAX_UPDATE_FACTOR * count / MV_COUNT_SAT;
|
|
|
|
*dest = weighted_prob(prep, newp, factor);
|
2013-03-11 17:34:05 +01:00
|
|
|
} else {
|
|
|
|
*dest = prep;
|
2012-07-26 22:42:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-27 22:22:30 +01:00
|
|
|
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);
|
2012-11-09 19:52:08 +01:00
|
|
|
}
|
|
|
|
|
2013-03-11 17:34:05 +01:00
|
|
|
static unsigned int adapt_probs(unsigned int i,
|
|
|
|
vp9_tree tree,
|
|
|
|
vp9_prob this_probs[],
|
|
|
|
const vp9_prob last_probs[],
|
|
|
|
const unsigned int num_events[]) {
|
|
|
|
vp9_prob this_prob;
|
|
|
|
|
2013-03-27 22:22:30 +01:00
|
|
|
const uint32_t left = tree[i] <= 0
|
|
|
|
? num_events[-tree[i]]
|
|
|
|
: adapt_probs(tree[i], tree, this_probs, last_probs, num_events);
|
|
|
|
|
|
|
|
const uint32_t right = tree[i + 1] <= 0
|
|
|
|
? num_events[-tree[i + 1]]
|
|
|
|
: adapt_probs(tree[i + 1], tree, this_probs, last_probs, num_events);
|
2013-03-11 17:34:05 +01:00
|
|
|
|
2013-03-27 22:22:30 +01:00
|
|
|
uint32_t weight = left + right;
|
2013-03-11 17:34:05 +01:00
|
|
|
if (weight) {
|
|
|
|
this_prob = get_binary_prob(left, right);
|
|
|
|
weight = weight > MV_COUNT_SAT ? MV_COUNT_SAT : weight;
|
2013-03-27 22:22:30 +01:00
|
|
|
this_prob = weighted_prob(last_probs[i >> 1], this_prob,
|
2013-03-11 17:34:05 +01:00
|
|
|
MV_MAX_UPDATE_FACTOR * weight / MV_COUNT_SAT);
|
|
|
|
} else {
|
|
|
|
this_prob = last_probs[i >> 1];
|
|
|
|
}
|
2013-03-27 22:22:30 +01:00
|
|
|
this_probs[i >> 1] = this_prob;
|
2013-03-11 17:34:05 +01:00
|
|
|
return left + right;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-06-19 03:28:10 +02:00
|
|
|
void vp9_adapt_mv_probs(VP9_COMMON *cm, int usehp) {
|
2013-03-11 17:34:05 +01:00
|
|
|
int i, j;
|
2012-07-26 22:42:07 +02:00
|
|
|
#ifdef MV_COUNT_TESTING
|
|
|
|
printf("joints count: ");
|
|
|
|
for (j = 0; j < MV_JOINTS; ++j) printf("%d ", cm->fc.NMVcount.joints[j]);
|
|
|
|
printf("\n"); fflush(stdout);
|
|
|
|
printf("signs count:\n");
|
|
|
|
for (i = 0; i < 2; ++i)
|
|
|
|
printf("%d/%d ", cm->fc.NMVcount.comps[i].sign[0], cm->fc.NMVcount.comps[i].sign[1]);
|
|
|
|
printf("\n"); fflush(stdout);
|
|
|
|
printf("classes count:\n");
|
|
|
|
for (i = 0; i < 2; ++i) {
|
|
|
|
for (j = 0; j < MV_CLASSES; ++j)
|
|
|
|
printf("%d ", cm->fc.NMVcount.comps[i].classes[j]);
|
|
|
|
printf("\n"); fflush(stdout);
|
|
|
|
}
|
|
|
|
printf("class0 count:\n");
|
|
|
|
for (i = 0; i < 2; ++i) {
|
|
|
|
for (j = 0; j < CLASS0_SIZE; ++j)
|
|
|
|
printf("%d ", cm->fc.NMVcount.comps[i].class0[j]);
|
|
|
|
printf("\n"); fflush(stdout);
|
|
|
|
}
|
|
|
|
printf("bits count:\n");
|
|
|
|
for (i = 0; i < 2; ++i) {
|
|
|
|
for (j = 0; j < MV_OFFSET_BITS; ++j)
|
|
|
|
printf("%d/%d ", cm->fc.NMVcount.comps[i].bits[j][0],
|
|
|
|
cm->fc.NMVcount.comps[i].bits[j][1]);
|
|
|
|
printf("\n"); fflush(stdout);
|
|
|
|
}
|
|
|
|
printf("class0_fp count:\n");
|
|
|
|
for (i = 0; i < 2; ++i) {
|
|
|
|
for (j = 0; j < CLASS0_SIZE; ++j) {
|
|
|
|
printf("{");
|
|
|
|
for (k = 0; k < 4; ++k)
|
|
|
|
printf("%d ", cm->fc.NMVcount.comps[i].class0_fp[j][k]);
|
|
|
|
printf("}, ");
|
|
|
|
}
|
|
|
|
printf("\n"); fflush(stdout);
|
|
|
|
}
|
|
|
|
printf("fp count:\n");
|
|
|
|
for (i = 0; i < 2; ++i) {
|
|
|
|
for (j = 0; j < 4; ++j)
|
|
|
|
printf("%d ", cm->fc.NMVcount.comps[i].fp[j]);
|
|
|
|
printf("\n"); fflush(stdout);
|
|
|
|
}
|
|
|
|
if (usehp) {
|
|
|
|
printf("class0_hp count:\n");
|
|
|
|
for (i = 0; i < 2; ++i)
|
|
|
|
printf("%d/%d ", cm->fc.NMVcount.comps[i].class0_hp[0],
|
|
|
|
cm->fc.NMVcount.comps[i].class0_hp[1]);
|
|
|
|
printf("\n"); fflush(stdout);
|
|
|
|
printf("hp count:\n");
|
|
|
|
for (i = 0; i < 2; ++i)
|
|
|
|
printf("%d/%d ", cm->fc.NMVcount.comps[i].hp[0],
|
|
|
|
cm->fc.NMVcount.comps[i].hp[1]);
|
|
|
|
printf("\n"); fflush(stdout);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#ifdef SMOOTH_MV_COUNTS
|
|
|
|
smooth_counts(&cm->fc.NMVcount.comps[0]);
|
|
|
|
smooth_counts(&cm->fc.NMVcount.comps[1]);
|
|
|
|
#endif
|
2013-03-11 17:34:05 +01:00
|
|
|
vp9_counts_process(&cm->fc.NMVcount, usehp);
|
|
|
|
|
|
|
|
adapt_probs(0, vp9_mv_joint_tree,
|
|
|
|
cm->fc.nmvc.joints, cm->fc.pre_nmvc.joints,
|
|
|
|
cm->fc.NMVcount.joints);
|
|
|
|
|
2012-07-26 22:42:07 +02:00
|
|
|
for (i = 0; i < 2; ++i) {
|
|
|
|
adapt_prob(&cm->fc.nmvc.comps[i].sign,
|
|
|
|
cm->fc.pre_nmvc.comps[i].sign,
|
2013-03-11 17:34:05 +01:00
|
|
|
cm->fc.NMVcount.comps[i].sign);
|
|
|
|
adapt_probs(0, vp9_mv_class_tree,
|
|
|
|
cm->fc.nmvc.comps[i].classes, cm->fc.pre_nmvc.comps[i].classes,
|
|
|
|
cm->fc.NMVcount.comps[i].classes);
|
|
|
|
adapt_probs(0, vp9_mv_class0_tree,
|
|
|
|
cm->fc.nmvc.comps[i].class0, cm->fc.pre_nmvc.comps[i].class0,
|
|
|
|
cm->fc.NMVcount.comps[i].class0);
|
2012-07-26 22:42:07 +02:00
|
|
|
for (j = 0; j < MV_OFFSET_BITS; ++j) {
|
|
|
|
adapt_prob(&cm->fc.nmvc.comps[i].bits[j],
|
|
|
|
cm->fc.pre_nmvc.comps[i].bits[j],
|
2013-03-11 17:34:05 +01:00
|
|
|
cm->fc.NMVcount.comps[i].bits[j]);
|
2012-07-26 22:42:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
for (i = 0; i < 2; ++i) {
|
|
|
|
for (j = 0; j < CLASS0_SIZE; ++j) {
|
2013-03-11 17:34:05 +01:00
|
|
|
adapt_probs(0, vp9_mv_fp_tree,
|
|
|
|
cm->fc.nmvc.comps[i].class0_fp[j],
|
|
|
|
cm->fc.pre_nmvc.comps[i].class0_fp[j],
|
|
|
|
cm->fc.NMVcount.comps[i].class0_fp[j]);
|
2012-07-26 22:42:07 +02:00
|
|
|
}
|
2013-03-11 17:34:05 +01:00
|
|
|
adapt_probs(0, vp9_mv_fp_tree,
|
|
|
|
cm->fc.nmvc.comps[i].fp,
|
|
|
|
cm->fc.pre_nmvc.comps[i].fp,
|
|
|
|
cm->fc.NMVcount.comps[i].fp);
|
2012-07-26 22:42:07 +02:00
|
|
|
}
|
|
|
|
if (usehp) {
|
|
|
|
for (i = 0; i < 2; ++i) {
|
|
|
|
adapt_prob(&cm->fc.nmvc.comps[i].class0_hp,
|
|
|
|
cm->fc.pre_nmvc.comps[i].class0_hp,
|
2013-03-11 17:34:05 +01:00
|
|
|
cm->fc.NMVcount.comps[i].class0_hp);
|
2012-07-26 22:42:07 +02:00
|
|
|
adapt_prob(&cm->fc.nmvc.comps[i].hp,
|
|
|
|
cm->fc.pre_nmvc.comps[i].hp,
|
2013-03-11 17:34:05 +01:00
|
|
|
cm->fc.NMVcount.comps[i].hp);
|
2012-07-26 22:42:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-31 00:25:53 +01:00
|
|
|
void vp9_entropy_mv_init() {
|
2012-10-31 01:12:12 +01:00
|
|
|
vp9_tokens_from_tree(vp9_mv_joint_encodings, vp9_mv_joint_tree);
|
|
|
|
vp9_tokens_from_tree(vp9_mv_class_encodings, vp9_mv_class_tree);
|
|
|
|
vp9_tokens_from_tree(vp9_mv_class0_encodings, vp9_mv_class0_tree);
|
|
|
|
vp9_tokens_from_tree(vp9_mv_fp_encodings, vp9_mv_fp_tree);
|
2012-07-26 22:42:07 +02:00
|
|
|
}
|
|
|
|
|
2012-10-31 01:53:32 +01:00
|
|
|
void vp9_init_mv_probs(VP9_COMMON *cm) {
|
2012-10-31 01:12:12 +01:00
|
|
|
vpx_memcpy(&cm->fc.nmvc, &vp9_default_nmv_context, sizeof(nmv_context));
|
2012-07-26 22:42:07 +02:00
|
|
|
}
|