Skip to content

Commit

Permalink
Add VBAQ option (alvr-org#1336)
Browse files Browse the repository at this point in the history
* Add VBAQ option to AMF

* Add VBAQ to VAAPI
  • Loading branch information
deiteris authored and korejan committed Jun 16, 2024
1 parent 3fee729 commit c80cd06
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 3 deletions.
4 changes: 4 additions & 0 deletions alvr/dashboard/js/app/nls/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ define({
"Specifies the entropy coding method (h264 only). CABAC - provides better quality at lower bitrate, but may increase the encoder/decoder latency, CAVLC - provides worse quality that can be compensated with higher bitrate, and may significantly decrease encoder/decoder latency.",
"_root_video_entropyCoding_cabac-choice-.name": "CABAC",
"_root_video_entropyCoding_cavlc-choice-.name": "CAVLC",
"_root_video_advancedCodecOptions_amfControls_enableVbaq.name":
"Enable VBAQ",
"_root_video_advancedCodecOptions_amfControls_enableVbaq.description":
"Enables Variance Based Adaptive Quantization (VBAQ) that allocates more bits to smooth areas (gradients, solid colors), but picture details may suffer from compression artifacts.",
"_root_video_advancedCodecOptions_amfControls_usePreproc.name":
"Enable Pre-Processor component",
"_root_video_advancedCodecOptions_amfControls_usePreproc.description":
Expand Down
1 change: 1 addition & 0 deletions alvr/server/cpp/alvr_server/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ void Settings::Load()
m_adaptiveBitrateDownRate = (int)config.get("bitrate_down_rate").get<int64_t>();
m_adaptiveBitrateLightLoadThreshold = config.get("bitrate_light_load_threshold").get<double>();
m_use10bitEncoder = config.get("use_10bit_encoder").get<bool>();
m_enableVbaq = config.get("enable_vbaq").get<bool>();
m_usePreproc = config.get("use_preproc").get<bool>();
m_preProcSigma = (uint32_t)config.get("preproc_sigma").get<int64_t>();
m_preProcTor = (uint32_t)config.get("preproc_tor").get<int64_t>();
Expand Down
1 change: 1 addition & 0 deletions alvr/server/cpp/alvr_server/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class Settings
uint64_t m_adaptiveBitrateDownRate;
float m_adaptiveBitrateLightLoadThreshold;
bool m_use10bitEncoder;
bool m_enableVbaq;
bool m_usePreproc;
uint32_t m_preProcSigma;
uint32_t m_preProcTor;
Expand Down
2 changes: 1 addition & 1 deletion alvr/server/cpp/platform/linux/EncodePipelineVAAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ alvr::EncodePipelineVAAPI::EncodePipelineVAAPI(std::vector<VkFrame>& input_frame

vlVaQualityBits quality = {};
quality.valid_setting = 1;
quality.vbaq_mode = 1; //No noticable performance difference and should improve subjective quality by allocating more bits to smooth areas
quality.vbaq_mode = Settings::Instance().m_enableVbaq; //No noticable performance difference and should improve subjective quality by allocating more bits to smooth areas
switch (settings.m_encoderQualityPreset)
{
case ALVR_QUALITY:
Expand Down
4 changes: 2 additions & 2 deletions alvr/server/cpp/platform/win32/VideoEncoderVCE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ amf::AMFComponentPtr VideoEncoderVCE::MakeEncoder(
}

//No noticable performance difference and should improve subjective quality by allocating more bits to smooth areas
amfEncoder->SetProperty(AMF_VIDEO_ENCODER_ENABLE_VBAQ, true);
amfEncoder->SetProperty(AMF_VIDEO_ENCODER_ENABLE_VBAQ, Settings::Instance().m_enableVbaq);

//Turns Off IDR/I Frames
amfEncoder->SetProperty(AMF_VIDEO_ENCODER_IDR_PERIOD, 0);
Expand Down Expand Up @@ -256,7 +256,7 @@ amf::AMFComponentPtr VideoEncoderVCE::MakeEncoder(
}

//No noticable performance difference and should improve subjective quality by allocating more bits to smooth areas
amfEncoder->SetProperty(AMF_VIDEO_ENCODER_HEVC_ENABLE_VBAQ, true);
amfEncoder->SetProperty(AMF_VIDEO_ENCODER_HEVC_ENABLE_VBAQ, Settings::Instance().m_enableVbaq);

//Turns Off IDR/I Frames
amfEncoder->SetProperty(AMF_VIDEO_ENCODER_HEVC_NUM_GOPS_PER_IDR, 0);
Expand Down
1 change: 1 addition & 0 deletions alvr/server/src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ async fn client_handshake(
entropy_coding: settings.video.entropy_coding as u32,
refresh_rate: fps as _,
use_10bit_encoder: settings.video.use_10bit_encoder,
enable_vbaq: amf_controls.enable_vbaq,
use_preproc: amf_controls.use_preproc,
preproc_sigma: amf_controls.preproc_sigma,
preproc_tor: amf_controls.preproc_tor,
Expand Down
1 change: 1 addition & 0 deletions alvr/session/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ pub struct OpenvrConfig {
pub codec: u32,
pub refresh_rate: u32,
pub use_10bit_encoder: bool,
pub enable_vbaq: bool,
pub use_preproc: bool,
pub preproc_sigma: u32,
pub preproc_tor: u32,
Expand Down
2 changes: 2 additions & 0 deletions alvr/session/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ pub struct NvencOverrides {
#[derive(SettingsSchema, Serialize, Deserialize, Clone)]
#[serde(rename_all = "camelCase")]
pub struct AmfControls {
pub enable_vbaq: bool,
pub use_preproc: bool,
#[schema(min = 0, max = 10)]
pub preproc_sigma: u32,
Expand Down Expand Up @@ -716,6 +717,7 @@ pub fn session_settings_default() -> SettingsDefault {
enable_weighted_prediction: false,
},
amf_controls: AmfControlsDefault {
enable_vbaq: false,
use_preproc: false,
preproc_sigma: 4,
preproc_tor: 7,
Expand Down

0 comments on commit c80cd06

Please sign in to comment.