blob: 2ebe7f4d8a5a7727eef224e40d5069915beedb4b [file] [log] [blame]
Dmitry Kovalevb5c92612013-12-16 12:53:09 -08001/*
Yaowu Xu9c01aa12016-09-01 14:32:49 -07002 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
Dmitry Kovalevb5c92612013-12-16 12:53:09 -08003 *
Yaowu Xu9c01aa12016-09-01 14:32:49 -07004 * This source code is subject to the terms of the BSD 2 Clause License and
5 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6 * was not distributed with this source code in the LICENSE file, you can
7 * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8 * Media Patent License 1.0 was not distributed with this source code in the
9 * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
Dmitry Kovalevb5c92612013-12-16 12:53:09 -080010 */
11
Yaowu Xu87d2c3c2015-07-17 14:09:05 -070012#include "./prob.h"
Dmitry Kovalevb5c92612013-12-16 12:53:09 -080013
Yaowu Xuf883b422016-08-30 14:01:10 -070014const uint8_t aom_norm[256] = {
clang-format1214cee2016-08-08 22:59:08 -070015 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,
16 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,
17 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,
18 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,
19 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,
20 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,
21 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,
22 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,
23 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
Dmitry Kovalevb5c92612013-12-16 12:53:09 -080025};
Jim Bankoski69f58b42014-02-10 07:39:12 -080026
Jim Bankoski69f58b42014-02-10 07:39:12 -080027static unsigned int tree_merge_probs_impl(unsigned int i,
Yaowu Xuf883b422016-08-30 14:01:10 -070028 const aom_tree_index *tree,
29 const aom_prob *pre_probs,
Jim Bankoski69f58b42014-02-10 07:39:12 -080030 const unsigned int *counts,
Yaowu Xuf883b422016-08-30 14:01:10 -070031 aom_prob *probs) {
Jim Bankoski69f58b42014-02-10 07:39:12 -080032 const int l = tree[i];
clang-format1214cee2016-08-08 22:59:08 -070033 const unsigned int left_count =
34 (l <= 0) ? counts[-l]
35 : tree_merge_probs_impl(l, tree, pre_probs, counts, probs);
Jim Bankoski69f58b42014-02-10 07:39:12 -080036 const int r = tree[i + 1];
clang-format1214cee2016-08-08 22:59:08 -070037 const unsigned int right_count =
38 (r <= 0) ? counts[-r]
39 : tree_merge_probs_impl(r, tree, pre_probs, counts, probs);
Jim Bankoski69f58b42014-02-10 07:39:12 -080040 const unsigned int ct[2] = { left_count, right_count };
Yaowu Xueda17972015-01-22 15:27:43 -080041 probs[i >> 1] = mode_mv_merge_probs(pre_probs[i >> 1], ct);
Jim Bankoski69f58b42014-02-10 07:39:12 -080042 return left_count + right_count;
43}
44
Yaowu Xuf883b422016-08-30 14:01:10 -070045void aom_tree_merge_probs(const aom_tree_index *tree, const aom_prob *pre_probs,
46 const unsigned int *counts, aom_prob *probs) {
Yaowu Xueda17972015-01-22 15:27:43 -080047 tree_merge_probs_impl(0, tree, pre_probs, counts, probs);
Jim Bankoski69f58b42014-02-10 07:39:12 -080048}