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 | 11 |
12 #include <assert.h> | 12 #include <assert.h> |
13 | 13 |
14 #include "./vpx_config.h" | 14 #include "./vpx_config.h" |
15 #include "vp9/common/vp9_treecoder.h" | 15 #include "vp9/common/vp9_treecoder.h" |
16 | 16 |
17 static void tree2tok(struct vp9_token *const p, vp9_tree t, | 17 static void tree2tok(struct vp9_token *const p, vp9_tree t, |
18 int i, int v, int l) { | 18 int i, int v, int l) { |
19 v += v; | 19 v += v; |
20 ++l; | 20 ++l; |
21 | 21 |
22 do { | 22 do { |
23 const vp9_tree_index j = t[i++]; | 23 const vp9_tree_index j = t[i++]; |
24 | 24 |
25 if (j <= 0) { | 25 if (j <= 0) { |
26 p[-j].value = v; | 26 p[-j].value = v; |
27 p[-j].len = l; | 27 p[-j].len = l; |
28 } else | 28 } else { |
29 tree2tok(p, t, j, v, l); | 29 tree2tok(p, t, j, v, l); |
| 30 } |
30 } while (++v & 1); | 31 } while (++v & 1); |
31 } | 32 } |
32 | 33 |
33 void vp9_tokens_from_tree(struct vp9_token *p, vp9_tree t) { | 34 void vp9_tokens_from_tree(struct vp9_token *p, vp9_tree t) { |
34 tree2tok(p, t, 0, 0, 0); | 35 tree2tok(p, t, 0, 0, 0); |
35 } | 36 } |
36 | 37 |
37 void vp9_tokens_from_tree_offset(struct vp9_token *p, vp9_tree t, | 38 void vp9_tokens_from_tree_offset(struct vp9_token *p, vp9_tree t, |
38 int offset) { | 39 int offset) { |
39 tree2tok(p - offset, t, 0, 0, 0); | 40 tree2tok(p - offset, t, 0, 0, 0); |
(...skipping 18 matching lines...) Expand all Loading... |
58 else | 59 else |
59 right = convert_distribution(tree[i + 1], tree, probs, branch_ct, | 60 right = convert_distribution(tree[i + 1], tree, probs, branch_ct, |
60 num_events, tok0_offset); | 61 num_events, tok0_offset); |
61 | 62 |
62 probs[i>>1] = get_binary_prob(left, right); | 63 probs[i>>1] = get_binary_prob(left, right); |
63 branch_ct[i>>1][0] = left; | 64 branch_ct[i>>1][0] = left; |
64 branch_ct[i>>1][1] = right; | 65 branch_ct[i>>1][1] = right; |
65 return left + right; | 66 return left + right; |
66 } | 67 } |
67 | 68 |
68 void vp9_tree_probs_from_distribution( | 69 void vp9_tree_probs_from_distribution(vp9_tree tree, vp9_prob probs[/* n-1 */], |
69 vp9_tree tree, | 70 unsigned int branch_ct[/* n-1 */][2], |
70 vp9_prob probs [ /* n-1 */ ], | 71 const unsigned int num_events[/* n */], |
71 unsigned int branch_ct [ /* n-1 */ ] [2], | 72 unsigned int tok0_offset) { |
72 const unsigned int num_events[ /* n */ ], | |
73 unsigned int tok0_offset) { | |
74 convert_distribution(0, tree, probs, branch_ct, num_events, tok0_offset); | 73 convert_distribution(0, tree, probs, branch_ct, num_events, tok0_offset); |
75 } | 74 } |
OLD | NEW |