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