Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
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 | } |