1 /*
2 * Copyright (c) 2020-2023, Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included
12 * in all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 */
22 //!
23 //! \file encode_avc_vdenc_const_settings.cpp
24 //! \brief Defines the common interface for avc vdenc const settings
25 //! \details The encode feature manager is further sub-divided by platform type
26 //! this file is for the base interface which is shared by all components.
27 //!
28
29 #include "encode_avc_vdenc_const_settings.h"
30 #include "encode_utils.h"
31 #include "mos_utilities.h"
32 #include "codec_def_encode.h"
33
34 namespace encode
35 {
36
37 const uint8_t AvcVdencCMD3ConstSettings::AvcVdencCMD3ConstSettings_0[8][52] = {
38 {
39 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
40 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
41 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
42 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
43 },
44 {
45 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
46 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
47 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
48 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
49 },
50 {
51 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
52 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
53 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
54 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
55 },
56 {
57 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
58 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
59 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
60 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
61 },
62 {
63 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
64 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
65 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
66 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
67 },
68 {
69 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
70 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
71 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
72 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
73 },
74 {
75 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
76 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
77 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
78 26, 26, 26, 26, 26, 31, 31, 31, 31, 31, 31, 31, 31,
79 },
80 {
81 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
82 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
83 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
84 26, 26, 26, 31, 42, 45, 45, 45, 45, 45, 45, 45, 45,
85 }
86 };
87
88 const uint8_t AvcVdencCMD3ConstSettings::AvcVdencCMD3ConstSettings_1[3][12] =
89 {
90 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
91 {4, 12, 20, 28, 36, 44, 52, 60, 68, 76, 84, 92},
92 {0, 8, 8, 24, 40, 48, 56, 64, 72, 88, 104, 120},
93 };
94
95 const uint8_t AvcVdencCMD3ConstSettings::AvcVdencCMD3ConstSettings_2[3][13] =
96 {
97 {12, 28, 24, 72, 0, 0, 0, 0, 0, 0, 4, 0, 0},
98 {12, 32, 40, 88, 16, 10, 18, 8, 0, 4, 4, 0, 0},
99 {12, 40, 56, 104, 32, 22, 33, 16, 4, 4, 4, 0, 8},
100 };
101
102 const uint8_t AvcVdencCMD3ConstSettings::AvcVdencCMD3ConstSettings_3[3][52] =
103 {
104 {
105 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
106 32, 36, 44, 48, 26, 30, 32, 36, 26, 30, 30, 24, 28,
107 24, 24, 20, 20, 22, 20, 20, 20, 18, 18, 16, 16, 16,
108 16, 16, 16, 16, 16, 16, 16, 16, 14, 14, 14, 14, 14,
109 },
110 {
111 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
112 14, 16, 18, 20, 10, 12, 14, 16, 12, 14, 14, 14, 14,
113 12, 14, 14, 12, 14, 14, 14, 14, 14, 14, 14, 14, 14,
114 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
115 },
116 {
117 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
118 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
119 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
120 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
121 }
122 };
123
124 const uint8_t AvcVdencCMD3ConstSettings::AvcVdencCMD3ConstSettings_4[52] =
125 {
126 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
127 47, 56, 57, 59, 44, 45, 47, 56, 44, 47, 47, 45, 47,
128 47, 47, 47, 45, 47, 47, 56, 47, 47, 47, 47, 47, 47,
129 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
130 };
131
132 const uint16_t AvcVdencCMD3ConstSettings::AvcVdencCMD3ConstSettings_5[4][2][40] =
133 {
134 {
135 {
136 2, 3, 4, 5, 6, 8, 10, 13, 16, 20,
137 26, 33, 41, 52, 66, 83, 104, 132, 166, 209,
138 264, 332, 419, 528, 665, 838, 1056, 1331, 1677, 2113,
139 2662, 3354, 4226, 5324, 6708, 8452, 10649, 13417, 16905, 21299,
140 },
141 {
142 2, 3, 4, 5, 6, 8, 10, 13, 16, 20,
143 26, 33, 41, 52, 66, 83, 104, 132, 166, 209,
144 264, 332, 419, 528, 665, 838, 1056, 1331, 1677, 2113,
145 2662, 3354, 4226, 5324, 6708, 8452, 10649, 13417, 16905, 21299,
146 },
147 },
148 {
149 {
150 2, 2, 3, 4, 5, 6, 8, 10, 12, 16,
151 20, 25, 32, 40, 50, 64, 80, 101, 128, 161,
152 203, 256, 322, 406, 512, 645, 812, 1024, 1290, 1625,
153 2048, 2580, 3250, 4096, 5160, 6501, 8192, 10321, 13003, 16384,
154 },
155 {
156 3, 4, 5, 6, 8, 10, 12, 16, 20, 25,
157 32, 40, 51, 64, 81, 102, 129, 162, 204, 258,
158 325, 409, 516, 650, 819, 1032, 1300, 1638, 2064, 2600,
159 3276, 4128, 5201, 6553, 8257, 10403, 13107, 16514, 20806, 26214,
160 },
161 },
162 {
163 {
164 4, 6, 7, 9, 12, 15, 19, 24, 30, 38,
165 48, 60, 76, 96, 121, 153, 193, 243, 307, 387,
166 487, 614, 774, 975, 1228, 1548, 1950, 2457, 3096, 3901,
167 4915, 6192, 7802, 9830, 12385, 15604, 19660, 24771, 31209, 39321,
168 },
169 {
170 4, 6, 7, 9, 12, 15, 19, 24, 30, 38,
171 48, 60, 76, 96, 121, 153, 193, 243, 307, 387,
172 487, 614, 774, 975, 1228, 1548, 1950, 2457, 3096, 3901,
173 4915, 6192, 7802, 9830, 12385, 15604, 19660, 24771, 31209, 39321,
174 },
175 },
176 {
177 {
178 3, 4, 5, 7, 9, 11, 14, 18, 22, 28,
179 36, 45, 57, 72, 91, 115, 145, 182, 230, 290,
180 365, 460, 580, 731, 921, 1161, 1462, 1843, 2322, 2925,
181 3686, 4644, 5851, 7372, 9289, 11703, 14745, 18578, 23407, 29491,
182 },
183 {
184 3, 4, 5, 7, 9, 11, 14, 18, 22, 28,
185 36, 45, 57, 72, 91, 115, 145, 182, 230, 290,
186 365, 460, 580, 731, 921, 1161, 1462, 1843, 2322, 2925,
187 3686, 4644, 5851, 7372, 9289, 11703, 14745, 18578, 23407, 29491,
188 },
189 }
190 };
191
192 const uint16_t AvcVdencCMD3ConstSettings::AvcVdencCMD3ConstSettings_6[4][2][40] =
193 {
194 {
195 {
196 2, 2, 3, 3, 4, 4, 5, 5, 6, 7,
197 8, 9, 10, 11, 13, 14, 16, 18, 20, 23,
198 26, 29, 33, 37, 41, 46, 52, 58, 66, 74,
199 83, 93, 104, 117, 132, 148, 166, 186, 209, 235,
200 },
201 {
202 2, 2, 3, 3, 4, 4, 5, 5, 6, 7,
203 8, 9, 10, 11, 13, 14, 16, 18, 20, 23,
204 26, 29, 33, 37, 41, 46, 52, 58, 66, 74,
205 83, 93, 104, 117, 132, 148, 166, 186, 209, 235,
206 },
207 },
208 {
209 {
210 3, 3, 3, 4, 4, 5, 6, 6, 7, 8,
211 9, 10, 12, 13, 15, 16, 19, 21, 24, 26,
212 30, 33, 38, 42, 48, 53, 60, 67, 76, 85,
213 96, 107, 120, 135, 152, 171, 192, 215, 241, 271,
214 },
215 {
216 3, 4, 4, 5, 5, 6, 7, 8, 9, 10,
217 11, 12, 14, 16, 18, 20, 22, 25, 28, 32,
218 36, 40, 45, 51, 57, 64, 72, 81, 91, 102,
219 115, 129, 145, 162, 182, 205, 230, 258, 290, 325,
220 },
221 },
222 {
223 {
224 4, 4, 5, 6, 6, 7, 8, 9, 11, 12,
225 13, 15, 17, 19, 22, 24, 27, 31, 35, 39,
226 44, 49, 55, 62, 70, 79, 88, 99, 111, 125,
227 140, 158, 177, 199, 223, 250, 281, 316, 354, 398,
228 },
229 {
230 4, 4, 5, 6, 6, 7, 8, 9, 11, 12,
231 13, 15, 17, 19, 22, 24, 27, 31, 35, 39,
232 44, 49, 55, 62, 70, 79, 88, 99, 111, 125,
233 140, 158, 177, 199, 223, 250, 281, 316, 354, 398,
234 },
235 },
236 {
237 {
238 3, 4, 4, 5, 5, 6, 7, 8, 9, 10,
239 11, 12, 14, 16, 18, 20, 22, 25, 28, 32,
240 36, 40, 45, 51, 57, 64, 72, 81, 91, 102,
241 115, 129, 145, 162, 182, 205, 230, 258, 290, 325,
242 },
243 {
244 3, 4, 4, 5, 5, 6, 7, 8, 9, 10,
245 11, 12, 14, 16, 18, 20, 22, 25, 28, 32,
246 36, 40, 45, 51, 57, 64, 72, 81, 91, 102,
247 115, 129, 145, 162, 182, 205, 230, 258, 290, 325,
248 },
249 }
250 };
251
252 const uint16_t AvcVdencCMD3ConstSettings::par31Table[2][3][2][52] =
253 {
254 {
255 {
256 {
257 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
258 3, 4, 5, 6, 8, 10, 13, 16, 20, 26, 33, 41, 52,
259 66, 83, 104, 132, 166, 209, 264, 332, 419, 528, 665, 838, 1056,
260 1331, 1677, 2113, 2662, 3354, 4226, 5324, 6708, 8452, 10649, 13417, 16905, 21299,
261 },
262 {
263 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
264 3, 4, 5, 6, 8, 10, 13, 16, 20, 26, 33, 41, 52,
265 66, 83, 104, 132, 166, 209, 264, 332, 419, 528, 665, 838, 1056,
266 1331, 1677, 2113, 2662, 3354, 4226, 5324, 6708, 8452, 10649, 13417, 16905, 21299,
267 },
268 },
269 {
270 {
271 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
272 2, 3, 4, 5, 6, 8, 10, 12, 16, 20, 25, 32, 40,
273 50, 64, 80, 101, 128, 161, 203, 256, 322, 406, 512, 645, 812,
274 1024, 1290, 1625, 2048, 2580, 3250, 4096, 5160, 6501, 8192, 10321, 13003, 16384,
275 },
276 {
277 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
278 2, 3, 4, 5, 6, 8, 10, 12, 16, 20, 25, 32, 40,
279 50, 64, 80, 101, 128, 161, 203, 256, 322, 406, 512, 645, 812,
280 1024, 1290, 1625, 2048, 2580, 3250, 4096, 5160, 6501, 8192, 10321, 13003, 16384,
281 },
282 },
283 {
284 {
285 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
286 6, 7, 9, 12, 15, 19, 24, 30, 38, 48, 60, 76, 96,
287 121, 153, 193, 243, 307, 387, 487, 614, 774, 975, 1228, 1548, 1950,
288 2457, 3096, 3901, 4915, 6192, 7802, 9830, 12385, 15604, 19660, 24771, 31209, 39321,
289 },
290 {
291 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
292 4, 5, 7, 9, 11, 14, 18, 22, 28, 36, 45, 57, 72,
293 91, 115, 145, 182, 230, 290, 365, 460, 580, 731, 921, 1161, 1462,
294 1843, 2322, 2925, 3686, 4644, 5851, 7372, 9289, 11703, 14745, 18578, 23407, 29491,
295 },
296 },
297 },
298 {
299 {
300 {
301 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
302 3, 4, 5, 6, 8, 10, 13, 16, 20, 26, 33, 41, 52,
303 66, 83, 104, 132, 166, 209, 264, 332, 419, 528, 665, 838, 1056,
304 1331, 1677, 2113, 2662, 3354, 4226, 5324, 6708, 8452, 10649, 13417, 16905, 21299,
305 },
306 {
307 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
308 3, 4, 5, 6, 8, 10, 13, 16, 20, 26, 33, 41, 52,
309 66, 83, 104, 132, 166, 209, 264, 332, 419, 528, 665, 838, 1056,
310 1331, 1677, 2113, 2662, 3354, 4226, 5324, 6708, 8452, 10649, 13417, 16905, 21299,
311 },
312 },
313 {
314 {
315 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
316 4, 5, 6, 8, 10, 12, 16, 20, 25, 32, 40, 51, 64,
317 81, 102, 129, 162, 204, 258, 325, 409, 516, 650, 819, 1032, 1300,
318 1638, 2064, 2600, 3276, 4128, 5201, 6553, 8257, 10403, 13107, 16514, 20806, 26214,
319 },
320 {
321 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
322 4, 5, 6, 8, 10, 12, 16, 20, 25, 32, 40, 51, 64,
323 81, 102, 129, 162, 204, 258, 325, 409, 516, 650, 819, 1032, 1300,
324 1638, 2064, 2600, 3276, 4128, 5201, 6553, 8257, 10403, 13107, 16514, 20806, 26214,
325 },
326 },
327 {
328 {
329 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
330 6, 7, 9, 12, 15, 19, 24, 30, 38, 48, 60, 76, 96,
331 121, 153, 193, 243, 307, 387, 487, 614, 774, 975, 1228, 1548, 1950,
332 2457, 3096, 3901, 4915, 6192, 7802, 9830, 12385, 15604, 19660, 24771, 31209, 39321,
333 },
334 {
335 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
336 4, 5, 7, 9, 11, 14, 18, 22, 28, 36, 45, 57, 72,
337 91, 115, 145, 182, 230, 290, 365, 460, 580, 731, 921, 1161, 1462,
338 1843, 2322, 2925, 3686, 4644, 5851, 7372, 9289, 11703, 14745, 18578, 23407, 29491,
339 },
340 },
341 }
342 };
343
344 const uint16_t AvcVdencCMD3ConstSettings::par32Table[2][3][2][52] =
345 {
346 {
347 {
348 {
349 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
350 2, 3, 3, 4, 4, 5, 5, 6, 7, 8, 9, 10, 11,
351 13, 14, 16, 18, 20, 23, 26, 29, 33, 37, 41, 46, 52,
352 58, 66, 74, 83, 93, 104, 117, 132, 148, 166, 186, 209, 235,
353 },
354 {
355 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
356 2, 3, 3, 4, 4, 5, 5, 6, 7, 8, 9, 10, 11,
357 13, 14, 16, 18, 20, 23, 26, 29, 33, 37, 41, 46, 52,
358 58, 66, 74, 83, 93, 104, 117, 132, 148, 166, 186, 209, 235,
359 },
360 },
361 {
362 {
363 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
364 3, 3, 4, 4, 5, 6, 6, 7, 8, 9, 10, 12, 13,
365 15, 16, 19, 21, 24, 26, 30, 33, 38, 42, 48, 53, 60,
366 67, 76, 85, 96, 107, 120, 135, 152, 171, 192, 215, 241, 271,
367 },
368 {
369 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
370 3, 3, 4, 4, 5, 6, 6, 7, 8, 9, 10, 12, 13,
371 15, 16, 19, 21, 24, 26, 30, 33, 38, 42, 48, 53, 60,
372 67, 76, 85, 96, 107, 120, 135, 152, 171, 192, 215, 241, 271,
373 },
374 },
375 {
376 {
377 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
378 4, 5, 6, 6, 7, 8, 9, 11, 12, 13, 15, 17, 19,
379 22, 24, 27, 31, 35, 39, 44, 49, 55, 62, 70, 79, 88,
380 99, 111, 125, 140, 158, 177, 199, 223, 250, 281, 316, 354, 398,
381 },
382 {
383 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
384 4, 4, 5, 5, 6, 7, 8, 9, 10, 11, 12, 14, 16,
385 18, 20, 22, 25, 28, 32, 36, 40, 45, 51, 57, 64, 72,
386 81, 91, 102, 115, 129, 145, 162, 182, 205, 230, 258, 290, 325,
387 },
388 },
389 },
390 {
391 {
392 {
393 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
394 2, 3, 3, 4, 4, 5, 5, 6, 7, 8, 9, 10, 11,
395 13, 14, 16, 18, 20, 23, 26, 29, 33, 37, 41, 46, 52,
396 58, 66, 74, 83, 93, 104, 117, 132, 148, 166, 186, 209, 235,
397 },
398 {
399 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
400 2, 3, 3, 4, 4, 5, 5, 6, 7, 8, 9, 10, 11,
401 13, 14, 16, 18, 20, 23, 26, 29, 33, 37, 41, 46, 52,
402 58, 66, 74, 83, 93, 104, 117, 132, 148, 166, 186, 209, 235,
403 },
404 },
405 {
406 {
407 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
408 4, 4, 5, 5, 6, 7, 8, 9, 10, 11, 12, 14, 16,
409 18, 20, 22, 25, 28, 32, 36, 40, 45, 51, 57, 64, 72,
410 81, 91, 102, 115, 129, 145, 162, 182, 205, 230, 258, 290, 325,
411 },
412 {
413 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
414 4, 4, 5, 5, 6, 7, 8, 9, 10, 11, 12, 14, 16,
415 18, 20, 22, 25, 28, 32, 36, 40, 45, 51, 57, 64, 72,
416 81, 91, 102, 115, 129, 145, 162, 182, 205, 230, 258, 290, 325,
417 },
418 },
419 {
420 {
421 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
422 4, 5, 6, 6, 7, 8, 9, 11, 12, 13, 15, 17, 19,
423 22, 24, 27, 31, 35, 39, 44, 49, 55, 62, 70, 79, 88,
424 99, 111, 125, 140, 158, 177, 199, 223, 250, 281, 316, 354, 398,
425 },
426 {
427 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
428 4, 4, 5, 5, 6, 7, 8, 9, 10, 11, 12, 14, 16,
429 18, 20, 22, 25, 28, 32, 36, 40, 45, 51, 57, 64, 72,
430 81, 91, 102, 115, 129, 145, 162, 182, 205, 230, 258, 290, 325,
431 },
432 },
433 }
434 };
435
436 const bool EncodeAvcVdencConstSettings::m_perfModeEnabled[NUM_VDENC_TARGET_USAGE_MODES] =
437 {
438 0, 0, 0, 0, 0, 0, 1, 1
439 };
440
441 const uint8_t EncodeAvcVdencConstSettings::adaptiveRoundingIntra_P_G1[CODEC_AVC_NUM_QP] =
442 {
443 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, //QP=[0~12]
444 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, //QP=[13~25]
445 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, //QP=[26~38]
446 2, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0 //QP=[39~51]
447 };
448
449 const uint8_t EncodeAvcVdencConstSettings::adaptiveRoundingIntra_P[CODEC_AVC_NUM_QP] =
450 {
451 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, //QP=[0~12]
452 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, //QP=[13~25]
453 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, //QP=[26~38]
454 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 //QP=[39~51]
455 };
456
457 const uint8_t EncodeAvcVdencConstSettings::adaptiveRoundingIntra_BR[CODEC_AVC_NUM_QP] =
458 {
459 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, //QP=[0~12]
460 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, //QP=[13~25]
461 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, //QP=[26~38]
462 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 //QP=[39~51]
463 };
464
465 const uint8_t EncodeAvcVdencConstSettings::adaptiveRoundingIntra_B[CODEC_AVC_NUM_QP] =
466 {
467 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, //QP=[0~12]
468 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, //QP=[13~25]
469 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, //QP=[26~38]
470 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 //QP=[39~51]
471 };
472
473 const uint8_t EncodeAvcVdencConstSettings::adaptiveRoundingInter_P_G1[CODEC_AVC_NUM_QP] =
474 {
475 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, //QP=[0~12]
476 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, //QP=[13~25]
477 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, //QP=[26~38]
478 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 //QP=[39~51]
479 };
480
481 const uint8_t EncodeAvcVdencConstSettings::adaptiveRoundingInter_P[CODEC_AVC_NUM_QP] =
482 {
483 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, //QP=[0~12]
484 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, //QP=[13~25]
485 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, //QP=[26~38]
486 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2 //QP=[39~51]
487 };
488
489 const uint8_t EncodeAvcVdencConstSettings::adaptiveRoundingInter_BR[CODEC_AVC_NUM_QP] =
490 {
491 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, //QP=[0~12]
492 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, //QP=[13~25]
493 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, //QP=[26~38]
494 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0 //QP=[39~51]
495 };
496
497 const uint8_t EncodeAvcVdencConstSettings::adaptiveRoundingInter_B[CODEC_AVC_NUM_QP] =
498 {
499 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, //QP=[0~12]
500 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, //QP=[13~25]
501 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //QP=[26~38]
502 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 //QP=[39~51]
503 };
504
505 const uint16_t EncodeAvcVdencConstSettings::m_SliceSizeThrsholdsP[52] = // slice size threshold delta for P frame targeted for 99% compliance
506 {
507 850, 850, 850, 850, 850, 850, 850, 850, 850, 850, //[ 0- 9]
508 525, 525, 325, 325, 325, 325, 325, 325, 325, 325, //[10-19]
509 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, //[20-29]
510 250, 250, 250, 250, 250, 125, 125, 125, 125, 125, //[30-39]
511 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, //[40-49]
512 125, 125 //[50-51]
513 };
514
515 const uint16_t EncodeAvcVdencConstSettings::m_SliceSizeThrsholdsI[52] = // slice size threshold delta for I frame targeted for 99% compliance
516 {
517 850, 850, 850, 850, 850, 850, 850, 850, 850, 850, //[ 0- 9]
518 525, 525, 325, 325, 325, 325, 325, 325, 325, 325, //[10-19]
519 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, //[20-29]
520 250, 250, 250, 250, 250, 125, 125, 125, 125, 125, //[30-39]
521 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, //[40-49]
522 125, 125 //[50-51]
523 };
524
525 const uint32_t EncodeAvcVdencConstSettings::m_trellisQuantizationRounding[NUM_VDENC_TARGET_USAGE_MODES] =
526 {
527 0, 3, 3, 3, 3, 3, 3, 3
528 };
529
530 const bool EncodeAvcVdencConstSettings::m_trellisQuantizationEnable[NUM_VDENC_TARGET_USAGE_MODES] =
531 {
532 0, 1, 1, 0, 0, 0, 0, 0
533 };
534
535 const uint8_t EncodeAvcVdencConstSettings::m_columnScan4x4[16] =
536 {
537 0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15
538 };
539
540 const uint8_t EncodeAvcVdencConstSettings::m_columnScan8x8[64] =
541 {
542 0, 8, 16, 24, 32, 40, 48, 56, 1, 9, 17, 25, 33, 41, 49, 57,
543 2, 10, 18, 26, 34, 42, 50, 58, 3, 11, 19, 27, 35, 43, 51, 59,
544 4, 12, 20, 28, 36, 44, 52, 60, 5, 13, 21, 29, 37, 45, 53, 61,
545 6, 14, 22, 30, 38, 46, 54, 62, 7, 15, 23, 31, 39, 47, 55, 63
546 };
547
548 /* real thresholds are computed as multiplication on -50 and casting to int */
549 const double AvcVdencBrcConstSettings::m_BRC_DevThreshI0_FP_NEG[m_numDevThreshlds / 2] = {0.80, 0.60, 0.34, 0.2};
550
551 /* real thresholds are computed as multiplication on 50 and casting to int */
552 const double AvcVdencBrcConstSettings::m_BRC_DevThreshI0_FP_POS[m_numDevThreshlds / 2] = {0.2, 0.4, 0.66, 0.9};
553
554 /* real thresholds are computed as multiplication on 50 and casting to int */
555 const double AvcVdencBrcConstSettings::m_BRC_DevThreshPB0_FP_NEG[m_numDevThreshlds / 2] = {0.90, 0.66, 0.46, 0.3};
556
557 /* real thresholds are computed as multiplication on 50 and casting to int */
558 const double AvcVdencBrcConstSettings::m_BRC_DevThreshPB0_FP_POS[m_numDevThreshlds / 2] = {0.3, 0.46, 0.70, 0.90};
559
560 /* real negative thresholds are computed as multiplication on -50 and casting to int */
561 const double AvcVdencBrcConstSettings::m_BRC_DevThreshVBR0_NEG[m_numDevThreshlds / 2] = {0.90, 0.70, 0.50, 0.3};
562
563 /* positive thresholds are computed as multiplication on 100 and casting to int */
564 const double AvcVdencBrcConstSettings::m_BRC_DevThreshVBR0_POS[m_numDevThreshlds / 2] = {0.4, 0.5, 0.75, 0.90};
565
566 const int8_t AvcVdencBrcConstSettings::m_BRC_LowDelay_DevThreshPB0_S8[8] = {-45, -33, -23, -15, -8, 0, 15, 25};
567 const int8_t AvcVdencBrcConstSettings::m_BRC_LowDelay_DevThreshI0_S8[8] = {-40, -30, -17, -10, -5, 0, 10, 20};
568 const int8_t AvcVdencBrcConstSettings::m_BRC_LowDelay_DevThreshVBR0_S8[8] = {-45, -35, -25, -15, -8, 0, 20, 40};
569 const int8_t AvcVdencBrcConstSettings::m_BRC_INIT_DistQPDelta_I8[4] = {-5, -2, 2, 5};
570 const uint8_t AvcVdencBrcConstSettings::m_BRC_EstRateThreshP0_U8[7] = {4, 8, 12, 16, 20, 24, 28};
571 const uint8_t AvcVdencBrcConstSettings::m_BRC_EstRateThreshI0_U8[7] = {4, 8, 12, 16, 20, 24, 28};
572 const int8_t AvcVdencBrcConstSettings::m_brcInitDistQpDeltaI8[4] = {0, 0, 0, 0};
573 const int8_t AvcVdencBrcConstSettings::m_brcInitDistQpDeltaI8LowDelay[4] ={-5, -2, 2, 5};
574
575 const uint16_t AvcVdencBrcConstSettings::m_BRC_UPD_start_global_adjust_frame[4] = {10, 50, 100, 150};
576 const uint8_t AvcVdencBrcConstSettings::m_BRC_UPD_global_rate_ratio_threshold[7] = {80, 90, 95, 101, 105, 115, 130};
577 const uint8_t AvcVdencBrcConstSettings::m_BRC_UPD_slwin_global_rate_ratio_threshold[7] = {80, 90, 95, 101, 105, 110, 120};
578 const uint8_t AvcVdencBrcConstSettings::m_BRC_UPD_start_global_adjust_mult[5] = {1, 1, 3, 2, 1};
579 const uint8_t AvcVdencBrcConstSettings::m_BRC_UPD_start_global_adjust_div[5] = {40, 5, 5, 3, 1};
580 const int8_t AvcVdencBrcConstSettings::m_BRC_UPD_global_rate_ratio_threshold_qp[8] = {-3, -2, -1, 0, 1, 1, 2, 3};
581
582 const int8_t AvcVdencBrcConstSettings::m_BRC_UPD_GlobalRateQPAdjTabI_U8[64] =
583 {
584 48, 40, 32, 24, 16, 8, 0, -8,
585 40, 32, 24, 16, 8, 0, -8, -16,
586 32, 24, 16, 8, 0, -8, -16, -24,
587 24, 16, 8, 0, -8, -16, -24, -32,
588 16, 8, 0, -8, -16, -24, -32, -40,
589 8, 0, -8, -16, -24, -32, -40, -48,
590 0, -8, -16, -24, -32, -40, -48, -56,
591 48, 40, 32, 24, 16, 8, 0, -8,
592 };
593
594 const int8_t AvcVdencBrcConstSettings::m_BRC_UPD_GlobalRateQPAdjTabP_U8[64] =
595 {
596 48, 40, 32, 24, 16, 8, 0, -8,
597 40, 32, 24, 16, 8, 0, -8, -16,
598 16, 8, 8, 4, -8, -16, -16, -24,
599 8, 0, 0, -8, -16, -16, -16, -24,
600 8, 0, 0, -24, -32, -32, -32, -48,
601 0, -16, -16, -24, -32, -48, -56, -64,
602 -8, -16, -32, -32, -48, -48, -56, -64,
603 -16, -32, -48, -48, -48, -56, -64, -80,
604 };
605
606 // P picture global rate QP Adjustment table for sliding window BRC
607 const int8_t AvcVdencBrcConstSettings::m_BRC_UPD_SlWinGlobalRateQPAdjTabP_U8[64] =
608 {
609 48, 40, 32, 24, 16, 8, 0, -8,
610 40, 32, 24, 16, 8, 0, -8, -16,
611 16, 8, 8, 4, -8, -16, -16, -24,
612 8, 0, 0, -8, -16, -16, -16, -24,
613 8, 0, 0, -24, -32, -32, -32, -48,
614 0, -16, -24, -32, -40, -56, -64, -72,
615 -8, -16, -32, -40, -48, -56, -64, -64,
616 -16, -32, -48, -48, -48, -56, -64, -80,
617 };
618
619 const int8_t AvcVdencBrcConstSettings::m_BRC_UPD_GlobalRateQPAdjTabB_U8[64] =
620 {
621 48, 40, 32, 24, 16, 8, 0, -8,
622 40, 32, 24, 16, 8, 0, -8, -16,
623 32, 24, 16, 8, 0, -8, -16, -24,
624 24, 16, 8, 0, -8, -8, -16, -24,
625 16, 8, 0, 0, -8, -16, -24, -32,
626 16, 8, 0, 0, -8, -16, -24, -32,
627 0, -8, -8, -16, -32, -48, -56, -64,
628 0, -8, -8, -16, -32, -48, -56, -64,
629 };
630
631 const uint8_t AvcVdencBrcConstSettings::m_BRC_UPD_DistThreshldI_U8[10] = {2, 4, 8, 12, 19, 32, 64, 128, 0, 0};
632 const uint8_t AvcVdencBrcConstSettings::m_BRC_UPD_DistThreshldP_U8[10] = {2, 4, 8, 12, 19, 32, 64, 128, 0, 0};
633 const uint8_t AvcVdencBrcConstSettings::m_BRC_UPD_DistThreshldB_U8[10] = {2, 4, 8, 12, 19, 32, 64, 128, 0, 0};
634
635 const int8_t AvcVdencBrcConstSettings::m_CBR_UPD_DistQPAdjTabI_U8[81] =
636 {
637 0, 0, 0, 0, 0, 3, 4, 6, 8,
638 0, 0, 0, 0, 0, 2, 3, 5, 7,
639 -1, 0, 0, 0, 0, 2, 2, 4, 5,
640 -1,-1, 0, 0, 0, 1, 2, 2, 4,
641 -2,-2,-1, 0, 0, 0, 1, 2, 4,
642 -2,-2,-1, 0, 0, 0, 1, 2, 4,
643 -3,-2,-1,-1, 0, 0, 1, 2, 5,
644 -3,-2,-1,-1, 0, 0, 2, 4, 7,
645 -4,-3,-2,-1, 0, 1, 3, 5, 8,
646 };
647
648 const int8_t AvcVdencBrcConstSettings::m_CBR_UPD_DistQPAdjTabP_U8[81] =
649 {
650 -1, 0, 0, 0, 0, 1, 1, 2, 3,
651 -1,-1, 0, 0, 0, 1, 1, 2, 3,
652 -2,-1,-1, 0, 0, 1, 1, 2, 3,
653 -3,-2,-2,-1, 0, 0, 1, 2, 3,
654 -3,-2,-1,-1, 0, 0, 1, 2, 3,
655 -3,-2,-1,-1, 0, 0, 1, 2, 3,
656 -3,-2,-1,-1, 0, 0, 1, 2, 3,
657 -3,-2,-1,-1, 0, 0, 1, 2, 3,
658 -3,-2,-1,-1, 0, 0, 1, 2, 3,
659 };
660
661 const int8_t AvcVdencBrcConstSettings::m_CBR_UPD_DistQPAdjTabB_U8[81] =
662 {
663 0, 0, 0, 0, 0, 2, 3, 3, 4,
664 0, 0, 0, 0, 0, 2, 3, 3, 4,
665 -1, 0, 0, 0, 0, 2, 2, 3, 3,
666 -1,-1, 0, 0, 0, 1, 2, 2, 2,
667 -1,-1,-1, 0, 0, 0, 1, 2, 2,
668 -2,-1,-1, 0, 0, 0, 0, 1, 2,
669 -2,-1,-1,-1, 0, 0, 0, 1, 3,
670 -2,-2,-1,-1, 0, 0, 1, 1, 3,
671 -2,-2,-1,-1, 0, 1, 1, 2, 4,
672 };
673
674 const int8_t AvcVdencBrcConstSettings::m_VBR_UPD_DistQPAdjTabI_U8[81] =
675 {
676 0, 0, 0, 0, 0, 3, 4, 6, 8,
677 0, 0, 0, 0, 0, 2, 3, 5, 7,
678 -1, 0, 0, 0, 0, 2, 2, 4, 5,
679 -1,-1, 0, 0, 0, 1, 2, 2, 4,
680 -2,-2,-1, 0, 0, 0, 1, 2, 4,
681 -2,-2,-1, 0, 0, 0, 1, 2, 4,
682 -3,-2,-1,-1, 0, 0, 1, 2, 5,
683 -3,-2,-1,-1, 0, 0, 2, 4, 7,
684 -4,-3,-2,-1, 0, 1, 3, 5, 8,
685 };
686
687 const int8_t AvcVdencBrcConstSettings::m_VBR_UPD_DistQPAdjTabP_U8[81] =
688 {
689 -1, 0, 0, 0, 0, 1, 1, 2, 3,
690 -1,-1, 0, 0, 0, 1, 1, 2, 3,
691 -2,-1,-1, 0, 0, 1, 1, 2, 3,
692 -3,-2,-2,-1, 0, 0, 1, 2, 3,
693 -3,-2,-1,-1, 0, 0, 1, 2, 3,
694 -3,-2,-1,-1, 0, 0, 1, 2, 3,
695 -3,-2,-1,-1, 0, 0, 1, 2, 3,
696 -3,-2,-1,-1, 0, 0, 1, 2, 3,
697 -3,-2,-1,-1, 0, 0, 1, 2, 3,
698 };
699
700 const int8_t AvcVdencBrcConstSettings::m_VBR_UPD_DistQPAdjTabB_U8[81] =
701 {
702 0, 0, 0, 0, 0, 2, 3, 3, 4,
703 0, 0, 0, 0, 0, 2, 3, 3, 4,
704 -1, 0, 0, 0, 0, 2, 2, 3, 3,
705 -1,-1, 0, 0, 0, 1, 2, 2, 2,
706 -1,-1,-1, 0, 0, 0, 1, 2, 2,
707 -2,-1,-1, 0, 0, 0, 0, 1, 2,
708 -2,-1,-1,-1, 0, 0, 0, 1, 3,
709 -2,-2,-1,-1, 0, 0, 1, 1, 3,
710 -2,-2,-1,-1, 0, 1, 1, 2, 4,
711 };
712
713 const int8_t AvcVdencBrcConstSettings::m_CBR_UPD_FrmSzAdjTabI_S8[72] =
714 {
715 -4, -20, -28, -36, -40, -44, -48, -80,
716 0, -8, -12, -20, -24, -28, -32, -36,
717 0, 0, -8, -16, -20, -24, -28, -32,
718 8, 4, 0, 0, -8, -16, -24, -28,
719 32, 24, 16, 2, -4, -8, -16, -20,
720 36, 32, 28, 16, 8, 0, -4, -8,
721 40, 36, 24, 20, 16, 8, 0, -8,
722 48, 40, 28, 24, 20, 12, 0, -4,
723 64, 48, 28, 20, 16, 12, 8, 4,
724 };
725
726 const int8_t AvcVdencBrcConstSettings::m_CBR_UPD_FrmSzAdjTabP_S8[72] =
727 {
728 -8, -24, -32, -44, -48, -56, -64, -80,
729 -8, -16, -32, -40, -44, -52, -56, -64,
730 0, 0, -16, -28, -36, -40, -44, -48,
731 8, 4, 0, 0, -8, -16, -24, -36,
732 20, 12, 4, 0, -8, -8, -8, -16,
733 24, 16, 8, 8, 8, 0, -4, -8,
734 40, 36, 24, 20, 16, 8, 0, -8,
735 48, 40, 28, 24, 20, 12, 0, -4,
736 64, 48, 28, 20, 16, 12, 8, 4,
737 };
738
739 const int8_t AvcVdencBrcConstSettings::m_CBR_UPD_FrmSzAdjTabB_S8[72] =
740 {
741 0, -4, -8, -16, -24, -32, -40, -48,
742 1, 0, -4, -8, -16, -24, -32, -40,
743 4, 2, 0, -1, -3, -8, -16, -24,
744 8, 4, 2, 0, -1, -4, -8, -16,
745 20, 16, 4, 0, -1, -4, -8, -16,
746 24, 20, 16, 8, 4, 0, -4, -8,
747 28, 24, 20, 16, 8, 4, 0, -8,
748 32, 24, 20, 16, 8, 4, 0, -4,
749 64, 48, 28, 20, 16, 12, 8, 4,
750 };
751
752 const int8_t AvcVdencBrcConstSettings::m_VBR_UPD_FrmSzAdjTabI_S8[72] =
753 {
754 -4, -20, -28, -36, -40, -44, -48, -80,
755 0, -8, -12, -20, -24, -28, -32, -36,
756 0, 0, -8, -16, -20, -24, -28, -32,
757 8, 4, 0, 0, -8, -16, -24, -28,
758 32, 24, 16, 2, -4, -8, -16, -20,
759 36, 32, 28, 16, 8, 0, -4, -8,
760 40, 36, 24, 20, 16, 8, 0, -8,
761 48, 40, 28, 24, 20, 12, 0, -4,
762 64, 48, 28, 20, 16, 12, 8, 4,
763 };
764
765 const int8_t AvcVdencBrcConstSettings::m_VBR_UPD_FrmSzAdjTabP_S8[72] =
766 {
767 -8, -24, -32, -44, -48, -56, -64, -80,
768 -8, -16, -32, -40, -44, -52, -56, -64,
769 0, 0, -16, -28, -36, -40, -44, -48,
770 8, 4, 0, 0, -8, -16, -24, -36,
771 20, 12, 4, 0, -8, -8, -8, -16,
772 24, 16, 8, 8, 8, 0, -4, -8,
773 40, 36, 24, 20, 16, 8, 0, -8,
774 48, 40, 28, 24, 20, 12, 0, -4,
775 64, 48, 28, 20, 16, 12, 8, 4,
776 };
777
778 const int8_t AvcVdencBrcConstSettings::m_VBR_UPD_FrmSzAdjTabB_S8[72] =
779 {
780 0, -4, -8, -16, -24, -32, -40, -48,
781 1, 0, -4, -8, -16, -24, -32, -40,
782 4, 2, 0, -1, -3, -8, -16, -24,
783 8, 4, 2, 0, -1, -4, -8, -16,
784 20, 16, 4, 0, -1, -4, -8, -16,
785 24, 20, 16, 8, 4, 0, -4, -8,
786 28, 24, 20, 16, 8, 4, 0, -8,
787 32, 24, 20, 16, 8, 4, 0, -4,
788 64, 48, 28, 20, 16, 12, 8, 4,
789 };
790
791 const int8_t AvcVdencBrcConstSettings::m_QVBR_UPD_FrmSzAdjTabP_S8[72] =
792 {
793 -8, -24, -32, -44, -48, -56, -64, -80,
794 -8, -16, -32, -40, -44, -52, -56, -64,
795 0, 0, -16, -28, -36, -40, -44, -48,
796 16, 16, 8, 0, -8, -16, -24, -36,
797 20, 16, 8, 0, -8, -8, -8, -16,
798 24, 16, 8, 8, 8, 0, -4, -8,
799 40, 36, 24, 20, 16, 8, 0, -8,
800 48, 40, 28, 24, 20, 12, 0, -4,
801 64, 48, 28, 20, 16, 12, 8, 4,
802 };
803
804 const int8_t AvcVdencBrcConstSettings::m_LOW_DELAY_UPD_FrmSzAdjTabI_S8[72] =
805 {
806 0, 0, -8, -12, -16, -20, -28, -36,
807 0, 0, -4, -8, -12, -16, -24, -32,
808 4, 2, 0, -1, -3, -8, -16, -24,
809 8, 4, 2, 0, -1, -4, -8, -16,
810 20, 16, 4, 0, -1, -4, -8, -16,
811 24, 20, 16, 8, 4, 0, -4, -8,
812 28, 24, 20, 16, 8, 4, 0, -8,
813 32, 24, 20, 16, 8, 4, 0, -4,
814 64, 48, 28, 20, 16, 12, 8, 4,
815 };
816
817 const int8_t AvcVdencBrcConstSettings::m_LOW_DELAY_UPD_FrmSzAdjTabP_S8[72] =
818 {
819 -8, -24, -32, -40, -44, -48, -52, -80,
820 -8, -16, -32, -40, -40, -44, -44, -56,
821 0, 0, -12, -20, -24, -28, -32, -36,
822 8, 4, 0, 0, -8, -16, -24, -32,
823 32, 16, 8, 4, -4, -8, -16, -20,
824 36, 24, 16, 8, 4, -2, -4, -8,
825 40, 36, 24, 20, 16, 8, 0, -8,
826 48, 40, 28, 24, 20, 12, 0, -4,
827 64, 48, 28, 20, 16, 12, 8, 4,
828 };
829
830 const int8_t AvcVdencBrcConstSettings::m_LOW_DELAY_UPD_FrmSzAdjTabB_S8[72] =
831 {
832 0, -4, -8, -16, -24, -32, -40, -48,
833 1, 0, -4, -8, -16, -24, -32, -40,
834 4, 2, 0, -1, -3, -8, -16, -24,
835 8, 4, 2, 0, -1, -4, -8, -16,
836 20, 16, 4, 0, -1, -4, -8, -16,
837 24, 20, 16, 8, 4, 0, -4, -8,
838 28, 24, 20, 16, 8, 4, 0, -8,
839 32, 24, 20, 16, 8, 4, 0, -4,
840 64, 48, 28, 20, 16, 12, 8, 4,
841 };
842
843 const uint8_t AvcVdencBrcConstSettings::m_BRC_UPD_FrmSzMinTabP_U8[9] = {1, 2, 4, 6, 8, 10, 16, 16, 16};
844 const uint8_t AvcVdencBrcConstSettings::m_BRC_UPD_FrmSzMinTabI_U8[9] = {1, 2, 4, 8, 16, 20, 24, 32, 36};
845 const uint8_t AvcVdencBrcConstSettings::m_BRC_UPD_FrmSzMaxTabP_U8[9] = {48, 64, 80, 96, 112, 128, 144, 160, 160};
846 const uint8_t AvcVdencBrcConstSettings::m_BRC_UPD_FrmSzMaxTabI_U8[9] = {48, 64, 80, 96, 112, 128, 144, 160, 160};
847 const uint8_t AvcVdencBrcConstSettings::m_BRC_UPD_FrmSzSCGTabP_U8[9] = {4, 8, 12, 16, 20, 24, 24, 0, 0};
848 const uint8_t AvcVdencBrcConstSettings::m_BRC_UPD_FrmSzSCGTabI_U8[9] = {4, 8, 12, 16, 20, 24, 24, 0, 0};
849
850 const uint8_t AvcVdencBrcConstSettings::m_BRC_UPD_I_IntraNonPred[42] =
851 {
852 0x0e, 0x0e, 0x0e, 0x18, 0x19, 0x1b, 0x1c,
853 0x0d, 0x0f, 0x18, 0x19, 0x0d, 0x0f, 0x0f,
854 0x0c, 0x0e, 0x0c, 0x0c, 0x0a, 0x0a, 0x0b,
855 0x0a, 0x0a, 0x0a, 0x09, 0x09, 0x08, 0x08,
856 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
857 0x08, 0x08, 0x07, 0x07, 0x07, 0x07, 0x07
858 };
859
860 const uint8_t AvcVdencBrcConstSettings::m_BRC_UPD_I_Intra8x8[42] =
861 {
862 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
863 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01,
864 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
865 0x04, 0x04, 0x04, 0x04, 0x06, 0x06, 0x06,
866 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
867 0x06, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07,
868 };
869
870 const uint8_t AvcVdencBrcConstSettings::m_BRC_UPD_I_Intra4x4[42] =
871 {
872 0x2e, 0x2e, 0x2e, 0x38, 0x39, 0x3a, 0x3b,
873 0x2c, 0x2e, 0x38, 0x39, 0x2d, 0x2f, 0x38,
874 0x2e, 0x38, 0x2e, 0x38, 0x2f, 0x2e, 0x38,
875 0x38, 0x38, 0x38, 0x2f, 0x2f, 0x2f, 0x2e,
876 0x2d, 0x2c, 0x2b, 0x2a, 0x29, 0x28, 0x1e,
877 0x1c, 0x1b, 0x1a, 0x19, 0x18, 0x0e, 0x0d
878 };
879
880 const uint8_t AvcVdencBrcConstSettings::m_BRC_UPD_P_IntraNonPred[42] =
881 {
882 0x06, 0x06, 0x06, 0x07, 0x08, 0x09, 0x0a,
883 0x05, 0x06, 0x07, 0x08, 0x06, 0x07, 0x07,
884 0x07, 0x07, 0x06, 0x07, 0x07, 0x06, 0x07,
885 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
886 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
887 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07
888 };
889
890 const uint8_t AvcVdencBrcConstSettings::m_BRC_UPD_P_Intra16x16[42] =
891 {
892 0x1b, 0x1b, 0x1b, 0x1c, 0x1e, 0x28, 0x29,
893 0x1a, 0x1b, 0x1c, 0x1e, 0x1a, 0x1c, 0x1d,
894 0x1b, 0x1c, 0x1c, 0x1c, 0x1c, 0x1b, 0x1c,
895 0x1c, 0x1d, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c,
896 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c,
897 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c
898 };
899
900 const uint8_t AvcVdencBrcConstSettings::m_BRC_UPD_P_Intra8x8[42] =
901 {
902 0x1d, 0x1d, 0x1d, 0x1e, 0x28, 0x29, 0x2a,
903 0x1b, 0x1d, 0x1e, 0x28, 0x1c, 0x1d, 0x1f,
904 0x1d, 0x1e, 0x1d, 0x1e, 0x1d, 0x1d, 0x1f,
905 0x1e, 0x1e, 0x1e, 0x1d, 0x1e, 0x1e, 0x1d,
906 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e,
907 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e,
908 };
909
910 const uint8_t AvcVdencBrcConstSettings::m_BRC_UPD_P_Intra4x4[42] =
911 {
912 0x38, 0x38, 0x38, 0x39, 0x3a, 0x3b, 0x3d,
913 0x2e, 0x38, 0x39, 0x3a, 0x2f, 0x39, 0x3a,
914 0x38, 0x39, 0x38, 0x39, 0x39, 0x38, 0x39,
915 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39,
916 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39,
917 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39,
918 };
919
920 const uint8_t AvcVdencBrcConstSettings::m_BRC_UPD_P_Inter16x8[42] =
921 {
922 0x07, 0x07, 0x07, 0x08, 0x09, 0x0b, 0x0c,
923 0x06, 0x07, 0x09, 0x0a, 0x07, 0x08, 0x09,
924 0x08, 0x09, 0x08, 0x09, 0x08, 0x08, 0x09,
925 0x09, 0x09, 0x09, 0x08, 0x08, 0x08, 0x08,
926 0x08, 0x08, 0x08, 0x08, 0x09, 0x09, 0x09,
927 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09,
928 };
929
930 const uint8_t AvcVdencBrcConstSettings::m_BRC_UPD_P_Inter8x8[42] =
931 {
932 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03,
933 0x02, 0x02, 0x02, 0x03, 0x02, 0x02, 0x02,
934 0x02, 0x03, 0x02, 0x02, 0x03, 0x03, 0x03,
935 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
936 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
937 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
938 };
939
940 const uint8_t AvcVdencBrcConstSettings::m_BRC_UPD_P_Inter16x16[42] =
941 {
942 0x05, 0x05, 0x05, 0x06, 0x06, 0x06, 0x06,
943 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
944 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
945 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
946 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
947 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
948 };
949
950 const uint8_t AvcVdencBrcConstSettings::m_BRC_UPD_P_RefId[42] =
951 {
952 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
953 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
954 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
955 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
956 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
957 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
958 };
959
EncodeAvcVdencConstSettings(PMOS_INTERFACE osInterface)960 EncodeAvcVdencConstSettings::EncodeAvcVdencConstSettings(PMOS_INTERFACE osInterface) : VdencConstSettings(osInterface)
961 {
962 m_featureSetting = MOS_New(AvcVdencFeatureSettings);
963 }
964
PrepareConstSettings()965 MOS_STATUS EncodeAvcVdencConstSettings::PrepareConstSettings()
966 {
967 ENCODE_FUNC_CALL();
968
969 ENCODE_CHK_STATUS_RETURN(SetCommonSettings());
970 ENCODE_CHK_STATUS_RETURN(SetBrcSettings());
971 ENCODE_CHK_STATUS_RETURN(SetVdencCmd3Settings());
972 ENCODE_CHK_STATUS_RETURN(SetVdencAvcImgStateSettings());
973
974 return MOS_STATUS_SUCCESS;
975 }
976
SetCommonSettings()977 MOS_STATUS EncodeAvcVdencConstSettings::SetCommonSettings()
978 {
979 ENCODE_FUNC_CALL();
980 ENCODE_CHK_NULL_RETURN(m_featureSetting);
981
982 auto setting = static_cast<AvcVdencFeatureSettings *>(m_featureSetting);
983 ENCODE_CHK_NULL_RETURN(setting);
984
985 setting->singlePassMinFrameWidth = m_singlePassMinFrameWidth;
986 setting->singlePassMinFrameHeight = m_singlePassMinFrameHeight;
987 setting->singlePassMinFramePer100s = m_singlePassMinFramePer100s;
988
989 setting->interMbMaxSize = m_interMbMaxSize;
990 setting->intraMbMaxSize = m_intraMbMaxSize;
991
992 setting->perfModeEnabled = (bool*) m_perfModeEnabled;
993
994 setting->DefaultIntraRounding = defIntraRounding;
995 setting->StaticIntraRounding[0] = defIntraRounding;
996 setting->StaticIntraRounding[1] = defIntraRounding;
997 setting->StaticIntraRounding[2] = defIntraRounding;
998 setting->StaticIntraRounding[3] = defIntraRounding;
999
1000 setting->DefaultInterRounding = defInterRounding;
1001 setting->StaticInterRounding[0] = interRoundingB;
1002 setting->StaticInterRounding[1] = interRoundingBR;
1003 setting->StaticInterRounding[2] = interRoundingP;
1004 setting->StaticInterRounding[3] = interRoundingP;
1005
1006 setting->AdaptiveIntraRounding[0] = static_cast<const uint8_t *>(adaptiveRoundingIntra_B);
1007 setting->AdaptiveIntraRounding[1] = static_cast<const uint8_t *>(adaptiveRoundingIntra_BR);
1008 setting->AdaptiveIntraRounding[2] = static_cast<const uint8_t *>(adaptiveRoundingIntra_P);
1009 setting->AdaptiveIntraRounding[3] = static_cast<const uint8_t *>(adaptiveRoundingIntra_P_G1);
1010
1011 setting->AdaptiveInterRounding[0] = static_cast<const uint8_t *>(adaptiveRoundingInter_B);
1012 setting->AdaptiveInterRounding[1] = static_cast<const uint8_t *>(adaptiveRoundingInter_BR);
1013 setting->AdaptiveInterRounding[2] = static_cast<const uint8_t *>(adaptiveRoundingInter_P);
1014 setting->AdaptiveInterRounding[3] = static_cast<const uint8_t *>(adaptiveRoundingInter_P_G1);
1015
1016 setting->SliceSizeThrsholdsI = (uint16_t *)m_SliceSizeThrsholdsI;
1017 setting->SliceSizeThrsholdsP = (uint16_t *)m_SliceSizeThrsholdsP;
1018
1019 setting->TrellisQuantizationRounding = (uint32_t*)m_trellisQuantizationRounding;
1020 setting->TrellisQuantizationEnable = (bool*)m_trellisQuantizationEnable;
1021
1022 setting->columnScan4x4 = (uint8_t*)m_columnScan4x4;
1023 setting->columnScan8x8 = (uint8_t*)m_columnScan8x8;
1024
1025 setting->vdencCMD3Table = (AvcVdencCMD3ConstSettings*)&m_CMD3Settings;
1026
1027 return MOS_STATUS_SUCCESS;
1028 }
1029
SetBrcSettings()1030 MOS_STATUS EncodeAvcVdencConstSettings::SetBrcSettings()
1031 {
1032 ENCODE_FUNC_CALL();
1033 ENCODE_CHK_NULL_RETURN(m_featureSetting);
1034
1035 auto setting = static_cast<AvcVdencFeatureSettings *>(m_featureSetting);
1036 ENCODE_CHK_NULL_RETURN(setting);
1037
1038 setting->brcSettings.vdencBrcPakStatsBufferSize = m_brcSettings.m_vdencBrcPakStatsBufferSize;
1039 setting->brcSettings.vdencBrcStatsBufferSize = m_brcSettings.m_vdencBrcStatsBufferSize;
1040 setting->brcSettings.vdencBrcDbgBufferSize = m_brcSettings.m_vdencBrcDbgBufferSize;
1041 setting->brcSettings.vdencBrcHistoryBufferSize = m_brcSettings.m_vdencBrcHistoryBufferSize;
1042
1043 setting->brcSettings.vdboxHucVdencBrcInitKernelDescriptor = m_brcSettings.m_vdboxHucVdencBrcInitKernelDescriptor;
1044 setting->brcSettings.vdboxHucVdencBrcUpdateKernelDescriptor = m_brcSettings.m_vdboxHucVdencBrcUpdateKernelDescriptor;
1045
1046 setting->brcSettings.BRC_DevThreshI0_FP_NEG = (double*)m_brcSettings.m_BRC_DevThreshI0_FP_NEG;
1047 setting->brcSettings.BRC_DevThreshI0_FP_POS = (double*)m_brcSettings.m_BRC_DevThreshI0_FP_POS;
1048 setting->brcSettings.BRC_DevThreshPB0_FP_NEG = (double*)m_brcSettings.m_BRC_DevThreshPB0_FP_NEG;
1049 setting->brcSettings.BRC_DevThreshPB0_FP_POS = (double*)m_brcSettings.m_BRC_DevThreshPB0_FP_POS;
1050 setting->brcSettings.BRC_DevThreshVBR0_NEG = (double*)m_brcSettings.m_BRC_DevThreshVBR0_NEG;
1051 setting->brcSettings.BRC_DevThreshVBR0_POS = (double*)m_brcSettings.m_BRC_DevThreshVBR0_POS;
1052
1053 setting->brcSettings.BRC_LowDelay_DevThreshPB0_S8 = (int8_t*)m_brcSettings.m_BRC_LowDelay_DevThreshPB0_S8;
1054 setting->brcSettings.BRC_LowDelay_DevThreshI0_S8 = (int8_t*)m_brcSettings.m_BRC_LowDelay_DevThreshI0_S8;
1055 setting->brcSettings.BRC_LowDelay_DevThreshVBR0_S8 = (int8_t*)m_brcSettings.m_BRC_LowDelay_DevThreshVBR0_S8;
1056 setting->brcSettings.BRC_INIT_DistQPDelta_I8 = (int8_t*)m_brcSettings.m_BRC_INIT_DistQPDelta_I8;
1057 setting->brcSettings.BRC_EstRateThreshP0_U8 = (uint8_t*)m_brcSettings.m_BRC_EstRateThreshP0_U8;
1058 setting->brcSettings.BRC_EstRateThreshI0_U8 = (uint8_t*)m_brcSettings.m_BRC_EstRateThreshI0_U8;
1059
1060 setting->brcSettings.brcInitDistQpDeltaI8 = (int8_t*)m_brcSettings.m_brcInitDistQpDeltaI8;
1061 setting->brcSettings.brcInitDistQpDeltaI8LowDelay = (int8_t*)m_brcSettings.m_brcInitDistQpDeltaI8LowDelay;
1062
1063 setting->brcSettings.BRC_UPD_start_global_adjust_frame = (uint16_t*)m_brcSettings.m_BRC_UPD_start_global_adjust_frame;
1064 setting->brcSettings.BRC_UPD_global_rate_ratio_threshold = (uint8_t*)m_brcSettings.m_BRC_UPD_global_rate_ratio_threshold;
1065 setting->brcSettings.BRC_UPD_slwin_global_rate_ratio_threshold = (uint8_t*)m_brcSettings.m_BRC_UPD_slwin_global_rate_ratio_threshold;
1066 setting->brcSettings.BRC_UPD_start_global_adjust_mult = (uint8_t*)m_brcSettings.m_BRC_UPD_start_global_adjust_mult;
1067 setting->brcSettings.BRC_UPD_start_global_adjust_div = (uint8_t*)m_brcSettings.m_BRC_UPD_start_global_adjust_div;
1068 setting->brcSettings.BRC_UPD_global_rate_ratio_threshold_qp = (int8_t*)m_brcSettings.m_BRC_UPD_global_rate_ratio_threshold_qp;
1069
1070 setting->brcSettings.BRC_UPD_GlobalRateQPAdjTabI_U8 = (int8_t*)m_brcSettings.m_BRC_UPD_GlobalRateQPAdjTabI_U8;
1071 setting->brcSettings.BRC_UPD_GlobalRateQPAdjTabP_U8 = (int8_t*)m_brcSettings.m_BRC_UPD_GlobalRateQPAdjTabP_U8;
1072 setting->brcSettings.BRC_UPD_SlWinGlobalRateQPAdjTabP_U8 = (int8_t*)m_brcSettings.m_BRC_UPD_SlWinGlobalRateQPAdjTabP_U8;
1073 setting->brcSettings.BRC_UPD_GlobalRateQPAdjTabB_U8 = (int8_t*)m_brcSettings.m_BRC_UPD_GlobalRateQPAdjTabB_U8;
1074 setting->brcSettings.BRC_UPD_DistThreshldI_U8 = (uint8_t*)m_brcSettings.m_BRC_UPD_DistThreshldI_U8;
1075 setting->brcSettings.BRC_UPD_DistThreshldP_U8 = (uint8_t*)m_brcSettings.m_BRC_UPD_DistThreshldP_U8;
1076 setting->brcSettings.BRC_UPD_DistThreshldB_U8 = (uint8_t*)m_brcSettings.m_BRC_UPD_DistThreshldB_U8;
1077 setting->brcSettings.CBR_UPD_DistQPAdjTabI_U8 = (int8_t*)m_brcSettings.m_CBR_UPD_DistQPAdjTabI_U8;
1078 setting->brcSettings.CBR_UPD_DistQPAdjTabP_U8 = (int8_t*)m_brcSettings.m_CBR_UPD_DistQPAdjTabP_U8;
1079 setting->brcSettings.CBR_UPD_DistQPAdjTabB_U8 = (int8_t*)m_brcSettings.m_CBR_UPD_DistQPAdjTabB_U8;
1080 setting->brcSettings.VBR_UPD_DistQPAdjTabI_U8 = (int8_t*)m_brcSettings.m_VBR_UPD_DistQPAdjTabI_U8;
1081 setting->brcSettings.VBR_UPD_DistQPAdjTabP_U8 = (int8_t*)m_brcSettings.m_VBR_UPD_DistQPAdjTabP_U8;
1082 setting->brcSettings.VBR_UPD_DistQPAdjTabB_U8 = (int8_t*)m_brcSettings.m_VBR_UPD_DistQPAdjTabB_U8;
1083 setting->brcSettings.CBR_UPD_FrmSzAdjTabI_S8 = (int8_t*)m_brcSettings.m_CBR_UPD_FrmSzAdjTabI_S8;
1084 setting->brcSettings.CBR_UPD_FrmSzAdjTabP_S8 = (int8_t*)m_brcSettings.m_CBR_UPD_FrmSzAdjTabP_S8;
1085 setting->brcSettings.CBR_UPD_FrmSzAdjTabB_S8 = (int8_t*)m_brcSettings.m_CBR_UPD_FrmSzAdjTabB_S8;
1086 setting->brcSettings.VBR_UPD_FrmSzAdjTabI_S8 = (int8_t*)m_brcSettings.m_VBR_UPD_FrmSzAdjTabI_S8;
1087 setting->brcSettings.VBR_UPD_FrmSzAdjTabP_S8 = (int8_t*)m_brcSettings.m_VBR_UPD_FrmSzAdjTabP_S8;
1088 setting->brcSettings.VBR_UPD_FrmSzAdjTabB_S8 = (int8_t*)m_brcSettings.m_VBR_UPD_FrmSzAdjTabB_S8;
1089 setting->brcSettings.QVBR_UPD_FrmSzAdjTabP_S8 = (int8_t*)m_brcSettings.m_QVBR_UPD_FrmSzAdjTabP_S8;
1090 setting->brcSettings.LOW_DELAY_UPD_FrmSzAdjTabI_S8 = (int8_t*)m_brcSettings.m_LOW_DELAY_UPD_FrmSzAdjTabI_S8;
1091 setting->brcSettings.LOW_DELAY_UPD_FrmSzAdjTabP_S8 = (int8_t*)m_brcSettings.m_LOW_DELAY_UPD_FrmSzAdjTabP_S8;
1092 setting->brcSettings.LOW_DELAY_UPD_FrmSzAdjTabB_S8 = (int8_t*)m_brcSettings.m_LOW_DELAY_UPD_FrmSzAdjTabB_S8;
1093 setting->brcSettings.BRC_UPD_FrmSzMinTabP_U8 = (uint8_t*)m_brcSettings.m_BRC_UPD_FrmSzMinTabP_U8;
1094 setting->brcSettings.BRC_UPD_FrmSzMinTabI_U8 = (uint8_t*)m_brcSettings.m_BRC_UPD_FrmSzMinTabI_U8;
1095 setting->brcSettings.BRC_UPD_FrmSzMaxTabP_U8 = (uint8_t*)m_brcSettings.m_BRC_UPD_FrmSzMaxTabP_U8;
1096 setting->brcSettings.BRC_UPD_FrmSzMaxTabI_U8 = (uint8_t*)m_brcSettings.m_BRC_UPD_FrmSzMaxTabI_U8;
1097 setting->brcSettings.BRC_UPD_FrmSzSCGTabP_U8 = (uint8_t*)m_brcSettings.m_BRC_UPD_FrmSzSCGTabP_U8;
1098 setting->brcSettings.BRC_UPD_FrmSzSCGTabI_U8 = (uint8_t*)m_brcSettings.m_BRC_UPD_FrmSzSCGTabI_U8;
1099
1100 setting->brcSettings.BRC_UPD_I_IntraNonPred = (uint8_t*)m_brcSettings.m_BRC_UPD_I_IntraNonPred;
1101 setting->brcSettings.BRC_UPD_I_Intra8x8 = (uint8_t*)m_brcSettings.m_BRC_UPD_I_Intra8x8;
1102 setting->brcSettings.BRC_UPD_I_Intra4x4 = (uint8_t*)m_brcSettings.m_BRC_UPD_I_Intra4x4;
1103 setting->brcSettings.BRC_UPD_P_IntraNonPred = (uint8_t*)m_brcSettings.m_BRC_UPD_P_IntraNonPred;
1104 setting->brcSettings.BRC_UPD_P_Intra16x16 = (uint8_t*)m_brcSettings.m_BRC_UPD_P_Intra16x16;
1105 setting->brcSettings.BRC_UPD_P_Intra8x8 = (uint8_t*)m_brcSettings.m_BRC_UPD_P_Intra8x8;
1106 setting->brcSettings.BRC_UPD_P_Intra4x4 = (uint8_t*)m_brcSettings.m_BRC_UPD_P_Intra4x4;
1107 setting->brcSettings.BRC_UPD_P_Inter16x8 = (uint8_t*)m_brcSettings.m_BRC_UPD_P_Inter16x8;
1108 setting->brcSettings.BRC_UPD_P_Inter8x8 = (uint8_t*)m_brcSettings.m_BRC_UPD_P_Inter8x8;
1109 setting->brcSettings.BRC_UPD_P_Inter16x16 = (uint8_t*)m_brcSettings.m_BRC_UPD_P_Inter16x16;
1110 setting->brcSettings.BRC_UPD_P_RefId = (uint8_t*)m_brcSettings.m_BRC_UPD_P_RefId;
1111
1112 return MOS_STATUS_SUCCESS;
1113 }
1114
Update(void * params)1115 MOS_STATUS EncodeAvcVdencConstSettings::Update(void *params)
1116 {
1117 EncoderParams* encodeParams = (EncoderParams*)params;
1118
1119 PCODEC_AVC_ENCODE_SEQUENCE_PARAMS avcSeqParams =
1120 static_cast<PCODEC_AVC_ENCODE_SEQUENCE_PARAMS>(encodeParams->pSeqParams);
1121 ENCODE_CHK_NULL_RETURN(avcSeqParams);
1122 m_avcSeqParams = avcSeqParams;
1123
1124 PCODEC_AVC_ENCODE_PIC_PARAMS avcPicParams =
1125 static_cast<PCODEC_AVC_ENCODE_PIC_PARAMS>(encodeParams->pPicParams);
1126 ENCODE_CHK_NULL_RETURN(avcPicParams);
1127 m_avcPicParams = avcPicParams;
1128
1129 PCODEC_AVC_ENCODE_SLICE_PARAMS avcSliceParams =
1130 static_cast<PCODEC_AVC_ENCODE_SLICE_PARAMS>(encodeParams->pSliceParams);
1131 ENCODE_CHK_NULL_RETURN(avcSliceParams);
1132 m_avcSliceParams = avcSliceParams;
1133
1134 return MOS_STATUS_SUCCESS;
1135 }
1136
SetVdencCmd3Settings()1137 MOS_STATUS EncodeAvcVdencConstSettings::SetVdencCmd3Settings()
1138 {
1139 ENCODE_FUNC_CALL();
1140
1141 ENCODE_CHK_NULL_RETURN(m_featureSetting);
1142
1143 auto setting = static_cast<AvcVdencFeatureSettings *>(m_featureSetting);
1144 ENCODE_CHK_NULL_RETURN(setting);
1145
1146 setting->vdencCmd3Settings = {
1147 VDENC_CMD3_LAMBDA()
1148 {
1149 auto pictureType = CodecHal_Clip3(0, 2, m_avcPicParams->CodingType - 1);
1150 uint16_t picWidthInMb = CODECHAL_GET_WIDTH_IN_MACROBLOCKS(m_avcSeqParams->FrameWidth);
1151 uint16_t picHeightInMb = CODECHAL_GET_HEIGHT_IN_MACROBLOCKS(m_avcSeqParams->FrameHeight);
1152 m_qp = CodecHal_Clip3(10, 51, m_avcPicParams->QpY + m_avcSliceParams->slice_qp_delta);
1153
1154 // Only do this lambda offset for lower resolution and high QP range.
1155 uint16_t gopP = (m_avcSeqParams->GopRefDist) ? ((m_avcSeqParams->GopPicSize - 1) / m_avcSeqParams->GopRefDist) : 0;
1156 uint16_t gopB = m_avcSeqParams->GopPicSize - 1 - gopP;
1157 uint16_t numB = ((gopP > 0) ? (gopB / gopP) : 0);
1158 if ((numB != 0) && (picWidthInMb * 16 < 1920) && (picHeightInMb * 16 < 1080) && (m_qp >= 32))
1159 {
1160 uint8_t index0 = m_avcPicParams->RefPicFlag ? 0 : 1;
1161 static const std::array<
1162 std::array<
1163 uint8_t,
1164 3>,
1165 2>
1166 table = {{
1167 {0, 1, 1},
1168 {0, 1, 2},
1169 }};
1170 m_qp += table[index0][pictureType];
1171 m_qp = CodecHal_Clip3(0, 51, m_qp);
1172 }
1173 return MOS_STATUS_SUCCESS;
1174 },
1175 VDENC_CMD3_LAMBDA()
1176 {
1177 for (auto i = 0; i < 8; i++)
1178 {
1179 par.vdencCmd3Par0[i] = m_CMD3Settings.AvcVdencCMD3ConstSettings_0[i][m_qp];
1180 }
1181 return MOS_STATUS_SUCCESS;
1182 },
1183 VDENC_CMD3_LAMBDA()
1184 {
1185 auto codingType = m_avcPicParams->CodingType;
1186 auto pictureType = CodecHal_Clip3(0, 2, m_avcPicParams->CodingType - 1);
1187
1188 if (codingType == P_TYPE || codingType == B_TYPE)
1189 {
1190 for (auto i = 0; i < 12; i++)
1191 {
1192 static const uint8_t cmd3Par1_ptype[12] = {4, 12, 20, 28, 36, 44, 52, 60, 68, 76, 84, 92};
1193 static const uint8_t cmd3Par2_ptype[12] = {3, 10, 16, 22, 29, 35, 42, 48, 54, 61, 67, 74};
1194
1195 static const uint8_t cmd3Par1_btype[12] = {4, 12, 20, 28, 36, 44, 52, 60, 68, 76, 84, 92};
1196 static const uint8_t cmd3Par2_btype[12] = {2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35};
1197
1198 par.vdencCmd3Par1[i] = codingType == P_TYPE ? cmd3Par1_ptype[i] : cmd3Par1_btype[i];
1199 par.vdencCmd3Par2[i] = codingType == P_TYPE ? cmd3Par2_ptype[i] : cmd3Par2_btype[i];
1200 }
1201 }
1202 else
1203 {
1204 for (auto i = 0; i < 12; i++)
1205 {
1206 par.vdencCmd3Par1[i] = m_CMD3Settings.AvcVdencCMD3ConstSettings_1[pictureType][i];
1207 par.vdencCmd3Par2[i] = par.vdencCmd3Par1[i];
1208 }
1209 }
1210 return MOS_STATUS_SUCCESS;
1211 },
1212 VDENC_CMD3_LAMBDA()
1213 {
1214 auto codingType = m_avcPicParams->CodingType;
1215 auto isIPGOP = m_avcSeqParams->GopRefDist == 1;
1216 auto pictureType = CodecHal_Clip3(0, 2, m_avcPicParams->CodingType - 1);
1217 if (codingType == P_TYPE)
1218 {
1219 par.vdencCmd3Par3 = 0;
1220 par.vdencCmd3Par4 = 0;
1221 par.vdencCmd3Par5 = isIPGOP ? 29 : 23;
1222 par.vdencCmd3Par6 = 6;
1223 par.vdencCmd3Par7 = isIPGOP ? 26 : 21;
1224 par.vdencCmd3Par8 = isIPGOP ? 16 : 13;
1225 par.vdencCmd3Par10 = 0;
1226 par.vdencCmd3Par11 = 4;
1227
1228 par.vdencCmd3Par9 = isIPGOP ? 0 : 2;
1229 par.vdencCmd3Par12 = isIPGOP ? 12 : 4;
1230
1231 par.vdencCmd3Par19 = m_CMD3Settings.AvcVdencCMD3ConstSettings_3[pictureType][m_qp];
1232
1233 par.vdencCmd3Par20 = 6;
1234 par.vdencCmd3Par23 = isIPGOP ? 53 : 44;
1235 par.vdencCmd3Par21 = 16;
1236 par.vdencCmd3Par22 = isIPGOP ? 32 : 18;
1237 }
1238 else if (codingType == B_TYPE)
1239 {
1240 par.vdencCmd3Par3 = 0;
1241 par.vdencCmd3Par4 = 0;
1242 par.vdencCmd3Par5 = 36;
1243 par.vdencCmd3Par6 = 12;
1244 par.vdencCmd3Par7 = 35;
1245 par.vdencCmd3Par8 = 24;
1246 par.vdencCmd3Par10 = 4;
1247 par.vdencCmd3Par11 = 4;
1248
1249 par.vdencCmd3Par9 = 2;
1250 par.vdencCmd3Par12 = 4;
1251
1252 par.vdencCmd3Par19 = 14;
1253 par.vdencCmd3Par20 = 6;
1254 par.vdencCmd3Par23 = 42;
1255 par.vdencCmd3Par21 = 16;
1256 par.vdencCmd3Par22 = 22;
1257 }
1258 else if (codingType == I_TYPE)
1259 {
1260 par.vdencCmd3Par3 = m_CMD3Settings.AvcVdencCMD3ConstSettings_2[pictureType][RdModeConstSettings::SKIP_16X16];
1261 par.vdencCmd3Par4 = m_CMD3Settings.AvcVdencCMD3ConstSettings_2[pictureType][RdModeConstSettings::DIRECT_16X16];
1262
1263 par.vdencCmd3Par5 = m_CMD3Settings.AvcVdencCMD3ConstSettings_2[pictureType][RdModeConstSettings::INTER_8X4];
1264 par.vdencCmd3Par6 = m_CMD3Settings.AvcVdencCMD3ConstSettings_2[pictureType][RdModeConstSettings::INTER_16X16];
1265 par.vdencCmd3Par7 = m_CMD3Settings.AvcVdencCMD3ConstSettings_2[pictureType][RdModeConstSettings::INTER_16X8];
1266 par.vdencCmd3Par8 = m_CMD3Settings.AvcVdencCMD3ConstSettings_2[pictureType][RdModeConstSettings::INTER_8X8];
1267
1268 par.vdencCmd3Par9 = 4;
1269 par.vdencCmd3Par10 = m_CMD3Settings.AvcVdencCMD3ConstSettings_2[pictureType][RdModeConstSettings::INTER_BWD];
1270 par.vdencCmd3Par11 = m_avcSliceParams->num_ref_idx_l0_active_minus1 == 0 ? 0 : m_CMD3Settings.AvcVdencCMD3ConstSettings_2[pictureType][RdModeConstSettings::REF_ID];
1271 par.vdencCmd3Par12 = 0;
1272
1273 par.vdencCmd3Par19 = m_CMD3Settings.AvcVdencCMD3ConstSettings_3[pictureType][m_qp];
1274
1275 par.vdencCmd3Par20 = 6;
1276 par.vdencCmd3Par23 = 36;
1277 par.vdencCmd3Par21 = 14;
1278 par.vdencCmd3Par22 = 12;
1279 }
1280 return MOS_STATUS_SUCCESS;
1281 },
1282 VDENC_CMD3_LAMBDA()
1283 {
1284 par.vdencCmd3Par13 = 4;
1285 par.vdencCmd3Par14 = 36;
1286 par.vdencCmd3Par15 = 12;
1287
1288 par.vdencCmd3Par16 = 0;
1289 par.vdencCmd3Par17 = 0;
1290 par.vdencCmd3Par18 = 0;
1291
1292 par.vdencCmd3Par27 = 0;
1293 par.vdencCmd3Par28 = 0;
1294
1295 par.vdencCmd3Par29 = 0;
1296 par.vdencCmd3Par30 = 0;
1297
1298 return MOS_STATUS_SUCCESS;
1299 },
1300 VDENC_CMD3_LAMBDA()
1301 {
1302 uint8_t isIPGOP = m_avcSeqParams->GopRefDist == 1 ? 1 : 0;
1303 uint8_t codingTypeMinus1 = m_avcPicParams->CodingType - 1;
1304 uint8_t refPic = m_avcPicParams->RefPicFlag;
1305
1306 par.vdencCmd3Par31 = m_CMD3Settings.par31Table[isIPGOP][codingTypeMinus1][refPic][m_qp];
1307 par.vdencCmd3Par32 = m_CMD3Settings.par32Table[isIPGOP][codingTypeMinus1][refPic][m_qp];
1308
1309 return MOS_STATUS_SUCCESS;
1310 }
1311 };
1312
1313 return MOS_STATUS_SUCCESS;
1314 }
1315
1316 } // namespace encode
1317