From 2037bf63cdf25462ca606f4a28636e12df77c2a0 Mon Sep 17 00:00:00 2001
From: Good Guy <good1.2guy@gmail.com>
Date: Wed, 13 Nov 2024 12:46:29 -0700
Subject: [PATCH] Credit Andrew and Terje -add build capability for OneVPL and
 usage of QSV hardware rendering (accelerators)

---
 cinelerra-5.1/configure.ac                    | 20 +++++++++++++++----
 .../ffmpeg/video/hevc_qsv_10b420.mp4          |  5 +++++
 .../ffmpeg/video/hevc_qsv_10b422.mp4          |  6 ++++++
 cinelerra-5.1/ffmpeg/video/hevc_qsv_8b420.mp4 |  4 ++++
 cinelerra-5.1/thirdparty/Makefile             |  1 +
 5 files changed, 32 insertions(+), 4 deletions(-)
 create mode 100644 cinelerra-5.1/ffmpeg/video/hevc_qsv_10b420.mp4
 create mode 100644 cinelerra-5.1/ffmpeg/video/hevc_qsv_10b422.mp4
 create mode 100644 cinelerra-5.1/ffmpeg/video/hevc_qsv_8b420.mp4

diff --git a/cinelerra-5.1/configure.ac b/cinelerra-5.1/configure.ac
index 93e34b6d..a1b1dabd 100644
--- a/cinelerra-5.1/configure.ac
+++ b/cinelerra-5.1/configure.ac
@@ -86,6 +86,7 @@ CHECK_WITH([wintv],[usb 2040:826d wintv device],[WINTV],[yes])
 CHECK_WITH([x10tv],[usb 0bc7:0004 X10 remote device],[X10TV],[yes])
 CHECK_WITH([vaapi],[video acceleration api],[VAAPI],[yes])
 CHECK_WITH([vdpau],[video decode+presentation api for unix],[VDPAU],[yes])
+CHECK_WITH([onevpl],[Intel QSV api for unix],[ONEVPL],[no])
 CHECK_WITH([nv],[nvenc/nvdec ffnvcodec api],[NV],[yes])
 CHECK_WITH([cuda],[nv cuda plugins],[CUDA],[auto])
 CHECK_WITH([clang],[use clang instead of gcc/g++],[CLANG],[no])
@@ -512,7 +513,6 @@ AC_ARG_ENABLE([$1],
 ])
 
 CHECK_ENABLE([static-build], [STATIC_BUILD], [build static], [auto])
-CHECK_ENABLE([x264_hidepth], [X264_HIDEPTH], [build x264 10bit], [no])
 CHECK_ENABLE([x265_hidepth], [X265_HIDEPTH], [build x265 10bit], [no])
 
 test "x$WANT_STATIC_BUILD" = "xauto" && WANT_STATIC_BUILD=$WANT_CINBIN_BUILD
@@ -559,7 +559,7 @@ fi
 
 REQUIRE_PROG(OBJCOPY, [objcopy])
 if test "x$FATAL_ERROR" != "x"; then
- AC_MSG_ERROR("fatal eror.")
+ AC_MSG_ERROR("fatal error.")
 fi
 CHECK_PROG(PACTL, [pactl])
 WANT_PACTL=$PROG_PACTL
@@ -696,6 +696,11 @@ if test "x$HAVE_VAAPI" != "xyes" -a "x$WANT_VAAPI" = "xyes"; then
   AC_MSG_ERROR([requires vaapi support.])
 fi
 
+CHECK_LIB([ONEVPL], [vpl], [MFXCreateSession])
+if test "x$HAVE_ONEVPL" != "xyes" -a "x$WANT_ONEVPL" = "xyes"; then
+  AC_MSG_ERROR([requires onevpl support.])
+fi
+
 #CHECK_LIB([NVENC], [nvidia-encode], [NvEncodeAPICreateInstance])
 
 #if test "x$HAVE_mjpegtools" = "xyes"; then
@@ -1077,7 +1082,7 @@ fi
 for v in GL XFT XXF86VM OSS ALSA FIREWIRE OGG DV DVB LADSPA \
 	 VIDEO4LINUX2 ESOUND PULSE PACTL OPENEXR LV2 \
 	 COMMERCIAL GIFLIB LIBZMPEG LIBDPX SHUTTLE SHUTTLE_USB XV \
