blob: 4bc470acda9295588326447dba00bb449c632352 [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_ALT_INTRA
20
21const aom_prob av1_kf_y_mode_prob[INTRA_MODES][INTRA_MODES][INTRA_MODES - 1] = {
22 {
23 // above = dc
24 { 121, 30, 54, 128, 164, 158, 45, 41, 57, 91 }, // left = dc
25 { 91, 38, 101, 102, 124, 141, 49, 48, 45, 73 }, // left = v
26 { 66, 28, 27, 177, 225, 178, 32, 27, 52, 114 }, // left = h
27 { 106, 23, 50, 101, 134, 148, 64, 50, 49, 107 }, // left = d45
28 { 75, 24, 32, 118, 66, 143, 42, 28, 57, 74 }, // left = d135
29 { 95, 24, 40, 142, 56, 141, 72, 121, 129, 255 }, // left = d117
30 { 71, 14, 25, 126, 117, 201, 28, 21, 117, 89 }, // left = d153
31 { 85, 16, 37, 110, 163, 178, 41, 28, 48, 134 }, // left = d207
32 { 86, 25, 32, 83, 105, 133, 58, 81, 46, 95 }, // left = d63
33 { 79, 25, 38, 75, 150, 255, 30, 49, 34, 51 }, // left = smooth
34 { 68, 59, 48, 122, 193, 158, 43, 46, 46, 112 }, // left = paeth
35 },
36 {
37 // above = v
38 { 66, 21, 118, 111, 145, 107, 27, 50, 27, 54 }, // left = dc
39 { 52, 25, 167, 81, 120, 101, 34, 55, 19, 32 }, // left = v
40 { 56, 18, 72, 134, 208, 139, 31, 34, 27, 89 }, // left = h
41 { 75, 21, 94, 88, 134, 123, 49, 57, 30, 68 }, // left = d45
42 { 54, 18, 95, 96, 78, 107, 33, 49, 28, 65 }, // left = d135
43 { 61, 19, 121, 131, 58, 101, 56, 143, 120, 255 }, // left = d117
44 { 53, 13, 78, 103, 110, 147, 31, 41, 64, 77 }, // left = d153
45 { 69, 14, 78, 93, 167, 121, 31, 39, 25, 113 }, // left = d207
46 { 64, 18, 103, 79, 90, 108, 34, 73, 27, 69 }, // left = d63
47 { 52, 20, 103, 61, 161, 255, 22, 42, 16, 35 }, // left = smooth
48 { 50, 31, 124, 92, 161, 120, 50, 53, 23, 60 }, // left = paeth
49 },
50 {
51 // above = h
52 { 94, 29, 31, 158, 214, 178, 35, 31, 72, 111 }, // left = dc
53 { 72, 37, 72, 149, 184, 177, 43, 40, 53, 105 }, // left = v
54 { 53, 21, 14, 196, 242, 209, 29, 19, 55, 145 }, // left = h
55 { 93, 36, 36, 104, 176, 166, 56, 37, 49, 141 }, // left = d45
56 { 84, 32, 27, 124, 108, 143, 38, 36, 76, 134 }, // left = d135
57 { 82, 31, 47, 142, 122, 161, 83, 73, 126, 255 }, // left = d117
58 { 66, 16, 20, 133, 148, 210, 30, 17, 113, 104 }, // left = d153
59 { 76, 16, 17, 129, 207, 181, 41, 20, 46, 163 }, // left = d207
60 { 72, 38, 21, 100, 142, 171, 37, 70, 49, 111 }, // left = d63
61 { 61, 30, 27, 115, 208, 255, 27, 31, 44, 63 }, // left = smooth
62 { 53, 45, 29, 157, 222, 185, 49, 37, 55, 102 }, // left = paeth
63 },
64 {
65 // above = d45
66 { 96, 18, 37, 98, 138, 154, 68, 56, 59, 96 }, // left = dc
67 { 73, 18, 92, 81, 125, 132, 75, 64, 27, 67 }, // left = v
68 { 73, 17, 27, 128, 213, 154, 56, 44, 32, 105 }, // left = h
69 { 101, 20, 21, 75, 138, 138, 82, 56, 23, 154 }, // left = d45
70 { 71, 15, 33, 91, 70, 150, 62, 55, 38, 118 }, // left = d135
71 { 80, 19, 38, 116, 69, 122, 88, 132, 92, 255 }, // left = d117
72 { 68, 11, 22, 101, 116, 179, 52, 44, 85, 96 }, // left = d153
73 { 101, 8, 59, 77, 151, 170, 53, 41, 35, 172 }, // left = d207
74 { 82, 19, 24, 81, 172, 129, 82, 128, 43, 108 }, // left = d63
75 { 66, 18, 42, 64, 143, 255, 52, 52, 25, 83 }, // left = smooth
76 { 57, 24, 42, 85, 169, 145, 104, 71, 34, 86 }, // left = paeth
77 },
78 {
79 // above = d135
80 { 85, 15, 29, 113, 83, 176, 26, 29, 70, 110 }, // left = dc
81 { 78, 28, 49, 111, 91, 141, 30, 42, 48, 75 }, // left = v
82 { 56, 21, 16, 146, 190, 178, 23, 31, 49, 92 }, // left = h
83 { 70, 19, 20, 65, 90, 173, 97, 36, 57, 98 }, // left = d45
84 { 77, 14, 26, 110, 51, 156, 34, 35, 54, 74 }, // left = d135
85 { 78, 18, 36, 153, 47, 131, 62, 102, 155, 255 }, // left = d117
86 { 56, 11, 15, 115, 85, 196, 32, 45, 81, 96 }, // left = d153
87 { 90, 18, 24, 95, 126, 159, 34, 31, 46, 136 }, // left = d207
88 { 80, 23, 28, 90, 75, 141, 39, 50, 46, 87 }, // left = d63
89 { 63, 22, 31, 91, 110, 255, 26, 43, 51, 51 }, // left = smooth
90 { 66, 32, 31, 122, 145, 165, 40, 43, 56, 79 }, // left = paeth
91 },
92 {
93 // above = d117
94 { 81, 16, 61, 170, 74, 105, 54, 105, 113, 255 }, // left = dc
95 { 74, 20, 86, 163, 64, 97, 65, 129, 101, 255 }, // left = v
96 { 63, 15, 47, 168, 141, 176, 69, 77, 77, 255 }, // left = h
97 { 70, 17, 59, 97, 78, 114, 74, 122, 80, 255 }, // left = d45
98 { 78, 13, 50, 153, 34, 126, 75, 114, 120, 255 }, // left = d135
99 { 72, 16, 69, 159, 28, 108, 63, 134, 107, 255 }, // left = d117
100 { 66, 9, 47, 131, 79, 148, 41, 88, 105, 255 }, // left = d153
101 { 78, 12, 60, 119, 105, 133, 47, 95, 63, 255 }, // left = d207
102 { 82, 21, 58, 128, 61, 98, 64, 136, 91, 255 }, // left = d63
103 { 23, 26, 28, 96, 85, 128, 51, 64, 85, 128 }, // left = smooth
104 { 58, 27, 62, 162, 109, 151, 75, 106, 78, 255 }, // left = paeth
105 },
106 {
107 // above = d153
108 { 91, 18, 25, 121, 166, 173, 25, 25, 128, 102 }, // left = dc
109 { 80, 27, 51, 111, 141, 147, 45, 38, 70, 85 }, // left = v
110 { 53, 12, 11, 154, 197, 225, 17, 17, 74, 145 }, // left = h
111 { 93, 27, 23, 111, 143, 188, 43, 39, 69, 112 }, // left = d45
112 { 83, 15, 21, 118, 67, 178, 40, 33, 73, 92 }, // left = d135
113 { 94, 13, 31, 132, 66, 110, 61, 82, 148, 255 }, // left = d117
114 { 76, 9, 11, 96, 105, 201, 16, 13, 157, 97 }, // left = d153
115 { 70, 10, 12, 100, 172, 201, 23, 17, 53, 158 }, // left = d207
116 { 114, 25, 21, 104, 108, 163, 30, 47, 53, 111 }, // left = d63
117 { 70, 16, 21, 80, 157, 255, 25, 30, 81, 69 }, // left = smooth
118 { 87, 32, 26, 120, 191, 168, 32, 33, 70, 118 }, // left = paeth
119 },
120 {
121 // above = d207
122 { 98, 20, 39, 122, 168, 188, 38, 36, 54, 132 }, // left = dc
123 { 81, 37, 62, 97, 122, 153, 38, 43, 36, 118 }, // left = v
124 { 71, 21, 22, 154, 227, 183, 37, 31, 46, 140 }, // left = h
125 { 90, 34, 19, 93, 144, 194, 65, 47, 41, 163 }, // left = d45
126 { 78, 20, 27, 91, 93, 173, 57, 52, 49, 113 }, // left = d135
127 { 79, 25, 45, 121, 101, 147, 69, 56, 122, 255 }, // left = d117
128 { 73, 13, 19, 105, 122, 206, 40, 28, 91, 126 }, // left = d153
129 { 101, 14, 22, 87, 153, 169, 33, 25, 26, 175 }, // left = d207
130 { 81, 28, 23, 86, 115, 169, 48, 56, 41, 111 }, // left = d63
131 { 70, 24, 30, 90, 180, 255, 38, 26, 36, 82 }, // left = smooth
132 { 61, 37, 30, 94, 189, 163, 76, 50, 36, 127 }, // left = paeth
133 },
134 {
135 // above = d63
136 { 77, 13, 46, 86, 138, 117, 55, 88, 34, 68 }, // left = dc
137 { 68, 17, 80, 64, 105, 108, 66, 115, 32, 45 }, // left = v
138 { 62, 13, 37, 124, 210, 131, 46, 57, 28, 103 }, // left = h
139 { 88, 15, 45, 73, 134, 145, 73, 101, 37, 87 }, // left = d45
140 { 68, 16, 35, 78, 81, 133, 54, 71, 33, 67 }, // left = d135
141 { 71, 16, 57, 108, 61, 135, 71, 184, 113, 255 }, // left = d117
142 { 55, 10, 27, 69, 107, 158, 39, 76, 82, 95 }, // left = d153
143 { 80, 9, 38, 78, 153, 145, 50, 63, 28, 123 }, // left = d207
144 { 86, 12, 33, 49, 107, 135, 64, 134, 57, 89 }, // left = d63
145 { 56, 19, 55, 60, 163, 255, 38, 84, 22, 36 }, // left = smooth
146 { 53, 17, 60, 69, 151, 126, 73, 113, 26, 80 }, // left = paeth
147 },
148 {
149 // above = smooth
150 { 79, 16, 46, 89, 167, 255, 22, 36, 29, 42 }, // left = dc
151 { 63, 22, 88, 71, 131, 255, 26, 41, 21, 35 }, // left = v
152 { 51, 18, 28, 142, 232, 255, 26, 25, 25, 75 }, // left = h
153 { 75, 18, 43, 70, 140, 255, 37, 49, 34, 89 }, // left = d45
154 { 70, 14, 35, 87, 83, 255, 30, 36, 34, 50 }, // left = d135
155 { 23, 26, 28, 96, 85, 128, 51, 64, 85, 128 }, // left = d117
156 { 74, 12, 33, 83, 128, 255, 27, 33, 58, 68 }, // left = d153
157 { 66, 11, 30, 77, 179, 255, 21, 27, 23, 113 }, // left = d207
158 { 68, 22, 40, 65, 118, 255, 28, 61, 30, 50 }, // left = d63
159 { 60, 18, 44, 69, 141, 255, 18, 32, 22, 40 }, // left = smooth
160 { 52, 32, 54, 96, 194, 255, 33, 37, 25, 53 }, // left = paeth
161 },
162 {
163 // above = paeth
164 { 76, 47, 67, 123, 182, 150, 41, 52, 55, 97 }, // left = dc
165 { 69, 40, 125, 102, 138, 138, 42, 55, 32, 70 }, // left = v
166 { 46, 28, 27, 160, 232, 169, 34, 21, 32, 122 }, // left = h
167 { 78, 35, 41, 99, 128, 124, 49, 43, 35, 111 }, // left = d45
168 { 66, 28, 47, 100, 113, 145, 37, 40, 72, 93 }, // left = d135
169 { 77, 37, 76, 134, 124, 124, 65, 122, 88, 255 }, // left = d117
170 { 53, 23, 38, 108, 128, 204, 26, 32, 115, 114 }, // left = d153
171 { 65, 20, 29, 101, 202, 186, 29, 24, 29, 188 }, // left = d207
172 { 71, 24, 49, 81, 126, 151, 36, 65, 28, 93 }, // left = d63
173 { 54, 36, 53, 94, 193, 255, 25, 38, 20, 64 }, // left = smooth
174 { 52, 54, 60, 108, 176, 168, 47, 44, 50, 105 }, // left = paeth
175 },
176};
177
178static const aom_prob default_if_y_probs[BLOCK_SIZE_GROUPS][INTRA_MODES - 1] = {
179 { 88, 16, 47, 133, 143, 150, 70, 48, 84, 122 }, // block_size < 8x8
180 { 75, 26, 51, 120, 158, 157, 44, 45, 56, 102 }, // block_size < 16x16
181 { 73, 24, 60, 115, 184, 164, 26, 36, 32, 63 }, // block_size < 32x32
182 { 96, 27, 50, 107, 221, 148, 16, 22, 14, 39 }, // block_size >= 32x32
183};
184
185static const aom_prob default_uv_probs[INTRA_MODES][INTRA_MODES - 1] = {
186 { 199, 3, 79, 179, 220, 109, 38, 50, 68, 138 }, // y = dc
187 { 17, 2, 219, 136, 131, 58, 21, 106, 23, 41 }, // y = v
188 { 26, 1, 5, 244, 253, 138, 16, 21, 68, 205 }, // y = h
189 { 183, 3, 66, 94, 195, 97, 101, 104, 41, 178 }, // y = d45
190 { 178, 2, 36, 158, 99, 175, 21, 29, 105, 77 }, // y = d135
191 { 154, 3, 65, 219, 40, 48, 45, 95, 146, 255 }, // y = d117
192 { 167, 1, 16, 160, 214, 187, 10, 10, 200, 155 }, // y = d153
193 { 154, 2, 18, 178, 238, 132, 25, 21, 34, 221 }, // y = d207
194 { 153, 4, 76, 85, 157, 90, 38, 165, 46, 104 }, // y = d63
195 { 163, 3, 68, 87, 190, 255, 19, 27, 25, 46 }, // y = smooth
196 { 185, 7, 113, 171, 203, 57, 18, 69, 49, 104 }, // y = paeth
197};
198
199#else
200
Yaowu Xuf883b422016-08-30 14:01:10 -0700201const aom_prob av1_kf_y_mode_prob[INTRA_MODES][INTRA_MODES][INTRA_MODES - 1] = {
202 {
203 // above = dc
204 { 137, 30, 42, 148, 151, 207, 70, 52, 91 }, // left = dc
205 { 92, 45, 102, 136, 116, 180, 74, 90, 100 }, // left = v
206 { 73, 32, 19, 187, 222, 215, 46, 34, 100 }, // left = h
207 { 91, 30, 32, 116, 121, 186, 93, 86, 94 }, // left = d45
208 { 72, 35, 36, 149, 68, 206, 68, 63, 105 }, // left = d135
209 { 73, 31, 28, 138, 57, 124, 55, 122, 151 }, // left = d117
210 { 67, 23, 21, 140, 126, 197, 40, 37, 171 }, // left = d153
211 { 86, 27, 28, 128, 154, 212, 45, 43, 53 }, // left = d207
212 { 74, 32, 27, 107, 86, 160, 63, 134, 102 }, // left = d63
213 { 59, 67, 44, 140, 161, 202, 78, 67, 119 } // left = tm
214 },
215 {
216 // above = v
217 { 63, 36, 126, 146, 123, 158, 60, 90, 96 }, // left = dc
218 { 43, 46, 168, 134, 107, 128, 69, 142, 92 }, // left = v
219 { 44, 29, 68, 159, 201, 177, 50, 57, 77 }, // left = h
220 { 58, 38, 76, 114, 97, 172, 78, 133, 92 }, // left = d45
221 { 46, 41, 76, 140, 63, 184, 69, 112, 57 }, // left = d135
222 { 38, 32, 85, 140, 46, 112, 54, 151, 133 }, // left = d117
223 { 39, 27, 61, 131, 110, 175, 44, 75, 136 }, // left = d153
224 { 52, 30, 74, 113, 130, 175, 51, 64, 58 }, // left = d207
225 { 47, 35, 80, 100, 74, 143, 64, 163, 74 }, // left = d63
226 { 36, 61, 116, 114, 128, 162, 80, 125, 82 } // left = tm
227 },
228 {
229 // above = h
230 { 82, 26, 26, 171, 208, 204, 44, 32, 105 }, // left = dc
231 { 55, 44, 68, 166, 179, 192, 57, 57, 108 }, // left = v
232 { 42, 26, 11, 199, 241, 228, 23, 15, 85 }, // left = h
233 { 68, 42, 19, 131, 160, 199, 55, 52, 83 }, // left = d45
234 { 58, 50, 25, 139, 115, 232, 39, 52, 118 }, // left = d135
235 { 50, 35, 33, 153, 104, 162, 64, 59, 131 }, // left = d117
236 { 44, 24, 16, 150, 177, 202, 33, 19, 156 }, // left = d153
237 { 55, 27, 12, 153, 203, 218, 26, 27, 49 }, // left = d207
238 { 53, 49, 21, 110, 116, 168, 59, 80, 76 }, // left = d63
239 { 38, 72, 19, 168, 203, 212, 50, 50, 107 } // left = tm
240 },
241 {
242 // above = d45
243 { 103, 26, 36, 129, 132, 201, 83, 80, 93 }, // left = dc
244 { 59, 38, 83, 112, 103, 162, 98, 136, 90 }, // left = v
245 { 62, 30, 23, 158, 200, 207, 59, 57, 50 }, // left = h
246 { 67, 30, 29, 84, 86, 191, 102, 91, 59 }, // left = d45
247 { 60, 32, 33, 112, 71, 220, 64, 89, 104 }, // left = d135
248 { 53, 26, 34, 130, 56, 149, 84, 120, 103 }, // left = d117
249 { 53, 21, 23, 133, 109, 210, 56, 77, 172 }, // left = d153
250 { 77, 19, 29, 112, 142, 228, 55, 66, 36 }, // left = d207
251 { 61, 29, 29, 93, 97, 165, 83, 175, 162 }, // left = d63
252 { 47, 47, 43, 114, 137, 181, 100, 99, 95 } // left = tm
253 },
254 {
255 // above = d135
256 { 69, 23, 29, 128, 83, 199, 46, 44, 101 }, // left = dc
257 { 53, 40, 55, 139, 69, 183, 61, 80, 110 }, // left = v
258 { 40, 29, 19, 161, 180, 207, 43, 24, 91 }, // left = h
259 { 60, 34, 19, 105, 61, 198, 53, 64, 89 }, // left = d45
260 { 52, 31, 22, 158, 40, 209, 58, 62, 89 }, // left = d135
261 { 44, 31, 29, 147, 46, 158, 56, 102, 198 }, // left = d117
262 { 35, 19, 12, 135, 87, 209, 41, 45, 167 }, // left = d153
263 { 55, 25, 21, 118, 95, 215, 38, 39, 66 }, // left = d207
264 { 51, 38, 25, 113, 58, 164, 70, 93, 97 }, // left = d63
265 { 47, 54, 34, 146, 108, 203, 72, 103, 151 } // left = tm
266 },
267 {
268 // above = d117
269 { 64, 19, 37, 156, 66, 138, 49, 95, 133 }, // left = dc
270 { 46, 27, 80, 150, 55, 124, 55, 121, 135 }, // left = v
271 { 36, 23, 27, 165, 149, 166, 54, 64, 118 }, // left = h
272 { 53, 21, 36, 131, 63, 163, 60, 109, 81 }, // left = d45
273 { 40, 26, 35, 154, 40, 185, 51, 97, 123 }, // left = d135
274 { 35, 19, 34, 179, 19, 97, 48, 129, 124 }, // left = d117
275 { 36, 20, 26, 136, 62, 164, 33, 77, 154 }, // left = d153
276 { 45, 18, 32, 130, 90, 157, 40, 79, 91 }, // left = d207
277 { 45, 26, 28, 129, 45, 129, 49, 147, 123 }, // left = d63
278 { 38, 44, 51, 136, 74, 162, 57, 97, 121 } // left = tm
279 },
280 {
281 // above = d153
282 { 75, 17, 22, 136, 138, 185, 32, 34, 166 }, // left = dc
283 { 56, 39, 58, 133, 117, 173, 48, 53, 187 }, // left = v
284 { 35, 21, 12, 161, 212, 207, 20, 23, 145 }, // left = h
285 { 56, 29, 19, 117, 109, 181, 55, 68, 112 }, // left = d45
286 { 47, 29, 17, 153, 64, 220, 59, 51, 114 }, // left = d135
287 { 46, 16, 24, 136, 76, 147, 41, 64, 172 }, // left = d117
288 { 34, 17, 11, 108, 152, 187, 13, 15, 209 }, // left = d153
289 { 51, 24, 14, 115, 133, 209, 32, 26, 104 }, // left = d207
290 { 55, 30, 18, 122, 79, 179, 44, 88, 116 }, // left = d63
291 { 37, 49, 25, 129, 168, 164, 41, 54, 148 } // left = tm
292 },
293 {
294 // above = d207
295 { 82, 22, 32, 127, 143, 213, 39, 41, 70 }, // left = dc
296 { 62, 44, 61, 123, 105, 189, 48, 57, 64 }, // left = v
297 { 47, 25, 17, 175, 222, 220, 24, 30, 86 }, // left = h
298 { 68, 36, 17, 106, 102, 206, 59, 74, 74 }, // left = d45
299 { 57, 39, 23, 151, 68, 216, 55, 63, 58 }, // left = d135
300 { 49, 30, 35, 141, 70, 168, 82, 40, 115 }, // left = d117
301 { 51, 25, 15, 136, 129, 202, 38, 35, 139 }, // left = d153
302 { 68, 26, 16, 111, 141, 215, 29, 28, 28 }, // left = d207
303 { 59, 39, 19, 114, 75, 180, 77, 104, 42 }, // left = d63
304 { 40, 61, 26, 126, 152, 206, 61, 59, 93 } // left = tm
305 },
306 {
307 // above = d63
308 { 78, 23, 39, 111, 117, 170, 74, 124, 94 }, // left = dc
309 { 48, 34, 86, 101, 92, 146, 78, 179, 134 }, // left = v
310 { 47, 22, 24, 138, 187, 178, 68, 69, 59 }, // left = h
311 { 56, 25, 33, 105, 112, 187, 95, 177, 129 }, // left = d45
312 { 48, 31, 27, 114, 63, 183, 82, 116, 56 }, // left = d135
313 { 43, 28, 37, 121, 63, 123, 61, 192, 169 }, // left = d117
314 { 42, 17, 24, 109, 97, 177, 56, 76, 122 }, // left = d153
315 { 58, 18, 28, 105, 139, 182, 70, 92, 63 }, // left = d207
316 { 46, 23, 32, 74, 86, 150, 67, 183, 88 }, // left = d63
317 { 36, 38, 48, 92, 122, 165, 88, 137, 91 } // left = tm
318 },
319 {
320 // above = tm
321 { 65, 70, 60, 155, 159, 199, 61, 60, 81 }, // left = dc
322 { 44, 78, 115, 132, 119, 173, 71, 112, 93 }, // left = v
323 { 39, 38, 21, 184, 227, 206, 42, 32, 64 }, // left = h
324 { 58, 47, 36, 124, 137, 193, 80, 82, 78 }, // left = d45
325 { 49, 50, 35, 144, 95, 205, 63, 78, 59 }, // left = d135
326 { 41, 53, 52, 148, 71, 142, 65, 128, 51 }, // left = d117
327 { 40, 36, 28, 143, 143, 202, 40, 55, 137 }, // left = d153
328 { 52, 34, 29, 129, 183, 227, 42, 35, 43 }, // left = d207
329 { 42, 44, 44, 104, 105, 164, 64, 130, 80 }, // left = d63
330 { 43, 81, 53, 140, 169, 204, 68, 84, 72 } // left = tm
331 }
332};
Yaowu Xuc27fc142016-08-22 16:08:15 -0700333
Urvang Joshi92b90f32017-02-07 17:06:31 -0800334// Default probabilities for signaling Intra mode for Y plane -- used only for
335// inter frames. ('av1_kf_y_mode_prob' is used for intra-only frames).
336// Context used: block size group.
Yaowu Xuf883b422016-08-30 14:01:10 -0700337static const aom_prob default_if_y_probs[BLOCK_SIZE_GROUPS][INTRA_MODES - 1] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700338 { 65, 32, 18, 144, 162, 194, 41, 51, 98 }, // block_size < 8x8
339 { 132, 68, 18, 165, 217, 196, 45, 40, 78 }, // block_size < 16x16
340 { 173, 80, 19, 176, 240, 193, 64, 35, 46 }, // block_size < 32x32
341 { 221, 135, 38, 194, 248, 121, 96, 85, 29 } // block_size >= 32x32
342};
343
Urvang Joshi92b90f32017-02-07 17:06:31 -0800344// Default probabilities for signaling Intra mode for UV plane -- common for
345// both intra and inter frames.
346// Context used: Intra mode used by Y plane of the same block.
Yaowu Xuf883b422016-08-30 14:01:10 -0700347static const aom_prob default_uv_probs[INTRA_MODES][INTRA_MODES - 1] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700348 { 120, 7, 76, 176, 208, 126, 28, 54, 103 }, // y = dc
349 { 48, 12, 154, 155, 139, 90, 34, 117, 119 }, // y = v
350 { 67, 6, 25, 204, 243, 158, 13, 21, 96 }, // y = h
351 { 97, 5, 44, 131, 176, 139, 48, 68, 97 }, // y = d45
352 { 83, 5, 42, 156, 111, 152, 26, 49, 152 }, // y = d135
353 { 80, 5, 58, 178, 74, 83, 33, 62, 145 }, // y = d117
354 { 86, 5, 32, 154, 192, 168, 14, 22, 163 }, // y = d153
355 { 85, 5, 32, 156, 216, 148, 19, 29, 73 }, // y = d207
356 { 77, 7, 64, 116, 132, 122, 37, 126, 120 }, // y = d63
357 { 101, 21, 107, 181, 192, 103, 19, 67, 125 } // y = tm
358};
359
Urvang Joshi6be4a542016-11-03 15:24:05 -0700360#endif // CONFIG_ALT_INTRA
361
Yaowu Xuc27fc142016-08-22 16:08:15 -0700362#if CONFIG_EXT_PARTITION_TYPES
Yaowu Xuf883b422016-08-30 14:01:10 -0700363static const aom_prob
Yaowu Xuc27fc142016-08-22 16:08:15 -0700364 default_partition_probs[PARTITION_CONTEXTS][EXT_PARTITION_TYPES - 1] = {
365 // 8x8 -> 4x4
366 { 199, 122, 141, 128, 128, 128, 128 }, // a/l both not split
367 { 147, 63, 159, 128, 128, 128, 128 }, // a split, l not split
368 { 148, 133, 118, 128, 128, 128, 128 }, // l split, a not split
369 { 121, 104, 114, 128, 128, 128, 128 }, // a/l both split
370 // 16x16 -> 8x8
371 { 174, 73, 87, 128, 128, 128, 128 }, // a/l both not split
372 { 92, 41, 83, 128, 128, 128, 128 }, // a split, l not split
373 { 82, 99, 50, 128, 128, 128, 128 }, // l split, a not split
374 { 53, 39, 39, 128, 128, 128, 128 }, // a/l both split
375 // 32x32 -> 16x16
376 { 177, 58, 59, 128, 128, 128, 128 }, // a/l both not split
377 { 68, 26, 63, 128, 128, 128, 128 }, // a split, l not split
378 { 52, 79, 25, 128, 128, 128, 128 }, // l split, a not split
379 { 17, 14, 12, 128, 128, 128, 128 }, // a/l both split
380 // 64x64 -> 32x32
381 { 222, 34, 30, 128, 128, 128, 128 }, // a/l both not split
382 { 72, 16, 44, 128, 128, 128, 128 }, // a split, l not split
383 { 58, 32, 12, 128, 128, 128, 128 }, // l split, a not split
384 { 10, 7, 6, 128, 128, 128, 128 }, // a/l both split
385#if CONFIG_EXT_PARTITION
386 // 128x128 -> 64x64
387 { 222, 34, 30, 128, 128, 128, 128 }, // a/l both not split
388 { 72, 16, 44, 128, 128, 128, 128 }, // a split, l not split
389 { 58, 32, 12, 128, 128, 128, 128 }, // l split, a not split
390 { 10, 7, 6, 128, 128, 128, 128 }, // a/l both split
391#endif // CONFIG_EXT_PARTITION
Alex Converse55c6bde2017-01-12 15:55:31 -0800392#if CONFIG_UNPOISON_PARTITION_CTX
393 { 0, 0, 141, 0, 0, 0, 0 }, // 8x8 -> 4x4
394 { 0, 0, 87, 0, 0, 0, 0 }, // 16x16 -> 8x8
395 { 0, 0, 59, 0, 0, 0, 0 }, // 32x32 -> 16x16
396 { 0, 0, 30, 0, 0, 0, 0 }, // 64x64 -> 32x32
397#if CONFIG_EXT_PARTITION
398 { 0, 0, 30, 0, 0, 0, 0 }, // 128x128 -> 64x64
399#endif // CONFIG_EXT_PARTITION
400 { 0, 122, 0, 0, 0, 0, 0 }, // 8x8 -> 4x4
401 { 0, 73, 0, 0, 0, 0, 0 }, // 16x16 -> 8x8
402 { 0, 58, 0, 0, 0, 0, 0 }, // 32x32 -> 16x16
403 { 0, 34, 0, 0, 0, 0, 0 }, // 64x64 -> 32x32
404#if CONFIG_EXT_PARTITION
405 { 0, 34, 0, 0, 0, 0, 0 }, // 128x128 -> 64x64
406#endif // CONFIG_EXT_PARTITION
407#endif // CONFIG_UNPOISON_PARTITION_CTX
Yaowu Xuc27fc142016-08-22 16:08:15 -0700408 };
409#else
Yaowu Xuf883b422016-08-30 14:01:10 -0700410static const aom_prob
Yaowu Xuc27fc142016-08-22 16:08:15 -0700411 default_partition_probs[PARTITION_CONTEXTS][PARTITION_TYPES - 1] = {
412 // 8x8 -> 4x4
413 { 199, 122, 141 }, // a/l both not split
414 { 147, 63, 159 }, // a split, l not split
415 { 148, 133, 118 }, // l split, a not split
416 { 121, 104, 114 }, // a/l both split
417 // 16x16 -> 8x8
418 { 174, 73, 87 }, // a/l both not split
419 { 92, 41, 83 }, // a split, l not split
420 { 82, 99, 50 }, // l split, a not split
421 { 53, 39, 39 }, // a/l both split
422 // 32x32 -> 16x16
423 { 177, 58, 59 }, // a/l both not split
424 { 68, 26, 63 }, // a split, l not split
425 { 52, 79, 25 }, // l split, a not split
426 { 17, 14, 12 }, // a/l both split
427 // 64x64 -> 32x32
428 { 222, 34, 30 }, // a/l both not split
429 { 72, 16, 44 }, // a split, l not split
430 { 58, 32, 12 }, // l split, a not split
431 { 10, 7, 6 }, // a/l both split
432#if CONFIG_EXT_PARTITION
433 // 128x128 -> 64x64
434 { 222, 34, 30 }, // a/l both not split
435 { 72, 16, 44 }, // a split, l not split
436 { 58, 32, 12 }, // l split, a not split
437 { 10, 7, 6 }, // a/l both split
438#endif // CONFIG_EXT_PARTITION
Alex Converse55c6bde2017-01-12 15:55:31 -0800439#if CONFIG_UNPOISON_PARTITION_CTX
440 { 0, 0, 141 }, // 8x8 -> 4x4
441 { 0, 0, 87 }, // 16x16 -> 8x8
442 { 0, 0, 59 }, // 32x32 -> 16x16
443 { 0, 0, 30 }, // 64x64 -> 32x32
444#if CONFIG_EXT_PARTITION
445 { 0, 0, 30 }, // 128x128 -> 64x64
446#endif // CONFIG_EXT_PARTITION
447 { 0, 122, 0 }, // 8x8 -> 4x4
448 { 0, 73, 0 }, // 16x16 -> 8x8
449 { 0, 58, 0 }, // 32x32 -> 16x16
450 { 0, 34, 0 }, // 64x64 -> 32x32
451#if CONFIG_EXT_PARTITION
452 { 0, 34, 0 }, // 128x128 -> 64x64
453#endif // CONFIG_EXT_PARTITION
454#endif // CONFIG_UNPOISON_PARTITION_CTX
Yaowu Xuc27fc142016-08-22 16:08:15 -0700455 };
456#endif // CONFIG_EXT_PARTITION_TYPES
457
458#if CONFIG_REF_MV
Yaowu Xuf883b422016-08-30 14:01:10 -0700459static const aom_prob default_newmv_prob[NEWMV_MODE_CONTEXTS] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700460 200, 180, 150, 150, 110, 70, 60,
461};
462
Yaowu Xuf883b422016-08-30 14:01:10 -0700463static const aom_prob default_zeromv_prob[ZEROMV_MODE_CONTEXTS] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700464 192, 64,
465};
466
Yaowu Xuf883b422016-08-30 14:01:10 -0700467static const aom_prob default_refmv_prob[REFMV_MODE_CONTEXTS] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700468 220, 220, 200, 200, 180, 128, 30, 220, 30,
469};
470
Yaowu Xuf883b422016-08-30 14:01:10 -0700471static const aom_prob default_drl_prob[DRL_MODE_CONTEXTS] = { 128, 160, 180,
Yaowu Xuc27fc142016-08-22 16:08:15 -0700472 128, 160 };
473
474#if CONFIG_EXT_INTER
Yaowu Xuf883b422016-08-30 14:01:10 -0700475static const aom_prob default_new2mv_prob = 180;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700476#endif // CONFIG_EXT_INTER
477#endif // CONFIG_REF_MV
478
Yaowu Xuf883b422016-08-30 14:01:10 -0700479static const aom_prob
Yaowu Xuc27fc142016-08-22 16:08:15 -0700480 default_inter_mode_probs[INTER_MODE_CONTEXTS][INTER_MODES - 1] = {
481#if CONFIG_EXT_INTER
482 // TODO(zoeliu): To adjust the initial default probs
483 { 2, 173, 34, 173 }, // 0 = both zero mv
484 { 7, 145, 85, 145 }, // 1 = one zero mv + one a predicted mv
485 { 7, 166, 63, 166 }, // 2 = two predicted mvs
486 { 7, 94, 66, 128 }, // 3 = one predicted/zero and one new mv
487 { 8, 64, 46, 128 }, // 4 = two new mvs
488 { 17, 81, 31, 128 }, // 5 = one intra neighbour + x
489 { 25, 29, 30, 96 }, // 6 = two intra neighbours
490#else
491 { 2, 173, 34 }, // 0 = both zero mv
492 { 7, 145, 85 }, // 1 = one zero mv + one a predicted mv
493 { 7, 166, 63 }, // 2 = two predicted mvs
494 { 7, 94, 66 }, // 3 = one predicted/zero and one new mv
495 { 8, 64, 46 }, // 4 = two new mvs
496 { 17, 81, 31 }, // 5 = one intra neighbour + x
497 { 25, 29, 30 }, // 6 = two intra neighbours
498#endif // CONFIG_EXT_INTER
499 };
500
501#if CONFIG_EXT_INTER
Yaowu Xuf883b422016-08-30 14:01:10 -0700502static const aom_prob default_inter_compound_mode_probs
Yaowu Xuc27fc142016-08-22 16:08:15 -0700503 [INTER_MODE_CONTEXTS][INTER_COMPOUND_MODES - 1] = {
504 { 2, 173, 68, 192, 64, 192, 128, 180, 180 }, // 0 = both zero mv
505 { 7, 145, 160, 192, 64, 192, 128, 180, 180 }, // 1 = 1 zero + 1 predicted
506 { 7, 166, 126, 192, 64, 192, 128, 180, 180 }, // 2 = two predicted mvs
507 { 7, 94, 132, 192, 64, 192, 128, 180, 180 }, // 3 = 1 pred/zero, 1 new
508 { 8, 64, 64, 192, 64, 192, 128, 180, 180 }, // 4 = two new mvs
509 { 17, 81, 52, 192, 64, 192, 128, 180, 180 }, // 5 = one intra neighbour
510 { 25, 29, 50, 192, 64, 192, 128, 180, 180 }, // 6 = two intra neighbours
511 };
512
Sarah Parker2f6ce752016-12-08 15:26:46 -0800513#if CONFIG_COMPOUND_SEGMENT
514static const aom_prob
515 default_compound_type_probs[BLOCK_SIZES][COMPOUND_TYPES - 1] = {
Yue Chen4415b6c2017-01-31 11:59:38 -0800516#if CONFIG_CB4X4
517 { 255, 255 }, { 255, 255 }, { 255, 255 },
518#endif
Sarah Parker2f6ce752016-12-08 15:26:46 -0800519 { 208, 200 }, { 208, 200 }, { 208, 200 }, { 208, 200 }, { 208, 200 },
520 { 208, 200 }, { 216, 200 }, { 216, 200 }, { 216, 200 }, { 224, 200 },
521 { 224, 200 }, { 240, 200 }, { 240, 200 },
522#if CONFIG_EXT_PARTITION
523 { 255, 200 }, { 255, 200 }, { 255, 200 },
524#endif // CONFIG_EXT_PARTITION
525 };
526#else // !CONFIG_COMPOUND_SEGMENT
clang-format55ce9e02017-02-15 22:27:12 -0800527static const aom_prob
528 default_compound_type_probs[BLOCK_SIZES][COMPOUND_TYPES - 1] = {
Jingning Han61418bb2017-01-23 17:12:48 -0800529#if CONFIG_CB4X4
clang-format55ce9e02017-02-15 22:27:12 -0800530 { 208 }, { 208 }, { 208 },
Jingning Han61418bb2017-01-23 17:12:48 -0800531#endif
clang-format55ce9e02017-02-15 22:27:12 -0800532 { 208 }, { 208 }, { 208 }, { 208 }, { 208 }, { 208 }, { 216 },
533 { 216 }, { 216 }, { 224 }, { 224 }, { 240 }, { 240 },
Sarah Parker6fddd182016-11-10 20:57:20 -0800534#if CONFIG_EXT_PARTITION
clang-format55ce9e02017-02-15 22:27:12 -0800535 { 255 }, { 255 }, { 255 },
Sarah Parker6fddd182016-11-10 20:57:20 -0800536#endif // CONFIG_EXT_PARTITION
clang-format55ce9e02017-02-15 22:27:12 -0800537 };
Sarah Parker2f6ce752016-12-08 15:26:46 -0800538#endif // CONFIG_COMPOUND_SEGMENT
Sarah Parker6fddd182016-11-10 20:57:20 -0800539
Yaowu Xuf883b422016-08-30 14:01:10 -0700540static const aom_prob default_interintra_prob[BLOCK_SIZE_GROUPS] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700541 208, 208, 208, 208,
542};
543
Yaowu Xuf883b422016-08-30 14:01:10 -0700544static const aom_prob
Yaowu Xuc27fc142016-08-22 16:08:15 -0700545 default_interintra_mode_prob[BLOCK_SIZE_GROUPS][INTERINTRA_MODES - 1] = {
546 { 65, 32, 18, 144, 162, 194, 41, 51, 98 }, // block_size < 8x8
547 { 132, 68, 18, 165, 217, 196, 45, 40, 78 }, // block_size < 16x16
548 { 173, 80, 19, 176, 240, 193, 64, 35, 46 }, // block_size < 32x32
549 { 221, 135, 38, 194, 248, 121, 96, 85, 29 } // block_size >= 32x32
550 };
551
Yaowu Xuf883b422016-08-30 14:01:10 -0700552static const aom_prob default_wedge_interintra_prob[BLOCK_SIZES] = {
Jingning Han61418bb2017-01-23 17:12:48 -0800553#if CONFIG_CB4X4
554 208, 208, 208,
555#endif
Yaowu Xuc27fc142016-08-22 16:08:15 -0700556 208, 208, 208, 208, 208, 208, 216, 216, 216, 224, 224, 224, 240,
557#if CONFIG_EXT_PARTITION
558 208, 208, 208
559#endif // CONFIG_EXT_PARTITION
560};
Yaowu Xuc27fc142016-08-22 16:08:15 -0700561#endif // CONFIG_EXT_INTER
562
563// Change this section appropriately once warped motion is supported
Yue Chencb60b182016-10-13 15:18:22 -0700564#if CONFIG_MOTION_VAR && !CONFIG_WARPED_MOTION
565const aom_tree_index av1_motion_mode_tree[TREE_SIZE(MOTION_MODES)] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700566 -SIMPLE_TRANSLATION, -OBMC_CAUSAL
567};
clang-format55ce9e02017-02-15 22:27:12 -0800568static const aom_prob default_motion_mode_prob[BLOCK_SIZES][MOTION_MODES - 1] =
569 {
Jingning Hanb3044dd2017-01-18 16:14:56 -0800570#if CONFIG_CB4X4
clang-format55ce9e02017-02-15 22:27:12 -0800571 { 255 }, { 255 }, { 255 },
Jingning Hanb3044dd2017-01-18 16:14:56 -0800572#endif
clang-format55ce9e02017-02-15 22:27:12 -0800573 { 255 }, { 255 }, { 255 }, { 151 }, { 153 }, { 144 }, { 178 },
574 { 165 }, { 160 }, { 207 }, { 195 }, { 168 }, { 244 },
Yaowu Xuc27fc142016-08-22 16:08:15 -0700575#if CONFIG_EXT_PARTITION
clang-format55ce9e02017-02-15 22:27:12 -0800576 { 252 }, { 252 }, { 252 },
Yaowu Xuc27fc142016-08-22 16:08:15 -0700577#endif // CONFIG_EXT_PARTITION
clang-format55ce9e02017-02-15 22:27:12 -0800578 };
Yaowu Xuc27fc142016-08-22 16:08:15 -0700579
Yue Chencb60b182016-10-13 15:18:22 -0700580#elif !CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
Yaowu Xuc27fc142016-08-22 16:08:15 -0700581
Yue Chencb60b182016-10-13 15:18:22 -0700582const aom_tree_index av1_motion_mode_tree[TREE_SIZE(MOTION_MODES)] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700583 -SIMPLE_TRANSLATION, -WARPED_CAUSAL
584};
Yue Chen69f18e12016-09-08 14:48:15 -0700585
clang-format55ce9e02017-02-15 22:27:12 -0800586static const aom_prob default_motion_mode_prob[BLOCK_SIZES][MOTION_MODES - 1] =
587 {
Jingning Han71bf3ee2017-01-18 17:23:27 -0800588#if CONFIG_CB4X4
clang-format55ce9e02017-02-15 22:27:12 -0800589 { 255 }, { 255 }, { 255 },
Jingning Han71bf3ee2017-01-18 17:23:27 -0800590#endif
clang-format55ce9e02017-02-15 22:27:12 -0800591 { 255 }, { 255 }, { 255 }, { 151 }, { 153 }, { 144 }, { 178 },
592 { 165 }, { 160 }, { 207 }, { 195 }, { 168 }, { 244 },
Yaowu Xuc27fc142016-08-22 16:08:15 -0700593#if CONFIG_EXT_PARTITION
clang-format55ce9e02017-02-15 22:27:12 -0800594 { 252 }, { 252 }, { 252 },
Yaowu Xuc27fc142016-08-22 16:08:15 -0700595#endif // CONFIG_EXT_PARTITION
clang-format55ce9e02017-02-15 22:27:12 -0800596 };
Yaowu Xuc27fc142016-08-22 16:08:15 -0700597
Yue Chencb60b182016-10-13 15:18:22 -0700598#elif CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
Yaowu Xuc27fc142016-08-22 16:08:15 -0700599
Yue Chencb60b182016-10-13 15:18:22 -0700600const aom_tree_index av1_motion_mode_tree[TREE_SIZE(MOTION_MODES)] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700601 -SIMPLE_TRANSLATION, 2, -OBMC_CAUSAL, -WARPED_CAUSAL,
602};
Yue Chencb60b182016-10-13 15:18:22 -0700603static const aom_prob default_motion_mode_prob[BLOCK_SIZES][MOTION_MODES - 1] =
Yaowu Xuc27fc142016-08-22 16:08:15 -0700604 {
Jingning Han71bf3ee2017-01-18 17:23:27 -0800605#if CONFIG_CB4X4
606 { 255, 200 }, { 255, 200 }, { 255, 200 },
607#endif
Yaowu Xuc27fc142016-08-22 16:08:15 -0700608 { 255, 200 }, { 255, 200 }, { 255, 200 }, { 151, 200 }, { 153, 200 },
609 { 144, 200 }, { 178, 200 }, { 165, 200 }, { 160, 200 }, { 207, 200 },
610 { 195, 200 }, { 168, 200 }, { 244, 200 },
611#if CONFIG_EXT_PARTITION
612 { 252, 200 }, { 252, 200 }, { 252, 200 },
613#endif // CONFIG_EXT_PARTITION
614 };
Yue Chen69f18e12016-09-08 14:48:15 -0700615
616// Probability for the case that only 1 additional motion mode is allowed
617static const aom_prob default_obmc_prob[BLOCK_SIZES] = {
Jingning Han71bf3ee2017-01-18 17:23:27 -0800618#if CONFIG_CB4X4
619 255, 255, 255,
620#endif
Yue Chen69f18e12016-09-08 14:48:15 -0700621 255, 255, 255, 151, 153, 144, 178, 165, 160, 207, 195, 168, 244,
622#if CONFIG_EXT_PARTITION
623 252, 252, 252,
624#endif // CONFIG_EXT_PARTITION
625};
626#endif
Yaowu Xuc27fc142016-08-22 16:08:15 -0700627
Thomas Daviesf6936102016-09-05 16:51:31 +0100628#if CONFIG_DELTA_Q
Thomas Davies665cd702017-03-02 10:20:30 +0000629static const aom_prob default_delta_q_probs[DELTA_Q_PROBS] = { 220, 220, 220 };
Thomas Daviesd6ee8a82017-03-02 14:42:50 +0000630#if CONFIG_EC_MULTISYMBOL
631static const aom_cdf_prob default_delta_q_cdf[CDF_SIZE(DELTA_Q_PROBS + 1)] = {
632 28160, 32120, 32677, 32768, 0
633};
634#endif
Thomas Daviesf6936102016-09-05 16:51:31 +0100635#endif
Nathan E. Eggeecc21ec2016-11-16 09:44:26 -0500636#if CONFIG_EC_MULTISYMBOL
Nathan E. Egge3ef926e2016-09-07 18:20:41 -0400637int av1_intra_mode_ind[INTRA_MODES];
638int av1_intra_mode_inv[INTRA_MODES];
Nathan E. Egge6ec4d102016-09-08 10:41:20 -0400639int av1_inter_mode_ind[INTER_MODES];
640int av1_inter_mode_inv[INTER_MODES];
Nathan E. Eggea59b23d2016-11-16 09:44:26 -0500641#endif
Thomas Daviesf6936102016-09-05 16:51:31 +0100642
Yaowu Xuc27fc142016-08-22 16:08:15 -0700643/* Array indices are identical to previously-existing INTRAMODECONTEXTNODES. */
Urvang Joshi6be4a542016-11-03 15:24:05 -0700644#if CONFIG_ALT_INTRA
645const aom_tree_index av1_intra_mode_tree[TREE_SIZE(INTRA_MODES)] = {
646 -DC_PRED, 2, /* 0 = DC_NODE */
647 -TM_PRED, 4, /* 1 = TM_NODE */
648 -V_PRED, 6, /* 2 = V_NODE */
649 8, 12, /* 3 = COM_NODE */
650 -H_PRED, 10, /* 4 = H_NODE */
651 -D135_PRED, -D117_PRED, /* 5 = D135_NODE */
652 -D45_PRED, 14, /* 6 = D45_NODE */
653 -D63_PRED, 16, /* 7 = D63_NODE */
654 -D153_PRED, 18, /* 8 = D153_NODE */
655 -D207_PRED, -SMOOTH_PRED, /* 9 = D207_NODE */
656};
657#else
Yaowu Xuf883b422016-08-30 14:01:10 -0700658const aom_tree_index av1_intra_mode_tree[TREE_SIZE(INTRA_MODES)] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700659 -DC_PRED, 2, /* 0 = DC_NODE */
660 -TM_PRED, 4, /* 1 = TM_NODE */
661 -V_PRED, 6, /* 2 = V_NODE */
662 8, 12, /* 3 = COM_NODE */
663 -H_PRED, 10, /* 4 = H_NODE */
664 -D135_PRED, -D117_PRED, /* 5 = D135_NODE */
665 -D45_PRED, 14, /* 6 = D45_NODE */
666 -D63_PRED, 16, /* 7 = D63_NODE */
667 -D153_PRED, -D207_PRED /* 8 = D153_NODE */
668};
Urvang Joshi6be4a542016-11-03 15:24:05 -0700669#endif // CONFIG_ALT_INTRA
Yaowu Xuc27fc142016-08-22 16:08:15 -0700670
Yaowu Xuf883b422016-08-30 14:01:10 -0700671const aom_tree_index av1_inter_mode_tree[TREE_SIZE(INTER_MODES)] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700672 -INTER_OFFSET(ZEROMV), 2,
673 -INTER_OFFSET(NEARESTMV), 4,
674#if CONFIG_EXT_INTER
675 -INTER_OFFSET(NEARMV), 6,
676 -INTER_OFFSET(NEWMV), -INTER_OFFSET(NEWFROMNEARMV)
677#else
678 -INTER_OFFSET(NEARMV), -INTER_OFFSET(NEWMV)
679#endif // CONFIG_EXT_INTER
680};
681
682#if CONFIG_EXT_INTER
683/* clang-format off */
Yaowu Xuf883b422016-08-30 14:01:10 -0700684const aom_tree_index av1_interintra_mode_tree[TREE_SIZE(INTERINTRA_MODES)] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700685 -II_DC_PRED, 2, /* 0 = II_DC_NODE */
686 -II_TM_PRED, 4, /* 1 = II_TM_NODE */
687 -II_V_PRED, 6, /* 2 = II_V_NODE */
688 8, 12, /* 3 = II_COM_NODE */
689 -II_H_PRED, 10, /* 4 = II_H_NODE */
690 -II_D135_PRED, -II_D117_PRED, /* 5 = II_D135_NODE */
691 -II_D45_PRED, 14, /* 6 = II_D45_NODE */
692 -II_D63_PRED, 16, /* 7 = II_D63_NODE */
693 -II_D153_PRED, -II_D207_PRED /* 8 = II_D153_NODE */
694};
695
Yaowu Xuf883b422016-08-30 14:01:10 -0700696const aom_tree_index av1_inter_compound_mode_tree
Yaowu Xuc27fc142016-08-22 16:08:15 -0700697 [TREE_SIZE(INTER_COMPOUND_MODES)] = {
698 -INTER_COMPOUND_OFFSET(ZERO_ZEROMV), 2,
699 -INTER_COMPOUND_OFFSET(NEAREST_NEARESTMV), 4,
700 6, -INTER_COMPOUND_OFFSET(NEW_NEWMV),
701 8, 12,
702 -INTER_COMPOUND_OFFSET(NEAR_NEARMV), 10,
703 -INTER_COMPOUND_OFFSET(NEAREST_NEARMV),
704 -INTER_COMPOUND_OFFSET(NEAR_NEARESTMV),
705 14, 16,
706 -INTER_COMPOUND_OFFSET(NEAREST_NEWMV), -INTER_COMPOUND_OFFSET(NEW_NEARESTMV),
707 -INTER_COMPOUND_OFFSET(NEAR_NEWMV), -INTER_COMPOUND_OFFSET(NEW_NEARMV)
708};
Sarah Parker6fddd182016-11-10 20:57:20 -0800709
Sarah Parker2f6ce752016-12-08 15:26:46 -0800710#if CONFIG_COMPOUND_SEGMENT
711const aom_tree_index av1_compound_type_tree[TREE_SIZE(COMPOUND_TYPES)] = {
712 -COMPOUND_AVERAGE, 2, -COMPOUND_WEDGE, -COMPOUND_SEG
713};
714#else // !CONFIG_COMPOUND_SEGMENT
Sarah Parker6fddd182016-11-10 20:57:20 -0800715const aom_tree_index av1_compound_type_tree[TREE_SIZE(COMPOUND_TYPES)] = {
716 -COMPOUND_AVERAGE, -COMPOUND_WEDGE
717};
Sarah Parker2f6ce752016-12-08 15:26:46 -0800718#endif // CONFIG_COMPOUND_SEGMENT
Yaowu Xuc27fc142016-08-22 16:08:15 -0700719/* clang-format on */
720#endif // CONFIG_EXT_INTER
721
Yaowu Xuf883b422016-08-30 14:01:10 -0700722const aom_tree_index av1_partition_tree[TREE_SIZE(PARTITION_TYPES)] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700723 -PARTITION_NONE, 2, -PARTITION_HORZ, 4, -PARTITION_VERT, -PARTITION_SPLIT
724};
725
726#if CONFIG_EXT_PARTITION_TYPES
727/* clang-format off */
Yaowu Xuf883b422016-08-30 14:01:10 -0700728const aom_tree_index av1_ext_partition_tree[TREE_SIZE(EXT_PARTITION_TYPES)] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700729 -PARTITION_NONE, 2,
730 6, 4,
731 8, -PARTITION_SPLIT,
732 -PARTITION_HORZ, 10,
733 -PARTITION_VERT, 12,
734 -PARTITION_HORZ_A, -PARTITION_HORZ_B,
735 -PARTITION_VERT_A, -PARTITION_VERT_B
736};
737/* clang-format on */
738#endif // CONFIG_EXT_PARTITION_TYPES
739
Yaowu Xuf883b422016-08-30 14:01:10 -0700740static const aom_prob default_intra_inter_p[INTRA_INTER_CONTEXTS] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700741 9, 102, 187, 225
742};
743
Yaowu Xuf883b422016-08-30 14:01:10 -0700744static const aom_prob default_comp_inter_p[COMP_INTER_CONTEXTS] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700745 239, 183, 119, 96, 41
746};
747
748#if CONFIG_EXT_REFS
Yaowu Xuf883b422016-08-30 14:01:10 -0700749static const aom_prob default_comp_ref_p[REF_CONTEXTS][FWD_REFS - 1] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700750 // TODO(zoeliu): To adjust the initial prob values.
751 { 33, 16, 16 },
752 { 77, 74, 74 },
753 { 142, 142, 142 },
754 { 172, 170, 170 },
755 { 238, 247, 247 }
756};
Yaowu Xuf883b422016-08-30 14:01:10 -0700757static const aom_prob default_comp_bwdref_p[REF_CONTEXTS][BWD_REFS - 1] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700758 { 16 }, { 74 }, { 142 }, { 170 }, { 247 }
759};
760#else
Yaowu Xuf883b422016-08-30 14:01:10 -0700761static const aom_prob default_comp_ref_p[REF_CONTEXTS][COMP_REFS - 1] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700762 { 50 }, { 126 }, { 123 }, { 221 }, { 226 }
763};
764#endif // CONFIG_EXT_REFS
765
Yaowu Xuf883b422016-08-30 14:01:10 -0700766static const aom_prob default_single_ref_p[REF_CONTEXTS][SINGLE_REFS - 1] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700767#if CONFIG_EXT_REFS
768 { 33, 16, 16, 16, 16 },
769 { 77, 74, 74, 74, 74 },
770 { 142, 142, 142, 142, 142 },
771 { 172, 170, 170, 170, 170 },
772 { 238, 247, 247, 247, 247 }
773#else
774 { 33, 16 }, { 77, 74 }, { 142, 142 }, { 172, 170 }, { 238, 247 }
775#endif // CONFIG_EXT_REFS
776};
777
Urvang Joshib100db72016-10-12 16:28:56 -0700778#if CONFIG_PALETTE
Urvang Joshi23a61112017-01-30 14:59:27 -0800779
780// Tree to code palette size (number of colors in a palette) and the
781// corresponding probabilities for Y and UV planes.
Yaowu Xuf883b422016-08-30 14:01:10 -0700782const aom_tree_index av1_palette_size_tree[TREE_SIZE(PALETTE_SIZES)] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700783 -TWO_COLORS, 2, -THREE_COLORS, 4, -FOUR_COLORS, 6,
784 -FIVE_COLORS, 8, -SIX_COLORS, 10, -SEVEN_COLORS, -EIGHT_COLORS,
785};
786
787// TODO(huisu): tune these probs
Yaowu Xuf883b422016-08-30 14:01:10 -0700788const aom_prob
789 av1_default_palette_y_size_prob[PALETTE_BLOCK_SIZES][PALETTE_SIZES - 1] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700790 { 96, 89, 100, 64, 77, 130 }, { 22, 15, 44, 16, 34, 82 },
791 { 30, 19, 57, 18, 38, 86 }, { 94, 36, 104, 23, 43, 92 },
792 { 116, 76, 107, 46, 65, 105 }, { 112, 82, 94, 40, 70, 112 },
793 { 147, 124, 123, 58, 69, 103 }, { 180, 113, 136, 49, 45, 114 },
794 { 107, 70, 87, 49, 154, 156 }, { 98, 105, 142, 63, 64, 152 },
795#if CONFIG_EXT_PARTITION
796 { 98, 105, 142, 63, 64, 152 }, { 98, 105, 142, 63, 64, 152 },
797 { 98, 105, 142, 63, 64, 152 },
798#endif // CONFIG_EXT_PARTITION
799 };
800
Yaowu Xuf883b422016-08-30 14:01:10 -0700801const aom_prob
802 av1_default_palette_uv_size_prob[PALETTE_BLOCK_SIZES][PALETTE_SIZES - 1] = {
803 { 160, 196, 228, 213, 175, 230 }, { 87, 148, 208, 141, 166, 163 },
804 { 72, 151, 204, 139, 155, 161 }, { 78, 135, 171, 104, 120, 173 },
805 { 59, 92, 131, 78, 92, 142 }, { 75, 118, 149, 84, 90, 128 },
806 { 89, 87, 92, 66, 66, 128 }, { 67, 53, 54, 55, 66, 93 },
807 { 120, 130, 83, 171, 75, 214 }, { 72, 55, 66, 68, 79, 107 },
Yaowu Xuc27fc142016-08-22 16:08:15 -0700808#if CONFIG_EXT_PARTITION
Yaowu Xuf883b422016-08-30 14:01:10 -0700809 { 72, 55, 66, 68, 79, 107 }, { 72, 55, 66, 68, 79, 107 },
810 { 72, 55, 66, 68, 79, 107 },
Yaowu Xuc27fc142016-08-22 16:08:15 -0700811#endif // CONFIG_EXT_PARTITION
Yaowu Xuf883b422016-08-30 14:01:10 -0700812 };
Yaowu Xuc27fc142016-08-22 16:08:15 -0700813
Urvang Joshi23a61112017-01-30 14:59:27 -0800814// When palette mode is enabled, following probability tables indicate the
815// probabilities to code the "is_palette" bit (i.e. the bit that indicates
816// if this block uses palette mode or DC_PRED mode).
clang-format55ce9e02017-02-15 22:27:12 -0800817const aom_prob av1_default_palette_y_mode_prob
818 [PALETTE_BLOCK_SIZES][PALETTE_Y_MODE_CONTEXTS] = {
819 { 240, 180, 100 }, { 240, 180, 100 }, { 240, 180, 100 },
820 { 240, 180, 100 }, { 240, 180, 100 }, { 240, 180, 100 },
821 { 240, 180, 100 }, { 240, 180, 100 }, { 240, 180, 100 },
822 { 240, 180, 100 },
Yaowu Xuc27fc142016-08-22 16:08:15 -0700823#if CONFIG_EXT_PARTITION
clang-format55ce9e02017-02-15 22:27:12 -0800824 { 240, 180, 100 }, { 240, 180, 100 }, { 240, 180, 100 },
Yaowu Xuc27fc142016-08-22 16:08:15 -0700825#endif // CONFIG_EXT_PARTITION
clang-format55ce9e02017-02-15 22:27:12 -0800826 };
Yaowu Xuc27fc142016-08-22 16:08:15 -0700827
Urvang Joshi23a61112017-01-30 14:59:27 -0800828const aom_prob av1_default_palette_uv_mode_prob[PALETTE_UV_MODE_CONTEXTS] = {
829 253, 229
830};
Yaowu Xuc27fc142016-08-22 16:08:15 -0700831
Urvang Joshi23a61112017-01-30 14:59:27 -0800832// Trees to code palette color indices (for various palette sizes), and the
833// corresponding probability tables for Y and UV planes.
Yaowu Xuf883b422016-08-30 14:01:10 -0700834const aom_tree_index
Alex Converse92109812017-02-22 10:21:40 -0800835 av1_palette_color_index_tree[PALETTE_SIZES][TREE_SIZE(PALETTE_COLORS)] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700836 { // 2 colors
837 -PALETTE_COLOR_ONE, -PALETTE_COLOR_TWO },
838 { // 3 colors
839 -PALETTE_COLOR_ONE, 2, -PALETTE_COLOR_TWO, -PALETTE_COLOR_THREE },
840 { // 4 colors
841 -PALETTE_COLOR_ONE, 2, -PALETTE_COLOR_TWO, 4, -PALETTE_COLOR_THREE,
842 -PALETTE_COLOR_FOUR },
843 { // 5 colors
844 -PALETTE_COLOR_ONE, 2, -PALETTE_COLOR_TWO, 4, -PALETTE_COLOR_THREE, 6,
845 -PALETTE_COLOR_FOUR, -PALETTE_COLOR_FIVE },
846 { // 6 colors
847 -PALETTE_COLOR_ONE, 2, -PALETTE_COLOR_TWO, 4, -PALETTE_COLOR_THREE, 6,
848 -PALETTE_COLOR_FOUR, 8, -PALETTE_COLOR_FIVE, -PALETTE_COLOR_SIX },
849 { // 7 colors
850 -PALETTE_COLOR_ONE, 2, -PALETTE_COLOR_TWO, 4, -PALETTE_COLOR_THREE, 6,
851 -PALETTE_COLOR_FOUR, 8, -PALETTE_COLOR_FIVE, 10, -PALETTE_COLOR_SIX,
852 -PALETTE_COLOR_SEVEN },
853 { // 8 colors
854 -PALETTE_COLOR_ONE, 2, -PALETTE_COLOR_TWO, 4, -PALETTE_COLOR_THREE, 6,
855 -PALETTE_COLOR_FOUR, 8, -PALETTE_COLOR_FIVE, 10, -PALETTE_COLOR_SIX, 12,
856 -PALETTE_COLOR_SEVEN, -PALETTE_COLOR_EIGHT },
857 };
858
Urvang Joshieb54e0c2016-11-01 15:25:57 -0700859// Note: Has to be non-zero to avoid any asserts triggering.
860#define UNUSED_PROB 128
Yaowu Xuc27fc142016-08-22 16:08:15 -0700861
Urvang Joshi23a61112017-01-30 14:59:27 -0800862const aom_prob av1_default_palette_y_color_index_prob
Alex Converse92109812017-02-22 10:21:40 -0800863 [PALETTE_SIZES][PALETTE_COLOR_INDEX_CONTEXTS][PALETTE_COLORS - 1] = {
Urvang Joshieb54e0c2016-11-01 15:25:57 -0700864 {
865 // 2 colors
Urvang Joshi199a2f42017-01-23 15:02:07 -0800866 { 231, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
Urvang Joshieb54e0c2016-11-01 15:25:57 -0700867 UNUSED_PROB, UNUSED_PROB },
868 { UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
869 UNUSED_PROB, UNUSED_PROB },
Urvang Joshi199a2f42017-01-23 15:02:07 -0800870 { 69, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
Urvang Joshieb54e0c2016-11-01 15:25:57 -0700871 UNUSED_PROB },
Urvang Joshi199a2f42017-01-23 15:02:07 -0800872 { 224, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
Urvang Joshieb54e0c2016-11-01 15:25:57 -0700873 UNUSED_PROB, UNUSED_PROB },
874 { 249, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
875 UNUSED_PROB, UNUSED_PROB },
876 },
877 {
878 // 3 colors
Urvang Joshi199a2f42017-01-23 15:02:07 -0800879 { 219, 124, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
Urvang Joshieb54e0c2016-11-01 15:25:57 -0700880 UNUSED_PROB },
Urvang Joshi199a2f42017-01-23 15:02:07 -0800881 { 91, 191, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
Urvang Joshieb54e0c2016-11-01 15:25:57 -0700882 UNUSED_PROB },
Urvang Joshi199a2f42017-01-23 15:02:07 -0800883 { 34, 237, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
Urvang Joshieb54e0c2016-11-01 15:25:57 -0700884 UNUSED_PROB },
Urvang Joshi199a2f42017-01-23 15:02:07 -0800885 { 184, 118, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
Urvang Joshieb54e0c2016-11-01 15:25:57 -0700886 UNUSED_PROB },
Urvang Joshi199a2f42017-01-23 15:02:07 -0800887 { 252, 124, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
Urvang Joshieb54e0c2016-11-01 15:25:57 -0700888 UNUSED_PROB },
889 },
890 {
891 // 4 colors
Urvang Joshi199a2f42017-01-23 15:02:07 -0800892 { 204, 87, 97, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
893 { 74, 144, 129, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
894 { 52, 191, 134, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
895 { 151, 85, 147, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
896 { 248, 60, 115, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
Urvang Joshieb54e0c2016-11-01 15:25:57 -0700897 },
898 {
899 // 5 colors
Urvang Joshi199a2f42017-01-23 15:02:07 -0800900 { 218, 69, 62, 106, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
901 { 76, 143, 89, 127, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
902 { 21, 233, 94, 131, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
903 { 172, 72, 89, 112, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
904 { 253, 66, 65, 128, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
Urvang Joshieb54e0c2016-11-01 15:25:57 -0700905 },
906 {
907 // 6 colors
Urvang Joshi199a2f42017-01-23 15:02:07 -0800908 { 190, 60, 47, 54, 74, UNUSED_PROB, UNUSED_PROB },
909 { 62, 106, 51, 95, 110, UNUSED_PROB, UNUSED_PROB },
910 { 52, 180, 69, 72, 107, UNUSED_PROB, UNUSED_PROB },
911 { 156, 83, 72, 83, 101, UNUSED_PROB, UNUSED_PROB },
912 { 245, 45, 37, 52, 91, UNUSED_PROB, UNUSED_PROB },
Urvang Joshieb54e0c2016-11-01 15:25:57 -0700913 },
914 {
915 // 7 colors
Urvang Joshi199a2f42017-01-23 15:02:07 -0800916 { 206, 56, 42, 42, 53, 85, UNUSED_PROB },
917 { 70, 100, 45, 68, 77, 94, UNUSED_PROB },
918 { 57, 169, 51, 62, 74, 119, UNUSED_PROB },
919 { 172, 76, 71, 40, 59, 76, UNUSED_PROB },
920 { 248, 47, 36, 53, 61, 110, UNUSED_PROB },
Urvang Joshieb54e0c2016-11-01 15:25:57 -0700921 },
922 {
923 // 8 colors
Urvang Joshi199a2f42017-01-23 15:02:07 -0800924 { 208, 52, 38, 34, 34, 44, 66 },
925 { 52, 107, 34, 73, 69, 82, 87 },
926 { 28, 208, 53, 43, 62, 70, 102 },
927 { 184, 64, 45, 37, 37, 69, 105 },
928 { 251, 18, 31, 45, 47, 61, 104 },
929 },
930 };
931
Urvang Joshi23a61112017-01-30 14:59:27 -0800932const aom_prob av1_default_palette_uv_color_index_prob
Alex Converse92109812017-02-22 10:21:40 -0800933 [PALETTE_SIZES][PALETTE_COLOR_INDEX_CONTEXTS][PALETTE_COLORS - 1] = {
Urvang Joshi199a2f42017-01-23 15:02:07 -0800934 {
935 // 2 colors
936 { 233, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
937 UNUSED_PROB, UNUSED_PROB },
938 { UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
939 UNUSED_PROB, UNUSED_PROB },
940 { 69, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
941 UNUSED_PROB },
942 { 240, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
943 UNUSED_PROB, UNUSED_PROB },
944 { 248, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
945 UNUSED_PROB, UNUSED_PROB },
946 },
947 {
948 // 3 colors
949 { 216, 128, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
950 UNUSED_PROB },
951 { 110, 171, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
952 UNUSED_PROB },
953 { 40, 239, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
954 UNUSED_PROB },
955 { 191, 104, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
956 UNUSED_PROB },
957 { 247, 134, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB,
958 UNUSED_PROB },
959 },
960 {
961 // 4 colors
962 { 202, 89, 132, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
963 { 90, 132, 136, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
964 { 63, 195, 149, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
965 { 152, 84, 152, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
966 { 241, 87, 136, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
967 },
968 {
969 // 5 colors
970 { 209, 54, 82, 134, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
971 { 94, 173, 180, 93, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
972 { 10, 251, 127, 84, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
973 { 183, 20, 150, 47, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
974 { 252, 73, 111, 150, UNUSED_PROB, UNUSED_PROB, UNUSED_PROB },
975 },
976 {
977 // 6 colors
978 { 192, 67, 59, 46, 184, UNUSED_PROB, UNUSED_PROB },
979 { 59, 92, 61, 100, 130, UNUSED_PROB, UNUSED_PROB },
980 { 49, 162, 68, 91, 150, UNUSED_PROB, UNUSED_PROB },
981 { 133, 29, 36, 153, 101, UNUSED_PROB, UNUSED_PROB },
982 { 247, 71, 44, 90, 129, UNUSED_PROB, UNUSED_PROB },
983 },
984 {
985 // 7 colors
986 { 182, 62, 80, 78, 46, 116, UNUSED_PROB },
987 { 59, 62, 39, 81, 65, 99, UNUSED_PROB },
988 { 54, 177, 48, 58, 93, 104, UNUSED_PROB },
989 { 137, 79, 54, 55, 44, 134, UNUSED_PROB },
990 { 239, 82, 79, 44, 69, 71, UNUSED_PROB },
991 },
992 {
993 // 8 colors
994 { 172, 53, 27, 67, 30, 79, 113 },
995 { 63, 57, 45, 81, 62, 35, 47 },
996 { 51, 200, 36, 47, 82, 165, 129 },
997 { 141, 100, 47, 29, 33, 37, 129 },
998 { 236, 42, 50, 91, 24, 154, 65 },
999 },
Urvang Joshieb54e0c2016-11-01 15:25:57 -07001000 };
1001
1002#undef UNUSED_PROB
Yaowu Xuc27fc142016-08-22 16:08:15 -07001003
Urvang Joshicdbe7082017-01-26 13:06:49 -08001004#define MAX_COLOR_CONTEXT_HASH 8
1005// Negative values are invalid
Urvang Joshi23a61112017-01-30 14:59:27 -08001006static const int palette_color_index_context_lookup[MAX_COLOR_CONTEXT_HASH +
1007 1] = { -1, -1, 0, -1, -1,
1008 4, 3, 2, 1 };
Urvang Joshicdbe7082017-01-26 13:06:49 -08001009
Urvang Joshib100db72016-10-12 16:28:56 -07001010#endif // CONFIG_PALETTE
Yaowu Xuc27fc142016-08-22 16:08:15 -07001011
Jingning Hanb4329a22016-11-22 16:20:13 -08001012// The transform size is coded as an offset to the smallest transform
1013// block size.
Jingning Han607fa6a2016-10-26 10:46:28 -07001014const aom_tree_index av1_tx_size_tree[MAX_TX_DEPTH][TREE_SIZE(TX_SIZES)] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -07001015 {
1016 // Max tx_size is 8X8
Jingning Hanb4329a22016-11-22 16:20:13 -08001017 -0, -1,
Yaowu Xuc27fc142016-08-22 16:08:15 -07001018 },
1019 {
1020 // Max tx_size is 16X16
Jingning Hanb4329a22016-11-22 16:20:13 -08001021 -0, 2, -1, -2,
Yaowu Xuc27fc142016-08-22 16:08:15 -07001022 },
1023 {
1024 // Max tx_size is 32X32
Jingning Hanb4329a22016-11-22 16:20:13 -08001025 -0, 2, -1, 4, -2, -3,
Yaowu Xuc27fc142016-08-22 16:08:15 -07001026 },
Debargha Mukherjee18d38f62016-11-17 20:30:16 -08001027#if CONFIG_TX64X64
Debargha Mukherjee25ed5302016-11-22 12:13:41 -08001028 {
1029 // Max tx_size is 64X64
Jingning Hanb4329a22016-11-22 16:20:13 -08001030 -0, 2, -1, 4, -2, 6, -3, -4,
Debargha Mukherjee25ed5302016-11-22 12:13:41 -08001031 },
Debargha Mukherjee18d38f62016-11-17 20:30:16 -08001032#endif // CONFIG_TX64X64
Yaowu Xuc27fc142016-08-22 16:08:15 -07001033};
1034
Jingning Hanaae72a62016-10-25 15:35:29 -07001035static const aom_prob default_tx_size_prob[MAX_TX_DEPTH][TX_SIZE_CONTEXTS]
1036 [MAX_TX_DEPTH] = {
clang-format67948d32016-09-07 22:40:40 -07001037 {
1038 // Max tx_size is 8X8
1039 { 100 },
1040 { 66 },
1041 },
1042 {
1043 // Max tx_size is 16X16
1044 { 20, 152 },
1045 { 15, 101 },
1046 },
1047 {
1048 // Max tx_size is 32X32
1049 { 3, 136, 37 },
1050 { 5, 52, 13 },
1051 },
Debargha Mukherjee18d38f62016-11-17 20:30:16 -08001052#if CONFIG_TX64X64
1053 {
1054 // Max tx_size is 64X64
1055 { 1, 64, 136, 127 },
1056 { 1, 32, 52, 67 },
1057 },
1058#endif // CONFIG_TX64X64
clang-format67948d32016-09-07 22:40:40 -07001059 };
Yaowu Xuc27fc142016-08-22 16:08:15 -07001060
Debargha Mukherjee5cd2ab92016-09-08 15:15:17 -07001061#if CONFIG_LOOP_RESTORATION
Debargha Mukherjeeb3c43bc2017-02-01 13:09:03 -08001062const aom_tree_index
1063 av1_switchable_restore_tree[TREE_SIZE(RESTORE_SWITCHABLE_TYPES)] = {
1064 -RESTORE_NONE, 2, -RESTORE_WIENER, -RESTORE_SGRPROJ,
1065 };
1066
1067static const aom_prob
1068 default_switchable_restore_prob[RESTORE_SWITCHABLE_TYPES - 1] = {
1069 32, 128,
1070 };
Debargha Mukherjee5cd2ab92016-09-08 15:15:17 -07001071#endif // CONFIG_LOOP_RESTORATION
1072
Urvang Joshib100db72016-10-12 16:28:56 -07001073#if CONFIG_PALETTE
Urvang Joshi23a61112017-01-30 14:59:27 -08001074#define NUM_PALETTE_NEIGHBORS 3 // left, top-left and top.
1075int av1_get_palette_color_index_context(const uint8_t *color_map, int stride,
1076 int r, int c, int palette_size,
1077 uint8_t *color_order, int *color_idx) {
Urvang Joshi4f4b68e2016-10-24 17:11:10 -07001078 int i;
1079 // The +10 below should not be needed. But we get a warning "array subscript
1080 // is above array bounds [-Werror=array-bounds]" without it, possibly due to
1081 // this (or similar) bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59124
Yaowu Xuc27fc142016-08-22 16:08:15 -07001082 int scores[PALETTE_MAX_SIZE + 10];
Urvang Joshicdbe7082017-01-26 13:06:49 -08001083 const int weights[NUM_PALETTE_NEIGHBORS] = { 2, 1, 2 };
1084 const int hash_multipliers[NUM_PALETTE_NEIGHBORS] = { 1, 2, 2 };
Urvang Joshi23a61112017-01-30 14:59:27 -08001085 int color_index_ctx_hash;
1086 int color_index_ctx;
Urvang Joshicdbe7082017-01-26 13:06:49 -08001087 int color_neighbors[NUM_PALETTE_NEIGHBORS];
Urvang Joshi967ff392016-09-07 14:57:49 -07001088 int inverse_color_order[PALETTE_MAX_SIZE];
Urvang Joshi56ba91b2017-01-10 13:22:09 -08001089 assert(palette_size <= PALETTE_MAX_SIZE);
Urvang Joshicdbe7082017-01-26 13:06:49 -08001090 assert(r > 0 || c > 0);
Yaowu Xuc27fc142016-08-22 16:08:15 -07001091
Urvang Joshi79f4fc42016-10-26 09:40:35 -07001092 // Get color indices of neighbors.
Urvang Joshi56ba91b2017-01-10 13:22:09 -08001093 color_neighbors[0] = (c - 1 >= 0) ? color_map[r * stride + c - 1] : -1;
Urvang Joshi4f4b68e2016-10-24 17:11:10 -07001094 color_neighbors[1] =
Urvang Joshi56ba91b2017-01-10 13:22:09 -08001095 (c - 1 >= 0 && r - 1 >= 0) ? color_map[(r - 1) * stride + c - 1] : -1;
1096 color_neighbors[2] = (r - 1 >= 0) ? color_map[(r - 1) * stride + c] : -1;
Yaowu Xuc27fc142016-08-22 16:08:15 -07001097
Urvang Joshi967ff392016-09-07 14:57:49 -07001098 for (i = 0; i < PALETTE_MAX_SIZE; ++i) {
1099 color_order[i] = i;
1100 inverse_color_order[i] = i;
1101 }
Yaowu Xuc27fc142016-08-22 16:08:15 -07001102 memset(scores, 0, PALETTE_MAX_SIZE * sizeof(scores[0]));
Urvang Joshicdbe7082017-01-26 13:06:49 -08001103 for (i = 0; i < NUM_PALETTE_NEIGHBORS; ++i) {
Urvang Joshi4f4b68e2016-10-24 17:11:10 -07001104 if (color_neighbors[i] >= 0) {
1105 scores[color_neighbors[i]] += weights[i];
1106 }
Yaowu Xuc27fc142016-08-22 16:08:15 -07001107 }
1108
Urvang Joshicdbe7082017-01-26 13:06:49 -08001109 // Get the top NUM_PALETTE_NEIGHBORS scores (sorted from large to small).
1110 for (i = 0; i < NUM_PALETTE_NEIGHBORS; ++i) {
Urvang Joshi4f4b68e2016-10-24 17:11:10 -07001111 int max = scores[i];
1112 int max_idx = i;
1113 int j;
Urvang Joshi56ba91b2017-01-10 13:22:09 -08001114 for (j = i + 1; j < palette_size; ++j) {
Yaowu Xuc27fc142016-08-22 16:08:15 -07001115 if (scores[j] > max) {
1116 max = scores[j];
1117 max_idx = j;
1118 }
Yaowu Xuc27fc142016-08-22 16:08:15 -07001119 }
Yaowu Xuc27fc142016-08-22 16:08:15 -07001120 if (max_idx != i) {
Urvang Joshif1c06a72017-01-09 14:46:51 -08001121 // Move the score at index 'max_idx' to index 'i', and shift the scores
1122 // from 'i' to 'max_idx - 1' by 1.
1123 const int max_score = scores[max_idx];
1124 const uint8_t max_color_order = color_order[max_idx];
1125 int k;
1126 for (k = max_idx; k > i; --k) {
1127 scores[k] = scores[k - 1];
1128 color_order[k] = color_order[k - 1];
1129 inverse_color_order[color_order[k]] = k;
1130 }
1131 scores[i] = max_score;
1132 color_order[i] = max_color_order;
Urvang Joshi967ff392016-09-07 14:57:49 -07001133 inverse_color_order[color_order[i]] = i;
Yaowu Xuc27fc142016-08-22 16:08:15 -07001134 }
1135 }
1136
Urvang Joshi79f4fc42016-10-26 09:40:35 -07001137 // Get hash value of context.
Urvang Joshi23a61112017-01-30 14:59:27 -08001138 color_index_ctx_hash = 0;
Urvang Joshicdbe7082017-01-26 13:06:49 -08001139 for (i = 0; i < NUM_PALETTE_NEIGHBORS; ++i) {
Urvang Joshi23a61112017-01-30 14:59:27 -08001140 color_index_ctx_hash += scores[i] * hash_multipliers[i];
Urvang Joshicdbe7082017-01-26 13:06:49 -08001141 }
Urvang Joshi23a61112017-01-30 14:59:27 -08001142 assert(color_index_ctx_hash > 0);
1143 assert(color_index_ctx_hash <= MAX_COLOR_CONTEXT_HASH);
Yaowu Xuc27fc142016-08-22 16:08:15 -07001144
Urvang Joshi79f4fc42016-10-26 09:40:35 -07001145 // Lookup context from hash.
Urvang Joshi23a61112017-01-30 14:59:27 -08001146 color_index_ctx = palette_color_index_context_lookup[color_index_ctx_hash];
1147 assert(color_index_ctx >= 0);
1148 assert(color_index_ctx < PALETTE_COLOR_INDEX_CONTEXTS);
Yaowu Xuc27fc142016-08-22 16:08:15 -07001149
Urvang Joshi967ff392016-09-07 14:57:49 -07001150 if (color_idx != NULL) {
Urvang Joshi56ba91b2017-01-10 13:22:09 -08001151 *color_idx = inverse_color_order[color_map[r * stride + c]];
Urvang Joshi967ff392016-09-07 14:57:49 -07001152 }
Urvang Joshi23a61112017-01-30 14:59:27 -08001153 return color_index_ctx;
Yaowu Xuc27fc142016-08-22 16:08:15 -07001154}
Urvang Joshicdbe7082017-01-26 13:06:49 -08001155#undef NUM_PALETTE_NEIGHBORS
1156#undef MAX_COLOR_CONTEXT_HASH
1157
Urvang Joshib100db72016-10-12 16:28:56 -07001158#endif // CONFIG_PALETTE
Yaowu Xuc27fc142016-08-22 16:08:15 -07001159
1160#if CONFIG_VAR_TX
Yaowu Xuf883b422016-08-30 14:01:10 -07001161static const aom_prob default_txfm_partition_probs[TXFM_PARTITION_CONTEXTS] = {
Jingning Hanc8b89362016-11-01 10:28:53 -07001162 250, 231, 212, 241, 166, 66, 241, 230, 135, 243, 154, 64, 248, 161, 63, 128,
Yaowu Xuc27fc142016-08-22 16:08:15 -07001163};
1164#endif
1165
Yaowu Xuf883b422016-08-30 14:01:10 -07001166static const aom_prob default_skip_probs[SKIP_CONTEXTS] = { 192, 128, 64 };
Yaowu Xuc27fc142016-08-22 16:08:15 -07001167
Angie Chiang1733f6b2017-01-05 09:52:20 -08001168#if CONFIG_DUAL_FILTER
clang-format55ce9e02017-02-15 22:27:12 -08001169static const aom_prob default_switchable_interp_prob
1170 [SWITCHABLE_FILTER_CONTEXTS][SWITCHABLE_FILTERS - 1] = {
1171 { 235, 192, 128 }, { 36, 243, 48 }, { 34, 16, 128 },
1172 { 34, 16, 128 }, { 149, 160, 128 }, { 235, 192, 128 },
1173 { 36, 243, 48 }, { 34, 16, 128 }, { 34, 16, 128 },
1174 { 149, 160, 128 }, { 235, 192, 128 }, { 36, 243, 48 },
1175 { 34, 16, 128 }, { 34, 16, 128 }, { 149, 160, 128 },
1176 { 235, 192, 128 }, { 36, 243, 48 }, { 34, 16, 128 },
1177 { 34, 16, 128 }, { 149, 160, 128 },
1178 };
Angie Chiang1733f6b2017-01-05 09:52:20 -08001179#else // CONFIG_DUAL_FILTER
clang-format67948d32016-09-07 22:40:40 -07001180static const aom_prob default_switchable_interp_prob[SWITCHABLE_FILTER_CONTEXTS]
1181 [SWITCHABLE_FILTERS - 1] = {
1182 { 235, 162 },
1183 { 36, 255 },
1184 { 34, 3 },
1185 { 149, 144 },
1186 };
Angie Chiang1733f6b2017-01-05 09:52:20 -08001187#endif // CONFIG_DUAL_FILTER
Yaowu Xuc27fc142016-08-22 16:08:15 -07001188
1189#if CONFIG_EXT_TX
1190/* clang-format off */
Yaowu Xuf883b422016-08-30 14:01:10 -07001191const aom_tree_index av1_ext_tx_inter_tree[EXT_TX_SETS_INTER]
Yaowu Xuc27fc142016-08-22 16:08:15 -07001192 [TREE_SIZE(TX_TYPES)] = {
1193 { // ToDo(yaowu): remove used entry 0.
1194 0
1195 }, {
1196 -IDTX, 2,
1197 4, 14,
1198 6, 8,
1199 -V_DCT, -H_DCT,
1200 10, 12,
1201 -V_ADST, -H_ADST,
1202 -V_FLIPADST, -H_FLIPADST,
1203 -DCT_DCT, 16,
1204 18, 24,
1205 20, 22,
1206 -ADST_DCT, -DCT_ADST,
1207 -FLIPADST_DCT, -DCT_FLIPADST,
1208 26, 28,
1209 -ADST_ADST, -FLIPADST_FLIPADST,
1210 -ADST_FLIPADST, -FLIPADST_ADST
1211 }, {
1212 -IDTX, 2,
1213 4, 6,
1214 -V_DCT, -H_DCT,
1215 -DCT_DCT, 8,
1216 10, 16,
1217 12, 14,
1218 -ADST_DCT, -DCT_ADST,
1219 -FLIPADST_DCT, -DCT_FLIPADST,
1220 18, 20,
1221 -ADST_ADST, -FLIPADST_FLIPADST,
1222 -ADST_FLIPADST, -FLIPADST_ADST
1223 }, {
1224 -IDTX, -DCT_DCT,
1225 }
1226};
1227
Yaowu Xuf883b422016-08-30 14:01:10 -07001228const aom_tree_index av1_ext_tx_intra_tree[EXT_TX_SETS_INTRA]
Yaowu Xuc27fc142016-08-22 16:08:15 -07001229 [TREE_SIZE(TX_TYPES)] = {
1230 { // ToDo(yaowu): remove unused entry 0.
1231 0
1232 }, {
1233 -IDTX, 2,
1234 -DCT_DCT, 4,
1235 6, 8,
1236 -V_DCT, -H_DCT,
1237 -ADST_ADST, 10,
1238 -ADST_DCT, -DCT_ADST,
1239 }, {
1240 -IDTX, 2,
1241 -DCT_DCT, 4,
1242 -ADST_ADST, 6,
1243 -ADST_DCT, -DCT_ADST,
1244 }
1245};
1246/* clang-format on */
1247
Yaowu Xuf883b422016-08-30 14:01:10 -07001248static const aom_prob
Yaowu Xuc27fc142016-08-22 16:08:15 -07001249 default_inter_ext_tx_prob[EXT_TX_SETS_INTER][EXT_TX_SIZES][TX_TYPES - 1] = {
1250 {
Jingning Han1a00cff2016-12-28 14:53:14 -08001251// ToDo(yaowu): remove unused entry 0.
1252#if CONFIG_CB4X4
1253 { 0 },
1254#endif
Yaowu Xuc27fc142016-08-22 16:08:15 -07001255 { 0 },
1256 { 0 },
1257 { 0 },
Yaowu Xuc27fc142016-08-22 16:08:15 -07001258 { 0 },
Yaowu Xuc27fc142016-08-22 16:08:15 -07001259 },
1260 {
Jingning Han1a00cff2016-12-28 14:53:14 -08001261#if CONFIG_CB4X4
1262 { 0 },
1263#endif
Yaowu Xuc27fc142016-08-22 16:08:15 -07001264 { 10, 24, 30, 128, 128, 128, 128, 112, 160, 128, 128, 128, 128, 128,
1265 128 },
1266 { 10, 24, 30, 128, 128, 128, 128, 112, 160, 128, 128, 128, 128, 128,
1267 128 },
1268 { 10, 24, 30, 128, 128, 128, 128, 112, 160, 128, 128, 128, 128, 128,
1269 128 },
Yaowu Xuc27fc142016-08-22 16:08:15 -07001270 { 10, 24, 30, 128, 128, 128, 128, 112, 160, 128, 128, 128, 128, 128,
1271 128 },
Yaowu Xuc27fc142016-08-22 16:08:15 -07001272 },
1273 {
Jingning Han1a00cff2016-12-28 14:53:14 -08001274#if CONFIG_CB4X4
1275 { 0 },
1276#endif
Yaowu Xuc27fc142016-08-22 16:08:15 -07001277 { 10, 30, 128, 112, 160, 128, 128, 128, 128, 128, 128 },
1278 { 10, 30, 128, 112, 160, 128, 128, 128, 128, 128, 128 },
1279 { 10, 30, 128, 112, 160, 128, 128, 128, 128, 128, 128 },
Yaowu Xuc27fc142016-08-22 16:08:15 -07001280 { 10, 30, 128, 112, 160, 128, 128, 128, 128, 128, 128 },
Yaowu Xuc27fc142016-08-22 16:08:15 -07001281 },
1282 {
Jingning Han1a00cff2016-12-28 14:53:14 -08001283#if CONFIG_CB4X4
1284 { 0 },
1285#endif
1286 { 12 },
1287 { 12 },
1288 { 12 },
1289 { 12 },
Yaowu Xuc27fc142016-08-22 16:08:15 -07001290 }
1291 };
1292
Urvang Joshi3a9a5272017-03-10 14:40:36 -08001293// TODO(urvang): 3rd context should be tx_type instead of intra mode just like
1294// the baseline.
clang-format67948d32016-09-07 22:40:40 -07001295static const aom_prob
1296 default_intra_ext_tx_prob[EXT_TX_SETS_INTRA][EXT_TX_SIZES][INTRA_MODES]
1297 [TX_TYPES - 1] = {
1298 {
Jingning Han1a00cff2016-12-28 14:53:14 -08001299// ToDo(yaowu): remove unused entry 0.
1300#if CONFIG_CB4X4
1301 {
1302 { 0 },
1303 },
1304#endif
clang-format67948d32016-09-07 22:40:40 -07001305 {
1306 { 0 },
1307 { 0 },
1308 { 0 },
1309 { 0 },
1310 { 0 },
1311 { 0 },
1312 { 0 },
1313 { 0 },
1314 { 0 },
1315 { 0 },
Urvang Joshi3a9a5272017-03-10 14:40:36 -08001316#if CONFIG_ALT_INTRA
1317 { 0 },
1318#endif // CONFIG_ALT_INTRA
clang-format67948d32016-09-07 22:40:40 -07001319 },
1320 {
1321 { 0 },
1322 { 0 },
1323 { 0 },
1324 { 0 },
1325 { 0 },
1326 { 0 },
1327 { 0 },
1328 { 0 },
1329 { 0 },
1330 { 0 },
Urvang Joshi3a9a5272017-03-10 14:40:36 -08001331#if CONFIG_ALT_INTRA
1332 { 0 },
1333#endif // CONFIG_ALT_INTRA
clang-format67948d32016-09-07 22:40:40 -07001334 },
1335 {
1336 { 0 },
1337 { 0 },
1338 { 0 },
1339 { 0 },
1340 { 0 },
1341 { 0 },
1342 { 0 },
1343 { 0 },
1344 { 0 },
1345 { 0 },
Urvang Joshi3a9a5272017-03-10 14:40:36 -08001346#if CONFIG_ALT_INTRA
1347 { 0 },
1348#endif // CONFIG_ALT_INTRA
clang-format67948d32016-09-07 22:40:40 -07001349 },
1350 {
1351 { 0 },
1352 { 0 },
1353 { 0 },
1354 { 0 },
1355 { 0 },
1356 { 0 },
1357 { 0 },
1358 { 0 },
1359 { 0 },
1360 { 0 },
Urvang Joshi3a9a5272017-03-10 14:40:36 -08001361#if CONFIG_ALT_INTRA
1362 { 0 },
1363#endif // CONFIG_ALT_INTRA
clang-format67948d32016-09-07 22:40:40 -07001364 },
1365 },
1366 {
Jingning Han1a00cff2016-12-28 14:53:14 -08001367#if CONFIG_CB4X4
1368 {
1369 { 0 },
1370 },
1371#endif
clang-format67948d32016-09-07 22:40:40 -07001372 {
1373 { 8, 224, 32, 128, 64, 128 },
1374 { 10, 32, 32, 128, 16, 192 },
1375 { 10, 32, 32, 128, 16, 64 },
1376 { 9, 200, 32, 128, 64, 128 },
1377 { 8, 8, 32, 128, 224, 128 },
1378 { 10, 32, 32, 128, 16, 192 },
1379 { 10, 32, 32, 128, 16, 64 },
1380 { 10, 23, 32, 128, 80, 176 },
1381 { 10, 23, 32, 128, 80, 176 },
1382 { 10, 32, 32, 128, 16, 64 },
Urvang Joshi3a9a5272017-03-10 14:40:36 -08001383#if CONFIG_ALT_INTRA
1384 { 10, 32, 32, 128, 16, 64 },
1385#endif // CONFIG_ALT_INTRA
clang-format67948d32016-09-07 22:40:40 -07001386 },
1387 {
1388 { 8, 224, 32, 128, 64, 128 },
1389 { 10, 32, 32, 128, 16, 192 },
1390 { 10, 32, 32, 128, 16, 64 },
1391 { 9, 200, 32, 128, 64, 128 },
1392 { 8, 8, 32, 128, 224, 128 },
1393 { 10, 32, 32, 128, 16, 192 },
1394 { 10, 32, 32, 128, 16, 64 },
1395 { 10, 23, 32, 128, 80, 176 },
1396 { 10, 23, 32, 128, 80, 176 },
1397 { 10, 32, 32, 128, 16, 64 },
Urvang Joshi3a9a5272017-03-10 14:40:36 -08001398#if CONFIG_ALT_INTRA
1399 { 10, 32, 32, 128, 16, 64 },
1400#endif // CONFIG_ALT_INTRA
clang-format67948d32016-09-07 22:40:40 -07001401 },
1402 {
1403 { 8, 224, 32, 128, 64, 128 },
1404 { 10, 32, 32, 128, 16, 192 },
1405 { 10, 32, 32, 128, 16, 64 },
1406 { 9, 200, 32, 128, 64, 128 },
1407 { 8, 8, 32, 128, 224, 128 },
1408 { 10, 32, 32, 128, 16, 192 },
1409 { 10, 32, 32, 128, 16, 64 },
1410 { 10, 23, 32, 128, 80, 176 },
1411 { 10, 23, 32, 128, 80, 176 },
1412 { 10, 32, 32, 128, 16, 64 },
Urvang Joshi3a9a5272017-03-10 14:40:36 -08001413#if CONFIG_ALT_INTRA
1414 { 10, 32, 32, 128, 16, 64 },
1415#endif // CONFIG_ALT_INTRA
clang-format67948d32016-09-07 22:40:40 -07001416 },
1417 {
1418 { 8, 224, 32, 128, 64, 128 },
1419 { 10, 32, 32, 128, 16, 192 },
1420 { 10, 32, 32, 128, 16, 64 },
1421 { 9, 200, 32, 128, 64, 128 },
1422 { 8, 8, 32, 128, 224, 128 },
1423 { 10, 32, 32, 128, 16, 192 },
1424 { 10, 32, 32, 128, 16, 64 },
1425 { 10, 23, 32, 128, 80, 176 },
1426 { 10, 23, 32, 128, 80, 176 },
1427 { 10, 32, 32, 128, 16, 64 },
Urvang Joshi3a9a5272017-03-10 14:40:36 -08001428#if CONFIG_ALT_INTRA
1429 { 10, 32, 32, 128, 16, 64 },
1430#endif // CONFIG_ALT_INTRA
clang-format67948d32016-09-07 22:40:40 -07001431 },
1432 },
1433 {
Jingning Han1a00cff2016-12-28 14:53:14 -08001434#if CONFIG_CB4X4
1435 {
1436 { 0 },
1437 },
1438#endif
clang-format67948d32016-09-07 22:40:40 -07001439 {
1440 { 8, 224, 64, 128 },
1441 { 10, 32, 16, 192 },
1442 { 10, 32, 16, 64 },
1443 { 9, 200, 64, 128 },
1444 { 8, 8, 224, 128 },
1445 { 10, 32, 16, 192 },
1446 { 10, 32, 16, 64 },
1447 { 10, 23, 80, 176 },
1448 { 10, 23, 80, 176 },
1449 { 10, 32, 16, 64 },
Urvang Joshi3a9a5272017-03-10 14:40:36 -08001450#if CONFIG_ALT_INTRA
1451 { 10, 32, 16, 64 },
1452#endif // CONFIG_ALT_INTRA
clang-format67948d32016-09-07 22:40:40 -07001453 },
1454 {
1455 { 8, 224, 64, 128 },
1456 { 10, 32, 16, 192 },
1457 { 10, 32, 16, 64 },
1458 { 9, 200, 64, 128 },
1459 { 8, 8, 224, 128 },
1460 { 10, 32, 16, 192 },
1461 { 10, 32, 16, 64 },
1462 { 10, 23, 80, 176 },
1463 { 10, 23, 80, 176 },
1464 { 10, 32, 16, 64 },
Urvang Joshi3a9a5272017-03-10 14:40:36 -08001465#if CONFIG_ALT_INTRA
1466 { 10, 32, 16, 64 },
1467#endif // CONFIG_ALT_INTRA
clang-format67948d32016-09-07 22:40:40 -07001468 },
1469 {
1470 { 8, 224, 64, 128 },
1471 { 10, 32, 16, 192 },
1472 { 10, 32, 16, 64 },
1473 { 9, 200, 64, 128 },
1474 { 8, 8, 224, 128 },
1475 { 10, 32, 16, 192 },
1476 { 10, 32, 16, 64 },
1477 { 10, 23, 80, 176 },
1478 { 10, 23, 80, 176 },
1479 { 10, 32, 16, 64 },
Urvang Joshi3a9a5272017-03-10 14:40:36 -08001480#if CONFIG_ALT_INTRA
1481 { 10, 32, 16, 64 },
1482#endif // CONFIG_ALT_INTRA
clang-format67948d32016-09-07 22:40:40 -07001483 },
1484 {
1485 { 8, 224, 64, 128 },
1486 { 10, 32, 16, 192 },
1487 { 10, 32, 16, 64 },
1488 { 9, 200, 64, 128 },
1489 { 8, 8, 224, 128 },
1490 { 10, 32, 16, 192 },
1491 { 10, 32, 16, 64 },
1492 { 10, 23, 80, 176 },
1493 { 10, 23, 80, 176 },
1494 { 10, 32, 16, 64 },
Urvang Joshi3a9a5272017-03-10 14:40:36 -08001495#if CONFIG_ALT_INTRA
1496 { 10, 32, 16, 64 },
1497#endif // CONFIG_ALT_INTRA
clang-format67948d32016-09-07 22:40:40 -07001498 },
1499 },
1500 };
Yaowu Xuc27fc142016-08-22 16:08:15 -07001501#else
1502
1503/* clang-format off */
Yaowu Xuf883b422016-08-30 14:01:10 -07001504const aom_tree_index av1_ext_tx_tree[TREE_SIZE(TX_TYPES)] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -07001505 -DCT_DCT, 2,
1506 -ADST_ADST, 4,
1507 -ADST_DCT, -DCT_ADST
1508};
1509/* clang-format on */
1510
Nathan E. Egge7c5b4c12016-04-26 12:31:14 -04001511int av1_ext_tx_ind[TX_TYPES];
1512int av1_ext_tx_inv[TX_TYPES];
1513
Yaowu Xuf883b422016-08-30 14:01:10 -07001514static const aom_prob
Yaowu Xuc27fc142016-08-22 16:08:15 -07001515 default_intra_ext_tx_prob[EXT_TX_SIZES][TX_TYPES][TX_TYPES - 1] = {
Jingning Han607fa6a2016-10-26 10:46:28 -07001516#if CONFIG_CB4X4
1517 { { 240, 85, 128 }, { 4, 1, 248 }, { 4, 1, 8 }, { 4, 248, 128 } },
1518#endif
Yaowu Xuc27fc142016-08-22 16:08:15 -07001519 { { 240, 85, 128 }, { 4, 1, 248 }, { 4, 1, 8 }, { 4, 248, 128 } },
1520 { { 244, 85, 128 }, { 8, 2, 248 }, { 8, 2, 8 }, { 8, 248, 128 } },
1521 { { 248, 85, 128 }, { 16, 4, 248 }, { 16, 4, 8 }, { 16, 248, 128 } },
1522 };
1523
Yaowu Xuf883b422016-08-30 14:01:10 -07001524static const aom_prob default_inter_ext_tx_prob[EXT_TX_SIZES][TX_TYPES - 1] = {
Jingning Han607fa6a2016-10-26 10:46:28 -07001525#if CONFIG_CB4X4
1526 { 160, 85, 128 },
1527#endif
1528 { 160, 85, 128 },
1529 { 176, 85, 128 },
1530 { 192, 85, 128 },
Yaowu Xuc27fc142016-08-22 16:08:15 -07001531};
1532#endif // CONFIG_EXT_TX
1533
1534#if CONFIG_EXT_INTRA
hui sueda3d762016-12-06 16:58:23 -08001535#if CONFIG_INTRA_INTERP
clang-format55ce9e02017-02-15 22:27:12 -08001536static const aom_prob
1537 default_intra_filter_probs[INTRA_FILTERS + 1][INTRA_FILTERS - 1] = {
1538 { 98, 63, 60 }, { 98, 82, 80 }, { 94, 65, 103 },
1539 { 49, 25, 24 }, { 72, 38, 50 },
1540 };
Yaowu Xuf883b422016-08-30 14:01:10 -07001541const aom_tree_index av1_intra_filter_tree[TREE_SIZE(INTRA_FILTERS)] = {
Yaowu Xuc27fc142016-08-22 16:08:15 -07001542 -INTRA_FILTER_LINEAR, 2, -INTRA_FILTER_8TAP, 4, -INTRA_FILTER_8TAP_SHARP,
1543 -INTRA_FILTER_8TAP_SMOOTH,
1544};
hui sueda3d762016-12-06 16:58:23 -08001545#endif // CONFIG_INTRA_INTERP
Yaowu Xuc27fc142016-08-22 16:08:15 -07001546#endif // CONFIG_EXT_INTRA
1547
hui su5db97432016-10-14 16:10:14 -07001548#if CONFIG_FILTER_INTRA
1549static const aom_prob default_filter_intra_probs[2] = { 230, 230 };
1550#endif // CONFIG_FILTER_INTRA
1551
Yaowu Xuc27fc142016-08-22 16:08:15 -07001552#if CONFIG_SUPERTX
clang-format55ce9e02017-02-15 22:27:12 -08001553static const aom_prob
1554 default_supertx_prob[PARTITION_SUPERTX_CONTEXTS][TX_SIZES] = {
Jingning Hanfeb517c2016-12-21 16:02:07 -08001555#if CONFIG_CB4X4
1556#if CONFIG_TX64X64
clang-format55ce9e02017-02-15 22:27:12 -08001557 { 1, 1, 160, 160, 170, 180 }, { 1, 1, 200, 200, 210, 220 },
Jingning Hanfeb517c2016-12-21 16:02:07 -08001558#else
clang-format55ce9e02017-02-15 22:27:12 -08001559 { 1, 1, 160, 160, 170 }, { 1, 1, 200, 200, 210 },
Jingning Hanfeb517c2016-12-21 16:02:07 -08001560#endif // CONFIG_TX64X64
1561#else
Debargha Mukherjee5a488a62016-11-22 22:24:10 -08001562#if CONFIG_TX64X64
clang-format55ce9e02017-02-15 22:27:12 -08001563 { 1, 160, 160, 170, 180 }, { 1, 200, 200, 210, 220 },
Debargha Mukherjee5a488a62016-11-22 22:24:10 -08001564#else
clang-format55ce9e02017-02-15 22:27:12 -08001565 { 1, 160, 160, 170 }, { 1, 200, 200, 210 },
Jingning Hanfeb517c2016-12-21 16:02:07 -08001566#endif // CONFIG_CB4X4
Debargha Mukherjee5a488a62016-11-22 22:24:10 -08001567#endif // CONFIG_TX64X64
clang-format55ce9e02017-02-15 22:27:12 -08001568 };
Yaowu Xuc27fc142016-08-22 16:08:15 -07001569#endif // CONFIG_SUPERTX
1570
1571// FIXME(someone) need real defaults here
Nathan E. Eggef627e582016-08-19 20:06:51 -04001572static const aom_prob default_segment_tree_probs[SEG_TREE_PROBS] = {
1573 128, 128, 128, 128, 128, 128, 128
Yaowu Xuc27fc142016-08-22 16:08:15 -07001574};
Nathan E. Eggef627e582016-08-19 20:06:51 -04001575// clang-format off
1576static const aom_prob default_segment_pred_probs[PREDICTION_PROBS] = {
1577 128, 128, 128
1578};
1579// clang-format on
Yaowu Xuc27fc142016-08-22 16:08:15 -07001580
Thomas Davies1d7db722017-02-22 11:15:00 +00001581#if CONFIG_EC_MULTISYMBOL
1582static const aom_cdf_prob
1583 default_switchable_interp_cdf[SWITCHABLE_FILTER_CONTEXTS]
1584 [CDF_SIZE(SWITCHABLE_FILTERS)] = {
1585 { 30080, 31781, 32768, 0 },
1586 { 4608, 32658, 32768, 0 },
1587 { 4352, 4685, 32768, 0 },
1588 { 19072, 26776, 32768, 0 },
1589 };
1590
1591static const aom_cdf_prob default_seg_tree_cdf[CDF_SIZE(MAX_SEGMENTS)] = {
1592 4096, 8192, 12288, 16384, 20480, 24576, 28672, 32768, 0
1593};
1594
1595static const aom_cdf_prob
1596 default_tx_size_cdf[MAX_TX_DEPTH][TX_SIZE_CONTEXTS][CDF_SIZE(MAX_TX_DEPTH +
1597 1)] = {
1598 { { 12800, 32768, 0 }, { 8448, 32768, 0 } },
1599 { { 2560, 20496, 32768, 0 }, { 1920, 14091, 32768, 0 } },
1600 { { 384, 17588, 19782, 32768, 0 }, { 640, 7166, 8466, 32768, 0 } },
1601#if CONFIG_TX64X64
1602 { { 128, 8288, 21293, 26986, 32768, 0 },
1603 { 128, 4208, 10009, 15965, 32768, 0 } },
1604#endif
1605 };
1606
Urvang Joshi63234542017-03-10 12:04:03 -08001607#if CONFIG_ALT_INTRA
1608static const aom_cdf_prob
1609 default_if_y_mode_cdf[BLOCK_SIZE_GROUPS][CDF_SIZE(INTRA_MODES)] = {
1610 { 11264, 12608, 16309, 21086, 23297, 24860, 27022, 28099, 29631, 31126,
1611 32768, 0 },
1612 { 9600, 11953, 16100, 20922, 22756, 23913, 25435, 26724, 28046, 29927,
1613 32768, 0 },
1614 { 9344, 11540, 16515, 21763, 23078, 23816, 24725, 25856, 26720, 28208,
1615 32768, 0 },
1616 { 12288, 14448, 18026, 23346, 23833, 24188, 24724, 25415, 25817, 26876,
1617 32768, 0 },
1618 };
1619
1620static const aom_cdf_prob
1621 default_uv_mode_cdf[INTRA_MODES][CDF_SIZE(INTRA_MODES)] = {
1622 { 25472, 25558, 27783, 30779, 30988, 31269, 31492, 31741, 32014, 32420,
1623 32768, 0 },
1624 { 2176, 2415, 28381, 29574, 29832, 30712, 30881, 31662, 31761, 31922,
1625 32768, 0 },
1626 { 3328, 3443, 4016, 31099, 31272, 31420, 31504, 31608, 31916, 32598,
1627 32768, 0 },
1628 { 23424, 23534, 25915, 27831, 28058, 28431, 30142, 31209, 31459, 32369,
1629 32768, 0 },
1630 { 22784, 22862, 24255, 26287, 28490, 29509, 29776, 30115, 31203, 31674,
1631 32768, 0 },
1632 { 19712, 19865, 23141, 24428, 25731, 31377, 31622, 32047, 32458, 32767,
1633 32768, 0 },
1634 { 21376, 21421, 22130, 27688, 28485, 28779, 28935, 29085, 31962, 32450,
1635 32768, 0 },
1636 { 19712, 19814, 20725, 28510, 28814, 29099, 29457, 29729, 30133, 32408,
1637 32768, 0 },
1638 { 19584, 19790, 23643, 25501, 25913, 26673, 27578, 30923, 31255, 31870,
1639 32768, 0 },
1640 { 20864, 21004, 24129, 26308, 27062, 27065, 27488, 28045, 28506, 29272,
1641 32768, 0 },
1642 { 23680, 23929, 27831, 30446, 30598, 31129, 31244, 31655, 31868, 32234,
1643 32768, 0 },
1644 };
1645#else
Thomas Davies1d7db722017-02-22 11:15:00 +00001646static const aom_cdf_prob default_if_y_mode_cdf[BLOCK_SIZE_GROUPS][CDF_SIZE(
1647 INTRA_MODES)] = {
1648 { 8320, 11376, 12880, 19959, 23072, 24067, 25461, 26917, 29157, 32768, 0 },
1649 { 16896, 21112, 21932, 27852, 28667, 28916, 29593, 30089, 30905, 32768, 0 },
1650 { 22144, 25464, 26006, 30364, 30583, 30655, 31183, 31400, 31646, 32768, 0 },
1651 { 28288, 30650, 30964, 32288, 32308, 32331, 32495, 32586, 32607, 32768, 0 },
1652};
1653
1654static const aom_cdf_prob default_uv_mode_cdf[INTRA_MODES][CDF_SIZE(
1655 INTRA_MODES)] = {
1656 { 15360, 15836, 20863, 27513, 28269, 29048, 29455, 30154, 31206, 32768, 0 },
1657 { 6144, 7392, 22657, 25981, 26965, 28779, 29309, 30890, 31763, 32768, 0 },
1658 { 8576, 9143, 11450, 27575, 28108, 28438, 28658, 28995, 30410, 32768, 0 },
1659 { 12416, 12814, 16244, 22057, 23492, 24700, 26213, 27954, 29778, 32768, 0 },
1660 { 10624, 11057, 14619, 19415, 23134, 25679, 26399, 27618, 30676, 32768, 0 },
1661 { 10240, 10680, 15684, 19118, 21856, 27563, 28234, 29332, 31278, 32768, 0 },
1662 { 11008, 11433, 14100, 22522, 24365, 25330, 25737, 26341, 30433, 32768, 0 },
1663 { 10880, 11308, 13991, 23645, 24679, 25433, 25977, 26746, 28463, 32768, 0 },
1664 { 9856, 10483, 16054, 19959, 21708, 23628, 24949, 28797, 30658, 32768, 0 },
1665 { 12928, 14556, 22168, 27789, 28543, 29663, 29893, 30645, 31682, 32768, 0 },
1666};
Urvang Joshi63234542017-03-10 12:04:03 -08001667#endif // CONFIG_ALT_INTRA
Thomas Davies1d7db722017-02-22 11:15:00 +00001668
Alex Converse57795a42017-03-14 12:18:25 -07001669#if CONFIG_EXT_PARTITION_TYPES
1670static const aom_cdf_prob
1671 default_partition_cdf[PARTITION_CONTEXTS][CDF_SIZE(EXT_PARTITION_TYPES)] = {
1672 // 8x8 -> 4x4 only supports the four legacy partition types
1673 { 25472, 28949, 31052, 32768, 0, 0, 0, 0, 0 },
1674 { 18816, 22250, 28783, 32768, 0, 0, 0, 0, 0 },
1675 { 18944, 26126, 29188, 32768, 0, 0, 0, 0, 0 },
1676 { 15488, 22508, 27077, 32768, 0, 0, 0, 0, 0 },
1677 { 22272, 23768, 25043, 29996, 30744, 31493, 32130, 32768, 0 },
1678 { 11776, 13457, 16315, 28229, 29069, 29910, 31339, 32768, 0 },
1679 { 10496, 14802, 16136, 27127, 29280, 31434, 32101, 32768, 0 },
1680 { 6784, 8763, 10440, 29110, 30100, 31090, 31929, 32768, 0 },
1681 { 22656, 23801, 24702, 30721, 31294, 31867, 32317, 32768, 0 },
1682 { 8704, 9926, 12586, 28885, 29496, 30107, 31437, 32768, 0 },
1683 { 6656, 10685, 11566, 27857, 29871, 31886, 32327, 32768, 0 },
1684 { 2176, 3012, 3690, 31253, 31671, 32090, 32429, 32768, 0 },
1685 { 28416, 28705, 28926, 32258, 32402, 32547, 32657, 32768, 0 },
1686 { 9216, 9952, 11849, 30134, 30502, 30870, 31819, 32768, 0 },
1687 { 7424, 9008, 9528, 30664, 31456, 32248, 32508, 32768, 0 },
1688 { 1280, 1710, 2069, 31978, 32193, 32409, 32588, 32768, 0 },
1689#if CONFIG_EXT_PARTITION
1690 { 28416, 28705, 28926, 32258, 32402, 32547, 32657, 32768, 0 },
1691 { 9216, 9952, 11849, 30134, 30502, 30870, 31819, 32768, 0 },
1692 { 7424, 9008, 9528, 30664, 31456, 32248, 32508, 32768, 0 },
1693 { 1280, 1710, 2069, 31978, 32193, 32409, 32588, 32768, 0 },
1694#endif
1695 };
1696#else
Thomas Davies1d7db722017-02-22 11:15:00 +00001697static const aom_cdf_prob
1698 default_partition_cdf[PARTITION_CONTEXTS][CDF_SIZE(PARTITION_TYPES)] = {
1699 { 25472, 28949, 31052, 32768, 0 }, { 18816, 22250, 28783, 32768, 0 },
1700 { 18944, 26126, 29188, 32768, 0 }, { 15488, 22508, 27077, 32768, 0 },
1701 { 22272, 25265, 27815, 32768, 0 }, { 11776, 15138, 20854, 32768, 0 },
1702 { 10496, 19109, 21777, 32768, 0 }, { 6784, 10743, 14098, 32768, 0 },
1703 { 22656, 24947, 26749, 32768, 0 }, { 8704, 11148, 16469, 32768, 0 },
1704 { 6656, 14714, 16477, 32768, 0 }, { 2176, 3849, 5205, 32768, 0 },
1705 { 28416, 28994, 29436, 32768, 0 }, { 9216, 10688, 14483, 32768, 0 },
1706 { 7424, 10592, 11632, 32768, 0 }, { 1280, 2141, 2859, 32768, 0 },
Alex Converse57795a42017-03-14 12:18:25 -07001707#if CONFIG_EXT_PARTITION
1708 { 28416, 28994, 29436, 32768, 0 }, { 9216, 10688, 14483, 32768, 0 },
1709 { 7424, 10592, 11632, 32768, 0 }, { 1280, 2141, 2859, 32768, 0 },
1710#endif
Thomas Davies1d7db722017-02-22 11:15:00 +00001711 };
Alex Converse57795a42017-03-14 12:18:25 -07001712#endif
Thomas Davies1d7db722017-02-22 11:15:00 +00001713
1714static const aom_cdf_prob
1715 default_inter_mode_cdf[INTER_MODE_CONTEXTS][CDF_SIZE(INTER_MODES)] = {
1716 { 256, 22227, 23627, 32768, 0 }, { 896, 18948, 23537, 32768, 0 },
1717 { 896, 21563, 24320, 32768, 0 }, { 896, 12599, 17799, 32768, 0 },
1718 { 1024, 8960, 13238, 32768, 0 }, { 2176, 11856, 14388, 32768, 0 },
1719 { 3200, 6550, 9622, 32768, 0 },
1720 };
1721
1722#if !CONFIG_EXT_TX
1723static const aom_cdf_prob
1724 default_intra_ext_tx_cdf[EXT_TX_SIZES][TX_TYPES][CDF_SIZE(TX_TYPES)] = {
1725 { { 30720, 31400, 32084, 32768, 0 },
1726 { 512, 638, 31764, 32768, 0 },
1727 { 512, 638, 1642, 32768, 0 },
1728 { 512, 31760, 32264, 32768, 0 } },
1729 { { 31232, 31742, 32255, 32768, 0 },
1730 { 1024, 1272, 31784, 32768, 0 },
1731 { 1024, 1272, 2256, 32768, 0 },
1732 { 1024, 31776, 32272, 32768, 0 } },
1733 { { 31744, 32084, 32426, 32768, 0 },
1734 { 2048, 2528, 31823, 32768, 0 },
1735 { 2048, 2528, 3473, 32768, 0 },
1736 { 2048, 31808, 32288, 32768, 0 } },
1737 };
1738
1739static const aom_cdf_prob
1740 default_inter_ext_tx_cdf[EXT_TX_SIZES][CDF_SIZE(TX_TYPES)] = {
1741 { 20480, 24560, 28664, 32768, 0 },
1742 { 22528, 25928, 29348, 32768, 0 },
1743 { 24576, 27296, 30032, 32768, 0 },
1744 };
1745#endif
1746
1747// CDF version of 'av1_kf_y_mode_prob'.
Urvang Joshi63234542017-03-10 12:04:03 -08001748const aom_cdf_prob
1749 av1_kf_y_mode_cdf[INTRA_MODES][INTRA_MODES][CDF_SIZE(INTRA_MODES)] = {
1750#if CONFIG_ALT_INTRA
1751 {
1752 { 15488, 17513, 20731, 24586, 25921, 26749, 27807, 28602, 29530,
1753 30681, 32768, 0 },
1754 { 11648, 14783, 21879, 23981, 25213, 26218, 27472, 28465, 29221,
1755 30232, 32768, 0 },
1756 { 8448, 11108, 13392, 25167, 26295, 26789, 27536, 28088, 29039, 30700,
1757 32768, 0 },
1758 { 13568, 15293, 18706, 21610, 23139, 24254, 26383, 27630, 28613,
1759 30350, 32768, 0 },
1760 { 9600, 11772, 14397, 16580, 20091, 22865, 24490, 25395, 27037, 28694,
1761 32768, 0 },
1762 { 12160, 14092, 17010, 18922, 22683, 25751, 27725, 30109, 31449,
1763 32763, 32768, 0 },
1764 { 9088, 10383, 12569, 17113, 21351, 22511, 23633, 24382, 28215, 29798,
1765 32768, 0 },
1766 { 10880, 12248, 15214, 20017, 21922, 22757, 24360, 25280, 26684,
1767 29869, 32768, 0 },
1768 { 11008, 13133, 15587, 17872, 19579, 21157, 23788, 26629, 27732,
1769 29601, 32768, 0 },
1770 { 10112, 12325, 15360, 18348, 20452, 20460, 21902, 23982, 25149,
1771 26667, 32768, 0 },
1772 { 8704, 14250, 17722, 23128, 24217, 24892, 26215, 27392, 28358, 30287,
1773 32768, 0 },
1774 },
1775 {
1776 { 8448, 10443, 20733, 23689, 24634, 25951, 26670, 27861, 28379, 29305,
1777 32768, 0 },
1778 { 6656, 9206, 24577, 25792, 26335, 27169, 27913, 28956, 29239, 29680,
1779 32768, 0 },
1780 { 7168, 8968, 15662, 22937, 23849, 24616, 25603, 26555, 27210, 29142,
1781 32768, 0 },
1782 { 9600, 11501, 19310, 21731, 22790, 23936, 25627, 27217, 27868, 29170,
1783 32768, 0 },
1784 { 6912, 8730, 17650, 19377, 21025, 23319, 24537, 26112, 26840, 28345,
1785 32768, 0 },
1786 { 7808, 9661, 20583, 21996, 23898, 26818, 28120, 30716, 31678, 32764,
1787 32768, 0 },
1788 { 6784, 8104, 15619, 18584, 20844, 22519, 23760, 25203, 27094, 28801,
1789 32768, 0 },
1790 { 8832, 10141, 17035, 20764, 21703, 22751, 23964, 25305, 26034, 29006,
1791 32768, 0 },
1792 { 8192, 9920, 19113, 20594, 21747, 23327, 24581, 26916, 27533, 28944,
1793 32768, 0 },
1794 { 6656, 8696, 18381, 20537, 21804, 21809, 22751, 24394, 24917, 25990,
1795 32768, 0 },
1796 { 6400, 9593, 20818, 23519, 24266, 25113, 26608, 27883, 28322, 29364,
1797 32768, 0 },
1798 },
1799 {
1800 { 12032, 14381, 16608, 24946, 26084, 26582, 27428, 28075, 29395,
1801 30858, 32768, 0 },
1802 { 9216, 12620, 18287, 24345, 25984, 26715, 27732, 28519, 29399, 30781,
1803 32768, 0 },
1804 { 6784, 8916, 10220, 26539, 27310, 27483, 28082, 28430, 29362, 31291,
1805 32768, 0 },
1806 { 11904, 14838, 17359, 21663, 22931, 23619, 25620, 26653, 27823,
1807 30547, 32768, 0 },
1808 { 10752, 13504, 15536, 19057, 21753, 23883, 25202, 26266, 28196,
1809 30589, 32768, 0 },
1810 { 10496, 13193, 16787, 21011, 23929, 25651, 27958, 29330, 31022,
1811 32761, 32768, 0 },
1812 { 8448, 9968, 11749, 18062, 21841, 22669, 23852, 24444, 28118, 30007,
1813 32768, 0 },
1814 { 9728, 11168, 12602, 20819, 22194, 22764, 24366, 25022, 26414, 30460,
1815 32768, 0 },
1816 { 9216, 12712, 14357, 18346, 20486, 21549, 23170, 25794, 27129, 29574,
1817 32768, 0 },
1818 { 7808, 10733, 13057, 20252, 21906, 21912, 23057, 24233, 25700, 27439,
1819 32768, 0 },
1820 { 6784, 11352, 13778, 23877, 24995, 25424, 26830, 27688, 28779, 30368,
1821 32768, 0 },
1822 },
1823 {
1824 { 12288, 13728, 16480, 19841, 21570, 22715, 25385, 27000, 28329,
1825 29994, 32768, 0 },
1826 { 9344, 10991, 18817, 20972, 22137, 23231, 26025, 27711, 28244, 29428,
1827 32768, 0 },
1828 { 9344, 10900, 13206, 21344, 22332, 22987, 25127, 26440, 27231, 29502,
1829 32768, 0 },
1830 { 12928, 14478, 15978, 18630, 19852, 20897, 24699, 26464, 27030,
1831 30482, 32768, 0 },
1832 { 9088, 10476, 13350, 15237, 18175, 20252, 23283, 25321, 26426, 29349,
1833 32768, 0 },
1834 { 10240, 11912, 15008, 17177, 19979, 23056, 26395, 29681, 30790,
1835 32760, 32768, 0 },
1836 { 8704, 9738, 11717, 15480, 18656, 20022, 22611, 24357, 27150, 29257,
1837 32768, 0 },
1838 { 12928, 13548, 17978, 20602, 21814, 22427, 24568, 25881, 26823,
1839 30817, 32768, 0 },
1840 { 10496, 12149, 14082, 18054, 19032, 19994, 24086, 28427, 29156,
1841 30680, 32768, 0 },
1842 { 8448, 10158, 13867, 16506, 18584, 18592, 21472, 23767, 24646, 27279,
1843 32768, 0 },
1844 { 7296, 9684, 13471, 17701, 18934, 19878, 25115, 27238, 27972, 29583,
1845 32768, 0 },
1846 },
1847 {
1848 { 10880, 12163, 14497, 17112, 20859, 22562, 23599, 24638, 26861,
1849 29399, 32768, 0 },
1850 { 9984, 12476, 16360, 18889, 21414, 23474, 24563, 25909, 27195, 28828,
1851 32768, 0 },
1852 { 7168, 9268, 10737, 20063, 22315, 23302, 24152, 25195, 26645, 28845,
1853 32768, 0 },
1854 { 8960, 10727, 12449, 14263, 16523, 17608, 23352, 24676, 26478, 28886,
1855 32768, 0 },
1856 { 9856, 11109, 13309, 14975, 19055, 21670, 23144, 24460, 26212, 28107,
1857 32768, 0 },
1858 { 9984, 11586, 14565, 16562, 21107, 25444, 27218, 29429, 31451, 32763,
1859 32768, 0 },
1860 { 7168, 8268, 9704, 13144, 18443, 20065, 21653, 23607, 26506, 28854,
1861 32768, 0 },
1862 { 11520, 13014, 14866, 18136, 20231, 21509, 23004, 24186, 25728,
1863 29468, 32768, 0 },
1864 { 10240, 12264, 14507, 16388, 18888, 20927, 22731, 24691, 26142,
1865 28394, 32768, 0 },
1866 { 8064, 10187, 12921, 15952, 19960, 19976, 21275, 23205, 25110, 26636,
1867 32768, 0 },
1868 { 8448, 11488, 14065, 19113, 21604, 22978, 24508, 25895, 27398, 29055,
1869 32768, 0 },
1870 },
1871 {
1872 { 10368, 11768, 16772, 19842, 22940, 27394, 28528, 30267, 31371,
1873 32763, 32768, 0 },
1874 { 9472, 11292, 18507, 20777, 23357, 27587, 28902, 30850, 31607, 32763,
1875 32768, 0 },
1876 { 8064, 9512, 13782, 20645, 24493, 26242, 28001, 29435, 30438, 32759,
1877 32768, 0 },
1878 { 8960, 10541, 15664, 17639, 19646, 22145, 25216, 28815, 30050, 32757,
1879 32768, 0 },
1880 { 9984, 11141, 15365, 16746, 21186, 25766, 27817, 30022, 31309, 32762,
1881 32768, 0 },
1882 { 9216, 10688, 16639, 17735, 21499, 26657, 28161, 30572, 31490, 32763,
1883 32768, 0 },
1884 { 8448, 9303, 13611, 16636, 20555, 23414, 24912, 27613, 29727, 32756,
1885 32768, 0 },
1886 { 9984, 11052, 16142, 19312, 21680, 23870, 25504, 28200, 29324, 32755,
1887 32768, 0 },
1888 { 10496, 12323, 16955, 18839, 21144, 24861, 26838, 29988, 30976,
1889 32761, 32768, 0 },
1890 { 2944, 5973, 8904, 11875, 14864, 17853, 20824, 23810, 26784, 29776,
1891 32768, 0 },
1892 { 7424, 10097, 15588, 20217, 23899, 26460, 28308, 30155, 30951, 32761,
1893 32768, 0 },
1894 },
1895 {
1896 { 11648, 13133, 15050, 20481, 22470, 23425, 24337, 25160, 28964,
1897 30480, 32768, 0 },
1898 { 10240, 12616, 16631, 20485, 22290, 23628, 25235, 26353, 28107,
1899 29655, 32768, 0 },
1900 { 6784, 8002, 9066, 20038, 22926, 23324, 23951, 24537, 26916, 30231,
1901 32768, 0 },
1902 { 11904, 14105, 15782, 19896, 22283, 23147, 24763, 25983, 27812,
1903 29980, 32768, 0 },
1904 { 10624, 11922, 13632, 15941, 20469, 22453, 24065, 25187, 27349,
1905 29296, 32768, 0 },
1906 { 12032, 13085, 15468, 17768, 20613, 24388, 26385, 28430, 30938,
1907 32761, 32768, 0 },
1908 { 9728, 10538, 11493, 14765, 18460, 19471, 20302, 20935, 28192, 29926,
1909 32768, 0 },
1910 { 8960, 9890, 10962, 16685, 18880, 19480, 20674, 21477, 23815, 29341,
1911 32768, 0 },
1912 { 14592, 16367, 17712, 20293, 22544, 23829, 24877, 26326, 27660,
1913 29875, 32768, 0 },
1914 { 8960, 10448, 12279, 16206, 18672, 18682, 20058, 21547, 25097, 27165,
1915 32768, 0 },
1916 { 11136, 13840, 15762, 21710, 23038, 23734, 24863, 25882, 27765,
1917 30071, 32768, 0 },
1918 },
1919 {
1920 { 12544, 14124, 16964, 21907, 23808, 24496, 25724, 26715, 27992,
1921 30455, 32768, 0 },
1922 { 10368, 13606, 18247, 20869, 22590, 23749, 25088, 26378, 27277,
1923 29808, 32768, 0 },
1924 { 9088, 11031, 12899, 23497, 24465, 24851, 25995, 26815, 27885, 30555,
1925 32768, 0 },
1926 { 11520, 14342, 15710, 19196, 21250, 21907, 24665, 26153, 27212,
1927 30750, 32768, 0 },
1928 { 9984, 11764, 13979, 16405, 19279, 20658, 23354, 25266, 26702, 29380,
1929 32768, 0 },
1930 { 10112, 12325, 15918, 19060, 21829, 23882, 26277, 27697, 30114,
1931 32758, 32768, 0 },
1932 { 9344, 10534, 12184, 16208, 19764, 20627, 22524, 23644, 26887, 29782,
1933 32768, 0 },
1934 { 12928, 14013, 15625, 19107, 20654, 21451, 22910, 23873, 24776,
1935 30239, 32768, 0 },
1936 { 10368, 12818, 14610, 17350, 19568, 20710, 22971, 25114, 26340,
1937 29127, 32768, 0 },
1938 { 8960, 11192, 13720, 18429, 20409, 20417, 22250, 23318, 24647, 27248,
1939 32768, 0 },
1940 { 7808, 11416, 13918, 19028, 20181, 20839, 24380, 26018, 26967, 29845,
1941 32768, 0 },
1942 },
1943 {
1944 { 9856, 11020, 14928, 18159, 19421, 20921, 23466, 26664, 27475, 28881,
1945 32768, 0 },
1946 { 8704, 10302, 17323, 18907, 19868, 21184, 24171, 28033, 28625, 29353,
1947 32768, 0 },
1948 { 7936, 9197, 12604, 20616, 21514, 22371, 24239, 26138, 26863, 29239,
1949 32768, 0 },
1950 { 11264, 12524, 16083, 18574, 19858, 20841, 24242, 27606, 28352,
1951 29853, 32768, 0 },
1952 { 8704, 10208, 13292, 15170, 17277, 19226, 22083, 25046, 26041, 27802,
1953 32768, 0 },
1954 { 9088, 10568, 15511, 17246, 20170, 22791, 25558, 30740, 31635, 32764,
1955 32768, 0 },
1956 { 7040, 8045, 10653, 13145, 15286, 16614, 19075, 23140, 26224, 28652,
1957 32768, 0 },
1958 { 10240, 11032, 14258, 17629, 18914, 19898, 22412, 24961, 25815,
1959 29156, 32768, 0 },
1960 { 11008, 12028, 14702, 16147, 17209, 18160, 21812, 27547, 28709,
1961 30120, 32768, 0 },
1962 { 7168, 9068, 14160, 16937, 18515, 18521, 20636, 24617, 25317, 26365,
1963 32768, 0 },
1964 { 6784, 8510, 14195, 17148, 18158, 19201, 23070, 27351, 27901, 29422,
1965 32768, 0 },
1966 },
1967 {
1968 { 10112, 11528, 15345, 19296, 21394, 21402, 22379, 23840, 24851,
1969 26150, 32768, 0 },
1970 { 8064, 10187, 17949, 20052, 22051, 22059, 23147, 24688, 25351, 26365,
1971 32768, 0 },
1972 { 6528, 8373, 11041, 21963, 23089, 23093, 24076, 24925, 25691, 27764,
1973 32768, 0 },
1974 { 9600, 11229, 14847, 17527, 19738, 19747, 21629, 23761, 24957, 27673,
1975 32768, 0 },
1976 { 8960, 10262, 13339, 15480, 19925, 19942, 21445, 23037, 24329, 25977,
1977 32768, 0 },
1978 { 2944, 5973, 8904, 11875, 14864, 17853, 20824, 23810, 26784, 29776,
1979 32768, 0 },
1980 { 9472, 10564, 13426, 16561, 19685, 19697, 21076, 22583, 24891, 26983,
1981 32768, 0 },
1982 { 8448, 9493, 12221, 16542, 18394, 18401, 19580, 20971, 22031, 26770,
1983 32768, 0 },
1984 { 8704, 10772, 14209, 16381, 18911, 18921, 20436, 23374, 24475, 26095,
1985 32768, 0 },
1986 { 7680, 9444, 13453, 16320, 18650, 18659, 19651, 21291, 22277, 23916,
1987 32768, 0 },
1988 { 6656, 9920, 14740, 19864, 21495, 21501, 22953, 24372, 25192, 26760,
1989 32768, 0 },
1990 },
1991 {
1992 { 9728, 13958, 18881, 23624, 24754, 25553, 26709, 27940, 28977, 30413,
1993 32768, 0 },
1994 { 8832, 12572, 22433, 24653, 25676, 26551, 27571, 28688, 29198, 30174,
1995 32768, 0 },
1996 { 5888, 8828, 11353, 23482, 24310, 24737, 25804, 26375, 27174, 29840,
1997 32768, 0 },
1998 { 9984, 13099, 16249, 19443, 20990, 22637, 24576, 25952, 26884, 29435,
1999 32768, 0 },
2000 { 8448, 11108, 15085, 18134, 20319, 21992, 23549, 24989, 27177, 29208,
2001 32768, 0 },
2002 { 9856, 13168, 18987, 22481, 24282, 26200, 27868, 30203, 31085, 32761,
2003 32768, 0 },
2004 { 6784, 9119, 12629, 16877, 20262, 21125, 22307, 23615, 27727, 29972,
2005 32768, 0 },
2006 { 8320, 10230, 12783, 19005, 20213, 20668, 22039, 23045, 24146, 30478,
2007 32768, 0 },
2008 { 9088, 11308, 15416, 18118, 19762, 20906, 22574, 25162, 25994, 28455,
2009 32768, 0 },
2010 { 6912, 10548, 15148, 20026, 21612, 21618, 22707, 24200, 24869, 26844,
2011 32768, 0 },
2012 { 6656, 12164, 16993, 21568, 22933, 23648, 25322, 26602, 27806, 29841,
2013 32768, 0 },
2014 },
2015#else
2016 { { 17536, 19321, 21527, 25360, 27516, 28026, 29323, 30023, 30999, 32768,
2017 0 },
2018 { 11776, 15466, 22360, 24865, 26991, 27889, 29299, 30519, 31398, 32768,
2019 0 },
2020 { 9344, 12272, 13793, 25813, 27359, 27654, 28573, 29130, 30551, 32768,
2021 0 },
2022 { 11648, 14123, 16454, 19948, 22780, 23846, 27087, 28995, 30380, 32768,
2023 0 },
2024 { 9216, 12436, 15295, 17996, 24006, 25465, 27405, 28725, 30383, 32768,
2025 0 },
2026 { 9344, 12181, 14433, 16634, 20355, 24317, 26133, 29295, 31344, 32768,
2027 0 },
2028 { 8576, 10750, 12556, 17996, 22315, 23609, 25040, 26157, 30573, 32768,
2029 0 },
2030 { 11008, 13303, 15432, 20646, 23506, 24100, 25624, 26824, 28055, 32768,
2031 0 },
2032 { 9472, 12384, 14534, 17094, 20257, 22155, 24767, 28955, 30474, 32768,
2033 0 },
2034 { 7552, 14152, 17352, 22654, 25123, 25783, 27911, 29182, 30849, 32768,
2035 0 } },
2036 { { 8064, 11538, 21987, 24941, 26913, 28136, 29222, 30469, 31331, 32768,
2037 0 },
2038 { 5504, 10403, 25080, 26762, 27933, 29104, 30092, 31576, 32004, 32768,
2039 0 },
2040 { 5632, 8706, 15097, 23714, 25344, 26072, 27380, 28580, 29840, 32768,
2041 0 },
2042 { 7424, 11186, 17593, 20154, 22974, 24351, 26916, 29956, 30967, 32768,
2043 0 },
2044 { 5888, 10193, 16895, 19031, 23735, 25576, 27514, 29813, 30471, 32768,
2045 0 },
2046 { 4864, 8352, 16459, 18062, 21263, 25378, 26937, 30376, 31619, 32768,
2047 0 },
2048 { 4992, 7922, 13842, 18004, 21779, 23527, 25115, 27357, 30232, 32768,
2049 0 },
2050 { 6656, 9716, 16379, 20053, 22487, 23613, 25437, 27270, 28516, 32768,
2051 0 },
2052 { 6016, 9674, 16891, 18684, 21147, 23093, 25512, 30132, 30894, 32768,
2053 0 },
2054 { 4608, 11318, 21038, 23650, 25303, 26262, 28295, 30479, 31212, 32768,
2055 0 } },
2056 { { 10496, 12758, 14790, 24547, 26342, 26799, 27825, 28443, 30217, 32768,
2057 0 },
2058 { 7040, 11462, 17121, 24215, 26504, 27267, 28492, 29444, 30846, 32768,
2059 0 },
2060 { 5376, 8158, 9215, 26451, 27407, 27524, 27995, 28275, 29767, 32768,
2061 0 },
2062 { 8704, 12652, 14145, 20101, 22879, 23675, 25629, 27079, 28923, 32768,
2063 0 },
2064 { 7424, 12374, 14366, 18855, 23842, 24358, 25639, 27087, 29706, 32768,
2065 0 },
2066 { 6400, 10005, 12939, 17753, 22206, 24790, 26785, 28164, 30520, 32768,
2067 0 },
2068 { 5632, 8176, 9713, 19053, 22343, 23222, 24453, 25070, 29761, 32768,
2069 0 },
2070 { 7040, 9754, 10833, 21229, 23540, 23943, 24839, 25675, 27033, 32768,
2071 0 },
2072 { 6784, 11758, 13481, 17236, 20210, 21768, 24303, 26948, 28676, 32768,
2073 0 },
2074 { 4864, 12712, 14201, 23863, 25952, 26386, 27632, 28635, 30362, 32768,
2075 0 } },
2076 { { 13184, 15173, 17647, 21576, 24474, 25267, 27699, 29283, 30549, 32768,
2077 0 },
2078 { 7552, 11295, 18257, 20811, 23213, 24606, 27731, 30407, 31237, 32768,
2079 0 },
2080 { 7936, 10846, 12816, 22436, 24614, 25130, 26890, 28199, 29091, 32768,
2081 0 },
2082 { 8576, 11411, 13830, 15918, 18996, 20044, 25114, 27835, 28972, 32768,
2083 0 },
2084 { 7680, 10816, 13646, 15966, 21162, 22012, 24701, 27506, 29644, 32768,
2085 0 },
2086 { 6784, 9423, 12524, 14773, 19447, 22804, 26073, 29211, 30642, 32768,
2087 0 },
2088 { 6784, 8916, 11059, 15861, 21174, 22338, 24620, 27071, 30899, 32768,
2089 0 },
2090 { 9856, 11557, 13960, 18525, 21788, 22189, 24462, 26603, 27470, 32768,
2091 0 },
2092 { 7808, 10636, 13143, 15844, 18698, 20272, 24323, 30096, 31787, 32768,
2093 0 },
2094 { 6016, 10928, 14596, 18926, 21586, 22688, 26626, 29001, 30399, 32768,
2095 0 } },
2096 { { 8832, 10983, 13451, 16582, 21656, 23109, 24845, 26207, 28796, 32768,
2097 0 },
2098 { 6784, 10844, 15554, 18073, 22954, 24901, 26776, 28649, 30419, 32768,
2099 0 },
2100 { 5120, 8252, 10072, 20108, 23535, 24346, 25761, 26418, 28675, 32768,
2101 0 },
2102 { 7680, 11012, 12627, 14595, 19462, 20888, 23348, 25703, 28159, 32768,
2103 0 },
2104 { 6656, 9818, 11790, 13813, 22731, 24737, 26557, 28061, 29697, 32768,
2105 0 },
2106 { 5632, 8918, 11620, 13802, 19950, 23764, 25734, 28537, 31809, 32768,
2107 0 },
2108 { 4480, 6580, 7808, 12281, 19375, 20970, 22860, 24602, 29929, 32768,
2109 0 },
2110 { 7040, 9553, 11457, 15102, 20291, 21280, 22985, 24475, 26613, 32768,
2111 0 },
2112 { 6528, 10423, 12605, 14621, 19031, 21505, 24585, 27558, 29532, 32768,
2113 0 },
2114 { 6016, 11659, 14463, 18867, 23653, 24903, 27115, 29389, 31382, 32768,
2115 0 } },
2116 { { 8192, 10016, 13304, 16362, 21107, 25165, 26620, 28901, 30910, 32768,
2117 0 },
2118 { 5888, 8723, 16237, 18318, 22002, 25923, 27394, 29934, 31428, 32768,
2119 0 },
2120 { 4608, 7138, 9841, 18442, 22447, 24618, 26337, 27945, 30168, 32768,
2121 0 },
2122 { 6784, 8916, 12270, 14851, 19886, 22759, 25105, 28368, 29760, 32768,
2123 0 },
2124 { 5120, 7928, 11324, 13340, 21205, 24224, 25926, 28518, 30560, 32768,
2125 0 },
2126 { 4480, 6580, 10058, 11237, 16807, 25937, 27218, 30015, 31348, 32768,
2127 0 },
2128 { 4608, 6808, 9445, 12446, 18461, 21835, 23244, 26109, 30115, 32768,
2129 0 },
2130 { 5760, 7659, 10798, 14720, 19157, 21955, 23645, 26460, 28702, 32768,
2131 0 },
2132 { 5760, 8503, 11157, 13071, 17594, 22047, 24099, 29077, 30850, 32768,
2133 0 },
2134 { 4864, 9660, 14264, 17105, 21528, 24094, 26025, 28580, 30559, 32768,
2135 0 } },
2136 { { 9600, 11139, 12998, 18660, 22158, 23501, 24659, 25736, 30296, 32768,
2137 0 },
2138 { 7168, 11068, 15984, 19969, 23169, 24704, 26216, 27572, 31368, 32768,
2139 0 },
2140 { 4480, 6801, 8018, 20908, 23071, 23583, 24301, 25062, 29427, 32768,
2141 0 },
2142 { 7168, 10068, 11753, 15843, 19742, 21358, 23809, 26189, 29067, 32768,
2143 0 },
2144 { 6016, 9047, 10622, 13931, 22462, 23858, 25911, 27277, 29722, 32768,
2145 0 },
2146 { 5888, 7568, 9931, 13533, 18431, 22063, 23777, 26025, 30555, 32768,
2147 0 },
2148 { 4352, 6239, 7379, 13739, 16917, 18090, 18835, 19651, 30360, 32768,
2149 0 },
2150 { 6528, 8988, 10288, 15534, 19495, 20386, 21934, 23034, 26988, 32768,
2151 0 },
2152 { 7040, 10055, 11652, 14757, 19622, 21715, 23615, 26761, 29483, 32768,
2153 0 },
2154 { 4736, 10102, 12315, 19078, 21348, 22621, 24246, 26044, 29931, 32768,
2155 0 } },
2156 { { 10496, 12410, 14955, 19891, 23137, 23792, 25159, 26378, 28125, 32768,
2157 0 },
2158 { 7936, 12204, 17104, 20191, 23468, 24630, 26156, 27628, 28913, 32768,
2159 0 },
2160 { 6016, 8629, 10232, 23591, 25349, 25637, 26306, 27063, 28980, 32768,
2161 0 },
2162 { 8704, 12088, 13461, 16646, 20516, 21455, 24062, 26579, 28368, 32768,
2163 0 },
2164 { 7296, 11177, 13117, 16196, 23378, 24708, 26440, 27997, 29078, 32768,
2165 0 },
2166 { 6272, 9377, 12575, 15616, 20919, 23697, 26603, 27566, 29903, 32768,
2167 0 },
2168 { 6528, 9091, 10478, 16445, 21081, 22320, 23871, 25087, 29258, 32768,
2169 0 },
2170 { 8704, 11148, 12499, 17340, 20656, 21288, 22588, 23701, 24693, 32768,
2171 0 },
2172 { 7552, 11394, 12980, 15562, 19942, 21792, 25093, 28211, 28959, 32768,
2173 0 },
2174 { 5120, 11708, 13847, 19377, 22421, 23160, 25449, 27136, 29182, 32768,
2175 0 } },
2176 { { 9984, 12031, 15190, 18673, 21422, 22812, 25690, 29118, 30458, 32768,
2177 0 },
2178 { 6144, 9680, 17436, 19610, 21820, 23485, 26313, 30826, 31843, 32768,
2179 0 },
2180 { 6016, 8315, 10607, 19333, 21572, 22553, 25266, 27288, 28551, 32768,
2181 0 },
2182 { 7168, 9668, 12646, 16257, 19648, 20899, 25304, 30465, 31625, 32768,
2183 0 },
2184 { 6144, 9368, 11836, 14130, 19153, 21157, 24876, 28452, 29396, 32768,
2185 0 },
2186 { 5504, 8486, 11996, 14412, 17968, 21814, 24424, 30682, 32059, 32768,
2187 0 },
2188 { 5376, 7195, 9592, 13331, 17569, 19460, 22371, 25458, 28942, 32768,
2189 0 },
2190 { 7424, 9206, 11783, 16456, 19253, 20390, 23775, 27007, 28425, 32768,
2191 0 },
2192 { 5888, 8303, 11361, 13440, 15848, 17549, 21532, 29564, 30665, 32768,
2193 0 },
2194 { 4608, 8788, 13284, 16621, 18983, 20286, 24577, 28960, 30314, 32768,
2195 0 } },
2196 { { 8320, 15005, 19168, 24282, 26707, 27402, 28681, 29639, 30629, 32768,
2197 0 },
2198 { 5632, 13900, 22376, 24867, 26804, 27734, 29130, 30722, 31465, 32768,
2199 0 },
2200 { 4992, 9115, 11055, 24893, 26316, 26661, 27663, 28301, 29418, 32768,
2201 0 },
2202 { 7424, 12077, 14987, 19596, 22615, 23600, 26465, 28484, 29789, 32768,
2203 0 },
2204 { 6272, 11447, 14362, 18204, 23418, 24715, 26697, 28547, 29520, 32768,
2205 0 },
2206 { 5248, 10946, 15379, 18167, 22197, 25432, 27295, 30031, 30576, 32768,
2207 0 },
2208 { 5120, 9008, 11607, 18210, 22327, 23427, 24887, 26580, 29892, 32768,
2209 0 },
2210 { 6656, 10124, 12689, 19922, 22480, 22807, 24441, 25579, 26787, 32768,
2211 0 },
2212 { 5376, 10084, 13983, 17113, 19996, 21614, 24403, 28651, 29938, 32768,
2213 0 },
2214 { 5504, 14131, 17989, 23324, 25513, 26071, 27850, 29464, 30393, 32768,
2215 0 } },
2216#endif // CONFIG_ALT_INTRA
2217 };
Thomas Davies1d7db722017-02-22 11:15:00 +00002218#endif // CONFIG_EC_MULTISYMBOL
2219
Yaowu Xuc27fc142016-08-22 16:08:15 -07002220static void init_mode_probs(FRAME_CONTEXT *fc) {
Yaowu Xuf883b422016-08-30 14:01:10 -07002221 av1_copy(fc->uv_mode_prob, default_uv_probs);
2222 av1_copy(fc->y_mode_prob, default_if_y_probs);
2223 av1_copy(fc->switchable_interp_prob, default_switchable_interp_prob);
2224 av1_copy(fc->partition_prob, default_partition_probs);
2225 av1_copy(fc->intra_inter_prob, default_intra_inter_p);
2226 av1_copy(fc->comp_inter_prob, default_comp_inter_p);
2227 av1_copy(fc->comp_ref_prob, default_comp_ref_p);
Yaowu Xuc27fc142016-08-22 16:08:15 -07002228#if CONFIG_EXT_REFS
Yaowu Xuf883b422016-08-30 14:01:10 -07002229 av1_copy(fc->comp_bwdref_prob, default_comp_bwdref_p);
Yaowu Xuc27fc142016-08-22 16:08:15 -07002230#endif // CONFIG_EXT_REFS
Yaowu Xuf883b422016-08-30 14:01:10 -07002231 av1_copy(fc->single_ref_prob, default_single_ref_p);
2232 av1_copy(fc->tx_size_probs, default_tx_size_prob);
Yaowu Xuc27fc142016-08-22 16:08:15 -07002233#if CONFIG_VAR_TX
Yaowu Xuf883b422016-08-30 14:01:10 -07002234 av1_copy(fc->txfm_partition_prob, default_txfm_partition_probs);
Yaowu Xuc27fc142016-08-22 16:08:15 -07002235#endif
Yaowu Xuf883b422016-08-30 14:01:10 -07002236 av1_copy(fc->skip_probs, default_skip_probs);
Yaowu Xuc27fc142016-08-22 16:08:15 -07002237#if CONFIG_REF_MV
Yaowu Xuf883b422016-08-30 14:01:10 -07002238 av1_copy(fc->newmv_prob, default_newmv_prob);
2239 av1_copy(fc->zeromv_prob, default_zeromv_prob);
2240 av1_copy(fc->refmv_prob, default_refmv_prob);
2241 av1_copy(fc->drl_prob, default_drl_prob);
Yaowu Xuc27fc142016-08-22 16:08:15 -07002242#if CONFIG_EXT_INTER
2243 fc->new2mv_prob = default_new2mv_prob;
2244#endif // CONFIG_EXT_INTER
2245#endif // CONFIG_REF_MV
Yaowu Xuf883b422016-08-30 14:01:10 -07002246 av1_copy(fc->inter_mode_probs, default_inter_mode_probs);
Yue Chencb60b182016-10-13 15:18:22 -07002247#if CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
2248 av1_copy(fc->motion_mode_prob, default_motion_mode_prob);
Yue Chen69f18e12016-09-08 14:48:15 -07002249#if CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
2250 av1_copy(fc->obmc_prob, default_obmc_prob);
2251#endif // CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
Yue Chencb60b182016-10-13 15:18:22 -07002252#endif // CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
Yaowu Xuc27fc142016-08-22 16:08:15 -07002253#if CONFIG_EXT_INTER
Yaowu Xuf883b422016-08-30 14:01:10 -07002254 av1_copy(fc->inter_compound_mode_probs, default_inter_compound_mode_probs);
Sarah Parker6fddd182016-11-10 20:57:20 -08002255 av1_copy(fc->compound_type_prob, default_compound_type_probs);
Yaowu Xuf883b422016-08-30 14:01:10 -07002256 av1_copy(fc->interintra_prob, default_interintra_prob);
2257 av1_copy(fc->interintra_mode_prob, default_interintra_mode_prob);
2258 av1_copy(fc->wedge_interintra_prob, default_wedge_interintra_prob);
Yaowu Xuc27fc142016-08-22 16:08:15 -07002259#endif // CONFIG_EXT_INTER
2260#if CONFIG_SUPERTX
Yaowu Xuf883b422016-08-30 14:01:10 -07002261 av1_copy(fc->supertx_prob, default_supertx_prob);
Yaowu Xuc27fc142016-08-22 16:08:15 -07002262#endif // CONFIG_SUPERTX
Nathan E. Eggef627e582016-08-19 20:06:51 -04002263 av1_copy(fc->seg.tree_probs, default_segment_tree_probs);
2264 av1_copy(fc->seg.pred_probs, default_segment_pred_probs);
Yaowu Xuc27fc142016-08-22 16:08:15 -07002265#if CONFIG_EXT_INTRA
hui sueda3d762016-12-06 16:58:23 -08002266#if CONFIG_INTRA_INTERP
Yaowu Xuf883b422016-08-30 14:01:10 -07002267 av1_copy(fc->intra_filter_probs, default_intra_filter_probs);
hui sueda3d762016-12-06 16:58:23 -08002268#endif // CONFIG_INTRA_INTERP
Yaowu Xuc27fc142016-08-22 16:08:15 -07002269#endif // CONFIG_EXT_INTRA
hui su5db97432016-10-14 16:10:14 -07002270#if CONFIG_FILTER_INTRA
2271 av1_copy(fc->filter_intra_probs, default_filter_intra_probs);
2272#endif // CONFIG_FILTER_INTRA
Yaowu Xuf883b422016-08-30 14:01:10 -07002273 av1_copy(fc->inter_ext_tx_prob, default_inter_ext_tx_prob);
2274 av1_copy(fc->intra_ext_tx_prob, default_intra_ext_tx_prob);
Debargha Mukherjee5cd2ab92016-09-08 15:15:17 -07002275#if CONFIG_LOOP_RESTORATION
2276 av1_copy(fc->switchable_restore_prob, default_switchable_restore_prob);
2277#endif // CONFIG_LOOP_RESTORATION
Nathan E. Egge31296062016-11-16 09:44:26 -05002278#if CONFIG_EC_MULTISYMBOL
Thomas Davies1d7db722017-02-22 11:15:00 +00002279 av1_copy(fc->y_mode_cdf, default_if_y_mode_cdf);
2280 av1_copy(fc->uv_mode_cdf, default_uv_mode_cdf);
2281 av1_copy(fc->switchable_interp_cdf, default_switchable_interp_cdf);
2282 av1_copy(fc->partition_cdf, default_partition_cdf);
2283 av1_copy(fc->inter_mode_cdf, default_inter_mode_cdf);
Nathan E. Eggedfa33f22016-11-16 09:44:26 -05002284#if !CONFIG_EXT_TX
Thomas Davies1d7db722017-02-22 11:15:00 +00002285 av1_copy(fc->intra_ext_tx_cdf, default_intra_ext_tx_cdf);
2286 av1_copy(fc->inter_ext_tx_cdf, default_inter_ext_tx_cdf);
Nathan E. Eggedfa33f22016-11-16 09:44:26 -05002287#endif
Thomas Davies1d7db722017-02-22 11:15:00 +00002288 av1_copy(fc->seg.tree_cdf, default_seg_tree_cdf);
2289 av1_copy(fc->tx_size_cdf, default_tx_size_cdf);
Nathan E. Egge4947c292016-04-26 11:37:06 -04002290#endif
Thomas Daviesf6936102016-09-05 16:51:31 +01002291#if CONFIG_DELTA_Q
2292 av1_copy(fc->delta_q_prob, default_delta_q_probs);
Thomas Daviesd6ee8a82017-03-02 14:42:50 +00002293#if CONFIG_EC_MULTISYMBOL
2294 av1_copy(fc->delta_q_cdf, default_delta_q_cdf);
2295#endif
Thomas Daviesf6936102016-09-05 16:51:31 +01002296#endif
Yaowu Xuc27fc142016-08-22 16:08:15 -07002297}
2298
Nathan E. Egge00b33312016-11-16 09:44:26 -05002299#if CONFIG_EC_MULTISYMBOL
Nathan E. Egge4947c292016-04-26 11:37:06 -04002300int av1_switchable_interp_ind[SWITCHABLE_FILTERS];
2301int av1_switchable_interp_inv[SWITCHABLE_FILTERS];
Thomas Davies6519beb2016-10-19 14:46:07 +01002302
Thomas Davies028b57f2017-02-22 16:42:11 +00002303#if !CONFIG_EC_ADAPT
Thomas Davies6519beb2016-10-19 14:46:07 +01002304void av1_set_mode_cdfs(struct AV1Common *cm) {
2305 FRAME_CONTEXT *fc = cm->fc;
2306 int i, j;
2307 if (cm->seg.enabled && cm->seg.update_map) {
2308 av1_tree_to_cdf(av1_segment_tree, cm->fc->seg.tree_probs,
2309 cm->fc->seg.tree_cdf);
2310 }
Thomas Davies6519beb2016-10-19 14:46:07 +01002311
Nathan E. Eggedd28aed2016-11-16 09:44:26 -05002312 for (i = 0; i < INTRA_MODES; ++i)
2313 av1_tree_to_cdf(av1_intra_mode_tree, fc->uv_mode_prob[i],
2314 fc->uv_mode_cdf[i]);
Thomas Davies028b57f2017-02-22 16:42:11 +00002315#if CONFIG_EXT_PARTITION_TYPES
Alex Converse57795a42017-03-14 12:18:25 -07002316 for (i = 0; i < PARTITION_PLOFFSET; ++i)
2317 av1_tree_to_cdf(av1_partition_tree, fc->partition_prob[i],
2318 fc->partition_cdf[i]);
2319 // Logical index (enum value) to inorder index (tree_to_cdf order)
2320 aom_cdf_prob inorder_partition_cdf[CDF_SIZE(EXT_PARTITION_TYPES)] = {};
2321 // TODO(aconverse): Generate this dynamically. The assumptions that
2322 // av1_indices_from_tree() makes don't hold for this tree.
2323 static const uint8_t av1_ext_partition_index_map[EXT_PARTITION_TYPES] = {
2324 0, 1, 4, 7, 2, 3, 5, 6,
2325 };
2326 for (; i < PARTITION_CONTEXTS; ++i) {
2327 av1_tree_to_cdf(av1_ext_partition_tree, fc->partition_prob[i],
2328 inorder_partition_cdf);
2329 aom_cdf_prob cum_prob = 0;
2330 for (j = 0; j < EXT_PARTITION_TYPES; ++j) {
2331 int inorder_idx = av1_ext_partition_index_map[j];
2332 aom_cdf_prob prob =
2333 inorder_partition_cdf[inorder_idx] -
2334 (inorder_idx > 0 ? inorder_partition_cdf[inorder_idx - 1] : 0);
2335 fc->partition_cdf[i][j] = (cum_prob += prob);
2336 }
2337 assert(cum_prob == CDF_PROB_TOP);
2338 }
Thomas Davies028b57f2017-02-22 16:42:11 +00002339#else
Thomas Davies6519beb2016-10-19 14:46:07 +01002340 for (i = 0; i < PARTITION_CONTEXTS; ++i)
2341 av1_tree_to_cdf(av1_partition_tree, fc->partition_prob[i],
2342 fc->partition_cdf[i]);
Thomas Davies028b57f2017-02-22 16:42:11 +00002343#endif
Nathan E. Eggedfa33f22016-11-16 09:44:26 -05002344
Nathan E. Egge10ba2be2016-11-16 09:44:26 -05002345 for (i = 0; i < INTRA_MODES; ++i)
2346 for (j = 0; j < INTRA_MODES; ++j)
2347 av1_tree_to_cdf(av1_intra_mode_tree, cm->kf_y_prob[i][j],
Thomas Davies1bfb5ed2017-01-11 15:28:11 +00002348 cm->fc->kf_y_cdf[i][j]);
Nathan E. Egge10ba2be2016-11-16 09:44:26 -05002349
Nathan E. Egge00b33312016-11-16 09:44:26 -05002350 for (j = 0; j < SWITCHABLE_FILTER_CONTEXTS; ++j)
2351 av1_tree_to_cdf(av1_switchable_interp_tree, fc->switchable_interp_prob[j],
2352 fc->switchable_interp_cdf[j]);
2353
Nathan E. Eggea59b23d2016-11-16 09:44:26 -05002354 for (i = 0; i < INTER_MODE_CONTEXTS; ++i)
2355 av1_tree_to_cdf(av1_inter_mode_tree, fc->inter_mode_probs[i],
2356 fc->inter_mode_cdf[i]);
2357
Nathan E. Eggeecc21ec2016-11-16 09:44:26 -05002358 for (i = 0; i < BLOCK_SIZE_GROUPS; ++i)
2359 av1_tree_to_cdf(av1_intra_mode_tree, fc->y_mode_prob[i], fc->y_mode_cdf[i]);
2360
Nathan E. Eggedfa33f22016-11-16 09:44:26 -05002361#if !CONFIG_EXT_TX
2362 for (i = TX_4X4; i < EXT_TX_SIZES; ++i)
Nathan E. Egge29ccee02016-11-16 09:44:26 -05002363 for (j = 0; j < TX_TYPES; ++j)
2364 av1_tree_to_cdf(av1_ext_tx_tree, fc->intra_ext_tx_prob[i][j],
2365 fc->intra_ext_tx_cdf[i][j]);
2366
2367 for (i = TX_4X4; i < EXT_TX_SIZES; ++i)
Nathan E. Eggedfa33f22016-11-16 09:44:26 -05002368 av1_tree_to_cdf(av1_ext_tx_tree, fc->inter_ext_tx_prob[i],
2369 fc->inter_ext_tx_cdf[i]);
2370#endif
Nathan E. Egge2ea519e2017-02-16 18:18:15 -05002371 for (i = 0; i < MAX_TX_DEPTH; i++) {
2372 for (j = 0; j < TX_SIZE_CONTEXTS; j++) {
2373 av1_tree_to_cdf(av1_tx_size_tree[i], fc->tx_size_probs[i][j],
2374 fc->tx_size_cdf[i][j]);
2375 }
2376 }
Thomas Davies6519beb2016-10-19 14:46:07 +01002377}
Thomas Davies028b57f2017-02-22 16:42:11 +00002378#endif // !CONFIG_EC_ADAPT
Nathan E. Egge4947c292016-04-26 11:37:06 -04002379#endif
2380
Angie Chiang1733f6b2017-01-05 09:52:20 -08002381#if CONFIG_DUAL_FILTER
Yaowu Xuf883b422016-08-30 14:01:10 -07002382const aom_tree_index av1_switchable_interp_tree[TREE_SIZE(SWITCHABLE_FILTERS)] =
2383 {
Angie Chiangd91ab372016-11-21 18:16:49 -08002384 -EIGHTTAP_REGULAR, 2, 4, -MULTITAP_SHARP, -EIGHTTAP_SMOOTH,
Yaowu Xuc27fc142016-08-22 16:08:15 -07002385 -EIGHTTAP_SMOOTH2,
Yaowu Xuc27fc142016-08-22 16:08:15 -07002386 };
2387#else
Yaowu Xuf883b422016-08-30 14:01:10 -07002388const aom_tree_index av1_switchable_interp_tree[TREE_SIZE(SWITCHABLE_FILTERS)] =
2389 { -EIGHTTAP_REGULAR, 2, -EIGHTTAP_SMOOTH, -MULTITAP_SHARP };
Angie Chiang1733f6b2017-01-05 09:52:20 -08002390#endif // CONFIG_DUAL_FILTER
Yaowu Xuc27fc142016-08-22 16:08:15 -07002391
Yaowu Xuf883b422016-08-30 14:01:10 -07002392void av1_adapt_inter_frame_probs(AV1_COMMON *cm) {
Yaowu Xuc27fc142016-08-22 16:08:15 -07002393 int i, j;
2394 FRAME_CONTEXT *fc = cm->fc;
2395 const FRAME_CONTEXT *pre_fc = &cm->frame_contexts[cm->frame_context_idx];
2396 const FRAME_COUNTS *counts = &cm->counts;
2397
2398 for (i = 0; i < INTRA_INTER_CONTEXTS; i++)
Yaowu Xuf883b422016-08-30 14:01:10 -07002399 fc->intra_inter_prob[i] = av1_mode_mv_merge_probs(
Yaowu Xuc27fc142016-08-22 16:08:15 -07002400 pre_fc->intra_inter_prob[i], counts->intra_inter[i]);
2401 for (i = 0; i < COMP_INTER_CONTEXTS; i++)
Yaowu Xuf883b422016-08-30 14:01:10 -07002402 fc->comp_inter_prob[i] = av1_mode_mv_merge_probs(pre_fc->comp_inter_prob[i],
2403 counts->comp_inter[i]);
Yaowu Xuc27fc142016-08-22 16:08:15 -07002404
2405#if CONFIG_EXT_REFS
2406 for (i = 0; i < REF_CONTEXTS; i++)
2407 for (j = 0; j < (FWD_REFS - 1); j++)
2408 fc->comp_ref_prob[i][j] = mode_mv_merge_probs(pre_fc->comp_ref_prob[i][j],
2409 counts->comp_ref[i][j]);
2410 for (i = 0; i < REF_CONTEXTS; i++)
2411 for (j = 0; j < (BWD_REFS - 1); j++)
2412 fc->comp_bwdref_prob[i][j] = mode_mv_merge_probs(
2413 pre_fc->comp_bwdref_prob[i][j], counts->comp_bwdref[i][j]);
2414#else
2415 for (i = 0; i < REF_CONTEXTS; i++)
2416 for (j = 0; j < (COMP_REFS - 1); j++)
2417 fc->comp_ref_prob[i][j] = mode_mv_merge_probs(pre_fc->comp_ref_prob[i][j],
2418 counts->comp_ref[i][j]);
2419#endif // CONFIG_EXT_REFS
2420
2421 for (i = 0; i < REF_CONTEXTS; i++)
2422 for (j = 0; j < (SINGLE_REFS - 1); j++)
Yaowu Xuf883b422016-08-30 14:01:10 -07002423 fc->single_ref_prob[i][j] = av1_mode_mv_merge_probs(
Yaowu Xuc27fc142016-08-22 16:08:15 -07002424 pre_fc->single_ref_prob[i][j], counts->single_ref[i][j]);
2425
2426#if CONFIG_REF_MV
2427 for (i = 0; i < NEWMV_MODE_CONTEXTS; ++i)
2428 fc->newmv_prob[i] =
Yaowu Xuf883b422016-08-30 14:01:10 -07002429 av1_mode_mv_merge_probs(pre_fc->newmv_prob[i], counts->newmv_mode[i]);
Yaowu Xuc27fc142016-08-22 16:08:15 -07002430 for (i = 0; i < ZEROMV_MODE_CONTEXTS; ++i)
Yaowu Xuf883b422016-08-30 14:01:10 -07002431 fc->zeromv_prob[i] =
2432 av1_mode_mv_merge_probs(pre_fc->zeromv_prob[i], counts->zeromv_mode[i]);
Yaowu Xuc27fc142016-08-22 16:08:15 -07002433 for (i = 0; i < REFMV_MODE_CONTEXTS; ++i)
2434 fc->refmv_prob[i] =
Yaowu Xuf883b422016-08-30 14:01:10 -07002435 av1_mode_mv_merge_probs(pre_fc->refmv_prob[i], counts->refmv_mode[i]);
Yaowu Xuc27fc142016-08-22 16:08:15 -07002436
2437 for (i = 0; i < DRL_MODE_CONTEXTS; ++i)
2438 fc->drl_prob[i] =
Yaowu Xuf883b422016-08-30 14:01:10 -07002439 av1_mode_mv_merge_probs(pre_fc->drl_prob[i], counts->drl_mode[i]);
Yaowu Xuc27fc142016-08-22 16:08:15 -07002440#if CONFIG_EXT_INTER
2441 fc->new2mv_prob =
Yaowu Xuf883b422016-08-30 14:01:10 -07002442 av1_mode_mv_merge_probs(pre_fc->new2mv_prob, counts->new2mv_mode);
Yaowu Xuc27fc142016-08-22 16:08:15 -07002443#endif // CONFIG_EXT_INTER
2444#else
2445 for (i = 0; i < INTER_MODE_CONTEXTS; i++)
Yaowu Xuf883b422016-08-30 14:01:10 -07002446 aom_tree_merge_probs(av1_inter_mode_tree, pre_fc->inter_mode_probs[i],
Yaowu Xuc27fc142016-08-22 16:08:15 -07002447 counts->inter_mode[i], fc->inter_mode_probs[i]);
2448#endif
2449
Yue Chencb60b182016-10-13 15:18:22 -07002450#if CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
Yaowu Xuc27fc142016-08-22 16:08:15 -07002451 for (i = BLOCK_8X8; i < BLOCK_SIZES; ++i)
Yue Chencb60b182016-10-13 15:18:22 -07002452 aom_tree_merge_probs(av1_motion_mode_tree, pre_fc->motion_mode_prob[i],
2453 counts->motion_mode[i], fc->motion_mode_prob[i]);
Yue Chen69f18e12016-09-08 14:48:15 -07002454#if CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
2455 for (i = BLOCK_8X8; i < BLOCK_SIZES; ++i)
2456 fc->obmc_prob[i] =
2457 av1_mode_mv_merge_probs(pre_fc->obmc_prob[i], counts->obmc[i]);
2458#endif // CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
Yue Chencb60b182016-10-13 15:18:22 -07002459#endif // CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
Yaowu Xuc27fc142016-08-22 16:08:15 -07002460
2461#if CONFIG_SUPERTX
2462 for (i = 0; i < PARTITION_SUPERTX_CONTEXTS; ++i) {
Jingning Han93531242016-12-20 11:54:36 -08002463 for (j = TX_8X8; j < TX_SIZES; ++j) {
Yaowu Xuf883b422016-08-30 14:01:10 -07002464 fc->supertx_prob[i][j] = av1_mode_mv_merge_probs(
Yaowu Xuc27fc142016-08-22 16:08:15 -07002465 pre_fc->supertx_prob[i][j], counts->supertx[i][j]);
2466 }
2467 }
2468#endif // CONFIG_SUPERTX
2469
2470#if CONFIG_EXT_INTER
2471 for (i = 0; i < INTER_MODE_CONTEXTS; i++)
Yaowu Xuf883b422016-08-30 14:01:10 -07002472 aom_tree_merge_probs(
2473 av1_inter_compound_mode_tree, pre_fc->inter_compound_mode_probs[i],
Yaowu Xuc27fc142016-08-22 16:08:15 -07002474 counts->inter_compound_mode[i], fc->inter_compound_mode_probs[i]);
2475 for (i = 0; i < BLOCK_SIZE_GROUPS; ++i) {
2476 if (is_interintra_allowed_bsize_group(i))
Yaowu Xuf883b422016-08-30 14:01:10 -07002477 fc->interintra_prob[i] = av1_mode_mv_merge_probs(
Yaowu Xuc27fc142016-08-22 16:08:15 -07002478 pre_fc->interintra_prob[i], counts->interintra[i]);
2479 }
2480 for (i = 0; i < BLOCK_SIZE_GROUPS; i++) {
Yaowu Xuf883b422016-08-30 14:01:10 -07002481 aom_tree_merge_probs(
2482 av1_interintra_mode_tree, pre_fc->interintra_mode_prob[i],
Yaowu Xuc27fc142016-08-22 16:08:15 -07002483 counts->interintra_mode[i], fc->interintra_mode_prob[i]);
2484 }
2485 for (i = 0; i < BLOCK_SIZES; ++i) {
2486 if (is_interintra_allowed_bsize(i) && is_interintra_wedge_used(i))
Yaowu Xuf883b422016-08-30 14:01:10 -07002487 fc->wedge_interintra_prob[i] = av1_mode_mv_merge_probs(
Yaowu Xuc27fc142016-08-22 16:08:15 -07002488 pre_fc->wedge_interintra_prob[i], counts->wedge_interintra[i]);
2489 }
Sarah Parker6fddd182016-11-10 20:57:20 -08002490
Yaowu Xuc27fc142016-08-22 16:08:15 -07002491 for (i = 0; i < BLOCK_SIZES; ++i) {
Sarah Parker6fdc8532016-11-16 17:47:13 -08002492 aom_tree_merge_probs(av1_compound_type_tree, pre_fc->compound_type_prob[i],
2493 counts->compound_interinter[i],
2494 fc->compound_type_prob[i]);
Yaowu Xuc27fc142016-08-22 16:08:15 -07002495 }
2496#endif // CONFIG_EXT_INTER
2497
2498 for (i = 0; i < BLOCK_SIZE_GROUPS; i++)
Yaowu Xuf883b422016-08-30 14:01:10 -07002499 aom_tree_merge_probs(av1_intra_mode_tree, pre_fc->y_mode_prob[i],
Yaowu Xuc27fc142016-08-22 16:08:15 -07002500 counts->y_mode[i], fc->y_mode_prob[i]);
2501
2502 if (cm->interp_filter == SWITCHABLE) {
2503 for (i = 0; i < SWITCHABLE_FILTER_CONTEXTS; i++)
Yaowu Xuf883b422016-08-30 14:01:10 -07002504 aom_tree_merge_probs(
2505 av1_switchable_interp_tree, pre_fc->switchable_interp_prob[i],
Yaowu Xuc27fc142016-08-22 16:08:15 -07002506 counts->switchable_interp[i], fc->switchable_interp_prob[i]);
2507 }
2508}
2509
Yaowu Xuf883b422016-08-30 14:01:10 -07002510void av1_adapt_intra_frame_probs(AV1_COMMON *cm) {
Yaowu Xuc27fc142016-08-22 16:08:15 -07002511 int i, j;
2512 FRAME_CONTEXT *fc = cm->fc;
2513 const FRAME_CONTEXT *pre_fc = &cm->frame_contexts[cm->frame_context_idx];
2514 const FRAME_COUNTS *counts = &cm->counts;
2515
2516 if (cm->tx_mode == TX_MODE_SELECT) {
Jingning Hanaae72a62016-10-25 15:35:29 -07002517 for (i = 0; i < MAX_TX_DEPTH; ++i) {
Yaowu Xuc27fc142016-08-22 16:08:15 -07002518 for (j = 0; j < TX_SIZE_CONTEXTS; ++j)
Yaowu Xuf883b422016-08-30 14:01:10 -07002519 aom_tree_merge_probs(av1_tx_size_tree[i], pre_fc->tx_size_probs[i][j],
Yaowu Xuc27fc142016-08-22 16:08:15 -07002520 counts->tx_size[i][j], fc->tx_size_probs[i][j]);
2521 }
2522 }
2523
2524#if CONFIG_VAR_TX
Yue Chena1e48dc2016-08-29 17:29:33 -07002525 if (cm->tx_mode == TX_MODE_SELECT) {
Yaowu Xuc27fc142016-08-22 16:08:15 -07002526 for (i = 0; i < TXFM_PARTITION_CONTEXTS; ++i)
Yaowu Xuf883b422016-08-30 14:01:10 -07002527 fc->txfm_partition_prob[i] = av1_mode_mv_merge_probs(
Yaowu Xuc27fc142016-08-22 16:08:15 -07002528 pre_fc->txfm_partition_prob[i], counts->txfm_partition[i]);
Yue Chena1e48dc2016-08-29 17:29:33 -07002529 }
Yaowu Xuc27fc142016-08-22 16:08:15 -07002530#endif
2531
2532 for (i = 0; i < SKIP_CONTEXTS; ++i)
2533 fc->skip_probs[i] =
Yaowu Xuf883b422016-08-30 14:01:10 -07002534 av1_mode_mv_merge_probs(pre_fc->skip_probs[i], counts->skip[i]);
Yaowu Xuc27fc142016-08-22 16:08:15 -07002535
2536#if CONFIG_EXT_TX
2537 for (i = TX_4X4; i < EXT_TX_SIZES; ++i) {
2538 int s;
2539 for (s = 1; s < EXT_TX_SETS_INTER; ++s) {
2540 if (use_inter_ext_tx_for_txsize[s][i]) {
Yaowu Xuf883b422016-08-30 14:01:10 -07002541 aom_tree_merge_probs(
2542 av1_ext_tx_inter_tree[s], pre_fc->inter_ext_tx_prob[s][i],
Yaowu Xuc27fc142016-08-22 16:08:15 -07002543 counts->inter_ext_tx[s][i], fc->inter_ext_tx_prob[s][i]);
2544 }
2545 }
2546 for (s = 1; s < EXT_TX_SETS_INTRA; ++s) {
2547 if (use_intra_ext_tx_for_txsize[s][i]) {
Yaowu Xuc27fc142016-08-22 16:08:15 -07002548 for (j = 0; j < INTRA_MODES; ++j)
Yaowu Xuf883b422016-08-30 14:01:10 -07002549 aom_tree_merge_probs(
2550 av1_ext_tx_intra_tree[s], pre_fc->intra_ext_tx_prob[s][i][j],
Yaowu Xuc27fc142016-08-22 16:08:15 -07002551 counts->intra_ext_tx[s][i][j], fc->intra_ext_tx_prob[s][i][j]);
2552 }
2553 }
2554 }
2555#else
2556 for (i = TX_4X4; i < EXT_TX_SIZES; ++i) {
Nathan E. Egge7c5b4c12016-04-26 12:31:14 -04002557 for (j = 0; j < TX_TYPES; ++j) {
Yaowu Xuf883b422016-08-30 14:01:10 -07002558 aom_tree_merge_probs(av1_ext_tx_tree, pre_fc->intra_ext_tx_prob[i][j],
Yaowu Xuc27fc142016-08-22 16:08:15 -07002559 counts->intra_ext_tx[i][j],
2560 fc->intra_ext_tx_prob[i][j]);
Nathan E. Egge7c5b4c12016-04-26 12:31:14 -04002561 }
Yaowu Xuc27fc142016-08-22 16:08:15 -07002562 }
2563 for (i = TX_4X4; i < EXT_TX_SIZES; ++i) {
Yaowu Xuf883b422016-08-30 14:01:10 -07002564 aom_tree_merge_probs(av1_ext_tx_tree, pre_fc->inter_ext_tx_prob[i],
Yaowu Xuc27fc142016-08-22 16:08:15 -07002565 counts->inter_ext_tx[i], fc->inter_ext_tx_prob[i]);
2566 }
2567#endif // CONFIG_EXT_TX
2568
2569 if (cm->seg.temporal_update) {
2570 for (i = 0; i < PREDICTION_PROBS; i++)
Yaowu Xuf883b422016-08-30 14:01:10 -07002571 fc->seg.pred_probs[i] = av1_mode_mv_merge_probs(pre_fc->seg.pred_probs[i],
2572 counts->seg.pred[i]);
Yaowu Xuc27fc142016-08-22 16:08:15 -07002573
Yaowu Xuf883b422016-08-30 14:01:10 -07002574 aom_tree_merge_probs(av1_segment_tree, pre_fc->seg.tree_probs,
Yaowu Xuc27fc142016-08-22 16:08:15 -07002575 counts->seg.tree_mispred, fc->seg.tree_probs);
2576 } else {
Yaowu Xuf883b422016-08-30 14:01:10 -07002577 aom_tree_merge_probs(av1_segment_tree, pre_fc->seg.tree_probs,
Yaowu Xuc27fc142016-08-22 16:08:15 -07002578 counts->seg.tree_total, fc->seg.tree_probs);
2579 }
2580
2581 for (i = 0; i < INTRA_MODES; ++i)
Yaowu Xuf883b422016-08-30 14:01:10 -07002582 aom_tree_merge_probs(av1_intra_mode_tree, pre_fc->uv_mode_prob[i],
Yaowu Xuc27fc142016-08-22 16:08:15 -07002583 counts->uv_mode[i], fc->uv_mode_prob[i]);
2584
2585#if CONFIG_EXT_PARTITION_TYPES
Alex Converse4e18d402017-03-14 15:36:38 -07002586 for (i = 0; i < PARTITION_PLOFFSET; ++i)
2587 aom_tree_merge_probs(av1_partition_tree, pre_fc->partition_prob[i],
2588 counts->partition[i], fc->partition_prob[i]);
2589 for (; i < PARTITION_CONTEXTS_PRIMARY; ++i)
Yaowu Xuf883b422016-08-30 14:01:10 -07002590 aom_tree_merge_probs(av1_ext_partition_tree, pre_fc->partition_prob[i],
Yaowu Xuc27fc142016-08-22 16:08:15 -07002591 counts->partition[i], fc->partition_prob[i]);
2592#else
Alex Converse4e18d402017-03-14 15:36:38 -07002593 for (i = 0; i < PARTITION_CONTEXTS_PRIMARY; ++i) {
Yaowu Xuf883b422016-08-30 14:01:10 -07002594 aom_tree_merge_probs(av1_partition_tree, pre_fc->partition_prob[i],
Yaowu Xuc27fc142016-08-22 16:08:15 -07002595 counts->partition[i], fc->partition_prob[i]);
Nathan E. Eggefba2be62016-05-03 09:48:54 -04002596 }
Yaowu Xuc27fc142016-08-22 16:08:15 -07002597#endif // CONFIG_EXT_PARTITION_TYPES
Alex Converse55c6bde2017-01-12 15:55:31 -08002598#if CONFIG_UNPOISON_PARTITION_CTX
2599 for (i = PARTITION_CONTEXTS_PRIMARY;
2600 i < PARTITION_CONTEXTS_PRIMARY + PARTITION_BLOCK_SIZES; ++i) {
2601 unsigned int ct[2] = { counts->partition[i][PARTITION_VERT],
2602 counts->partition[i][PARTITION_SPLIT] };
2603 assert(counts->partition[i][PARTITION_NONE] == 0);
2604 assert(counts->partition[i][PARTITION_HORZ] == 0);
2605 assert(fc->partition_prob[i][PARTITION_NONE] == 0);
2606 assert(fc->partition_prob[i][PARTITION_HORZ] == 0);
2607 fc->partition_prob[i][PARTITION_VERT] =
2608 av1_mode_mv_merge_probs(pre_fc->partition_prob[i][PARTITION_VERT], ct);
2609 }
2610 for (i = PARTITION_CONTEXTS_PRIMARY + PARTITION_BLOCK_SIZES;
2611 i < PARTITION_CONTEXTS_PRIMARY + 2 * PARTITION_BLOCK_SIZES; ++i) {
2612 unsigned int ct[2] = { counts->partition[i][PARTITION_HORZ],
2613 counts->partition[i][PARTITION_SPLIT] };
2614 assert(counts->partition[i][PARTITION_NONE] == 0);
2615 assert(counts->partition[i][PARTITION_VERT] == 0);
2616 assert(fc->partition_prob[i][PARTITION_NONE] == 0);
2617 assert(fc->partition_prob[i][PARTITION_VERT] == 0);
2618 fc->partition_prob[i][PARTITION_HORZ] =
2619 av1_mode_mv_merge_probs(pre_fc->partition_prob[i][PARTITION_HORZ], ct);
2620 }
2621#endif
Thomas Daviesf6936102016-09-05 16:51:31 +01002622#if CONFIG_DELTA_Q
Thomas Davies665cd702017-03-02 10:20:30 +00002623 for (i = 0; i < DELTA_Q_PROBS; ++i)
Thomas Daviesf6936102016-09-05 16:51:31 +01002624 fc->delta_q_prob[i] =
2625 mode_mv_merge_probs(pre_fc->delta_q_prob[i], counts->delta_q[i]);
2626#endif
Yaowu Xuc27fc142016-08-22 16:08:15 -07002627#if CONFIG_EXT_INTRA
hui sueda3d762016-12-06 16:58:23 -08002628#if CONFIG_INTRA_INTERP
hui su5db97432016-10-14 16:10:14 -07002629 for (i = 0; i < INTRA_FILTERS + 1; ++i) {
Yaowu Xuf883b422016-08-30 14:01:10 -07002630 aom_tree_merge_probs(av1_intra_filter_tree, pre_fc->intra_filter_probs[i],
Yaowu Xuc27fc142016-08-22 16:08:15 -07002631 counts->intra_filter[i], fc->intra_filter_probs[i]);
hui su5db97432016-10-14 16:10:14 -07002632 }
hui sueda3d762016-12-06 16:58:23 -08002633#endif // CONFIG_INTRA_INTERP
Yaowu Xuc27fc142016-08-22 16:08:15 -07002634#endif // CONFIG_EXT_INTRA
hui su5db97432016-10-14 16:10:14 -07002635#if CONFIG_FILTER_INTRA
2636 for (i = 0; i < PLANE_TYPES; ++i) {
2637 fc->filter_intra_probs[i] = av1_mode_mv_merge_probs(
2638 pre_fc->filter_intra_probs[i], counts->filter_intra[i]);
2639 }
2640#endif // CONFIG_FILTER_INTRA
Yaowu Xuc27fc142016-08-22 16:08:15 -07002641}
2642
2643static void set_default_lf_deltas(struct loopfilter *lf) {
2644 lf->mode_ref_delta_enabled = 1;
2645 lf->mode_ref_delta_update = 1;
2646
2647 lf->ref_deltas[INTRA_FRAME] = 1;
2648 lf->ref_deltas[LAST_FRAME] = 0;
2649#if CONFIG_EXT_REFS
2650 lf->ref_deltas[LAST2_FRAME] = lf->ref_deltas[LAST_FRAME];
2651 lf->ref_deltas[LAST3_FRAME] = lf->ref_deltas[LAST_FRAME];
2652 lf->ref_deltas[BWDREF_FRAME] = lf->ref_deltas[LAST_FRAME];
2653#endif // CONFIG_EXT_REFS
2654 lf->ref_deltas[GOLDEN_FRAME] = -1;
2655 lf->ref_deltas[ALTREF_FRAME] = -1;
2656
2657 lf->mode_deltas[0] = 0;
2658 lf->mode_deltas[1] = 0;
2659}
2660
Yaowu Xuf883b422016-08-30 14:01:10 -07002661void av1_setup_past_independence(AV1_COMMON *cm) {
Yaowu Xuc27fc142016-08-22 16:08:15 -07002662 // Reset the segment feature data to the default stats:
2663 // Features disabled, 0, with delta coding (Default state).
2664 struct loopfilter *const lf = &cm->lf;
2665
2666 int i;
Yaowu Xuf883b422016-08-30 14:01:10 -07002667 av1_clearall_segfeatures(&cm->seg);
Yaowu Xuc27fc142016-08-22 16:08:15 -07002668 cm->seg.abs_delta = SEGMENT_DELTADATA;
2669
2670 if (cm->last_frame_seg_map && !cm->frame_parallel_decode)
2671 memset(cm->last_frame_seg_map, 0, (cm->mi_rows * cm->mi_cols));
2672
2673 if (cm->current_frame_seg_map)
2674 memset(cm->current_frame_seg_map, 0, (cm->mi_rows * cm->mi_cols));
2675
2676 // Reset the mode ref deltas for loop filter
Yaowu Xuf883b422016-08-30 14:01:10 -07002677 av1_zero(lf->last_ref_deltas);
2678 av1_zero(lf->last_mode_deltas);
Yaowu Xuc27fc142016-08-22 16:08:15 -07002679 set_default_lf_deltas(lf);
2680
2681 // To force update of the sharpness
2682 lf->last_sharpness_level = -1;
Yaowu Xuc27fc142016-08-22 16:08:15 -07002683
Yaowu Xuf883b422016-08-30 14:01:10 -07002684 av1_default_coef_probs(cm);
Yaowu Xuc27fc142016-08-22 16:08:15 -07002685 init_mode_probs(cm->fc);
Yaowu Xuf883b422016-08-30 14:01:10 -07002686 av1_init_mv_probs(cm);
Angie Chianged8cd9a2016-10-21 16:44:47 -07002687#if CONFIG_ADAPT_SCAN
2688 av1_init_scan_order(cm);
2689#endif
Angie Chiang0a2c0cb2017-02-23 14:19:15 -08002690 av1_convolve_init(cm);
Yaowu Xuc27fc142016-08-22 16:08:15 -07002691 cm->fc->initialized = 1;
2692
2693 if (cm->frame_type == KEY_FRAME || cm->error_resilient_mode ||
2694 cm->reset_frame_context == RESET_FRAME_CONTEXT_ALL) {
2695 // Reset all frame contexts.
2696 for (i = 0; i < FRAME_CONTEXTS; ++i) cm->frame_contexts[i] = *cm->fc;
2697 } else if (cm->reset_frame_context == RESET_FRAME_CONTEXT_CURRENT) {
2698 // Reset only the frame context specified in the frame header.
2699 cm->frame_contexts[cm->frame_context_idx] = *cm->fc;
2700 }
2701
2702 // prev_mip will only be allocated in encoder.
2703 if (frame_is_intra_only(cm) && cm->prev_mip && !cm->frame_parallel_decode)
2704 memset(cm->prev_mip, 0,
2705 cm->mi_stride * (cm->mi_rows + 1) * sizeof(*cm->prev_mip));
2706
2707 cm->frame_context_idx = 0;
2708}