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_boolhuff.h" | 14 #include "vp9/encoder/vp9_boolhuff.h" |
15 #include "vp9/encoder/vp9_treewriter.h" | 15 #include "vp9/encoder/vp9_treewriter.h" |
16 | 16 |
17 #define vp9_cost_upd ((int)(vp9_cost_one(upd) - vp9_cost_zero(upd)) >> 8) | |
18 #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))) |
19 | 18 |
20 static int update_bits[255]; | 19 static int update_bits[255]; |
21 | 20 |
22 static int count_uniform(int v, int n) { | 21 static int count_uniform(int v, int n) { |
23 int l = get_unsigned_bits(n); | 22 int l = get_unsigned_bits(n); |
24 int m; | 23 int m; |
25 if (l == 0) return 0; | 24 if (l == 0) return 0; |
26 m = (1 << l) - n; | 25 m = (1 << l) - n; |
27 if (v < m) | 26 if (v < m) |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 if (savings > bestsavings) { | 213 if (savings > bestsavings) { |
215 bestsavings = savings; | 214 bestsavings = savings; |
216 bestnewp = newp; | 215 bestnewp = newp; |
217 } | 216 } |
218 } | 217 } |
219 *bestp = bestnewp; | 218 *bestp = bestnewp; |
220 return bestsavings; | 219 return bestsavings; |
221 } | 220 } |
222 | 221 |
223 void vp9_cond_prob_diff_update(vp9_writer *w, vp9_prob *oldp, | 222 void vp9_cond_prob_diff_update(vp9_writer *w, vp9_prob *oldp, |
224 unsigned int *ct) { | 223 const unsigned int ct[2]) { |
225 const vp9_prob upd = DIFF_UPDATE_PROB; | 224 const vp9_prob upd = DIFF_UPDATE_PROB; |
226 vp9_prob newp = get_binary_prob(ct[0], ct[1]); | 225 vp9_prob newp = get_binary_prob(ct[0], ct[1]); |
227 const int savings = vp9_prob_diff_update_savings_search(ct, *oldp, &newp, | 226 const int savings = vp9_prob_diff_update_savings_search(ct, *oldp, &newp, |
228 upd); | 227 upd); |
229 assert(newp >= 1); | 228 assert(newp >= 1); |
230 if (savings > 0) { | 229 if (savings > 0) { |
231 vp9_write(w, 1, upd); | 230 vp9_write(w, 1, upd); |
232 vp9_write_prob_diff_update(w, newp, *oldp); | 231 vp9_write_prob_diff_update(w, newp, *oldp); |
233 *oldp = newp; | 232 *oldp = newp; |
234 } else { | 233 } else { |
235 vp9_write(w, 0, upd); | 234 vp9_write(w, 0, upd); |
236 } | 235 } |
237 } | 236 } |
OLD | NEW |