Rev 6135 | Rev 6144 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 6135 | Rev 6136 | ||
---|---|---|---|
Line 37... | Line 37... | ||
37 | #define ARRAY_ELEMS(a) (sizeof(a) / sizeof((a)[0])) |
37 | #define ARRAY_ELEMS(a) (sizeof(a) / sizeof((a)[0])) |
Line 38... | Line 38... | ||
38 | 38 | ||
39 | static int drm_fd = 0; |
39 | static int drm_fd = 0; |
Line 40... | Line 40... | ||
40 | static struct vaapi_context *v_context; |
40 | static struct vaapi_context *v_context; |
Line 41... | Line 41... | ||
41 | 41 | ||
42 | static VASurfaceID v_surface_id[HWDEC_NUM_SURFACES]; |
42 | static VASurfaceID v_surface_id[16]; |
Line 43... | Line 43... | ||
43 | 43 | ||
Line 279... | Line 279... | ||
279 | return 1; |
279 | return 1; |
280 | } |
280 | } |
281 | return 0; |
281 | return 0; |
282 | } |
282 | } |
Line 283... | Line 283... | ||
283 | 283 | ||
284 | static int vaapi_init_decoder(VAProfile profile, |
284 | static int vaapi_init_decoder(vst_t *vst,VAProfile profile, |
285 | VAEntrypoint entrypoint, |
285 | VAEntrypoint entrypoint, |
286 | unsigned int picture_width, |
286 | unsigned int picture_width, |
287 | unsigned int picture_height) |
287 | unsigned int picture_height) |
288 | { |
288 | { |
Line 341... | Line 341... | ||
341 | return -1; |
341 | return -1; |
342 | } |
342 | } |
Line 343... | Line 343... | ||
343 | 343 | ||
344 | printf("vaCreateSurfaces %dx%d\n",picture_width,picture_height); |
344 | printf("vaCreateSurfaces %dx%d\n",picture_width,picture_height); |
345 | status = vaCreateSurfaces(vaapi->display, VA_RT_FORMAT_YUV420, picture_width, picture_height, |
345 | status = vaCreateSurfaces(vaapi->display, VA_RT_FORMAT_YUV420, picture_width, picture_height, |
346 | v_surface_id,HWDEC_NUM_SURFACES,NULL,0); |
346 | v_surface_id,vst->nframes,NULL,0); |
347 | if (!vaapi_check_status(status, "vaCreateSurfaces()")) |
347 | if (!vaapi_check_status(status, "vaCreateSurfaces()")) |
348 | { |
348 | { |
349 | FAIL(); |
349 | FAIL(); |
350 | return -1; |
350 | return -1; |
Line 376... | Line 376... | ||
376 | 376 | ||
377 | printf("vaCreateContext %dx%d\n",picture_width,picture_height); |
377 | printf("vaCreateContext %dx%d\n",picture_width,picture_height); |
378 | status = vaCreateContext(vaapi->display, config_id, |
378 | status = vaCreateContext(vaapi->display, config_id, |
379 | picture_width, picture_height, |
379 | picture_width, picture_height, |
380 | VA_PROGRESSIVE, |
380 | VA_PROGRESSIVE, |
381 | v_surface_id, HWDEC_NUM_SURFACES, |
381 | v_surface_id, vst->nframes, |
382 | &context_id); |
382 | &context_id); |
383 | if (!vaapi_check_status(status, "vaCreateContext()")) |
383 | if (!vaapi_check_status(status, "vaCreateContext()")) |
384 | { |
384 | { |
385 | FAIL(); |
385 | FAIL(); |
Line 394... | Line 394... | ||
394 | 394 | ||
395 | 395 | ||
396 | static enum PixelFormat get_format(struct AVCodecContext *avctx, |
396 | static enum PixelFormat get_format(struct AVCodecContext *avctx, |
- | 397 | const enum AVPixelFormat *fmt) |
|
397 | const enum AVPixelFormat *fmt) |
398 | { |
Line 398... | Line -... | ||
398 | { |
- | |
Line 399... | Line 399... | ||
399 | VAProfile profile = VAProfileNone; |
399 | vst_t *vst = (vst_t*)avctx->opaque; |
400 | 400 | VAProfile profile = VAProfileNone; |
|
401 | ENTER(); |
401 | |
Line 417... | Line 417... | ||
417 | { |
417 | { |
418 | if (hw_profiles[n].av_codec == codec && |
418 | if (hw_profiles[n].av_codec == codec && |
419 | hw_profiles[n].ff_profile == avctx->profile) |
419 | hw_profiles[n].ff_profile == avctx->profile) |
420 | { |
420 | { |
421 | profile = hw_profiles[n].va_profile; |
421 | profile = hw_profiles[n].va_profile; |
422 | if (vaapi_init_decoder(profile, VAEntrypointVLD, avctx->width, avctx->height) == 0) |
422 | if (vaapi_init_decoder(vst, profile, VAEntrypointVLD, avctx->width, avctx->height) == 0) |
423 | { |
423 | { |
424 | avctx->hwaccel_context = v_context; |
424 | avctx->hwaccel_context = v_context; |
425 | LEAVE(); |
- | |
426 | return fmt[i]; ; |
425 | return fmt[i]; ; |
427 | } |
426 | } |
428 | } |
427 | } |
429 | } |
428 | } |
Line 430... | Line 429... | ||
430 | 429 | ||
431 | } |
- | |
432 | FAIL(); |
430 | } |
433 | return PIX_FMT_NONE; |
431 | return PIX_FMT_NONE; |
Line 434... | Line 432... | ||
434 | } |
432 | } |
435 | 433 | ||
Line 470... | Line 468... | ||
470 | 468 | ||
471 | int fplay_init_context(vst_t *vst) |
469 | int fplay_init_context(vst_t *vst) |
472 | { |
470 | { |
Line -... | Line 471... | ||
- | 471 | AVCodecContext *vCtx = vst->vCtx; |
|
- | 472 | ||
473 | AVCodecContext *vCtx = vst->vCtx; |
473 | vst->nframes = 4; |
474 | 474 | ||
475 | if(va_check_codec_support(vCtx->codec_id)) |
475 | if(va_check_codec_support(vCtx->codec_id)) |
Line 476... | Line 476... | ||
476 | { |
476 | { |
477 | VADisplay dpy; |
477 | VADisplay dpy; |
Line 478... | Line 478... | ||
478 | 478 | ||
479 | dpy = va_open_display(); |
479 | dpy = va_open_display(); |
- | 480 | vst->hwCtx = vaapi_init(dpy); |
|
- | 481 | ||
- | 482 | if(vst->hwCtx != NULL) |
|
480 | vst->hwCtx = vaapi_init(dpy); |
483 | { |
481 | 484 | if(vCtx->codec_id == AV_CODEC_ID_H264) |
|
482 | if(vst->hwCtx != NULL) |
485 | vst->nframes = 16; |
Line 483... | Line 486... | ||
483 | { |
486 | |
484 | for(int i = 0; i < HWDEC_NUM_SURFACES; i++) |
487 | for(int i = 0; i < vst->nframes; i++) |
485 | { |
488 | { |
486 | vframe_t *vframe = calloc(1, sizeof(*vframe)); |
489 | vframe_t *vframe = &vst->vframes[i]; |
487 | 490 | ||
488 | vframe->format = AV_PIX_FMT_NONE; |
491 | vframe->format = AV_PIX_FMT_NONE; |
489 | vframe->is_hw_pic = 1; |
492 | vframe->is_hw_pic = 1; |
Line 490... | Line 493... | ||
490 | vframe->index = i; |
493 | vframe->index = i; |
- | 494 | vframe->pts = 0; |
|
491 | vframe->pts = 0; |
495 | vframe->ready = 0; |
492 | vframe->ready = 0; |
496 | list_add_tail(&vframe->list, &vst->input_list); |
493 | list_add_tail(&vframe->list, &vst->input_list); |
497 | }; |
494 | }; |
498 | |
495 | 499 | vst->hwdec = 1; |
|
496 | vst->hwdec = 1; |
500 | vst->frame_reorder = 1; |
497 | vCtx->opaque = vst; |
501 | vCtx->opaque = vst; |
Line 498... | Line 502... | ||
498 | vCtx->thread_count = 1; |
502 | vCtx->thread_count = 1; |
Line 499... | Line 503... | ||
499 | vCtx->get_format = get_format; |
503 | vCtx->get_format = get_format; |
500 | vCtx->get_buffer2 = get_buffer2; |
504 | vCtx->get_buffer2 = get_buffer2; |
501 | return 0; |
505 | return 0; |
502 | }; |
506 | }; |
Line 503... | Line 507... | ||
503 | }; |
507 | }; |
Line 504... | Line 508... | ||
504 | 508 | ||
505 | vst->hwdec = 0; |
509 | vst->hwdec = 0; |
506 | 510 | ||
507 | for(int i = 0; i < HWDEC_NUM_SURFACES; i++) |
511 | for(int i = 0; i < vst->nframes; i++) |