OLD | NEW |
(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 "vp9/encoder/vp9_treewriter.h" |
| 13 |
| 14 static void cost( |
| 15 int *const C, |
| 16 vp9_tree T, |
| 17 const vp9_prob *const P, |
| 18 int i, |
| 19 int c |
| 20 ) { |
| 21 const vp9_prob p = P [i >> 1]; |
| 22 |
| 23 do { |
| 24 const vp9_tree_index j = T[i]; |
| 25 const int d = c + vp9_cost_bit(p, i & 1); |
| 26 |
| 27 if (j <= 0) |
| 28 C[-j] = d; |
| 29 else |
| 30 cost(C, T, P, j, d); |
| 31 } while (++i & 1); |
| 32 } |
| 33 void vp9_cost_tokens(int *c, const vp9_prob *p, vp9_tree t) { |
| 34 cost(c, t, p, 0, 0); |
| 35 } |
| 36 |
| 37 void vp9_cost_tokens_skip(int *c, const vp9_prob *p, vp9_tree t) { |
| 38 cost(c, t, p, 2, 0); |
| 39 } |
OLD | NEW |