OLD | NEW |
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 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 bool suppress_rendering, | 415 bool suppress_rendering, |
416 int delay_reuse_after_frame_num, | 416 int delay_reuse_after_frame_num, |
417 int decode_calls_per_second, | 417 int decode_calls_per_second, |
418 bool render_as_thumbnails); | 418 bool render_as_thumbnails); |
419 ~GLRenderingVDAClient() override; | 419 ~GLRenderingVDAClient() override; |
420 void CreateAndStartDecoder(); | 420 void CreateAndStartDecoder(); |
421 | 421 |
422 // VideoDecodeAccelerator::Client implementation. | 422 // VideoDecodeAccelerator::Client implementation. |
423 // The heart of the Client. | 423 // The heart of the Client. |
424 void ProvidePictureBuffers(uint32_t requested_num_of_buffers, | 424 void ProvidePictureBuffers(uint32_t requested_num_of_buffers, |
| 425 VideoPixelFormat format, |
425 uint32_t textures_per_buffer, | 426 uint32_t textures_per_buffer, |
426 const gfx::Size& dimensions, | 427 const gfx::Size& dimensions, |
427 uint32_t texture_target) override; | 428 uint32_t texture_target) override; |
428 void DismissPictureBuffer(int32_t picture_buffer_id) override; | 429 void DismissPictureBuffer(int32_t picture_buffer_id) override; |
429 void PictureReady(const media::Picture& picture) override; | 430 void PictureReady(const media::Picture& picture) override; |
430 // Simple state changes. | 431 // Simple state changes. |
431 void NotifyEndOfBitstreamBuffer(int32_t bitstream_buffer_id) override; | 432 void NotifyEndOfBitstreamBuffer(int32_t bitstream_buffer_id) override; |
432 void NotifyFlushDone() override; | 433 void NotifyFlushDone() override; |
433 void NotifyResetDone() override; | 434 void NotifyResetDone() override; |
434 void NotifyError(VideoDecodeAccelerator::Error error) override; | 435 void NotifyError(VideoDecodeAccelerator::Error error) override; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 int delete_decoder_state_; | 490 int delete_decoder_state_; |
490 ClientState state_; | 491 ClientState state_; |
491 int num_skipped_fragments_; | 492 int num_skipped_fragments_; |
492 int num_queued_fragments_; | 493 int num_queued_fragments_; |
493 int num_decoded_frames_; | 494 int num_decoded_frames_; |
494 int num_done_bitstream_buffers_; | 495 int num_done_bitstream_buffers_; |
495 base::TimeTicks initialize_done_ticks_; | 496 base::TimeTicks initialize_done_ticks_; |
496 media::VideoCodecProfile profile_; | 497 media::VideoCodecProfile profile_; |
497 int fake_decoder_; | 498 int fake_decoder_; |
498 GLenum texture_target_; | 499 GLenum texture_target_; |
| 500 VideoPixelFormat pixel_format_; |
499 bool suppress_rendering_; | 501 bool suppress_rendering_; |
500 std::vector<base::TimeTicks> frame_delivery_times_; | 502 std::vector<base::TimeTicks> frame_delivery_times_; |
501 int delay_reuse_after_frame_num_; | 503 int delay_reuse_after_frame_num_; |
502 // A map from bitstream buffer id to the decode start time of the buffer. | 504 // A map from bitstream buffer id to the decode start time of the buffer. |
503 std::map<int, base::TimeTicks> decode_start_time_; | 505 std::map<int, base::TimeTicks> decode_start_time_; |
504 // The decode time of all decoded frames. | 506 // The decode time of all decoded frames. |
505 std::vector<base::TimeDelta> decode_time_; | 507 std::vector<base::TimeDelta> decode_time_; |
506 // The number of VDA::Decode calls per second. This is to simulate webrtc. | 508 // The number of VDA::Decode calls per second. This is to simulate webrtc. |
507 int decode_calls_per_second_; | 509 int decode_calls_per_second_; |
508 bool render_as_thumbnails_; | 510 bool render_as_thumbnails_; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
567 remaining_play_throughs_(num_play_throughs), | 569 remaining_play_throughs_(num_play_throughs), |
568 reset_after_frame_num_(reset_after_frame_num), | 570 reset_after_frame_num_(reset_after_frame_num), |
569 delete_decoder_state_(delete_decoder_state), | 571 delete_decoder_state_(delete_decoder_state), |
570 state_(CS_CREATED), | 572 state_(CS_CREATED), |
571 num_skipped_fragments_(0), | 573 num_skipped_fragments_(0), |
572 num_queued_fragments_(0), | 574 num_queued_fragments_(0), |
573 num_decoded_frames_(0), | 575 num_decoded_frames_(0), |
574 num_done_bitstream_buffers_(0), | 576 num_done_bitstream_buffers_(0), |
575 fake_decoder_(fake_decoder), | 577 fake_decoder_(fake_decoder), |
576 texture_target_(0), | 578 texture_target_(0), |
| 579 pixel_format_(PIXEL_FORMAT_UNKNOWN), |
577 suppress_rendering_(suppress_rendering), | 580 suppress_rendering_(suppress_rendering), |
578 delay_reuse_after_frame_num_(delay_reuse_after_frame_num), | 581 delay_reuse_after_frame_num_(delay_reuse_after_frame_num), |
579 decode_calls_per_second_(decode_calls_per_second), | 582 decode_calls_per_second_(decode_calls_per_second), |
580 render_as_thumbnails_(render_as_thumbnails), | 583 render_as_thumbnails_(render_as_thumbnails), |
581 next_picture_buffer_id_(1), | 584 next_picture_buffer_id_(1), |
582 weak_this_factory_(this) { | 585 weak_this_factory_(this) { |
583 LOG_ASSERT(num_in_flight_decodes > 0); | 586 LOG_ASSERT(num_in_flight_decodes > 0); |
584 LOG_ASSERT(num_play_throughs > 0); | 587 LOG_ASSERT(num_play_throughs > 0); |
585 // |num_in_flight_decodes_| is unsupported if |decode_calls_per_second_| > 0. | 588 // |num_in_flight_decodes_| is unsupported if |decode_calls_per_second_| > 0. |
586 if (decode_calls_per_second_ > 0) | 589 if (decode_calls_per_second_ > 0) |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
634 weak_vda_ptr_factory_.reset( | 637 weak_vda_ptr_factory_.reset( |
635 new base::WeakPtrFactory<VideoDecodeAccelerator>(decoder_.get())); | 638 new base::WeakPtrFactory<VideoDecodeAccelerator>(decoder_.get())); |
636 weak_vda_ = weak_vda_ptr_factory_->GetWeakPtr(); | 639 weak_vda_ = weak_vda_ptr_factory_->GetWeakPtr(); |
637 | 640 |
638 SetState(CS_DECODER_SET); | 641 SetState(CS_DECODER_SET); |
639 FinishInitialization(); | 642 FinishInitialization(); |
640 } | 643 } |
641 | 644 |
642 void GLRenderingVDAClient::ProvidePictureBuffers( | 645 void GLRenderingVDAClient::ProvidePictureBuffers( |
643 uint32_t requested_num_of_buffers, | 646 uint32_t requested_num_of_buffers, |
| 647 VideoPixelFormat pixel_format, |
644 uint32_t textures_per_buffer, | 648 uint32_t textures_per_buffer, |
645 const gfx::Size& dimensions, | 649 const gfx::Size& dimensions, |
646 uint32_t texture_target) { | 650 uint32_t texture_target) { |
647 if (decoder_deleted()) | 651 if (decoder_deleted()) |
648 return; | 652 return; |
649 LOG_ASSERT(textures_per_buffer == 1u); | 653 LOG_ASSERT(textures_per_buffer == 1u); |
650 std::vector<media::PictureBuffer> buffers; | 654 std::vector<media::PictureBuffer> buffers; |
651 | 655 |
652 requested_num_of_buffers += kExtraPictureBuffers; | 656 requested_num_of_buffers += kExtraPictureBuffers; |
| 657 if (pixel_format == media::PIXEL_FORMAT_UNKNOWN) |
| 658 pixel_format = media::PIXEL_FORMAT_ARGB; |
| 659 |
| 660 LOG_ASSERT((pixel_format_ == PIXEL_FORMAT_UNKNOWN) || |
| 661 (pixel_format_ == pixel_format)); |
| 662 pixel_format_ = pixel_format; |
653 | 663 |
654 texture_target_ = texture_target; | 664 texture_target_ = texture_target; |
655 for (uint32_t i = 0; i < requested_num_of_buffers; ++i) { | 665 for (uint32_t i = 0; i < requested_num_of_buffers; ++i) { |
656 uint32_t texture_id; | 666 uint32_t texture_id; |
657 base::WaitableEvent done(false, false); | 667 base::WaitableEvent done(false, false); |
658 rendering_helper_->CreateTexture(texture_target_, &texture_id, dimensions, | 668 rendering_helper_->CreateTexture(texture_target_, &texture_id, dimensions, |
659 &done); | 669 &done); |
660 done.Wait(); | 670 done.Wait(); |
661 | 671 |
662 scoped_refptr<TextureRef> texture_ref; | 672 scoped_refptr<TextureRef> texture_ref; |
663 base::Closure delete_texture_cb = | 673 base::Closure delete_texture_cb = |
664 base::Bind(&RenderingHelper::DeleteTexture, | 674 base::Bind(&RenderingHelper::DeleteTexture, |
665 base::Unretained(rendering_helper_), texture_id); | 675 base::Unretained(rendering_helper_), texture_id); |
666 | 676 |
667 if (g_test_import) { | 677 if (g_test_import) { |
668 media::VideoPixelFormat pixel_format = decoder_->GetOutputFormat(); | |
669 if (pixel_format == media::PIXEL_FORMAT_UNKNOWN) | |
670 pixel_format = media::PIXEL_FORMAT_ARGB; | |
671 texture_ref = TextureRef::CreatePreallocated( | 678 texture_ref = TextureRef::CreatePreallocated( |
672 texture_id, delete_texture_cb, pixel_format, dimensions); | 679 texture_id, delete_texture_cb, pixel_format, dimensions); |
673 } else { | 680 } else { |
674 texture_ref = TextureRef::Create(texture_id, delete_texture_cb); | 681 texture_ref = TextureRef::Create(texture_id, delete_texture_cb); |
675 } | 682 } |
676 | 683 |
677 LOG_ASSERT(texture_ref); | 684 LOG_ASSERT(texture_ref); |
678 | 685 |
679 int32_t picture_buffer_id = next_picture_buffer_id_++; | 686 int32_t picture_buffer_id = next_picture_buffer_id_++; |
680 LOG_ASSERT( | 687 LOG_ASSERT( |
(...skipping 1055 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1736 media::VaapiWrapper::PreSandboxInitialization(); | 1743 media::VaapiWrapper::PreSandboxInitialization(); |
1737 #endif | 1744 #endif |
1738 | 1745 |
1739 media::g_env = | 1746 media::g_env = |
1740 reinterpret_cast<media::VideoDecodeAcceleratorTestEnvironment*>( | 1747 reinterpret_cast<media::VideoDecodeAcceleratorTestEnvironment*>( |
1741 testing::AddGlobalTestEnvironment( | 1748 testing::AddGlobalTestEnvironment( |
1742 new media::VideoDecodeAcceleratorTestEnvironment())); | 1749 new media::VideoDecodeAcceleratorTestEnvironment())); |
1743 | 1750 |
1744 return RUN_ALL_TESTS(); | 1751 return RUN_ALL_TESTS(); |
1745 } | 1752 } |
OLD | NEW |