Skip to content

Commit

Permalink
Update vaapi_wrapper.cc
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex313031 authored Jun 18, 2022
1 parent a54d57a commit ee9980b
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions media/gpu/vaapi/vaapi_wrapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit ee9980b

Please sign in to comment.