OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2010 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 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 | 72 |
73 static INLINE vp9_prob get_binary_prob(int n0, int n1) { | 73 static INLINE vp9_prob get_binary_prob(int n0, int n1) { |
74 return get_prob(n0, n0 + n1); | 74 return get_prob(n0, n0 + n1); |
75 } | 75 } |
76 | 76 |
77 /* this function assumes prob1 and prob2 are already within [1,255] range */ | 77 /* this function assumes prob1 and prob2 are already within [1,255] range */ |
78 static INLINE vp9_prob weighted_prob(int prob1, int prob2, int factor) { | 78 static INLINE vp9_prob weighted_prob(int prob1, int prob2, int factor) { |
79 return ROUND_POWER_OF_TWO(prob1 * (256 - factor) + prob2 * factor, 8); | 79 return ROUND_POWER_OF_TWO(prob1 * (256 - factor) + prob2 * factor, 8); |
80 } | 80 } |
81 | 81 |
| 82 static INLINE vp9_prob merge_probs(vp9_prob pre_prob, vp9_prob prob, |
| 83 const unsigned int ct[2], |
| 84 unsigned int count_sat, |
| 85 unsigned int max_update_factor) { |
| 86 const unsigned int count = MIN(ct[0] + ct[1], count_sat); |
| 87 const unsigned int factor = max_update_factor * count / count_sat; |
| 88 return weighted_prob(pre_prob, prob, factor); |
| 89 } |
| 90 |
| 91 static INLINE vp9_prob merge_probs2(vp9_prob pre_prob, |
| 92 const unsigned int ct[2], |
| 93 unsigned int count_sat, |
| 94 unsigned int max_update_factor) { |
| 95 return merge_probs(pre_prob, get_binary_prob(ct[0], ct[1]), ct, count_sat, |
| 96 max_update_factor); |
| 97 } |
| 98 |
| 99 |
82 #endif // VP9_COMMON_VP9_TREECODER_H_ | 100 #endif // VP9_COMMON_VP9_TREECODER_H_ |
OLD | NEW |