prob.c 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * Copyright (c) 2013 The WebM project authors. All Rights Reserved.
  3. *
  4. * Use of this source code is governed by a BSD-style license
  5. * that can be found in the LICENSE file in the root of the source
  6. * tree. An additional intellectual property rights grant can be found
  7. * in the file PATENTS. All contributing project authors may
  8. * be found in the AUTHORS file in the root of the source tree.
  9. */
  10. #include "./prob.h"
  11. const uint8_t vpx_norm[256] = {
  12. 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,
  13. 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,
  14. 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,
  15. 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,
  16. 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,
  17. 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,
  18. 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,
  19. 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,
  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
  22. };
  23. static unsigned int tree_merge_probs_impl(unsigned int i,
  24. const vpx_tree_index *tree,
  25. const vpx_prob *pre_probs,
  26. const unsigned int *counts,
  27. vpx_prob *probs) {
  28. const int l = tree[i];
  29. const unsigned int left_count =
  30. (l <= 0) ? counts[-l]
  31. : tree_merge_probs_impl(l, tree, pre_probs, counts, probs);
  32. const int r = tree[i + 1];
  33. const unsigned int right_count =
  34. (r <= 0) ? counts[-r]
  35. : tree_merge_probs_impl(r, tree, pre_probs, counts, probs);
  36. const unsigned int ct[2] = { left_count, right_count };
  37. probs[i >> 1] = mode_mv_merge_probs(pre_probs[i >> 1], ct);
  38. return left_count + right_count;
  39. }
  40. void vpx_tree_merge_probs(const vpx_tree_index *tree, const vpx_prob *pre_probs,
  41. const unsigned int *counts, vpx_prob *probs) {
  42. tree_merge_probs_impl(0, tree, pre_probs, counts, probs);
  43. }