From patchwork Wed Sep 16 06:44:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xiang, Haihao" X-Patchwork-Id: 22428 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 7F276449470 for ; Wed, 16 Sep 2020 09:49:35 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 685A668BA7A; Wed, 16 Sep 2020 09:49:35 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9F39768B966 for ; Wed, 16 Sep 2020 09:49:28 +0300 (EEST) IronPort-SDR: WXC+AZqa2yz3oHU+eaoWJdqPKSIeWStn6N5gNDRwe7i/jk3U0WRZaodw90hXQ8iaNu92R/nECO xUchv3f4Fa+Q== X-IronPort-AV: E=McAfee;i="6000,8403,9745"; a="158693657" X-IronPort-AV: E=Sophos;i="5.76,431,1592895600"; d="scan'208";a="158693657" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2020 23:49:26 -0700 IronPort-SDR: RSvT8N+DlNsajt+Sp0k2vN1Bm9NO7dq+W+KCzQypp40qFoc3c/Gd/OSMvrbBT4afPfuW4XnNwX KZtda1sGl1fw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,431,1592895600"; d="scan'208";a="331551213" Received: from xhh-tgl64.sh.intel.com ([10.239.159.152]) by fmsmga004.fm.intel.com with ESMTP; 15 Sep 2020 23:49:25 -0700 From: Haihao Xiang To: ffmpeg-devel@ffmpeg.org Date: Wed, 16 Sep 2020 14:44:52 +0800 Message-Id: <20200916064457.181230-2-haihao.xiang@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200916064457.181230-1-haihao.xiang@intel.com> References: <20200916064457.181230-1-haihao.xiang@intel.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/6] qsv: add ${includedir}/mfx to the search path for old versions of libmfx X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Haihao Xiang Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" ${includedir}/mfx has been added to Cflags in libmfx.pc for the current libmfx. We may add ${includedir}/mfx to the search path for olda versions of libmfx so that we may include foo.h instead of mfx/foo.h After applying this change, we won't need to change #include to include the right header files when the mfx header files are installed to a new directory for a new version of libmfx. E.g. for libmfx 2.0 (oneVPL, https://github.com/oneapi-src/oneVPL), the header files will be installed in vpl directory If your libmfx comes without pkg-config support, this patch requires a small change to your environment setting (e.g. adding /opt/intel/mediasdk/include/mfx instead of /opt/intel/mediasdk/include to CFLAGS) so that the build can find the headers --- configure | 15 ++++++++++++--- fftools/ffmpeg_qsv.c | 2 +- libavcodec/qsv.c | 8 ++++---- libavcodec/qsv.h | 2 +- libavcodec/qsv_internal.h | 2 +- libavcodec/qsvdec.c | 2 +- libavcodec/qsvdec.h | 2 +- libavcodec/qsvdec_h2645.c | 2 +- libavcodec/qsvdec_other.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 +- 22 files changed, 36 insertions(+), 27 deletions(-) diff --git a/configure b/configure index 5d68695192..767bc4ca69 100755 --- a/configure +++ b/configure @@ -1458,6 +1458,14 @@ check_pkg_config(){ eval add_cflags \$${name}_cflags } +append_subdir_to_pkg_includedir(){ + log append_subdir_to_pkg_includedir "$@" + name="$1" + subdir="$2" + incdir=$($pkg_config --variable=includedir $name) + add_cflags -I$incdir/$subdir +} + test_exec(){ test_ld "cc" "$@" && { enabled cross_compile || $TMPE >> $logfile 2>&1; } } @@ -6355,10 +6363,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 "mfxvideo.h" MFXInit || + { check_pkg_config libmfx libmfx "mfx/mfxvideo.h" MFXInit && append_subdir_to_pkg_includedir libmfx mfx; } || + { require libmfx "mfxvideo.h" MFXInit "-llibmfx $advapi32_extralibs" && warn "using libmfx without pkg-config"; } } if enabled libmfx; then - check_cc MFX_CODEC_VP9 "mfx/mfxvp9.h mfx/mfxstructures.h" "MFX_CODEC_VP9" + check_cc MFX_CODEC_VP9 "mfxvp9.h mfxstructures.h" "MFX_CODEC_VP9" fi enabled libmodplug && require_pkg_config libmodplug libmodplug libmodplug/modplug.h ModPlug_Load diff --git a/fftools/ffmpeg_qsv.c b/fftools/ffmpeg_qsv.c index 960c88b69d..0df0b5832c 100644 --- a/fftools/ffmpeg_qsv.c +++ b/fftools/ffmpeg_qsv.c @@ -16,7 +16,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include +#include #include #include "libavutil/dict.h" diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c index 17720070f1..55184e075a 100644 --- a/libavcodec/qsv.c +++ b/libavcodec/qsv.c @@ -18,9 +18,9 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include -#include -#include +#include +#include +#include #include #include @@ -37,7 +37,7 @@ #include "qsv_internal.h" #if QSV_VERSION_ATLEAST(1, 12) -#include "mfx/mfxvp8.h" +#include "mfxvp8.h" #endif int ff_qsv_codec_id_to_mfx(enum AVCodecID codec_id) diff --git a/libavcodec/qsv.h b/libavcodec/qsv.h index b77158ec26..04ae0d6f34 100644 --- a/libavcodec/qsv.h +++ b/libavcodec/qsv.h @@ -21,7 +21,7 @@ #ifndef AVCODEC_QSV_H #define AVCODEC_QSV_H -#include +#include #include "libavutil/buffer.h" diff --git a/libavcodec/qsv_internal.h b/libavcodec/qsv_internal.h index 6b2fbbe252..4609e7a53b 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 fc25dc73e5..9e319ae709 100644 --- a/libavcodec/qsvdec.c +++ b/libavcodec/qsvdec.c @@ -24,7 +24,7 @@ #include #include -#include +#include #include "libavutil/common.h" #include "libavutil/hwcontext.h" diff --git a/libavcodec/qsvdec.h b/libavcodec/qsvdec.h index cb948f516d..435e8eae3e 100644 --- a/libavcodec/qsvdec.h +++ b/libavcodec/qsvdec.h @@ -26,7 +26,7 @@ #include #include -#include +#include #include "libavutil/fifo.h" #include "libavutil/frame.h" diff --git a/libavcodec/qsvdec_h2645.c b/libavcodec/qsvdec_h2645.c index 02c41883b6..ad0fcae3e5 100644 --- a/libavcodec/qsvdec_h2645.c +++ b/libavcodec/qsvdec_h2645.c @@ -25,7 +25,7 @@ #include #include -#include +#include #include "libavutil/common.h" #include "libavutil/fifo.h" diff --git a/libavcodec/qsvdec_other.c b/libavcodec/qsvdec_other.c index b4df76739c..4c0abeb9f3 100644 --- a/libavcodec/qsvdec_other.c +++ b/libavcodec/qsvdec_other.c @@ -24,7 +24,7 @@ #include #include -#include +#include #include "libavutil/common.h" #include "libavutil/fifo.h" diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index 1ed8f5d973..3c66eed554 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 4f579d1db1..77f886981c 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 ddafc45ec3..25b87a0506 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 347f30655e..a15b06bebb 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 f76af9486b..163608a725 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 0e34bb75dc..dd7b867ed6 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 ce44c09397..159f5cb983 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 c2bcce7548..cd3655b7a3 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" diff --git a/libavfilter/vf_deinterlace_qsv.c b/libavfilter/vf_deinterlace_qsv.c index 80217c8419..99257be433 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 5064dcbb60..b79ef75b0f 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 cd8638abbb..029be4034a 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 35a944f8f8..e36299896c 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 Wed Sep 16 06:44:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xiang, Haihao" X-Patchwork-Id: 22429 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 4D92E449470 for ; Wed, 16 Sep 2020 09:49:37 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3895168B9FA; Wed, 16 Sep 2020 09:49:37 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9B1CB68BACB for ; Wed, 16 Sep 2020 09:49:30 +0300 (EEST) IronPort-SDR: HFYqYwtqSDJjvMC6cb1LaF9qCfhctN022MITkXP6YUhDm/WaK2ebjI9PG8SA54szw9gyze+xO7 5gn0s3Ms1Zuw== X-IronPort-AV: E=McAfee;i="6000,8403,9745"; a="158693659" X-IronPort-AV: E=Sophos;i="5.76,431,1592895600"; d="scan'208";a="158693659" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2020 23:49:27 -0700 IronPort-SDR: 8hgWsa4p5G5l+mj9CJbAHRs/I6v6SzkHzBjxdVmoO5AZg05jT9GVwxAn7+7Ui3I6ijkhe2nZCJ FmMJX7aT/I5g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,431,1592895600"; d="scan'208";a="331551217" Received: from xhh-tgl64.sh.intel.com ([10.239.159.152]) by fmsmga004.fm.intel.com with ESMTP; 15 Sep 2020 23:49:26 -0700 From: Haihao Xiang To: ffmpeg-devel@ffmpeg.org Date: Wed, 16 Sep 2020 14:44:53 +0800 Message-Id: <20200916064457.181230-3-haihao.xiang@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200916064457.181230-1-haihao.xiang@intel.com> References: <20200916064457.181230-1-haihao.xiang@intel.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/6] qsv: libmfx no longer supports user plugin since version 2.0 (oneVPL) X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Haihao Xiang Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" See https://spec.oneapi.com/versions/latest/elements/oneVPL/source/VPL_intel_media_sdk.html#msdk-full-name-feature-removals https://github.com/oneapi-src/oneVPL --- libavcodec/qsv.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c index 55184e075a..472e0952b3 100644 --- a/libavcodec/qsv.c +++ b/libavcodec/qsv.c @@ -19,7 +19,6 @@ */ #include -#include #include #include @@ -40,6 +39,10 @@ #include "mfxvp8.h" #endif +#if !QSV_VERSION_ATLEAST(2, 0) +#include +#endif + int ff_qsv_codec_id_to_mfx(enum AVCodecID codec_id) { switch (codec_id) { @@ -295,6 +298,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_VERSION_ATLEAST(2, 0) if (!load_plugins || !*load_plugins) return 0; @@ -338,6 +342,7 @@ load_plugin_fail: if (err < 0) return err; } +#endif return 0; From patchwork Wed Sep 16 06:44:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xiang, Haihao" X-Patchwork-Id: 22430 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 2003C449470 for ; Wed, 16 Sep 2020 09:49:41 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0A58F68BBA1; Wed, 16 Sep 2020 09:49:41 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9856A68B966 for ; Wed, 16 Sep 2020 09:49:33 +0300 (EEST) IronPort-SDR: hNF3LCNmHg8RN2MG+F+F9JF2EiDDKIvtoYM1kPA7QvIkIBeL/Xz6vPVJU+N3II5eYyjd8H2+Tq 1SihvRz+QWbg== X-IronPort-AV: E=McAfee;i="6000,8403,9745"; a="158693660" X-IronPort-AV: E=Sophos;i="5.76,431,1592895600"; d="scan'208";a="158693660" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2020 23:49:27 -0700 IronPort-SDR: /otVFqkmkMtlea9OPpcFXTWw6fLDD7pYXsGZQTyxHoS0E/4dWo9us3LwpuYf+5wA1qdxuRuoeL Y7t2BlkaJ0cw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,431,1592895600"; d="scan'208";a="331551223" Received: from xhh-tgl64.sh.intel.com ([10.239.159.152]) by fmsmga004.fm.intel.com with ESMTP; 15 Sep 2020 23:49:27 -0700 From: Haihao Xiang To: ffmpeg-devel@ffmpeg.org Date: Wed, 16 Sep 2020 14:44:54 +0800 Message-Id: <20200916064457.181230-4-haihao.xiang@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200916064457.181230-1-haihao.xiang@intel.com> References: <20200916064457.181230-1-haihao.xiang@intel.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/6] qsv: libmfx no longer supports audio since version 2.0 (oneVPL) X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Haihao Xiang Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" --- libavcodec/qsv.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c index 472e0952b3..2b77fdb2bf 100644 --- a/libavcodec/qsv.c +++ b/libavcodec/qsv.c @@ -143,8 +143,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_VERSION_ATLEAST(2, 0) { 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" }, @@ -154,7 +156,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_VERSION_ATLEAST(2, 0) { MFX_WRN_INCOMPATIBLE_AUDIO_PARAM, 0, "incompatible audio parameters" }, +#endif }; int ff_qsv_map_error(mfxStatus mfx_err, const char **desc) From patchwork Wed Sep 16 06:44:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xiang, Haihao" X-Patchwork-Id: 22431 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 3451A449470 for ; Wed, 16 Sep 2020 09:49:42 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1F86368BC2D; Wed, 16 Sep 2020 09:49:42 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8465068B966 for ; Wed, 16 Sep 2020 09:49:34 +0300 (EEST) IronPort-SDR: c4UGIyTv/q+UWedPwB4VXgKrwGkS7G0509CzmjK5jixx+in+o7NSfWk2nYyv6WuG23VheRfqz2 8AGoPr5BCEDQ== X-IronPort-AV: E=McAfee;i="6000,8403,9745"; a="158693661" X-IronPort-AV: E=Sophos;i="5.76,431,1592895600"; d="scan'208";a="158693661" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2020 23:49:28 -0700 IronPort-SDR: Mkpgy7lUsVT7GgQ5vFNwBTQJZnOjU6r/6S1QADj9nbKKac/06zDhm/KiR7c92KAPEawSjJRqFm 1teloKYpqnlA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,431,1592895600"; d="scan'208";a="331551231" Received: from xhh-tgl64.sh.intel.com ([10.239.159.152]) by fmsmga004.fm.intel.com with ESMTP; 15 Sep 2020 23:49:28 -0700 From: Haihao Xiang To: ffmpeg-devel@ffmpeg.org Date: Wed, 16 Sep 2020 14:44:55 +0800 Message-Id: <20200916064457.181230-5-haihao.xiang@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200916064457.181230-1-haihao.xiang@intel.com> References: <20200916064457.181230-1-haihao.xiang@intel.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 4/6] qsvenc: libmfx no longer supports multi-frame encode since version 2.0 (oneVPL) X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Haihao Xiang Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" --- libavcodec/qsvenc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h index 77f886981c..9f3dc0b2ad 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_VERSION_ATLEAST(2, 0) #endif #if !QSV_HAVE_LA_DS From patchwork Wed Sep 16 06:44:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xiang, Haihao" X-Patchwork-Id: 22432 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 379C4449470 for ; Wed, 16 Sep 2020 09:49:44 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1613768BC53; Wed, 16 Sep 2020 09:49:44 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8970668BBF1 for ; Wed, 16 Sep 2020 09:49:36 +0300 (EEST) IronPort-SDR: xZvHzlXBFKbojxaYOCjAnNchmpfWM4FmnkwZrSvDnhZUU571GI5fpSyMsJFw3md6Rk97EDtCp0 fuQDjOKsYMxw== X-IronPort-AV: E=McAfee;i="6000,8403,9745"; a="158693662" X-IronPort-AV: E=Sophos;i="5.76,431,1592895600"; d="scan'208";a="158693662" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2020 23:49:29 -0700 IronPort-SDR: t3qZakYPbY8NTJmqo1jWC+ei7dFSNdOSt9aYxoCuHF4CRmAA3zCV8QZ0K0dAHk2JyRPz1vUvO0 NDQrxPbMQbXA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,431,1592895600"; d="scan'208";a="331551236" Received: from xhh-tgl64.sh.intel.com ([10.239.159.152]) by fmsmga004.fm.intel.com with ESMTP; 15 Sep 2020 23:49:29 -0700 From: Haihao Xiang To: ffmpeg-devel@ffmpeg.org Date: Wed, 16 Sep 2020 14:44:56 +0800 Message-Id: <20200916064457.181230-6-haihao.xiang@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200916064457.181230-1-haihao.xiang@intel.com> References: <20200916064457.181230-1-haihao.xiang@intel.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 5/6] qsvenc: libmfx no longer supports MFX_RATECONTROL_LA_EXT since version 2.0 (oneVPL) X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Haihao Xiang Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" --- libavcodec/qsvenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index 3c66eed554..88a8a99517 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_VERSION_ATLEAST(2, 0) { MFX_RATECONTROL_LA_EXT, "LA_EXT" }, #endif #if QSV_HAVE_LA_HRD From patchwork Wed Sep 16 06:44:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xiang, Haihao" X-Patchwork-Id: 22433 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 46EFE449470 for ; Wed, 16 Sep 2020 09:49:47 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2E17168BB9D; Wed, 16 Sep 2020 09:49:47 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 827EF68BC73 for ; Wed, 16 Sep 2020 09:49:39 +0300 (EEST) IronPort-SDR: wdGUwwWA4X06CQM2biJs24TIcVyi3WDKsXCGBLfAl7kHuFEmAPPOaB8PLohPLA7v2B4el8FAld AmbDIo5DHLiA== X-IronPort-AV: E=McAfee;i="6000,8403,9745"; a="158693663" X-IronPort-AV: E=Sophos;i="5.76,431,1592895600"; d="scan'208";a="158693663" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2020 23:49:30 -0700 IronPort-SDR: wYqoa68vA+M1DXh+F4lLzaD9cUoPla/C9Hg4ujAEXZ77zUwqUTsHUDVlDORdCVJOw1SdFa5mZs rD+MTrGLlWIQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,431,1592895600"; d="scan'208";a="331551243" Received: from xhh-tgl64.sh.intel.com ([10.239.159.152]) by fmsmga004.fm.intel.com with ESMTP; 15 Sep 2020 23:49:30 -0700 From: Haihao Xiang To: ffmpeg-devel@ffmpeg.org Date: Wed, 16 Sep 2020 14:44:57 +0800 Message-Id: <20200916064457.181230-7-haihao.xiang@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200916064457.181230-1-haihao.xiang@intel.com> References: <20200916064457.181230-1-haihao.xiang@intel.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 6/6] qsv: libmfx no longer supports OPAQUE memory since version 2.0 (oneVPL) X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Haihao Xiang Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" --- libavcodec/qsv.c | 4 ++ libavcodec/qsv.h | 2 + libavcodec/qsv_internal.h | 2 + libavcodec/qsvdec.c | 9 ++++ libavcodec/qsvenc.c | 21 +++++++++ libavcodec/qsvenc.h | 2 + libavfilter/qsvvpp.c | 24 ++++++++++- libavfilter/qsvvpp.h | 2 + libavfilter/vf_deinterlace_qsv.c | 56 +++++++++++++----------- libavfilter/vf_scale_qsv.c | 74 ++++++++++++++++++-------------- libavutil/hwcontext_qsv.c | 56 +++++++++++++++++------- 11 files changed, 178 insertions(+), 74 deletions(-) diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c index 2b77fdb2bf..47adacf4f1 100644 --- a/libavcodec/qsv.c +++ b/libavcodec/qsv.c @@ -94,10 +94,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..be7b95c724 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 (libmfx 2.0+) */ int opaque_alloc; diff --git a/libavcodec/qsv_internal.h b/libavcodec/qsv_internal.h index 4609e7a53b..420615bdce 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_HAVE_OPAQUE !QSV_VERSION_ATLEAST(2, 0) + typedef struct QSVMid { AVBufferRef *hw_frames_ref; mfxHDL handle; diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c index 9e319ae709..95931aad7d 100644 --- a/libavcodec/qsvdec.c +++ b/libavcodec/qsvdec.c @@ -119,7 +119,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); @@ -201,10 +205,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 88a8a99517..60e6d64458 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -1008,6 +1008,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; @@ -1044,6 +1045,7 @@ static int qsv_init_opaque_alloc(AVCodecContext *avctx, QSVEncContext *q) return 0; } +#endif static int qsvenc_init_session(AVCodecContext *avctx, QSVEncContext *q) { @@ -1059,7 +1061,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); @@ -1121,11 +1127,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 } } @@ -1198,9 +1210,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); @@ -1647,8 +1666,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 9f3dc0b2ad..295271cdf7 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 mfxExtBuffer *extparam_internal[2 + QSV_HAVE_CO2 + QSV_HAVE_CO3 + (QSV_HAVE_MF * 2)]; int nb_extparam_internal; diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c index 8d5ff2eb65..ff6a871956 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) typedef struct QSVFrame { @@ -62,10 +64,12 @@ 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 }; static const mfxHandleType handle_types[] = { @@ -449,9 +453,13 @@ static int init_vpp_session(AVFilterContext *avctx, QSVVPPContext *s) if (!out_frames_ref) return AVERROR(ENOMEM); +#if QSV_HAVE_OPAQUE s->out_mem_mode = IS_OPAQUE_MEMORY(s->in_mem_mode) ? MFX_MEMTYPE_OPAQUE_FRAME : MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET; +#else + s->out_mem_mode = MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET; +#endif out_frames_ctx = (AVHWFramesContext *)out_frames_ref->data; out_frames_hwctx = out_frames_ctx->hwctx; @@ -529,6 +537,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; @@ -540,7 +549,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, @@ -612,6 +623,7 @@ int ff_qsvvpp_create(AVFilterContext *avctx, QSVVPPContext **vpp, QSVVPPParam *p goto failed; } +#if QSV_HAVE_OPAQUE if (IS_OPAQUE_MEMORY(s->in_mem_mode) || IS_OPAQUE_MEMORY(s->out_mem_mode)) { s->nb_ext_buffers = param->num_ext_buf + 1; s->ext_buffers = av_mallocz_array(s->nb_ext_buffers, sizeof(*s->ext_buffers)); @@ -629,6 +641,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->vpp_param.AsyncDepth = 1; @@ -636,15 +652,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 ret = MFXVideoVPP_Init(s->session, &s->vpp_param); if (ret < 0) { @@ -678,7 +698,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_freep(vpp); diff --git a/libavfilter/qsvvpp.h b/libavfilter/qsvvpp.h index cd3655b7a3..753d4fa767 100644 --- a/libavfilter/qsvvpp.h +++ b/libavfilter/qsvvpp.h @@ -39,6 +39,8 @@ ((MFX_VERSION.Major > (MAJOR)) || \ (MFX_VERSION.Major == (MAJOR) && MFX_VERSION.Minor >= (MINOR))) +#define QSV_HAVE_OPAQUE !QSV_VERSION_ATLEAST(2, 0) + typedef struct QSVVPPContext QSVVPPContext; typedef struct QSVVPPCrop { diff --git a/libavfilter/vf_deinterlace_qsv.c b/libavfilter/vf_deinterlace_qsv.c index 99257be433..97b580cac9 100644 --- a/libavfilter/vf_deinterlace_qsv.c +++ b/libavfilter/vf_deinterlace_qsv.c @@ -68,7 +68,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; @@ -174,9 +176,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; @@ -185,6 +185,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) @@ -235,28 +238,7 @@ static int init_out_session(AVFilterContext *ctx) s->ext_buffers[s->num_ext_buffers++] = (mfxExtBuffer *)&s->deint_conf; - if (opaque) { - s->surface_ptrs = av_mallocz_array(hw_frames_hwctx->nb_surfaces, - sizeof(*s->surface_ptrs)); - if (!s->surface_ptrs) - return AVERROR(ENOMEM); - for (i = 0; i < hw_frames_hwctx->nb_surfaces; i++) - s->surface_ptrs[i] = hw_frames_hwctx->surfaces + i; - s->nb_surface_ptrs = hw_frames_hwctx->nb_surfaces; - - s->opaque_alloc.In.Surfaces = s->surface_ptrs; - s->opaque_alloc.In.NumSurface = s->nb_surface_ptrs; - s->opaque_alloc.In.Type = hw_frames_hwctx->frame_type; - - s->opaque_alloc.Out = s->opaque_alloc.In; - - s->opaque_alloc.Header.BufferId = MFX_EXTBUFF_OPAQUE_SURFACE_ALLOCATION; - s->opaque_alloc.Header.BufferSz = sizeof(s->opaque_alloc); - - s->ext_buffers[s->num_ext_buffers++] = (mfxExtBuffer *)&s->opaque_alloc; - - par.IOPattern = MFX_IOPATTERN_IN_OPAQUE_MEMORY | MFX_IOPATTERN_OUT_OPAQUE_MEMORY; - } else { + if (!opaque) { mfxFrameAllocator frame_allocator = { .pthis = ctx, .Alloc = frame_alloc, @@ -280,6 +262,30 @@ static int init_out_session(AVFilterContext *ctx) par.IOPattern = MFX_IOPATTERN_IN_VIDEO_MEMORY | MFX_IOPATTERN_OUT_VIDEO_MEMORY; } +#if QSV_HAVE_OPAQUE + else { + s->surface_ptrs = av_mallocz_array(hw_frames_hwctx->nb_surfaces, + sizeof(*s->surface_ptrs)); + if (!s->surface_ptrs) + return AVERROR(ENOMEM); + for (i = 0; i < hw_frames_hwctx->nb_surfaces; i++) + s->surface_ptrs[i] = hw_frames_hwctx->surfaces + i; + s->nb_surface_ptrs = hw_frames_hwctx->nb_surfaces; + + s->opaque_alloc.In.Surfaces = s->surface_ptrs; + s->opaque_alloc.In.NumSurface = s->nb_surface_ptrs; + s->opaque_alloc.In.Type = hw_frames_hwctx->frame_type; + + s->opaque_alloc.Out = s->opaque_alloc.In; + + s->opaque_alloc.Header.BufferId = MFX_EXTBUFF_OPAQUE_SURFACE_ALLOCATION; + s->opaque_alloc.Header.BufferSz = sizeof(s->opaque_alloc); + + s->ext_buffers[s->num_ext_buffers++] = (mfxExtBuffer *)&s->opaque_alloc; + + par.IOPattern = MFX_IOPATTERN_IN_OPAQUE_MEMORY | MFX_IOPATTERN_OUT_OPAQUE_MEMORY; + } +#endif par.ExtParam = s->ext_buffers; par.NumExtParam = s->num_ext_buffers; diff --git a/libavfilter/vf_scale_qsv.c b/libavfilter/vf_scale_qsv.c index b79ef75b0f..69a5ac7d13 100644 --- a/libavfilter/vf_scale_qsv.c +++ b/libavfilter/vf_scale_qsv.c @@ -89,7 +89,9 @@ typedef struct QSVScaleContext { mfxFrameSurface1 **surface_ptrs_out; int nb_surface_ptrs_out; +#if QSV_HAVE_OPAQUE mfxExtOpaqueSurfaceAlloc opaque_alloc; +#endif #if QSV_HAVE_SCALING_CONFIG mfxExtVPPScaling scale_conf; @@ -284,7 +286,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; @@ -294,6 +296,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 */ @@ -340,38 +345,7 @@ static int init_out_session(AVFilterContext *ctx) memset(&par, 0, sizeof(par)); - if (opaque) { - s->surface_ptrs_in = av_mallocz_array(in_frames_hwctx->nb_surfaces, - sizeof(*s->surface_ptrs_in)); - if (!s->surface_ptrs_in) - return AVERROR(ENOMEM); - for (i = 0; i < in_frames_hwctx->nb_surfaces; i++) - s->surface_ptrs_in[i] = in_frames_hwctx->surfaces + i; - s->nb_surface_ptrs_in = in_frames_hwctx->nb_surfaces; - - s->surface_ptrs_out = av_mallocz_array(out_frames_hwctx->nb_surfaces, - sizeof(*s->surface_ptrs_out)); - if (!s->surface_ptrs_out) - return AVERROR(ENOMEM); - for (i = 0; i < out_frames_hwctx->nb_surfaces; i++) - s->surface_ptrs_out[i] = out_frames_hwctx->surfaces + i; - s->nb_surface_ptrs_out = out_frames_hwctx->nb_surfaces; - - s->opaque_alloc.In.Surfaces = s->surface_ptrs_in; - s->opaque_alloc.In.NumSurface = s->nb_surface_ptrs_in; - s->opaque_alloc.In.Type = in_frames_hwctx->frame_type; - - s->opaque_alloc.Out.Surfaces = s->surface_ptrs_out; - s->opaque_alloc.Out.NumSurface = s->nb_surface_ptrs_out; - s->opaque_alloc.Out.Type = out_frames_hwctx->frame_type; - - s->opaque_alloc.Header.BufferId = MFX_EXTBUFF_OPAQUE_SURFACE_ALLOCATION; - s->opaque_alloc.Header.BufferSz = sizeof(s->opaque_alloc); - - s->ext_buffers[s->num_ext_buf++] = (mfxExtBuffer*)&s->opaque_alloc; - - par.IOPattern = MFX_IOPATTERN_IN_OPAQUE_MEMORY | MFX_IOPATTERN_OUT_OPAQUE_MEMORY; - } else { + if (!opaque) { mfxFrameAllocator frame_allocator = { .pthis = ctx, .Alloc = frame_alloc, @@ -403,6 +377,40 @@ static int init_out_session(AVFilterContext *ctx) par.IOPattern = MFX_IOPATTERN_IN_VIDEO_MEMORY | MFX_IOPATTERN_OUT_VIDEO_MEMORY; } +#if QSV_HAVE_OPAQUE + else { + s->surface_ptrs_in = av_mallocz_array(in_frames_hwctx->nb_surfaces, + sizeof(*s->surface_ptrs_in)); + if (!s->surface_ptrs_in) + return AVERROR(ENOMEM); + for (i = 0; i < in_frames_hwctx->nb_surfaces; i++) + s->surface_ptrs_in[i] = in_frames_hwctx->surfaces + i; + s->nb_surface_ptrs_in = in_frames_hwctx->nb_surfaces; + + s->surface_ptrs_out = av_mallocz_array(out_frames_hwctx->nb_surfaces, + sizeof(*s->surface_ptrs_out)); + if (!s->surface_ptrs_out) + return AVERROR(ENOMEM); + for (i = 0; i < out_frames_hwctx->nb_surfaces; i++) + s->surface_ptrs_out[i] = out_frames_hwctx->surfaces + i; + s->nb_surface_ptrs_out = out_frames_hwctx->nb_surfaces; + + s->opaque_alloc.In.Surfaces = s->surface_ptrs_in; + s->opaque_alloc.In.NumSurface = s->nb_surface_ptrs_in; + s->opaque_alloc.In.Type = in_frames_hwctx->frame_type; + + s->opaque_alloc.Out.Surfaces = s->surface_ptrs_out; + s->opaque_alloc.Out.NumSurface = s->nb_surface_ptrs_out; + s->opaque_alloc.Out.Type = out_frames_hwctx->frame_type; + + s->opaque_alloc.Header.BufferId = MFX_EXTBUFF_OPAQUE_SURFACE_ALLOCATION; + s->opaque_alloc.Header.BufferSz = sizeof(s->opaque_alloc); + + s->ext_buffers[s->num_ext_buf++] = (mfxExtBuffer*)&s->opaque_alloc; + + par.IOPattern = MFX_IOPATTERN_IN_OPAQUE_MEMORY | MFX_IOPATTERN_OUT_OPAQUE_MEMORY; + } +#endif #if QSV_HAVE_SCALING_CONFIG memset(&s->scale_conf, 0, sizeof(mfxExtVPPScaling)); diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c index e36299896c..91c621850e 100644 --- a/libavutil/hwcontext_qsv.c +++ b/libavutil/hwcontext_qsv.c @@ -48,6 +48,8 @@ (MFX_VERSION_MAJOR > (MAJOR) || \ MFX_VERSION_MAJOR == (MAJOR) && MFX_VERSION_MINOR >= (MINOR)) +#define QSV_HAVE_OPAQUE !QSV_VERSION_ATLEAST(2, 0) + typedef struct QSVDevicePriv { AVBufferRef *child_device_ctx; } QSVDevicePriv; @@ -78,11 +80,13 @@ typedef struct QSVFramesContext { // used in the frame allocator for non-opaque surfaces mfxMemId *mem_ids; +#if QSV_HAVE_OPAQUE // used in the opaque alloc request for opaque surfaces mfxFrameSurface1 **surface_ptrs; mfxExtOpaqueSurfaceAlloc opaque_alloc; mfxExtBuffer *ext_buffers[1]; +#endif } QSVFramesContext; static const struct { @@ -185,7 +189,9 @@ static void qsv_frames_uninit(AVHWFramesContext *ctx) #endif av_freep(&s->mem_ids); +#if QSV_HAVE_OPAQUE av_freep(&s->surface_ptrs); +#endif av_freep(&s->surfaces_internal); av_buffer_unref(&s->child_frames_ref); } @@ -371,11 +377,17 @@ static int qsv_init_pool(AVHWFramesContext *ctx, uint32_t fourcc) return ret; } +#if QSV_HAVE_OPAQUE if (!(frames_hwctx->frame_type & MFX_MEMTYPE_OPAQUE_FRAME)) { ret = qsv_init_child_ctx(ctx); if (ret < 0) return ret; } +#else + ret = qsv_init_child_ctx(ctx); + if (ret < 0) + return ret; +#endif ctx->internal->pool_internal = av_buffer_pool_init2(sizeof(mfxFrameSurface1), ctx, qsv_pool_alloc, NULL); @@ -440,10 +452,9 @@ static mfxStatus frame_get_hdl(mfxHDL pthis, mfxMemId mid, mfxHDL *hdl) static int qsv_init_internal_session(AVHWFramesContext *ctx, mfxSession *session, int upload) { - QSVFramesContext *s = ctx->internal->priv; AVQSVFramesContext *frames_hwctx = ctx->hwctx; QSVDeviceContext *device_priv = ctx->device_ctx->internal->priv; - int opaque = !!(frames_hwctx->frame_type & MFX_MEMTYPE_OPAQUE_FRAME); + int opaque = 0; mfxFrameAllocator frame_allocator = { .pthis = ctx, @@ -457,6 +468,11 @@ static int qsv_init_internal_session(AVHWFramesContext *ctx, mfxVideoParam par; mfxStatus err; +#if QSV_HAVE_OPAQUE + QSVFramesContext *s = ctx->internal->priv; + opaque = !!(frames_hwctx->frame_type & MFX_MEMTYPE_OPAQUE_FRAME); +#endif + err = MFXInit(device_priv->impl, &device_priv->ver, session); if (err != MFX_ERR_NONE) { av_log(ctx, AV_LOG_ERROR, "Error initializing an internal session\n"); @@ -478,15 +494,18 @@ static int qsv_init_internal_session(AVHWFramesContext *ctx, memset(&par, 0, sizeof(par)); - if (opaque) { + if (!opaque) { + par.IOPattern = upload ? MFX_IOPATTERN_OUT_VIDEO_MEMORY : + MFX_IOPATTERN_IN_VIDEO_MEMORY; + } +#if QSV_HAVE_OPAQUE + else { par.ExtParam = s->ext_buffers; par.NumExtParam = FF_ARRAY_ELEMS(s->ext_buffers); par.IOPattern = upload ? MFX_IOPATTERN_OUT_OPAQUE_MEMORY : MFX_IOPATTERN_IN_OPAQUE_MEMORY; - } else { - par.IOPattern = upload ? MFX_IOPATTERN_OUT_VIDEO_MEMORY : - MFX_IOPATTERN_IN_VIDEO_MEMORY; } +#endif par.IOPattern |= upload ? MFX_IOPATTERN_IN_SYSTEM_MEMORY : MFX_IOPATTERN_OUT_SYSTEM_MEMORY; @@ -518,11 +537,15 @@ static int qsv_frames_init(AVHWFramesContext *ctx) QSVFramesContext *s = ctx->internal->priv; AVQSVFramesContext *frames_hwctx = ctx->hwctx; - int opaque = !!(frames_hwctx->frame_type & MFX_MEMTYPE_OPAQUE_FRAME); + int opaque = 0; uint32_t fourcc; int i, ret; +#if QSV_HAVE_OPAQUE + opaque = !!(frames_hwctx->frame_type & MFX_MEMTYPE_OPAQUE_FRAME); +#endif + fourcc = qsv_fourcc_from_pix_fmt(ctx->sw_format); if (!fourcc) { av_log(ctx, AV_LOG_ERROR, "Unsupported pixel format\n"); @@ -537,7 +560,16 @@ static int qsv_frames_init(AVHWFramesContext *ctx) } } - if (opaque) { + if (!opaque) { + s->mem_ids = av_mallocz_array(frames_hwctx->nb_surfaces, sizeof(*s->mem_ids)); + if (!s->mem_ids) + return AVERROR(ENOMEM); + + for (i = 0; i < frames_hwctx->nb_surfaces; i++) + s->mem_ids[i] = frames_hwctx->surfaces[i].Data.MemId; + } +#if QSV_HAVE_OPAQUE + else { s->surface_ptrs = av_mallocz_array(frames_hwctx->nb_surfaces, sizeof(*s->surface_ptrs)); if (!s->surface_ptrs) @@ -556,14 +588,8 @@ static int qsv_frames_init(AVHWFramesContext *ctx) s->opaque_alloc.Header.BufferSz = sizeof(s->opaque_alloc); s->ext_buffers[0] = (mfxExtBuffer*)&s->opaque_alloc; - } else { - s->mem_ids = av_mallocz_array(frames_hwctx->nb_surfaces, sizeof(*s->mem_ids)); - if (!s->mem_ids) - return AVERROR(ENOMEM); - - for (i = 0; i < frames_hwctx->nb_surfaces; i++) - s->mem_ids[i] = frames_hwctx->surfaces[i].Data.MemId; } +#endif s->session_download = NULL; s->session_upload = NULL;