#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include <drm_fourcc.h>
#include <gbm.h>
#include <unistd.h>
#include <va/va.h>
#include <va/va_drmcommon.h>
#include <va/va_str.h>
#include <xf86drm.h>
#include <map>
#include <optional>
#include <vector>
#include "base/bits.h"
#include "base/containers/contains.h"
#include "base/cpu.h"
#include "base/files/file.h"
#include "base/files/file_util.h"
#include "base/files/scoped_file.h"
#include "base/functional/callback_helpers.h"
#include "base/logging.h"
#include "base/process/launch.h"
#include "base/strings/pattern.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/test/launcher/unit_test_launcher.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/test_suite.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "media/base/media_switches.h"
#include "media/base/platform_features.h"
#include "media/gpu/vaapi/vaapi_wrapper.h"
#include "media/media_buildflags.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/linux/gbm_defines.h"
#ifndef I915_FORMAT_MOD_4_TILED
#define I915_FORMAT_MOD_4_TILED …
#endif
namespace media {
namespace {
std::optional<VAProfile> ConvertToVAProfile(VideoCodecProfile profile) { … }
std::optional<VAProfile> StringToVAProfile(const std::string& va_profile) { … }
std::optional<VAEntrypoint> StringToVAEntrypoint(
const std::string& va_entrypoint) { … }
unsigned int ToVaRTFormat(uint32_t va_fourcc) { … }
uint32_t ToVaFourcc(unsigned int va_rt_format) { … }
int ToGBMFormat(unsigned int va_rt_format) { … }
const std::string VARTFormatToString(unsigned int va_rt_format) { … }
#define TOSTR(enumCase) …
const char* VAProfileToString(VAProfile profile) { … }
bool IsDisplayVer14() { … }
}
class VaapiTest : public testing::Test { … };
std::map<VAProfile, std::vector<VAEntrypoint>> ParseVainfo(
const std::string& output) { … }
std::string GetVaInfo(std::vector<std::string> argv) { … }
std::map<VAProfile, std::vector<VAEntrypoint>> RetrieveVAInfoOutput() { … }
TEST_F(VaapiTest, VaapiSandboxInitialization) { … }
TEST_F(VaapiTest, VerifyNoVAProfileH264Baseline) { … }
TEST_F(VaapiTest, GetSupportedDecodeProfiles) { … }
TEST_F(VaapiTest, GetSupportedEncodeProfiles) { … }
TEST_F(VaapiTest, VbrAndCbrResolutionsMatch) { … }
#if BUILDFLAG(USE_CHROMEOS_PROTECTED_MEDIA)
#if BUILDFLAG(IS_CHROMEOS_ASH)
TEST_F(VaapiTest, VaapiProfileProtected) {
VAImplementation impl = VaapiWrapper::GetImplementationType();
if (impl == VAImplementation::kIntelIHD) {
const auto va_info = RetrieveVAInfoOutput();
EXPECT_TRUE(base::Contains(va_info.at(VAProfileProtected),
VAEntrypointProtectedContent))
<< ", va profile: " << vaProfileStr(VAProfileProtected);
} else {
EXPECT_EQ(impl, VAImplementation::kMesaGallium);
}
}
#endif
#endif
TEST_F(VaapiTest, VaapiProfilesJPEG) { … }
TEST_F(VaapiTest, DefaultEntrypointIsSupported) { … }
TEST_F(VaapiTest, UnsupportedVAProfile) { … }
TEST_F(VaapiTest, TooManyDecoderInstances) { … }
TEST_F(VaapiTest, EncryptionSchemeNeedsCodecMode) { … }
TEST_F(VaapiTest, LowQualityEncodingSetting) { … }
TEST_F(VaapiTest, CheckSupportedSVCScalabilityModes) { … }
class VaapiVppTest
: public VaapiTest,
public testing::WithParamInterface<std::tuple<uint32_t, uint32_t>> { … };
TEST_P(VaapiVppTest, BlitWithVAAllocatedSurfaces) { … }
constexpr uint32_t kVAFourCCs[] = …;
INSTANTIATE_TEST_SUITE_P(…);
class VaapiMinigbmTest
: public VaapiTest,
public testing::WithParamInterface<
std::tuple<VAProfile, unsigned int , gfx::Size>> { … };
TEST_P(VaapiMinigbmTest, AllocateAndCompareWithMinigbm) { … }
constexpr VAProfile kVACodecProfiles[] = …;
constexpr uint32_t kVARTFormatsForGBM[] = …;
constexpr gfx::Size kResolutions[] = …;
INSTANTIATE_TEST_SUITE_P(…);
}
int main(int argc, char** argv) { … }