prob.c 2.23 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
/*
 *  Copyright (c) 2013 The WebM project authors. All Rights Reserved.
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree. An additional intellectual property rights grant can be found
 *  in the file PATENTS.  All contributing project authors may
 *  be found in the AUTHORS file in the root of the source tree.
 */

11
#include "./prob.h"
12

Yaowu Xu's avatar
Yaowu Xu committed
13
const uint8_t vpx_norm[256] = {
14 15 16 17 18 19 20 21 22 23
  0, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
  3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0,
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
24
};
25 26

static unsigned int tree_merge_probs_impl(unsigned int i,
Yaowu Xu's avatar
Yaowu Xu committed
27
                                          const vpx_tree_index *tree,
28
                                          const vpx_prob *pre_probs,
29
                                          const unsigned int *counts,
30
                                          vpx_prob *probs) {
31
  const int l = tree[i];
32 33 34
  const unsigned int left_count =
      (l <= 0) ? counts[-l]
               : tree_merge_probs_impl(l, tree, pre_probs, counts, probs);
35
  const int r = tree[i + 1];
36 37 38
  const unsigned int right_count =
      (r <= 0) ? counts[-r]
               : tree_merge_probs_impl(r, tree, pre_probs, counts, probs);
39
  const unsigned int ct[2] = { left_count, right_count };
Yaowu Xu's avatar
Yaowu Xu committed
40
  probs[i >> 1] = mode_mv_merge_probs(pre_probs[i >> 1], ct);
41 42 43
  return left_count + right_count;
}

Yaowu Xu's avatar
Yaowu Xu committed
44
void vpx_tree_merge_probs(const vpx_tree_index *tree, const vpx_prob *pre_probs,
45
                          const unsigned int *counts, vpx_prob *probs) {
Yaowu Xu's avatar
Yaowu Xu committed
46
  tree_merge_probs_impl(0, tree, pre_probs, counts, probs);
47
}