Browse Source

obs-qsv11: Add AV1 Screen Content Tools

Gale, Thy-Lan 1 year ago
parent
commit
53853df33a

+ 1 - 0
plugins/obs-qsv11/QSV_Encoder.h

@@ -56,6 +56,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 
 #pragma once
 #pragma once
 
 
+#define ONEVPL_EXPERIMENTAL
 #include <vpl/mfxstructures.h>
 #include <vpl/mfxstructures.h>
 #include <vpl/mfxadapter.h>
 #include <vpl/mfxadapter.h>
 #include <stdint.h>
 #include <stdint.h>

+ 32 - 0
plugins/obs-qsv11/QSV_Encoder_Internal.cpp

@@ -195,6 +195,22 @@ static inline bool HasOptimizedBRCSupport(const mfxPlatform &platform,
 	UNUSED_PARAMETER(rateControl);
 	UNUSED_PARAMETER(rateControl);
 	return false;
 	return false;
 }
 }
+
+static inline bool HasAV1ScreenContentSupport(const mfxPlatform &platform,
+					      const mfxVersion &version)
+{
+#if (MFX_VERSION_MAJOR >= 2 && MFX_VERSION_MINOR >= 12) || MFX_VERSION_MAJOR > 2
+	// Platform enums needed are introduced in VPL version 2.12
+	if ((version.Major >= 2 && version.Minor >= 12) || version.Major > 2)
+		if (platform.CodeName >= MFX_PLATFORM_LUNARLAKE &&
+		    platform.CodeName != MFX_PLATFORM_ALDERLAKE_N &&
+		    platform.CodeName != MFX_PLATFORM_ARROWLAKE)
+			return true;
+#endif
+	UNUSED_PARAMETER(platform);
+	UNUSED_PARAMETER(version);
+	return false;
+}
 PRAGMA_WARN_POP
 PRAGMA_WARN_POP
 
 
 mfxStatus QSV_Encoder_Internal::InitParams(qsv_param_t *pParams,
 mfxStatus QSV_Encoder_Internal::InitParams(qsv_param_t *pParams,
@@ -372,6 +388,22 @@ mfxStatus QSV_Encoder_Internal::InitParams(qsv_param_t *pParams,
 		extendedBuffers.push_back((mfxExtBuffer *)&m_ExtAv1TileParam);
 		extendedBuffers.push_back((mfxExtBuffer *)&m_ExtAv1TileParam);
 	}
 	}
 
 
+	// AV1_SCREEN_CONTENT_TOOLS API is introduced in VPL version 2.11
+#if (MFX_VERSION_MAJOR >= 2 && MFX_VERSION_MINOR >= 11) || MFX_VERSION_MAJOR > 2
+	if (codec == QSV_CODEC_AV1 &&
+	    HasAV1ScreenContentSupport(platform, m_ver)) {
+		memset(&m_ExtAV1ScreenContentTools, 0,
+		       sizeof(m_ExtAV1ScreenContentTools));
+		m_ExtAV1ScreenContentTools.Header.BufferId =
+			MFX_EXTBUFF_AV1_SCREEN_CONTENT_TOOLS;
+		m_ExtAV1ScreenContentTools.Header.BufferSz =
+			sizeof(m_ExtAV1ScreenContentTools);
+		m_ExtAV1ScreenContentTools.Palette = MFX_CODINGOPTION_ON;
+		extendedBuffers.push_back(
+			(mfxExtBuffer *)&m_ExtAV1ScreenContentTools);
+	}
+#endif
+
 #if defined(_WIN32)
 #if defined(_WIN32)
 	// TODO: Ask about this one on VAAPI too.
 	// TODO: Ask about this one on VAAPI too.
 	memset(&m_ExtVideoSignalInfo, 0, sizeof(m_ExtVideoSignalInfo));
 	memset(&m_ExtVideoSignalInfo, 0, sizeof(m_ExtVideoSignalInfo));

+ 4 - 0
plugins/obs-qsv11/QSV_Encoder_Internal.h

@@ -54,6 +54,7 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 */
 #pragma once
 #pragma once
+#define ONEVPL_EXPERIMENTAL
 #include <vpl/mfxstructures.h>
 #include <vpl/mfxstructures.h>
 #include <vpl/mfxvideo++.h>
 #include <vpl/mfxvideo++.h>
 #include "QSV_Encoder.h"
 #include "QSV_Encoder.h"
@@ -121,6 +122,9 @@ private:
 	mfxExtCodingOption m_co;
 	mfxExtCodingOption m_co;
 	mfxExtHEVCParam m_ExtHEVCParam{};
 	mfxExtHEVCParam m_ExtHEVCParam{};
 	mfxExtAV1TileParam m_ExtAv1TileParam{};
 	mfxExtAV1TileParam m_ExtAv1TileParam{};
+#if (MFX_VERSION_MAJOR >= 2 && MFX_VERSION_MINOR >= 11) || MFX_VERSION_MAJOR > 2
+	mfxExtAV1ScreenContentTools m_ExtAV1ScreenContentTools{};
+#endif
 	mfxExtVideoSignalInfo m_ExtVideoSignalInfo{};
 	mfxExtVideoSignalInfo m_ExtVideoSignalInfo{};
 	mfxExtChromaLocInfo m_ExtChromaLocInfo{};
 	mfxExtChromaLocInfo m_ExtChromaLocInfo{};
 	mfxExtMasteringDisplayColourVolume m_ExtMasteringDisplayColourVolume{};
 	mfxExtMasteringDisplayColourVolume m_ExtMasteringDisplayColourVolume{};

+ 1 - 0
plugins/obs-qsv11/obs-qsv-test/obs-qsv-test.cpp

@@ -1,3 +1,4 @@
+#define ONEVPL_EXPERIMENTAL
 #include <vpl/mfxstructures.h>
 #include <vpl/mfxstructures.h>
 #include <vpl/mfxadapter.h>
 #include <vpl/mfxadapter.h>
 #include <vpl/mfxvideo++.h>
 #include <vpl/mfxvideo++.h>