Commit 7883e6b9 authored by David Staessens's avatar David Staessens Committed by Commit Bot

media/gpu/test: Cleanup and split test helpers build target.

This change splits up the test helpers target in separate encode, decode and
other helpers. Tests now only depend on what they actually need. This change
doesn't introduce any new code, but some things are moved to avoid weird
dependancies (such as encode helpers depending on frame mapper which depends on
decode helpers).

This change also moves code in the video_accelerator_unittest_helpers.h file
from the media to the media/test namespace.

TEST=ran video/jpeg encode/decode tests on nocturne

CQ-DEPEND=CL:1345670

BUG=879065

Change-Id: I17704399c5724cbacc5611578e0dec22191e7a50
Reviewed-on: https://chromium-review.googlesource.com/c/1345701Reviewed-by: default avatarHirokazu Honda <hiroh@chromium.org>
Commit-Queue: David Staessens <dstaessens@chromium.org>
Cr-Commit-Position: refs/heads/master@{#610757}
parent 3819e0e4
...@@ -363,10 +363,6 @@ source_set("common") { ...@@ -363,10 +363,6 @@ source_set("common") {
# TODO(watk): Run this on bots. http://crbug.com/461437 # TODO(watk): Run this on bots. http://crbug.com/461437
if (is_win || is_android || use_v4l2_codec || use_vaapi) { if (is_win || is_android || use_v4l2_codec || use_vaapi) {
test("video_decode_accelerator_unittest") { test("video_decode_accelerator_unittest") {
sources = [
"test/video_accelerator_unittest_helpers.h",
]
data = [ data = [
"//media/test/data/", "//media/test/data/",
] ]
...@@ -392,9 +388,12 @@ if (is_win || is_android || use_v4l2_codec || use_vaapi) { ...@@ -392,9 +388,12 @@ if (is_win || is_android || use_v4l2_codec || use_vaapi) {
configs += [ "//third_party/khronos:khronos_headers" ] configs += [ "//third_party/khronos:khronos_headers" ]
if (is_win || is_chromeos || use_v4l2_codec) { if (is_win || is_chromeos || use_v4l2_codec) {
sources += [ "video_decode_accelerator_unittest.cc" ] sources = [
"video_decode_accelerator_unittest.cc",
]
deps += [ deps += [
"test:helpers", "test:decode_helpers",
"test:frame_validator",
"//mojo/core/embedder", "//mojo/core/embedder",
"//ui/display", "//ui/display",
"//ui/display/types", "//ui/display/types",
...@@ -477,7 +476,7 @@ source_set("android_video_decode_accelerator_unittests") { ...@@ -477,7 +476,7 @@ source_set("android_video_decode_accelerator_unittests") {
if (use_v4l2_codec || use_vaapi || is_mac || is_win) { if (use_v4l2_codec || use_vaapi || is_mac || is_win) {
test("video_encode_accelerator_unittest") { test("video_encode_accelerator_unittest") {
deps = [ deps = [
"test:helpers", "test:encode_helpers",
"//base", "//base",
"//base/test:test_support", "//base/test:test_support",
"//media:test_support", "//media:test_support",
...@@ -507,6 +506,7 @@ if (use_v4l2_codec || use_vaapi || is_mac || is_win) { ...@@ -507,6 +506,7 @@ if (use_v4l2_codec || use_vaapi || is_mac || is_win) {
if (use_v4l2_codec || use_vaapi) { if (use_v4l2_codec || use_vaapi) {
test("jpeg_encode_accelerator_unittest") { test("jpeg_encode_accelerator_unittest") {
deps = [ deps = [
"test:helpers",
"//base", "//base",
"//base/test:test_support", "//base/test:test_support",
"//media:test_support", "//media:test_support",
...@@ -525,7 +525,6 @@ if (use_v4l2_codec || use_vaapi) { ...@@ -525,7 +525,6 @@ if (use_v4l2_codec || use_vaapi) {
configs += [ "//third_party/libyuv:libyuv_config" ] configs += [ "//third_party/libyuv:libyuv_config" ]
sources = [ sources = [
"jpeg_encode_accelerator_unittest.cc", "jpeg_encode_accelerator_unittest.cc",
"test/video_accelerator_unittest_helpers.h",
] ]
if (use_x11) { if (use_x11) {
deps += [ "//ui/gfx/x" ] deps += [ "//ui/gfx/x" ]
...@@ -539,6 +538,7 @@ if (use_v4l2_codec || use_vaapi) { ...@@ -539,6 +538,7 @@ if (use_v4l2_codec || use_vaapi) {
if (is_chromeos || is_linux) { if (is_chromeos || is_linux) {
test("jpeg_decode_accelerator_unittest") { test("jpeg_decode_accelerator_unittest") {
deps = [ deps = [
"test:helpers",
"//base", "//base",
"//media:test_support", "//media:test_support",
"//media/gpu", "//media/gpu",
...@@ -556,7 +556,6 @@ if (is_chromeos || is_linux) { ...@@ -556,7 +556,6 @@ if (is_chromeos || is_linux) {
configs += [ "//third_party/libyuv:libyuv_config" ] configs += [ "//third_party/libyuv:libyuv_config" ]
sources = [ sources = [
"jpeg_decode_accelerator_unittest.cc", "jpeg_decode_accelerator_unittest.cc",
"test/video_accelerator_unittest_helpers.h",
] ]
data = [ data = [
"//media/test/data/peach_pi-1280x720.jpg", "//media/test/data/peach_pi-1280x720.jpg",
......
...@@ -2,10 +2,6 @@ ...@@ -2,10 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// This has to be included first.
// See http://code.google.com/p/googletest/issues/detail?id=371
#include "testing/gtest/include/gtest/gtest.h"
#include <stddef.h> #include <stddef.h>
#include <stdint.h> #include <stdint.h>
#include <string.h> #include <string.h>
...@@ -34,6 +30,7 @@ ...@@ -34,6 +30,7 @@
#include "media/gpu/test/video_accelerator_unittest_helpers.h" #include "media/gpu/test/video_accelerator_unittest_helpers.h"
#include "media/video/jpeg_decode_accelerator.h" #include "media/video/jpeg_decode_accelerator.h"
#include "mojo/core/embedder/embedder.h" #include "mojo/core/embedder/embedder.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/libyuv/include/libyuv.h" #include "third_party/libyuv/include/libyuv.h"
#include "ui/gfx/codec/jpeg_codec.h" #include "ui/gfx/codec/jpeg_codec.h"
#include "ui/gfx/codec/png_codec.h" #include "ui/gfx/codec/png_codec.h"
...@@ -246,9 +243,10 @@ enum ClientState { ...@@ -246,9 +243,10 @@ enum ClientState {
class JpegClient : public JpegDecodeAccelerator::Client { class JpegClient : public JpegDecodeAccelerator::Client {
public: public:
// JpegClient takes ownership of |note|. // JpegClient takes ownership of |note|.
JpegClient(const std::vector<ParsedJpegImage*>& test_image_files, JpegClient(
std::unique_ptr<ClientStateNotification<ClientState>> note, const std::vector<ParsedJpegImage*>& test_image_files,
bool is_skip); std::unique_ptr<media::test::ClientStateNotification<ClientState>> note,
bool is_skip);
~JpegClient() override; ~JpegClient() override;
void CreateJpegDecoder(); void CreateJpegDecoder();
void StartDecode(int32_t bitstream_buffer_id, bool do_prepare_memory = true); void StartDecode(int32_t bitstream_buffer_id, bool do_prepare_memory = true);
...@@ -261,7 +259,9 @@ class JpegClient : public JpegDecodeAccelerator::Client { ...@@ -261,7 +259,9 @@ class JpegClient : public JpegDecodeAccelerator::Client {
JpegDecodeAccelerator::Error error) override; JpegDecodeAccelerator::Error error) override;
// Accessors. // Accessors.
ClientStateNotification<ClientState>* note() const { return note_.get(); } media::test::ClientStateNotification<ClientState>* note() const {
return note_.get();
}
private: private:
FRIEND_TEST_ALL_PREFIXES(JpegClientTest, GetMeanAbsoluteDifference); FRIEND_TEST_ALL_PREFIXES(JpegClientTest, GetMeanAbsoluteDifference);
...@@ -284,7 +284,7 @@ class JpegClient : public JpegDecodeAccelerator::Client { ...@@ -284,7 +284,7 @@ class JpegClient : public JpegDecodeAccelerator::Client {
ClientState state_; ClientState state_;
// Used to notify another thread about the state. JpegClient owns this. // Used to notify another thread about the state. JpegClient owns this.
std::unique_ptr<ClientStateNotification<ClientState>> note_; std::unique_ptr<media::test::ClientStateNotification<ClientState>> note_;
// Skip JDA decode result. Used for testing performance. // Skip JDA decode result. Used for testing performance.
bool is_skip_; bool is_skip_;
...@@ -311,7 +311,7 @@ class JpegClient : public JpegDecodeAccelerator::Client { ...@@ -311,7 +311,7 @@ class JpegClient : public JpegDecodeAccelerator::Client {
JpegClient::JpegClient( JpegClient::JpegClient(
const std::vector<ParsedJpegImage*>& test_image_files, const std::vector<ParsedJpegImage*>& test_image_files,
std::unique_ptr<ClientStateNotification<ClientState>> note, std::unique_ptr<media::test::ClientStateNotification<ClientState>> note,
bool is_skip) bool is_skip)
: test_image_files_(test_image_files), : test_image_files_(test_image_files),
state_(CS_CREATED), state_(CS_CREATED),
...@@ -588,7 +588,8 @@ void JpegDecodeAcceleratorTest::TestDecode( ...@@ -588,7 +588,8 @@ void JpegDecodeAcceleratorTest::TestDecode(
for (size_t i = 0; i < num_concurrent_decoders; i++) { for (size_t i = 0; i < num_concurrent_decoders; i++) {
auto client = std::make_unique<JpegClient>( auto client = std::make_unique<JpegClient>(
images, std::make_unique<ClientStateNotification<ClientState>>(), images,
std::make_unique<media::test::ClientStateNotification<ClientState>>(),
false /* is_skip */); false /* is_skip */);
scoped_clients.emplace_back( scoped_clients.emplace_back(
new ScopedJpegClient(decoder_thread.task_runner(), std::move(client))); new ScopedJpegClient(decoder_thread.task_runner(), std::move(client)));
...@@ -624,7 +625,8 @@ void JpegDecodeAcceleratorTest::PerfDecodeByJDA( ...@@ -624,7 +625,8 @@ void JpegDecodeAcceleratorTest::PerfDecodeByJDA(
ASSERT_TRUE(decoder_thread.Start()); ASSERT_TRUE(decoder_thread.Start());
auto client = std::make_unique<JpegClient>( auto client = std::make_unique<JpegClient>(
images, std::make_unique<ClientStateNotification<ClientState>>(), images,
std::make_unique<media::test::ClientStateNotification<ClientState>>(),
true /* is_skip */); true /* is_skip */);
auto scoped_client = std::make_unique<ScopedJpegClient>( auto scoped_client = std::make_unique<ScopedJpegClient>(
decoder_thread.task_runner(), std::move(client)); decoder_thread.task_runner(), std::move(client));
...@@ -658,7 +660,8 @@ void JpegDecodeAcceleratorTest::PerfDecodeBySW( ...@@ -658,7 +660,8 @@ void JpegDecodeAcceleratorTest::PerfDecodeBySW(
LOG_ASSERT(images.size() == 1); LOG_ASSERT(images.size() == 1);
std::unique_ptr<JpegClient> client = std::make_unique<JpegClient>( std::unique_ptr<JpegClient> client = std::make_unique<JpegClient>(
images, std::make_unique<ClientStateNotification<ClientState>>(), images,
std::make_unique<media::test::ClientStateNotification<ClientState>>(),
true /* is_skip */); true /* is_skip */);
const int32_t bitstream_buffer_id = 0; const int32_t bitstream_buffer_id = 0;
......
...@@ -240,7 +240,7 @@ class JpegClient : public JpegEncodeAccelerator::Client { ...@@ -240,7 +240,7 @@ class JpegClient : public JpegEncodeAccelerator::Client {
public: public:
JpegClient(const std::vector<TestImage*>& test_aligned_images, JpegClient(const std::vector<TestImage*>& test_aligned_images,
const std::vector<TestImage*>& test_images, const std::vector<TestImage*>& test_images,
ClientStateNotification<ClientState>* note); media::test::ClientStateNotification<ClientState>* note);
~JpegClient() override; ~JpegClient() override;
void CreateJpegEncoder(); void CreateJpegEncoder();
void DestroyJpegEncoder(); void DestroyJpegEncoder();
...@@ -291,7 +291,7 @@ class JpegClient : public JpegEncodeAccelerator::Client { ...@@ -291,7 +291,7 @@ class JpegClient : public JpegEncodeAccelerator::Client {
// Used to notify another thread about the state. JpegClient does not own // Used to notify another thread about the state. JpegClient does not own
// this. // this.
ClientStateNotification<ClientState>* note_; media::test::ClientStateNotification<ClientState>* note_;
// Output buffer prepared for JpegEncodeAccelerator. // Output buffer prepared for JpegEncodeAccelerator.
std::unique_ptr<BitstreamBuffer> encoded_buffer_; std::unique_ptr<BitstreamBuffer> encoded_buffer_;
...@@ -308,7 +308,7 @@ class JpegClient : public JpegEncodeAccelerator::Client { ...@@ -308,7 +308,7 @@ class JpegClient : public JpegEncodeAccelerator::Client {
JpegClient::JpegClient(const std::vector<TestImage*>& test_aligned_images, JpegClient::JpegClient(const std::vector<TestImage*>& test_aligned_images,
const std::vector<TestImage*>& test_images, const std::vector<TestImage*>& test_images,
ClientStateNotification<ClientState>* note) media::test::ClientStateNotification<ClientState>* note)
: test_aligned_images_(test_aligned_images), : test_aligned_images_(test_aligned_images),
test_images_(test_images), test_images_(test_images),
state_(ClientState::CREATED), state_(ClientState::CREATED),
...@@ -594,11 +594,14 @@ void JpegEncodeAcceleratorTest::TestEncode(size_t num_concurrent_encoders) { ...@@ -594,11 +594,14 @@ void JpegEncodeAcceleratorTest::TestEncode(size_t num_concurrent_encoders) {
base::Thread encoder_thread("EncoderThread"); base::Thread encoder_thread("EncoderThread");
ASSERT_TRUE(encoder_thread.Start()); ASSERT_TRUE(encoder_thread.Start());
std::vector<std::unique_ptr<ClientStateNotification<ClientState>>> notes; std::vector<
std::unique_ptr<media::test::ClientStateNotification<ClientState>>>
notes;
std::vector<std::unique_ptr<JpegClient>> clients; std::vector<std::unique_ptr<JpegClient>> clients;
for (size_t i = 0; i < num_concurrent_encoders; i++) { for (size_t i = 0; i < num_concurrent_encoders; i++) {
notes.push_back(std::make_unique<ClientStateNotification<ClientState>>()); notes.push_back(
std::make_unique<media::test::ClientStateNotification<ClientState>>());
clients.push_back(std::make_unique<JpegClient>( clients.push_back(std::make_unique<JpegClient>(
test_aligned_images_, test_images_, notes.back().get())); test_aligned_images_, test_images_, notes.back().get()));
encoder_thread.task_runner()->PostTask( encoder_thread.task_runner()->PostTask(
......
...@@ -5,25 +5,39 @@ ...@@ -5,25 +5,39 @@
import("//build/config/ui.gni") import("//build/config/ui.gni")
import("//media/gpu/args.gni") import("//media/gpu/args.gni")
# TODO(dstaessens@) Split up in encode/decode/render/common helpers
source_set("helpers") { source_set("helpers") {
testonly = true testonly = true
sources = [
"video_accelerator_unittest_helpers.h",
]
deps = [
"//base:base",
]
}
source_set("render_helpers") {
testonly = true
sources = [ sources = [
"rendering_helper.cc", "rendering_helper.cc",
"rendering_helper.h", "rendering_helper.h",
"texture_ref.cc", "texture_ref.cc",
"texture_ref.h", "texture_ref.h",
"video_accelerator_unittest_helpers.h", ]
"video_decode_accelerator_unittest_helpers.cc", deps = [
"video_decode_accelerator_unittest_helpers.h", "//media/gpu",
"video_encode_accelerator_unittest_helpers.cc", "//ui/gl/init:init",
"video_encode_accelerator_unittest_helpers.h", ]
if (use_ozone) {
deps += [ "//ui/ozone" ]
}
}
source_set("frame_mapper") {
testonly = true
sources = [
"video_frame_mapper.h", "video_frame_mapper.h",
"video_frame_mapper_factory.cc", "video_frame_mapper_factory.cc",
"video_frame_mapper_factory.h", "video_frame_mapper_factory.h",
"video_frame_validator.cc",
"video_frame_validator.h",
] ]
if (is_chromeos) { if (is_chromeos) {
sources += [ sources += [
...@@ -37,22 +51,67 @@ source_set("helpers") { ...@@ -37,22 +51,67 @@ source_set("helpers") {
] ]
} }
} }
deps = [
"//media/gpu",
]
}
source_set("frame_validator") {
testonly = true
sources = [
"video_frame_validator.cc",
"video_frame_validator.h",
]
public_deps = [
":frame_mapper",
]
deps = [
":decode_helpers",
":helpers",
"//media/gpu",
]
}
source_set("decode_helpers") {
testonly = true
sources = [
"video_decode_accelerator_unittest_helpers.cc",
"video_decode_accelerator_unittest_helpers.h",
]
public_deps = [
":helpers",
":render_helpers",
]
deps = [ deps = [
"//media/gpu", "//media/gpu",
"//testing/gtest", "//testing/gtest",
"//third_party/libyuv",
"//ui/gl/init:init",
] ]
if (use_ozone) { if (use_ozone) {
deps += [ "//ui/ozone" ] deps += [ "//ui/ozone" ]
} }
} }
source_set("encode_helpers") {
testonly = true
sources = [
"video_encode_accelerator_unittest_helpers.cc",
"video_encode_accelerator_unittest_helpers.h",
]
public_deps = [
":helpers",
":render_helpers",
]
deps = [
":frame_mapper",
"//media/gpu",
]
}
# TODO(dstaessens@) Make this work on other platforms too. # TODO(dstaessens@) Make this work on other platforms too.
if (is_chromeos) { if (is_chromeos) {
static_library("video_player") { static_library("video_player") {
testonly = true testonly = true
sources = [ sources = [
"video_player/frame_renderer.h", "video_player/frame_renderer.h",
"video_player/frame_renderer_dummy.cc", "video_player/frame_renderer_dummy.cc",
...@@ -66,16 +125,13 @@ if (is_chromeos) { ...@@ -66,16 +125,13 @@ if (is_chromeos) {
"video_player/video_player.cc", "video_player/video_player.cc",
"video_player/video_player.h", "video_player/video_player.h",
] ]
data = [ data = [
"//media/test/data/", "//media/test/data/",
] ]
deps = [ deps = [
":helpers", ":decode_helpers",
"//media/gpu", "//media/gpu",
] ]
if (use_ozone) { if (use_ozone) {
deps += [ "//ui/ozone" ] deps += [ "//ui/ozone" ]
} }
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <algorithm> #include <algorithm>
#include <memory> #include <memory>
#include <numeric> #include <numeric>
#include <utility>
#include <vector> #include <vector>
#include "base/bind.h" #include "base/bind.h"
...@@ -25,7 +26,6 @@ ...@@ -25,7 +26,6 @@
#include "base/time/time.h" #include "base/time/time.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "media/gpu/test/texture_ref.h" #include "media/gpu/test/texture_ref.h"
#include "media/gpu/test/video_decode_accelerator_unittest_helpers.h"
#include "ui/gfx/buffer_types.h" #include "ui/gfx/buffer_types.h"
#include "ui/gl/gl_context.h" #include "ui/gl/gl_context.h"
#include "ui/gl/gl_implementation.h" #include "ui/gl/gl_implementation.h"
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "base/synchronization/lock.h" #include "base/synchronization/lock.h"
namespace media { namespace media {
namespace test {
// Helper class allowing one thread to wait on a notification from another. // Helper class allowing one thread to wait on a notification from another.
// If notifications come in faster than they are Wait()'d for, they are // If notifications come in faster than they are Wait()'d for, they are
...@@ -57,6 +58,7 @@ StateEnum ClientStateNotification<StateEnum>::Wait() { ...@@ -57,6 +58,7 @@ StateEnum ClientStateNotification<StateEnum>::Wait() {
return ret; return ret;
} }
} // namespace test
} // namespace media } // namespace media
#endif // MEDIA_GPU_TEST_VIDEO_ACCELERATOR_UNITTEST_HELPERS_H_ #endif // MEDIA_GPU_TEST_VIDEO_ACCELERATOR_UNITTEST_HELPERS_H_
...@@ -8,12 +8,10 @@ ...@@ -8,12 +8,10 @@
#include "base/callback_helpers.h" #include "base/callback_helpers.h"
#include "base/files/file_util.h" #include "base/files/file_util.h"
#include "base/files/scoped_file.h"
#include "base/strings/string_split.h" #include "base/strings/string_split.h"
#include "base/threading/thread_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h"
#include "media/base/video_decoder_config.h" #include "media/base/video_decoder_config.h"
#include "media/gpu/test/rendering_helper.h" #include "media/gpu/test/rendering_helper.h"
#include "media/gpu/test/texture_ref.h"
#include "media/video/h264_parser.h" #include "media/video/h264_parser.h"
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
......
...@@ -3,8 +3,6 @@ ...@@ -3,8 +3,6 @@
// found in the LICENSE file. // found in the LICENSE file.
#include "media/gpu/test/video_frame_validator.h" #include "media/gpu/test/video_frame_validator.h"
// TODO(dstaessens@) Avoid depending on video_decode_accelerator here.
#include "media/gpu/test/video_decode_accelerator_unittest_helpers.h"
#include <libyuv.h> #include <libyuv.h>
...@@ -13,6 +11,7 @@ ...@@ -13,6 +11,7 @@
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "base/numerics/safe_conversions.h" #include "base/numerics/safe_conversions.h"
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
#include "media/gpu/test/video_decode_accelerator_unittest_helpers.h"
namespace media { namespace media {
namespace test { namespace test {
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
#include "base/threading/thread_checker.h" #include "base/threading/thread_checker.h"
#include "media/base/video_frame.h" #include "media/base/video_frame.h"
#include "media/base/video_types.h" #include "media/base/video_types.h"
#include "media/gpu/test/video_decode_accelerator_unittest_helpers.h"
#include "media/gpu/test/video_frame_mapper.h" #include "media/gpu/test/video_frame_mapper.h"
#include "media/gpu/test/video_frame_mapper_factory.h" #include "media/gpu/test/video_frame_mapper_factory.h"
#include "ui/gfx/geometry/rect.h" #include "ui/gfx/geometry/rect.h"
......
...@@ -88,7 +88,6 @@ ...@@ -88,7 +88,6 @@
#endif // defined(OS_CHROMEOS) #endif // defined(OS_CHROMEOS)
namespace media { namespace media {
namespace { namespace {
// Values optionally filled in from flags; see main() below. // Values optionally filled in from flags; see main() below.
...@@ -293,7 +292,7 @@ class GLRenderingVDAClient ...@@ -293,7 +292,7 @@ class GLRenderingVDAClient
std::string encoded_data, std::string encoded_data,
RenderingHelper* rendering_helper, RenderingHelper* rendering_helper,
std::unique_ptr<media::test::VideoFrameValidator> video_frame_validator, std::unique_ptr<media::test::VideoFrameValidator> video_frame_validator,
ClientStateNotification<ClientState>* note); media::test::ClientStateNotification<ClientState>* note);
~GLRenderingVDAClient() override; ~GLRenderingVDAClient() override;
void CreateAndStartDecoder(); void CreateAndStartDecoder();
...@@ -353,7 +352,7 @@ class GLRenderingVDAClient ...@@ -353,7 +352,7 @@ class GLRenderingVDAClient
gfx::Size frame_size_; gfx::Size frame_size_;
size_t outstanding_decodes_; size_t outstanding_decodes_;
int next_bitstream_buffer_id_; int next_bitstream_buffer_id_;
ClientStateNotification<ClientState>* const note_; media::test::ClientStateNotification<ClientState>* const note_;
std::unique_ptr<VideoDecodeAccelerator> decoder_; std::unique_ptr<VideoDecodeAccelerator> decoder_;
base::WeakPtr<VideoDecodeAccelerator> weak_vda_; base::WeakPtr<VideoDecodeAccelerator> weak_vda_;
std::unique_ptr<base::WeakPtrFactory<VideoDecodeAccelerator>> std::unique_ptr<base::WeakPtrFactory<VideoDecodeAccelerator>>
...@@ -414,7 +413,7 @@ GLRenderingVDAClient::GLRenderingVDAClient( ...@@ -414,7 +413,7 @@ GLRenderingVDAClient::GLRenderingVDAClient(
std::string encoded_data, std::string encoded_data,
RenderingHelper* rendering_helper, RenderingHelper* rendering_helper,
std::unique_ptr<media::test::VideoFrameValidator> video_frame_validator, std::unique_ptr<media::test::VideoFrameValidator> video_frame_validator,
ClientStateNotification<ClientState>* note) media::test::ClientStateNotification<ClientState>* note)
: config_(std::move(config)), : config_(std::move(config)),
rendering_helper_(rendering_helper), rendering_helper_(rendering_helper),
frame_size_(config_.frame_size), frame_size_(config_.frame_size),
...@@ -927,11 +926,13 @@ class VideoDecodeAcceleratorTest : public ::testing::Test { ...@@ -927,11 +926,13 @@ class VideoDecodeAcceleratorTest : public ::testing::Test {
TestFilesVector* test_video_files); TestFilesVector* test_video_files);
void InitializeRenderingHelper(const RenderingHelperParams& helper_params); void InitializeRenderingHelper(const RenderingHelperParams& helper_params);
void CreateAndStartDecoder(GLRenderingVDAClient* client, void CreateAndStartDecoder(
ClientStateNotification<ClientState>* note); GLRenderingVDAClient* client,
media::test::ClientStateNotification<ClientState>* note);
// Wait until decode finishes and return the last state. // Wait until decode finishes and return the last state.
ClientState WaitUntilDecodeFinish(ClientStateNotification<ClientState>* note); ClientState WaitUntilDecodeFinish(
media::test::ClientStateNotification<ClientState>* note);
void WaitUntilIdle(); void WaitUntilIdle();
void OutputLogFile(const base::FilePath::CharType* log_path, void OutputLogFile(const base::FilePath::CharType* log_path,
...@@ -946,8 +947,8 @@ class VideoDecodeAcceleratorTest : public ::testing::Test { ...@@ -946,8 +947,8 @@ class VideoDecodeAcceleratorTest : public ::testing::Test {
static void Delete(T item) { static void Delete(T item) {
// |item| is cleared when the scope of this function is left. // |item| is cleared when the scope of this function is left.
} }
using NotesVector = using NotesVector = std::vector<
std::vector<std::unique_ptr<ClientStateNotification<ClientState>>>; std::unique_ptr<media::test::ClientStateNotification<ClientState>>>;
using ClientsVector = std::vector<std::unique_ptr<GLRenderingVDAClient>>; using ClientsVector = std::vector<std::unique_ptr<GLRenderingVDAClient>>;
NotesVector notes_; NotesVector notes_;
...@@ -1074,7 +1075,7 @@ void VideoDecodeAcceleratorTest::InitializeRenderingHelper( ...@@ -1074,7 +1075,7 @@ void VideoDecodeAcceleratorTest::InitializeRenderingHelper(
void VideoDecodeAcceleratorTest::CreateAndStartDecoder( void VideoDecodeAcceleratorTest::CreateAndStartDecoder(
GLRenderingVDAClient* client, GLRenderingVDAClient* client,
ClientStateNotification<ClientState>* note) { media::test::ClientStateNotification<ClientState>* note) {
g_env->GetRenderingTaskRunner()->PostTask( g_env->GetRenderingTaskRunner()->PostTask(
FROM_HERE, base::BindOnce(&GLRenderingVDAClient::CreateAndStartDecoder, FROM_HERE, base::BindOnce(&GLRenderingVDAClient::CreateAndStartDecoder,
base::Unretained(client))); base::Unretained(client)));
...@@ -1082,7 +1083,7 @@ void VideoDecodeAcceleratorTest::CreateAndStartDecoder( ...@@ -1082,7 +1083,7 @@ void VideoDecodeAcceleratorTest::CreateAndStartDecoder(
} }
ClientState VideoDecodeAcceleratorTest::WaitUntilDecodeFinish( ClientState VideoDecodeAcceleratorTest::WaitUntilDecodeFinish(
ClientStateNotification<ClientState>* note) { media::test::ClientStateNotification<ClientState>* note) {
ClientState state = CS_DESTROYED; ClientState state = CS_DESTROYED;
for (int i = 0; i < CS_MAX; i++) { for (int i = 0; i < CS_MAX; i++) {
state = note->Wait(); state = note->Wait();
...@@ -1132,7 +1133,7 @@ class VideoDecodeAcceleratorParamTest ...@@ -1132,7 +1133,7 @@ class VideoDecodeAcceleratorParamTest
// Wait for |note| to report a state and if it's not |expected_state| then // Wait for |note| to report a state and if it's not |expected_state| then
// assert |client| has deleted its decoder. // assert |client| has deleted its decoder.
static void AssertWaitForStateOrDeleted( static void AssertWaitForStateOrDeleted(
ClientStateNotification<ClientState>* note, media::test::ClientStateNotification<ClientState>* note,
GLRenderingVDAClient* client, GLRenderingVDAClient* client,
ClientState expected_state) { ClientState expected_state) {
// Skip waiting state if decoder of |client| is already deleted. // Skip waiting state if decoder of |client| is already deleted.
...@@ -1220,8 +1221,8 @@ TEST_P(VideoDecodeAcceleratorParamTest, MAYBE_TestSimpleDecode) { ...@@ -1220,8 +1221,8 @@ TEST_P(VideoDecodeAcceleratorParamTest, MAYBE_TestSimpleDecode) {
for (size_t index = 0; index < num_concurrent_decoders; ++index) { for (size_t index = 0; index < num_concurrent_decoders; ++index) {
TestVideoFile* video_file = TestVideoFile* video_file =
test_video_files_[index % test_video_files_.size()].get(); test_video_files_[index % test_video_files_.size()].get();
std::unique_ptr<ClientStateNotification<ClientState>> note = std::unique_ptr<media::test::ClientStateNotification<ClientState>> note =
std::make_unique<ClientStateNotification<ClientState>>(); std::make_unique<media::test::ClientStateNotification<ClientState>>();
notes_[index] = std::move(note); notes_[index] = std::move(note);
size_t delay_reuse_after_frame_num = std::numeric_limits<size_t>::max(); size_t delay_reuse_after_frame_num = std::numeric_limits<size_t>::max();
...@@ -1274,7 +1275,7 @@ TEST_P(VideoDecodeAcceleratorParamTest, MAYBE_TestSimpleDecode) { ...@@ -1274,7 +1275,7 @@ TEST_P(VideoDecodeAcceleratorParamTest, MAYBE_TestSimpleDecode) {
// Only check performance & correctness later if we play through only once. // Only check performance & correctness later if we play through only once.
bool skip_performance_and_correctness_checks = num_play_throughs > 1; bool skip_performance_and_correctness_checks = num_play_throughs > 1;
for (size_t i = 0; i < num_concurrent_decoders; ++i) { for (size_t i = 0; i < num_concurrent_decoders; ++i) {
ClientStateNotification<ClientState>* note = notes_[i].get(); media::test::ClientStateNotification<ClientState>* note = notes_[i].get();
ClientState state = note->Wait(); ClientState state = note->Wait();
EXPECT_TRUE(delete_decoder_state != CS_DECODER_SET || EXPECT_TRUE(delete_decoder_state != CS_DECODER_SET ||
state == CS_DESTROYED); state == CS_DESTROYED);
...@@ -1597,7 +1598,8 @@ WRAPPED_INSTANTIATE_TEST_CASE_P( ...@@ -1597,7 +1598,8 @@ WRAPPED_INSTANTIATE_TEST_CASE_P(
// Measure the median of the decode time when VDA::Decode is called 30 times per // Measure the median of the decode time when VDA::Decode is called 30 times per
// second. // second.
TEST_F(VideoDecodeAcceleratorTest, TestDecodeTimeMedian) { TEST_F(VideoDecodeAcceleratorTest, TestDecodeTimeMedian) {
notes_.push_back(std::make_unique<ClientStateNotification<ClientState>>()); notes_.push_back(
std::make_unique<media::test::ClientStateNotification<ClientState>>());
const TestVideoFile* video_file = test_video_files_[0].get(); const TestVideoFile* video_file = test_video_files_[0].get();
GLRenderingVDAClient::Config config; GLRenderingVDAClient::Config config;
...@@ -1632,7 +1634,8 @@ TEST_F(VideoDecodeAcceleratorTest, TestDecodeTimeMedian) { ...@@ -1632,7 +1634,8 @@ TEST_F(VideoDecodeAcceleratorTest, TestDecodeTimeMedian) {
// is not considered as a failure because the input may be unsupported or // is not considered as a failure because the input may be unsupported or
// corrupted videos. // corrupted videos.
TEST_F(VideoDecodeAcceleratorTest, NoCrash) { TEST_F(VideoDecodeAcceleratorTest, NoCrash) {
notes_.push_back(std::make_unique<ClientStateNotification<ClientState>>()); notes_.push_back(
std::make_unique<media::test::ClientStateNotification<ClientState>>());
const TestVideoFile* video_file = test_video_files_[0].get(); const TestVideoFile* video_file = test_video_files_[0].get();
GLRenderingVDAClient::Config config; GLRenderingVDAClient::Config config;
...@@ -1662,7 +1665,8 @@ TEST_F(VideoDecodeAcceleratorTest, DISABLED_GenMD5) { ...@@ -1662,7 +1665,8 @@ TEST_F(VideoDecodeAcceleratorTest, DISABLED_GenMD5) {
g_test_import = true; g_test_import = true;
ASSERT_EQ(test_video_files_.size(), 1u); ASSERT_EQ(test_video_files_.size(), 1u);
notes_.push_back(std::make_unique<ClientStateNotification<ClientState>>()); notes_.push_back(
std::make_unique<media::test::ClientStateNotification<ClientState>>());
const TestVideoFile* video_file = test_video_files_[0].get(); const TestVideoFile* video_file = test_video_files_[0].get();
GLRenderingVDAClient::Config config; GLRenderingVDAClient::Config config;
config.frame_size = gfx::Size(video_file->width, video_file->height); config.frame_size = gfx::Size(video_file->width, video_file->height);
......
...@@ -1185,7 +1185,8 @@ class VEAClientBase : public VideoEncodeAccelerator::Client { ...@@ -1185,7 +1185,8 @@ class VEAClientBase : public VideoEncodeAccelerator::Client {
} }
protected: protected:
VEAClientBase(ClientStateNotification<ClientState>* note) explicit VEAClientBase(
media::test::ClientStateNotification<ClientState>* note)
: note_(note), next_output_buffer_id_(0) {} : note_(note), next_output_buffer_id_(0) {}
bool has_encoder() { return encoder_.get(); } bool has_encoder() { return encoder_.get(); }
...@@ -1196,7 +1197,7 @@ class VEAClientBase : public VideoEncodeAccelerator::Client { ...@@ -1196,7 +1197,7 @@ class VEAClientBase : public VideoEncodeAccelerator::Client {
// Used to notify another thread about the state. VEAClientBase does not own // Used to notify another thread about the state. VEAClientBase does not own
// this. // this.
ClientStateNotification<ClientState>* note_; media::test::ClientStateNotification<ClientState>* note_;
// All methods of this class should be run on the same thread. // All methods of this class should be run on the same thread.
base::ThreadChecker thread_checker_; base::ThreadChecker thread_checker_;
...@@ -1208,7 +1209,7 @@ class VEAClientBase : public VideoEncodeAccelerator::Client { ...@@ -1208,7 +1209,7 @@ class VEAClientBase : public VideoEncodeAccelerator::Client {
class VEAClient : public VEAClientBase { class VEAClient : public VEAClientBase {
public: public:
VEAClient(TestStream* test_stream, VEAClient(TestStream* test_stream,
ClientStateNotification<ClientState>* note, media::test::ClientStateNotification<ClientState>* note,
bool save_to_file, bool save_to_file,
unsigned int keyframe_period, unsigned int keyframe_period,
bool force_bitrate, bool force_bitrate,
...@@ -1418,7 +1419,7 @@ class VEAClient : public VEAClientBase { ...@@ -1418,7 +1419,7 @@ class VEAClient : public VEAClientBase {
}; };
VEAClient::VEAClient(TestStream* test_stream, VEAClient::VEAClient(TestStream* test_stream,
ClientStateNotification<ClientState>* note, media::test::ClientStateNotification<ClientState>* note,
bool save_to_file, bool save_to_file,
unsigned int keyframe_period, unsigned int keyframe_period,
bool force_bitrate, bool force_bitrate,
...@@ -2121,7 +2122,7 @@ class SimpleVEAClientBase : public VEAClientBase { ...@@ -2121,7 +2122,7 @@ class SimpleVEAClientBase : public VEAClientBase {
size_t output_buffer_size) override; size_t output_buffer_size) override;
protected: protected:
SimpleVEAClientBase(ClientStateNotification<ClientState>* note, SimpleVEAClientBase(media::test::ClientStateNotification<ClientState>* note,
const int width, const int width,
const int height); const int height);
...@@ -2137,7 +2138,7 @@ class SimpleVEAClientBase : public VEAClientBase { ...@@ -2137,7 +2138,7 @@ class SimpleVEAClientBase : public VEAClientBase {
}; };
SimpleVEAClientBase::SimpleVEAClientBase( SimpleVEAClientBase::SimpleVEAClientBase(
ClientStateNotification<ClientState>* note, media::test::ClientStateNotification<ClientState>* note,
const int width, const int width,
const int height) const int height)
: VEAClientBase(note), : VEAClientBase(note),
...@@ -2214,7 +2215,8 @@ void SimpleVEAClientBase::FeedEncoderWithOutput(base::SharedMemory* shm, ...@@ -2214,7 +2215,8 @@ void SimpleVEAClientBase::FeedEncoderWithOutput(base::SharedMemory* shm,
// frame before getting any input. // frame before getting any input.
class VEANoInputClient : public SimpleVEAClientBase { class VEANoInputClient : public SimpleVEAClientBase {
public: public:
explicit VEANoInputClient(ClientStateNotification<ClientState>* note); explicit VEANoInputClient(
media::test::ClientStateNotification<ClientState>* note);
void DestroyEncoder(); void DestroyEncoder();
// VideoDecodeAccelerator::Client implementation. // VideoDecodeAccelerator::Client implementation.
...@@ -2231,7 +2233,8 @@ class VEANoInputClient : public SimpleVEAClientBase { ...@@ -2231,7 +2233,8 @@ class VEANoInputClient : public SimpleVEAClientBase {
std::unique_ptr<base::OneShotTimer> timer_; std::unique_ptr<base::OneShotTimer> timer_;
}; };
VEANoInputClient::VEANoInputClient(ClientStateNotification<ClientState>* note) VEANoInputClient::VEANoInputClient(
media::test::ClientStateNotification<ClientState>* note)
: SimpleVEAClientBase(note, 320, 240) {} : SimpleVEAClientBase(note, 320, 240) {}
void VEANoInputClient::DestroyEncoder() { void VEANoInputClient::DestroyEncoder() {
...@@ -2269,7 +2272,7 @@ void VEANoInputClient::BitstreamBufferReady( ...@@ -2269,7 +2272,7 @@ void VEANoInputClient::BitstreamBufferReady(
class VEACacheLineUnalignedInputClient : public SimpleVEAClientBase { class VEACacheLineUnalignedInputClient : public SimpleVEAClientBase {
public: public:
explicit VEACacheLineUnalignedInputClient( explicit VEACacheLineUnalignedInputClient(
ClientStateNotification<ClientState>* note); media::test::ClientStateNotification<ClientState>* note);
// VideoDecodeAccelerator::Client implementation. // VideoDecodeAccelerator::Client implementation.
void RequireBitstreamBuffers(unsigned int input_count, void RequireBitstreamBuffers(unsigned int input_count,
...@@ -2285,7 +2288,7 @@ class VEACacheLineUnalignedInputClient : public SimpleVEAClientBase { ...@@ -2285,7 +2288,7 @@ class VEACacheLineUnalignedInputClient : public SimpleVEAClientBase {
}; };
VEACacheLineUnalignedInputClient::VEACacheLineUnalignedInputClient( VEACacheLineUnalignedInputClient::VEACacheLineUnalignedInputClient(
ClientStateNotification<ClientState>* note) media::test::ClientStateNotification<ClientState>* note)
: SimpleVEAClientBase(note, 368, 368) { : SimpleVEAClientBase(note, 368, 368) {
} // 368 is divisible by 16 but not 32 } // 368 is divisible by 16 but not 32
...@@ -2401,7 +2404,9 @@ TEST_P(VideoEncodeAcceleratorTest, TestSimpleEncode) { ...@@ -2401,7 +2404,9 @@ TEST_P(VideoEncodeAcceleratorTest, TestSimpleEncode) {
std::get<7>(GetParam()) || g_env->verify_all_output(); std::get<7>(GetParam()) || g_env->verify_all_output();
const bool verify_output_timestamp = std::get<8>(GetParam()); const bool verify_output_timestamp = std::get<8>(GetParam());
std::vector<std::unique_ptr<ClientStateNotification<ClientState>>> notes; std::vector<
std::unique_ptr<media::test::ClientStateNotification<ClientState>>>
notes;
std::vector<std::unique_ptr<VEAClient>> clients; std::vector<std::unique_ptr<VEAClient>> clients;
base::Thread vea_client_thread("EncoderClientThread"); base::Thread vea_client_thread("EncoderClientThread");
StartVEAThread(&vea_client_thread); StartVEAThread(&vea_client_thread);
...@@ -2426,7 +2431,8 @@ TEST_P(VideoEncodeAcceleratorTest, TestSimpleEncode) { ...@@ -2426,7 +2431,8 @@ TEST_P(VideoEncodeAcceleratorTest, TestSimpleEncode) {
(save_to_file && (save_to_file &&
!g_env->test_streams_[test_stream_index]->out_filename.empty()); !g_env->test_streams_[test_stream_index]->out_filename.empty());
notes.push_back(std::make_unique<ClientStateNotification<ClientState>>()); notes.push_back(
std::make_unique<media::test::ClientStateNotification<ClientState>>());
clients.push_back(std::make_unique<VEAClient>( clients.push_back(std::make_unique<VEAClient>(
g_env->test_streams_[test_stream_index].get(), notes.back().get(), g_env->test_streams_[test_stream_index].get(), notes.back().get(),
encoder_save_to_file, keyframe_period, force_bitrate, test_perf, encoder_save_to_file, keyframe_period, force_bitrate, test_perf,
...@@ -2478,8 +2484,8 @@ class VideoEncodeAcceleratorSimpleTest : public ::testing::TestWithParam<int> { ...@@ -2478,8 +2484,8 @@ class VideoEncodeAcceleratorSimpleTest : public ::testing::TestWithParam<int> {
template <class TestClient> template <class TestClient>
void SimpleTestFunc() { void SimpleTestFunc() {
std::unique_ptr<ClientStateNotification<ClientState>> note( std::unique_ptr<media::test::ClientStateNotification<ClientState>> note(
new ClientStateNotification<ClientState>()); new media::test::ClientStateNotification<ClientState>());
std::unique_ptr<TestClient> client(new TestClient(note.get())); std::unique_ptr<TestClient> client(new TestClient(note.get()));
base::Thread vea_client_thread("EncoderClientThread"); base::Thread vea_client_thread("EncoderClientThread");
ASSERT_TRUE(vea_client_thread.Start()); ASSERT_TRUE(vea_client_thread.Start());
......
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