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

Encoders: support full 0-255 color range #1971

Merged
merged 2 commits into from
Mar 4, 2024
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/platform/linux/EncodePipelineNvEnc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ alvr::EncodePipelineNvEnc::EncodePipelineNvEnc(Renderer *render,
encoder_ctx->sample_aspect_ratio = AVRational{1, 1};
encoder_ctx->max_b_frames = 0;
encoder_ctx->gop_size = INT16_MAX;
encoder_ctx->color_range = Settings::Instance().m_useFullRangeEncoding ? AVCOL_RANGE_JPEG : AVCOL_RANGE_MPEG;
auto params = FfiDynamicEncoderParams {};
params.updated = true;
params.bitrate_bps = 30'000'000;
Expand Down
3 changes: 2 additions & 1 deletion alvr/server/cpp/platform/linux/EncodePipelineVAAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ alvr::EncodePipelineVAAPI::EncodePipelineVAAPI(Renderer *render, VkContext &vk_c
encoder_ctx->pix_fmt = AV_PIX_FMT_VAAPI;
encoder_ctx->max_b_frames = 0;
encoder_ctx->gop_size = INT_MAX;
encoder_ctx->color_range = Settings::Instance().m_useFullRangeEncoding ? AVCOL_RANGE_JPEG : AVCOL_RANGE_MPEG;

auto params = FfiDynamicEncoderParams {};
params.updated = true;
Expand Down Expand Up @@ -332,7 +333,7 @@ alvr::EncodePipelineVAAPI::EncodePipelineVAAPI(Renderer *render, VkContext &vk_c
inputs->pad_idx = 0;
inputs->next = NULL;

std::string filters = "scale_vaapi=format=";
std::string filters = Settings::Instance().m_useFullRangeEncoding ? "scale_vaapi=out_range=full:format=" : "scale_vaapi=format=";
if ((Settings::Instance().m_codec == ALVR_CODEC_HEVC || Settings::Instance().m_codec == ALVR_CODEC_AV1) && Settings::Instance().m_use10bitEncoder) {
filters += "p010";
} else {
Expand Down
9 changes: 9 additions & 0 deletions alvr/server/cpp/platform/win32/VideoEncoderAMF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,9 @@ amf::AMFComponentPtr VideoEncoderAMF::MakeEncoder(
}
}

// Enable Full Range
amfEncoder->SetProperty(AMF_VIDEO_ENCODER_FULL_RANGE_COLOR, Settings::Instance().m_useFullRangeEncoding);

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

Expand Down Expand Up @@ -299,6 +302,9 @@ amf::AMFComponentPtr VideoEncoderAMF::MakeEncoder(
}
}

// Enable Full Range
amfEncoder->SetProperty(AMF_VIDEO_ENCODER_HEVC_NOMINAL_RANGE, Settings::Instance().m_useFullRangeEncoding ? AMF_VIDEO_ENCODER_HEVC_NOMINAL_RANGE_FULL : AMF_VIDEO_ENCODER_HEVC_NOMINAL_RANGE_STUDIO);

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

Expand Down Expand Up @@ -385,6 +391,9 @@ amf::AMFComponentPtr VideoEncoderAMF::MakeEncoder(
}
}

// Enable Full Range
amfEncoder->SetProperty(AMF_VIDEO_ENCODER_AV1_OUTPUT_COLOR_PROFILE, Settings::Instance().m_useFullRangeEncoding ? AMF_VIDEO_CONVERTER_COLOR_PROFILE_JPEG : AMF_VIDEO_CONVERTER_COLOR_PROFILE_UNKNOWN);

// May impact performance but improves quality in high-motion areas
amfEncoder->SetProperty(AMF_VIDEO_ENCODER_AV1_HIGH_MOTION_QUALITY_BOOST, Settings::Instance().m_enableHmqb);

Expand Down
Loading