Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(250)

Side by Side Diff: source/libvpx/vp9/common/vp9_treecoder.c

Issue 111463005: libvpx: Pull from upstream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11
12 #include <assert.h>
13
14 #include "./vpx_config.h"
15 #include "vp9/common/vp9_treecoder.h"
16
17 static void tree2tok(struct vp9_token *const p, vp9_tree t,
18 int i, int v, int l) {
19 v += v;
20 ++l;
21
22 do {
23 const vp9_tree_index j = t[i++];
24
25 if (j <= 0) {
26 p[-j].value = v;
27 p[-j].len = l;
28 } else {
29 tree2tok(p, t, j, v, l);
30 }
31 } while (++v & 1);
32 }
33
34 void vp9_tokens_from_tree(struct vp9_token *p, vp9_tree t) {
35 tree2tok(p, t, 0, 0, 0);
36 }
37
38 void vp9_tokens_from_tree_offset(struct vp9_token *p, vp9_tree t,
39 int offset) {
40 tree2tok(p - offset, t, 0, 0, 0);
41 }
42
43 static unsigned int convert_distribution(unsigned int i,
44 vp9_tree tree,
45 vp9_prob probs[],
46 unsigned int branch_ct[][2],
47 const unsigned int num_events[],
48 unsigned int tok0_offset) {
49 unsigned int left, right;
50
51 if (tree[i] <= 0) {
52 left = num_events[-tree[i] - tok0_offset];
53 } else {
54 left = convert_distribution(tree[i], tree, probs, branch_ct,
55 num_events, tok0_offset);
56 }
57 if (tree[i + 1] <= 0)
58 right = num_events[-tree[i + 1] - tok0_offset];
59 else
60 right = convert_distribution(tree[i + 1], tree, probs, branch_ct,
61 num_events, tok0_offset);
62
63 probs[i>>1] = get_binary_prob(left, right);
64 branch_ct[i>>1][0] = left;
65 branch_ct[i>>1][1] = right;
66 return left + right;
67 }
68
69 void vp9_tree_probs_from_distribution(vp9_tree tree, vp9_prob probs[/* n-1 */],
70 unsigned int branch_ct[/* n-1 */][2],
71 const unsigned int num_events[/* n */],
72 unsigned int tok0_offset) {
73 convert_distribution(0, tree, probs, branch_ct, num_events, tok0_offset);
74 }
OLDNEW
« no previous file with comments | « source/libvpx/vp9/common/vp9_treecoder.h ('k') | source/libvpx/vp9/common/x86/vp9_idct_intrin_sse2.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698