Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
3769 | Serge | 1 | /* |
2 | * Copyright © 2009 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 |
||
26 | * Zou Nan hai |
||
27 | * |
||
28 | */ |
||
29 | |||
30 | #include |
||
31 | #include |
||
32 | #include |
||
33 | #include |
||
34 | |||
35 | #include "intel_batchbuffer.h" |
||
36 | #include "intel_driver.h" |
||
37 | #include "i965_defines.h" |
||
38 | #include "i965_drv_video.h" |
||
39 | #include "i965_decoder_utils.h" |
||
40 | |||
41 | #include "i965_media.h" |
||
42 | #include "i965_media_mpeg2.h" |
||
43 | |||
44 | #define SURFACE_TARGET 0 |
||
45 | #define SURFACE_FORWARD 1 |
||
46 | #define SURFACE_BACKWARD 2 |
||
47 | #define SURFACE_BIDIRECT 3 |
||
48 | |||
49 | enum interface { |
||
50 | FRAME_INTRA = 0, |
||
51 | FRAME_FRAME_PRED_FORWARD, |
||
52 | FRAME_FRAME_PRED_BACKWARD, |
||
53 | FRAME_FRAME_PRED_BIDIRECT, |
||
54 | FRAME_FIELD_PRED_FORWARD, |
||
55 | FRAME_FIELD_PRED_BACKWARD, |
||
56 | FRAME_FIELD_PRED_BIDIRECT, |
||
57 | LIB_INTERFACE, |
||
58 | FIELD_INTRA, |
||
59 | FIELD_FORWARD, |
||
60 | FIELD_FORWARD_16X8, |
||
61 | FIELD_BACKWARD, |
||
62 | FIELD_BACKWARD_16X8, |
||
63 | FIELD_BIDIRECT, |
||
64 | FIELD_BIDIRECT_16X8 |
||
65 | }; |
||
66 | |||
67 | /* idct table */ |
||
68 | #define C0 23170 |
||
69 | #define C1 22725 |
||
70 | #define C2 21407 |
||
71 | #define C3 19266 |
||
72 | #define C4 16383 |
||
73 | #define C5 12873 |
||
74 | #define C6 8867 |
||
75 | #define C7 4520 |
||
76 | const uint32_t idct_table[] = { |
||
77 | C4, C1, C2, C3, C4, C5, C6, C7, //g5 |
||
78 | C4, C1, C2, C3, C4, C5, C6, C7, |
||
79 | C4, C3, C6,-C7,-C4,-C1,-C2,-C5, |
||
80 | C4, C3, C6,-C7,-C4,-C1,-C2,-C5, |
||
81 | C4, C5,-C6,-C1,-C4, C7, C2, C3, |
||
82 | C4, C5,-C6,-C1,-C4, C7, C2, C3, |
||
83 | C4, C7,-C2,-C5, C4, C3,-C6,-C1, |
||
84 | C4, C7,-C2,-C5, C4, C3,-C6,-C1, |
||
85 | C4,-C7,-C2, C5, C4,-C3,-C6, C1, |
||
86 | C4,-C7,-C2, C5, C4,-C3,-C6, C1, |
||
87 | C4,-C5,-C6, C1,-C4,-C7, C2,-C3, |
||
88 | C4,-C5,-C6, C1,-C4,-C7, C2,-C3, |
||
89 | C4,-C3, C6, C7,-C4, C1,-C2, C5, |
||
90 | C4,-C3, C6, C7,-C4, C1,-C2, C5, |
||
91 | C4,-C1, C2,-C3, C4,-C5, C6,-C7, |
||
92 | C4,-C1, C2,-C3, C4,-C5, C6,-C7 //g20 |
||
93 | }; |
||
94 | #undef C0 |
||
95 | #undef C1 |
||
96 | #undef C2 |
||
97 | #undef C3 |
||
98 | #undef C4 |
||
99 | #undef C5 |
||
100 | #undef C6 |
||
101 | #undef C7 |
||
102 | |||
103 | const uint32_t zigzag_direct[64] = { |
||
104 | 0, 1, 8, 16, 9, 2, 3, 10, |
||
105 | 17, 24, 32, 25, 18, 11, 4, 5, |
||
106 | 12, 19, 26, 33, 40, 48, 41, 34, |
||
107 | 27, 20, 13, 6, 7, 14, 21, 28, |
||
108 | 35, 42, 49, 56, 57, 50, 43, 36, |
||
109 | 29, 22, 15, 23, 30, 37, 44, 51, |
||
110 | 58, 59, 52, 45, 38, 31, 39, 46, |
||
111 | 53, 60, 61, 54, 47, 55, 62, 63 |
||
112 | }; |
||
113 | |||
114 | static const uint32_t frame_intra_kernel[][4] = { |
||
115 | #include "shaders/mpeg2/vld/frame_intra.g4b" |
||
116 | }; |
||
117 | static const uint32_t frame_frame_pred_forward_kernel[][4] = { |
||
118 | #include "shaders/mpeg2/vld/frame_frame_pred_forward.g4b" |
||
119 | }; |
||
120 | static const uint32_t frame_frame_pred_backward_kernel[][4] = { |
||
121 | #include "shaders/mpeg2/vld/frame_frame_pred_backward.g4b" |
||
122 | }; |
||
123 | static const uint32_t frame_frame_pred_bidirect_kernel[][4] = { |
||
124 | #include "shaders/mpeg2/vld/frame_frame_pred_bidirect.g4b" |
||
125 | }; |
||
126 | static const uint32_t frame_field_pred_forward_kernel[][4] = { |
||
127 | #include "shaders/mpeg2/vld/frame_field_pred_forward.g4b" |
||
128 | }; |
||
129 | static const uint32_t frame_field_pred_backward_kernel[][4] = { |
||
130 | #include "shaders/mpeg2/vld/frame_field_pred_backward.g4b" |
||
131 | }; |
||
132 | static const uint32_t frame_field_pred_bidirect_kernel[][4] = { |
||
133 | #include "shaders/mpeg2/vld/frame_field_pred_bidirect.g4b" |
||
134 | }; |
||
135 | static const uint32_t lib_kernel[][4] = { |
||
136 | #include "shaders/mpeg2/vld/lib.g4b" |
||
137 | }; |
||
138 | /*field picture*/ |
||
139 | static const uint32_t field_intra_kernel[][4] = { |
||
140 | #include "shaders/mpeg2/vld/field_intra.g4b" |
||
141 | }; |
||
142 | static const uint32_t field_forward_kernel[][4] = { |
||
143 | #include "shaders/mpeg2/vld/field_forward.g4b" |
||
144 | }; |
||
145 | static const uint32_t field_forward_16x8_kernel[][4] = { |
||
146 | #include "shaders/mpeg2/vld/field_forward_16x8.g4b" |
||
147 | }; |
||
148 | static const uint32_t field_backward_kernel[][4] = { |
||
149 | #include "shaders/mpeg2/vld/field_backward.g4b" |
||
150 | }; |
||
151 | static const uint32_t field_backward_16x8_kernel[][4] = { |
||
152 | #include "shaders/mpeg2/vld/field_backward_16x8.g4b" |
||
153 | }; |
||
154 | static const uint32_t field_bidirect_kernel[][4] = { |
||
155 | #include "shaders/mpeg2/vld/field_bidirect.g4b" |
||
156 | }; |
||
157 | static const uint32_t field_bidirect_16x8_kernel[][4] = { |
||
158 | #include "shaders/mpeg2/vld/field_bidirect_16x8.g4b" |
||
159 | }; |
||
160 | |||
161 | static struct i965_kernel mpeg2_vld_kernels_gen4[] = { |
||
162 | { |
||
163 | "FRAME_INTRA", |
||
164 | FRAME_INTRA, |
||
165 | frame_intra_kernel, |
||
166 | sizeof(frame_intra_kernel), |
||
167 | NULL |
||
168 | }, |
||
169 | |||
170 | { |
||
171 | "FRAME_FRAME_PRED_FORWARD", |
||
172 | FRAME_FRAME_PRED_FORWARD, |
||
173 | frame_frame_pred_forward_kernel, |
||
174 | sizeof(frame_frame_pred_forward_kernel), |
||
175 | NULL |
||
176 | }, |
||
177 | |||
178 | { |
||
179 | "FRAME_FRAME_PRED_BACKWARD", |
||
180 | FRAME_FRAME_PRED_BACKWARD, |
||
181 | frame_frame_pred_backward_kernel, |
||
182 | sizeof(frame_frame_pred_backward_kernel), |
||
183 | NULL |
||
184 | }, |
||
185 | |||
186 | { |
||
187 | "FRAME_FRAME_PRED_BIDIRECT", |
||
188 | FRAME_FRAME_PRED_BIDIRECT, |
||
189 | frame_frame_pred_bidirect_kernel, |
||
190 | sizeof(frame_frame_pred_bidirect_kernel), |
||
191 | NULL |
||
192 | }, |
||
193 | |||
194 | { |
||
195 | "FRAME_FIELD_PRED_FORWARD", |
||
196 | FRAME_FIELD_PRED_FORWARD, |
||
197 | frame_field_pred_forward_kernel, |
||
198 | sizeof(frame_field_pred_forward_kernel), |
||
199 | NULL |
||
200 | }, |
||
201 | |||
202 | { |
||
203 | "FRAME_FIELD_PRED_BACKWARD", |
||
204 | FRAME_FIELD_PRED_BACKWARD, |
||
205 | frame_field_pred_backward_kernel, |
||
206 | sizeof(frame_field_pred_backward_kernel), |
||
207 | NULL |
||
208 | }, |
||
209 | |||
210 | { |
||
211 | "FRAME_FIELD_PRED_BIDIRECT", |
||
212 | FRAME_FIELD_PRED_BIDIRECT, |
||
213 | frame_field_pred_bidirect_kernel, |
||
214 | sizeof(frame_field_pred_bidirect_kernel), |
||
215 | NULL |
||
216 | }, |
||
217 | |||
218 | { |
||
219 | "LIB", |
||
220 | LIB_INTERFACE, |
||
221 | lib_kernel, |
||
222 | sizeof(lib_kernel), |
||
223 | NULL |
||
224 | }, |
||
225 | |||
226 | { |
||
227 | "FIELD_INTRA", |
||
228 | FIELD_INTRA, |
||
229 | field_intra_kernel, |
||
230 | sizeof(field_intra_kernel), |
||
231 | NULL |
||
232 | }, |
||
233 | |||
234 | { |
||
235 | "FIELD_FORWARD", |
||
236 | FIELD_FORWARD, |
||
237 | field_forward_kernel, |
||
238 | sizeof(field_forward_kernel), |
||
239 | NULL |
||
240 | }, |
||
241 | |||
242 | { |
||
243 | "FIELD_FORWARD_16X8", |
||
244 | FIELD_FORWARD_16X8, |
||
245 | field_forward_16x8_kernel, |
||
246 | sizeof(field_forward_16x8_kernel), |
||
247 | NULL |
||
248 | }, |
||
249 | |||
250 | { |
||
251 | "FIELD_BACKWARD", |
||
252 | FIELD_BACKWARD, |
||
253 | field_backward_kernel, |
||
254 | sizeof(field_backward_kernel), |
||
255 | NULL |
||
256 | }, |
||
257 | |||
258 | { |
||
259 | "FIELD_BACKWARD_16X8", |
||
260 | FIELD_BACKWARD_16X8, |
||
261 | field_backward_16x8_kernel, |
||
262 | sizeof(field_backward_16x8_kernel), |
||
263 | NULL |
||
264 | }, |
||
265 | |||
266 | { |
||
267 | "FIELD_BIDIRECT", |
||
268 | FIELD_BIDIRECT, |
||
269 | field_bidirect_kernel, |
||
270 | sizeof(field_bidirect_kernel), |
||
271 | NULL |
||
272 | }, |
||
273 | |||
274 | { |
||
275 | "FIELD_BIDIRECT_16X8", |
||
276 | FIELD_BIDIRECT_16X8, |
||
277 | field_bidirect_16x8_kernel, |
||
278 | sizeof(field_bidirect_16x8_kernel), |
||
279 | NULL |
||
280 | } |
||
281 | }; |
||
282 | |||
283 | /* On IRONLAKE */ |
||
284 | static const uint32_t frame_intra_kernel_gen5[][4] = { |
||
285 | #include "shaders/mpeg2/vld/frame_intra.g4b.gen5" |
||
286 | }; |
||
287 | static const uint32_t frame_frame_pred_forward_kernel_gen5[][4] = { |
||
288 | #include "shaders/mpeg2/vld/frame_frame_pred_forward.g4b.gen5" |
||
289 | }; |
||
290 | static const uint32_t frame_frame_pred_backward_kernel_gen5[][4] = { |
||
291 | #include "shaders/mpeg2/vld/frame_frame_pred_backward.g4b.gen5" |
||
292 | }; |
||
293 | static const uint32_t frame_frame_pred_bidirect_kernel_gen5[][4] = { |
||
294 | #include "shaders/mpeg2/vld/frame_frame_pred_bidirect.g4b.gen5" |
||
295 | }; |
||
296 | static const uint32_t frame_field_pred_forward_kernel_gen5[][4] = { |
||
297 | #include "shaders/mpeg2/vld/frame_field_pred_forward.g4b.gen5" |
||
298 | }; |
||
299 | static const uint32_t frame_field_pred_backward_kernel_gen5[][4] = { |
||
300 | #include "shaders/mpeg2/vld/frame_field_pred_backward.g4b.gen5" |
||
301 | }; |
||
302 | static const uint32_t frame_field_pred_bidirect_kernel_gen5[][4] = { |
||
303 | #include "shaders/mpeg2/vld/frame_field_pred_bidirect.g4b.gen5" |
||
304 | }; |
||
305 | static const uint32_t lib_kernel_gen5[][4] = { |
||
306 | #include "shaders/mpeg2/vld/lib.g4b.gen5" |
||
307 | }; |
||
308 | /*field picture*/ |
||
309 | static const uint32_t field_intra_kernel_gen5[][4] = { |
||
310 | #include "shaders/mpeg2/vld/field_intra.g4b.gen5" |
||
311 | }; |
||
312 | static const uint32_t field_forward_kernel_gen5[][4] = { |
||
313 | #include "shaders/mpeg2/vld/field_forward.g4b.gen5" |
||
314 | }; |
||
315 | static const uint32_t field_forward_16x8_kernel_gen5[][4] = { |
||
316 | #include "shaders/mpeg2/vld/field_forward_16x8.g4b.gen5" |
||
317 | }; |
||
318 | static const uint32_t field_backward_kernel_gen5[][4] = { |
||
319 | #include "shaders/mpeg2/vld/field_backward.g4b.gen5" |
||
320 | }; |
||
321 | static const uint32_t field_backward_16x8_kernel_gen5[][4] = { |
||
322 | #include "shaders/mpeg2/vld/field_backward_16x8.g4b.gen5" |
||
323 | }; |
||
324 | static const uint32_t field_bidirect_kernel_gen5[][4] = { |
||
325 | #include "shaders/mpeg2/vld/field_bidirect.g4b.gen5" |
||
326 | }; |
||
327 | static const uint32_t field_bidirect_16x8_kernel_gen5[][4] = { |
||
328 | #include "shaders/mpeg2/vld/field_bidirect_16x8.g4b.gen5" |
||
329 | }; |
||
330 | |||
331 | static struct i965_kernel mpeg2_vld_kernels_gen5[] = { |
||
332 | { |
||
333 | "FRAME_INTRA", |
||
334 | FRAME_INTRA, |
||
335 | frame_intra_kernel_gen5, |
||
336 | sizeof(frame_intra_kernel_gen5), |
||
337 | NULL |
||
338 | }, |
||
339 | |||
340 | { |
||
341 | "FRAME_FRAME_PRED_FORWARD", |
||
342 | FRAME_FRAME_PRED_FORWARD, |
||
343 | frame_frame_pred_forward_kernel_gen5, |
||
344 | sizeof(frame_frame_pred_forward_kernel_gen5), |
||
345 | NULL |
||
346 | }, |
||
347 | |||
348 | { |
||
349 | "FRAME_FRAME_PRED_BACKWARD", |
||
350 | FRAME_FRAME_PRED_BACKWARD, |
||
351 | frame_frame_pred_backward_kernel_gen5, |
||
352 | sizeof(frame_frame_pred_backward_kernel_gen5), |
||
353 | NULL |
||
354 | }, |
||
355 | |||
356 | { |
||
357 | "FRAME_FRAME_PRED_BIDIRECT", |
||
358 | FRAME_FRAME_PRED_BIDIRECT, |
||
359 | frame_frame_pred_bidirect_kernel_gen5, |
||
360 | sizeof(frame_frame_pred_bidirect_kernel_gen5), |
||
361 | NULL |
||
362 | }, |
||
363 | |||
364 | { |
||
365 | "FRAME_FIELD_PRED_FORWARD", |
||
366 | FRAME_FIELD_PRED_FORWARD, |
||
367 | frame_field_pred_forward_kernel_gen5, |
||
368 | sizeof(frame_field_pred_forward_kernel_gen5), |
||
369 | NULL |
||
370 | }, |
||
371 | |||
372 | { |
||
373 | "FRAME_FIELD_PRED_BACKWARD", |
||
374 | FRAME_FIELD_PRED_BACKWARD, |
||
375 | frame_field_pred_backward_kernel_gen5, |
||
376 | sizeof(frame_field_pred_backward_kernel_gen5), |
||
377 | NULL |
||
378 | }, |
||
379 | |||
380 | { |
||
381 | "FRAME_FIELD_PRED_BIDIRECT", |
||
382 | FRAME_FIELD_PRED_BIDIRECT, |
||
383 | frame_field_pred_bidirect_kernel_gen5, |
||
384 | sizeof(frame_field_pred_bidirect_kernel_gen5), |
||
385 | NULL |
||
386 | }, |
||
387 | |||
388 | { |
||
389 | "LIB", |
||
390 | LIB_INTERFACE, |
||
391 | lib_kernel_gen5, |
||
392 | sizeof(lib_kernel_gen5), |
||
393 | NULL |
||
394 | }, |
||
395 | |||
396 | { |
||
397 | "FIELD_INTRA", |
||
398 | FIELD_INTRA, |
||
399 | field_intra_kernel_gen5, |
||
400 | sizeof(field_intra_kernel_gen5), |
||
401 | NULL |
||
402 | }, |
||
403 | |||
404 | { |
||
405 | "FIELD_FORWARD", |
||
406 | FIELD_FORWARD, |
||
407 | field_forward_kernel_gen5, |
||
408 | sizeof(field_forward_kernel_gen5), |
||
409 | NULL |
||
410 | }, |
||
411 | |||
412 | { |
||
413 | "FIELD_FORWARD_16X8", |
||
414 | FIELD_FORWARD_16X8, |
||
415 | field_forward_16x8_kernel_gen5, |
||
416 | sizeof(field_forward_16x8_kernel_gen5), |
||
417 | NULL |
||
418 | }, |
||
419 | |||
420 | { |
||
421 | "FIELD_BACKWARD", |
||
422 | FIELD_BACKWARD, |
||
423 | field_backward_kernel_gen5, |
||
424 | sizeof(field_backward_kernel_gen5), |
||
425 | NULL |
||
426 | }, |
||
427 | |||
428 | { |
||
429 | "FIELD_BACKWARD_16X8", |
||
430 | FIELD_BACKWARD_16X8, |
||
431 | field_backward_16x8_kernel_gen5, |
||
432 | sizeof(field_backward_16x8_kernel_gen5), |
||
433 | NULL |
||
434 | }, |
||
435 | |||
436 | { |
||
437 | "FIELD_BIDIRECT", |
||
438 | FIELD_BIDIRECT, |
||
439 | field_bidirect_kernel_gen5, |
||
440 | sizeof(field_bidirect_kernel_gen5), |
||
441 | NULL |
||
442 | }, |
||
443 | |||
444 | { |
||
445 | "FIELD_BIDIRECT_16X8", |
||
446 | FIELD_BIDIRECT_16X8, |
||
447 | field_bidirect_16x8_kernel_gen5, |
||
448 | sizeof(field_bidirect_16x8_kernel_gen5), |
||
449 | NULL |
||
450 | } |
||
451 | }; |
||
452 | |||
453 | static void |
||
454 | i965_media_mpeg2_surface_state(VADriverContextP ctx, |
||
455 | int index, |
||
456 | struct object_surface *obj_surface, |
||
457 | unsigned long offset, |
||
458 | int w, int h, |
||
459 | Bool is_dst, |
||
460 | int vert_line_stride, |
||
461 | int vert_line_stride_ofs, |
||
462 | struct i965_media_context *media_context) |
||
463 | { |
||
464 | struct i965_driver_data *i965 = i965_driver_data(ctx); |
||
465 | struct i965_surface_state *ss; |
||
466 | dri_bo *bo; |
||
467 | uint32_t write_domain, read_domain; |
||
468 | |||
469 | bo = dri_bo_alloc(i965->intel.bufmgr, |
||
470 | "surface state", |
||
471 | sizeof(struct i965_surface_state), 32); |
||
472 | assert(bo); |
||
473 | dri_bo_map(bo, 1); |
||
474 | assert(bo->virtual); |
||
475 | ss = bo->virtual; |
||
476 | memset(ss, 0, sizeof(*ss)); |
||
477 | ss->ss0.surface_type = I965_SURFACE_2D; |
||
478 | ss->ss0.surface_format = I965_SURFACEFORMAT_R8_SINT; |
||
479 | ss->ss0.vert_line_stride = vert_line_stride; |
||
480 | ss->ss0.vert_line_stride_ofs = vert_line_stride_ofs; |
||
481 | ss->ss1.base_addr = obj_surface->bo->offset + offset; |
||
482 | ss->ss2.width = w - 1; |
||
483 | ss->ss2.height = h - 1; |
||
484 | ss->ss3.pitch = w - 1; |
||
485 | |||
486 | if (is_dst) { |
||
487 | write_domain = I915_GEM_DOMAIN_RENDER; |
||
488 | read_domain = I915_GEM_DOMAIN_RENDER; |
||
489 | } else { |
||
490 | write_domain = 0; |
||
491 | read_domain = I915_GEM_DOMAIN_SAMPLER; |
||
492 | } |
||
493 | |||
494 | dri_bo_emit_reloc(bo, |
||
495 | read_domain, write_domain, |
||
496 | offset, |
||
497 | offsetof(struct i965_surface_state, ss1), |
||
498 | obj_surface->bo); |
||
499 | dri_bo_unmap(bo); |
||
500 | |||
501 | assert(index < MAX_MEDIA_SURFACES); |
||
502 | // assert(media_context->surface_state[index].bo == NULL); |
||
503 | media_context->surface_state[index].bo = bo; |
||
504 | } |
||
505 | |||
506 | static void |
||
507 | i965_media_mpeg2_surface_setup(VADriverContextP ctx, |
||
508 | int base_index, |
||
509 | struct object_surface *obj_surface, |
||
510 | Bool is_dst, |
||
511 | int picture_structure, |
||
512 | int surface, |
||
513 | struct i965_media_context *media_context) |
||
514 | { |
||
515 | int w = obj_surface->width; |
||
516 | int h = obj_surface->height; |
||
517 | |||
518 | i965_check_alloc_surface_bo(ctx, obj_surface, 0, VA_FOURCC('I','4','2','0'), SUBSAMPLE_YUV420); |
||
519 | |||
520 | if (picture_structure == MPEG_FRAME) { |
||
521 | i965_media_mpeg2_surface_state(ctx, base_index + 0, obj_surface, |
||
522 | 0, w, h, |
||
523 | is_dst, 0, 0, |
||
524 | media_context); |
||
525 | i965_media_mpeg2_surface_state(ctx, base_index + 1, obj_surface, |
||
526 | w * h, w / 2, h / 2, |
||
527 | is_dst, 0, 0, |
||
528 | media_context); |
||
529 | i965_media_mpeg2_surface_state(ctx, base_index + 2, obj_surface, |
||
530 | w * h + w * h / 4, w / 2, h / 2, |
||
531 | is_dst, 0, 0, |
||
532 | media_context); |
||
533 | } else { |
||
534 | if (surface == SURFACE_TARGET) { |
||
535 | i965_media_mpeg2_surface_state(ctx, 3, obj_surface, |
||
536 | 0, w, h, |
||
537 | False, 0, 0, |
||
538 | media_context); |
||
539 | i965_media_mpeg2_surface_state(ctx, 10, obj_surface, |
||
540 | w * h, w / 2, h / 2, |
||
541 | False, 0, 0, |
||
542 | media_context); |
||
543 | i965_media_mpeg2_surface_state(ctx, 11, obj_surface, |
||
544 | w * h + w * h / 4, w / 2, h / 2, |
||
545 | False, 0, 0, |
||
546 | media_context); |
||
547 | if (picture_structure == MPEG_TOP_FIELD) { |
||
548 | i965_media_mpeg2_surface_state(ctx, base_index + 0, obj_surface, |
||
549 | 0, w, h, |
||
550 | True, 1, 0, |
||
551 | media_context); |
||
552 | i965_media_mpeg2_surface_state(ctx, base_index + 1, obj_surface, |
||
553 | w * h, w / 2, h / 2, |
||
554 | True, 1, 0, |
||
555 | media_context); |
||
556 | i965_media_mpeg2_surface_state(ctx, base_index + 2, obj_surface, |
||
557 | w * h + w * h / 4, w / 2, h / 2, |
||
558 | True, 1, 0, |
||
559 | media_context); |
||
560 | } else { |
||
561 | assert(picture_structure == MPEG_BOTTOM_FIELD); |
||
562 | i965_media_mpeg2_surface_state(ctx, base_index + 0, obj_surface, |
||
563 | 0, w, h, |
||
564 | True, 1, 1, |
||
565 | media_context); |
||
566 | i965_media_mpeg2_surface_state(ctx, base_index + 1, obj_surface, |
||
567 | w * h, w / 2, h / 2, |
||
568 | True, 1, 1, |
||
569 | media_context); |
||
570 | i965_media_mpeg2_surface_state(ctx, base_index + 2, obj_surface, |
||
571 | w * h + w * h / 4, w / 2, h / 2, |
||
572 | True, 1, 1, |
||
573 | media_context); |
||
574 | } |
||
575 | } else { |
||
576 | i965_media_mpeg2_surface_state(ctx, base_index + 0, obj_surface, |
||
577 | 0, w, h, |
||
578 | is_dst, 0, 0, |
||
579 | media_context); |
||
580 | i965_media_mpeg2_surface_state(ctx, base_index + 1, obj_surface, |
||
581 | w * h, w / 2, h / 2, |
||
582 | is_dst, 0, 0, |
||
583 | media_context); |
||
584 | i965_media_mpeg2_surface_state(ctx, base_index + 2, obj_surface, |
||
585 | w * h + w * h / 4, w / 2, h / 2, |
||
586 | is_dst, 0, 0, |
||
587 | media_context); |
||
588 | } |
||
589 | } |
||
590 | } |
||
591 | |||
592 | void |
||
593 | i965_media_mpeg2_surfaces_setup(VADriverContextP ctx, |
||
594 | struct decode_state *decode_state, |
||
595 | struct i965_media_context *media_context) |
||
596 | { |
||
597 | struct i965_driver_data *i965 = i965_driver_data(ctx); |
||
598 | struct object_surface *obj_surface; |
||
599 | VAPictureParameterBufferMPEG2 *param; |
||
600 | |||
601 | assert(decode_state->pic_param && decode_state->pic_param->buffer); |
||
602 | param = (VAPictureParameterBufferMPEG2 *)decode_state->pic_param->buffer; |
||
603 | |||
604 | obj_surface = SURFACE(decode_state->current_render_target); |
||
605 | assert(obj_surface); |
||
606 | i965_media_mpeg2_surface_setup(ctx, 0, obj_surface, True, |
||
607 | param->picture_coding_extension.bits.picture_structure, |
||
608 | SURFACE_TARGET, |
||
609 | media_context); |
||
610 | |||
611 | obj_surface = SURFACE(param->forward_reference_picture); |
||
612 | if (!obj_surface) { |
||
613 | // assert(param->picture_coding_type == 1); /* I-picture */ |
||
614 | } else { |
||
615 | i965_media_mpeg2_surface_setup(ctx, 4, obj_surface, False, |
||
616 | param->picture_coding_extension.bits.picture_structure, |
||
617 | SURFACE_FORWARD, |
||
618 | media_context); |
||
619 | obj_surface = SURFACE(param->backward_reference_picture); |
||
620 | if (!obj_surface) { |
||
621 | assert(param->picture_coding_type == 2); /* P-picture */ |
||
622 | |||
623 | obj_surface = SURFACE(param->forward_reference_picture); |
||
624 | i965_media_mpeg2_surface_setup(ctx, 7, obj_surface, False, |
||
625 | param->picture_coding_extension.bits.picture_structure, |
||
626 | SURFACE_BACKWARD, |
||
627 | media_context); |
||
628 | } else { |
||
629 | assert(param->picture_coding_type == 3); /* B-picture */ |
||
630 | i965_media_mpeg2_surface_setup(ctx, 7, obj_surface, False, |
||
631 | param->picture_coding_extension.bits.picture_structure, |
||
632 | SURFACE_BIDIRECT, |
||
633 | media_context); |
||
634 | } |
||
635 | } |
||
636 | } |
||
637 | |||
638 | static void |
||
639 | i965_media_mpeg2_binding_table(VADriverContextP ctx, struct i965_media_context *media_context) |
||
640 | { |
||
641 | int i; |
||
642 | unsigned int *binding_table; |
||
643 | dri_bo *bo = media_context->binding_table.bo; |
||
644 | |||
645 | dri_bo_map(bo, 1); |
||
646 | assert(bo->virtual); |
||
647 | binding_table = bo->virtual; |
||
648 | memset(binding_table, 0, bo->size); |
||
649 | |||
650 | for (i = 0; i < MAX_MEDIA_SURFACES; i++) { |
||
651 | if (media_context->surface_state[i].bo) { |
||
652 | binding_table[i] = media_context->surface_state[i].bo->offset; |
||
653 | dri_bo_emit_reloc(bo, |
||
654 | I915_GEM_DOMAIN_INSTRUCTION, 0, |
||
655 | 0, |
||
656 | i * sizeof(*binding_table), |
||
657 | media_context->surface_state[i].bo); |
||
658 | } |
||
659 | } |
||
660 | |||
661 | dri_bo_unmap(media_context->binding_table.bo); |
||
662 | } |
||
663 | |||
664 | static void |
||
665 | i965_media_mpeg2_vfe_state(VADriverContextP ctx, struct i965_media_context *media_context) |
||
666 | { |
||
667 | struct i965_vfe_state *vfe_state; |
||
668 | dri_bo *bo; |
||
669 | |||
670 | bo = media_context->vfe_state.bo; |
||
671 | dri_bo_map(bo, 1); |
||
672 | assert(bo->virtual); |
||
673 | vfe_state = bo->virtual; |
||
674 | memset(vfe_state, 0, sizeof(*vfe_state)); |
||
675 | vfe_state->vfe0.extend_vfe_state_present = 1; |
||
676 | vfe_state->vfe1.vfe_mode = VFE_VLD_MODE; |
||
677 | vfe_state->vfe1.num_urb_entries = media_context->urb.num_vfe_entries; |
||
678 | vfe_state->vfe1.children_present = 0; |
||
679 | vfe_state->vfe1.urb_entry_alloc_size = media_context->urb.size_vfe_entry - 1; |
||
680 | vfe_state->vfe1.max_threads = media_context->urb.num_vfe_entries - 1; |
||
681 | vfe_state->vfe2.interface_descriptor_base = |
||
682 | media_context->idrt.bo->offset >> 4; /* reloc */ |
||
683 | dri_bo_emit_reloc(bo, |
||
684 | I915_GEM_DOMAIN_INSTRUCTION, 0, |
||
685 | 0, |
||
686 | offsetof(struct i965_vfe_state, vfe2), |
||
687 | media_context->idrt.bo); |
||
688 | dri_bo_unmap(bo); |
||
689 | } |
||
690 | |||
691 | static void |
||
692 | i965_media_mpeg2_interface_descriptor_remap_table(VADriverContextP ctx, struct i965_media_context *media_context) |
||
693 | { |
||
694 | struct i965_mpeg2_context *i965_mpeg2_context = (struct i965_mpeg2_context *)media_context->private_context; |
||
695 | struct i965_interface_descriptor *desc; |
||
696 | int i; |
||
697 | dri_bo *bo; |
||
698 | |||
699 | bo = media_context->idrt.bo; |
||
700 | dri_bo_map(bo, 1); |
||
701 | assert(bo->virtual); |
||
702 | desc = bo->virtual; |
||
703 | |||
704 | for (i = 0; i < NUM_MPEG2_VLD_KERNELS; i++) { |
||
705 | memset(desc, 0, sizeof(*desc)); |
||
706 | desc->desc0.grf_reg_blocks = 15; |
||
707 | desc->desc0.kernel_start_pointer = i965_mpeg2_context->vld_kernels[i].bo->offset >> 6; /* reloc */ |
||
708 | desc->desc1.const_urb_entry_read_offset = 0; |
||
709 | desc->desc1.const_urb_entry_read_len = 30; |
||
710 | desc->desc3.binding_table_entry_count = 0; |
||
711 | desc->desc3.binding_table_pointer = |
||
712 | media_context->binding_table.bo->offset >> 5; /*reloc */ |
||
713 | |||
714 | dri_bo_emit_reloc(bo, |
||
715 | I915_GEM_DOMAIN_INSTRUCTION, 0, |
||
716 | desc->desc0.grf_reg_blocks, |
||
717 | i * sizeof(*desc) + offsetof(struct i965_interface_descriptor, desc0), |
||
718 | i965_mpeg2_context->vld_kernels[i].bo); |
||
719 | |||
720 | dri_bo_emit_reloc(bo, |
||
721 | I915_GEM_DOMAIN_INSTRUCTION, 0, |
||
722 | desc->desc3.binding_table_entry_count, |
||
723 | i * sizeof(*desc) + offsetof(struct i965_interface_descriptor, desc3), |
||
724 | media_context->binding_table.bo); |
||
725 | desc++; |
||
726 | } |
||
727 | |||
728 | dri_bo_unmap(bo); |
||
729 | } |
||
730 | |||
731 | void |
||
732 | i965_media_mpeg2_vld_state(VADriverContextP ctx, |
||
733 | struct decode_state *decode_state, |
||
734 | struct i965_media_context *media_context) |
||
735 | { |
||
736 | struct i965_vld_state *vld_state; |
||
737 | VAPictureParameterBufferMPEG2 *param; |
||
738 | |||
739 | assert(decode_state->pic_param && decode_state->pic_param->buffer); |
||
740 | param = (VAPictureParameterBufferMPEG2 *)decode_state->pic_param->buffer; |
||
741 | |||
742 | assert(media_context->extended_state.bo); |
||
743 | dri_bo_map(media_context->extended_state.bo, 1); |
||
744 | assert(media_context->extended_state.bo->virtual); |
||
745 | vld_state = media_context->extended_state.bo->virtual; |
||
746 | memset(vld_state, 0, sizeof(*vld_state)); |
||
747 | |||
748 | vld_state->vld0.f_code_0_0 = ((param->f_code >> 12) & 0xf); |
||
749 | vld_state->vld0.f_code_0_1 = ((param->f_code >> 8) & 0xf); |
||
750 | vld_state->vld0.f_code_1_0 = ((param->f_code >> 4) & 0xf); |
||
751 | vld_state->vld0.f_code_1_1 = (param->f_code & 0xf); |
||
752 | vld_state->vld0.intra_dc_precision = param->picture_coding_extension.bits.intra_dc_precision; |
||
753 | vld_state->vld0.picture_structure = param->picture_coding_extension.bits.picture_structure; |
||
754 | vld_state->vld0.top_field_first = param->picture_coding_extension.bits.top_field_first; |
||
755 | vld_state->vld0.frame_predict_frame_dct = param->picture_coding_extension.bits.frame_pred_frame_dct; |
||
756 | vld_state->vld0.concealment_motion_vector = param->picture_coding_extension.bits.concealment_motion_vectors; |
||
757 | vld_state->vld0.quantizer_scale_type = param->picture_coding_extension.bits.q_scale_type; |
||
758 | vld_state->vld0.intra_vlc_format = param->picture_coding_extension.bits.intra_vlc_format; |
||
759 | vld_state->vld0.scan_order = param->picture_coding_extension.bits.alternate_scan; |
||
760 | |||
761 | vld_state->vld1.picture_coding_type = param->picture_coding_type; |
||
762 | |||
763 | if (vld_state->vld0.picture_structure == MPEG_FRAME) { |
||
764 | /*frame picture*/ |
||
765 | vld_state->desc_remap_table0.index_0 = FRAME_INTRA; |
||
766 | vld_state->desc_remap_table0.index_1 = FRAME_FRAME_PRED_FORWARD; |
||
767 | vld_state->desc_remap_table0.index_2 = FRAME_FIELD_PRED_FORWARD; |
||
768 | vld_state->desc_remap_table0.index_3 = FRAME_FIELD_PRED_BIDIRECT; /* dual prime */ |
||
769 | vld_state->desc_remap_table0.index_4 = FRAME_FRAME_PRED_BACKWARD; |
||
770 | vld_state->desc_remap_table0.index_5 = FRAME_FIELD_PRED_BACKWARD; |
||
771 | vld_state->desc_remap_table0.index_6 = FRAME_FRAME_PRED_BIDIRECT; |
||
772 | vld_state->desc_remap_table0.index_7 = FRAME_FIELD_PRED_BIDIRECT; |
||
773 | |||
774 | vld_state->desc_remap_table1.index_8 = FRAME_INTRA; |
||
775 | vld_state->desc_remap_table1.index_9 = FRAME_FRAME_PRED_FORWARD; |
||
776 | vld_state->desc_remap_table1.index_10 = FRAME_FIELD_PRED_FORWARD; |
||
777 | vld_state->desc_remap_table1.index_11 = FRAME_FIELD_PRED_BIDIRECT; |
||
778 | vld_state->desc_remap_table1.index_12 = FRAME_FRAME_PRED_BACKWARD; |
||
779 | vld_state->desc_remap_table1.index_13 = FRAME_FIELD_PRED_BACKWARD; |
||
780 | vld_state->desc_remap_table1.index_14 = FRAME_FRAME_PRED_BIDIRECT; |
||
781 | vld_state->desc_remap_table1.index_15 = FRAME_FIELD_PRED_BIDIRECT; |
||
782 | } else { |
||
783 | /*field picture*/ |
||
784 | vld_state->desc_remap_table0.index_0 = FIELD_INTRA; |
||
785 | vld_state->desc_remap_table0.index_1 = FIELD_FORWARD; |
||
786 | vld_state->desc_remap_table0.index_2 = FIELD_FORWARD_16X8; |
||
787 | vld_state->desc_remap_table0.index_3 = FIELD_BIDIRECT; /* dual prime */ |
||
788 | vld_state->desc_remap_table0.index_4 = FIELD_BACKWARD; |
||
789 | vld_state->desc_remap_table0.index_5 = FIELD_BACKWARD_16X8; |
||
790 | vld_state->desc_remap_table0.index_6 = FIELD_BIDIRECT; |
||
791 | vld_state->desc_remap_table0.index_7 = FIELD_BIDIRECT_16X8; |
||
792 | } |
||
793 | |||
794 | dri_bo_unmap(media_context->extended_state.bo); |
||
795 | } |
||
796 | |||
797 | static void |
||
798 | i965_media_mpeg2_upload_constants(VADriverContextP ctx, |
||
799 | struct decode_state *decode_state, |
||
800 | struct i965_media_context *media_context) |
||
801 | { |
||
802 | struct i965_mpeg2_context *i965_mpeg2_context = (struct i965_mpeg2_context *)media_context->private_context; |
||
803 | VAIQMatrixBufferMPEG2 * const gen_iq_matrix = &i965_mpeg2_context->iq_matrix; |
||
804 | int i; |
||
805 | unsigned char *constant_buffer; |
||
806 | unsigned int *lib_reloc; |
||
807 | int lib_reloc_offset = 0; |
||
808 | |||
809 | dri_bo_map(media_context->curbe.bo, 1); |
||
810 | assert(media_context->curbe.bo->virtual); |
||
811 | constant_buffer = media_context->curbe.bo->virtual; |
||
812 | |||
813 | /* iq_matrix */ |
||
814 | if (decode_state->iq_matrix && decode_state->iq_matrix->buffer) { |
||
815 | VAIQMatrixBufferMPEG2 * const iq_matrix = |
||
816 | (VAIQMatrixBufferMPEG2 *)decode_state->iq_matrix->buffer; |
||
817 | |||
818 | gen_iq_matrix->load_intra_quantiser_matrix = |
||
819 | iq_matrix->load_intra_quantiser_matrix; |
||
820 | if (iq_matrix->load_intra_quantiser_matrix) { |
||
821 | for (i = 0; i < 64; i++) |
||
822 | gen_iq_matrix->intra_quantiser_matrix[zigzag_direct[i]] = |
||
823 | iq_matrix->intra_quantiser_matrix[i]; |
||
824 | } |
||
825 | |||
826 | gen_iq_matrix->load_non_intra_quantiser_matrix = |
||
827 | iq_matrix->load_non_intra_quantiser_matrix; |
||
828 | if (iq_matrix->load_non_intra_quantiser_matrix) { |
||
829 | for (i = 0; i < 64; i++) |
||
830 | gen_iq_matrix->non_intra_quantiser_matrix[zigzag_direct[i]] = |
||
831 | iq_matrix->non_intra_quantiser_matrix[i]; |
||
832 | } |
||
833 | |||
834 | /* no chroma quantisation matrices for 4:2:0 data */ |
||
835 | } |
||
836 | |||
837 | if (gen_iq_matrix->load_intra_quantiser_matrix) { |
||
838 | unsigned char * const qm = constant_buffer; |
||
839 | memcpy(qm, gen_iq_matrix->intra_quantiser_matrix, 64); |
||
840 | } |
||
841 | |||
842 | if (gen_iq_matrix->load_non_intra_quantiser_matrix) { |
||
843 | unsigned char * const qm = constant_buffer + 64; |
||
844 | memcpy(qm, gen_iq_matrix->non_intra_quantiser_matrix, 64); |
||
845 | } |
||
846 | |||
847 | /* idct table */ |
||
848 | memcpy(constant_buffer + 128, idct_table, sizeof(idct_table)); |
||
849 | |||
850 | /* idct lib reloc */ |
||
851 | lib_reloc_offset = 128 + sizeof(idct_table); |
||
852 | lib_reloc = (unsigned int *)(constant_buffer + lib_reloc_offset); |
||
853 | for (i = 0; i < 8; i++) { |
||
854 | lib_reloc[i] = i965_mpeg2_context->vld_kernels[LIB_INTERFACE].bo->offset; |
||
855 | dri_bo_emit_reloc(media_context->curbe.bo, |
||
856 | I915_GEM_DOMAIN_INSTRUCTION, 0, |
||
857 | 0, |
||
858 | lib_reloc_offset + i * sizeof(unsigned int), |
||
859 | i965_mpeg2_context->vld_kernels[LIB_INTERFACE].bo); |
||
860 | } |
||
861 | |||
862 | dri_bo_unmap(media_context->curbe.bo); |
||
863 | } |
||
864 | |||
865 | static void |
||
866 | i965_media_mpeg2_states_setup(VADriverContextP ctx, |
||
867 | struct decode_state *decode_state, |
||
868 | struct i965_media_context *media_context) |
||
869 | { |
||
870 | i965_media_mpeg2_surfaces_setup(ctx, decode_state, media_context); |
||
871 | i965_media_mpeg2_binding_table(ctx, media_context); |
||
872 | i965_media_mpeg2_interface_descriptor_remap_table(ctx, media_context); |
||
873 | i965_media_mpeg2_vld_state(ctx, decode_state, media_context); |
||
874 | i965_media_mpeg2_vfe_state(ctx, media_context); |
||
875 | i965_media_mpeg2_upload_constants(ctx, decode_state, media_context); |
||
876 | } |
||
877 | |||
878 | static void |
||
879 | i965_media_mpeg2_objects(VADriverContextP ctx, |
||
880 | struct decode_state *decode_state, |
||
881 | struct i965_media_context *media_context) |
||
882 | { |
||
883 | struct i965_mpeg2_context * const i965_mpeg2_context = media_context->private_context; |
||
884 | struct intel_batchbuffer *batch = media_context->base.batch; |
||
885 | VASliceParameterBufferMPEG2 *slice_param; |
||
886 | VAPictureParameterBufferMPEG2 *pic_param; |
||
887 | int i, j; |
||
888 | |||
889 | assert(decode_state->pic_param && decode_state->pic_param->buffer); |
||
890 | pic_param = (VAPictureParameterBufferMPEG2 *)decode_state->pic_param->buffer; |
||
891 | |||
892 | if (i965_mpeg2_context->wa_slice_vertical_position < 0) |
||
893 | i965_mpeg2_context->wa_slice_vertical_position = |
||
894 | mpeg2_wa_slice_vertical_position(decode_state, pic_param); |
||
895 | |||
896 | for (j = 0; j < decode_state->num_slice_params; j++) { |
||
897 | assert(decode_state->slice_params[j] && decode_state->slice_params[j]->buffer); |
||
898 | assert(decode_state->slice_datas[j] && decode_state->slice_datas[j]->bo); |
||
899 | slice_param = (VASliceParameterBufferMPEG2 *)decode_state->slice_params[j]->buffer; |
||
900 | |||
901 | for (i = 0; i < decode_state->slice_params[j]->num_elements; i++) { |
||
902 | int vpos, hpos, is_field_pic = 0; |
||
903 | |||
904 | if (i965_mpeg2_context->wa_slice_vertical_position > 0 && |
||
905 | (pic_param->picture_coding_extension.bits.picture_structure == MPEG_TOP_FIELD || |
||
906 | pic_param->picture_coding_extension.bits.picture_structure == MPEG_BOTTOM_FIELD)) |
||
907 | is_field_pic = 1; |
||
908 | |||
909 | assert(slice_param->slice_data_flag == VA_SLICE_DATA_FLAG_ALL); |
||
910 | vpos = slice_param->slice_vertical_position / (1 + is_field_pic); |
||
911 | hpos = slice_param->slice_horizontal_position; |
||
912 | |||
913 | BEGIN_BATCH(batch, 6); |
||
914 | OUT_BATCH(batch, CMD_MEDIA_OBJECT | 4); |
||
915 | OUT_BATCH(batch, 0); |
||
916 | OUT_BATCH(batch, slice_param->slice_data_size - (slice_param->macroblock_offset >> 3)); |
||
917 | OUT_RELOC(batch, decode_state->slice_datas[j]->bo, |
||
918 | I915_GEM_DOMAIN_SAMPLER, 0, |
||
919 | slice_param->slice_data_offset + (slice_param->macroblock_offset >> 3)); |
||
920 | OUT_BATCH(batch, |
||
921 | ((hpos << 24) | |
||
922 | (vpos << 16) | |
||
923 | (127 << 8) | |
||
924 | (slice_param->macroblock_offset & 0x7))); |
||
925 | OUT_BATCH(batch, slice_param->quantiser_scale_code << 24); |
||
926 | ADVANCE_BATCH(batch); |
||
927 | slice_param++; |
||
928 | } |
||
929 | } |
||
930 | } |
||
931 | |||
932 | static void |
||
933 | i965_media_mpeg2_free_private_context(void **data) |
||
934 | { |
||
935 | struct i965_mpeg2_context *i965_mpeg2_context = *data; |
||
936 | int i; |
||
937 | |||
938 | if (i965_mpeg2_context == NULL) |
||
939 | return; |
||
940 | |||
941 | for (i = 0; i < NUM_MPEG2_VLD_KERNELS; i++) { |
||
942 | struct i965_kernel *kernel = &i965_mpeg2_context->vld_kernels[i]; |
||
943 | |||
944 | dri_bo_unreference(kernel->bo); |
||
945 | kernel->bo = NULL; |
||
946 | } |
||
947 | |||
948 | free(i965_mpeg2_context); |
||
949 | *data = NULL; |
||
950 | } |
||
951 | |||
952 | void |
||
953 | i965_media_mpeg2_decode_init(VADriverContextP ctx, |
||
954 | struct decode_state *decode_state, |
||
955 | struct i965_media_context *media_context) |
||
956 | { |
||
957 | struct i965_driver_data *i965 = i965_driver_data(ctx); |
||
958 | dri_bo *bo; |
||
959 | |||
960 | dri_bo_unreference(media_context->indirect_object.bo); |
||
961 | media_context->indirect_object.bo = NULL; |
||
962 | |||
963 | media_context->extended_state.enabled = 1; |
||
964 | dri_bo_unreference(media_context->extended_state.bo); |
||
965 | bo = dri_bo_alloc(i965->intel.bufmgr, |
||
966 | "vld state", |
||
967 | sizeof(struct i965_vld_state), 32); |
||
968 | assert(bo); |
||
969 | media_context->extended_state.bo = bo; |
||
970 | } |
||
971 | |||
972 | void |
||
973 | i965_media_mpeg2_dec_context_init(VADriverContextP ctx, struct i965_media_context *media_context) |
||
974 | { |
||
975 | struct i965_driver_data *i965 = i965_driver_data(ctx); |
||
976 | struct i965_mpeg2_context *i965_mpeg2_context; |
||
977 | int i; |
||
978 | |||
979 | i965_mpeg2_context = calloc(1, sizeof(struct i965_mpeg2_context)); |
||
980 | i965_mpeg2_context->wa_slice_vertical_position = -1; |
||
981 | |||
982 | /* kernel */ |
||
983 | assert(NUM_MPEG2_VLD_KERNELS == (sizeof(mpeg2_vld_kernels_gen4) / |
||
984 | sizeof(mpeg2_vld_kernels_gen4[0]))); |
||
985 | assert(NUM_MPEG2_VLD_KERNELS == (sizeof(mpeg2_vld_kernels_gen5) / |
||
986 | sizeof(mpeg2_vld_kernels_gen5[0]))); |
||
987 | assert(NUM_MPEG2_VLD_KERNELS <= MAX_INTERFACE_DESC); |
||
988 | |||
989 | if (IS_IRONLAKE(i965->intel.device_id)) |
||
990 | memcpy(i965_mpeg2_context->vld_kernels, mpeg2_vld_kernels_gen5, sizeof(i965_mpeg2_context->vld_kernels)); |
||
991 | else |
||
992 | memcpy(i965_mpeg2_context->vld_kernels, mpeg2_vld_kernels_gen4, sizeof(i965_mpeg2_context->vld_kernels)); |
||
993 | |||
994 | for (i = 0; i < NUM_MPEG2_VLD_KERNELS; i++) { |
||
995 | struct i965_kernel *kernel = &i965_mpeg2_context->vld_kernels[i]; |
||
996 | kernel->bo = dri_bo_alloc(i965->intel.bufmgr, |
||
997 | kernel->name, |
||
998 | kernel->size, 64); |
||
999 | assert(kernel->bo); |
||
1000 | dri_bo_subdata(kernel->bo, 0, kernel->size, kernel->bin); |
||
1001 | } |
||
1002 | |||
1003 | /* URB */ |
||
1004 | media_context->urb.num_vfe_entries = 28; |
||
1005 | media_context->urb.size_vfe_entry = 13; |
||
1006 | |||
1007 | media_context->urb.num_cs_entries = 1; |
||
1008 | media_context->urb.size_cs_entry = 16; |
||
1009 | |||
1010 | media_context->urb.vfe_start = 0; |
||
1011 | media_context->urb.cs_start = media_context->urb.vfe_start + |
||
1012 | media_context->urb.num_vfe_entries * media_context->urb.size_vfe_entry; |
||
1013 | assert(media_context->urb.cs_start + |
||
1014 | media_context->urb.num_cs_entries * media_context->urb.size_cs_entry <= URB_SIZE((&i965->intel))); |
||
1015 | |||
1016 | /* hook functions */ |
||
1017 | media_context->media_states_setup = i965_media_mpeg2_states_setup; |
||
1018 | media_context->media_objects = i965_media_mpeg2_objects; |
||
1019 | media_context->private_context = i965_mpeg2_context; |
||
1020 | media_context->free_private_context = i965_media_mpeg2_free_private_context; |
||
1021 | }=>>=>>><>><>><>><>>>>>>>>>> |