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