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 974134738D for ; Wed, 6 Sep 2023 06:02:57 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5549D68C878; Wed, 6 Sep 2023 09:01:38 +0300 (EEST) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.93]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 73B8C68C7F2 for ; Wed, 6 Sep 2023 09:01:32 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1693980092; x=1725516092; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2g24ZbPUjpNpUIM43E6+1/ShO9eJe8ljY2VhpL17F+E=; b=Fb9wa0BtHZjeVpcPLPBxepuoePkldhjhhphXnTmLaKyVM+0QJ3v1bTmf ZwhNA79b7oH0bZaxNPy6GWIPb+pZj7dUIyAS8elvuvu/7b9Tpw83I4F43 NYPGMfdOvySoaY5yoCUxs8dvRVb2SXufMGm8aT6dBs2NLWRF0Pg4fbtJE ZlpFdW4xUrm6sGHSkGylm87t2XSrNDyJO0s0m6KkFdfei549p2ZojhWyC 4/9LW/f8ZfRRp5GT22dBZ1s6SPeOfXt4ZGCIvYlLhH3j6mp39R2UJhJ8n smZvTKQy4w7HYKvZVQ6AlYWrD/unlHz1C1GzXDYraCtw5WG3sFVTq6zZd Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10824"; a="374372450" X-IronPort-AV: E=Sophos;i="6.02,231,1688454000"; d="scan'208";a="374372450" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Sep 2023 23:01:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10824"; a="734919067" X-IronPort-AV: E=Sophos;i="6.02,231,1688454000"; d="scan'208";a="734919067" Received: from xhh-dg264.sh.intel.com ([10.238.2.76]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Sep 2023 23:01:20 -0700 From: "Xiang, Haihao" To: ffmpeg-devel@ffmpeg.org Date: Wed, 6 Sep 2023 14:00:49 +0800 Message-Id: <20230906060052.698620-10-haihao.xiang@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230906060052.698620-1-haihao.xiang@intel.com> References: <20230906060052.698620-1-haihao.xiang@intel.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 10/13] 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 d09140d89b..2c8e73e87d 100644 --- a/libavfilter/qsvvpp.c +++ b/libavfilter/qsvvpp.c @@ -603,6 +603,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); @@ -624,9 +644,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); @@ -652,26 +678,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".