Skip to content

Commit

Permalink
Fix pre-analysis setting for AMF (#1985)
Browse files Browse the repository at this point in the history
* actually obey pre-analysis setting

* give warnings about latency when the encoder enables pre-analysis

* nvm actually enable pre-analysis with the setting lol

* remove typo
  • Loading branch information
barnabwhy authored Feb 14, 2024
1 parent a2bbc6a commit 13cdcc5
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 14 deletions.
43 changes: 30 additions & 13 deletions alvr/server/cpp/platform/win32/VideoEncoderAMF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,16 @@ amf::AMFComponentPtr VideoEncoderAMF::MakeEncoder(
caps->GetProperty(AMF_VIDEO_ENCODER_CAP_PRE_ANALYSIS, &m_hasPreAnalysis);
caps->GetProperty(AMF_VIDEO_ENCODER_CAPS_QUERY_TIMEOUT_SUPPORT, &m_hasQueryTimeout);
}
if (m_hasPreAnalysis) {
amfEncoder->SetProperty(AMF_VIDEO_ENCODER_PRE_ANALYSIS_ENABLE, Settings::Instance().m_enablePreAnalysis);
} else {
Warn("Pre-analysis could not be enabled because your GPU does not support it for h264 encoding.");

if (Settings::Instance().m_enablePreAnalysis) {
if (!Settings::Instance().m_usePreproc || Settings::Instance().m_use10bitEncoder) {
Warn("Pre-analysis could not be enabled because \"Use preproc\" is not enabled or \"Reduce color banding\" is enabled.");
} else if (m_hasPreAnalysis) {
Warn("Enabling h264 pre-analysis. You may experience higher latency when this is enabled.");
amfEncoder->SetProperty(AMF_VIDEO_ENCODER_PRE_ANALYSIS_ENABLE, Settings::Instance().m_enablePreAnalysis);
} else {
Warn("Pre-analysis could not be enabled because your GPU does not support it for h264 encoding.");
}
}

//No noticable performance difference and should improve subjective quality by allocating more bits to smooth areas
Expand Down Expand Up @@ -281,10 +287,16 @@ amf::AMFComponentPtr VideoEncoderAMF::MakeEncoder(
caps->GetProperty(AMF_VIDEO_ENCODER_HEVC_CAP_PRE_ANALYSIS, &m_hasPreAnalysis);
caps->GetProperty(AMF_VIDEO_ENCODER_CAPS_HEVC_QUERY_TIMEOUT_SUPPORT, &m_hasQueryTimeout);
}
if (m_hasPreAnalysis) {
amfEncoder->SetProperty(AMF_VIDEO_ENCODER_HEVC_PRE_ANALYSIS_ENABLE, Settings::Instance().m_enablePreAnalysis);
} else {
Warn("Pre-analysis could not be enabled because your GPU does not support it for HEVC encoding.");

if (Settings::Instance().m_enablePreAnalysis) {
if (!Settings::Instance().m_usePreproc || Settings::Instance().m_use10bitEncoder) {
Warn("Pre-analysis could not be enabled because \"Use preproc\" is not enabled or \"Reduce color banding\" is enabled.");
} else if (m_hasPreAnalysis) {
Warn("Enabling HEVC pre-analysis. You may experience higher latency when this is enabled.");
amfEncoder->SetProperty(AMF_VIDEO_ENCODER_HEVC_PRE_ANALYSIS_ENABLE, Settings::Instance().m_enablePreAnalysis);
} else {
Warn("Pre-analysis could not be enabled because your GPU does not support it for HEVC encoding.");
}
}

//No noticable performance difference and should improve subjective quality by allocating more bits to smooth areas
Expand Down Expand Up @@ -361,11 +373,16 @@ amf::AMFComponentPtr VideoEncoderAMF::MakeEncoder(
if (amfEncoder->GetCaps(&caps) == AMF_OK) {
caps->GetProperty(AMF_VIDEO_ENCODER_AV1_CAP_PRE_ANALYSIS, &m_hasPreAnalysis);
}
if (m_hasPreAnalysis) {
Warn("Enabling AV1 pre-analysis.");
amfEncoder->SetProperty(AMF_VIDEO_ENCODER_AV1_PRE_ANALYSIS_ENABLE, Settings::Instance().m_enablePreAnalysis);
} else {
Warn("Pre-analysis could not be enabled because your GPU does not support it for AV1 encoding.");

if (Settings::Instance().m_enablePreAnalysis) {
if (!Settings::Instance().m_usePreproc || Settings::Instance().m_use10bitEncoder) {
Warn("Pre-analysis could not be enabled because \"Use preproc\" is not enabled or \"Reduce color banding\" is enabled.");
} else if (m_hasPreAnalysis) {
Warn("Enabling AV1 pre-analysis. You may experience higher latency when this is enabled.");
amfEncoder->SetProperty(AMF_VIDEO_ENCODER_AV1_PRE_ANALYSIS_ENABLE, Settings::Instance().m_enablePreAnalysis);
} else {
Warn("Pre-analysis could not be enabled because your GPU does not support it for AV1 encoding.");
}
}

// May impact performance but improves quality in high-motion areas
Expand Down
2 changes: 1 addition & 1 deletion alvr/server/src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ pub fn contruct_openvr_config(session: &SessionConfig) -> OpenvrConfig {
filler_data: settings.video.encoder_config.filler_data,
entropy_coding: settings.video.encoder_config.entropy_coding as u32,
use_10bit_encoder: settings.video.encoder_config.use_10bit,
// enable_pre_analysis: amf_controls.enable_pre_analysis,
enable_pre_analysis: amf_controls.enable_pre_analysis,
enable_vbaq: amf_controls.enable_vbaq,
enable_hmqb: amf_controls.enable_hmqb,
use_preproc: amf_controls.use_preproc,
Expand Down

0 comments on commit 13cdcc5

Please sign in to comment.