media/libvpx/vp9/encoder/vp9_treewriter.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 #include "vp9/encoder/vp9_treewriter.h"
michael@0 12
michael@0 13 static void cost(int *costs, vp9_tree tree, const vp9_prob *probs,
michael@0 14 int i, int c) {
michael@0 15 const vp9_prob prob = probs[i / 2];
michael@0 16 int b;
michael@0 17
michael@0 18 for (b = 0; b <= 1; ++b) {
michael@0 19 const int cc = c + vp9_cost_bit(prob, b);
michael@0 20 const vp9_tree_index ii = tree[i + b];
michael@0 21
michael@0 22 if (ii <= 0)
michael@0 23 costs[-ii] = cc;
michael@0 24 else
michael@0 25 cost(costs, tree, probs, ii, cc);
michael@0 26 }
michael@0 27 }
michael@0 28
michael@0 29 void vp9_cost_tokens(int *costs, const vp9_prob *probs, vp9_tree tree) {
michael@0 30 cost(costs, tree, probs, 0, 0);
michael@0 31 }
michael@0 32
michael@0 33 void vp9_cost_tokens_skip(int *costs, const vp9_prob *probs, vp9_tree tree) {
michael@0 34 assert(tree[0] <= 0 && tree[1] > 0);
michael@0 35
michael@0 36 costs[-tree[0]] = vp9_cost_bit(probs[0], 0);
michael@0 37 cost(costs, tree, probs, 2, 0);
michael@0 38 }

mercurial