Skip to content

Commit

Permalink
vaapi: use |decode_using_client_picture_buffers| for VDA test parameter
Browse files Browse the repository at this point in the history
This CL extends VaapiVideoDecodeAcceleratorTest to use the flag
|decode_using_client_picture_buffers| as test parameter, and
teaches it what to do when it's true (on ToT is always false).

Test: bots chromeos-amd64-generic-rel linux-chromeos-rel run the new cases.
Bug: 875005
Change-Id: Id0d500d4f27e273037a80c2e0507d906690ac98d
Reviewed-on: https://chromium-review.googlesource.com/c/1394946
Reviewed-by: Daniele Castagna <dcastagna@chromium.org>
Commit-Queue: Miguel Casas <mcasas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#619838}
  • Loading branch information
yellowdoge authored and Commit Bot committed Jan 4, 2019
1 parent 68b0fa4 commit c3c351c
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 20 deletions.
65 changes: 46 additions & 19 deletions media/gpu/vaapi/vaapi_video_decode_accelerator_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,11 @@ ACTION_P(RunClosure, closure) {
closure.Run();
}

constexpr VideoCodecProfile kCodecProfiles[] = {H264PROFILE_MIN, VP8PROFILE_MIN,
VP9PROFILE_MIN};
struct TestParams {
VideoCodecProfile video_codec;
bool decode_using_client_picture_buffers;
};

constexpr int32_t kBitstreamId = 123;
constexpr size_t kInputSize = 256;

Expand Down Expand Up @@ -66,6 +69,7 @@ class MockVaapiWrapper : public VaapiWrapper {
MOCK_METHOD4(
CreateContextAndSurfaces,
bool(unsigned int, const gfx::Size&, size_t, std::vector<VASurfaceID>*));
MOCK_METHOD2(CreateContext, bool(unsigned int, const gfx::Size&));
MOCK_METHOD0(DestroyContextAndSurfaces, void());

private:
Expand Down Expand Up @@ -104,6 +108,10 @@ class MockVaapiPicture : public VaapiPicture {
return true;
}
bool AllowOverlay() const override { return false; }
VASurfaceID va_surface_id() const override {
// Return any number different from VA_INVALID_ID and VaapiPicture specific.
return static_cast<VASurfaceID>(texture_id_);
}
};

class MockVaapiPictureFactory : public VaapiPictureFactory {
Expand All @@ -127,7 +135,7 @@ class MockVaapiPictureFactory : public VaapiPictureFactory {
}
};

class VaapiVideoDecodeAcceleratorTest : public TestWithParam<VideoCodecProfile>,
class VaapiVideoDecodeAcceleratorTest : public TestWithParam<TestParams>,
public VideoDecodeAccelerator::Client {
public:
VaapiVideoDecodeAcceleratorTest()
Expand Down Expand Up @@ -155,6 +163,11 @@ class VaapiVideoDecodeAcceleratorTest : public TestWithParam<VideoCodecProfile>,
vda_.vpp_vaapi_wrapper_ = mock_vpp_vaapi_wrapper_;
vda_.vaapi_picture_factory_.reset(mock_vaapi_picture_factory_);

vda_.output_mode_ = VideoDecodeAccelerator::Config::OutputMode::ALLOCATE;

vda_.decode_using_client_picture_buffers_ =
GetParam().decode_using_client_picture_buffers;

vda_.state_ = VaapiVideoDecodeAccelerator::kIdle;
}
~VaapiVideoDecodeAcceleratorTest() {}
Expand Down Expand Up @@ -240,21 +253,29 @@ class VaapiVideoDecodeAcceleratorTest : public TestWithParam<VideoCodecProfile>,
base::RunLoop run_loop;
base::Closure quit_closure = run_loop.QuitClosure();

// TODO(crbug.com/): We assume that |decode_using_client_picture_buffers_|
// is false, we should also support a pattern when
// |decode_using_client_picture_buffers_|.
EXPECT_CALL(*mock_vaapi_wrapper_,
CreateContextAndSurfaces(_, picture_size, num_pictures, _))
.WillOnce(
DoAll(WithArg<3>(Invoke(
[num_pictures](std::vector<VASurfaceID>* va_surface_ids) {
va_surface_ids->resize(num_pictures);
})),
Return(true)));
EXPECT_CALL(
*mock_vaapi_picture_factory_,
MockCreateVaapiPicture(mock_vpp_vaapi_wrapper_.get(), picture_size))
.Times(num_pictures);
// |decode_using_client_picture_buffers| determines the concrete method for
// creation of context, surfaces and VaapiPictures.
if (GetParam().decode_using_client_picture_buffers) {
EXPECT_CALL(*mock_vaapi_wrapper_, CreateContext(_, picture_size))
.WillOnce(Return(true));
EXPECT_CALL(
*mock_vaapi_picture_factory_,
MockCreateVaapiPicture(mock_vaapi_wrapper_.get(), picture_size))
.Times(num_pictures);
} else {
EXPECT_CALL(*mock_vaapi_wrapper_,
CreateContextAndSurfaces(_, picture_size, num_pictures, _))
.WillOnce(DoAll(
WithArg<3>(Invoke(
[num_pictures](std::vector<VASurfaceID>* va_surface_ids) {
va_surface_ids->resize(num_pictures);
})),
Return(true)));
EXPECT_CALL(
*mock_vaapi_picture_factory_,
MockCreateVaapiPicture(mock_vpp_vaapi_wrapper_.get(), picture_size))
.Times(num_pictures);
}

::testing::InSequence s;
EXPECT_CALL(*mock_decoder_, Decode())
Expand Down Expand Up @@ -420,8 +441,14 @@ TEST_P(VaapiVideoDecodeAcceleratorTest,
ResetSequence();
}

constexpr TestParams kTestCases[] = {
{H264PROFILE_MIN, false /* decode_using_client_picture_buffers */},
{VP8PROFILE_MIN, false /* decode_using_client_picture_buffers */},
{VP9PROFILE_MIN, false /* decode_using_client_picture_buffers */},
{VP9PROFILE_MIN, true /* decode_using_client_picture_buffers */}};

INSTANTIATE_TEST_CASE_P(/* No prefix. */,
VaapiVideoDecodeAcceleratorTest,
ValuesIn(kCodecProfiles));
ValuesIn(kTestCases));

} // namespace media
2 changes: 1 addition & 1 deletion media/gpu/vaapi/vaapi_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class MEDIA_GPU_EXPORT VaapiWrapper
// Creates a VA Context associated with |format| and |size|, and sets
// |va_context_id_|. The |va_context_id_| will be destroyed by
// DestroyContextAndSurfaces().
bool CreateContext(unsigned int va_format, const gfx::Size& size);
virtual bool CreateContext(unsigned int va_format, const gfx::Size& size);

// Frees all memory allocated in CreateContextAndSurfaces() and destroys
// |va_context_id_|.
Expand Down

0 comments on commit c3c351c

Please sign in to comment.