media/libvpx/vp9/encoder/vp9_treewriter.c

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/media/libvpx/vp9/encoder/vp9_treewriter.c	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,38 @@
     1.4 +/*
     1.5 + *  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
     1.6 + *
     1.7 + *  Use of this source code is governed by a BSD-style license
     1.8 + *  that can be found in the LICENSE file in the root of the source
     1.9 + *  tree. An additional intellectual property rights grant can be found
    1.10 + *  in the file PATENTS.  All contributing project authors may
    1.11 + *  be found in the AUTHORS file in the root of the source tree.
    1.12 + */
    1.13 +
    1.14 +#include "vp9/encoder/vp9_treewriter.h"
    1.15 +
    1.16 +static void cost(int *costs, vp9_tree tree, const vp9_prob *probs,
    1.17 +                 int i, int c) {
    1.18 +  const vp9_prob prob = probs[i / 2];
    1.19 +  int b;
    1.20 +
    1.21 +  for (b = 0; b <= 1; ++b) {
    1.22 +    const int cc = c + vp9_cost_bit(prob, b);
    1.23 +    const vp9_tree_index ii = tree[i + b];
    1.24 +
    1.25 +    if (ii <= 0)
    1.26 +      costs[-ii] = cc;
    1.27 +    else
    1.28 +      cost(costs, tree, probs, ii, cc);
    1.29 +  }
    1.30 +}
    1.31 +
    1.32 +void vp9_cost_tokens(int *costs, const vp9_prob *probs, vp9_tree tree) {
    1.33 +  cost(costs, tree, probs, 0, 0);
    1.34 +}
    1.35 +
    1.36 +void vp9_cost_tokens_skip(int *costs, const vp9_prob *probs, vp9_tree tree) {
    1.37 +  assert(tree[0] <= 0 && tree[1] > 0);
    1.38 +
    1.39 +  costs[-tree[0]] = vp9_cost_bit(probs[0], 0);
    1.40 +  cost(costs, tree, probs, 2, 0);
    1.41 +}

mercurial