Dmitry Kovalev | b5c9261 | 2013-12-16 12:53:09 -0800 | [diff] [blame] | 1 | /* |
Yaowu Xu | 9c01aa1 | 2016-09-01 14:32:49 -0700 | [diff] [blame] | 2 | * Copyright (c) 2016, Alliance for Open Media. All rights reserved |
Dmitry Kovalev | b5c9261 | 2013-12-16 12:53:09 -0800 | [diff] [blame] | 3 | * |
Yaowu Xu | 9c01aa1 | 2016-09-01 14:32:49 -0700 | [diff] [blame] | 4 | * 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 Kovalev | b5c9261 | 2013-12-16 12:53:09 -0800 | [diff] [blame] | 10 | */ |
| 11 | |
Yaowu Xu | 87d2c3c | 2015-07-17 14:09:05 -0700 | [diff] [blame] | 12 | #include "./prob.h" |
Dmitry Kovalev | b5c9261 | 2013-12-16 12:53:09 -0800 | [diff] [blame] | 13 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 14 | const uint8_t aom_norm[256] = { |
clang-format | 1214cee | 2016-08-08 22:59:08 -0700 | [diff] [blame] | 15 | 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 Kovalev | b5c9261 | 2013-12-16 12:53:09 -0800 | [diff] [blame] | 25 | }; |
Jim Bankoski | 69f58b4 | 2014-02-10 07:39:12 -0800 | [diff] [blame] | 26 | |
Jim Bankoski | 69f58b4 | 2014-02-10 07:39:12 -0800 | [diff] [blame] | 27 | static unsigned int tree_merge_probs_impl(unsigned int i, |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 28 | const aom_tree_index *tree, |
| 29 | const aom_prob *pre_probs, |
Jim Bankoski | 69f58b4 | 2014-02-10 07:39:12 -0800 | [diff] [blame] | 30 | const unsigned int *counts, |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 31 | aom_prob *probs) { |
Jim Bankoski | 69f58b4 | 2014-02-10 07:39:12 -0800 | [diff] [blame] | 32 | const int l = tree[i]; |
clang-format | 1214cee | 2016-08-08 22:59:08 -0700 | [diff] [blame] | 33 | const unsigned int left_count = |
| 34 | (l <= 0) ? counts[-l] |
| 35 | : tree_merge_probs_impl(l, tree, pre_probs, counts, probs); |
Jim Bankoski | 69f58b4 | 2014-02-10 07:39:12 -0800 | [diff] [blame] | 36 | const int r = tree[i + 1]; |
clang-format | 1214cee | 2016-08-08 22:59:08 -0700 | [diff] [blame] | 37 | const unsigned int right_count = |
| 38 | (r <= 0) ? counts[-r] |
| 39 | : tree_merge_probs_impl(r, tree, pre_probs, counts, probs); |
Jim Bankoski | 69f58b4 | 2014-02-10 07:39:12 -0800 | [diff] [blame] | 40 | const unsigned int ct[2] = { left_count, right_count }; |
Yaowu Xu | eda1797 | 2015-01-22 15:27:43 -0800 | [diff] [blame] | 41 | probs[i >> 1] = mode_mv_merge_probs(pre_probs[i >> 1], ct); |
Jim Bankoski | 69f58b4 | 2014-02-10 07:39:12 -0800 | [diff] [blame] | 42 | return left_count + right_count; |
| 43 | } |
| 44 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 45 | void aom_tree_merge_probs(const aom_tree_index *tree, const aom_prob *pre_probs, |
| 46 | const unsigned int *counts, aom_prob *probs) { |
Yaowu Xu | eda1797 | 2015-01-22 15:27:43 -0800 | [diff] [blame] | 47 | tree_merge_probs_impl(0, tree, pre_probs, counts, probs); |
Jim Bankoski | 69f58b4 | 2014-02-10 07:39:12 -0800 | [diff] [blame] | 48 | } |