2
0

entropymode.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. * Copyright (c) 2010 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. #define USE_PREBUILT_TABLES
  11. #include "entropymode.h"
  12. #include "entropy.h"
  13. #include "vpx_mem/vpx_mem.h"
  14. #include "vp8_entropymodedata.h"
  15. int vp8_mv_cont(const int_mv *l, const int_mv *a) {
  16. int lez = (l->as_int == 0);
  17. int aez = (a->as_int == 0);
  18. int lea = (l->as_int == a->as_int);
  19. if (lea && lez) return SUBMVREF_LEFT_ABOVE_ZED;
  20. if (lea) return SUBMVREF_LEFT_ABOVE_SAME;
  21. if (aez) return SUBMVREF_ABOVE_ZED;
  22. if (lez) return SUBMVREF_LEFT_ZED;
  23. return SUBMVREF_NORMAL;
  24. }
  25. static const vp8_prob sub_mv_ref_prob[VP8_SUBMVREFS - 1] = { 180, 162, 25 };
  26. const vp8_prob vp8_sub_mv_ref_prob2[SUBMVREF_COUNT][VP8_SUBMVREFS - 1] = {
  27. { 147, 136, 18 },
  28. { 106, 145, 1 },
  29. { 179, 121, 1 },
  30. { 223, 1, 34 },
  31. { 208, 1, 1 }
  32. };
  33. const vp8_mbsplit vp8_mbsplits[VP8_NUMMBSPLITS] = {
  34. { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1 },
  35. { 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1 },
  36. { 0, 0, 1, 1, 0, 0, 1, 1, 2, 2, 3, 3, 2, 2, 3, 3 },
  37. { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }
  38. };
  39. const int vp8_mbsplit_count[VP8_NUMMBSPLITS] = { 2, 2, 4, 16 };
  40. const vp8_prob vp8_mbsplit_probs[VP8_NUMMBSPLITS - 1] = { 110, 111, 150 };
  41. /* Array indices are identical to previously-existing INTRAMODECONTEXTNODES. */
  42. const vp8_tree_index vp8_bmode_tree[18] = /* INTRAMODECONTEXTNODE value */
  43. {
  44. -B_DC_PRED, 2, /* 0 = DC_NODE */
  45. -B_TM_PRED, 4, /* 1 = TM_NODE */
  46. -B_VE_PRED, 6, /* 2 = VE_NODE */
  47. 8, 12, /* 3 = COM_NODE */
  48. -B_HE_PRED, 10, /* 4 = HE_NODE */
  49. -B_RD_PRED, -B_VR_PRED, /* 5 = RD_NODE */
  50. -B_LD_PRED, 14, /* 6 = LD_NODE */
  51. -B_VL_PRED, 16, /* 7 = VL_NODE */
  52. -B_HD_PRED, -B_HU_PRED /* 8 = HD_NODE */
  53. };
  54. /* Again, these trees use the same probability indices as their
  55. explicitly-programmed predecessors. */
  56. const vp8_tree_index vp8_ymode_tree[8] = {
  57. -DC_PRED, 2, 4, 6, -V_PRED, -H_PRED, -TM_PRED, -B_PRED
  58. };
  59. const vp8_tree_index vp8_kf_ymode_tree[8] = { -B_PRED, 2, 4,
  60. 6, -DC_PRED, -V_PRED,
  61. -H_PRED, -TM_PRED };
  62. const vp8_tree_index vp8_uv_mode_tree[6] = { -DC_PRED, 2, -V_PRED,
  63. 4, -H_PRED, -TM_PRED };
  64. const vp8_tree_index vp8_mbsplit_tree[6] = { -3, 2, -2, 4, -0, -1 };
  65. const vp8_tree_index vp8_mv_ref_tree[8] = { -ZEROMV, 2, -NEARESTMV, 4,
  66. -NEARMV, 6, -NEWMV, -SPLITMV };
  67. const vp8_tree_index vp8_sub_mv_ref_tree[6] = { -LEFT4X4, 2, -ABOVE4X4,
  68. 4, -ZERO4X4, -NEW4X4 };
  69. const vp8_tree_index vp8_small_mvtree[14] = { 2, 8, 4, 6, -0, -1, -2,
  70. -3, 10, 12, -4, -5, -6, -7 };
  71. void vp8_init_mbmode_probs(VP8_COMMON *x) {
  72. memcpy(x->fc.ymode_prob, vp8_ymode_prob, sizeof(vp8_ymode_prob));
  73. memcpy(x->fc.uv_mode_prob, vp8_uv_mode_prob, sizeof(vp8_uv_mode_prob));
  74. memcpy(x->fc.sub_mv_ref_prob, sub_mv_ref_prob, sizeof(sub_mv_ref_prob));
  75. }
  76. void vp8_default_bmode_probs(vp8_prob dest[VP8_BINTRAMODES - 1]) {
  77. memcpy(dest, vp8_bmode_prob, sizeof(vp8_bmode_prob));
  78. }