hardware/intel/intel-driver
Revision | 9540f1e194e0f18f72a9496899bf7d1323b923af (tree) |
---|---|
Zeit | 2016-01-15 10:21:52 |
Autor | Xiang, Haihao <haihao.xiang@inte...> |
Commiter | Xiang, Haihao |
Merge remote-tracking branch 'fdo/master' into v1.6-branch
Conflicts:
configure.ac
src/gen9_mfd.c
src/gen9_mfd.h
src/i965_device_info.c
src/i965_drv_video.c
src/i965_drv_video.h
src/intel_media_common.c
@@ -1,8 +1,8 @@ | ||
1 | 1 | # intel-driver package version number |
2 | 2 | m4_define([intel_driver_major_version], [1]) |
3 | 3 | m4_define([intel_driver_minor_version], [6]) |
4 | -m4_define([intel_driver_micro_version], [2]) | |
5 | -m4_define([intel_driver_pre_version], [0]) | |
4 | +m4_define([intel_driver_micro_version], [3]) | |
5 | +m4_define([intel_driver_pre_version], [1]) | |
6 | 6 | m4_define([intel_driver_version], |
7 | 7 | [intel_driver_major_version.intel_driver_minor_version.intel_driver_micro_version]) |
8 | 8 | m4_if(intel_driver_pre_version, [0], [], [ |
@@ -28,6 +28,7 @@ | ||
28 | 28 | #include <stdio.h> |
29 | 29 | #include <stdlib.h> |
30 | 30 | #include <assert.h> |
31 | +#include <string.h> | |
31 | 32 | |
32 | 33 | #include "intel_batchbuffer.h" |
33 | 34 | #include "intel_driver.h" |
@@ -123,6 +124,15 @@ gen75_proc_picture(VADriverContextP ctx, | ||
123 | 124 | (VAProcPipelineParameterBuffer *)proc_st->pipeline_param->buffer; |
124 | 125 | struct object_surface *obj_dst_surf = NULL; |
125 | 126 | struct object_surface *obj_src_surf = NULL; |
127 | + | |
128 | + VAProcPipelineParameterBuffer pipeline_param2; | |
129 | + struct object_surface *stage1_dst_surf = NULL; | |
130 | + struct object_surface *stage2_dst_surf = NULL; | |
131 | + VARectangle src_rect, dst_rect; | |
132 | + VASurfaceID tmp_surfaces[2]; | |
133 | + VASurfaceID out_surface_id1 = VA_INVALID_ID, out_surface_id2 = VA_INVALID_ID; | |
134 | + int num_tmp_surfaces = 0; | |
135 | + | |
126 | 136 | VAStatus status; |
127 | 137 | |
128 | 138 | proc_ctx->pipeline_param = pipeline_param; |
@@ -168,69 +178,221 @@ gen75_proc_picture(VADriverContextP ctx, | ||
168 | 178 | proc_ctx->surface_pipeline_input_object = obj_src_surf; |
169 | 179 | assert(pipeline_param->num_filters <= 4); |
170 | 180 | |
181 | + int vpp_stage1 = 0, vpp_stage2 = 1, vpp_stage3 = 0; | |
182 | + | |
183 | + if (pipeline_param->surface_region) { | |
184 | + src_rect.x = pipeline_param->surface_region->x; | |
185 | + src_rect.y = pipeline_param->surface_region->y; | |
186 | + src_rect.width = pipeline_param->surface_region->width; | |
187 | + src_rect.height = pipeline_param->surface_region->height; | |
188 | + } else { | |
189 | + src_rect.x = 0; | |
190 | + src_rect.y = 0; | |
191 | + src_rect.width = obj_src_surf->orig_width; | |
192 | + src_rect.height = obj_src_surf->orig_height; | |
193 | + } | |
194 | + | |
195 | + if (pipeline_param->output_region) { | |
196 | + dst_rect.x = pipeline_param->output_region->x; | |
197 | + dst_rect.y = pipeline_param->output_region->y; | |
198 | + dst_rect.width = pipeline_param->output_region->width; | |
199 | + dst_rect.height = pipeline_param->output_region->height; | |
200 | + } else { | |
201 | + dst_rect.x = 0; | |
202 | + dst_rect.y = 0; | |
203 | + dst_rect.width = obj_dst_surf->orig_width; | |
204 | + dst_rect.height = obj_dst_surf->orig_height; | |
205 | + } | |
206 | + | |
207 | + if(obj_src_surf->fourcc == VA_FOURCC_P010) { | |
208 | + vpp_stage1 = 1; | |
209 | + vpp_stage2 = 0; | |
210 | + vpp_stage3 = 0; | |
211 | + if(pipeline_param->num_filters == 0 || pipeline_param->filters == NULL) { | |
212 | + if(src_rect.x != dst_rect.x || | |
213 | + src_rect.y != dst_rect.y || | |
214 | + src_rect.width != dst_rect.width || | |
215 | + src_rect.height != dst_rect.height) | |
216 | + vpp_stage2 = 1; | |
217 | + | |
218 | + if(obj_dst_surf->fourcc != VA_FOURCC_NV12 && | |
219 | + obj_dst_surf->fourcc != VA_FOURCC_P010) | |
220 | + vpp_stage2 = 1; | |
221 | + } | |
222 | + else | |
223 | + vpp_stage2 = 1; | |
224 | + | |
225 | + if(vpp_stage2 == 1) { | |
226 | + if(obj_dst_surf->fourcc == VA_FOURCC_P010) | |
227 | + vpp_stage3 = 1; | |
228 | + } | |
229 | + } | |
230 | + else if(obj_dst_surf->fourcc == VA_FOURCC_P010) { | |
231 | + vpp_stage2 = 1; | |
232 | + vpp_stage3 = 1; | |
233 | + | |
234 | + if((obj_src_surf->fourcc == VA_FOURCC_NV12) && | |
235 | + (pipeline_param->num_filters == 0 || pipeline_param->filters == NULL)) { | |
236 | + if((src_rect.x == dst_rect.x) && | |
237 | + (src_rect.y == dst_rect.y) && | |
238 | + (src_rect.width == dst_rect.width) && | |
239 | + (src_rect.height == dst_rect.height)) | |
240 | + vpp_stage2 = 0; | |
241 | + } | |
242 | + } | |
243 | + | |
244 | + if(vpp_stage1 == 1){ | |
245 | + memset((void *)&pipeline_param2, 0, sizeof(pipeline_param2)); | |
246 | + pipeline_param2.surface = pipeline_param->surface; | |
247 | + pipeline_param2.surface_region = &src_rect; | |
248 | + pipeline_param2.output_region = &src_rect; | |
249 | + pipeline_param2.filter_flags = 0; | |
250 | + pipeline_param2.num_filters = 0; | |
251 | + | |
252 | + proc_ctx->pipeline_param = &pipeline_param2; | |
253 | + | |
254 | + if(vpp_stage2 == 1) { | |
255 | + status = i965_CreateSurfaces(ctx, | |
256 | + obj_src_surf->orig_width, | |
257 | + obj_src_surf->orig_height, | |
258 | + VA_RT_FORMAT_YUV420, | |
259 | + 1, | |
260 | + &out_surface_id1); | |
261 | + assert(status == VA_STATUS_SUCCESS); | |
262 | + tmp_surfaces[num_tmp_surfaces++] = out_surface_id1; | |
263 | + stage1_dst_surf = SURFACE(out_surface_id1); | |
264 | + assert(stage1_dst_surf); | |
265 | + i965_check_alloc_surface_bo(ctx, stage1_dst_surf, 1, VA_FOURCC_NV12, SUBSAMPLE_YUV420); | |
266 | + | |
267 | + proc_ctx->surface_render_output_object = stage1_dst_surf; | |
268 | + } | |
269 | + | |
270 | + gen75_vpp_vebox(ctx, proc_ctx); | |
271 | + } | |
272 | + | |
273 | + if((vpp_stage3 == 1) && (vpp_stage2 == 1)) { | |
274 | + status = i965_CreateSurfaces(ctx, | |
275 | + obj_dst_surf->orig_width, | |
276 | + obj_dst_surf->orig_height, | |
277 | + VA_RT_FORMAT_YUV420, | |
278 | + 1, | |
279 | + &out_surface_id2); | |
280 | + assert(status == VA_STATUS_SUCCESS); | |
281 | + tmp_surfaces[num_tmp_surfaces++] = out_surface_id2; | |
282 | + stage2_dst_surf = SURFACE(out_surface_id2); | |
283 | + assert(stage2_dst_surf); | |
284 | + i965_check_alloc_surface_bo(ctx, stage2_dst_surf, 1, VA_FOURCC_NV12, SUBSAMPLE_YUV420); | |
285 | + } | |
286 | + | |
171 | 287 | VABufferID *filter_id = (VABufferID*) pipeline_param->filters; |
172 | - | |
173 | - if(pipeline_param->num_filters == 0 || pipeline_param->filters == NULL ){ | |
174 | - /* implicity surface format coversion and scaling */ | |
175 | - gen75_vpp_fmt_cvt(ctx, profile, codec_state, hw_context); | |
176 | - }else if(pipeline_param->num_filters == 1) { | |
177 | - struct object_buffer * obj_buf = BUFFER((*filter_id) + 0); | |
178 | - | |
179 | - assert(obj_buf && obj_buf->buffer_store && obj_buf->buffer_store->buffer); | |
180 | - | |
181 | - if (!obj_buf || | |
182 | - !obj_buf->buffer_store || | |
183 | - !obj_buf->buffer_store->buffer) { | |
184 | - status = VA_STATUS_ERROR_INVALID_FILTER_CHAIN; | |
185 | - goto error; | |
186 | - } | |
187 | - | |
188 | - VAProcFilterParameterBuffer* filter = | |
189 | - (VAProcFilterParameterBuffer*)obj_buf-> buffer_store->buffer; | |
190 | - | |
191 | - if (filter->type == VAProcFilterNoiseReduction || | |
192 | - filter->type == VAProcFilterDeinterlacing || | |
193 | - filter->type == VAProcFilterSkinToneEnhancement || | |
194 | - filter->type == VAProcFilterColorBalance){ | |
195 | - gen75_vpp_vebox(ctx, proc_ctx); | |
196 | - }else if(filter->type == VAProcFilterSharpening){ | |
197 | - if (obj_src_surf->fourcc != VA_FOURCC_NV12 || | |
198 | - obj_dst_surf->fourcc != VA_FOURCC_NV12) { | |
199 | - status = VA_STATUS_ERROR_UNIMPLEMENTED; | |
288 | + | |
289 | + if(vpp_stage2 == 1) { | |
290 | + if(stage1_dst_surf != NULL) { | |
291 | + proc_ctx->surface_pipeline_input_object = stage1_dst_surf; | |
292 | + proc_ctx->surface_render_output_object = obj_dst_surf; | |
293 | + | |
294 | + pipeline_param->surface = out_surface_id1; | |
295 | + } | |
296 | + | |
297 | + if(stage2_dst_surf != NULL) { | |
298 | + proc_ctx->surface_render_output_object = stage2_dst_surf; | |
299 | + | |
300 | + proc_st->current_render_target = out_surface_id2; | |
301 | + } | |
302 | + | |
303 | + proc_ctx->pipeline_param = pipeline_param; | |
304 | + | |
305 | + if(pipeline_param->num_filters == 0 || pipeline_param->filters == NULL ){ | |
306 | + /* implicity surface format coversion and scaling */ | |
307 | + | |
308 | + gen75_vpp_fmt_cvt(ctx, profile, codec_state, hw_context); | |
309 | + }else if(pipeline_param->num_filters == 1) { | |
310 | + struct object_buffer * obj_buf = BUFFER((*filter_id) + 0); | |
311 | + | |
312 | + assert(obj_buf && obj_buf->buffer_store && obj_buf->buffer_store->buffer); | |
313 | + | |
314 | + if (!obj_buf || | |
315 | + !obj_buf->buffer_store || | |
316 | + !obj_buf->buffer_store->buffer) { | |
317 | + status = VA_STATUS_ERROR_INVALID_FILTER_CHAIN; | |
200 | 318 | goto error; |
201 | 319 | } |
202 | 320 | |
203 | - gen75_vpp_gpe(ctx, proc_ctx); | |
204 | - } | |
205 | - }else if (pipeline_param->num_filters >= 2) { | |
206 | - unsigned int i = 0; | |
207 | - for (i = 0; i < pipeline_param->num_filters; i++){ | |
208 | - struct object_buffer * obj_buf = BUFFER(pipeline_param->filters[i]); | |
209 | - | |
210 | - if (!obj_buf || | |
211 | - !obj_buf->buffer_store || | |
212 | - !obj_buf->buffer_store->buffer) { | |
213 | - status = VA_STATUS_ERROR_INVALID_FILTER_CHAIN; | |
214 | - goto error; | |
321 | + VAProcFilterParameterBuffer* filter = | |
322 | + (VAProcFilterParameterBuffer*)obj_buf-> buffer_store->buffer; | |
323 | + | |
324 | + if (filter->type == VAProcFilterNoiseReduction || | |
325 | + filter->type == VAProcFilterDeinterlacing || | |
326 | + filter->type == VAProcFilterSkinToneEnhancement || | |
327 | + filter->type == VAProcFilterColorBalance){ | |
328 | + gen75_vpp_vebox(ctx, proc_ctx); | |
329 | + }else if(filter->type == VAProcFilterSharpening){ | |
330 | + if (proc_ctx->surface_pipeline_input_object->fourcc != VA_FOURCC_NV12 || | |
331 | + proc_ctx->surface_render_output_object->fourcc != VA_FOURCC_NV12) { | |
332 | + status = VA_STATUS_ERROR_UNIMPLEMENTED; | |
333 | + goto error; | |
334 | + } | |
335 | + | |
336 | + gen75_vpp_gpe(ctx, proc_ctx); | |
337 | + } | |
338 | + }else if (pipeline_param->num_filters >= 2) { | |
339 | + unsigned int i = 0; | |
340 | + for (i = 0; i < pipeline_param->num_filters; i++){ | |
341 | + struct object_buffer * obj_buf = BUFFER(pipeline_param->filters[i]); | |
342 | + | |
343 | + if (!obj_buf || | |
344 | + !obj_buf->buffer_store || | |
345 | + !obj_buf->buffer_store->buffer) { | |
346 | + status = VA_STATUS_ERROR_INVALID_FILTER_CHAIN; | |
347 | + goto error; | |
348 | + } | |
349 | + | |
350 | + VAProcFilterParameterBuffer* filter = | |
351 | + (VAProcFilterParameterBuffer*)obj_buf-> buffer_store->buffer; | |
352 | + | |
353 | + if (filter->type != VAProcFilterNoiseReduction && | |
354 | + filter->type != VAProcFilterDeinterlacing && | |
355 | + filter->type != VAProcFilterSkinToneEnhancement && | |
356 | + filter->type != VAProcFilterColorBalance) { | |
357 | + fprintf(stderr, "Do not support multiply filters outside vebox pipeline \n"); | |
358 | + assert(0); | |
359 | + } | |
215 | 360 | } |
361 | + gen75_vpp_vebox(ctx, proc_ctx); | |
362 | + } | |
363 | + } | |
216 | 364 | |
217 | - VAProcFilterParameterBuffer* filter = | |
218 | - (VAProcFilterParameterBuffer*)obj_buf-> buffer_store->buffer; | |
365 | + if(vpp_stage3 == 1) | |
366 | + { | |
367 | + if(vpp_stage2 == 1) { | |
368 | + memset(&pipeline_param2, 0, sizeof(pipeline_param2)); | |
369 | + pipeline_param2.surface = out_surface_id2; | |
370 | + pipeline_param2.surface_region = &dst_rect; | |
371 | + pipeline_param2.output_region = &dst_rect; | |
372 | + pipeline_param2.filter_flags = 0; | |
373 | + pipeline_param2.num_filters = 0; | |
374 | + | |
375 | + proc_ctx->pipeline_param = &pipeline_param2; | |
376 | + proc_ctx->surface_pipeline_input_object = proc_ctx->surface_render_output_object; | |
377 | + proc_ctx->surface_render_output_object = obj_dst_surf; | |
378 | + } | |
379 | + | |
380 | + gen75_vpp_vebox(ctx, proc_ctx); | |
381 | + } | |
219 | 382 | |
220 | - if (filter->type != VAProcFilterNoiseReduction && | |
221 | - filter->type != VAProcFilterDeinterlacing && | |
222 | - filter->type != VAProcFilterSkinToneEnhancement && | |
223 | - filter->type != VAProcFilterColorBalance) { | |
224 | - fprintf(stderr, "Do not support multiply filters outside vebox pipeline \n"); | |
225 | - assert(0); | |
226 | - } | |
227 | - } | |
228 | - gen75_vpp_vebox(ctx, proc_ctx); | |
229 | - } | |
383 | + if (num_tmp_surfaces) | |
384 | + i965_DestroySurfaces(ctx, | |
385 | + tmp_surfaces, | |
386 | + num_tmp_surfaces); | |
230 | 387 | |
231 | 388 | return VA_STATUS_SUCCESS; |
232 | 389 | |
233 | 390 | error: |
391 | + if (num_tmp_surfaces) | |
392 | + i965_DestroySurfaces(ctx, | |
393 | + tmp_surfaces, | |
394 | + num_tmp_surfaces); | |
395 | + | |
234 | 396 | return status; |
235 | 397 | } |
236 | 398 |
@@ -1408,7 +1408,9 @@ int hsw_veb_pre_format_convert(VADriverContextP ctx, | ||
1408 | 1408 | |
1409 | 1409 | } else if(obj_surf_input->fourcc == VA_FOURCC_AYUV || |
1410 | 1410 | obj_surf_input->fourcc == VA_FOURCC_YUY2 || |
1411 | - obj_surf_input->fourcc == VA_FOURCC_NV12){ | |
1411 | + obj_surf_input->fourcc == VA_FOURCC_NV12 || | |
1412 | + obj_surf_input->fourcc == VA_FOURCC_P010){ | |
1413 | + | |
1412 | 1414 | // nothing to do here |
1413 | 1415 | } else { |
1414 | 1416 | /* not support other format as input */ |
@@ -1447,7 +1449,9 @@ int hsw_veb_pre_format_convert(VADriverContextP ctx, | ||
1447 | 1449 | proc_ctx->format_convert_flags |= POST_FORMAT_CONVERT; |
1448 | 1450 | } else if(obj_surf_output->fourcc == VA_FOURCC_AYUV || |
1449 | 1451 | obj_surf_output->fourcc == VA_FOURCC_YUY2 || |
1450 | - obj_surf_output->fourcc == VA_FOURCC_NV12){ | |
1452 | + obj_surf_input->fourcc == VA_FOURCC_NV12 || | |
1453 | + obj_surf_input->fourcc == VA_FOURCC_P010){ | |
1454 | + | |
1451 | 1455 | /* Nothing to do here */ |
1452 | 1456 | } else { |
1453 | 1457 | /* not support other format as input */ |
@@ -1602,6 +1606,11 @@ gen75_vebox_init_filter_params(VADriverContextP ctx, | ||
1602 | 1606 | proc_ctx->is_first_frame = 0; |
1603 | 1607 | proc_ctx->is_second_field = 0; |
1604 | 1608 | |
1609 | + if(!proc_ctx->is_di_enabled && !proc_ctx->is_dn_enabled) { | |
1610 | + // MUST enable IECP if all DI&DN are disabled | |
1611 | + proc_ctx->is_iecp_enabled = 1; | |
1612 | + } | |
1613 | + | |
1605 | 1614 | /* Check whether we are deinterlacing the second field */ |
1606 | 1615 | if (proc_ctx->is_di_enabled) { |
1607 | 1616 | const VAProcFilterParameterBufferDeinterlacing * const deint_params = |
@@ -2290,7 +2299,8 @@ void skl_veb_surface_state(VADriverContextP ctx, struct intel_vebox_context *pro | ||
2290 | 2299 | assert(obj_surf->fourcc == VA_FOURCC_NV12 || |
2291 | 2300 | obj_surf->fourcc == VA_FOURCC_YUY2 || |
2292 | 2301 | obj_surf->fourcc == VA_FOURCC_AYUV || |
2293 | - obj_surf->fourcc == VA_FOURCC_RGBA); | |
2302 | + obj_surf->fourcc == VA_FOURCC_RGBA || | |
2303 | + obj_surf->fourcc == VA_FOURCC_P010); | |
2294 | 2304 | |
2295 | 2305 | if (obj_surf->fourcc == VA_FOURCC_NV12) { |
2296 | 2306 | surface_format = PLANAR_420_8; |
@@ -2312,6 +2322,11 @@ void skl_veb_surface_state(VADriverContextP ctx, struct intel_vebox_context *pro | ||
2312 | 2322 | surface_pitch = obj_surf->width * 4; |
2313 | 2323 | is_uv_interleaved = 0; |
2314 | 2324 | half_pitch_chroma = 0; |
2325 | + } else if (obj_surf->fourcc == VA_FOURCC_P010) { | |
2326 | + surface_format = PLANAR_420_16; | |
2327 | + surface_pitch = obj_surf->width; | |
2328 | + is_uv_interleaved = 1; | |
2329 | + half_pitch_chroma = 0; | |
2315 | 2330 | } |
2316 | 2331 | |
2317 | 2332 | derived_pitch = surface_pitch; |
@@ -42,6 +42,8 @@ | ||
42 | 42 | #include "i965_yuv_coefs.h" |
43 | 43 | #include "intel_media.h" |
44 | 44 | |
45 | +#include "gen75_picture_process.h" | |
46 | + | |
45 | 47 | #define SURFACE_STATE_PADDED_SIZE SURFACE_STATE_PADDED_SIZE_GEN8 |
46 | 48 | |
47 | 49 | #define SURFACE_STATE_OFFSET(index) (SURFACE_STATE_PADDED_SIZE * index) |
@@ -1460,6 +1462,11 @@ static void | ||
1460 | 1462 | gen8_post_processing_context_finalize(VADriverContextP ctx, |
1461 | 1463 | struct i965_post_processing_context *pp_context) |
1462 | 1464 | { |
1465 | + if(pp_context->vebox_proc_ctx){ | |
1466 | + gen75_vebox_context_destroy(ctx,pp_context->vebox_proc_ctx); | |
1467 | + pp_context->vebox_proc_ctx = NULL; | |
1468 | + } | |
1469 | + | |
1463 | 1470 | dri_bo_unreference(pp_context->surface_state_binding_table.bo); |
1464 | 1471 | pp_context->surface_state_binding_table.bo = NULL; |
1465 | 1472 |
@@ -982,23 +982,44 @@ out: | ||
982 | 982 | #define VP9_PROB_BUFFER_RESTORED_SECNE_2 2 |
983 | 983 | #define VP9_PROB_BUFFER_RESTORED_SECNE_MAX (VP9_PROB_BUFFER_RESTORED_SECNE_2 + 1) |
984 | 984 | |
985 | -static void vp9_update_segmentId_buffer(VADriverContextP ctx, | |
985 | +#define ALLOC_MV_BUFFER(gen_buffer, string, size,width,height) \ | |
986 | + do { \ | |
987 | + dri_bo_unreference(gen_buffer->bo); \ | |
988 | + gen_buffer->bo = dri_bo_alloc(i965->intel.bufmgr, \ | |
989 | + string, \ | |
990 | + size, \ | |
991 | + 0x1000); \ | |
992 | + assert(gen_buffer->bo); \ | |
993 | + gen_buffer->frame_width = width ; \ | |
994 | + gen_buffer->frame_height = height; \ | |
995 | + } while (0) | |
996 | + | |
997 | +static void | |
998 | +vp9_update_segmentId_buffer(VADriverContextP ctx, | |
986 | 999 | struct decode_state *decode_state, |
987 | - struct gen9_hcpd_context *gen9_hcpd_context, uint8_t isScaling) | |
1000 | + struct gen9_hcpd_context *gen9_hcpd_context) | |
988 | 1001 | { |
1002 | + struct i965_driver_data *i965 = i965_driver_data(ctx); | |
989 | 1003 | VADecPictureParameterBufferVP9 *pic_param; |
990 | 1004 | |
1005 | + int size = 0; | |
1006 | + int is_scaling = 0; | |
991 | 1007 | assert(decode_state->pic_param && decode_state->pic_param->buffer); |
992 | 1008 | pic_param = (VADecPictureParameterBufferVP9 *)decode_state->pic_param->buffer; |
993 | 1009 | |
994 | - int size = 0; | |
1010 | + size = gen9_hcpd_context->picture_width_in_ctbs * gen9_hcpd_context->picture_height_in_ctbs * 1 ; | |
1011 | + size <<= 6; | |
1012 | + if (gen9_hcpd_context->vp9_segment_id_buffer.bo == NULL || pic_param->frame_width > gen9_hcpd_context->last_frame.frame_width || pic_param->frame_height > gen9_hcpd_context->last_frame.frame_height) | |
1013 | + { | |
1014 | + ALLOC_GEN_BUFFER((&gen9_hcpd_context->vp9_segment_id_buffer), "vp9 segment id buffer", size); | |
1015 | + } | |
1016 | + | |
1017 | + is_scaling = (pic_param->frame_width != gen9_hcpd_context->last_frame.frame_width) || (pic_param->frame_height != gen9_hcpd_context->last_frame.frame_height); | |
995 | 1018 | |
996 | 1019 | if((pic_param->pic_fields.bits.frame_type == HCP_VP9_KEY_FRAME) || |
997 | 1020 | pic_param->pic_fields.bits.error_resilient_mode || |
998 | - pic_param->pic_fields.bits.intra_only || isScaling) { | |
1021 | + pic_param->pic_fields.bits.intra_only || is_scaling) { | |
999 | 1022 | |
1000 | - size = (gen9_hcpd_context->picture_width_in_min_cb_minus1+2)*(gen9_hcpd_context->picture_height_in_min_cb_minus1 + 2) * 1; | |
1001 | - size<<=6; | |
1002 | 1023 | //VP9 Segment ID buffer needs to be zero |
1003 | 1024 | dri_bo_map(gen9_hcpd_context->vp9_segment_id_buffer.bo,1); |
1004 | 1025 | memset((unsigned char *)gen9_hcpd_context->vp9_segment_id_buffer.bo->virtual,0, size); |
@@ -1007,6 +1028,31 @@ static void vp9_update_segmentId_buffer(VADriverContextP ctx, | ||
1007 | 1028 | } |
1008 | 1029 | |
1009 | 1030 | static void |
1031 | +vp9_update_mv_temporal_buffer(VADriverContextP ctx, | |
1032 | + struct decode_state *decode_state, | |
1033 | + struct gen9_hcpd_context *gen9_hcpd_context) | |
1034 | +{ | |
1035 | + struct i965_driver_data *i965 = i965_driver_data(ctx); | |
1036 | + VADecPictureParameterBufferVP9 *pic_param; | |
1037 | + int size = 0; | |
1038 | + | |
1039 | + assert(decode_state->pic_param && decode_state->pic_param->buffer); | |
1040 | + pic_param = (VADecPictureParameterBufferVP9 *)decode_state->pic_param->buffer; | |
1041 | + | |
1042 | + size = gen9_hcpd_context->picture_width_in_ctbs * gen9_hcpd_context->picture_height_in_ctbs * 9 ; | |
1043 | + size <<= 6; //CL aligned | |
1044 | + if (gen9_hcpd_context->vp9_mv_temporal_buffer_curr.bo == NULL || pic_param->frame_width > gen9_hcpd_context->vp9_mv_temporal_buffer_curr.frame_width || pic_param->frame_height > gen9_hcpd_context->vp9_mv_temporal_buffer_curr.frame_height) | |
1045 | + { | |
1046 | + ALLOC_MV_BUFFER((&gen9_hcpd_context->vp9_mv_temporal_buffer_curr), "vp9 curr mv temporal buffer", size,pic_param->frame_width,pic_param->frame_height); | |
1047 | + } | |
1048 | + if (gen9_hcpd_context->vp9_mv_temporal_buffer_last.bo == NULL) | |
1049 | + { | |
1050 | + ALLOC_MV_BUFFER((&gen9_hcpd_context->vp9_mv_temporal_buffer_last), "vp9 last mv temporal buffer", size,pic_param->frame_width,pic_param->frame_height); | |
1051 | + } | |
1052 | + | |
1053 | +} | |
1054 | + | |
1055 | +static void | |
1010 | 1056 | vp9_gen_default_probabilities(VADriverContextP ctx, struct gen9_hcpd_context *gen9_hcpd_context) |
1011 | 1057 | { |
1012 | 1058 | int i = 0; |
@@ -1103,7 +1149,7 @@ vp9_update_probabilities(VADriverContextP ctx, | ||
1103 | 1149 | } |
1104 | 1150 | }else if(gen9_hcpd_context->last_frame.prob_buffer_saved_flag == VP9_PROB_BUFFER_SAVED_SECNE_2) |
1105 | 1151 | { |
1106 | - if((pic_param->pic_fields.bits.frame_type == HCP_VP9_KEY_FRAME) ||pic_param->pic_fields.bits.intra_only|pic_param->pic_fields.bits.error_resilient_mode) | |
1152 | + if((pic_param->pic_fields.bits.frame_type == HCP_VP9_KEY_FRAME) ||pic_param->pic_fields.bits.intra_only||pic_param->pic_fields.bits.error_resilient_mode) | |
1107 | 1153 | { |
1108 | 1154 | temp_frame_ctx_id = 0; |
1109 | 1155 | } |
@@ -1130,7 +1176,7 @@ vp9_update_probabilities(VADriverContextP ctx, | ||
1130 | 1176 | } |
1131 | 1177 | } |
1132 | 1178 | //first part buffer update: Case 1)Reset all 4 probablity buffers |
1133 | - if((pic_param->pic_fields.bits.frame_type == HCP_VP9_KEY_FRAME) ||pic_param->pic_fields.bits.intra_only|pic_param->pic_fields.bits.error_resilient_mode) | |
1179 | + if((pic_param->pic_fields.bits.frame_type == HCP_VP9_KEY_FRAME) ||pic_param->pic_fields.bits.intra_only||pic_param->pic_fields.bits.error_resilient_mode) | |
1134 | 1180 | { |
1135 | 1181 | if((pic_param->pic_fields.bits.frame_type == HCP_VP9_KEY_FRAME) || |
1136 | 1182 | (pic_param->pic_fields.bits.reset_frame_context == 3)|| |
@@ -1265,9 +1311,7 @@ gen9_hcpd_init_vp9_surface(VADriverContextP ctx, | ||
1265 | 1311 | struct object_surface *obj_surface, |
1266 | 1312 | struct gen9_hcpd_context *gen9_hcpd_context) |
1267 | 1313 | { |
1268 | - struct i965_driver_data *i965 = i965_driver_data(ctx); | |
1269 | 1314 | GenVP9Surface *gen9_vp9_surface; |
1270 | - uint32_t size=0; | |
1271 | 1315 | |
1272 | 1316 | if (!obj_surface) |
1273 | 1317 | return; |
@@ -1277,20 +1321,11 @@ gen9_hcpd_init_vp9_surface(VADriverContextP ctx, | ||
1277 | 1321 | |
1278 | 1322 | if (!gen9_vp9_surface) { |
1279 | 1323 | gen9_vp9_surface = calloc(sizeof(GenVP9Surface), 1); |
1324 | + assert(gen9_vp9_surface); | |
1280 | 1325 | gen9_vp9_surface->base.frame_store_id = -1; |
1281 | 1326 | obj_surface->private_data = gen9_vp9_surface; |
1282 | 1327 | } |
1283 | 1328 | |
1284 | - //Super block size in VP9 is 64x64, size in SBs | |
1285 | - size = gen9_hcpd_context->picture_width_in_ctbs * gen9_hcpd_context->picture_height_in_ctbs * 9 ; | |
1286 | - size<<=6; //CL aligned | |
1287 | - | |
1288 | - if (gen9_vp9_surface->motion_vector_temporal_bo == NULL) { | |
1289 | - gen9_vp9_surface->motion_vector_temporal_bo = dri_bo_alloc(i965->intel.bufmgr, | |
1290 | - "current motion vector temporal buffer", | |
1291 | - size, | |
1292 | - 0x1000); | |
1293 | - } | |
1294 | 1329 | gen9_vp9_surface->frame_width = pic_param->frame_width; |
1295 | 1330 | gen9_vp9_surface->frame_height = pic_param->frame_height; |
1296 | 1331 |
@@ -1373,10 +1408,6 @@ gen9_hcpd_vp9_decode_init(VADriverContextP ctx, | ||
1373 | 1408 | size<<=6; |
1374 | 1409 | ALLOC_GEN_BUFFER((&gen9_hcpd_context->vp9_probability_buffer), "vp9 probability buffer", size); |
1375 | 1410 | |
1376 | - size = (gen9_hcpd_context->picture_width_in_min_cb_minus1+2)*(gen9_hcpd_context->picture_height_in_min_cb_minus1 + 2) * 1; | |
1377 | - size<<=6; | |
1378 | - ALLOC_GEN_BUFFER((&gen9_hcpd_context->vp9_segment_id_buffer), "vp9 segment id buffer", size); | |
1379 | - | |
1380 | 1411 | gen9_hcpd_context->first_inter_slice_collocated_ref_idx = 0; |
1381 | 1412 | gen9_hcpd_context->first_inter_slice_collocated_from_l0_flag = 0; |
1382 | 1413 | gen9_hcpd_context->first_inter_slice_valid = 0; |
@@ -1450,7 +1481,6 @@ gen9_hcpd_vp9_pipe_buf_addr_state(VADriverContextP ctx, | ||
1450 | 1481 | { |
1451 | 1482 | struct intel_batchbuffer *batch = gen9_hcpd_context->base.batch; |
1452 | 1483 | struct object_surface *obj_surface; |
1453 | - GenVP9Surface *gen9_vp9_surface; | |
1454 | 1484 | int i=0; |
1455 | 1485 | |
1456 | 1486 | BEGIN_BCS_BATCH(batch, 95); |
@@ -1459,8 +1489,6 @@ gen9_hcpd_vp9_pipe_buf_addr_state(VADriverContextP ctx, | ||
1459 | 1489 | |
1460 | 1490 | obj_surface = decode_state->render_object; |
1461 | 1491 | assert(obj_surface && obj_surface->bo); |
1462 | - gen9_vp9_surface = obj_surface->private_data; | |
1463 | - assert(gen9_vp9_surface && gen9_vp9_surface->motion_vector_temporal_bo); | |
1464 | 1492 | |
1465 | 1493 | OUT_BUFFER_MA_TARGET(obj_surface->bo); /* DW 1..3 */ |
1466 | 1494 | OUT_BUFFER_MA_TARGET(gen9_hcpd_context->deblocking_filter_line_buffer.bo);/* DW 4..6 */ |
@@ -1472,7 +1500,7 @@ gen9_hcpd_vp9_pipe_buf_addr_state(VADriverContextP ctx, | ||
1472 | 1500 | OUT_BUFFER_MA_TARGET(NULL); /* DW 22..24, ignore for VP9 */ |
1473 | 1501 | OUT_BUFFER_MA_TARGET(NULL); /* DW 25..27, ignore for VP9 */ |
1474 | 1502 | OUT_BUFFER_MA_TARGET(NULL); /* DW 28..30, ignore for VP9 */ |
1475 | - OUT_BUFFER_MA_TARGET(gen9_vp9_surface->motion_vector_temporal_bo); /* DW 31..33 */ | |
1503 | + OUT_BUFFER_MA_TARGET(gen9_hcpd_context->vp9_mv_temporal_buffer_curr.bo); /* DW 31..33 */ | |
1476 | 1504 | |
1477 | 1505 | OUT_BUFFER_MA_TARGET(NULL); /* DW 34..36, reserved */ |
1478 | 1506 |
@@ -1502,7 +1530,7 @@ gen9_hcpd_vp9_pipe_buf_addr_state(VADriverContextP ctx, | ||
1502 | 1530 | /* DW 66..81 - for 8 Collocated motion vectors */ |
1503 | 1531 | for (i = 0; i < 1; i++) |
1504 | 1532 | { |
1505 | - OUT_BUFFER_NMA_REFERENCE(gen9_hcpd_context->last_frame.mv_temporal_buffer_bo); | |
1533 | + OUT_BUFFER_NMA_REFERENCE(gen9_hcpd_context->vp9_mv_temporal_buffer_last.bo); | |
1506 | 1534 | } |
1507 | 1535 | for (; i < ARRAY_ELEMS(gen9_hcpd_context->reference_surfaces); i++) |
1508 | 1536 | { |
@@ -1517,7 +1545,6 @@ gen9_hcpd_vp9_pipe_buf_addr_state(VADriverContextP ctx, | ||
1517 | 1545 | OUT_BUFFER_MA_TARGET(gen9_hcpd_context->hvd_tile_rowstore_buffer.bo);/* DW 92..94, VP9 HVD Tile Rowstore buffer */ |
1518 | 1546 | |
1519 | 1547 | ADVANCE_BCS_BATCH(batch); |
1520 | - gen9_hcpd_context->last_frame.mv_temporal_buffer_bo = gen9_vp9_surface->motion_vector_temporal_bo; | |
1521 | 1548 | } |
1522 | 1549 | |
1523 | 1550 | static inline int |
@@ -1718,16 +1745,25 @@ gen9_hcpd_vp9_segment_state(VADriverContextP ctx, | ||
1718 | 1745 | seg_param->segment_flags.fields.segment_reference_enabled << 3 | |
1719 | 1746 | seg_param->segment_flags.fields.segment_reference << 1 | |
1720 | 1747 | seg_param->segment_flags.fields.segment_reference_skipped <<0 ); /* DW 2 */ |
1721 | - OUT_BCS_BATCH(batch, | |
1722 | - seg_param->filter_level[1][1] << 24 | //FilterLevelRef1Mode1 | |
1723 | - seg_param->filter_level[1][0] << 16 | //FilterLevelRef1Mode0 | |
1724 | - seg_param->filter_level[0][1] << 8 | //FilterLevelRef0Mode1 | |
1725 | - seg_param->filter_level[0][0] << 0 ); //FilterLevelRef0Mode0 /* DW 3 */ | |
1726 | - OUT_BCS_BATCH(batch, | |
1727 | - seg_param->filter_level[3][1] << 24 | //FilterLevelRef3Mode1 | |
1728 | - seg_param->filter_level[3][0] << 16 | //FilterLevelRef3Mode0 | |
1729 | - seg_param->filter_level[2][1] << 8 | //FilterLevelRef2Mode1 | |
1730 | - seg_param->filter_level[2][0] << 0 ); //FilterLevelRef2Mode0 /* DW 4 */ | |
1748 | + if(pic_param->filter_level) | |
1749 | + { | |
1750 | + OUT_BCS_BATCH(batch, | |
1751 | + seg_param->filter_level[1][1] << 24 | //FilterLevelRef1Mode1 | |
1752 | + seg_param->filter_level[1][0] << 16 | //FilterLevelRef1Mode0 | |
1753 | + seg_param->filter_level[0][1] << 8 | //FilterLevelRef0Mode1 | |
1754 | + seg_param->filter_level[0][0] << 0 ); //FilterLevelRef0Mode0 /* DW 3 */ | |
1755 | + OUT_BCS_BATCH(batch, | |
1756 | + seg_param->filter_level[3][1] << 24 | //FilterLevelRef3Mode1 | |
1757 | + seg_param->filter_level[3][0] << 16 | //FilterLevelRef3Mode0 | |
1758 | + seg_param->filter_level[2][1] << 8 | //FilterLevelRef2Mode1 | |
1759 | + seg_param->filter_level[2][0] << 0 ); //FilterLevelRef2Mode0 /* DW 4 */ | |
1760 | + }else | |
1761 | + { | |
1762 | + OUT_BCS_BATCH(batch, | |
1763 | + 0 ); /* DW 3 */ | |
1764 | + OUT_BCS_BATCH(batch, | |
1765 | + 0 ); /* DW 4 */ | |
1766 | + } | |
1731 | 1767 | OUT_BCS_BATCH(batch, |
1732 | 1768 | seg_param->luma_ac_quant_scale << 16 | |
1733 | 1769 | seg_param->luma_dc_quant_scale << 0 ); /* DW 5 */ |
@@ -1765,39 +1801,35 @@ gen9_hcpd_vp9_decode_picture(VADriverContextP ctx, | ||
1765 | 1801 | struct decode_state *decode_state, |
1766 | 1802 | struct gen9_hcpd_context *gen9_hcpd_context) |
1767 | 1803 | { |
1768 | - VAStatus vaStatus; | |
1804 | + VAStatus vaStatus = VA_STATUS_SUCCESS; | |
1769 | 1805 | struct i965_driver_data *i965 = i965_driver_data(ctx); |
1770 | 1806 | struct intel_batchbuffer *batch = gen9_hcpd_context->base.batch; |
1771 | 1807 | VADecPictureParameterBufferVP9 *pic_param; |
1772 | 1808 | VASliceParameterBufferVP9 *slice_param; |
1773 | 1809 | dri_bo *slice_data_bo; |
1774 | - int i = 0, num_segments=0, isScaling=0; | |
1775 | - struct object_surface *obj_surface; | |
1776 | - GenVP9Surface *gen9_vp9_surface; | |
1777 | - vaStatus = gen9_hcpd_vp9_decode_init(ctx, decode_state, gen9_hcpd_context); | |
1778 | - | |
1779 | - if (vaStatus != VA_STATUS_SUCCESS) | |
1780 | - goto out; | |
1810 | + dri_bo *tmp_bo; | |
1811 | + uint16_t tmp; | |
1812 | + int i = 0, num_segments=0; | |
1781 | 1813 | |
1782 | 1814 | assert(decode_state->pic_param && decode_state->pic_param->buffer); |
1815 | + assert(decode_state->slice_params && decode_state->slice_params[0]->buffer); | |
1816 | + slice_param = (VASliceParameterBufferVP9 *)decode_state->slice_params[0]->buffer; | |
1783 | 1817 | pic_param = (VADecPictureParameterBufferVP9 *)decode_state->pic_param->buffer; |
1784 | 1818 | |
1785 | - //****And set the isScaling value accordingly****** | |
1786 | - isScaling = 0; | |
1787 | - for(i = 0; i < 3; i++) | |
1819 | + if(slice_param->slice_data_size == 1) | |
1788 | 1820 | { |
1789 | - obj_surface = gen9_hcpd_context->reference_surfaces[i].obj_surface; | |
1790 | - gen9_vp9_surface = NULL; | |
1791 | - if (obj_surface && obj_surface->private_data) | |
1792 | - { | |
1793 | - gen9_vp9_surface = obj_surface->private_data; | |
1794 | - isScaling |= (gen9_vp9_surface->frame_width == pic_param->frame_width && | |
1795 | - gen9_vp9_surface->frame_height == pic_param->frame_height)? 0:1; | |
1796 | - } | |
1821 | + goto out; | |
1797 | 1822 | } |
1798 | 1823 | |
1824 | + vaStatus = gen9_hcpd_vp9_decode_init(ctx, decode_state, gen9_hcpd_context); | |
1825 | + | |
1826 | + if (vaStatus != VA_STATUS_SUCCESS) | |
1827 | + goto out; | |
1828 | + | |
1799 | 1829 | //Update segment id buffer if needed |
1800 | - vp9_update_segmentId_buffer(ctx, decode_state, gen9_hcpd_context, isScaling); | |
1830 | + vp9_update_segmentId_buffer(ctx, decode_state, gen9_hcpd_context); | |
1831 | + //Update mv buffer if needed | |
1832 | + vp9_update_mv_temporal_buffer(ctx, decode_state, gen9_hcpd_context); | |
1801 | 1833 | //Update probability buffer if needed |
1802 | 1834 | vp9_update_probabilities(ctx, decode_state, gen9_hcpd_context); |
1803 | 1835 |
@@ -1812,8 +1844,6 @@ gen9_hcpd_vp9_decode_picture(VADriverContextP ctx, | ||
1812 | 1844 | gen9_hcpd_vp9_surface_state(ctx, decode_state, gen9_hcpd_context); |
1813 | 1845 | |
1814 | 1846 | //Only one VASliceParameterBufferVP9 should be sent per frame |
1815 | - assert(decode_state->slice_params && decode_state->slice_params[0]->buffer); | |
1816 | - slice_param = (VASliceParameterBufferVP9 *)decode_state->slice_params[0]->buffer; | |
1817 | 1847 | slice_data_bo = decode_state->slice_datas[0]->bo; |
1818 | 1848 | |
1819 | 1849 | gen9_hcpd_ind_obj_base_addr_state(ctx, slice_data_bo, gen9_hcpd_context); |
@@ -1835,6 +1865,9 @@ gen9_hcpd_vp9_decode_picture(VADriverContextP ctx, | ||
1835 | 1865 | |
1836 | 1866 | gen9_hcpd_vp9_bsd_object(ctx, pic_param, slice_param, gen9_hcpd_context); |
1837 | 1867 | |
1868 | + intel_batchbuffer_end_atomic(batch); | |
1869 | + intel_batchbuffer_flush(batch); | |
1870 | + | |
1838 | 1871 | // keep track of the last frame status |
1839 | 1872 | gen9_hcpd_context->last_frame.frame_width = pic_param->frame_width; |
1840 | 1873 | gen9_hcpd_context->last_frame.frame_height = pic_param->frame_height; |
@@ -1844,11 +1877,23 @@ gen9_hcpd_vp9_decode_picture(VADriverContextP ctx, | ||
1844 | 1877 | gen9_hcpd_context->last_frame.frame_context_idx = pic_param->pic_fields.bits.frame_context_idx; |
1845 | 1878 | gen9_hcpd_context->last_frame.intra_only = pic_param->pic_fields.bits.intra_only; |
1846 | 1879 | |
1847 | - // update prob buffer to vp9_fc; | |
1880 | + // switch mv buffer | |
1881 | + if(pic_param->pic_fields.bits.frame_type != HCP_VP9_KEY_FRAME) | |
1882 | + { | |
1883 | + tmp_bo = gen9_hcpd_context->vp9_mv_temporal_buffer_last.bo; | |
1884 | + gen9_hcpd_context->vp9_mv_temporal_buffer_last.bo = gen9_hcpd_context->vp9_mv_temporal_buffer_curr.bo; | |
1885 | + gen9_hcpd_context->vp9_mv_temporal_buffer_curr.bo = tmp_bo; | |
1848 | 1886 | |
1849 | - intel_batchbuffer_end_atomic(batch); | |
1850 | - intel_batchbuffer_flush(batch); | |
1887 | + tmp = gen9_hcpd_context->vp9_mv_temporal_buffer_last.frame_width; | |
1888 | + gen9_hcpd_context->vp9_mv_temporal_buffer_last.frame_width = gen9_hcpd_context->vp9_mv_temporal_buffer_curr.frame_width; | |
1889 | + gen9_hcpd_context->vp9_mv_temporal_buffer_curr.frame_width = tmp; | |
1890 | + | |
1891 | + tmp = gen9_hcpd_context->vp9_mv_temporal_buffer_last.frame_height; | |
1892 | + gen9_hcpd_context->vp9_mv_temporal_buffer_last.frame_height = gen9_hcpd_context->vp9_mv_temporal_buffer_curr.frame_height; | |
1893 | + gen9_hcpd_context->vp9_mv_temporal_buffer_curr.frame_height = tmp; | |
1851 | 1894 | |
1895 | + | |
1896 | + } | |
1852 | 1897 | //update vp9_frame_ctx according to frame_context_id |
1853 | 1898 | if (pic_param->pic_fields.bits.refresh_frame_context) |
1854 | 1899 | { |
@@ -1919,6 +1964,8 @@ gen9_hcpd_context_destroy(void *hw_context) | ||
1919 | 1964 | FREE_GEN_BUFFER((&gen9_hcpd_context->hvd_tile_rowstore_buffer)); |
1920 | 1965 | FREE_GEN_BUFFER((&gen9_hcpd_context->vp9_probability_buffer)); |
1921 | 1966 | FREE_GEN_BUFFER((&gen9_hcpd_context->vp9_segment_id_buffer)); |
1967 | + dri_bo_unreference(gen9_hcpd_context->vp9_mv_temporal_buffer_curr.bo); | |
1968 | + dri_bo_unreference(gen9_hcpd_context->vp9_mv_temporal_buffer_last.bo); | |
1922 | 1969 | |
1923 | 1970 | intel_batchbuffer_free(gen9_hcpd_context->base.batch); |
1924 | 1971 | free(gen9_hcpd_context); |
@@ -1935,17 +1982,19 @@ static void | ||
1935 | 1982 | gen9_hcpd_vp9_context_init(VADriverContextP ctx, |
1936 | 1983 | struct gen9_hcpd_context *gen9_hcpd_context) |
1937 | 1984 | { |
1938 | - int default_value = 255; | |
1939 | 1985 | |
1940 | 1986 | gen9_hcpd_context->last_frame.frame_height = 0; |
1941 | 1987 | gen9_hcpd_context->last_frame.show_frame = 0; |
1942 | 1988 | gen9_hcpd_context->last_frame.frame_type = 0; |
1943 | - gen9_hcpd_context->last_frame.refresh_frame_context = default_value; | |
1944 | - gen9_hcpd_context->last_frame.frame_context_idx = default_value; | |
1989 | + gen9_hcpd_context->last_frame.refresh_frame_context = 0; | |
1990 | + gen9_hcpd_context->last_frame.frame_context_idx = 0; | |
1945 | 1991 | gen9_hcpd_context->last_frame.intra_only = 0; |
1946 | 1992 | gen9_hcpd_context->last_frame.prob_buffer_saved_flag = 0; |
1947 | 1993 | gen9_hcpd_context->last_frame.prob_buffer_restored_flag = 0; |
1948 | - gen9_hcpd_context->last_frame.mv_temporal_buffer_bo = NULL; | |
1994 | + | |
1995 | + //Super block in VP9 is 64x64 | |
1996 | + gen9_hcpd_context->ctb_size = 64; | |
1997 | + gen9_hcpd_context->min_cb_size = 8; //Min block size is 8 | |
1949 | 1998 | |
1950 | 1999 | vp9_gen_default_probabilities(ctx, gen9_hcpd_context); |
1951 | 2000 | } |
@@ -49,9 +49,15 @@ typedef struct vp9_frame_status | ||
49 | 49 | uint8_t intra_only; |
50 | 50 | uint8_t prob_buffer_saved_flag; |
51 | 51 | uint8_t prob_buffer_restored_flag; |
52 | - dri_bo * mv_temporal_buffer_bo; | |
53 | 52 | }vp9_last_frame_status; |
54 | 53 | |
54 | +typedef struct vp9_mv_temporal_buffer | |
55 | +{ | |
56 | + dri_bo *bo; | |
57 | + uint16_t frame_width; | |
58 | + uint16_t frame_height; | |
59 | +}VP9_MV_BUFFER; | |
60 | + | |
55 | 61 | struct gen9_hcpd_context |
56 | 62 | { |
57 | 63 | struct hw_context base; |
@@ -84,6 +90,8 @@ struct gen9_hcpd_context | ||
84 | 90 | GenBuffer hvd_tile_rowstore_buffer; |
85 | 91 | GenBuffer vp9_probability_buffer; |
86 | 92 | GenBuffer vp9_segment_id_buffer; |
93 | + VP9_MV_BUFFER vp9_mv_temporal_buffer_curr; | |
94 | + VP9_MV_BUFFER vp9_mv_temporal_buffer_last; | |
87 | 95 | |
88 | 96 | unsigned short first_inter_slice_collocated_ref_idx; |
89 | 97 | unsigned short first_inter_slice_collocated_from_l0_flag; |
@@ -401,6 +401,7 @@ static struct hw_codec_info bxt_hw_codec_info = { | ||
401 | 401 | .has_hevc_encoding = 1, |
402 | 402 | .has_hevc10_decoding = 1, |
403 | 403 | .has_vp9_decoding = 1, |
404 | + .has_vpp_p010 = 1, | |
404 | 405 | |
405 | 406 | .num_filters = 5, |
406 | 407 | .filters = { |
@@ -412,7 +413,6 @@ static struct hw_codec_info bxt_hw_codec_info = { | ||
412 | 413 | }, |
413 | 414 | }; |
414 | 415 | |
415 | - | |
416 | 416 | struct hw_codec_info * |
417 | 417 | i965_get_codec_info(int devid) |
418 | 418 | { |
@@ -112,6 +112,9 @@ | ||
112 | 112 | #define HAS_HEVC10_DECODING(ctx) ((ctx)->codec_info->has_hevc10_decoding && \ |
113 | 113 | (ctx)->intel.has_bsd) |
114 | 114 | |
115 | +#define HAS_VPP_P010(ctx) ((ctx)->codec_info->has_vpp_p010 && \ | |
116 | + (ctx)->intel.has_bsd) | |
117 | + | |
115 | 118 | static int get_sampling_from_fourcc(unsigned int fourcc); |
116 | 119 | |
117 | 120 | /* Check whether we are rendering to X11 (VA/X11 or VA/GLX API) */ |
@@ -316,6 +319,8 @@ i965_image_formats_map[I965_MAX_IMAGE_FORMATS + 1] = { | ||
316 | 319 | { VA_FOURCC_RGBX, VA_LSB_FIRST, 32, 24, 0x000000ff, 0x0000ff00, 0x00ff0000 } }, |
317 | 320 | { I965_SURFACETYPE_RGBA, |
318 | 321 | { VA_FOURCC_BGRX, VA_LSB_FIRST, 32, 24, 0x00ff0000, 0x0000ff00, 0x000000ff } }, |
322 | + { I965_SURFACETYPE_YUV, | |
323 | + { VA_FOURCC_P010, VA_LSB_FIRST, 24, } }, | |
319 | 324 | }; |
320 | 325 | |
321 | 326 | /* List of supported subpicture formats */ |
@@ -878,6 +883,12 @@ i965_get_default_chroma_formats(VADriverContextP ctx, VAProfile profile, | ||
878 | 883 | if (HAS_HEVC10_DECODING(i965) && entrypoint == VAEntrypointVLD) |
879 | 884 | chroma_formats |= i965->codec_info->hevc_dec_chroma_formats; |
880 | 885 | break; |
886 | + | |
887 | + case VAProfileNone: | |
888 | + if(HAS_VPP_P010(i965)) | |
889 | + chroma_formats |= VA_RT_FORMAT_YUV420_10BPP; | |
890 | + break; | |
891 | + | |
881 | 892 | default: |
882 | 893 | break; |
883 | 894 | } |
@@ -3759,6 +3770,14 @@ i965_CreateImage(VADriverContextP ctx, | ||
3759 | 3770 | image->offsets[0] = 0; |
3760 | 3771 | image->data_size = size * 2; |
3761 | 3772 | break; |
3773 | + case VA_FOURCC_P010: | |
3774 | + image->num_planes = 2; | |
3775 | + image->pitches[0] = awidth * 2; | |
3776 | + image->offsets[0] = 0; | |
3777 | + image->pitches[1] = awidth * 2; | |
3778 | + image->offsets[1] = size * 2; | |
3779 | + image->data_size = size * 2 + 2 * size2 * 2; | |
3780 | + break; | |
3762 | 3781 | default: |
3763 | 3782 | goto error; |
3764 | 3783 | } |
@@ -3819,22 +3838,22 @@ i965_check_alloc_surface_bo(VADriverContextP ctx, | ||
3819 | 3838 | |
3820 | 3839 | int bpp_1stplane = bpp_1stplane_by_fourcc(fourcc); |
3821 | 3840 | |
3822 | - if (obj_surface->user_h_stride_set) { | |
3823 | - ASSERT_RET(IS_ALIGNED(obj_surface->width, 128), VA_STATUS_ERROR_INVALID_PARAMETER); | |
3824 | - } else | |
3825 | - obj_surface->width = ALIGN(obj_surface->orig_width * bpp_1stplane, 128); | |
3826 | - | |
3827 | - if (obj_surface->user_v_stride_set) { | |
3828 | - ASSERT_RET(IS_ALIGNED(obj_surface->height, 32), VA_STATUS_ERROR_INVALID_PARAMETER); | |
3829 | - } else | |
3830 | - obj_surface->height = ALIGN(obj_surface->orig_height, 32); | |
3831 | - | |
3832 | 3841 | if ((tiled && !obj_surface->user_disable_tiling)) { |
3833 | 3842 | ASSERT_RET(fourcc != VA_FOURCC_I420 && |
3834 | 3843 | fourcc != VA_FOURCC_IYUV && |
3835 | 3844 | fourcc != VA_FOURCC_YV12, |
3836 | 3845 | VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT); |
3837 | 3846 | |
3847 | + if (obj_surface->user_h_stride_set) { | |
3848 | + ASSERT_RET(IS_ALIGNED(obj_surface->width, 128), VA_STATUS_ERROR_INVALID_PARAMETER); | |
3849 | + } else | |
3850 | + obj_surface->width = ALIGN(obj_surface->orig_width * bpp_1stplane, 128); | |
3851 | + | |
3852 | + if (obj_surface->user_v_stride_set) { | |
3853 | + ASSERT_RET(IS_ALIGNED(obj_surface->height, 32), VA_STATUS_ERROR_INVALID_PARAMETER); | |
3854 | + }else | |
3855 | + obj_surface->height = ALIGN(obj_surface->orig_height, 32); | |
3856 | + | |
3838 | 3857 | region_height = obj_surface->height; |
3839 | 3858 | |
3840 | 3859 | switch (fourcc) { |
@@ -5688,6 +5707,14 @@ i965_QuerySurfaceAttributes(VADriverContextP ctx, | ||
5688 | 5707 | attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
5689 | 5708 | attribs[i].value.value.i = VA_FOURCC_YV16; |
5690 | 5709 | i++; |
5710 | + | |
5711 | + if(HAS_VPP_P010(i965)) { | |
5712 | + attribs[i].type = VASurfaceAttribPixelFormat; | |
5713 | + attribs[i].value.type = VAGenericValueTypeInteger; | |
5714 | + attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; | |
5715 | + attribs[i].value.value.i = VA_FOURCC_P010; | |
5716 | + i++; | |
5717 | + } | |
5691 | 5718 | } |
5692 | 5719 | } |
5693 | 5720 | } |
@@ -388,6 +388,7 @@ struct hw_codec_info | ||
388 | 388 | unsigned int has_hevc_encoding:1; |
389 | 389 | unsigned int has_hevc10_decoding:1; |
390 | 390 | unsigned int has_vp9_decoding:1; |
391 | + unsigned int has_vpp_p010:1; | |
391 | 392 | |
392 | 393 | unsigned int num_filters; |
393 | 394 | struct i965_filter filters[VAProcFilterCount]; |
@@ -41,6 +41,8 @@ | ||
41 | 41 | #include "i965_yuv_coefs.h" |
42 | 42 | #include "intel_media.h" |
43 | 43 | |
44 | +#include "gen75_picture_process.h" | |
45 | + | |
44 | 46 | extern VAStatus |
45 | 47 | vpp_surface_convert(VADriverContextP ctx, |
46 | 48 | struct object_surface *src_obj_surf, |
@@ -5296,6 +5298,183 @@ i965_image_pl1_processing(VADriverContextP ctx, | ||
5296 | 5298 | return vaStatus; |
5297 | 5299 | } |
5298 | 5300 | |
5301 | +// it only support NV12 and P010 for vebox proc ctx | |
5302 | +static struct object_surface *derive_surface(VADriverContextP ctx, | |
5303 | + struct object_image *obj_image, | |
5304 | + struct object_surface *obj_surface) | |
5305 | +{ | |
5306 | + VAImage * const image = &obj_image->image; | |
5307 | + | |
5308 | + memset((void *)obj_surface, 0, sizeof(*obj_surface)); | |
5309 | + obj_surface->fourcc = image->format.fourcc; | |
5310 | + obj_surface->orig_width = image->width; | |
5311 | + obj_surface->orig_height = image->height; | |
5312 | + obj_surface->width = image->pitches[0]; | |
5313 | + obj_surface->height = image->height; | |
5314 | + obj_surface->y_cb_offset = image->offsets[1] / obj_surface->width; | |
5315 | + obj_surface->y_cr_offset = obj_surface->y_cb_offset; | |
5316 | + obj_surface->bo = obj_image->bo; | |
5317 | + obj_surface->subsampling = SUBSAMPLE_YUV420; | |
5318 | + | |
5319 | + return obj_surface; | |
5320 | +} | |
5321 | + | |
5322 | +static VAStatus | |
5323 | +vebox_processing_simple(VADriverContextP ctx, | |
5324 | + struct i965_post_processing_context *pp_context, | |
5325 | + struct object_surface *src_obj_surface, | |
5326 | + struct object_surface *dst_obj_surface, | |
5327 | + const VARectangle *rect) | |
5328 | +{ | |
5329 | + struct i965_driver_data *i965 = i965_driver_data(ctx); | |
5330 | + VAProcPipelineParameterBuffer pipeline_param; | |
5331 | + VAStatus status = VA_STATUS_ERROR_UNIMPLEMENTED; | |
5332 | + | |
5333 | + if(pp_context->vebox_proc_ctx == NULL) { | |
5334 | + pp_context->vebox_proc_ctx = gen75_vebox_context_init(ctx); | |
5335 | + } | |
5336 | + | |
5337 | + memset((void *)&pipeline_param, 0, sizeof(pipeline_param)); | |
5338 | + pipeline_param.surface_region = rect; | |
5339 | + pipeline_param.output_region = rect; | |
5340 | + pipeline_param.filter_flags = 0; | |
5341 | + pipeline_param.num_filters = 0; | |
5342 | + | |
5343 | + pp_context->vebox_proc_ctx->pipeline_param = &pipeline_param; | |
5344 | + pp_context->vebox_proc_ctx->surface_input_object = src_obj_surface; | |
5345 | + pp_context->vebox_proc_ctx->surface_output_object = dst_obj_surface; | |
5346 | + | |
5347 | + if (IS_GEN9(i965->intel.device_info)) | |
5348 | + status = gen9_vebox_process_picture(ctx, pp_context->vebox_proc_ctx); | |
5349 | + | |
5350 | + return status; | |
5351 | +} | |
5352 | + | |
5353 | +static VAStatus | |
5354 | +i965_image_p010_processing(VADriverContextP ctx, | |
5355 | + const struct i965_surface *src_surface, | |
5356 | + const VARectangle *src_rect, | |
5357 | + struct i965_surface *dst_surface, | |
5358 | + const VARectangle *dst_rect) | |
5359 | +{ | |
5360 | +#define HAS_VPP_P010(ctx) ((ctx)->codec_info->has_vpp_p010 && \ | |
5361 | + (ctx)->intel.has_bsd) | |
5362 | + | |
5363 | + struct i965_driver_data *i965 = i965_driver_data(ctx); | |
5364 | + struct i965_post_processing_context *pp_context = i965->pp_context; | |
5365 | + struct object_surface *src_obj_surface = NULL, *dst_obj_surface = NULL; | |
5366 | + struct object_surface tmp_src_obj_surface, tmp_dst_obj_surface; | |
5367 | + struct object_surface *tmp_surface = NULL; | |
5368 | + VASurfaceID tmp_surface_id[3], out_surface_id = VA_INVALID_ID; | |
5369 | + int num_tmp_surfaces = 0; | |
5370 | + int fourcc = pp_get_surface_fourcc(ctx, dst_surface); | |
5371 | + VAStatus vaStatus = VA_STATUS_ERROR_UNIMPLEMENTED; | |
5372 | + int vpp_post = 0; | |
5373 | + | |
5374 | + if(HAS_VPP_P010(i965)) { | |
5375 | + vpp_post = 0; | |
5376 | + switch(fourcc) { | |
5377 | + case VA_FOURCC_NV12: | |
5378 | + if(src_rect->x != dst_rect->x || | |
5379 | + src_rect->y != dst_rect->y || | |
5380 | + src_rect->width != dst_rect->width || | |
5381 | + src_rect->height != dst_rect->height) { | |
5382 | + vpp_post = 1; | |
5383 | + } | |
5384 | + break; | |
5385 | + case VA_FOURCC_P010: | |
5386 | + // don't support scaling while the fourcc of dst_surface is P010 | |
5387 | + if(src_rect->x != dst_rect->x || | |
5388 | + src_rect->y != dst_rect->y || | |
5389 | + src_rect->width != dst_rect->width || | |
5390 | + src_rect->height != dst_rect->height) { | |
5391 | + vaStatus = VA_STATUS_ERROR_UNIMPLEMENTED; | |
5392 | + goto EXIT; | |
5393 | + } | |
5394 | + break; | |
5395 | + default: | |
5396 | + vpp_post = 1; | |
5397 | + break; | |
5398 | + } | |
5399 | + | |
5400 | + if(src_surface->type == I965_SURFACE_TYPE_IMAGE) { | |
5401 | + src_obj_surface = derive_surface(ctx, (struct object_image *)src_surface->base, | |
5402 | + &tmp_src_obj_surface); | |
5403 | + } | |
5404 | + else | |
5405 | + src_obj_surface = (struct object_surface *)src_surface->base; | |
5406 | + | |
5407 | + if(src_obj_surface == NULL) { | |
5408 | + vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED; | |
5409 | + goto EXIT; | |
5410 | + } | |
5411 | + | |
5412 | + if(vpp_post == 1) { | |
5413 | + vaStatus = i965_CreateSurfaces(ctx, | |
5414 | + src_obj_surface->orig_width, | |
5415 | + src_obj_surface->orig_height, | |
5416 | + VA_RT_FORMAT_YUV420, | |
5417 | + 1, | |
5418 | + &out_surface_id); | |
5419 | + assert(vaStatus == VA_STATUS_SUCCESS); | |
5420 | + tmp_surface_id[num_tmp_surfaces++] = out_surface_id; | |
5421 | + tmp_surface = SURFACE(out_surface_id); | |
5422 | + assert(tmp_surface); | |
5423 | + i965_check_alloc_surface_bo(ctx, tmp_surface, 1, VA_FOURCC_NV12, SUBSAMPLE_YUV420); | |
5424 | + } | |
5425 | + | |
5426 | + if(tmp_surface != NULL) | |
5427 | + dst_obj_surface = tmp_surface; | |
5428 | + else { | |
5429 | + if(dst_surface->type == I965_SURFACE_TYPE_IMAGE) { | |
5430 | + dst_obj_surface = derive_surface(ctx, (struct object_image *)dst_surface->base, | |
5431 | + &tmp_dst_obj_surface); | |
5432 | + } | |
5433 | + else | |
5434 | + dst_obj_surface = (struct object_surface *)dst_surface->base; | |
5435 | + } | |
5436 | + | |
5437 | + if(dst_obj_surface == NULL) { | |
5438 | + vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED; | |
5439 | + goto EXIT; | |
5440 | + } | |
5441 | + | |
5442 | + vaStatus = vebox_processing_simple(ctx, | |
5443 | + pp_context, | |
5444 | + src_obj_surface, | |
5445 | + dst_obj_surface, | |
5446 | + src_rect); | |
5447 | + if(vaStatus != VA_STATUS_SUCCESS) | |
5448 | + goto EXIT; | |
5449 | + | |
5450 | + if(vpp_post == 1) { | |
5451 | + struct i965_surface src_surface_new; | |
5452 | + | |
5453 | + if(tmp_surface != NULL){ | |
5454 | + src_surface_new.base = (struct object_base *)tmp_surface; | |
5455 | + src_surface_new.type = I965_SURFACE_TYPE_SURFACE; | |
5456 | + src_surface_new.flags = I965_SURFACE_FLAG_FRAME; | |
5457 | + } | |
5458 | + else | |
5459 | + memcpy((void *)&src_surface_new, (void *)src_surface, sizeof(src_surface_new)); | |
5460 | + | |
5461 | + vaStatus = i965_image_pl2_processing(ctx, | |
5462 | + &src_surface_new, | |
5463 | + src_rect, | |
5464 | + dst_surface, | |
5465 | + dst_rect); | |
5466 | + } | |
5467 | + } | |
5468 | + | |
5469 | +EXIT: | |
5470 | + if(num_tmp_surfaces) | |
5471 | + i965_DestroySurfaces(ctx, | |
5472 | + tmp_surface_id, | |
5473 | + num_tmp_surfaces); | |
5474 | + | |
5475 | + return vaStatus; | |
5476 | +} | |
5477 | + | |
5299 | 5478 | VAStatus |
5300 | 5479 | i965_image_processing(VADriverContextP ctx, |
5301 | 5480 | const struct i965_surface *src_surface, |
@@ -5353,6 +5532,13 @@ i965_image_processing(VADriverContextP ctx, | ||
5353 | 5532 | dst_surface, |
5354 | 5533 | dst_rect); |
5355 | 5534 | break; |
5535 | + case VA_FOURCC_P010: | |
5536 | + status = i965_image_p010_processing(ctx, | |
5537 | + src_surface, | |
5538 | + src_rect, | |
5539 | + dst_surface, | |
5540 | + dst_rect); | |
5541 | + break; | |
5356 | 5542 | default: |
5357 | 5543 | status = VA_STATUS_ERROR_UNIMPLEMENTED; |
5358 | 5544 | break; |
@@ -528,6 +528,8 @@ struct i965_post_processing_context | ||
528 | 528 | unsigned int curbe_allocation_size : 16; |
529 | 529 | } vfe_gpu_state; |
530 | 530 | |
531 | + struct intel_vebox_context *vebox_proc_ctx; | |
532 | + | |
531 | 533 | struct pp_load_save_context pp_load_save_context; |
532 | 534 | struct pp_scaling_context pp_scaling_context; |
533 | 535 | struct pp_avs_context pp_avs_context; |
@@ -123,9 +123,6 @@ void gen_free_vp9_surface(void **data) | ||
123 | 123 | return; |
124 | 124 | } |
125 | 125 | |
126 | - dri_bo_unreference(vp9_surface->motion_vector_temporal_bo); | |
127 | - vp9_surface->motion_vector_temporal_bo = NULL; | |
128 | - | |
129 | 126 | free(vp9_surface); |
130 | 127 | *data = NULL; |
131 | 128 |