#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "media/gpu/vaapi/vaapi_video_encode_accelerator.h"
#include <memory>
#include <numeric>
#include <vector>
#include "base/bits.h"
#include "base/memory/raw_ptr.h"
#include "base/run_loop.h"
#include "base/test/gmock_callback_support.h"
#include "base/test/task_environment.h"
#include "build/chromeos_buildflags.h"
#include "media/base/media_util.h"
#include "media/base/mock_media_log.h"
#include "media/base/video_frame.h"
#include "media/gpu/gpu_video_encode_accelerator_helpers.h"
#include "media/gpu/vaapi/vaapi_utils.h"
#include "media/gpu/vaapi/vaapi_video_encoder_delegate.h"
#include "media/gpu/vaapi/vaapi_wrapper.h"
#include "media/gpu/vaapi/vp9_vaapi_video_encoder_delegate.h"
#include "media/gpu/vp9_picture.h"
#include "media/video/fake_gpu_memory_buffer.h"
#include "media/video/video_encode_accelerator.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/native_pixmap.h"
RunClosure;
_;
Eq;
HasSubstr;
Return;
WithArgs;
namespace media {
namespace {
constexpr gfx::Size kDefaultEncodeSize(1280, 720);
constexpr uint32_t kDefaultBitrateBps = …;
constexpr Bitrate kDefaultBitrate = …;
constexpr uint32_t kDefaultFramerate = …;
constexpr size_t kMaxNumOfRefFrames = …;
constexpr int kSpatialLayersResolutionDenom[][3] = …;
VideoEncodeAccelerator::Config DefaultVideoEncodeAcceleratorConfig() { … }
std::vector<VideoEncodeAccelerator::Config::SpatialLayer> GetDefaultSVCLayers(
size_t num_spatial_layers,
size_t num_temporal_layers) { … }
std::vector<gfx::Size> GetDefaultSVCResolutions(size_t num_spatial_layers) { … }
bool IsSVCSupported(const VideoEncodeAccelerator::Config& config) { … }
MATCHER_P(CheckEncodeData, payload_size_bytes, "") { … }
MATCHER_P3(MatchesBitstreamBufferMetadata,
payload_size_bytes,
key_frame,
has_vp9_metadata,
"") { … }
MATCHER_P2(MatchesEncoderInfo,
num_of_spatial_layers,
num_of_temporal_layers,
"") { … }
MATCHER(ContainsTooManyEncoderInstances, "") { … }
class MockVideoEncodeAcceleratorClient : public VideoEncodeAccelerator::Client { … };
class MockVaapiWrapper : public VaapiWrapper { … };
class MockVaapiVideoEncoderDelegate : public VaapiVideoEncoderDelegate { … };
class MockVP9VaapiVideoEncoderDelegate : public VP9VaapiVideoEncoderDelegate { … };
}
struct VaapiVideoEncodeAcceleratorTestParam;
class VaapiVideoEncodeAcceleratorTest
: public ::testing::TestWithParam<VaapiVideoEncodeAcceleratorTestParam> { … };
struct VaapiVideoEncodeAcceleratorTestParam { … } kTestCases[]{ … };
TEST_P(VaapiVideoEncodeAcceleratorTest, Initialize) { … }
TEST_P(VaapiVideoEncodeAcceleratorTest, EncodeVP9WithSingleSpatialLayer) { … }
TEST_P(VaapiVideoEncodeAcceleratorTest, EncodeVP9WithMultipleSpatialLayers) { … }
TEST_F(VaapiVideoEncodeAcceleratorTest, TooManyEncoderInstances) { … }
TEST_F(VaapiVideoEncodeAcceleratorTest, AttemptedInitialization) { … }
TEST_F(VaapiVideoEncodeAcceleratorTest, InitializeWithUnsupportedConfig) { … }
TEST_F(VaapiVideoEncodeAcceleratorTest, EncodingParametersChange) { … }
TEST_F(VaapiVideoEncodeAcceleratorTest,
EncodingParametersChangeWithBitrateAllocation) { … }
INSTANTIATE_TEST_SUITE_P(…);
}