entropymode.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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. {
  17. int lez = (l->as_int == 0);
  18. int aez = (a->as_int == 0);
  19. int lea = (l->as_int == a->as_int);
  20. if (lea && lez)
  21. return SUBMVREF_LEFT_ABOVE_ZED;
  22. if (lea)
  23. return SUBMVREF_LEFT_ABOVE_SAME;
  24. if (aez)
  25. return SUBMVREF_ABOVE_ZED;
  26. if (lez)
  27. return SUBMVREF_LEFT_ZED;
  28. return SUBMVREF_NORMAL;
  29. }
  30. static const vp8_prob sub_mv_ref_prob [VP8_SUBMVREFS-1] = { 180, 162, 25};
  31. const vp8_prob vp8_sub_mv_ref_prob2 [SUBMVREF_COUNT][VP8_SUBMVREFS-1] =
  32. {
  33. { 147, 136, 18 },
  34. { 106, 145, 1 },
  35. { 179, 121, 1 },
  36. { 223, 1 , 34 },
  37. { 208, 1 , 1 }
  38. };
  39. const vp8_mbsplit vp8_mbsplits [VP8_NUMMBSPLITS] =
  40. {
  41. {
  42. 0, 0, 0, 0,
  43. 0, 0, 0, 0,
  44. 1, 1, 1, 1,
  45. 1, 1, 1, 1,
  46. },
  47. {
  48. 0, 0, 1, 1,
  49. 0, 0, 1, 1,
  50. 0, 0, 1, 1,
  51. 0, 0, 1, 1,
  52. },
  53. {
  54. 0, 0, 1, 1,
  55. 0, 0, 1, 1,
  56. 2, 2, 3, 3,
  57. 2, 2, 3, 3,
  58. },
  59. {
  60. 0, 1, 2, 3,
  61. 4, 5, 6, 7,
  62. 8, 9, 10, 11,
  63. 12, 13, 14, 15,
  64. }
  65. };
  66. const int vp8_mbsplit_count [VP8_NUMMBSPLITS] = { 2, 2, 4, 16};
  67. const vp8_prob vp8_mbsplit_probs [VP8_NUMMBSPLITS-1] = { 110, 111, 150};
  68. /* Array indices are identical to previously-existing INTRAMODECONTEXTNODES. */
  69. const vp8_tree_index vp8_bmode_tree[18] = /* INTRAMODECONTEXTNODE value */
  70. {
  71. -B_DC_PRED, 2, /* 0 = DC_NODE */
  72. -B_TM_PRED, 4, /* 1 = TM_NODE */
  73. -B_VE_PRED, 6, /* 2 = VE_NODE */
  74. 8, 12, /* 3 = COM_NODE */
  75. -B_HE_PRED, 10, /* 4 = HE_NODE */
  76. -B_RD_PRED, -B_VR_PRED, /* 5 = RD_NODE */
  77. -B_LD_PRED, 14, /* 6 = LD_NODE */
  78. -B_VL_PRED, 16, /* 7 = VL_NODE */
  79. -B_HD_PRED, -B_HU_PRED /* 8 = HD_NODE */
  80. };
  81. /* Again, these trees use the same probability indices as their
  82. explicitly-programmed predecessors. */
  83. const vp8_tree_index vp8_ymode_tree[8] =
  84. {
  85. -DC_PRED, 2,
  86. 4, 6,
  87. -V_PRED, -H_PRED,
  88. -TM_PRED, -B_PRED
  89. };
  90. const vp8_tree_index vp8_kf_ymode_tree[8] =
  91. {
  92. -B_PRED, 2,
  93. 4, 6,
  94. -DC_PRED, -V_PRED,
  95. -H_PRED, -TM_PRED
  96. };
  97. const vp8_tree_index vp8_uv_mode_tree[6] =
  98. {
  99. -DC_PRED, 2,
  100. -V_PRED, 4,
  101. -H_PRED, -TM_PRED
  102. };
  103. const vp8_tree_index vp8_mbsplit_tree[6] =
  104. {
  105. -3, 2,
  106. -2, 4,
  107. -0, -1
  108. };
  109. const vp8_tree_index vp8_mv_ref_tree[8] =
  110. {
  111. -ZEROMV, 2,
  112. -NEARESTMV, 4,
  113. -NEARMV, 6,
  114. -NEWMV, -SPLITMV
  115. };
  116. const vp8_tree_index vp8_sub_mv_ref_tree[6] =
  117. {
  118. -LEFT4X4, 2,
  119. -ABOVE4X4, 4,
  120. -ZERO4X4, -NEW4X4
  121. };
  122. const vp8_tree_index vp8_small_mvtree [14] =
  123. {
  124. 2, 8,
  125. 4, 6,
  126. -0, -1,
  127. -2, -3,
  128. 10, 12,
  129. -4, -5,
  130. -6, -7
  131. };
  132. void vp8_init_mbmode_probs(VP8_COMMON *x)
  133. {
  134. memcpy(x->fc.ymode_prob, vp8_ymode_prob, sizeof(vp8_ymode_prob));
  135. memcpy(x->fc.uv_mode_prob, vp8_uv_mode_prob, sizeof(vp8_uv_mode_prob));
  136. memcpy(x->fc.sub_mv_ref_prob, sub_mv_ref_prob, sizeof(sub_mv_ref_prob));
  137. }
  138. void vp8_default_bmode_probs(vp8_prob p [VP8_BINTRAMODES-1])
  139. {
  140. memcpy(p, vp8_bmode_prob, sizeof(vp8_bmode_prob));
  141. }