Skip to content

Commit

Permalink
obs-qsv11: Add AV1 Screen Content Tools
Browse files Browse the repository at this point in the history
  • Loading branch information
thyintel committed Sep 10, 2024
1 parent de2e42b commit bd16942
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions plugins/obs-qsv11/QSV_Encoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#pragma once

#define ONEVPL_EXPERIMENTAL
#include <vpl/mfxstructures.h>
#include <vpl/mfxadapter.h>
#include <stdint.h>
Expand Down
31 changes: 31 additions & 0 deletions plugins/obs-qsv11/QSV_Encoder_Internal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,22 @@ static inline bool HasOptimizedBRCSupport(const mfxPlatform &platform,
UNUSED_PARAMETER(rateControl);
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
// AV1_SCREEN_CONTENT_TOOLS API is introduced in VPL version 2.11
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

mfxStatus QSV_Encoder_Internal::InitParams(qsv_param_t *pParams,
Expand Down Expand Up @@ -372,6 +388,21 @@ mfxStatus QSV_Encoder_Internal::InitParams(qsv_param_t *pParams,
extendedBuffers.push_back((mfxExtBuffer *)&m_ExtAv1TileParam);
}

#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)
// TODO: Ask about this one on VAAPI too.
memset(&m_ExtVideoSignalInfo, 0, sizeof(m_ExtVideoSignalInfo));
Expand Down
4 changes: 4 additions & 0 deletions plugins/obs-qsv11/QSV_Encoder_Internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
#pragma once
#define ONEVPL_EXPERIMENTAL
#include <vpl/mfxstructures.h>
#include <vpl/mfxvideo++.h>
#include "QSV_Encoder.h"
Expand Down Expand Up @@ -121,6 +122,9 @@ class QSV_Encoder_Internal {
mfxExtCodingOption m_co;
mfxExtHEVCParam m_ExtHEVCParam{};
mfxExtAV1TileParam m_ExtAv1TileParam{};
#if (MFX_VERSION_MAJOR >= 2 && MFX_VERSION_MINOR >= 11) || MFX_VERSION_MAJOR > 2
mfxExtAV1ScreenContentTools m_ExtAV1ScreenContentTools{};
#endif
mfxExtVideoSignalInfo m_ExtVideoSignalInfo{};
mfxExtChromaLocInfo m_ExtChromaLocInfo{};
mfxExtMasteringDisplayColourVolume m_ExtMasteringDisplayColourVolume{};
Expand Down
1 change: 1 addition & 0 deletions plugins/obs-qsv11/obs-qsv-test/obs-qsv-test.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#define ONEVPL_EXPERIMENTAL
#include <vpl/mfxstructures.h>
#include <vpl/mfxadapter.h>
#include <vpl/mfxvideo++.h>
Expand Down

0 comments on commit bd16942

Please sign in to comment.