media/libvpx/vp9/common/vp9_treecoder.c

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /*
michael@0 2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
michael@0 3 *
michael@0 4 * Use of this source code is governed by a BSD-style license
michael@0 5 * that can be found in the LICENSE file in the root of the source
michael@0 6 * tree. An additional intellectual property rights grant can be found
michael@0 7 * in the file PATENTS. All contributing project authors may
michael@0 8 * be found in the AUTHORS file in the root of the source tree.
michael@0 9 */
michael@0 10
michael@0 11
michael@0 12 #include <assert.h>
michael@0 13
michael@0 14 #include "./vpx_config.h"
michael@0 15 #include "vp9/common/vp9_treecoder.h"
michael@0 16
michael@0 17 static void tree2tok(struct vp9_token *const p, vp9_tree t,
michael@0 18 int i, int v, int l) {
michael@0 19 v += v;
michael@0 20 ++l;
michael@0 21
michael@0 22 do {
michael@0 23 const vp9_tree_index j = t[i++];
michael@0 24
michael@0 25 if (j <= 0) {
michael@0 26 p[-j].value = v;
michael@0 27 p[-j].len = l;
michael@0 28 } else {
michael@0 29 tree2tok(p, t, j, v, l);
michael@0 30 }
michael@0 31 } while (++v & 1);
michael@0 32 }
michael@0 33
michael@0 34 void vp9_tokens_from_tree(struct vp9_token *p, vp9_tree t) {
michael@0 35 tree2tok(p, t, 0, 0, 0);
michael@0 36 }
michael@0 37
michael@0 38 static unsigned int convert_distribution(unsigned int i, vp9_tree tree,
michael@0 39 unsigned int branch_ct[][2],
michael@0 40 const unsigned int num_events[]) {
michael@0 41 unsigned int left, right;
michael@0 42
michael@0 43 if (tree[i] <= 0)
michael@0 44 left = num_events[-tree[i]];
michael@0 45 else
michael@0 46 left = convert_distribution(tree[i], tree, branch_ct, num_events);
michael@0 47
michael@0 48 if (tree[i + 1] <= 0)
michael@0 49 right = num_events[-tree[i + 1]];
michael@0 50 else
michael@0 51 right = convert_distribution(tree[i + 1], tree, branch_ct, num_events);
michael@0 52
michael@0 53 branch_ct[i >> 1][0] = left;
michael@0 54 branch_ct[i >> 1][1] = right;
michael@0 55 return left + right;
michael@0 56 }
michael@0 57
michael@0 58 void vp9_tree_probs_from_distribution(vp9_tree tree,
michael@0 59 unsigned int branch_ct[/* n-1 */][2],
michael@0 60 const unsigned int num_events[/* n */]) {
michael@0 61 convert_distribution(0, tree, branch_ct, num_events);
michael@0 62 }
michael@0 63
michael@0 64

mercurial