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

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

Issue 845663003: Add multiple video encoders/decoders to video encoder/decoder unittest (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix win compile error Created 5 years, 11 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
« no previous file with comments | « no previous file | content/common/gpu/media/video_encode_accelerator_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 #include "base/synchronization/lock.h" 47 #include "base/synchronization/lock.h"
48 #include "base/synchronization/waitable_event.h" 48 #include "base/synchronization/waitable_event.h"
49 #include "base/threading/thread.h" 49 #include "base/threading/thread.h"
50 #include "content/common/gpu/media/rendering_helper.h" 50 #include "content/common/gpu/media/rendering_helper.h"
51 #include "content/common/gpu/media/video_accelerator_unittest_helpers.h" 51 #include "content/common/gpu/media/video_accelerator_unittest_helpers.h"
52 #include "content/public/common/content_switches.h" 52 #include "content/public/common/content_switches.h"
53 #include "media/filters/h264_parser.h" 53 #include "media/filters/h264_parser.h"
54 #include "ui/gfx/codec/png_codec.h" 54 #include "ui/gfx/codec/png_codec.h"
55 55
56 #if defined(OS_WIN) 56 #if defined(OS_WIN)
57 #include "base/win/windows_version.h"
57 #include "content/common/gpu/media/dxva_video_decode_accelerator.h" 58 #include "content/common/gpu/media/dxva_video_decode_accelerator.h"
58 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) 59 #elif defined(OS_CHROMEOS)
60 #if defined(ARCH_CPU_ARMEL) || (defined(USE_OZONE) && defined(USE_V4L2_CODEC))
59 #include "content/common/gpu/media/v4l2_video_decode_accelerator.h" 61 #include "content/common/gpu/media/v4l2_video_decode_accelerator.h"
60 #include "content/common/gpu/media/v4l2_video_device.h" 62 #include "content/common/gpu/media/v4l2_video_device.h"
61 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) 63 #endif
64 #if defined(ARCH_CPU_X86_FAMILY)
62 #include "content/common/gpu/media/vaapi_video_decode_accelerator.h" 65 #include "content/common/gpu/media/vaapi_video_decode_accelerator.h"
63 #include "content/common/gpu/media/vaapi_wrapper.h" 66 #include "content/common/gpu/media/vaapi_wrapper.h"
67 #endif // defined(ARCH_CPU_X86_FAMILY)
64 #else 68 #else
65 #error The VideoAccelerator tests are not supported on this platform. 69 #error The VideoAccelerator tests are not supported on this platform.
66 #endif // OS_WIN 70 #endif // OS_WIN
67 71
68 using media::VideoDecodeAccelerator; 72 using media::VideoDecodeAccelerator;
69 73
70 namespace content { 74 namespace content {
71 namespace { 75 namespace {
72 76
73 // Values optionally filled in from flags; see main() below. 77 // Values optionally filled in from flags; see main() below.
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 int num_queued_fragments() { return num_queued_fragments_; } 279 int num_queued_fragments() { return num_queued_fragments_; }
276 int num_decoded_frames() { return num_decoded_frames_; } 280 int num_decoded_frames() { return num_decoded_frames_; }
277 double frames_per_second(); 281 double frames_per_second();
278 // Return the median of the decode time of all decoded frames. 282 // Return the median of the decode time of all decoded frames.
279 base::TimeDelta decode_time_median(); 283 base::TimeDelta decode_time_median();
280 bool decoder_deleted() { return !decoder_.get(); } 284 bool decoder_deleted() { return !decoder_.get(); }
281 285
282 private: 286 private:
283 typedef std::map<int32, scoped_refptr<TextureRef>> TextureRefMap; 287 typedef std::map<int32, scoped_refptr<TextureRef>> TextureRefMap;
284 288
289 scoped_ptr<media::VideoDecodeAccelerator> CreateDXVAVDA();
290 scoped_ptr<media::VideoDecodeAccelerator> CreateV4L2VDA();
291 scoped_ptr<media::VideoDecodeAccelerator> CreateVaapiVDA();
292
285 void SetState(ClientState new_state); 293 void SetState(ClientState new_state);
286 void FinishInitialization(); 294 void FinishInitialization();
287 void ReturnPicture(int32 picture_buffer_id); 295 void ReturnPicture(int32 picture_buffer_id);
288 296
289 // Delete the associated decoder helper. 297 // Delete the associated decoder helper.
290 void DeleteDecoder(); 298 void DeleteDecoder();
291 299
292 // Compute & return the first encoded bytes (including a start frame) to send 300 // Compute & return the first encoded bytes (including a start frame) to send
293 // to the decoder, starting at |start_pos| and returning one fragment. Skips 301 // to the decoder, starting at |start_pos| and returning one fragment. Skips
294 // to the first decodable position. 302 // to the first decodable position.
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 } 412 }
405 413
406 GLRenderingVDAClient::~GLRenderingVDAClient() { 414 GLRenderingVDAClient::~GLRenderingVDAClient() {
407 DeleteDecoder(); // Clean up in case of expected error. 415 DeleteDecoder(); // Clean up in case of expected error.
408 CHECK(decoder_deleted()); 416 CHECK(decoder_deleted());
409 SetState(CS_DESTROYED); 417 SetState(CS_DESTROYED);
410 } 418 }
411 419
412 static bool DoNothingReturnTrue() { return true; } 420 static bool DoNothingReturnTrue() { return true; }
413 421
422 scoped_ptr<media::VideoDecodeAccelerator>
423 GLRenderingVDAClient::CreateDXVAVDA() {
424 scoped_ptr<media::VideoDecodeAccelerator> decoder;
425 #if defined(OS_WIN)
426 if (base::win::GetVersion() >= base::win::VERSION_WIN7)
427 decoder.reset(
428 new DXVAVideoDecodeAccelerator(base::Bind(&DoNothingReturnTrue)));
429 #endif
430 return decoder.Pass();
431 }
432
433 scoped_ptr<media::VideoDecodeAccelerator>
434 GLRenderingVDAClient::CreateV4L2VDA() {
435 scoped_ptr<media::VideoDecodeAccelerator> decoder;
436 #if defined(OS_CHROMEOS) && (defined(ARCH_CPU_ARMEL) || \
437 (defined(USE_OZONE) && defined(USE_V4L2_CODEC)))
438 scoped_ptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kDecoder);
439 if (device.get()) {
440 base::WeakPtr<VideoDecodeAccelerator::Client> weak_client = AsWeakPtr();
441 decoder.reset(new V4L2VideoDecodeAccelerator(
442 static_cast<EGLDisplay>(rendering_helper_->GetGLDisplay()),
443 static_cast<EGLContext>(rendering_helper_->GetGLContextHandle()),
444 weak_client,
445 base::Bind(&DoNothingReturnTrue),
446 device.Pass(),
447 base::MessageLoopProxy::current()));
448 }
449 #endif
450 return decoder.Pass();
451 }
452
453 scoped_ptr<media::VideoDecodeAccelerator>
454 GLRenderingVDAClient::CreateVaapiVDA() {
455 scoped_ptr<media::VideoDecodeAccelerator> decoder;
456 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)
457 decoder.reset(
458 new VaapiVideoDecodeAccelerator(base::Bind(&DoNothingReturnTrue)));
459 #endif
460 return decoder.Pass();
461 }
462
414 void GLRenderingVDAClient::CreateAndStartDecoder() { 463 void GLRenderingVDAClient::CreateAndStartDecoder() {
415 CHECK(decoder_deleted()); 464 CHECK(decoder_deleted());
416 CHECK(!decoder_.get()); 465 CHECK(!decoder_.get());
417 466
418 VideoDecodeAccelerator::Client* client = this; 467 VideoDecodeAccelerator::Client* client = this;
419 base::WeakPtr<VideoDecodeAccelerator::Client> weak_client = AsWeakPtr();
420 #if defined(OS_WIN)
421 decoder_.reset(
422 new DXVAVideoDecodeAccelerator(base::Bind(&DoNothingReturnTrue)));
423 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL)
424 468
425 scoped_ptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kDecoder); 469 scoped_ptr<media::VideoDecodeAccelerator> decoders[] = {
426 if (!device.get()) { 470 CreateDXVAVDA(),
427 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); 471 CreateV4L2VDA(),
428 return; 472 CreateVaapiVDA()
473 };
474
475 for (size_t i = 0; i < arraysize(decoders); ++i) {
476 if (!decoders[i])
477 continue;
478 decoder_ = decoders[i].Pass();
479 weak_decoder_factory_.reset(
480 new base::WeakPtrFactory<VideoDecodeAccelerator>(decoder_.get()));
481 SetState(CS_DECODER_SET);
482 if (decoder_->Initialize(profile_, client)) {
483 FinishInitialization();
484 return;
485 }
429 } 486 }
430 decoder_.reset(new V4L2VideoDecodeAccelerator( 487 // Decoders are all initialize failed.
431 static_cast<EGLDisplay>(rendering_helper_->GetGLDisplay()), 488 LOG(ERROR) << "VideoDecodeAccelerator::Initialize() failed";
432 static_cast<EGLContext>(rendering_helper_->GetGLContextHandle()), 489 CHECK(false);
433 weak_client, base::Bind(&DoNothingReturnTrue), device.Pass(),
434 base::MessageLoopProxy::current()));
435 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)
436 decoder_.reset(
437 new VaapiVideoDecodeAccelerator(base::Bind(&DoNothingReturnTrue)));
438 #endif // OS_WIN
439 CHECK(decoder_.get());
440 weak_decoder_factory_.reset(
441 new base::WeakPtrFactory<VideoDecodeAccelerator>(decoder_.get()));
442 SetState(CS_DECODER_SET);
443 if (decoder_deleted())
444 return;
445
446 CHECK(decoder_->Initialize(profile_, client));
447 FinishInitialization();
448 } 490 }
449 491
450 void GLRenderingVDAClient::ProvidePictureBuffers( 492 void GLRenderingVDAClient::ProvidePictureBuffers(
451 uint32 requested_num_of_buffers, 493 uint32 requested_num_of_buffers,
452 const gfx::Size& dimensions, 494 const gfx::Size& dimensions,
453 uint32 texture_target) { 495 uint32 texture_target) {
454 if (decoder_deleted()) 496 if (decoder_deleted())
455 return; 497 return;
456 std::vector<media::PictureBuffer> buffers; 498 std::vector<media::PictureBuffer> buffers;
457 499
(...skipping 1014 matching lines...) Expand 10 before | Expand all | Expand 10 after
1472 if (it->first == "ozone-platform" || it->first == "ozone-use-surfaceless") 1514 if (it->first == "ozone-platform" || it->first == "ozone-use-surfaceless")
1473 continue; 1515 continue;
1474 LOG(FATAL) << "Unexpected switch: " << it->first << ":" << it->second; 1516 LOG(FATAL) << "Unexpected switch: " << it->first << ":" << it->second;
1475 } 1517 }
1476 1518
1477 base::ShadowingAtExitManager at_exit_manager; 1519 base::ShadowingAtExitManager at_exit_manager;
1478 content::RenderingHelper::InitializeOneOff(); 1520 content::RenderingHelper::InitializeOneOff();
1479 1521
1480 return RUN_ALL_TESTS(); 1522 return RUN_ALL_TESTS();
1481 } 1523 }
OLDNEW
« no previous file with comments | « no previous file | content/common/gpu/media/video_encode_accelerator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698