1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
|
/*
* Copyright © 2010 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
* IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Authors:
* Xiang Haihao <haihao.xiang@intel.com>
*
*/
#ifndef __I965_POST_PROCESSING_H__
#define __I965_POST_PROCESSING_H__
#include "i965_vpp_avs.h"
#define MAX_PP_SURFACES 48
enum
{
PP_NULL = 0,
PP_NV12_LOAD_SAVE_N12,
PP_NV12_LOAD_SAVE_PL3,
PP_PL3_LOAD_SAVE_N12,
PP_PL3_LOAD_SAVE_PL3,
PP_NV12_SCALING,
PP_NV12_AVS,
PP_NV12_DNDI,
PP_NV12_DN,
PP_NV12_LOAD_SAVE_PA,
PP_PL3_LOAD_SAVE_PA,
PP_PA_LOAD_SAVE_NV12,
PP_PA_LOAD_SAVE_PL3,
PP_PA_LOAD_SAVE_PA,
PP_RGBX_LOAD_SAVE_NV12,
PP_NV12_LOAD_SAVE_RGBX,
NUM_PP_MODULES,
};
struct i965_post_processing_context;
struct pp_load_save_context
{
int dest_x;
int dest_y;
int dest_w;
int dest_h;
};
struct pp_scaling_context
{
int dest_x; /* in pixel */
int dest_y; /* in pixel */
int dest_w;
int dest_h;
float src_normalized_x;
float src_normalized_y;
};
struct pp_avs_context
{
AVSState state;
int dest_x; /* in pixel */
int dest_y; /* in pixel */
int dest_w;
int dest_h;
float src_normalized_x;
float src_normalized_y;
int src_w;
int src_h;
float horiz_range;
};
enum {
DNDI_FRAME_IN_CURRENT = 0,
DNDI_FRAME_IN_PREVIOUS,
DNDI_FRAME_IN_STMM,
DNDI_FRAME_OUT_STMM,
DNDI_FRAME_OUT_CURRENT,
DNDI_FRAME_OUT_PREVIOUS,
DNDI_FRAME_STORE_COUNT
};
typedef struct dndi_frame_store {
struct object_surface *obj_surface;
VASurfaceID surface_id; /* always relative to the input surface */
unsigned int is_scratch_surface : 1;
} DNDIFrameStore;
struct pp_dndi_context
{
int dest_w;
int dest_h;
DNDIFrameStore frame_store[DNDI_FRAME_STORE_COUNT];
/* Temporary flags live until the current picture is processed */
unsigned int is_di_enabled : 1;
unsigned int is_di_adv_enabled : 1;
unsigned int is_first_frame : 1;
unsigned int is_second_field : 1;
};
struct pp_dn_context
{
int dest_w;
int dest_h;
dri_bo *stmm_bo;
};
struct i965_post_processing_context;
struct pp_module
{
struct i965_kernel kernel;
/* others */
VAStatus (*initialize)(VADriverContextP ctx, struct i965_post_processing_context *pp_context,
const struct i965_surface *src_surface,
const VARectangle *src_rect,
struct i965_surface *dst_surface,
const VARectangle *dst_rect,
void *filter_param);
};
struct pp_static_parameter
{
struct {
/* Procamp r1.0 */
float procamp_constant_c0;
/* Load and Same r1.1 */
unsigned int source_packed_y_offset:8;
unsigned int source_packed_u_offset:8;
unsigned int source_packed_v_offset:8;
unsigned int source_rgb_layout:8; // 1 for |R|G|B|X| layout, 0 for |B|G|R|X| layout
union {
/* Load and Save r1.2 */
struct {
unsigned int destination_packed_y_offset:8;
unsigned int destination_packed_u_offset:8;
unsigned int destination_packed_v_offset:8;
unsigned int pad0:8;
} load_and_save;
/* CSC r1.2 */
struct {
unsigned int pad0:24;
unsigned int destination_rgb_layout:8; // 1 for |R|G|B|X| layout, 0 for |B|G|R|X| layout
} csc;
} r1_2;
/* Procamp r1.3 */
float procamp_constant_c1;
/* Procamp r1.4 */
float procamp_constant_c2;
/* DI r1.5 */
unsigned int statistics_surface_picth:16; /* Devided by 2 */
unsigned int pad1:16;
union {
/* DI r1.6 */
struct {
unsigned int pad0:24;
unsigned int top_field_first:8;
} di;
/* AVS/Scaling r1.6 */
float normalized_video_y_scaling_step;
} r1_6;
/* Procamp r1.7 */
float procamp_constant_c5;
} grf1;
struct {
/* Procamp r2.0 */
float procamp_constant_c3;
/* MBZ r2.1*/
unsigned int pad0;
/* WG+CSC r2.2 */
float wg_csc_constant_c4;
/* WG+CSC r2.3 */
float wg_csc_constant_c8;
/* Procamp r2.4 */
float procamp_constant_c4;
/* MBZ r2.5 */
unsigned int pad1;
/* MBZ r2.6 */
unsigned int pad2;
/* WG+CSC r2.7 */
float wg_csc_constant_c9;
} grf2;
struct {
/* WG+CSC r3.0 */
float wg_csc_constant_c0;
/* Blending r3.1 */
float scaling_step_ratio;
/* Blending r3.2 */
float normalized_alpha_y_scaling;
/* WG+CSC r3.3 */
float wg_csc_constant_c4;
/* WG+CSC r3.4 */
float wg_csc_constant_c1;
/* ALL r3.5 */
int horizontal_origin_offset:16;
int vertical_origin_offset:16;
/* Shared r3.6*/
union {
/* Color filll */
unsigned int color_pixel;
/* WG+CSC */
float wg_csc_constant_c2;
} r3_6;
/* WG+CSC r3.7 */
float wg_csc_constant_c3;
} grf3;
struct {
/* WG+CSC r4.0 */
float wg_csc_constant_c6;
/* ALL r4.1 MBZ ???*/
unsigned int pad0;
/* Shared r4.2 */
union {
/* AVS */
struct {
unsigned int pad1:15;
unsigned int nlas:1;
unsigned int pad2:16;
} avs;
/* DI */
struct {
unsigned int motion_history_coefficient_m2:8;
unsigned int motion_history_coefficient_m1:8;
unsigned int pad0:16;
} di;
} r4_2;
/* WG+CSC r4.3 */
float wg_csc_constant_c7;
/* WG+CSC r4.4 */
float wg_csc_constant_c10;
/* AVS r4.5 */
float source_video_frame_normalized_horizontal_origin;
/* MBZ r4.6 */
unsigned int pad1;
/* WG+CSC r4.7 */
float wg_csc_constant_c11;
} grf4;
};
struct pp_inline_parameter
{
struct {
/* ALL r5.0 */
int destination_block_horizontal_origin:16;
int destination_block_vertical_origin:16;
/* Shared r5.1 */
union {
/* AVS/Scaling */
float source_surface_block_normalized_horizontal_origin;
/* FMD */
struct {
unsigned int variance_surface_vertical_origin:16;
unsigned int pad0:16;
} fmd;
} r5_1;
/* AVS/Scaling r5.2 */
float source_surface_block_normalized_vertical_origin;
/* Alpha r5.3 */
float alpha_surface_block_normalized_horizontal_origin;
/* Alpha r5.4 */
float alpha_surface_block_normalized_vertical_origin;
/* Alpha r5.5 */
unsigned int alpha_mask_x:16;
unsigned int alpha_mask_y:8;
unsigned int block_count_x:8;
/* r5.6 */
/* we only support M*1 or 1*N block partitation now.
* -- it means asm code only need update this mask from grf6 for the last block
*/
unsigned int block_horizontal_mask:16;
unsigned int block_vertical_mask:8;
unsigned int number_blocks:8;
/* AVS/Scaling r5.7 */
float normalized_video_x_scaling_step;
} grf5;
struct {
/* AVS r6.0 */
float video_step_delta;
/* r6.1 */ // sizeof(int) == 4?
unsigned int block_horizontal_mask_right:16;
unsigned int block_vertical_mask_bottom:8;
unsigned int pad1:8;
/* r6.2 */
unsigned int block_horizontal_mask_middle:16;
unsigned int pad2:16;
/* r6.3-r6.7 */
unsigned int padx[5];
} grf6;
};
struct gen7_pp_static_parameter
{
struct {
/* r1.0-r1.5 */
unsigned int padx[6];
/* r1.6 */
unsigned int di_statistics_surface_pitch_div2:16;
unsigned int di_statistics_surface_height_div4:16;
/* r1.7 */
unsigned int di_top_field_first:8;
unsigned int pad0:16;
unsigned int pointer_to_inline_parameter:8; /* value: 7 */
} grf1;
struct {
/* r2.0 */
/* Indicates whether the rgb is swapped for the src surface
* 0: RGBX(MSB. X-B-G-R). 1: BGRX(MSB: X-R-G-B)
*/
unsigned int src_avs_rgb_swap:1;
unsigned int pad3:31;
/* r2.1 */
unsigned int pad2:16;
unsigned int save_avs_rgb_swap:1; /* 0: RGB, 1: BGR */
unsigned int avs_wa_enable:1; /* must enabled for GEN7 */
unsigned int ief_enable:1;
unsigned int avs_wa_width:13;
/* 2.2 */
float avs_wa_one_div_256_width;
/* 2.3 */
float avs_wa_five_div_256_width;
/* 2.4 - 2.6 */
unsigned int padx[3];
/* r2.7 */
unsigned int di_destination_packed_y_component_offset:8;
unsigned int di_destination_packed_u_component_offset:8;
unsigned int di_destination_packed_v_component_offset:8;
unsigned int alpha:8;
} grf2;
struct {
float sampler_load_horizontal_scaling_step_ratio;
unsigned int padx[7];
} grf3;
struct {
float sampler_load_vertical_scaling_step;
unsigned int pad0;
unsigned int di_hoffset_svf_from_dvf:16;
unsigned int di_voffset_svf_from_dvf:16;
unsigned int padx[5];
} grf4;
struct {
float sampler_load_vertical_frame_origin;
unsigned int padx[7];
} grf5;
struct {
float sampler_load_horizontal_frame_origin;
unsigned int padx[7];
} grf6;
struct {
/* r7.0 -> r7.3 */
float coef_ry;
float coef_ru;
float coef_rv;
float coef_yd;
/* r7.4 -> r7.7 */
float coef_gy;
float coef_gu;
float coef_gv;
float coef_ud;
} grf7;
struct {
/* r8.0 -> r8.3 */
float coef_by;
float coef_bu;
float coef_bv;
float coef_vd;
/* r8.4 -> r8.7 */
unsigned int padx[4];
} grf8;
};
struct gen7_pp_inline_parameter
{
struct {
/* r9.0 */
unsigned int destination_block_horizontal_origin:16;
unsigned int destination_block_vertical_origin:16;
/* r9.1: 0xffffffff */
unsigned int constant_0;
/* r9.2 */
unsigned int pad0;
/* r9.3 */
unsigned int pad1;
/* r9.4 */
float sampler_load_main_video_x_scaling_step;
/* r9.5 */
unsigned int pad2;
/* r9.6: must be zero */
unsigned int avs_vertical_block_number;
/* r9.7: 0 */
unsigned int group_id_number;
} grf9;
struct {
unsigned int padx[8];
} grf10;
};
struct i965_post_processing_context
{
int current_pp;
struct pp_module pp_modules[NUM_PP_MODULES];
void *pp_static_parameter;
void *pp_inline_parameter;
struct {
dri_bo *bo;
} surface_state_binding_table;
struct {
dri_bo *bo;
} curbe;
struct {
dri_bo *bo;
int num_interface_descriptors;
} idrt;
struct {
dri_bo *bo;
} vfe_state;
struct {
dri_bo *bo;
dri_bo *bo_8x8;
dri_bo *bo_8x8_uv;
} sampler_state_table;
struct {
unsigned int size;
unsigned int vfe_start;
unsigned int cs_start;
unsigned int num_vfe_entries;
unsigned int num_cs_entries;
unsigned int size_vfe_entry;
unsigned int size_cs_entry;
} urb;
struct {
unsigned int gpgpu_mode : 1;
unsigned int pad0 : 7;
unsigned int max_num_threads : 16;
unsigned int num_urb_entries : 8;
unsigned int urb_entry_size : 16;
unsigned int curbe_allocation_size : 16;
} vfe_gpu_state;
struct intel_vebox_context *vebox_proc_ctx;
struct pp_load_save_context pp_load_save_context;
struct pp_scaling_context pp_scaling_context;
struct pp_avs_context pp_avs_context;
struct pp_dndi_context pp_dndi_context;
struct pp_dn_context pp_dn_context;
void *private_context; /* pointer to the current private context */
void *pipeline_param; /* pointer to the pipeline parameter */
/**
* \ref Extra filter flags used as a fast path.
*
* This corresponds to vaPutSurface() flags, for direct rendering,
* or to VAProcPipelineParameterBuffer.filter_flags when the VPP
* interfaces are used. In the latter case, this is just a copy of
* that field.
*/
unsigned int filter_flags;
int (*pp_x_steps)(void *private_context);
int (*pp_y_steps)(void *private_context);
int (*pp_set_block_parameter)(struct i965_post_processing_context *pp_context, int x, int y);
struct intel_batchbuffer *batch;
unsigned int block_horizontal_mask_left:16;
unsigned int block_horizontal_mask_right:16;
unsigned int block_vertical_mask_bottom:8;
struct {
dri_bo *bo;
int bo_size;
unsigned int end_offset;
} instruction_state;
struct {
dri_bo *bo;
} indirect_state;
struct {
dri_bo *bo;
int bo_size;
unsigned int end_offset;
} dynamic_state;
unsigned int sampler_offset;
int sampler_size;
unsigned int idrt_offset;
int idrt_size;
unsigned int curbe_offset;
int curbe_size;
VAStatus (*intel_post_processing)(VADriverContextP ctx,
struct i965_post_processing_context *pp_context,
const struct i965_surface *src_surface,
const VARectangle *src_rect,
struct i965_surface *dst_surface,
const VARectangle *dst_rect,
int pp_index,
void * filter_param);
void (*finalize)(VADriverContextP ctx,
struct i965_post_processing_context *pp_context);
};
struct i965_proc_context
{
struct hw_context base;
void *driver_context;
struct i965_post_processing_context pp_context;
};
VASurfaceID
i965_post_processing(
VADriverContextP ctx,
struct object_surface *obj_surface,
const VARectangle *src_rect,
const VARectangle *dst_rect,
unsigned int va_flags,
int *has_done_scaling,
VARectangle *calibrated_rect
);
VAStatus
i965_scaling_processing(
VADriverContextP ctx,
struct object_surface *src_surface_obj,
const VARectangle *src_rect,
struct object_surface *dst_surface_obj,
const VARectangle *dst_rect,
unsigned int va_flags
);
VAStatus
i965_image_processing(VADriverContextP ctx,
const struct i965_surface *src_surface,
const VARectangle *src_rect,
struct i965_surface *dst_surface,
const VARectangle *dst_rect);
void
i965_post_processing_terminate(VADriverContextP ctx);
bool
i965_post_processing_init(VADriverContextP ctx);
extern VAStatus
i965_proc_picture(VADriverContextP ctx,
VAProfile profile,
union codec_state *codec_state,
struct hw_context *hw_context);
#endif /* __I965_POST_PROCESSING_H__ */
|