blob: d8715c01f3225bc53e2aaf8eee1fe135c7f9d85c [file] [log] [blame]
Yaowu Xuc27fc142016-08-22 16:08:15 -07001/*
Yaowu Xu2ab7ff02016-09-02 12:04:54 -07002 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
Yaowu Xuc27fc142016-08-22 16:08:15 -07003 *
Yaowu Xu2ab7ff02016-09-02 12:04:54 -07004 * This source code is subject to the terms of the BSD 2 Clause License and
5 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6 * was not distributed with this source code in the LICENSE file, you can
7 * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8 * Media Patent License 1.0 was not distributed with this source code in the
9 * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
Yaowu Xuc27fc142016-08-22 16:08:15 -070010 */
11
Yaowu Xuf883b422016-08-30 14:01:10 -070012#include "aom_mem/aom_mem.h"
Yaowu Xuc27fc142016-08-22 16:08:15 -070013
14#include "av1/common/reconinter.h"
Angie Chianged8cd9a2016-10-21 16:44:47 -070015#include "av1/common/scan.h"
Yaowu Xuc27fc142016-08-22 16:08:15 -070016#include "av1/common/onyxc_int.h"
17#include "av1/common/seg_common.h"
18
Nathan E. Egge10ba2be2016-11-16 09:44:26 -050019#if CONFIG_EC_MULTISYMBOL
Urvang Joshi6be4a542016-11-03 15:24:05 -070020aom_cdf_prob av1_kf_y_mode_cdf[INTRA_MODES][INTRA_MODES][INTRA_MODES];
21#endif
22
23#if CONFIG_ALT_INTRA
24
25const aom_prob av1_kf_y_mode_prob[INTRA_MODES][INTRA_MODES][INTRA_MODES - 1] = {
26 {
27 // above = dc
28 { 121, 30, 54, 128, 164, 158, 45, 41, 57, 91 }, // left = dc
29 { 91, 38, 101, 102, 124, 141, 49, 48, 45, 73 }, // left = v
30 { 66, 28, 27, 177, 225, 178, 32, 27, 52, 114 }, // left = h
31 { 106, 23, 50, 101, 134, 148, 64, 50, 49, 107 }, // left = d45
32 { 75, 24, 32, 118, 66, 143, 42, 28, 57, 74 }, // left = d135
33 { 95, 24, 40, 142, 56, 141, 72, 121, 129, 255 }, // left = d117
34 { 71, 14, 25, 126, 117, 201, 28, 21, 117, 89 }, // left = d153
35 { 85, 16, 37, 110, 163, 178, 41, 28, 48, 134 }, // left = d207
36 { 86, 25, 32, 83, 105, 133, 58, 81, 46, 95 }, // left = d63
37 { 79, 25, 38, 75, 150, 255, 30, 49, 34, 51 }, // left = smooth
38 { 68, 59, 48, 122, 193, 158, 43, 46, 46, 112 }, // left = paeth
39 },
40 {
41 // above = v
42 { 66, 21, 118, 111, 145, 107, 27, 50, 27, 54 }, // left = dc
43 { 52, 25, 167, 81, 120, 101, 34, 55, 19, 32 }, // left = v
44 { 56, 18, 72, 134, 208, 139, 31, 34, 27, 89 }, // left = h
45 { 75, 21, 94, 88, 134, 123, 49, 57, 30, 68 }, // left = d45
46 { 54, 18, 95, 96, 78, 107, 33, 49, 28, 65 }, // left = d135
47 { 61, 19, 121, 131, 58, 101, 56, 143, 120, 255 }, // left = d117
48 { 53, 13, 78, 103, 110, 147, 31, 41, 64, 77 }, // left = d153
49 { 69, 14, 78, 93, 167, 121, 31, 39, 25, 113 }, // left = d207
50 { 64, 18, 103, 79, 90, 108, 34, 73, 27, 69 }, // left = d63
51 { 52, 20, 103, 61, 161, 255, 22, 42, 16, 35 }, // left = smooth
52 { 50, 31, 124, 92, 161, 120, 50, 53, 23, 60 }, // left = paeth
53 },
54 {
55 // above = h
56 { 94, 29, 31, 158, 214, 178, 35, 31, 72, 111 }, // left = dc
57 { 72, 37, 72, 149, 184, 177, 43, 40, 53, 105 }, // left = v
58 { 53, 21, 14, 196, 242, 209, 29, 19, 55, 145 }, // left = h
59 { 93, 36, 36, 104, 176, 166, 56, 37, 49, 141 }, // left = d45
60 { 84, 32, 27, 124, 108, 143, 38, 36, 76, 134 }, // left = d135
61 { 82, 31, 47, 142, 122, 161, 83, 73, 126, 255 }, // left = d117
62 { 66, 16, 20, 133, 148, 210, 30, 17, 113, 104 }, // left = d153
63 { 76, 16, 17, 129, 207, 181, 41, 20, 46, 163 }, // left = d207
64 { 72, 38, 21, 100, 142, 171, 37, 70, 49, 111 }, // left = d63
65 { 61, 30, 27, 115, 208, 255, 27, 31, 44, 63 }, // left = smooth
66 { 53, 45, 29, 157, 222, 185, 49, 37, 55, 102 }, // left = paeth
67 },
68 {
69 // above = d45
70 { 96, 18, 37, 98, 138, 154, 68, 56, 59, 96 }, // left = dc
71 { 73, 18, 92, 81, 125, 132, 75, 64, 27, 67 }, // left = v
72 { 73, 17, 27, 128, 213, 154, 56, 44, 32, 105 }, // left = h
73 { 101, 20, 21, 75, 138, 138, 82, 56, 23, 154 }, // left = d45
74 { 71, 15, 33, 91, 70, 150, 62, 55, 38, 118 }, // left = d135
75 { 80, 19, 38, 116, 69, 122, 88, 132, 92, 255 }, // left = d117
76 { 68, 11, 22, 101, 116, 179, 52, 44, 85, 96 }, // left = d153
77 { 101, 8, 59, 77, 151, 170, 53, 41, 35, 172 }, // left = d207
78 { 82, 19, 24, 81, 172, 129, 82, 128, 43, 108 }, // left = d63
79 { 66, 18, 42, 64, 143, 255, 52, 52, 25, 83 }, // left = smooth
80 { 57, 24, 42, 85, 169, 145, 104, 71, 34, 86 }, // left = paeth
81 },
82 {
83 // above = d135
84 { 85, 15, 29, 113, 83, 176, 26, 29, 70, 110 }, // left = dc
85 { 78, 28, 49, 111, 91, 141, 30, 42, 48, 75 }, // left = v
86 { 56, 21, 16, 146, 190, 178, 23, 31, 49, 92 }, // left = h
87 { 70, 19, 20, 65, 90, 173, 97, 36, 57, 98 }, // left = d45
88 { 77, 14, 26, 110, 51, 156, 34, 35, 54, 74 }, // left = d135
89 { 78, 18, 36, 153, 47, 131, 62, 102, 155, 255 }, // left = d117
90 { 56, 11, 15, 115, 85, 196, 32, 45, 81, 96 }, // left = d153
91 { 90, 18, 24, 95, 126, 159, 34, 31, 46, 136 }, // left = d207
92 { 80, 23, 28, 90, 75, 141, 39, 50, 46, 87 }, // left = d63
93 { 63, 22, 31, 91, 110, 255, 26, 43, 51, 51 }, // left = smooth
94 { 66, 32, 31, 122, 145, 165, 40, 43, 56, 79 }, // left = paeth
95 },
96 {
97 // above = d117
98 { 81, 16, 61, 170, 74, 105, 54, 105, 113, 255 }, // left = dc
99 { 74, 20, 86, 163, 64, 97, 65, 129, 101, 255 }, // left = v
100 { 63, 15, 47, 168, 141, 176, 69, 77, 77, 255 }, // left = h
101 { 70, 17, 59, 97, 78, 114, 74, 122, 80, 255 }, // left = d45
102 { 78, 13, 50, 153, 34, 126, 75, 114, 120, 255 }, // left = d135
103 { 72, 16, 69, 159, 28, 108, 63, 134, 107, 255 }, // left = d117
104 { 66, 9, 47, 131, 79, 148, 41, 88, 105, 255 }, // left = d153
105 { 78, 12, 60, 119, 105, 133, 47, 95, 63, 255 }, // left = d207
106 { 82, 21, 58, 128, 61, 98, 64, 136, 91, 255 }, // left = d63
107 { 23, 26, 28, 96, 85, 128, 51, 64, 85, 128 }, // left = smooth
108 { 58, 27, 62, 162, 109, 151, 75, 106, 78, 255 }, // left = paeth
109 },
110 {
111 // above = d153
112 { 91, 18, 25, 121, 166, 173, 25, 25, 128, 102 }, // left = dc
113 { 80, 27, 51, 111, 141, 147, 45, 38, 70, 85 }, // left = v
114 { 53, 12, 11, 154, 197, 225, 17, 17, 74, 145 }, // left = h
115 { 93, 27, 23, 111, 143, 188, 43, 39, 69, 112 }, // left = d45
116 { 83, 15, 21, 118, 67, 178, 40, 33, 73, 92 }, // left = d135
117 { 94, 13, 31, 132, 66, 110, 61, 82, 148, 255 }, // left = d117
118 { 76, 9, 11, 96, 105, 201, 16, 13, 157, 97 }, // left = d153
119 { 70, 10, 12, 100, 172, 201, 23, 17, 53, 158 }, // left = d207
120 { 114, 25, 21, 104, 108, 163, 30, 47, 53, 111 }, // left = d63
121 { 70, 16, 21, 80, 157, 255, 25, 30, 81, 69 }, // left = smooth
122 { 87, 32, 26, 120, 191, 168, 32, 33, 70, 118 }, // left = paeth
123 },
124 {
125 // above = d207
126 { 98, 20, 39, 122, 168, 188, 38, 36, 54, 132 }, // left = dc
127 { 81, 37, 62, 97, 122, 153, 38, 43, 36, 118 }, // left = v
128 { 71, 21, 22, 154, 227, 183, 37, 31, 46, 140 }, // left = h
129 { 90, 34, 19, 93, 144, 194, 65, 47, 41, 163 }, // left = d45
130 { 78, 20, 27, 91, 93, 173, 57, 52, 49, 113 }, // left = d135
131 { 79, 25, 45, 121, 101, 147, 69, 56, 122, 255 }, // left = d117
132 { 73, 13, 19, 105, 122, 206, 40, 28, 91, 126 }, // left = d153
133 { 101, 14, 22, 87, 153, 169, 33, 25, 26, 175 }, // left = d207
134 { 81, 28, 23, 86, 115, 169, 48, 56, 41, 111 }, // left = d63
135 { 70, 24, 30, 90, 180, 255, 38, 26, 36, 82 }, // left = smooth
136 { 61, 37, 30, 94, 189, 163, 76, 50, 36, 127 }, // left = paeth
137 },
138 {
139 // above = d63
140 { 77, 13, 46, 86, 138, 117, 55, 88, 34, 68 }, // left = dc
141 { 68, 17, 80, 64, 105, 108, 66, 115, 32, 45 }, // left = v
142 { 62, 13, 37, 124, 210, 131, 46, 57, 28, 103 }, // left = h
143 { 88, 15, 45, 73, 134, 145, 73, 101, 37, 87 }, // left = d45
144 { 68, 16, 35, 78, 81, 133, 54, 71, 33, 67 }, // left = d135
145 { 71, 16, 57, 108, 61, 135, 71, 184, 113, 255 }, // left = d117
146 { 55, 10, 27, 69, 107, 158, 39, 76, 82, 95 }, // left = d153
147 { 80, 9, 38, 78, 153, 145, 50, 63, 28, 123 }, // left = d207
148 { 86, 12, 33, 49, 107, 135, 64, 134, 57, 89 }, // left = d63
149 { 56, 19, 55, 60, 163, 255, 38, 84, 22, 36 }, // left = smooth
150 { 53, 17, 60, 69, 151, 126, 73, 113, 26, 80 }, // left = paeth
151 },
152 {
153 // above = smooth
154 { 79, 16, 46, 89, 167, 255, 22, 36, 29, 42 }, // left = dc
155 { 63, 22, 88, 71, 131, 255, 26, 41, 21, 35 }, // left = v
156 { 51, 18, 28, 142, 232, 255, 26, 25, 25, 75 }, // left = h
157 { 75, 18, 43, 70, 140, 255, 37, 49, 34, 89 }, // left = d45
158 { 70, 14, 35, 87, 83, 255, 30, 36, 34, 50 }, // left = d135
159 { 23, 26, 28, 96, 85, 128, 51, 64, 85, 128 }, // left = d117
160 { 74, 12, 33, 83, 128, 255, 27, 33, 58, 68 }, // left = d153
161 { 66, 11, 30, 77, 179, 255, 21, 27, 23, 113 }, // left = d207
162 { 68, 22, 40, 65, 118, 255, 28, 61, 30, 50 }, // left = d63
163 { 60, 18, 44, 69, 141, 255, 18, 32, 22, 40 }, // left = smooth
164 { 52, 32, 54, 96, 194, 255, 33, 37, 25, 53 }, // left = paeth
165 },
166 {
167 // above = paeth
168 { 76, 47, 67, 123, 182, 150, 41, 52, 55, 97 }, // left = dc
169 { 69, 40, 125, 102, 138, 138, 42, 55, 32, 70 }, // left = v
170 { 46, 28, 27, 160, 232, 169, 34, 21, 32, 122 }, // left = h
171 { 78, 35, 41, 99, 128, 124, 49, 43, 35, 111 }, // left = d45
172 { 66, 28, 47, 100, 113, 145, 37, 40, 72, 93 }, // left = d135
173 { 77, 37, 76, 134, 124, 124, 65, 122, 88, 255 }, // left = d117
174 { 53, 23, 38, 108, 128, 204, 26, 32, 115, 114 }, // left = d153
175 { 65, 20, 29, 101, 202, 186, 29, 24, 29, 188 }, // left = d207
176 { 71, 24, 49, 81, 126, 151, 36, 65, 28, 93 }, // left = d63
177 { 54, 36, 53, 94, 193, 255, 25, 38, 20, 64 }, // left = smooth
178 { 52, 54, 60, 108, 176, 168, 47, 44, 50, 105 }, // left = paeth
179 },
180};
181
182static const aom_prob default_if_y_probs[BLOCK_SIZE_GROUPS][INTRA_MODES - 1] = {
183 { 88, 16, 47, 133, 143, 150, 70, 48, 84, 122 }, // block_size < 8x8
184 { 75, 26, 51, 120, 158, 157, 44, 45, 56, 102 }, // block_size < 16x16
185 { 73, 24, 60, 115, 184, 164, 26, 36, 32, 63 }, // block_size < 32x32
186 { 96, 27, 50, 107, 221, 148, 16, 22, 14, 39 }, // block_size >= 32x32
187};
188
189static const aom_prob default_uv_probs[INTRA_MODES][INTRA_MODES - 1] = {
190 { 199, 3, 79, 179, 220, 109, 38, 50, 68, 138 }, // y = dc
191 { 17, 2, 219, 136, 131, 58, 21, 106, 23, 41 }, // y = v
192 { 26, 1, 5, 244, 253, 138, 16, 21, 68, 205 }, // y = h
193 { 183, 3, 66, 94, 195, 97, 101, 104, 41, 178 }, // y = d45
194 { 178, 2, 36, 158, 99, 175, 21, 29, 105, 77 }, // y = d135
195 { 154, 3, 65, 219, 40, 48, 45, 95, 146, 255 }, // y = d117
196 { 167, 1, 16, 160, 214, 187, 10, 10, 200, 155 }, // y = d153
197 { 154, 2, 18, 178, 238, 132, 25, 21, 34, 221 }, // y = d207
198 { 153, 4, 76, 85, 157, 90, 38, 165, 46, 104 }, // y = d63
199 { 163, 3, 68, 87, 190, 255, 19, 27, 25, 46 }, // y = smooth
200 { 185, 7, 113, 171, 203, 57, 18, 69, 49, 104 }, // y = paeth
201};
202
203#else
204
Yaowu Xuf883b422016-08-30 14:01:10 -0700205const aom_prob av1_kf_y_mode_prob[INTRA_MODES][INTRA_MODES][INTRA_MODES - 1] = {
206 {
207 // above = dc
208 { 137, 30, 42, 148, 151, 207, 70, 52, 91 }, // left = dc
209 { 92, 45, 102, 136, 116, 180, 74, 90, 100 }, // left = v
210 { 73, 32, 19, 187, 222, 215, 46, 34, 100 }, // left = h
211 { 91, 30, 32, 116, 121, 186, 93, 86, 94 }, // left = d45
212 { 72, 35, 36, 149, 68, 206, 68, 63, 105 }, // left = d135
213 { 73, 31, 28, 138, 57, 124, 55, 122, 151 }, // left = d117
214 { 67, 23, 21, 140, 126, 197, 40, 37, 171 }, // left = d153
215 { 86, 27, 28, 128, 154, 212, 45, 43, 53 }, // left = d207
216 { 74, 32, 27, 107, 86, 160, 63, 134, 102 }, // left = d63
217 { 59, 67, 44, 140, 161, 202, 78, 67, 119 } // left = tm
218 },
219 {
220 // above = v
221 { 63, 36, 126, 146, 123, 158, 60, 90, 96 }, // left = dc
222 { 43, 46, 168, 134, 107, 128, 69, 142, 92 }, // left = v
223 { 44, 29, 68, 159, 201, 177, 50, 57, 77 }, // left = h
224 { 58, 38, 76, 114, 97, 172, 78, 133, 92 }, // left = d45
225 { 46, 41, 76, 140, 63, 184, 69, 112, 57 }, // left = d135
226 { 38, 32, 85, 140, 46, 112, 54, 151, 133 }, // left = d117
227 { 39, 27, 61, 131, 110, 175, 44, 75, 136 }, // left = d153
228 { 52, 30, 74, 113, 130, 175, 51, 64, 58 }, // left = d207
229 { 47, 35, 80, 100, 74, 143, 64, 163, 74 }, // left = d63
230 { 36, 61, 116, 114, 128, 162, 80, 125, 82 } // left = tm
231 },
232 {
233 // above = h
234 { 82, 26, 26, 171, 208, 204, 44, 32, 105 }, // left = dc
235 { 55, 44, 68, 166, 179, 192, 57, 57, 108 }, // left = v
236 { 42, 26, 11, 199, 241, 228, 23, 15, 85 }, // left = h
237 { 68, 42, 19, 131, 160, 199, 55, 52, 83 }, // left = d45
238 { 58, 50, 25, 139, 115, 232, 39, 52, 118 }, // left = d135
239 { 50, 35, 33, 153, 104, 162, 64, 59, 131 }, // left = d117
240 { 44, 24, 16, 150, 177, 202, 33, 19, 156 }, // left = d153
241 { 55, 27, 12, 153, 203, 218, 26, 27, 49 }, // left = d207
242 { 53, 49, 21, 110, 116, 168, 59, 80, 76 }, // left = d63
243 { 38, 72, 19, 168, 203, 212, 50, 50, 107 } // left = tm
244 },
245 {
246 // above = d45
247 { 103, 26, 36, 129, 132, 201, 83, 80, 93 }, // left = dc
248 { 59, 38, 83, 112, 103, 162, 98, 136, 90 }, // left = v
249 { 62, 30, 23, 158, 200, 207, 59, 57, 50 }, // left = h
250 { 67, 30, 29, 84, 86, 191, 102, 91, 59 }, // left = d45
251 { 60, 32, 33, 112, 71, 220, 64, 89, 104 }, // left = d135
252 { 53, 26, 34, 130, 56, 149, 84, 120, 103 }, // left = d117
253 { 53, 21, 23, 133, 109, 210, 56, 77, 172 }, // left = d153
254 { 77, 19, 29, 112, 142, 228, 55, 66, 36 }, // left = d207
255 { 61, 29, 29, 93, 97, 165, 83, 175, 162 }, // left = d63
256 { 47, 47, 43, 114, 137, 181, 100, 99, 95 } // left = tm
257 },
258 {
259 // above = d135
260 { 69, 23, 29, 128, 83, 199, 46, 44, 101 }, // left = dc
261 { 53, 40, 55, 139, 69, 183, 61, 80, 110 }, // left = v
262 { 40, 29, 19, 161, 180, 207, 43, 24, 91 }, // left = h
263 { 60, 34, 19, 105, 61, 198, 53, 64, 89 }, // left = d45
264 { 52, 31, 22, 158, 40, 209, 58, 62, 89 }, // left = d135
265 { 44, 31, 29, 147, 46, 158, 56, 102, 198 }, // left = d117
266 { 35, 19, 12, 135, 87, 209, 41, 45, 167 }, // left = d153
267 { 55, 25, 21, 118, 95, 215, 38, 39, 66 }, // left = d207
268 { 51, 38, 25, 113, 58, 164, 70, 93, 97 }, // left = d63
269 { 47, 54, 34, 146, 108, 203, 72, 103, 151 } // left = tm
270 },
271 {
272 // above = d117
273 { 64, 19, 37, 156, 66, 138, 49, 95, 133 }, // left = dc
274 { 46, 27, 80, 150, 55, 124, 55, 121, 135 }, // left = v
275 { 36, 23, 27, 165, 149, 166, 54, 64, 118 }, // left = h
276 { 53, 21, 36, 131, 63, 163, 60, 109, 81 }, // left = d45
277 { 40, 26, 35, 154, 40, 185, 51, 97, 123 }, // left = d135
278 { 35, 19, 34, 179, 19, 97, 48, 129, 124 }, // left = d117
279 { 36, 20, 26, 136, 62, 164, 33, 77, 154 }, // left = d153
280 { 45, 18, 32, 130, 90, 157, 40, 79, 91 }, // left = d207
281 { 45, 26, 28, 129, 45, 129, 49, 147, 123 }, // left = d63
282 { 38, 44, 51, 136, 74, 162, 57, 97, 121 } // left = tm
283 },
284 {
285 // above = d153
286 { 75, 17, 22, 136, 138, 185, 32, 34, 166 }, // left = dc
287 { 56, 39, 58, 133, 117, 173, 48, 53, 187 }, // left = v
288 { 35, 21, 12, 161, 212, 207, 20, 23, 145 }, // left = h
289 { 56, 29, 19, 117, 109, 181, 55, 68, 112 }, // left = d45
290 { 47, 29, 17, 153, 64, 220, 59, 51, 114 }, // left = d135
291 { 46, 16, 24, 136, 76, 147, 41, 64, 172 }, // left = d117
292 { 34, 17, 11, 108, 152, 187, 13, 15, 209 }, // left = d153
293 { 51, 24, 14, 115, 133, 209, 32, 26, 104 }, // left = d207
294 { 55, 30, 18, 122, 79, 179, 44, 88, 116 }, // left = d63
295 { 37, 49, 25, 129, 168, 164, 41, 54, 148 } // left = tm
296 },
297 {
298 // above = d207
299 { 82, 22, 32, 127, 143, 213, 39, 41, 70 }, // left = dc
300 { 62, 44, 61, 123, 105, 189, 48, 57, 64 }, // left = v
301 { 47, 25, 17, 175, 222, 220, 24, 30, 86 }, // left = h
302 { 68, 36, 17, 106, 102, 206, 59, 74, 74 }, // left = d45
303 { 57, 39, 23, 151, 68, 216, 55, 63, 58 }, // left = d135
304 { 49, 30, 35, 141, 70, 168, 82, 40, 115 }, // left = d117
305 { 51, 25, 15, 136, 129, 202, 38, 35, 139 }, // left = d153
306 { 68, 26, 16, 111, 141, 215, 29, 28, 28 }, // left = d207
307 { 59, 39, 19, 114, 75, 180, 77, 104, 42 }, // left = d63
308 { 40, 61, 26, 126, 152, 206, 61, 59, 93 } // left = tm
309 },
310 {
311 // above = d63
312 { 78, 23, 39, 111, 117, 170, 74, 124, 94 }, // left = dc
313 { 48, 34, 86, 101, 92, 146, 78, 179, 134 }, // left = v
314 { 47, 22, 24, 138, 187, 178, 68, 69, 59 }, // left = h
315 { 56, 25, 33, 105, 112, 187, 95, 177, 129 }, // left = d45
316 { 48, 31, 27, 114, 63, 183, 82, 116, 56 }, // left = d135
317 { 43, 28, 37, 121, 63, 123, 61, 192, 169 }, // left = d117
318 { 42, 17, 24, 109, 97, 177, 56, 76, 122 }, // left = d153
319 { 58, 18, 28, 105, 139, 182, 70, 92, 63 }, // left = d207
320 { 46, 23, 32, 74, 86, 150, 67, 183, 88 }, // left = d63
321 { 36, 38, 48, 92, 122, 165, 88, 137, 91 } // left = tm
322 },
323 {
324 // above = tm
325 { 65, 70, 60, 155, 159, 199, 61, 60, 81 }, // left = dc
326 { 44, 78, 115, 132, 119, 173, 71, 112, 93 }, // left = v
327 { 39, 38, 21, 184, 227, 206, 42, 32, 64 }, // left = h
328 { 58, 47, 36, 124, 137, 193, 80, 82, 78 }, // left = d45
329 { 49, 50, 35, 144, 95, 205, 63, 78, 59 }, // left = d135
330 { 41, 53, 52, 148, 71, 142, 65, 128, 51 }, // left = d117
331 { 40, 36, 28, 143, 143, 202, 40, 55, 137 }, // left = d153
332 { 52, 34, 29, 129, 183, 227, 42, 35, 43 }, // left = d207
333 { 42, 44, 44, 104, 105, 164, 64, 130, 80 }, // left = d63
334 { 43, 81, 53, 140, 169, 204, 68, 84, 72 } // left = tm
335 }
336};
Yaowu Xuc27fc142016-08-22 16:08:15 -0700337
Yaowu Xuf883b422016-08-30 14:01:10 -0700338static const aom_prob default_if_y_probs[BLOCK_SIZE_GROUPS][INTRA_MODES - 1] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700339 { 65, 32, 18, 144, 162, 194, 41, 51, 98 }, // block_size < 8x8
340 { 132, 68, 18, 165, 217, 196, 45, 40, 78 }, // block_size < 16x16
341 { 173, 80, 19, 176, 240, 193, 64, 35, 46 }, // block_size < 32x32
342 { 221, 135, 38, 194, 248, 121, 96, 85, 29 } // block_size >= 32x32
343};
344
Yaowu Xuf883b422016-08-30 14:01:10 -0700345static const aom_prob default_uv_probs[INTRA_MODES][INTRA_MODES - 1] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700346 { 120, 7, 76, 176, 208, 126, 28, 54, 103 }, // y = dc
347 { 48, 12, 154, 155, 139, 90, 34, 117, 119 }, // y = v
348 { 67, 6, 25, 204, 243, 158, 13, 21, 96 }, // y = h
349 { 97, 5, 44, 131, 176, 139, 48, 68, 97 }, // y = d45
350 { 83, 5, 42, 156, 111, 152, 26, 49, 152 }, // y = d135
351 { 80, 5, 58, 178, 74, 83, 33, 62, 145 }, // y = d117
352 { 86, 5, 32, 154, 192, 168, 14, 22, 163 }, // y = d153
353 { 85, 5, 32, 156, 216, 148, 19, 29, 73 }, // y = d207
354 { 77, 7, 64, 116, 132, 122, 37, 126, 120 }, // y = d63
355 { 101, 21, 107, 181, 192, 103, 19, 67, 125 } // y = tm
356};
357
Urvang Joshi6be4a542016-11-03 15:24:05 -0700358#endif // CONFIG_ALT_INTRA
359
Yaowu Xuc27fc142016-08-22 16:08:15 -0700360#if CONFIG_EXT_PARTITION_TYPES
Yaowu Xuf883b422016-08-30 14:01:10 -0700361static const aom_prob
Yaowu Xuc27fc142016-08-22 16:08:15 -0700362 default_partition_probs[PARTITION_CONTEXTS][EXT_PARTITION_TYPES - 1] = {
363 // 8x8 -> 4x4
364 { 199, 122, 141, 128, 128, 128, 128 }, // a/l both not split
365 { 147, 63, 159, 128, 128, 128, 128 }, // a split, l not split
366 { 148, 133, 118, 128, 128, 128, 128 }, // l split, a not split
367 { 121, 104, 114, 128, 128, 128, 128 }, // a/l both split
368 // 16x16 -> 8x8
369 { 174, 73, 87, 128, 128, 128, 128 }, // a/l both not split
370 { 92, 41, 83, 128, 128, 128, 128 }, // a split, l not split
371 { 82, 99, 50, 128, 128, 128, 128 }, // l split, a not split
372 { 53, 39, 39, 128, 128, 128, 128 }, // a/l both split
373 // 32x32 -> 16x16
374 { 177, 58, 59, 128, 128, 128, 128 }, // a/l both not split
375 { 68, 26, 63, 128, 128, 128, 128 }, // a split, l not split
376 { 52, 79, 25, 128, 128, 128, 128 }, // l split, a not split
377 { 17, 14, 12, 128, 128, 128, 128 }, // a/l both split
378 // 64x64 -> 32x32
379 { 222, 34, 30, 128, 128, 128, 128 }, // a/l both not split
380 { 72, 16, 44, 128, 128, 128, 128 }, // a split, l not split
381 { 58, 32, 12, 128, 128, 128, 128 }, // l split, a not split
382 { 10, 7, 6, 128, 128, 128, 128 }, // a/l both split
383#if CONFIG_EXT_PARTITION
384 // 128x128 -> 64x64
385 { 222, 34, 30, 128, 128, 128, 128 }, // a/l both not split
386 { 72, 16, 44, 128, 128, 128, 128 }, // a split, l not split
387 { 58, 32, 12, 128, 128, 128, 128 }, // l split, a not split
388 { 10, 7, 6, 128, 128, 128, 128 }, // a/l both split
389#endif // CONFIG_EXT_PARTITION
390 };
391#else
Yaowu Xuf883b422016-08-30 14:01:10 -0700392static const aom_prob
Yaowu Xuc27fc142016-08-22 16:08:15 -0700393 default_partition_probs[PARTITION_CONTEXTS][PARTITION_TYPES - 1] = {
394 // 8x8 -> 4x4
395 { 199, 122, 141 }, // a/l both not split
396 { 147, 63, 159 }, // a split, l not split
397 { 148, 133, 118 }, // l split, a not split
398 { 121, 104, 114 }, // a/l both split
399 // 16x16 -> 8x8
400 { 174, 73, 87 }, // a/l both not split
401 { 92, 41, 83 }, // a split, l not split
402 { 82, 99, 50 }, // l split, a not split
403 { 53, 39, 39 }, // a/l both split
404 // 32x32 -> 16x16
405 { 177, 58, 59 }, // a/l both not split
406 { 68, 26, 63 }, // a split, l not split
407 { 52, 79, 25 }, // l split, a not split
408 { 17, 14, 12 }, // a/l both split
409 // 64x64 -> 32x32
410 { 222, 34, 30 }, // a/l both not split
411 { 72, 16, 44 }, // a split, l not split
412 { 58, 32, 12 }, // l split, a not split
413 { 10, 7, 6 }, // a/l both split
414#if CONFIG_EXT_PARTITION
415 // 128x128 -> 64x64
416 { 222, 34, 30 }, // a/l both not split
417 { 72, 16, 44 }, // a split, l not split
418 { 58, 32, 12 }, // l split, a not split
419 { 10, 7, 6 }, // a/l both split
420#endif // CONFIG_EXT_PARTITION
421 };
422#endif // CONFIG_EXT_PARTITION_TYPES
423
424#if CONFIG_REF_MV
Yaowu Xuf883b422016-08-30 14:01:10 -0700425static const aom_prob default_newmv_prob[NEWMV_MODE_CONTEXTS] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700426 200, 180, 150, 150, 110, 70, 60,
427};
428
Yaowu Xuf883b422016-08-30 14:01:10 -0700429static const aom_prob default_zeromv_prob[ZEROMV_MODE_CONTEXTS] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700430 192, 64,
431};
432
Yaowu Xuf883b422016-08-30 14:01:10 -0700433static const aom_prob default_refmv_prob[REFMV_MODE_CONTEXTS] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700434 220, 220, 200, 200, 180, 128, 30, 220, 30,
435};
436
Yaowu Xuf883b422016-08-30 14:01:10 -0700437static const aom_prob default_drl_prob[DRL_MODE_CONTEXTS] = { 128, 160, 180,
Yaowu Xuc27fc142016-08-22 16:08:15 -0700438 128, 160 };
439
440#if CONFIG_EXT_INTER
Yaowu Xuf883b422016-08-30 14:01:10 -0700441static const aom_prob default_new2mv_prob = 180;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700442#endif // CONFIG_EXT_INTER
443#endif // CONFIG_REF_MV
444
Yaowu Xuf883b422016-08-30 14:01:10 -0700445static const aom_prob
Yaowu Xuc27fc142016-08-22 16:08:15 -0700446 default_inter_mode_probs[INTER_MODE_CONTEXTS][INTER_MODES - 1] = {
447#if CONFIG_EXT_INTER
448 // TODO(zoeliu): To adjust the initial default probs
449 { 2, 173, 34, 173 }, // 0 = both zero mv
450 { 7, 145, 85, 145 }, // 1 = one zero mv + one a predicted mv
451 { 7, 166, 63, 166 }, // 2 = two predicted mvs
452 { 7, 94, 66, 128 }, // 3 = one predicted/zero and one new mv
453 { 8, 64, 46, 128 }, // 4 = two new mvs
454 { 17, 81, 31, 128 }, // 5 = one intra neighbour + x
455 { 25, 29, 30, 96 }, // 6 = two intra neighbours
456#else
457 { 2, 173, 34 }, // 0 = both zero mv
458 { 7, 145, 85 }, // 1 = one zero mv + one a predicted mv
459 { 7, 166, 63 }, // 2 = two predicted mvs
460 { 7, 94, 66 }, // 3 = one predicted/zero and one new mv
461 { 8, 64, 46 }, // 4 = two new mvs
462 { 17, 81, 31 }, // 5 = one intra neighbour + x
463 { 25, 29, 30 }, // 6 = two intra neighbours
464#endif // CONFIG_EXT_INTER
465 };
466
467#if CONFIG_EXT_INTER
Yaowu Xuf883b422016-08-30 14:01:10 -0700468static const aom_prob default_inter_compound_mode_probs
Yaowu Xuc27fc142016-08-22 16:08:15 -0700469 [INTER_MODE_CONTEXTS][INTER_COMPOUND_MODES - 1] = {
470 { 2, 173, 68, 192, 64, 192, 128, 180, 180 }, // 0 = both zero mv
471 { 7, 145, 160, 192, 64, 192, 128, 180, 180 }, // 1 = 1 zero + 1 predicted
472 { 7, 166, 126, 192, 64, 192, 128, 180, 180 }, // 2 = two predicted mvs
473 { 7, 94, 132, 192, 64, 192, 128, 180, 180 }, // 3 = 1 pred/zero, 1 new
474 { 8, 64, 64, 192, 64, 192, 128, 180, 180 }, // 4 = two new mvs
475 { 17, 81, 52, 192, 64, 192, 128, 180, 180 }, // 5 = one intra neighbour
476 { 25, 29, 50, 192, 64, 192, 128, 180, 180 }, // 6 = two intra neighbours
477 };
478
Sarah Parker2f6ce752016-12-08 15:26:46 -0800479#if CONFIG_COMPOUND_SEGMENT
480static const aom_prob
481 default_compound_type_probs[BLOCK_SIZES][COMPOUND_TYPES - 1] = {
482 { 208, 200 }, { 208, 200 }, { 208, 200 }, { 208, 200 }, { 208, 200 },
483 { 208, 200 }, { 216, 200 }, { 216, 200 }, { 216, 200 }, { 224, 200 },
484 { 224, 200 }, { 240, 200 }, { 240, 200 },
485#if CONFIG_EXT_PARTITION
486 { 255, 200 }, { 255, 200 }, { 255, 200 },
487#endif // CONFIG_EXT_PARTITION
488 };
489#else // !CONFIG_COMPOUND_SEGMENT
Sarah Parker6fddd182016-11-10 20:57:20 -0800490static const aom_prob default_compound_type_probs[BLOCK_SIZES]
491 [COMPOUND_TYPES - 1] = {
492 { 208 }, { 208 }, { 208 },
493 { 208 }, { 208 }, { 208 },
494 { 216 }, { 216 }, { 216 },
495 { 224 }, { 224 }, { 240 },
496 { 240 },
497#if CONFIG_EXT_PARTITION
498 { 255 }, { 255 }, { 255 },
499#endif // CONFIG_EXT_PARTITION
500 };
Sarah Parker2f6ce752016-12-08 15:26:46 -0800501#endif // CONFIG_COMPOUND_SEGMENT
Sarah Parker6fddd182016-11-10 20:57:20 -0800502
Yaowu Xuf883b422016-08-30 14:01:10 -0700503static const aom_prob default_interintra_prob[BLOCK_SIZE_GROUPS] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700504 208, 208, 208, 208,
505};
506
Yaowu Xuf883b422016-08-30 14:01:10 -0700507static const aom_prob
Yaowu Xuc27fc142016-08-22 16:08:15 -0700508 default_interintra_mode_prob[BLOCK_SIZE_GROUPS][INTERINTRA_MODES - 1] = {
509 { 65, 32, 18, 144, 162, 194, 41, 51, 98 }, // block_size < 8x8
510 { 132, 68, 18, 165, 217, 196, 45, 40, 78 }, // block_size < 16x16
511 { 173, 80, 19, 176, 240, 193, 64, 35, 46 }, // block_size < 32x32
512 { 221, 135, 38, 194, 248, 121, 96, 85, 29 } // block_size >= 32x32
513 };
514
Yaowu Xuf883b422016-08-30 14:01:10 -0700515static const aom_prob default_wedge_interintra_prob[BLOCK_SIZES] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700516 208, 208, 208, 208, 208, 208, 216, 216, 216, 224, 224, 224, 240,
517#if CONFIG_EXT_PARTITION
518 208, 208, 208
519#endif // CONFIG_EXT_PARTITION
520};
Yaowu Xuc27fc142016-08-22 16:08:15 -0700521#endif // CONFIG_EXT_INTER
522
523// Change this section appropriately once warped motion is supported
Yue Chencb60b182016-10-13 15:18:22 -0700524#if CONFIG_MOTION_VAR && !CONFIG_WARPED_MOTION
525const aom_tree_index av1_motion_mode_tree[TREE_SIZE(MOTION_MODES)] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700526 -SIMPLE_TRANSLATION, -OBMC_CAUSAL
527};
Yue Chencb60b182016-10-13 15:18:22 -0700528static const aom_prob default_motion_mode_prob[BLOCK_SIZES]
529 [MOTION_MODES - 1] = {
530 { 255 }, { 255 }, { 255 },
531 { 151 }, { 153 }, { 144 },
532 { 178 }, { 165 }, { 160 },
533 { 207 }, { 195 }, { 168 },
534 { 244 },
Yaowu Xuc27fc142016-08-22 16:08:15 -0700535#if CONFIG_EXT_PARTITION
Yue Chencb60b182016-10-13 15:18:22 -0700536 { 252 }, { 252 }, { 252 },
Yaowu Xuc27fc142016-08-22 16:08:15 -0700537#endif // CONFIG_EXT_PARTITION
Yue Chencb60b182016-10-13 15:18:22 -0700538 };
Yaowu Xuc27fc142016-08-22 16:08:15 -0700539
Yue Chencb60b182016-10-13 15:18:22 -0700540#elif !CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
Yaowu Xuc27fc142016-08-22 16:08:15 -0700541
Yue Chencb60b182016-10-13 15:18:22 -0700542const aom_tree_index av1_motion_mode_tree[TREE_SIZE(MOTION_MODES)] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700543 -SIMPLE_TRANSLATION, -WARPED_CAUSAL
544};
Yue Chen69f18e12016-09-08 14:48:15 -0700545
Yue Chencb60b182016-10-13 15:18:22 -0700546static const aom_prob default_motion_mode_prob[BLOCK_SIZES]
547 [MOTION_MODES - 1] = {
548 { 255 }, { 255 }, { 255 },
549 { 151 }, { 153 }, { 144 },
550 { 178 }, { 165 }, { 160 },
551 { 207 }, { 195 }, { 168 },
552 { 244 },
Yaowu Xuc27fc142016-08-22 16:08:15 -0700553#if CONFIG_EXT_PARTITION
Yue Chencb60b182016-10-13 15:18:22 -0700554 { 252 }, { 252 }, { 252 },
Yaowu Xuc27fc142016-08-22 16:08:15 -0700555#endif // CONFIG_EXT_PARTITION
Yue Chencb60b182016-10-13 15:18:22 -0700556 };
Yaowu Xuc27fc142016-08-22 16:08:15 -0700557
Yue Chencb60b182016-10-13 15:18:22 -0700558#elif CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
Yaowu Xuc27fc142016-08-22 16:08:15 -0700559
Yue Chencb60b182016-10-13 15:18:22 -0700560const aom_tree_index av1_motion_mode_tree[TREE_SIZE(MOTION_MODES)] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700561 -SIMPLE_TRANSLATION, 2, -OBMC_CAUSAL, -WARPED_CAUSAL,
562};
Yue Chencb60b182016-10-13 15:18:22 -0700563static const aom_prob default_motion_mode_prob[BLOCK_SIZES][MOTION_MODES - 1] =
Yaowu Xuc27fc142016-08-22 16:08:15 -0700564 {
565 { 255, 200 }, { 255, 200 }, { 255, 200 }, { 151, 200 }, { 153, 200 },
566 { 144, 200 }, { 178, 200 }, { 165, 200 }, { 160, 200 }, { 207, 200 },
567 { 195, 200 }, { 168, 200 }, { 244, 200 },
568#if CONFIG_EXT_PARTITION
569 { 252, 200 }, { 252, 200 }, { 252, 200 },
570#endif // CONFIG_EXT_PARTITION
571 };
Yue Chen69f18e12016-09-08 14:48:15 -0700572
573// Probability for the case that only 1 additional motion mode is allowed
574static const aom_prob default_obmc_prob[BLOCK_SIZES] = {
575 255, 255, 255, 151, 153, 144, 178, 165, 160, 207, 195, 168, 244,
576#if CONFIG_EXT_PARTITION
577 252, 252, 252,
578#endif // CONFIG_EXT_PARTITION
579};
580#endif
Yaowu Xuc27fc142016-08-22 16:08:15 -0700581
Thomas Daviesf6936102016-09-05 16:51:31 +0100582#if CONFIG_DELTA_Q
583static const aom_prob default_delta_q_probs[DELTA_Q_CONTEXTS] = { 220, 220,
584 220 };
585#endif
Nathan E. Eggeecc21ec2016-11-16 09:44:26 -0500586#if CONFIG_EC_MULTISYMBOL
Nathan E. Egge3ef926e2016-09-07 18:20:41 -0400587int av1_intra_mode_ind[INTRA_MODES];
588int av1_intra_mode_inv[INTRA_MODES];
Nathan E. Egge6ec4d102016-09-08 10:41:20 -0400589int av1_inter_mode_ind[INTER_MODES];
590int av1_inter_mode_inv[INTER_MODES];
Nathan E. Eggea59b23d2016-11-16 09:44:26 -0500591#endif
Thomas Daviesf6936102016-09-05 16:51:31 +0100592
Yaowu Xuc27fc142016-08-22 16:08:15 -0700593/* Array indices are identical to previously-existing INTRAMODECONTEXTNODES. */
Urvang Joshi6be4a542016-11-03 15:24:05 -0700594#if CONFIG_ALT_INTRA
595const aom_tree_index av1_intra_mode_tree[TREE_SIZE(INTRA_MODES)] = {
596 -DC_PRED, 2, /* 0 = DC_NODE */
597 -TM_PRED, 4, /* 1 = TM_NODE */
598 -V_PRED, 6, /* 2 = V_NODE */
599 8, 12, /* 3 = COM_NODE */
600 -H_PRED, 10, /* 4 = H_NODE */
601 -D135_PRED, -D117_PRED, /* 5 = D135_NODE */
602 -D45_PRED, 14, /* 6 = D45_NODE */
603 -D63_PRED, 16, /* 7 = D63_NODE */
604 -D153_PRED, 18, /* 8 = D153_NODE */
605 -D207_PRED, -SMOOTH_PRED, /* 9 = D207_NODE */
606};
607#else
Yaowu Xuf883b422016-08-30 14:01:10 -0700608const aom_tree_index av1_intra_mode_tree[TREE_SIZE(INTRA_MODES)] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700609 -DC_PRED, 2, /* 0 = DC_NODE */
610 -TM_PRED, 4, /* 1 = TM_NODE */
611 -V_PRED, 6, /* 2 = V_NODE */
612 8, 12, /* 3 = COM_NODE */
613 -H_PRED, 10, /* 4 = H_NODE */
614 -D135_PRED, -D117_PRED, /* 5 = D135_NODE */
615 -D45_PRED, 14, /* 6 = D45_NODE */
616 -D63_PRED, 16, /* 7 = D63_NODE */
617 -D153_PRED, -D207_PRED /* 8 = D153_NODE */
618};
Urvang Joshi6be4a542016-11-03 15:24:05 -0700619#endif // CONFIG_ALT_INTRA
Yaowu Xuc27fc142016-08-22 16:08:15 -0700620
Yaowu Xuf883b422016-08-30 14:01:10 -0700621const aom_tree_index av1_inter_mode_tree[TREE_SIZE(INTER_MODES)] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700622 -INTER_OFFSET(ZEROMV), 2,
623 -INTER_OFFSET(NEARESTMV), 4,
624#if CONFIG_EXT_INTER
625 -INTER_OFFSET(NEARMV), 6,
626 -INTER_OFFSET(NEWMV), -INTER_OFFSET(NEWFROMNEARMV)
627#else
628 -INTER_OFFSET(NEARMV), -INTER_OFFSET(NEWMV)
629#endif // CONFIG_EXT_INTER
630};
631
632#if CONFIG_EXT_INTER
633/* clang-format off */
Yaowu Xuf883b422016-08-30 14:01:10 -0700634const aom_tree_index av1_interintra_mode_tree[TREE_SIZE(INTERINTRA_MODES)] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700635 -II_DC_PRED, 2, /* 0 = II_DC_NODE */
636 -II_TM_PRED, 4, /* 1 = II_TM_NODE */
637 -II_V_PRED, 6, /* 2 = II_V_NODE */
638 8, 12, /* 3 = II_COM_NODE */
639 -II_H_PRED, 10, /* 4 = II_H_NODE */
640 -II_D135_PRED, -II_D117_PRED, /* 5 = II_D135_NODE */
641 -II_D45_PRED, 14, /* 6 = II_D45_NODE */
642 -II_D63_PRED, 16, /* 7 = II_D63_NODE */
643 -II_D153_PRED, -II_D207_PRED /* 8 = II_D153_NODE */
644};
645
Yaowu Xuf883b422016-08-30 14:01:10 -0700646const aom_tree_index av1_inter_compound_mode_tree
Yaowu Xuc27fc142016-08-22 16:08:15 -0700647 [TREE_SIZE(INTER_COMPOUND_MODES)] = {
648 -INTER_COMPOUND_OFFSET(ZERO_ZEROMV), 2,
649 -INTER_COMPOUND_OFFSET(NEAREST_NEARESTMV), 4,
650 6, -INTER_COMPOUND_OFFSET(NEW_NEWMV),
651 8, 12,
652 -INTER_COMPOUND_OFFSET(NEAR_NEARMV), 10,
653 -INTER_COMPOUND_OFFSET(NEAREST_NEARMV),
654 -INTER_COMPOUND_OFFSET(NEAR_NEARESTMV),
655 14, 16,
656 -INTER_COMPOUND_OFFSET(NEAREST_NEWMV), -INTER_COMPOUND_OFFSET(NEW_NEARESTMV),
657 -INTER_COMPOUND_OFFSET(NEAR_NEWMV), -INTER_COMPOUND_OFFSET(NEW_NEARMV)
658};
Sarah Parker6fddd182016-11-10 20:57:20 -0800659
Sarah Parker2f6ce752016-12-08 15:26:46 -0800660#if CONFIG_COMPOUND_SEGMENT
661const aom_tree_index av1_compound_type_tree[TREE_SIZE(COMPOUND_TYPES)] = {
662 -COMPOUND_AVERAGE, 2, -COMPOUND_WEDGE, -COMPOUND_SEG
663};
664#else // !CONFIG_COMPOUND_SEGMENT
Sarah Parker6fddd182016-11-10 20:57:20 -0800665const aom_tree_index av1_compound_type_tree[TREE_SIZE(COMPOUND_TYPES)] = {
666 -COMPOUND_AVERAGE, -COMPOUND_WEDGE
667};
Sarah Parker2f6ce752016-12-08 15:26:46 -0800668#endif // CONFIG_COMPOUND_SEGMENT
Yaowu Xuc27fc142016-08-22 16:08:15 -0700669/* clang-format on */
670#endif // CONFIG_EXT_INTER
671
Yaowu Xuf883b422016-08-30 14:01:10 -0700672const aom_tree_index av1_partition_tree[TREE_SIZE(PARTITION_TYPES)] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700673 -PARTITION_NONE, 2, -PARTITION_HORZ, 4, -PARTITION_VERT, -PARTITION_SPLIT
674};
675
676#if CONFIG_EXT_PARTITION_TYPES
677/* clang-format off */
Yaowu Xuf883b422016-08-30 14:01:10 -0700678const aom_tree_index av1_ext_partition_tree[TREE_SIZE(EXT_PARTITION_TYPES)] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700679 -PARTITION_NONE, 2,
680 6, 4,
681 8, -PARTITION_SPLIT,
682 -PARTITION_HORZ, 10,
683 -PARTITION_VERT, 12,
684 -PARTITION_HORZ_A, -PARTITION_HORZ_B,
685 -PARTITION_VERT_A, -PARTITION_VERT_B
686};
687/* clang-format on */
688#endif // CONFIG_EXT_PARTITION_TYPES
689
Yaowu Xuf883b422016-08-30 14:01:10 -0700690static const aom_prob default_intra_inter_p[INTRA_INTER_CONTEXTS] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700691 9, 102, 187, 225
692};
693
Yaowu Xuf883b422016-08-30 14:01:10 -0700694static const aom_prob default_comp_inter_p[COMP_INTER_CONTEXTS] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700695 239, 183, 119, 96, 41
696};
697
698#if CONFIG_EXT_REFS
Yaowu Xuf883b422016-08-30 14:01:10 -0700699static const aom_prob default_comp_ref_p[REF_CONTEXTS][FWD_REFS - 1] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700700 // TODO(zoeliu): To adjust the initial prob values.
701 { 33, 16, 16 },
702 { 77, 74, 74 },
703 { 142, 142, 142 },
704 { 172, 170, 170 },
705 { 238, 247, 247 }
706};
Yaowu Xuf883b422016-08-30 14:01:10 -0700707static const aom_prob default_comp_bwdref_p[REF_CONTEXTS][BWD_REFS - 1] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700708 { 16 }, { 74 }, { 142 }, { 170 }, { 247 }
709};
710#else
Yaowu Xuf883b422016-08-30 14:01:10 -0700711static const aom_prob default_comp_ref_p[REF_CONTEXTS][COMP_REFS - 1] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700712 { 50 }, { 126 }, { 123 }, { 221 }, { 226 }
713};
714#endif // CONFIG_EXT_REFS
715
Yaowu Xuf883b422016-08-30 14:01:10 -0700716static const aom_prob default_single_ref_p[REF_CONTEXTS][SINGLE_REFS - 1] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700717#if CONFIG_EXT_REFS
718 { 33, 16, 16, 16, 16 },
719 { 77, 74, 74, 74, 74 },
720 { 142, 142, 142, 142, 142 },
721 { 172, 170, 170, 170, 170 },
722 { 238, 247, 247, 247, 247 }
723#else
724 { 33, 16 }, { 77, 74 }, { 142, 142 }, { 172, 170 }, { 238, 247 }
725#endif // CONFIG_EXT_REFS
726};
727
Urvang Joshib100db72016-10-12 16:28:56 -0700728#if CONFIG_PALETTE
Yaowu Xuf883b422016-08-30 14:01:10 -0700729const aom_tree_index av1_palette_size_tree[TREE_SIZE(PALETTE_SIZES)] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700730 -TWO_COLORS, 2, -THREE_COLORS, 4, -FOUR_COLORS, 6,
731 -FIVE_COLORS, 8, -SIX_COLORS, 10, -SEVEN_COLORS, -EIGHT_COLORS,
732};
733
734// TODO(huisu): tune these probs
Yaowu Xuf883b422016-08-30 14:01:10 -0700735const aom_prob
736 av1_default_palette_y_size_prob[PALETTE_BLOCK_SIZES][PALETTE_SIZES - 1] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700737 { 96, 89, 100, 64, 77, 130 }, { 22, 15, 44, 16, 34, 82 },
738 { 30, 19, 57, 18, 38, 86 }, { 94, 36, 104, 23, 43, 92 },
739 { 116, 76, 107, 46, 65, 105 }, { 112, 82, 94, 40, 70, 112 },
740 { 147, 124, 123, 58, 69, 103 }, { 180, 113, 136, 49, 45, 114 },
741 { 107, 70, 87, 49, 154, 156 }, { 98, 105, 142, 63, 64, 152 },
742#if CONFIG_EXT_PARTITION
743 { 98, 105, 142, 63, 64, 152 }, { 98, 105, 142, 63, 64, 152 },
744 { 98, 105, 142, 63, 64, 152 },
745#endif // CONFIG_EXT_PARTITION
746 };
747
Yaowu Xuf883b422016-08-30 14:01:10 -0700748const aom_prob
749 av1_default_palette_uv_size_prob[PALETTE_BLOCK_SIZES][PALETTE_SIZES - 1] = {
750 { 160, 196, 228, 213, 175, 230 }, { 87, 148, 208, 141, 166, 163 },
751 { 72, 151, 204, 139, 155, 161 }, { 78, 135, 171, 104, 120, 173 },
752 { 59, 92, 131, 78, 92, 142 }, { 75, 118, 149, 84, 90, 128 },
753 { 89, 87, 92, 66, 66, 128 }, { 67, 53, 54, 55, 66, 93 },
754 { 120, 130, 83, 171, 75, 214 }, { 72, 55, 66, 68, 79, 107 },
Yaowu Xuc27fc142016-08-22 16:08:15 -0700755#if CONFIG_EXT_PARTITION
Yaowu Xuf883b422016-08-30 14:01:10 -0700756 { 72, 55, 66, 68, 79, 107 }, { 72, 55, 66, 68, 79, 107 },
757 { 72, 55, 66, 68, 79, 107 },
Yaowu Xuc27fc142016-08-22 16:08:15 -0700758#endif // CONFIG_EXT_PARTITION
Yaowu Xuf883b422016-08-30 14:01:10 -0700759 };
Yaowu Xuc27fc142016-08-22 16:08:15 -0700760
clang-format67948d32016-09-07 22:40:40 -0700761const aom_prob
762 av1_default_palette_y_mode_prob[PALETTE_BLOCK_SIZES]
763 [PALETTE_Y_MODE_CONTEXTS] = {
764 { 240, 180, 100 }, { 240, 180, 100 },
765 { 240, 180, 100 }, { 240, 180, 100 },
766 { 240, 180, 100 }, { 240, 180, 100 },
767 { 240, 180, 100 }, { 240, 180, 100 },
768 { 240, 180, 100 }, { 240, 180, 100 },
Yaowu Xuc27fc142016-08-22 16:08:15 -0700769#if CONFIG_EXT_PARTITION
clang-format67948d32016-09-07 22:40:40 -0700770 { 240, 180, 100 }, { 240, 180, 100 },
771 { 240, 180, 100 },
Yaowu Xuc27fc142016-08-22 16:08:15 -0700772#endif // CONFIG_EXT_PARTITION
clang-format67948d32016-09-07 22:40:40 -0700773 };
Yaowu Xuc27fc142016-08-22 16:08:15 -0700774
Yaowu Xuf883b422016-08-30 14:01:10 -0700775const aom_prob av1_default_palette_uv_mode_prob[2] = { 253, 229 };
Yaowu Xuc27fc142016-08-22 16:08:15 -0700776
Yaowu Xuf883b422016-08-30 14:01:10 -0700777const aom_tree_index
778 av1_palette_color_tree[PALETTE_MAX_SIZE - 1][TREE_SIZE(PALETTE_COLORS)] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700779 { // 2 colors
780 -PALETTE_COLOR_ONE, -PALETTE_COLOR_TWO },
781 { // 3 colors
782 -PALETTE_COLOR_ONE, 2, -PALETTE_COLOR_TWO, -PALETTE_COLOR_THREE },
783 { // 4 colors
784 -PALETTE_COLOR_ONE, 2, -PALETTE_COLOR_TWO, 4, -PALETTE_COLOR_THREE,
785 -PALETTE_COLOR_FOUR },
786 { // 5 colors
787 -PALETTE_COLOR_ONE, 2, -PALETTE_COLOR_TWO, 4, -PALETTE_COLOR_THREE, 6,
788 -PALETTE_COLOR_FOUR, -PALETTE_COLOR_FIVE },
789 { // 6 colors
790 -PALETTE_COLOR_ONE, 2, -PALETTE_COLOR_TWO, 4, -PALETTE_COLOR_THREE, 6,
791 -PALETTE_COLOR_FOUR, 8, -PALETTE_COLOR_FIVE, -PALETTE_COLOR_SIX },
792 { // 7 colors
793 -PALETTE_COLOR_ONE, 2, -PALETTE_COLOR_TWO, 4, -PALETTE_COLOR_THREE, 6,
794 -PALETTE_COLOR_FOUR, 8, -PALETTE_COLOR_FIVE, 10, -PALETTE_COLOR_SIX,
795 -PALETTE_COLOR_SEVEN },
796 { // 8 colors
797 -PALETTE_COLOR_ONE, 2, -PALETTE_COLOR_TWO, 4, -PALETTE_COLOR_THREE, 6,
798 -PALETTE_COLOR_FOUR, 8, -PALETTE_COLOR_FIVE, 10, -PALETTE_COLOR_SIX, 12,
799 -PALETTE_COLOR_SEVEN, -PALETTE_COLOR_EIGHT },
800 };
801
Urvang Joshieb54e0c2016-11-01 15:25:57 -0700802// Note: Has to be non-zero to avoid any asserts triggering.
803#define UNUSED_PROB 128
Yaowu Xuc27fc142016-08-22 16:08:15 -0700804
Urvang Joshieb54e0c2016-11-01 15:25:57 -0700805const aom_prob av1_default_palette_y_color_prob
806 [PALETTE_MAX_SIZE - 1][PALETTE_COLOR_CONTEXTS][PALETTE_COLORS - 1] = {
807 {
808 // 2 colors
809 { 230, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
810 UNUSED_PROB, UNUSED_PROB },
811 { 214, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
812 UNUSED_PROB, UNUSED_PROB },
813 { UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
814 UNUSED_PROB, UNUSED_PROB },
815 { UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
816 UNUSED_PROB, UNUSED_PROB },
817 { UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
818 UNUSED_PROB, UNUSED_PROB },
819 { 240, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
820 UNUSED_PROB, UNUSED_PROB },
821 { 73, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
822 UNUSED_PROB },
823 { UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
824 UNUSED_PROB, UNUSED_PROB },
825 { 130, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
826 UNUSED_PROB, UNUSED_PROB },
827 { 227, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
828 UNUSED_PROB, UNUSED_PROB },
829 { UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
830 UNUSED_PROB, UNUSED_PROB },
831 { 188, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
832 UNUSED_PROB, UNUSED_PROB },
833 { 75, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
834 UNUSED_PROB },
835 { 250, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
836 UNUSED_PROB, UNUSED_PROB },
837 { 223, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
838 UNUSED_PROB, UNUSED_PROB },
839 { 252, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
840 UNUSED_PROB, UNUSED_PROB },
841 },
842 {
843 // 3 colors
844 { 229, 137, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
845 UNUSED_PROB },
846 { 197, 120, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
847 UNUSED_PROB },
848 { 107, 195, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
849 UNUSED_PROB },
850 { UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
851 UNUSED_PROB, UNUSED_PROB },
852 { 27, 151, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
853 UNUSED_PROB },
854 { 230, 130, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
855 UNUSED_PROB },
856 { 37, 230, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
857 UNUSED_PROB },
858 { 67, 221, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
859 UNUSED_PROB },
860 { 124, 230, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
861 UNUSED_PROB },
862 { 195, 109, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
863 UNUSED_PROB },
864 { 99, 122, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
865 UNUSED_PROB },
866 { 205, 208, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
867 UNUSED_PROB },
868 { 40, 235, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
869 UNUSED_PROB },
870 { 251, 132, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
871 UNUSED_PROB },
872 { 237, 186, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
873 UNUSED_PROB },
874 { 253, 112, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
875 UNUSED_PROB },
876 },
877 {
878 // 4 colors
879 { 195, 87, 128, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
880 { 143, 100, 123, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
881 { 94, 124, 119, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
882 { 77, 91, 130, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
883 { 39, 114, 178, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
884 { 222, 94, 125, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
885 { 44, 203, 132, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
886 { 68, 175, 122, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
887 { 110, 187, 124, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
888 { 152, 91, 128, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
889 { 70, 109, 181, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
890 { 133, 113, 164, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
891 { 47, 205, 133, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
892 { 247, 94, 136, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
893 { 205, 122, 146, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
894 { 251, 100, 141, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
895 },
896 {
897 // 5 colors
898 { 195, 65, 84, 125, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
899 { 150, 76, 84, 121, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
900 { 94, 110, 81, 117, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
901 { 79, 85, 91, 139, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
902 { 26, 102, 139, 127, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
903 { 220, 73, 91, 119, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
904 { 38, 203, 86, 127, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
905 { 61, 186, 72, 124, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
906 { 132, 199, 84, 128, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
907 { 172, 52, 62, 120, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
908 { 102, 89, 121, 122, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
909 { 182, 48, 69, 186, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
910 { 36, 206, 87, 126, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
911 { 249, 55, 67, 122, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
912 { 218, 88, 75, 122, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
913 { 253, 64, 80, 119, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
914 },
915 {
916 // 6 colors
917 { 182, 54, 64, 75, 118, UNUSED_PROB, UNUSED_PROB },
918 { 126, 67, 70, 76, 116, UNUSED_PROB, UNUSED_PROB },
919 { 79, 92, 67, 85, 120, UNUSED_PROB, UNUSED_PROB },
920 { 63, 61, 81, 118, 132, UNUSED_PROB, UNUSED_PROB },
921 { 21, 80, 105, 83, 119, UNUSED_PROB, UNUSED_PROB },
922 { 215, 72, 74, 74, 111, UNUSED_PROB, UNUSED_PROB },
923 { 50, 176, 63, 79, 120, UNUSED_PROB, UNUSED_PROB },
924 { 72, 148, 66, 77, 120, UNUSED_PROB, UNUSED_PROB },
925 { 105, 177, 57, 78, 130, UNUSED_PROB, UNUSED_PROB },
926 { 150, 66, 66, 80, 127, UNUSED_PROB, UNUSED_PROB },
927 { 81, 76, 109, 85, 116, UNUSED_PROB, UNUSED_PROB },
928 { 113, 81, 62, 96, 148, UNUSED_PROB, UNUSED_PROB },
929 { 54, 179, 69, 82, 121, UNUSED_PROB, UNUSED_PROB },
930 { 244, 47, 48, 67, 118, UNUSED_PROB, UNUSED_PROB },
931 { 198, 83, 53, 65, 121, UNUSED_PROB, UNUSED_PROB },
932 { 250, 42, 51, 69, 110, UNUSED_PROB, UNUSED_PROB },
933 },
934 {
935 // 7 colors
936 { 182, 45, 54, 62, 74, 113, UNUSED_PROB },
937 { 124, 63, 57, 62, 77, 114, UNUSED_PROB },
938 { 77, 80, 56, 66, 76, 117, UNUSED_PROB },
939 { 63, 57, 69, 98, 85, 131, UNUSED_PROB },
940 { 19, 81, 98, 63, 80, 116, UNUSED_PROB },
941 { 215, 56, 60, 63, 68, 105, UNUSED_PROB },
942 { 50, 174, 50, 60, 79, 118, UNUSED_PROB },
943 { 68, 151, 50, 58, 73, 117, UNUSED_PROB },
944 { 104, 182, 53, 57, 79, 127, UNUSED_PROB },
945 { 156, 50, 51, 63, 77, 111, UNUSED_PROB },
946 { 88, 67, 97, 59, 82, 120, UNUSED_PROB },
947 { 114, 81, 46, 65, 103, 132, UNUSED_PROB },
948 { 55, 166, 57, 66, 82, 120, UNUSED_PROB },
949 { 245, 34, 38, 43, 63, 114, UNUSED_PROB },
950 { 203, 68, 45, 47, 60, 118, UNUSED_PROB },
951 { 250, 35, 37, 47, 66, 110, UNUSED_PROB },
952 },
953 {
954 // 8 colors
955 { 180, 43, 46, 50, 56, 69, 109 },
956 { 116, 53, 51, 49, 57, 73, 115 },
957 { 79, 70, 49, 50, 59, 74, 117 },
958 { 60, 54, 57, 70, 62, 83, 129 },
959 { 20, 73, 85, 52, 66, 81, 119 },
960 { 213, 56, 52, 49, 53, 62, 104 },
961 { 48, 161, 41, 45, 56, 77, 116 },
962 { 68, 139, 40, 47, 54, 71, 116 },
963 { 123, 166, 42, 43, 52, 76, 130 },
964 { 153, 44, 44, 47, 54, 79, 129 },
965 { 87, 64, 83, 49, 60, 75, 127 },
966 { 131, 68, 43, 48, 73, 96, 130 },
967 { 55, 152, 45, 51, 64, 77, 113 },
968 { 243, 30, 28, 33, 41, 65, 114 },
969 { 202, 56, 35, 36, 42, 63, 123 },
970 { 249, 31, 29, 32, 45, 68, 111 },
971 }
972 };
973
974const aom_prob av1_default_palette_uv_color_prob
975 [PALETTE_MAX_SIZE - 1][PALETTE_COLOR_CONTEXTS][PALETTE_COLORS - 1] = {
976 {
977 // 2 colors
978 { 228, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
979 UNUSED_PROB, UNUSED_PROB },
980 { 195, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
981 UNUSED_PROB, UNUSED_PROB },
982 { UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
983 UNUSED_PROB, UNUSED_PROB },
984 { UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
985 UNUSED_PROB, UNUSED_PROB },
986 { UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
987 UNUSED_PROB, UNUSED_PROB },
988 { 228, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
989 UNUSED_PROB, UNUSED_PROB },
990 { 71, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
991 UNUSED_PROB },
992 { UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
993 UNUSED_PROB, UNUSED_PROB },
994 { 129, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
995 UNUSED_PROB, UNUSED_PROB },
996 { 206, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
997 UNUSED_PROB, UNUSED_PROB },
998 { UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
999 UNUSED_PROB, UNUSED_PROB },
1000 { 136, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
1001 UNUSED_PROB, UNUSED_PROB },
1002 { 98, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
1003 UNUSED_PROB },
1004 { 236, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
1005 UNUSED_PROB, UNUSED_PROB },
1006 { 222, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
1007 UNUSED_PROB, UNUSED_PROB },
1008 { 249, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
1009 UNUSED_PROB, UNUSED_PROB },
1010 },
1011 {
1012 // 3 colors
1013 { 198, 136, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
1014 UNUSED_PROB },
1015 { 178, 105, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
1016 UNUSED_PROB },
1017 { 100, 206, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
1018 UNUSED_PROB },
1019 { UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
1020 UNUSED_PROB, UNUSED_PROB },
1021 { 12, 136, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
1022 UNUSED_PROB },
1023 { 219, 134, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
1024 UNUSED_PROB },
1025 { 50, 198, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
1026 UNUSED_PROB },
1027 { 61, 231, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
1028 UNUSED_PROB },
1029 { 110, 209, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
1030 UNUSED_PROB },
1031 { 173, 106, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
1032 UNUSED_PROB },
1033 { 145, 166, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
1034 UNUSED_PROB },
1035 { 156, 175, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
1036 UNUSED_PROB },
1037 { 69, 183, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
1038 UNUSED_PROB },
1039 { 241, 163, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
1040 UNUSED_PROB },
1041 { 224, 160, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
1042 UNUSED_PROB },
1043 { 246, 154, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
1044 UNUSED_PROB },
1045 },
1046 {
1047 // 4 colors
1048 { 173, 88, 143, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
1049 { 146, 81, 127, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
1050 { 84, 134, 102, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
1051 { 69, 138, 140, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
1052 { 31, 103, 200, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
1053 { 217, 101, 139, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
1054 { 51, 174, 121, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
1055 { 64, 177, 109, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
1056 { 96, 179, 145, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
1057 { 164, 77, 114, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
1058 { 87, 94, 156, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
1059 { 105, 57, 173, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
1060 { 63, 158, 137, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
1061 { 236, 102, 156, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
1062 { 197, 115, 153, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
1063 { 245, 106, 154, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
1064 },
1065 {
1066 // 5 colors
1067 { 179, 64, 97, 129, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
1068 { 137, 56, 88, 125, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
1069 { 82, 107, 61, 118, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
1070 { 59, 113, 86, 115, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
1071 { 23, 88, 118, 130, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
1072 { 213, 66, 90, 125, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
1073 { 37, 181, 103, 121, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
1074 { 47, 188, 61, 131, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
1075 { 104, 185, 103, 144, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
1076 { 163, 39, 76, 112, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
1077 { 94, 74, 131, 126, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
1078 { 142, 42, 103, 163, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
1079 { 53, 162, 99, 149, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
1080 { 239, 54, 84, 108, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
1081 { 203, 84, 110, 147, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
1082 { 248, 70, 105, 151, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
1083 },
1084 {
1085 // 6 colors
1086 { 189, 50, 67, 90, 130, UNUSED_PROB, UNUSED_PROB },
1087 { 114, 50, 55, 90, 123, UNUSED_PROB, UNUSED_PROB },
1088 { 66, 76, 54, 82, 128, UNUSED_PROB, UNUSED_PROB },
1089 { 43, 69, 69, 80, 129, UNUSED_PROB, UNUSED_PROB },
1090 { 22, 59, 87, 88, 141, UNUSED_PROB, UNUSED_PROB },
1091 { 203, 49, 68, 87, 122, UNUSED_PROB, UNUSED_PROB },
1092 { 43, 157, 74, 104, 146, UNUSED_PROB, UNUSED_PROB },
1093 { 54, 138, 51, 95, 138, UNUSED_PROB, UNUSED_PROB },
1094 { 82, 171, 58, 102, 146, UNUSED_PROB, UNUSED_PROB },
1095 { 129, 38, 59, 64, 168, UNUSED_PROB, UNUSED_PROB },
1096 { 56, 67, 119, 92, 112, UNUSED_PROB, UNUSED_PROB },
1097 { 96, 62, 53, 132, 82, UNUSED_PROB, UNUSED_PROB },
1098 { 60, 147, 77, 108, 145, UNUSED_PROB, UNUSED_PROB },
1099 { 238, 76, 73, 93, 148, UNUSED_PROB, UNUSED_PROB },
1100 { 189, 86, 73, 103, 157, UNUSED_PROB, UNUSED_PROB },
1101 { 246, 62, 75, 83, 167, UNUSED_PROB, UNUSED_PROB },
1102 },
1103 {
1104 // 7 colors
1105 { 179, 42, 51, 73, 99, 134, UNUSED_PROB },
1106 { 119, 52, 52, 61, 64, 114, UNUSED_PROB },
1107 { 53, 77, 35, 65, 71, 131, UNUSED_PROB },
1108 { 38, 70, 51, 68, 89, 144, UNUSED_PROB },
1109 { 23, 65, 128, 73, 97, 131, UNUSED_PROB },
1110 { 210, 47, 52, 63, 81, 143, UNUSED_PROB },
1111 { 42, 159, 57, 68, 98, 143, UNUSED_PROB },
1112 { 49, 153, 45, 82, 93, 143, UNUSED_PROB },
1113 { 81, 169, 52, 72, 113, 151, UNUSED_PROB },
1114 { 136, 46, 35, 56, 75, 96, UNUSED_PROB },
1115 { 57, 84, 109, 47, 107, 131, UNUSED_PROB },
1116 { 128, 78, 57, 36, 128, 85, UNUSED_PROB },
1117 { 54, 149, 68, 77, 94, 153, UNUSED_PROB },
1118 { 243, 58, 50, 71, 81, 167, UNUSED_PROB },
1119 { 189, 92, 64, 70, 121, 173, UNUSED_PROB },
1120 { 248, 35, 38, 51, 82, 201, UNUSED_PROB },
1121 },
1122 {
1123 // 8 colors
1124 { 201, 40, 36, 42, 64, 92, 123 },
1125 { 116, 43, 33, 43, 73, 102, 128 },
1126 { 46, 77, 37, 69, 62, 78, 150 },
1127 { 40, 65, 52, 50, 76, 89, 133 },
1128 { 28, 48, 91, 17, 64, 77, 133 },
1129 { 218, 43, 43, 37, 56, 72, 163 },
1130 { 41, 155, 44, 83, 82, 129, 180 },
1131 { 44, 141, 29, 55, 64, 89, 147 },
1132 { 92, 166, 48, 45, 59, 126, 179 },
1133 { 169, 35, 49, 41, 36, 99, 139 },
1134 { 55, 77, 77, 56, 60, 75, 156 },
1135 { 155, 81, 51, 64, 57, 182, 255 },
1136 { 60, 134, 49, 49, 93, 128, 174 },
1137 { 244, 98, 51, 46, 22, 73, 238 },
1138 { 189, 70, 40, 87, 93, 79, 201 },
1139 { 248, 54, 49, 40, 29, 42, 227 },
1140 }
1141 };
1142
1143#undef UNUSED_PROB
Yaowu Xuc27fc142016-08-22 16:08:15 -07001144
1145static const int palette_color_context_lookup[PALETTE_COLOR_CONTEXTS] = {
1146 // (3, 0, 0, 0), (3, 2, 0, 0), (3, 3, 2, 0), (3, 3, 2, 2),
1147 3993, 4235, 4378, 4380,
1148 // (4, 3, 3, 0), (5, 0, 0, 0), (5, 3, 0, 0), (5, 3, 2, 0),
1149 5720, 6655, 7018, 7040,
1150 // (5, 5, 0, 0), (6, 2, 0, 0), (6, 2, 2, 0), (6, 4, 0, 0),
1151 7260, 8228, 8250, 8470,
1152 // (7, 3, 0, 0), (8, 0, 0, 0), (8, 2, 0, 0), (10, 0, 0, 0)
1153 9680, 10648, 10890, 13310
1154};
Urvang Joshib100db72016-10-12 16:28:56 -07001155#endif // CONFIG_PALETTE
Yaowu Xuc27fc142016-08-22 16:08:15 -07001156
Jingning Hanb4329a22016-11-22 16:20:13 -08001157// The transform size is coded as an offset to the smallest transform
1158// block size.
Jingning Han607fa6a2016-10-26 10:46:28 -07001159const aom_tree_index av1_tx_size_tree[MAX_TX_DEPTH][TREE_SIZE(TX_SIZES)] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -07001160 {
1161 // Max tx_size is 8X8
Jingning Hanb4329a22016-11-22 16:20:13 -08001162 -0, -1,
Yaowu Xuc27fc142016-08-22 16:08:15 -07001163 },
1164 {
1165 // Max tx_size is 16X16
Jingning Hanb4329a22016-11-22 16:20:13 -08001166 -0, 2, -1, -2,
Yaowu Xuc27fc142016-08-22 16:08:15 -07001167 },
1168 {
1169 // Max tx_size is 32X32
Jingning Hanb4329a22016-11-22 16:20:13 -08001170 -0, 2, -1, 4, -2, -3,
Yaowu Xuc27fc142016-08-22 16:08:15 -07001171 },
Debargha Mukherjee18d38f62016-11-17 20:30:16 -08001172#if CONFIG_TX64X64
Debargha Mukherjee25ed5302016-11-22 12:13:41 -08001173 {
1174 // Max tx_size is 64X64
Jingning Hanb4329a22016-11-22 16:20:13 -08001175 -0, 2, -1, 4, -2, 6, -3, -4,
Debargha Mukherjee25ed5302016-11-22 12:13:41 -08001176 },
Debargha Mukherjee18d38f62016-11-17 20:30:16 -08001177#endif // CONFIG_TX64X64
Yaowu Xuc27fc142016-08-22 16:08:15 -07001178};
1179
Jingning Hanaae72a62016-10-25 15:35:29 -07001180static const aom_prob default_tx_size_prob[MAX_TX_DEPTH][TX_SIZE_CONTEXTS]
1181 [MAX_TX_DEPTH] = {
clang-format67948d32016-09-07 22:40:40 -07001182 {
1183 // Max tx_size is 8X8
1184 { 100 },
1185 { 66 },
1186 },
1187 {
1188 // Max tx_size is 16X16
1189 { 20, 152 },
1190 { 15, 101 },
1191 },
1192 {
1193 // Max tx_size is 32X32
1194 { 3, 136, 37 },
1195 { 5, 52, 13 },
1196 },
Debargha Mukherjee18d38f62016-11-17 20:30:16 -08001197#if CONFIG_TX64X64
1198 {
1199 // Max tx_size is 64X64
1200 { 1, 64, 136, 127 },
1201 { 1, 32, 52, 67 },
1202 },
1203#endif // CONFIG_TX64X64
clang-format67948d32016-09-07 22:40:40 -07001204 };
Yaowu Xuc27fc142016-08-22 16:08:15 -07001205
Debargha Mukherjee5cd2ab92016-09-08 15:15:17 -07001206#if CONFIG_LOOP_RESTORATION
Debargha Mukherjee8f209a82016-10-12 10:47:01 -07001207const aom_tree_index av1_switchable_restore_tree[TREE_SIZE(
1208 RESTORE_SWITCHABLE_TYPES)] = {
Debargha Mukherjee0e67b252016-12-08 09:22:44 -08001209 -RESTORE_NONE, 2, -RESTORE_WIENER, 4, -RESTORE_SGRPROJ, -RESTORE_DOMAINTXFMRF,
Debargha Mukherjee8f209a82016-10-12 10:47:01 -07001210};
Debargha Mukherjee5cd2ab92016-09-08 15:15:17 -07001211
Debargha Mukherjee0e67b252016-12-08 09:22:44 -08001212static const aom_prob
1213 default_switchable_restore_prob[RESTORE_SWITCHABLE_TYPES - 1] = {
1214 32, 128, 128,
1215 };
Debargha Mukherjee5cd2ab92016-09-08 15:15:17 -07001216#endif // CONFIG_LOOP_RESTORATION
1217
Urvang Joshib100db72016-10-12 16:28:56 -07001218#if CONFIG_PALETTE
Yaowu Xuf883b422016-08-30 14:01:10 -07001219int av1_get_palette_color_context(const uint8_t *color_map, int cols, int r,
Urvang Joshi967ff392016-09-07 14:57:49 -07001220 int c, int n, uint8_t *color_order,
1221 int *color_idx) {
Urvang Joshi4f4b68e2016-10-24 17:11:10 -07001222 int i;
1223 // The +10 below should not be needed. But we get a warning "array subscript
1224 // is above array bounds [-Werror=array-bounds]" without it, possibly due to
1225 // this (or similar) bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59124
Yaowu Xuc27fc142016-08-22 16:08:15 -07001226 int scores[PALETTE_MAX_SIZE + 10];
Urvang Joshi4f4b68e2016-10-24 17:11:10 -07001227 const int weights[4] = { 3, 2, 3, 2 };
Urvang Joshi79f4fc42016-10-26 09:40:35 -07001228 int color_ctx_hash;
1229 int color_ctx;
Yaowu Xuc27fc142016-08-22 16:08:15 -07001230 int color_neighbors[4];
Urvang Joshi967ff392016-09-07 14:57:49 -07001231 int inverse_color_order[PALETTE_MAX_SIZE];
Yaowu Xuc27fc142016-08-22 16:08:15 -07001232 assert(n <= PALETTE_MAX_SIZE);
1233
Urvang Joshi79f4fc42016-10-26 09:40:35 -07001234 // Get color indices of neighbors.
Urvang Joshi4f4b68e2016-10-24 17:11:10 -07001235 color_neighbors[0] = (c - 1 >= 0) ? color_map[r * cols + c - 1] : -1;
1236 color_neighbors[1] =
1237 (c - 1 >= 0 && r - 1 >= 0) ? color_map[(r - 1) * cols + c - 1] : -1;
1238 color_neighbors[2] = (r - 1 >= 0) ? color_map[(r - 1) * cols + c] : -1;
1239 color_neighbors[3] = (r - 1 >= 0 && c + 1 <= cols - 1)
1240 ? color_map[(r - 1) * cols + c + 1]
1241 : -1;
Yaowu Xuc27fc142016-08-22 16:08:15 -07001242
Urvang Joshi967ff392016-09-07 14:57:49 -07001243 for (i = 0; i < PALETTE_MAX_SIZE; ++i) {
1244 color_order[i] = i;
1245 inverse_color_order[i] = i;
1246 }
Yaowu Xuc27fc142016-08-22 16:08:15 -07001247 memset(scores, 0, PALETTE_MAX_SIZE * sizeof(scores[0]));
1248 for (i = 0; i < 4; ++i) {
Urvang Joshi4f4b68e2016-10-24 17:11:10 -07001249 if (color_neighbors[i] >= 0) {
1250 scores[color_neighbors[i]] += weights[i];
1251 }
Yaowu Xuc27fc142016-08-22 16:08:15 -07001252 }
1253
Urvang Joshi4f4b68e2016-10-24 17:11:10 -07001254 // Get the top 4 scores (sorted from large to small).
Yaowu Xuc27fc142016-08-22 16:08:15 -07001255 for (i = 0; i < 4; ++i) {
Urvang Joshi4f4b68e2016-10-24 17:11:10 -07001256 int max = scores[i];
1257 int max_idx = i;
1258 int j;
1259 for (j = i + 1; j < n; ++j) {
Yaowu Xuc27fc142016-08-22 16:08:15 -07001260 if (scores[j] > max) {
1261 max = scores[j];
1262 max_idx = j;
1263 }
Yaowu Xuc27fc142016-08-22 16:08:15 -07001264 }
1265
1266 if (max_idx != i) {
Urvang Joshi4f4b68e2016-10-24 17:11:10 -07001267 int temp = scores[i];
Yaowu Xuc27fc142016-08-22 16:08:15 -07001268 scores[i] = scores[max_idx];
1269 scores[max_idx] = temp;
1270
1271 temp = color_order[i];
1272 color_order[i] = color_order[max_idx];
1273 color_order[max_idx] = temp;
Urvang Joshi967ff392016-09-07 14:57:49 -07001274 inverse_color_order[color_order[i]] = i;
1275 inverse_color_order[color_order[max_idx]] = max_idx;
Yaowu Xuc27fc142016-08-22 16:08:15 -07001276 }
1277 }
1278
Urvang Joshi79f4fc42016-10-26 09:40:35 -07001279 // Get hash value of context.
1280 color_ctx_hash = 0;
1281 for (i = 0; i < 4; ++i) color_ctx_hash = color_ctx_hash * 11 + scores[i];
Yaowu Xuc27fc142016-08-22 16:08:15 -07001282
Urvang Joshi79f4fc42016-10-26 09:40:35 -07001283 // Lookup context from hash.
1284 color_ctx = 0; // Default.
1285 for (i = 0; i < PALETTE_COLOR_CONTEXTS; ++i) {
1286 if (color_ctx_hash == palette_color_context_lookup[i]) {
Yaowu Xuc27fc142016-08-22 16:08:15 -07001287 color_ctx = i;
1288 break;
1289 }
Urvang Joshi79f4fc42016-10-26 09:40:35 -07001290 }
Yaowu Xuc27fc142016-08-22 16:08:15 -07001291
Urvang Joshi967ff392016-09-07 14:57:49 -07001292 if (color_idx != NULL) {
1293 *color_idx = inverse_color_order[color_map[r * cols + c]];
1294 }
Yaowu Xuc27fc142016-08-22 16:08:15 -07001295 return color_ctx;
1296}
Urvang Joshib100db72016-10-12 16:28:56 -07001297#endif // CONFIG_PALETTE
Yaowu Xuc27fc142016-08-22 16:08:15 -07001298
1299#if CONFIG_VAR_TX
Yaowu Xuf883b422016-08-30 14:01:10 -07001300static const aom_prob default_txfm_partition_probs[TXFM_PARTITION_CONTEXTS] = {
Jingning Hanc8b89362016-11-01 10:28:53 -07001301 250, 231, 212, 241, 166, 66, 241, 230, 135, 243, 154, 64, 248, 161, 63, 128,
Yaowu Xuc27fc142016-08-22 16:08:15 -07001302};
1303#endif
1304
Yaowu Xuf883b422016-08-30 14:01:10 -07001305static const aom_prob default_skip_probs[SKIP_CONTEXTS] = { 192, 128, 64 };
Yaowu Xuc27fc142016-08-22 16:08:15 -07001306
Angie Chiang1733f6b2017-01-05 09:52:20 -08001307#if CONFIG_DUAL_FILTER
Angie Chiangd91ab372016-11-21 18:16:49 -08001308static const aom_prob
1309 default_switchable_interp_prob[SWITCHABLE_FILTER_CONTEXTS]
1310 [SWITCHABLE_FILTERS - 1] = {
Angie Chiangd91ab372016-11-21 18:16:49 -08001311 { 235, 192, 128 }, { 36, 243, 48 },
1312 { 34, 16, 128 }, { 34, 16, 128 },
1313 { 149, 160, 128 }, { 235, 192, 128 },
1314 { 36, 243, 48 }, { 34, 16, 128 },
1315 { 34, 16, 128 }, { 149, 160, 128 },
1316 { 235, 192, 128 }, { 36, 243, 48 },
1317 { 34, 16, 128 }, { 34, 16, 128 },
1318 { 149, 160, 128 }, { 235, 192, 128 },
1319 { 36, 243, 48 }, { 34, 16, 128 },
1320 { 34, 16, 128 }, { 149, 160, 128 },
Angie Chiangd91ab372016-11-21 18:16:49 -08001321 };
Angie Chiang1733f6b2017-01-05 09:52:20 -08001322#else // CONFIG_DUAL_FILTER
clang-format67948d32016-09-07 22:40:40 -07001323static const aom_prob default_switchable_interp_prob[SWITCHABLE_FILTER_CONTEXTS]
1324 [SWITCHABLE_FILTERS - 1] = {
1325 { 235, 162 },
1326 { 36, 255 },
1327 { 34, 3 },
1328 { 149, 144 },
1329 };
Angie Chiang1733f6b2017-01-05 09:52:20 -08001330#endif // CONFIG_DUAL_FILTER
Yaowu Xuc27fc142016-08-22 16:08:15 -07001331
1332#if CONFIG_EXT_TX
1333/* clang-format off */
Yaowu Xuf883b422016-08-30 14:01:10 -07001334const aom_tree_index av1_ext_tx_inter_tree[EXT_TX_SETS_INTER]
Yaowu Xuc27fc142016-08-22 16:08:15 -07001335 [TREE_SIZE(TX_TYPES)] = {
1336 { // ToDo(yaowu): remove used entry 0.
1337 0
1338 }, {
1339 -IDTX, 2,
1340 4, 14,
1341 6, 8,
1342 -V_DCT, -H_DCT,
1343 10, 12,
1344 -V_ADST, -H_ADST,
1345 -V_FLIPADST, -H_FLIPADST,
1346 -DCT_DCT, 16,
1347 18, 24,
1348 20, 22,
1349 -ADST_DCT, -DCT_ADST,
1350 -FLIPADST_DCT, -DCT_FLIPADST,
1351 26, 28,
1352 -ADST_ADST, -FLIPADST_FLIPADST,
1353 -ADST_FLIPADST, -FLIPADST_ADST
1354 }, {
1355 -IDTX, 2,
1356 4, 6,
1357 -V_DCT, -H_DCT,
1358 -DCT_DCT, 8,
1359 10, 16,
1360 12, 14,
1361 -ADST_DCT, -DCT_ADST,
1362 -FLIPADST_DCT, -DCT_FLIPADST,
1363 18, 20,
1364 -ADST_ADST, -FLIPADST_FLIPADST,
1365 -ADST_FLIPADST, -FLIPADST_ADST
1366 }, {
1367 -IDTX, -DCT_DCT,
1368 }
1369};
1370
Yaowu Xuf883b422016-08-30 14:01:10 -07001371const aom_tree_index av1_ext_tx_intra_tree[EXT_TX_SETS_INTRA]
Yaowu Xuc27fc142016-08-22 16:08:15 -07001372 [TREE_SIZE(TX_TYPES)] = {
1373 { // ToDo(yaowu): remove unused entry 0.
1374 0
1375 }, {
1376 -IDTX, 2,
1377 -DCT_DCT, 4,
1378 6, 8,
1379 -V_DCT, -H_DCT,
1380 -ADST_ADST, 10,
1381 -ADST_DCT, -DCT_ADST,
1382 }, {
1383 -IDTX, 2,
1384 -DCT_DCT, 4,
1385 -ADST_ADST, 6,
1386 -ADST_DCT, -DCT_ADST,
1387 }
1388};
1389/* clang-format on */
1390
Yaowu Xuf883b422016-08-30 14:01:10 -07001391static const aom_prob
Yaowu Xuc27fc142016-08-22 16:08:15 -07001392 default_inter_ext_tx_prob[EXT_TX_SETS_INTER][EXT_TX_SIZES][TX_TYPES - 1] = {
1393 {
Jingning Han1a00cff2016-12-28 14:53:14 -08001394// ToDo(yaowu): remove unused entry 0.
1395#if CONFIG_CB4X4
1396 { 0 },
1397#endif
Yaowu Xuc27fc142016-08-22 16:08:15 -07001398 { 0 },
1399 { 0 },
1400 { 0 },
Yaowu Xuc27fc142016-08-22 16:08:15 -07001401 { 0 },
Yaowu Xuc27fc142016-08-22 16:08:15 -07001402 },
1403 {
Jingning Han1a00cff2016-12-28 14:53:14 -08001404#if CONFIG_CB4X4
1405 { 0 },
1406#endif
Yaowu Xuc27fc142016-08-22 16:08:15 -07001407 { 10, 24, 30, 128, 128, 128, 128, 112, 160, 128, 128, 128, 128, 128,
1408 128 },
1409 { 10, 24, 30, 128, 128, 128, 128, 112, 160, 128, 128, 128, 128, 128,
1410 128 },
1411 { 10, 24, 30, 128, 128, 128, 128, 112, 160, 128, 128, 128, 128, 128,
1412 128 },
Yaowu Xuc27fc142016-08-22 16:08:15 -07001413 { 10, 24, 30, 128, 128, 128, 128, 112, 160, 128, 128, 128, 128, 128,
1414 128 },
Yaowu Xuc27fc142016-08-22 16:08:15 -07001415 },
1416 {
Jingning Han1a00cff2016-12-28 14:53:14 -08001417#if CONFIG_CB4X4
1418 { 0 },
1419#endif
Yaowu Xuc27fc142016-08-22 16:08:15 -07001420 { 10, 30, 128, 112, 160, 128, 128, 128, 128, 128, 128 },
1421 { 10, 30, 128, 112, 160, 128, 128, 128, 128, 128, 128 },
1422 { 10, 30, 128, 112, 160, 128, 128, 128, 128, 128, 128 },
Yaowu Xuc27fc142016-08-22 16:08:15 -07001423 { 10, 30, 128, 112, 160, 128, 128, 128, 128, 128, 128 },
Yaowu Xuc27fc142016-08-22 16:08:15 -07001424 },
1425 {
Jingning Han1a00cff2016-12-28 14:53:14 -08001426#if CONFIG_CB4X4
1427 { 0 },
1428#endif
1429 { 12 },
1430 { 12 },
1431 { 12 },
1432 { 12 },
Yaowu Xuc27fc142016-08-22 16:08:15 -07001433 }
1434 };
1435
clang-format67948d32016-09-07 22:40:40 -07001436static const aom_prob
1437 default_intra_ext_tx_prob[EXT_TX_SETS_INTRA][EXT_TX_SIZES][INTRA_MODES]
1438 [TX_TYPES - 1] = {
1439 {
Jingning Han1a00cff2016-12-28 14:53:14 -08001440// ToDo(yaowu): remove unused entry 0.
1441#if CONFIG_CB4X4
1442 {
1443 { 0 },
1444 },
1445#endif
clang-format67948d32016-09-07 22:40:40 -07001446 {
1447 { 0 },
1448 { 0 },
1449 { 0 },
1450 { 0 },
1451 { 0 },
1452 { 0 },
1453 { 0 },
1454 { 0 },
1455 { 0 },
1456 { 0 },
1457 },
1458 {
1459 { 0 },
1460 { 0 },
1461 { 0 },
1462 { 0 },
1463 { 0 },
1464 { 0 },
1465 { 0 },
1466 { 0 },
1467 { 0 },
1468 { 0 },
1469 },
1470 {
1471 { 0 },
1472 { 0 },
1473 { 0 },
1474 { 0 },
1475 { 0 },
1476 { 0 },
1477 { 0 },
1478 { 0 },
1479 { 0 },
1480 { 0 },
clang-format67948d32016-09-07 22:40:40 -07001481 },
1482 {
1483 { 0 },
1484 { 0 },
1485 { 0 },
1486 { 0 },
1487 { 0 },
1488 { 0 },
1489 { 0 },
1490 { 0 },
1491 { 0 },
1492 { 0 },
clang-format67948d32016-09-07 22:40:40 -07001493 },
1494 },
1495 {
Jingning Han1a00cff2016-12-28 14:53:14 -08001496#if CONFIG_CB4X4
1497 {
1498 { 0 },
1499 },
1500#endif
clang-format67948d32016-09-07 22:40:40 -07001501 {
1502 { 8, 224, 32, 128, 64, 128 },
1503 { 10, 32, 32, 128, 16, 192 },
1504 { 10, 32, 32, 128, 16, 64 },
1505 { 9, 200, 32, 128, 64, 128 },
1506 { 8, 8, 32, 128, 224, 128 },
1507 { 10, 32, 32, 128, 16, 192 },
1508 { 10, 32, 32, 128, 16, 64 },
1509 { 10, 23, 32, 128, 80, 176 },
1510 { 10, 23, 32, 128, 80, 176 },
1511 { 10, 32, 32, 128, 16, 64 },
1512 },
1513 {
1514 { 8, 224, 32, 128, 64, 128 },
1515 { 10, 32, 32, 128, 16, 192 },
1516 { 10, 32, 32, 128, 16, 64 },
1517 { 9, 200, 32, 128, 64, 128 },
1518 { 8, 8, 32, 128, 224, 128 },
1519 { 10, 32, 32, 128, 16, 192 },
1520 { 10, 32, 32, 128, 16, 64 },
1521 { 10, 23, 32, 128, 80, 176 },
1522 { 10, 23, 32, 128, 80, 176 },
1523 { 10, 32, 32, 128, 16, 64 },
1524 },
1525 {
1526 { 8, 224, 32, 128, 64, 128 },
1527 { 10, 32, 32, 128, 16, 192 },
1528 { 10, 32, 32, 128, 16, 64 },
1529 { 9, 200, 32, 128, 64, 128 },
1530 { 8, 8, 32, 128, 224, 128 },
1531 { 10, 32, 32, 128, 16, 192 },
1532 { 10, 32, 32, 128, 16, 64 },
1533 { 10, 23, 32, 128, 80, 176 },
1534 { 10, 23, 32, 128, 80, 176 },
1535 { 10, 32, 32, 128, 16, 64 },
clang-format67948d32016-09-07 22:40:40 -07001536 },
1537 {
1538 { 8, 224, 32, 128, 64, 128 },
1539 { 10, 32, 32, 128, 16, 192 },
1540 { 10, 32, 32, 128, 16, 64 },
1541 { 9, 200, 32, 128, 64, 128 },
1542 { 8, 8, 32, 128, 224, 128 },
1543 { 10, 32, 32, 128, 16, 192 },
1544 { 10, 32, 32, 128, 16, 64 },
1545 { 10, 23, 32, 128, 80, 176 },
1546 { 10, 23, 32, 128, 80, 176 },
1547 { 10, 32, 32, 128, 16, 64 },
clang-format67948d32016-09-07 22:40:40 -07001548 },
1549 },
1550 {
Jingning Han1a00cff2016-12-28 14:53:14 -08001551#if CONFIG_CB4X4
1552 {
1553 { 0 },
1554 },
1555#endif
clang-format67948d32016-09-07 22:40:40 -07001556 {
1557 { 8, 224, 64, 128 },
1558 { 10, 32, 16, 192 },
1559 { 10, 32, 16, 64 },
1560 { 9, 200, 64, 128 },
1561 { 8, 8, 224, 128 },
1562 { 10, 32, 16, 192 },
1563 { 10, 32, 16, 64 },
1564 { 10, 23, 80, 176 },
1565 { 10, 23, 80, 176 },
1566 { 10, 32, 16, 64 },
1567 },
1568 {
1569 { 8, 224, 64, 128 },
1570 { 10, 32, 16, 192 },
1571 { 10, 32, 16, 64 },
1572 { 9, 200, 64, 128 },
1573 { 8, 8, 224, 128 },
1574 { 10, 32, 16, 192 },
1575 { 10, 32, 16, 64 },
1576 { 10, 23, 80, 176 },
1577 { 10, 23, 80, 176 },
1578 { 10, 32, 16, 64 },
1579 },
1580 {
1581 { 8, 224, 64, 128 },
1582 { 10, 32, 16, 192 },
1583 { 10, 32, 16, 64 },
1584 { 9, 200, 64, 128 },
1585 { 8, 8, 224, 128 },
1586 { 10, 32, 16, 192 },
1587 { 10, 32, 16, 64 },
1588 { 10, 23, 80, 176 },
1589 { 10, 23, 80, 176 },
1590 { 10, 32, 16, 64 },
clang-format67948d32016-09-07 22:40:40 -07001591 },
1592 {
1593 { 8, 224, 64, 128 },
1594 { 10, 32, 16, 192 },
1595 { 10, 32, 16, 64 },
1596 { 9, 200, 64, 128 },
1597 { 8, 8, 224, 128 },
1598 { 10, 32, 16, 192 },
1599 { 10, 32, 16, 64 },
1600 { 10, 23, 80, 176 },
1601 { 10, 23, 80, 176 },
1602 { 10, 32, 16, 64 },
clang-format67948d32016-09-07 22:40:40 -07001603 },
1604 },
1605 };
Yaowu Xuc27fc142016-08-22 16:08:15 -07001606#else
1607
1608/* clang-format off */
Yaowu Xuf883b422016-08-30 14:01:10 -07001609const aom_tree_index av1_ext_tx_tree[TREE_SIZE(TX_TYPES)] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -07001610 -DCT_DCT, 2,
1611 -ADST_ADST, 4,
1612 -ADST_DCT, -DCT_ADST
1613};
1614/* clang-format on */
1615
Nathan E. Egge7c5b4c12016-04-26 12:31:14 -04001616int av1_ext_tx_ind[TX_TYPES];
1617int av1_ext_tx_inv[TX_TYPES];
1618
Yaowu Xuf883b422016-08-30 14:01:10 -07001619static const aom_prob
Yaowu Xuc27fc142016-08-22 16:08:15 -07001620 default_intra_ext_tx_prob[EXT_TX_SIZES][TX_TYPES][TX_TYPES - 1] = {
Jingning Han607fa6a2016-10-26 10:46:28 -07001621#if CONFIG_CB4X4
1622 { { 240, 85, 128 }, { 4, 1, 248 }, { 4, 1, 8 }, { 4, 248, 128 } },
1623#endif
Yaowu Xuc27fc142016-08-22 16:08:15 -07001624 { { 240, 85, 128 }, { 4, 1, 248 }, { 4, 1, 8 }, { 4, 248, 128 } },
1625 { { 244, 85, 128 }, { 8, 2, 248 }, { 8, 2, 8 }, { 8, 248, 128 } },
1626 { { 248, 85, 128 }, { 16, 4, 248 }, { 16, 4, 8 }, { 16, 248, 128 } },
1627 };
1628
Yaowu Xuf883b422016-08-30 14:01:10 -07001629static const aom_prob default_inter_ext_tx_prob[EXT_TX_SIZES][TX_TYPES - 1] = {
Jingning Han607fa6a2016-10-26 10:46:28 -07001630#if CONFIG_CB4X4
1631 { 160, 85, 128 },
1632#endif
1633 { 160, 85, 128 },
1634 { 176, 85, 128 },
1635 { 192, 85, 128 },
Yaowu Xuc27fc142016-08-22 16:08:15 -07001636};
1637#endif // CONFIG_EXT_TX
1638
1639#if CONFIG_EXT_INTRA
hui sueda3d762016-12-06 16:58:23 -08001640#if CONFIG_INTRA_INTERP
clang-format67948d32016-09-07 22:40:40 -07001641static const aom_prob default_intra_filter_probs[INTRA_FILTERS + 1]
1642 [INTRA_FILTERS - 1] = {
1643 { 98, 63, 60 },
1644 { 98, 82, 80 },
1645 { 94, 65, 103 },
1646 { 49, 25, 24 },
1647 { 72, 38, 50 },
1648 };
Yaowu Xuf883b422016-08-30 14:01:10 -07001649const aom_tree_index av1_intra_filter_tree[TREE_SIZE(INTRA_FILTERS)] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -07001650 -INTRA_FILTER_LINEAR, 2, -INTRA_FILTER_8TAP, 4, -INTRA_FILTER_8TAP_SHARP,
1651 -INTRA_FILTER_8TAP_SMOOTH,
1652};
hui sueda3d762016-12-06 16:58:23 -08001653#endif // CONFIG_INTRA_INTERP
Yaowu Xuc27fc142016-08-22 16:08:15 -07001654#endif // CONFIG_EXT_INTRA
1655
hui su5db97432016-10-14 16:10:14 -07001656#if CONFIG_FILTER_INTRA
1657static const aom_prob default_filter_intra_probs[2] = { 230, 230 };
1658#endif // CONFIG_FILTER_INTRA
1659
Yaowu Xuc27fc142016-08-22 16:08:15 -07001660#if CONFIG_SUPERTX
clang-format67948d32016-09-07 22:40:40 -07001661static const aom_prob default_supertx_prob[PARTITION_SUPERTX_CONTEXTS]
1662 [TX_SIZES] = {
Jingning Hanfeb517c2016-12-21 16:02:07 -08001663#if CONFIG_CB4X4
1664#if CONFIG_TX64X64
1665 { 1, 1, 160, 160, 170, 180 },
1666 { 1, 1, 200, 200, 210, 220 },
1667#else
1668 { 1, 1, 160, 160, 170 },
1669 { 1, 1, 200, 200, 210 },
1670#endif // CONFIG_TX64X64
1671#else
Debargha Mukherjee5a488a62016-11-22 22:24:10 -08001672#if CONFIG_TX64X64
1673 { 1, 160, 160, 170, 180 },
1674 { 1, 200, 200, 210, 220 },
1675#else
clang-format67948d32016-09-07 22:40:40 -07001676 { 1, 160, 160, 170 },
1677 { 1, 200, 200, 210 },
Jingning Hanfeb517c2016-12-21 16:02:07 -08001678#endif // CONFIG_CB4X4
Debargha Mukherjee5a488a62016-11-22 22:24:10 -08001679#endif // CONFIG_TX64X64
clang-format67948d32016-09-07 22:40:40 -07001680 };
Yaowu Xuc27fc142016-08-22 16:08:15 -07001681#endif // CONFIG_SUPERTX
1682
1683// FIXME(someone) need real defaults here
Nathan E. Eggef627e582016-08-19 20:06:51 -04001684static const aom_prob default_segment_tree_probs[SEG_TREE_PROBS] = {
1685 128, 128, 128, 128, 128, 128, 128
Yaowu Xuc27fc142016-08-22 16:08:15 -07001686};
Nathan E. Eggef627e582016-08-19 20:06:51 -04001687// clang-format off
1688static const aom_prob default_segment_pred_probs[PREDICTION_PROBS] = {
1689 128, 128, 128
1690};
1691// clang-format on
Yaowu Xuc27fc142016-08-22 16:08:15 -07001692
1693static void init_mode_probs(FRAME_CONTEXT *fc) {
Yaowu Xuf883b422016-08-30 14:01:10 -07001694 av1_copy(fc->uv_mode_prob, default_uv_probs);
1695 av1_copy(fc->y_mode_prob, default_if_y_probs);
1696 av1_copy(fc->switchable_interp_prob, default_switchable_interp_prob);
1697 av1_copy(fc->partition_prob, default_partition_probs);
1698 av1_copy(fc->intra_inter_prob, default_intra_inter_p);
1699 av1_copy(fc->comp_inter_prob, default_comp_inter_p);
1700 av1_copy(fc->comp_ref_prob, default_comp_ref_p);
Yaowu Xuc27fc142016-08-22 16:08:15 -07001701#if CONFIG_EXT_REFS
Yaowu Xuf883b422016-08-30 14:01:10 -07001702 av1_copy(fc->comp_bwdref_prob, default_comp_bwdref_p);
Yaowu Xuc27fc142016-08-22 16:08:15 -07001703#endif // CONFIG_EXT_REFS
Yaowu Xuf883b422016-08-30 14:01:10 -07001704 av1_copy(fc->single_ref_prob, default_single_ref_p);
1705 av1_copy(fc->tx_size_probs, default_tx_size_prob);
Yaowu Xuc27fc142016-08-22 16:08:15 -07001706#if CONFIG_VAR_TX
Yaowu Xuf883b422016-08-30 14:01:10 -07001707 av1_copy(fc->txfm_partition_prob, default_txfm_partition_probs);
Yaowu Xuc27fc142016-08-22 16:08:15 -07001708#endif
Yaowu Xuf883b422016-08-30 14:01:10 -07001709 av1_copy(fc->skip_probs, default_skip_probs);
Yaowu Xuc27fc142016-08-22 16:08:15 -07001710#if CONFIG_REF_MV
Yaowu Xuf883b422016-08-30 14:01:10 -07001711 av1_copy(fc->newmv_prob, default_newmv_prob);
1712 av1_copy(fc->zeromv_prob, default_zeromv_prob);
1713 av1_copy(fc->refmv_prob, default_refmv_prob);
1714 av1_copy(fc->drl_prob, default_drl_prob);
Yaowu Xuc27fc142016-08-22 16:08:15 -07001715#if CONFIG_EXT_INTER
1716 fc->new2mv_prob = default_new2mv_prob;
1717#endif // CONFIG_EXT_INTER
1718#endif // CONFIG_REF_MV
Yaowu Xuf883b422016-08-30 14:01:10 -07001719 av1_copy(fc->inter_mode_probs, default_inter_mode_probs);
Yue Chencb60b182016-10-13 15:18:22 -07001720#if CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
1721 av1_copy(fc->motion_mode_prob, default_motion_mode_prob);
Yue Chen69f18e12016-09-08 14:48:15 -07001722#if CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
1723 av1_copy(fc->obmc_prob, default_obmc_prob);
1724#endif // CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
Yue Chencb60b182016-10-13 15:18:22 -07001725#endif // CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
Yaowu Xuc27fc142016-08-22 16:08:15 -07001726#if CONFIG_EXT_INTER
Yaowu Xuf883b422016-08-30 14:01:10 -07001727 av1_copy(fc->inter_compound_mode_probs, default_inter_compound_mode_probs);
Sarah Parker6fddd182016-11-10 20:57:20 -08001728 av1_copy(fc->compound_type_prob, default_compound_type_probs);
Yaowu Xuf883b422016-08-30 14:01:10 -07001729 av1_copy(fc->interintra_prob, default_interintra_prob);
1730 av1_copy(fc->interintra_mode_prob, default_interintra_mode_prob);
1731 av1_copy(fc->wedge_interintra_prob, default_wedge_interintra_prob);
Yaowu Xuc27fc142016-08-22 16:08:15 -07001732#endif // CONFIG_EXT_INTER
1733#if CONFIG_SUPERTX
Yaowu Xuf883b422016-08-30 14:01:10 -07001734 av1_copy(fc->supertx_prob, default_supertx_prob);
Yaowu Xuc27fc142016-08-22 16:08:15 -07001735#endif // CONFIG_SUPERTX
Nathan E. Eggef627e582016-08-19 20:06:51 -04001736 av1_copy(fc->seg.tree_probs, default_segment_tree_probs);
1737 av1_copy(fc->seg.pred_probs, default_segment_pred_probs);
Yaowu Xuc27fc142016-08-22 16:08:15 -07001738#if CONFIG_EXT_INTRA
hui sueda3d762016-12-06 16:58:23 -08001739#if CONFIG_INTRA_INTERP
Yaowu Xuf883b422016-08-30 14:01:10 -07001740 av1_copy(fc->intra_filter_probs, default_intra_filter_probs);
hui sueda3d762016-12-06 16:58:23 -08001741#endif // CONFIG_INTRA_INTERP
Yaowu Xuc27fc142016-08-22 16:08:15 -07001742#endif // CONFIG_EXT_INTRA
hui su5db97432016-10-14 16:10:14 -07001743#if CONFIG_FILTER_INTRA
1744 av1_copy(fc->filter_intra_probs, default_filter_intra_probs);
1745#endif // CONFIG_FILTER_INTRA
Yaowu Xuf883b422016-08-30 14:01:10 -07001746 av1_copy(fc->inter_ext_tx_prob, default_inter_ext_tx_prob);
1747 av1_copy(fc->intra_ext_tx_prob, default_intra_ext_tx_prob);
Debargha Mukherjee5cd2ab92016-09-08 15:15:17 -07001748#if CONFIG_LOOP_RESTORATION
1749 av1_copy(fc->switchable_restore_prob, default_switchable_restore_prob);
1750#endif // CONFIG_LOOP_RESTORATION
Nathan E. Egge31296062016-11-16 09:44:26 -05001751#if CONFIG_EC_MULTISYMBOL
Nathan E. Eggeecc21ec2016-11-16 09:44:26 -05001752 av1_tree_to_cdf_1D(av1_intra_mode_tree, fc->y_mode_prob, fc->y_mode_cdf,
1753 BLOCK_SIZE_GROUPS);
Nathan E. Eggedd28aed2016-11-16 09:44:26 -05001754 av1_tree_to_cdf_1D(av1_intra_mode_tree, fc->uv_mode_prob, fc->uv_mode_cdf,
1755 INTRA_MODES);
Nathan E. Egge00b33312016-11-16 09:44:26 -05001756 av1_tree_to_cdf_1D(av1_switchable_interp_tree, fc->switchable_interp_prob,
1757 fc->switchable_interp_cdf, SWITCHABLE_FILTER_CONTEXTS);
Nathan E. Egge9d9eb6c2016-11-16 09:44:26 -05001758 av1_tree_to_cdf_1D(av1_partition_tree, fc->partition_prob, fc->partition_cdf,
1759 PARTITION_CONTEXTS);
Nathan E. Eggea59b23d2016-11-16 09:44:26 -05001760 av1_tree_to_cdf_1D(av1_inter_mode_tree, fc->inter_mode_probs,
1761 fc->inter_mode_cdf, INTER_MODE_CONTEXTS);
Nathan E. Eggedfa33f22016-11-16 09:44:26 -05001762#if !CONFIG_EXT_TX
Nathan E. Egge29ccee02016-11-16 09:44:26 -05001763 av1_tree_to_cdf_2D(av1_ext_tx_tree, fc->intra_ext_tx_prob,
1764 fc->intra_ext_tx_cdf, EXT_TX_SIZES, TX_TYPES);
Nathan E. Eggedfa33f22016-11-16 09:44:26 -05001765 av1_tree_to_cdf_1D(av1_ext_tx_tree, fc->inter_ext_tx_prob,
1766 fc->inter_ext_tx_cdf, EXT_TX_SIZES);
1767#endif
Nathan E. Egge10ba2be2016-11-16 09:44:26 -05001768 av1_tree_to_cdf_2D(av1_intra_mode_tree, av1_kf_y_mode_prob, av1_kf_y_mode_cdf,
1769 INTRA_MODES, INTRA_MODES);
Nathan E. Eggef627e582016-08-19 20:06:51 -04001770 av1_tree_to_cdf(av1_segment_tree, fc->seg.tree_probs, fc->seg.tree_cdf);
Nathan E. Egge4947c292016-04-26 11:37:06 -04001771#endif
Thomas Daviesf6936102016-09-05 16:51:31 +01001772#if CONFIG_DELTA_Q
1773 av1_copy(fc->delta_q_prob, default_delta_q_probs);
1774#endif
Yaowu Xuc27fc142016-08-22 16:08:15 -07001775}
1776
Nathan E. Egge00b33312016-11-16 09:44:26 -05001777#if CONFIG_EC_MULTISYMBOL
Nathan E. Egge4947c292016-04-26 11:37:06 -04001778int av1_switchable_interp_ind[SWITCHABLE_FILTERS];
1779int av1_switchable_interp_inv[SWITCHABLE_FILTERS];
Thomas Davies6519beb2016-10-19 14:46:07 +01001780
1781void av1_set_mode_cdfs(struct AV1Common *cm) {
1782 FRAME_CONTEXT *fc = cm->fc;
1783 int i, j;
1784 if (cm->seg.enabled && cm->seg.update_map) {
1785 av1_tree_to_cdf(av1_segment_tree, cm->fc->seg.tree_probs,
1786 cm->fc->seg.tree_cdf);
1787 }
Thomas Davies6519beb2016-10-19 14:46:07 +01001788
Nathan E. Eggedd28aed2016-11-16 09:44:26 -05001789 for (i = 0; i < INTRA_MODES; ++i)
1790 av1_tree_to_cdf(av1_intra_mode_tree, fc->uv_mode_prob[i],
1791 fc->uv_mode_cdf[i]);
1792
Thomas Davies6519beb2016-10-19 14:46:07 +01001793 for (i = 0; i < PARTITION_CONTEXTS; ++i)
1794 av1_tree_to_cdf(av1_partition_tree, fc->partition_prob[i],
1795 fc->partition_cdf[i]);
Nathan E. Eggedfa33f22016-11-16 09:44:26 -05001796
Nathan E. Egge10ba2be2016-11-16 09:44:26 -05001797 for (i = 0; i < INTRA_MODES; ++i)
1798 for (j = 0; j < INTRA_MODES; ++j)
1799 av1_tree_to_cdf(av1_intra_mode_tree, cm->kf_y_prob[i][j],
1800 cm->kf_y_cdf[i][j]);
1801
Nathan E. Egge00b33312016-11-16 09:44:26 -05001802 for (j = 0; j < SWITCHABLE_FILTER_CONTEXTS; ++j)
1803 av1_tree_to_cdf(av1_switchable_interp_tree, fc->switchable_interp_prob[j],
1804 fc->switchable_interp_cdf[j]);
1805
Nathan E. Eggea59b23d2016-11-16 09:44:26 -05001806 for (i = 0; i < INTER_MODE_CONTEXTS; ++i)
1807 av1_tree_to_cdf(av1_inter_mode_tree, fc->inter_mode_probs[i],
1808 fc->inter_mode_cdf[i]);
1809
Nathan E. Eggeecc21ec2016-11-16 09:44:26 -05001810 for (i = 0; i < BLOCK_SIZE_GROUPS; ++i)
1811 av1_tree_to_cdf(av1_intra_mode_tree, fc->y_mode_prob[i], fc->y_mode_cdf[i]);
1812
Nathan E. Eggedfa33f22016-11-16 09:44:26 -05001813#if !CONFIG_EXT_TX
1814 for (i = TX_4X4; i < EXT_TX_SIZES; ++i)
Nathan E. Egge29ccee02016-11-16 09:44:26 -05001815 for (j = 0; j < TX_TYPES; ++j)
1816 av1_tree_to_cdf(av1_ext_tx_tree, fc->intra_ext_tx_prob[i][j],
1817 fc->intra_ext_tx_cdf[i][j]);
1818
1819 for (i = TX_4X4; i < EXT_TX_SIZES; ++i)
Nathan E. Eggedfa33f22016-11-16 09:44:26 -05001820 av1_tree_to_cdf(av1_ext_tx_tree, fc->inter_ext_tx_prob[i],
1821 fc->inter_ext_tx_cdf[i]);
1822#endif
Thomas Davies6519beb2016-10-19 14:46:07 +01001823}
Nathan E. Egge4947c292016-04-26 11:37:06 -04001824#endif
1825
Angie Chiang1733f6b2017-01-05 09:52:20 -08001826#if CONFIG_DUAL_FILTER
Yaowu Xuf883b422016-08-30 14:01:10 -07001827const aom_tree_index av1_switchable_interp_tree[TREE_SIZE(SWITCHABLE_FILTERS)] =
1828 {
Angie Chiangd91ab372016-11-21 18:16:49 -08001829 -EIGHTTAP_REGULAR, 2, 4, -MULTITAP_SHARP, -EIGHTTAP_SMOOTH,
Yaowu Xuc27fc142016-08-22 16:08:15 -07001830 -EIGHTTAP_SMOOTH2,
Yaowu Xuc27fc142016-08-22 16:08:15 -07001831 };
1832#else
Yaowu Xuf883b422016-08-30 14:01:10 -07001833const aom_tree_index av1_switchable_interp_tree[TREE_SIZE(SWITCHABLE_FILTERS)] =
1834 { -EIGHTTAP_REGULAR, 2, -EIGHTTAP_SMOOTH, -MULTITAP_SHARP };
Angie Chiang1733f6b2017-01-05 09:52:20 -08001835#endif // CONFIG_DUAL_FILTER
Yaowu Xuc27fc142016-08-22 16:08:15 -07001836
Yaowu Xuf883b422016-08-30 14:01:10 -07001837void av1_adapt_inter_frame_probs(AV1_COMMON *cm) {
Yaowu Xuc27fc142016-08-22 16:08:15 -07001838 int i, j;
1839 FRAME_CONTEXT *fc = cm->fc;
1840 const FRAME_CONTEXT *pre_fc = &cm->frame_contexts[cm->frame_context_idx];
1841 const FRAME_COUNTS *counts = &cm->counts;
1842
1843 for (i = 0; i < INTRA_INTER_CONTEXTS; i++)
Yaowu Xuf883b422016-08-30 14:01:10 -07001844 fc->intra_inter_prob[i] = av1_mode_mv_merge_probs(
Yaowu Xuc27fc142016-08-22 16:08:15 -07001845 pre_fc->intra_inter_prob[i], counts->intra_inter[i]);
1846 for (i = 0; i < COMP_INTER_CONTEXTS; i++)
Yaowu Xuf883b422016-08-30 14:01:10 -07001847 fc->comp_inter_prob[i] = av1_mode_mv_merge_probs(pre_fc->comp_inter_prob[i],
1848 counts->comp_inter[i]);
Yaowu Xuc27fc142016-08-22 16:08:15 -07001849
1850#if CONFIG_EXT_REFS
1851 for (i = 0; i < REF_CONTEXTS; i++)
1852 for (j = 0; j < (FWD_REFS - 1); j++)
1853 fc->comp_ref_prob[i][j] = mode_mv_merge_probs(pre_fc->comp_ref_prob[i][j],
1854 counts->comp_ref[i][j]);
1855 for (i = 0; i < REF_CONTEXTS; i++)
1856 for (j = 0; j < (BWD_REFS - 1); j++)
1857 fc->comp_bwdref_prob[i][j] = mode_mv_merge_probs(
1858 pre_fc->comp_bwdref_prob[i][j], counts->comp_bwdref[i][j]);
1859#else
1860 for (i = 0; i < REF_CONTEXTS; i++)
1861 for (j = 0; j < (COMP_REFS - 1); j++)
1862 fc->comp_ref_prob[i][j] = mode_mv_merge_probs(pre_fc->comp_ref_prob[i][j],
1863 counts->comp_ref[i][j]);
1864#endif // CONFIG_EXT_REFS
1865
1866 for (i = 0; i < REF_CONTEXTS; i++)
1867 for (j = 0; j < (SINGLE_REFS - 1); j++)
Yaowu Xuf883b422016-08-30 14:01:10 -07001868 fc->single_ref_prob[i][j] = av1_mode_mv_merge_probs(
Yaowu Xuc27fc142016-08-22 16:08:15 -07001869 pre_fc->single_ref_prob[i][j], counts->single_ref[i][j]);
1870
1871#if CONFIG_REF_MV
1872 for (i = 0; i < NEWMV_MODE_CONTEXTS; ++i)
1873 fc->newmv_prob[i] =
Yaowu Xuf883b422016-08-30 14:01:10 -07001874 av1_mode_mv_merge_probs(pre_fc->newmv_prob[i], counts->newmv_mode[i]);
Yaowu Xuc27fc142016-08-22 16:08:15 -07001875 for (i = 0; i < ZEROMV_MODE_CONTEXTS; ++i)
Yaowu Xuf883b422016-08-30 14:01:10 -07001876 fc->zeromv_prob[i] =
1877 av1_mode_mv_merge_probs(pre_fc->zeromv_prob[i], counts->zeromv_mode[i]);
Yaowu Xuc27fc142016-08-22 16:08:15 -07001878 for (i = 0; i < REFMV_MODE_CONTEXTS; ++i)
1879 fc->refmv_prob[i] =
Yaowu Xuf883b422016-08-30 14:01:10 -07001880 av1_mode_mv_merge_probs(pre_fc->refmv_prob[i], counts->refmv_mode[i]);
Yaowu Xuc27fc142016-08-22 16:08:15 -07001881
1882 for (i = 0; i < DRL_MODE_CONTEXTS; ++i)
1883 fc->drl_prob[i] =
Yaowu Xuf883b422016-08-30 14:01:10 -07001884 av1_mode_mv_merge_probs(pre_fc->drl_prob[i], counts->drl_mode[i]);
Yaowu Xuc27fc142016-08-22 16:08:15 -07001885#if CONFIG_EXT_INTER
1886 fc->new2mv_prob =
Yaowu Xuf883b422016-08-30 14:01:10 -07001887 av1_mode_mv_merge_probs(pre_fc->new2mv_prob, counts->new2mv_mode);
Yaowu Xuc27fc142016-08-22 16:08:15 -07001888#endif // CONFIG_EXT_INTER
1889#else
1890 for (i = 0; i < INTER_MODE_CONTEXTS; i++)
Yaowu Xuf883b422016-08-30 14:01:10 -07001891 aom_tree_merge_probs(av1_inter_mode_tree, pre_fc->inter_mode_probs[i],
Yaowu Xuc27fc142016-08-22 16:08:15 -07001892 counts->inter_mode[i], fc->inter_mode_probs[i]);
1893#endif
1894
Yue Chencb60b182016-10-13 15:18:22 -07001895#if CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
Yaowu Xuc27fc142016-08-22 16:08:15 -07001896 for (i = BLOCK_8X8; i < BLOCK_SIZES; ++i)
Yue Chencb60b182016-10-13 15:18:22 -07001897 aom_tree_merge_probs(av1_motion_mode_tree, pre_fc->motion_mode_prob[i],
1898 counts->motion_mode[i], fc->motion_mode_prob[i]);
Yue Chen69f18e12016-09-08 14:48:15 -07001899#if CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
1900 for (i = BLOCK_8X8; i < BLOCK_SIZES; ++i)
1901 fc->obmc_prob[i] =
1902 av1_mode_mv_merge_probs(pre_fc->obmc_prob[i], counts->obmc[i]);
1903#endif // CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
Yue Chencb60b182016-10-13 15:18:22 -07001904#endif // CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
Yaowu Xuc27fc142016-08-22 16:08:15 -07001905
1906#if CONFIG_SUPERTX
1907 for (i = 0; i < PARTITION_SUPERTX_CONTEXTS; ++i) {
Jingning Han93531242016-12-20 11:54:36 -08001908 for (j = TX_8X8; j < TX_SIZES; ++j) {
Yaowu Xuf883b422016-08-30 14:01:10 -07001909 fc->supertx_prob[i][j] = av1_mode_mv_merge_probs(
Yaowu Xuc27fc142016-08-22 16:08:15 -07001910 pre_fc->supertx_prob[i][j], counts->supertx[i][j]);
1911 }
1912 }
1913#endif // CONFIG_SUPERTX
1914
1915#if CONFIG_EXT_INTER
1916 for (i = 0; i < INTER_MODE_CONTEXTS; i++)
Yaowu Xuf883b422016-08-30 14:01:10 -07001917 aom_tree_merge_probs(
1918 av1_inter_compound_mode_tree, pre_fc->inter_compound_mode_probs[i],
Yaowu Xuc27fc142016-08-22 16:08:15 -07001919 counts->inter_compound_mode[i], fc->inter_compound_mode_probs[i]);
1920 for (i = 0; i < BLOCK_SIZE_GROUPS; ++i) {
1921 if (is_interintra_allowed_bsize_group(i))
Yaowu Xuf883b422016-08-30 14:01:10 -07001922 fc->interintra_prob[i] = av1_mode_mv_merge_probs(
Yaowu Xuc27fc142016-08-22 16:08:15 -07001923 pre_fc->interintra_prob[i], counts->interintra[i]);
1924 }
1925 for (i = 0; i < BLOCK_SIZE_GROUPS; i++) {
Yaowu Xuf883b422016-08-30 14:01:10 -07001926 aom_tree_merge_probs(
1927 av1_interintra_mode_tree, pre_fc->interintra_mode_prob[i],
Yaowu Xuc27fc142016-08-22 16:08:15 -07001928 counts->interintra_mode[i], fc->interintra_mode_prob[i]);
1929 }
1930 for (i = 0; i < BLOCK_SIZES; ++i) {
1931 if (is_interintra_allowed_bsize(i) && is_interintra_wedge_used(i))
Yaowu Xuf883b422016-08-30 14:01:10 -07001932 fc->wedge_interintra_prob[i] = av1_mode_mv_merge_probs(
Yaowu Xuc27fc142016-08-22 16:08:15 -07001933 pre_fc->wedge_interintra_prob[i], counts->wedge_interintra[i]);
1934 }
Sarah Parker6fddd182016-11-10 20:57:20 -08001935
Yaowu Xuc27fc142016-08-22 16:08:15 -07001936 for (i = 0; i < BLOCK_SIZES; ++i) {
Sarah Parker6fdc8532016-11-16 17:47:13 -08001937 aom_tree_merge_probs(av1_compound_type_tree, pre_fc->compound_type_prob[i],
1938 counts->compound_interinter[i],
1939 fc->compound_type_prob[i]);
Yaowu Xuc27fc142016-08-22 16:08:15 -07001940 }
1941#endif // CONFIG_EXT_INTER
1942
1943 for (i = 0; i < BLOCK_SIZE_GROUPS; i++)
Yaowu Xuf883b422016-08-30 14:01:10 -07001944 aom_tree_merge_probs(av1_intra_mode_tree, pre_fc->y_mode_prob[i],
Yaowu Xuc27fc142016-08-22 16:08:15 -07001945 counts->y_mode[i], fc->y_mode_prob[i]);
1946
1947 if (cm->interp_filter == SWITCHABLE) {
1948 for (i = 0; i < SWITCHABLE_FILTER_CONTEXTS; i++)
Yaowu Xuf883b422016-08-30 14:01:10 -07001949 aom_tree_merge_probs(
1950 av1_switchable_interp_tree, pre_fc->switchable_interp_prob[i],
Yaowu Xuc27fc142016-08-22 16:08:15 -07001951 counts->switchable_interp[i], fc->switchable_interp_prob[i]);
1952 }
Thomas Daviesf6936102016-09-05 16:51:31 +01001953
1954#if CONFIG_DELTA_Q
1955 for (i = 0; i < DELTA_Q_CONTEXTS; ++i)
1956 fc->delta_q_prob[i] =
1957 mode_mv_merge_probs(pre_fc->delta_q_prob[i], counts->delta_q[i]);
1958#endif
Yaowu Xuc27fc142016-08-22 16:08:15 -07001959}
1960
Yaowu Xuf883b422016-08-30 14:01:10 -07001961void av1_adapt_intra_frame_probs(AV1_COMMON *cm) {
Yaowu Xuc27fc142016-08-22 16:08:15 -07001962 int i, j;
1963 FRAME_CONTEXT *fc = cm->fc;
1964 const FRAME_CONTEXT *pre_fc = &cm->frame_contexts[cm->frame_context_idx];
1965 const FRAME_COUNTS *counts = &cm->counts;
1966
1967 if (cm->tx_mode == TX_MODE_SELECT) {
Jingning Hanaae72a62016-10-25 15:35:29 -07001968 for (i = 0; i < MAX_TX_DEPTH; ++i) {
Yaowu Xuc27fc142016-08-22 16:08:15 -07001969 for (j = 0; j < TX_SIZE_CONTEXTS; ++j)
Yaowu Xuf883b422016-08-30 14:01:10 -07001970 aom_tree_merge_probs(av1_tx_size_tree[i], pre_fc->tx_size_probs[i][j],
Yaowu Xuc27fc142016-08-22 16:08:15 -07001971 counts->tx_size[i][j], fc->tx_size_probs[i][j]);
1972 }
1973 }
1974
1975#if CONFIG_VAR_TX
Yue Chena1e48dc2016-08-29 17:29:33 -07001976 if (cm->tx_mode == TX_MODE_SELECT) {
Yaowu Xuc27fc142016-08-22 16:08:15 -07001977 for (i = 0; i < TXFM_PARTITION_CONTEXTS; ++i)
Yaowu Xuf883b422016-08-30 14:01:10 -07001978 fc->txfm_partition_prob[i] = av1_mode_mv_merge_probs(
Yaowu Xuc27fc142016-08-22 16:08:15 -07001979 pre_fc->txfm_partition_prob[i], counts->txfm_partition[i]);
Yue Chena1e48dc2016-08-29 17:29:33 -07001980 }
Yaowu Xuc27fc142016-08-22 16:08:15 -07001981#endif
1982
1983 for (i = 0; i < SKIP_CONTEXTS; ++i)
1984 fc->skip_probs[i] =
Yaowu Xuf883b422016-08-30 14:01:10 -07001985 av1_mode_mv_merge_probs(pre_fc->skip_probs[i], counts->skip[i]);
Yaowu Xuc27fc142016-08-22 16:08:15 -07001986
1987#if CONFIG_EXT_TX
1988 for (i = TX_4X4; i < EXT_TX_SIZES; ++i) {
1989 int s;
1990 for (s = 1; s < EXT_TX_SETS_INTER; ++s) {
1991 if (use_inter_ext_tx_for_txsize[s][i]) {
Yaowu Xuf883b422016-08-30 14:01:10 -07001992 aom_tree_merge_probs(
1993 av1_ext_tx_inter_tree[s], pre_fc->inter_ext_tx_prob[s][i],
Yaowu Xuc27fc142016-08-22 16:08:15 -07001994 counts->inter_ext_tx[s][i], fc->inter_ext_tx_prob[s][i]);
1995 }
1996 }
1997 for (s = 1; s < EXT_TX_SETS_INTRA; ++s) {
1998 if (use_intra_ext_tx_for_txsize[s][i]) {
Yaowu Xuc27fc142016-08-22 16:08:15 -07001999 for (j = 0; j < INTRA_MODES; ++j)
Yaowu Xuf883b422016-08-30 14:01:10 -07002000 aom_tree_merge_probs(
2001 av1_ext_tx_intra_tree[s], pre_fc->intra_ext_tx_prob[s][i][j],
Yaowu Xuc27fc142016-08-22 16:08:15 -07002002 counts->intra_ext_tx[s][i][j], fc->intra_ext_tx_prob[s][i][j]);
2003 }
2004 }
2005 }
2006#else
2007 for (i = TX_4X4; i < EXT_TX_SIZES; ++i) {
Nathan E. Egge7c5b4c12016-04-26 12:31:14 -04002008 for (j = 0; j < TX_TYPES; ++j) {
Yaowu Xuf883b422016-08-30 14:01:10 -07002009 aom_tree_merge_probs(av1_ext_tx_tree, pre_fc->intra_ext_tx_prob[i][j],
Yaowu Xuc27fc142016-08-22 16:08:15 -07002010 counts->intra_ext_tx[i][j],
2011 fc->intra_ext_tx_prob[i][j]);
Nathan E. Egge7c5b4c12016-04-26 12:31:14 -04002012 }
Yaowu Xuc27fc142016-08-22 16:08:15 -07002013 }
2014 for (i = TX_4X4; i < EXT_TX_SIZES; ++i) {
Yaowu Xuf883b422016-08-30 14:01:10 -07002015 aom_tree_merge_probs(av1_ext_tx_tree, pre_fc->inter_ext_tx_prob[i],
Yaowu Xuc27fc142016-08-22 16:08:15 -07002016 counts->inter_ext_tx[i], fc->inter_ext_tx_prob[i]);
2017 }
2018#endif // CONFIG_EXT_TX
2019
2020 if (cm->seg.temporal_update) {
2021 for (i = 0; i < PREDICTION_PROBS; i++)
Yaowu Xuf883b422016-08-30 14:01:10 -07002022 fc->seg.pred_probs[i] = av1_mode_mv_merge_probs(pre_fc->seg.pred_probs[i],
2023 counts->seg.pred[i]);
Yaowu Xuc27fc142016-08-22 16:08:15 -07002024
Yaowu Xuf883b422016-08-30 14:01:10 -07002025 aom_tree_merge_probs(av1_segment_tree, pre_fc->seg.tree_probs,
Yaowu Xuc27fc142016-08-22 16:08:15 -07002026 counts->seg.tree_mispred, fc->seg.tree_probs);
2027 } else {
Yaowu Xuf883b422016-08-30 14:01:10 -07002028 aom_tree_merge_probs(av1_segment_tree, pre_fc->seg.tree_probs,
Yaowu Xuc27fc142016-08-22 16:08:15 -07002029 counts->seg.tree_total, fc->seg.tree_probs);
2030 }
2031
2032 for (i = 0; i < INTRA_MODES; ++i)
Yaowu Xuf883b422016-08-30 14:01:10 -07002033 aom_tree_merge_probs(av1_intra_mode_tree, pre_fc->uv_mode_prob[i],
Yaowu Xuc27fc142016-08-22 16:08:15 -07002034 counts->uv_mode[i], fc->uv_mode_prob[i]);
2035
2036#if CONFIG_EXT_PARTITION_TYPES
Yaowu Xuf883b422016-08-30 14:01:10 -07002037 aom_tree_merge_probs(av1_partition_tree, pre_fc->partition_prob[0],
Yaowu Xuc27fc142016-08-22 16:08:15 -07002038 counts->partition[0], fc->partition_prob[0]);
2039 for (i = 1; i < PARTITION_CONTEXTS; i++)
Yaowu Xuf883b422016-08-30 14:01:10 -07002040 aom_tree_merge_probs(av1_ext_partition_tree, pre_fc->partition_prob[i],
Yaowu Xuc27fc142016-08-22 16:08:15 -07002041 counts->partition[i], fc->partition_prob[i]);
2042#else
Nathan E. Eggefba2be62016-05-03 09:48:54 -04002043 for (i = 0; i < PARTITION_CONTEXTS; i++) {
Yaowu Xuf883b422016-08-30 14:01:10 -07002044 aom_tree_merge_probs(av1_partition_tree, pre_fc->partition_prob[i],
Yaowu Xuc27fc142016-08-22 16:08:15 -07002045 counts->partition[i], fc->partition_prob[i]);
Nathan E. Eggefba2be62016-05-03 09:48:54 -04002046 }
Yaowu Xuc27fc142016-08-22 16:08:15 -07002047#endif // CONFIG_EXT_PARTITION_TYPES
Thomas Daviesf6936102016-09-05 16:51:31 +01002048#if CONFIG_DELTA_Q
2049 for (i = 0; i < DELTA_Q_CONTEXTS; ++i)
2050 fc->delta_q_prob[i] =
2051 mode_mv_merge_probs(pre_fc->delta_q_prob[i], counts->delta_q[i]);
2052#endif
Yaowu Xuc27fc142016-08-22 16:08:15 -07002053#if CONFIG_EXT_INTRA
hui sueda3d762016-12-06 16:58:23 -08002054#if CONFIG_INTRA_INTERP
hui su5db97432016-10-14 16:10:14 -07002055 for (i = 0; i < INTRA_FILTERS + 1; ++i) {
Yaowu Xuf883b422016-08-30 14:01:10 -07002056 aom_tree_merge_probs(av1_intra_filter_tree, pre_fc->intra_filter_probs[i],
Yaowu Xuc27fc142016-08-22 16:08:15 -07002057 counts->intra_filter[i], fc->intra_filter_probs[i]);
hui su5db97432016-10-14 16:10:14 -07002058 }
hui sueda3d762016-12-06 16:58:23 -08002059#endif // CONFIG_INTRA_INTERP
Yaowu Xuc27fc142016-08-22 16:08:15 -07002060#endif // CONFIG_EXT_INTRA
hui su5db97432016-10-14 16:10:14 -07002061#if CONFIG_FILTER_INTRA
2062 for (i = 0; i < PLANE_TYPES; ++i) {
2063 fc->filter_intra_probs[i] = av1_mode_mv_merge_probs(
2064 pre_fc->filter_intra_probs[i], counts->filter_intra[i]);
2065 }
2066#endif // CONFIG_FILTER_INTRA
Yaowu Xuc27fc142016-08-22 16:08:15 -07002067}
2068
2069static void set_default_lf_deltas(struct loopfilter *lf) {
2070 lf->mode_ref_delta_enabled = 1;
2071 lf->mode_ref_delta_update = 1;
2072
2073 lf->ref_deltas[INTRA_FRAME] = 1;
2074 lf->ref_deltas[LAST_FRAME] = 0;
2075#if CONFIG_EXT_REFS
2076 lf->ref_deltas[LAST2_FRAME] = lf->ref_deltas[LAST_FRAME];
2077 lf->ref_deltas[LAST3_FRAME] = lf->ref_deltas[LAST_FRAME];
2078 lf->ref_deltas[BWDREF_FRAME] = lf->ref_deltas[LAST_FRAME];
2079#endif // CONFIG_EXT_REFS
2080 lf->ref_deltas[GOLDEN_FRAME] = -1;
2081 lf->ref_deltas[ALTREF_FRAME] = -1;
2082
2083 lf->mode_deltas[0] = 0;
2084 lf->mode_deltas[1] = 0;
2085}
2086
Yaowu Xuf883b422016-08-30 14:01:10 -07002087void av1_setup_past_independence(AV1_COMMON *cm) {
Yaowu Xuc27fc142016-08-22 16:08:15 -07002088 // Reset the segment feature data to the default stats:
2089 // Features disabled, 0, with delta coding (Default state).
2090 struct loopfilter *const lf = &cm->lf;
2091
2092 int i;
Yaowu Xuf883b422016-08-30 14:01:10 -07002093 av1_clearall_segfeatures(&cm->seg);
Yaowu Xuc27fc142016-08-22 16:08:15 -07002094 cm->seg.abs_delta = SEGMENT_DELTADATA;
2095
2096 if (cm->last_frame_seg_map && !cm->frame_parallel_decode)
2097 memset(cm->last_frame_seg_map, 0, (cm->mi_rows * cm->mi_cols));
2098
2099 if (cm->current_frame_seg_map)
2100 memset(cm->current_frame_seg_map, 0, (cm->mi_rows * cm->mi_cols));
2101
2102 // Reset the mode ref deltas for loop filter
Yaowu Xuf883b422016-08-30 14:01:10 -07002103 av1_zero(lf->last_ref_deltas);
2104 av1_zero(lf->last_mode_deltas);
Yaowu Xuc27fc142016-08-22 16:08:15 -07002105 set_default_lf_deltas(lf);
2106
2107 // To force update of the sharpness
2108 lf->last_sharpness_level = -1;
Yaowu Xuc27fc142016-08-22 16:08:15 -07002109
Yaowu Xuf883b422016-08-30 14:01:10 -07002110 av1_default_coef_probs(cm);
Yaowu Xuc27fc142016-08-22 16:08:15 -07002111 init_mode_probs(cm->fc);
Yaowu Xuf883b422016-08-30 14:01:10 -07002112 av1_init_mv_probs(cm);
Angie Chianged8cd9a2016-10-21 16:44:47 -07002113#if CONFIG_ADAPT_SCAN
2114 av1_init_scan_order(cm);
2115#endif
Angie Chiange067de02016-11-28 14:55:14 -08002116 av1_convolve_init();
Yaowu Xuc27fc142016-08-22 16:08:15 -07002117 cm->fc->initialized = 1;
2118
2119 if (cm->frame_type == KEY_FRAME || cm->error_resilient_mode ||
2120 cm->reset_frame_context == RESET_FRAME_CONTEXT_ALL) {
2121 // Reset all frame contexts.
2122 for (i = 0; i < FRAME_CONTEXTS; ++i) cm->frame_contexts[i] = *cm->fc;
2123 } else if (cm->reset_frame_context == RESET_FRAME_CONTEXT_CURRENT) {
2124 // Reset only the frame context specified in the frame header.
2125 cm->frame_contexts[cm->frame_context_idx] = *cm->fc;
2126 }
2127
2128 // prev_mip will only be allocated in encoder.
2129 if (frame_is_intra_only(cm) && cm->prev_mip && !cm->frame_parallel_decode)
2130 memset(cm->prev_mip, 0,
2131 cm->mi_stride * (cm->mi_rows + 1) * sizeof(*cm->prev_mip));
2132
2133 cm->frame_context_idx = 0;
2134}