Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(448)

Unified Diff: media/gpu/jpeg_decode_accelerator_unittest.cc

Issue 1882373004: Migrate content/common/gpu/media code to media/gpu (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix prefix to content references in content_gpu.gypi Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 53bc5d1cf50985d93001469fca0b403493030151..1b7e0acf71f74de00e91bd30852a2cc19c4ebd6e 100644
--- a/content/common/gpu/media/jpeg_decode_accelerator_unittest.cc
+++ b/media/gpu/jpeg_decode_accelerator_unittest.cc
@@ -22,27 +22,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.
@@ -128,11 +128,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)
@@ -177,7 +175,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);
}
}
@@ -254,15 +253,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_);
}
@@ -275,30 +269,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;
@@ -311,7 +297,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;
@@ -419,13 +405,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);
@@ -469,8 +455,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]);
@@ -542,7 +527,7 @@ TEST_F(JpegDecodeAcceleratorTest, KeepDecodeAfterFailure) {
}
} // namespace
-} // namespace content
+} // namespace media
int main(int argc, char** argv) {
testing::InitGoogleTest(&argc, argv);
@@ -567,7 +552,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")
@@ -575,14 +560,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();
}

Powered by Google App Engine
This is Rietveld 408576698