| Index: media/gpu/jpeg_decode_accelerator_unittest.cc
|
| diff --git a/content/common/gpu/media/jpeg_decode_accelerator_unittest.cc b/media/gpu/jpeg_decode_accelerator_unittest.cc
|
| similarity index 90%
|
| rename from content/common/gpu/media/jpeg_decode_accelerator_unittest.cc
|
| rename to media/gpu/jpeg_decode_accelerator_unittest.cc
|
| index d8723210b8782ff533a024cd167ca91ec2f91d14..dc8757ae16f016f7bbc3fa15bb8723336821eb45 100644
|
| --- a/content/common/gpu/media/jpeg_decode_accelerator_unittest.cc
|
| +++ b/media/gpu/jpeg_decode_accelerator_unittest.cc
|
| @@ -24,27 +24,27 @@
|
| #include "base/strings/string_split.h"
|
| #include "base/thread_task_runner_handle.h"
|
| #include "build/build_config.h"
|
| -#include "content/common/gpu/media/video_accelerator_unittest_helpers.h"
|
| #include "media/base/test_data_util.h"
|
| #include "media/filters/jpeg_parser.h"
|
| +#include "media/gpu/video_accelerator_unittest_helpers.h"
|
| #include "media/video/jpeg_decode_accelerator.h"
|
| #include "third_party/libyuv/include/libyuv.h"
|
| #include "ui/gfx/codec/jpeg_codec.h"
|
|
|
| #if defined(OS_CHROMEOS)
|
| #if defined(USE_V4L2_CODEC)
|
| -#include "content/common/gpu/media/v4l2_device.h"
|
| -#include "content/common/gpu/media/v4l2_jpeg_decode_accelerator.h"
|
| +#include "media/gpu/v4l2_device.h"
|
| +#include "media/gpu/v4l2_jpeg_decode_accelerator.h"
|
| #endif
|
| #if defined(ARCH_CPU_X86_FAMILY)
|
| -#include "content/common/gpu/media/vaapi_jpeg_decode_accelerator.h"
|
| -#include "content/common/gpu/media/vaapi_wrapper.h"
|
| +#include "media/gpu/vaapi_jpeg_decode_accelerator.h"
|
| +#include "media/gpu/vaapi_wrapper.h"
|
| #endif
|
| #endif
|
|
|
| using media::JpegDecodeAccelerator;
|
|
|
| -namespace content {
|
| +namespace media {
|
| namespace {
|
|
|
| // Default test image file.
|
| @@ -130,11 +130,9 @@ class JpegClient : public JpegDecodeAccelerator::Client {
|
|
|
| JpegClient::JpegClient(const std::vector<TestImageFile*>& test_image_files,
|
| ClientStateNotification<ClientState>* note)
|
| - : test_image_files_(test_image_files), state_(CS_CREATED), note_(note) {
|
| -}
|
| + : test_image_files_(test_image_files), state_(CS_CREATED), note_(note) {}
|
|
|
| -JpegClient::~JpegClient() {
|
| -}
|
| +JpegClient::~JpegClient() {}
|
|
|
| void JpegClient::CreateJpegDecoder() {
|
| #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)
|
| @@ -179,7 +177,8 @@ void JpegClient::VideoFrameReady(int32_t bitstream_buffer_id) {
|
| SetState(CS_DECODE_PASS);
|
| } else {
|
| LOG(ERROR) << "The mean absolute difference between software and hardware "
|
| - "decode is " << difference;
|
| + "decode is "
|
| + << difference;
|
| SetState(CS_ERROR);
|
| }
|
| }
|
| @@ -256,15 +255,10 @@ void JpegClient::StartDecode(int32_t bitstream_buffer_id) {
|
| image_file->data_str.size());
|
| scoped_refptr<media::VideoFrame> out_frame_ =
|
| media::VideoFrame::WrapExternalSharedMemory(
|
| - media::PIXEL_FORMAT_I420,
|
| - image_file->visible_size,
|
| - gfx::Rect(image_file->visible_size),
|
| - image_file->visible_size,
|
| - static_cast<uint8_t*>(hw_out_shm_->memory()),
|
| - image_file->output_size,
|
| - hw_out_shm_->handle(),
|
| - 0,
|
| - base::TimeDelta());
|
| + media::PIXEL_FORMAT_I420, image_file->visible_size,
|
| + gfx::Rect(image_file->visible_size), image_file->visible_size,
|
| + static_cast<uint8_t*>(hw_out_shm_->memory()), image_file->output_size,
|
| + hw_out_shm_->handle(), 0, base::TimeDelta());
|
| LOG_ASSERT(out_frame_.get());
|
| decoder_->Decode(bitstream_buffer, out_frame_);
|
| }
|
| @@ -277,30 +271,22 @@ bool JpegClient::GetSoftwareDecodeResult(int32_t bitstream_buffer_id) {
|
| uint8_t* uplane =
|
| yplane +
|
| media::VideoFrame::PlaneSize(format, media::VideoFrame::kYPlane,
|
| - image_file->visible_size).GetArea();
|
| + image_file->visible_size)
|
| + .GetArea();
|
| uint8_t* vplane =
|
| uplane +
|
| media::VideoFrame::PlaneSize(format, media::VideoFrame::kUPlane,
|
| - image_file->visible_size).GetArea();
|
| + image_file->visible_size)
|
| + .GetArea();
|
| int yplane_stride = image_file->visible_size.width();
|
| int uv_plane_stride = yplane_stride / 2;
|
|
|
| if (libyuv::ConvertToI420(
|
| - static_cast<uint8_t*>(in_shm_->memory()),
|
| - image_file->data_str.size(),
|
| - yplane,
|
| - yplane_stride,
|
| - uplane,
|
| - uv_plane_stride,
|
| - vplane,
|
| - uv_plane_stride,
|
| - 0,
|
| - 0,
|
| - image_file->visible_size.width(),
|
| - image_file->visible_size.height(),
|
| - image_file->visible_size.width(),
|
| - image_file->visible_size.height(),
|
| - libyuv::kRotate0,
|
| + static_cast<uint8_t*>(in_shm_->memory()), image_file->data_str.size(),
|
| + yplane, yplane_stride, uplane, uv_plane_stride, vplane,
|
| + uv_plane_stride, 0, 0, image_file->visible_size.width(),
|
| + image_file->visible_size.height(), image_file->visible_size.width(),
|
| + image_file->visible_size.height(), libyuv::kRotate0,
|
| libyuv::FOURCC_MJPG) != 0) {
|
| LOG(ERROR) << "Software decode " << image_file->filename << " failed.";
|
| return false;
|
| @@ -313,7 +299,7 @@ class JpegDecodeAcceleratorTestEnvironment : public ::testing::Environment {
|
| JpegDecodeAcceleratorTestEnvironment(
|
| const base::FilePath::CharType* jpeg_filenames) {
|
| user_jpeg_filenames_ =
|
| - jpeg_filenames ? jpeg_filenames: kDefaultJpegFilename;
|
| + jpeg_filenames ? jpeg_filenames : kDefaultJpegFilename;
|
| }
|
| void SetUp() override;
|
| void TearDown() override;
|
| @@ -421,13 +407,13 @@ bool JpegDecodeAcceleratorTestEnvironment::CreateTestJpegImage(
|
| }
|
|
|
| void JpegDecodeAcceleratorTestEnvironment::ReadTestJpegImage(
|
| - base::FilePath& input_file, TestImageFile* image_data) {
|
| + base::FilePath& input_file,
|
| + TestImageFile* image_data) {
|
| ASSERT_TRUE(base::ReadFileToString(input_file, &image_data->data_str));
|
|
|
| ASSERT_TRUE(media::ParseJpegPicture(
|
| reinterpret_cast<const uint8_t*>(image_data->data_str.data()),
|
| - image_data->data_str.size(),
|
| - &image_data->parse_result));
|
| + image_data->data_str.size(), &image_data->parse_result));
|
| image_data->visible_size.SetSize(
|
| image_data->parse_result.frame_header.visible_width,
|
| image_data->parse_result.frame_header.visible_height);
|
| @@ -471,8 +457,7 @@ void JpegDecodeAcceleratorTest::TestDecode(size_t num_concurrent_decoders) {
|
| for (size_t i = 0; i < num_concurrent_decoders; i++) {
|
| decoder_thread.task_runner()->PostTask(
|
| FROM_HERE, base::Bind(&JpegClient::StartDecode,
|
| - base::Unretained(clients[i]),
|
| - index));
|
| + base::Unretained(clients[i]), index));
|
| }
|
| for (size_t i = 0; i < num_concurrent_decoders; i++) {
|
| ASSERT_EQ(notes[i]->Wait(), expected_status_[index]);
|
| @@ -544,7 +529,7 @@ TEST_F(JpegDecodeAcceleratorTest, KeepDecodeAfterFailure) {
|
| }
|
|
|
| } // namespace
|
| -} // namespace content
|
| +} // namespace media
|
|
|
| int main(int argc, char** argv) {
|
| testing::InitGoogleTest(&argc, argv);
|
| @@ -569,7 +554,7 @@ int main(int argc, char** argv) {
|
| continue;
|
| }
|
| if (it->first == "save_to_file") {
|
| - content::g_save_to_file = true;
|
| + media::g_save_to_file = true;
|
| continue;
|
| }
|
| if (it->first == "v" || it->first == "vmodule")
|
| @@ -577,14 +562,12 @@ int main(int argc, char** argv) {
|
| LOG(FATAL) << "Unexpected switch: " << it->first << ":" << it->second;
|
| }
|
| #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)
|
| - content::VaapiWrapper::PreSandboxInitialization();
|
| + media::VaapiWrapper::PreSandboxInitialization();
|
| #endif
|
|
|
| - content::g_env =
|
| - reinterpret_cast<content::JpegDecodeAcceleratorTestEnvironment*>(
|
| - testing::AddGlobalTestEnvironment(
|
| - new content::JpegDecodeAcceleratorTestEnvironment(
|
| - jpeg_filenames)));
|
| + media::g_env = reinterpret_cast<media::JpegDecodeAcceleratorTestEnvironment*>(
|
| + testing::AddGlobalTestEnvironment(
|
| + new media::JpegDecodeAcceleratorTestEnvironment(jpeg_filenames)));
|
|
|
| return RUN_ALL_TESTS();
|
| }
|
|
|