0

media/gpu/vaapi: kEncode -> kEncodeConstantBitrate

This CL renames VaapiWrapper::CodecMode::kEncode to
VaapiWrapper::CodecMode::kEncodeConstantBitrate. This is in preparation
for adding variable bitrate encoding to VA-API. This renaming
disambiguates the enum's name to reflect that it is not a general
encoding specifier, but instead intended for use with a specific
encoding mode.

Test: Mechanical change; ran UTs.
Bug: b:193680666
Change-Id: I21e3218014bc5eb6ece48b6c920cacf0316d3a56
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3027427
Reviewed-by: Miguel Casas <mcasas@chromium.org>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Commit-Queue: Clarissa Garvey <clarissagarvey@chromium.org>
Cr-Commit-Position: refs/heads/master@{#902728}
This commit is contained in:
Clarissa Garvey
2021-07-16 23:22:56 +00:00
committed by Chromium LUCI CQ
parent 8d03b9f0db
commit c7960737e3
8 changed files with 25 additions and 21 deletions

@ -34,7 +34,7 @@ VideoEncodeAccelerator::Config kDefaultVEAConfig(
class MockVaapiWrapper : public VaapiWrapper {
public:
MockVaapiWrapper() : VaapiWrapper(kEncode) {}
MockVaapiWrapper() : VaapiWrapper(kEncodeConstantBitrate) {}
protected:
~MockVaapiWrapper() override = default;

@ -499,7 +499,7 @@ VaapiJpegEncodeAccelerator::Initialize(
client_ = client;
scoped_refptr<VaapiWrapper> vaapi_wrapper = VaapiWrapper::Create(
VaapiWrapper::kEncode, VAProfileJPEGBaseline,
VaapiWrapper::kEncodeConstantBitrate, VAProfileJPEGBaseline,
EncryptionScheme::kUnencrypted,
base::BindRepeating(&ReportVaapiErrorToUMA,
"Media.VaapiJpegEncodeAccelerator.VAAPIError"));

@ -25,8 +25,9 @@ class VaapiWrapper;
// VaapiWrapper, and pass them to this class.
class MEDIA_GPU_EXPORT VaapiJpegEncoder {
public:
// |vaapi_wrapper| should be initialized in VaapiWrapper::kEncode
// mode with VAProfileJPEGBaseline profile.
// |vaapi_wrapper| should be initialized in
// VaapiWrapper::kEncodeConstantBitrate mode with VAProfileJPEGBaseline
// profile.
explicit VaapiJpegEncoder(scoped_refptr<VaapiWrapper> vaapi_wrapper);
~VaapiJpegEncoder();

@ -305,10 +305,10 @@ TEST_F(VaapiTest, LowQualityEncodingSetting) {
std::map<VAProfile, std::vector<VAEntrypoint>> configurations =
VaapiWrapper::GetSupportedConfigurationsForCodecModeForTesting(
VaapiWrapper::kEncode);
VaapiWrapper::kEncodeConstantBitrate);
for (const auto& codec_mode :
{VaapiWrapper::kEncode,
{VaapiWrapper::kEncodeConstantBitrate,
VaapiWrapper::kEncodeConstantQuantizationParameter}) {
std::map<VAProfile, std::vector<VAEntrypoint>> configurations =
VaapiWrapper::GetSupportedConfigurationsForCodecModeForTesting(
@ -317,8 +317,8 @@ TEST_F(VaapiTest, LowQualityEncodingSetting) {
for (const auto& profile_and_entrypoints : configurations) {
const VAProfile va_profile = profile_and_entrypoints.first;
scoped_refptr<VaapiWrapper> wrapper = VaapiWrapper::Create(
VaapiWrapper::kEncode, va_profile, EncryptionScheme::kUnencrypted,
base::DoNothing());
VaapiWrapper::kEncodeConstantBitrate, va_profile,
EncryptionScheme::kUnencrypted, base::DoNothing());
// Depending on the GPU Gen, flags and policies, we may or may not utilize
// all entrypoints (e.g. we might always want VAEntrypointEncSliceLP if

@ -267,7 +267,7 @@ bool VaapiVideoEncodeAccelerator::Initialize(const Config& config,
}
VaapiWrapper::CodecMode mode =
codec == kCodecVP9 ? VaapiWrapper::kEncodeConstantQuantizationParameter
: VaapiWrapper::kEncode;
: VaapiWrapper::kEncodeConstantBitrate;
vaapi_wrapper_ = VaapiWrapper::CreateForVideoCodec(
mode, config.output_profile, EncryptionScheme::kUnencrypted,
base::BindRepeating(&ReportVaapiErrorToUMA,

@ -218,8 +218,8 @@ class VaapiVideoEncodeAcceleratorTest
MOCK_METHOD0(OnError, void());
void SetUp() override {
mock_vaapi_wrapper_ =
base::MakeRefCounted<MockVaapiWrapper>(VaapiWrapper::kEncode);
mock_vaapi_wrapper_ = base::MakeRefCounted<MockVaapiWrapper>(
VaapiWrapper::kEncodeConstantBitrate);
ResetEncoder();
}

@ -318,7 +318,7 @@ bool IsLowPowerIntelProcessor() {
}
bool IsModeEncoding(VaapiWrapper::CodecMode mode) {
return mode == VaapiWrapper::CodecMode::kEncode ||
return mode == VaapiWrapper::CodecMode::kEncodeConstantBitrate ||
mode == VaapiWrapper::CodecMode::kEncodeConstantQuantizationParameter;
}
@ -783,7 +783,7 @@ std::vector<VAEntrypoint> GetEntryPointsForProfile(const base::Lock* va_lock,
{VAEntrypointVLD, VAEntrypointProtectedContent}, // kDecodeProtected.
#endif
{VAEntrypointEncSlice, VAEntrypointEncPicture,
VAEntrypointEncSliceLP}, // kEncode.
VAEntrypointEncSliceLP}, // kEncodeConstantBitrate.
{VAEntrypointEncSlice,
VAEntrypointEncSliceLP}, // kEncodeConstantQuantizationParameter.
{VAEntrypointVideoProc} // kVideoProcess.
@ -846,7 +846,7 @@ bool GetRequiredAttribs(const base::Lock* va_lock,
if (profile == VAProfileJPEGBaseline)
return true;
if (mode == VaapiWrapper::kEncode)
if (mode == VaapiWrapper::kEncodeConstantBitrate)
required_attribs->push_back({VAConfigAttribRateControl, VA_RC_CBR});
if (mode == VaapiWrapper::kEncodeConstantQuantizationParameter)
required_attribs->push_back({VAConfigAttribRateControl, VA_RC_CQP});
@ -1014,7 +1014,7 @@ void VASupportedProfiles::FillSupportedProfileInfos(base::Lock* va_lock,
#if BUILDFLAG(IS_CHROMEOS_ASH)
VaapiWrapper::kDecodeProtected,
#endif
VaapiWrapper::kEncode,
VaapiWrapper::kEncodeConstantBitrate,
VaapiWrapper::kEncodeConstantQuantizationParameter,
VaapiWrapper::kVideoProcess
};
@ -1379,7 +1379,8 @@ bool IsLowPowerEncSupported(VAProfile va_profile) {
}
if (VASupportedProfiles::Get().IsProfileSupported(
VaapiWrapper::kEncode, va_profile, VAEntrypointEncSliceLP)) {
VaapiWrapper::kEncodeConstantBitrate, va_profile,
VAEntrypointEncSliceLP)) {
return true;
}
return false;
@ -1449,7 +1450,8 @@ VaapiWrapper::GetSupportedEncodeProfiles() {
DCHECK(va_profile != VAProfileNone);
const VASupportedProfiles::ProfileInfo* profile_info =
VASupportedProfiles::Get().IsProfileSupported(kEncode, va_profile);
VASupportedProfiles::Get().IsProfileSupported(kEncodeConstantBitrate,
va_profile);
if (!profile_info)
continue;
@ -1664,7 +1666,7 @@ bool VaapiWrapper::IsVppSupportedForJpegDecodedSurfaceToFourCC(
// static
bool VaapiWrapper::IsJpegEncodeSupported() {
return VASupportedProfiles::Get().IsProfileSupported(kEncode,
return VASupportedProfiles::Get().IsProfileSupported(kEncodeConstantBitrate,
VAProfileJPEGBaseline);
}
@ -1703,7 +1705,7 @@ VAEntrypoint VaapiWrapper::GetDefaultVaEntryPoint(CodecMode mode,
return VAEntrypointProtectedContent;
return VAEntrypointVLD;
#endif
case VaapiWrapper::kEncode:
case VaapiWrapper::kEncodeConstantBitrate:
case VaapiWrapper::kEncodeConstantQuantizationParameter:
if (profile == VAProfileJPEGBaseline)
return VAEntrypointEncPicture;
@ -2626,7 +2628,8 @@ bool VaapiWrapper::DownloadFromVABuffer(VABufferID buffer_id,
bool VaapiWrapper::GetVAEncMaxNumOfRefFrames(VideoCodecProfile profile,
size_t* max_ref_frames) {
const VAProfile va_profile = ProfileToVAProfile(profile, CodecMode::kEncode);
const VAProfile va_profile =
ProfileToVAProfile(profile, CodecMode::kEncodeConstantBitrate);
VAConfigAttrib attrib;
attrib.type = VAConfigAttribEncMaxRefFrames;

@ -117,7 +117,7 @@ class MEDIA_GPU_EXPORT VaapiWrapper
// be submitted.
kDecodeProtected, // Decrypt + decode to protected surface.
#endif
kEncode, // Encode with Constant Bitrate algorithm.
kEncodeConstantBitrate, // Encode with Constant Bitrate algorithm.
kEncodeConstantQuantizationParameter, // Encode with Constant Quantization
// Parameter algorithm.
kVideoProcess,