blob: 2afec9b3e78bb06a1c6a3705485afa4fc35e0bd9 [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
Urvang Joshi6be4a542016-11-03 15:24:05 -070019#if CONFIG_DAALA_EC
20aom_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 Parker6fddd182016-11-10 20:57:20 -0800479static const aom_prob default_compound_type_probs[BLOCK_SIZES]
480 [COMPOUND_TYPES - 1] = {
481 { 208 }, { 208 }, { 208 },
482 { 208 }, { 208 }, { 208 },
483 { 216 }, { 216 }, { 216 },
484 { 224 }, { 224 }, { 240 },
485 { 240 },
486#if CONFIG_EXT_PARTITION
487 { 255 }, { 255 }, { 255 },
488#endif // CONFIG_EXT_PARTITION
489 };
490
Yaowu Xuf883b422016-08-30 14:01:10 -0700491static const aom_prob default_interintra_prob[BLOCK_SIZE_GROUPS] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700492 208, 208, 208, 208,
493};
494
Yaowu Xuf883b422016-08-30 14:01:10 -0700495static const aom_prob
Yaowu Xuc27fc142016-08-22 16:08:15 -0700496 default_interintra_mode_prob[BLOCK_SIZE_GROUPS][INTERINTRA_MODES - 1] = {
497 { 65, 32, 18, 144, 162, 194, 41, 51, 98 }, // block_size < 8x8
498 { 132, 68, 18, 165, 217, 196, 45, 40, 78 }, // block_size < 16x16
499 { 173, 80, 19, 176, 240, 193, 64, 35, 46 }, // block_size < 32x32
500 { 221, 135, 38, 194, 248, 121, 96, 85, 29 } // block_size >= 32x32
501 };
502
Yaowu Xuf883b422016-08-30 14:01:10 -0700503static const aom_prob default_wedge_interintra_prob[BLOCK_SIZES] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700504 208, 208, 208, 208, 208, 208, 216, 216, 216, 224, 224, 224, 240,
505#if CONFIG_EXT_PARTITION
506 208, 208, 208
507#endif // CONFIG_EXT_PARTITION
508};
Yaowu Xuc27fc142016-08-22 16:08:15 -0700509#endif // CONFIG_EXT_INTER
510
511// Change this section appropriately once warped motion is supported
Yue Chencb60b182016-10-13 15:18:22 -0700512#if CONFIG_MOTION_VAR && !CONFIG_WARPED_MOTION
513const aom_tree_index av1_motion_mode_tree[TREE_SIZE(MOTION_MODES)] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700514 -SIMPLE_TRANSLATION, -OBMC_CAUSAL
515};
Yue Chencb60b182016-10-13 15:18:22 -0700516static const aom_prob default_motion_mode_prob[BLOCK_SIZES]
517 [MOTION_MODES - 1] = {
518 { 255 }, { 255 }, { 255 },
519 { 151 }, { 153 }, { 144 },
520 { 178 }, { 165 }, { 160 },
521 { 207 }, { 195 }, { 168 },
522 { 244 },
Yaowu Xuc27fc142016-08-22 16:08:15 -0700523#if CONFIG_EXT_PARTITION
Yue Chencb60b182016-10-13 15:18:22 -0700524 { 252 }, { 252 }, { 252 },
Yaowu Xuc27fc142016-08-22 16:08:15 -0700525#endif // CONFIG_EXT_PARTITION
Yue Chencb60b182016-10-13 15:18:22 -0700526 };
Yaowu Xuc27fc142016-08-22 16:08:15 -0700527
Yue Chencb60b182016-10-13 15:18:22 -0700528#elif !CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
Yaowu Xuc27fc142016-08-22 16:08:15 -0700529
Yue Chencb60b182016-10-13 15:18:22 -0700530const aom_tree_index av1_motion_mode_tree[TREE_SIZE(MOTION_MODES)] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700531 -SIMPLE_TRANSLATION, -WARPED_CAUSAL
532};
Yue Chencb60b182016-10-13 15:18:22 -0700533static const aom_prob default_motion_mode_prob[BLOCK_SIZES]
534 [MOTION_MODES - 1] = {
535 { 255 }, { 255 }, { 255 },
536 { 151 }, { 153 }, { 144 },
537 { 178 }, { 165 }, { 160 },
538 { 207 }, { 195 }, { 168 },
539 { 244 },
Yaowu Xuc27fc142016-08-22 16:08:15 -0700540#if CONFIG_EXT_PARTITION
Yue Chencb60b182016-10-13 15:18:22 -0700541 { 252 }, { 252 }, { 252 },
Yaowu Xuc27fc142016-08-22 16:08:15 -0700542#endif // CONFIG_EXT_PARTITION
Yue Chencb60b182016-10-13 15:18:22 -0700543 };
Yaowu Xuc27fc142016-08-22 16:08:15 -0700544
Yue Chencb60b182016-10-13 15:18:22 -0700545#elif CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
Yaowu Xuc27fc142016-08-22 16:08:15 -0700546
Yue Chencb60b182016-10-13 15:18:22 -0700547const aom_tree_index av1_motion_mode_tree[TREE_SIZE(MOTION_MODES)] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700548 -SIMPLE_TRANSLATION, 2, -OBMC_CAUSAL, -WARPED_CAUSAL,
549};
Yue Chencb60b182016-10-13 15:18:22 -0700550static const aom_prob default_motion_mode_prob[BLOCK_SIZES][MOTION_MODES - 1] =
Yaowu Xuc27fc142016-08-22 16:08:15 -0700551 {
552 { 255, 200 }, { 255, 200 }, { 255, 200 }, { 151, 200 }, { 153, 200 },
553 { 144, 200 }, { 178, 200 }, { 165, 200 }, { 160, 200 }, { 207, 200 },
554 { 195, 200 }, { 168, 200 }, { 244, 200 },
555#if CONFIG_EXT_PARTITION
556 { 252, 200 }, { 252, 200 }, { 252, 200 },
557#endif // CONFIG_EXT_PARTITION
558 };
Yue Chencb60b182016-10-13 15:18:22 -0700559#endif // CONFIG_MOTION_VAR || !CONFIG_WARPED_MOTION
Yaowu Xuc27fc142016-08-22 16:08:15 -0700560
Thomas Daviesf6936102016-09-05 16:51:31 +0100561#if CONFIG_DELTA_Q
562static const aom_prob default_delta_q_probs[DELTA_Q_CONTEXTS] = { 220, 220,
563 220 };
564#endif
Nathan E. Egge3ef926e2016-09-07 18:20:41 -0400565int av1_intra_mode_ind[INTRA_MODES];
566int av1_intra_mode_inv[INTRA_MODES];
Nathan E. Egge6ec4d102016-09-08 10:41:20 -0400567int av1_inter_mode_ind[INTER_MODES];
568int av1_inter_mode_inv[INTER_MODES];
Thomas Daviesf6936102016-09-05 16:51:31 +0100569
Yaowu Xuc27fc142016-08-22 16:08:15 -0700570/* Array indices are identical to previously-existing INTRAMODECONTEXTNODES. */
Urvang Joshi6be4a542016-11-03 15:24:05 -0700571#if CONFIG_ALT_INTRA
572const aom_tree_index av1_intra_mode_tree[TREE_SIZE(INTRA_MODES)] = {
573 -DC_PRED, 2, /* 0 = DC_NODE */
574 -TM_PRED, 4, /* 1 = TM_NODE */
575 -V_PRED, 6, /* 2 = V_NODE */
576 8, 12, /* 3 = COM_NODE */
577 -H_PRED, 10, /* 4 = H_NODE */
578 -D135_PRED, -D117_PRED, /* 5 = D135_NODE */
579 -D45_PRED, 14, /* 6 = D45_NODE */
580 -D63_PRED, 16, /* 7 = D63_NODE */
581 -D153_PRED, 18, /* 8 = D153_NODE */
582 -D207_PRED, -SMOOTH_PRED, /* 9 = D207_NODE */
583};
584#else
Yaowu Xuf883b422016-08-30 14:01:10 -0700585const aom_tree_index av1_intra_mode_tree[TREE_SIZE(INTRA_MODES)] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700586 -DC_PRED, 2, /* 0 = DC_NODE */
587 -TM_PRED, 4, /* 1 = TM_NODE */
588 -V_PRED, 6, /* 2 = V_NODE */
589 8, 12, /* 3 = COM_NODE */
590 -H_PRED, 10, /* 4 = H_NODE */
591 -D135_PRED, -D117_PRED, /* 5 = D135_NODE */
592 -D45_PRED, 14, /* 6 = D45_NODE */
593 -D63_PRED, 16, /* 7 = D63_NODE */
594 -D153_PRED, -D207_PRED /* 8 = D153_NODE */
595};
Urvang Joshi6be4a542016-11-03 15:24:05 -0700596#endif // CONFIG_ALT_INTRA
Yaowu Xuc27fc142016-08-22 16:08:15 -0700597
Yaowu Xuf883b422016-08-30 14:01:10 -0700598const aom_tree_index av1_inter_mode_tree[TREE_SIZE(INTER_MODES)] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700599 -INTER_OFFSET(ZEROMV), 2,
600 -INTER_OFFSET(NEARESTMV), 4,
601#if CONFIG_EXT_INTER
602 -INTER_OFFSET(NEARMV), 6,
603 -INTER_OFFSET(NEWMV), -INTER_OFFSET(NEWFROMNEARMV)
604#else
605 -INTER_OFFSET(NEARMV), -INTER_OFFSET(NEWMV)
606#endif // CONFIG_EXT_INTER
607};
608
609#if CONFIG_EXT_INTER
610/* clang-format off */
Yaowu Xuf883b422016-08-30 14:01:10 -0700611const aom_tree_index av1_interintra_mode_tree[TREE_SIZE(INTERINTRA_MODES)] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700612 -II_DC_PRED, 2, /* 0 = II_DC_NODE */
613 -II_TM_PRED, 4, /* 1 = II_TM_NODE */
614 -II_V_PRED, 6, /* 2 = II_V_NODE */
615 8, 12, /* 3 = II_COM_NODE */
616 -II_H_PRED, 10, /* 4 = II_H_NODE */
617 -II_D135_PRED, -II_D117_PRED, /* 5 = II_D135_NODE */
618 -II_D45_PRED, 14, /* 6 = II_D45_NODE */
619 -II_D63_PRED, 16, /* 7 = II_D63_NODE */
620 -II_D153_PRED, -II_D207_PRED /* 8 = II_D153_NODE */
621};
622
Yaowu Xuf883b422016-08-30 14:01:10 -0700623const aom_tree_index av1_inter_compound_mode_tree
Yaowu Xuc27fc142016-08-22 16:08:15 -0700624 [TREE_SIZE(INTER_COMPOUND_MODES)] = {
625 -INTER_COMPOUND_OFFSET(ZERO_ZEROMV), 2,
626 -INTER_COMPOUND_OFFSET(NEAREST_NEARESTMV), 4,
627 6, -INTER_COMPOUND_OFFSET(NEW_NEWMV),
628 8, 12,
629 -INTER_COMPOUND_OFFSET(NEAR_NEARMV), 10,
630 -INTER_COMPOUND_OFFSET(NEAREST_NEARMV),
631 -INTER_COMPOUND_OFFSET(NEAR_NEARESTMV),
632 14, 16,
633 -INTER_COMPOUND_OFFSET(NEAREST_NEWMV), -INTER_COMPOUND_OFFSET(NEW_NEARESTMV),
634 -INTER_COMPOUND_OFFSET(NEAR_NEWMV), -INTER_COMPOUND_OFFSET(NEW_NEARMV)
635};
Sarah Parker6fddd182016-11-10 20:57:20 -0800636
637const aom_tree_index av1_compound_type_tree[TREE_SIZE(COMPOUND_TYPES)] = {
638 -COMPOUND_AVERAGE, -COMPOUND_WEDGE
639};
Yaowu Xuc27fc142016-08-22 16:08:15 -0700640/* clang-format on */
641#endif // CONFIG_EXT_INTER
642
Yaowu Xuf883b422016-08-30 14:01:10 -0700643const aom_tree_index av1_partition_tree[TREE_SIZE(PARTITION_TYPES)] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700644 -PARTITION_NONE, 2, -PARTITION_HORZ, 4, -PARTITION_VERT, -PARTITION_SPLIT
645};
646
647#if CONFIG_EXT_PARTITION_TYPES
648/* clang-format off */
Yaowu Xuf883b422016-08-30 14:01:10 -0700649const aom_tree_index av1_ext_partition_tree[TREE_SIZE(EXT_PARTITION_TYPES)] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700650 -PARTITION_NONE, 2,
651 6, 4,
652 8, -PARTITION_SPLIT,
653 -PARTITION_HORZ, 10,
654 -PARTITION_VERT, 12,
655 -PARTITION_HORZ_A, -PARTITION_HORZ_B,
656 -PARTITION_VERT_A, -PARTITION_VERT_B
657};
658/* clang-format on */
659#endif // CONFIG_EXT_PARTITION_TYPES
660
Yaowu Xuf883b422016-08-30 14:01:10 -0700661static const aom_prob default_intra_inter_p[INTRA_INTER_CONTEXTS] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700662 9, 102, 187, 225
663};
664
Yaowu Xuf883b422016-08-30 14:01:10 -0700665static const aom_prob default_comp_inter_p[COMP_INTER_CONTEXTS] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700666 239, 183, 119, 96, 41
667};
668
669#if CONFIG_EXT_REFS
Yaowu Xuf883b422016-08-30 14:01:10 -0700670static const aom_prob default_comp_ref_p[REF_CONTEXTS][FWD_REFS - 1] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700671 // TODO(zoeliu): To adjust the initial prob values.
672 { 33, 16, 16 },
673 { 77, 74, 74 },
674 { 142, 142, 142 },
675 { 172, 170, 170 },
676 { 238, 247, 247 }
677};
Yaowu Xuf883b422016-08-30 14:01:10 -0700678static const aom_prob default_comp_bwdref_p[REF_CONTEXTS][BWD_REFS - 1] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700679 { 16 }, { 74 }, { 142 }, { 170 }, { 247 }
680};
681#else
Yaowu Xuf883b422016-08-30 14:01:10 -0700682static const aom_prob default_comp_ref_p[REF_CONTEXTS][COMP_REFS - 1] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700683 { 50 }, { 126 }, { 123 }, { 221 }, { 226 }
684};
685#endif // CONFIG_EXT_REFS
686
Yaowu Xuf883b422016-08-30 14:01:10 -0700687static const aom_prob default_single_ref_p[REF_CONTEXTS][SINGLE_REFS - 1] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700688#if CONFIG_EXT_REFS
689 { 33, 16, 16, 16, 16 },
690 { 77, 74, 74, 74, 74 },
691 { 142, 142, 142, 142, 142 },
692 { 172, 170, 170, 170, 170 },
693 { 238, 247, 247, 247, 247 }
694#else
695 { 33, 16 }, { 77, 74 }, { 142, 142 }, { 172, 170 }, { 238, 247 }
696#endif // CONFIG_EXT_REFS
697};
698
Urvang Joshib100db72016-10-12 16:28:56 -0700699#if CONFIG_PALETTE
Yaowu Xuf883b422016-08-30 14:01:10 -0700700const aom_tree_index av1_palette_size_tree[TREE_SIZE(PALETTE_SIZES)] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700701 -TWO_COLORS, 2, -THREE_COLORS, 4, -FOUR_COLORS, 6,
702 -FIVE_COLORS, 8, -SIX_COLORS, 10, -SEVEN_COLORS, -EIGHT_COLORS,
703};
704
705// TODO(huisu): tune these probs
Yaowu Xuf883b422016-08-30 14:01:10 -0700706const aom_prob
707 av1_default_palette_y_size_prob[PALETTE_BLOCK_SIZES][PALETTE_SIZES - 1] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700708 { 96, 89, 100, 64, 77, 130 }, { 22, 15, 44, 16, 34, 82 },
709 { 30, 19, 57, 18, 38, 86 }, { 94, 36, 104, 23, 43, 92 },
710 { 116, 76, 107, 46, 65, 105 }, { 112, 82, 94, 40, 70, 112 },
711 { 147, 124, 123, 58, 69, 103 }, { 180, 113, 136, 49, 45, 114 },
712 { 107, 70, 87, 49, 154, 156 }, { 98, 105, 142, 63, 64, 152 },
713#if CONFIG_EXT_PARTITION
714 { 98, 105, 142, 63, 64, 152 }, { 98, 105, 142, 63, 64, 152 },
715 { 98, 105, 142, 63, 64, 152 },
716#endif // CONFIG_EXT_PARTITION
717 };
718
Yaowu Xuf883b422016-08-30 14:01:10 -0700719const aom_prob
720 av1_default_palette_uv_size_prob[PALETTE_BLOCK_SIZES][PALETTE_SIZES - 1] = {
721 { 160, 196, 228, 213, 175, 230 }, { 87, 148, 208, 141, 166, 163 },
722 { 72, 151, 204, 139, 155, 161 }, { 78, 135, 171, 104, 120, 173 },
723 { 59, 92, 131, 78, 92, 142 }, { 75, 118, 149, 84, 90, 128 },
724 { 89, 87, 92, 66, 66, 128 }, { 67, 53, 54, 55, 66, 93 },
725 { 120, 130, 83, 171, 75, 214 }, { 72, 55, 66, 68, 79, 107 },
Yaowu Xuc27fc142016-08-22 16:08:15 -0700726#if CONFIG_EXT_PARTITION
Yaowu Xuf883b422016-08-30 14:01:10 -0700727 { 72, 55, 66, 68, 79, 107 }, { 72, 55, 66, 68, 79, 107 },
728 { 72, 55, 66, 68, 79, 107 },
Yaowu Xuc27fc142016-08-22 16:08:15 -0700729#endif // CONFIG_EXT_PARTITION
Yaowu Xuf883b422016-08-30 14:01:10 -0700730 };
Yaowu Xuc27fc142016-08-22 16:08:15 -0700731
clang-format67948d32016-09-07 22:40:40 -0700732const aom_prob
733 av1_default_palette_y_mode_prob[PALETTE_BLOCK_SIZES]
734 [PALETTE_Y_MODE_CONTEXTS] = {
735 { 240, 180, 100 }, { 240, 180, 100 },
736 { 240, 180, 100 }, { 240, 180, 100 },
737 { 240, 180, 100 }, { 240, 180, 100 },
738 { 240, 180, 100 }, { 240, 180, 100 },
739 { 240, 180, 100 }, { 240, 180, 100 },
Yaowu Xuc27fc142016-08-22 16:08:15 -0700740#if CONFIG_EXT_PARTITION
clang-format67948d32016-09-07 22:40:40 -0700741 { 240, 180, 100 }, { 240, 180, 100 },
742 { 240, 180, 100 },
Yaowu Xuc27fc142016-08-22 16:08:15 -0700743#endif // CONFIG_EXT_PARTITION
clang-format67948d32016-09-07 22:40:40 -0700744 };
Yaowu Xuc27fc142016-08-22 16:08:15 -0700745
Yaowu Xuf883b422016-08-30 14:01:10 -0700746const aom_prob av1_default_palette_uv_mode_prob[2] = { 253, 229 };
Yaowu Xuc27fc142016-08-22 16:08:15 -0700747
Yaowu Xuf883b422016-08-30 14:01:10 -0700748const aom_tree_index
749 av1_palette_color_tree[PALETTE_MAX_SIZE - 1][TREE_SIZE(PALETTE_COLORS)] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700750 { // 2 colors
751 -PALETTE_COLOR_ONE, -PALETTE_COLOR_TWO },
752 { // 3 colors
753 -PALETTE_COLOR_ONE, 2, -PALETTE_COLOR_TWO, -PALETTE_COLOR_THREE },
754 { // 4 colors
755 -PALETTE_COLOR_ONE, 2, -PALETTE_COLOR_TWO, 4, -PALETTE_COLOR_THREE,
756 -PALETTE_COLOR_FOUR },
757 { // 5 colors
758 -PALETTE_COLOR_ONE, 2, -PALETTE_COLOR_TWO, 4, -PALETTE_COLOR_THREE, 6,
759 -PALETTE_COLOR_FOUR, -PALETTE_COLOR_FIVE },
760 { // 6 colors
761 -PALETTE_COLOR_ONE, 2, -PALETTE_COLOR_TWO, 4, -PALETTE_COLOR_THREE, 6,
762 -PALETTE_COLOR_FOUR, 8, -PALETTE_COLOR_FIVE, -PALETTE_COLOR_SIX },
763 { // 7 colors
764 -PALETTE_COLOR_ONE, 2, -PALETTE_COLOR_TWO, 4, -PALETTE_COLOR_THREE, 6,
765 -PALETTE_COLOR_FOUR, 8, -PALETTE_COLOR_FIVE, 10, -PALETTE_COLOR_SIX,
766 -PALETTE_COLOR_SEVEN },
767 { // 8 colors
768 -PALETTE_COLOR_ONE, 2, -PALETTE_COLOR_TWO, 4, -PALETTE_COLOR_THREE, 6,
769 -PALETTE_COLOR_FOUR, 8, -PALETTE_COLOR_FIVE, 10, -PALETTE_COLOR_SIX, 12,
770 -PALETTE_COLOR_SEVEN, -PALETTE_COLOR_EIGHT },
771 };
772
Urvang Joshieb54e0c2016-11-01 15:25:57 -0700773// Note: Has to be non-zero to avoid any asserts triggering.
774#define UNUSED_PROB 128
Yaowu Xuc27fc142016-08-22 16:08:15 -0700775
Urvang Joshieb54e0c2016-11-01 15:25:57 -0700776const aom_prob av1_default_palette_y_color_prob
777 [PALETTE_MAX_SIZE - 1][PALETTE_COLOR_CONTEXTS][PALETTE_COLORS - 1] = {
778 {
779 // 2 colors
780 { 230, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
781 UNUSED_PROB, UNUSED_PROB },
782 { 214, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
783 UNUSED_PROB, UNUSED_PROB },
784 { UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
785 UNUSED_PROB, UNUSED_PROB },
786 { UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
787 UNUSED_PROB, UNUSED_PROB },
788 { UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
789 UNUSED_PROB, UNUSED_PROB },
790 { 240, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
791 UNUSED_PROB, UNUSED_PROB },
792 { 73, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
793 UNUSED_PROB },
794 { UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
795 UNUSED_PROB, UNUSED_PROB },
796 { 130, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
797 UNUSED_PROB, UNUSED_PROB },
798 { 227, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
799 UNUSED_PROB, UNUSED_PROB },
800 { UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
801 UNUSED_PROB, UNUSED_PROB },
802 { 188, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
803 UNUSED_PROB, UNUSED_PROB },
804 { 75, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
805 UNUSED_PROB },
806 { 250, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
807 UNUSED_PROB, UNUSED_PROB },
808 { 223, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
809 UNUSED_PROB, UNUSED_PROB },
810 { 252, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
811 UNUSED_PROB, UNUSED_PROB },
812 },
813 {
814 // 3 colors
815 { 229, 137, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
816 UNUSED_PROB },
817 { 197, 120, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
818 UNUSED_PROB },
819 { 107, 195, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
820 UNUSED_PROB },
821 { UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
822 UNUSED_PROB, UNUSED_PROB },
823 { 27, 151, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
824 UNUSED_PROB },
825 { 230, 130, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
826 UNUSED_PROB },
827 { 37, 230, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
828 UNUSED_PROB },
829 { 67, 221, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
830 UNUSED_PROB },
831 { 124, 230, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
832 UNUSED_PROB },
833 { 195, 109, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
834 UNUSED_PROB },
835 { 99, 122, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
836 UNUSED_PROB },
837 { 205, 208, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
838 UNUSED_PROB },
839 { 40, 235, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
840 UNUSED_PROB },
841 { 251, 132, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
842 UNUSED_PROB },
843 { 237, 186, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
844 UNUSED_PROB },
845 { 253, 112, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
846 UNUSED_PROB },
847 },
848 {
849 // 4 colors
850 { 195, 87, 128, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
851 { 143, 100, 123, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
852 { 94, 124, 119, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
853 { 77, 91, 130, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
854 { 39, 114, 178, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
855 { 222, 94, 125, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
856 { 44, 203, 132, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
857 { 68, 175, 122, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
858 { 110, 187, 124, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
859 { 152, 91, 128, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
860 { 70, 109, 181, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
861 { 133, 113, 164, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
862 { 47, 205, 133, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
863 { 247, 94, 136, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
864 { 205, 122, 146, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
865 { 251, 100, 141, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
866 },
867 {
868 // 5 colors
869 { 195, 65, 84, 125, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
870 { 150, 76, 84, 121, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
871 { 94, 110, 81, 117, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
872 { 79, 85, 91, 139, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
873 { 26, 102, 139, 127, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
874 { 220, 73, 91, 119, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
875 { 38, 203, 86, 127, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
876 { 61, 186, 72, 124, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
877 { 132, 199, 84, 128, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
878 { 172, 52, 62, 120, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
879 { 102, 89, 121, 122, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
880 { 182, 48, 69, 186, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
881 { 36, 206, 87, 126, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
882 { 249, 55, 67, 122, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
883 { 218, 88, 75, 122, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
884 { 253, 64, 80, 119, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
885 },
886 {
887 // 6 colors
888 { 182, 54, 64, 75, 118, UNUSED_PROB, UNUSED_PROB },
889 { 126, 67, 70, 76, 116, UNUSED_PROB, UNUSED_PROB },
890 { 79, 92, 67, 85, 120, UNUSED_PROB, UNUSED_PROB },
891 { 63, 61, 81, 118, 132, UNUSED_PROB, UNUSED_PROB },
892 { 21, 80, 105, 83, 119, UNUSED_PROB, UNUSED_PROB },
893 { 215, 72, 74, 74, 111, UNUSED_PROB, UNUSED_PROB },
894 { 50, 176, 63, 79, 120, UNUSED_PROB, UNUSED_PROB },
895 { 72, 148, 66, 77, 120, UNUSED_PROB, UNUSED_PROB },
896 { 105, 177, 57, 78, 130, UNUSED_PROB, UNUSED_PROB },
897 { 150, 66, 66, 80, 127, UNUSED_PROB, UNUSED_PROB },
898 { 81, 76, 109, 85, 116, UNUSED_PROB, UNUSED_PROB },
899 { 113, 81, 62, 96, 148, UNUSED_PROB, UNUSED_PROB },
900 { 54, 179, 69, 82, 121, UNUSED_PROB, UNUSED_PROB },
901 { 244, 47, 48, 67, 118, UNUSED_PROB, UNUSED_PROB },
902 { 198, 83, 53, 65, 121, UNUSED_PROB, UNUSED_PROB },
903 { 250, 42, 51, 69, 110, UNUSED_PROB, UNUSED_PROB },
904 },
905 {
906 // 7 colors
907 { 182, 45, 54, 62, 74, 113, UNUSED_PROB },
908 { 124, 63, 57, 62, 77, 114, UNUSED_PROB },
909 { 77, 80, 56, 66, 76, 117, UNUSED_PROB },
910 { 63, 57, 69, 98, 85, 131, UNUSED_PROB },
911 { 19, 81, 98, 63, 80, 116, UNUSED_PROB },
912 { 215, 56, 60, 63, 68, 105, UNUSED_PROB },
913 { 50, 174, 50, 60, 79, 118, UNUSED_PROB },
914 { 68, 151, 50, 58, 73, 117, UNUSED_PROB },
915 { 104, 182, 53, 57, 79, 127, UNUSED_PROB },
916 { 156, 50, 51, 63, 77, 111, UNUSED_PROB },
917 { 88, 67, 97, 59, 82, 120, UNUSED_PROB },
918 { 114, 81, 46, 65, 103, 132, UNUSED_PROB },
919 { 55, 166, 57, 66, 82, 120, UNUSED_PROB },
920 { 245, 34, 38, 43, 63, 114, UNUSED_PROB },
921 { 203, 68, 45, 47, 60, 118, UNUSED_PROB },
922 { 250, 35, 37, 47, 66, 110, UNUSED_PROB },
923 },
924 {
925 // 8 colors
926 { 180, 43, 46, 50, 56, 69, 109 },
927 { 116, 53, 51, 49, 57, 73, 115 },
928 { 79, 70, 49, 50, 59, 74, 117 },
929 { 60, 54, 57, 70, 62, 83, 129 },
930 { 20, 73, 85, 52, 66, 81, 119 },
931 { 213, 56, 52, 49, 53, 62, 104 },
932 { 48, 161, 41, 45, 56, 77, 116 },
933 { 68, 139, 40, 47, 54, 71, 116 },
934 { 123, 166, 42, 43, 52, 76, 130 },
935 { 153, 44, 44, 47, 54, 79, 129 },
936 { 87, 64, 83, 49, 60, 75, 127 },
937 { 131, 68, 43, 48, 73, 96, 130 },
938 { 55, 152, 45, 51, 64, 77, 113 },
939 { 243, 30, 28, 33, 41, 65, 114 },
940 { 202, 56, 35, 36, 42, 63, 123 },
941 { 249, 31, 29, 32, 45, 68, 111 },
942 }
943 };
944
945const aom_prob av1_default_palette_uv_color_prob
946 [PALETTE_MAX_SIZE - 1][PALETTE_COLOR_CONTEXTS][PALETTE_COLORS - 1] = {
947 {
948 // 2 colors
949 { 228, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
950 UNUSED_PROB, UNUSED_PROB },
951 { 195, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
952 UNUSED_PROB, UNUSED_PROB },
953 { UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
954 UNUSED_PROB, UNUSED_PROB },
955 { UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
956 UNUSED_PROB, UNUSED_PROB },
957 { UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
958 UNUSED_PROB, UNUSED_PROB },
959 { 228, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
960 UNUSED_PROB, UNUSED_PROB },
961 { 71, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
962 UNUSED_PROB },
963 { UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
964 UNUSED_PROB, UNUSED_PROB },
965 { 129, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
966 UNUSED_PROB, UNUSED_PROB },
967 { 206, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
968 UNUSED_PROB, UNUSED_PROB },
969 { UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
970 UNUSED_PROB, UNUSED_PROB },
971 { 136, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
972 UNUSED_PROB, UNUSED_PROB },
973 { 98, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
974 UNUSED_PROB },
975 { 236, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
976 UNUSED_PROB, UNUSED_PROB },
977 { 222, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
978 UNUSED_PROB, UNUSED_PROB },
979 { 249, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
980 UNUSED_PROB, UNUSED_PROB },
981 },
982 {
983 // 3 colors
984 { 198, 136, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
985 UNUSED_PROB },
986 { 178, 105, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
987 UNUSED_PROB },
988 { 100, 206, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
989 UNUSED_PROB },
990 { UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
991 UNUSED_PROB, UNUSED_PROB },
992 { 12, 136, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
993 UNUSED_PROB },
994 { 219, 134, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
995 UNUSED_PROB },
996 { 50, 198, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
997 UNUSED_PROB },
998 { 61, 231, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
999 UNUSED_PROB },
1000 { 110, 209, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
1001 UNUSED_PROB },
1002 { 173, 106, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
1003 UNUSED_PROB },
1004 { 145, 166, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
1005 UNUSED_PROB },
1006 { 156, 175, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
1007 UNUSED_PROB },
1008 { 69, 183, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
1009 UNUSED_PROB },
1010 { 241, 163, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
1011 UNUSED_PROB },
1012 { 224, 160, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
1013 UNUSED_PROB },
1014 { 246, 154, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
1015 UNUSED_PROB },
1016 },
1017 {
1018 // 4 colors
1019 { 173, 88, 143, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
1020 { 146, 81, 127, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
1021 { 84, 134, 102, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
1022 { 69, 138, 140, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
1023 { 31, 103, 200, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
1024 { 217, 101, 139, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
1025 { 51, 174, 121, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
1026 { 64, 177, 109, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
1027 { 96, 179, 145, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
1028 { 164, 77, 114, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
1029 { 87, 94, 156, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
1030 { 105, 57, 173, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
1031 { 63, 158, 137, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
1032 { 236, 102, 156, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
1033 { 197, 115, 153, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
1034 { 245, 106, 154, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
1035 },
1036 {
1037 // 5 colors
1038 { 179, 64, 97, 129, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
1039 { 137, 56, 88, 125, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
1040 { 82, 107, 61, 118, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
1041 { 59, 113, 86, 115, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
1042 { 23, 88, 118, 130, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
1043 { 213, 66, 90, 125, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
1044 { 37, 181, 103, 121, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
1045 { 47, 188, 61, 131, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
1046 { 104, 185, 103, 144, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
1047 { 163, 39, 76, 112, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
1048 { 94, 74, 131, 126, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
1049 { 142, 42, 103, 163, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
1050 { 53, 162, 99, 149, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
1051 { 239, 54, 84, 108, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
1052 { 203, 84, 110, 147, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
1053 { 248, 70, 105, 151, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
1054 },
1055 {
1056 // 6 colors
1057 { 189, 50, 67, 90, 130, UNUSED_PROB, UNUSED_PROB },
1058 { 114, 50, 55, 90, 123, UNUSED_PROB, UNUSED_PROB },
1059 { 66, 76, 54, 82, 128, UNUSED_PROB, UNUSED_PROB },
1060 { 43, 69, 69, 80, 129, UNUSED_PROB, UNUSED_PROB },
1061 { 22, 59, 87, 88, 141, UNUSED_PROB, UNUSED_PROB },
1062 { 203, 49, 68, 87, 122, UNUSED_PROB, UNUSED_PROB },
1063 { 43, 157, 74, 104, 146, UNUSED_PROB, UNUSED_PROB },
1064 { 54, 138, 51, 95, 138, UNUSED_PROB, UNUSED_PROB },
1065 { 82, 171, 58, 102, 146, UNUSED_PROB, UNUSED_PROB },
1066 { 129, 38, 59, 64, 168, UNUSED_PROB, UNUSED_PROB },
1067 { 56, 67, 119, 92, 112, UNUSED_PROB, UNUSED_PROB },
1068 { 96, 62, 53, 132, 82, UNUSED_PROB, UNUSED_PROB },
1069 { 60, 147, 77, 108, 145, UNUSED_PROB, UNUSED_PROB },
1070 { 238, 76, 73, 93, 148, UNUSED_PROB, UNUSED_PROB },
1071 { 189, 86, 73, 103, 157, UNUSED_PROB, UNUSED_PROB },
1072 { 246, 62, 75, 83, 167, UNUSED_PROB, UNUSED_PROB },
1073 },
1074 {
1075 // 7 colors
1076 { 179, 42, 51, 73, 99, 134, UNUSED_PROB },
1077 { 119, 52, 52, 61, 64, 114, UNUSED_PROB },
1078 { 53, 77, 35, 65, 71, 131, UNUSED_PROB },
1079 { 38, 70, 51, 68, 89, 144, UNUSED_PROB },
1080 { 23, 65, 128, 73, 97, 131, UNUSED_PROB },
1081 { 210, 47, 52, 63, 81, 143, UNUSED_PROB },
1082 { 42, 159, 57, 68, 98, 143, UNUSED_PROB },
1083 { 49, 153, 45, 82, 93, 143, UNUSED_PROB },
1084 { 81, 169, 52, 72, 113, 151, UNUSED_PROB },
1085 { 136, 46, 35, 56, 75, 96, UNUSED_PROB },
1086 { 57, 84, 109, 47, 107, 131, UNUSED_PROB },
1087 { 128, 78, 57, 36, 128, 85, UNUSED_PROB },
1088 { 54, 149, 68, 77, 94, 153, UNUSED_PROB },
1089 { 243, 58, 50, 71, 81, 167, UNUSED_PROB },
1090 { 189, 92, 64, 70, 121, 173, UNUSED_PROB },
1091 { 248, 35, 38, 51, 82, 201, UNUSED_PROB },
1092 },
1093 {
1094 // 8 colors
1095 { 201, 40, 36, 42, 64, 92, 123 },
1096 { 116, 43, 33, 43, 73, 102, 128 },
1097 { 46, 77, 37, 69, 62, 78, 150 },
1098 { 40, 65, 52, 50, 76, 89, 133 },
1099 { 28, 48, 91, 17, 64, 77, 133 },
1100 { 218, 43, 43, 37, 56, 72, 163 },
1101 { 41, 155, 44, 83, 82, 129, 180 },
1102 { 44, 141, 29, 55, 64, 89, 147 },
1103 { 92, 166, 48, 45, 59, 126, 179 },
1104 { 169, 35, 49, 41, 36, 99, 139 },
1105 { 55, 77, 77, 56, 60, 75, 156 },
1106 { 155, 81, 51, 64, 57, 182, 255 },
1107 { 60, 134, 49, 49, 93, 128, 174 },
1108 { 244, 98, 51, 46, 22, 73, 238 },
1109 { 189, 70, 40, 87, 93, 79, 201 },
1110 { 248, 54, 49, 40, 29, 42, 227 },
1111 }
1112 };
1113
1114#undef UNUSED_PROB
Yaowu Xuc27fc142016-08-22 16:08:15 -07001115
1116static const int palette_color_context_lookup[PALETTE_COLOR_CONTEXTS] = {
1117 // (3, 0, 0, 0), (3, 2, 0, 0), (3, 3, 2, 0), (3, 3, 2, 2),
1118 3993, 4235, 4378, 4380,
1119 // (4, 3, 3, 0), (5, 0, 0, 0), (5, 3, 0, 0), (5, 3, 2, 0),
1120 5720, 6655, 7018, 7040,
1121 // (5, 5, 0, 0), (6, 2, 0, 0), (6, 2, 2, 0), (6, 4, 0, 0),
1122 7260, 8228, 8250, 8470,
1123 // (7, 3, 0, 0), (8, 0, 0, 0), (8, 2, 0, 0), (10, 0, 0, 0)
1124 9680, 10648, 10890, 13310
1125};
Urvang Joshib100db72016-10-12 16:28:56 -07001126#endif // CONFIG_PALETTE
Yaowu Xuc27fc142016-08-22 16:08:15 -07001127
Jingning Hanb4329a22016-11-22 16:20:13 -08001128// The transform size is coded as an offset to the smallest transform
1129// block size.
Jingning Han607fa6a2016-10-26 10:46:28 -07001130const aom_tree_index av1_tx_size_tree[MAX_TX_DEPTH][TREE_SIZE(TX_SIZES)] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -07001131 {
1132 // Max tx_size is 8X8
Jingning Hanb4329a22016-11-22 16:20:13 -08001133 -0, -1,
Yaowu Xuc27fc142016-08-22 16:08:15 -07001134 },
1135 {
1136 // Max tx_size is 16X16
Jingning Hanb4329a22016-11-22 16:20:13 -08001137 -0, 2, -1, -2,
Yaowu Xuc27fc142016-08-22 16:08:15 -07001138 },
1139 {
1140 // Max tx_size is 32X32
Jingning Hanb4329a22016-11-22 16:20:13 -08001141 -0, 2, -1, 4, -2, -3,
Yaowu Xuc27fc142016-08-22 16:08:15 -07001142 },
Debargha Mukherjee18d38f62016-11-17 20:30:16 -08001143#if CONFIG_TX64X64
Debargha Mukherjee25ed5302016-11-22 12:13:41 -08001144 {
1145 // Max tx_size is 64X64
Jingning Hanb4329a22016-11-22 16:20:13 -08001146 -0, 2, -1, 4, -2, 6, -3, -4,
Debargha Mukherjee25ed5302016-11-22 12:13:41 -08001147 },
Debargha Mukherjee18d38f62016-11-17 20:30:16 -08001148#endif // CONFIG_TX64X64
Yaowu Xuc27fc142016-08-22 16:08:15 -07001149};
1150
Jingning Hanaae72a62016-10-25 15:35:29 -07001151static const aom_prob default_tx_size_prob[MAX_TX_DEPTH][TX_SIZE_CONTEXTS]
1152 [MAX_TX_DEPTH] = {
clang-format67948d32016-09-07 22:40:40 -07001153 {
1154 // Max tx_size is 8X8
1155 { 100 },
1156 { 66 },
1157 },
1158 {
1159 // Max tx_size is 16X16
1160 { 20, 152 },
1161 { 15, 101 },
1162 },
1163 {
1164 // Max tx_size is 32X32
1165 { 3, 136, 37 },
1166 { 5, 52, 13 },
1167 },
Debargha Mukherjee18d38f62016-11-17 20:30:16 -08001168#if CONFIG_TX64X64
1169 {
1170 // Max tx_size is 64X64
1171 { 1, 64, 136, 127 },
1172 { 1, 32, 52, 67 },
1173 },
1174#endif // CONFIG_TX64X64
clang-format67948d32016-09-07 22:40:40 -07001175 };
Yaowu Xuc27fc142016-08-22 16:08:15 -07001176
Debargha Mukherjee5cd2ab92016-09-08 15:15:17 -07001177#if CONFIG_LOOP_RESTORATION
Debargha Mukherjee8f209a82016-10-12 10:47:01 -07001178const aom_tree_index av1_switchable_restore_tree[TREE_SIZE(
1179 RESTORE_SWITCHABLE_TYPES)] = {
1180 -RESTORE_NONE, 2, -RESTORE_SGRPROJ, 4, -RESTORE_BILATERAL, -RESTORE_WIENER,
1181};
Debargha Mukherjee5cd2ab92016-09-08 15:15:17 -07001182
Debargha Mukherjee8f209a82016-10-12 10:47:01 -07001183static const aom_prob default_switchable_restore_prob[RESTORE_SWITCHABLE_TYPES -
1184 1] = { 32, 85, 128 };
Debargha Mukherjee5cd2ab92016-09-08 15:15:17 -07001185#endif // CONFIG_LOOP_RESTORATION
1186
Urvang Joshib100db72016-10-12 16:28:56 -07001187#if CONFIG_PALETTE
Yaowu Xuf883b422016-08-30 14:01:10 -07001188int av1_get_palette_color_context(const uint8_t *color_map, int cols, int r,
Urvang Joshi967ff392016-09-07 14:57:49 -07001189 int c, int n, uint8_t *color_order,
1190 int *color_idx) {
Urvang Joshi4f4b68e2016-10-24 17:11:10 -07001191 int i;
1192 // The +10 below should not be needed. But we get a warning "array subscript
1193 // is above array bounds [-Werror=array-bounds]" without it, possibly due to
1194 // this (or similar) bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59124
Yaowu Xuc27fc142016-08-22 16:08:15 -07001195 int scores[PALETTE_MAX_SIZE + 10];
Urvang Joshi4f4b68e2016-10-24 17:11:10 -07001196 const int weights[4] = { 3, 2, 3, 2 };
Urvang Joshi79f4fc42016-10-26 09:40:35 -07001197 int color_ctx_hash;
1198 int color_ctx;
Yaowu Xuc27fc142016-08-22 16:08:15 -07001199 int color_neighbors[4];
Urvang Joshi967ff392016-09-07 14:57:49 -07001200 int inverse_color_order[PALETTE_MAX_SIZE];
Yaowu Xuc27fc142016-08-22 16:08:15 -07001201 assert(n <= PALETTE_MAX_SIZE);
1202
Urvang Joshi79f4fc42016-10-26 09:40:35 -07001203 // Get color indices of neighbors.
Urvang Joshi4f4b68e2016-10-24 17:11:10 -07001204 color_neighbors[0] = (c - 1 >= 0) ? color_map[r * cols + c - 1] : -1;
1205 color_neighbors[1] =
1206 (c - 1 >= 0 && r - 1 >= 0) ? color_map[(r - 1) * cols + c - 1] : -1;
1207 color_neighbors[2] = (r - 1 >= 0) ? color_map[(r - 1) * cols + c] : -1;
1208 color_neighbors[3] = (r - 1 >= 0 && c + 1 <= cols - 1)
1209 ? color_map[(r - 1) * cols + c + 1]
1210 : -1;
Yaowu Xuc27fc142016-08-22 16:08:15 -07001211
Urvang Joshi967ff392016-09-07 14:57:49 -07001212 for (i = 0; i < PALETTE_MAX_SIZE; ++i) {
1213 color_order[i] = i;
1214 inverse_color_order[i] = i;
1215 }
Yaowu Xuc27fc142016-08-22 16:08:15 -07001216 memset(scores, 0, PALETTE_MAX_SIZE * sizeof(scores[0]));
1217 for (i = 0; i < 4; ++i) {
Urvang Joshi4f4b68e2016-10-24 17:11:10 -07001218 if (color_neighbors[i] >= 0) {
1219 scores[color_neighbors[i]] += weights[i];
1220 }
Yaowu Xuc27fc142016-08-22 16:08:15 -07001221 }
1222
Urvang Joshi4f4b68e2016-10-24 17:11:10 -07001223 // Get the top 4 scores (sorted from large to small).
Yaowu Xuc27fc142016-08-22 16:08:15 -07001224 for (i = 0; i < 4; ++i) {
Urvang Joshi4f4b68e2016-10-24 17:11:10 -07001225 int max = scores[i];
1226 int max_idx = i;
1227 int j;
1228 for (j = i + 1; j < n; ++j) {
Yaowu Xuc27fc142016-08-22 16:08:15 -07001229 if (scores[j] > max) {
1230 max = scores[j];
1231 max_idx = j;
1232 }
Yaowu Xuc27fc142016-08-22 16:08:15 -07001233 }
1234
1235 if (max_idx != i) {
Urvang Joshi4f4b68e2016-10-24 17:11:10 -07001236 int temp = scores[i];
Yaowu Xuc27fc142016-08-22 16:08:15 -07001237 scores[i] = scores[max_idx];
1238 scores[max_idx] = temp;
1239
1240 temp = color_order[i];
1241 color_order[i] = color_order[max_idx];
1242 color_order[max_idx] = temp;
Urvang Joshi967ff392016-09-07 14:57:49 -07001243 inverse_color_order[color_order[i]] = i;
1244 inverse_color_order[color_order[max_idx]] = max_idx;
Yaowu Xuc27fc142016-08-22 16:08:15 -07001245 }
1246 }
1247
Urvang Joshi79f4fc42016-10-26 09:40:35 -07001248 // Get hash value of context.
1249 color_ctx_hash = 0;
1250 for (i = 0; i < 4; ++i) color_ctx_hash = color_ctx_hash * 11 + scores[i];
Yaowu Xuc27fc142016-08-22 16:08:15 -07001251
Urvang Joshi79f4fc42016-10-26 09:40:35 -07001252 // Lookup context from hash.
1253 color_ctx = 0; // Default.
1254 for (i = 0; i < PALETTE_COLOR_CONTEXTS; ++i) {
1255 if (color_ctx_hash == palette_color_context_lookup[i]) {
Yaowu Xuc27fc142016-08-22 16:08:15 -07001256 color_ctx = i;
1257 break;
1258 }
Urvang Joshi79f4fc42016-10-26 09:40:35 -07001259 }
Yaowu Xuc27fc142016-08-22 16:08:15 -07001260
Urvang Joshi967ff392016-09-07 14:57:49 -07001261 if (color_idx != NULL) {
1262 *color_idx = inverse_color_order[color_map[r * cols + c]];
1263 }
Yaowu Xuc27fc142016-08-22 16:08:15 -07001264 return color_ctx;
1265}
Urvang Joshib100db72016-10-12 16:28:56 -07001266#endif // CONFIG_PALETTE
Yaowu Xuc27fc142016-08-22 16:08:15 -07001267
1268#if CONFIG_VAR_TX
Yaowu Xuf883b422016-08-30 14:01:10 -07001269static const aom_prob default_txfm_partition_probs[TXFM_PARTITION_CONTEXTS] = {
Jingning Hanc8b89362016-11-01 10:28:53 -07001270 250, 231, 212, 241, 166, 66, 241, 230, 135, 243, 154, 64, 248, 161, 63, 128,
Yaowu Xuc27fc142016-08-22 16:08:15 -07001271};
1272#endif
1273
Yaowu Xuf883b422016-08-30 14:01:10 -07001274static const aom_prob default_skip_probs[SKIP_CONTEXTS] = { 192, 128, 64 };
Yaowu Xuc27fc142016-08-22 16:08:15 -07001275
1276#if CONFIG_EXT_INTERP
Yaowu Xuf883b422016-08-30 14:01:10 -07001277static const aom_prob default_switchable_interp_prob
Yaowu Xuc27fc142016-08-22 16:08:15 -07001278 [SWITCHABLE_FILTER_CONTEXTS][SWITCHABLE_FILTERS - 1] = {
1279#if CONFIG_DUAL_FILTER
1280 { 235, 192, 128, 128 }, { 36, 243, 208, 128 }, { 34, 16, 128, 128 },
1281 { 36, 243, 48, 128 }, { 34, 16, 128, 128 }, { 149, 160, 128, 128 },
1282
1283 { 235, 192, 128, 128 }, { 36, 243, 208, 128 }, { 34, 16, 128, 128 },
1284 { 36, 243, 48, 128 }, { 34, 16, 128, 128 }, { 149, 160, 128, 128 },
1285
1286 { 235, 192, 128, 128 }, { 36, 243, 208, 128 }, { 34, 16, 128, 128 },
1287 { 36, 243, 48, 128 }, { 34, 16, 128, 128 }, { 149, 160, 128, 128 },
1288
1289 { 235, 192, 128, 128 }, { 36, 243, 208, 128 }, { 34, 16, 128, 128 },
1290 { 36, 243, 48, 128 }, { 34, 16, 128, 128 }, { 149, 160, 128, 128 },
1291#else
1292 { 235, 192, 128, 128 }, { 36, 243, 208, 128 }, { 34, 16, 128, 128 },
1293 { 36, 243, 48, 128 }, { 34, 16, 128, 128 }, { 149, 160, 128, 128 },
1294#endif
1295 };
1296#else // CONFIG_EXT_INTERP
1297#if CONFIG_DUAL_FILTER
clang-format67948d32016-09-07 22:40:40 -07001298static const aom_prob
1299 default_switchable_interp_prob[SWITCHABLE_FILTER_CONTEXTS]
1300 [SWITCHABLE_FILTERS - 1] = {
1301 { 235, 162 }, { 36, 255 },
1302 { 34, 3 }, { 149, 144 },
Yaowu Xuc27fc142016-08-22 16:08:15 -07001303
clang-format67948d32016-09-07 22:40:40 -07001304 { 235, 162 }, { 36, 255 },
1305 { 34, 3 }, { 10, 3 },
Yaowu Xuc27fc142016-08-22 16:08:15 -07001306
clang-format67948d32016-09-07 22:40:40 -07001307 { 235, 162 }, { 36, 255 },
1308 { 34, 3 }, { 149, 144 },
Yaowu Xuc27fc142016-08-22 16:08:15 -07001309
clang-format67948d32016-09-07 22:40:40 -07001310 { 235, 162 }, { 36, 255 },
1311 { 34, 3 }, { 10, 3 },
1312 };
Yaowu Xuc27fc142016-08-22 16:08:15 -07001313#else
clang-format67948d32016-09-07 22:40:40 -07001314static const aom_prob default_switchable_interp_prob[SWITCHABLE_FILTER_CONTEXTS]
1315 [SWITCHABLE_FILTERS - 1] = {
1316 { 235, 162 },
1317 { 36, 255 },
1318 { 34, 3 },
1319 { 149, 144 },
1320 };
Yaowu Xuc27fc142016-08-22 16:08:15 -07001321#endif
1322#endif // CONFIG_EXT_INTERP
1323
1324#if CONFIG_EXT_TX
1325/* clang-format off */
Yaowu Xuf883b422016-08-30 14:01:10 -07001326const aom_tree_index av1_ext_tx_inter_tree[EXT_TX_SETS_INTER]
Yaowu Xuc27fc142016-08-22 16:08:15 -07001327 [TREE_SIZE(TX_TYPES)] = {
1328 { // ToDo(yaowu): remove used entry 0.
1329 0
1330 }, {
1331 -IDTX, 2,
1332 4, 14,
1333 6, 8,
1334 -V_DCT, -H_DCT,
1335 10, 12,
1336 -V_ADST, -H_ADST,
1337 -V_FLIPADST, -H_FLIPADST,
1338 -DCT_DCT, 16,
1339 18, 24,
1340 20, 22,
1341 -ADST_DCT, -DCT_ADST,
1342 -FLIPADST_DCT, -DCT_FLIPADST,
1343 26, 28,
1344 -ADST_ADST, -FLIPADST_FLIPADST,
1345 -ADST_FLIPADST, -FLIPADST_ADST
1346 }, {
1347 -IDTX, 2,
1348 4, 6,
1349 -V_DCT, -H_DCT,
1350 -DCT_DCT, 8,
1351 10, 16,
1352 12, 14,
1353 -ADST_DCT, -DCT_ADST,
1354 -FLIPADST_DCT, -DCT_FLIPADST,
1355 18, 20,
1356 -ADST_ADST, -FLIPADST_FLIPADST,
1357 -ADST_FLIPADST, -FLIPADST_ADST
1358 }, {
1359 -IDTX, -DCT_DCT,
1360 }
1361};
1362
Yaowu Xuf883b422016-08-30 14:01:10 -07001363const aom_tree_index av1_ext_tx_intra_tree[EXT_TX_SETS_INTRA]
Yaowu Xuc27fc142016-08-22 16:08:15 -07001364 [TREE_SIZE(TX_TYPES)] = {
1365 { // ToDo(yaowu): remove unused entry 0.
1366 0
1367 }, {
1368 -IDTX, 2,
1369 -DCT_DCT, 4,
1370 6, 8,
1371 -V_DCT, -H_DCT,
1372 -ADST_ADST, 10,
1373 -ADST_DCT, -DCT_ADST,
1374 }, {
1375 -IDTX, 2,
1376 -DCT_DCT, 4,
1377 -ADST_ADST, 6,
1378 -ADST_DCT, -DCT_ADST,
1379 }
1380};
1381/* clang-format on */
1382
Yaowu Xuf883b422016-08-30 14:01:10 -07001383static const aom_prob
Yaowu Xuc27fc142016-08-22 16:08:15 -07001384 default_inter_ext_tx_prob[EXT_TX_SETS_INTER][EXT_TX_SIZES][TX_TYPES - 1] = {
1385 {
1386 // ToDo(yaowu): remove unused entry 0.
1387 { 0 },
1388 { 0 },
1389 { 0 },
1390#if EXT_TX_SIZES == 4
1391 { 0 },
1392#endif
1393 },
1394 {
1395 { 10, 24, 30, 128, 128, 128, 128, 112, 160, 128, 128, 128, 128, 128,
1396 128 },
1397 { 10, 24, 30, 128, 128, 128, 128, 112, 160, 128, 128, 128, 128, 128,
1398 128 },
1399 { 10, 24, 30, 128, 128, 128, 128, 112, 160, 128, 128, 128, 128, 128,
1400 128 },
1401#if EXT_TX_SIZES == 4
1402 { 10, 24, 30, 128, 128, 128, 128, 112, 160, 128, 128, 128, 128, 128,
1403 128 },
1404#endif
1405 },
1406 {
1407 { 10, 30, 128, 112, 160, 128, 128, 128, 128, 128, 128 },
1408 { 10, 30, 128, 112, 160, 128, 128, 128, 128, 128, 128 },
1409 { 10, 30, 128, 112, 160, 128, 128, 128, 128, 128, 128 },
1410#if EXT_TX_SIZES == 4
1411 { 10, 30, 128, 112, 160, 128, 128, 128, 128, 128, 128 },
1412#endif
1413 },
1414 {
1415 { 12 },
1416 { 12 },
1417 { 12 },
1418#if EXT_TX_SIZES == 4
1419 { 12 },
1420#endif
1421 }
1422 };
1423
clang-format67948d32016-09-07 22:40:40 -07001424static const aom_prob
1425 default_intra_ext_tx_prob[EXT_TX_SETS_INTRA][EXT_TX_SIZES][INTRA_MODES]
1426 [TX_TYPES - 1] = {
1427 {
1428 // ToDo(yaowu): remove unused entry 0.
1429 {
1430 { 0 },
1431 { 0 },
1432 { 0 },
1433 { 0 },
1434 { 0 },
1435 { 0 },
1436 { 0 },
1437 { 0 },
1438 { 0 },
1439 { 0 },
1440 },
1441 {
1442 { 0 },
1443 { 0 },
1444 { 0 },
1445 { 0 },
1446 { 0 },
1447 { 0 },
1448 { 0 },
1449 { 0 },
1450 { 0 },
1451 { 0 },
1452 },
1453 {
1454 { 0 },
1455 { 0 },
1456 { 0 },
1457 { 0 },
1458 { 0 },
1459 { 0 },
1460 { 0 },
1461 { 0 },
1462 { 0 },
1463 { 0 },
Yaowu Xuc27fc142016-08-22 16:08:15 -07001464#if EXT_TX_SIZES == 4
clang-format67948d32016-09-07 22:40:40 -07001465 },
1466 {
1467 { 0 },
1468 { 0 },
1469 { 0 },
1470 { 0 },
1471 { 0 },
1472 { 0 },
1473 { 0 },
1474 { 0 },
1475 { 0 },
1476 { 0 },
Yaowu Xuc27fc142016-08-22 16:08:15 -07001477#endif
clang-format67948d32016-09-07 22:40:40 -07001478 },
1479 },
1480 {
1481 {
1482 { 8, 224, 32, 128, 64, 128 },
1483 { 10, 32, 32, 128, 16, 192 },
1484 { 10, 32, 32, 128, 16, 64 },
1485 { 9, 200, 32, 128, 64, 128 },
1486 { 8, 8, 32, 128, 224, 128 },
1487 { 10, 32, 32, 128, 16, 192 },
1488 { 10, 32, 32, 128, 16, 64 },
1489 { 10, 23, 32, 128, 80, 176 },
1490 { 10, 23, 32, 128, 80, 176 },
1491 { 10, 32, 32, 128, 16, 64 },
1492 },
1493 {
1494 { 8, 224, 32, 128, 64, 128 },
1495 { 10, 32, 32, 128, 16, 192 },
1496 { 10, 32, 32, 128, 16, 64 },
1497 { 9, 200, 32, 128, 64, 128 },
1498 { 8, 8, 32, 128, 224, 128 },
1499 { 10, 32, 32, 128, 16, 192 },
1500 { 10, 32, 32, 128, 16, 64 },
1501 { 10, 23, 32, 128, 80, 176 },
1502 { 10, 23, 32, 128, 80, 176 },
1503 { 10, 32, 32, 128, 16, 64 },
1504 },
1505 {
1506 { 8, 224, 32, 128, 64, 128 },
1507 { 10, 32, 32, 128, 16, 192 },
1508 { 10, 32, 32, 128, 16, 64 },
1509 { 9, 200, 32, 128, 64, 128 },
1510 { 8, 8, 32, 128, 224, 128 },
1511 { 10, 32, 32, 128, 16, 192 },
1512 { 10, 32, 32, 128, 16, 64 },
1513 { 10, 23, 32, 128, 80, 176 },
1514 { 10, 23, 32, 128, 80, 176 },
1515 { 10, 32, 32, 128, 16, 64 },
Yaowu Xuc27fc142016-08-22 16:08:15 -07001516#if EXT_TX_SIZES == 4
clang-format67948d32016-09-07 22:40:40 -07001517 },
1518 {
1519 { 8, 224, 32, 128, 64, 128 },
1520 { 10, 32, 32, 128, 16, 192 },
1521 { 10, 32, 32, 128, 16, 64 },
1522 { 9, 200, 32, 128, 64, 128 },
1523 { 8, 8, 32, 128, 224, 128 },
1524 { 10, 32, 32, 128, 16, 192 },
1525 { 10, 32, 32, 128, 16, 64 },
1526 { 10, 23, 32, 128, 80, 176 },
1527 { 10, 23, 32, 128, 80, 176 },
1528 { 10, 32, 32, 128, 16, 64 },
Yaowu Xuc27fc142016-08-22 16:08:15 -07001529#endif
clang-format67948d32016-09-07 22:40:40 -07001530 },
1531 },
1532 {
1533 {
1534 { 8, 224, 64, 128 },
1535 { 10, 32, 16, 192 },
1536 { 10, 32, 16, 64 },
1537 { 9, 200, 64, 128 },
1538 { 8, 8, 224, 128 },
1539 { 10, 32, 16, 192 },
1540 { 10, 32, 16, 64 },
1541 { 10, 23, 80, 176 },
1542 { 10, 23, 80, 176 },
1543 { 10, 32, 16, 64 },
1544 },
1545 {
1546 { 8, 224, 64, 128 },
1547 { 10, 32, 16, 192 },
1548 { 10, 32, 16, 64 },
1549 { 9, 200, 64, 128 },
1550 { 8, 8, 224, 128 },
1551 { 10, 32, 16, 192 },
1552 { 10, 32, 16, 64 },
1553 { 10, 23, 80, 176 },
1554 { 10, 23, 80, 176 },
1555 { 10, 32, 16, 64 },
1556 },
1557 {
1558 { 8, 224, 64, 128 },
1559 { 10, 32, 16, 192 },
1560 { 10, 32, 16, 64 },
1561 { 9, 200, 64, 128 },
1562 { 8, 8, 224, 128 },
1563 { 10, 32, 16, 192 },
1564 { 10, 32, 16, 64 },
1565 { 10, 23, 80, 176 },
1566 { 10, 23, 80, 176 },
1567 { 10, 32, 16, 64 },
Yaowu Xuc27fc142016-08-22 16:08:15 -07001568#if EXT_TX_SIZES == 4
clang-format67948d32016-09-07 22:40:40 -07001569 },
1570 {
1571 { 8, 224, 64, 128 },
1572 { 10, 32, 16, 192 },
1573 { 10, 32, 16, 64 },
1574 { 9, 200, 64, 128 },
1575 { 8, 8, 224, 128 },
1576 { 10, 32, 16, 192 },
1577 { 10, 32, 16, 64 },
1578 { 10, 23, 80, 176 },
1579 { 10, 23, 80, 176 },
1580 { 10, 32, 16, 64 },
Yaowu Xuc27fc142016-08-22 16:08:15 -07001581#endif
clang-format67948d32016-09-07 22:40:40 -07001582 },
1583 },
1584 };
Yaowu Xuc27fc142016-08-22 16:08:15 -07001585
1586#else
1587
1588/* clang-format off */
Yaowu Xuf883b422016-08-30 14:01:10 -07001589const aom_tree_index av1_ext_tx_tree[TREE_SIZE(TX_TYPES)] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -07001590 -DCT_DCT, 2,
1591 -ADST_ADST, 4,
1592 -ADST_DCT, -DCT_ADST
1593};
1594/* clang-format on */
1595
Nathan E. Egge7c5b4c12016-04-26 12:31:14 -04001596int av1_ext_tx_ind[TX_TYPES];
1597int av1_ext_tx_inv[TX_TYPES];
1598
Yaowu Xuf883b422016-08-30 14:01:10 -07001599static const aom_prob
Yaowu Xuc27fc142016-08-22 16:08:15 -07001600 default_intra_ext_tx_prob[EXT_TX_SIZES][TX_TYPES][TX_TYPES - 1] = {
Jingning Han607fa6a2016-10-26 10:46:28 -07001601#if CONFIG_CB4X4
1602 { { 240, 85, 128 }, { 4, 1, 248 }, { 4, 1, 8 }, { 4, 248, 128 } },
1603#endif
Yaowu Xuc27fc142016-08-22 16:08:15 -07001604 { { 240, 85, 128 }, { 4, 1, 248 }, { 4, 1, 8 }, { 4, 248, 128 } },
1605 { { 244, 85, 128 }, { 8, 2, 248 }, { 8, 2, 8 }, { 8, 248, 128 } },
1606 { { 248, 85, 128 }, { 16, 4, 248 }, { 16, 4, 8 }, { 16, 248, 128 } },
1607 };
1608
Yaowu Xuf883b422016-08-30 14:01:10 -07001609static const aom_prob default_inter_ext_tx_prob[EXT_TX_SIZES][TX_TYPES - 1] = {
Jingning Han607fa6a2016-10-26 10:46:28 -07001610#if CONFIG_CB4X4
1611 { 160, 85, 128 },
1612#endif
1613 { 160, 85, 128 },
1614 { 176, 85, 128 },
1615 { 192, 85, 128 },
Yaowu Xuc27fc142016-08-22 16:08:15 -07001616};
1617#endif // CONFIG_EXT_TX
1618
1619#if CONFIG_EXT_INTRA
clang-format67948d32016-09-07 22:40:40 -07001620static const aom_prob default_intra_filter_probs[INTRA_FILTERS + 1]
1621 [INTRA_FILTERS - 1] = {
1622 { 98, 63, 60 },
1623 { 98, 82, 80 },
1624 { 94, 65, 103 },
1625 { 49, 25, 24 },
1626 { 72, 38, 50 },
1627 };
Yaowu Xuf883b422016-08-30 14:01:10 -07001628const aom_tree_index av1_intra_filter_tree[TREE_SIZE(INTRA_FILTERS)] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -07001629 -INTRA_FILTER_LINEAR, 2, -INTRA_FILTER_8TAP, 4, -INTRA_FILTER_8TAP_SHARP,
1630 -INTRA_FILTER_8TAP_SMOOTH,
1631};
1632#endif // CONFIG_EXT_INTRA
1633
hui su5db97432016-10-14 16:10:14 -07001634#if CONFIG_FILTER_INTRA
1635static const aom_prob default_filter_intra_probs[2] = { 230, 230 };
1636#endif // CONFIG_FILTER_INTRA
1637
Yaowu Xuc27fc142016-08-22 16:08:15 -07001638#if CONFIG_SUPERTX
clang-format67948d32016-09-07 22:40:40 -07001639static const aom_prob default_supertx_prob[PARTITION_SUPERTX_CONTEXTS]
1640 [TX_SIZES] = {
Debargha Mukherjee5a488a62016-11-22 22:24:10 -08001641#if CONFIG_TX64X64
1642 { 1, 160, 160, 170, 180 },
1643 { 1, 200, 200, 210, 220 },
1644#else
clang-format67948d32016-09-07 22:40:40 -07001645 { 1, 160, 160, 170 },
1646 { 1, 200, 200, 210 },
Debargha Mukherjee5a488a62016-11-22 22:24:10 -08001647#endif // CONFIG_TX64X64
clang-format67948d32016-09-07 22:40:40 -07001648 };
Yaowu Xuc27fc142016-08-22 16:08:15 -07001649#endif // CONFIG_SUPERTX
1650
1651// FIXME(someone) need real defaults here
Nathan E. Eggef627e582016-08-19 20:06:51 -04001652static const aom_prob default_segment_tree_probs[SEG_TREE_PROBS] = {
1653 128, 128, 128, 128, 128, 128, 128
Yaowu Xuc27fc142016-08-22 16:08:15 -07001654};
Nathan E. Eggef627e582016-08-19 20:06:51 -04001655// clang-format off
1656static const aom_prob default_segment_pred_probs[PREDICTION_PROBS] = {
1657 128, 128, 128
1658};
1659// clang-format on
Yaowu Xuc27fc142016-08-22 16:08:15 -07001660
1661static void init_mode_probs(FRAME_CONTEXT *fc) {
Yaowu Xuf883b422016-08-30 14:01:10 -07001662 av1_copy(fc->uv_mode_prob, default_uv_probs);
1663 av1_copy(fc->y_mode_prob, default_if_y_probs);
1664 av1_copy(fc->switchable_interp_prob, default_switchable_interp_prob);
1665 av1_copy(fc->partition_prob, default_partition_probs);
1666 av1_copy(fc->intra_inter_prob, default_intra_inter_p);
1667 av1_copy(fc->comp_inter_prob, default_comp_inter_p);
1668 av1_copy(fc->comp_ref_prob, default_comp_ref_p);
Yaowu Xuc27fc142016-08-22 16:08:15 -07001669#if CONFIG_EXT_REFS
Yaowu Xuf883b422016-08-30 14:01:10 -07001670 av1_copy(fc->comp_bwdref_prob, default_comp_bwdref_p);
Yaowu Xuc27fc142016-08-22 16:08:15 -07001671#endif // CONFIG_EXT_REFS
Yaowu Xuf883b422016-08-30 14:01:10 -07001672 av1_copy(fc->single_ref_prob, default_single_ref_p);
1673 av1_copy(fc->tx_size_probs, default_tx_size_prob);
Yaowu Xuc27fc142016-08-22 16:08:15 -07001674#if CONFIG_VAR_TX
Yaowu Xuf883b422016-08-30 14:01:10 -07001675 av1_copy(fc->txfm_partition_prob, default_txfm_partition_probs);
Yaowu Xuc27fc142016-08-22 16:08:15 -07001676#endif
Yaowu Xuf883b422016-08-30 14:01:10 -07001677 av1_copy(fc->skip_probs, default_skip_probs);
Yaowu Xuc27fc142016-08-22 16:08:15 -07001678#if CONFIG_REF_MV
Yaowu Xuf883b422016-08-30 14:01:10 -07001679 av1_copy(fc->newmv_prob, default_newmv_prob);
1680 av1_copy(fc->zeromv_prob, default_zeromv_prob);
1681 av1_copy(fc->refmv_prob, default_refmv_prob);
1682 av1_copy(fc->drl_prob, default_drl_prob);
Yaowu Xuc27fc142016-08-22 16:08:15 -07001683#if CONFIG_EXT_INTER
1684 fc->new2mv_prob = default_new2mv_prob;
1685#endif // CONFIG_EXT_INTER
1686#endif // CONFIG_REF_MV
Yaowu Xuf883b422016-08-30 14:01:10 -07001687 av1_copy(fc->inter_mode_probs, default_inter_mode_probs);
Yue Chencb60b182016-10-13 15:18:22 -07001688#if CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
1689 av1_copy(fc->motion_mode_prob, default_motion_mode_prob);
1690#endif // CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
Yaowu Xuc27fc142016-08-22 16:08:15 -07001691#if CONFIG_EXT_INTER
Yaowu Xuf883b422016-08-30 14:01:10 -07001692 av1_copy(fc->inter_compound_mode_probs, default_inter_compound_mode_probs);
Sarah Parker6fddd182016-11-10 20:57:20 -08001693 av1_copy(fc->compound_type_prob, default_compound_type_probs);
Yaowu Xuf883b422016-08-30 14:01:10 -07001694 av1_copy(fc->interintra_prob, default_interintra_prob);
1695 av1_copy(fc->interintra_mode_prob, default_interintra_mode_prob);
1696 av1_copy(fc->wedge_interintra_prob, default_wedge_interintra_prob);
Yaowu Xuc27fc142016-08-22 16:08:15 -07001697#endif // CONFIG_EXT_INTER
1698#if CONFIG_SUPERTX
Yaowu Xuf883b422016-08-30 14:01:10 -07001699 av1_copy(fc->supertx_prob, default_supertx_prob);
Yaowu Xuc27fc142016-08-22 16:08:15 -07001700#endif // CONFIG_SUPERTX
Nathan E. Eggef627e582016-08-19 20:06:51 -04001701 av1_copy(fc->seg.tree_probs, default_segment_tree_probs);
1702 av1_copy(fc->seg.pred_probs, default_segment_pred_probs);
Yaowu Xuc27fc142016-08-22 16:08:15 -07001703#if CONFIG_EXT_INTRA
Yaowu Xuf883b422016-08-30 14:01:10 -07001704 av1_copy(fc->intra_filter_probs, default_intra_filter_probs);
Yaowu Xuc27fc142016-08-22 16:08:15 -07001705#endif // CONFIG_EXT_INTRA
hui su5db97432016-10-14 16:10:14 -07001706#if CONFIG_FILTER_INTRA
1707 av1_copy(fc->filter_intra_probs, default_filter_intra_probs);
1708#endif // CONFIG_FILTER_INTRA
Yaowu Xuf883b422016-08-30 14:01:10 -07001709 av1_copy(fc->inter_ext_tx_prob, default_inter_ext_tx_prob);
1710 av1_copy(fc->intra_ext_tx_prob, default_intra_ext_tx_prob);
Debargha Mukherjee5cd2ab92016-09-08 15:15:17 -07001711#if CONFIG_LOOP_RESTORATION
1712 av1_copy(fc->switchable_restore_prob, default_switchable_restore_prob);
1713#endif // CONFIG_LOOP_RESTORATION
Nathan E. Egge4947c292016-04-26 11:37:06 -04001714#if CONFIG_DAALA_EC
Nathan E. Egge5710c722016-09-08 10:01:16 -04001715 av1_tree_to_cdf_1D(av1_intra_mode_tree, fc->y_mode_prob, fc->y_mode_cdf,
1716 BLOCK_SIZE_GROUPS);
Nathan E. Egge380cb1a2016-09-08 10:13:42 -04001717 av1_tree_to_cdf_1D(av1_intra_mode_tree, fc->uv_mode_prob, fc->uv_mode_cdf,
1718 INTRA_MODES);
Nathan E. Egge4947c292016-04-26 11:37:06 -04001719 av1_tree_to_cdf_1D(av1_switchable_interp_tree, fc->switchable_interp_prob,
1720 fc->switchable_interp_cdf, SWITCHABLE_FILTER_CONTEXTS);
Nathan E. Egge6ec4d102016-09-08 10:41:20 -04001721 av1_tree_to_cdf_1D(av1_partition_tree, fc->partition_prob, fc->partition_cdf,
1722 PARTITION_CONTEXTS);
1723 av1_tree_to_cdf_1D(av1_inter_mode_tree, fc->inter_mode_probs,
1724 fc->inter_mode_cdf, INTER_MODE_CONTEXTS);
David Barkerf5419322016-11-10 12:04:21 +00001725#if !CONFIG_EXT_TX
Nathan E. Egge7c5b4c12016-04-26 12:31:14 -04001726 av1_tree_to_cdf_2D(av1_ext_tx_tree, fc->intra_ext_tx_prob,
1727 fc->intra_ext_tx_cdf, EXT_TX_SIZES, TX_TYPES);
Nathan E. Egge93878c42016-05-03 10:01:32 -04001728 av1_tree_to_cdf_1D(av1_ext_tx_tree, fc->inter_ext_tx_prob,
1729 fc->inter_ext_tx_cdf, EXT_TX_SIZES);
David Barkerf5419322016-11-10 12:04:21 +00001730#endif
Nathan E. Egge3ef926e2016-09-07 18:20:41 -04001731 av1_tree_to_cdf_2D(av1_intra_mode_tree, av1_kf_y_mode_prob, av1_kf_y_mode_cdf,
1732 INTRA_MODES, INTRA_MODES);
Nathan E. Eggef627e582016-08-19 20:06:51 -04001733 av1_tree_to_cdf(av1_segment_tree, fc->seg.tree_probs, fc->seg.tree_cdf);
Nathan E. Egge4947c292016-04-26 11:37:06 -04001734#endif
Thomas Daviesf6936102016-09-05 16:51:31 +01001735#if CONFIG_DELTA_Q
1736 av1_copy(fc->delta_q_prob, default_delta_q_probs);
1737#endif
Yaowu Xuc27fc142016-08-22 16:08:15 -07001738}
1739
Nathan E. Egge4947c292016-04-26 11:37:06 -04001740#if CONFIG_DAALA_EC
1741int av1_switchable_interp_ind[SWITCHABLE_FILTERS];
1742int av1_switchable_interp_inv[SWITCHABLE_FILTERS];
Thomas Davies6519beb2016-10-19 14:46:07 +01001743
1744void av1_set_mode_cdfs(struct AV1Common *cm) {
1745 FRAME_CONTEXT *fc = cm->fc;
1746 int i, j;
1747 if (cm->seg.enabled && cm->seg.update_map) {
1748 av1_tree_to_cdf(av1_segment_tree, cm->fc->seg.tree_probs,
1749 cm->fc->seg.tree_cdf);
1750 }
1751
1752 for (i = 0; i < INTRA_MODES; ++i)
Yaowu Xu6043bfd2016-11-01 09:54:05 -07001753 av1_tree_to_cdf(av1_intra_mode_tree, fc->uv_mode_prob[i],
1754 fc->uv_mode_cdf[i]);
Thomas Davies6519beb2016-10-19 14:46:07 +01001755
1756 for (i = 0; i < PARTITION_CONTEXTS; ++i)
1757 av1_tree_to_cdf(av1_partition_tree, fc->partition_prob[i],
1758 fc->partition_cdf[i]);
1759
1760 for (i = 0; i < INTRA_MODES; ++i)
1761 for (j = 0; j < INTRA_MODES; ++j)
1762 av1_tree_to_cdf(av1_intra_mode_tree, cm->kf_y_prob[i][j],
1763 cm->kf_y_cdf[i][j]);
1764
1765 for (j = 0; j < SWITCHABLE_FILTER_CONTEXTS; ++j)
1766 av1_tree_to_cdf(av1_switchable_interp_tree, fc->switchable_interp_prob[j],
1767 fc->switchable_interp_cdf[j]);
1768
1769 for (i = 0; i < INTER_MODE_CONTEXTS; ++i)
1770 av1_tree_to_cdf(av1_inter_mode_tree, fc->inter_mode_probs[i],
1771 fc->inter_mode_cdf[i]);
1772
1773 for (i = 0; i < BLOCK_SIZE_GROUPS; ++i)
1774 av1_tree_to_cdf(av1_intra_mode_tree, fc->y_mode_prob[i], fc->y_mode_cdf[i]);
1775
David Barkerf5419322016-11-10 12:04:21 +00001776#if !CONFIG_EXT_TX
Thomas Davies6519beb2016-10-19 14:46:07 +01001777 for (i = TX_4X4; i < EXT_TX_SIZES; ++i)
1778 for (j = 0; j < TX_TYPES; ++j)
1779 av1_tree_to_cdf(av1_ext_tx_tree, fc->intra_ext_tx_prob[i][j],
1780 fc->intra_ext_tx_cdf[i][j]);
1781
1782 for (i = TX_4X4; i < EXT_TX_SIZES; ++i)
1783 av1_tree_to_cdf(av1_ext_tx_tree, fc->inter_ext_tx_prob[i],
1784 fc->inter_ext_tx_cdf[i]);
David Barkerf5419322016-11-10 12:04:21 +00001785#endif
Thomas Davies6519beb2016-10-19 14:46:07 +01001786}
Nathan E. Egge4947c292016-04-26 11:37:06 -04001787#endif
1788
Yaowu Xuc27fc142016-08-22 16:08:15 -07001789#if CONFIG_EXT_INTERP
Yaowu Xuf883b422016-08-30 14:01:10 -07001790const aom_tree_index av1_switchable_interp_tree[TREE_SIZE(SWITCHABLE_FILTERS)] =
1791 {
Yaowu Xuc27fc142016-08-22 16:08:15 -07001792 -EIGHTTAP_REGULAR,
1793 2,
1794 4,
1795 6,
1796 -EIGHTTAP_SMOOTH,
1797 -EIGHTTAP_SMOOTH2,
1798 -MULTITAP_SHARP,
1799 -MULTITAP_SHARP2,
1800 };
1801#else
Yaowu Xuf883b422016-08-30 14:01:10 -07001802const aom_tree_index av1_switchable_interp_tree[TREE_SIZE(SWITCHABLE_FILTERS)] =
1803 { -EIGHTTAP_REGULAR, 2, -EIGHTTAP_SMOOTH, -MULTITAP_SHARP };
Yaowu Xuc27fc142016-08-22 16:08:15 -07001804#endif // CONFIG_EXT_INTERP
1805
Yaowu Xuf883b422016-08-30 14:01:10 -07001806void av1_adapt_inter_frame_probs(AV1_COMMON *cm) {
Yaowu Xuc27fc142016-08-22 16:08:15 -07001807 int i, j;
1808 FRAME_CONTEXT *fc = cm->fc;
1809 const FRAME_CONTEXT *pre_fc = &cm->frame_contexts[cm->frame_context_idx];
1810 const FRAME_COUNTS *counts = &cm->counts;
1811
1812 for (i = 0; i < INTRA_INTER_CONTEXTS; i++)
Yaowu Xuf883b422016-08-30 14:01:10 -07001813 fc->intra_inter_prob[i] = av1_mode_mv_merge_probs(
Yaowu Xuc27fc142016-08-22 16:08:15 -07001814 pre_fc->intra_inter_prob[i], counts->intra_inter[i]);
1815 for (i = 0; i < COMP_INTER_CONTEXTS; i++)
Yaowu Xuf883b422016-08-30 14:01:10 -07001816 fc->comp_inter_prob[i] = av1_mode_mv_merge_probs(pre_fc->comp_inter_prob[i],
1817 counts->comp_inter[i]);
Yaowu Xuc27fc142016-08-22 16:08:15 -07001818
1819#if CONFIG_EXT_REFS
1820 for (i = 0; i < REF_CONTEXTS; i++)
1821 for (j = 0; j < (FWD_REFS - 1); j++)
1822 fc->comp_ref_prob[i][j] = mode_mv_merge_probs(pre_fc->comp_ref_prob[i][j],
1823 counts->comp_ref[i][j]);
1824 for (i = 0; i < REF_CONTEXTS; i++)
1825 for (j = 0; j < (BWD_REFS - 1); j++)
1826 fc->comp_bwdref_prob[i][j] = mode_mv_merge_probs(
1827 pre_fc->comp_bwdref_prob[i][j], counts->comp_bwdref[i][j]);
1828#else
1829 for (i = 0; i < REF_CONTEXTS; i++)
1830 for (j = 0; j < (COMP_REFS - 1); j++)
1831 fc->comp_ref_prob[i][j] = mode_mv_merge_probs(pre_fc->comp_ref_prob[i][j],
1832 counts->comp_ref[i][j]);
1833#endif // CONFIG_EXT_REFS
1834
1835 for (i = 0; i < REF_CONTEXTS; i++)
1836 for (j = 0; j < (SINGLE_REFS - 1); j++)
Yaowu Xuf883b422016-08-30 14:01:10 -07001837 fc->single_ref_prob[i][j] = av1_mode_mv_merge_probs(
Yaowu Xuc27fc142016-08-22 16:08:15 -07001838 pre_fc->single_ref_prob[i][j], counts->single_ref[i][j]);
1839
1840#if CONFIG_REF_MV
1841 for (i = 0; i < NEWMV_MODE_CONTEXTS; ++i)
1842 fc->newmv_prob[i] =
Yaowu Xuf883b422016-08-30 14:01:10 -07001843 av1_mode_mv_merge_probs(pre_fc->newmv_prob[i], counts->newmv_mode[i]);
Yaowu Xuc27fc142016-08-22 16:08:15 -07001844 for (i = 0; i < ZEROMV_MODE_CONTEXTS; ++i)
Yaowu Xuf883b422016-08-30 14:01:10 -07001845 fc->zeromv_prob[i] =
1846 av1_mode_mv_merge_probs(pre_fc->zeromv_prob[i], counts->zeromv_mode[i]);
Yaowu Xuc27fc142016-08-22 16:08:15 -07001847 for (i = 0; i < REFMV_MODE_CONTEXTS; ++i)
1848 fc->refmv_prob[i] =
Yaowu Xuf883b422016-08-30 14:01:10 -07001849 av1_mode_mv_merge_probs(pre_fc->refmv_prob[i], counts->refmv_mode[i]);
Yaowu Xuc27fc142016-08-22 16:08:15 -07001850
1851 for (i = 0; i < DRL_MODE_CONTEXTS; ++i)
1852 fc->drl_prob[i] =
Yaowu Xuf883b422016-08-30 14:01:10 -07001853 av1_mode_mv_merge_probs(pre_fc->drl_prob[i], counts->drl_mode[i]);
Yaowu Xuc27fc142016-08-22 16:08:15 -07001854#if CONFIG_EXT_INTER
1855 fc->new2mv_prob =
Yaowu Xuf883b422016-08-30 14:01:10 -07001856 av1_mode_mv_merge_probs(pre_fc->new2mv_prob, counts->new2mv_mode);
Yaowu Xuc27fc142016-08-22 16:08:15 -07001857#endif // CONFIG_EXT_INTER
1858#else
1859 for (i = 0; i < INTER_MODE_CONTEXTS; i++)
Yaowu Xuf883b422016-08-30 14:01:10 -07001860 aom_tree_merge_probs(av1_inter_mode_tree, pre_fc->inter_mode_probs[i],
Yaowu Xuc27fc142016-08-22 16:08:15 -07001861 counts->inter_mode[i], fc->inter_mode_probs[i]);
1862#endif
1863
Yue Chencb60b182016-10-13 15:18:22 -07001864#if CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
Yaowu Xuc27fc142016-08-22 16:08:15 -07001865 for (i = BLOCK_8X8; i < BLOCK_SIZES; ++i)
Yue Chencb60b182016-10-13 15:18:22 -07001866 aom_tree_merge_probs(av1_motion_mode_tree, pre_fc->motion_mode_prob[i],
1867 counts->motion_mode[i], fc->motion_mode_prob[i]);
1868#endif // CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
Yaowu Xuc27fc142016-08-22 16:08:15 -07001869
1870#if CONFIG_SUPERTX
1871 for (i = 0; i < PARTITION_SUPERTX_CONTEXTS; ++i) {
Yaowu Xuc27fc142016-08-22 16:08:15 -07001872 for (j = 1; j < TX_SIZES; ++j) {
Yaowu Xuf883b422016-08-30 14:01:10 -07001873 fc->supertx_prob[i][j] = av1_mode_mv_merge_probs(
Yaowu Xuc27fc142016-08-22 16:08:15 -07001874 pre_fc->supertx_prob[i][j], counts->supertx[i][j]);
1875 }
1876 }
1877#endif // CONFIG_SUPERTX
1878
1879#if CONFIG_EXT_INTER
1880 for (i = 0; i < INTER_MODE_CONTEXTS; i++)
Yaowu Xuf883b422016-08-30 14:01:10 -07001881 aom_tree_merge_probs(
1882 av1_inter_compound_mode_tree, pre_fc->inter_compound_mode_probs[i],
Yaowu Xuc27fc142016-08-22 16:08:15 -07001883 counts->inter_compound_mode[i], fc->inter_compound_mode_probs[i]);
1884 for (i = 0; i < BLOCK_SIZE_GROUPS; ++i) {
1885 if (is_interintra_allowed_bsize_group(i))
Yaowu Xuf883b422016-08-30 14:01:10 -07001886 fc->interintra_prob[i] = av1_mode_mv_merge_probs(
Yaowu Xuc27fc142016-08-22 16:08:15 -07001887 pre_fc->interintra_prob[i], counts->interintra[i]);
1888 }
1889 for (i = 0; i < BLOCK_SIZE_GROUPS; i++) {
Yaowu Xuf883b422016-08-30 14:01:10 -07001890 aom_tree_merge_probs(
1891 av1_interintra_mode_tree, pre_fc->interintra_mode_prob[i],
Yaowu Xuc27fc142016-08-22 16:08:15 -07001892 counts->interintra_mode[i], fc->interintra_mode_prob[i]);
1893 }
1894 for (i = 0; i < BLOCK_SIZES; ++i) {
1895 if (is_interintra_allowed_bsize(i) && is_interintra_wedge_used(i))
Yaowu Xuf883b422016-08-30 14:01:10 -07001896 fc->wedge_interintra_prob[i] = av1_mode_mv_merge_probs(
Yaowu Xuc27fc142016-08-22 16:08:15 -07001897 pre_fc->wedge_interintra_prob[i], counts->wedge_interintra[i]);
1898 }
Sarah Parker6fddd182016-11-10 20:57:20 -08001899
Yaowu Xuc27fc142016-08-22 16:08:15 -07001900 for (i = 0; i < BLOCK_SIZES; ++i) {
1901 if (is_interinter_wedge_used(i))
Sarah Parker6fddd182016-11-10 20:57:20 -08001902 aom_tree_merge_probs(
1903 av1_compound_type_tree, pre_fc->compound_type_prob[i],
1904 counts->compound_interinter[i], fc->compound_type_prob[i]);
Yaowu Xuc27fc142016-08-22 16:08:15 -07001905 }
1906#endif // CONFIG_EXT_INTER
1907
1908 for (i = 0; i < BLOCK_SIZE_GROUPS; i++)
Yaowu Xuf883b422016-08-30 14:01:10 -07001909 aom_tree_merge_probs(av1_intra_mode_tree, pre_fc->y_mode_prob[i],
Yaowu Xuc27fc142016-08-22 16:08:15 -07001910 counts->y_mode[i], fc->y_mode_prob[i]);
1911
1912 if (cm->interp_filter == SWITCHABLE) {
1913 for (i = 0; i < SWITCHABLE_FILTER_CONTEXTS; i++)
Yaowu Xuf883b422016-08-30 14:01:10 -07001914 aom_tree_merge_probs(
1915 av1_switchable_interp_tree, pre_fc->switchable_interp_prob[i],
Yaowu Xuc27fc142016-08-22 16:08:15 -07001916 counts->switchable_interp[i], fc->switchable_interp_prob[i]);
1917 }
Thomas Daviesf6936102016-09-05 16:51:31 +01001918
1919#if CONFIG_DELTA_Q
1920 for (i = 0; i < DELTA_Q_CONTEXTS; ++i)
1921 fc->delta_q_prob[i] =
1922 mode_mv_merge_probs(pre_fc->delta_q_prob[i], counts->delta_q[i]);
1923#endif
Yaowu Xuc27fc142016-08-22 16:08:15 -07001924}
1925
Yaowu Xuf883b422016-08-30 14:01:10 -07001926void av1_adapt_intra_frame_probs(AV1_COMMON *cm) {
Yaowu Xuc27fc142016-08-22 16:08:15 -07001927 int i, j;
1928 FRAME_CONTEXT *fc = cm->fc;
1929 const FRAME_CONTEXT *pre_fc = &cm->frame_contexts[cm->frame_context_idx];
1930 const FRAME_COUNTS *counts = &cm->counts;
1931
1932 if (cm->tx_mode == TX_MODE_SELECT) {
Jingning Hanaae72a62016-10-25 15:35:29 -07001933 for (i = 0; i < MAX_TX_DEPTH; ++i) {
Yaowu Xuc27fc142016-08-22 16:08:15 -07001934 for (j = 0; j < TX_SIZE_CONTEXTS; ++j)
Yaowu Xuf883b422016-08-30 14:01:10 -07001935 aom_tree_merge_probs(av1_tx_size_tree[i], pre_fc->tx_size_probs[i][j],
Yaowu Xuc27fc142016-08-22 16:08:15 -07001936 counts->tx_size[i][j], fc->tx_size_probs[i][j]);
1937 }
1938 }
1939
1940#if CONFIG_VAR_TX
Yue Chena1e48dc2016-08-29 17:29:33 -07001941 if (cm->tx_mode == TX_MODE_SELECT) {
Yaowu Xuc27fc142016-08-22 16:08:15 -07001942 for (i = 0; i < TXFM_PARTITION_CONTEXTS; ++i)
Yaowu Xuf883b422016-08-30 14:01:10 -07001943 fc->txfm_partition_prob[i] = av1_mode_mv_merge_probs(
Yaowu Xuc27fc142016-08-22 16:08:15 -07001944 pre_fc->txfm_partition_prob[i], counts->txfm_partition[i]);
Yue Chena1e48dc2016-08-29 17:29:33 -07001945 }
Yaowu Xuc27fc142016-08-22 16:08:15 -07001946#endif
1947
1948 for (i = 0; i < SKIP_CONTEXTS; ++i)
1949 fc->skip_probs[i] =
Yaowu Xuf883b422016-08-30 14:01:10 -07001950 av1_mode_mv_merge_probs(pre_fc->skip_probs[i], counts->skip[i]);
Yaowu Xuc27fc142016-08-22 16:08:15 -07001951
1952#if CONFIG_EXT_TX
1953 for (i = TX_4X4; i < EXT_TX_SIZES; ++i) {
1954 int s;
1955 for (s = 1; s < EXT_TX_SETS_INTER; ++s) {
1956 if (use_inter_ext_tx_for_txsize[s][i]) {
Yaowu Xuf883b422016-08-30 14:01:10 -07001957 aom_tree_merge_probs(
1958 av1_ext_tx_inter_tree[s], pre_fc->inter_ext_tx_prob[s][i],
Yaowu Xuc27fc142016-08-22 16:08:15 -07001959 counts->inter_ext_tx[s][i], fc->inter_ext_tx_prob[s][i]);
1960 }
1961 }
1962 for (s = 1; s < EXT_TX_SETS_INTRA; ++s) {
1963 if (use_intra_ext_tx_for_txsize[s][i]) {
Yaowu Xuc27fc142016-08-22 16:08:15 -07001964 for (j = 0; j < INTRA_MODES; ++j)
Yaowu Xuf883b422016-08-30 14:01:10 -07001965 aom_tree_merge_probs(
1966 av1_ext_tx_intra_tree[s], pre_fc->intra_ext_tx_prob[s][i][j],
Yaowu Xuc27fc142016-08-22 16:08:15 -07001967 counts->intra_ext_tx[s][i][j], fc->intra_ext_tx_prob[s][i][j]);
1968 }
1969 }
1970 }
1971#else
1972 for (i = TX_4X4; i < EXT_TX_SIZES; ++i) {
Nathan E. Egge7c5b4c12016-04-26 12:31:14 -04001973 for (j = 0; j < TX_TYPES; ++j) {
Yaowu Xuf883b422016-08-30 14:01:10 -07001974 aom_tree_merge_probs(av1_ext_tx_tree, pre_fc->intra_ext_tx_prob[i][j],
Yaowu Xuc27fc142016-08-22 16:08:15 -07001975 counts->intra_ext_tx[i][j],
1976 fc->intra_ext_tx_prob[i][j]);
Nathan E. Egge7c5b4c12016-04-26 12:31:14 -04001977 }
Yaowu Xuc27fc142016-08-22 16:08:15 -07001978 }
1979 for (i = TX_4X4; i < EXT_TX_SIZES; ++i) {
Yaowu Xuf883b422016-08-30 14:01:10 -07001980 aom_tree_merge_probs(av1_ext_tx_tree, pre_fc->inter_ext_tx_prob[i],
Yaowu Xuc27fc142016-08-22 16:08:15 -07001981 counts->inter_ext_tx[i], fc->inter_ext_tx_prob[i]);
1982 }
1983#endif // CONFIG_EXT_TX
1984
1985 if (cm->seg.temporal_update) {
1986 for (i = 0; i < PREDICTION_PROBS; i++)
Yaowu Xuf883b422016-08-30 14:01:10 -07001987 fc->seg.pred_probs[i] = av1_mode_mv_merge_probs(pre_fc->seg.pred_probs[i],
1988 counts->seg.pred[i]);
Yaowu Xuc27fc142016-08-22 16:08:15 -07001989
Yaowu Xuf883b422016-08-30 14:01:10 -07001990 aom_tree_merge_probs(av1_segment_tree, pre_fc->seg.tree_probs,
Yaowu Xuc27fc142016-08-22 16:08:15 -07001991 counts->seg.tree_mispred, fc->seg.tree_probs);
1992 } else {
Yaowu Xuf883b422016-08-30 14:01:10 -07001993 aom_tree_merge_probs(av1_segment_tree, pre_fc->seg.tree_probs,
Yaowu Xuc27fc142016-08-22 16:08:15 -07001994 counts->seg.tree_total, fc->seg.tree_probs);
1995 }
1996
1997 for (i = 0; i < INTRA_MODES; ++i)
Yaowu Xuf883b422016-08-30 14:01:10 -07001998 aom_tree_merge_probs(av1_intra_mode_tree, pre_fc->uv_mode_prob[i],
Yaowu Xuc27fc142016-08-22 16:08:15 -07001999 counts->uv_mode[i], fc->uv_mode_prob[i]);
2000
2001#if CONFIG_EXT_PARTITION_TYPES
Yaowu Xuf883b422016-08-30 14:01:10 -07002002 aom_tree_merge_probs(av1_partition_tree, pre_fc->partition_prob[0],
Yaowu Xuc27fc142016-08-22 16:08:15 -07002003 counts->partition[0], fc->partition_prob[0]);
2004 for (i = 1; i < PARTITION_CONTEXTS; i++)
Yaowu Xuf883b422016-08-30 14:01:10 -07002005 aom_tree_merge_probs(av1_ext_partition_tree, pre_fc->partition_prob[i],
Yaowu Xuc27fc142016-08-22 16:08:15 -07002006 counts->partition[i], fc->partition_prob[i]);
2007#else
Nathan E. Eggefba2be62016-05-03 09:48:54 -04002008 for (i = 0; i < PARTITION_CONTEXTS; i++) {
Yaowu Xuf883b422016-08-30 14:01:10 -07002009 aom_tree_merge_probs(av1_partition_tree, pre_fc->partition_prob[i],
Yaowu Xuc27fc142016-08-22 16:08:15 -07002010 counts->partition[i], fc->partition_prob[i]);
Nathan E. Eggefba2be62016-05-03 09:48:54 -04002011 }
Yaowu Xuc27fc142016-08-22 16:08:15 -07002012#endif // CONFIG_EXT_PARTITION_TYPES
Thomas Daviesf6936102016-09-05 16:51:31 +01002013#if CONFIG_DELTA_Q
2014 for (i = 0; i < DELTA_Q_CONTEXTS; ++i)
2015 fc->delta_q_prob[i] =
2016 mode_mv_merge_probs(pre_fc->delta_q_prob[i], counts->delta_q[i]);
2017#endif
Yaowu Xuc27fc142016-08-22 16:08:15 -07002018#if CONFIG_EXT_INTRA
hui su5db97432016-10-14 16:10:14 -07002019 for (i = 0; i < INTRA_FILTERS + 1; ++i) {
Yaowu Xuf883b422016-08-30 14:01:10 -07002020 aom_tree_merge_probs(av1_intra_filter_tree, pre_fc->intra_filter_probs[i],
Yaowu Xuc27fc142016-08-22 16:08:15 -07002021 counts->intra_filter[i], fc->intra_filter_probs[i]);
hui su5db97432016-10-14 16:10:14 -07002022 }
Yaowu Xuc27fc142016-08-22 16:08:15 -07002023#endif // CONFIG_EXT_INTRA
hui su5db97432016-10-14 16:10:14 -07002024#if CONFIG_FILTER_INTRA
2025 for (i = 0; i < PLANE_TYPES; ++i) {
2026 fc->filter_intra_probs[i] = av1_mode_mv_merge_probs(
2027 pre_fc->filter_intra_probs[i], counts->filter_intra[i]);
2028 }
2029#endif // CONFIG_FILTER_INTRA
Yaowu Xuc27fc142016-08-22 16:08:15 -07002030}
2031
2032static void set_default_lf_deltas(struct loopfilter *lf) {
2033 lf->mode_ref_delta_enabled = 1;
2034 lf->mode_ref_delta_update = 1;
2035
2036 lf->ref_deltas[INTRA_FRAME] = 1;
2037 lf->ref_deltas[LAST_FRAME] = 0;
2038#if CONFIG_EXT_REFS
2039 lf->ref_deltas[LAST2_FRAME] = lf->ref_deltas[LAST_FRAME];
2040 lf->ref_deltas[LAST3_FRAME] = lf->ref_deltas[LAST_FRAME];
2041 lf->ref_deltas[BWDREF_FRAME] = lf->ref_deltas[LAST_FRAME];
2042#endif // CONFIG_EXT_REFS
2043 lf->ref_deltas[GOLDEN_FRAME] = -1;
2044 lf->ref_deltas[ALTREF_FRAME] = -1;
2045
2046 lf->mode_deltas[0] = 0;
2047 lf->mode_deltas[1] = 0;
2048}
2049
Yaowu Xuf883b422016-08-30 14:01:10 -07002050void av1_setup_past_independence(AV1_COMMON *cm) {
Yaowu Xuc27fc142016-08-22 16:08:15 -07002051 // Reset the segment feature data to the default stats:
2052 // Features disabled, 0, with delta coding (Default state).
2053 struct loopfilter *const lf = &cm->lf;
2054
2055 int i;
Yaowu Xuf883b422016-08-30 14:01:10 -07002056 av1_clearall_segfeatures(&cm->seg);
Yaowu Xuc27fc142016-08-22 16:08:15 -07002057 cm->seg.abs_delta = SEGMENT_DELTADATA;
2058
2059 if (cm->last_frame_seg_map && !cm->frame_parallel_decode)
2060 memset(cm->last_frame_seg_map, 0, (cm->mi_rows * cm->mi_cols));
2061
2062 if (cm->current_frame_seg_map)
2063 memset(cm->current_frame_seg_map, 0, (cm->mi_rows * cm->mi_cols));
2064
2065 // Reset the mode ref deltas for loop filter
Yaowu Xuf883b422016-08-30 14:01:10 -07002066 av1_zero(lf->last_ref_deltas);
2067 av1_zero(lf->last_mode_deltas);
Yaowu Xuc27fc142016-08-22 16:08:15 -07002068 set_default_lf_deltas(lf);
2069
2070 // To force update of the sharpness
2071 lf->last_sharpness_level = -1;
2072#if CONFIG_LOOP_RESTORATION
Debargha Mukherjee5d89a632016-09-17 13:16:58 -07002073 if (cm->rst_info.bilateral_info) {
2074 int s;
Yaowu Xuc27fc142016-08-22 16:08:15 -07002075 for (i = 0; i < cm->rst_internal.ntiles; ++i)
Debargha Mukherjee5d89a632016-09-17 13:16:58 -07002076 for (s = 0; s < BILATERAL_SUBTILES; ++s)
2077 cm->rst_info.bilateral_info[i].level[s] = -1;
Yaowu Xuc27fc142016-08-22 16:08:15 -07002078 }
2079#endif // CONFIG_LOOP_RESTORATION
2080
Yaowu Xuf883b422016-08-30 14:01:10 -07002081 av1_default_coef_probs(cm);
Yaowu Xuc27fc142016-08-22 16:08:15 -07002082 init_mode_probs(cm->fc);
Yaowu Xuf883b422016-08-30 14:01:10 -07002083 av1_init_mv_probs(cm);
Angie Chianged8cd9a2016-10-21 16:44:47 -07002084#if CONFIG_ADAPT_SCAN
2085 av1_init_scan_order(cm);
2086#endif
Yaowu Xuc27fc142016-08-22 16:08:15 -07002087 cm->fc->initialized = 1;
2088
2089 if (cm->frame_type == KEY_FRAME || cm->error_resilient_mode ||
2090 cm->reset_frame_context == RESET_FRAME_CONTEXT_ALL) {
2091 // Reset all frame contexts.
2092 for (i = 0; i < FRAME_CONTEXTS; ++i) cm->frame_contexts[i] = *cm->fc;
2093 } else if (cm->reset_frame_context == RESET_FRAME_CONTEXT_CURRENT) {
2094 // Reset only the frame context specified in the frame header.
2095 cm->frame_contexts[cm->frame_context_idx] = *cm->fc;
2096 }
2097
2098 // prev_mip will only be allocated in encoder.
2099 if (frame_is_intra_only(cm) && cm->prev_mip && !cm->frame_parallel_decode)
2100 memset(cm->prev_mip, 0,
2101 cm->mi_stride * (cm->mi_rows + 1) * sizeof(*cm->prev_mip));
2102
2103 cm->frame_context_idx = 0;
2104}