From patchwork Thu Apr 8 07:09:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xiang, Haihao" X-Patchwork-Id: 26806 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 7845F44AA12 for ; Thu, 8 Apr 2021 10:10:15 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 65FC668A6D2; Thu, 8 Apr 2021 10:10:15 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id AB266680508 for ; Thu, 8 Apr 2021 10:10:08 +0300 (EEST) IronPort-SDR: bmtJOYCVShJo92pQ4gbCPbQ1ymfYyZqfZUVVaiaCpsVP/hToRd6LEUprHGSiLLA9YRXSBYWL1f Oz4vz0DNKuXw== X-IronPort-AV: E=McAfee;i="6000,8403,9947"; a="213879025" X-IronPort-AV: E=Sophos;i="5.82,205,1613462400"; d="scan'208";a="213879025" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Apr 2021 00:10:00 -0700 IronPort-SDR: vJ7sOpVPlB9Ioc0gNFI5+QcvLXiyKnHb5XXD3ge3pN/DfobqVWHC8P5CKoFO/zXA/ZgTHlCmTo dSWR2nVmejbg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,205,1613462400"; d="scan'208";a="519741652" Received: from xhh-tgl64.sh.intel.com ([10.239.159.152]) by fmsmga001.fm.intel.com with ESMTP; 08 Apr 2021 00:09:59 -0700 From: Haihao Xiang To: ffmpeg-devel@ffmpeg.org Date: Thu, 8 Apr 2021 15:09:29 +0800 Message-Id: <20210408070929.860244-3-haihao.xiang@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210408070929.860244-1-haihao.xiang@intel.com> References: <20210408070929.860244-1-haihao.xiang@intel.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/3] lavu/hwcontext_qsv: limit the number of threads used for hwupload & hwdownload to 2 X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" The session for hwupload & hwdownload is used to copy data between system and video memory, 2 threads are sufficient for the copy in the SDK. --- libavutil/hwcontext_qsv.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c index 84cf5015ff..5dbe2b1701 100644 --- a/libavutil/hwcontext_qsv.c +++ b/libavutil/hwcontext_qsv.c @@ -456,8 +456,25 @@ static int qsv_init_internal_session(AVHWFramesContext *ctx, mfxVideoParam par; mfxStatus err; + mfxInitParam init_par = { MFX_IMPL_AUTO_ANY }; - err = MFXInit(device_priv->impl, &device_priv->ver, session); +#if QSV_VERSION_ATLEAST(1, 15) + mfxExtBuffer *ext_params[1]; + mfxExtThreadsParam thread_param; + + memset(&thread_param, 0, sizeof(thread_param)); + thread_param.Header.BufferId = MFX_EXTBUFF_THREADS_PARAM; + thread_param.Header.BufferSz = sizeof(thread_param); + thread_param.NumThread = 2; + ext_params[0] = (mfxExtBuffer *)&thread_param; + init_par.ExtParam = (mfxExtBuffer **)&ext_params; + init_par.NumExtParam = 1; +#endif + + init_par.Implementation = device_priv->impl; + init_par.Version = device_priv->ver; + + err = MFXInitEx(init_par, session); if (err != MFX_ERR_NONE) { av_log(ctx, AV_LOG_ERROR, "Error initializing an internal session\n"); return AVERROR_UNKNOWN;