OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2013 The WebM project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #include "vp9/common/vp9_common.h" | 11 #include "vp9/common/vp9_common.h" |
12 #include "vp9/common/vp9_entropy.h" | 12 #include "vp9/common/vp9_entropy.h" |
13 | 13 |
14 #include "vp9/encoder/vp9_treewriter.h" | 14 #include "vp9/encoder/vp9_cost.h" |
15 #include "vp9/encoder/vp9_writer.h" | 15 #include "vp9/encoder/vp9_writer.h" |
16 | 16 |
17 #define vp9_cost_upd256 ((int)(vp9_cost_one(upd) - vp9_cost_zero(upd))) | 17 #define vp9_cost_upd256 ((int)(vp9_cost_one(upd) - vp9_cost_zero(upd))) |
18 | 18 |
19 static int update_bits[255]; | 19 static int update_bits[255]; |
20 | 20 |
21 static int split_index(int i, int n, int modulus) { | |
22 int max1 = (n - 1 - modulus / 2) / modulus + 1; | |
23 if (i % modulus == modulus / 2) | |
24 i = i / modulus; | |
25 else | |
26 i = max1 + i - (i + modulus - modulus / 2) / modulus; | |
27 return i; | |
28 } | |
29 | |
30 static int recenter_nonneg(int v, int m) { | 21 static int recenter_nonneg(int v, int m) { |
31 if (v > (m << 1)) | 22 if (v > (m << 1)) |
32 return v; | 23 return v; |
33 else if (v >= m) | 24 else if (v >= m) |
34 return ((v - m) << 1); | 25 return ((v - m) << 1); |
35 else | 26 else |
36 return ((m - v) << 1) - 1; | 27 return ((m - v) << 1) - 1; |
37 } | 28 } |
38 | 29 |
39 static int remap_prob(int v, int m) { | 30 static int remap_prob(int v, int m) { |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 upd); | 184 upd); |
194 assert(newp >= 1); | 185 assert(newp >= 1); |
195 if (savings > 0) { | 186 if (savings > 0) { |
196 vp9_write(w, 1, upd); | 187 vp9_write(w, 1, upd); |
197 vp9_write_prob_diff_update(w, newp, *oldp); | 188 vp9_write_prob_diff_update(w, newp, *oldp); |
198 *oldp = newp; | 189 *oldp = newp; |
199 } else { | 190 } else { |
200 vp9_write(w, 0, upd); | 191 vp9_write(w, 0, upd); |
201 } | 192 } |
202 } | 193 } |
OLD | NEW |