Initial WebM release
[libvpx.git] / vp8 / encoder / treewriter.c
blobe398044db68704e68eb0f25534e99c7676c5b755
1 /*
2 * Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
4 * Use of this source code is governed by a BSD-style license and patent
5 * grant that can be found in the LICENSE file in the root of the source
6 * tree. All contributing project authors may be found in the AUTHORS
7 * file in the root of the source tree.
8 */
11 #include "treewriter.h"
13 static void cost(
14 int *const C,
15 vp8_tree T,
16 const vp8_prob *const P,
17 int i,
18 int c
21 const vp8_prob p = P [i>>1];
25 const vp8_tree_index j = T[i];
26 const int d = c + vp8_cost_bit(p, i & 1);
28 if (j <= 0)
29 C[-j] = d;
30 else
31 cost(C, T, P, j, d);
33 while (++i & 1);
35 void vp8_cost_tokens(int *c, const vp8_prob *p, vp8_tree t)
37 cost(c, t, p, 0, 0);