28 int max_count,
int update_factor)
30 unsigned ct = ct0 + ct1, p2, p1;
35 update_factor =
FASTDIV(update_factor *
FFMIN(ct, max_count), max_count);
37 p2 = ((((int64_t) ct0) << 8) + (ct >> 1)) / ct;
41 *p = p1 + (((p2 - p1) * update_factor + 128) >> 8);
48 int uf = (
s->s.h.keyframe ||
s->s.h.intraonly || !
s->last_keyframe) ? 112 : 128;
51 for (
i = 0;
i < 4;
i++)
52 for (j = 0; j < 2; j++)
53 for (k = 0; k < 2; k++)
54 for (l = 0; l < 6; l++)
55 for (m = 0; m < 6; m++) {
56 uint8_t *pp =
s->prob_ctx[
s->s.h.framectxid].coef[
i][j][k][l][m];
57 unsigned *e =
s->td[0].counts.eob[
i][j][k][l][m];
58 unsigned *
c =
s->td[0].counts.coef[
i][j][k][l][m];
68 if (
s->s.h.keyframe ||
s->s.h.intraonly) {
69 memcpy(p->
skip,
s->prob.p.skip,
sizeof(p->
skip));
70 memcpy(p->
tx32p,
s->prob.p.tx32p,
sizeof(p->
tx32p));
71 memcpy(p->
tx16p,
s->prob.p.tx16p,
sizeof(p->
tx16p));
72 memcpy(p->
tx8p,
s->prob.p.tx8p,
sizeof(p->
tx8p));
77 for (
i = 0;
i < 3;
i++)
79 s->td[0].counts.skip[
i][1], 20, 128);
82 for (
i = 0;
i < 4;
i++)
84 s->td[0].counts.intra[
i][1], 20, 128);
88 for (
i = 0;
i < 5;
i++)
90 s->td[0].counts.comp[
i][1], 20, 128);
95 for (
i = 0;
i < 5;
i++)
97 s->td[0].counts.comp_ref[
i][1], 20, 128);
101 for (
i = 0;
i < 5;
i++) {
103 unsigned (*
c)[2] =
s->td[0].counts.single_ref[
i];
111 for (
i = 0;
i < 4;
i++)
112 for (j = 0; j < 4; j++) {
114 unsigned *
c =
s->td[0].counts.partition[
i][j];
123 for (
i = 0;
i < 2;
i++) {
124 unsigned *c16 =
s->td[0].counts.tx16p[
i], *c32 =
s->td[0].counts.tx32p[
i];
127 s->td[0].counts.tx8p[
i][1], 20, 128);
138 for (
i = 0;
i < 4;
i++) {
140 unsigned *
c =
s->td[0].counts.filter[
i];
148 for (
i = 0;
i < 7;
i++) {
150 unsigned *
c =
s->td[0].counts.mv_mode[
i];
160 unsigned *
c =
s->td[0].counts.mv_joint;
168 for (
i = 0;
i < 2;
i++) {
170 unsigned *
c, (*c2)[2], sum;
173 s->td[0].counts.mv_comp[
i].sign[1], 20, 128);
176 c =
s->td[0].counts.mv_comp[
i].classes;
177 sum =
c[1] +
c[2] +
c[3] +
c[4] +
c[5] +
178 c[6] +
c[7] +
c[8] +
c[9] +
c[10];
195 s->td[0].counts.mv_comp[
i].class0[1], 20, 128);
197 c2 =
s->td[0].counts.mv_comp[
i].bits;
198 for (j = 0; j < 10; j++)
201 for (j = 0; j < 2; j++) {
203 c =
s->td[0].counts.mv_comp[
i].class0_fp[j];
209 c =
s->td[0].counts.mv_comp[
i].fp;
214 if (
s->s.h.highprecisionmvs) {
216 s->td[0].counts.mv_comp[
i].class0_hp[0],
217 s->td[0].counts.mv_comp[
i].class0_hp[1], 20, 128);
219 s->td[0].counts.mv_comp[
i].hp[1], 20, 128);
224 for (
i = 0;
i < 4;
i++) {
226 unsigned *
c =
s->td[0].counts.y_mode[
i], sum,
s2;
228 sum =
c[0] +
c[1] +
c[3] +
c[4] +
c[5] +
c[6] +
c[7] +
c[8] +
c[9];
249 for (
i = 0;
i < 10;
i++) {
251 unsigned *
c =
s->td[0].counts.uv_mode[
i], sum,
s2;
253 sum =
c[0] +
c[1] +
c[3] +
c[4] +
c[5] +
c[6] +
c[7] +
c[8] +
c[9];