2013-12-17 00:53:09 +04:00
|
|
|
/*
|
2016-09-02 00:32:49 +03:00
|
|
|
* Copyright (c) 2016, Alliance for Open Media. All rights reserved
|
2013-12-17 00:53:09 +04:00
|
|
|
*
|
2016-09-02 00:32:49 +03:00
|
|
|
* This source code is subject to the terms of the BSD 2 Clause License and
|
|
|
|
* the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
|
|
|
|
* was not distributed with this source code in the LICENSE file, you can
|
|
|
|
* obtain it at www.aomedia.org/license/software. If the Alliance for Open
|
|
|
|
* Media Patent License 1.0 was not distributed with this source code in the
|
|
|
|
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
2013-12-17 00:53:09 +04:00
|
|
|
*/
|
|
|
|
|
2015-07-18 00:09:05 +03:00
|
|
|
#include "./prob.h"
|
2013-12-17 00:53:09 +04:00
|
|
|
|
2016-08-31 00:01:10 +03:00
|
|
|
const uint8_t aom_norm[256] = {
|
2016-08-09 08:59:08 +03:00
|
|
|
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
|
2013-12-17 00:53:09 +04:00
|
|
|
};
|
2014-02-10 19:39:12 +04:00
|
|
|
|
|
|
|
static unsigned int tree_merge_probs_impl(unsigned int i,
|
2016-08-31 00:01:10 +03:00
|
|
|
const aom_tree_index *tree,
|
|
|
|
const aom_prob *pre_probs,
|
2014-02-10 19:39:12 +04:00
|
|
|
const unsigned int *counts,
|
2016-08-31 00:01:10 +03:00
|
|
|
aom_prob *probs) {
|
2014-02-10 19:39:12 +04:00
|
|
|
const int l = tree[i];
|
2016-08-09 08:59:08 +03:00
|
|
|
const unsigned int left_count =
|
|
|
|
(l <= 0) ? counts[-l]
|
|
|
|
: tree_merge_probs_impl(l, tree, pre_probs, counts, probs);
|
2014-02-10 19:39:12 +04:00
|
|
|
const int r = tree[i + 1];
|
2016-08-09 08:59:08 +03:00
|
|
|
const unsigned int right_count =
|
|
|
|
(r <= 0) ? counts[-r]
|
|
|
|
: tree_merge_probs_impl(r, tree, pre_probs, counts, probs);
|
2014-02-10 19:39:12 +04:00
|
|
|
const unsigned int ct[2] = { left_count, right_count };
|
2015-01-23 02:27:43 +03:00
|
|
|
probs[i >> 1] = mode_mv_merge_probs(pre_probs[i >> 1], ct);
|
2014-02-10 19:39:12 +04:00
|
|
|
return left_count + right_count;
|
|
|
|
}
|
|
|
|
|
2016-08-31 00:01:10 +03:00
|
|
|
void aom_tree_merge_probs(const aom_tree_index *tree, const aom_prob *pre_probs,
|
|
|
|
const unsigned int *counts, aom_prob *probs) {
|
2015-01-23 02:27:43 +03:00
|
|
|
tree_merge_probs_impl(0, tree, pre_probs, counts, probs);
|
2014-02-10 19:39:12 +04:00
|
|
|
}
|