From ee9980b0c52b4c2572c2f807a2302e2ec41b9f5b Mon Sep 17 00:00:00 2001 From: Alexander David Frick Date: Fri, 17 Jun 2022 22:30:21 -0500 Subject: [PATCH] Update vaapi_wrapper.cc --- media/gpu/vaapi/vaapi_wrapper.cc | 33 ++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/media/gpu/vaapi/vaapi_wrapper.cc b/media/gpu/vaapi/vaapi_wrapper.cc index 9562d522c..324fbbd49 100644 --- a/media/gpu/vaapi/vaapi_wrapper.cc +++ b/media/gpu/vaapi/vaapi_wrapper.cc @@ -630,17 +630,6 @@ bool IsVAProfileSupported(VAProfile va_profile) { }) != profiles.end(); } -bool IsImplementedVbr(VideoCodecProfile codec_profile) { - switch (codec_profile) { - case H264PROFILE_BASELINE: - case H264PROFILE_MAIN: - case H264PROFILE_HIGH: - return true; - default: - return false; - } -} - bool IsBlockedDriver(VaapiWrapper::CodecMode mode, VAProfile va_profile) { if (!IsModeEncoding(mode)) { return va_profile == VAProfileAV1Profile0 && @@ -1603,6 +1592,24 @@ bool IsLowPowerEncSupported(VAProfile va_profile) { return false; } +bool IsVBREncodingSupported(VAProfile va_profile) { + if (!base::FeatureList::IsEnabled(kChromeOSHWVBREncoding)) + return false; + + auto mode = VaapiWrapper::CodecMode::kCodecModeMax; + switch (va_profile) { + case VAProfileH264ConstrainedBaseline: + case VAProfileH264Main: + case VAProfileH264High: + mode = VaapiWrapper::CodecMode::kEncodeVariableBitrate; + break; + default: + return false; + } + + return VASupportedProfiles::Get().IsProfileSupported(mode, va_profile); +} + } // namespace NativePixmapAndSizeInfo::NativePixmapAndSizeInfo() = default; @@ -1723,9 +1730,7 @@ VaapiWrapper::GetSupportedEncodeProfiles() { profile.rate_control_modes = media::VideoEncodeAccelerator::kConstantMode; // This code assumes that the resolutions are the same between CBR and VBR. // This is checked in a test in vaapi_unittest.cc: VbrAndCbrResolutionsMatch - if (IsImplementedVbr(media_profile) && - VASupportedProfiles::Get().IsProfileSupported(kEncodeVariableBitrate, - va_profile)) { + if (IsVBREncodingSupported(va_profile)) { profile.rate_control_modes |= media::VideoEncodeAccelerator::kVariableMode; }