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

Side by Side Diff: content/common/gpu/media/video_decode_accelerator_unittest.cc

Issue 490233002: VaapiVideoAccelerator: make Vaapi accelerator work with ozone (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Don't limit h264_bitstream_buffer_unittest to x11 Created 6 years, 3 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 // 4 //
5 // The bulk of this file is support code; sorry about that. Here's an overview 5 // The bulk of this file is support code; sorry about that. Here's an overview
6 // to hopefully help readers of this code: 6 // to hopefully help readers of this code:
7 // - RenderingHelper is charged with interacting with X11/{EGL/GLES2,GLX/GL} or 7 // - RenderingHelper is charged with interacting with X11/{EGL/GLES2,GLX/GL} or
8 // Win/EGL. 8 // Win/EGL.
9 // - ClientState is an enum for the state of the decode client used by the test. 9 // - ClientState is an enum for the state of the decode client used by the test.
10 // - ClientStateNotification is a barrier abstraction that allows the test code 10 // - ClientStateNotification is a barrier abstraction that allows the test code
(...skipping 16 matching lines...) Expand all
27 // This is http://code.google.com/p/googletest/issues/detail?id=371 27 // This is http://code.google.com/p/googletest/issues/detail?id=371
28 #include "testing/gtest/include/gtest/gtest.h" 28 #include "testing/gtest/include/gtest/gtest.h"
29 29
30 #include "base/at_exit.h" 30 #include "base/at_exit.h"
31 #include "base/bind.h" 31 #include "base/bind.h"
32 #include "base/command_line.h" 32 #include "base/command_line.h"
33 #include "base/files/file.h" 33 #include "base/files/file.h"
34 #include "base/files/file_util.h" 34 #include "base/files/file_util.h"
35 #include "base/format_macros.h" 35 #include "base/format_macros.h"
36 #include "base/md5.h" 36 #include "base/md5.h"
37 #include "base/message_loop/message_loop.h"
37 #include "base/message_loop/message_loop_proxy.h" 38 #include "base/message_loop/message_loop_proxy.h"
39 #include "base/message_loop/message_pump_libevent.h"
38 #include "base/process/process.h" 40 #include "base/process/process.h"
39 #include "base/stl_util.h" 41 #include "base/stl_util.h"
40 #include "base/strings/string_number_conversions.h" 42 #include "base/strings/string_number_conversions.h"
41 #include "base/strings/string_split.h" 43 #include "base/strings/string_split.h"
42 #include "base/strings/stringize_macros.h" 44 #include "base/strings/stringize_macros.h"
43 #include "base/strings/stringprintf.h" 45 #include "base/strings/stringprintf.h"
44 #include "base/strings/utf_string_conversions.h" 46 #include "base/strings/utf_string_conversions.h"
45 #include "base/synchronization/condition_variable.h" 47 #include "base/synchronization/condition_variable.h"
46 #include "base/synchronization/lock.h" 48 #include "base/synchronization/lock.h"
47 #include "base/synchronization/waitable_event.h" 49 #include "base/synchronization/waitable_event.h"
48 #include "base/threading/thread.h" 50 #include "base/threading/thread.h"
49 #include "content/common/gpu/media/rendering_helper.h" 51 #include "content/common/gpu/media/rendering_helper.h"
50 #include "content/common/gpu/media/video_accelerator_unittest_helpers.h" 52 #include "content/common/gpu/media/video_accelerator_unittest_helpers.h"
51 #include "content/public/common/content_switches.h" 53 #include "content/public/common/content_switches.h"
52 #include "media/filters/h264_parser.h" 54 #include "media/filters/h264_parser.h"
53 #include "ui/gfx/codec/png_codec.h" 55 #include "ui/gfx/codec/png_codec.h"
54 56
55 #if defined(OS_WIN) 57 #if defined(OS_WIN)
56 #include "content/common/gpu/media/dxva_video_decode_accelerator.h" 58 #include "content/common/gpu/media/dxva_video_decode_accelerator.h"
57 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) 59 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL)
58 #include "content/common/gpu/media/v4l2_video_decode_accelerator.h" 60 #include "content/common/gpu/media/v4l2_video_decode_accelerator.h"
59 #include "content/common/gpu/media/v4l2_video_device.h" 61 #include "content/common/gpu/media/v4l2_video_device.h"
60 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) 62 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)
61 #include "content/common/gpu/media/vaapi_video_decode_accelerator.h" 63 #include "content/common/gpu/media/vaapi_video_decode_accelerator.h"
62 #include "content/common/gpu/media/vaapi_wrapper.h" 64 #include "content/common/gpu/media/vaapi_wrapper.h"
63 #if defined(USE_X11)
64 #include "ui/gl/gl_implementation.h"
65 #endif // USE_X11
66 #else 65 #else
67 #error The VideoAccelerator tests are not supported on this platform. 66 #error The VideoAccelerator tests are not supported on this platform.
68 #endif // OS_WIN 67 #endif // OS_WIN
69 68
70 using media::VideoDecodeAccelerator; 69 using media::VideoDecodeAccelerator;
71 70
72 namespace content { 71 namespace content {
73 namespace { 72 namespace {
74 73
75 // Values optionally filled in from flags; see main() below. 74 // Values optionally filled in from flags; see main() below.
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 : media::H264PROFILE_BASELINE); 374 : media::H264PROFILE_BASELINE);
376 } 375 }
377 376
378 GLRenderingVDAClient::~GLRenderingVDAClient() { 377 GLRenderingVDAClient::~GLRenderingVDAClient() {
379 DeleteDecoder(); // Clean up in case of expected error. 378 DeleteDecoder(); // Clean up in case of expected error.
380 CHECK(decoder_deleted()); 379 CHECK(decoder_deleted());
381 STLDeleteValues(&picture_buffers_by_id_); 380 STLDeleteValues(&picture_buffers_by_id_);
382 SetState(CS_DESTROYED); 381 SetState(CS_DESTROYED);
383 } 382 }
384 383
384 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)
Pawel Osciak 2014/09/24 11:27:13 Why were we ok without this before?
Pawel Osciak 2014/10/08 08:17:21 Question still stands please.
llandwerlin-old 2014/10/13 16:53:00 Removed.
385 static bool MakeDecoderCurrent(scoped_refptr<gfx::GLContext> context) {
Pawel Osciak 2014/09/24 11:27:13 s/MakeDecoderCurrent/MakeContextCurrent/
Pawel Osciak 2014/10/08 08:17:21 I think MakeContextCurrent is still a better name?
llandwerlin-old 2014/10/08 09:31:17 Acknowledged.
386 context->MakeCurrent(NULL);
387 return true;
388 }
389 #else
385 static bool DoNothingReturnTrue() { return true; } 390 static bool DoNothingReturnTrue() { return true; }
391 #endif
386 392
387 void GLRenderingVDAClient::CreateAndStartDecoder() { 393 void GLRenderingVDAClient::CreateAndStartDecoder() {
388 CHECK(decoder_deleted()); 394 CHECK(decoder_deleted());
389 CHECK(!decoder_.get()); 395 CHECK(!decoder_.get());
390 396
391 VideoDecodeAccelerator::Client* client = this; 397 VideoDecodeAccelerator::Client* client = this;
392 base::WeakPtr<VideoDecodeAccelerator::Client> weak_client = AsWeakPtr(); 398 base::WeakPtr<VideoDecodeAccelerator::Client> weak_client = AsWeakPtr();
393 #if defined(OS_WIN) 399 #if defined(OS_WIN)
394 decoder_.reset( 400 decoder_.reset(
395 new DXVAVideoDecodeAccelerator(base::Bind(&DoNothingReturnTrue))); 401 new DXVAVideoDecodeAccelerator(base::Bind(&DoNothingReturnTrue)));
396 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) 402 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL)
397 403
398 scoped_ptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kDecoder); 404 scoped_ptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kDecoder);
399 if (!device.get()) { 405 if (!device.get()) {
400 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); 406 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE);
401 return; 407 return;
402 } 408 }
403 decoder_.reset(new V4L2VideoDecodeAccelerator( 409 decoder_.reset(new V4L2VideoDecodeAccelerator(
404 static_cast<EGLDisplay>(rendering_helper_->GetGLDisplay()), 410 static_cast<EGLDisplay>(rendering_helper_->GetGLDisplay()),
405 static_cast<EGLContext>(rendering_helper_->GetGLContext()), 411 static_cast<EGLContext>(rendering_helper_->GetGLContextHandle()),
406 weak_client, 412 weak_client,
407 base::Bind(&DoNothingReturnTrue), 413 base::Bind(&DoNothingReturnTrue),
408 device.Pass(), 414 device.Pass(),
409 base::MessageLoopProxy::current())); 415 base::MessageLoopProxy::current()));
410 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) 416 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)
411 CHECK_EQ(gfx::kGLImplementationDesktopGL, gfx::GetGLImplementation())
412 << "Hardware video decode does not work with OSMesa";
413 decoder_.reset(new VaapiVideoDecodeAccelerator( 417 decoder_.reset(new VaapiVideoDecodeAccelerator(
414 static_cast<Display*>(rendering_helper_->GetGLDisplay()), 418 rendering_helper_->GetGLContext(),
415 base::Bind(&DoNothingReturnTrue))); 419 base::Bind(&MakeDecoderCurrent,
420 rendering_helper_->GetGLContext())));
416 #endif // OS_WIN 421 #endif // OS_WIN
417 CHECK(decoder_.get()); 422 CHECK(decoder_.get());
418 weak_decoder_factory_.reset( 423 weak_decoder_factory_.reset(
419 new base::WeakPtrFactory<VideoDecodeAccelerator>(decoder_.get())); 424 new base::WeakPtrFactory<VideoDecodeAccelerator>(decoder_.get()));
420 SetState(CS_DECODER_SET); 425 SetState(CS_DECODER_SET);
421 if (decoder_deleted()) 426 if (decoder_deleted())
422 return; 427 return;
423 428
424 CHECK(decoder_->Initialize(profile_, client)); 429 CHECK(decoder_->Initialize(profile_, client));
425 FinishInitialization(); 430 FinishInitialization();
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
863 868
864 VideoDecodeAcceleratorTest::VideoDecodeAcceleratorTest() 869 VideoDecodeAcceleratorTest::VideoDecodeAcceleratorTest()
865 : rendering_thread_("GLRenderingVDAClientThread") {} 870 : rendering_thread_("GLRenderingVDAClientThread") {}
866 871
867 void VideoDecodeAcceleratorTest::SetUp() { 872 void VideoDecodeAcceleratorTest::SetUp() {
868 ParseAndReadTestVideoData(g_test_video_data, &test_video_files_); 873 ParseAndReadTestVideoData(g_test_video_data, &test_video_files_);
869 874
870 // Initialize the rendering thread. 875 // Initialize the rendering thread.
871 base::Thread::Options options; 876 base::Thread::Options options;
872 options.message_loop_type = base::MessageLoop::TYPE_DEFAULT; 877 options.message_loop_type = base::MessageLoop::TYPE_DEFAULT;
873 #if defined(OS_WIN) 878 #if defined(OS_WIN) || defined (USE_OZONE)
874 // For windows the decoding thread initializes the media foundation decoder 879 // For windows the decoding thread initializes the media foundation decoder
875 // which uses COM. We need the thread to be a UI thread. 880 // which uses COM. We need the thread to be a UI thread.
876 options.message_loop_type = base::MessageLoop::TYPE_UI; 881 options.message_loop_type = base::MessageLoop::TYPE_UI;
877 #endif // OS_WIN 882 #endif // OS_WIN
878 883
879 rendering_thread_.StartWithOptions(options); 884 rendering_thread_.StartWithOptions(options);
880 rendering_loop_proxy_ = rendering_thread_.message_loop_proxy(); 885 rendering_loop_proxy_ = rendering_thread_.message_loop_proxy();
881 } 886 }
882 887
883 void VideoDecodeAcceleratorTest::TearDown() { 888 void VideoDecodeAcceleratorTest::TearDown() {
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
1421 CHECK(base::StringToDouble(input, &content::g_rendering_fps)); 1426 CHECK(base::StringToDouble(input, &content::g_rendering_fps));
1422 continue; 1427 continue;
1423 } 1428 }
1424 // TODO(owenlin): Remove this flag once it is not used in autotest. 1429 // TODO(owenlin): Remove this flag once it is not used in autotest.
1425 if (it->first == "disable_rendering") { 1430 if (it->first == "disable_rendering") {
1426 content::g_rendering_fps = 0; 1431 content::g_rendering_fps = 0;
1427 continue; 1432 continue;
1428 } 1433 }
1429 if (it->first == "v" || it->first == "vmodule") 1434 if (it->first == "v" || it->first == "vmodule")
1430 continue; 1435 continue;
1436 if (it->first == "ozone-platform" || it->first == "ozone-use-surfaceless")
1437 continue;
1431 LOG(FATAL) << "Unexpected switch: " << it->first << ":" << it->second; 1438 LOG(FATAL) << "Unexpected switch: " << it->first << ":" << it->second;
1432 } 1439 }
1433 1440
1434 base::ShadowingAtExitManager at_exit_manager; 1441 base::ShadowingAtExitManager at_exit_manager;
1435 content::RenderingHelper::InitializeOneOff(); 1442 content::RenderingHelper::InitializeOneOff();
1436 1443
1437 return RUN_ALL_TESTS(); 1444 return RUN_ALL_TESTS();
1438 } 1445 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698