From patchwork Mon Aug 16 07:33:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xiang, Haihao" X-Patchwork-Id: 29551 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2a4a:0:0:0:0 with SMTP id k10csp1799321iov; Mon, 16 Aug 2021 00:33:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxAOUMclq1C2lXGSaAKBdN8L0qf8a+RccixvNCZm4KWFVWPG68ogSYJ8qR0gGX1kYLCh31M X-Received: by 2002:a17:907:1b06:: with SMTP id mp6mr15057884ejc.188.1629099234285; Mon, 16 Aug 2021 00:33:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629099234; cv=none; d=google.com; s=arc-20160816; b=vUffKcVN5/wt9pbIaku1xnUwaSV8uOZHb2rc4zE8dcTRZ7iiY0rkia0ovcVkzCYOYu AECulMsaH1hYpLo2Bwi44+RXuO5JKzQJE+kjbljMQ3+4U7LvSMtZq2m4xzrVpsIb+9B7 TKTmvAouB+3lJxgjW6xrLTR/HdzZOv6YtBvtYZJoOTZ5/2eHs6/ALfORaN5qzUw2rh6b GyCwNNFroPJKk1MNLHxdJtBrG9qg6A/xGCLO/yOz51QEepRFFXxRBiGl7K6RrDTamSFy tk4AmSkJxAlif9KxyWx6/cI1Ole5FLUde6jHWgjSljo50K4ijavjsqKAfEsWrbbtViu2 akWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:delivered-to; bh=XaeDIlG29UPXqCN1cbX2rUiHxI/3MN9DbyuLSIRE5+c=; b=rGZbw2kYfxIS2k9QkEyjyOeD1zVPaE5wswdx5pnKy4wrmH1+bqCtDI1DmloY+NQQ60 giXLFCihrnDKkrolP45Umclr8vqAn70LDcZ6K7eEqbJgWZ6WYzdctATckK5AIqRpeInT pSJsnaKef+bjxfIkUgXkkjZDWna1o/C3b3XvIA6e9E2NxndQ5bMqJ0JGYPlrXRW8oPZB 8YETSbeE/XI8smmwPQaIi0h+sNm6osXXyLLjAksMSrb3DwJGSS1qheyeGUUtn7YjfWaH gP40p9m96O3R+VoYYOq/BLY3AjfGrbFXjN01Vjc3F5axQ+jP+kr0jzF4R4SllvEQli9K 5KEA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id hg14si8983460ejc.653.2021.08.16.00.33.53; Mon, 16 Aug 2021 00:33:54 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0B84768A539; Mon, 16 Aug 2021 10:33:49 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B2F3568092F for ; Mon, 16 Aug 2021 10:33:42 +0300 (EEST) X-IronPort-AV: E=McAfee;i="6200,9189,10077"; a="203011855" X-IronPort-AV: E=Sophos;i="5.84,324,1620716400"; d="scan'208";a="203011855" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Aug 2021 00:33:40 -0700 X-IronPort-AV: E=Sophos;i="5.84,324,1620716400"; d="scan'208";a="519461820" Received: from xhh-dg164.sh.intel.com ([10.239.159.167]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Aug 2021 00:33:39 -0700 From: Haihao Xiang To: ffmpeg-devel@ffmpeg.org Date: Mon, 16 Aug 2021 15:33:16 +0800 Message-Id: <20210816073325.27020-2-haihao.xiang@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210816073325.27020-1-haihao.xiang@intel.com> References: <20210816073325.27020-1-haihao.xiang@intel.com> Subject: [FFmpeg-devel] [PATCH v2 01/10] configure: ensure --enable-libmfx uses libmfx 1.x 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 3E0JNka/WaBK Intel's oneVPL is a successor to MediaSDK, but removed some obsolete features of MediaSDK[1]. Some early versions of oneVPL still uses libmfx as library name[2], however some of obsolete features, including OPAQUE memory, multi-frame encode, user plugins and LA_EXT rate control mode etc, have been enabled in QSV, so user can not use --enable-libmfx to enable QSV if using an early version of oneVPL SDK. In order to make sure user builds FFmpeg against a right version of libmfx, this patch added a check for the version of libmfx and warning message about the used obsolete features. [1] https://spec.oneapi.io/versions/latest/elements/oneVPL/source/appendix/VPL_intel_media_sdk.html [2] https://github.com/oneapi-src/oneVPL --- configure | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/configure b/configure index af8a934af9..4bdb8bac18 100755 --- a/configure +++ b/configure @@ -6436,8 +6436,11 @@ enabled liblensfun && require_pkg_config liblensfun lensfun lensfun.h lf_ # Media SDK or Intel Media Server Studio, these don't come with # pkg-config support. Instead, users should make sure that the build # can find the libraries and headers through other means. -enabled libmfx && { check_pkg_config libmfx libmfx "mfx/mfxvideo.h" MFXInit || - { require libmfx "mfx/mfxvideo.h" MFXInit "-llibmfx $advapi32_extralibs" && warn "using libmfx without pkg-config"; } } +enabled libmfx && { { check_pkg_config libmfx "libmfx < 2.0" "mfx/mfxvideo.h" MFXInit || + { require "libmfx < 2.0" "mfx/mfxvideo.h" MFXInit "-llibmfx $advapi32_extralibs" && warn "using libmfx without pkg-config"; } } && + warn "build FFmpeg against libmfx 1.x, obsolete features of libmfx such as OPAQUE memory,\n"\ + "multi-frame encode, user plugins and LA_EXT rate control mode are enabled"; } + if enabled libmfx; then check_cc MFX_CODEC_VP9 "mfx/mfxvp9.h mfx/mfxstructures.h" "MFX_CODEC_VP9" fi From patchwork Mon Aug 16 07:33:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xiang, Haihao" X-Patchwork-Id: 29550 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2a4a:0:0:0:0 with SMTP id k10csp1799724iov; Mon, 16 Aug 2021 00:34:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw6TH0hA4nD/REwMCz37b5j3fYA7hz5vs0co1hN7lw3juwwPgHaHLC7NoDIr+IL/yBknV5s X-Received: by 2002:a17:907:c28:: with SMTP id ga40mr14782455ejc.330.1629099269626; Mon, 16 Aug 2021 00:34:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629099269; cv=none; d=google.com; s=arc-20160816; b=Zqko+teumavoPOFD+MKnkbK6DT2jKnEppn5A88/Bvqb8EFUWGIMr5sJWlk1OPYCxID z9FyOFMEEskzFI3pM+LaXj/5/KkWIDOpEfRrEROIrtFhe1AWkQsHbc0sKdxWMIzQ3aLR 5Su59N+eBopTGmDmWcscKzn14s6n4tsctJd8x+CykUWY/NapX1BnTMvQZUSISyz/QvSA bSTa7KrJoXvK8MDKoZr+Itgt+Cqvw8QI+MHC2JDXkHUp7+mEP/7xphJQj0sZrfZFFR+D qzfnSEi+g+MtFo1ilJx9aMzYAyuRZfBFwlg3h6r0rTM2PVi2giaCZI3qr9xBg1W1+n59 XVxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:delivered-to; bh=At75D1DKvYJoSH/ThAzgHnFzw7yewjsQ4ErFxntoCwk=; b=FRY/H2Z9QAp6+pFw2aXAamj3b5g5gT1pq1o5sxBBIyf65H8/7IujsoRhWwjBpUG2qi 1Bq9zeRfzl+dtkTlz2hL5VMpBlfFf68wBz5UJmIYHlBDdHvUWmLPFsANYrsXnAJWMCaU 4vMKp9CR7fTCEkkI4BAnwrrSopDD7TvVP3iPOgABt/dGGtINUXu7KgrKcKbKfXqMr9yn j3/epQbAqgfVQavG/gAX2uJNvtJ+oFD6Zzuoqo4Ie0PTqXuHRPgNd68e3XDEqDiGR9Be t8tEqBOvU/zj5UAwKYIi477Q8roCWB//15nYxO1qpRcR+He4DVpagx/NLcV13XL2oF72 ZrJg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id h6si9188850edv.408.2021.08.16.00.34.29; Mon, 16 Aug 2021 00:34:29 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id EAA2A68A5F0; Mon, 16 Aug 2021 10:33:57 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9E29368A583 for ; Mon, 16 Aug 2021 10:33:48 +0300 (EEST) X-IronPort-AV: E=McAfee;i="6200,9189,10077"; a="203011859" X-IronPort-AV: E=Sophos;i="5.84,324,1620716400"; d="scan'208";a="203011859" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Aug 2021 00:33:41 -0700 X-IronPort-AV: E=Sophos;i="5.84,324,1620716400"; d="scan'208";a="519461827" Received: from xhh-dg164.sh.intel.com ([10.239.159.167]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Aug 2021 00:33:40 -0700 From: Haihao Xiang To: ffmpeg-devel@ffmpeg.org Date: Mon, 16 Aug 2021 15:33:17 +0800 Message-Id: <20210816073325.27020-3-haihao.xiang@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210816073325.27020-1-haihao.xiang@intel.com> References: <20210816073325.27020-1-haihao.xiang@intel.com> Subject: [FFmpeg-devel] [PATCH v2 02/10] configure: fix the check for MFX_CODEC_VP9 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: x5+/y7WMveDS The data structures for VP9 in mfxvp9.h is wrapped by MFX_VERSION_NEXT, which means those data structures have never been used in a public release. Actually MFX_CODEC_VP9 and other VP9 stuffs is added in mfxstructures.h. In addition, mfxdefs.h is included in mfxvp9.h, so we may use the check in this patch for MFX_CODEC_VP9 This is in preparation for oneVPL support because mfxvp9.h is removed from oneVPL [1] [1]: https://github.com/oneapi-src/oneVPL --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 4bdb8bac18..b10a7b5a52 100755 --- a/configure +++ b/configure @@ -6442,7 +6442,7 @@ enabled libmfx && { { check_pkg_config libmfx "libmfx < 2.0" "mfx/mfx "multi-frame encode, user plugins and LA_EXT rate control mode are enabled"; } if enabled libmfx; then - check_cc MFX_CODEC_VP9 "mfx/mfxvp9.h mfx/mfxstructures.h" "MFX_CODEC_VP9" + check_cc MFX_CODEC_VP9 "mfx/mfxdefs.h mfx/mfxstructures.h" "MFX_CODEC_VP9" fi enabled libmodplug && require_pkg_config libmodplug libmodplug libmodplug/modplug.h ModPlug_Load From patchwork Mon Aug 16 07:33:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xiang, Haihao" X-Patchwork-Id: 29557 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2a4a:0:0:0:0 with SMTP id k10csp1799941iov; Mon, 16 Aug 2021 00:34:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxWVNFpbajsCzwkExpRyLeON4AePfeEAOiAISZ6TdH9jEOHxY8DQOfTilYz/jxSEwU63jtf X-Received: by 2002:a17:906:7246:: with SMTP id n6mr14650233ejk.94.1629099290296; Mon, 16 Aug 2021 00:34:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629099290; cv=none; d=google.com; s=arc-20160816; b=02FpQ97RlZl+WAF200gJ0aQNMaAUOrWsAQsiEWMyOGO9+PwRrrDpAfPcQcjK/qbr/P oarJMKD/ZMwq6FscT878nkGFQqTDoQJDcIpKr7oDlM0mOA37H/xkOoIpQrS30LkPNg05 a1YsX61tR3vjx6dipeiPQl9I2VVc3tTYn8jsDKghl7TUFPuuAeY/1MV9zA+fNvwlt8sR P0uByzOL0p6eX2gszwiGLaJ5aWs9v+W/UqOsIywxQeikc+av5pX/dAqCpXk3KsyqyyqG 2q9ii49N3e9lOX5wDqKH5SJaeCLoL/sFIsPwRkeEGB7hrnGKAfYN/d/bF7BEjxiiRFBK OLtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:delivered-to; bh=6UzrD+W6RJot24X8iemdAnssf/TexNhaZhBbdYEnO0s=; b=Meq49nWezojbHreNYcolsZPJuZBO96W8PBrygpwgpTTGJj0zC5SgIki9YPVspcs7zw ViT6wdIH0nes64BGpYHtdSbr9FL7nmelfVMHghoU+jHh6I1KFyi2xxg5ARM2IFyXSS+F eVKPz5dwbsqDqfpQ82xOuDyLGIvizkrDN9FbtPDJ/6/mGlqhGz2cfHCy1jpemfdxN1t0 TOuKOne2nAmBs4dcdd/ioHOp7iiX3KbpLth/iNpKMCxOPe/Ux5pFxARbqgDoOxoJIUnU EDG+DvHhcNBl3w0xKR0JHYp73pkURlCBq1hCh5MweKd+n2MbuoJ71JVnes9cjVe8mro+ HqUQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id n26si9305498edr.521.2021.08.16.00.34.50; Mon, 16 Aug 2021 00:34:50 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1026268A5FC; Mon, 16 Aug 2021 10:34:00 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E504468A59F for ; Mon, 16 Aug 2021 10:33:49 +0300 (EEST) X-IronPort-AV: E=McAfee;i="6200,9189,10077"; a="203011865" X-IronPort-AV: E=Sophos;i="5.84,324,1620716400"; d="scan'208";a="203011865" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Aug 2021 00:33:42 -0700 X-IronPort-AV: E=Sophos;i="5.84,324,1620716400"; d="scan'208";a="519461838" Received: from xhh-dg164.sh.intel.com ([10.239.159.167]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Aug 2021 00:33:41 -0700 From: Haihao Xiang To: ffmpeg-devel@ffmpeg.org Date: Mon, 16 Aug 2021 15:33:18 +0800 Message-Id: <20210816073325.27020-4-haihao.xiang@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210816073325.27020-1-haihao.xiang@intel.com> References: <20210816073325.27020-1-haihao.xiang@intel.com> Subject: [FFmpeg-devel] [PATCH v2 03/10] qsv: remove mfx/ prefix from mfx headers 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: RQMQRiJT33wL The following Cflags has been added to libmfx.pc, so mfx/ prefix is no longer needed when including mfx headers in FFmpeg. Cflags: -I${includedir} -I${includedir}/mfx Some old versions of libmfx have the following Cflags in libmfx.pc Cflags: -I${includedir} We may add -I${includedir}/mfx to CFLAGS when running 'configure --enable-libmfx' for old versions of libmfx, if so, mfx headers without mfx/ prefix can be included too. If libmfx comes without pkg-config support, we may do a small change to the settings of the environment(e.g. set -I/opt/intel/mediasdk/include/mfx instead of -I/opt/intel/mediasdk/include to CFLAGS), then the build can find the mfx headers without mfx/ prefix After applying this change, we won't need to change #include for mfx headers when mfx headers are installed under a new directory. This is in preparation for oneVPL support (mfx headers in oneVPL are installed under vpl directory) --- configure | 13 +++++++++---- libavcodec/qsv.c | 8 ++++---- libavcodec/qsv.h | 2 +- libavcodec/qsv_internal.h | 2 +- libavcodec/qsvdec.c | 2 +- libavcodec/qsvenc.c | 2 +- libavcodec/qsvenc.h | 2 +- libavcodec/qsvenc_h264.c | 2 +- libavcodec/qsvenc_hevc.c | 2 +- libavcodec/qsvenc_jpeg.c | 2 +- libavcodec/qsvenc_mpeg2.c | 2 +- libavcodec/qsvenc_vp9.c | 2 +- libavfilter/qsvvpp.h | 2 +- libavfilter/vf_deinterlace_qsv.c | 2 +- libavfilter/vf_scale_qsv.c | 2 +- libavutil/hwcontext_opencl.c | 2 +- libavutil/hwcontext_qsv.c | 2 +- libavutil/hwcontext_qsv.h | 2 +- 18 files changed, 29 insertions(+), 24 deletions(-) diff --git a/configure b/configure index b10a7b5a52..d3c0f63f85 100755 --- a/configure +++ b/configure @@ -6436,13 +6436,18 @@ enabled liblensfun && require_pkg_config liblensfun lensfun lensfun.h lf_ # Media SDK or Intel Media Server Studio, these don't come with # pkg-config support. Instead, users should make sure that the build # can find the libraries and headers through other means. -enabled libmfx && { { check_pkg_config libmfx "libmfx < 2.0" "mfx/mfxvideo.h" MFXInit || - { require "libmfx < 2.0" "mfx/mfxvideo.h" MFXInit "-llibmfx $advapi32_extralibs" && warn "using libmfx without pkg-config"; } } && + +enabled libmfx && { { check_pkg_config libmfx "libmfx < 2.0" "mfxvideo.h" MFXInit || +# Some old versions of libmfx have the following settings in libmfx.pc: +# includedir=/usr/include +# Cflags: -I${includedir} +# So add -I${includedir}/mfx to CFLAGS + { check_pkg_config libmfx "libmfx < 2.0" "mfx/mfxvideo.h" MFXInit && add_cflags -I$($pkg_config --variable=includedir libmfx)/mfx; } || + { require "libmfx < 2.0" "mfxvideo.h" MFXInit "-llibmfx $advapi32_extralibs" && warn "using libmfx without pkg-config"; } } && warn "build FFmpeg against libmfx 1.x, obsolete features of libmfx such as OPAQUE memory,\n"\ "multi-frame encode, user plugins and LA_EXT rate control mode are enabled"; } - if enabled libmfx; then - check_cc MFX_CODEC_VP9 "mfx/mfxdefs.h mfx/mfxstructures.h" "MFX_CODEC_VP9" + check_cc MFX_CODEC_VP9 "mfxdefs.h mfxstructures.h" "MFX_CODEC_VP9" fi enabled libmodplug && require_pkg_config libmodplug libmodplug libmodplug/modplug.h ModPlug_Load diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c index c53e2e3b07..93cd4892dc 100644 --- a/libavcodec/qsv.c +++ b/libavcodec/qsv.c @@ -18,9 +18,9 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include -#include -#include +#include +#include +#include #include #include @@ -37,7 +37,7 @@ #include "qsv_internal.h" #if QSV_VERSION_ATLEAST(1, 12) -#include "mfx/mfxvp8.h" +#include "mfxvp8.h" #endif int ff_qsv_codec_id_to_mfx(enum AVCodecID codec_id) diff --git a/libavcodec/qsv.h b/libavcodec/qsv.h index b77158ec26..04ae0d6f34 100644 --- a/libavcodec/qsv.h +++ b/libavcodec/qsv.h @@ -21,7 +21,7 @@ #ifndef AVCODEC_QSV_H #define AVCODEC_QSV_H -#include +#include #include "libavutil/buffer.h" diff --git a/libavcodec/qsv_internal.h b/libavcodec/qsv_internal.h index 327a8d3385..3eed35c13a 100644 --- a/libavcodec/qsv_internal.h +++ b/libavcodec/qsv_internal.h @@ -39,7 +39,7 @@ #include "libavutil/hwcontext_vaapi.h" #endif -#include +#include #include "libavutil/frame.h" diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c index 8bce9f2cf0..1cadb846f5 100644 --- a/libavcodec/qsvdec.c +++ b/libavcodec/qsvdec.c @@ -25,7 +25,7 @@ #include #include -#include +#include #include "libavutil/common.h" #include "libavutil/fifo.h" diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index 50ec7065ca..b561e20971 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -23,7 +23,7 @@ #include #include -#include +#include #include "libavutil/common.h" #include "libavutil/hwcontext.h" diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h index 31516b8e55..7a71ffe98f 100644 --- a/libavcodec/qsvenc.h +++ b/libavcodec/qsvenc.h @@ -26,7 +26,7 @@ #include #include -#include +#include #include "libavutil/avutil.h" #include "libavutil/fifo.h" diff --git a/libavcodec/qsvenc_h264.c b/libavcodec/qsvenc_h264.c index 80fe3cc280..9134e6a68c 100644 --- a/libavcodec/qsvenc_h264.c +++ b/libavcodec/qsvenc_h264.c @@ -24,7 +24,7 @@ #include #include -#include +#include #include "libavutil/common.h" #include "libavutil/opt.h" diff --git a/libavcodec/qsvenc_hevc.c b/libavcodec/qsvenc_hevc.c index b7b2f5633e..a268a002d6 100644 --- a/libavcodec/qsvenc_hevc.c +++ b/libavcodec/qsvenc_hevc.c @@ -22,7 +22,7 @@ #include #include -#include +#include #include "libavutil/common.h" #include "libavutil/opt.h" diff --git a/libavcodec/qsvenc_jpeg.c b/libavcodec/qsvenc_jpeg.c index dd082692be..ad8f09befe 100644 --- a/libavcodec/qsvenc_jpeg.c +++ b/libavcodec/qsvenc_jpeg.c @@ -22,7 +22,7 @@ #include #include -#include +#include #include "libavutil/common.h" #include "libavutil/opt.h" diff --git a/libavcodec/qsvenc_mpeg2.c b/libavcodec/qsvenc_mpeg2.c index 525df99e50..610bbf79c1 100644 --- a/libavcodec/qsvenc_mpeg2.c +++ b/libavcodec/qsvenc_mpeg2.c @@ -22,7 +22,7 @@ #include #include -#include +#include #include "libavutil/common.h" #include "libavutil/opt.h" diff --git a/libavcodec/qsvenc_vp9.c b/libavcodec/qsvenc_vp9.c index 9329990d11..0a382eb76d 100644 --- a/libavcodec/qsvenc_vp9.c +++ b/libavcodec/qsvenc_vp9.c @@ -22,7 +22,7 @@ #include #include -#include +#include #include "libavutil/common.h" #include "libavutil/opt.h" diff --git a/libavfilter/qsvvpp.h b/libavfilter/qsvvpp.h index e0f4c8f5bb..8c0cf3ed95 100644 --- a/libavfilter/qsvvpp.h +++ b/libavfilter/qsvvpp.h @@ -24,7 +24,7 @@ #ifndef AVFILTER_QSVVPP_H #define AVFILTER_QSVVPP_H -#include +#include #include "avfilter.h" #include "libavutil/fifo.h" diff --git a/libavfilter/vf_deinterlace_qsv.c b/libavfilter/vf_deinterlace_qsv.c index 06c4c5e2df..ba04b11e50 100644 --- a/libavfilter/vf_deinterlace_qsv.c +++ b/libavfilter/vf_deinterlace_qsv.c @@ -21,7 +21,7 @@ * deinterlace video filter - QSV */ -#include +#include #include #include diff --git a/libavfilter/vf_scale_qsv.c b/libavfilter/vf_scale_qsv.c index 2f3afa6ace..8fcb07cec9 100644 --- a/libavfilter/vf_scale_qsv.c +++ b/libavfilter/vf_scale_qsv.c @@ -21,7 +21,7 @@ * scale video filter - QSV */ -#include +#include #include #include diff --git a/libavutil/hwcontext_opencl.c b/libavutil/hwcontext_opencl.c index 41fac43229..fa72d9920b 100644 --- a/libavutil/hwcontext_opencl.c +++ b/libavutil/hwcontext_opencl.c @@ -47,7 +47,7 @@ #if HAVE_OPENCL_VAAPI_INTEL_MEDIA #if CONFIG_LIBMFX -#include +#include #endif #include #include diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c index 08a6e0ee1c..cd7fe72109 100644 --- a/libavutil/hwcontext_qsv.c +++ b/libavutil/hwcontext_qsv.c @@ -19,7 +19,7 @@ #include #include -#include +#include #include "config.h" diff --git a/libavutil/hwcontext_qsv.h b/libavutil/hwcontext_qsv.h index b98d611cfc..42e34d0dda 100644 --- a/libavutil/hwcontext_qsv.h +++ b/libavutil/hwcontext_qsv.h @@ -19,7 +19,7 @@ #ifndef AVUTIL_HWCONTEXT_QSV_H #define AVUTIL_HWCONTEXT_QSV_H -#include +#include /** * @file From patchwork Mon Aug 16 07:33:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xiang, Haihao" X-Patchwork-Id: 29556 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2a4a:0:0:0:0 with SMTP id k10csp1800499iov; Mon, 16 Aug 2021 00:35:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyzUNHSrBU61PTt4SOE4NSfEMFupT6RPMHVa7qQG40JpM5HdDY31Fmy9AP5YcCbxgPeOuNF X-Received: by 2002:a17:906:1289:: with SMTP id k9mr11228028ejb.2.1629099343419; Mon, 16 Aug 2021 00:35:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629099343; cv=none; d=google.com; s=arc-20160816; b=c19k6oXe4fqjnD+GlxjhsTaUy42Czy5Nd77e5egBJdJ4+SD8j0qYJON7t734Y89blz dHN66fgpKgsR6ZeupHKP+PiIOUOm7HYV+0ApxHSSO+FVDldtEF9ugpqb07lEqJyRV6PI XU0ioBRxv+bvxpPqpJkjK4eK4u1eb//tpmcR7u9ioLR6HYGUyU1JE1MJg+keoFUgUzjA K8e8quOkqfap2KBpHiljGplupEoTSAi9yBM+7l0IVAb3U7nDFHw9x1fsP62veNaedoFd 65YXTBhsoG6esm64fZxF8+J2qp0Jw2FE3W+28WeVVWEUkU1c363aBYvkkIFMzJXTLKUu NUZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:delivered-to; bh=5LIrUxL9A3PXtypjRTDdLJO/WcV5ySqun/Dc+VzW5TQ=; b=oMf/AB7h6/LeTN956hgJ5mrmU1E45axSsieBl5XMHWLARYpkRcz1bRizVxJplzKN2g xz0Ku+c6W86dAx2SgKm5csrT/XWraPZ4X+DzXsfC/8XuW1anpEcNFP+585pA5aMbuDe8 VZCu2aXPterC1iIdpEGuZLME9rLdD+Nt+fnyRisyaj0d6u7YqwyDsNyr0WtCcytYX63J s52q99DuLltRQzxFi1f+srSdHTB6mQfKnKkWnHvp7MHoqjD+jBZXylg4DgzZ11mJkfR9 rMMpwhDfQolacGvA3w828bBS2WuaynO+2Ykj/ak/8eFPr4niOCdoTU/7gjXcQ89iijYQ ViEQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id f17si9856233ejz.260.2021.08.16.00.35.43; Mon, 16 Aug 2021 00:35:43 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6B53668A64A; Mon, 16 Aug 2021 10:34:05 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1DA0068A5F6 for ; Mon, 16 Aug 2021 10:33:52 +0300 (EEST) X-IronPort-AV: E=McAfee;i="6200,9189,10077"; a="203011869" X-IronPort-AV: E=Sophos;i="5.84,324,1620716400"; d="scan'208";a="203011869" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Aug 2021 00:33:44 -0700 X-IronPort-AV: E=Sophos;i="5.84,324,1620716400"; d="scan'208";a="519461844" Received: from xhh-dg164.sh.intel.com ([10.239.159.167]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Aug 2021 00:33:43 -0700 From: Haihao Xiang To: ffmpeg-devel@ffmpeg.org Date: Mon, 16 Aug 2021 15:33:19 +0800 Message-Id: <20210816073325.27020-5-haihao.xiang@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210816073325.27020-1-haihao.xiang@intel.com> References: <20210816073325.27020-1-haihao.xiang@intel.com> Subject: [FFmpeg-devel] [PATCH v2 04/10] qsv: load user plugin for MFX_VERSION < 2.0 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: J93YaQWTNi8H User plugin isn't supported for MFX_VERSION >= 2.0[1][2]. This is in preparation for oneVPL Support [1]: https://spec.oneapi.io/versions/latest/elements/oneVPL/source/appendix/VPL_intel_media_sdk.html#msdk-full-name-feature-removals [2]: https://github.com/oneapi-src/oneVPL --- libavcodec/qsv.c | 9 ++++++++- libavcodec/qsv_internal.h | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c index 93cd4892dc..8ac2293b57 100644 --- a/libavcodec/qsv.c +++ b/libavcodec/qsv.c @@ -19,7 +19,6 @@ */ #include -#include #include #include @@ -36,10 +35,16 @@ #include "avcodec.h" #include "qsv_internal.h" +#define QSV_HAVE_USER_PLUGIN !QSV_ONEVPL + #if QSV_VERSION_ATLEAST(1, 12) #include "mfxvp8.h" #endif +#if QSV_HAVE_USER_PLUGIN +#include +#endif + int ff_qsv_codec_id_to_mfx(enum AVCodecID codec_id) { switch (codec_id) { @@ -286,6 +291,7 @@ enum AVPictureType ff_qsv_map_pictype(int mfx_pic_type) static int qsv_load_plugins(mfxSession session, const char *load_plugins, void *logctx) { +#if QSV_HAVE_USER_PLUGIN if (!load_plugins || !*load_plugins) return 0; @@ -329,6 +335,7 @@ load_plugin_fail: if (err < 0) return err; } +#endif return 0; diff --git a/libavcodec/qsv_internal.h b/libavcodec/qsv_internal.h index 3eed35c13a..10114f1c00 100644 --- a/libavcodec/qsv_internal.h +++ b/libavcodec/qsv_internal.h @@ -60,6 +60,8 @@ ((MFX_VERSION.Major > (MAJOR)) || \ (MFX_VERSION.Major == (MAJOR) && MFX_VERSION.Minor >= (MINOR))) +#define QSV_ONEVPL QSV_VERSION_ATLEAST(2, 0) + typedef struct QSVMid { AVBufferRef *hw_frames_ref; mfxHDL handle; From patchwork Mon Aug 16 07:33:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xiang, Haihao" X-Patchwork-Id: 29553 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2a4a:0:0:0:0 with SMTP id k10csp1799603iov; Mon, 16 Aug 2021 00:34:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyTBkJrgMQzMJ4ymuJKhPaft2XGM/JPw7QJYmIa5eCokFKIZUoni+Co5iDGnGE4OqNdjsdb X-Received: by 2002:a17:907:35d0:: with SMTP id ap16mr14707873ejc.456.1629099259608; Mon, 16 Aug 2021 00:34:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629099259; cv=none; d=google.com; s=arc-20160816; b=p+99fFZ45iUBUQb7DrXyQezEG3XkhJLD7hyovbS+AwkvxfErIodbJ1lLl9+QltcYDJ dTAKFY/+FTlEQzVu1qAsR7oYrLrDLDiek/auNHEte0bJGXnRNE+ed+sSp4XPjg2mFuy2 2cAXeu0CWsvp/V7dEiG4HLCbHxKHFvWB/O7FcfdMrX1cTjuGvbC05bfwOpLX8giHDMi1 YH08OmYY5l33OR3UFhNA4WVQ8xI2usU9KF+7gw0nmOblUVpyGkjqo+I8RIlQG4Crp39d +AeA2/O/EY9qY6KeNBrK2Tiy7tOUr4qxhBCZtnMdssYYJxGKzunEV4763OS0nB7jukfc spGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:delivered-to; bh=IqSQCrPOyOvszFzK+0O9cghkJx/uqE9RMqnl3bR+hDY=; b=mjeOlgXb3rX0MXRSIZhyK3M1OyfU7qw4ZneouNxemv/wLKRD9ryszstLCNiPi51S8u qfTPDCtAno8QRh5+1+UYPTdpCslncup9ERsbm0+AUtc1uZDemqnuyRVvjYDrH4hhSdLv xF3wSD+fFOJ95e46ob7NSaHeo8IWoH71YLBlKeFBkutHrJNxID4uj5In/8Hv8VJvVNBo eHCyYPQ3fJgqty7I/idhR9nqqmHd+n1Dd4z7ZwsXvaYTNTrgjRvO5D4HwkFx/iG/aMNo mvgNZlh/U49TOqA39y4njqzyxjWfLYHmlde5h3gXiwMGTsNfkuso8DgiiMxBZl7vGBIA eppg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id e10si1109962edz.275.2021.08.16.00.34.19; Mon, 16 Aug 2021 00:34:19 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 00B9268A5A2; Mon, 16 Aug 2021 10:33:55 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7929468092F for ; Mon, 16 Aug 2021 10:33:47 +0300 (EEST) X-IronPort-AV: E=McAfee;i="6200,9189,10077"; a="215841330" X-IronPort-AV: E=Sophos;i="5.84,324,1620716400"; d="scan'208";a="215841330" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Aug 2021 00:33:45 -0700 X-IronPort-AV: E=Sophos;i="5.84,324,1620716400"; d="scan'208";a="519461857" Received: from xhh-dg164.sh.intel.com ([10.239.159.167]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Aug 2021 00:33:44 -0700 From: Haihao Xiang To: ffmpeg-devel@ffmpeg.org Date: Mon, 16 Aug 2021 15:33:20 +0800 Message-Id: <20210816073325.27020-6-haihao.xiang@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210816073325.27020-1-haihao.xiang@intel.com> References: <20210816073325.27020-1-haihao.xiang@intel.com> Subject: [FFmpeg-devel] [PATCH v2 05/10] qsv: build audio related code when MFX_VERSION < 2.0 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: F0SsYyCbsO4y Audio isn't supported for MFX_VERSION >= 2.0[1][2]. This is in preparation for oneVPL support [1]: https://spec.oneapi.io/versions/latest/elements/oneVPL/source/appendix/VPL_intel_media_sdk.html#msdk-full-name-feature-removals [2]: https://github.com/oneapi-src/oneVPL --- libavcodec/qsv.c | 5 +++++ libavfilter/qsvvpp.c | 6 ++++++ libavfilter/qsvvpp.h | 2 ++ 3 files changed, 13 insertions(+) diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c index 8ac2293b57..b1d50f8999 100644 --- a/libavcodec/qsv.c +++ b/libavcodec/qsv.c @@ -36,6 +36,7 @@ #include "qsv_internal.h" #define QSV_HAVE_USER_PLUGIN !QSV_ONEVPL +#define QSV_HAVE_AUDIO !QSV_ONEVPL #if QSV_VERSION_ATLEAST(1, 12) #include "mfxvp8.h" @@ -136,8 +137,10 @@ static const struct { { MFX_ERR_INVALID_VIDEO_PARAM, AVERROR(EINVAL), "invalid video parameters" }, { MFX_ERR_UNDEFINED_BEHAVIOR, AVERROR_BUG, "undefined behavior" }, { MFX_ERR_DEVICE_FAILED, AVERROR(EIO), "device failed" }, +#if QSV_HAVE_AUDIO { MFX_ERR_INCOMPATIBLE_AUDIO_PARAM, AVERROR(EINVAL), "incompatible audio parameters" }, { MFX_ERR_INVALID_AUDIO_PARAM, AVERROR(EINVAL), "invalid audio parameters" }, +#endif { MFX_WRN_IN_EXECUTION, 0, "operation in execution" }, { MFX_WRN_DEVICE_BUSY, 0, "device busy" }, @@ -147,7 +150,9 @@ static const struct { { MFX_WRN_VALUE_NOT_CHANGED, 0, "value is saturated" }, { MFX_WRN_OUT_OF_RANGE, 0, "value out of range" }, { MFX_WRN_FILTER_SKIPPED, 0, "filter skipped" }, +#if QSV_HAVE_AUDIO { MFX_WRN_INCOMPATIBLE_AUDIO_PARAM, 0, "incompatible audio parameters" }, +#endif }; int ff_qsv_map_error(mfxStatus mfx_err, const char **desc) diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c index c7ef8a915f..73fcfecb46 100644 --- a/libavfilter/qsvvpp.c +++ b/libavfilter/qsvvpp.c @@ -37,6 +37,8 @@ #define IS_OPAQUE_MEMORY(mode) (mode & MFX_MEMTYPE_OPAQUE_FRAME) #define IS_SYSTEM_MEMORY(mode) (mode & MFX_MEMTYPE_SYSTEM_MEMORY) +#define QSV_HAVE_AUDIO !QSV_ONEVPL + static const mfxHandleType handle_types[] = { MFX_HANDLE_VA_DISPLAY, MFX_HANDLE_D3D9_DEVICE_MANAGER, @@ -100,8 +102,10 @@ static const struct { { MFX_ERR_INVALID_VIDEO_PARAM, AVERROR(EINVAL), "invalid video parameters" }, { MFX_ERR_UNDEFINED_BEHAVIOR, AVERROR_BUG, "undefined behavior" }, { MFX_ERR_DEVICE_FAILED, AVERROR(EIO), "device failed" }, +#if QSV_HAVE_AUDIO { MFX_ERR_INCOMPATIBLE_AUDIO_PARAM, AVERROR(EINVAL), "incompatible audio parameters" }, { MFX_ERR_INVALID_AUDIO_PARAM, AVERROR(EINVAL), "invalid audio parameters" }, +#endif { MFX_WRN_IN_EXECUTION, 0, "operation in execution" }, { MFX_WRN_DEVICE_BUSY, 0, "device busy" }, @@ -111,7 +115,9 @@ static const struct { { MFX_WRN_VALUE_NOT_CHANGED, 0, "value is saturated" }, { MFX_WRN_OUT_OF_RANGE, 0, "value out of range" }, { MFX_WRN_FILTER_SKIPPED, 0, "filter skipped" }, +#if QSV_HAVE_AUDIO { MFX_WRN_INCOMPATIBLE_AUDIO_PARAM, 0, "incompatible audio parameters" }, +#endif }; static int qsv_map_error(mfxStatus mfx_err, const char **desc) diff --git a/libavfilter/qsvvpp.h b/libavfilter/qsvvpp.h index 8c0cf3ed95..46e90c1d2c 100644 --- a/libavfilter/qsvvpp.h +++ b/libavfilter/qsvvpp.h @@ -40,6 +40,8 @@ ((MFX_VERSION.Major > (MAJOR)) || \ (MFX_VERSION.Major == (MAJOR) && MFX_VERSION.Minor >= (MINOR))) +#define QSV_ONEVPL QSV_VERSION_ATLEAST(2, 0) + typedef struct QSVFrame { AVFrame *frame; mfxFrameSurface1 surface; From patchwork Mon Aug 16 07:33:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xiang, Haihao" X-Patchwork-Id: 29555 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2a4a:0:0:0:0 with SMTP id k10csp1799826iov; Mon, 16 Aug 2021 00:34:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwbtNmanPPFv7icgMlkTNjmMjW/pollqwYelmTfwm8WjwrSLQ3EmZZV3VgBSHQ+NgsXdgY7 X-Received: by 2002:a05:6402:5:: with SMTP id d5mr18346075edu.359.1629099279914; Mon, 16 Aug 2021 00:34:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629099279; cv=none; d=google.com; s=arc-20160816; b=AB2pAnrtM0XlvmBk33NkF0ELHzp+Ie9aXx62Kw6fNSNwXiGO9Qs10Y5ecB6pyMZKLw 7Q9lAPACYMam2VI0vibzugF/7KI66YklOsSolJxRM5tEIa3HopIuLVQ5gdP+syEDv2PW D2oRAocTHXRq141KdKUY1o97zWLJ7LLGsQhjxUBBNqHquS9AB7vIEL69kF7+7rjO3yPB MuAsqEFLwgL0K2cYJYdlkpcFnb4nVYDBhCAFgaUneNFxTJweT19chxbT5vI4v7MgflrN VNTCdlS2xYb5oi/71KSXC5rxv/PTOCM30mMGbYJceDv84zDxIbJjGe63zi862cLDXsO4 KomA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:delivered-to; bh=fm8XtoUhMarykFo7b/qESK8aANSZJrtBHk/zHF+G/ko=; b=j+j4+cIsK3DSYya6aWGKu+sqexoHESwQbr/lGmASCL24YeISivX5DRPv0nMrZYaoKW aI4ZMA0P1MrDE9iF2jQe8pwWTEUBE/sK3BjsKPH5MKVtbh8NVDfuJus2zsjl7sBxgWkq TDoOLi4Uh9ixQICa5uKchzpXdURZJ7veTB/FBgxKLYtrTtwwFj7TRK69Cf2/kLNqUwIS qvm8KK7CORH9P6o2qQ5HawVWHZ8jMuAs8lcma5mIt/Zz1VjtXTuBT3Auf5ToIo6vRn1v xkGcnQGC+FNpMuXrMxoYn9l+ujTR062AZ73jjB6rXo9PufLABGV3JwiJobfR6ZDGY+1v q+Iw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id h4si10923371edt.426.2021.08.16.00.34.39; Mon, 16 Aug 2021 00:34:39 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id F2A0368A5F6; Mon, 16 Aug 2021 10:33:58 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4DFB168092F for ; Mon, 16 Aug 2021 10:33:48 +0300 (EEST) X-IronPort-AV: E=McAfee;i="6200,9189,10077"; a="279553916" X-IronPort-AV: E=Sophos;i="5.84,324,1620716400"; d="scan'208";a="279553916" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Aug 2021 00:33:46 -0700 X-IronPort-AV: E=Sophos;i="5.84,324,1620716400"; d="scan'208";a="519461870" Received: from xhh-dg164.sh.intel.com ([10.239.159.167]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Aug 2021 00:33:45 -0700 From: Haihao Xiang To: ffmpeg-devel@ffmpeg.org Date: Mon, 16 Aug 2021 15:33:21 +0800 Message-Id: <20210816073325.27020-7-haihao.xiang@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210816073325.27020-1-haihao.xiang@intel.com> References: <20210816073325.27020-1-haihao.xiang@intel.com> Subject: [FFmpeg-devel] [PATCH v2 06/10] qsvenc: support multi-frame encode when MFX_VERSION < 2.0 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: q+Bsl2ozQUk3 Multi-frame encode isn't supported for MFX_VERSION >= 2.0[1][2]. This is in preparation for oneVPL support [1]: https://spec.oneapi.io/versions/latest/elements/oneVPL/source/appendix/VPL_intel_media_sdk.html#msdk-full-name-feature-removals [2]: https://github.com/oneapi-src/oneVPL --- libavcodec/qsvenc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h index 7a71ffe98f..93af4d1198 100644 --- a/libavcodec/qsvenc.h +++ b/libavcodec/qsvenc.h @@ -64,7 +64,7 @@ #define QSV_HAVE_ICQ QSV_VERSION_ATLEAST(1, 28) #define QSV_HAVE_VCM 0 #define QSV_HAVE_QVBR QSV_VERSION_ATLEAST(1, 28) -#define QSV_HAVE_MF QSV_VERSION_ATLEAST(1, 25) +#define QSV_HAVE_MF QSV_VERSION_ATLEAST(1, 25) && !QSV_ONEVPL #endif #if !QSV_HAVE_LA_DS From patchwork Mon Aug 16 07:33:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xiang, Haihao" X-Patchwork-Id: 29558 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2a4a:0:0:0:0 with SMTP id k10csp1800057iov; Mon, 16 Aug 2021 00:35:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwfbP5j6Q57Kj1Iws3SyGabjZjtE91j3SBSgsiqP3+4Z3FWmqIxVgA+CtDUr0csZD17KR+C X-Received: by 2002:a17:907:1199:: with SMTP id uz25mr14736411ejb.448.1629099300485; Mon, 16 Aug 2021 00:35:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629099300; cv=none; d=google.com; s=arc-20160816; b=M/R7SXjb7oiPQKNHhEEo37Zjd6w8FfNsCLJChLfqXu0G5dJ+sRiBZ87ju9nAnlO64o 3l+UFDdxn90N0WjDr3Yj45OUQu831kYB6lUqnhcaY24djrmamVf2HmhJfd4ZC+QJ8sLA uljnwZDS8G2XoIsASucDmBFItbQ78y3QN2pbjw8Z5/mTKDwuBJoeZC0TUWwU21yFsKit m/u5TgqkLG6zwFCrN4JVq9ZiQXrdyDUV+LxUPntWMyLw8SxEkanFACaR7sWljeZvQ2y+ Afg8bubT4S4+y/bUioDTBJZAFoY8WWrXU+Jzym/CHU9x/jDuU5bJnwjTtE3y+8L+NOXo xrTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:delivered-to; bh=ANxRg9jDAYhlzmzDM6L4C2dUfOx21LTkqKYpewBg32M=; b=YbYrc587lwhNYS9G3M8HsxOln4CQLD8D6iKojfHm8CyExd8WU8nDtWnVT+b8Dta72X c3pRhCWFnNzYv7rSVFKgkdNYolR7/vQQTdd0s6pchUGl9x8Tfjt+neMP1AuPP7N4STOo sSZYMfv8AppwftcfR8qPQPz5K+1Dn3vsVjBdvmDJWn8AZjfw/i8qmyB97sgQ3xZTK5Zf HujQ5SkCO2Ienlr9j4dDTes0AZLaBt55D100txfsyRtLpTbEeO5C8nzAHFq+CDmD4jsT 2Wu3L+pMc+tvblUOYuQ8RUtPC3GVWXPSkBmnUXiFV9BtFVfydPoO7N5VoJBP8zU3PIGf MoHA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id lk15si9484384ejb.563.2021.08.16.00.35.00; Mon, 16 Aug 2021 00:35:00 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 21CCC68A61A; Mon, 16 Aug 2021 10:34:01 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0AD2368A5AA for ; Mon, 16 Aug 2021 10:33:54 +0300 (EEST) X-IronPort-AV: E=McAfee;i="6200,9189,10077"; a="279553919" X-IronPort-AV: E=Sophos;i="5.84,324,1620716400"; d="scan'208";a="279553919" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Aug 2021 00:33:47 -0700 X-IronPort-AV: E=Sophos;i="5.84,324,1620716400"; d="scan'208";a="519461876" Received: from xhh-dg164.sh.intel.com ([10.239.159.167]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Aug 2021 00:33:46 -0700 From: Haihao Xiang To: ffmpeg-devel@ffmpeg.org Date: Mon, 16 Aug 2021 15:33:22 +0800 Message-Id: <20210816073325.27020-8-haihao.xiang@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210816073325.27020-1-haihao.xiang@intel.com> References: <20210816073325.27020-1-haihao.xiang@intel.com> Subject: [FFmpeg-devel] [PATCH v2 07/10] qsvenc: support MFX_RATECONTROL_LA_EXT when MFX_VERSION < 2.0 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: UmJxYTKD07my MFX_RATECONTROL_LA_EXT isn't supported for MFX_VERSION >= 2.0[1][2]. This is in preparation for oneVPL support [1]: https://spec.oneapi.io/versions/latest/elements/oneVPL/source/appendix/VPL_intel_media_sdk.html#msdk-full-name-feature-removals [2]: https://github.com/oneapi-src/oneVPL --- libavcodec/qsvenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index b561e20971..542eaca7a4 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -100,7 +100,7 @@ static const struct { #if QSV_HAVE_VCM { MFX_RATECONTROL_VCM, "VCM" }, #endif -#if QSV_VERSION_ATLEAST(1, 10) +#if QSV_VERSION_ATLEAST(1, 10) && !QSV_ONEVPL { MFX_RATECONTROL_LA_EXT, "LA_EXT" }, #endif #if QSV_HAVE_LA_HRD From patchwork Mon Aug 16 07:33:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xiang, Haihao" X-Patchwork-Id: 29552 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2a4a:0:0:0:0 with SMTP id k10csp1800176iov; Mon, 16 Aug 2021 00:35:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyNYu4AkUjaryNu5V5KXFWQNVMcmyF3DTJdUTGjYAAZw+k7eLb3K5s9y1ere10oqRlxS6fy X-Received: by 2002:a17:907:2cf0:: with SMTP id hz16mr14650242ejc.466.1629099310304; Mon, 16 Aug 2021 00:35:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629099310; cv=none; d=google.com; s=arc-20160816; b=WmJsnhxQcTAkmK+5IS8TBoAw9Z/GG45mOv1ORz1Z614TGalNDrkz5moEgQJ7q6NCqZ 4JKHJ7Rw8d7Qr+5ljrcBo49JVFJIi24cFIGpb2jrOL27LV9qwdqi4SNgMsfecos5UYUt 8rGpXMRqkWhJ4MOncxMootpurwH4Av+3ayRz67YQy5LDpP5PpMBNbduteGicVO1sBw7v 06IQqpWuI+s9DJnKAxmNdC/g/tmE0rnkwNW6+XNSlBRlZpYPJkPx7YJvOWcStDAmL+uy Gek3jH56TUBGiaezUNy6yI8ogcjJxWDSbBJ417KeSG4tWWk7vgCDd3m3wjKPAdZM3++p CSlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:delivered-to; bh=VJ9vkh5NHpN8TKqXzGTfe/YbBPg3UebLKq9F4JiR6/4=; b=PwsDtWG9eMcmVB6YpG2uRYGmX80EOdhcJEkJVdC7bNoEXHbgJH5JF8i6rxed2YF89q u5CdouS3wCa+SXR0+X9UvyYT6NmyyUaS05gYdjGPATtKDKdX7Hd6QIISEqZwMXfwW4cM 67A0yiBeFetx8cDxZEaYCbNKRL0+ex5azbj9Wy8X1rZOZ76hP4GN8zPkGM+PG9J9/pNg VJS4Tv7/l7gjoY6DTmgiGdzkkMKj30jcYflev5TMWfbOWVngU6cZRGeVGx5qe96v+sqN HsP2RpkEhaPhUrJ9nx4HQMN7gMtu4U7Dd63JqJfpRfwzknv2T8LIX70mS2SnRepSBamA 0EhA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id z21si9150689edx.140.2021.08.16.00.35.09; Mon, 16 Aug 2021 00:35:10 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4C13968A60A; Mon, 16 Aug 2021 10:34:02 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 123A468A5AC for ; Mon, 16 Aug 2021 10:33:54 +0300 (EEST) X-IronPort-AV: E=McAfee;i="6200,9189,10077"; a="279553922" X-IronPort-AV: E=Sophos;i="5.84,324,1620716400"; d="scan'208";a="279553922" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Aug 2021 00:33:48 -0700 X-IronPort-AV: E=Sophos;i="5.84,324,1620716400"; d="scan'208";a="519461885" Received: from xhh-dg164.sh.intel.com ([10.239.159.167]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Aug 2021 00:33:47 -0700 From: Haihao Xiang To: ffmpeg-devel@ffmpeg.org Date: Mon, 16 Aug 2021 15:33:23 +0800 Message-Id: <20210816073325.27020-9-haihao.xiang@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210816073325.27020-1-haihao.xiang@intel.com> References: <20210816073325.27020-1-haihao.xiang@intel.com> Subject: [FFmpeg-devel] [PATCH v2 08/10] qsv: support OPAQUE memory when MFX_VERSION < 2.0 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: I90fkNtgW/Dr OPAQUE memory isn't supported for MFX_VERSION >= 2.0[1][2]. This is in preparation for oneVPL support [1]: https://spec.oneapi.io/versions/latest/elements/oneVPL/source/appendix/VPL_intel_media_sdk.html#msdk-full-name-feature-removals [2]: https://github.com/oneapi-src/oneVPL --- libavcodec/qsv.c | 4 ++ libavcodec/qsv.h | 2 + libavcodec/qsv_internal.h | 1 + libavcodec/qsvdec.c | 9 ++++ libavcodec/qsvenc.c | 21 +++++++++ libavcodec/qsvenc.h | 2 + libavfilter/qsvvpp.c | 26 ++++++++++- libavfilter/qsvvpp.h | 3 ++ libavfilter/vf_deinterlace_qsv.c | 56 +++++++++++++----------- libavfilter/vf_scale_qsv.c | 74 ++++++++++++++++++-------------- libavutil/hwcontext_qsv.c | 57 +++++++++++++++++------- 11 files changed, 181 insertions(+), 74 deletions(-) diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c index b1d50f8999..98fc6a92b6 100644 --- a/libavcodec/qsv.c +++ b/libavcodec/qsv.c @@ -88,10 +88,14 @@ static const struct { } qsv_iopatterns[] = { {MFX_IOPATTERN_IN_VIDEO_MEMORY, "input is video memory surface" }, {MFX_IOPATTERN_IN_SYSTEM_MEMORY, "input is system memory surface" }, +#if QSV_HAVE_OPAQUE {MFX_IOPATTERN_IN_OPAQUE_MEMORY, "input is opaque memory surface" }, +#endif {MFX_IOPATTERN_OUT_VIDEO_MEMORY, "output is video memory surface" }, {MFX_IOPATTERN_OUT_SYSTEM_MEMORY, "output is system memory surface" }, +#if QSV_HAVE_OPAQUE {MFX_IOPATTERN_OUT_OPAQUE_MEMORY, "output is opaque memory surface" }, +#endif }; int ff_qsv_print_iopattern(void *log_ctx, int mfx_iopattern, diff --git a/libavcodec/qsv.h b/libavcodec/qsv.h index 04ae0d6f34..c156b08d07 100644 --- a/libavcodec/qsv.h +++ b/libavcodec/qsv.h @@ -61,6 +61,8 @@ typedef struct AVQSVContext { * required by the encoder and the user-provided value nb_opaque_surfaces. * The array of the opaque surfaces will be exported to the caller through * the opaque_surfaces field. + * + * The caller must set this field to zero for oneVPL (MFX_VERSION >= 2.0) */ int opaque_alloc; diff --git a/libavcodec/qsv_internal.h b/libavcodec/qsv_internal.h index 10114f1c00..2afb46167d 100644 --- a/libavcodec/qsv_internal.h +++ b/libavcodec/qsv_internal.h @@ -61,6 +61,7 @@ (MFX_VERSION.Major == (MAJOR) && MFX_VERSION.Minor >= (MINOR))) #define QSV_ONEVPL QSV_VERSION_ATLEAST(2, 0) +#define QSV_HAVE_OPAQUE !QSV_ONEVPL typedef struct QSVMid { AVBufferRef *hw_frames_ref; diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c index 1cadb846f5..9395a1fd9a 100644 --- a/libavcodec/qsvdec.c +++ b/libavcodec/qsvdec.c @@ -171,7 +171,11 @@ static int qsv_init_session(AVCodecContext *avctx, QSVContext *q, mfxSession ses ret = ff_qsv_init_session_frames(avctx, &q->internal_qs.session, &q->frames_ctx, q->load_plugins, +#if QSV_HAVE_OPAQUE q->iopattern == MFX_IOPATTERN_OUT_OPAQUE_MEMORY, +#else + 0, +#endif q->gpu_copy); if (ret < 0) { av_buffer_unref(&q->frames_ctx.hw_frames_ctx); @@ -282,10 +286,15 @@ static int qsv_decode_preinit(AVCodecContext *avctx, QSVContext *q, enum AVPixel AVQSVFramesContext *frames_hwctx = frames_ctx->hwctx; if (!iopattern) { +#if QSV_HAVE_OPAQUE if (frames_hwctx->frame_type & MFX_MEMTYPE_OPAQUE_FRAME) iopattern = MFX_IOPATTERN_OUT_OPAQUE_MEMORY; else if (frames_hwctx->frame_type & MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET) iopattern = MFX_IOPATTERN_OUT_VIDEO_MEMORY; +#else + if (frames_hwctx->frame_type & MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET) + iopattern = MFX_IOPATTERN_OUT_VIDEO_MEMORY; +#endif } } diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index 542eaca7a4..5e600afca4 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -1029,6 +1029,7 @@ static int qsv_retrieve_enc_params(AVCodecContext *avctx, QSVEncContext *q) return 0; } +#if QSV_HAVE_OPAQUE static int qsv_init_opaque_alloc(AVCodecContext *avctx, QSVEncContext *q) { AVQSVContext *qsv = avctx->hwaccel_context; @@ -1065,6 +1066,7 @@ static int qsv_init_opaque_alloc(AVCodecContext *avctx, QSVEncContext *q) return 0; } +#endif static int qsvenc_init_session(AVCodecContext *avctx, QSVEncContext *q) { @@ -1080,7 +1082,11 @@ static int qsvenc_init_session(AVCodecContext *avctx, QSVEncContext *q) ret = ff_qsv_init_session_frames(avctx, &q->internal_qs.session, &q->frames_ctx, q->load_plugins, +#if QSV_HAVE_OPAQUE q->param.IOPattern == MFX_IOPATTERN_IN_OPAQUE_MEMORY, +#else + 0, +#endif MFX_GPUCOPY_OFF); if (ret < 0) { av_buffer_unref(&q->frames_ctx.hw_frames_ctx); @@ -1142,11 +1148,17 @@ int ff_qsv_enc_init(AVCodecContext *avctx, QSVEncContext *q) AVQSVFramesContext *frames_hwctx = frames_ctx->hwctx; if (!iopattern) { +#if QSV_HAVE_OPAQUE if (frames_hwctx->frame_type & MFX_MEMTYPE_OPAQUE_FRAME) iopattern = MFX_IOPATTERN_IN_OPAQUE_MEMORY; else if (frames_hwctx->frame_type & (MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET | MFX_MEMTYPE_VIDEO_MEMORY_PROCESSOR_TARGET)) iopattern = MFX_IOPATTERN_IN_VIDEO_MEMORY; +#else + if (frames_hwctx->frame_type & + (MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET | MFX_MEMTYPE_VIDEO_MEMORY_PROCESSOR_TARGET)) + iopattern = MFX_IOPATTERN_IN_VIDEO_MEMORY; +#endif } } @@ -1220,9 +1232,16 @@ int ff_qsv_enc_init(AVCodecContext *avctx, QSVEncContext *q) "Error querying (IOSurf) the encoding parameters"); if (opaque_alloc) { +#if QSV_HAVE_OPAQUE ret = qsv_init_opaque_alloc(avctx, q); if (ret < 0) return ret; +#else + av_log(avctx, AV_LOG_ERROR, "User is requesting to allocate OPAQUE surface, " + "however libmfx %d.%d doesn't support OPAQUE memory.\n", + q->ver.Major, q->ver.Minor); + return AVERROR_UNKNOWN; +#endif } ret = MFXVideoENCODE_Init(q->session, &q->param); @@ -1663,8 +1682,10 @@ int ff_qsv_enc_close(AVCodecContext *avctx, QSVEncContext *q) av_fifo_free(q->async_fifo); q->async_fifo = NULL; +#if QSV_HAVE_OPAQUE av_freep(&q->opaque_surfaces); av_buffer_unref(&q->opaque_alloc_buf); +#endif av_freep(&q->extparam); diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h index 93af4d1198..320ad6db2b 100644 --- a/libavcodec/qsvenc.h +++ b/libavcodec/qsvenc.h @@ -135,9 +135,11 @@ typedef struct QSVEncContext { mfxExtVP9Param extvp9param; #endif +#if QSV_HAVE_OPAQUE mfxExtOpaqueSurfaceAlloc opaque_alloc; mfxFrameSurface1 **opaque_surfaces; AVBufferRef *opaque_alloc_buf; +#endif mfxExtVideoSignalInfo extvsi; diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c index 73fcfecb46..b3adfb9296 100644 --- a/libavfilter/qsvvpp.c +++ b/libavfilter/qsvvpp.c @@ -34,7 +34,9 @@ #define IS_VIDEO_MEMORY(mode) (mode & (MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET | \ MFX_MEMTYPE_VIDEO_MEMORY_PROCESSOR_TARGET)) +#if QSV_HAVE_OPAQUE #define IS_OPAQUE_MEMORY(mode) (mode & MFX_MEMTYPE_OPAQUE_FRAME) +#endif #define IS_SYSTEM_MEMORY(mode) (mode & MFX_MEMTYPE_SYSTEM_MEMORY) #define QSV_HAVE_AUDIO !QSV_ONEVPL @@ -53,10 +55,14 @@ static const struct { } qsv_iopatterns[] = { {MFX_IOPATTERN_IN_VIDEO_MEMORY, "input is video memory surface" }, {MFX_IOPATTERN_IN_SYSTEM_MEMORY, "input is system memory surface" }, +#if QSV_HAVE_OPAQUE {MFX_IOPATTERN_IN_OPAQUE_MEMORY, "input is opaque memory surface" }, +#endif {MFX_IOPATTERN_OUT_VIDEO_MEMORY, "output is video memory surface" }, {MFX_IOPATTERN_OUT_SYSTEM_MEMORY, "output is system memory surface" }, +#if QSV_HAVE_OPAQUE {MFX_IOPATTERN_OUT_OPAQUE_MEMORY, "output is opaque memory surface" }, +#endif }; int ff_qsvvpp_print_iopattern(void *log_ctx, int mfx_iopattern, @@ -530,9 +536,13 @@ static int init_vpp_session(AVFilterContext *avctx, QSVVPPContext *s) if (!out_frames_ref) return AVERROR(ENOMEM); +#if QSV_HAVE_OPAQUE s->out_mem_mode = IS_OPAQUE_MEMORY(s->in_mem_mode) ? MFX_MEMTYPE_OPAQUE_FRAME : MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET; +#else + s->out_mem_mode = MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET; +#endif out_frames_ctx = (AVHWFramesContext *)out_frames_ref->data; out_frames_hwctx = out_frames_ctx->hwctx; @@ -614,6 +624,7 @@ static int init_vpp_session(AVFilterContext *avctx, QSVVPPContext *s) return AVERROR_UNKNOWN; } +#if QSV_HAVE_OPAQUE if (IS_OPAQUE_MEMORY(s->in_mem_mode) || IS_OPAQUE_MEMORY(s->out_mem_mode)) { s->opaque_alloc.In.Surfaces = s->surface_ptrs_in; s->opaque_alloc.In.NumSurface = s->nb_surface_ptrs_in; @@ -625,7 +636,9 @@ static int init_vpp_session(AVFilterContext *avctx, QSVVPPContext *s) s->opaque_alloc.Header.BufferId = MFX_EXTBUFF_OPAQUE_SURFACE_ALLOCATION; s->opaque_alloc.Header.BufferSz = sizeof(s->opaque_alloc); - } else if (IS_VIDEO_MEMORY(s->in_mem_mode) || IS_VIDEO_MEMORY(s->out_mem_mode)) { + } else +#endif + if (IS_VIDEO_MEMORY(s->in_mem_mode) || IS_VIDEO_MEMORY(s->out_mem_mode)) { mfxFrameAllocator frame_allocator = { .pthis = s, .Alloc = frame_alloc, @@ -707,6 +720,7 @@ int ff_qsvvpp_create(AVFilterContext *avctx, QSVVPPContext **vpp, QSVVPPParam *p goto failed; } +#if QSV_HAVE_OPAQUE if (IS_OPAQUE_MEMORY(s->in_mem_mode) || IS_OPAQUE_MEMORY(s->out_mem_mode)) { s->nb_ext_buffers = param->num_ext_buf + 1; s->ext_buffers = av_mallocz_array(s->nb_ext_buffers, sizeof(*s->ext_buffers)); @@ -724,6 +738,10 @@ int ff_qsvvpp_create(AVFilterContext *avctx, QSVVPPContext **vpp, QSVVPPParam *p s->vpp_param.NumExtParam = param->num_ext_buf; s->vpp_param.ExtParam = param->ext_buf; } +#else + s->vpp_param.NumExtParam = param->num_ext_buf; + s->vpp_param.ExtParam = param->ext_buf; +#endif s->got_frame = 0; @@ -741,15 +759,19 @@ int ff_qsvvpp_create(AVFilterContext *avctx, QSVVPPContext **vpp, QSVVPPParam *p s->vpp_param.IOPattern |= MFX_IOPATTERN_IN_SYSTEM_MEMORY; else if (IS_VIDEO_MEMORY(s->in_mem_mode)) s->vpp_param.IOPattern |= MFX_IOPATTERN_IN_VIDEO_MEMORY; +#if QSV_HAVE_OPAQUE else if (IS_OPAQUE_MEMORY(s->in_mem_mode)) s->vpp_param.IOPattern |= MFX_IOPATTERN_IN_OPAQUE_MEMORY; +#endif if (IS_SYSTEM_MEMORY(s->out_mem_mode)) s->vpp_param.IOPattern |= MFX_IOPATTERN_OUT_SYSTEM_MEMORY; else if (IS_VIDEO_MEMORY(s->out_mem_mode)) s->vpp_param.IOPattern |= MFX_IOPATTERN_OUT_VIDEO_MEMORY; +#if QSV_HAVE_OPAQUE else if (IS_OPAQUE_MEMORY(s->out_mem_mode)) s->vpp_param.IOPattern |= MFX_IOPATTERN_OUT_OPAQUE_MEMORY; +#endif /* Print input memory mode */ ff_qsvvpp_print_iopattern(avctx, s->vpp_param.IOPattern & 0x0F, "VPP"); @@ -788,7 +810,9 @@ int ff_qsvvpp_free(QSVVPPContext **vpp) clear_frame_list(&s->out_frame_list); av_freep(&s->surface_ptrs_in); av_freep(&s->surface_ptrs_out); +#if QSV_HAVE_OPAQUE av_freep(&s->ext_buffers); +#endif av_freep(&s->frame_infos); av_fifo_free(s->async_fifo); av_freep(vpp); diff --git a/libavfilter/qsvvpp.h b/libavfilter/qsvvpp.h index 46e90c1d2c..67c351f297 100644 --- a/libavfilter/qsvvpp.h +++ b/libavfilter/qsvvpp.h @@ -41,6 +41,7 @@ (MFX_VERSION.Major == (MAJOR) && MFX_VERSION.Minor >= (MINOR))) #define QSV_ONEVPL QSV_VERSION_ATLEAST(2, 0) +#define QSV_HAVE_OPAQUE !QSV_ONEVPL typedef struct QSVFrame { AVFrame *frame; @@ -66,10 +67,12 @@ typedef struct QSVVPPContext { mfxFrameSurface1 **surface_ptrs_in; mfxFrameSurface1 **surface_ptrs_out; +#if QSV_HAVE_OPAQUE /** MFXVPP extern parameters */ mfxExtOpaqueSurfaceAlloc opaque_alloc; mfxExtBuffer **ext_buffers; int nb_ext_buffers; +#endif int got_frame; int async_depth; diff --git a/libavfilter/vf_deinterlace_qsv.c b/libavfilter/vf_deinterlace_qsv.c index ba04b11e50..57efa1a791 100644 --- a/libavfilter/vf_deinterlace_qsv.c +++ b/libavfilter/vf_deinterlace_qsv.c @@ -60,7 +60,9 @@ typedef struct QSVDeintContext { mfxFrameSurface1 **surface_ptrs; int nb_surface_ptrs; +#if QSV_HAVE_OPAQUE mfxExtOpaqueSurfaceAlloc opaque_alloc; +#endif mfxExtVPPDeinterlacing deint_conf; mfxExtBuffer *ext_buffers[2]; int num_ext_buffers; @@ -161,9 +163,7 @@ static int init_out_session(AVFilterContext *ctx) AVHWFramesContext *hw_frames_ctx = (AVHWFramesContext*)s->hw_frames_ctx->data; AVQSVFramesContext *hw_frames_hwctx = hw_frames_ctx->hwctx; AVQSVDeviceContext *device_hwctx = hw_frames_ctx->device_ctx->hwctx; - - int opaque = !!(hw_frames_hwctx->frame_type & MFX_MEMTYPE_OPAQUE_FRAME); - + int opaque = 0; mfxHDL handle = NULL; mfxHandleType handle_type; mfxVersion ver; @@ -172,6 +172,9 @@ static int init_out_session(AVFilterContext *ctx) mfxStatus err; int i; +#if QSV_HAVE_OPAQUE + opaque = !!(hw_frames_hwctx->frame_type & MFX_MEMTYPE_OPAQUE_FRAME); +#endif /* extract the properties of the "master" session given to us */ err = MFXQueryIMPL(device_hwctx->session, &impl); if (err == MFX_ERR_NONE) @@ -226,28 +229,7 @@ static int init_out_session(AVFilterContext *ctx) s->ext_buffers[s->num_ext_buffers++] = (mfxExtBuffer *)&s->deint_conf; - if (opaque) { - s->surface_ptrs = av_mallocz_array(hw_frames_hwctx->nb_surfaces, - sizeof(*s->surface_ptrs)); - if (!s->surface_ptrs) - return AVERROR(ENOMEM); - for (i = 0; i < hw_frames_hwctx->nb_surfaces; i++) - s->surface_ptrs[i] = hw_frames_hwctx->surfaces + i; - s->nb_surface_ptrs = hw_frames_hwctx->nb_surfaces; - - s->opaque_alloc.In.Surfaces = s->surface_ptrs; - s->opaque_alloc.In.NumSurface = s->nb_surface_ptrs; - s->opaque_alloc.In.Type = hw_frames_hwctx->frame_type; - - s->opaque_alloc.Out = s->opaque_alloc.In; - - s->opaque_alloc.Header.BufferId = MFX_EXTBUFF_OPAQUE_SURFACE_ALLOCATION; - s->opaque_alloc.Header.BufferSz = sizeof(s->opaque_alloc); - - s->ext_buffers[s->num_ext_buffers++] = (mfxExtBuffer *)&s->opaque_alloc; - - par.IOPattern = MFX_IOPATTERN_IN_OPAQUE_MEMORY | MFX_IOPATTERN_OUT_OPAQUE_MEMORY; - } else { + if (!opaque) { mfxFrameAllocator frame_allocator = { .pthis = ctx, .Alloc = frame_alloc, @@ -271,6 +253,30 @@ static int init_out_session(AVFilterContext *ctx) par.IOPattern = MFX_IOPATTERN_IN_VIDEO_MEMORY | MFX_IOPATTERN_OUT_VIDEO_MEMORY; } +#if QSV_HAVE_OPAQUE + else { + s->surface_ptrs = av_mallocz_array(hw_frames_hwctx->nb_surfaces, + sizeof(*s->surface_ptrs)); + if (!s->surface_ptrs) + return AVERROR(ENOMEM); + for (i = 0; i < hw_frames_hwctx->nb_surfaces; i++) + s->surface_ptrs[i] = hw_frames_hwctx->surfaces + i; + s->nb_surface_ptrs = hw_frames_hwctx->nb_surfaces; + + s->opaque_alloc.In.Surfaces = s->surface_ptrs; + s->opaque_alloc.In.NumSurface = s->nb_surface_ptrs; + s->opaque_alloc.In.Type = hw_frames_hwctx->frame_type; + + s->opaque_alloc.Out = s->opaque_alloc.In; + + s->opaque_alloc.Header.BufferId = MFX_EXTBUFF_OPAQUE_SURFACE_ALLOCATION; + s->opaque_alloc.Header.BufferSz = sizeof(s->opaque_alloc); + + s->ext_buffers[s->num_ext_buffers++] = (mfxExtBuffer *)&s->opaque_alloc; + + par.IOPattern = MFX_IOPATTERN_IN_OPAQUE_MEMORY | MFX_IOPATTERN_OUT_OPAQUE_MEMORY; + } +#endif par.ExtParam = s->ext_buffers; par.NumExtParam = s->num_ext_buffers; diff --git a/libavfilter/vf_scale_qsv.c b/libavfilter/vf_scale_qsv.c index 8fcb07cec9..9bb5906141 100644 --- a/libavfilter/vf_scale_qsv.c +++ b/libavfilter/vf_scale_qsv.c @@ -89,7 +89,9 @@ typedef struct QSVScaleContext { mfxFrameSurface1 **surface_ptrs_out; int nb_surface_ptrs_out; +#if QSV_HAVE_OPAQUE mfxExtOpaqueSurfaceAlloc opaque_alloc; +#endif #if QSV_HAVE_SCALING_CONFIG mfxExtVPPScaling scale_conf; @@ -279,7 +281,7 @@ static int init_out_session(AVFilterContext *ctx) AVQSVFramesContext *out_frames_hwctx = out_frames_ctx->hwctx; AVQSVDeviceContext *device_hwctx = in_frames_ctx->device_ctx->hwctx; - int opaque = !!(in_frames_hwctx->frame_type & MFX_MEMTYPE_OPAQUE_FRAME); + int opaque = 0; mfxHDL handle = NULL; mfxHandleType handle_type; @@ -289,6 +291,9 @@ static int init_out_session(AVFilterContext *ctx) mfxStatus err; int i; +#if QSV_HAVE_OPAQUE + opaque = !!(in_frames_hwctx->frame_type & MFX_MEMTYPE_OPAQUE_FRAME); +#endif s->num_ext_buf = 0; /* extract the properties of the "master" session given to us */ @@ -337,38 +342,7 @@ static int init_out_session(AVFilterContext *ctx) memset(&par, 0, sizeof(par)); - if (opaque) { - s->surface_ptrs_in = av_mallocz_array(in_frames_hwctx->nb_surfaces, - sizeof(*s->surface_ptrs_in)); - if (!s->surface_ptrs_in) - return AVERROR(ENOMEM); - for (i = 0; i < in_frames_hwctx->nb_surfaces; i++) - s->surface_ptrs_in[i] = in_frames_hwctx->surfaces + i; - s->nb_surface_ptrs_in = in_frames_hwctx->nb_surfaces; - - s->surface_ptrs_out = av_mallocz_array(out_frames_hwctx->nb_surfaces, - sizeof(*s->surface_ptrs_out)); - if (!s->surface_ptrs_out) - return AVERROR(ENOMEM); - for (i = 0; i < out_frames_hwctx->nb_surfaces; i++) - s->surface_ptrs_out[i] = out_frames_hwctx->surfaces + i; - s->nb_surface_ptrs_out = out_frames_hwctx->nb_surfaces; - - s->opaque_alloc.In.Surfaces = s->surface_ptrs_in; - s->opaque_alloc.In.NumSurface = s->nb_surface_ptrs_in; - s->opaque_alloc.In.Type = in_frames_hwctx->frame_type; - - s->opaque_alloc.Out.Surfaces = s->surface_ptrs_out; - s->opaque_alloc.Out.NumSurface = s->nb_surface_ptrs_out; - s->opaque_alloc.Out.Type = out_frames_hwctx->frame_type; - - s->opaque_alloc.Header.BufferId = MFX_EXTBUFF_OPAQUE_SURFACE_ALLOCATION; - s->opaque_alloc.Header.BufferSz = sizeof(s->opaque_alloc); - - s->ext_buffers[s->num_ext_buf++] = (mfxExtBuffer*)&s->opaque_alloc; - - par.IOPattern = MFX_IOPATTERN_IN_OPAQUE_MEMORY | MFX_IOPATTERN_OUT_OPAQUE_MEMORY; - } else { + if (!opaque) { mfxFrameAllocator frame_allocator = { .pthis = ctx, .Alloc = frame_alloc, @@ -400,6 +374,40 @@ static int init_out_session(AVFilterContext *ctx) par.IOPattern = MFX_IOPATTERN_IN_VIDEO_MEMORY | MFX_IOPATTERN_OUT_VIDEO_MEMORY; } +#if QSV_HAVE_OPAQUE + else { + s->surface_ptrs_in = av_mallocz_array(in_frames_hwctx->nb_surfaces, + sizeof(*s->surface_ptrs_in)); + if (!s->surface_ptrs_in) + return AVERROR(ENOMEM); + for (i = 0; i < in_frames_hwctx->nb_surfaces; i++) + s->surface_ptrs_in[i] = in_frames_hwctx->surfaces + i; + s->nb_surface_ptrs_in = in_frames_hwctx->nb_surfaces; + + s->surface_ptrs_out = av_mallocz_array(out_frames_hwctx->nb_surfaces, + sizeof(*s->surface_ptrs_out)); + if (!s->surface_ptrs_out) + return AVERROR(ENOMEM); + for (i = 0; i < out_frames_hwctx->nb_surfaces; i++) + s->surface_ptrs_out[i] = out_frames_hwctx->surfaces + i; + s->nb_surface_ptrs_out = out_frames_hwctx->nb_surfaces; + + s->opaque_alloc.In.Surfaces = s->surface_ptrs_in; + s->opaque_alloc.In.NumSurface = s->nb_surface_ptrs_in; + s->opaque_alloc.In.Type = in_frames_hwctx->frame_type; + + s->opaque_alloc.Out.Surfaces = s->surface_ptrs_out; + s->opaque_alloc.Out.NumSurface = s->nb_surface_ptrs_out; + s->opaque_alloc.Out.Type = out_frames_hwctx->frame_type; + + s->opaque_alloc.Header.BufferId = MFX_EXTBUFF_OPAQUE_SURFACE_ALLOCATION; + s->opaque_alloc.Header.BufferSz = sizeof(s->opaque_alloc); + + s->ext_buffers[s->num_ext_buf++] = (mfxExtBuffer*)&s->opaque_alloc; + + par.IOPattern = MFX_IOPATTERN_IN_OPAQUE_MEMORY | MFX_IOPATTERN_OUT_OPAQUE_MEMORY; + } +#endif #if QSV_HAVE_SCALING_CONFIG memset(&s->scale_conf, 0, sizeof(mfxExtVPPScaling)); diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c index cd7fe72109..5a93d7f3bf 100644 --- a/libavutil/hwcontext_qsv.c +++ b/libavutil/hwcontext_qsv.c @@ -48,6 +48,9 @@ (MFX_VERSION_MAJOR > (MAJOR) || \ MFX_VERSION_MAJOR == (MAJOR) && MFX_VERSION_MINOR >= (MINOR)) +#define QSV_ONEVPL QSV_VERSION_ATLEAST(2, 0) +#define QSV_HAVE_OPAQUE !QSV_ONEVPL + typedef struct QSVDevicePriv { AVBufferRef *child_device_ctx; } QSVDevicePriv; @@ -78,11 +81,13 @@ typedef struct QSVFramesContext { // used in the frame allocator for non-opaque surfaces mfxMemId *mem_ids; +#if QSV_HAVE_OPAQUE // used in the opaque alloc request for opaque surfaces mfxFrameSurface1 **surface_ptrs; mfxExtOpaqueSurfaceAlloc opaque_alloc; mfxExtBuffer *ext_buffers[1]; +#endif } QSVFramesContext; static const struct { @@ -185,7 +190,9 @@ static void qsv_frames_uninit(AVHWFramesContext *ctx) #endif av_freep(&s->mem_ids); +#if QSV_HAVE_OPAQUE av_freep(&s->surface_ptrs); +#endif av_freep(&s->surfaces_internal); av_buffer_unref(&s->child_frames_ref); } @@ -371,11 +378,17 @@ static int qsv_init_pool(AVHWFramesContext *ctx, uint32_t fourcc) return ret; } +#if QSV_HAVE_OPAQUE if (!(frames_hwctx->frame_type & MFX_MEMTYPE_OPAQUE_FRAME)) { ret = qsv_init_child_ctx(ctx); if (ret < 0) return ret; } +#else + ret = qsv_init_child_ctx(ctx); + if (ret < 0) + return ret; +#endif ctx->internal->pool_internal = av_buffer_pool_init2(sizeof(mfxFrameSurface1), ctx, qsv_pool_alloc, NULL); @@ -440,10 +453,9 @@ static mfxStatus frame_get_hdl(mfxHDL pthis, mfxMemId mid, mfxHDL *hdl) static int qsv_init_internal_session(AVHWFramesContext *ctx, mfxSession *session, int upload) { - QSVFramesContext *s = ctx->internal->priv; AVQSVFramesContext *frames_hwctx = ctx->hwctx; QSVDeviceContext *device_priv = ctx->device_ctx->internal->priv; - int opaque = !!(frames_hwctx->frame_type & MFX_MEMTYPE_OPAQUE_FRAME); + int opaque = 0; mfxFrameAllocator frame_allocator = { .pthis = ctx, @@ -457,6 +469,11 @@ static int qsv_init_internal_session(AVHWFramesContext *ctx, mfxVideoParam par; mfxStatus err; +#if QSV_HAVE_OPAQUE + QSVFramesContext *s = ctx->internal->priv; + opaque = !!(frames_hwctx->frame_type & MFX_MEMTYPE_OPAQUE_FRAME); +#endif + err = MFXInit(device_priv->impl, &device_priv->ver, session); if (err != MFX_ERR_NONE) { av_log(ctx, AV_LOG_ERROR, "Error initializing an internal session\n"); @@ -478,15 +495,18 @@ static int qsv_init_internal_session(AVHWFramesContext *ctx, memset(&par, 0, sizeof(par)); - if (opaque) { + if (!opaque) { + par.IOPattern = upload ? MFX_IOPATTERN_OUT_VIDEO_MEMORY : + MFX_IOPATTERN_IN_VIDEO_MEMORY; + } +#if QSV_HAVE_OPAQUE + else { par.ExtParam = s->ext_buffers; par.NumExtParam = FF_ARRAY_ELEMS(s->ext_buffers); par.IOPattern = upload ? MFX_IOPATTERN_OUT_OPAQUE_MEMORY : MFX_IOPATTERN_IN_OPAQUE_MEMORY; - } else { - par.IOPattern = upload ? MFX_IOPATTERN_OUT_VIDEO_MEMORY : - MFX_IOPATTERN_IN_VIDEO_MEMORY; } +#endif par.IOPattern |= upload ? MFX_IOPATTERN_IN_SYSTEM_MEMORY : MFX_IOPATTERN_OUT_SYSTEM_MEMORY; @@ -518,11 +538,15 @@ static int qsv_frames_init(AVHWFramesContext *ctx) QSVFramesContext *s = ctx->internal->priv; AVQSVFramesContext *frames_hwctx = ctx->hwctx; - int opaque = !!(frames_hwctx->frame_type & MFX_MEMTYPE_OPAQUE_FRAME); + int opaque = 0; uint32_t fourcc; int i, ret; +#if QSV_HAVE_OPAQUE + opaque = !!(frames_hwctx->frame_type & MFX_MEMTYPE_OPAQUE_FRAME); +#endif + fourcc = qsv_fourcc_from_pix_fmt(ctx->sw_format); if (!fourcc) { av_log(ctx, AV_LOG_ERROR, "Unsupported pixel format\n"); @@ -537,7 +561,16 @@ static int qsv_frames_init(AVHWFramesContext *ctx) } } - if (opaque) { + if (!opaque) { + s->mem_ids = av_mallocz_array(frames_hwctx->nb_surfaces, sizeof(*s->mem_ids)); + if (!s->mem_ids) + return AVERROR(ENOMEM); + + for (i = 0; i < frames_hwctx->nb_surfaces; i++) + s->mem_ids[i] = frames_hwctx->surfaces[i].Data.MemId; + } +#if QSV_HAVE_OPAQUE + else { s->surface_ptrs = av_mallocz_array(frames_hwctx->nb_surfaces, sizeof(*s->surface_ptrs)); if (!s->surface_ptrs) @@ -556,14 +589,8 @@ static int qsv_frames_init(AVHWFramesContext *ctx) s->opaque_alloc.Header.BufferSz = sizeof(s->opaque_alloc); s->ext_buffers[0] = (mfxExtBuffer*)&s->opaque_alloc; - } else { - s->mem_ids = av_mallocz_array(frames_hwctx->nb_surfaces, sizeof(*s->mem_ids)); - if (!s->mem_ids) - return AVERROR(ENOMEM); - - for (i = 0; i < frames_hwctx->nb_surfaces; i++) - s->mem_ids[i] = frames_hwctx->surfaces[i].Data.MemId; } +#endif s->session_download = NULL; s->session_upload = NULL; From patchwork Mon Aug 16 07:33:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xiang, Haihao" X-Patchwork-Id: 29554 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2a4a:0:0:0:0 with SMTP id k10csp1800275iov; Mon, 16 Aug 2021 00:35:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzGF9OFK8Acg+BOfZwecfn61NFdZt6EdImmASewhMTcL1qMgFsmTiKdNYRKgZsDSnbum0Nk X-Received: by 2002:aa7:da8c:: with SMTP id q12mr18496401eds.304.1629099321228; Mon, 16 Aug 2021 00:35:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629099321; cv=none; d=google.com; s=arc-20160816; b=dpkQnaDkMCGogAF9BZhLQ4MseOcipQmdDhNnBkxcHHp7aytvImWxcXLyrSph6+t7q+ GU9cZxry3yU2wWgYP2+8bZfWHDj6qZpO72nIGV4ve3k/uZ4J9WbPfKukrzmRJ+xJxcg5 0hpXtlOebIQ5VF6Sy77ivr0I7WJ5Jq/SFFAxL7+qkERgXHivDJMbvRlSQ2PE7LNYQr6H TaKfQF9/ADZRTGkkrRQXRd953SbHk388mE24rmf70Ud0+twpGzAdL+aYll5KLqKrsM3u RooSRJGTv2yiZJtcUaxid0vkOXweT5VNsBF+oppQlA98M4sxdkP3Q861EqOi9IkU3LKf NfuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:delivered-to; bh=7ps33u2VSm4Lhkz9SuvGh6iPygMyI/KhF3jOsgbJ4e4=; b=YMR4XPbbwFwnhj5o9xBp8D6cpnRNRqyzdqOsZaK6wiSiH4svDlKz7mPeTgJWSOyu/Y 6H/2jockUYZb9ToOg8oF/7smtA4BmQIRJsD1vGsjSj5ck66GC4ONgtyA+Eym7QUMq/W3 wlH6CSfmuPqc6M+wsjcyjCuvl+8Scr8+P4EFWEyqohBR80InMRL6/Tpj83uylvB7688y qvhgZX6yrDebnY1kGf7geXf54F0BHD6zpVWFU/XHSP3Ul4/tulvuf8ioeE2oEEOtW4AO M/vIuYlf12xTDwYUNkdLxnlZ+EJq15elgfk90nVwF4Kr5zqqvUe9a1V5V53P1IBs72bM 3vcg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id o23si10202836edt.314.2021.08.16.00.35.20; Mon, 16 Aug 2021 00:35:21 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4972D68A5D1; Mon, 16 Aug 2021 10:34:03 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6F87E68A5AA for ; Mon, 16 Aug 2021 10:33:56 +0300 (EEST) X-IronPort-AV: E=McAfee;i="6200,9189,10077"; a="279553925" X-IronPort-AV: E=Sophos;i="5.84,324,1620716400"; d="scan'208";a="279553925" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Aug 2021 00:33:54 -0700 X-IronPort-AV: E=Sophos;i="5.84,324,1620716400"; d="scan'208";a="519461892" Received: from xhh-dg164.sh.intel.com ([10.239.159.167]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Aug 2021 00:33:48 -0700 From: Haihao Xiang To: ffmpeg-devel@ffmpeg.org Date: Mon, 16 Aug 2021 15:33:24 +0800 Message-Id: <20210816073325.27020-10-haihao.xiang@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210816073325.27020-1-haihao.xiang@intel.com> References: <20210816073325.27020-1-haihao.xiang@intel.com> Subject: [FFmpeg-devel] [PATCH v2 09/10] qsv: use a new method to create mfx session when using the oneVPL SDK 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 , galinart MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: Bd0P77r1lUIB In oneVPL, MFXLoad() and MFXCreateSession() are required to create a workable mfx session[1] Add AccelerationMode config filter for D3D9 session (galinart) This is in preparation for oneVPL support [1] https://spec.oneapi.io/versions/latest/elements/oneVPL/source/programming_guide/VPL_prg_session.html#onevpl-dispatcher Signed-off-by: galinart --- libavcodec/qsv.c | 191 +++++++++++++++++--- libavcodec/qsv_internal.h | 1 + libavcodec/qsvdec.c | 4 + libavcodec/qsvenc.h | 3 + libavcodec/qsvenc_h264.c | 1 - libavcodec/qsvenc_hevc.c | 1 - libavcodec/qsvenc_jpeg.c | 1 - libavcodec/qsvenc_mpeg2.c | 1 - libavcodec/qsvenc_vp9.c | 1 - libavfilter/qsvvpp.c | 107 ++++++++++- libavfilter/qsvvpp.h | 5 + libavfilter/vf_deinterlace_qsv.c | 14 +- libavfilter/vf_scale_qsv.c | 12 +- libavutil/hwcontext_qsv.c | 300 ++++++++++++++++++++++++++----- libavutil/hwcontext_qsv.h | 16 ++ 15 files changed, 569 insertions(+), 89 deletions(-) diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c index 98fc6a92b6..bfa9cad8a2 100644 --- a/libavcodec/qsv.c +++ b/libavcodec/qsv.c @@ -383,25 +383,176 @@ static int ff_qsv_set_display_handle(AVCodecContext *avctx, QSVSession *qs) } #endif //AVCODEC_QSV_LINUX_SESSION_HANDLE +#if QSV_ONEVPL + +static int qsv_create_mfx_session(AVCodecContext *avctx, + mfxIMPL implementation, + mfxVersion *pver, + int gpu_copy, + mfxSession *psession, + mfxLoader *ploader) +{ + mfxStatus sts; + mfxLoader loader = NULL; + mfxSession session = NULL; + mfxConfig cfg; + mfxVariant impl_value; + uint32_t impl_idx = 0; + + *psession = NULL; + + /* Don't create a new MFX loader if the input loader is valid */ + if (*ploader == NULL) { + av_log(avctx, AV_LOG_VERBOSE, + "Use the Intel oneVPL SDK to create MFX session, the required " + "implementation version is %d.%d\n", + pver->Major, pver->Minor); + + loader = MFXLoad(); + + if (!loader) { + av_log(avctx, AV_LOG_ERROR, "Error creating a MFX loader\n"); + goto fail; + } + + /* Create configurations for implementation */ + cfg = MFXCreateConfig(loader); + + if (!cfg) { + av_log(avctx, AV_LOG_ERROR, "Error creating a MFX configurations\n"); + goto fail; + } + + impl_value.Type = MFX_VARIANT_TYPE_U32; + impl_value.Data.U32 = (implementation == MFX_IMPL_SOFTWARE) ? + MFX_IMPL_TYPE_SOFTWARE : MFX_IMPL_TYPE_HARDWARE; + sts = MFXSetConfigFilterProperty(cfg, + (const mfxU8 *)"mfxImplDescription.Impl", impl_value); + + if (sts != MFX_ERR_NONE) { + av_log(avctx, AV_LOG_ERROR, "Error adding a MFX configuration " + "property: %d\n", sts); + goto fail; + } + + impl_value.Type = MFX_VARIANT_TYPE_U32; + impl_value.Data.U32 = pver->Version; + sts = MFXSetConfigFilterProperty(cfg, + (const mfxU8 *)"mfxImplDescription.ApiVersion.Version", + impl_value); + + if (sts != MFX_ERR_NONE) { + av_log(avctx, AV_LOG_ERROR, "Error adding a MFX configuration " + "property: %d\n", sts); + goto fail; + } + } else { + av_log(avctx, AV_LOG_VERBOSE, + "Use the Intel oneVPL SDK to create MFX session with the specified MFX loader\n"); + + loader = *ploader; + } + + while (1) { + /* Enumerate all implementations */ + mfxImplDescription *impl_desc; + + sts = MFXEnumImplementations(loader, impl_idx, + MFX_IMPLCAPS_IMPLDESCSTRUCTURE, + (mfxHDL *)&impl_desc); + + /* Failed to find an available implementation */ + if (sts == MFX_ERR_NOT_FOUND) + break; + else if (sts != MFX_ERR_NONE) { + impl_idx++; + continue; + } + + sts = MFXCreateSession(loader, impl_idx, &session); + MFXDispReleaseImplDescription(loader, impl_desc); + + if (sts == MFX_ERR_NONE) + break; + + impl_idx++; + } + + if (sts != MFX_ERR_NONE) { + av_log(avctx, AV_LOG_ERROR, "Error creating a MFX session: %d.\n", sts); + goto fail; + } + + *psession = session; + + if (!*ploader) + *ploader = loader; + + return 0; + +fail: + if (!*ploader && loader) + MFXUnload(loader); + + return AVERROR_UNKNOWN; +} + +#else + +static int qsv_create_mfx_session(AVCodecContext *avctx, + mfxIMPL implementation, + mfxVersion *pver, + int gpu_copy, + mfxSession *psession, + mfxLoader *ploader) +{ + mfxInitParam init_par = { MFX_IMPL_AUTO_ANY }; + mfxSession session = NULL; + mfxStatus sts; + + av_log(avctx, AV_LOG_VERBOSE, + "Use the Intel Media SDK to create MFX session, the required " + "implementation version is %d.%d\n", + pver->Major, pver->Minor); + + *psession = NULL; + *ploader = NULL; + +#if QSV_VERSION_ATLEAST(1, 16) + init_par.GPUCopy = gpu_copy; +#endif + init_par.Implementation = implementation; + init_par.Version = *pver; + sts = MFXInitEx(init_par, &session); + + if (sts < 0) + return ff_qsv_print_error(avctx, sts, + "Error initializing a MFX session"); + else if (sts > 0) { + ff_qsv_print_warning(avctx, sts, + "Warning in MFX initialization"); + return AVERROR_UNKNOWN; + } + + *psession = session; + + return 0; +} + +#endif + int ff_qsv_init_internal_session(AVCodecContext *avctx, QSVSession *qs, const char *load_plugins, int gpu_copy) { mfxIMPL impl = MFX_IMPL_AUTO_ANY; mfxVersion ver = { { QSV_VERSION_MINOR, QSV_VERSION_MAJOR } }; - mfxInitParam init_par = { MFX_IMPL_AUTO_ANY }; const char *desc; - int ret; + int ret = qsv_create_mfx_session(avctx, impl, &ver, gpu_copy, &qs->session, + &qs->loader); -#if QSV_VERSION_ATLEAST(1, 16) - init_par.GPUCopy = gpu_copy; -#endif - init_par.Implementation = impl; - init_par.Version = ver; - ret = MFXInitEx(init_par, &qs->session); - if (ret < 0) - return ff_qsv_print_error(avctx, ret, - "Error initializing an internal MFX session"); + if (ret) + return ret; #ifdef AVCODEC_QSV_LINUX_SESSION_HANDLE ret = ff_qsv_set_display_handle(avctx, qs); @@ -701,7 +852,7 @@ int ff_qsv_init_session_device(AVCodecContext *avctx, mfxSession *psession, AVHWDeviceContext *device_ctx = (AVHWDeviceContext*)device_ref->data; AVQSVDeviceContext *device_hwctx = device_ctx->hwctx; mfxSession parent_session = device_hwctx->session; - mfxInitParam init_par = { MFX_IMPL_AUTO_ANY }; + mfxLoader loader = device_hwctx->loader; mfxHDL handle = NULL; mfxSession session; @@ -732,15 +883,11 @@ int ff_qsv_init_session_device(AVCodecContext *avctx, mfxSession *psession, "from the session\n"); } -#if QSV_VERSION_ATLEAST(1, 16) - init_par.GPUCopy = gpu_copy; -#endif - init_par.Implementation = impl; - init_par.Version = ver; - err = MFXInitEx(init_par, &session); - if (err != MFX_ERR_NONE) - return ff_qsv_print_error(avctx, err, - "Error initializing a child MFX session"); + ret = qsv_create_mfx_session(avctx, impl, &ver, gpu_copy, &session, + &loader); + + if (ret) + return ret; if (handle) { err = MFXVideoCORE_SetHandle(session, handle_type, handle); @@ -817,7 +964,9 @@ int ff_qsv_close_internal_session(QSVSession *qs) { if (qs->session) { MFXClose(qs->session); + MFXUnload(qs->loader); qs->session = NULL; + qs->loader = NULL; } #ifdef AVCODEC_QSV_LINUX_SESSION_HANDLE av_buffer_unref(&qs->va_device_ref); diff --git a/libavcodec/qsv_internal.h b/libavcodec/qsv_internal.h index 2afb46167d..83a4495325 100644 --- a/libavcodec/qsv_internal.h +++ b/libavcodec/qsv_internal.h @@ -87,6 +87,7 @@ typedef struct QSVFrame { typedef struct QSVSession { mfxSession session; + mfxLoader loader; #ifdef AVCODEC_QSV_LINUX_SESSION_HANDLE AVBufferRef *va_device_ref; AVHWDeviceContext *va_device_ctx; diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c index 9395a1fd9a..c4daa44c1c 100644 --- a/libavcodec/qsvdec.c +++ b/libavcodec/qsvdec.c @@ -161,7 +161,9 @@ static int qsv_init_session(AVCodecContext *avctx, QSVContext *q, mfxSession ses } else if (hw_frames_ref) { if (q->internal_qs.session) { MFXClose(q->internal_qs.session); + MFXUnload(q->internal_qs.loader); q->internal_qs.session = NULL; + q->internal_qs.loader = NULL; } av_buffer_unref(&q->frames_ctx.hw_frames_ctx); @@ -186,7 +188,9 @@ static int qsv_init_session(AVCodecContext *avctx, QSVContext *q, mfxSession ses } else if (hw_device_ref) { if (q->internal_qs.session) { MFXClose(q->internal_qs.session); + MFXUnload(q->internal_qs.loader); q->internal_qs.session = NULL; + q->internal_qs.loader = NULL; } ret = ff_qsv_init_session_device(avctx, &q->internal_qs.session, diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h index 320ad6db2b..7a7eaea156 100644 --- a/libavcodec/qsvenc.h +++ b/libavcodec/qsvenc.h @@ -28,6 +28,9 @@ #include +#include "libavutil/common.h" +#include "libavutil/hwcontext.h" +#include "libavutil/hwcontext_qsv.h" #include "libavutil/avutil.h" #include "libavutil/fifo.h" diff --git a/libavcodec/qsvenc_h264.c b/libavcodec/qsvenc_h264.c index 9134e6a68c..5ed5e1ed0d 100644 --- a/libavcodec/qsvenc_h264.c +++ b/libavcodec/qsvenc_h264.c @@ -32,7 +32,6 @@ #include "avcodec.h" #include "internal.h" #include "qsv.h" -#include "qsv_internal.h" #include "qsvenc.h" #include "atsc_a53.h" diff --git a/libavcodec/qsvenc_hevc.c b/libavcodec/qsvenc_hevc.c index a268a002d6..7519b7b436 100644 --- a/libavcodec/qsvenc_hevc.c +++ b/libavcodec/qsvenc_hevc.c @@ -35,7 +35,6 @@ #include "h2645_parse.h" #include "internal.h" #include "qsv.h" -#include "qsv_internal.h" #include "qsvenc.h" enum LoadPlugin { diff --git a/libavcodec/qsvenc_jpeg.c b/libavcodec/qsvenc_jpeg.c index ad8f09befe..f473b1ddbc 100644 --- a/libavcodec/qsvenc_jpeg.c +++ b/libavcodec/qsvenc_jpeg.c @@ -30,7 +30,6 @@ #include "avcodec.h" #include "internal.h" #include "qsv.h" -#include "qsv_internal.h" #include "qsvenc.h" typedef struct QSVMJPEGEncContext { diff --git a/libavcodec/qsvenc_mpeg2.c b/libavcodec/qsvenc_mpeg2.c index 610bbf79c1..0e2a51811c 100644 --- a/libavcodec/qsvenc_mpeg2.c +++ b/libavcodec/qsvenc_mpeg2.c @@ -30,7 +30,6 @@ #include "avcodec.h" #include "internal.h" #include "qsv.h" -#include "qsv_internal.h" #include "qsvenc.h" typedef struct QSVMpeg2EncContext { diff --git a/libavcodec/qsvenc_vp9.c b/libavcodec/qsvenc_vp9.c index 0a382eb76d..9d88b03bbf 100644 --- a/libavcodec/qsvenc_vp9.c +++ b/libavcodec/qsvenc_vp9.c @@ -30,7 +30,6 @@ #include "avcodec.h" #include "internal.h" #include "qsv.h" -#include "qsv_internal.h" #include "qsvenc.h" typedef struct QSVVP9EncContext { diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c index b3adfb9296..63990f5df3 100644 --- a/libavfilter/qsvvpp.c +++ b/libavfilter/qsvvpp.c @@ -23,8 +23,6 @@ #include "libavutil/common.h" #include "libavutil/mathematics.h" -#include "libavutil/hwcontext.h" -#include "libavutil/hwcontext_qsv.h" #include "libavutil/time.h" #include "libavutil/pixdesc.h" @@ -604,13 +602,11 @@ static int init_vpp_session(AVFilterContext *avctx, QSVVPPContext *s) } /* create a "slave" session with those same properties, to be used for vpp */ - ret = MFXInit(impl, &ver, &s->session); - if (ret < 0) - return ff_qsvvpp_print_error(avctx, ret, "Error initializing a session"); - else if (ret > 0) { - ff_qsvvpp_print_warning(avctx, ret, "Warning in session initialization"); - return AVERROR_UNKNOWN; - } + ret = ff_qsvvpp_create_mfx_session(avctx, device_hwctx->loader, impl, &ver, + &s->session); + + if (ret) + return ret; if (handle) { ret = MFXVideoCORE_SetHandle(s->session, handle_type, handle); @@ -909,3 +905,96 @@ int ff_qsvvpp_filter_frame(QSVVPPContext *s, AVFilterLink *inlink, AVFrame *picr return 0; } + +#if QSV_ONEVPL + +int ff_qsvvpp_create_mfx_session(void *ctx, + mfxLoader loader, + mfxIMPL implementation, + mfxVersion *pver, + mfxSession *psession) +{ + mfxStatus sts; + mfxSession session = NULL; + uint32_t impl_idx = 0; + + av_log(ctx, AV_LOG_VERBOSE, + "Use the Intel oneVPL SDK to create MFX session with the specified MFX loader\n"); + + if (!loader) { + av_log(ctx, AV_LOG_ERROR, "Invalid MFX Loader handle\n"); + return AVERROR(EINVAL); + } + + while (1) { + /* Enumerate all implementations */ + mfxImplDescription *impl_desc; + + sts = MFXEnumImplementations(loader, impl_idx, + MFX_IMPLCAPS_IMPLDESCSTRUCTURE, + (mfxHDL *)&impl_desc); + + /* Failed to find an available implementation */ + if (sts == MFX_ERR_NOT_FOUND) + break; + else if (sts != MFX_ERR_NONE) { + impl_idx++; + continue; + } + + sts = MFXCreateSession(loader, impl_idx, &session); + MFXDispReleaseImplDescription(loader, impl_desc); + + if (sts == MFX_ERR_NONE) + break; + + impl_idx++; + } + + if (sts < 0) + return ff_qsvvpp_print_error(ctx, sts, + "Error creating a MFX session"); + else if (sts > 0) { + ff_qsvvpp_print_warning(ctx, sts, + "Warning in MFX session creation"); + return AVERROR_UNKNOWN; + } + + *psession = session; + + return 0; +} + +#else + +int ff_qsvvpp_create_mfx_session(void *ctx, + mfxLoader loader, + mfxIMPL implementation, + mfxVersion *pver, + mfxSession *psession) +{ + mfxSession session = NULL; + mfxStatus sts; + + av_log(ctx, AV_LOG_VERBOSE, + "Use the Intel Media SDK to create MFX session, API version is " + "%d.%d, the required implementation version is %d.%d\n", + MFX_VERSION_MAJOR, MFX_VERSION_MINOR, pver->Major, pver->Minor); + + *psession = NULL; + sts = MFXInit(implementation, pver, &session); + + if (sts < 0) + return ff_qsvvpp_print_error(ctx, sts, + "Error initializing an MFX session"); + else if (sts > 0) { + ff_qsvvpp_print_warning(ctx, sts, "Warning in MFX session initialization"); + return AVERROR_UNKNOWN; + } + + *psession = session; + + return 0; +} + +#endif diff --git a/libavfilter/qsvvpp.h b/libavfilter/qsvvpp.h index 67c351f297..d1c12be25b 100644 --- a/libavfilter/qsvvpp.h +++ b/libavfilter/qsvvpp.h @@ -28,6 +28,8 @@ #include "avfilter.h" #include "libavutil/fifo.h" +#include "libavutil/hwcontext.h" +#include "libavutil/hwcontext_qsv.h" #define FF_INLINK_IDX(link) ((int)((link)->dstpad - (link)->dst->input_pads)) #define FF_OUTLINK_IDX(link) ((int)((link)->srcpad - (link)->src->output_pads)) @@ -122,4 +124,7 @@ int ff_qsvvpp_print_error(void *log_ctx, mfxStatus err, int ff_qsvvpp_print_warning(void *log_ctx, mfxStatus err, const char *warning_string); +int ff_qsvvpp_create_mfx_session(void *ctx, mfxLoader loader, mfxIMPL implementation, + mfxVersion *pver, mfxSession *psession); + #endif /* AVFILTER_QSVVPP_H */ diff --git a/libavfilter/vf_deinterlace_qsv.c b/libavfilter/vf_deinterlace_qsv.c index 57efa1a791..bb27cca63a 100644 --- a/libavfilter/vf_deinterlace_qsv.c +++ b/libavfilter/vf_deinterlace_qsv.c @@ -170,7 +170,7 @@ static int init_out_session(AVFilterContext *ctx) mfxIMPL impl; mfxVideoParam par; mfxStatus err; - int i; + int i, ret; #if QSV_HAVE_OPAQUE opaque = !!(hw_frames_hwctx->frame_type & MFX_MEMTYPE_OPAQUE_FRAME); @@ -201,13 +201,11 @@ static int init_out_session(AVFilterContext *ctx) /* create a "slave" session with those same properties, to be used for * actual deinterlacing */ - err = MFXInit(impl, &ver, &s->session); - if (err < 0) - return ff_qsvvpp_print_error(ctx, err, "Error initializing a session for deinterlacing"); - else if (err > 0) { - ff_qsvvpp_print_warning(ctx, err, "Warning in session initialization"); - return AVERROR_UNKNOWN; - } + ret = ff_qsvvpp_create_mfx_session(ctx, device_hwctx->loader, impl, &ver, + &s->session); + + if (ret) + return ret; if (handle) { err = MFXVideoCORE_SetHandle(s->session, handle_type, handle); diff --git a/libavfilter/vf_scale_qsv.c b/libavfilter/vf_scale_qsv.c index 9bb5906141..ac0c58388b 100644 --- a/libavfilter/vf_scale_qsv.c +++ b/libavfilter/vf_scale_qsv.c @@ -289,7 +289,7 @@ static int init_out_session(AVFilterContext *ctx) mfxIMPL impl; mfxVideoParam par; mfxStatus err; - int i; + int i, ret; #if QSV_HAVE_OPAQUE opaque = !!(in_frames_hwctx->frame_type & MFX_MEMTYPE_OPAQUE_FRAME); @@ -322,11 +322,11 @@ static int init_out_session(AVFilterContext *ctx) /* create a "slave" session with those same properties, to be used for * actual scaling */ - err = MFXInit(impl, &ver, &s->session); - if (err != MFX_ERR_NONE) { - av_log(ctx, AV_LOG_ERROR, "Error initializing a session for scaling\n"); - return AVERROR_UNKNOWN; - } + ret = ff_qsvvpp_create_mfx_session(ctx, device_hwctx->loader, impl, &ver, + &s->session); + + if (ret) + return ret; if (handle) { err = MFXVideoCORE_SetHandle(s->session, handle_type, handle); diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c index 5a93d7f3bf..cbff9916e1 100644 --- a/libavutil/hwcontext_qsv.c +++ b/libavutil/hwcontext_qsv.c @@ -51,6 +51,8 @@ #define QSV_ONEVPL QSV_VERSION_ATLEAST(2, 0) #define QSV_HAVE_OPAQUE !QSV_ONEVPL +#define MFX_IMPL_VIA_MASK(impl) (0x0f00 & (impl)) + typedef struct QSVDevicePriv { AVBufferRef *child_device_ctx; } QSVDevicePriv; @@ -67,8 +69,10 @@ typedef struct QSVDeviceContext { typedef struct QSVFramesContext { mfxSession session_download; + mfxLoader loader_download; int session_download_init; mfxSession session_upload; + mfxLoader loader_upload; int session_upload_init; #if HAVE_PTHREADS pthread_mutex_t session_lock; @@ -173,15 +177,19 @@ static void qsv_frames_uninit(AVHWFramesContext *ctx) if (s->session_download) { MFXVideoVPP_Close(s->session_download); MFXClose(s->session_download); + MFXUnload(s->loader_download); } s->session_download = NULL; + s->loader_download = NULL; s->session_download_init = 0; if (s->session_upload) { MFXVideoVPP_Close(s->session_upload); MFXClose(s->session_upload); + MFXUnload(s->loader_upload); } s->session_upload = NULL; + s->loader_upload = NULL; s->session_upload_init = 0; #if HAVE_PTHREADS @@ -450,8 +458,218 @@ static mfxStatus frame_get_hdl(mfxHDL pthis, mfxMemId mid, mfxHDL *hdl) return MFX_ERR_NONE; } +#if QSV_ONEVPL + +static int qsv_create_mfx_session(void *ctx, + mfxHandleType handle_type, + mfxIMPL implementation, + mfxVersion *pver, + mfxSession *psession, + mfxLoader *ploader) +{ + mfxStatus sts; + mfxLoader loader = NULL; + mfxSession session = NULL; + mfxConfig cfg; + mfxVersion ver; + mfxVariant impl_value; + uint32_t impl_idx = 0; + + av_log(ctx, AV_LOG_VERBOSE, + "Use the Intel oneVPL SDK to create MFX session, API version is " + "%d.%d, the required implementation version is %d.%d\n", + MFX_VERSION_MAJOR, MFX_VERSION_MINOR, pver->Major, pver->Minor); + + if (handle_type != MFX_HANDLE_VA_DISPLAY && + handle_type != MFX_HANDLE_D3D9_DEVICE_MANAGER) { + av_log(ctx, AV_LOG_ERROR, + "Invalid MFX device handle\n"); + return AVERROR(EXDEV); + } + + *psession = NULL; + *ploader = NULL; + loader = MFXLoad(); + + if (!loader) { + av_log(ctx, AV_LOG_ERROR, "Error creating a MFX loader\n"); + goto fail; + } + + /* Create configurations for implementation */ + cfg = MFXCreateConfig(loader); + + if (!cfg) { + av_log(ctx, AV_LOG_ERROR, "Error creating a MFX configuration\n"); + goto fail; + } + + impl_value.Type = MFX_VARIANT_TYPE_U32; + impl_value.Data.U32 = (implementation == MFX_IMPL_SOFTWARE) ? + MFX_IMPL_TYPE_SOFTWARE : MFX_IMPL_TYPE_HARDWARE; + sts = MFXSetConfigFilterProperty(cfg, + (const mfxU8 *)"mfxImplDescription.Impl", impl_value); + + if (sts != MFX_ERR_NONE) { + av_log(ctx, AV_LOG_ERROR, "Error adding a MFX configuration " + "property: %d.\n", sts); + goto fail; + } + + impl_value.Type = MFX_VARIANT_TYPE_U32; + + if (MFX_HANDLE_VA_DISPLAY == handle_type) + impl_value.Data.U32 = MFX_ACCEL_MODE_VIA_VAAPI; + else + impl_value.Data.U32 = MFX_ACCEL_MODE_VIA_D3D9; + + sts = MFXSetConfigFilterProperty(cfg, + (const mfxU8 *)"mfxImplDescription.AccelerationMode", impl_value); + + if (sts != MFX_ERR_NONE) { + av_log(ctx, AV_LOG_ERROR, "Error adding a MFX configuration" + "MFX_ACCEL_MODE_VIA_D3D9 property: %d.\n", sts); + goto fail; + } + + impl_value.Type = MFX_VARIANT_TYPE_U32; + impl_value.Data.U32 = pver->Version; + sts = MFXSetConfigFilterProperty(cfg, + (const mfxU8 *)"mfxImplDescription.ApiVersion.Version", + impl_value); + + if (sts != MFX_ERR_NONE) { + av_log(ctx, AV_LOG_ERROR, "Error adding a MFX configuration " + "property: %d.\n", sts); + goto fail; + } + + while (1) { + /* Enumerate all implementations */ + mfxImplDescription *impl_desc; + + sts = MFXEnumImplementations(loader, impl_idx, + MFX_IMPLCAPS_IMPLDESCSTRUCTURE, + (mfxHDL *)&impl_desc); + + /* Failed to find an available implementation */ + if (sts == MFX_ERR_NOT_FOUND) + break; + else if (sts != MFX_ERR_NONE) { + impl_idx++; + continue; + } + + sts = MFXCreateSession(loader, impl_idx, &session); + MFXDispReleaseImplDescription(loader, impl_desc); + + if (sts == MFX_ERR_NONE) + break; + + impl_idx++; + } + + if (sts != MFX_ERR_NONE) { + av_log(ctx, AV_LOG_ERROR, "Error creating a MFX session: %d.\n", sts); + goto fail; + } + + sts = MFXQueryVersion(session, &ver); + + if (sts != MFX_ERR_NONE) { + av_log(ctx, AV_LOG_ERROR, "Error querying a MFX session: %d.\n", sts); + goto fail; + } + + av_log(ctx, AV_LOG_VERBOSE, "Initialize MFX session: implementation " + "version is %d.%d\n", ver.Major, ver.Minor); + + *psession = session; + *ploader = loader; + + return 0; + +fail: + if (session) + MFXClose(session); + + MFXUnload(loader); + + return AVERROR_UNKNOWN; +} + +#else + +static int qsv_create_mfx_session(void *ctx, + mfxHandleType handle_type, + mfxIMPL implementation, + mfxVersion *pver, + mfxSession *psession, + mfxLoader *ploader) +{ + mfxVersion ver; + mfxStatus sts; + mfxSession session = NULL; + + av_log(ctx, AV_LOG_VERBOSE, + "Use the Intel Media SDK to create MFX session, API version is " + "%d.%d, the required implementation version is %d.%d\n", + MFX_VERSION_MAJOR, MFX_VERSION_MINOR, pver->Major, pver->Minor); + + if (handle_type != MFX_HANDLE_VA_DISPLAY && + handle_type != MFX_HANDLE_D3D9_DEVICE_MANAGER) { + av_log(ctx, AV_LOG_ERROR, + "Invalid MFX device handle\n"); + return AVERROR(EXDEV); + } + + *ploader = NULL; + *psession = NULL; + ver = *pver; + sts = MFXInit(implementation, &ver, &session); + + if (sts != MFX_ERR_NONE) { + av_log(ctx, AV_LOG_ERROR, "Error initializing an MFX session: " + "%d.\n", sts); + goto fail; + } + + sts = MFXQueryVersion(session, &ver); + + if (sts != MFX_ERR_NONE) { + av_log(ctx, AV_LOG_ERROR, "Error querying an MFX session: " + "%d.\n", sts); + goto fail; + } + + av_log(ctx, AV_LOG_VERBOSE, "Initialize MFX session: implementation " + "version is %d.%d\n", ver.Major, ver.Minor); + + MFXClose(session); + sts = MFXInit(implementation, &ver, &session); + + if (sts != MFX_ERR_NONE) { + av_log(ctx, AV_LOG_ERROR, "Error initializing an MFX session: " + "%d.\n", sts); + goto fail; + } + + *psession = session; + + return 0; + +fail: + if (session) + MFXClose(session); + + return AVERROR_UNKNOWN; +} + +#endif + static int qsv_init_internal_session(AVHWFramesContext *ctx, - mfxSession *session, int upload) + mfxSession *session, mfxLoader *loader, + int upload) { AVQSVFramesContext *frames_hwctx = ctx->hwctx; QSVDeviceContext *device_priv = ctx->device_ctx->internal->priv; @@ -468,29 +686,35 @@ static int qsv_init_internal_session(AVHWFramesContext *ctx, mfxVideoParam par; mfxStatus err; + int ret = AVERROR_UNKNOWN; #if QSV_HAVE_OPAQUE QSVFramesContext *s = ctx->internal->priv; opaque = !!(frames_hwctx->frame_type & MFX_MEMTYPE_OPAQUE_FRAME); #endif - err = MFXInit(device_priv->impl, &device_priv->ver, session); - if (err != MFX_ERR_NONE) { - av_log(ctx, AV_LOG_ERROR, "Error initializing an internal session\n"); - return AVERROR_UNKNOWN; - } + ret = qsv_create_mfx_session(ctx, device_priv->handle_type, + device_priv->impl, &device_priv->ver, session, + loader); + + if (ret) + goto fail; if (device_priv->handle) { err = MFXVideoCORE_SetHandle(*session, device_priv->handle_type, device_priv->handle); - if (err != MFX_ERR_NONE) - return AVERROR_UNKNOWN; + if (err != MFX_ERR_NONE) { + ret = AVERROR_UNKNOWN; + goto fail; + } } if (!opaque) { err = MFXVideoCORE_SetFrameAllocator(*session, &frame_allocator); - if (err != MFX_ERR_NONE) - return AVERROR_UNKNOWN; + if (err != MFX_ERR_NONE) { + ret = AVERROR_UNKNOWN; + goto fail; + } } memset(&par, 0, sizeof(par)); @@ -526,11 +750,22 @@ static int qsv_init_internal_session(AVHWFramesContext *ctx, if (err != MFX_ERR_NONE) { av_log(ctx, AV_LOG_VERBOSE, "Error opening the internal VPP session." "Surface upload/download will not be possible\n"); - MFXClose(*session); - *session = NULL; + + ret = AVERROR_UNKNOWN; + goto fail; } return 0; + +fail: + if (*session) + MFXClose(*session); + + MFXUnload(*loader); + *session = NULL; + *loader = NULL; + + return ret; } static int qsv_frames_init(AVHWFramesContext *ctx) @@ -595,6 +830,9 @@ static int qsv_frames_init(AVHWFramesContext *ctx) s->session_download = NULL; s->session_upload = NULL; + s->loader_download = NULL; + s->loader_upload = NULL; + s->session_download_init = 0; s->session_upload_init = 0; @@ -850,7 +1088,8 @@ static int qsv_transfer_data_from(AVHWFramesContext *ctx, AVFrame *dst, if (pthread_mutex_trylock(&s->session_lock) == 0) { #endif if (!s->session_download_init) { - ret = qsv_init_internal_session(ctx, &s->session_download, 0); + ret = qsv_init_internal_session(ctx, &s->session_download, + &s->loader_download, 0); if (s->session_download) s->session_download_init = 1; } @@ -924,7 +1163,8 @@ static int qsv_transfer_data_to(AVHWFramesContext *ctx, AVFrame *dst, if (pthread_mutex_trylock(&s->session_lock) == 0) { #endif if (!s->session_upload_init) { - ret = qsv_init_internal_session(ctx, &s->session_upload, 1); + ret = qsv_init_internal_session(ctx, &s->session_upload, + &s->loader_upload, 1); if (s->session_upload) s->session_upload_init = 1; } @@ -1121,6 +1361,7 @@ static void qsv_device_free(AVHWDeviceContext *ctx) if (hwctx->session) MFXClose(hwctx->session); + MFXUnload(hwctx->loader); av_buffer_unref(&priv->child_device_ctx); av_freep(&priv); } @@ -1194,34 +1435,11 @@ static int qsv_device_derive_from_child(AVHWDeviceContext *ctx, goto fail; } - err = MFXInit(implementation, &ver, &hwctx->session); - if (err != MFX_ERR_NONE) { - av_log(ctx, AV_LOG_ERROR, "Error initializing an MFX session: " - "%d.\n", err); - ret = AVERROR_UNKNOWN; - goto fail; - } + ret = qsv_create_mfx_session(ctx, handle_type, implementation, &ver, + &hwctx->session, &hwctx->loader); - err = MFXQueryVersion(hwctx->session, &ver); - if (err != MFX_ERR_NONE) { - av_log(ctx, AV_LOG_ERROR, "Error querying an MFX session: %d.\n", err); - ret = AVERROR_UNKNOWN; + if (ret) goto fail; - } - - av_log(ctx, AV_LOG_VERBOSE, - "Initialize MFX session: API version is %d.%d, implementation version is %d.%d\n", - MFX_VERSION_MAJOR, MFX_VERSION_MINOR, ver.Major, ver.Minor); - - MFXClose(hwctx->session); - - err = MFXInit(implementation, &ver, &hwctx->session); - if (err != MFX_ERR_NONE) { - av_log(ctx, AV_LOG_ERROR, - "Error initializing an MFX session: %d.\n", err); - ret = AVERROR_UNKNOWN; - goto fail; - } err = MFXVideoCORE_SetHandle(hwctx->session, handle_type, handle); if (err != MFX_ERR_NONE) { @@ -1236,6 +1454,8 @@ static int qsv_device_derive_from_child(AVHWDeviceContext *ctx, fail: if (hwctx->session) MFXClose(hwctx->session); + + MFXUnload(hwctx->loader); return ret; } diff --git a/libavutil/hwcontext_qsv.h b/libavutil/hwcontext_qsv.h index 42e34d0dda..65415d3d8c 100644 --- a/libavutil/hwcontext_qsv.h +++ b/libavutil/hwcontext_qsv.h @@ -19,8 +19,23 @@ #ifndef AVUTIL_HWCONTEXT_QSV_H #define AVUTIL_HWCONTEXT_QSV_H +#include #include +#if (MFX_VERSION_MAJOR < 2) + +typedef void * mfxLoader; + +static av_always_inline void MFXUnload (mfxLoader mfxloader) +{ +} + +#else + +#include + +#endif + /** * @file * An API-specific header for AV_HWDEVICE_TYPE_QSV. @@ -33,6 +48,7 @@ * This struct is allocated as AVHWDeviceContext.hwctx */ typedef struct AVQSVDeviceContext { + mfxLoader loader; mfxSession session; } AVQSVDeviceContext; From patchwork Mon Aug 16 07:33:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xiang, Haihao" X-Patchwork-Id: 29549 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2a4a:0:0:0:0 with SMTP id k10csp1800402iov; Mon, 16 Aug 2021 00:35:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz7Qt27UKJAa8BSdCKgX+YouhWeNb6UWtlPDTTA4zTU2gX/XFTSzdnhc80x7IZJJe7TCVqe X-Received: by 2002:aa7:cc0d:: with SMTP id q13mr9435371edt.109.1629099332860; Mon, 16 Aug 2021 00:35:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629099332; cv=none; d=google.com; s=arc-20160816; b=FsGxzweDexNpy+8MyjHO5N3r684iTWAbGlxqVQ4ix+EqOxKskawpP/KsPhlydzccS6 XYu82b7voyAOACWdV8cYsL3lJ+L5MSNaHHNqQUwJKPm5NZQtWs8PGU59o8uiDO1P7/sW bFUwft6Semh6UVm6r5T2q4x8/KDKEVW0AkFjKQFIougfSewjayOhXlx+Epmehi/RFxTe mdZqb8xrThxZfgdFKfoyu/yURFx2/lPpBYzSMMaiSV0kHcFOXOa0x7MMX7cl8luepI62 IbSPv3CzO7T5QCwL+0CAVH7uHSeDXsAJZwNJxvGa9vDm/qX8GMxgI7FE76reHVc3ewzw k01g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:delivered-to; bh=jHOB1E2jk4el1ArMn8i2wSBLBPQVmVvCwEkVPp5b/FI=; b=QPIwF06qPZZDfibp+AB56rQbPqCVfEouLAdrXpLR60ZVzsq2jXUmOMFs4/4dwwKYTI Kd0oHcHrLmY67sszrs0z/cWD4zBJBxBhwRjw3YMkj5wvmnEryNAiAFrsiOtepAUn8wNU bZ+1oD8yDLFAJ4P5uAMyH4NZEFxwoeVLFPVny9BlZ89WmC5y0axc4aZANm1FAZF7eAr/ 8A3UJ6WHGbWTmjNoV8Gr/b5G3SQIdjjLtlPn1zHt4lU2WwRbhGkr2qlPJR9+/VTY4vMX t4AbPPJmrtitYy0rUgF1NlW2lgZVYdT8Xu9h+HWPMxjSp0j5/Yu04Aqr03kW06ZayoEp ZptQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id ec28si10459048edb.404.2021.08.16.00.35.32; Mon, 16 Aug 2021 00:35:32 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4B24568A646; Mon, 16 Aug 2021 10:34:04 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0347368A5F3 for ; Mon, 16 Aug 2021 10:33:52 +0300 (EEST) X-IronPort-AV: E=McAfee;i="6200,9189,10077"; a="301396339" X-IronPort-AV: E=Sophos;i="5.84,324,1620716400"; d="scan'208";a="301396339" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Aug 2021 00:33:51 -0700 X-IronPort-AV: E=Sophos;i="5.84,324,1620716400"; d="scan'208";a="519461897" Received: from xhh-dg164.sh.intel.com ([10.239.159.167]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Aug 2021 00:33:50 -0700 From: Haihao Xiang To: ffmpeg-devel@ffmpeg.org Date: Mon, 16 Aug 2021 15:33:25 +0800 Message-Id: <20210816073325.27020-11-haihao.xiang@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210816073325.27020-1-haihao.xiang@intel.com> References: <20210816073325.27020-1-haihao.xiang@intel.com> Subject: [FFmpeg-devel] [PATCH v2 10/10] configure: add --enable-libvpl option 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: qNqUcD4PMOht This allows user to build FFmpeg against Intel's oneVPL SDK. oneVPL 2.2 is the required minimum version when building Intel oneVPL SDK code. It will fail to run configure script if both libmfx and libvpl are enabled. --- configure | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/configure b/configure index d3c0f63f85..b2e819a695 100755 --- a/configure +++ b/configure @@ -337,6 +337,7 @@ External library support: --disable-ffnvcodec disable dynamically linked Nvidia code [autodetect] --enable-libdrm enable DRM code (Linux) [no] --enable-libmfx enable Intel MediaSDK (AKA Quick Sync Video) code via libmfx [no] + --enable-libvpl enable Intel oneVPL SDK code via libvpl if libmfx is not used [no] --enable-libnpp enable Nvidia Performance Primitives-based code [no] --enable-mmal enable Broadcom Multi-Media Abstraction Layer (Raspberry Pi) via MMAL [no] --disable-nvdec disable Nvidia video decoding acceleration (via hwaccel) [autodetect] @@ -1895,6 +1896,7 @@ HWACCEL_LIBRARY_NONFREE_LIST=" HWACCEL_LIBRARY_LIST=" $HWACCEL_LIBRARY_NONFREE_LIST libmfx + libvpl mmal omx opencl @@ -6430,22 +6432,34 @@ enabled libilbc && require libilbc ilbc.h WebRtcIlbcfix_InitDecode -li enabled libklvanc && require libklvanc libklvanc/vanc.h klvanc_context_create -lklvanc enabled libkvazaar && require_pkg_config libkvazaar "kvazaar >= 0.8.1" kvazaar.h kvz_api_get enabled liblensfun && require_pkg_config liblensfun lensfun lensfun.h lf_db_new + +if enabled libmfx && enabled libvpl; then + die "ERROR: can not use libmfx and libvpl together" # While it may appear that require is being used as a pkg-config # fallback for libmfx, it is actually being used to detect a different # installation route altogether. If libmfx is installed via the Intel # Media SDK or Intel Media Server Studio, these don't come with # pkg-config support. Instead, users should make sure that the build # can find the libraries and headers through other means. - -enabled libmfx && { { check_pkg_config libmfx "libmfx < 2.0" "mfxvideo.h" MFXInit || +elif enabled libmfx; then + { check_pkg_config libmfx "libmfx < 2.0" "mfxvideo.h" MFXInit || \ # Some old versions of libmfx have the following settings in libmfx.pc: # includedir=/usr/include # Cflags: -I${includedir} # So add -I${includedir}/mfx to CFLAGS - { check_pkg_config libmfx "libmfx < 2.0" "mfx/mfxvideo.h" MFXInit && add_cflags -I$($pkg_config --variable=includedir libmfx)/mfx; } || - { require "libmfx < 2.0" "mfxvideo.h" MFXInit "-llibmfx $advapi32_extralibs" && warn "using libmfx without pkg-config"; } } && - warn "build FFmpeg against libmfx 1.x, obsolete features of libmfx such as OPAQUE memory,\n"\ - "multi-frame encode, user plugins and LA_EXT rate control mode are enabled"; } + { check_pkg_config libmfx "libmfx < 2.0" "mfx/mfxvideo.h" MFXInit && add_cflags -I$($pkg_config --variable=includedir libmfx)/mfx; } || + { require "libmfx < 2.0" "mfxvideo.h" MFXInit "-llibmfx $advapi32_extralibs" && warn "using libmfx without pkg-config"; } } && + warn "build FFmpeg against libmfx 1.x, obsolete features of libmfx such as OPAQUE memory,\n"\ + "multi-frame encode, user plugins and LA_EXT rate control mode are enabled" +elif enabled libvpl; then +# Consider pkg-config only. The name of libmfx is still used in the following check for --enable-vpl option +# because QSV has dependency on libmfx, we can use the same dependency if using libmfx in this check. + check_pkg_config libmfx "vpl >= 2.2" "mfxvideo.h mfxdispatcher.h" MFXLoad && \ + warn "build FFmpeg against oneVPL 2.2+, OPAQUE memory, multi-frame encode, user plugins\n"\ + "and LA_EXT rate control mode in FFmpeg QSV won't be supported." || + die "ERROR: libvpl >= 2.2 not found" +fi + if enabled libmfx; then check_cc MFX_CODEC_VP9 "mfxdefs.h mfxstructures.h" "MFX_CODEC_VP9" fi