From patchwork Mon Jul 25 04:11:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xiang, Haihao" X-Patchwork-Id: 36938 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:1649:b0:8b:613a:194d with SMTP id no9csp1814351pzb; Sun, 24 Jul 2022 21:12:25 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vxpbYHBsGf1waW+Y/XrS00zqmVwhDfC7C/8meBeOEaE9BKNXZRKk1/sizTrL2K1i6xJJRi X-Received: by 2002:a05:6402:331d:b0:43b:ee33:8a5e with SMTP id e29-20020a056402331d00b0043bee338a5emr4900879eda.49.1658722345256; Sun, 24 Jul 2022 21:12:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658722345; cv=none; d=google.com; s=arc-20160816; b=DEMGbbevs5VYlsed3TroJoJ4zKPCvQUZWpzdpNxz6byhcfC+sz3+H7btm6wjRtmhgy ADL8h5A4h9QDYFsAdqMWa+c+6bhk8Zr7N9FaRW5/6wSDy0JWargMnBZzRSGBxr7rTXqU R1xcljsOdhxUVias8mLXdjaNnekzqQK6sMdXcPQd77NvGKz9nslnYycK6jwZKrUuGF6J wf2UY3uuMuTBwAi0D275CkVIS7rbLDhnhDMUiY9fc6Fh/rLMFjY9CyiPaYnQ3FWPx1vK V16Z5KGVwVgYiOLNsynbB8ue/cLDLr/pdd6+f88YkDDh1w0Fsk0R4RktzFHpwul+5MvJ ECWg== 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:dkim-signature:delivered-to; bh=I8WG+IvGuZ4uIMzT8Z3JiVCd9j7ztNbna/JcKosXL3k=; b=k8ENW/jR9JuNG20Xv/ya7ehzbIrYisiZOnfF7nEDEgWUhrKy2TGKhhmhLQ/DAuNrGl pS1bfIrf42pQ+V7slUvr4S8Rpm12Jp0KRLld7w1iGtYs2XJpyY2D3apzGY54OtjzeFSr 4S0gCNaC3tj4FW4p/4MG6NMu6mPCeOfRkXVRQmadq41CZXmPW2ZySTGVIFktvG/0qok8 MfDR8bwO4r7Jf2cwA6UQNGaT8/X+DqfsTyHbplhcsi+terwW8WiY5x0kq1cxclZf5Hd1 hzJDfkCMsYKe1pugJMSIDZivm6lVcEKgHc7B0U5tGwVXHFPqWwQEUHJHIAiolZFWSFDo v5AQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b=JhqSG1mT; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id qk41-20020a1709077fa900b0072a6be70d30si13763242ejc.385.2022.07.24.21.12.24; Sun, 24 Jul 2022 21:12:25 -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; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b=JhqSG1mT; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7712168B7B9; Mon, 25 Jul 2022 07:12:13 +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 EDD4968B378 for ; Mon, 25 Jul 2022 07:12:05 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658722331; x=1690258331; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=X7SDer9iE1ImLo26egOeUCdUM916OU5P5JMd8m2LV/I=; b=JhqSG1mTjBFYRZgzP1xA0OU55ELg4dP8OKQf6tX6MFozDwL5PQqk/QY0 bP/7/n18Q6Mt4wPbu0tUGe6y9VTp94gY9YDGroPIudVMYbNbtmmL19jYp m58Iqqk5lKzEsN1dW0bqe+BH+xnymG+/v7H6UT2iaR1fQCdmJgOTc+Mt2 HlRlZwUfYvdiL1oHfuIfZWRtYOSVN2g9AhBLa0c+lCUqZDyfSLj5CoEFw 0YudiFJZCusPRjj2XZXdcAEn53+yj0H/XEfyODuRUYBLZx9e9Q3XDEgCu aIGVFIHrGquVUy2GZzc7tz15XZZuJ1rlAJMQnFwO93/amYOXKYae5Uslf w==; X-IronPort-AV: E=McAfee;i="6400,9594,10418"; a="274468200" X-IronPort-AV: E=Sophos;i="5.93,191,1654585200"; d="scan'208";a="274468200" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jul 2022 21:12:02 -0700 X-IronPort-AV: E=Sophos;i="5.93,191,1654585200"; d="scan'208";a="596543981" Received: from xhh-dg164.sh.intel.com ([10.238.5.169]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jul 2022 21:12:01 -0700 From: "Xiang, Haihao" To: ffmpeg-devel@ffmpeg.org Date: Mon, 25 Jul 2022 12:11:39 +0800 Message-Id: <20220725041151.7710-2-haihao.xiang@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220725041151.7710-1-haihao.xiang@intel.com> References: <20220725041151.7710-1-haihao.xiang@intel.com> Subject: [FFmpeg-devel] [PATCH v12 01/13] 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: 5kbWjyHTjFJu From: Haihao Xiang Intel's oneVPL is a successor to MediaSDK, but removed some obsolete features of MediaSDK[1], some early versions of oneVPL still use 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 ensure user builds FFmpeg against a right version of libmfx, this patch added a check for version < 2.0 and warning message about the used obsolete features. [1] https://spec.oneapi.io/versions/latest/elements/oneVPL/source/VPL_intel_media_sdk.html [2] https://github.com/oneapi-src/oneVPL --- configure | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/configure b/configure index 6629d14099..027fd756c4 100755 --- a/configure +++ b/configure @@ -6580,10 +6580,12 @@ 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 >= 1.28" "mfx/mfxvideo.h" MFXInit || - { require libmfx "mfx/mfxvideo.h mfx/mfxdefs.h" MFXInit "-llibmfx $advapi32_extralibs" && - { test_cpp_condition mfx/mfxdefs.h "MFX_VERSION >= 1028" || die "ERROR: libmfx version must be >= 1.28"; } && - warn "using libmfx without pkg-config"; } } +enabled libmfx && { { check_pkg_config libmfx "libmfx >= 1.28 libmfx < 2.0" "mfx/mfxvideo.h" MFXInit || + { require libmfx "mfx/mfxvideo.h mfx/mfxdefs.h" MFXInit "-llibmfx $advapi32_extralibs" && + { test_cpp_condition mfx/mfxdefs.h "MFX_VERSION >= 1028 && MFX_VERSION < 2000" || die "ERROR: libmfx version must be >= 1.28 and < 2.0"; } && + 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" From patchwork Mon Jul 25 04:11:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xiang, Haihao" X-Patchwork-Id: 36939 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:1649:b0:8b:613a:194d with SMTP id no9csp1814393pzb; Sun, 24 Jul 2022 21:12:35 -0700 (PDT) X-Google-Smtp-Source: AGRyM1smMXGTkoY3lTRWq3nKwaM7DC6HY3GCYIMkyRqupQCXWZwDHtYxA2HviRXVjx1P0bY4yWwr X-Received: by 2002:a17:907:2894:b0:72b:3554:353d with SMTP id em20-20020a170907289400b0072b3554353dmr8797600ejc.297.1658722355705; Sun, 24 Jul 2022 21:12:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658722355; cv=none; d=google.com; s=arc-20160816; b=pbB1RHvB7KtlgBRJorG9NKjJgLeSSO/qxD75rfkTEkkC3dzPfk6MoKsE0jbqAURGXD x0ZAAzHVtg4P4LSNUIZQwzAqQvFNbL4RDrVlEv//+mGb3ZXhptuSyGiVe2OwgC22kX3l +1ytH8MADcbY4NzcrqQzTAKp60Tsctwl4vMp0d7q7hd504k2OUmUa6Ntg9ZpbNZ2cVIm u6ldbVK7v6lrncHuMHeTYeDc2KjwS4ttiYflbzXxOECq5KQVb6/jHmhLWivuGxg02vGH ootlLF2J/N6paOXcpb0MoIG6neRPioS0DzvysmmMil0kJiU1Eb5OyrB+5b7w5i3L3w0D tDJA== 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:dkim-signature:delivered-to; bh=nNEXdS+7PzsoD8oB22oI7jQOf1Nuy6FSC4IcO8WOsEw=; b=eQ3Sk8QOucaZ0Y75S6xiVMxpbo1WmyCuL09BJsQeozbfEfsgDWZ0Tc/57JZD5htskH zxBxWQqZ3KFFWtjSSd2oH/i01j7iw6qYr13fcXDL2k1ZaigergRsvcBXslQZovs8dwJ6 82+FqShMLq80iwOpnQSmSooYF0sRF4oAgPPQurnPFKZ1e7QWaV8u1fvNMG/HO0iPZvYQ +zN+FaUuRkvyMa1yKhSC/d7rjWxAMOdRhPA7yJGnoCmXO1wOCngwTq3+nEE2jsVYZ1jy M235ztHZd9qzlmLSZpibyu5NnQYK8jhhihwbYWaJTw07cLXccsE6InQUro59U6lef32L WDIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b="oIKP/hLO"; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id hd34-20020a17090796a200b006fed9affed0si15085914ejc.528.2022.07.24.21.12.34; Sun, 24 Jul 2022 21:12:35 -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; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b="oIKP/hLO"; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 666E768B7D1; Mon, 25 Jul 2022 07:12:14 +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 BD2B968B378 for ; Mon, 25 Jul 2022 07:12:06 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658722331; x=1690258331; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=llqVbTszsBYvpYCOwRZnu8VUYC+RpLfUIsLZ35xLBYU=; b=oIKP/hLOLmDtOeN3QqzbYknVC2Y6TUv79GAEAz3WcZnMdi5LghPw4MU9 qr/ffaYCWWWTdENqFnZTXcOwJhNYW9dPeqF/zcThi8+DaxKTIDZRPuHEx PIjC7w0hUWr8Ebh4uQ+CbSOA40PhhIxbWioFNkqqwtyxq2NfTlu6SPJA3 KvuBiVesriLHgyzk41g667pvY9OWXIhoko7OTlPyVYPg6CzXI0yomaafq JNTvOgwBBAhMWXaOSdyigH8vAcIiPrOe1a7ldBFvDyrIKO07ZbtT2TrXB g+5G1EW4fNMGiQwid/obR4bylDLRIGtCDhsdjL9HVXyGifflG06QT1ouq w==; X-IronPort-AV: E=McAfee;i="6400,9594,10418"; a="274468205" X-IronPort-AV: E=Sophos;i="5.93,191,1654585200"; d="scan'208";a="274468205" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jul 2022 21:12:03 -0700 X-IronPort-AV: E=Sophos;i="5.93,191,1654585200"; d="scan'208";a="596543987" Received: from xhh-dg164.sh.intel.com ([10.238.5.169]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jul 2022 21:12:02 -0700 From: "Xiang, Haihao" To: ffmpeg-devel@ffmpeg.org Date: Mon, 25 Jul 2022 12:11:40 +0800 Message-Id: <20220725041151.7710-3-haihao.xiang@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220725041151.7710-1-haihao.xiang@intel.com> References: <20220725041151.7710-1-haihao.xiang@intel.com> Subject: [FFmpeg-devel] [PATCH v12 02/13] 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: TrKzTpwrJrCY From: Haihao Xiang 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 are 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 027fd756c4..33ca654424 100755 --- a/configure +++ b/configure @@ -6588,7 +6588,7 @@ enabled libmfx && { { check_pkg_config libmfx "libmfx >= 1.28 libmfx "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 Jul 25 04:11:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xiang, Haihao" X-Patchwork-Id: 36940 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:1649:b0:8b:613a:194d with SMTP id no9csp1814436pzb; Sun, 24 Jul 2022 21:12:43 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vhlPqLJ2tifQvVRQCmmS+Q3VaRHzBtW6NCOwi0F1AoIZKZqhmHjCn7qfmagnpas2EwlX34 X-Received: by 2002:a17:906:4793:b0:72f:b204:c277 with SMTP id cw19-20020a170906479300b0072fb204c277mr8160299ejc.497.1658722363801; Sun, 24 Jul 2022 21:12:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658722363; cv=none; d=google.com; s=arc-20160816; b=JUPjT6EJJ/35DjBSiSAnLQlAnflc/lmnGny9rk2RPQIuGSCcXAIWOLyf5tlnIQwq5j Q/pQOps8k4fChTuH+WpQ/kzxvJaZMOzP6SLgyXi0bN6IN1H7Liv/kI1RH6527OMDPaCG zrgrwwxXSEIZF7UZcM8CFiePVm5/fyr53+Ou3CH/zOt5lmMxcXIvWj6NxSsG0I4l/b/l BR3/uhjPPTurVjBsTAFqJ0rJXv3OGmfdxPntBNUbw9X4KdxJkNFJaBvyLw9PEbxH9KZe P6th1oJ4XLvuc6Uv3mr7DJ7Xj6enFRZH0FBWEz06nvPK8pZ/bwCt9Bgr0evbUS7xcYPE ljGQ== 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:dkim-signature:delivered-to; bh=APxP5bs7hU1XTB3kxcSi9PGu/2alUVksGNaIMC6G+wI=; b=UHlG0d7nTNN3hVvCKLNvTsqzKreEdtoKpZT2+b0ko/4ayPfY7e8dCDP1PNMQyAxikj Tb6HdnTbNJQDR68cOw692aMBQBbFBRtfl3uK0vvOVHUuTB+Efv7MmAWEr5COWCl+utJw rwkdOhXrMbviJbcn4YYSySzD5IPbJf8evxFutVMHehGmWVH3Ro3OaL6uQ6SJIedozBsh Hnck6SiPQJ6IX5CRcnNg40OesbaYAPhhBJ3w9BBDpIt8x6Xu5oq28stRpTckE8pPO9KJ yR3OEcNEZmR/wJGv8a9d43/Vu1GDabng5S01nAasBqzpQ8VZhbSccuub5vvw8KjD8Yj8 et7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b="A4g/0iQS"; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id c11-20020a17090603cb00b00726dbafec2asi10679792eja.446.2022.07.24.21.12.43; Sun, 24 Jul 2022 21:12: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; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b="A4g/0iQS"; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 65B7A68B7D2; Mon, 25 Jul 2022 07:12:16 +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 6874E68B7D2 for ; Mon, 25 Jul 2022 07:12:09 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658722334; x=1690258334; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=Uz5UD7BMbIs3Z/LMer/RsFYo3CuhzOZSK1c4SjpH/MQ=; b=A4g/0iQSxPbvdj9ZhFTeJrA9pTXTgz6K8mfGoKlcV0EbiM5XY20JOWcb H9mDoShCELDS6K3QTnHiGD8wqOpYtJy89/CytOu91DwYjq6VN8jWWPTb2 zB/HdT9YLsisvpLKxTQh9rJCGKsi87jHy1FAr+WXbXTKdTg1bCSCrilIq MTxAFArgnTDuSW4weK/NFhxuZYwLkyzJ9GnKLssOOFM0NUWdx3OB2NDtj AaRZuXSS97uakxvko8h3sKrMMgb9mjjGKgkHevki7R5Of/4WU5e74ZGTD 9+8GComsmr55gjHQ8r/9QIk0OuZZsGm7MQ58PgROhX0winjmP2DNw5ISd w==; X-IronPort-AV: E=McAfee;i="6400,9594,10418"; a="274468207" X-IronPort-AV: E=Sophos;i="5.93,191,1654585200"; d="scan'208";a="274468207" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jul 2022 21:12:05 -0700 X-IronPort-AV: E=Sophos;i="5.93,191,1654585200"; d="scan'208";a="596543997" Received: from xhh-dg164.sh.intel.com ([10.238.5.169]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jul 2022 21:12:03 -0700 From: "Xiang, Haihao" To: ffmpeg-devel@ffmpeg.org Date: Mon, 25 Jul 2022 12:11:41 +0800 Message-Id: <20220725041151.7710-4-haihao.xiang@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220725041151.7710-1-haihao.xiang@intel.com> References: <20220725041151.7710-1-haihao.xiang@intel.com> Subject: [FFmpeg-devel] [PATCH v12 03/13] 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: 40ecU2kkIFIM From: Haihao Xiang 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 | 19 ++++++++++++------- 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, 32 insertions(+), 27 deletions(-) diff --git a/configure b/configure index 33ca654424..8a6702f2a8 100755 --- a/configure +++ b/configure @@ -6580,15 +6580,20 @@ 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 >= 1.28 libmfx < 2.0" "mfx/mfxvideo.h" MFXInit || - { require libmfx "mfx/mfxvideo.h mfx/mfxdefs.h" MFXInit "-llibmfx $advapi32_extralibs" && - { test_cpp_condition mfx/mfxdefs.h "MFX_VERSION >= 1028 && MFX_VERSION < 2000" || die "ERROR: libmfx version must be >= 1.28 and < 2.0"; } && - 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"; } +enabled libmfx && { { check_pkg_config libmfx "libmfx >= 1.28 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 >= 1.28 libmfx < 2.0" "mfx/mfxvideo.h" MFXInit && add_cflags -I${libmfx_incdir}/mfx; } || + { require libmfx "mfxvideo.h mfxdefs.h" MFXInit "-llibmfx $advapi32_extralibs" && + { test_cpp_condition mfxdefs.h "MFX_VERSION >= 1028 && MFX_VERSION < 2000" || die "ERROR: libmfx version must be >= 1.28 and < 2.0"; } && + 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 385b43bb6c..25331ccce8 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 @@ -38,7 +38,7 @@ #define MFX_IMPL_VIA_MASK(impl) (0x0f00 & (impl)) -#include "mfx/mfxvp8.h" +#include "mfxvp8.h" 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 8131acdae9..cb1e55ae30 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 d8283b9207..edbe7bcdee 100644 --- a/libavcodec/qsvdec.c +++ b/libavcodec/qsvdec.c @@ -27,7 +27,7 @@ #include #include -#include +#include #include "libavutil/common.h" #include "libavutil/fifo.h" diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index 7594091a4b..e772bd99b5 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -25,7 +25,7 @@ #include #include -#include +#include #include "libavutil/common.h" #include "libavutil/hwcontext.h" diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h index bffe957526..4cadc38a59 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 7756dc1789..64c22852d2 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 b09640365c..1d92b8ec13 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 c5b6a406a5..582886c7c0 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 7340ece9a9..8ed578c396 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 3662df1823..7ae392da75 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 4fe07ab1f7..543c58a967 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 fb54d179ed..b8ff3e8339 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 da3c2eca86..af0e85bd03 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 32aec7d228..247834aaf6 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 56dffa1f25..99735f5557 100644 --- a/libavutil/hwcontext_qsv.c +++ b/libavutil/hwcontext_qsv.c @@ -20,7 +20,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 Jul 25 04:11:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xiang, Haihao" X-Patchwork-Id: 36941 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:1649:b0:8b:613a:194d with SMTP id no9csp1814489pzb; Sun, 24 Jul 2022 21:12:53 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sbR/yTaNnUSvMwZmRcPpFaOJMPH+6PJrHT8CGnY42cKAW+HkPNtRs46SvfyAxydKZBRjJq X-Received: by 2002:a17:907:3d90:b0:72f:2994:74a1 with SMTP id he16-20020a1709073d9000b0072f299474a1mr8793444ejc.261.1658722373714; Sun, 24 Jul 2022 21:12:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658722373; cv=none; d=google.com; s=arc-20160816; b=JnsuvxpOk1qEXvgHnPURSCw/GFOq0QLZ2CAlukQFnG63P+T5etNxbalVySbVRVwcoz pfjPSNxrvFxyVP+tiI0WWNkHqkKk43MiA1Azm2+Nk175VMQ1nDR9CEvIFp2TYLqOxBTi yi3PrW8qNMR3kNdhCui4hxau13ovvWaDQLhk24QIvgFlWuag73GtlVuTbZpGUUHPrT7U ZCEJc2Co2CIpZPjiNitRrKEHGMaPhYRQk6zn7aPrThp1OEEsoPs5TEXEFLc+Bn6YXgLO RpEx6k25NoXtuyfZlvBbBlyIfOIb+tusy0h/AzBwtbCPlSbosCSscJsMxAeMzXUWnQnk 4Adg== 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:dkim-signature:delivered-to; bh=AnwdXoqeq+gGMKX3JXkusg4oX3usHY0A/1vG+GLLbGs=; b=cRnip5MKgLub03bS661M56Y1Vn/ql214LItWbEy3vfRFpANUfpzaiA+soclovIw5U+ mjCruWVjkdxCI+HlGj8+GtZDlVWo9XJKnFnpkzvkHSwyY3eoOyU+WoZwa5rCLDRdmuy1 iyDVgtBIdGHLzx9rhdHh1ntcb8xtMB/fU+Z706J2DtPMog7S14mvXwpWBPoZnYhthqTb w3m4BD4RJlPpMl9VpbCbMEXcIaFEzHxagogJgfA4zMzr6MZFfDJS9uRxyTfujBOJpL3E ymjZndrX77QyDR5ixqcXli87/k1GW93/9oihGd+B0+r7Kkuw8XRAKEQ/rwiDjVPAi+JI eOlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b=CQxkEaEH; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id m20-20020a17090607d400b0072b1b099d55si11327961ejc.268.2022.07.24.21.12.53; Sun, 24 Jul 2022 21:12:53 -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; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b=CQxkEaEH; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6149968B7EA; Mon, 25 Jul 2022 07:12:19 +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 D85DD68B7D8 for ; Mon, 25 Jul 2022 07:12:11 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658722337; x=1690258337; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=6T3q/ixzmvd37cl6Wq8idExBe1EPyKa3CgsePxX190Q=; b=CQxkEaEHVX3pYXgNp6JBoDuL2BYGI9Q7bBu+NRzgQhewrUNEMBZlW8hY Xj0xjKf3Vxgq2aw029aM+kFS+vG+J4iy8CluB1veN+aXiH73UNnQecUY8 sSS3NMBEYcsxnJwtcKuWaELl7vw9+VOAMmZILeUQu21l+gfaApOJRQOYi iUj2Tbn6hECLR6m4IyDuaXSPnUDD88VbAGy5I+ivOWd+aaCEks4WUNfYh Au/ymzBRmVz1mf8Az0J93n9PGGouMNDi/VFB0NxyFlpEmujr0OPaFwU0S IjzqpawLsOzSiaG1jJJnOT3ST0wpARv5451r1wq8+5Z6pcKyxte0122Fk w==; X-IronPort-AV: E=McAfee;i="6400,9594,10418"; a="274468211" X-IronPort-AV: E=Sophos;i="5.93,191,1654585200"; d="scan'208";a="274468211" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jul 2022 21:12:06 -0700 X-IronPort-AV: E=Sophos;i="5.93,191,1654585200"; d="scan'208";a="596544003" Received: from xhh-dg164.sh.intel.com ([10.238.5.169]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jul 2022 21:12:05 -0700 From: "Xiang, Haihao" To: ffmpeg-devel@ffmpeg.org Date: Mon, 25 Jul 2022 12:11:42 +0800 Message-Id: <20220725041151.7710-5-haihao.xiang@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220725041151.7710-1-haihao.xiang@intel.com> References: <20220725041151.7710-1-haihao.xiang@intel.com> Subject: [FFmpeg-devel] [PATCH v12 04/13] qsv: restrict user plugin to 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: 6xA0cS+HoRe+ From: Haihao Xiang 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/VPL_intel_media_sdk.html#msdk-full-name-feature-removals [2] https://github.com/oneapi-src/oneVPL --- libavcodec/qsv.c | 8 +++++++- libavcodec/qsv_internal.h | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c index 25331ccce8..74fc8ff18e 100644 --- a/libavcodec/qsv.c +++ b/libavcodec/qsv.c @@ -19,7 +19,6 @@ */ #include -#include #include #include @@ -37,9 +36,14 @@ #include "qsv_internal.h" #define MFX_IMPL_VIA_MASK(impl) (0x0f00 & (impl)) +#define QSV_HAVE_USER_PLUGIN !QSV_ONEVPL #include "mfxvp8.h" +#if QSV_HAVE_USER_PLUGIN +#include +#endif + int ff_qsv_codec_id_to_mfx(enum AVCodecID codec_id) { switch (codec_id) { @@ -323,6 +327,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; @@ -366,6 +371,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 cb1e55ae30..949955bda0 100644 --- a/libavcodec/qsv_internal.h +++ b/libavcodec/qsv_internal.h @@ -65,6 +65,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; mfxHDLPair *handle_pair; From patchwork Mon Jul 25 04:11:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xiang, Haihao" X-Patchwork-Id: 36942 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:1649:b0:8b:613a:194d with SMTP id no9csp1814535pzb; Sun, 24 Jul 2022 21:13:03 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tawTwQdJgwJ5nSbairUOE5CC26qWGfovemRNptH2EBUgi7xy2BETzDQviDiv9uwe7Tpj9s X-Received: by 2002:a17:907:2854:b0:72b:7daf:cc0d with SMTP id el20-20020a170907285400b0072b7dafcc0dmr8482511ejc.524.1658722383189; Sun, 24 Jul 2022 21:13:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658722383; cv=none; d=google.com; s=arc-20160816; b=T3oAgls7WSZ+lhVx0rjPwT57goS8Nd07FEspBoG8NlbhduQaDlko6jt5LmfoxmaNl+ aGeg9wEy7t5KwhcYrZqY2w23DrFu9AF7+TK4E4QhgQeV8GKIBWW2ryaHqNfcQVk2Gipw 0S8zrfH4lQtPvYNN1+SBowtuueNY75jDokT/oktGZVEfbHwgWaNB5/+M+xvp2PJEdA0o 6KCx4p4xD6jn1ufSri2+Xj4VAv0XdTF829gN18Yy6rzskuur9vLRxMI/AeuLm07EqgD+ rcADl1Ykh1FeHzDdSko/LNp3jJGVUrGpOpeUgwsgFWARpiPVCq5Yw/rM+RQAaTtoX/tz ck2A== 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:dkim-signature:delivered-to; bh=YppFaNTspxGG1tRHKEBWi5Yq6QkSq30ehXL3zrNRcNk=; b=sTdkfoLGmWg6Khm9EjG9nFyrGoEJgtlcIjejCM951S7ueAcp4YJ8XOwLHqLiAGT7FN M4l2a2jmm9k+WV8Ho6Xge9iZtnlHOaFu7xGQU2wuGJ0TTlzj1UywwAUU86BnzGk9a6Uh yRvm6JeqJP6LKurwMnim5gqq+WYv3tBYD8oUtW0cuaNh7o6pZyRPPkLaJ2ALmMzR5lKs IR+v5+2wikqjshy7C6Q2Jq8uYrwZ+C56pbNJDatcAgBhcPbmC2sRPNfD0TybCYFluzW1 CuXEaL4ezlQebgDSo2iy7vI0khtzfwbeHfiY6xOe6zBZ5IDezc6GHK4HPAQ7fFi1jywa 26ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b=bDewHuCz; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id z91-20020a509e64000000b0043bb9752e0csi13835054ede.406.2022.07.24.21.13.02; Sun, 24 Jul 2022 21:13:03 -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; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b=bDewHuCz; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1BF2168B7FC; Mon, 25 Jul 2022 07:12:20 +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 A86E368B7D8 for ; Mon, 25 Jul 2022 07:12:12 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658722337; x=1690258337; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=fCXU9LuwdZNTLvg5mpefjh4baFlfi5IJNBj3/bSHENs=; b=bDewHuCzgELjQUZhfuYB+OSGFBCXipu4KoIWMTG1Ul36xn5dLp/COhe2 u3jwzY4/vjxl4N40aYMF30nqZ2TacBCXJR0w00GEp0mVpv9MX1Um8ggXj R3tYwuev+QdR+NcZQXNZP4XALs5x0C6ygIiVHl8xpYfj6WoFtihSq8KNl rNWw8/SKHvpC1ZzSR1v8klj0vfF2nHRYoendYhKV5A1a0KOzynG97P0Fi 0teOJE46I/ilRalMyMqwRVH3a3buW3HBvV5KST7PdhyHqVcJ+g4UMbbXI Px/INJ4Qc94SZB6o9YNBiL0qIbYekGH9yRx89KokFEi4HKVcVY77DnwTc Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10418"; a="274468213" X-IronPort-AV: E=Sophos;i="5.93,191,1654585200"; d="scan'208";a="274468213" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jul 2022 21:12:07 -0700 X-IronPort-AV: E=Sophos;i="5.93,191,1654585200"; d="scan'208";a="596544009" Received: from xhh-dg164.sh.intel.com ([10.238.5.169]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jul 2022 21:12:06 -0700 From: "Xiang, Haihao" To: ffmpeg-devel@ffmpeg.org Date: Mon, 25 Jul 2022 12:11:43 +0800 Message-Id: <20220725041151.7710-6-haihao.xiang@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220725041151.7710-1-haihao.xiang@intel.com> References: <20220725041151.7710-1-haihao.xiang@intel.com> Subject: [FFmpeg-devel] [PATCH v12 05/13] qsv: restrict audio related code to 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: Yq/qnpm5IL4b From: Haihao Xiang 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/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 74fc8ff18e..cc4b6cfd5d 100644 --- a/libavcodec/qsv.c +++ b/libavcodec/qsv.c @@ -37,6 +37,7 @@ #define MFX_IMPL_VIA_MASK(impl) (0x0f00 & (impl)) #define QSV_HAVE_USER_PLUGIN !QSV_ONEVPL +#define QSV_HAVE_AUDIO !QSV_ONEVPL #include "mfxvp8.h" @@ -129,8 +130,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" }, @@ -140,7 +143,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 }; /** diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c index 954f882637..3647891d13 100644 --- a/libavfilter/qsvvpp.c +++ b/libavfilter/qsvvpp.c @@ -38,6 +38,8 @@ #define IS_SYSTEM_MEMORY(mode) (mode & MFX_MEMTYPE_SYSTEM_MEMORY) #define MFX_IMPL_VIA_MASK(impl) (0x0f00 & (impl)) +#define QSV_HAVE_AUDIO !QSV_ONEVPL + static const AVRational default_tb = { 1, 90000 }; typedef struct QSVAsyncFrame { @@ -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 543c58a967..802abd987d 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 Jul 25 04:11:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xiang, Haihao" X-Patchwork-Id: 36948 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:1649:b0:8b:613a:194d with SMTP id no9csp1814800pzb; Sun, 24 Jul 2022 21:14:00 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uQbeTIf9mIdLQOoLFpVBFMVNy4PSJhqpBqq7j8iSvafBQza9dI3vl7r7+pbeW2OPw5FjiB X-Received: by 2002:a17:907:2cf6:b0:72b:9d9b:2404 with SMTP id hz22-20020a1709072cf600b0072b9d9b2404mr8300067ejc.171.1658722440212; Sun, 24 Jul 2022 21:14:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658722440; cv=none; d=google.com; s=arc-20160816; b=sTPo4XwWOUgCmGf3MlHprcxa6OuB+6smInnEB3ooxSrs55tl6CGoIpkjlbswZ3ZR4x enoNToQSHWrR8zkm/fbitRRp0dGEMOUjx9dKQMpz+oXTeNY9cAmqwvzDbwVkD/Oc8+V3 KB+E/6VIbxCTjzrnVCexQ/0EO5wrcRRSWo0WAdZJUZb+ory1yfJXfuGbLZXbf+sKCK6B kPEcGcPFWp3avsu8srrlsWBKXFU6EDRhJ87ZNKDeMYJvp/e6Ge5w5nvkExVHWuZ/LK2L 0m5rtLWy9PZXyXtJnz2aTLaFq5fXxMm0lEG1HXBldUW+esOFl8mrVg5ZuHaIPcN2o9W7 Wvdw== 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:dkim-signature:delivered-to; bh=RHFgSf07JClSF0WvLIe+RGE7OsX3ofsMzvj0MkM9Xa8=; b=dWvRQXtqnH6ZQrWF+2FB4PQMZSzIVwTtr8SAw6osdoEsZjpYS5SJU0J9ir++TwVWV+ 4M34VxRCRZxi09FNf+Qd6o24sEFsbUn0zuQLg3CQZWCbFHKZFclsXxs/QvPiSqFbwlOd p2OVIssp/rhX+NCv1uCeNsyMs0k4f8+uODk/e23olJeq8WblBa264Cbua9CpVxL2Q22g OpZwWMp3rVkGdUY2STl/XDLu062m9ZhA7P4AGbJwn1FQGZufYOkc5yzFr4+NT8Xpe7s4 ppNGvX+3I1fQWX2S2XCuRT+v8xQi63uEME47mZ0+AXrH9FnvJyi9v1g3eGvZsTYJsErS /HNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b=fQLoZXhL; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id hg3-20020a1709072cc300b006fe8fdac65dsi12612301ejc.745.2022.07.24.21.13.59; Sun, 24 Jul 2022 21:14: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; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b=fQLoZXhL; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 85A2168B7DB; Mon, 25 Jul 2022 07:12:25 +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 55E1F68B7E6 for ; Mon, 25 Jul 2022 07:12:15 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658722340; x=1690258340; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=K0hg8uWa+SqFdbpqf4Shkmjy9DmGbZOcxp4gyL+3SSw=; b=fQLoZXhLlrzIpjkK2C8D2sTu5excfnv5ExGO4qDv9LxVltPepxfbdfL7 aAucxDr9iV0fZe/9+1ZZaFGOc1PEZ1rWX6XZglXk8yogSUuoIFnsven9E T5qFP48Ru3xkzlGVv8/viRhoTaVRJ7uza1OQ4eeAuwu3qdgJ+EVEJ3IIb R1jY5BQTF3vEgqtENVaTSvTgY9y3G31QTwRmIKJC2asN3XPudJDmr6ojg idziJaaDrAUpIxHIihjCH9cteWvu0GFvR6zeMcwXIfXmVYb0DxJQNnDW+ HLcyw1FWV2MiDe5FtzVuwSdx1GiM6dS8GxkTQJDhtTpRg2CMYQHT2l9VF w==; X-IronPort-AV: E=McAfee;i="6400,9594,10418"; a="274468216" X-IronPort-AV: E=Sophos;i="5.93,191,1654585200"; d="scan'208";a="274468216" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jul 2022 21:12:08 -0700 X-IronPort-AV: E=Sophos;i="5.93,191,1654585200"; d="scan'208";a="596544014" Received: from xhh-dg164.sh.intel.com ([10.238.5.169]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jul 2022 21:12:07 -0700 From: "Xiang, Haihao" To: ffmpeg-devel@ffmpeg.org Date: Mon, 25 Jul 2022 12:11:44 +0800 Message-Id: <20220725041151.7710-7-haihao.xiang@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220725041151.7710-1-haihao.xiang@intel.com> References: <20220725041151.7710-1-haihao.xiang@intel.com> Subject: [FFmpeg-devel] [PATCH v12 06/13] qsvenc: restrict multi-frame encode to 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: DyrVnDjnZLOe From: Haihao Xiang 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/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 4cadc38a59..40e2f65eff 100644 --- a/libavcodec/qsvenc.h +++ b/libavcodec/qsvenc.h @@ -44,7 +44,7 @@ #else #define QSV_HAVE_AVBR 0 #define QSV_HAVE_VCM 0 -#define QSV_HAVE_MF 1 +#define QSV_HAVE_MF !QSV_ONEVPL #endif #define QSV_COMMON_OPTS \ From patchwork Mon Jul 25 04:11:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xiang, Haihao" X-Patchwork-Id: 36943 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:1649:b0:8b:613a:194d with SMTP id no9csp1814580pzb; Sun, 24 Jul 2022 21:13:12 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sVYC0tOYYgLB3olm/QmqQfCvoz1rOUeT28UUhDY/cptlsNosxunpqD4djuvUGalBcwlXdK X-Received: by 2002:a17:907:a05b:b0:72b:33f9:f927 with SMTP id gz27-20020a170907a05b00b0072b33f9f927mr8766495ejc.707.1658722392359; Sun, 24 Jul 2022 21:13:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658722392; cv=none; d=google.com; s=arc-20160816; b=v+Xth6ypAsZFrTI1EOBNgdtz5DcoavkTERlnGIWp+M/Ktr4XevZzy1OXQ3Nq6HCRw5 j3w3vypHT3XsJr1rKrb6iWURFLl3KhlnN2JpPTPEfbjIqsJqXE5wSlk5eygB4ihg7qHG 1b7eCsMpneHNEXixDBLncu7TBGdRwPxU2EP7/NKCfA8uivMe9NObNnzwWP70749uAh+/ qWNcIsns20YishaaMi+qTubst1c7ouu3R2SMP19eb+xprpE//3GBmuaYJDhLrnqEEwt2 aE1QuaHVWOX3Mgp114MHaEcOQfoDvTkThK3pBLvIAi612rE57wyos/fIwgPL4YzW3wTC Kttg== 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:dkim-signature:delivered-to; bh=MbIOcljK7f99D4KEW9+BlxSe3OCfVTffCZTJcvsSll8=; b=Bxmnv+U6oUKQkOEGwX8KmkmaCsZlweUn2EvLlqxehddeYubERJKEFpugiNU4Gt5Grd M5KMFI06DrzKlM5kWbzTwG00xlF42bnaESmGYJTi5H8XBJrScUVSD+xXNW15o2Tc3Ggz bNc2MIgWgQFUEwqNESElyTxpWeByenLnaLZWOSNGfoqBaFLdwgBMTfnT4cZFUrlSC3oK RLBtqDqrnaCejVfMdcboFztfJf0JISWr6xUlMDQ5cmLMhMtEfxD7h0UXkfErsZ6n8LW1 b4W5rO+56/Whc6uW28so2hnjK/79/wGDAhrFCgQQeMTmT25rek+2TA07wjQCTrYL4EJS JvoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b=lKvJIvs2; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id sd6-20020a1709076e0600b0072f1cccbc62si13233432ejc.641.2022.07.24.21.13.12; Sun, 24 Jul 2022 21:13:12 -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; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b=lKvJIvs2; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C2AD068B83C; Mon, 25 Jul 2022 07:12:20 +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 0715468B7DB for ; Mon, 25 Jul 2022 07:12:17 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658722338; x=1690258338; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=i1mR8QdpsiJbS8YxMGnj/fu2UbCa2e+vA4OG4/kMvIg=; b=lKvJIvs2lbFlnct1PJHThw2N+piuBVJ5gt1OnAKSfHQ7KlbFwaoA+TW9 uY7mp+5uFQMF9kIik5f88A0E8D7Ri++cEUFs51rC2zMcwzc0GS6glErIN 4edzP1KuMOcrNok0GOF6d/9QOoP6EspovJTdDBABkj76sGspNtSnTWbo/ 25kp3N8Olmvw/+BU/J+TzsVwmLrEBWo1dZu157QwrCa4tO8XwMTKvj0oz tSNIS/HSnw4pvyshRrAnnTpIAp3P7FhUSIor/YRmipmkVavANppUD2vpv CBZneJQIBPtHq6AY7rDX/1TERIGsOUfTiU2aZApXJ5/5cvasxPiDQlCtn g==; X-IronPort-AV: E=McAfee;i="6400,9594,10418"; a="274468217" X-IronPort-AV: E=Sophos;i="5.93,191,1654585200"; d="scan'208";a="274468217" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jul 2022 21:12:10 -0700 X-IronPort-AV: E=Sophos;i="5.93,191,1654585200"; d="scan'208";a="596544019" Received: from xhh-dg164.sh.intel.com ([10.238.5.169]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jul 2022 21:12:09 -0700 From: "Xiang, Haihao" To: ffmpeg-devel@ffmpeg.org Date: Mon, 25 Jul 2022 12:11:45 +0800 Message-Id: <20220725041151.7710-8-haihao.xiang@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220725041151.7710-1-haihao.xiang@intel.com> References: <20220725041151.7710-1-haihao.xiang@intel.com> Subject: [FFmpeg-devel] [PATCH v12 07/13] qsvenc: restrict MFX_RATECONTROL_LA_EXT to 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: x7Ss/C+sozL3 From: Haihao Xiang 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/VPL_intel_media_sdk.html#msdk-full-name-feature-removals [2] https://github.com/oneapi-src/oneVPL --- libavcodec/qsvenc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index e772bd99b5..d3a9a2118e 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -141,7 +141,9 @@ static const struct { #if QSV_HAVE_VCM { MFX_RATECONTROL_VCM, "VCM" }, #endif +#if !QSV_ONEVPL { MFX_RATECONTROL_LA_EXT, "LA_EXT" }, +#endif { MFX_RATECONTROL_LA_HRD, "LA_HRD" }, { MFX_RATECONTROL_QVBR, "QVBR" }, }; From patchwork Mon Jul 25 04:11:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xiang, Haihao" X-Patchwork-Id: 36944 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:1649:b0:8b:613a:194d with SMTP id no9csp1814630pzb; Sun, 24 Jul 2022 21:13:22 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t/PCKSMYBlWFPi0LwzFtM9fc4gaqWUcTi+UPnTxgxTpv6wVAVo2BYcMxY88OMpbnJIGSsT X-Received: by 2002:a05:6402:d0a:b0:437:f9a1:8493 with SMTP id eb10-20020a0564020d0a00b00437f9a18493mr11288082edb.226.1658722401825; Sun, 24 Jul 2022 21:13:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658722401; cv=none; d=google.com; s=arc-20160816; b=CyH6GX0i+Knqt3hkhG2u+3CutKhOxADjpYq+keZIew3Y03vfbjW/ADcg+JgIh6ntMd B67nyVn0cY4IAD+WVwi5kw0oqjKDhXS1FK398fbxnDHw6kwP1o3O7WyacLmKoWUh5tFD i48dYWAkJQI0Aqap2LfaUjKeEiNKuncTBntjW0BcXK6bGoSFkEH5jyPlkF+LEK7+E4QB FGDM7RkvN0L04ReEeqbneKaANTDZFDfFcPAqiebA+Lll2qT/ESbOgGuPnezv/UcYN93u UDE+kAEIdpt7+w88iS0O9yStoSN5N3UqLS7HFxU4dYMCRMge2+8oEwnC6PCLZxdvfUaS BWkg== 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:dkim-signature:delivered-to; bh=crSmFePEV+cpxUqq8DxGNquAYAgNUlUrgzU3PJenO3o=; b=VcWoofJRfY1uaPuDlWAfyQQtmwyQ7Da2fbuRAAoBMvk90ghA7JUc+DxkEt/q9coIam mdRL4lrXUElVBR6Fzu+XTvQROh6YynlGmrQbxaj9Cddz1gDquGYBo9rl490TNkW6EDhD /hKQMCMyT2/1Fd1VUyjl4fgAyeOoYXqSanr+xyMM+z0jbGv77csRdb+CV53toAU8TUeM teCPqU7WQad+rnXnsarqrrZSv7H+W0lkmMPuerkNit4ZCZ6hvv39s04lKTJpWXcZjjVz 0YMXTzD36yjDxWGnkRT/LzqOcYvzh7M4YU5/1D1g2ykFC2S1Okvp+21/pJl95bwX7ZHI 75Iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b=M0ehEFH3; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id g9-20020a056402090900b0043a735e3e22si12417972edz.600.2022.07.24.21.13.21; Sun, 24 Jul 2022 21:13: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; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b=M0ehEFH3; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id AC0BC68B800; Mon, 25 Jul 2022 07:12:21 +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 945EE68B7BA for ; Mon, 25 Jul 2022 07:12:18 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658722338; x=1690258338; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=BCghDp/DS5NOhmcfwjvrI+6F5Aln62sWCWKYxuXAdV4=; b=M0ehEFH32Q3x3iTKQFMG3wbV0yFIax9JJkbJn5zBb9GAPDMAiJu3Unpk M/yy+ze84kjDXzsGg+vBjkZFl6QtMQDlRbZ5tads0iuOUXB9yfiUkfB5L xhXwm0CqSRaVoNHk1x8m9pV6eVf839m+JH2KSFJIKW3bKl3jS2XljIb/a 1Rselg/vhcxY9oc9e9ijxGZfjmJm6kPmyNHs3jl5QeUMcUpRIImmq/0yb 5E65ap5jbee7nXygbCpkjENU9TFmDPBI6jkaa0FsEsKhLljHRjfoGeNsw qx61hMK/1Z/1pG2hgQGrLQXMTg5hMtYXAUHL5FTaTHm2+COLQ8CGXPU3U w==; X-IronPort-AV: E=McAfee;i="6400,9594,10418"; a="274468221" X-IronPort-AV: E=Sophos;i="5.93,191,1654585200"; d="scan'208";a="274468221" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jul 2022 21:12:11 -0700 X-IronPort-AV: E=Sophos;i="5.93,191,1654585200"; d="scan'208";a="596544031" Received: from xhh-dg164.sh.intel.com ([10.238.5.169]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jul 2022 21:12:10 -0700 From: "Xiang, Haihao" To: ffmpeg-devel@ffmpeg.org Date: Mon, 25 Jul 2022 12:11:46 +0800 Message-Id: <20220725041151.7710-9-haihao.xiang@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220725041151.7710-1-haihao.xiang@intel.com> References: <20220725041151.7710-1-haihao.xiang@intel.com> Subject: [FFmpeg-devel] [PATCH v12 08/13] qsv: restrict OPAQUE memory to 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: M6kHsS0ehd5/ From: Haihao Xiang 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/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 | 57 +++++++++++++----------- libavfilter/vf_scale_qsv.c | 74 ++++++++++++++++++-------------- libavutil/hwcontext_qsv.c | 56 +++++++++++++++++------- 11 files changed, 181 insertions(+), 74 deletions(-) diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c index cc4b6cfd5d..432675bccf 100644 --- a/libavcodec/qsv.c +++ b/libavcodec/qsv.c @@ -81,10 +81,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 949955bda0..d52f0dcd15 100644 --- a/libavcodec/qsv_internal.h +++ b/libavcodec/qsv_internal.h @@ -66,6 +66,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 edbe7bcdee..8b718a08ff 100644 --- a/libavcodec/qsvdec.c +++ b/libavcodec/qsvdec.c @@ -187,7 +187,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); @@ -300,10 +304,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 d3a9a2118e..4831640868 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -1176,6 +1176,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; @@ -1212,6 +1213,7 @@ static int qsv_init_opaque_alloc(AVCodecContext *avctx, QSVEncContext *q) return 0; } +#endif static int qsvenc_init_session(AVCodecContext *avctx, QSVEncContext *q) { @@ -1227,7 +1229,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); @@ -1279,11 +1285,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 } } @@ -1357,9 +1369,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); @@ -1913,8 +1932,10 @@ int ff_qsv_enc_close(AVCodecContext *avctx, QSVEncContext *q) av_fifo_freep2(&q->async_fifo); } +#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 40e2f65eff..c2def19658 100644 --- a/libavcodec/qsvenc.h +++ b/libavcodec/qsvenc.h @@ -137,9 +137,11 @@ typedef struct QSVEncContext { mfxExtHEVCTiles exthevctiles; mfxExtVP9Param extvp9param; +#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 3647891d13..3f984fd5f9 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 MFX_IMPL_VIA_MASK(impl) (0x0f00 & (impl)) @@ -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, @@ -536,9 +542,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 | MFX_MEMTYPE_FROM_VPPOUT; +#else + s->out_mem_mode = MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET | MFX_MEMTYPE_FROM_VPPOUT; +#endif out_frames_ctx = (AVHWFramesContext *)out_frames_ref->data; out_frames_hwctx = out_frames_ctx->hwctx; @@ -624,6 +634,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; @@ -635,7 +646,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_calloc(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_freep2(&s->async_fifo); av_freep(vpp); diff --git a/libavfilter/qsvvpp.h b/libavfilter/qsvvpp.h index 802abd987d..3e7d56021b 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 b8ff3e8339..50f9156d14 100644 --- a/libavfilter/vf_deinterlace_qsv.c +++ b/libavfilter/vf_deinterlace_qsv.c @@ -62,7 +62,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; @@ -154,9 +156,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; @@ -165,6 +165,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) @@ -223,28 +226,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_calloc(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, @@ -268,6 +250,31 @@ 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_calloc(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 af0e85bd03..fa0152d785 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 mfxExtVPPScaling scale_conf; int mode; @@ -268,7 +270,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; @@ -278,6 +280,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 */ @@ -330,38 +335,7 @@ static int init_out_session(AVFilterContext *ctx) memset(&par, 0, sizeof(par)); - if (opaque) { - s->surface_ptrs_in = av_calloc(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_calloc(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, @@ -393,6 +367,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_calloc(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_calloc(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 memset(&s->scale_conf, 0, sizeof(mfxExtVPPScaling)); s->scale_conf.Header.BufferId = MFX_EXTBUFF_VPP_SCALING; diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c index 99735f5557..21a2a805f8 100644 --- a/libavutil/hwcontext_qsv.c +++ b/libavutil/hwcontext_qsv.c @@ -55,6 +55,8 @@ MFX_VERSION_MAJOR == (MAJOR) && MFX_VERSION_MINOR >= (MINOR)) #define MFX_IMPL_VIA_MASK(impl) (0x0f00 & (impl)) +#define QSV_ONEVPL QSV_VERSION_ATLEAST(2, 0) +#define QSV_HAVE_OPAQUE !QSV_ONEVPL typedef struct QSVDevicePriv { AVBufferRef *child_device_ctx; @@ -86,11 +88,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 AVFrame realigned_upload_frame; AVFrame realigned_download_frame; } QSVFramesContext; @@ -299,7 +303,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_freep(&s->handle_pairs_internal); av_frame_unref(&s->realigned_upload_frame); @@ -535,11 +541,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); @@ -610,10 +622,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, @@ -627,6 +638,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"); @@ -648,15 +664,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; @@ -688,11 +707,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"); @@ -707,7 +730,16 @@ static int qsv_frames_init(AVHWFramesContext *ctx) } } - if (opaque) { + if (!opaque) { + s->mem_ids = av_calloc(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_calloc(frames_hwctx->nb_surfaces, sizeof(*s->surface_ptrs)); if (!s->surface_ptrs) @@ -726,14 +758,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_calloc(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 Jul 25 04:11:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xiang, Haihao" X-Patchwork-Id: 36945 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:1649:b0:8b:613a:194d with SMTP id no9csp1814677pzb; Sun, 24 Jul 2022 21:13:31 -0700 (PDT) X-Google-Smtp-Source: AGRyM1u0RA+Se8iJrwwzu/+s5FKnrZ/wbW4FgKz5hP3lF+JIvDznOBs0oODWebwrRra1lH2irHEt X-Received: by 2002:aa7:df07:0:b0:43b:de50:3573 with SMTP id c7-20020aa7df07000000b0043bde503573mr10009921edy.367.1658722411249; Sun, 24 Jul 2022 21:13:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658722411; cv=none; d=google.com; s=arc-20160816; b=GjQ+8AuWgDiQC3+ZLxo3G2KqkEd8QHQ18YgLezA1gWuR/SIvb2+6hx/eI79/mx7Ovu +V03oIbhCM4gpJ390qO3XuAZLq9Kg8jyfmzFOvcE64Q23kGYiLlhiIQlGLlUwRAfgFxI SIGih9LBeAh/YHWuZ3Fz+L+PIK0fzKL5w1RKpDr5kzcEdd0FhrwgYFDvpxERKPe2ctLq zO3rqpbkvaZMxPovAaBhSuPsfW8fAUh/NCbJN9DQlWK6gos7h0QvsIbzxBvAMbwRlmaQ 24HihD9BSpDDp9TskP0uEKp9oXYZP7DAqAQueEfPd5IZsJz8ptGkD51XAB0i/GpvISVO PDJg== 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:dkim-signature:delivered-to; bh=q6CyBPUyjTbkJrX+c/mAirBpLEYGrfKgsPk+Pxls2pc=; b=Doq8zWunnF+tN7Ly5VUNThELOmRm9owiT9pSGw8i1sEmWD2rEkXPu7kNml1ojatCqm XSpBU9iM/GY6RlyJ2FtAB/hPu0ae8X8PcQ+IxPO412lrhcxCMrlKlbNXuiJduFtePta3 bqsXqeu57NAklWPzU6bw0XsfZ8MCQngfmSwfR27aQHRD2QS682HbQ+OAhmOETwmaBOyH RwxAgG7Rq3lC/U1Bp0a374fxGWcS3RYC7HnpeLjErMz6N1FSlgMIfn3yZr/5kBtW8c6X Fd2G4+Sc+u/aEDij9Yx7vS0HmAG37IA6Fv9cK24Ur5itu6+zd/9aO8sMsYG4tevhXwRC sCSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b=BLNPc+4Q; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id gt13-20020a1709072d8d00b007156fe1aa6asi14208856ejc.650.2022.07.24.21.13.30; Sun, 24 Jul 2022 21:13:31 -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; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b=BLNPc+4Q; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9FDE468B804; Mon, 25 Jul 2022 07:12:22 +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 EC02F68B72C for ; Mon, 25 Jul 2022 07:12:18 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658722339; x=1690258339; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=Ku82n9OlQ4KwO5Tu9boTbaX37MVWsRzgUq4BFZTYncU=; b=BLNPc+4Q4XHpxvaiGmcDrdbL1EHmuogrj796VyHs+Lz1Nw+V0fgosotp +5ANbFSbr3DcXvmwGLsh/B6gp5tM4L8Kwo2UYa9L2ebU5yNkIfUUgtM+1 yMyil+NdZMCnPxykwQat+PU88fg8vaO1qc2+QunOXCrNJ8izSuf99mJ2I +RAYx3XKL1X1BfNK4i/2bDl/M0ea5rax0Xw/p9Nh4F6MUlH0I3DkEqjyV dpczo1MSU0ulOkr+QzAgLEUR3dANCWd4XAk2aer92ZcFdZRKLqco1nZ/t ssaohZxWk2UETO64a3INrmE7IImOZD+1SD6d2vipZ0Z1okkjMFM/lqw3G w==; X-IronPort-AV: E=McAfee;i="6400,9594,10418"; a="274468228" X-IronPort-AV: E=Sophos;i="5.93,191,1654585200"; d="scan'208";a="274468228" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jul 2022 21:12:12 -0700 X-IronPort-AV: E=Sophos;i="5.93,191,1654585200"; d="scan'208";a="596544034" Received: from xhh-dg164.sh.intel.com ([10.238.5.169]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jul 2022 21:12:11 -0700 From: "Xiang, Haihao" To: ffmpeg-devel@ffmpeg.org Date: Mon, 25 Jul 2022 12:11:47 +0800 Message-Id: <20220725041151.7710-10-haihao.xiang@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220725041151.7710-1-haihao.xiang@intel.com> References: <20220725041151.7710-1-haihao.xiang@intel.com> Subject: [FFmpeg-devel] [PATCH v12 09/13] lavu/hwcontext_qsv: add loader field to AVQSVDeviceContext 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: erk8fa+K/Rus From: Haihao Xiang In oneVPL, a valid mfxLoader handle is needed when creating mfx session for decoding, encoding and processing[1], so add loader field to AVQSVDeviceContext. User should fill this field before calling av_hwdevice_ctx_init() if using oneVPL 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 --- doc/APIchanges | 3 +++ libavutil/hwcontext_qsv.h | 11 +++++++++++ libavutil/version.h | 2 +- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/doc/APIchanges b/doc/APIchanges index b3563cd528..265361c979 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -14,6 +14,9 @@ libavutil: 2021-04-27 API changes, most recent first: +2022-07-xx - xxxxxxxxxx - lavu 57.31.100 - hwcontext_qsv.h + Add loader field to AVQSVDeviceContext + 2022-07-xx - xxxxxxxxxx - lavu 57.30.100 - frame.h Add AVFrame.duration, deprecate AVFrame.pkt_duration. diff --git a/libavutil/hwcontext_qsv.h b/libavutil/hwcontext_qsv.h index 42e34d0dda..e2dba8ad83 100644 --- a/libavutil/hwcontext_qsv.h +++ b/libavutil/hwcontext_qsv.h @@ -34,6 +34,17 @@ */ typedef struct AVQSVDeviceContext { mfxSession session; + /** + * The mfxLoader handle used for mfxSession creation + * + * This field is only available for oneVPL user. For non-oneVPL user, this + * field must be set to NULL. + * + * Filled by the user before calling av_hwdevice_ctx_init() and should be + * cast to mfxLoader handle. Deallocating the AVHWDeviceContext will always + * release this interface. + */ + void *loader; } AVQSVDeviceContext; /** diff --git a/libavutil/version.h b/libavutil/version.h index ee4c531b80..e9eefcdb2c 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -79,7 +79,7 @@ */ #define LIBAVUTIL_VERSION_MAJOR 57 -#define LIBAVUTIL_VERSION_MINOR 30 +#define LIBAVUTIL_VERSION_MINOR 31 #define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ From patchwork Mon Jul 25 04:11:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xiang, Haihao" X-Patchwork-Id: 36947 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:1649:b0:8b:613a:194d with SMTP id no9csp1814754pzb; Sun, 24 Jul 2022 21:13:50 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t8FFVA9o0nu1gCY/x3KG/FGslw+jgP7ufTunFcXpKuz0lDjTErwRrZThsIM8rD3I2a4ag5 X-Received: by 2002:a17:907:608d:b0:72f:191b:7625 with SMTP id ht13-20020a170907608d00b0072f191b7625mr8659933ejc.754.1658722430621; Sun, 24 Jul 2022 21:13:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658722430; cv=none; d=google.com; s=arc-20160816; b=TEUL/MbeikELm5A/BSJQNEUCv56+C03jnOzZz/0zNP930vn0G6+7RoLIYAVfDIGbM9 MmvvB5N18UVtDkCexbSHOHchq7c0GshdIciKI931xo0XtRRYdh+zxUkRA52B6Z9hG2sA CGpb6Ve+FN4VCyNIHex5gAyIixlYjsjDkiUYyzyp1HFbQgqNDXP3XLeTB7Y3Q2+47YlB 3MMd0kUlJMlxilhNHDZeD+wE9Em+5jDBn3B+XC1U8LfU1dK4TesQ4xyOZcDTgjIF65YV +4GLJrrUzgtjKrvqY6cm/iWFfNnyG6HXXGfJt+Cvcg/4B9lenWsVCL0Omim5FS/Gornk ZZzQ== 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:dkim-signature:delivered-to; bh=oltiS7B0ZxF0ZUm8pKJzI4WmdCjdyJN0AHxGVf5Fd9A=; b=e6SVXGE6/MXR1JCduDOOilhTeDNZNTb4c5kzBwxvpwET16npFpOh+bLjHw6n8dt0wR zd8PE082oUPj46+KmDeqC2tvGZR2yFGK8anoS2VnRAHTHvBXPnt6R8Z3YSowyCc2/fH9 vWPb1sxSU69QJd7gaOQ5H0aCNUf8qTUuLPcXMCCJ9n4CLjgtFI2Bn34TrdCWKcQt/jvT wNg4kB0Z/zK71TpepPbk0+5bqMZNlDRfcTDjgsR7wazNnoaQ1/bzfLAnYUxBO5EtV7Cf E3sloKCvbe8ADgRowHJX7Avd5w7U7sn0/n3Fc/SQj03X2xE8sj9qCrvWp9uGcv4IE+gx Vk7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b=XoVGSwN4; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id l15-20020a056402230f00b0043a71d95839si10358887eda.546.2022.07.24.21.13.50; Sun, 24 Jul 2022 21:13: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; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b=XoVGSwN4; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8137168B87D; Mon, 25 Jul 2022 07:12:24 +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 E319568B7E1 for ; Mon, 25 Jul 2022 07:12:19 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658722340; x=1690258340; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=i0fgplRIzUKWDHHLj8VwsI4HhAtqY+JcEOB1+wISYfg=; b=XoVGSwN4jWsrUwq8uEee2bonQnQlkRuhBI+lzVh6BJ67+VUZA3rO0HCk +C4iVhsel/nvv+hGUBA5qOuNwa1ELrdt81t20hoBbHtBXoOO3G+q+hnx8 QYZ8TmZR2kXLzHR/d48diizPpGLNA5ojku/23InbF4lBeHGLpDnqc2yiQ g+nRa3/QLrojs2JtqEbuhhieoSlVSefrR9OJwrXmCpfYzZGXXrKHaLvYJ usQGvx9b53v1ckxgR/ybsU0WoxGliFWcwUvQFZhQR8tT/arUsURYW+aKq McNr/U036o6AJJKzajsvls5iV4fe0knFgiK/GRLVrunTafBLLLZMMkHb+ w==; X-IronPort-AV: E=McAfee;i="6400,9594,10418"; a="274468235" X-IronPort-AV: E=Sophos;i="5.93,191,1654585200"; d="scan'208";a="274468235" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jul 2022 21:12:14 -0700 X-IronPort-AV: E=Sophos;i="5.93,191,1654585200"; d="scan'208";a="596544038" Received: from xhh-dg164.sh.intel.com ([10.238.5.169]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jul 2022 21:12:13 -0700 From: "Xiang, Haihao" To: ffmpeg-devel@ffmpeg.org Date: Mon, 25 Jul 2022 12:11:48 +0800 Message-Id: <20220725041151.7710-11-haihao.xiang@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220725041151.7710-1-haihao.xiang@intel.com> References: <20220725041151.7710-1-haihao.xiang@intel.com> Subject: [FFmpeg-devel] [PATCH v12 10/13] lavu/hwcontext_qsv: make qsv hwdevice works with oneVPL 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: 9ECtkKy+2Iq2 From: Haihao Xiang In oneVPL, MFXLoad() and MFXCreateSession() are required to create a workable mfx session[1] Add config filters for D3D9/D3D11 session (galinart) The default device is changed to d3d11va for oneVPL when both d3d11va and dxva2 are enabled on Microsoft Windows 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 Co-authored-by: galinart Signed-off-by: galinart Signed-off-by: Haihao Xiang --- libavutil/hwcontext_qsv.c | 532 +++++++++++++++++++++++++++++++++++--- 1 file changed, 494 insertions(+), 38 deletions(-) diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c index 21a2a805f8..510f422562 100644 --- a/libavutil/hwcontext_qsv.c +++ b/libavutil/hwcontext_qsv.c @@ -49,6 +49,7 @@ #include "pixdesc.h" #include "time.h" #include "imgutils.h" +#include "avassert.h" #define QSV_VERSION_ATLEAST(MAJOR, MINOR) \ (MFX_VERSION_MAJOR > (MAJOR) || \ @@ -58,6 +59,12 @@ #define QSV_ONEVPL QSV_VERSION_ATLEAST(2, 0) #define QSV_HAVE_OPAQUE !QSV_ONEVPL +#if QSV_ONEVPL +#include +#else +#define MFXUnload(a) do { } while(0) +#endif + typedef struct QSVDevicePriv { AVBufferRef *child_device_ctx; } QSVDevicePriv; @@ -619,6 +626,437 @@ static mfxStatus frame_get_hdl(mfxHDL pthis, mfxMemId mid, mfxHDL *hdl) return MFX_ERR_NONE; } +#if QSV_ONEVPL + +static int qsv_d3d11_update_config(void *ctx, mfxHDL handle, mfxConfig cfg) +{ +#if CONFIG_D3D11VA + mfxStatus sts; + IDXGIAdapter *pDXGIAdapter; + DXGI_ADAPTER_DESC adapterDesc; + IDXGIDevice *pDXGIDevice = NULL; + HRESULT hr; + ID3D11Device *device = handle; + mfxVariant impl_value; + + hr = ID3D11Device_QueryInterface(device, &IID_IDXGIDevice, (void**)&pDXGIDevice); + if (SUCCEEDED(hr)) { + hr = IDXGIDevice_GetAdapter(pDXGIDevice, &pDXGIAdapter); + if (FAILED(hr)) { + av_log(ctx, AV_LOG_ERROR, "Error IDXGIDevice_GetAdapter %d\n", hr); + goto fail; + } + + hr = IDXGIAdapter_GetDesc(pDXGIAdapter, &adapterDesc); + if (FAILED(hr)) { + av_log(ctx, AV_LOG_ERROR, "Error IDXGIAdapter_GetDesc %d\n", hr); + goto fail; + } + } else { + av_log(ctx, AV_LOG_ERROR, "Error ID3D11Device_QueryInterface %d\n", hr); + goto fail; + } + + impl_value.Type = MFX_VARIANT_TYPE_U16; + impl_value.Data.U16 = adapterDesc.DeviceId; + sts = MFXSetConfigFilterProperty(cfg, + (const mfxU8 *)"mfxExtendedDeviceId.DeviceID", impl_value); + if (sts != MFX_ERR_NONE) { + av_log(ctx, AV_LOG_ERROR, "Error adding a MFX configuration" + "DeviceID property: %d.\n", sts); + goto fail; + } + + impl_value.Type = MFX_VARIANT_TYPE_PTR; + impl_value.Data.Ptr = &adapterDesc.AdapterLuid; + sts = MFXSetConfigFilterProperty(cfg, + (const mfxU8 *)"mfxExtendedDeviceId.DeviceLUID", impl_value); + if (sts != MFX_ERR_NONE) { + av_log(ctx, AV_LOG_ERROR, "Error adding a MFX configuration" + "DeviceLUID property: %d.\n", sts); + goto fail; + } + + impl_value.Type = MFX_VARIANT_TYPE_U32; + impl_value.Data.U32 = 0x0001; + sts = MFXSetConfigFilterProperty(cfg, + (const mfxU8 *)"mfxExtendedDeviceId.LUIDDeviceNodeMask", impl_value); + if (sts != MFX_ERR_NONE) { + av_log(ctx, AV_LOG_ERROR, "Error adding a MFX configuration" + "LUIDDeviceNodeMask property: %d.\n", sts); + goto fail; + } + + return 0; + +fail: +#endif + return AVERROR_UNKNOWN; +} + +static int qsv_d3d9_update_config(void *ctx, mfxHDL handle, mfxConfig cfg) +{ + int ret = AVERROR_UNKNOWN; +#if CONFIG_DXVA2 + mfxStatus sts; + IDirect3DDeviceManager9* devmgr = handle; + IDirect3DDevice9Ex *device = NULL; + HANDLE device_handle = 0; + IDirect3D9Ex *d3d9ex = NULL; + LUID luid; + D3DDEVICE_CREATION_PARAMETERS params; + HRESULT hr; + mfxVariant impl_value; + + hr = IDirect3DDeviceManager9_OpenDeviceHandle(devmgr, &device_handle); + if (FAILED(hr)) { + av_log(ctx, AV_LOG_ERROR, "Error OpenDeviceHandle %d\n", hr); + goto fail; + } + + hr = IDirect3DDeviceManager9_LockDevice(devmgr, device_handle, &device, TRUE); + if (FAILED(hr)) { + av_log(ctx, AV_LOG_ERROR, "Error LockDevice %d\n", hr); + goto fail; + } + + hr = IDirect3DDevice9Ex_GetCreationParameters(device, ¶ms); + if (FAILED(hr)) { + av_log(ctx, AV_LOG_ERROR, "Error IDirect3DDevice9_GetCreationParameters %d\n", hr); + goto unlock; + } + + hr = IDirect3DDevice9Ex_GetDirect3D(device, &d3d9ex); + if (FAILED(hr)) { + av_log(ctx, AV_LOG_ERROR, "Error IDirect3DDevice9Ex_GetAdapterLUID %d\n", hr); + goto unlock; + } + + hr = IDirect3D9Ex_GetAdapterLUID(d3d9ex, params.AdapterOrdinal, &luid); + if (FAILED(hr)) { + av_log(ctx, AV_LOG_ERROR, "Error IDirect3DDevice9Ex_GetAdapterLUID %d\n", hr); + goto unlock; + } + + impl_value.Type = MFX_VARIANT_TYPE_PTR; + impl_value.Data.Ptr = &luid; + sts = MFXSetConfigFilterProperty(cfg, + (const mfxU8 *)"mfxExtendedDeviceId.DeviceLUID", impl_value); + if (sts != MFX_ERR_NONE) { + av_log(ctx, AV_LOG_ERROR, "Error adding a MFX configuration" + "DeviceLUID property: %d.\n", sts); + goto unlock; + } + + ret = 0; + +unlock: + IDirect3DDeviceManager9_UnlockDevice(devmgr, device_handle, FALSE); +fail: +#endif + return ret; +} + +static int qsv_va_update_config(void *ctx, mfxHDL handle, mfxConfig cfg) +{ +#if CONFIG_VAAPI +#if VA_CHECK_VERSION(1, 15, 0) + mfxStatus sts; + VADisplay dpy = handle; + VAStatus vas; + VADisplayAttribute attr = { + .type = VADisplayPCIID, + }; + mfxVariant impl_value; + + vas = vaGetDisplayAttributes(dpy, &attr, 1); + if (vas == VA_STATUS_SUCCESS && attr.flags != VA_DISPLAY_ATTRIB_NOT_SUPPORTED) { + impl_value.Type = MFX_VARIANT_TYPE_U16; + impl_value.Data.U16 = (attr.value & 0xFFFF); + sts = MFXSetConfigFilterProperty(cfg, + (const mfxU8 *)"mfxExtendedDeviceId.DeviceID", impl_value); + if (sts != MFX_ERR_NONE) { + av_log(ctx, AV_LOG_ERROR, "Error adding a MFX configuration" + "DeviceID property: %d.\n", sts); + goto fail; + } + } else { + av_log(ctx, AV_LOG_ERROR, "libva: Failed to get device id from the driver. Please " + "consider to upgrade the driver to support VA-API 1.15.0\n"); + goto fail; + } + + return 0; + +fail: +#else + av_log(ctx, AV_LOG_ERROR, "libva: This version of libva doesn't support retrieving " + "the device information from the driver. Please consider to upgrade libva to " + "support VA-API 1.15.0\n"); +#endif +#endif + return AVERROR_UNKNOWN; +} + +static int qsv_new_mfx_loader(void *ctx, + mfxHDL handle, + mfxHandleType handle_type, + mfxIMPL implementation, + mfxVersion *pver, + void **ploader) +{ + mfxStatus sts; + mfxLoader loader = NULL; + mfxConfig cfg; + mfxVariant impl_value; + + *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; + 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; + } + + impl_value.Type = MFX_VARIANT_TYPE_U16; + impl_value.Data.U16 = 0x8086; // Intel device only + sts = MFXSetConfigFilterProperty(cfg, + (const mfxU8 *)"mfxExtendedDeviceId.VendorID", impl_value); + if (sts != MFX_ERR_NONE) { + av_log(ctx, AV_LOG_ERROR, "Error adding a MFX configuration" + "VendorID property: %d.\n", sts); + goto fail; + } + + if (MFX_HANDLE_VA_DISPLAY == handle_type) { + if (handle && qsv_va_update_config(ctx, handle, cfg)) + goto fail; + + impl_value.Data.U32 = MFX_ACCEL_MODE_VIA_VAAPI; + } else if (MFX_HANDLE_D3D9_DEVICE_MANAGER == handle_type) { + if (handle && qsv_d3d9_update_config(ctx, handle, cfg)) + goto fail; + + impl_value.Data.U32 = MFX_ACCEL_MODE_VIA_D3D9; + } else { + if (handle && qsv_d3d11_update_config(ctx, handle, cfg)) + goto fail; + + impl_value.Data.U32 = MFX_ACCEL_MODE_VIA_D3D11; + } + + impl_value.Type = MFX_VARIANT_TYPE_U32; + 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" + "AccelerationMode property: %d.\n", sts); + goto fail; + } + + *ploader = loader; + + return 0; + +fail: + if (loader) + MFXUnload(loader); + + return AVERROR_UNKNOWN; +} + +static int qsv_create_mfx_session_from_loader(void *ctx, mfxLoader loader, mfxSession *psession) +{ + mfxStatus sts; + mfxSession session = NULL; + uint32_t impl_idx = 0; + mfxVersion ver; + + 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; + + return 0; + +fail: + if (session) + MFXClose(session); + + return AVERROR_UNKNOWN; +} + +static int qsv_create_mfx_session(void *ctx, + mfxHDL handle, + mfxHandleType handle_type, + mfxIMPL implementation, + mfxVersion *pver, + mfxSession *psession, + void **ploader) +{ + mfxLoader loader = NULL; + + av_log(ctx, AV_LOG_VERBOSE, + "Use Intel(R) oneVPL 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 && + handle_type != MFX_HANDLE_D3D11_DEVICE) { + av_log(ctx, AV_LOG_ERROR, + "Invalid MFX device handle type\n"); + return AVERROR(EXDEV); + } + + *psession = NULL; + + if (!*ploader) { + if (qsv_new_mfx_loader(ctx, handle, handle_type, implementation, pver, (void **)&loader)) + goto fail; + + av_assert0(loader); + } else + loader = *ploader; // Use the input mfxLoader to create mfx session + + if (qsv_create_mfx_session_from_loader(ctx, loader, psession)) + goto fail; + + if (!*ploader) + *ploader = loader; + + return 0; + +fail: + if (!*ploader && loader) + MFXUnload(loader); + + return AVERROR_UNKNOWN; +} + +#else + +static int qsv_create_mfx_session(void *ctx, + mfxHDL handle, + mfxHandleType handle_type, + mfxIMPL implementation, + mfxVersion *pver, + mfxSession *psession, + void **ploader) +{ + mfxVersion ver; + mfxStatus sts; + mfxSession session = NULL; + + av_log(ctx, AV_LOG_VERBOSE, + "Use Intel(R) 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); + + *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) { @@ -637,29 +1075,36 @@ static int qsv_init_internal_session(AVHWFramesContext *ctx, mfxVideoParam par; mfxStatus err; + int ret = AVERROR_UNKNOWN; + AVQSVDeviceContext *hwctx = ctx->device_ctx->hwctx; + /* hwctx->loader is non-NULL for oneVPL user and NULL for non-oneVPL user */ + void **loader = &hwctx->loader; #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, 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)); @@ -695,11 +1140,20 @@ 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); + + *session = NULL; + + return ret; } static int qsv_frames_init(AVHWFramesContext *ctx) @@ -1456,6 +1910,8 @@ static void qsv_device_free(AVHWDeviceContext *ctx) if (hwctx->session) MFXClose(hwctx->session); + if (hwctx->loader) + MFXUnload(hwctx->loader); av_buffer_unref(&priv->child_device_ctx); av_freep(&priv); } @@ -1545,34 +2001,10 @@ 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; - } - - 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; - 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; + ret = qsv_create_mfx_session(ctx, handle, handle_type, implementation, &ver, + &hwctx->session, &hwctx->loader); + if (ret) goto fail; - } err = MFXVideoCORE_SetHandle(hwctx->session, handle_type, handle); if (err != MFX_ERR_NONE) { @@ -1587,6 +2019,12 @@ static int qsv_device_derive_from_child(AVHWDeviceContext *ctx, fail: if (hwctx->session) MFXClose(hwctx->session); + + if (hwctx->loader) + MFXUnload(hwctx->loader); + + hwctx->session = NULL; + hwctx->loader = NULL; return ret; } @@ -1629,6 +2067,16 @@ static int qsv_device_create(AVHWDeviceContext *ctx, const char *device, } } else if (CONFIG_VAAPI) { child_device_type = AV_HWDEVICE_TYPE_VAAPI; +#if QSV_ONEVPL + } else if (CONFIG_D3D11VA) { // Use D3D11 by default if d3d11va is enabled + av_log(ctx, AV_LOG_VERBOSE, + "Defaulting child_device_type to AV_HWDEVICE_TYPE_D3D11VA for oneVPL." + "Please explicitly set child device type via \"-init_hw_device\" " + "option if needed.\n"); + child_device_type = AV_HWDEVICE_TYPE_D3D11VA; + } else if (CONFIG_DXVA2) { + child_device_type = AV_HWDEVICE_TYPE_DXVA2; +#else } else if (CONFIG_DXVA2) { av_log(NULL, AV_LOG_WARNING, "WARNING: defaulting child_device_type to AV_HWDEVICE_TYPE_DXVA2 for compatibility " @@ -1637,6 +2085,7 @@ static int qsv_device_create(AVHWDeviceContext *ctx, const char *device, child_device_type = AV_HWDEVICE_TYPE_DXVA2; } else if (CONFIG_D3D11VA) { child_device_type = AV_HWDEVICE_TYPE_D3D11VA; +#endif } else { av_log(ctx, AV_LOG_ERROR, "No supported child device type is enabled\n"); return AVERROR(ENOSYS); @@ -1663,6 +2112,13 @@ static int qsv_device_create(AVHWDeviceContext *ctx, const char *device, #endif #if CONFIG_DXVA2 case AV_HWDEVICE_TYPE_DXVA2: +#if QSV_ONEVPL + { + av_log(ctx, AV_LOG_VERBOSE, + "d3d11va is not available or child device type is set to dxva2 " + "explicitly for oneVPL.\n"); + } +#endif break; #endif default: From patchwork Mon Jul 25 04:11:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xiang, Haihao" X-Patchwork-Id: 36946 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:1649:b0:8b:613a:194d with SMTP id no9csp1814703pzb; Sun, 24 Jul 2022 21:13:40 -0700 (PDT) X-Google-Smtp-Source: AGRyM1u8BX3QM8a05U/aJ1HDWDvOjTrrugEe0puNWV5A9WLHkurqsVyYiSFus0+z8s5hP8uLuB/e X-Received: by 2002:a17:906:dc92:b0:72f:da9b:7702 with SMTP id cs18-20020a170906dc9200b0072fda9b7702mr1477347ejc.383.1658722420656; Sun, 24 Jul 2022 21:13:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658722420; cv=none; d=google.com; s=arc-20160816; b=H/so8wAXHAfDHxQD9pIAPkks5bOfCjM3fdnJ7PrKalzzAH7egZ9kXv/a4p/Zv0Zq84 JaRN7ZWsCicOcLIpztUVEkEIhnV3GVss8EVZpitxBSxUjFSPTkscpuXkgIgfCxul+wVa AJDlhyNZoSd56eCvz5PpxbfkxXKu2N1RZLO0gxmBOs1ozuXIzPkCA9LZ6kP04bT01deX Kyjf4I3918O9otLXDqVEg8li53UgRpvZVpVMsAw+4PbIRe12/oZ0I0CJZimJ3+6eX/AQ tv80W10fjnnbEeaH/zae6G9yymzNjsPW5f+2Uhsn+UtEiuvQccJ1dgm6uEnWV1QzkJbg zqZw== 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:dkim-signature:delivered-to; bh=dTRbBqmzwyKjIY8K0eeWHGKrt1a3Y83wyNsc0JhltVg=; b=vH4wy/uhC+qDXIDD0BoWgQoZGqqNMM1hUe/bYGLrzQCraDB/yFI+2ReyW8H2S+ueqe RJNqeCv0yShssscLUn9mUpSYvn2tWs2OMbqfe4hOrIvjiAhmcLrJLqAAzFbFW0ZNP7jZ ZfiKNd4I4LydPIeeEP62xvKBs+5IV6E4IpenX9HfAHEsPwQ0ow8n8kgHxV77SDDFh8FV Dgs0bJvsnTjgj7YyJ21mJSdFsQgyY+LhfpIMZc6JxpZsJxTTJroHDg6vrN+CHRSNtOan Ra44qimK48B5fF8bRFj94tC70QZ/oLbASyAP78AjNqDDIDkOlSoAdZvp0zLb5WXla1Zx +2Cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b=Ull3qvD9; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id sa36-20020a1709076d2400b0072b960ad734si9828511ejc.746.2022.07.24.21.13.40; Sun, 24 Jul 2022 21:13:40 -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; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b=Ull3qvD9; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 84CA468B872; Mon, 25 Jul 2022 07:12:23 +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 E32FF68B7F1 for ; Mon, 25 Jul 2022 07:12:19 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658722340; x=1690258340; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=oSyHAQZC2n3eLSkDGGRrcvnLojmpjfFMPs4NZd15J2Q=; b=Ull3qvD94BC3ljtQc6A/KWo+CqWxyzo1PMqKM3NdcS9rk9rUzVPYF0SJ 1MLS7E32RgJf3qyMEIdU6HLnoSSBK9xemsxLbXYJAE/5FaLD4Kr2tycsW nlHOqp/wT+i6b0/dN7jEi92PJvzob24fySvF380DESJQGTwcz/hRsXOcB GKk/UEVrgT327twhwahMsFR1qGxco0XFQ5K1GtHx0pMrwCudoY2P5GBQw nmmJkq9m2kviAq+NCctz0CvsTcJaejD5xK/NWqHyTCrof+YqzZ8MuGUpo Kpvr1uC7LGhBS92FVL79eBR6rrkBCoZwNJnQi+3ZArhyqcyQ75pVbmHxC w==; X-IronPort-AV: E=McAfee;i="6400,9594,10418"; a="274468238" X-IronPort-AV: E=Sophos;i="5.93,191,1654585200"; d="scan'208";a="274468238" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jul 2022 21:12:15 -0700 X-IronPort-AV: E=Sophos;i="5.93,191,1654585200"; d="scan'208";a="596544044" Received: from xhh-dg164.sh.intel.com ([10.238.5.169]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jul 2022 21:12:14 -0700 From: "Xiang, Haihao" To: ffmpeg-devel@ffmpeg.org Date: Mon, 25 Jul 2022 12:11:49 +0800 Message-Id: <20220725041151.7710-12-haihao.xiang@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220725041151.7710-1-haihao.xiang@intel.com> References: <20220725041151.7710-1-haihao.xiang@intel.com> Subject: [FFmpeg-devel] [PATCH v12 11/13] lavc/qsv: create mfx session using oneVPL for decoding/encoding 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: GMgkGO4OWm/C From: Haihao Xiang If qsv hwdevice is available, use the mfxLoader handle in qsv hwdevice to create mfx session. Otherwise create mfx session with a new mfxLoader handle. This is in preparation for oneVPL support --- libavcodec/qsv.c | 226 +++++++++++++++++++++++++++++++++++--- libavcodec/qsv_internal.h | 1 + libavcodec/qsvdec.c | 11 ++ 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 - 9 files changed, 223 insertions(+), 23 deletions(-) diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c index 432675bccf..fe998c9649 100644 --- a/libavcodec/qsv.c +++ b/libavcodec/qsv.c @@ -45,6 +45,12 @@ #include #endif +#if QSV_ONEVPL +#include +#else +#define MFXUnload(a) do { } while(0) +#endif + int ff_qsv_codec_id_to_mfx(enum AVCodecID codec_id) { switch (codec_id) { @@ -419,6 +425,193 @@ static int ff_qsv_set_display_handle(AVCodecContext *avctx, QSVSession *qs) } #endif //AVCODEC_QSV_LINUX_SESSION_HANDLE +#if QSV_ONEVPL +static int qsv_new_mfx_loader(AVCodecContext *avctx, + mfxIMPL implementation, + mfxVersion *pver, + void **ploader) +{ + mfxStatus sts; + mfxLoader loader = NULL; + mfxConfig cfg; + mfxVariant impl_value; + + 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; + } + + *ploader = loader; + + return 0; + +fail: + if (loader) + MFXUnload(loader); + + *ploader = NULL; + return AVERROR_UNKNOWN; +} + +static int qsv_create_mfx_session_from_loader(void *ctx, mfxLoader loader, mfxSession *psession) +{ + mfxStatus sts; + mfxSession session = NULL; + uint32_t impl_idx = 0; + + 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; + } + + *psession = session; + + return 0; + +fail: + if (session) + MFXClose(session); + + *psession = NULL; + return AVERROR_UNKNOWN; +} + +static int qsv_create_mfx_session(AVCodecContext *avctx, + mfxIMPL implementation, + mfxVersion *pver, + int gpu_copy, + mfxSession *psession, + void **ploader) +{ + mfxLoader loader = NULL; + + /* Don't create a new MFX loader if the input loader is valid */ + if (*ploader == NULL) { + av_log(avctx, AV_LOG_VERBOSE, + "Use Intel(R) oneVPL to create MFX session, the required " + "implementation version is %d.%d\n", + pver->Major, pver->Minor); + + if (qsv_new_mfx_loader(avctx, implementation, pver, (void **)&loader)) + goto fail; + + av_assert0(loader); + } else { + av_log(avctx, AV_LOG_VERBOSE, + "Use Intel(R) oneVPL to create MFX session with the specified MFX loader\n"); + + loader = *ploader; + } + + if (qsv_create_mfx_session_from_loader(avctx, loader, psession)) + goto fail; + + 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, + void **ploader) +{ + mfxInitParam init_par = { MFX_IMPL_AUTO_ANY }; + mfxSession session = NULL; + mfxStatus sts; + + av_log(avctx, AV_LOG_VERBOSE, + "Use Intel(R) Media SDK to create MFX session, the required " + "implementation version is %d.%d\n", + pver->Major, pver->Minor); + + *psession = NULL; + *ploader = NULL; + + init_par.GPUCopy = gpu_copy; + 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) { @@ -428,18 +621,12 @@ int ff_qsv_init_internal_session(AVCodecContext *avctx, QSVSession *qs, mfxIMPL impl = MFX_IMPL_AUTO_ANY; #endif mfxVersion ver = { { QSV_VERSION_MINOR, QSV_VERSION_MAJOR } }; - mfxInitParam init_par = { MFX_IMPL_AUTO_ANY }; const char *desc; - int ret; - - init_par.GPUCopy = gpu_copy; - 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"); + int ret = qsv_create_mfx_session(avctx, impl, &ver, gpu_copy, &qs->session, + &qs->loader); + if (ret) + return ret; #ifdef AVCODEC_QSV_LINUX_SESSION_HANDLE ret = ff_qsv_set_display_handle(avctx, qs); @@ -743,7 +930,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 }; + void *loader = device_hwctx->loader; mfxHDL handle = NULL; int hw_handle_supported = 0; @@ -784,13 +971,10 @@ int ff_qsv_init_session_device(AVCodecContext *avctx, mfxSession *psession, "from the session\n"); } - init_par.GPUCopy = gpu_copy; - 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); @@ -869,6 +1053,12 @@ int ff_qsv_close_internal_session(QSVSession *qs) MFXClose(qs->session); qs->session = NULL; } + + if (qs->loader) { + MFXUnload(qs->loader); + qs->loader = NULL; + } + #ifdef AVCODEC_QSV_LINUX_SESSION_HANDLE av_buffer_unref(&qs->va_device_ref); #endif diff --git a/libavcodec/qsv_internal.h b/libavcodec/qsv_internal.h index d52f0dcd15..f914956596 100644 --- a/libavcodec/qsv_internal.h +++ b/libavcodec/qsv_internal.h @@ -103,6 +103,7 @@ typedef struct QSVSession { AVBufferRef *va_device_ref; AVHWDeviceContext *va_device_ctx; #endif + void *loader; } QSVSession; typedef struct QSVFramesContext { diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c index 8b718a08ff..89ec5dcee8 100644 --- a/libavcodec/qsvdec.c +++ b/libavcodec/qsvdec.c @@ -50,6 +50,12 @@ #include "qsv.h" #include "qsv_internal.h" +#if QSV_ONEVPL +#include +#else +#define MFXUnload(a) do { } while(0) +#endif + static const AVRational mfx_tb = { 1, 90000 }; #define PTS_TO_MFX_PTS(pts, pts_tb) ((pts) == AV_NOPTS_VALUE ? \ @@ -231,6 +237,11 @@ static int qsv_init_session(AVCodecContext *avctx, QSVContext *q, mfxSession ses q->internal_qs.session = NULL; } + if (q->internal_qs.loader) { + MFXUnload(q->internal_qs.loader); + q->internal_qs.loader = NULL; + } + return AVERROR_EXTERNAL; } diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h index c2def19658..d35a1318f2 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 64c22852d2..ad9cf629df 100644 --- a/libavcodec/qsvenc_h264.c +++ b/libavcodec/qsvenc_h264.c @@ -32,7 +32,6 @@ #include "avcodec.h" #include "codec_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 1d92b8ec13..e11f5dec4a 100644 --- a/libavcodec/qsvenc_hevc.c +++ b/libavcodec/qsvenc_hevc.c @@ -35,7 +35,6 @@ #include "hevcdec.h" #include "h2645_parse.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 582886c7c0..6d17d896eb 100644 --- a/libavcodec/qsvenc_jpeg.c +++ b/libavcodec/qsvenc_jpeg.c @@ -30,7 +30,6 @@ #include "avcodec.h" #include "codec_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 8ed578c396..5666b3e6e2 100644 --- a/libavcodec/qsvenc_mpeg2.c +++ b/libavcodec/qsvenc_mpeg2.c @@ -30,7 +30,6 @@ #include "avcodec.h" #include "codec_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 7ae392da75..c738da3904 100644 --- a/libavcodec/qsvenc_vp9.c +++ b/libavcodec/qsvenc_vp9.c @@ -30,7 +30,6 @@ #include "avcodec.h" #include "codec_internal.h" #include "qsv.h" -#include "qsv_internal.h" #include "qsvenc.h" typedef struct QSVVP9EncContext { From patchwork Mon Jul 25 04:11:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xiang, Haihao" X-Patchwork-Id: 36949 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:1649:b0:8b:613a:194d with SMTP id no9csp1814842pzb; Sun, 24 Jul 2022 21:14:09 -0700 (PDT) X-Google-Smtp-Source: AGRyM1s418YFwnEGjgE1ULG61bjm9nGXAdXHlpTXZrW0Mvltx7EF0oSktErE8isx51iIo/956ikK X-Received: by 2002:a17:907:a0c7:b0:72f:b205:112 with SMTP id hw7-20020a170907a0c700b0072fb2050112mr8412517ejc.559.1658722449381; Sun, 24 Jul 2022 21:14:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658722449; cv=none; d=google.com; s=arc-20160816; b=EBi5B/c6rpObyENabMEwpNmtjODc/eowbOKxPFBzAkPCEUaZ3ivNLyv5uLmEZyGV77 vQaB/JDIS0xxq0l9Qo2nYjSicXMoZcfqO54LY9GW/4OLJyHXXIwNpsnhK3ZHgQe/yuiK y9sLr/+oHMn4qS7W+6mx772HhDAlSFEMUChHw6U+xKqFFEd92/iuXV3gzLiHTDX/Lkym /lBP7dj0cRd59+f6qRSNIeXvTjAdhmDTSOo27LbidjazY15PE7NYzX5EYtTGmsG2aghv w/gWIzxroVsa9UKi/NfYuYvgWEiDPuNnAD1zEvsWzD+WRg9XcgTmiJxDEiAjkB+HgJMg eAuw== 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:dkim-signature:delivered-to; bh=u4qOwk32lYrcVieAD2JB5l1qfLD0btKPj+g7zURtKE4=; b=pwU8FQVZEYQbQJCYl+WzJfPewtlEVIYIz0We6OLs759i7Zn1+jBj0kE6MClr9mv6cL F89m3nwK6ajOhVx6E4U3FDLUkQ1Isn7WsHGAZe1MIjXUSCallnLSwNiHHtDf5jrqzTvY tLTmxIXbAZxiJPXJDFsus87TNnt+DaXTWBW3swbCU3y97Xvs3YcCWMzWvZ0BOOTpiiRe oC01hZtnkGSFh1yyIMapidThKx5WlwAaO6zImPv6BvzkVGeNAu5gmz0athrvI/3p5t8k 73FcSEjQ0J4AjD/2fzIV1oyruGr1/VDD0BAmfJHj5ZJqV+rEk8d6sBdA2/KS2iBNTH1x 9sGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b=MyGh05VH; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id gb15-20020a170907960f00b007269f720fb5si12678718ejc.530.2022.07.24.21.14.09; Sun, 24 Jul 2022 21:14:09 -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; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b=MyGh05VH; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 75DD768B887; Mon, 25 Jul 2022 07:12:26 +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 13AC868B845 for ; Mon, 25 Jul 2022 07:12:20 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658722341; x=1690258341; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=Nxs9rrCrG3wqHr3V3+jdBIPZLzcb05JL2RA9v5AxCIs=; b=MyGh05VH88UQhFrIXUWPh0XX/C8GWp8bdsS7JO31miISwo+h7t1QaqwR WvuGbuv+QVL0KG6OXV63VuN7KlB4w5DqOAsSQgNWSX5DjGyzBr8xwS1lC QAEIkMasGFjkZ561OoJDHmRVqvS7c4nhyNyLU29i/GT3SA3N82GVo0EB6 G4aMgkqGyCwgaJzPCpc2zVnjpvBpwAVALgreWHeL0LYR7FjCGqSJpNCYX mNZevGGlzOOptJPkL0UTqVHzvKL7oBM08ICBEJAyzo9FxzSoFjGqd1hWC OZjzYLj3wgM8PGJ9wxSKqkDgNYcZY25VVrhQsCrynO47We1b+zAei2Mt7 A==; X-IronPort-AV: E=McAfee;i="6400,9594,10418"; a="274468246" X-IronPort-AV: E=Sophos;i="5.93,191,1654585200"; d="scan'208";a="274468246" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jul 2022 21:12:17 -0700 X-IronPort-AV: E=Sophos;i="5.93,191,1654585200"; d="scan'208";a="596544050" Received: from xhh-dg164.sh.intel.com ([10.238.5.169]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jul 2022 21:12:15 -0700 From: "Xiang, Haihao" To: ffmpeg-devel@ffmpeg.org Date: Mon, 25 Jul 2022 12:11:50 +0800 Message-Id: <20220725041151.7710-13-haihao.xiang@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220725041151.7710-1-haihao.xiang@intel.com> References: <20220725041151.7710-1-haihao.xiang@intel.com> Subject: [FFmpeg-devel] [PATCH v12 12/13] lavfi/qsv: create mfx session using oneVPL for qsv filters 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: JycTVwFZmyP3 From: Haihao Xiang Use the mfxLoader handle in qsv hwdevice to create mfx session for qsv filters. This is in preparation for oneVPL support --- libavfilter/qsvvpp.c | 109 ++++++++++++++++++++++++++++--- libavfilter/qsvvpp.h | 5 ++ libavfilter/vf_deinterlace_qsv.c | 13 ++-- libavfilter/vf_scale_qsv.c | 11 ++-- 4 files changed, 115 insertions(+), 23 deletions(-) diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c index 3f984fd5f9..5068ce0d5a 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" @@ -32,6 +30,12 @@ #include "qsvvpp.h" #include "video.h" +#if QSV_ONEVPL +#include +#else +#define MFXUnload(a) do { } while(0) +#endif + #define IS_VIDEO_MEMORY(mode) (mode & (MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET | \ MFX_MEMTYPE_VIDEO_MEMORY_PROCESSOR_TARGET)) #if QSV_HAVE_OPAQUE @@ -614,13 +618,10 @@ 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); @@ -906,3 +907,93 @@ int ff_qsvvpp_filter_frame(QSVVPPContext *s, AVFilterLink *inlink, AVFrame *picr return 0; } + +#if QSV_ONEVPL + +int ff_qsvvpp_create_mfx_session(void *ctx, + void *loader, + mfxIMPL implementation, + mfxVersion *pver, + mfxSession *psession) +{ + mfxStatus sts; + mfxSession session = NULL; + uint32_t impl_idx = 0; + + av_log(ctx, AV_LOG_VERBOSE, + "Use Intel(R) oneVPL 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, + void *loader, + mfxIMPL implementation, + mfxVersion *pver, + mfxSession *psession) +{ + mfxSession session = NULL; + mfxStatus sts; + + av_log(ctx, AV_LOG_VERBOSE, + "Use Intel(R) 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 3e7d56021b..a8cfcc565a 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, void *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 50f9156d14..3065d6ac95 100644 --- a/libavfilter/vf_deinterlace_qsv.c +++ b/libavfilter/vf_deinterlace_qsv.c @@ -163,7 +163,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); @@ -198,13 +198,10 @@ 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 fa0152d785..758e730f78 100644 --- a/libavfilter/vf_scale_qsv.c +++ b/libavfilter/vf_scale_qsv.c @@ -278,7 +278,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); @@ -315,11 +315,10 @@ 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); From patchwork Mon Jul 25 04:11:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xiang, Haihao" X-Patchwork-Id: 36950 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:1649:b0:8b:613a:194d with SMTP id no9csp1814886pzb; Sun, 24 Jul 2022 21:14:18 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uEGkbCxjOZsl5YYG2qLtmlHU2Shy4+t4EMicVT3aePZ/9SPPSgn45qZCtt08n3+8jrMVof X-Received: by 2002:a17:907:3d89:b0:72f:18b7:9035 with SMTP id he9-20020a1709073d8900b0072f18b79035mr8950857ejc.13.1658722458444; Sun, 24 Jul 2022 21:14:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658722458; cv=none; d=google.com; s=arc-20160816; b=SOBeSJmwByonJG4JCxJCMx/RYuxFsnWxNccmIxPDXKklmrIw1Ll/tYYaXDPxFU1uJ5 XUM3N+OG71FOIKEG3eo2NzG1J+Z5wupf7I4Z8oTtM0+chv/IKrYqab3XUQmHeIkKLbew lmXhQqBQJgU74eqZwZ5thbdGpSkJhfi/TUGIY+ur76MOK9y8j840EfsF227dU6198QB3 5D1Te56cCZo5kjyTQlmVUe75TIeu/jVve68vz9j7TyeC6hXii4xFEIz2sESIKbMpOz8a HpSgA/Ig9GaW1Whe+/rXfizog8lx9GjVWk45qFD/ZDHVYxfJ80r7GrfNXJjBJKnNh3aN YkrA== 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:dkim-signature:delivered-to; bh=jgATp59h2Ck1mtx3JZqKgz3/OL1SxGWUQXFEoxb40O0=; b=Hyp2BLCZ64GqpDnhQeTdvDqpZaTkB00k46brqmh1QJ2qcvC0UpLE4gOoMN7HGeJ33h OQ2/OHQ8ARzp56WsGNfnerczJU9Lr1jBgvMRqfJEQtQcArENiiruzFtvMhUyEea4nc2T /sPOd47sgJ1Tz8EGaleK3A2zpU9cdr1YG5qFKgczz1Nh3k1K9wl9A1MNUV+2kNH82RF4 /TUx5gdcA7xL4i0nM4D3YAlbwaEl+t+hKLe2yeQrghLfKAVJIcy6OeD7OP3tR5zhddp3 l8cQfZLp94B1jfnn6yz6vhoSGM949h/h50kJv1K6ncQ7A3oI/xweEHQ/AqfWEsP8MrQL bgwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b=GCRETAMp; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id p22-20020a056402045600b0043aa021096dsi12117607edw.378.2022.07.24.21.14.18; Sun, 24 Jul 2022 21:14:18 -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; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b=GCRETAMp; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8077C68B88C; Mon, 25 Jul 2022 07:12:27 +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 1392968B840 for ; Mon, 25 Jul 2022 07:12:20 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658722341; x=1690258341; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=pMooe1NRJB8uP3MknIQ20JJgsPBni+5mweJpSlqyWZU=; b=GCRETAMpT4EsJQvGO5ihiwM4HAFGz1cdX0VWZ5Eeb+XpsOkpUgxFnAwy C/TbPgArmYcbC3vmneDfnA6jZzwbuEpgpEIvTuRaHIpAd4K2bMQSoePKo GFojwCPffjguPia3zfs5ufeoWWpzA+pJrIiLVSAjiV3Nl0Frt0a9SQJeE +hu2QTcayZydrGlLIwZ6eF3QWCH98E2rNHUMtzs/6m+11jIZHPZJMhjxt K+T+IFTS0YrIJyoUOtSA8WmCUNwCVIPLkexeAb9EOUCTbCrHVZDXHOgxv LmFd8DhAnC3n/H/gLNRiZ464MtkNW/swgnn4d/VOlaUYCn27Fhb5WGZs8 A==; X-IronPort-AV: E=McAfee;i="6400,9594,10418"; a="274468248" X-IronPort-AV: E=Sophos;i="5.93,191,1654585200"; d="scan'208";a="274468248" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jul 2022 21:12:18 -0700 X-IronPort-AV: E=Sophos;i="5.93,191,1654585200"; d="scan'208";a="596544059" Received: from xhh-dg164.sh.intel.com ([10.238.5.169]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jul 2022 21:12:17 -0700 From: "Xiang, Haihao" To: ffmpeg-devel@ffmpeg.org Date: Mon, 25 Jul 2022 12:11:51 +0800 Message-Id: <20220725041151.7710-14-haihao.xiang@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220725041151.7710-1-haihao.xiang@intel.com> References: <20220725041151.7710-1-haihao.xiang@intel.com> Subject: [FFmpeg-devel] [PATCH v12 13/13] 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: JXVHkl0WhLwL From: Haihao Xiang This allows user to build FFmpeg against Intel oneVPL. oneVPL 2.6 is the required minimum version when building Intel oneVPL code. It will fail to run configure script if both libmfx and libvpl are enabled. It is recommended to use oneVPL for new work, even for currently available hardwares [1] Note the preferred child device type is d3d11va for libvpl on Windows. The commands below will use d3d11va if d3d11va is available on Windows. $ ffmpeg -hwaccel qsv -c:v h264_qsv ... $ ffmpeg -qsv_device 0 -hwaccel qsv -c:v h264_qsv ... $ ffmpeg -init_hw_device qsv=qsv:hw_any -hwaccel qsv -c:v h264_qsv ... $ ffmpeg -init_hw_device qsv=qsv:hw_any,child_device=0 -hwaccel qsv -c:v h264_qsv ... User may use child_device_type option to specify child device type to dxva2 or derive a qsv device from a dxva2 device $ ffmpeg -init_hw_device qsv=qsv:hw_any,child_device=0,child_device_type=dxva2 -hwaccel qsv -c:v h264_qsv ... $ ffmpeg -init_hw_device dxva2=d3d9:0 -init_hw_device qsv=qsv@d3d9 -hwaccel qsv -c:v h264_qsv ... [1] https://www.intel.com/content/www/us/en/develop/documentation/upgrading-from-msdk-to-onevpl/top.html --- configure | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/configure b/configure index 8a6702f2a8..b292de69e2 100755 --- a/configure +++ b/configure @@ -341,6 +341,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 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] @@ -1921,6 +1922,7 @@ HWACCEL_LIBRARY_NONFREE_LIST=" HWACCEL_LIBRARY_LIST=" $HWACCEL_LIBRARY_NONFREE_LIST libmfx + libvpl mmal omx opencl @@ -6574,23 +6576,36 @@ enabled libjxl && require_pkg_config libjxl "libjxl >= 0.7.0" jxl/dec 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 >= 1.28 libmfx < 2.0" "mfxvideo.h" MFXInit || +elif enabled libmfx; then + { check_pkg_config libmfx "libmfx >= 1.28 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 >= 1.28 libmfx < 2.0" "mfx/mfxvideo.h" MFXInit && add_cflags -I${libmfx_incdir}/mfx; } || - { require libmfx "mfxvideo.h mfxdefs.h" MFXInit "-llibmfx $advapi32_extralibs" && - { test_cpp_condition mfxdefs.h "MFX_VERSION >= 1028 && MFX_VERSION < 2000" || die "ERROR: libmfx version must be >= 1.28 and < 2.0"; } && - 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 >= 1.28 libmfx < 2.0" "mfx/mfxvideo.h" MFXInit && add_cflags -I${libmfx_incdir}/mfx; } || + { require libmfx "mfxvideo.h mfxdefs.h" MFXInit "-llibmfx $advapi32_extralibs" && + { test_cpp_condition mfxdefs.h "MFX_VERSION >= 1028 && MFX_VERSION < 2000" || die "ERROR: libmfx version must be >= 1.28 and < 2.0"; } && + 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 passed to check_pkg_config function for --enable-libvpl option +# because QSV has dependency on libmfx, we can use the same dependency if using libmfx in this check. The package name +# is extracted from "vpl >= 2.6" + check_pkg_config libmfx "vpl >= 2.6" "mfxvideo.h mfxdispatcher.h" MFXLoad && \ + warn "build FFmpeg against oneVPL 2.6+, 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.6 not found" +fi if enabled libmfx; then check_cc MFX_CODEC_VP9 "mfxdefs.h mfxstructures.h" "MFX_CODEC_VP9"