| 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 26 matching lines...) Expand all Loading... |
| 37 /* We build coding trees compactly in arrays. | 37 /* We build coding trees compactly in arrays. |
| 38 Each node of the tree is a pair of vp9_tree_indices. | 38 Each node of the tree is a pair of vp9_tree_indices. |
| 39 Array index often references a corresponding probability table. | 39 Array index often references a corresponding probability table. |
| 40 Index <= 0 means done encoding/decoding and value = -Index, | 40 Index <= 0 means done encoding/decoding and value = -Index, |
| 41 Index > 0 means need another bit, specification at index. | 41 Index > 0 means need another bit, specification at index. |
| 42 Nonnegative indices are always even; processing begins at node 0. */ | 42 Nonnegative indices are always even; processing begins at node 0. */ |
| 43 | 43 |
| 44 typedef const vp9_tree_index vp9_tree[]; | 44 typedef const vp9_tree_index vp9_tree[]; |
| 45 | 45 |
| 46 static INLINE vp9_prob clip_prob(int p) { | 46 static INLINE vp9_prob clip_prob(int p) { |
| 47 return (p > 255) ? 255u : (p < 1) ? 1u : p; | 47 return (p > 255) ? 255 : (p < 1) ? 1 : p; |
| 48 } | 48 } |
| 49 | 49 |
| 50 // int64 is not needed for normal frame level calculations. | |
| 51 // However when outputting entropy stats accumulated over many frames | |
| 52 // or even clips we can overflow int math. | |
| 53 #ifdef ENTROPY_STATS | |
| 54 static INLINE vp9_prob get_prob(int num, int den) { | 50 static INLINE vp9_prob get_prob(int num, int den) { |
| 55 return (den == 0) ? 128u : clip_prob(((int64_t)num * 256 + (den >> 1)) / den); | 51 return (den == 0) ? 128u : clip_prob(((int64_t)num * 256 + (den >> 1)) / den); |
| 56 } | 52 } |
| 57 #else | |
| 58 static INLINE vp9_prob get_prob(int num, int den) { | |
| 59 return (den == 0) ? 128u : clip_prob((num * 256 + (den >> 1)) / den); | |
| 60 } | |
| 61 #endif | |
| 62 | 53 |
| 63 static INLINE vp9_prob get_binary_prob(int n0, int n1) { | 54 static INLINE vp9_prob get_binary_prob(int n0, int n1) { |
| 64 return get_prob(n0, n0 + n1); | 55 return get_prob(n0, n0 + n1); |
| 65 } | 56 } |
| 66 | 57 |
| 67 /* This function assumes prob1 and prob2 are already within [1,255] range. */ | 58 /* This function assumes prob1 and prob2 are already within [1,255] range. */ |
| 68 static INLINE vp9_prob weighted_prob(int prob1, int prob2, int factor) { | 59 static INLINE vp9_prob weighted_prob(int prob1, int prob2, int factor) { |
| 69 return ROUND_POWER_OF_TWO(prob1 * (256 - factor) + prob2 * factor, 8); | 60 return ROUND_POWER_OF_TWO(prob1 * (256 - factor) + prob2 * factor, 8); |
| 70 } | 61 } |
| 71 | 62 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 84 unsigned int max_update_factor, vp9_prob *probs); | 75 unsigned int max_update_factor, vp9_prob *probs); |
| 85 | 76 |
| 86 | 77 |
| 87 DECLARE_ALIGNED(16, extern const uint8_t, vp9_norm[256]); | 78 DECLARE_ALIGNED(16, extern const uint8_t, vp9_norm[256]); |
| 88 | 79 |
| 89 #ifdef __cplusplus | 80 #ifdef __cplusplus |
| 90 } // extern "C" | 81 } // extern "C" |
| 91 #endif | 82 #endif |
| 92 | 83 |
| 93 #endif // VP9_COMMON_VP9_PROB_H_ | 84 #endif // VP9_COMMON_VP9_PROB_H_ |
| OLD | NEW |