Showing the changes to libavfilter (1 of 1 file). Show all
Unified · Split
| @@ -587,6 +587,26 @@ static int init_vpp_session(AVFilterContext *avctx, QSVVPPContext *s) · 586 unmodified lines | |||
| 587 | device_ctx = (AVHWDeviceContext *)device_ref->data; | 587 | device_ctx = (AVHWDeviceContext *)device_ref->data; |
| 588 | device_hwctx = device_ctx->hwctx; | 588 | device_hwctx = device_ctx->hwctx; |
| 589 | 589 | ||
| 590 | /* extract the properties of the "master" session given to us */ | ||
| 591 | ret = MFXQueryIMPL(device_hwctx->session, &impl); | ||
| 592 | if (ret == MFX_ERR_NONE) | ||
| 593 | ret = MFXQueryVersion(device_hwctx->session, &ver); | ||
| 594 | if (ret != MFX_ERR_NONE) { | ||
| 595 | av_log(avctx, AV_LOG_ERROR, "Error querying the session attributes\n"); | ||
| 596 | return AVERROR_UNKNOWN; | ||
| 597 | } | ||
| 598 | |||
| 599 | if (MFX_IMPL_VIA_VAAPI == MFX_IMPL_VIA_MASK(impl)) { | ||
| 600 | handle_type = MFX_HANDLE_VA_DISPLAY; | ||
| 601 | } else if (MFX_IMPL_VIA_D3D11 == MFX_IMPL_VIA_MASK(impl)) { | ||
| 602 | handle_type = MFX_HANDLE_D3D11_DEVICE; | ||
| 603 | } else if (MFX_IMPL_VIA_D3D9 == MFX_IMPL_VIA_MASK(impl)) { | ||
| 604 | handle_type = MFX_HANDLE_D3D9_DEVICE_MANAGER; | ||
| 605 | } else { | ||
| 606 | av_log(avctx, AV_LOG_ERROR, "Error unsupported handle type\n"); | ||
| 607 | return AVERROR_UNKNOWN; | ||
| 608 | } | ||
| 609 | |||
| 590 | if (outlink->format == AV_PIX_FMT_QSV) { | 610 | if (outlink->format == AV_PIX_FMT_QSV) { |
| 591 | AVHWFramesContext *out_frames_ctx; | 611 | AVHWFramesContext *out_frames_ctx; |
| 592 | AVBufferRef *out_frames_ref = av_hwframe_ctx_alloc(device_ref); | 612 | AVBufferRef *out_frames_ref = av_hwframe_ctx_alloc(device_ref); |
| @@ -608,9 +628,15 @@ static int init_vpp_session(AVFilterContext *avctx, QSVVPPContext *s) · 15 unmodified lines | |||
| 608 | out_frames_ctx->width = FFALIGN(outlink->w, 32); | 628 | out_frames_ctx->width = FFALIGN(outlink->w, 32); |
| 609 | out_frames_ctx->height = FFALIGN(outlink->h, 32); | 629 | out_frames_ctx->height = FFALIGN(outlink->h, 32); |
| 610 | out_frames_ctx->sw_format = s->out_sw_format; | 630 | out_frames_ctx->sw_format = s->out_sw_format; |
| 611 | out_frames_ctx->initial_pool_size = 64; | 631 | |
| 612 | if (avctx->extra_hw_frames > 0) | 632 | if (QSV_RUNTIME_VERSION_ATLEAST(ver, 2, 9) && handle_type != MFX_HANDLE_D3D9_DEVICE_MANAGER) |
| 613 | out_frames_ctx->initial_pool_size += avctx->extra_hw_frames; | 633 | out_frames_ctx->initial_pool_size = 0; |
| 634 | else { | ||
| 635 | out_frames_ctx->initial_pool_size = 64; | ||
| 636 | if (avctx->extra_hw_frames > 0) | ||
| 637 | out_frames_ctx->initial_pool_size += avctx->extra_hw_frames; | ||
| 638 | } | ||
| 639 | |||
| 614 | out_frames_hwctx->frame_type = s->out_mem_mode; | 640 | out_frames_hwctx->frame_type = s->out_mem_mode; |
| 615 | 641 | ||
| 616 | ret = av_hwframe_ctx_init(out_frames_ref); | 642 | ret = av_hwframe_ctx_init(out_frames_ref); |
| @@ -636,26 +662,6 @@ static int init_vpp_session(AVFilterContext *avctx, QSVVPPContext *s) · 19 unmodified lines | |||
| 636 | } else | 662 | } else |
| 637 | s->out_mem_mode = MFX_MEMTYPE_SYSTEM_MEMORY; | 663 | s->out_mem_mode = MFX_MEMTYPE_SYSTEM_MEMORY; |
| 638 | 664 | ||
| 639 | /* extract the properties of the "master" session given to us */ | ||
| 640 | ret = MFXQueryIMPL(device_hwctx->session, &impl); | ||
| 641 | if (ret == MFX_ERR_NONE) | ||
| 642 | ret = MFXQueryVersion(device_hwctx->session, &ver); | ||
| 643 | if (ret != MFX_ERR_NONE) { | ||
| 644 | av_log(avctx, AV_LOG_ERROR, "Error querying the session attributes\n"); | ||
| 645 | return AVERROR_UNKNOWN; | ||
| 646 | } | ||
| 647 | |||
| 648 | if (MFX_IMPL_VIA_VAAPI == MFX_IMPL_VIA_MASK(impl)) { | ||
| 649 | handle_type = MFX_HANDLE_VA_DISPLAY; | ||
| 650 | } else if (MFX_IMPL_VIA_D3D11 == MFX_IMPL_VIA_MASK(impl)) { | ||
| 651 | handle_type = MFX_HANDLE_D3D11_DEVICE; | ||
| 652 | } else if (MFX_IMPL_VIA_D3D9 == MFX_IMPL_VIA_MASK(impl)) { | ||
| 653 | handle_type = MFX_HANDLE_D3D9_DEVICE_MANAGER; | ||
| 654 | } else { | ||
| 655 | av_log(avctx, AV_LOG_ERROR, "Error unsupported handle type\n"); | ||
| 656 | return AVERROR_UNKNOWN; | ||
| 657 | } | ||
| 658 | |||
| 659 | ret = MFXVideoCORE_GetHandle(device_hwctx->session, handle_type, &handle); | 665 | ret = MFXVideoCORE_GetHandle(device_hwctx->session, handle_type, &handle); |
| 660 | if (ret < 0) | 666 | if (ret < 0) |
| 661 | return ff_qsvvpp_print_error(avctx, ret, "Error getting the session handle"); | 667 | return ff_qsvvpp_print_error(avctx, ret, "Error getting the session handle"); |