From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 0EA93492ED for ; Wed, 8 May 2024 06:05:38 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 23FD668D5F5; Wed, 8 May 2024 09:04:42 +0300 (EEST) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B5ACD68D5D8 for ; Wed, 8 May 2024 09:04:36 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715148279; x=1746684279; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=OoPeKkAvhxHVU4hubUQpR7EdVjMYzcQM42Wq+DAjSqo=; b=iwCb0Ixr7es4ydP2BUiZZDy1mRzd9xqdh7t7N4oUGFj95VpKnajrn2E2 JSVwAv8YqelfW03dLjbReuLqJdOWFRWBbINtsExdmT89oldPdH2HU3s83 gr3+fKxzme/ksE8UKhSg9eb02a2E6EXxZox9Y9kD2bygK9ESnx5D3obhG Peq5nSgW05t6xXBl6Fj0rMLfNoVf/Y32bfQ/2clsROM9gXbMx4Bgcpdb7 56CggJGvj69i3huT4EfcdAax9lXQBxHOkCR+EJsVyPcs244bTKm+nqhRJ 95X64PSo+mWt3otsqMtUxx+NT4jWlwumJLgIfoNXtP1WML8KHcWkak6WF A==; X-CSE-ConnectionGUID: FvelZFQ7SZmyHVmjPKygTw== X-CSE-MsgGUID: vtlYQIr4TtSzECMD/WNumg== X-IronPort-AV: E=McAfee;i="6600,9927,11066"; a="10855373" X-IronPort-AV: E=Sophos;i="6.08,144,1712646000"; d="scan'208";a="10855373" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 May 2024 23:04:28 -0700 X-CSE-ConnectionGUID: vYmVCAnZQl+QhqBUSBaJvA== X-CSE-MsgGUID: e2L+BMA6QeGo/YThosL2JQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,144,1712646000"; d="scan'208";a="28828804" Received: from unknown (HELO xhh-dg264.sh.intel.com) ([10.238.2.76]) by fmviesa006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 May 2024 23:04:27 -0700 From: "Xiang, Haihao" To: ffmpeg-devel@ffmpeg.org Date: Wed, 8 May 2024 14:03:16 +0800 Message-Id: <20240508060316.681114-9-haihao.xiang@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240508060316.681114-1-haihao.xiang@intel.com> References: <20240508060316.681114-1-haihao.xiang@intel.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 9/9] lavfi/qsvvpp: require a dynamic frame pool for output if possible X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Haihao Xiang Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: From: Haihao Xiang Signed-off-by: Haihao Xiang --- libavfilter/qsvvpp.c | 52 ++++++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c index c4c338b36b..1c9773df09 100644 --- a/libavfilter/qsvvpp.c +++ b/libavfilter/qsvvpp.c @@ -587,6 +587,26 @@ static int init_vpp_session(AVFilterContext *avctx, QSVVPPContext *s) device_ctx = (AVHWDeviceContext *)device_ref->data; device_hwctx = device_ctx->hwctx; + /* extract the properties of the "master" session given to us */ + ret = MFXQueryIMPL(device_hwctx->session, &impl); + if (ret == MFX_ERR_NONE) + ret = MFXQueryVersion(device_hwctx->session, &ver); + if (ret != MFX_ERR_NONE) { + av_log(avctx, AV_LOG_ERROR, "Error querying the session attributes\n"); + return AVERROR_UNKNOWN; + } + + if (MFX_IMPL_VIA_VAAPI == MFX_IMPL_VIA_MASK(impl)) { + handle_type = MFX_HANDLE_VA_DISPLAY; + } else if (MFX_IMPL_VIA_D3D11 == MFX_IMPL_VIA_MASK(impl)) { + handle_type = MFX_HANDLE_D3D11_DEVICE; + } else if (MFX_IMPL_VIA_D3D9 == MFX_IMPL_VIA_MASK(impl)) { + handle_type = MFX_HANDLE_D3D9_DEVICE_MANAGER; + } else { + av_log(avctx, AV_LOG_ERROR, "Error unsupported handle type\n"); + return AVERROR_UNKNOWN; + } + if (outlink->format == AV_PIX_FMT_QSV) { AVHWFramesContext *out_frames_ctx; AVBufferRef *out_frames_ref = av_hwframe_ctx_alloc(device_ref); @@ -608,9 +628,15 @@ static int init_vpp_session(AVFilterContext *avctx, QSVVPPContext *s) out_frames_ctx->width = FFALIGN(outlink->w, 32); out_frames_ctx->height = FFALIGN(outlink->h, 32); out_frames_ctx->sw_format = s->out_sw_format; - out_frames_ctx->initial_pool_size = 64; - if (avctx->extra_hw_frames > 0) - out_frames_ctx->initial_pool_size += avctx->extra_hw_frames; + + if (QSV_RUNTIME_VERSION_ATLEAST(ver, 2, 9) && handle_type != MFX_HANDLE_D3D9_DEVICE_MANAGER) + out_frames_ctx->initial_pool_size = 0; + else { + out_frames_ctx->initial_pool_size = 64; + if (avctx->extra_hw_frames > 0) + out_frames_ctx->initial_pool_size += avctx->extra_hw_frames; + } + out_frames_hwctx->frame_type = s->out_mem_mode; ret = av_hwframe_ctx_init(out_frames_ref); @@ -636,26 +662,6 @@ static int init_vpp_session(AVFilterContext *avctx, QSVVPPContext *s) } else s->out_mem_mode = MFX_MEMTYPE_SYSTEM_MEMORY; - /* extract the properties of the "master" session given to us */ - ret = MFXQueryIMPL(device_hwctx->session, &impl); - if (ret == MFX_ERR_NONE) - ret = MFXQueryVersion(device_hwctx->session, &ver); - if (ret != MFX_ERR_NONE) { - av_log(avctx, AV_LOG_ERROR, "Error querying the session attributes\n"); - return AVERROR_UNKNOWN; - } - - if (MFX_IMPL_VIA_VAAPI == MFX_IMPL_VIA_MASK(impl)) { - handle_type = MFX_HANDLE_VA_DISPLAY; - } else if (MFX_IMPL_VIA_D3D11 == MFX_IMPL_VIA_MASK(impl)) { - handle_type = MFX_HANDLE_D3D11_DEVICE; - } else if (MFX_IMPL_VIA_D3D9 == MFX_IMPL_VIA_MASK(impl)) { - handle_type = MFX_HANDLE_D3D9_DEVICE_MANAGER; - } else { - av_log(avctx, AV_LOG_ERROR, "Error unsupported handle type\n"); - return AVERROR_UNKNOWN; - } - ret = MFXVideoCORE_GetHandle(device_hwctx->session, handle_type, &handle); if (ret < 0) return ff_qsvvpp_print_error(avctx, ret, "Error getting the session handle"); -- 2.34.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".