Commit a9bbd8a5 authored by Miguel Casas's avatar Miguel Casas Committed by Commit Bot

media/gpu/vaapi_wrapper: simplify internal VASupportedProfiles class

VASupportedProfiles is an internal class of vaapi_wrapper.cc in charge
of enumerating the encoding/decoding video/image profiles supported in
Chrome. It basically holds a |supported_profiles_| member, filled upon
construction from GetSupportedProfileInfosForCodecModeInternal().

This CL:

- Refactors GetSupportedProfileInfosForCodecModeInternal(), renaming it
to FillSupportedProfileInfos()) to do all the enumerations needed, and
reorders a bit the contents of the for-for-for loops, so that
IsEntrypointSupported_Locked() is unnecessary and removed entirely.

- Changes the signature of IsProfileSupported() to maybe-return a ptr to
the ProfileInfo entry (and not a bool), which simplifies callsites.

- Removes GetSupportedProfileInfosForCodecMode(), simplifying some of
the callsites as well (except GetSupported...ForTesting() which is made
a friend).

- Sprinkles static_assert()s to verify sizes of constexpr data structs.

This CL also removes the references to VAProfileVP9Profile1 and 3,
because those are not present in my experience in the wild, neither in
libva impls nor in videos, and are not properly validated nor tested.

Bug: 1040291, 1105103
Change-Id: I6717cac3e57f5e304eae04272842efacf7e1f762
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2292780Reviewed-by: default avatarHirokazu Honda <hiroh@chromium.org>
Commit-Queue: Miguel Casas <mcasas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#788767}
parent 7eea3e48
...@@ -36,7 +36,9 @@ base::Optional<VAProfile> ConvertToVAProfile(VideoCodecProfile profile) { ...@@ -36,7 +36,9 @@ base::Optional<VAProfile> ConvertToVAProfile(VideoCodecProfile profile) {
{H264PROFILE_HIGH, VAProfileH264High}, {H264PROFILE_HIGH, VAProfileH264High},
{VP8PROFILE_ANY, VAProfileVP8Version0_3}, {VP8PROFILE_ANY, VAProfileVP8Version0_3},
{VP9PROFILE_PROFILE0, VAProfileVP9Profile0}, {VP9PROFILE_PROFILE0, VAProfileVP9Profile0},
{VP9PROFILE_PROFILE1, VAProfileVP9Profile1},
{VP9PROFILE_PROFILE2, VAProfileVP9Profile2}, {VP9PROFILE_PROFILE2, VAProfileVP9Profile2},
{VP9PROFILE_PROFILE3, VAProfileVP9Profile3},
}; };
auto it = kProfileMap.find(profile); auto it = kProfileMap.find(profile);
return it != kProfileMap.end() ? base::make_optional<VAProfile>(it->second) return it != kProfileMap.end() ? base::make_optional<VAProfile>(it->second)
...@@ -56,7 +58,9 @@ base::Optional<VAProfile> StringToVAProfile(const std::string& va_profile) { ...@@ -56,7 +58,9 @@ base::Optional<VAProfile> StringToVAProfile(const std::string& va_profile) {
{"VAProfileJPEGBaseline", VAProfileJPEGBaseline}, {"VAProfileJPEGBaseline", VAProfileJPEGBaseline},
{"VAProfileVP8Version0_3", VAProfileVP8Version0_3}, {"VAProfileVP8Version0_3", VAProfileVP8Version0_3},
{"VAProfileVP9Profile0", VAProfileVP9Profile0}, {"VAProfileVP9Profile0", VAProfileVP9Profile0},
{"VAProfileVP9Profile1", VAProfileVP9Profile1},
{"VAProfileVP9Profile2", VAProfileVP9Profile2}, {"VAProfileVP9Profile2", VAProfileVP9Profile2},
{"VAProfileVP9Profile3", VAProfileVP9Profile3},
}; };
auto it = kStringToVAProfile.find(va_profile); auto it = kStringToVAProfile.find(va_profile);
...@@ -180,7 +184,7 @@ TEST_F(VaapiTest, GetSupportedEncodeProfiles) { ...@@ -180,7 +184,7 @@ TEST_F(VaapiTest, GetSupportedEncodeProfiles) {
const auto va_info = RetrieveVAInfoOutput(); const auto va_info = RetrieveVAInfoOutput();
for (const auto& profile : VaapiWrapper::GetSupportedEncodeProfiles()) { for (const auto& profile : VaapiWrapper::GetSupportedEncodeProfiles()) {
const auto va_profile = ConvertToVAProfile(profile.profile); auto va_profile = ConvertToVAProfile(profile.profile);
ASSERT_TRUE(va_profile.has_value()); ASSERT_TRUE(va_profile.has_value());
EXPECT_TRUE(base::Contains(va_info.at(*va_profile), VAEntrypointEncSlice) || EXPECT_TRUE(base::Contains(va_info.at(*va_profile), VAEntrypointEncSlice) ||
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment