| 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 |
| 11 #ifndef VP9_ENCODER_VP9_TREEWRITER_H_ | 11 #ifndef VP9_ENCODER_VP9_TREEWRITER_H_ |
| 12 #define VP9_ENCODER_VP9_TREEWRITER_H_ | 12 #define VP9_ENCODER_VP9_TREEWRITER_H_ |
| 13 | 13 |
| 14 #include "vp9/encoder/vp9_writer.h" | 14 #include "vp9/encoder/vp9_writer.h" |
| 15 | 15 |
| 16 #ifdef __cplusplus | 16 #ifdef __cplusplus |
| 17 extern "C" { | 17 extern "C" { |
| 18 #endif | 18 #endif |
| 19 | 19 |
| 20 #define vp9_cost_zero(prob) (vp9_prob_cost[prob]) | |
| 21 | |
| 22 #define vp9_cost_one(prob) vp9_cost_zero(vp9_complement(prob)) | |
| 23 | |
| 24 #define vp9_cost_bit(prob, bit) vp9_cost_zero((bit) ? vp9_complement(prob) \ | |
| 25 : (prob)) | |
| 26 | |
| 27 static INLINE unsigned int cost_branch256(const unsigned int ct[2], | |
| 28 vp9_prob p) { | |
| 29 return ct[0] * vp9_cost_zero(p) + ct[1] * vp9_cost_one(p); | |
| 30 } | |
| 31 | |
| 32 static INLINE int treed_cost(vp9_tree tree, const vp9_prob *probs, | |
| 33 int bits, int len) { | |
| 34 int cost = 0; | |
| 35 vp9_tree_index i = 0; | |
| 36 | |
| 37 do { | |
| 38 const int bit = (bits >> --len) & 1; | |
| 39 cost += vp9_cost_bit(probs[i >> 1], bit); | |
| 40 i = tree[i + bit]; | |
| 41 } while (len); | |
| 42 | |
| 43 return cost; | |
| 44 } | |
| 45 | |
| 46 void vp9_cost_tokens(int *costs, const vp9_prob *probs, vp9_tree tree); | |
| 47 void vp9_cost_tokens_skip(int *costs, const vp9_prob *probs, vp9_tree tree); | |
| 48 | |
| 49 void vp9_tree_probs_from_distribution(vp9_tree tree, | 20 void vp9_tree_probs_from_distribution(vp9_tree tree, |
| 50 unsigned int branch_ct[ /* n - 1 */ ][2], | 21 unsigned int branch_ct[ /* n - 1 */ ][2], |
| 51 const unsigned int num_events[ /* n */ ]); | 22 const unsigned int num_events[ /* n */ ]); |
| 52 | 23 |
| 53 struct vp9_token { | 24 struct vp9_token { |
| 54 int value; | 25 int value; |
| 55 int len; | 26 int len; |
| 56 }; | 27 }; |
| 57 | 28 |
| 58 void vp9_tokens_from_tree(struct vp9_token*, const vp9_tree_index *); | 29 void vp9_tokens_from_tree(struct vp9_token*, const vp9_tree_index *); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 71 const vp9_prob *probs, | 42 const vp9_prob *probs, |
| 72 const struct vp9_token *token) { | 43 const struct vp9_token *token) { |
| 73 vp9_write_tree(w, tree, probs, token->value, token->len, 0); | 44 vp9_write_tree(w, tree, probs, token->value, token->len, 0); |
| 74 } | 45 } |
| 75 | 46 |
| 76 #ifdef __cplusplus | 47 #ifdef __cplusplus |
| 77 } // extern "C" | 48 } // extern "C" |
| 78 #endif | 49 #endif |
| 79 | 50 |
| 80 #endif // VP9_ENCODER_VP9_TREEWRITER_H_ | 51 #endif // VP9_ENCODER_VP9_TREEWRITER_H_ |
| OLD | NEW |