-	 VAAPI VDPAU CUDA NV WINTV X10TV; do
+	 VAAPI VDPAU ONEVPL CUDA NV WINTV X10TV; do
   eval vv="\$WANT_$v"
   if test "x$vv" != "xno"; then
     CFG_CFLAGS+=" -DHAVE_$v"
@@ -1124,6 +1129,14 @@ if test "x$WANT_VDPAU" != "xno" -a "x$HAVE_VDPAU" = "xyes"; then
 fi
 CFG_WANTS+=" VDPAU"
 
+if test "x$WANT_ONEVPL" != "xno" -a "x$HAVE_ONEVPL" = "xyes"; then
+  FFMPEG_EXTRA_LDFLAGS+=' -lvpl `pkg-config --libs vpl`'
+  FFMPEG_EXTRA_CFG+=' --extra-cflags="'$(pkg-config --cflags vpl)'"'
+  WANT_ONEVPL="yes"
+fi
+CFG_WANTS+=" ONEVPL"
+
+
 if test "x$WANT_NV" != "xno"; then
   WANT_NV="yes"
   CFG_WANTS+=" NV"
@@ -1181,7 +1194,6 @@ echo ""
 AC_SUBST(WANT_CIN_3RDPARTY)
 AC_SUBST(EXTRA_LIBS)
 AC_SUBST(FFMPEG_EXTRA_CFG)
-AC_SUBST(WANT_X264_HIDEPTH)
 AC_SUBST(WANT_X265_HIDEPTH)
 
 AC_SUBST(CFG_CFLAGS)
diff --git a/cinelerra-5.1/ffmpeg/video/hevc_qsv_10b420.mp4 b/cinelerra-5.1/ffmpeg/video/hevc_qsv_10b420.mp4
new file mode 100644
index 00000000..1f183883
--- /dev/null
+++ b/cinelerra-5.1/ffmpeg/video/hevc_qsv_10b420.mp4
@@ -0,0 +1,5 @@
+mp4 hevc_qsv_10b420
+# usable with Pixels: p010le
+profile=main10
+# global_quality=25
+
diff --git a/cinelerra-5.1/ffmpeg/video/hevc_qsv_10b422.mp4 b/cinelerra-5.1/ffmpeg/video/hevc_qsv_10b422.mp4
new file mode 100644
index 00000000..421caf12
--- /dev/null
+++ b/cinelerra-5.1/ffmpeg/video/hevc_qsv_10b422.mp4
@@ -0,0 +1,6 @@
+mp4 hevc_qsv_10b422
+# usable with Pixels: y210le
+profile=0
+# global_quality=25
+
+
diff --git a/cinelerra-5.1/ffmpeg/video/hevc_qsv_8b420.mp4 b/cinelerra-5.1/ffmpeg/video/hevc_qsv_8b420.mp4
new file mode 100644
index 00000000..96c60ede
--- /dev/null
+++ b/cinelerra-5.1/ffmpeg/video/hevc_qsv_8b420.mp4
@@ -0,0 +1,4 @@
+mp4 hevc_qsv_8b420
+# usable with Pixels: nv12
+profile=main
+# global_quality=25
diff --git a/cinelerra-5.1/thirdparty/Makefile b/cinelerra-5.1/thirdparty/Makefile
index bf8f1f0a..e48c7df7 100644
--- a/cinelerra-5.1/thirdparty/Makefile
+++ b/cinelerra-5.1/thirdparty/Makefile
@@ -136,6 +136,7 @@ ffmpeg.cfg_params= \
 	--disable-doc \
 	$(call if_want,VAAPI,--enable-vaapi,--disable-vaapi) \
 	$(call if_want,VDPAU,--enable-vdpau,--disable-vdpau) \
+	$(call if_want,ONEVPL,--enable-libvpl,--disable-libvpl) \
 	$(call if_want,NV, --enable-nvenc --enable-nvdec --enable-ffnvcodec) \
 	$(call if_ena,twolame,--enable-libtwolame) \
 	$(call if_ena,openjpeg,--enable-libopenjpeg) \
-- 
2.26.2