| 690 | } |
| 691 | |
| 692 | int ff_vaapi_decode_init(AVCodecContext *avctx) |
| 693 | { |
| 694 | VAAPIDecodeContext *ctx = avctx->internal->hwaccel_priv_data; |
| 695 | VAStatus vas; |
| 696 | int err; |
| 697 | |
| 698 | ctx->va_config = VA_INVALID_ID; |
| 699 | ctx->va_context = VA_INVALID_ID; |
| 700 | |
| 701 | err = ff_decode_get_hw_frames_ctx(avctx, AV_HWDEVICE_TYPE_VAAPI); |
| 702 | if (err < 0) |
| 703 | goto fail; |
| 704 | |
| 705 | ctx->frames = (AVHWFramesContext*)avctx->hw_frames_ctx->data; |
| 706 | ctx->hwfc = ctx->frames->hwctx; |
| 707 | ctx->device = ctx->frames->device_ctx; |
| 708 | ctx->hwctx = ctx->device->hwctx; |
| 709 | |
| 710 | err = vaapi_decode_make_config(avctx, ctx->frames->device_ref, |
| 711 | &ctx->va_config, NULL); |
| 712 | if (err) |
| 713 | goto fail; |
| 714 | |
| 715 | vas = vaCreateContext(ctx->hwctx->display, ctx->va_config, |
| 716 | avctx->coded_width, avctx->coded_height, |
| 717 | VA_PROGRESSIVE, |
| 718 | ctx->hwfc->surface_ids, |
| 719 | ctx->hwfc->nb_surfaces, |
| 720 | &ctx->va_context); |
| 721 | if (vas != VA_STATUS_SUCCESS) { |
| 722 | av_log(avctx, AV_LOG_ERROR, "Failed to create decode " |
| 723 | "context: %d (%s).\n", vas, vaErrorStr(vas)); |
| 724 | err = AVERROR(EIO); |
| 725 | goto fail; |
| 726 | } |
| 727 | |
| 728 | av_log(avctx, AV_LOG_DEBUG, "Decode context initialised: " |
| 729 | "%#x/%#x.\n", ctx->va_config, ctx->va_context); |
| 730 | |
| 731 | return 0; |
| 732 | |
| 733 | fail: |
| 734 | ff_vaapi_decode_uninit(avctx); |
| 735 | return err; |
| 736 | } |
| 737 | |
| 738 | int ff_vaapi_decode_uninit(AVCodecContext *avctx) |
| 739 | { |
no test coverage detected