| Index: source/libvpx/vp9/encoder/vp9_subexp.c
|
| ===================================================================
|
| --- source/libvpx/vp9/encoder/vp9_subexp.c (revision 251189)
|
| +++ source/libvpx/vp9/encoder/vp9_subexp.c (working copy)
|
| @@ -18,17 +18,6 @@
|
|
|
| static int update_bits[255];
|
|
|
| -static int count_uniform(int v, int n) {
|
| - int l = get_unsigned_bits(n);
|
| - int m;
|
| - if (l == 0) return 0;
|
| - m = (1 << l) - n;
|
| - if (v < m)
|
| - return l - 1;
|
| - else
|
| - return l;
|
| -}
|
| -
|
| static int split_index(int i, int n, int modulus) {
|
| int max1 = (n - 1 - modulus / 2) / modulus + 1;
|
| if (i % modulus == modulus / 2)
|
| @@ -81,29 +70,16 @@
|
| return i;
|
| }
|
|
|
| -static int count_term_subexp(int word, int k, int num_syms) {
|
| - int count = 0;
|
| - int i = 0;
|
| - int mk = 0;
|
| - while (1) {
|
| - int b = (i ? k + i - 1 : k);
|
| - int a = (1 << b);
|
| - if (num_syms <= mk + 3 * a) {
|
| - count += count_uniform(word - mk, num_syms - mk);
|
| - break;
|
| - } else {
|
| - int t = (word >= mk + a);
|
| - count++;
|
| - if (t) {
|
| - i = i + 1;
|
| - mk += a;
|
| - } else {
|
| - count += b;
|
| - break;
|
| - }
|
| - }
|
| - }
|
| - return count;
|
| +static int count_term_subexp(int word) {
|
| + if (word < 16)
|
| + return 5;
|
| + if (word < 32)
|
| + return 6;
|
| + if (word < 64)
|
| + return 8;
|
| + if (word < 129)
|
| + return 10;
|
| + return 11;
|
| }
|
|
|
| static int prob_diff_update_cost(vp9_prob newp, vp9_prob oldp) {
|
| @@ -111,12 +87,9 @@
|
| return update_bits[delp] * 256;
|
| }
|
|
|
| -static void encode_uniform(vp9_writer *w, int v, int n) {
|
| - int l = get_unsigned_bits(n);
|
| - int m;
|
| - if (l == 0)
|
| - return;
|
| - m = (1 << l) - n;
|
| +static void encode_uniform(vp9_writer *w, int v) {
|
| + const int l = 8;
|
| + const int m = (1 << l) - 191;
|
| if (v < m) {
|
| vp9_write_literal(w, v, l - 1);
|
| } else {
|
| @@ -125,38 +98,32 @@
|
| }
|
| }
|
|
|
| -static void encode_term_subexp(vp9_writer *w, int word, int k, int num_syms) {
|
| - int i = 0;
|
| - int mk = 0;
|
| - while (1) {
|
| - int b = (i ? k + i - 1 : k);
|
| - int a = (1 << b);
|
| - if (num_syms <= mk + 3 * a) {
|
| - encode_uniform(w, word - mk, num_syms - mk);
|
| - break;
|
| - } else {
|
| - int t = (word >= mk + a);
|
| - vp9_write_literal(w, t, 1);
|
| - if (t) {
|
| - i = i + 1;
|
| - mk += a;
|
| - } else {
|
| - vp9_write_literal(w, word - mk, b);
|
| - break;
|
| - }
|
| - }
|
| +static INLINE int write_bit_gte(vp9_writer *w, int word, int test) {
|
| + vp9_write_literal(w, word >= test, 1);
|
| + return word >= test;
|
| +}
|
| +
|
| +static void encode_term_subexp(vp9_writer *w, int word) {
|
| + if (!write_bit_gte(w, word, 16)) {
|
| + vp9_write_literal(w, word, 4);
|
| + } else if (!write_bit_gte(w, word, 32)) {
|
| + vp9_write_literal(w, word - 16, 4);
|
| + } else if (!write_bit_gte(w, word, 64)) {
|
| + vp9_write_literal(w, word - 32, 5);
|
| + } else {
|
| + encode_uniform(w, word - 64);
|
| }
|
| }
|
|
|
| void vp9_write_prob_diff_update(vp9_writer *w, vp9_prob newp, vp9_prob oldp) {
|
| const int delp = remap_prob(newp, oldp);
|
| - encode_term_subexp(w, delp, SUBEXP_PARAM, 255);
|
| + encode_term_subexp(w, delp);
|
| }
|
|
|
| void vp9_compute_update_table() {
|
| int i;
|
| for (i = 0; i < 254; i++)
|
| - update_bits[i] = count_term_subexp(i, SUBEXP_PARAM, 255);
|
| + update_bits[i] = count_term_subexp(i);
|
| }
|
|
|
| int vp9_prob_diff_update_savings_search(const unsigned int *ct,
|
|
|