Debian Codegraph @

src/i965_encoder_vp8.h

raw
1 /*
2 * Copyright © 2017 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
6 * "Software"), to deal in the Software without restriction, including
7 * without limitation the rights to use, copy, modify, merge, publish,
8 * distribute, sub license, and/or sell copies of the Software, and to
9 * permit persons to whom the Software is furnished to do so, subject to
10 * the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the
13 * next paragraph) shall be included in all copies or substantial portions
14 * of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
19 * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
20 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 *
24 * Authors:
25 * Xiang, Haihao <[email protected]>
26 *
27 */
28
29 #ifndef I965_ENCODER_VP8_H
30 #define I965_ENCODER_VP8_H
31
32 #include <drm.h>
33 #include <i915_drm.h>
34 #include <intel_bufmgr.h>
35
36 #include "i965_gpe_utils.h"
37
38 #define VP8_ME_MV_DATA_SIZE_MULTIPLIER 3
39 #define VP8_HISTOGRAM_SIZE (136 * sizeof(unsigned int))
40 #define VP8_FRAME_HEADER_SIZE 4096
41 #define VP8_MODE_PROPABILITIES_SIZE 96
42
43 #define VP8_NUM_COEFF_PLANES 4
44 #define VP8_NUM_COEFF_BANDS 8
45 #define VP8_NUM_LOCAL_COMPLEXITIES 3
46 #define VP8_NUM_COEFF_NODES 11
47 #define VP8_COEFFS_PROPABILITIES_SIZE (VP8_NUM_COEFF_PLANES * VP8_NUM_COEFF_BANDS * VP8_NUM_LOCAL_COMPLEXITIES * VP8_NUM_COEFF_NODES)
48
49 #define VP8_TOKEN_BITS_DATA_SIZE (16 * sizeof(unsigned int))
50
51 #define VP8_HEADER_METADATA_SIZE (32 * sizeof(unsigned int))
52 #define VP8_PICTURE_STATE_CMD_SIZE (37 * sizeof(unsigned int))
53 #define VP8_PICTURE_STATE_SIZE (VP8_PICTURE_STATE_CMD_SIZE + VP8_HEADER_METADATA_SIZE + (16 * sizeof(unsigned int)))
54
55 #define VP8_MPU_BITSTREAM_SIZE 128
56 #define VP8_TPU_BITSTREAM_SIZE 1344
57 #define VP8_ENTROPY_COST_TABLE_SIZE (256 * sizeof(unsigned int))
58
59 #define VP8_TOKEN_STATISTICS_SIZE (304 * sizeof(unsigned int))
60
61 #define VP8_INTERMEDIATE_PARTITION0_SIZE (64 * 1024)
62
63 #define VP8_REPAK_DECISION_BUF_SIZE (4 * sizeof(unsigned int))
64
65 #define VP8_MAX_SEGMENTS 4
66
67 #define VP8_ENCODE_STATUS_NUM 512
68
69 #define VP8_HEADER_METADATA_SIZE (32 * sizeof(unsigned int))
70 #define VP8_PICTURE_STATE_CMD_SIZE (37 * sizeof(unsigned int))
71 #define VP8_PICTURE_STATE_SIZE (VP8_PICTURE_STATE_CMD_SIZE + VP8_HEADER_METADATA_SIZE + (16 * sizeof(unsigned int)))
72 #define VP8_HEADER_METADATA_OFFSET (VP8_PICTURE_STATE_CMD_SIZE + (3 * sizeof(unsigned int)))
73
74 #define VDBOX0_MMIO_BASE 0x12000
75 #define VDBOX1_MMIO_BASE 0x1c000
76
77 #define VP8_MFC_IMAGE_STATUS_MASK_REG_OFFSET 0x900
78 #define VP8_MFC_IMAGE_STATUS_CTRL_REG_OFFSET 0x904
79 #define VP8_MFC_BITSTREAM_BYTECOUNT_FRAME_REG_OFFSET 0x908
80
81 #define VP8_MFX_BRC_DQ_INDEX_REG_OFFSET 0x910
82 #define VP8_MFX_BRC_D_LOOP_FILTER_REG_OFFSET 0x914
83 #define VP8_MFX_BRC_CUMULATIVE_DQ_INDEX01_REG_OFFSET 0x918
84 #define VP8_MFX_BRC_CUMULATIVE_DQ_INDEX23_REG_OFFSET 0x91C
85 #define VP8_MFX_BRC_CUMULATIVE_D_LOOP_FILTER01_REG_OFFSET 0x920
86 #define VP8_MFX_BRC_CUMULATIVE_D_LOOP_FILTER23_REG_OFFSET 0x924
87 #define VP8_MFX_BRC_CONVERGENCE_STATUS_REG_OFFSET 0x928
88
89 struct encode_state;
90 struct intel_encoder_context;
91
92 struct i965_encoder_vp8_surface {
93 VADriverContextP ctx;
94 VASurfaceID scaled_4x_surface_id;
95 struct object_surface *scaled_4x_surface_obj;
96 VASurfaceID scaled_16x_surface_id;
97 struct object_surface *scaled_16x_surface_obj;
98 unsigned int qp_index;
99 };
100
101 enum vp8_binding_table_offset_vp8_brc_init_reset {
102 VP8_BTI_BRC_INIT_RESET_HISTORY = 0,
103 VP8_BTI_BRC_INIT_RESET_DISTORTION,
104 VP8_BTI_BRC_INIT_RESET_NUM_SURFACES
105 };
106
107 struct vp8_brc_init_reset_curbe_data {
108 struct {
109 uint32_t profile_level_max_frame;
110 } dw0;
111
112 struct {
113 uint32_t init_buf_full_in_bits;
114 } dw1;
115
116 struct {
117 uint32_t buf_size_in_bits;
118 } dw2;
119
120 struct {
121 uint32_t average_bitrate;
122 } dw3;
123
124 struct {
125 uint32_t max_bitrate;
126 } dw4;
127
128 struct {
129 uint32_t min_bitrate;
130 } dw5;
131
132 struct {
133 uint32_t frame_rate_m;
134 } dw6;
135
136 struct {
137 uint32_t frame_rate_d;
138 } dw7;
139
140 struct {
141 uint32_t brc_flag: 16;
142 uint32_t gop_minus1: 16;
143 } dw8;
144
145 struct {
146 uint32_t reserved: 16;
147 uint32_t frame_width_in_bytes: 16;
148 } dw9;
149
150 struct {
151 uint32_t frame_height_in_bytes: 16;
152 uint32_t avbr_accuracy: 16;
153 } dw10;
154
155 struct {
156 uint32_t avbr_convergence: 16;
157 uint32_t min_qp: 16;
158 } dw11;
159
160 struct {
161 uint32_t max_qp: 16;
162 uint32_t level_qp: 16;
163 } dw12;
164
165 struct {
166 uint32_t max_section_pct: 16;
167 uint32_t under_shoot_cbr_pct: 16;
168 } dw13;
169
170 struct {
171 uint32_t vbr_bias_pct: 16;
172 uint32_t min_section_pct: 16;
173 } dw14;
174
175 struct {
176 uint32_t instant_rate_threshold_0_for_p: 8;
177 uint32_t instant_rate_threshold_1_for_p: 8;
178 uint32_t instant_rate_threshold_2_for_p: 8;
179 uint32_t instant_rate_threshold_3_for_p: 8;
180 } dw15;
181
182 struct {
183 uint32_t reserved;
184 } dw16;
185
186 struct {
187 uint32_t instant_rate_threshold_0_for_i: 8;
188 uint32_t instant_rate_threshold_1_for_i: 8;
189 uint32_t instant_rate_threshold_2_for_i: 8;
190 uint32_t instant_rate_threshold_3_for_i: 8;
191 } dw17;
192
193 struct {
194 uint32_t deviation_threshold_0_for_p: 8; // Signed byte
195 uint32_t deviation_threshold_1_for_p: 8; // Signed byte
196 uint32_t deviation_threshold_2_for_p: 8; // Signed byte
197 uint32_t deviation_threshold_3_for_p: 8; // Signed byte
198 } dw18;
199
200 struct {
201 uint32_t deviation_threshold_4_for_p: 8; // Signed byte
202 uint32_t deviation_threshold_5_for_p: 8; // Signed byte
203 uint32_t deviation_threshold_6_for_p: 8; // Signed byte
204 uint32_t deviation_threshold_7_for_p: 8; // Signed byte
205 } dw19;
206
207 struct {
208 uint32_t deviation_threshold_0_for_vbr: 8; // Signed byte
209 uint32_t deviation_threshold_1_for_vbr: 8; // Signed byte
210 uint32_t deviation_threshold_2_for_vbr: 8; // Signed byte
211 uint32_t deviation_threshold_3_for_vbr: 8; // Signed byte
212 } dw20;
213
214 struct {
215 uint32_t deviation_threshold_4_for_vbr: 8; // Signed byte
216 uint32_t deviation_threshold_5_for_vbr: 8; // Signed byte
217 uint32_t deviation_threshold_6_for_vbr: 8; // Signed byte
218 uint32_t deviation_threshold_7_for_vbr: 8; // Signed byte
219 } dw21;
220
221 struct {
222 uint32_t deviation_threshold_0_for_i: 8; // Signed byte
223 uint32_t deviation_threshold_1_for_i: 8; // Signed byte
224 uint32_t deviation_threshold_2_for_i: 8; // Signed byte
225 uint32_t deviation_threshold_3_for_i: 8; // Signed byte
226 } dw22;
227
228 struct {
229 uint32_t deviation_threshold_4_for_i: 8; // Signed byte
230 uint32_t deviation_threshold_5_for_i: 8; // Signed byte
231 uint32_t deviation_threshold_6_for_i: 8; // Signed byte
232 uint32_t deviation_threshold_7_for_i: 8; // Signed byte
233 } dw23;
234
235 struct {
236 uint32_t num_t_levels: 8;
237 uint32_t reserved: 24;
238 } dw24;
239
240 struct {
241 uint32_t reserved;
242 } dw25;
243
244 struct {
245 uint32_t history_buffer_bti;
246 } dw26;
247
248 struct {
249 uint32_t distortion_buffer_bti;
250 } dw27;
251 };
252
253 #define VP8_BRC_INIT 0
254 #define VP8_BRC_RESET 1
255 #define NUM_VP8_BRC_RESET 2
256
257 struct i965_encoder_vp8_brc_init_reset_context {
258 struct i965_gpe_context gpe_contexts[NUM_VP8_BRC_RESET];
259 };
260
261 struct scaling_curbe_parameters {
262 unsigned int input_picture_width;
263 unsigned int input_picture_height;
264 char is_field_picture;
265 char flatness_check_enabled;
266 char mb_variance_output_enabled;
267 char mb_pixel_average_output_enabled;
268 };
269
270 struct scaling_surface_parameters {
271 struct object_surface *input_obj_surface;
272 struct object_surface *output_obj_surface;
273 unsigned int input_width;
274 unsigned int input_height;
275 unsigned int output_width;
276 unsigned int output_height;
277 };
278
279 enum vp8_binding_table_offset_scaling {
280 VP8_BTI_SCALING_FRAME_SRC_Y = 0,
281 VP8_BTI_SCALING_FRAME_DST_Y = 1,
282 VP8_BTI_SCALING_FIELD_TOP_SRC_Y = 0,
283 VP8_BTI_SCALING_FIELD_TOP_DST_Y = 1,
284 VP8_BTI_SCALING_FIELD_BOT_SRC_Y = 2,
285 VP8_BTI_SCALING_FIELD_BOT_DST_Y = 3,
286 VP8_BTI_SCALING_FRAME_FLATNESS_DST = 4,
287 VP8_BTI_SCALING_FIELD_TOP_FLATNESS_DST = 4,
288 VP8_BTI_SCALING_FIELD_BOT_FLATNESS_DST = 5,
289 VP8_BTI_SCALING_FRAME_MBVPROCSTATS_DST = 6,
290 VP8_BTI_SCALING_FIELD_TOP_MBVPROCSTATS_DST = 6,
291 VP8_BTI_SCALING_FIELD_BOT_MBVPROCSTATS_DST = 7,
292 VP8_BTI_SCALING_NUM_SURFACES = 8
293 };
294
295 struct vp8_scaling_curbe_data {
296 struct {
297 uint32_t input_picture_width: 16;
298 uint32_t input_picture_height: 16;
299 } dw0;
300
301 union {
302 uint32_t input_y_bti_frame;
303 uint32_t input_y_bti_top_field;
304 } dw1;
305
306 union {
307 uint32_t output_y_bti_frame;
308 uint32_t output_y_bti_top_field;
309 } dw2;
310
311 struct {
312 uint32_t input_y_bti_bottom_field;
313 } dw3;
314
315 struct {
316 uint32_t output_y_bti_bottom_field;
317 } dw4;
318
319 struct {
320 uint32_t flatness_threshold;
321 } dw5;
322
323 struct {
324 uint32_t enable_mb_flatness_check: 1;
325 uint32_t enable_mb_variance_output: 1;
326 uint32_t enable_mb_pixel_average_output: 1;
327 uint32_t reserved: 29;
328 } dw6;
329
330 struct {
331 uint32_t reserved;
332 } dw7;
333
334 union {
335 uint32_t flatness_output_bti_frame;
336 uint32_t flatness_output_bti_top_field;
337 } dw8;
338
339 struct {
340 uint32_t flatness_output_bti_bottom_field;
341 } dw9;
342
343 union {
344 uint32_t mbv_proc_stats_bti_frame;
345 uint32_t mbv_proc_stats_bti_top_field;
346 } dw10;
347
348 struct {
349 uint32_t mbv_proc_stats_bti_bottom_field;
350 } dw11;
351 };
352
353 #define VP8_SCALING_4X 0
354 #define VP8_SCALING_16X 1
355 #define NUM_VP8_SCALING 2
356
357 struct i965_encoder_vp8_scaling_context {
358 struct i965_gpe_context gpe_contexts[NUM_VP8_SCALING];
359 };
360
361 enum VP8_ME_MODES {
362 VP8_ME_MODE_ME16X_BEFORE_ME4X = 0,
363 VP8_ME_MODE_ME16X_ONLY = 1,
364 VP8_ME_MODE_ME4X_ONLY = 2,
365 VP8_ME_MODE_ME4X_AFTER_ME16X = 3
366 };
367
368 struct me_curbe_parameters {
369 unsigned int down_scaled_width_in_mbs;
370 unsigned int down_scaled_height_in_mbs;
371 int use_16x_me;
372 };
373
374 struct me_surface_parameters {
375 int use_16x_me;
376 };
377
378 struct vp8_search_path_delta {
379 char search_path_delta_x: 4;
380 char search_path_delta_y: 4;
381 };
382
383 enum vp8_binding_table_offset_me {
384 VP8_BTI_ME_MV_DATA = 0,
385 VP8_BTI_16X_ME_MV_DATA = 2,
386 VP8_BTI_ME_DISTORTION = 3,
387 VP8_BTI_ME_MIN_DIST_BRC_DATA = 4,
388 VP8_BTI_VME_INTER_PRED = 5,
389 VP8_BTI_ME_REF1_PIC = 6,
390 VP8_BTI_ME_REF2_PIC = 8,
391 VP8_BTI_ME_REF3_PIC = 10,
392 VP8_BTI_ME_NUM_SURFACES = 11
393 };
394
395 struct vp8_me_curbe_data {
396 struct {
397 uint32_t skip_mode_enable: 1;
398 uint32_t adaptive_enable: 1;
399 uint32_t bi_mix_dis: 1;
400 uint32_t reserved0: 2;
401 uint32_t early_ime_success_enable: 1;
402 uint32_t reserved1: 1;
403 uint32_t t8x8_flag_for_inter_enable: 1;
404 uint32_t reserved2: 16;
405 uint32_t early_ime_stop: 8;
406 } dw0;
407
408 struct {
409 uint32_t max_num_mvs: 6;
410 uint32_t reserved0: 10;
411 uint32_t bi_weight: 6;
412 uint32_t reserved1: 6;
413 uint32_t uni_mix_disable: 1;
414 uint32_t reserved2: 3;
415 } dw1;
416
417 struct {
418 uint32_t max_len_sp: 8;
419 uint32_t max_num_su: 8;
420 uint32_t reserved0: 16;
421 } dw2;
422
423 struct {
424 uint32_t src_size: 2;
425 uint32_t reserved0: 2;
426 uint32_t mb_type_remap: 2;
427 uint32_t src_Access: 1;
428 uint32_t ref_access: 1;
429 uint32_t search_ctrl: 3;
430 uint32_t dual_search_path_option: 1;
431 uint32_t sub_pel_mode: 2;
432 uint32_t skip_type: 1;
433 uint32_t disable_field_cache_allocation: 1;
434 uint32_t inter_chroma_mode: 1;
435 uint32_t ft_enable: 1;
436 uint32_t bme_disable_fbr: 1;
437 uint32_t block_based_skip_enable: 1;
438 uint32_t inter_sad: 2;
439 uint32_t intra_sad: 2;
440 uint32_t sub_mb_part_mask: 7;
441 uint32_t reserved1: 1;
442 } dw3;
443
444 struct {
445 uint32_t reserved0: 8;
446 uint32_t picture_height_minus1: 8;
447 uint32_t picture_width: 8;
448 uint32_t reserved1: 8;
449 } dw4;
450
451 struct {
452 uint32_t reserved0: 8;
453 uint32_t qp_prime_y: 8;
454 uint32_t ref_width: 8;
455 uint32_t ref_height: 8;
456
457 } dw5;
458
459 struct {
460 uint32_t reserved0: 3;
461 uint32_t me_mode: 2;
462 uint32_t reserved1: 3;
463 uint32_t super_combine_dist: 8;
464 uint32_t max_vmv_range: 16;
465 } dw6;
466
467 struct {
468 uint32_t reserved0: 16;
469 uint32_t mv_cost_scale_factor: 2;
470 uint32_t bilinear_enable: 1;
471 uint32_t src_field_polarity: 1;
472 uint32_t weightedsad_harr: 1;
473 uint32_t ac_only_haar: 1;
474 uint32_t ref_id_cost_mode: 1;
475 uint32_t reserved1: 1;
476 uint32_t skip_center_mask: 8;
477 } dw7;
478
479 struct {
480 uint32_t mode_0_cost: 8;
481 uint32_t mode_1_cost: 8;
482 uint32_t mode_2_cost: 8;
483 uint32_t mode_3_cost: 8;
484 } dw8;
485
486 struct {
487 uint32_t mode_4_cost: 8;
488 uint32_t mode_5_cost: 8;
489 uint32_t mode_6_cost: 8;
490 uint32_t mode_7_cost: 8;
491 } dw9;
492
493 struct {
494 uint32_t mode_8_cost: 8;
495 uint32_t mode_9_cost: 8;
496 uint32_t ref_id_cost: 8;
497 uint32_t chroma_intra_mode_cost: 8;
498 } dw10;
499
500 struct {
501 uint32_t mv_0_cost: 8;
502 uint32_t mv_1_cost: 8;
503 uint32_t mv_2_cost: 8;
504 uint32_t mv_3_cost: 8;
505 } dw11;
506
507 struct {
508 uint32_t mv_4_cost: 8;
509 uint32_t mv_5_cost: 8;
510 uint32_t mv_6_cost: 8;
511 uint32_t mv_7_cost: 8;
512 } dw12;
513
514 struct {
515 uint32_t num_ref_idx_l0_minus1: 8;
516 uint32_t num_ref_idx_l1_minus1: 8;
517 uint32_t actual_mb_width: 8;
518 uint32_t actual_mb_height: 8;
519 } dw13;
520
521 struct {
522 uint32_t l0_ref_pic_polarity_bits: 8;
523 uint32_t l1_ref_pic_polarity_bits: 2;
524 uint32_t reserved: 12;
525 } dw14;
526
527 struct {
528 uint32_t reserved;
529 } dw15;
530
531 struct {
532 struct vp8_search_path_delta sp_delta_0;
533 struct vp8_search_path_delta sp_delta_1;
534 struct vp8_search_path_delta sp_delta_2;
535 struct vp8_search_path_delta sp_delta_3;
536 } dw16;
537
538 struct {
539 struct vp8_search_path_delta sp_delta_4;
540 struct vp8_search_path_delta sp_delta_5;
541 struct vp8_search_path_delta sp_delta_6;
542 struct vp8_search_path_delta sp_delta_7;
543 } dw17;
544
545 struct {
546 struct vp8_search_path_delta sp_delta_8;
547 struct vp8_search_path_delta sp_delta_9;
548 struct vp8_search_path_delta sp_delta_10;
549 struct vp8_search_path_delta sp_delta_11;
550 } dw18;
551
552 struct {
553 struct vp8_search_path_delta sp_delta_12;
554 struct vp8_search_path_delta sp_delta_13;
555 struct vp8_search_path_delta sp_delta_14;
556 struct vp8_search_path_delta sp_delta_15;
557 } dw19;
558
559 struct {
560 struct vp8_search_path_delta sp_delta_16;
561 struct vp8_search_path_delta sp_delta_17;
562 struct vp8_search_path_delta sp_delta_18;
563 struct vp8_search_path_delta sp_delta_19;
564 } dw20;
565
566 struct {
567 struct vp8_search_path_delta sp_delta_20;
568 struct vp8_search_path_delta sp_delta_21;
569 struct vp8_search_path_delta sp_delta_22;
570 struct vp8_search_path_delta sp_delta_23;
571 } dw21;
572
573 struct {
574 struct vp8_search_path_delta sp_delta_24;
575 struct vp8_search_path_delta sp_delta_25;
576 struct vp8_search_path_delta sp_delta_26;
577 struct vp8_search_path_delta sp_delta_27;
578 } dw22;
579
580 struct {
581 struct vp8_search_path_delta sp_delta_28;
582 struct vp8_search_path_delta sp_delta_29;
583 struct vp8_search_path_delta sp_delta_30;
584 struct vp8_search_path_delta sp_delta_31;
585 } dw23;
586
587 struct {
588 struct vp8_search_path_delta sp_delta_32;
589 struct vp8_search_path_delta sp_delta_33;
590 struct vp8_search_path_delta sp_delta_34;
591 struct vp8_search_path_delta sp_delta_35;
592 } dw24;
593
594 struct {
595 struct vp8_search_path_delta sp_delta_36;
596 struct vp8_search_path_delta sp_delta_37;
597 struct vp8_search_path_delta sp_delta_38;
598 struct vp8_search_path_delta sp_delta_39;
599 } dw25;
600
601 struct {
602 struct vp8_search_path_delta sp_delta_40;
603 struct vp8_search_path_delta sp_delta_41;
604 struct vp8_search_path_delta sp_delta_42;
605 struct vp8_search_path_delta sp_delta_43;
606 } dw26;
607
608 struct {
609 struct vp8_search_path_delta sp_delta_44;
610 struct vp8_search_path_delta sp_delta_45;
611 struct vp8_search_path_delta sp_delta_46;
612 struct vp8_search_path_delta sp_delta_47;
613 } dw27;
614
615 struct {
616 struct vp8_search_path_delta sp_delta_48;
617 struct vp8_search_path_delta sp_delta_49;
618 struct vp8_search_path_delta sp_delta_50;
619 struct vp8_search_path_delta sp_delta_51;
620 } dw28;
621
622 struct {
623 struct vp8_search_path_delta sp_delta_52;
624 struct vp8_search_path_delta sp_delta_53;
625 struct vp8_search_path_delta sp_delta_54;
626 struct vp8_search_path_delta sp_delta_55;
627 } dw29;
628
629 struct {
630 uint32_t reserved0;
631 } dw30;
632
633 struct {
634 uint32_t reserved0;
635 } dw31;
636
637 struct {
638 uint32_t vp8_me_mv_output_data_bti;
639 } dw32;
640
641 struct {
642 uint32_t vp8_me_mv_input_data_bti;
643 } dw33;
644
645 struct {
646 uint32_t vp8_me_distorion_bti;
647 } dw34;
648
649 struct {
650 uint32_t vp8_me_min_dist_brc_bti;
651 } dw35;
652
653 struct {
654 uint32_t vp8_me_forward_ref_bti;
655 } dw36;
656
657 struct {
658 uint32_t vp8_me_backward_ref_bti;
659 } dw37;
660 };
661
662 #define VP8_ME_4X 0
663 #define VP8_ME_16X 1
664 #define NUM_VP8_ME 2
665
666 struct i965_encoder_vp8_me_context {
667 struct i965_gpe_context gpe_contexts[NUM_VP8_ME];
668 };
669
670 #define MAX_QP_VP8 127
671 #define NUM_QP_VP8 (MAX_QP_VP8 + 1)
672
673 #define DC_BIAS_SEGMENT_DEFAULT_VAL_VP8 1500
674
675 struct mbenc_surface_parameters {
676 int i_frame_dist_in_use;
677 struct i965_gpe_resource *me_brc_distortion_buffer;
678 };
679
680 enum vp8_binding_table_offset_mbenc {
681 VP8_BTI_MBENC_PER_MB_OUT = 0,
682 VP8_BTI_MBENC_CURR_Y = 1,
683 VP8_BTI_MBENC_CURR_UV = 2,
684
685 VP8_BTI_MBENC_MB_MODE_COST_LUMA = 3,
686 VP8_BTI_MBENC_BLOCK_MODE_COST = 4,
687 VP8_BTI_MBENC_CHROMA_RECON = 5,
688 VP8_BTI_MBENC_SEGMENTATION_MAP = 6,
689 VP8_BTI_MBENC_HISTOGRAM = 7,
690 VP8_BTI_MBENC_I_VME_DEBUG_STREAMOUT = 8,
691 VP8_BTI_MBENC_VME = 9,
692 VP8_BTI_MBENC_IDIST = 10,
693 VP8_BTI_MBENC_CURR_Y_DOWNSCALED = 11,
694 VP8_BTI_MBENC_VME_COARSE_INTRA = 12,
695
696 VP8_BTI_MBENC_MV_DATA_FROM_ME = 3,
697 VP8_BTI_MBENC_IND_MV_DATA = 4,
698 VP8_BTI_MBENC_REF_MB_COUNT = 5,
699 VP8_BTI_MBENC_INTER_PRED = 8,
700 VP8_BTI_MBENC_REF1_PIC = 9,
701 VP8_BTI_MBENC_REF2_PIC = 11,
702 VP8_BTI_MBENC_REF3_PIC = 13,
703 VP8_BTI_MBENC_P_PER_MB_QUANT = 14,
704 VP8_BTI_MBENC_INTER_PRED_DISTORTION = 15,
705 VP8_BTI_MBENC_PRED_MV_DATA = 16,
706 VP8_BTI_MBENC_MODE_COST_UPDATE = 17,
707 VP8_BTI_MBENC_P_VME_DEBUG_STREAMOUT = 18,
708 VP8_BTI_MBENC_NUM_SURFACES = 19
709 };
710
711 struct vp8_mbenc_i_frame_curbe_data {
712 struct {
713 uint32_t frame_width: 16;
714 uint32_t frame_height: 16;
715 } dw0;
716
717 struct {
718 uint32_t frame_type: 1;
719 uint32_t enable_segmentation: 1;
720 uint32_t enable_hw_intra_prediction: 1;
721 uint32_t enable_debug_dumps: 1;
722 uint32_t enable_coeff_clamp: 1;
723 uint32_t enable_chroma_ip_enhancement: 1;
724 uint32_t enable_mpu_histogram_update: 1;
725 uint32_t reserved0: 1;
726 uint32_t vme_enable_tm_check: 1;
727 uint32_t vme_distortion_measure: 2;
728 uint32_t reserved1: 21;
729 } dw1;
730
731 struct {
732 uint32_t lambda_seg_0: 16;
733 uint32_t lambda_seg_1: 16;
734 } dw2;
735
736 struct {
737 uint32_t lambda_seg_2: 16;
738 uint32_t lambda_seg_3: 16;
739 } dw3;
740
741 struct {
742 uint32_t all_dc_bias_segment_0: 16;
743 uint32_t all_dc_bias_segment_1: 16;
744 } dw4;
745
746 struct {
747 uint32_t all_dc_bias_segment_2: 16;
748 uint32_t all_dc_bias_segment_3: 16;
749 } dw5;
750
751 struct {
752 uint32_t chroma_dc_de_quant_segment_0: 16;
753 uint32_t chroma_dc_de_quant_segment_1: 16;
754 } dw6;
755
756 struct {
757 uint32_t chroma_dc_de_quant_segment_2: 16;
758 uint32_t chroma_dc_de_quant_segment_3: 16;
759 } dw7;
760
761 struct {
762 uint32_t chroma_ac_de_quant_segment0: 16;
763 uint32_t chroma_ac_de_quant_segment1: 16;
764 } dw8;
765
766 struct {
767 uint32_t chroma_ac_de_quant_segment2: 16;
768 uint32_t chroma_ac_de_quant_segment3: 16;
769 } dw9;
770
771 struct {
772 uint32_t chroma_ac0_threshold0_segment0: 16;
773 uint32_t chroma_ac0_threshold1_segment0: 16;
774 } dw10;
775
776 struct {
777 uint32_t chroma_ac0_threshold0_segment1: 16;
778 uint32_t chroma_ac0_threshold1_segment1: 16;
779 } dw11;
780
781 struct {
782 uint32_t chroma_ac0_threshold0_segment2: 16;
783 uint32_t chroma_ac0_threshold1_segment2: 16;
784 } dw12;
785
786 struct {
787 uint32_t chroma_ac0_threshold0_segment3: 16;
788 uint32_t chroma_ac0_threshold1_segment3: 16;
789 } dw13;
790
791 struct {
792 uint32_t chroma_dc_threshold0_segment0: 16;
793 uint32_t chroma_dc_threshold1_segment0: 16;
794 } dw14;
795
796 struct {
797 uint32_t chroma_dc_threshold2_segment0: 16;
798 uint32_t chroma_dc_threshold3_segment0: 16;
799 } dw15;
800
801 struct {
802 uint32_t chroma_dc_threshold0_segment1: 16;
803 uint32_t chroma_dc_threshold1_segment1: 16;
804 } dw16;
805
806 struct {
807 uint32_t chroma_dc_threshold2_segment1: 16;
808 uint32_t chroma_dc_threshold3_segment1: 16;
809 } dw17;
810
811 struct {
812 uint32_t chroma_dc_threshold0_segment2: 16;
813 uint32_t chroma_dc_threshold1_segment2: 16;
814 } dw18;
815
816 struct {
817 uint32_t chroma_dc_threshold2_segment2: 16;
818 uint32_t chroma_dc_threshold3_segment2: 16;
819 } dw19;
820
821 struct {
822 uint32_t chroma_dc_threshold0_segment3: 16;
823 uint32_t chroma_dc_threshold1_segment3: 16;
824 } dw20;
825
826 struct {
827 uint32_t chroma_dc_threshold2_segment3: 16;
828 uint32_t chroma_dc_threshold3_segment3: 16;
829 } dw21;
830
831 struct {
832 uint32_t chroma_ac1_threshold_segment0: 16;
833 uint32_t chroma_ac1_threshold_segment1: 16;
834 } dw22;
835
836 struct {
837 uint32_t chroma_ac1_threshold_segment2: 16;
838 uint32_t chroma_ac1_threshold_segment3: 16;
839 } dw23;
840
841 struct {
842 uint32_t vme_16x16_cost_segment0: 8;
843 uint32_t vme_16x16_cost_segment1: 8;
844 uint32_t vme_16x16_cost_segment2: 8;
845 uint32_t vme_16x16_cost_segment3: 8;
846 } dw24;
847
848 struct {
849 uint32_t vme_4x4_cost_segment0: 8;
850 uint32_t vme_4x4_cost_segment1: 8;
851 uint32_t vme_4x4_cost_segment2: 8;
852 uint32_t vme_4x4_cost_segment3: 8;
853 } dw25;
854
855 struct {
856 uint32_t vme_16x16_non_dc_penalty_segment0: 8;
857 uint32_t vme_16x16_non_dc_penalty_segment1: 8;
858 uint32_t vme_16x16_non_dc_penalty_segment2: 8;
859 uint32_t vme_16x16_non_dc_penalty_segment3: 8;
860 } dw26;
861
862 struct {
863 uint32_t vme_4x4_non_dc_penalty_segment0: 8;
864 uint32_t vme_4x4_non_dc_penalty_segment1: 8;
865 uint32_t vme_4x4_non_dc_penalty_segment2: 8;
866 uint32_t vme_4x4_non_dc_penalty_segment3: 8;
867 } dw27;
868
869 struct {
870 uint32_t reserved;
871 } dw28;
872
873 struct {
874 uint32_t reserved;
875 } dw29;
876
877 struct {
878 uint32_t reserved;
879 } dw30;
880
881 struct {
882 uint32_t reserved;
883 } dw31;
884
885 struct {
886 uint32_t mb_enc_per_mb_out_data_surf_bti;
887 } dw32;
888
889 struct {
890 uint32_t mb_enc_curr_y_bti;
891 } dw33;
892
893 struct {
894 uint32_t mb_enc_curr_uv_bti;
895 } dw34;
896
897 struct {
898 uint32_t mb_mode_cost_luma_bti;
899 } dw35;
900
901 struct {
902 uint32_t mb_enc_block_mode_cost_bti;
903 } dw36;
904
905 struct {
906 uint32_t chroma_recon_surf_bti;
907 } dw37;
908
909 struct {
910 uint32_t segmentation_map_bti;
911 } dw38;
912
913 struct {
914 uint32_t histogram_bti;
915 } dw39;
916
917 struct {
918 uint32_t mb_enc_vme_debug_stream_out_bti;
919 } dw40;
920
921 struct {
922 uint32_t vme_bti;
923 } dw41;
924
925 struct {
926 uint32_t idist_surface_bti;
927 } dw42;
928
929 struct {
930 uint32_t curr_y_down_scaled_bti;
931 } dw43;
932
933 struct {
934 uint32_t vme_coarse_intra_bti;
935 } dw44;
936 };
937
938 struct vp8_mbenc_p_frame_curbe_data {
939 struct {
940 uint32_t frame_width: 16;
941 uint32_t frame_height: 16;
942 } dw0;
943
944 struct {
945 uint32_t frame_type: 1;
946 uint32_t multiple_pred: 2;
947 uint32_t hme_enable: 1;
948 uint32_t hme_combine_overlap: 2;
949 uint32_t all_fractional: 1;
950 uint32_t enable_temporal_scalability: 1;
951 uint32_t hme_combined_extra_su: 8;
952 uint32_t ref_frame_flags: 4;
953 uint32_t enable_segmentation: 1;
954 uint32_t enable_segmentation_info_update: 1;
955 uint32_t enable_coeff_clamp: 1;
956 uint32_t multi_reference_qp_check: 1;
957 uint32_t mode_cost_enable_flag: 1;
958 uint32_t main_ref: 6;
959 uint32_t enable_debug_dumps: 1;
960 } dw1;
961
962 struct {
963 uint32_t lambda_intra_segment0: 16;
964 uint32_t lambda_inter_segment0: 16;
965 } dw2;
966
967 struct {
968 uint32_t lambda_intra_segment1: 16;
969 uint32_t lambda_inter_segment1: 16;
970 } dw3;
971
972 struct {
973 uint32_t lambda_intra_segment2: 16;
974 uint32_t lambda_inter_segment2: 16;
975 } dw4;
976
977 struct {
978 uint32_t lambda_intra_segment3: 16;
979 uint32_t lambda_inter_segment3: 16;
980 } dw5;
981
982 struct {
983 uint32_t reference_frame_sign_bias_0: 8;
984 uint32_t reference_frame_sign_bias_1: 8;
985 uint32_t reference_frame_sign_bias_2: 8;
986 uint32_t reference_frame_sign_bias_3: 8;
987 } dw6;
988
989 struct {
990 uint32_t raw_dist_threshold: 16;
991 uint32_t temporal_layer_id: 8;
992 uint32_t reserved_mbz: 8;
993 } dw7;
994
995 struct {
996 uint32_t skip_mode_enable: 1;
997 uint32_t adaptive_search_enable: 1;
998 uint32_t bidirectional_mix_disbale: 1;
999 uint32_t reserved_mbz1: 2;
1000 uint32_t early_ime_success_enable: 1;
1001 uint32_t reserved_mbz2: 1;
1002 uint32_t transform8x8_flag_for_inter_enable: 1;
1003 uint32_t reserved_mbz3: 16;
1004 uint32_t early_ime_successful_stop_threshold: 8;
1005 } dw8;
1006
1007 struct {
1008 uint32_t max_num_of_motion_vectors: 6;
1009 uint32_t reserved_mbz1: 2;
1010 uint32_t ref_id_polarity_bits: 8;
1011 uint32_t bidirectional_weight: 6;
1012 uint32_t reserved_mbz2: 6;
1013 uint32_t unidirection_mix_enable: 1;
1014 uint32_t ref_pixel_bias_enable: 1;
1015 uint32_t reserved_mbz3: 2;
1016 } dw9;
1017
1018 struct {
1019 uint32_t max_fixed_search_path_length: 8;
1020 uint32_t maximum_search_path_length: 8;
1021 uint32_t reserved_mbz: 16;
1022 } dw10;
1023
1024 struct {
1025 uint32_t source_block_size: 2;
1026 uint32_t reserved_mbz1: 2;
1027 uint32_t inter_mb_type_road_map: 2;
1028 uint32_t source_access: 1;
1029 uint32_t reference_access: 1;
1030 uint32_t search_control: 3;
1031 uint32_t dual_search_path_option: 1;
1032 uint32_t sub_pel_mode: 2;
1033 uint32_t skip_mode_type: 1;
1034 uint32_t disable_field_cache_allocation: 1;
1035 uint32_t process_inter_chroma_pixels_mode: 1;
1036 uint32_t forward_trans_form_skip_check_enable: 1;
1037 uint32_t bme_disable_for_fbr_message: 1;
1038 uint32_t block_based_skip_enable: 1;
1039 uint32_t inter_sad_measure_adjustment: 2;
1040 uint32_t intra_sad_measure_adjustment: 2;
1041 uint32_t submacro_block_subPartition_mask: 6;
1042 uint32_t reserved_mbz2: 1;
1043 } dw11;
1044
1045 struct {
1046 uint32_t reserved_mbz: 16;
1047 uint32_t reference_search_windows_width: 8;
1048 uint32_t reference_search_windows_height: 8;
1049 } dw12;
1050
1051 struct {
1052 uint32_t mode_0_3_cost_seg0;
1053 } dw13;
1054
1055 struct {
1056 uint32_t mode_4_7_cost_seg0;
1057 } dw14;
1058
1059 struct {
1060 uint32_t mode_8_9_ref_id_chroma_cost_seg0;
1061 } dw15;
1062
1063 struct {
1064 struct vp8_search_path_delta sp_delta_0;
1065 struct vp8_search_path_delta sp_delta_1;
1066 struct vp8_search_path_delta sp_delta_2;
1067 struct vp8_search_path_delta sp_delta_3;
1068 } dw16;
1069
1070 struct {
1071 struct vp8_search_path_delta sp_delta_4;
1072 struct vp8_search_path_delta sp_delta_5;
1073 struct vp8_search_path_delta sp_delta_6;
1074 struct vp8_search_path_delta sp_delta_7;
1075 } dw17;
1076
1077 struct {
1078 struct vp8_search_path_delta sp_delta_8;
1079 struct vp8_search_path_delta sp_delta_9;
1080 struct vp8_search_path_delta sp_delta_10;
1081 struct vp8_search_path_delta sp_delta_11;
1082 } dw18;
1083
1084 struct {
1085 struct vp8_search_path_delta sp_delta_12;
1086 struct vp8_search_path_delta sp_delta_13;
1087 struct vp8_search_path_delta sp_delta_14;
1088 struct vp8_search_path_delta sp_delta_15;
1089 } dw19;
1090
1091 struct {
1092 struct vp8_search_path_delta sp_delta_16;
1093 struct vp8_search_path_delta sp_delta_17;
1094 struct vp8_search_path_delta sp_delta_18;
1095 struct vp8_search_path_delta sp_delta_19;
1096 } dw20;
1097
1098 struct {
1099 struct vp8_search_path_delta sp_delta_20;
1100 struct vp8_search_path_delta sp_delta_21;
1101 struct vp8_search_path_delta sp_delta_22;
1102 struct vp8_search_path_delta sp_delta_23;
1103 } dw21;
1104
1105 struct {
1106 struct vp8_search_path_delta sp_delta_24;
1107 struct vp8_search_path_delta sp_delta_25;
1108 struct vp8_search_path_delta sp_delta_26;
1109 struct vp8_search_path_delta sp_delta_27;
1110 } dw22;
1111
1112 struct {
1113 struct vp8_search_path_delta sp_delta_28;
1114 struct vp8_search_path_delta sp_delta_29;
1115 struct vp8_search_path_delta sp_delta_30;
1116 struct vp8_search_path_delta sp_delta_31;
1117 } dw23;
1118
1119 struct {
1120 struct vp8_search_path_delta sp_delta_32;
1121 struct vp8_search_path_delta sp_delta_33;
1122 struct vp8_search_path_delta sp_delta_34;
1123 struct vp8_search_path_delta sp_delta_35;
1124 } dw24;
1125
1126 struct {
1127 struct vp8_search_path_delta sp_delta_36;
1128 struct vp8_search_path_delta sp_delta_37;
1129 struct vp8_search_path_delta sp_delta_38;
1130 struct vp8_search_path_delta sp_delta_39;
1131 } dw25;
1132
1133 struct {
1134 struct vp8_search_path_delta sp_delta_40;
1135 struct vp8_search_path_delta sp_delta_41;
1136 struct vp8_search_path_delta sp_delta_42;
1137 struct vp8_search_path_delta sp_delta_43;
1138 };
1139
1140 struct {
1141 struct vp8_search_path_delta sp_delta_44;
1142 struct vp8_search_path_delta sp_delta_45;
1143 struct vp8_search_path_delta sp_delta_46;
1144 struct vp8_search_path_delta sp_delta_47;
1145 } dw27;
1146
1147 struct {
1148 struct vp8_search_path_delta sp_delta_48;
1149 struct vp8_search_path_delta sp_delta_49;
1150 struct vp8_search_path_delta sp_delta_50;
1151 struct vp8_search_path_delta sp_delta_51;
1152 } dw28;
1153
1154 struct {
1155 struct vp8_search_path_delta sp_delta_52;
1156 struct vp8_search_path_delta sp_delta_53;
1157 struct vp8_search_path_delta sp_delta_54;
1158 struct vp8_search_path_delta sp_delta_55;
1159 } dw29;
1160
1161 struct {
1162 uint32_t mv_0_3_cost_seg0;
1163 } dw30;
1164
1165 struct {
1166 uint32_t mv_4_7_cost_seg0;
1167 } dw31;
1168
1169 struct {
1170 uint32_t intra_16x16_no_dc_penalty_segment0: 8;
1171 uint32_t intra_16x16_no_dc_penalty_segment1: 8;
1172 uint32_t reserved_mbz1: 7;
1173 uint32_t bilinear_enable: 1;
1174 uint32_t reserved_mbz2: 8;
1175 } dw32;
1176
1177 struct {
1178 uint32_t hme_combine_len: 16;
1179 uint32_t intra_16x16_no_dc_penalty_segment2: 8;
1180 uint32_t intra_16x16_no_dc_penalty_segment3: 8;
1181 } dw33;
1182
1183 struct {
1184 uint32_t mv_ref_cost_context_0_0_0: 16;
1185 uint32_t mv_ref_cost_context_0_0_1: 16;
1186 } dw34;
1187
1188 struct {
1189 uint32_t mv_ref_cost_context_0_1_0: 16;
1190 uint32_t mv_ref_cost_context_0_1_1: 16;
1191 } dw35;
1192
1193 struct {
1194 uint32_t mv_ref_cost_context_0_2_0: 16;
1195 uint32_t mv_ref_cost_context_0_2_1: 16;
1196 } dw36;
1197
1198 struct {
1199 uint32_t mv_ref_cost_context_0_3_0: 16;
1200 uint32_t mv_ref_cost_context_0_3_1: 16;
1201 } dw37;
1202
1203 struct {
1204 uint32_t mv_ref_cost_context_1_0_0: 16;
1205 uint32_t mv_ref_cost_context_1_0_1: 16;
1206 } dw38;
1207
1208 struct {
1209 uint32_t mv_ref_cost_context_1_1_0: 16;
1210 uint32_t mv_ref_cost_context_1_1_1: 16;
1211 } dw39;
1212
1213 struct {
1214 uint32_t mv_ref_cost_context_1_2_0: 16;
1215 uint32_t mv_ref_cost_context_1_2_1: 16;
1216 } dw40;
1217
1218 struct {
1219 uint32_t mv_ref_cost_context_1_3_0: 16;
1220 uint32_t mv_ref_cost_context_1_3_1: 16;
1221 } dw41;
1222
1223 struct {
1224 uint32_t mv_ref_cost_context_2_0_0: 16;
1225 uint32_t mv_ref_cost_context_2_0_1: 16;
1226 };
1227
1228 struct {
1229 uint32_t mv_ref_cost_context_2_1_0: 16;
1230 uint32_t mv_ref_cost_context_2_1_1: 16;
1231 };
1232
1233 struct {
1234 uint32_t mv_ref_cost_context_2_2_0: 16;
1235 uint32_t mv_ref_cost_context_2_2_1: 16;
1236 } dw44;
1237
1238 struct {
1239 uint32_t mv_ref_cost_context_2_3_0: 16;
1240 uint32_t mv_ref_cost_context_2_3_1: 16;
1241 } dw45;
1242
1243 struct {
1244 uint32_t mv_ref_cost_context_3_0_0: 16;
1245 uint32_t mv_ref_cost_context_3_0_1: 16;
1246 } dw46;
1247
1248 struct {
1249 uint32_t mv_ref_cost_context_3_1_0: 16;
1250 uint32_t mv_ref_cost_context_3_1_1: 16;
1251 } dw47;
1252
1253 struct {
1254 uint32_t mv_ref_cost_context_3_2_0: 16;
1255 uint32_t mv_ref_cost_context_3_2_1: 16;
1256 } dw48;
1257
1258 struct {
1259 uint32_t mv_ref_cost_context_3_3_0: 16;
1260 uint32_t mv_ref_cost_context_3_3_1: 16;
1261 } dw49;
1262
1263 struct {
1264 uint32_t mv_ref_cost_context_4_0_0: 16;
1265 uint32_t mv_ref_cost_context_4_0_1: 16;
1266 } dw50;
1267
1268 struct {
1269 uint32_t mv_ref_cost_context_4_1_0: 16;
1270 uint32_t mv_ref_cost_context_4_1_1: 16;
1271 } dw51;
1272
1273 struct {
1274 uint32_t mv_ref_cost_context_4_2_0: 16;
1275 uint32_t mv_ref_cost_context_4_2_1: 16;
1276 };
1277
1278 struct {
1279 uint32_t mv_ref_cost_context_4_3_0: 16;
1280 uint32_t mv_ref_cost_context_4_3_1: 16;
1281 };
1282
1283 struct {
1284 uint32_t mv_ref_cost_context_5_0_0: 16;
1285 uint32_t mv_ref_cost_context_5_0_1: 16;
1286 };
1287
1288 struct {
1289 uint32_t mv_ref_cost_context_5_1_0: 16;
1290 uint32_t mv_ref_cost_context_5_1_1: 16;
1291 } dw55;
1292
1293 struct {
1294 uint32_t mv_ref_cost_context_5_2_0: 16;
1295 uint32_t mv_ref_cost_context_5_2_1: 16;
1296 } dw56;
1297
1298 struct {
1299 uint32_t mv_ref_cost_context_5_3_0: 16;
1300 uint32_t mv_ref_cost_context_5_3_1: 16;
1301 } dw57;
1302
1303 struct {
1304 uint32_t enc_cost_16x16: 16;
1305 uint32_t enc_cost_16x8: 16;
1306 } dw58;
1307
1308 struct {
1309 uint32_t enc_cost_8x8: 16;
1310 uint32_t enc_cost_4x4: 16;
1311 } dw59;
1312
1313 struct {
1314 uint32_t frame_count_probability_ref_frame_cost_0: 16;
1315 uint32_t frame_count_probability_ref_frame_cost_1: 16;
1316 } dw60;
1317
1318 struct {
1319 uint32_t frame_count_probability_ref_frame_cost_2: 16;
1320 uint32_t frame_count_probability_ref_frame_cost_3: 16;
1321 } dw61;
1322
1323 struct {
1324 uint32_t average_qp_of_last_ref_frame: 8;
1325 uint32_t average_qp_of_gold_ref_frame: 8;
1326 uint32_t average_qp_of_alt_ref_frame: 8;
1327 uint32_t reserved_mbz: 8;
1328 } dw62;
1329
1330 struct {
1331 uint32_t intra_4x4_no_dc_penalty_segment0: 8;
1332 uint32_t intra_4x4_no_dc_penalty_segment1: 8;
1333 uint32_t intra_4x4_no_dc_penalty_segment2: 8;
1334 uint32_t intra_4x4_no_dc_penalty_segment3: 8;
1335 } dw63;
1336
1337 struct {
1338 uint32_t mode_0_3_cost_seg1;
1339 } dw64;
1340
1341 struct {
1342 uint32_t mode_4_7_cost_seg1;
1343 } dw65;
1344
1345 struct {
1346 uint32_t mode_8_9_ref_id_chroma_cost_seg1;
1347 } dw66;
1348
1349 struct {
1350 uint32_t mv_0_3_cost_seg1;
1351 } dw67;
1352
1353 struct {
1354 uint32_t mv_4_7_cost_seg1;
1355 } dw68;
1356
1357 struct {
1358 uint32_t mode_0_3_cost_seg2;
1359 } dw69;
1360
1361 struct {
1362 uint32_t mode_4_7_cost_seg2;
1363 } dw70;
1364
1365 struct {
1366 uint32_t mode_8_9_ref_id_chroma_cost_seg2;
1367 } dw71;
1368
1369 struct {
1370 uint32_t mv_0_3_cost_seg2;
1371 } dw72;
1372
1373 struct {
1374 uint32_t mv_4_7_cost_seg2;
1375 } dw73;
1376
1377 struct {
1378 uint32_t mode_0_3_cost_seg3;
1379 } dw74;
1380
1381 struct {
1382 uint32_t mode_4_7_cost_seg3;
1383 } dw75;
1384
1385 struct {
1386 uint32_t mode_8_9_ref_id_chroma_cost_seg3;
1387 } dw76;
1388
1389 struct {
1390 uint32_t mv_0_3_cost_seg3;
1391 } dw77;
1392
1393 struct {
1394 uint32_t mv_4_7_cost_seg3;
1395 } dw78;
1396
1397 struct {
1398 uint32_t new_mv_skip_threshold_segment0: 16;
1399 uint32_t new_mv_skip_threshold_segment1: 16;
1400 } dw79;
1401
1402 struct {
1403 uint32_t new_mv_skip_threshold_segment2: 16;
1404 uint32_t new_mv_skip_threshold_segment3: 16;
1405 } dw80;
1406
1407 struct {
1408 uint32_t per_mb_output_data_surface_bti;
1409 } dw81;
1410
1411 struct {
1412 uint32_t current_picture_y_surface_bti;
1413 } dw82;
1414
1415 struct {
1416 uint32_t current_picture_interleaved_uv_surface_bti;
1417 } dw83;
1418
1419 struct {
1420 uint32_t hme_mv_data_surface_bti;
1421 } dw84;
1422
1423 struct {
1424 uint32_t mv_data_surface_bti;
1425 } dw85;
1426
1427 struct {
1428 uint32_t mb_count_per_reference_frame_bti;
1429 } dw86;
1430
1431 struct {
1432 uint32_t vme_inter_prediction_bti;
1433 } dw87;
1434
1435 struct {
1436 uint32_t active_ref1_bti;
1437 } dw88;
1438
1439 struct {
1440 uint32_t active_ref2_bti;
1441 } dw89;
1442
1443 struct {
1444 uint32_t active_ref3_bti;
1445 } dw90;
1446
1447 struct {
1448 uint32_t per_mb_quant_data_bti;
1449 } dw91;
1450
1451 struct {
1452 uint32_t segment_map_bti;
1453 } dw92;
1454
1455 struct {
1456 uint32_t inter_prediction_distortion_bti;
1457 } dw93;
1458
1459 struct {
1460 uint32_t histogram_bti;
1461 } dw94;
1462
1463 struct {
1464 uint32_t pred_mv_data_bti;
1465 } dw95;
1466
1467 struct {
1468 uint32_t mode_cost_update_bti;
1469 } dw96;
1470
1471 struct {
1472 uint32_t kernel_debug_dump_bti;
1473 } dw97;
1474 };
1475
1476 #define VP8_MBENC_I_FRAME_DIST 0
1477 #define VP8_MBENC_I_FRAME_LUMA 1
1478 #define VP8_MBENC_I_FRAME_CHROMA 2
1479 #define VP8_MBENC_P_FRAME 3
1480 #define NUM_VP8_MBENC 4
1481
1482 struct i965_encoder_vp8_mbenc_context {
1483 struct i965_gpe_context gpe_contexts[NUM_VP8_MBENC];
1484 dri_bo *luma_chroma_dynamic_buffer;
1485 };
1486
1487 enum vp8_binding_table_offset_brc_update {
1488 VP8_BTI_BRC_UPDATE_HISTORY = 1,
1489 VP8_BTI_BRC_UPDATE_PAK_STATISTICS_OUTPUT = 2,
1490 VP8_BTI_BRC_UPDATE_MFX_ENCODER_CFG_READ = 3,
1491 VP8_BTI_BRC_UPDATE_MFX_ENCODER_CFG_WRITE = 4,
1492 VP8_BTI_BRC_UPDATE_MBENC_CURBE_READ = 5,
1493 VP8_BTI_BRC_UPDATE_MBENC_CURBE_WRITE = 6,
1494 VP8_BTI_BRC_UPDATE_DISTORTION_SURFACE = 7,
1495 VP8_BTI_BRC_UPDATE_CONSTANT_DATA = 8,
1496 VP8_BTI_BRC_UPDATE_SEGMENT_MAP = 9,
1497 VP8_BTI_BRC_UPDATE_MPU_CURBE_READ = 10,
1498 VP8_BTI_BRC_UPDATE_MPU_CURBE_WRITE = 11,
1499 VP8_BTI_BRC_UPDATE_TPU_CURBE_READ = 12,
1500 VP8_BTI_BRC_UPDATE_TPU_CURBE_WRITE = 13,
1501 VP8_BTI_BRC_UPDATE_NUM_SURFACES = 14
1502 };
1503
1504 struct brc_update_surface_parameters {
1505 struct i965_gpe_context *mbenc_gpe_context;
1506 struct i965_gpe_context *mpu_gpe_context;
1507 struct i965_gpe_context *tpu_gpe_context;
1508 };
1509
1510 struct vp8_brc_update_curbe_data {
1511 struct {
1512 uint32_t target_size;
1513 } dw0;
1514
1515 struct {
1516 uint32_t frame_number;
1517 } dw1;
1518
1519 struct {
1520 uint32_t picture_header_size;
1521 } dw2;
1522
1523 struct {
1524 uint32_t start_global_adjust_frame0: 16;
1525 uint32_t start_global_adjust_frame1: 16;
1526 } dw3;
1527
1528 struct {
1529 uint32_t start_global_adjust_frame2: 16;
1530 uint32_t start_global_adjust_frame3: 16;
1531 } dw4;
1532
1533 struct {
1534 uint32_t target_size_flag: 8;
1535 uint32_t brc_flag: 8;
1536 uint32_t max_num_paks: 8;
1537 uint32_t curr_frame_type: 8;
1538 } dw5;
1539
1540 struct {
1541 uint32_t tid: 8;
1542 uint32_t num_t_levels: 8;
1543 uint32_t reserved0: 16;
1544 } dw6;
1545
1546 struct {
1547 uint32_t reserved0;
1548 } dw7;
1549
1550 struct {
1551 uint32_t start_global_adjust_mult0: 8;
1552 uint32_t start_global_adjust_mult1: 8;
1553 uint32_t start_global_adjust_mult2: 8;
1554 uint32_t start_global_adjust_mult3: 8;
1555 } dw8;
1556
1557 struct {
1558 uint32_t start_global_adjust_mult4: 8;
1559 uint32_t start_global_adjust_div0: 8;
1560 uint32_t start_global_adjust_div1: 8;
1561 uint32_t start_global_adjust_div2: 8;
1562 } dw9;
1563
1564 struct {
1565 uint32_t start_global_adjust_div3: 8;
1566 uint32_t start_global_adjust_div4: 8;
1567 uint32_t qp_threshold0: 8;
1568 uint32_t qp_threshold1: 8;
1569 } dw10;
1570
1571 struct {
1572 uint32_t qp_threshold2: 8;
1573 uint32_t qp_threshold3: 8;
1574 uint32_t g_rate_ratio_threshold0: 8;
1575 uint32_t g_rate_ratio_threshold1: 8;
1576 } dw11;
1577
1578 struct {
1579 uint32_t g_rate_ratio_threshold2: 8;
1580 uint32_t g_rate_ratio_threshold3: 8;
1581 uint32_t g_rate_ratio_threshold4: 8;
1582 uint32_t g_rate_ratio_threshold5: 8;
1583 } dw12;
1584
1585 struct {
1586 uint32_t g_rate_ratio_threshold_qp0: 8;
1587 uint32_t g_rate_ratio_threshold_qp1: 8;
1588 uint32_t g_rate_ratio_threshold_qp2: 8;
1589 uint32_t g_rate_ratio_threshold_qp3: 8;
1590 } dw13;
1591
1592 struct {
1593 uint32_t g_rate_ratio_threshold_qp4: 8;
1594 uint32_t g_rate_ratio_threshold_qp5: 8;
1595 uint32_t g_rate_ratio_threshold_qp6: 8;
1596 uint32_t index_of_previous_qp: 8;
1597 } dw14;
1598
1599 struct {
1600 uint32_t frame_width_in_mb: 16;
1601 uint32_t frame_height_in_mb: 16;
1602 } dw15;
1603
1604 struct {
1605 uint32_t p_frame_qp_seg0: 8;
1606 uint32_t p_frame_qp_seg1: 8;
1607 uint32_t p_frame_qp_seg2: 8;
1608 uint32_t p_frame_qp_seg3: 8;
1609 } dw16;
1610
1611 struct {
1612 uint32_t key_frame_qp_seg0: 8;
1613 uint32_t key_frame_qp_seg1: 8;
1614 uint32_t key_frame_qp_seg2: 8;
1615 uint32_t key_frame_qp_seg3: 8;
1616 } dw17;
1617
1618 struct {
1619 uint32_t qdelta_plane0: 8;
1620 uint32_t qdelta_plane1: 8;
1621 uint32_t qdelta_plane2: 8;
1622 uint32_t qdelta_plane3: 8;
1623 } dw18;
1624
1625 struct {
1626 uint32_t qdelta_plane4: 8;
1627 uint32_t qindex: 8;
1628 uint32_t main_ref: 8;
1629 uint32_t ref_frame_flags: 8;
1630 } dw19;
1631
1632 struct {
1633 uint32_t seg_on: 8;
1634 uint32_t mb_rc: 8;
1635 uint32_t brc_method: 8;
1636 uint32_t vme_intra_prediction: 8;
1637 } dw20;
1638
1639 struct {
1640 uint32_t current_frame_qpindex: 8;
1641 uint32_t last_frame_qpindex: 8;
1642 uint32_t gold_frame_qpindex: 8;
1643 uint32_t alt_frame_qpindex: 8;
1644 } dw21;
1645
1646 struct {
1647 uint32_t historyt_buffer_bti;
1648 } dw22;
1649
1650 struct {
1651 uint32_t pak_statistics_bti;
1652 } dw23;
1653
1654 struct {
1655 uint32_t mfx_vp8_encoder_cfg_read_bti;
1656 } dw24;
1657
1658 struct {
1659 uint32_t mfx_vp8_encoder_cfg_write_bti;
1660 } dw25;
1661
1662 struct {
1663 uint32_t mbenc_curbe_read_bti;
1664 } dw26;
1665
1666 struct {
1667 uint32_t mbenc_curbe_write_bti;
1668 } dw27;
1669
1670 struct {
1671 uint32_t distortion_bti;
1672 } dw28;
1673
1674 struct {
1675 uint32_t constant_data_bti;
1676 } dw29;
1677
1678 struct {
1679 uint32_t segment_map_bti;
1680 } dw30;
1681
1682 struct {
1683 uint32_t mpu_curbe_read_bti;
1684 } dw31;
1685
1686 struct {
1687 uint32_t mpu_curbe_write_bti;
1688 } dw32;
1689
1690 struct {
1691 uint32_t tpu_curbe_read_bti;
1692 } dw33;
1693
1694 struct {
1695 uint32_t tpu_curbe_write_bti;
1696 } dw34;
1697 };
1698
1699 #define VP8_BRC_UPDATE 0
1700 #define NUM_VP8_BRC_UPDATE 1
1701
1702 struct i965_encoder_vp8_brc_update_context {
1703 struct i965_gpe_context gpe_contexts[NUM_VP8_BRC_UPDATE];
1704 };
1705
1706 enum vp8_binding_table_offset_mpu {
1707 VP8_BTI_MPU_HISTOGRAM = 0,
1708 VP8_BTI_MPU_REF_MODE_PROBABILITY = 1,
1709 VP8_BTI_MPU_CURR_MODE_PROBABILITY = 2,
1710 VP8_BTI_MPU_REF_TOKEN_PROBABILITY = 3,
1711 VP8_BTI_MPU_CURR_TOKEN_PROBABILITY = 4,
1712 VP8_BTI_MPU_HEADER_BITSTREAM = 5,
1713 VP8_BTI_MPU_HEADER_METADATA = 6,
1714 VP8_BTI_MPU_PICTURE_STATE = 7,
1715 VP8_BTI_MPU_MPU_BITSTREAM = 8,
1716 VP8_BTI_MPU_TOKEN_BITS_DATA_TABLE = 9,
1717 VP8_BTI_MPU_VME_DEBUG_STREAMOUT = 10,
1718 VP8_BTI_MPU_ENTROPY_COST_TABLE = 11,
1719 VP8_BTI_MPU_MODE_COST_UPDATE = 12,
1720 VP8_BTI_MPU_NUM_SURFACES = 13
1721 };
1722
1723 struct vp8_mpu_curbe_data {
1724 struct {
1725 uint32_t frame_width: 16;
1726 uint32_t frame_height: 16;
1727 } dw0;
1728
1729 struct {
1730 uint32_t frame_type: 1;
1731 uint32_t version: 3;
1732 uint32_t show_frame: 1;
1733 uint32_t horizontal_scale_code: 2;
1734 uint32_t vertical_scale_code: 2;
1735 uint32_t color_space_type: 1;
1736 uint32_t clamp_type: 1;
1737 uint32_t partition_num_l2: 2;
1738 uint32_t enable_segmentation: 1;
1739 uint32_t seg_map_update: 1;
1740 uint32_t segmentation_feature_update: 1;
1741 uint32_t segmentation_feature_mode: 1;
1742 uint32_t loop_filter_type: 1;
1743 uint32_t sharpness_level: 3;
1744 uint32_t loop_filter_adjustment_on: 1;
1745 uint32_t mb_no_coeffiscient_skip: 1;
1746 uint32_t golden_reference_copy_flag: 2;
1747 uint32_t alternate_reference_copy_flag: 2;
1748 uint32_t last_frame_update: 1;
1749 uint32_t sign_bias_golden: 1;
1750 uint32_t sign_bias_alt_ref: 1;
1751 uint32_t refresh_entropy_p: 1;
1752 uint32_t forced_lf_update_for_key_frame: 1;
1753 } dw1;
1754
1755 struct {
1756 uint32_t loop_filter_level: 6;
1757 uint32_t reserved0: 2;
1758 uint32_t qindex: 7;
1759 uint32_t reserved1: 1;
1760 uint32_t y1_dc_qindex: 8;
1761 uint32_t y2_dc_qindex: 8;
1762 } dw2;
1763
1764 struct {
1765 uint32_t y2_ac_qindex: 8;
1766 uint32_t uv_dc_qindex: 8;
1767 uint32_t uv_ac_qindex: 8;
1768 uint32_t feature_data0_segment0: 8;
1769 } dw3;
1770
1771 struct {
1772 uint32_t feature_data0_segment1: 8;
1773 uint32_t feature_data0_segment2: 8;
1774 uint32_t feature_data0_segment3: 8;
1775 uint32_t feature_data1_segment0: 8;
1776 } dw4;
1777
1778 struct {
1779 uint32_t feature_data1_segment1: 8;
1780 uint32_t feature_data1_segment2: 8;
1781 uint32_t feature_data1_segment3: 8;
1782 uint32_t ref_lf_delta0: 8;
1783 } dw5;
1784
1785 struct {
1786 uint32_t ref_lf_delta1: 8;
1787 uint32_t ref_lf_delta2: 8;
1788 uint32_t ref_lf_delta3: 8;
1789 uint32_t mode_lf_delta0: 8;
1790 } dw6;
1791
1792 struct {
1793 uint32_t mode_lf_delta1: 8;
1794 uint32_t mode_lf_delta2: 8;
1795 uint32_t mode_lf_delta3: 8;
1796 uint32_t forced_token_surface_read: 1;
1797 uint32_t mode_cost_enable_flag: 1;
1798 uint32_t mc_filter_select: 1;
1799 uint32_t chroma_full_pixel_mc_filter_mode: 1;
1800 uint32_t max_num_pak_passes: 4;
1801
1802 } dw7;
1803
1804 struct {
1805 uint32_t temporal_layer_id: 8;
1806 uint32_t num_t_levels: 8;
1807 uint32_t reserved: 16;
1808 } dw8;
1809
1810 struct {
1811 uint32_t reserved;
1812 } dw9;
1813
1814 struct {
1815 uint32_t reserved;
1816 } dw10;
1817
1818 struct {
1819 uint32_t reserved;
1820 } dw11;
1821
1822 struct {
1823 uint32_t histogram_bti;
1824 } dw12;
1825
1826 struct {
1827 uint32_t reference_mode_probability_bti;
1828 } dw13;
1829
1830 struct {
1831 uint32_t mode_probability_bti;
1832 } dw14;
1833
1834 struct {
1835 uint32_t reference_token_probability_bti;
1836 } dw15;
1837
1838 struct {
1839 uint32_t token_probability_bti;
1840 } dw16;
1841
1842 struct {
1843 uint32_t frame_header_bitstream_bti;
1844 } dw17;
1845
1846 struct {
1847 uint32_t header_meta_data_bti;
1848 } dw18;
1849
1850 struct {
1851 uint32_t picture_state_bti;
1852 } dw19;
1853
1854 struct {
1855 uint32_t mpu_bitstream_bti;
1856 } dw20;
1857
1858 struct {
1859 uint32_t token_bits_data_bti;
1860 } dw21;
1861
1862 struct {
1863 uint32_t kernel_debug_dump_bti;
1864 } dw22;
1865
1866 struct {
1867 uint32_t entropy_cost_bti;
1868 } dw23;
1869
1870 struct {
1871 uint32_t mode_cost_update_bti;
1872 } dw24;
1873 };
1874
1875 struct vp8_mfx_encoder_cfg_cmd {
1876 union {
1877 struct {
1878 uint32_t dword_length: 12;
1879 uint32_t reserved: 4;
1880 uint32_t sub_opcode_b: 5;
1881 uint32_t sub_opcode_a: 3;
1882 uint32_t media_command_opcode: 3;
1883 uint32_t pipeline: 2;
1884 uint32_t command_type: 3;
1885 };
1886
1887 uint32_t value;
1888 } dw0;
1889
1890 struct {
1891 uint32_t performance_counter_enable: 1;
1892 uint32_t final_bitstream_output_disable: 1;
1893 uint32_t token_statistics_output_enable: 1;
1894 uint32_t bitstream_statistics_output_enable: 1;
1895 uint32_t update_segment_feature_data_flag: 1;
1896 uint32_t skip_final_bitstream_when_over_under_flow: 1;
1897 uint32_t rate_control_initial_pass: 1;
1898 uint32_t per_segment_delta_qindex_loop_filter_disable: 1;
1899 uint32_t finer_brc_enable: 1;
1900 uint32_t compressed_bitstream_output_disable: 1;
1901 uint32_t clock_gating_disable: 1;
1902 uint32_t reserved: 21;
1903 } dw1;
1904
1905 struct {
1906 uint32_t max_frame_bit_count_rate_control_enable_mask: 1;
1907 uint32_t min_frame_bit_count_rate_control_enable_mask: 1;
1908 uint32_t max_inter_mb_bit_count_check_enable_mask: 1;
1909 uint32_t max_intra_mb_bit_count_check_enable_mask: 1;
1910 uint32_t inter_mediate_bit_buffer_overrun_enable_mask: 1;
1911 uint32_t final_bistream_buffer_overrun_enable_mask: 1;
1912 uint32_t qindex_clamp_high_mask_for_underflow: 1;
1913 uint32_t qindex_clamp_high_mask_for_overflow: 1;
1914 uint32_t reserved: 24;
1915 } dw2;
1916
1917 struct {
1918 uint32_t max_inter_mb_bit_count: 12;
1919 uint32_t reserved0: 4;
1920 uint32_t max_intra_mb_bit_count_limit: 12;
1921 uint32_t reserved1: 4;
1922 } dw3;
1923
1924 struct {
1925 uint32_t frame_bit_rate_max: 14;
1926 uint32_t frame_bit_rate_max_unit: 1;
1927 uint32_t frame_bit_rate_max_unit_mode: 1;
1928 uint32_t frame_bit_rate_min: 14;
1929 uint32_t frame_bit_rate_min_unit: 1;
1930 uint32_t frame_bit_rate_min_unit_mode: 1;
1931 } dw4;
1932
1933 struct {
1934 uint32_t frame_delta_qindex_max0: 8;
1935 uint32_t frame_delta_qindex_max1: 8;
1936 uint32_t frame_delta_qindex_max2: 8;
1937 uint32_t frame_delta_qindex_max3: 8;
1938 } dw5;
1939
1940 struct {
1941 uint32_t frame_delta_qindex_min0: 8;
1942 uint32_t frame_delta_qindex_min1: 8;
1943 uint32_t frame_delta_qindex_min2: 8;
1944 uint32_t frame_delta_qindex_min3: 8;
1945 } dw6;
1946
1947 struct {
1948 uint32_t per_segment_frame_delta_qindex_max1;
1949 } dw7;
1950
1951 struct {
1952 uint32_t per_segment_frame_delta_qindex_min1;
1953 } dw8;
1954
1955 struct {
1956 uint32_t per_segment_frame_delta_qindex_max2;
1957 } dw9;
1958
1959 struct {
1960 uint32_t per_segment_frame_delta_qindex_min2;
1961 } dw10;
1962
1963 struct {
1964 uint32_t per_segment_frame_delta_qindex_max3;
1965 } dw11;
1966
1967 struct {
1968 uint32_t per_segment_frame_delta_qindex_min3;
1969 } dw12;
1970
1971 struct {
1972 uint32_t frame_delta_loop_filter_max0: 8;
1973 uint32_t frame_delta_loop_filter_max1: 8;
1974 uint32_t frame_delta_loop_filter_max2: 8;
1975 uint32_t frame_delta_loop_filter_max3: 8;
1976 } dw13;
1977
1978 struct {
1979 uint32_t frame_delta_loop_filter_min0: 8;
1980 uint32_t frame_delta_loop_filter_min1: 8;
1981 uint32_t frame_delta_loop_filter_min2: 8;
1982 uint32_t frame_delta_loop_filter_min3: 8;
1983 } dw14;
1984
1985 struct {
1986 uint32_t per_segment_frame_delta_loop_filter_max1;
1987 } dw15;
1988
1989 struct {
1990 uint32_t per_segment_frame_delta_loop_filter_min1;
1991 } dw16;
1992
1993 struct {
1994 uint32_t per_segment_frame_delta_loop_filter_max2;
1995 } dw17;
1996
1997 struct {
1998 uint32_t per_segment_frame_delta_loop_filter_min2;
1999 } dw18;
2000
2001 struct {
2002 uint32_t per_segment_frame_delta_loop_filter_max3;
2003 } dw19;
2004
2005 struct {
2006 uint32_t per_segment_frame_delta_loop_filter_min3;
2007 } dw20;
2008
2009 struct {
2010 uint32_t frame_bit_rate_max_delta: 15;
2011 uint32_t reserved0: 1;
2012 uint32_t frame_bit_rate_min_delta: 15;
2013 uint32_t reserved1: 1;
2014 } dw21;
2015
2016 struct {
2017 uint32_t min_frame_w_size: 16;
2018 uint32_t min_frame_w_size_unit: 2;
2019 uint32_t reserved0: 2;
2020 uint32_t bitstream_format_version: 3;
2021 uint32_t show_frame: 1;
2022 uint32_t reserved1: 8;
2023 } dw22;
2024
2025 struct {
2026 uint32_t horizontal_size_code: 16;
2027 uint32_t vertical_size_code: 16;
2028 } dw23;
2029
2030 struct {
2031 uint32_t frame_header_bit_count;
2032 } dw24;
2033
2034 struct {
2035 uint32_t frame_header_bin_buffer_qindex_update_pointer;
2036 } dw25;
2037
2038 struct {
2039 uint32_t frame_header_bin_buffer_loopfilter_update_pointer;
2040 } dw26;
2041
2042 struct {
2043 uint32_t frame_header_bin_buffer_token_update_pointer;
2044 } dw27;
2045
2046 struct {
2047 uint32_t frame_header_bin_buffer_MvupdatePointer;
2048 } dw28;
2049
2050 struct {
2051 uint32_t cv0_neg_clamp_value0: 4;
2052 uint32_t cv1: 4;
2053 uint32_t cv2: 4;
2054 uint32_t cv3: 4;
2055 uint32_t cv4: 4;
2056 uint32_t cv5: 4;
2057 uint32_t cv6: 4;
2058 uint32_t clamp_values_cv7: 4;
2059 } dw29;
2060 };
2061
2062 struct vp8_mpu_encoder_config_parameters {
2063 struct i965_gpe_resource *config_buffer;
2064 unsigned int is_first_pass;
2065 unsigned int command_offset;
2066 unsigned int buffer_size;
2067 };
2068
2069 #define VP8_MPU 0
2070 #define NUM_VP8_MPU 1
2071
2072 struct i965_encoder_vp8_mpu_context {
2073 struct i965_gpe_context gpe_contexts[NUM_VP8_MPU];
2074 dri_bo *dynamic_buffer;
2075 };
2076
2077 enum vp8_binding_table_offset_tpu {
2078 VP8_BTI_TPU_PAK_TOKEN_STATISTICS = 0,
2079 VP8_BTI_TPU_TOKEN_UPDATE_FLAGS = 1,
2080 VP8_BTI_TPU_ENTROPY_COST_TABLE = 2,
2081 VP8_BTI_TPU_HEADER_BITSTREAM = 3,
2082 VP8_BTI_TPU_DEFAULT_TOKEN_PROBABILITY = 4,
2083 VP8_BTI_TPU_PICTURE_STATE = 5,
2084 VP8_BTI_TPU_MPU_CURBE_DATA = 6,
2085 VP8_BTI_TPU_HEADER_METADATA = 7,
2086 VP8_BTI_TPU_TOKEN_PROBABILITY = 8,
2087 VP8_BTI_TPU_PAK_HW_PASS1_PROBABILITY = 9,
2088 VP8_BTI_TPU_KEY_TOKEN_PROBABILITY = 10,
2089 VP8_BTI_TPU_UPDATED_TOKEN_PROBABILITY = 11,
2090 VP8_BTI_TPU_PAK_HW_PASS2_PROBABILITY = 12,
2091 VP8_BTI_TPU_VME_DEBUG_STREAMOUT = 13,
2092 VP8_BTI_TPU_REPAK_DECISION = 14,
2093 VP8_BTI_TPU_NUM_SURFACES = 15
2094 };
2095
2096 struct vp8_tpu_curbe_data {
2097 struct {
2098 uint32_t mbs_in_frame;
2099 } dw0;
2100
2101 struct {
2102 uint32_t frame_type: 1;
2103 uint32_t enable_segmentation: 1;
2104 uint32_t rebinarization_frame_hdr: 1;
2105 uint32_t refresh_entropy_p: 1;
2106 uint32_t mb_no_coeffiscient_skip: 1;
2107 uint32_t reserved: 27;
2108 } dw1;
2109
2110 struct {
2111 uint32_t token_probability_start_offset: 16;
2112 uint32_t token_probability_end_offset: 16;
2113 } dw2;
2114
2115 struct {
2116 uint32_t frame_header_bit_count: 16;
2117 uint32_t max_qp: 8;
2118 uint32_t min_qp: 8;
2119 } dw3;
2120
2121 struct {
2122 uint32_t loop_filter_level_segment0: 8;
2123 uint32_t loop_filter_level_segment1: 8;
2124 uint32_t loop_filter_level_segment2: 8;
2125 uint32_t loop_filter_level_segment3: 8;
2126 } dw4;
2127
2128 struct {
2129 uint32_t quantization_index_segment0: 8;
2130 uint32_t quantization_index_segment1: 8;
2131 uint32_t quantization_index_segment2: 8;
2132 uint32_t quantization_index_segment3: 8;
2133 } dw5;
2134
2135 struct {
2136 uint32_t pak_pass_num;
2137 } dw6;
2138
2139 struct {
2140 uint32_t token_cost_delta_threshold: 16;
2141 uint32_t skip_cost_delta_threshold: 16;
2142 } dw7;
2143
2144 struct {
2145 uint32_t cumulative_dqindex01;
2146 } dw8;
2147
2148 struct {
2149 uint32_t cumulative_dqindex02;
2150 } dw9;
2151
2152 struct {
2153 uint32_t cumulative_loop_filter01;
2154 } dw10;
2155
2156 struct {
2157 uint32_t cumulative_loop_filter02;
2158 } dw11;
2159
2160 struct {
2161 uint32_t pak_token_statistics_bti;
2162 } dw12;
2163
2164 struct {
2165 uint32_t token_update_flags_bti;
2166 } dw13;
2167
2168 struct {
2169 uint32_t entropy_cost_table_bti;
2170 } dw14;
2171
2172 struct {
2173 uint32_t frame_header_bitstream_bti;
2174 } dw15;
2175
2176 struct {
2177 uint32_t default_token_probability_bti;
2178 } dw16;
2179
2180 struct {
2181 uint32_t picture_state_bti;
2182 } dw17;
2183
2184 struct {
2185 uint32_t mpu_curbe_data_bti;
2186 } dw18;
2187
2188 struct {
2189 uint32_t header_meta_data_bti;
2190 } dw19;
2191
2192 struct {
2193 uint32_t token_probability_bti;
2194 } dw20;
2195
2196 struct {
2197 uint32_t pak_hardware_token_probability_pass1_bti;
2198 } dw21;
2199
2200 struct {
2201 uint32_t key_frame_token_probability_bti;
2202 } dw22;
2203
2204 struct {
2205 uint32_t updated_token_probability_bti;
2206 } dw23;
2207
2208 struct {
2209 uint32_t pak_hardware_token_probability_pass2_bti;
2210 } dw24;
2211
2212 struct {
2213 uint32_t kernel_debug_dump_bti;
2214 } dw25;
2215
2216 struct {
2217 uint32_t repak_decision_surface_bti;
2218 } dw26;
2219 };
2220
2221 #define VP8_TPU 0
2222 #define NUM_VP8_TPU 1
2223
2224 struct i965_encoder_vp8_tpu_context {
2225 struct i965_gpe_context gpe_contexts[NUM_VP8_TPU];
2226 dri_bo *dynamic_buffer;
2227 };
2228
2229 struct vp8_encoder_kernel_parameters {
2230 unsigned int curbe_size;
2231 unsigned int inline_data_size;
2232 unsigned int external_data_size;
2233 };
2234
2235 enum VP8_ENCODER_WALKER_DEGREE {
2236 VP8_ENCODER_NO_DEGREE = 0,
2237 VP8_ENCODER_45_DEGREE,
2238 VP8_ENCODER_26_DEGREE,
2239 VP8_ENCODER_46_DEGREE,
2240 VP8_ENCODER_45Z_DEGREE
2241 };
2242
2243 struct vp8_encoder_kernel_walker_parameter {
2244 unsigned int walker_degree;
2245 unsigned int use_scoreboard;
2246 unsigned int scoreboard_mask;
2247 unsigned int no_dependency;
2248 unsigned int resolution_x;
2249 unsigned int resolution_y;
2250 };
2251
2252 struct vp8_encoder_scoreboard_parameters {
2253 unsigned int mask;
2254 unsigned int type;
2255 unsigned int enable;
2256 };
2257
2258 #define VP8_BRC_HISTORY_BUFFER_SIZE 704
2259
2260 #define VP8_BRC_SINGLE_PASS 1 /* No IPCM case */
2261 #define VP8_BRC_MINIMUM_NUM_PASSES 2 /* 2 to cover IPCM case */
2262 #define VP8_BRC_DEFAULT_NUM_PASSES 4
2263 #define VP8_BRC_MAXIMUM_NUM_PASSES 7
2264
2265 #define VP8_BRC_IMG_STATE_SIZE_PER_PASS 128
2266
2267 #define VP8_BRC_CONSTANT_DATA_SIZE 2880
2268
2269 struct vp8_brc_pak_statistics {
2270 // DWORD 0
2271 struct {
2272 uint32_t bitstream_byte_count_per_frame;
2273 } dw0;
2274
2275 // DWORD 1
2276 struct {
2277 uint32_t bitstream_byte_count_frame_no_headers;
2278 } dw1;
2279
2280 // DWORD 2
2281 struct {
2282 uint32_t num_of_pak_passes_executed: 16;
2283 uint32_t reserved: 16;
2284 } dw2;
2285
2286 // DWORD 3
2287 struct {
2288 uint32_t previous_qp: 32;
2289 } dw3;
2290
2291 // DWORD 4 - 1st pass IMAGE_STATUS_CONTROL_MMIO
2292 struct {
2293 uint32_t max_macroblock_conformance_flag: 1;
2294 uint32_t frame_bit_count_over_underflow: 1;
2295 uint32_t reserved0: 14;
2296 uint32_t suggested_slice_qp_delta: 8;
2297 uint32_t reserved1: 8;
2298 } dw4;
2299
2300 // DWORD 5 - 2nd pass IMAGE_STATUS_CONTROL_MMIO
2301 struct {
2302 uint32_t max_macroblock_conformance_flag: 1;
2303 uint32_t frame_bit_count_over_underflow: 1;
2304 uint32_t reserved0: 14;
2305 uint32_t suggested_slice_qp_delta: 8;
2306 uint32_t reserved1: 8;
2307 } dw5;
2308
2309 // DWORD 6 - 3rd pass IMAGE_STATUS_CONTROL_MMIO
2310 struct {
2311 uint32_t max_macroblock_conformance_flag: 1;
2312 uint32_t frame_bit_count_over_underflow: 1;
2313 uint32_t reserved0: 14;
2314 uint32_t suggested_slice_qp_delta: 8;
2315 uint32_t reserved1: 8;
2316 } dw6;
2317
2318 // DWORD 7 - 4th pass IMAGE_STATUS_CONTROL_MMIO
2319 struct {
2320 uint32_t max_macroblock_conformance_flag: 1;
2321 uint32_t frame_bit_count_over_underflow: 1;
2322 uint32_t reserved0: 14;
2323 uint32_t suggested_slice_qp_delta: 8;
2324 uint32_t reserved1: 8;
2325 } dw7;
2326
2327 // DWORD 8 - 5th pass IMAGE_STATUS_CONTROL_MMIO
2328 struct {
2329 uint32_t max_macroblock_conformance_flag: 1;
2330 uint32_t frame_bit_count_over_underflow: 1;
2331 uint32_t reserved0: 14;
2332 uint32_t suggested_slice_qp_delta: 8;
2333 uint32_t reserved1: 8;
2334 } dw8;
2335
2336 // DWORD 9 - 6th pass IMAGE_STATUS_CONTROL_MMIO
2337 struct {
2338 uint32_t max_macroblock_conformance_flag: 1;
2339 uint32_t frame_bit_count_over_underflow: 1;
2340 uint32_t reserved0: 14;
2341 uint32_t suggested_slice_qp_delta: 8;
2342 uint32_t reserved1: 8;
2343 } dw9;
2344
2345 // DWORD 10 - 7th pass IMAGE_STATUS_CONTROL_MMIO
2346 struct {
2347 uint32_t max_macroblock_conformance_flag: 1;
2348 uint32_t frame_bit_count_over_underflow: 1;
2349 uint32_t reserved0: 14;
2350 uint32_t suggested_slice_qp_delta: 8;
2351 uint32_t reserved1: 8;
2352 } dw10;
2353
2354 // DWORD 11
2355 struct {
2356 uint32_t reserved;
2357 } dw11;
2358
2359 struct {
2360 uint32_t reserved;
2361 } dw12;
2362
2363 struct {
2364 uint32_t reserved;
2365 } dw13;
2366
2367 struct {
2368 uint32_t reserved;
2369 } dw14;
2370
2371 struct {
2372 uint32_t reserved;
2373 } dw15;
2374 };
2375
2376 enum vp8_media_state_type {
2377 VP8_MEDIA_STATE_ENC_I_FRAME_CHROMA = 0,
2378 VP8_MEDIA_STATE_ENC_I_FRAME_LUMA,
2379 VP8_MEDIA_STATE_ENC_I_FRAME_DIST,
2380 VP8_MEDIA_STATE_ENC_P_FRAME,
2381 VP8_MEDIA_STATE_16X_SCALING,
2382 VP8_MEDIA_STATE_4X_SCALING,
2383 VP8_MEDIA_STATE_16X_ME,
2384 VP8_MEDIA_STATE_4X_ME,
2385 VP8_MEDIA_STATE_BRC_INIT_RESET,
2386 VP8_MEDIA_STATE_BRC_UPDATE,
2387 VP8_MEDIA_STATE_MPU,
2388 VP8_MEDIA_STATE_TPU,
2389 VP8_NUM_MEDIA_STATES
2390 };
2391
2392 struct vp8_vdbox_image_status_control {
2393 uint32_t max_mb_conformance_flag: 1;
2394 uint32_t frame_bitcount_flag: 1;
2395 uint32_t panic: 1;
2396 uint32_t missing_huffman_code: 1;
2397 uint32_t reserved0: 4;
2398 uint32_t total_num_pass: 4;
2399 uint32_t reserved1: 1;
2400 uint32_t num_pass_polarity_change: 2;
2401 uint32_t cumulative_slice_qp_polarity_change: 1;
2402 uint32_t suggested_slice_qpdelta: 8;
2403 uint32_t cumulative_slice_delta_qp: 8;
2404 };
2405
2406 struct vp8_encode_status {
2407 uint32_t bitstream_byte_count_per_frame;
2408 uint32_t pad0;
2409 uint32_t image_status_mask;
2410 struct vp8_vdbox_image_status_control image_status_ctrl;
2411 uint32_t pad2;
2412 };
2413
2414 struct i965_encoder_vp8_encode_status_buffer {
2415 dri_bo *bo;
2416 uint32_t base_offset;
2417 uint32_t size;
2418
2419 uint32_t bitstream_byte_count_offset;
2420 uint32_t image_status_mask_offset;
2421 uint32_t image_status_ctrl_offset;
2422 };
2423
2424 #ifndef MAX_MFX_REFERENCE_SURFACES
2425 #define MAX_MFX_REFERENCE_SURFACES 16
2426 #endif
2427
2428 struct i965_encoder_vp8_context {
2429 struct i965_gpe_table *gpe_table;
2430
2431 struct i965_encoder_vp8_brc_init_reset_context brc_init_reset_context;
2432 struct i965_encoder_vp8_scaling_context scaling_context;
2433 struct i965_encoder_vp8_me_context me_context;
2434 struct i965_encoder_vp8_mbenc_context mbenc_context;
2435 struct i965_encoder_vp8_brc_update_context brc_update_context;
2436 struct i965_encoder_vp8_mpu_context mpu_context;
2437
2438 struct i965_encoder_vp8_tpu_context tpu_context;
2439
2440 struct i965_gpe_resource reference_frame_mb_count_buffer;
2441 struct i965_gpe_resource mb_mode_cost_luma_buffer;
2442 struct i965_gpe_resource block_mode_cost_buffer;
2443 struct i965_gpe_resource chroma_recon_buffer;
2444 struct i965_gpe_resource per_mb_quant_data_buffer;
2445 struct i965_gpe_resource pred_mv_data_buffer;
2446 struct i965_gpe_resource mode_cost_update_buffer;
2447
2448 struct i965_gpe_resource brc_history_buffer;
2449 struct i965_gpe_resource brc_segment_map_buffer;
2450 struct i965_gpe_resource brc_distortion_buffer;
2451 struct i965_gpe_resource brc_pak_statistics_buffer;
2452 struct i965_gpe_resource brc_vp8_cfg_command_read_buffer;
2453 struct i965_gpe_resource brc_vp8_cfg_command_write_buffer;
2454 struct i965_gpe_resource brc_vp8_constant_data_buffer;
2455 struct i965_gpe_resource brc_pak_statistics_dump_buffer;
2456
2457 struct i965_gpe_resource me_4x_mv_data_buffer;
2458 struct i965_gpe_resource me_4x_distortion_buffer;
2459 struct i965_gpe_resource me_16x_mv_data_buffer;
2460
2461 struct i965_gpe_resource histogram_buffer;
2462
2463 struct i965_gpe_resource pak_intra_row_store_scratch_buffer;
2464 struct i965_gpe_resource pak_deblocking_filter_row_store_scratch_buffer;
2465 struct i965_gpe_resource pak_mpc_row_store_scratch_buffer;
2466 struct i965_gpe_resource pak_stream_out_buffer;
2467 struct i965_gpe_resource pak_frame_header_buffer;
2468 struct i965_gpe_resource pak_intermediate_buffer;
2469 struct i965_gpe_resource pak_mpu_tpu_mode_probs_buffer;
2470 struct i965_gpe_resource pak_mpu_tpu_ref_mode_probs_buffer;
2471 struct i965_gpe_resource pak_mpu_tpu_coeff_probs_buffer;
2472 struct i965_gpe_resource pak_mpu_tpu_ref_coeff_probs_buffer;
2473 struct i965_gpe_resource pak_mpu_tpu_token_bits_data_buffer;
2474 struct i965_gpe_resource pak_mpu_tpu_picture_state_buffer;
2475 struct i965_gpe_resource pak_mpu_tpu_mpu_bitstream_buffer;
2476 struct i965_gpe_resource pak_mpu_tpu_tpu_bitstream_buffer;
2477 struct i965_gpe_resource pak_mpu_tpu_entropy_cost_table_buffer;
2478 struct i965_gpe_resource pak_mpu_tpu_pak_token_statistics_buffer;
2479 struct i965_gpe_resource pak_mpu_tpu_pak_token_update_flags_buffer;
2480 struct i965_gpe_resource pak_mpu_tpu_default_token_probability_buffer;
2481 struct i965_gpe_resource pak_mpu_tpu_key_frame_token_probability_buffer;
2482 struct i965_gpe_resource pak_mpu_tpu_updated_token_probability_buffer;
2483 struct i965_gpe_resource pak_mpu_tpu_hw_token_probability_pak_pass_2_buffer;
2484 struct i965_gpe_resource pak_mpu_tpu_repak_decision_buffer;
2485
2486 struct i965_gpe_resource mb_coded_buffer;
2487
2488 struct i965_encoder_vp8_encode_status_buffer encode_status_buffer;
2489
2490 struct object_surface *ref_last_frame;
2491 struct object_surface *ref_gf_frame;
2492 struct object_surface *ref_arf_frame;
2493
2494 unsigned long mv_offset;
2495 unsigned long mb_coded_buffer_size;
2496
2497 unsigned int ref_frame_ctrl;
2498 unsigned int average_i_frame_qp;
2499 unsigned int average_p_frame_qp;
2500
2501 /* TPU */
2502 unsigned int num_passes;
2503 unsigned int curr_pass;
2504 unsigned int repak_pass_iter_val;
2505 unsigned int min_pak_passes;
2506
2507 unsigned int num_brc_pak_passes;
2508
2509 unsigned int picture_width; /* in pixel */
2510 unsigned int picture_height;/* in pixel */
2511 unsigned int frame_width_in_mbs;
2512 unsigned int frame_height_in_mbs;
2513 unsigned int frame_width; /* frame_width_in_mbs * 16 */
2514 unsigned int frame_height; /* frame_height_in_mbs * 16 */
2515 unsigned int down_scaled_width_in_mb4x;
2516 unsigned int down_scaled_height_in_mb4x;
2517 unsigned int down_scaled_width_4x;
2518 unsigned int down_scaled_height_4x;
2519 unsigned int down_scaled_width_in_mb16x;
2520 unsigned int down_scaled_height_in_mb16x;
2521 unsigned int down_scaled_width_16x;
2522 unsigned int down_scaled_height_16x;
2523 unsigned int min_scaled_dimension;
2524 unsigned int min_scaled_dimension_in_mbs;
2525
2526 unsigned int frame_type;
2527 unsigned int internal_rate_mode;
2528 unsigned short avbr_accuracy;
2529 unsigned short avbr_convergence;
2530 unsigned int frame_num;
2531 struct intel_fraction framerate;
2532 unsigned int gop_size;
2533 unsigned int brc_init_reset_buf_size_in_bits;
2534 unsigned int target_bit_rate;
2535 unsigned int max_bit_rate;
2536 unsigned int min_bit_rate;
2537 unsigned long init_vbv_buffer_fullness_in_bit;
2538 unsigned long vbv_buffer_size_in_bit;
2539 double brc_init_current_target_buf_full_in_bits;
2540 double brc_init_reset_input_bits_per_frame;
2541
2542 unsigned int brc_initted: 1;
2543 unsigned int brc_need_reset: 1;
2544 unsigned int brc_mbenc_phase1_ignored: 1;
2545 unsigned int hme_supported: 1;
2546 unsigned int hme_16x_supported: 1;
2547 unsigned int hme_enabled : 1;
2548 unsigned int hme_16x_enabled : 1;
2549 unsigned int is_render_context: 1;
2550 unsigned int is_first_frame: 1;
2551 unsigned int is_first_two_frame: 1;
2552 unsigned int repak_supported: 1;
2553 unsigned int multiple_pass_brc_supported: 1;
2554 unsigned int use_hw_scoreboard: 1;
2555 unsigned int use_hw_non_stalling_scoreborad: 1;
2556 unsigned int ref_ctrl_optimization_done: 1;
2557 unsigned int brc_distortion_buffer_supported: 1;
2558 unsigned int brc_constant_buffer_supported: 1;
2559 unsigned int brc_distortion_buffer_need_reset: 1;
2560 unsigned int mbenc_curbe_updated_in_brc_update: 1;
2561 unsigned int mpu_curbe_updated_in_brc_update: 1;
2562 unsigned int mfx_encoder_config_command_initialized: 1;
2563 unsigned int tpu_curbe_updated_in_brc_update: 1;
2564 unsigned int tpu_required: 1;
2565 unsigned int submit_batchbuffer: 1;
2566
2567 struct {
2568 dri_bo *bo;
2569 } post_deblocking_output;
2570
2571 struct {
2572 dri_bo *bo;
2573 } pre_deblocking_output;
2574
2575 struct {
2576 dri_bo *bo;
2577 } uncompressed_picture_source;
2578
2579 struct {
2580 dri_bo *bo;
2581 int offset;
2582 int end_offset;
2583 } indirect_pak_bse_object;
2584
2585 struct {
2586 dri_bo *bo;
2587 } deblocking_filter_row_store_scratch_buffer;
2588
2589 struct {
2590 dri_bo *bo;
2591 } reference_surfaces[MAX_MFX_REFERENCE_SURFACES];
2592
2593 unsigned int vdbox_idc;
2594 unsigned int vdbox_mmio_base;
2595 unsigned int idrt_entry_size;
2596 unsigned int mocs;
2597 };
2598
2599 #endif /* I965_ENCODER_VP8_H */