Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add VBAQ option #1336

Merged
merged 2 commits into from
Jan 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
4 changes: 2 additions & 2 deletions alvr/server/cpp/platform/linux/EncodePipelineAMF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ amf::AMFComponentPtr EncodePipelineAMF::MakeEncoder(amf::AMF_SURFACE_FORMAT inpu
}

// 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 @@ -281,7 +281,7 @@ amf::AMFComponentPtr EncodePipelineAMF::MakeEncoder(amf::AMF_SURFACE_FORMAT inpu
amfEncoder->SetProperty(AMF_VIDEO_ENCODER_HEVC_NOMINAL_RANGE, AMF_VIDEO_ENCODER_HEVC_NOMINAL_RANGE_FULL);

// 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
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 @@ -156,7 +156,7 @@ alvr::EncodePipelineVAAPI::EncodePipelineVAAPI(VkFrame &input_frame, VkFrameCtx&

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 @@ -410,6 +410,7 @@ fn try_connect(mut client_ips: HashMap<IpAddr, String>) -> IntResult {
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 @@ -46,6 +46,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 @@ -97,6 +97,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 @@ -731,6 +732,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
4 changes: 4 additions & 0 deletions dashboard/js/app/nls/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,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