History

lavfi/qsvvpp: require a dynamic frame pool for output if possible

Haihao Xiang committed 2 years ago

Commit 127ded51 parent 56462851 file · +29 −23Browse files

Showing the changes to libavfilter (1 of 1 file). Show all

Unified · Split

libavfilter/qsvvpp.c+29−23
@@ -587,6 +587,26 @@ static int init_vpp_session(AVFilterContext *avctx, QSVVPPContext *s) · 586 unmodified lines
587587 device_ctx = (AVHWDeviceContext *)device_ref->data;
588588 device_hwctx = device_ctx->hwctx;
589589
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+
590610 if (outlink->format == AV_PIX_FMT_QSV) {
591611 AVHWFramesContext *out_frames_ctx;
592612 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
608628 out_frames_ctx->width = FFALIGN(outlink->w, 32);
609629 out_frames_ctx->height = FFALIGN(outlink->h, 32);
610630 out_frames_ctx->sw_format = s->out_sw_format;
611− out_frames_ctx->initial_pool_size = 64;
612− if (avctx->extra_hw_frames > 0)
613− out_frames_ctx->initial_pool_size += avctx->extra_hw_frames;
631+
632+ if (QSV_RUNTIME_VERSION_ATLEAST(ver, 2, 9) && handle_type != MFX_HANDLE_D3D9_DEVICE_MANAGER)
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+
614640 out_frames_hwctx->frame_type = s->out_mem_mode;
615641
616642 ret = av_hwframe_ctx_init(out_frames_ref);
@@ -636,26 +662,6 @@ static int init_vpp_session(AVFilterContext *avctx, QSVVPPContext *s) · 19 unmodified lines
636662 } else
637663 s->out_mem_mode = MFX_MEMTYPE_SYSTEM_MEMORY;
638664
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−
659665 ret = MFXVideoCORE_GetHandle(device_hwctx->session, handle_type, &handle);
660666 if (ret < 0)
661667 return ff_qsvvpp_print_error(avctx, ret, "Error getting the session handle");

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t