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

Side by Side Diff: content/common/gpu/media/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 several more bot-identified build issues 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // This has to be included first.
6 // See http://code.google.com/p/googletest/issues/detail?id=371
7 #include "testing/gtest/include/gtest/gtest.h"
8
9 #include <stddef.h>
10 #include <stdint.h>
11 #include <string.h>
12
13 #include "base/at_exit.h"
14 #include "base/bind.h"
15 #include "base/command_line.h"
16 #include "base/files/file_util.h"
17 #include "base/logging.h"
18 #include "base/macros.h"
19 #include "base/memory/scoped_vector.h"
20 #include "base/path_service.h"
21 #include "base/strings/string_piece.h"
22 #include "base/strings/string_split.h"
23 #include "base/thread_task_runner_handle.h"
24 #include "build/build_config.h"
25 #include "content/common/gpu/media/video_accelerator_unittest_helpers.h"
26 #include "media/base/test_data_util.h"
27 #include "media/filters/jpeg_parser.h"
28 #include "media/video/jpeg_decode_accelerator.h"
29 #include "third_party/libyuv/include/libyuv.h"
30 #include "ui/gfx/codec/jpeg_codec.h"
31
32 #if defined(OS_CHROMEOS)
33 #if defined(USE_V4L2_CODEC)
34 #include "content/common/gpu/media/v4l2_device.h"
35 #include "content/common/gpu/media/v4l2_jpeg_decode_accelerator.h"
36 #endif
37 #if defined(ARCH_CPU_X86_FAMILY)
38 #include "content/common/gpu/media/vaapi_jpeg_decode_accelerator.h"
39 #include "content/common/gpu/media/vaapi_wrapper.h"
40 #endif
41 #endif
42
43 using media::JpegDecodeAccelerator;
44
45 namespace content {
46 namespace {
47
48 // Default test image file.
49 const base::FilePath::CharType* kDefaultJpegFilename =
50 FILE_PATH_LITERAL("peach_pi-1280x720.jpg");
51 // Decide to save decode results to files or not. Output files will be saved
52 // in the same directory with unittest. File name is like input file but
53 // changing the extension to "yuv".
54 bool g_save_to_file = false;
55 // Threshold for mean absolute difference of hardware and software decode.
56 // Absolute difference is to calculate the difference between each pixel in two
57 // images. This is used for measuring of the similarity of two images.
58 const double kDecodeSimilarityThreshold = 1.0;
59
60 // Environment to create test data for all test cases.
61 class JpegDecodeAcceleratorTestEnvironment;
62 JpegDecodeAcceleratorTestEnvironment* g_env;
63
64 struct TestImageFile {
65 explicit TestImageFile(const base::FilePath::StringType& filename)
66 : filename(filename) {}
67
68 base::FilePath::StringType filename;
69
70 // The input content of |filename|.
71 std::string data_str;
72
73 media::JpegParseResult parse_result;
74 gfx::Size visible_size;
75 size_t output_size;
76 };
77
78 enum ClientState {
79 CS_CREATED,
80 CS_INITIALIZED,
81 CS_DECODE_PASS,
82 CS_ERROR,
83 };
84
85 class JpegClient : public JpegDecodeAccelerator::Client {
86 public:
87 JpegClient(const std::vector<TestImageFile*>& test_image_files,
88 ClientStateNotification<ClientState>* note);
89 ~JpegClient() override;
90 void CreateJpegDecoder();
91 void DestroyJpegDecoder();
92 void StartDecode(int32_t bitstream_buffer_id);
93
94 // JpegDecodeAccelerator::Client implementation.
95 void VideoFrameReady(int32_t bitstream_buffer_id) override;
96 void NotifyError(int32_t bitstream_buffer_id,
97 JpegDecodeAccelerator::Error error) override;
98
99 private:
100 void PrepareMemory(int32_t bitstream_buffer_id);
101 void SetState(ClientState new_state);
102 void SaveToFile(int32_t bitstream_buffer_id);
103 bool GetSoftwareDecodeResult(int32_t bitstream_buffer_id);
104
105 // Calculate mean absolute difference of hardware and software decode results
106 // to check the similarity.
107 double GetMeanAbsoluteDifference(int32_t bitstream_buffer_id);
108
109 // JpegClient doesn't own |test_image_files_|.
110 const std::vector<TestImageFile*>& test_image_files_;
111
112 std::unique_ptr<JpegDecodeAccelerator> decoder_;
113 ClientState state_;
114
115 // Used to notify another thread about the state. JpegClient does not own
116 // this.
117 ClientStateNotification<ClientState>* note_;
118
119 // Mapped memory of input file.
120 std::unique_ptr<base::SharedMemory> in_shm_;
121 // Mapped memory of output buffer from hardware decoder.
122 std::unique_ptr<base::SharedMemory> hw_out_shm_;
123 // Mapped memory of output buffer from software decoder.
124 std::unique_ptr<base::SharedMemory> sw_out_shm_;
125
126 DISALLOW_COPY_AND_ASSIGN(JpegClient);
127 };
128
129 JpegClient::JpegClient(const std::vector<TestImageFile*>& test_image_files,
130 ClientStateNotification<ClientState>* note)
131 : test_image_files_(test_image_files), state_(CS_CREATED), note_(note) {
132 }
133
134 JpegClient::~JpegClient() {
135 }
136
137 void JpegClient::CreateJpegDecoder() {
138 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)
139 decoder_.reset(
140 new VaapiJpegDecodeAccelerator(base::ThreadTaskRunnerHandle::Get()));
141 #elif defined(OS_CHROMEOS) && defined(USE_V4L2_CODEC)
142 scoped_refptr<V4L2Device> device =
143 V4L2Device::Create(V4L2Device::kJpegDecoder);
144 if (!device.get()) {
145 LOG(ERROR) << "V4L2Device::Create failed";
146 SetState(CS_ERROR);
147 return;
148 }
149 decoder_.reset(new V4L2JpegDecodeAccelerator(
150 device, base::ThreadTaskRunnerHandle::Get()));
151 #else
152 #error The JpegDecodeAccelerator is not supported on this platform.
153 #endif
154 if (!decoder_->Initialize(this)) {
155 LOG(ERROR) << "JpegDecodeAccelerator::Initialize() failed";
156 SetState(CS_ERROR);
157 return;
158 }
159 SetState(CS_INITIALIZED);
160 }
161
162 void JpegClient::DestroyJpegDecoder() {
163 decoder_.reset();
164 }
165
166 void JpegClient::VideoFrameReady(int32_t bitstream_buffer_id) {
167 if (!GetSoftwareDecodeResult(bitstream_buffer_id)) {
168 SetState(CS_ERROR);
169 return;
170 }
171 if (g_save_to_file) {
172 SaveToFile(bitstream_buffer_id);
173 }
174
175 double difference = GetMeanAbsoluteDifference(bitstream_buffer_id);
176 if (difference <= kDecodeSimilarityThreshold) {
177 SetState(CS_DECODE_PASS);
178 } else {
179 LOG(ERROR) << "The mean absolute difference between software and hardware "
180 "decode is " << difference;
181 SetState(CS_ERROR);
182 }
183 }
184
185 void JpegClient::NotifyError(int32_t bitstream_buffer_id,
186 JpegDecodeAccelerator::Error error) {
187 LOG(ERROR) << "Notifying of error " << error << " for buffer id "
188 << bitstream_buffer_id;
189 SetState(CS_ERROR);
190 }
191
192 void JpegClient::PrepareMemory(int32_t bitstream_buffer_id) {
193 TestImageFile* image_file = test_image_files_[bitstream_buffer_id];
194
195 size_t input_size = image_file->data_str.size();
196 if (!in_shm_.get() || input_size > in_shm_->mapped_size()) {
197 in_shm_.reset(new base::SharedMemory);
198 LOG_ASSERT(in_shm_->CreateAndMapAnonymous(input_size));
199 }
200 memcpy(in_shm_->memory(), image_file->data_str.data(), input_size);
201
202 if (!hw_out_shm_.get() ||
203 image_file->output_size > hw_out_shm_->mapped_size()) {
204 hw_out_shm_.reset(new base::SharedMemory);
205 LOG_ASSERT(hw_out_shm_->CreateAndMapAnonymous(image_file->output_size));
206 }
207 memset(hw_out_shm_->memory(), 0, image_file->output_size);
208
209 if (!sw_out_shm_.get() ||
210 image_file->output_size > sw_out_shm_->mapped_size()) {
211 sw_out_shm_.reset(new base::SharedMemory);
212 LOG_ASSERT(sw_out_shm_->CreateAndMapAnonymous(image_file->output_size));
213 }
214 memset(sw_out_shm_->memory(), 0, image_file->output_size);
215 }
216
217 void JpegClient::SetState(ClientState new_state) {
218 DVLOG(2) << "Changing state " << state_ << "->" << new_state;
219 note_->Notify(new_state);
220 state_ = new_state;
221 }
222
223 void JpegClient::SaveToFile(int32_t bitstream_buffer_id) {
224 TestImageFile* image_file = test_image_files_[bitstream_buffer_id];
225
226 base::FilePath in_filename(image_file->filename);
227 base::FilePath out_filename = in_filename.ReplaceExtension(".yuv");
228 int size = base::checked_cast<int>(image_file->output_size);
229 ASSERT_EQ(size,
230 base::WriteFile(out_filename,
231 static_cast<char*>(hw_out_shm_->memory()), size));
232 }
233
234 double JpegClient::GetMeanAbsoluteDifference(int32_t bitstream_buffer_id) {
235 TestImageFile* image_file = test_image_files_[bitstream_buffer_id];
236
237 double total_difference = 0;
238 uint8_t* hw_ptr = static_cast<uint8_t*>(hw_out_shm_->memory());
239 uint8_t* sw_ptr = static_cast<uint8_t*>(sw_out_shm_->memory());
240 for (size_t i = 0; i < image_file->output_size; i++)
241 total_difference += std::abs(hw_ptr[i] - sw_ptr[i]);
242 return total_difference / image_file->output_size;
243 }
244
245 void JpegClient::StartDecode(int32_t bitstream_buffer_id) {
246 DCHECK_LT(static_cast<size_t>(bitstream_buffer_id), test_image_files_.size());
247 TestImageFile* image_file = test_image_files_[bitstream_buffer_id];
248
249 PrepareMemory(bitstream_buffer_id);
250
251 base::SharedMemoryHandle dup_handle;
252 dup_handle = base::SharedMemory::DuplicateHandle(in_shm_->handle());
253 media::BitstreamBuffer bitstream_buffer(bitstream_buffer_id, dup_handle,
254 image_file->data_str.size());
255 scoped_refptr<media::VideoFrame> out_frame_ =
256 media::VideoFrame::WrapExternalSharedMemory(
257 media::PIXEL_FORMAT_I420,
258 image_file->visible_size,
259 gfx::Rect(image_file->visible_size),
260 image_file->visible_size,
261 static_cast<uint8_t*>(hw_out_shm_->memory()),
262 image_file->output_size,
263 hw_out_shm_->handle(),
264 0,
265 base::TimeDelta());
266 LOG_ASSERT(out_frame_.get());
267 decoder_->Decode(bitstream_buffer, out_frame_);
268 }
269
270 bool JpegClient::GetSoftwareDecodeResult(int32_t bitstream_buffer_id) {
271 media::VideoPixelFormat format = media::PIXEL_FORMAT_I420;
272 TestImageFile* image_file = test_image_files_[bitstream_buffer_id];
273
274 uint8_t* yplane = static_cast<uint8_t*>(sw_out_shm_->memory());
275 uint8_t* uplane =
276 yplane +
277 media::VideoFrame::PlaneSize(format, media::VideoFrame::kYPlane,
278 image_file->visible_size).GetArea();
279 uint8_t* vplane =
280 uplane +
281 media::VideoFrame::PlaneSize(format, media::VideoFrame::kUPlane,
282 image_file->visible_size).GetArea();
283 int yplane_stride = image_file->visible_size.width();
284 int uv_plane_stride = yplane_stride / 2;
285
286 if (libyuv::ConvertToI420(
287 static_cast<uint8_t*>(in_shm_->memory()),
288 image_file->data_str.size(),
289 yplane,
290 yplane_stride,
291 uplane,
292 uv_plane_stride,
293 vplane,
294 uv_plane_stride,
295 0,
296 0,
297 image_file->visible_size.width(),
298 image_file->visible_size.height(),
299 image_file->visible_size.width(),
300 image_file->visible_size.height(),
301 libyuv::kRotate0,
302 libyuv::FOURCC_MJPG) != 0) {
303 LOG(ERROR) << "Software decode " << image_file->filename << " failed.";
304 return false;
305 }
306 return true;
307 }
308
309 class JpegDecodeAcceleratorTestEnvironment : public ::testing::Environment {
310 public:
311 JpegDecodeAcceleratorTestEnvironment(
312 const base::FilePath::CharType* jpeg_filenames) {
313 user_jpeg_filenames_ =
314 jpeg_filenames ? jpeg_filenames: kDefaultJpegFilename;
315 }
316 void SetUp() override;
317 void TearDown() override;
318
319 // Create all black test image with |width| and |height| size.
320 bool CreateTestJpegImage(int width, int height, base::FilePath* filename);
321
322 // Read image from |filename| to |image_data|.
323 void ReadTestJpegImage(base::FilePath& filename, TestImageFile* image_data);
324
325 // Parsed data of |test_1280x720_jpeg_file_|.
326 std::unique_ptr<TestImageFile> image_data_1280x720_black_;
327 // Parsed data of |test_640x368_jpeg_file_|.
328 std::unique_ptr<TestImageFile> image_data_640x368_black_;
329 // Parsed data of |test_640x360_jpeg_file_|.
330 std::unique_ptr<TestImageFile> image_data_640x360_black_;
331 // Parsed data of "peach_pi-1280x720.jpg".
332 std::unique_ptr<TestImageFile> image_data_1280x720_default_;
333 // Parsed data of failure image.
334 std::unique_ptr<TestImageFile> image_data_invalid_;
335 // Parsed data from command line.
336 ScopedVector<TestImageFile> image_data_user_;
337
338 private:
339 const base::FilePath::CharType* user_jpeg_filenames_;
340
341 // Used for InputSizeChange test case. The image size should be smaller than
342 // |kDefaultJpegFilename|.
343 base::FilePath test_1280x720_jpeg_file_;
344 // Used for ResolutionChange test case.
345 base::FilePath test_640x368_jpeg_file_;
346 // Used for testing some drivers which will align the output resolution to a
347 // multiple of 16. 640x360 will be aligned to 640x368.
348 base::FilePath test_640x360_jpeg_file_;
349 };
350
351 void JpegDecodeAcceleratorTestEnvironment::SetUp() {
352 ASSERT_TRUE(CreateTestJpegImage(1280, 720, &test_1280x720_jpeg_file_));
353 ASSERT_TRUE(CreateTestJpegImage(640, 368, &test_640x368_jpeg_file_));
354 ASSERT_TRUE(CreateTestJpegImage(640, 360, &test_640x360_jpeg_file_));
355
356 image_data_1280x720_black_.reset(
357 new TestImageFile(test_1280x720_jpeg_file_.value()));
358 ASSERT_NO_FATAL_FAILURE(ReadTestJpegImage(test_1280x720_jpeg_file_,
359 image_data_1280x720_black_.get()));
360
361 image_data_640x368_black_.reset(
362 new TestImageFile(test_640x368_jpeg_file_.value()));
363 ASSERT_NO_FATAL_FAILURE(ReadTestJpegImage(test_640x368_jpeg_file_,
364 image_data_640x368_black_.get()));
365
366 image_data_640x360_black_.reset(
367 new TestImageFile(test_640x360_jpeg_file_.value()));
368 ASSERT_NO_FATAL_FAILURE(ReadTestJpegImage(test_640x360_jpeg_file_,
369 image_data_640x360_black_.get()));
370
371 base::FilePath default_jpeg_file =
372 media::GetTestDataFilePath(kDefaultJpegFilename);
373 image_data_1280x720_default_.reset(new TestImageFile(kDefaultJpegFilename));
374 ASSERT_NO_FATAL_FAILURE(
375 ReadTestJpegImage(default_jpeg_file, image_data_1280x720_default_.get()));
376
377 image_data_invalid_.reset(new TestImageFile("failure.jpg"));
378 image_data_invalid_->data_str.resize(100, 0);
379 image_data_invalid_->visible_size.SetSize(1280, 720);
380 image_data_invalid_->output_size = media::VideoFrame::AllocationSize(
381 media::PIXEL_FORMAT_I420, image_data_invalid_->visible_size);
382
383 // |user_jpeg_filenames_| may include many files and use ';' as delimiter.
384 std::vector<base::FilePath::StringType> filenames = base::SplitString(
385 user_jpeg_filenames_, base::FilePath::StringType(1, ';'),
386 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
387 for (const auto& filename : filenames) {
388 base::FilePath input_file = media::GetTestDataFilePath(filename);
389 TestImageFile* image_data = new TestImageFile(filename);
390 ASSERT_NO_FATAL_FAILURE(ReadTestJpegImage(input_file, image_data));
391 image_data_user_.push_back(image_data);
392 }
393 }
394
395 void JpegDecodeAcceleratorTestEnvironment::TearDown() {
396 base::DeleteFile(test_1280x720_jpeg_file_, false);
397 base::DeleteFile(test_640x368_jpeg_file_, false);
398 base::DeleteFile(test_640x360_jpeg_file_, false);
399 }
400
401 bool JpegDecodeAcceleratorTestEnvironment::CreateTestJpegImage(
402 int width,
403 int height,
404 base::FilePath* filename) {
405 const int kBytesPerPixel = 3;
406 const int kJpegQuality = 100;
407 std::vector<unsigned char> input_buffer(width * height * kBytesPerPixel);
408 std::vector<unsigned char> encoded;
409 if (!gfx::JPEGCodec::Encode(&input_buffer[0], gfx::JPEGCodec::FORMAT_RGB,
410 width, height, width * kBytesPerPixel,
411 kJpegQuality, &encoded)) {
412 return false;
413 }
414
415 LOG_ASSERT(base::CreateTemporaryFile(filename));
416 EXPECT_TRUE(base::AppendToFile(
417 *filename, reinterpret_cast<char*>(&encoded[0]), encoded.size()));
418 return true;
419 }
420
421 void JpegDecodeAcceleratorTestEnvironment::ReadTestJpegImage(
422 base::FilePath& input_file, TestImageFile* image_data) {
423 ASSERT_TRUE(base::ReadFileToString(input_file, &image_data->data_str));
424
425 ASSERT_TRUE(media::ParseJpegPicture(
426 reinterpret_cast<const uint8_t*>(image_data->data_str.data()),
427 image_data->data_str.size(),
428 &image_data->parse_result));
429 image_data->visible_size.SetSize(
430 image_data->parse_result.frame_header.visible_width,
431 image_data->parse_result.frame_header.visible_height);
432 image_data->output_size = media::VideoFrame::AllocationSize(
433 media::PIXEL_FORMAT_I420, image_data->visible_size);
434 }
435
436 class JpegDecodeAcceleratorTest : public ::testing::Test {
437 protected:
438 JpegDecodeAcceleratorTest() {}
439
440 void TestDecode(size_t num_concurrent_decoders);
441
442 // The elements of |test_image_files_| are owned by
443 // JpegDecodeAcceleratorTestEnvironment.
444 std::vector<TestImageFile*> test_image_files_;
445 std::vector<ClientState> expected_status_;
446
447 protected:
448 DISALLOW_COPY_AND_ASSIGN(JpegDecodeAcceleratorTest);
449 };
450
451 void JpegDecodeAcceleratorTest::TestDecode(size_t num_concurrent_decoders) {
452 LOG_ASSERT(test_image_files_.size() == expected_status_.size());
453 base::Thread decoder_thread("DecoderThread");
454 ASSERT_TRUE(decoder_thread.Start());
455
456 ScopedVector<ClientStateNotification<ClientState>> notes;
457 ScopedVector<JpegClient> clients;
458
459 for (size_t i = 0; i < num_concurrent_decoders; i++) {
460 notes.push_back(new ClientStateNotification<ClientState>());
461 clients.push_back(new JpegClient(test_image_files_, notes.back()));
462 decoder_thread.task_runner()->PostTask(
463 FROM_HERE, base::Bind(&JpegClient::CreateJpegDecoder,
464 base::Unretained(clients.back())));
465 ASSERT_EQ(notes[i]->Wait(), CS_INITIALIZED);
466 }
467
468 for (size_t index = 0; index < test_image_files_.size(); index++) {
469 for (size_t i = 0; i < num_concurrent_decoders; i++) {
470 decoder_thread.task_runner()->PostTask(
471 FROM_HERE, base::Bind(&JpegClient::StartDecode,
472 base::Unretained(clients[i]),
473 index));
474 }
475 for (size_t i = 0; i < num_concurrent_decoders; i++) {
476 ASSERT_EQ(notes[i]->Wait(), expected_status_[index]);
477 }
478 }
479
480 for (size_t i = 0; i < num_concurrent_decoders; i++) {
481 decoder_thread.task_runner()->PostTask(
482 FROM_HERE, base::Bind(&JpegClient::DestroyJpegDecoder,
483 base::Unretained(clients[i])));
484 }
485 decoder_thread.Stop();
486 }
487
488 TEST_F(JpegDecodeAcceleratorTest, SimpleDecode) {
489 for (const auto& image : g_env->image_data_user_) {
490 test_image_files_.push_back(image);
491 expected_status_.push_back(CS_DECODE_PASS);
492 }
493 TestDecode(1);
494 }
495
496 TEST_F(JpegDecodeAcceleratorTest, MultipleDecoders) {
497 for (const auto& image : g_env->image_data_user_) {
498 test_image_files_.push_back(image);
499 expected_status_.push_back(CS_DECODE_PASS);
500 }
501 TestDecode(3);
502 }
503
504 TEST_F(JpegDecodeAcceleratorTest, InputSizeChange) {
505 // The size of |image_data_1280x720_black_| is smaller than
506 // |image_data_1280x720_default_|.
507 test_image_files_.push_back(g_env->image_data_1280x720_black_.get());
508 test_image_files_.push_back(g_env->image_data_1280x720_default_.get());
509 test_image_files_.push_back(g_env->image_data_1280x720_black_.get());
510 for (size_t i = 0; i < test_image_files_.size(); i++)
511 expected_status_.push_back(CS_DECODE_PASS);
512 TestDecode(1);
513 }
514
515 TEST_F(JpegDecodeAcceleratorTest, ResolutionChange) {
516 test_image_files_.push_back(g_env->image_data_640x368_black_.get());
517 test_image_files_.push_back(g_env->image_data_1280x720_default_.get());
518 test_image_files_.push_back(g_env->image_data_640x368_black_.get());
519 for (size_t i = 0; i < test_image_files_.size(); i++)
520 expected_status_.push_back(CS_DECODE_PASS);
521 TestDecode(1);
522 }
523
524 TEST_F(JpegDecodeAcceleratorTest, CodedSizeAlignment) {
525 test_image_files_.push_back(g_env->image_data_640x360_black_.get());
526 expected_status_.push_back(CS_DECODE_PASS);
527 TestDecode(1);
528 }
529
530 TEST_F(JpegDecodeAcceleratorTest, FailureJpeg) {
531 test_image_files_.push_back(g_env->image_data_invalid_.get());
532 expected_status_.push_back(CS_ERROR);
533 TestDecode(1);
534 }
535
536 TEST_F(JpegDecodeAcceleratorTest, KeepDecodeAfterFailure) {
537 test_image_files_.push_back(g_env->image_data_invalid_.get());
538 test_image_files_.push_back(g_env->image_data_1280x720_default_.get());
539 expected_status_.push_back(CS_ERROR);
540 expected_status_.push_back(CS_DECODE_PASS);
541 TestDecode(1);
542 }
543
544 } // namespace
545 } // namespace content
546
547 int main(int argc, char** argv) {
548 testing::InitGoogleTest(&argc, argv);
549 base::CommandLine::Init(argc, argv);
550 base::ShadowingAtExitManager at_exit_manager;
551
552 // Needed to enable DVLOG through --vmodule.
553 logging::LoggingSettings settings;
554 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
555 LOG_ASSERT(logging::InitLogging(settings));
556
557 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess();
558 DCHECK(cmd_line);
559
560 const base::FilePath::CharType* jpeg_filenames = nullptr;
561 base::CommandLine::SwitchMap switches = cmd_line->GetSwitches();
562 for (base::CommandLine::SwitchMap::const_iterator it = switches.begin();
563 it != switches.end(); ++it) {
564 // jpeg_filenames can include one or many files and use ';' as delimiter.
565 if (it->first == "jpeg_filenames") {
566 jpeg_filenames = it->second.c_str();
567 continue;
568 }
569 if (it->first == "save_to_file") {
570 content::g_save_to_file = true;
571 continue;
572 }
573 if (it->first == "v" || it->first == "vmodule")
574 continue;
575 LOG(FATAL) << "Unexpected switch: " << it->first << ":" << it->second;
576 }
577 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)
578 content::VaapiWrapper::PreSandboxInitialization();
579 #endif
580
581 content::g_env =
582 reinterpret_cast<content::JpegDecodeAcceleratorTestEnvironment*>(
583 testing::AddGlobalTestEnvironment(
584 new content::JpegDecodeAcceleratorTestEnvironment(
585 jpeg_filenames)));
586
587 return RUN_ALL_TESTS();
588 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698