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 |
(...skipping 15 matching lines...) Expand all Loading... |
26 #define MAX_PROB 255 | 26 #define MAX_PROB 255 |
27 | 27 |
28 #define vp9_prob_half ((vp9_prob) 128) | 28 #define vp9_prob_half ((vp9_prob) 128) |
29 | 29 |
30 typedef int8_t vp9_tree_index; | 30 typedef int8_t vp9_tree_index; |
31 | 31 |
32 #define TREE_SIZE(leaf_count) (2 * (leaf_count) - 2) | 32 #define TREE_SIZE(leaf_count) (2 * (leaf_count) - 2) |
33 | 33 |
34 #define vp9_complement(x) (255 - x) | 34 #define vp9_complement(x) (255 - x) |
35 | 35 |
| 36 #define MODE_MV_COUNT_SAT 20 |
| 37 |
36 /* We build coding trees compactly in arrays. | 38 /* We build coding trees compactly in arrays. |
37 Each node of the tree is a pair of vp9_tree_indices. | 39 Each node of the tree is a pair of vp9_tree_indices. |
38 Array index often references a corresponding probability table. | 40 Array index often references a corresponding probability table. |
39 Index <= 0 means done encoding/decoding and value = -Index, | 41 Index <= 0 means done encoding/decoding and value = -Index, |
40 Index > 0 means need another bit, specification at index. | 42 Index > 0 means need another bit, specification at index. |
41 Nonnegative indices are always even; processing begins at node 0. */ | 43 Nonnegative indices are always even; processing begins at node 0. */ |
42 | 44 |
43 typedef const vp9_tree_index vp9_tree[]; | 45 typedef const vp9_tree_index vp9_tree[]; |
44 | 46 |
45 static INLINE vp9_prob clip_prob(int p) { | 47 static INLINE vp9_prob clip_prob(int p) { |
(...skipping 16 matching lines...) Expand all Loading... |
62 static INLINE vp9_prob merge_probs(vp9_prob pre_prob, | 64 static INLINE vp9_prob merge_probs(vp9_prob pre_prob, |
63 const unsigned int ct[2], | 65 const unsigned int ct[2], |
64 unsigned int count_sat, | 66 unsigned int count_sat, |
65 unsigned int max_update_factor) { | 67 unsigned int max_update_factor) { |
66 const vp9_prob prob = get_binary_prob(ct[0], ct[1]); | 68 const vp9_prob prob = get_binary_prob(ct[0], ct[1]); |
67 const unsigned int count = MIN(ct[0] + ct[1], count_sat); | 69 const unsigned int count = MIN(ct[0] + ct[1], count_sat); |
68 const unsigned int factor = max_update_factor * count / count_sat; | 70 const unsigned int factor = max_update_factor * count / count_sat; |
69 return weighted_prob(pre_prob, prob, factor); | 71 return weighted_prob(pre_prob, prob, factor); |
70 } | 72 } |
71 | 73 |
| 74 // MODE_MV_MAX_UPDATE_FACTOR (128) * count / MODE_MV_COUNT_SAT; |
| 75 static const int count_to_update_factor[MODE_MV_COUNT_SAT + 1] = { |
| 76 0, 6, 12, 19, 25, 32, 38, 44, 51, 57, 64, |
| 77 70, 76, 83, 89, 96, 102, 108, 115, 121, 128 |
| 78 }; |
| 79 |
| 80 static INLINE vp9_prob mode_mv_merge_probs(vp9_prob pre_prob, |
| 81 const unsigned int ct[2]) { |
| 82 const unsigned int den = ct[0] + ct[1]; |
| 83 if (den == 0) { |
| 84 return pre_prob; |
| 85 } else { |
| 86 const unsigned int count = MIN(den, MODE_MV_COUNT_SAT); |
| 87 const unsigned int factor = count_to_update_factor[count]; |
| 88 const vp9_prob prob = |
| 89 clip_prob(((int64_t)(ct[0]) * 256 + (den >> 1)) / den); |
| 90 return weighted_prob(pre_prob, prob, factor); |
| 91 } |
| 92 } |
| 93 |
72 void vp9_tree_merge_probs(const vp9_tree_index *tree, const vp9_prob *pre_probs, | 94 void vp9_tree_merge_probs(const vp9_tree_index *tree, const vp9_prob *pre_probs, |
73 const unsigned int *counts, unsigned int count_sat, | 95 const unsigned int *counts, vp9_prob *probs); |
74 unsigned int max_update_factor, vp9_prob *probs); | |
75 | 96 |
76 | 97 |
77 DECLARE_ALIGNED(16, extern const uint8_t, vp9_norm[256]); | 98 DECLARE_ALIGNED(16, extern const uint8_t, vp9_norm[256]); |
78 | 99 |
79 #ifdef __cplusplus | 100 #ifdef __cplusplus |
80 } // extern "C" | 101 } // extern "C" |
81 #endif | 102 #endif |
82 | 103 |
83 #endif // VP9_COMMON_VP9_PROB_H_ | 104 #endif // VP9_COMMON_VP9_PROB_H_ |
OLD | NEW |