From patchwork Thu Sep 23 06:28:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xiang, Haihao" X-Patchwork-Id: 30472 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:6506:0:0:0:0:0 with SMTP id z6csp158302iob; Wed, 22 Sep 2021 23:28:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzbw/T9DdpSTZdnfSz66GpAq4Sq9FWLqsMbzu5I+DVoZND2z+lWNpcRcYqy6LWcTif6Hs3I X-Received: by 2002:a17:906:689b:: with SMTP id n27mr3389786ejr.459.1632378534750; Wed, 22 Sep 2021 23:28:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632378534; cv=none; d=google.com; s=arc-20160816; b=Jk4nEOPNmkyDpmArVQeIAkQRLpuZMgtsJ2H3opDCOsGbVDVi076DXIQyXGxdBodSRQ ir15pdOkvF9uy4jReDQ0PQ1F7s3QcYHdhLD0l4gluhJXI5YFKxGlQFKhqjIexYnLY8rQ 8BZjAgDLWgZw89XiFfe5fH94P6aUbeHNab24rpVVRS8EBIbSzL+DZAXCLQmsbD9l3LyP ItHrwXx6um/lNCwx7iasfQB+GR2Pcj/WiywleHkCS1Lq2pnZ+rlstZzn7F5d/Sa9a1XX l8ICvygT6cmYC3l92kvc8OEdndsI4UgcfMNbmf5y2wxHqPH7yqTPtYr+m19rexScJ1ps pwSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:delivered-to; bh=ZM7U1SQN1XIPj0N6IcnLTR6cduhQMX9w1SZzNvgYs+c=; b=v3DYzeMpsYINwEJWlUMjl86QB4J3zFurYSRviMOLQ87tVAGBOuVvnyaf0chGFXwY+F 8SOufTST+BPtZ5GanC87upinOS2FokIOX5UQ65pcJ49GnZiyXaHixkjuQpDjyzFuMUl6 WO8t8+5sshRXJ03a6J3nO6yhgtLnSk3SqZpYtA1Md/EGNCWILAWu4zETsZb4T9JuRCbV baeATjSCbmHQD7BGZKOFS5riqiDWmeMY2vmEy1eQmR9cAoXjp3K1EmikXYn27TqNolJV vMnsWNVXlLT5cHpXPjyCse4yZziezJg0nIstLzW8ypjGf3D7NTG074TpOSnNKRNrY5pq T/Tg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 26si4889494ejl.648.2021.09.22.23.28.54; Wed, 22 Sep 2021 23:28:54 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 18E1068A94D; Thu, 23 Sep 2021 09:28:39 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A754568A926 for ; Thu, 23 Sep 2021 09:28:30 +0300 (EEST) X-IronPort-AV: E=McAfee;i="6200,9189,10115"; a="203930125" X-IronPort-AV: E=Sophos;i="5.85,316,1624345200"; d="scan'208";a="203930125" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2021 23:28:28 -0700 X-IronPort-AV: E=Sophos;i="5.85,316,1624345200"; d="scan'208";a="550689665" Received: from xhh-dg164.sh.intel.com ([10.239.159.167]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2021 23:28:27 -0700 From: Haihao Xiang To: ffmpeg-devel@ffmpeg.org Date: Thu, 23 Sep 2021 14:28:09 +0800 Message-Id: <20210923062818.18892-2-haihao.xiang@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210923062818.18892-1-haihao.xiang@intel.com> References: <20210923062818.18892-1-haihao.xiang@intel.com> Subject: [FFmpeg-devel] [PATCH v4 01/10] configure: ensure --enable-libmfx uses libmfx 1.x X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Haihao Xiang MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: rRizLMy0VMhe Intel's oneVPL is a successor to MediaSDK, but removed some obsolete features of MediaSDK[1]. Some early versions of oneVPL still uses libmfx as library name[2], however some of obsolete features, including OPAQUE memory, multi-frame encode, user plugins and LA_EXT rate control mode etc, have been enabled in QSV, so user can not use --enable-libmfx to enable QSV if using an early version of oneVPL SDK. In order to make sure user builds FFmpeg against a right version of libmfx, this patch added a check for the version of libmfx and warning message about the used obsolete features. [1] https://spec.oneapi.io/versions/latest/elements/oneVPL/source/appendix/VPL_intel_media_sdk.html [2] https://github.com/oneapi-src/oneVPL --- configure | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 231d0398a8..34e9a7c863 100755 --- a/configure +++ b/configure @@ -6434,8 +6434,11 @@ enabled liblensfun && require_pkg_config liblensfun lensfun lensfun.h lf_ # Media SDK or Intel Media Server Studio, these don't come with # pkg-config support. Instead, users should make sure that the build # can find the libraries and headers through other means. -enabled libmfx && { check_pkg_config libmfx libmfx "mfx/mfxvideo.h" MFXInit || - { require libmfx "mfx/mfxvideo.h" MFXInit "-llibmfx $advapi32_extralibs" && warn "using libmfx without pkg-config"; } } +enabled libmfx && { { check_pkg_config libmfx "libmfx < 2.0" "mfx/mfxvideo.h" MFXInit || + { require "libmfx < 2.0" "mfx/mfxvideo.h" MFXInit "-llibmfx $advapi32_extralibs" && warn "using libmfx without pkg-config"; } } && + warn "build FFmpeg against libmfx 1.x, obsolete features of libmfx such as OPAQUE memory,\n"\ + "multi-frame encode, user plugins and LA_EXT rate control mode are enabled"; } + if enabled libmfx; then check_cc MFX_CODEC_VP9 "mfx/mfxvp9.h mfx/mfxstructures.h" "MFX_CODEC_VP9" fi From patchwork Thu Sep 23 06:28:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xiang, Haihao" X-Patchwork-Id: 30480 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:6506:0:0:0:0:0 with SMTP id z6csp158439iob; Wed, 22 Sep 2021 23:29:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzCp+sZY2rjcQv05CFMKGcvLkJbpbXlmCVEQy5DWHIJ+b1qkTkTpNcZ1SjcRikmUEF+FdWK X-Received: by 2002:a50:bb09:: with SMTP id y9mr3584407ede.89.1632378546169; Wed, 22 Sep 2021 23:29:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632378546; cv=none; d=google.com; s=arc-20160816; b=hkOvrpX9Z4CCWuYGqZ4VMUbNV7IdIGEEG/zklH1wN8ke46ngSQ3gDQcuQP+cMl1A6q oaLmD5BL1JuHLYrrK9RSCe6VGfit6Tv7w4H6yAKwbzFxDUjMkZRROLzhvKF97tZ/vujs AWl6ItSTyhVK5IgCwLZNhLGc85l6CyeWrBmGTNxro7to6pIuf6m6Te6sZjREcKThFrq9 F4Xl6plSLIZ84iZIVINKHn5VtW5MSPJTyyBFG1b1gzFaGudYQW19HD1Jjy+TpMVHX7DP xvXq1RSYIH4S0EzpQJnYR6A3nksKfZxgp0HYJGArBK5pCqVV2764GZUtSUB45PaagVaX /eFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:delivered-to; bh=djioarOZ8oHOvjT3sO36d3dWxePGFxDnTXC9QgL4R/w=; b=cTyoQw5PjQct4ZapmiEXDUN2jQyKbi9X92/YWj3cm3BcvjKLhfwmKmpQ+7vm2JXopR 8XeSMQbxoP/hp8Vzwai62In3UIE0GzlcpxLb265w6agZf9IVDkGw1Qc3NnMh+ipB4Onb OWBhXQ0LJNGVn1KBtFmphMVyKpU7eb65W3OIsBy4MH6y7kaiPetU+XzYXbROmLlmy/NR q73h4kUZ694AZX+CI13d4EayrsnSZa9bk6DpcAFkANDb37Zpr1pnM8eioIItS3sf1PcE 1etqSp0rSWolG5SoSYFWUvzppiUwaoRSf+tiWm77TmHVa2l+ElN1b/8GsaaQhY5RIton FzsQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id b9si5162645edn.271.2021.09.22.23.29.05; Wed, 22 Sep 2021 23:29:06 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4A66F68A994; Thu, 23 Sep 2021 09:28:42 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C405768A920 for ; Thu, 23 Sep 2021 09:28:34 +0300 (EEST) X-IronPort-AV: E=McAfee;i="6200,9189,10115"; a="203930128" X-IronPort-AV: E=Sophos;i="5.85,316,1624345200"; d="scan'208";a="203930128" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2021 23:28:29 -0700 X-IronPort-AV: E=Sophos;i="5.85,316,1624345200"; d="scan'208";a="550689676" Received: from xhh-dg164.sh.intel.com ([10.239.159.167]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2021 23:28:28 -0700 From: Haihao Xiang To: ffmpeg-devel@ffmpeg.org Date: Thu, 23 Sep 2021 14:28:10 +0800 Message-Id: <20210923062818.18892-3-haihao.xiang@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210923062818.18892-1-haihao.xiang@intel.com> References: <20210923062818.18892-1-haihao.xiang@intel.com> Subject: [FFmpeg-devel] [PATCH v4 02/10] configure: fix the check for MFX_CODEC_VP9 X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Haihao Xiang MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: rGBpm42FZn0r The data structures for VP9 in mfxvp9.h is wrapped by MFX_VERSION_NEXT, which means those data structures have never been used in a public release. Actually MFX_CODEC_VP9 and other VP9 stuffs is added in mfxstructures.h. In addition, mfxdefs.h is included in mfxvp9.h, so we may use the check in this patch for MFX_CODEC_VP9 This is in preparation for oneVPL support because mfxvp9.h is removed from oneVPL [1] [1]: https://github.com/oneapi-src/oneVPL --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 34e9a7c863..21c744e627 100755 --- a/configure +++ b/configure @@ -6440,7 +6440,7 @@ enabled libmfx && { { check_pkg_config libmfx "libmfx < 2.0" "mfx/mfx "multi-frame encode, user plugins and LA_EXT rate control mode are enabled"; } if enabled libmfx; then - check_cc MFX_CODEC_VP9 "mfx/mfxvp9.h mfx/mfxstructures.h" "MFX_CODEC_VP9" + check_cc MFX_CODEC_VP9 "mfx/mfxdefs.h mfx/mfxstructures.h" "MFX_CODEC_VP9" fi enabled libmodplug && require_pkg_config libmodplug libmodplug libmodplug/modplug.h ModPlug_Load From patchwork Thu Sep 23 06:28:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xiang, Haihao" X-Patchwork-Id: 30475 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:6506:0:0:0:0:0 with SMTP id z6csp158551iob; Wed, 22 Sep 2021 23:29:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw3nPUqugfh9/AeICPSg1QJoFRp+jwOhkHRkvuzotv0OrjxQPPhPhltPY19ifdbebrdMTN2 X-Received: by 2002:a17:906:269a:: with SMTP id t26mr3378629ejc.20.1632378556721; Wed, 22 Sep 2021 23:29:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632378556; cv=none; d=google.com; s=arc-20160816; b=SxycvU8ixRQaM+shrvvzgh8yIBD88yV+2c2BXMPrRTajIvbRgVL6JW6zsEq/sc2hxn eEdIzeHbSSjRJdi9maiNzjfHRf6QH/AvfbwOxhC6/HBcWwgmuYKsCkrtnZsNS8PVpYoA VsjYqB5egIA9rFJwTlxcpcKmEq3ERXOvbGPy93p54OgOZonV9ezfmIWvlrKnmTvo8mYY lotQIhMhVJY0vAsJcD3tM2eePA7bzAqqIVzVstK0kVSvNOjoPT394WcWFTiUZ1mgiS9b QGM/Y/TWjievUKarmgf4Xw6juGFgB57vN6kzD2KlyFagPMgDdogWtMFMqnJEvOsd6two 6zoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:delivered-to; bh=+WuMXuZ4vxzCxICFUay+1huTGPuYDAGIV/vZeuf2u0E=; b=FyB8bAdxxB2r+f7TmnpFiUSGkOyAW2Zxcw0UhXnzNJQelozO4UODlWwyzQFqWXS3Z7 uK2HeXUOxqEM4vwk9M8zvcQAQFJWa+S85tw52PqxEmYfVsIIw1Rg8mNsxQ2crfGWmZ8w 5oiNn2J2kheS5hNVqOefKufIUQ+fJ6fuWUv23543GZmzLNC5rOQjPGYSyap6S90LZIdn w/X5yJ4hnczFmFtbuvrtVadhcsF5m4flYuS5Takrv2T0h4CAizMwXQtzJBepH6SHLv2U T6IRF3jqOBvCOfcZXFkqsa5H6AgHKS3OxJZpznQ79Zqta7ywwvnqSlvmpmlinGut5yCg 8hEQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id g4si5011301edq.224.2021.09.22.23.29.16; Wed, 22 Sep 2021 23:29:16 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 55EBB68A9CC; Thu, 23 Sep 2021 09:28:44 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DCEE86805AE for ; Thu, 23 Sep 2021 09:28:35 +0300 (EEST) X-IronPort-AV: E=McAfee;i="6200,9189,10115"; a="203930131" X-IronPort-AV: E=Sophos;i="5.85,316,1624345200"; d="scan'208";a="203930131" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2021 23:28:30 -0700 X-IronPort-AV: E=Sophos;i="5.85,316,1624345200"; d="scan'208";a="550689688" Received: from xhh-dg164.sh.intel.com ([10.239.159.167]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2021 23:28:29 -0700 From: Haihao Xiang To: ffmpeg-devel@ffmpeg.org Date: Thu, 23 Sep 2021 14:28:11 +0800 Message-Id: <20210923062818.18892-4-haihao.xiang@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210923062818.18892-1-haihao.xiang@intel.com> References: <20210923062818.18892-1-haihao.xiang@intel.com> Subject: [FFmpeg-devel] [PATCH v4 03/10] qsv: remove mfx/ prefix from mfx headers X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Haihao Xiang MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: B9NY9lr9zfji The following Cflags has been added to libmfx.pc, so mfx/ prefix is no longer needed when including mfx headers in FFmpeg. Cflags: -I${includedir} -I${includedir}/mfx Some old versions of libmfx have the following Cflags in libmfx.pc Cflags: -I${includedir} We may add -I${includedir}/mfx to CFLAGS when running 'configure --enable-libmfx' for old versions of libmfx, if so, mfx headers without mfx/ prefix can be included too. If libmfx comes without pkg-config support, we may do a small change to the settings of the environment(e.g. set -I/opt/intel/mediasdk/include/mfx instead of -I/opt/intel/mediasdk/include to CFLAGS), then the build can find the mfx headers without mfx/ prefix After applying this change, we won't need to change #include for mfx headers when mfx headers are installed under a new directory. This is in preparation for oneVPL support (mfx headers in oneVPL are installed under vpl directory) --- configure | 13 +++++++++---- libavcodec/qsv.c | 8 ++++---- libavcodec/qsv.h | 2 +- libavcodec/qsv_internal.h | 2 +- libavcodec/qsvdec.c | 2 +- libavcodec/qsvenc.c | 2 +- libavcodec/qsvenc.h | 2 +- libavcodec/qsvenc_h264.c | 2 +- libavcodec/qsvenc_hevc.c | 2 +- libavcodec/qsvenc_jpeg.c | 2 +- libavcodec/qsvenc_mpeg2.c | 2 +- libavcodec/qsvenc_vp9.c | 2 +- libavfilter/qsvvpp.h | 2 +- libavfilter/vf_deinterlace_qsv.c | 2 +- libavfilter/vf_scale_qsv.c | 2 +- libavutil/hwcontext_opencl.c | 2 +- libavutil/hwcontext_qsv.c | 2 +- libavutil/hwcontext_qsv.h | 2 +- 18 files changed, 29 insertions(+), 24 deletions(-) diff --git a/configure b/configure index 21c744e627..9655a5823e 100755 --- a/configure +++ b/configure @@ -6434,13 +6434,18 @@ enabled liblensfun && require_pkg_config liblensfun lensfun lensfun.h lf_ # Media SDK or Intel Media Server Studio, these don't come with # pkg-config support. Instead, users should make sure that the build # can find the libraries and headers through other means. -enabled libmfx && { { check_pkg_config libmfx "libmfx < 2.0" "mfx/mfxvideo.h" MFXInit || - { require "libmfx < 2.0" "mfx/mfxvideo.h" MFXInit "-llibmfx $advapi32_extralibs" && warn "using libmfx without pkg-config"; } } && + +enabled libmfx && { { check_pkg_config libmfx "libmfx < 2.0" "mfxvideo.h" MFXInit || +# Some old versions of libmfx have the following settings in libmfx.pc: +# includedir=/usr/include +# Cflags: -I${includedir} +# So add -I${includedir}/mfx to CFLAGS + { check_pkg_config libmfx "libmfx < 2.0" "mfx/mfxvideo.h" MFXInit && add_cflags -I$($pkg_config --variable=includedir libmfx)/mfx; } || + { require "libmfx < 2.0" "mfxvideo.h" MFXInit "-llibmfx $advapi32_extralibs" && warn "using libmfx without pkg-config"; } } && warn "build FFmpeg against libmfx 1.x, obsolete features of libmfx such as OPAQUE memory,\n"\ "multi-frame encode, user plugins and LA_EXT rate control mode are enabled"; } - if enabled libmfx; then - check_cc MFX_CODEC_VP9 "mfx/mfxdefs.h mfx/mfxstructures.h" "MFX_CODEC_VP9" + check_cc MFX_CODEC_VP9 "mfxdefs.h mfxstructures.h" "MFX_CODEC_VP9" fi enabled libmodplug && require_pkg_config libmodplug libmodplug libmodplug/modplug.h ModPlug_Load diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c index 9d08485c92..84f0401b0f 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 @@ -39,7 +39,7 @@ #define MFX_IMPL_VIA_MASK(impl) (0x0f00 & (impl)) #if QSV_VERSION_ATLEAST(1, 12) -#include "mfx/mfxvp8.h" +#include "mfxvp8.h" #endif int ff_qsv_codec_id_to_mfx(enum AVCodecID codec_id) diff --git a/libavcodec/qsv.h b/libavcodec/qsv.h index b77158ec26..04ae0d6f34 100644 --- a/libavcodec/qsv.h +++ b/libavcodec/qsv.h @@ -21,7 +21,7 @@ #ifndef AVCODEC_QSV_H #define AVCODEC_QSV_H -#include +#include #include "libavutil/buffer.h" diff --git a/libavcodec/qsv_internal.h b/libavcodec/qsv_internal.h index 8090b748b3..24c3e9307e 100644 --- a/libavcodec/qsv_internal.h +++ b/libavcodec/qsv_internal.h @@ -39,7 +39,7 @@ #include "libavutil/hwcontext_vaapi.h" #endif -#include +#include #include "libavutil/frame.h" diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c index 8bce9f2cf0..1cadb846f5 100644 --- a/libavcodec/qsvdec.c +++ b/libavcodec/qsvdec.c @@ -25,7 +25,7 @@ #include #include -#include +#include #include "libavutil/common.h" #include "libavutil/fifo.h" diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index f7bb3f5eff..5e76299372 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -23,7 +23,7 @@ #include #include -#include +#include #include "libavutil/common.h" #include "libavutil/hwcontext.h" diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h index 31516b8e55..7a71ffe98f 100644 --- a/libavcodec/qsvenc.h +++ b/libavcodec/qsvenc.h @@ -26,7 +26,7 @@ #include #include -#include +#include #include "libavutil/avutil.h" #include "libavutil/fifo.h" diff --git a/libavcodec/qsvenc_h264.c b/libavcodec/qsvenc_h264.c index 80fe3cc280..9134e6a68c 100644 --- a/libavcodec/qsvenc_h264.c +++ b/libavcodec/qsvenc_h264.c @@ -24,7 +24,7 @@ #include #include -#include +#include #include "libavutil/common.h" #include "libavutil/opt.h" diff --git a/libavcodec/qsvenc_hevc.c b/libavcodec/qsvenc_hevc.c index b7b2f5633e..a268a002d6 100644 --- a/libavcodec/qsvenc_hevc.c +++ b/libavcodec/qsvenc_hevc.c @@ -22,7 +22,7 @@ #include #include -#include +#include #include "libavutil/common.h" #include "libavutil/opt.h" diff --git a/libavcodec/qsvenc_jpeg.c b/libavcodec/qsvenc_jpeg.c index dd082692be..ad8f09befe 100644 --- a/libavcodec/qsvenc_jpeg.c +++ b/libavcodec/qsvenc_jpeg.c @@ -22,7 +22,7 @@ #include #include -#include +#include #include "libavutil/common.h" #include "libavutil/opt.h" diff --git a/libavcodec/qsvenc_mpeg2.c b/libavcodec/qsvenc_mpeg2.c index 525df99e50..610bbf79c1 100644 --- a/libavcodec/qsvenc_mpeg2.c +++ b/libavcodec/qsvenc_mpeg2.c @@ -22,7 +22,7 @@ #include #include -#include +#include #include "libavutil/common.h" #include "libavutil/opt.h" diff --git a/libavcodec/qsvenc_vp9.c b/libavcodec/qsvenc_vp9.c index 9329990d11..0a382eb76d 100644 --- a/libavcodec/qsvenc_vp9.c +++ b/libavcodec/qsvenc_vp9.c @@ -22,7 +22,7 @@ #include #include -#include +#include #include "libavutil/common.h" #include "libavutil/opt.h" diff --git a/libavfilter/qsvvpp.h b/libavfilter/qsvvpp.h index e0f4c8f5bb..8c0cf3ed95 100644 --- a/libavfilter/qsvvpp.h +++ b/libavfilter/qsvvpp.h @@ -24,7 +24,7 @@ #ifndef AVFILTER_QSVVPP_H #define AVFILTER_QSVVPP_H -#include +#include #include "avfilter.h" #include "libavutil/fifo.h" diff --git a/libavfilter/vf_deinterlace_qsv.c b/libavfilter/vf_deinterlace_qsv.c index 173c314bb8..ab849558ef 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 5a37cef63d..19c9bb6463 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 26a3a24593..194165fba2 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 225ae768a9..7ded65e6b5 100644 --- a/libavutil/hwcontext_qsv.c +++ b/libavutil/hwcontext_qsv.c @@ -19,7 +19,7 @@ #include #include -#include +#include #include "config.h" diff --git a/libavutil/hwcontext_qsv.h b/libavutil/hwcontext_qsv.h index b98d611cfc..42e34d0dda 100644 --- a/libavutil/hwcontext_qsv.h +++ b/libavutil/hwcontext_qsv.h @@ -19,7 +19,7 @@ #ifndef AVUTIL_HWCONTEXT_QSV_H #define AVUTIL_HWCONTEXT_QSV_H -#include +#include /** * @file From patchwork Thu Sep 23 06:28:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xiang, Haihao" X-Patchwork-Id: 30478 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:6506:0:0:0:0:0 with SMTP id z6csp158638iob; Wed, 22 Sep 2021 23:29:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzn4Gl3zb6yIXkxOJYrrlDvEUNYcMkWqk5NBQx6AbrZxlh1aOOPN7AswPjaHHV70xY1dnZR X-Received: by 2002:a50:9d85:: with SMTP id w5mr3675738ede.268.1632378567093; Wed, 22 Sep 2021 23:29:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632378567; cv=none; d=google.com; s=arc-20160816; b=BWBGiLIzDOWWDgMAvUQZSjSp1+vrO3eK9RoT1A+aBRuQYNcCkt0zpcfOJwS6vb+ReW i17LSxTJIG4RKhbi6v4sPMZaph2V2l6D+KJS78iRJ1wqa4fX9ySzXL+7wvkNlTzR4CIV VcbH5lYHTOkVuEPO8p7Pv5psZDynt5mzFWkOx70/ZGBoSIt/stRWS6xXFNcGbpkKva4j 27SKz6cRQUNk1GWKiiNISj+0horEIYFn4wQVraE7vA063AMR8Q5xpwcmoq4afjkGTToV Bn5PAuFZmRFGB1Wjd1Z66WnjBHkOhk0+vGlPTtutJhRG+7Gwz5+VDqQYTf58tZh6fvbH Y53Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:delivered-to; bh=oVJZmpxPf3chIli/qzwN1CMMiC/754nzmZ72JB6KNkA=; b=RyAo0cprTWDpTEIQuln5PzzlTazmzUM0ehxML8MS1tCkAVvWGkFjQimIcnwPVgHZYm /lMm9VijpL5lPvI6r+gbr0CNwo7obk4Jf8x9TzHvNIfXQTq04st75gJKdgDTDnp9tJOn ifA+tskvwTYwfGkuU5cacoB4tCrAw2YUPk147jIAPoISj2x5kVNgTpPQDkpZIXwx3uZF x3aMMSDzjOrUWmksylMCbeRTc6/jfdY6edUZXhFS4e9fXzq7GNx/17pLRPz4ySXS5Vlz 4Lx/yhd26i04cjwgO9mcOjZEI7nTHHWdlM/hnefyT5hVWh1sAglKGgO09Jegzi6Fi80u 7wbg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id dg13si4654922edb.604.2021.09.22.23.29.26; Wed, 22 Sep 2021 23:29:27 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5BE3E68AA81; Thu, 23 Sep 2021 09:28:47 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A842A68A9CC for ; Thu, 23 Sep 2021 09:28:37 +0300 (EEST) X-IronPort-AV: E=McAfee;i="6200,9189,10115"; a="203930133" X-IronPort-AV: E=Sophos;i="5.85,316,1624345200"; d="scan'208";a="203930133" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2021 23:28:32 -0700 X-IronPort-AV: E=Sophos;i="5.85,316,1624345200"; d="scan'208";a="550689705" Received: from xhh-dg164.sh.intel.com ([10.239.159.167]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2021 23:28:30 -0700 From: Haihao Xiang To: ffmpeg-devel@ffmpeg.org Date: Thu, 23 Sep 2021 14:28:12 +0800 Message-Id: <20210923062818.18892-5-haihao.xiang@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210923062818.18892-1-haihao.xiang@intel.com> References: <20210923062818.18892-1-haihao.xiang@intel.com> Subject: [FFmpeg-devel] [PATCH v4 04/10] qsv: load user plugin for MFX_VERSION < 2.0 X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Haihao Xiang MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: EOPqtyBsW2Sr User plugin isn't supported for MFX_VERSION >= 2.0[1][2]. This is in preparation for oneVPL Support [1]: https://spec.oneapi.io/versions/latest/elements/oneVPL/source/appendix/VPL_intel_media_sdk.html#msdk-full-name-feature-removals [2]: https://github.com/oneapi-src/oneVPL --- libavcodec/qsv.c | 8 +++++++- libavcodec/qsv_internal.h | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c index 84f0401b0f..83056e5976 100644 --- a/libavcodec/qsv.c +++ b/libavcodec/qsv.c @@ -19,7 +19,6 @@ */ #include -#include #include #include @@ -37,11 +36,16 @@ #include "qsv_internal.h" #define MFX_IMPL_VIA_MASK(impl) (0x0f00 & (impl)) +#define QSV_HAVE_USER_PLUGIN !QSV_ONEVPL #if QSV_VERSION_ATLEAST(1, 12) #include "mfxvp8.h" #endif +#if QSV_HAVE_USER_PLUGIN +#include +#endif + int ff_qsv_codec_id_to_mfx(enum AVCodecID codec_id) { switch (codec_id) { @@ -291,6 +295,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; @@ -334,6 +339,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 24c3e9307e..659417ded8 100644 --- a/libavcodec/qsv_internal.h +++ b/libavcodec/qsv_internal.h @@ -60,6 +60,8 @@ ((MFX_VERSION.Major > (MAJOR)) || \ (MFX_VERSION.Major == (MAJOR) && MFX_VERSION.Minor >= (MINOR))) +#define QSV_ONEVPL QSV_VERSION_ATLEAST(2, 0) + typedef struct QSVMid { AVBufferRef *hw_frames_ref; mfxHDLPair *handle_pair; From patchwork Thu Sep 23 06:28:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xiang, Haihao" X-Patchwork-Id: 30477 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:6506:0:0:0:0:0 with SMTP id z6csp158719iob; Wed, 22 Sep 2021 23:29:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJybg58I/b5cmJqKwW5WkBByoiXt8qa2MB+dErc3sdIfx4DiCJELwkjAT2Esr9mrcZIcFFRE X-Received: by 2002:a17:906:dbd7:: with SMTP id yc23mr3303836ejb.187.1632378577353; Wed, 22 Sep 2021 23:29:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632378577; cv=none; d=google.com; s=arc-20160816; b=Uzo1N8oxDg2vw/7c2OjIxT3vAoaz6NnJD/QXRZlBcDhmkAdkjjHT3fQg020GrpeWxH 4APa1UiPrZxGbHbT5negppEDxLHvBP0NxCYmOsz0TS1NN24qArmg9v1/q+Uge7j1NV62 zqg+xCblLqYMc8spdz/GyP/pfi2B921f4FgzyYHPoecmXJ2oUymQLeFYWy97/VUFcWAb ziVDoKYzl9coHQhIxUGXLdX1cn7A/Kk0AXXQm/bL1JeiBIIZ18J5AoK6PNT4ewD5YIWv 4lVJ570QDBZkHjlNDCl1RcwlMGTKxndZpqSs7tyzhA/pmtVxKuuFJpNVbwQ11yNA4JrN fFXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:delivered-to; bh=UIBVNB88fTHlUZoj3RlWVj2PKXaJkW91LGng8Huf7tc=; b=0M/0HCaRd1wqwyC1zwVPb6AupZxW0FTVRzapMjsSACRAfbs6+EM6TZOyy2GuMfTx1v GmafGuKYNyMFEDSUeSArjjzlGHUG/6JgTmq3mvOm1ZlEkZD1xwgTJ1SWg1r1nvuxUoJt 1AcbYqMTAsg6HflvCb64b/Lr8rYTxuZT8XAf6BDsLkzSd1J8jBKQb9EPeuqYpRs+8KnG f76CkPY16cgu8u8c+OHe6widdkP77j3HHpxy8lMLQ7uEw7bEDJ1ZDVx/3rmCQ4KsUjcc OapR9Yh8kAf1iwyAM3w9rvmthTfHROFgufDGykn5smAyfDWBuVndAI0LdoFo5gFgMRR3 /+rQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id h8si5254776ejo.303.2021.09.22.23.29.37; Wed, 22 Sep 2021 23:29:37 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 625DD68AAAC; Thu, 23 Sep 2021 09:28:48 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A907768A866 for ; Thu, 23 Sep 2021 09:28:40 +0300 (EEST) X-IronPort-AV: E=McAfee;i="6200,9189,10115"; a="203930134" X-IronPort-AV: E=Sophos;i="5.85,316,1624345200"; d="scan'208";a="203930134" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2021 23:28:33 -0700 X-IronPort-AV: E=Sophos;i="5.85,316,1624345200"; d="scan'208";a="550689718" Received: from xhh-dg164.sh.intel.com ([10.239.159.167]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2021 23:28:31 -0700 From: Haihao Xiang To: ffmpeg-devel@ffmpeg.org Date: Thu, 23 Sep 2021 14:28:13 +0800 Message-Id: <20210923062818.18892-6-haihao.xiang@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210923062818.18892-1-haihao.xiang@intel.com> References: <20210923062818.18892-1-haihao.xiang@intel.com> Subject: [FFmpeg-devel] [PATCH v4 05/10] qsv: build audio related code when MFX_VERSION < 2.0 X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Haihao Xiang MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: ADdzJo8Q/y6j Audio isn't supported for MFX_VERSION >= 2.0[1][2]. This is in preparation for oneVPL support [1]: https://spec.oneapi.io/versions/latest/elements/oneVPL/source/appendix/VPL_intel_media_sdk.html#msdk-full-name-feature-removals [2]: https://github.com/oneapi-src/oneVPL --- libavcodec/qsv.c | 5 +++++ libavfilter/qsvvpp.c | 6 ++++++ libavfilter/qsvvpp.h | 2 ++ 3 files changed, 13 insertions(+) diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c index 83056e5976..e0a124a5cb 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 #if QSV_VERSION_ATLEAST(1, 12) #include "mfxvp8.h" @@ -137,8 +138,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" }, @@ -148,7 +151,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 d1218355c7..1113d27ba1 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 }; static const struct { @@ -95,8 +97,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" }, @@ -106,7 +110,9 @@ static const struct { { MFX_WRN_VALUE_NOT_CHANGED, 0, "value is saturated" }, { MFX_WRN_OUT_OF_RANGE, 0, "value out of range" }, { MFX_WRN_FILTER_SKIPPED, 0, "filter skipped" }, +#if QSV_HAVE_AUDIO { MFX_WRN_INCOMPATIBLE_AUDIO_PARAM, 0, "incompatible audio parameters" }, +#endif }; static int qsv_map_error(mfxStatus mfx_err, const char **desc) diff --git a/libavfilter/qsvvpp.h b/libavfilter/qsvvpp.h index 8c0cf3ed95..46e90c1d2c 100644 --- a/libavfilter/qsvvpp.h +++ b/libavfilter/qsvvpp.h @@ -40,6 +40,8 @@ ((MFX_VERSION.Major > (MAJOR)) || \ (MFX_VERSION.Major == (MAJOR) && MFX_VERSION.Minor >= (MINOR))) +#define QSV_ONEVPL QSV_VERSION_ATLEAST(2, 0) + typedef struct QSVFrame { AVFrame *frame; mfxFrameSurface1 surface; From patchwork Thu Sep 23 06:28:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xiang, Haihao" X-Patchwork-Id: 30481 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:6506:0:0:0:0:0 with SMTP id z6csp158894iob; Wed, 22 Sep 2021 23:29:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJycHVFG9nEZblyhsCfc9156L5mAuL8CjkpRmxNJNb6LE9UsKXn7IvLdbRPYQc1sZHrIi8ry X-Received: by 2002:a50:9dcf:: with SMTP id l15mr3754434edk.128.1632378598193; Wed, 22 Sep 2021 23:29:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632378598; cv=none; d=google.com; s=arc-20160816; b=AqjGdOsazmavkZgBhSPBhfqFt6rrfuJmgF/8t1XbNPuxPZvlyzTALaL5wo6q+fkVUR 84Qg8GGhjnRA512B9Av+HDNofZldLmXwRPXbfDLI0m8IH0TRPtqTti43vXLieTk0QJfL wm6iqMmI8qENjR1IaLlOcboez76DzxZ4ajcouLMvCZeNZBjNJ0LgROTQVWpw9FNlhIRt Mym2DrLELPeH99950KBaGdwntrtfOEqA3Q9joTmPkbPEmPHd8VXACmNR/boC1dCAtVK/ JwSCDrMs8ist7LQvAk7svWLUSfU/6qnok1evszszKoRodtaiV2zPLHEUihIUICAGcW9f DgkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:delivered-to; bh=fm8XtoUhMarykFo7b/qESK8aANSZJrtBHk/zHF+G/ko=; b=koCX5LG2+fweC/m6+aB1sXnsAo5OHeoiN+CDmPvLDiTJFhX4v+9KOoadiOGG3yRtB/ wztTxURiX/uHHazZGOm7UZgh7mXAOLPWghQJBg0sPF7CsuD5WFeZ4/DHhoMBtdm5U8I+ v0+MFzmEqy8/CmucuY5aqpjn/dp50m8IutYM/p6x3itJuy5mg7kX28Az5P2Pn5DWl6TI bSGXauk21ihEqsV5vooWye1yDb+P4P5EMWI/R5BknuXCkpl+FvUSUhksrUZ+DIxhIICg bSrzEhaScO15u0E7VU1ZMYTIkJJTf54bgYAQ4sNBYUIk1evlH0FPRW2bN51I2qSVhBiO iYng== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id i5si5093397ejo.605.2021.09.22.23.29.57; Wed, 22 Sep 2021 23:29:58 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 585C368AA6E; Thu, 23 Sep 2021 09:28:50 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7443C68AA87 for ; Thu, 23 Sep 2021 09:28:41 +0300 (EEST) X-IronPort-AV: E=McAfee;i="6200,9189,10115"; a="203930135" X-IronPort-AV: E=Sophos;i="5.85,316,1624345200"; d="scan'208";a="203930135" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2021 23:28:33 -0700 X-IronPort-AV: E=Sophos;i="5.85,316,1624345200"; d="scan'208";a="550689727" Received: from xhh-dg164.sh.intel.com ([10.239.159.167]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2021 23:28:32 -0700 From: Haihao Xiang To: ffmpeg-devel@ffmpeg.org Date: Thu, 23 Sep 2021 14:28:14 +0800 Message-Id: <20210923062818.18892-7-haihao.xiang@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210923062818.18892-1-haihao.xiang@intel.com> References: <20210923062818.18892-1-haihao.xiang@intel.com> Subject: [FFmpeg-devel] [PATCH v4 06/10] qsvenc: support multi-frame encode when MFX_VERSION < 2.0 X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Haihao Xiang MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: G0VbqbMp84Ae Multi-frame encode isn't supported for MFX_VERSION >= 2.0[1][2]. This is in preparation for oneVPL support [1]: https://spec.oneapi.io/versions/latest/elements/oneVPL/source/appendix/VPL_intel_media_sdk.html#msdk-full-name-feature-removals [2]: https://github.com/oneapi-src/oneVPL --- libavcodec/qsvenc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h index 7a71ffe98f..93af4d1198 100644 --- a/libavcodec/qsvenc.h +++ b/libavcodec/qsvenc.h @@ -64,7 +64,7 @@ #define QSV_HAVE_ICQ QSV_VERSION_ATLEAST(1, 28) #define QSV_HAVE_VCM 0 #define QSV_HAVE_QVBR QSV_VERSION_ATLEAST(1, 28) -#define QSV_HAVE_MF QSV_VERSION_ATLEAST(1, 25) +#define QSV_HAVE_MF QSV_VERSION_ATLEAST(1, 25) && !QSV_ONEVPL #endif #if !QSV_HAVE_LA_DS From patchwork Thu Sep 23 06:28:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xiang, Haihao" X-Patchwork-Id: 30479 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:6506:0:0:0:0:0 with SMTP id z6csp159205iob; Wed, 22 Sep 2021 23:30:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyyC+okxemdYiagpzb2fsL9t3E3V5e6dMhrpmmfABe8lOEg3+cA/JZCUcAISY9j+47+xZa5 X-Received: by 2002:a17:906:48e:: with SMTP id f14mr3135443eja.433.1632378630285; Wed, 22 Sep 2021 23:30:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632378630; cv=none; d=google.com; s=arc-20160816; b=cp1OPZyXs+ehdVukfQ+aB+k58X8+ZshXHfJbgUcb0Reh+p6efSgtd8g9FVvkIBbZP9 td7SJlThEr+yl3US2shToT+n1ZrmTodz6hrn4tQ59fw7NhDSQpDmqvlvJHlNu/BdHwZD 5jse/cfaBTZtzvx+bFuuwySS09gBkeetAGnb/PwC8yvgvGCSbnXJrS0+HxniH21wK8+U OMNk/hgZ4gK4pd/nz4fUufA0kQwVmv0YCUh6eHXmSbz/l2DrhVQqY2kkc9GpLP0WXNv/ +X6SIPg7Kwnzc3CzJJgC+khBmg/W0T8KXnDRGmHFiya3A0cNRCfAwJXD4uekl/Qybuqd H0qQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:delivered-to; bh=tzmITKsXu5SXObFqJVtiWG9RtemQiQGtBkVYImy7TwA=; b=kTMpW8P1mGExQ21xsICA9DRcP34tFqZHRc69lbHVfCmzQ9GgXO/EKYYfgnm5AqcGhi nCK6I9aPUrWQnKolCSjc0SypqP2FnhwmJkCGuX2OF/JECHXWkx7FiIi9CSQlhovS4dp7 5cYFbDKUsbr1vEe45GrRiLAeEhdF+X7YC5AikzB+CPX9kJVgopssR2vQdcfX+ZgMB5bu lT5FFFZXeKvtrXK9qKO61feYyUO63LWCkZmtrQtmWeW8k9u42fQOs2Jux8FsrXl9qZC/ iiYy2oG3D+BnNDs/TQQV98Wo+C7cIMGgrYfXwm+viYsksjyo633uDS8rB2zhjMLvnQlP 3k2Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id e9si5983999edz.119.2021.09.22.23.30.29; Wed, 22 Sep 2021 23:30:30 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0EBC368AAE8; Thu, 23 Sep 2021 09:28:54 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 678BE68AB29 for ; Thu, 23 Sep 2021 09:28:44 +0300 (EEST) X-IronPort-AV: E=McAfee;i="6200,9189,10115"; a="203930147" X-IronPort-AV: E=Sophos;i="5.85,316,1624345200"; d="scan'208";a="203930147" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2021 23:28:34 -0700 X-IronPort-AV: E=Sophos;i="5.85,316,1624345200"; d="scan'208";a="550689730" Received: from xhh-dg164.sh.intel.com ([10.239.159.167]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2021 23:28:33 -0700 From: Haihao Xiang To: ffmpeg-devel@ffmpeg.org Date: Thu, 23 Sep 2021 14:28:15 +0800 Message-Id: <20210923062818.18892-8-haihao.xiang@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210923062818.18892-1-haihao.xiang@intel.com> References: <20210923062818.18892-1-haihao.xiang@intel.com> Subject: [FFmpeg-devel] [PATCH v4 07/10] qsvenc: support MFX_RATECONTROL_LA_EXT when MFX_VERSION < 2.0 X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Haihao Xiang MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: Y3zU00oowLmV MFX_RATECONTROL_LA_EXT isn't supported for MFX_VERSION >= 2.0[1][2]. This is in preparation for oneVPL support [1]: https://spec.oneapi.io/versions/latest/elements/oneVPL/source/appendix/VPL_intel_media_sdk.html#msdk-full-name-feature-removals [2]: https://github.com/oneapi-src/oneVPL --- libavcodec/qsvenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index 5e76299372..69fbc2b53b 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -100,7 +100,7 @@ static const struct { #if QSV_HAVE_VCM { MFX_RATECONTROL_VCM, "VCM" }, #endif -#if QSV_VERSION_ATLEAST(1, 10) +#if QSV_VERSION_ATLEAST(1, 10) && !QSV_ONEVPL { MFX_RATECONTROL_LA_EXT, "LA_EXT" }, #endif #if QSV_HAVE_LA_HRD From patchwork Thu Sep 23 06:28:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xiang, Haihao" X-Patchwork-Id: 30474 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:6506:0:0:0:0:0 with SMTP id z6csp158805iob; Wed, 22 Sep 2021 23:29:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwn6bwHKkzOZMBMMazlNcOsoFVKLNaX9D0AO/OQ1C4MWbNnJt/pzlXuSCjRAQDMn8VqSYJV X-Received: by 2002:a17:906:680c:: with SMTP id k12mr3267335ejr.85.1632378587943; Wed, 22 Sep 2021 23:29:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632378587; cv=none; d=google.com; s=arc-20160816; b=elwpu7joLbVQllqIrb6EWkzhCVypzMYAQ3yYSlozw6HOGOBU/FZVztSH9XrhSVIMZP nh+AqqroXHLj8NdK4/Q4DbpyDm2v8kVfpP/glQw06gPhiHpDJTJhK8zU9VZB970rM6sU UeGgZxdLy8wgack6p/22HR76BNVbBNWfscpe4altMmYx18y6yfJodWol/AIj/r3yPBSY 7P26cjOF9L2/2eJxnfLtsMXBGTM15KKd1smvPXWH3KrIQxVMnl8L35dPDH7IucUWak9W C1P9dfZa1+r88OFtUp97xKwmUsFrqlt2mXsGnoXFXZfQV2OW/8Fu+O+a9ZNysNiapCBg 7A5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:delivered-to; bh=JIYWGPy2FFUoJcQJtVZXZM+32rB8m0FMu6ze4EQ8mSI=; b=piAadU5pEtZcyBDne2Zb/WZdVS+ONycDY8gw09jBns46x4XVBnV75U0cbepjRu/2ls luPv2YqQR9SsNN3/mLEjNvEVg5hG9/8U/IWqD1Ax1Gt7LW7g9YMngfpGNkm6r6yy1228 iQt1u+z6dnmW0SUwKJC+O42xwtLCkhQdtVN6xhm+tkS0LxYpWSBAFUhaHMRfQ7j2vXtH WuUVXs7QxHeY7sW68Q4Kzzckb/DJ8mr7AwnOHSb9RhEHEb64s4Yj8fiudWyUvv/BEMie DzOf9ha4wErVgS5/eELv88TrpKc7GTWJdyR/vcZdR0HbhgvMSoroZLAr7y8BwQmyEGfH qq7A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id c24si5081107edn.26.2021.09.22.23.29.47; Wed, 22 Sep 2021 23:29:47 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5900A68AB25; Thu, 23 Sep 2021 09:28:49 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9E5AF68A866 for ; Thu, 23 Sep 2021 09:28:46 +0300 (EEST) X-IronPort-AV: E=McAfee;i="6200,9189,10115"; a="203930151" X-IronPort-AV: E=Sophos;i="5.85,316,1624345200"; d="scan'208";a="203930151" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2021 23:28:36 -0700 X-IronPort-AV: E=Sophos;i="5.85,316,1624345200"; d="scan'208";a="550689743" Received: from xhh-dg164.sh.intel.com ([10.239.159.167]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2021 23:28:35 -0700 From: Haihao Xiang To: ffmpeg-devel@ffmpeg.org Date: Thu, 23 Sep 2021 14:28:16 +0800 Message-Id: <20210923062818.18892-9-haihao.xiang@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210923062818.18892-1-haihao.xiang@intel.com> References: <20210923062818.18892-1-haihao.xiang@intel.com> Subject: [FFmpeg-devel] [PATCH v4 08/10] qsv: support OPAQUE memory when MFX_VERSION < 2.0 X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Haihao Xiang MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: CYTSeFP4M/oU OPAQUE memory isn't supported for MFX_VERSION >= 2.0[1][2]. This is in preparation for oneVPL support [1]: https://spec.oneapi.io/versions/latest/elements/oneVPL/source/appendix/VPL_intel_media_sdk.html#msdk-full-name-feature-removals [2]: https://github.com/oneapi-src/oneVPL --- libavcodec/qsv.c | 4 ++ libavcodec/qsv.h | 2 + libavcodec/qsv_internal.h | 1 + libavcodec/qsvdec.c | 9 ++++ libavcodec/qsvenc.c | 21 +++++++++ libavcodec/qsvenc.h | 2 + libavfilter/qsvvpp.c | 26 ++++++++++- libavfilter/qsvvpp.h | 3 ++ libavfilter/vf_deinterlace_qsv.c | 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 e0a124a5cb..d6f77908e4 100644 --- a/libavcodec/qsv.c +++ b/libavcodec/qsv.c @@ -89,10 +89,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 659417ded8..ff50b41de8 100644 --- a/libavcodec/qsv_internal.h +++ b/libavcodec/qsv_internal.h @@ -61,6 +61,7 @@ (MFX_VERSION.Major == (MAJOR) && MFX_VERSION.Minor >= (MINOR))) #define QSV_ONEVPL QSV_VERSION_ATLEAST(2, 0) +#define QSV_HAVE_OPAQUE !QSV_ONEVPL typedef struct QSVMid { AVBufferRef *hw_frames_ref; diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c index 1cadb846f5..9395a1fd9a 100644 --- a/libavcodec/qsvdec.c +++ b/libavcodec/qsvdec.c @@ -171,7 +171,11 @@ static int qsv_init_session(AVCodecContext *avctx, QSVContext *q, mfxSession ses ret = ff_qsv_init_session_frames(avctx, &q->internal_qs.session, &q->frames_ctx, q->load_plugins, +#if QSV_HAVE_OPAQUE q->iopattern == MFX_IOPATTERN_OUT_OPAQUE_MEMORY, +#else + 0, +#endif q->gpu_copy); if (ret < 0) { av_buffer_unref(&q->frames_ctx.hw_frames_ctx); @@ -282,10 +286,15 @@ static int qsv_decode_preinit(AVCodecContext *avctx, QSVContext *q, enum AVPixel AVQSVFramesContext *frames_hwctx = frames_ctx->hwctx; if (!iopattern) { +#if QSV_HAVE_OPAQUE if (frames_hwctx->frame_type & MFX_MEMTYPE_OPAQUE_FRAME) iopattern = MFX_IOPATTERN_OUT_OPAQUE_MEMORY; else if (frames_hwctx->frame_type & MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET) iopattern = MFX_IOPATTERN_OUT_VIDEO_MEMORY; +#else + if (frames_hwctx->frame_type & MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET) + iopattern = MFX_IOPATTERN_OUT_VIDEO_MEMORY; +#endif } } diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index 69fbc2b53b..bf106264c7 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -1029,6 +1029,7 @@ static int qsv_retrieve_enc_params(AVCodecContext *avctx, QSVEncContext *q) return 0; } +#if QSV_HAVE_OPAQUE static int qsv_init_opaque_alloc(AVCodecContext *avctx, QSVEncContext *q) { AVQSVContext *qsv = avctx->hwaccel_context; @@ -1065,6 +1066,7 @@ static int qsv_init_opaque_alloc(AVCodecContext *avctx, QSVEncContext *q) return 0; } +#endif static int qsvenc_init_session(AVCodecContext *avctx, QSVEncContext *q) { @@ -1080,7 +1082,11 @@ static int qsvenc_init_session(AVCodecContext *avctx, QSVEncContext *q) ret = ff_qsv_init_session_frames(avctx, &q->internal_qs.session, &q->frames_ctx, q->load_plugins, +#if QSV_HAVE_OPAQUE q->param.IOPattern == MFX_IOPATTERN_IN_OPAQUE_MEMORY, +#else + 0, +#endif MFX_GPUCOPY_OFF); if (ret < 0) { av_buffer_unref(&q->frames_ctx.hw_frames_ctx); @@ -1142,11 +1148,17 @@ int ff_qsv_enc_init(AVCodecContext *avctx, QSVEncContext *q) AVQSVFramesContext *frames_hwctx = frames_ctx->hwctx; if (!iopattern) { +#if QSV_HAVE_OPAQUE if (frames_hwctx->frame_type & MFX_MEMTYPE_OPAQUE_FRAME) iopattern = MFX_IOPATTERN_IN_OPAQUE_MEMORY; else if (frames_hwctx->frame_type & (MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET | MFX_MEMTYPE_VIDEO_MEMORY_PROCESSOR_TARGET)) iopattern = MFX_IOPATTERN_IN_VIDEO_MEMORY; +#else + if (frames_hwctx->frame_type & + (MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET | MFX_MEMTYPE_VIDEO_MEMORY_PROCESSOR_TARGET)) + iopattern = MFX_IOPATTERN_IN_VIDEO_MEMORY; +#endif } } @@ -1220,9 +1232,16 @@ int ff_qsv_enc_init(AVCodecContext *avctx, QSVEncContext *q) "Error querying (IOSurf) the encoding parameters"); if (opaque_alloc) { +#if QSV_HAVE_OPAQUE ret = qsv_init_opaque_alloc(avctx, q); if (ret < 0) return ret; +#else + av_log(avctx, AV_LOG_ERROR, "User is requesting to allocate OPAQUE surface, " + "however libmfx %d.%d doesn't support OPAQUE memory.\n", + q->ver.Major, q->ver.Minor); + return AVERROR_UNKNOWN; +#endif } ret = MFXVideoENCODE_Init(q->session, &q->param); @@ -1665,8 +1684,10 @@ int ff_qsv_enc_close(AVCodecContext *avctx, QSVEncContext *q) av_fifo_free(q->async_fifo); q->async_fifo = NULL; +#if QSV_HAVE_OPAQUE av_freep(&q->opaque_surfaces); av_buffer_unref(&q->opaque_alloc_buf); +#endif av_freep(&q->extparam); diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h index 93af4d1198..320ad6db2b 100644 --- a/libavcodec/qsvenc.h +++ b/libavcodec/qsvenc.h @@ -135,9 +135,11 @@ typedef struct QSVEncContext { mfxExtVP9Param extvp9param; #endif +#if QSV_HAVE_OPAQUE mfxExtOpaqueSurfaceAlloc opaque_alloc; mfxFrameSurface1 **opaque_surfaces; AVBufferRef *opaque_alloc_buf; +#endif mfxExtVideoSignalInfo extvsi; diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c index 1113d27ba1..d9d39c8b70 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)) @@ -48,10 +50,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, @@ -531,9 +537,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; @@ -619,6 +629,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; @@ -630,7 +641,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, @@ -712,6 +725,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)); @@ -729,6 +743,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; @@ -746,15 +764,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"); @@ -793,7 +815,9 @@ int ff_qsvvpp_free(QSVVPPContext **vpp) clear_frame_list(&s->out_frame_list); av_freep(&s->surface_ptrs_in); av_freep(&s->surface_ptrs_out); +#if QSV_HAVE_OPAQUE av_freep(&s->ext_buffers); +#endif av_freep(&s->frame_infos); av_fifo_free(s->async_fifo); av_freep(vpp); diff --git a/libavfilter/qsvvpp.h b/libavfilter/qsvvpp.h index 46e90c1d2c..67c351f297 100644 --- a/libavfilter/qsvvpp.h +++ b/libavfilter/qsvvpp.h @@ -41,6 +41,7 @@ (MFX_VERSION.Major == (MAJOR) && MFX_VERSION.Minor >= (MINOR))) #define QSV_ONEVPL QSV_VERSION_ATLEAST(2, 0) +#define QSV_HAVE_OPAQUE !QSV_ONEVPL typedef struct QSVFrame { AVFrame *frame; @@ -66,10 +67,12 @@ typedef struct QSVVPPContext { mfxFrameSurface1 **surface_ptrs_in; mfxFrameSurface1 **surface_ptrs_out; +#if QSV_HAVE_OPAQUE /** MFXVPP extern parameters */ mfxExtOpaqueSurfaceAlloc opaque_alloc; mfxExtBuffer **ext_buffers; int nb_ext_buffers; +#endif int got_frame; int async_depth; diff --git a/libavfilter/vf_deinterlace_qsv.c b/libavfilter/vf_deinterlace_qsv.c index ab849558ef..fe6cb69afe 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; @@ -163,9 +165,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; @@ -174,6 +174,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) @@ -232,28 +235,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, @@ -277,6 +259,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 19c9bb6463..6cc6d192ff 100644 --- a/libavfilter/vf_scale_qsv.c +++ b/libavfilter/vf_scale_qsv.c @@ -90,7 +90,9 @@ typedef struct QSVScaleContext { mfxFrameSurface1 **surface_ptrs_out; int nb_surface_ptrs_out; +#if QSV_HAVE_OPAQUE mfxExtOpaqueSurfaceAlloc opaque_alloc; +#endif #if QSV_HAVE_SCALING_CONFIG mfxExtVPPScaling scale_conf; @@ -280,7 +282,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; @@ -290,6 +292,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 */ @@ -342,38 +347,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, @@ -405,6 +379,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 #if QSV_HAVE_SCALING_CONFIG memset(&s->scale_conf, 0, sizeof(mfxExtVPPScaling)); diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c index 7ded65e6b5..25f75e0ee7 100644 --- a/libavutil/hwcontext_qsv.c +++ b/libavutil/hwcontext_qsv.c @@ -53,6 +53,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; @@ -85,11 +87,13 @@ typedef struct QSVFramesContext { // used in the frame allocator for non-opaque surfaces mfxMemId *mem_ids; +#if QSV_HAVE_OPAQUE // used in the opaque alloc request for opaque surfaces mfxFrameSurface1 **surface_ptrs; mfxExtOpaqueSurfaceAlloc opaque_alloc; mfxExtBuffer *ext_buffers[1]; +#endif } QSVFramesContext; static const struct { @@ -217,7 +221,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_buffer_unref(&s->child_frames_ref); @@ -453,11 +459,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); @@ -528,10 +540,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, @@ -545,6 +556,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"); @@ -566,15 +582,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; @@ -606,11 +625,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"); @@ -625,7 +648,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) @@ -644,14 +676,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 Thu Sep 23 06:28:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xiang, Haihao" X-Patchwork-Id: 30476 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:6506:0:0:0:0:0 with SMTP id z6csp159007iob; Wed, 22 Sep 2021 23:30:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzxxwjpQMKkS7Z7eM9FDlWx9b53y2S1BSvDX8x7/oIG4i+wKU1YQ2WCzhAIEFJJy9as+aOG X-Received: by 2002:a17:906:3b53:: with SMTP id h19mr3214491ejf.109.1632378608888; Wed, 22 Sep 2021 23:30:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632378608; cv=none; d=google.com; s=arc-20160816; b=OURI6Xq4IUj8X7s1nA5EdyeGQX7ONtp+DZHhlm+R9P5F12wuxuG8qzHi4IB1sClzH0 6BW5xGNZwLLt4vaS7PMh4UsVeJHEG3Nm5QgR/lWTEl2qrnUPvvuWl6zl4lqXI85qxVjx OCkY1X4j5er1W6LQ7WJm6NWtbINO9wA6yfAGs699/WgZqEeYVCe9KMW1rj2RaJcqTPuF DjksqPWET4xg2k/0WZsYVsqf98w3lbK7s9dS3GCH5atnhGgqKxzJPpH0VuSy1KGrQ/PN aFzHxbzoKyOU00BdPvhGwA4wjHDmIWLkdgRuzqlsHl98/H30LChMgE1NG71rYnzWYQTm grlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:delivered-to; bh=fmCR09oiBAzFF1BLGdvkimWMZkOwC4GA50AHM8dhDuA=; b=Ho4/OZdAt6bhrispkvySRdYb4ZhzoXipknEXGO2xOxc6TNSfW/fuwvgwA7xhk45ojJ /q0GjSe4DsCUzAxV4x5sPSm5j2Zs5LEWiofu9iBx6if0rgctdgs8bzJ/mFcQpS37njI8 RHGTDv4h7Cpe8Vvk54c1evME1SfsV8LKTeJVHlu+bxWVCaI0S4xN7+hyUnFU4mBA+Uqh uj4Q41vq5rUK1O6T26jzx1kLGUOsPW9pRih3AV38iHJkisdVzkYdMuekLchqV7daHIQu 4oTJGo9+lRVX21FSuv/N9dDZ9kveUFsk36pQfXmr+zEJ/TLQDYhxV09jNu6UnJU9e+yJ bwJg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id i18si1266484edc.512.2021.09.22.23.30.08; Wed, 22 Sep 2021 23:30:08 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4474268AA61; Thu, 23 Sep 2021 09:28:51 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id BDA6968AA97 for ; Thu, 23 Sep 2021 09:28:47 +0300 (EEST) X-IronPort-AV: E=McAfee;i="6200,9189,10115"; a="203930154" X-IronPort-AV: E=Sophos;i="5.85,316,1624345200"; d="scan'208";a="203930154" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2021 23:28:37 -0700 X-IronPort-AV: E=Sophos;i="5.85,316,1624345200"; d="scan'208";a="550689760" Received: from xhh-dg164.sh.intel.com ([10.239.159.167]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2021 23:28:36 -0700 From: Haihao Xiang To: ffmpeg-devel@ffmpeg.org Date: Thu, 23 Sep 2021 14:28:17 +0800 Message-Id: <20210923062818.18892-10-haihao.xiang@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210923062818.18892-1-haihao.xiang@intel.com> References: <20210923062818.18892-1-haihao.xiang@intel.com> Subject: [FFmpeg-devel] [PATCH v4 09/10] qsv: use a new method to create mfx session when using 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: D68ZiwOA5//i In oneVPL, MFXLoad() and MFXCreateSession() are required to create a workable mfx session[1] Add AccelerationMode config filter 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 Signed-off-by: galinart --- libavcodec/qsv.c | 191 ++++++++++++++++-- libavcodec/qsv_internal.h | 1 + libavcodec/qsvdec.c | 4 + libavcodec/qsvenc.h | 3 + libavcodec/qsvenc_h264.c | 1 - libavcodec/qsvenc_hevc.c | 1 - libavcodec/qsvenc_jpeg.c | 1 - libavcodec/qsvenc_mpeg2.c | 1 - libavcodec/qsvenc_vp9.c | 1 - libavfilter/qsvvpp.c | 107 ++++++++++- libavfilter/qsvvpp.h | 5 + libavfilter/vf_deinterlace_qsv.c | 14 +- libavfilter/vf_scale_qsv.c | 12 +- libavutil/hwcontext_qsv.c | 319 +++++++++++++++++++++++++++---- libavutil/hwcontext_qsv.h | 16 ++ 15 files changed, 588 insertions(+), 89 deletions(-) diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c index d6f77908e4..f00bb4db8a 100644 --- a/libavcodec/qsv.c +++ b/libavcodec/qsv.c @@ -387,6 +387,164 @@ static int ff_qsv_set_display_handle(AVCodecContext *avctx, QSVSession *qs) } #endif //AVCODEC_QSV_LINUX_SESSION_HANDLE +#if QSV_ONEVPL + +static int qsv_create_mfx_session(AVCodecContext *avctx, + mfxIMPL implementation, + mfxVersion *pver, + int gpu_copy, + mfxSession *psession, + mfxLoader *ploader) +{ + mfxStatus sts; + mfxLoader loader = NULL; + mfxSession session = NULL; + mfxConfig cfg; + mfxVariant impl_value; + uint32_t impl_idx = 0; + + *psession = NULL; + + /* Don't create a new MFX loader if the input loader is valid */ + if (*ploader == NULL) { + av_log(avctx, AV_LOG_VERBOSE, + "Use Intel(R) oneVPL to create MFX session, the required " + "implementation version is %d.%d\n", + pver->Major, pver->Minor); + + loader = MFXLoad(); + + if (!loader) { + av_log(avctx, AV_LOG_ERROR, "Error creating a MFX loader\n"); + goto fail; + } + + /* Create configurations for implementation */ + cfg = MFXCreateConfig(loader); + + if (!cfg) { + av_log(avctx, AV_LOG_ERROR, "Error creating a MFX configurations\n"); + goto fail; + } + + impl_value.Type = MFX_VARIANT_TYPE_U32; + impl_value.Data.U32 = (implementation == MFX_IMPL_SOFTWARE) ? + MFX_IMPL_TYPE_SOFTWARE : MFX_IMPL_TYPE_HARDWARE; + sts = MFXSetConfigFilterProperty(cfg, + (const mfxU8 *)"mfxImplDescription.Impl", impl_value); + + if (sts != MFX_ERR_NONE) { + av_log(avctx, AV_LOG_ERROR, "Error adding a MFX configuration " + "property: %d\n", sts); + goto fail; + } + + impl_value.Type = MFX_VARIANT_TYPE_U32; + impl_value.Data.U32 = pver->Version; + sts = MFXSetConfigFilterProperty(cfg, + (const mfxU8 *)"mfxImplDescription.ApiVersion.Version", + impl_value); + + if (sts != MFX_ERR_NONE) { + av_log(avctx, AV_LOG_ERROR, "Error adding a MFX configuration " + "property: %d\n", sts); + goto fail; + } + } else { + av_log(avctx, AV_LOG_VERBOSE, + "Use Intel(R) oneVPL to create MFX session with the specified MFX loader\n"); + + loader = *ploader; + } + + while (1) { + /* Enumerate all implementations */ + mfxImplDescription *impl_desc; + + sts = MFXEnumImplementations(loader, impl_idx, + MFX_IMPLCAPS_IMPLDESCSTRUCTURE, + (mfxHDL *)&impl_desc); + + /* Failed to find an available implementation */ + if (sts == MFX_ERR_NOT_FOUND) + break; + else if (sts != MFX_ERR_NONE) { + impl_idx++; + continue; + } + + sts = MFXCreateSession(loader, impl_idx, &session); + MFXDispReleaseImplDescription(loader, impl_desc); + + if (sts == MFX_ERR_NONE) + break; + + impl_idx++; + } + + if (sts != MFX_ERR_NONE) { + av_log(avctx, AV_LOG_ERROR, "Error creating a MFX session: %d.\n", sts); + goto fail; + } + + *psession = session; + + if (!*ploader) + *ploader = loader; + + return 0; + +fail: + if (!*ploader && loader) + MFXUnload(loader); + + return AVERROR_UNKNOWN; +} + +#else + +static int qsv_create_mfx_session(AVCodecContext *avctx, + mfxIMPL implementation, + mfxVersion *pver, + int gpu_copy, + mfxSession *psession, + mfxLoader *ploader) +{ + mfxInitParam init_par = { MFX_IMPL_AUTO_ANY }; + mfxSession session = NULL; + mfxStatus sts; + + av_log(avctx, AV_LOG_VERBOSE, + "Use Intel(R) Media SDK to create MFX session, the required " + "implementation version is %d.%d\n", + pver->Major, pver->Minor); + + *psession = NULL; + *ploader = NULL; + +#if QSV_VERSION_ATLEAST(1, 16) + init_par.GPUCopy = gpu_copy; +#endif + init_par.Implementation = implementation; + init_par.Version = *pver; + sts = MFXInitEx(init_par, &session); + + if (sts < 0) + return ff_qsv_print_error(avctx, sts, + "Error initializing a MFX session"); + else if (sts > 0) { + ff_qsv_print_warning(avctx, sts, + "Warning in MFX initialization"); + return AVERROR_UNKNOWN; + } + + *psession = session; + + return 0; +} + +#endif + int ff_qsv_init_internal_session(AVCodecContext *avctx, QSVSession *qs, const char *load_plugins, int gpu_copy) { @@ -396,20 +554,13 @@ 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; + int ret = qsv_create_mfx_session(avctx, impl, &ver, gpu_copy, &qs->session, + &qs->loader); -#if QSV_VERSION_ATLEAST(1, 16) - init_par.GPUCopy = gpu_copy; -#endif - init_par.Implementation = impl; - init_par.Version = ver; - ret = MFXInitEx(init_par, &qs->session); - if (ret < 0) - return ff_qsv_print_error(avctx, ret, - "Error initializing an internal MFX session"); + if (ret) + return ret; #ifdef AVCODEC_QSV_LINUX_SESSION_HANDLE ret = ff_qsv_set_display_handle(avctx, qs); @@ -710,7 +861,7 @@ int ff_qsv_init_session_device(AVCodecContext *avctx, mfxSession *psession, AVHWDeviceContext *device_ctx = (AVHWDeviceContext*)device_ref->data; AVQSVDeviceContext *device_hwctx = device_ctx->hwctx; mfxSession parent_session = device_hwctx->session; - mfxInitParam init_par = { MFX_IMPL_AUTO_ANY }; + mfxLoader loader = device_hwctx->loader; mfxHDL handle = NULL; int hw_handle_supported = 0; @@ -751,15 +902,11 @@ int ff_qsv_init_session_device(AVCodecContext *avctx, mfxSession *psession, "from the session\n"); } -#if QSV_VERSION_ATLEAST(1, 16) - init_par.GPUCopy = gpu_copy; -#endif - init_par.Implementation = impl; - init_par.Version = ver; - err = MFXInitEx(init_par, &session); - if (err != MFX_ERR_NONE) - return ff_qsv_print_error(avctx, err, - "Error initializing a child MFX session"); + ret = qsv_create_mfx_session(avctx, impl, &ver, gpu_copy, &session, + &loader); + + if (ret) + return ret; if (handle) { err = MFXVideoCORE_SetHandle(session, handle_type, handle); @@ -836,7 +983,9 @@ int ff_qsv_close_internal_session(QSVSession *qs) { if (qs->session) { MFXClose(qs->session); + MFXUnload(qs->loader); qs->session = NULL; + qs->loader = NULL; } #ifdef AVCODEC_QSV_LINUX_SESSION_HANDLE av_buffer_unref(&qs->va_device_ref); diff --git a/libavcodec/qsv_internal.h b/libavcodec/qsv_internal.h index ff50b41de8..aea1441c7f 100644 --- a/libavcodec/qsv_internal.h +++ b/libavcodec/qsv_internal.h @@ -87,6 +87,7 @@ typedef struct QSVFrame { typedef struct QSVSession { mfxSession session; + mfxLoader loader; #ifdef AVCODEC_QSV_LINUX_SESSION_HANDLE AVBufferRef *va_device_ref; AVHWDeviceContext *va_device_ctx; diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c index 9395a1fd9a..c4daa44c1c 100644 --- a/libavcodec/qsvdec.c +++ b/libavcodec/qsvdec.c @@ -161,7 +161,9 @@ static int qsv_init_session(AVCodecContext *avctx, QSVContext *q, mfxSession ses } else if (hw_frames_ref) { if (q->internal_qs.session) { MFXClose(q->internal_qs.session); + MFXUnload(q->internal_qs.loader); q->internal_qs.session = NULL; + q->internal_qs.loader = NULL; } av_buffer_unref(&q->frames_ctx.hw_frames_ctx); @@ -186,7 +188,9 @@ static int qsv_init_session(AVCodecContext *avctx, QSVContext *q, mfxSession ses } else if (hw_device_ref) { if (q->internal_qs.session) { MFXClose(q->internal_qs.session); + MFXUnload(q->internal_qs.loader); q->internal_qs.session = NULL; + q->internal_qs.loader = NULL; } ret = ff_qsv_init_session_device(avctx, &q->internal_qs.session, diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h index 320ad6db2b..7a7eaea156 100644 --- a/libavcodec/qsvenc.h +++ b/libavcodec/qsvenc.h @@ -28,6 +28,9 @@ #include +#include "libavutil/common.h" +#include "libavutil/hwcontext.h" +#include "libavutil/hwcontext_qsv.h" #include "libavutil/avutil.h" #include "libavutil/fifo.h" diff --git a/libavcodec/qsvenc_h264.c b/libavcodec/qsvenc_h264.c index 9134e6a68c..5ed5e1ed0d 100644 --- a/libavcodec/qsvenc_h264.c +++ b/libavcodec/qsvenc_h264.c @@ -32,7 +32,6 @@ #include "avcodec.h" #include "internal.h" #include "qsv.h" -#include "qsv_internal.h" #include "qsvenc.h" #include "atsc_a53.h" diff --git a/libavcodec/qsvenc_hevc.c b/libavcodec/qsvenc_hevc.c index a268a002d6..7519b7b436 100644 --- a/libavcodec/qsvenc_hevc.c +++ b/libavcodec/qsvenc_hevc.c @@ -35,7 +35,6 @@ #include "h2645_parse.h" #include "internal.h" #include "qsv.h" -#include "qsv_internal.h" #include "qsvenc.h" enum LoadPlugin { diff --git a/libavcodec/qsvenc_jpeg.c b/libavcodec/qsvenc_jpeg.c index ad8f09befe..f473b1ddbc 100644 --- a/libavcodec/qsvenc_jpeg.c +++ b/libavcodec/qsvenc_jpeg.c @@ -30,7 +30,6 @@ #include "avcodec.h" #include "internal.h" #include "qsv.h" -#include "qsv_internal.h" #include "qsvenc.h" typedef struct QSVMJPEGEncContext { diff --git a/libavcodec/qsvenc_mpeg2.c b/libavcodec/qsvenc_mpeg2.c index 610bbf79c1..0e2a51811c 100644 --- a/libavcodec/qsvenc_mpeg2.c +++ b/libavcodec/qsvenc_mpeg2.c @@ -30,7 +30,6 @@ #include "avcodec.h" #include "internal.h" #include "qsv.h" -#include "qsv_internal.h" #include "qsvenc.h" typedef struct QSVMpeg2EncContext { diff --git a/libavcodec/qsvenc_vp9.c b/libavcodec/qsvenc_vp9.c index 0a382eb76d..9d88b03bbf 100644 --- a/libavcodec/qsvenc_vp9.c +++ b/libavcodec/qsvenc_vp9.c @@ -30,7 +30,6 @@ #include "avcodec.h" #include "internal.h" #include "qsv.h" -#include "qsv_internal.h" #include "qsvenc.h" typedef struct QSVVP9EncContext { diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c index d9d39c8b70..8eaffb5005 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" @@ -609,13 +607,11 @@ static int init_vpp_session(AVFilterContext *avctx, QSVVPPContext *s) } /* create a "slave" session with those same properties, to be used for vpp */ - ret = MFXInit(impl, &ver, &s->session); - if (ret < 0) - return ff_qsvvpp_print_error(avctx, ret, "Error initializing a session"); - else if (ret > 0) { - ff_qsvvpp_print_warning(avctx, ret, "Warning in session initialization"); - return AVERROR_UNKNOWN; - } + ret = ff_qsvvpp_create_mfx_session(avctx, device_hwctx->loader, impl, &ver, + &s->session); + + if (ret) + return ret; if (handle) { ret = MFXVideoCORE_SetHandle(s->session, handle_type, handle); @@ -914,3 +910,96 @@ int ff_qsvvpp_filter_frame(QSVVPPContext *s, AVFilterLink *inlink, AVFrame *picr return 0; } + +#if QSV_ONEVPL + +int ff_qsvvpp_create_mfx_session(void *ctx, + mfxLoader loader, + mfxIMPL implementation, + mfxVersion *pver, + mfxSession *psession) +{ + mfxStatus sts; + mfxSession session = NULL; + uint32_t impl_idx = 0; + + av_log(ctx, AV_LOG_VERBOSE, + "Use 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, + mfxLoader 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 67c351f297..d1c12be25b 100644 --- a/libavfilter/qsvvpp.h +++ b/libavfilter/qsvvpp.h @@ -28,6 +28,8 @@ #include "avfilter.h" #include "libavutil/fifo.h" +#include "libavutil/hwcontext.h" +#include "libavutil/hwcontext_qsv.h" #define FF_INLINK_IDX(link) ((int)((link)->dstpad - (link)->dst->input_pads)) #define FF_OUTLINK_IDX(link) ((int)((link)->srcpad - (link)->src->output_pads)) @@ -122,4 +124,7 @@ int ff_qsvvpp_print_error(void *log_ctx, mfxStatus err, int ff_qsvvpp_print_warning(void *log_ctx, mfxStatus err, const char *warning_string); +int ff_qsvvpp_create_mfx_session(void *ctx, mfxLoader loader, mfxIMPL implementation, + mfxVersion *pver, mfxSession *psession); + #endif /* AVFILTER_QSVVPP_H */ diff --git a/libavfilter/vf_deinterlace_qsv.c b/libavfilter/vf_deinterlace_qsv.c index fe6cb69afe..205b164bf6 100644 --- a/libavfilter/vf_deinterlace_qsv.c +++ b/libavfilter/vf_deinterlace_qsv.c @@ -172,7 +172,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); @@ -207,13 +207,11 @@ static int init_out_session(AVFilterContext *ctx) /* create a "slave" session with those same properties, to be used for * actual deinterlacing */ - err = MFXInit(impl, &ver, &s->session); - if (err < 0) - return ff_qsvvpp_print_error(ctx, err, "Error initializing a session for deinterlacing"); - else if (err > 0) { - ff_qsvvpp_print_warning(ctx, err, "Warning in session initialization"); - return AVERROR_UNKNOWN; - } + ret = ff_qsvvpp_create_mfx_session(ctx, device_hwctx->loader, impl, &ver, + &s->session); + + if (ret) + return ret; if (handle) { err = MFXVideoCORE_SetHandle(s->session, handle_type, handle); diff --git a/libavfilter/vf_scale_qsv.c b/libavfilter/vf_scale_qsv.c index 6cc6d192ff..76ed178831 100644 --- a/libavfilter/vf_scale_qsv.c +++ b/libavfilter/vf_scale_qsv.c @@ -290,7 +290,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); @@ -327,11 +327,11 @@ static int init_out_session(AVFilterContext *ctx) /* create a "slave" session with those same properties, to be used for * actual scaling */ - err = MFXInit(impl, &ver, &s->session); - if (err != MFX_ERR_NONE) { - av_log(ctx, AV_LOG_ERROR, "Error initializing a session for scaling\n"); - return AVERROR_UNKNOWN; - } + ret = ff_qsvvpp_create_mfx_session(ctx, device_hwctx->loader, impl, &ver, + &s->session); + + if (ret) + return ret; if (handle) { err = MFXVideoCORE_SetHandle(s->session, handle_type, handle); diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c index 25f75e0ee7..46671c067d 100644 --- a/libavutil/hwcontext_qsv.c +++ b/libavutil/hwcontext_qsv.c @@ -72,8 +72,10 @@ typedef struct QSVDeviceContext { typedef struct QSVFramesContext { mfxSession session_download; + mfxLoader loader_download; int session_download_init; mfxSession session_upload; + mfxLoader loader_upload; int session_upload_init; #if HAVE_PTHREADS pthread_mutex_t session_lock; @@ -204,15 +206,19 @@ static void qsv_frames_uninit(AVHWFramesContext *ctx) if (s->session_download) { MFXVideoVPP_Close(s->session_download); MFXClose(s->session_download); + MFXUnload(s->loader_download); } s->session_download = NULL; + s->loader_download = NULL; s->session_download_init = 0; if (s->session_upload) { MFXVideoVPP_Close(s->session_upload); MFXClose(s->session_upload); + MFXUnload(s->loader_upload); } s->session_upload = NULL; + s->loader_upload = NULL; s->session_upload_init = 0; #if HAVE_PTHREADS @@ -537,8 +543,221 @@ static mfxStatus frame_get_hdl(mfxHDL pthis, mfxMemId mid, mfxHDL *hdl) return MFX_ERR_NONE; } +#if QSV_ONEVPL + +static int qsv_create_mfx_session(void *ctx, + mfxHandleType handle_type, + mfxIMPL implementation, + mfxVersion *pver, + mfxSession *psession, + mfxLoader *ploader) +{ + mfxStatus sts; + mfxLoader loader = NULL; + mfxSession session = NULL; + mfxConfig cfg; + mfxVersion ver; + mfxVariant impl_value; + uint32_t impl_idx = 0; + + av_log(ctx, AV_LOG_VERBOSE, + "Use 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\n"); + return AVERROR(EXDEV); + } + + *psession = NULL; + *ploader = NULL; + loader = MFXLoad(); + + if (!loader) { + av_log(ctx, AV_LOG_ERROR, "Error creating a MFX loader\n"); + goto fail; + } + + /* Create configurations for implementation */ + cfg = MFXCreateConfig(loader); + + if (!cfg) { + av_log(ctx, AV_LOG_ERROR, "Error creating a MFX configuration\n"); + goto fail; + } + + impl_value.Type = MFX_VARIANT_TYPE_U32; + impl_value.Data.U32 = (implementation == MFX_IMPL_SOFTWARE) ? + MFX_IMPL_TYPE_SOFTWARE : MFX_IMPL_TYPE_HARDWARE; + sts = MFXSetConfigFilterProperty(cfg, + (const mfxU8 *)"mfxImplDescription.Impl", impl_value); + + if (sts != MFX_ERR_NONE) { + av_log(ctx, AV_LOG_ERROR, "Error adding a MFX configuration " + "property: %d.\n", sts); + goto fail; + } + + impl_value.Type = MFX_VARIANT_TYPE_U32; + + if (MFX_HANDLE_VA_DISPLAY == handle_type) + impl_value.Data.U32 = MFX_ACCEL_MODE_VIA_VAAPI; + else if (MFX_HANDLE_D3D9_DEVICE_MANAGER == handle_type) + impl_value.Data.U32 = MFX_ACCEL_MODE_VIA_D3D9; + else + impl_value.Data.U32 = MFX_ACCEL_MODE_VIA_D3D11; + + sts = MFXSetConfigFilterProperty(cfg, + (const mfxU8 *)"mfxImplDescription.AccelerationMode", impl_value); + + if (sts != MFX_ERR_NONE) { + av_log(ctx, AV_LOG_ERROR, "Error adding a MFX configuration" + "MFX_ACCEL_MODE_VIA_D3D9 property: %d.\n", sts); + goto fail; + } + + impl_value.Type = MFX_VARIANT_TYPE_U32; + impl_value.Data.U32 = pver->Version; + sts = MFXSetConfigFilterProperty(cfg, + (const mfxU8 *)"mfxImplDescription.ApiVersion.Version", + impl_value); + + if (sts != MFX_ERR_NONE) { + av_log(ctx, AV_LOG_ERROR, "Error adding a MFX configuration " + "property: %d.\n", sts); + goto fail; + } + + while (1) { + /* Enumerate all implementations */ + mfxImplDescription *impl_desc; + + sts = MFXEnumImplementations(loader, impl_idx, + MFX_IMPLCAPS_IMPLDESCSTRUCTURE, + (mfxHDL *)&impl_desc); + + /* Failed to find an available implementation */ + if (sts == MFX_ERR_NOT_FOUND) + break; + else if (sts != MFX_ERR_NONE) { + impl_idx++; + continue; + } + + sts = MFXCreateSession(loader, impl_idx, &session); + MFXDispReleaseImplDescription(loader, impl_desc); + + if (sts == MFX_ERR_NONE) + break; + + impl_idx++; + } + + if (sts != MFX_ERR_NONE) { + av_log(ctx, AV_LOG_ERROR, "Error creating a MFX session: %d.\n", sts); + goto fail; + } + + sts = MFXQueryVersion(session, &ver); + + if (sts != MFX_ERR_NONE) { + av_log(ctx, AV_LOG_ERROR, "Error querying a MFX session: %d.\n", sts); + goto fail; + } + + av_log(ctx, AV_LOG_VERBOSE, "Initialize MFX session: implementation " + "version is %d.%d\n", ver.Major, ver.Minor); + + *psession = session; + *ploader = loader; + + return 0; + +fail: + if (session) + MFXClose(session); + + MFXUnload(loader); + + return AVERROR_UNKNOWN; +} + +#else + +static int qsv_create_mfx_session(void *ctx, + mfxHandleType handle_type, + mfxIMPL implementation, + mfxVersion *pver, + mfxSession *psession, + mfxLoader *ploader) +{ + mfxVersion ver; + mfxStatus sts; + mfxSession session = NULL; + + av_log(ctx, AV_LOG_VERBOSE, + "Use 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); + + if (handle_type != MFX_HANDLE_VA_DISPLAY && + handle_type != MFX_HANDLE_D3D9_DEVICE_MANAGER) { + av_log(ctx, AV_LOG_ERROR, + "Invalid MFX device handle\n"); + return AVERROR(EXDEV); + } + + *ploader = NULL; + *psession = NULL; + ver = *pver; + sts = MFXInit(implementation, &ver, &session); + + if (sts != MFX_ERR_NONE) { + av_log(ctx, AV_LOG_ERROR, "Error initializing an MFX session: " + "%d.\n", sts); + goto fail; + } + + sts = MFXQueryVersion(session, &ver); + + if (sts != MFX_ERR_NONE) { + av_log(ctx, AV_LOG_ERROR, "Error querying an MFX session: " + "%d.\n", sts); + goto fail; + } + + av_log(ctx, AV_LOG_VERBOSE, "Initialize MFX session: implementation " + "version is %d.%d\n", ver.Major, ver.Minor); + + MFXClose(session); + sts = MFXInit(implementation, &ver, &session); + + if (sts != MFX_ERR_NONE) { + av_log(ctx, AV_LOG_ERROR, "Error initializing an MFX session: " + "%d.\n", sts); + goto fail; + } + + *psession = session; + + return 0; + +fail: + if (session) + MFXClose(session); + + return AVERROR_UNKNOWN; +} + +#endif + static int qsv_init_internal_session(AVHWFramesContext *ctx, - mfxSession *session, int upload) + mfxSession *session, mfxLoader *loader, + int upload) { AVQSVFramesContext *frames_hwctx = ctx->hwctx; QSVDeviceContext *device_priv = ctx->device_ctx->internal->priv; @@ -555,29 +774,35 @@ static int qsv_init_internal_session(AVHWFramesContext *ctx, mfxVideoParam par; mfxStatus err; + int ret = AVERROR_UNKNOWN; #if QSV_HAVE_OPAQUE QSVFramesContext *s = ctx->internal->priv; opaque = !!(frames_hwctx->frame_type & MFX_MEMTYPE_OPAQUE_FRAME); #endif - err = MFXInit(device_priv->impl, &device_priv->ver, session); - if (err != MFX_ERR_NONE) { - av_log(ctx, AV_LOG_ERROR, "Error initializing an internal session\n"); - return AVERROR_UNKNOWN; - } + ret = qsv_create_mfx_session(ctx, device_priv->handle_type, + device_priv->impl, &device_priv->ver, session, + loader); + + if (ret) + goto fail; if (device_priv->handle) { err = MFXVideoCORE_SetHandle(*session, device_priv->handle_type, device_priv->handle); - if (err != MFX_ERR_NONE) - return AVERROR_UNKNOWN; + if (err != MFX_ERR_NONE) { + ret = AVERROR_UNKNOWN; + goto fail; + } } if (!opaque) { err = MFXVideoCORE_SetFrameAllocator(*session, &frame_allocator); - if (err != MFX_ERR_NONE) - return AVERROR_UNKNOWN; + if (err != MFX_ERR_NONE) { + ret = AVERROR_UNKNOWN; + goto fail; + } } memset(&par, 0, sizeof(par)); @@ -613,11 +838,22 @@ static int qsv_init_internal_session(AVHWFramesContext *ctx, if (err != MFX_ERR_NONE) { av_log(ctx, AV_LOG_VERBOSE, "Error opening the internal VPP session." "Surface upload/download will not be possible\n"); - MFXClose(*session); - *session = NULL; + + ret = AVERROR_UNKNOWN; + goto fail; } return 0; + +fail: + if (*session) + MFXClose(*session); + + MFXUnload(*loader); + *session = NULL; + *loader = NULL; + + return ret; } static int qsv_frames_init(AVHWFramesContext *ctx) @@ -682,6 +918,9 @@ static int qsv_frames_init(AVHWFramesContext *ctx) s->session_download = NULL; s->session_upload = NULL; + s->loader_download = NULL; + s->loader_upload = NULL; + s->session_download_init = 0; s->session_upload_init = 0; @@ -979,7 +1218,8 @@ static int qsv_transfer_data_from(AVHWFramesContext *ctx, AVFrame *dst, if (pthread_mutex_trylock(&s->session_lock) == 0) { #endif if (!s->session_download_init) { - ret = qsv_init_internal_session(ctx, &s->session_download, 0); + ret = qsv_init_internal_session(ctx, &s->session_download, + &s->loader_download, 0); if (s->session_download) s->session_download_init = 1; } @@ -1053,7 +1293,8 @@ static int qsv_transfer_data_to(AVHWFramesContext *ctx, AVFrame *dst, if (pthread_mutex_trylock(&s->session_lock) == 0) { #endif if (!s->session_upload_init) { - ret = qsv_init_internal_session(ctx, &s->session_upload, 1); + ret = qsv_init_internal_session(ctx, &s->session_upload, + &s->loader_upload, 1); if (s->session_upload) s->session_upload_init = 1; } @@ -1322,6 +1563,7 @@ static void qsv_device_free(AVHWDeviceContext *ctx) if (hwctx->session) MFXClose(hwctx->session); + MFXUnload(hwctx->loader); av_buffer_unref(&priv->child_device_ctx); av_freep(&priv); } @@ -1411,34 +1653,11 @@ static int qsv_device_derive_from_child(AVHWDeviceContext *ctx, goto fail; } - err = MFXInit(implementation, &ver, &hwctx->session); - if (err != MFX_ERR_NONE) { - av_log(ctx, AV_LOG_ERROR, "Error initializing an MFX session: " - "%d.\n", err); - ret = AVERROR_UNKNOWN; - goto fail; - } + ret = qsv_create_mfx_session(ctx, handle_type, implementation, &ver, + &hwctx->session, &hwctx->loader); - err = MFXQueryVersion(hwctx->session, &ver); - if (err != MFX_ERR_NONE) { - av_log(ctx, AV_LOG_ERROR, "Error querying an MFX session: %d.\n", err); - ret = AVERROR_UNKNOWN; + if (ret) goto fail; - } - - av_log(ctx, AV_LOG_VERBOSE, - "Initialize MFX session: API version is %d.%d, implementation version is %d.%d\n", - MFX_VERSION_MAJOR, MFX_VERSION_MINOR, ver.Major, ver.Minor); - - MFXClose(hwctx->session); - - err = MFXInit(implementation, &ver, &hwctx->session); - if (err != MFX_ERR_NONE) { - av_log(ctx, AV_LOG_ERROR, - "Error initializing an MFX session: %d.\n", err); - ret = AVERROR_UNKNOWN; - goto fail; - } err = MFXVideoCORE_SetHandle(hwctx->session, handle_type, handle); if (err != MFX_ERR_NONE) { @@ -1453,6 +1672,8 @@ static int qsv_device_derive_from_child(AVHWDeviceContext *ctx, fail: if (hwctx->session) MFXClose(hwctx->session); + + MFXUnload(hwctx->loader); return ret; } @@ -1495,6 +1716,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(NULL, AV_LOG_WARNING, + "WARNING: 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 " @@ -1503,6 +1734,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); @@ -1529,6 +1761,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(NULL, AV_LOG_WARNING, + "WARNING: d3d11va is not available or child device type is " + "set to dxva2 explicitly for oneVPL.\n"); + } +#endif break; #endif default: diff --git a/libavutil/hwcontext_qsv.h b/libavutil/hwcontext_qsv.h index 42e34d0dda..65415d3d8c 100644 --- a/libavutil/hwcontext_qsv.h +++ b/libavutil/hwcontext_qsv.h @@ -19,8 +19,23 @@ #ifndef AVUTIL_HWCONTEXT_QSV_H #define AVUTIL_HWCONTEXT_QSV_H +#include #include +#if (MFX_VERSION_MAJOR < 2) + +typedef void * mfxLoader; + +static av_always_inline void MFXUnload (mfxLoader mfxloader) +{ +} + +#else + +#include + +#endif + /** * @file * An API-specific header for AV_HWDEVICE_TYPE_QSV. @@ -33,6 +48,7 @@ * This struct is allocated as AVHWDeviceContext.hwctx */ typedef struct AVQSVDeviceContext { + mfxLoader loader; mfxSession session; } AVQSVDeviceContext; From patchwork Thu Sep 23 06:28:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xiang, Haihao" X-Patchwork-Id: 30473 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:6506:0:0:0:0:0 with SMTP id z6csp159093iob; Wed, 22 Sep 2021 23:30:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwiYZZtte1Z1ab04F0L9AwH8i8qq2GdLfGC2tij21yiujFY2W9l6YyS5yUNqOFinb/89d7K X-Received: by 2002:a17:906:f74f:: with SMTP id jp15mr3288363ejb.423.1632378619893; Wed, 22 Sep 2021 23:30:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632378619; cv=none; d=google.com; s=arc-20160816; b=hview9bxe3SkUBGK71Ay5CqKvwZ6yBn9TFJWV6dqmFvyKgzggGooKEGq96dAqEs7Sn QfYIP3g6AMJzB3IJ0yYkkaDEzInhyJQqRk0cLvpgqJuFJWlQ95XZvirnNgq+MF3IeJuJ h6BHaj8PY3aJxICjCu0XL5zBBwpV2VNnquWfvsrgwlaBJax/U7GjXVTCImpiZaceQ/W7 2OKzgGAolgmCRZUEfrOO+Y2fRO1EuSe7XX/yH8VzkA+WOtVFnvJXTM3hujz2DSwiPwvJ RsxiOGhORvs0r5t8pkq001PikhE/L3j8AJ2yXa7wBJXLyrLQmgsfvbUQ8u1X3CTRmU4B BUZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:delivered-to; bh=2/ICTFbQ2+afnuS3qbNjmlqpMjn5ulFgvKt79i+QAAs=; b=C99TVjF3MLIP3/t96wJqDha8RwcNYi8Sq7fnMDAKBBGw38depNZYfcgVDG6oiXXNzu BL6BZ4URRJy/BSUgPSsCtXqpMjHdqErlgMPTZJqv7rLuKftdfsF8UdUcximzYxyGni/v 3zEOe63xTwZZzc4b3PnWMGpwQrl3CUTOP+mpIUTLDHfrNgmts7WputRQ5nmjtNSV3BhY q2NFYefak/OsZxO3cQJzjj4mZZeUYJA/fUNhFzOdiqK++JB58BT1AEdW7Y1PHBoOJ8oS bzxLrJwjgxAH+CzLffoee4HtqMEpp3VcVuqshvoo8w8uvTdnyX9rsn7tjmsS6q7s+YLK H82g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id q15si5114440edc.297.2021.09.22.23.30.19; Wed, 22 Sep 2021 23:30:19 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2EAE168AC25; Thu, 23 Sep 2021 09:28:53 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6768268AAD5 for ; Thu, 23 Sep 2021 09:28:48 +0300 (EEST) X-IronPort-AV: E=McAfee;i="6200,9189,10115"; a="203930155" X-IronPort-AV: E=Sophos;i="5.85,316,1624345200"; d="scan'208";a="203930155" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2021 23:28:38 -0700 X-IronPort-AV: E=Sophos;i="5.85,316,1624345200"; d="scan'208";a="550689773" Received: from xhh-dg164.sh.intel.com ([10.239.159.167]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2021 23:28:37 -0700 From: Haihao Xiang To: ffmpeg-devel@ffmpeg.org Date: Thu, 23 Sep 2021 14:28:18 +0800 Message-Id: <20210923062818.18892-11-haihao.xiang@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210923062818.18892-1-haihao.xiang@intel.com> References: <20210923062818.18892-1-haihao.xiang@intel.com> Subject: [FFmpeg-devel] [PATCH v4 10/10] configure: add --enable-libvpl option X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Haihao Xiang MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 4gqR0tRmDUjH This allows user to build FFmpeg against Intel oneVPL. oneVPL 2.2 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] [1] https://software.intel.com/content/www/us/en/develop/articles/upgrading-from-msdk-to-onevpl.html --- configure | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/configure b/configure index 9655a5823e..e9d2564819 100755 --- a/configure +++ b/configure @@ -337,6 +337,7 @@ External library support: --disable-ffnvcodec disable dynamically linked Nvidia code [autodetect] --enable-libdrm enable DRM code (Linux) [no] --enable-libmfx enable Intel MediaSDK (AKA Quick Sync Video) code via libmfx [no] + --enable-libvpl enable Intel oneVPL code via libvpl if libmfx is not used [no] --enable-libnpp enable Nvidia Performance Primitives-based code [no] --enable-mmal enable Broadcom Multi-Media Abstraction Layer (Raspberry Pi) via MMAL [no] --disable-nvdec disable Nvidia video decoding acceleration (via hwaccel) [autodetect] @@ -1895,6 +1896,7 @@ HWACCEL_LIBRARY_NONFREE_LIST=" HWACCEL_LIBRARY_LIST=" $HWACCEL_LIBRARY_NONFREE_LIST libmfx + libvpl mmal omx opencl @@ -6428,22 +6430,34 @@ enabled libilbc && require libilbc ilbc.h WebRtcIlbcfix_InitDecode -li enabled libklvanc && require libklvanc libklvanc/vanc.h klvanc_context_create -lklvanc enabled libkvazaar && require_pkg_config libkvazaar "kvazaar >= 0.8.1" kvazaar.h kvz_api_get enabled liblensfun && require_pkg_config liblensfun lensfun lensfun.h lf_db_new + +if enabled libmfx && enabled libvpl; then + die "ERROR: can not use libmfx and libvpl together" # While it may appear that require is being used as a pkg-config # fallback for libmfx, it is actually being used to detect a different # installation route altogether. If libmfx is installed via the Intel # Media SDK or Intel Media Server Studio, these don't come with # pkg-config support. Instead, users should make sure that the build # can find the libraries and headers through other means. - -enabled libmfx && { { check_pkg_config libmfx "libmfx < 2.0" "mfxvideo.h" MFXInit || +elif enabled libmfx; then + { check_pkg_config libmfx "libmfx < 2.0" "mfxvideo.h" MFXInit || \ # Some old versions of libmfx have the following settings in libmfx.pc: # includedir=/usr/include # Cflags: -I${includedir} # So add -I${includedir}/mfx to CFLAGS - { check_pkg_config libmfx "libmfx < 2.0" "mfx/mfxvideo.h" MFXInit && add_cflags -I$($pkg_config --variable=includedir libmfx)/mfx; } || - { require "libmfx < 2.0" "mfxvideo.h" MFXInit "-llibmfx $advapi32_extralibs" && warn "using libmfx without pkg-config"; } } && - warn "build FFmpeg against libmfx 1.x, obsolete features of libmfx such as OPAQUE memory,\n"\ - "multi-frame encode, user plugins and LA_EXT rate control mode are enabled"; } + { check_pkg_config libmfx "libmfx < 2.0" "mfx/mfxvideo.h" MFXInit && add_cflags -I$($pkg_config --variable=includedir libmfx)/mfx; } || + { require "libmfx < 2.0" "mfxvideo.h" MFXInit "-llibmfx $advapi32_extralibs" && warn "using libmfx without pkg-config"; } } && + warn "build FFmpeg against libmfx 1.x, obsolete features of libmfx such as OPAQUE memory,\n"\ + "multi-frame encode, user plugins and LA_EXT rate control mode are enabled" +elif enabled libvpl; then +# Consider pkg-config only. The name of libmfx is still used in the following check for --enable-libvpl option +# because QSV has dependency on libmfx, we can use the same dependency if using libmfx in this check. + check_pkg_config libmfx "vpl >= 2.2" "mfxvideo.h mfxdispatcher.h" MFXLoad && \ + warn "build FFmpeg against oneVPL 2.2+, OPAQUE memory, multi-frame encode, user plugins\n"\ + "and LA_EXT rate control mode in FFmpeg QSV won't be supported." || + die "ERROR: libvpl >= 2.2 not found" +fi + if enabled libmfx; then check_cc MFX_CODEC_VP9 "mfxdefs.h mfxstructures.h" "MFX_CODEC_VP9" fi