michael@0: /* michael@0: * Copyright (c) 2010 The WebM project authors. All Rights Reserved. michael@0: * michael@0: * Use of this source code is governed by a BSD-style license michael@0: * that can be found in the LICENSE file in the root of the source michael@0: * tree. An additional intellectual property rights grant can be found michael@0: * in the file PATENTS. All contributing project authors may michael@0: * be found in the AUTHORS file in the root of the source tree. michael@0: */ michael@0: michael@0: michael@0: #include "treewriter.h" michael@0: michael@0: static void cost( michael@0: int *const C, michael@0: vp8_tree T, michael@0: const vp8_prob *const P, michael@0: int i, michael@0: int c michael@0: ) michael@0: { michael@0: const vp8_prob p = P [i>>1]; michael@0: michael@0: do michael@0: { michael@0: const vp8_tree_index j = T[i]; michael@0: const int d = c + vp8_cost_bit(p, i & 1); michael@0: michael@0: if (j <= 0) michael@0: C[-j] = d; michael@0: else michael@0: cost(C, T, P, j, d); michael@0: } michael@0: while (++i & 1); michael@0: } michael@0: void vp8_cost_tokens(int *c, const vp8_prob *p, vp8_tree t) michael@0: { michael@0: cost(c, t, p, 0, 0); michael@0: } michael@0: void vp8_cost_tokens2(int *c, const vp8_prob *p, vp8_tree t,int start) michael@0: { michael@0: cost(c, t, p, start, 0); michael@0: }