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 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 bool suppress_rendering_; | 462 bool suppress_rendering_; |
463 std::vector<base::TimeTicks> frame_delivery_times_; | 463 std::vector<base::TimeTicks> frame_delivery_times_; |
464 int delay_reuse_after_frame_num_; | 464 int delay_reuse_after_frame_num_; |
465 scoped_ptr<ThrottlingVDAClient> throttling_client_; | 465 scoped_ptr<ThrottlingVDAClient> throttling_client_; |
466 // A map from bitstream buffer id to the decode start time of the buffer. | 466 // A map from bitstream buffer id to the decode start time of the buffer. |
467 std::map<int, base::TimeTicks> decode_start_time_; | 467 std::map<int, base::TimeTicks> decode_start_time_; |
468 // The decode time of all decoded frames. | 468 // The decode time of all decoded frames. |
469 std::vector<base::TimeDelta> decode_time_; | 469 std::vector<base::TimeDelta> decode_time_; |
470 // The number of VDA::Decode calls per second. This is to simulate webrtc. | 470 // The number of VDA::Decode calls per second. This is to simulate webrtc. |
471 int decode_calls_per_second_; | 471 int decode_calls_per_second_; |
| 472 // The id of the picture which is being hold for displayed. |
| 473 int on_hold_picture_buffer_id_; |
472 | 474 |
473 DISALLOW_IMPLICIT_CONSTRUCTORS(GLRenderingVDAClient); | 475 DISALLOW_IMPLICIT_CONSTRUCTORS(GLRenderingVDAClient); |
474 }; | 476 }; |
475 | 477 |
476 GLRenderingVDAClient::GLRenderingVDAClient( | 478 GLRenderingVDAClient::GLRenderingVDAClient( |
477 RenderingHelper* rendering_helper, | 479 RenderingHelper* rendering_helper, |
478 int rendering_window_id, | 480 int rendering_window_id, |
479 ClientStateNotification<ClientState>* note, | 481 ClientStateNotification<ClientState>* note, |
480 const std::string& encoded_data, | 482 const std::string& encoded_data, |
481 int num_in_flight_decodes, | 483 int num_in_flight_decodes, |
(...skipping 19 matching lines...) Expand all Loading... |
501 reset_after_frame_num_(reset_after_frame_num), | 503 reset_after_frame_num_(reset_after_frame_num), |
502 delete_decoder_state_(delete_decoder_state), | 504 delete_decoder_state_(delete_decoder_state), |
503 state_(CS_CREATED), | 505 state_(CS_CREATED), |
504 num_skipped_fragments_(0), | 506 num_skipped_fragments_(0), |
505 num_queued_fragments_(0), | 507 num_queued_fragments_(0), |
506 num_decoded_frames_(0), | 508 num_decoded_frames_(0), |
507 num_done_bitstream_buffers_(0), | 509 num_done_bitstream_buffers_(0), |
508 texture_target_(0), | 510 texture_target_(0), |
509 suppress_rendering_(suppress_rendering), | 511 suppress_rendering_(suppress_rendering), |
510 delay_reuse_after_frame_num_(delay_reuse_after_frame_num), | 512 delay_reuse_after_frame_num_(delay_reuse_after_frame_num), |
511 decode_calls_per_second_(decode_calls_per_second) { | 513 decode_calls_per_second_(decode_calls_per_second), |
| 514 on_hold_picture_buffer_id_(-1) { |
512 CHECK_GT(num_in_flight_decodes, 0); | 515 CHECK_GT(num_in_flight_decodes, 0); |
513 CHECK_GT(num_play_throughs, 0); | 516 CHECK_GT(num_play_throughs, 0); |
514 CHECK_GE(rendering_fps, 0); | 517 CHECK_GE(rendering_fps, 0); |
515 // |num_in_flight_decodes_| is unsupported if |decode_calls_per_second_| > 0. | 518 // |num_in_flight_decodes_| is unsupported if |decode_calls_per_second_| > 0. |
516 if (decode_calls_per_second_ > 0) | 519 if (decode_calls_per_second_ > 0) |
517 CHECK_EQ(1, num_in_flight_decodes_); | 520 CHECK_EQ(1, num_in_flight_decodes_); |
518 | 521 |
519 // Default to H264 baseline if no profile provided. | 522 // Default to H264 baseline if no profile provided. |
520 profile_ = (profile != media::VIDEO_CODEC_PROFILE_UNKNOWN | 523 profile_ = (profile != media::VIDEO_CODEC_PROFILE_UNKNOWN |
521 ? profile | 524 ? profile |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
644 reset_after_frame_num_ = MID_STREAM_RESET; | 647 reset_after_frame_num_ = MID_STREAM_RESET; |
645 decoder_->Reset(); | 648 decoder_->Reset(); |
646 // Re-start decoding from the beginning of the stream to avoid needing to | 649 // Re-start decoding from the beginning of the stream to avoid needing to |
647 // know how to find I-frames and so on in this test. | 650 // know how to find I-frames and so on in this test. |
648 encoded_data_next_pos_to_decode_ = 0; | 651 encoded_data_next_pos_to_decode_ = 0; |
649 } | 652 } |
650 | 653 |
651 media::PictureBuffer* picture_buffer = | 654 media::PictureBuffer* picture_buffer = |
652 picture_buffers_by_id_[picture.picture_buffer_id()]; | 655 picture_buffers_by_id_[picture.picture_buffer_id()]; |
653 CHECK(picture_buffer); | 656 CHECK(picture_buffer); |
| 657 |
| 658 int released_picture_buffer_id = picture.picture_buffer_id(); |
654 if (!suppress_rendering_) { | 659 if (!suppress_rendering_) { |
| 660 // Replace with the last holding picture buffer. |
| 661 std::swap(released_picture_buffer_id, on_hold_picture_buffer_id_); |
655 rendering_helper_->RenderTexture(texture_target_, | 662 rendering_helper_->RenderTexture(texture_target_, |
656 picture_buffer->texture_id()); | 663 picture_buffer->texture_id()); |
657 } | 664 } |
658 | 665 |
659 if (num_decoded_frames() > delay_reuse_after_frame_num_) { | 666 if (released_picture_buffer_id < 0) |
| 667 return; |
| 668 |
| 669 if ((num_decoded_frames() > delay_reuse_after_frame_num_)) { |
660 base::MessageLoop::current()->PostDelayedTask( | 670 base::MessageLoop::current()->PostDelayedTask( |
661 FROM_HERE, | 671 FROM_HERE, |
662 base::Bind(&VideoDecodeAccelerator::ReusePictureBuffer, | 672 base::Bind(&VideoDecodeAccelerator::ReusePictureBuffer, |
663 weak_decoder_factory_->GetWeakPtr(), | 673 weak_decoder_factory_->GetWeakPtr(), |
664 picture.picture_buffer_id()), | 674 released_picture_buffer_id), |
665 kReuseDelay); | 675 kReuseDelay); |
666 } else { | 676 } else { |
667 decoder_->ReusePictureBuffer(picture.picture_buffer_id()); | 677 decoder_->ReusePictureBuffer(released_picture_buffer_id); |
668 } | 678 } |
669 } | 679 } |
670 | 680 |
671 void GLRenderingVDAClient::NotifyEndOfBitstreamBuffer( | 681 void GLRenderingVDAClient::NotifyEndOfBitstreamBuffer( |
672 int32 bitstream_buffer_id) { | 682 int32 bitstream_buffer_id) { |
673 // TODO(fischman): this test currently relies on this notification to make | 683 // TODO(fischman): this test currently relies on this notification to make |
674 // forward progress during a Reset(). But the VDA::Reset() API doesn't | 684 // forward progress during a Reset(). But the VDA::Reset() API doesn't |
675 // guarantee this, so stop relying on it (and remove the notifications from | 685 // guarantee this, so stop relying on it (and remove the notifications from |
676 // VaapiVideoDecodeAccelerator::FinishReset()). | 686 // VaapiVideoDecodeAccelerator::FinishReset()). |
677 ++num_done_bitstream_buffers_; | 687 ++num_done_bitstream_buffers_; |
678 --outstanding_decodes_; | 688 --outstanding_decodes_; |
679 if (decode_calls_per_second_ == 0) | 689 if (decode_calls_per_second_ == 0) |
680 DecodeNextFragment(); | 690 DecodeNextFragment(); |
681 } | 691 } |
682 | 692 |
683 void GLRenderingVDAClient::NotifyFlushDone() { | 693 void GLRenderingVDAClient::NotifyFlushDone() { |
684 if (decoder_deleted()) | 694 if (decoder_deleted()) |
685 return; | 695 return; |
| 696 |
686 SetState(CS_FLUSHED); | 697 SetState(CS_FLUSHED); |
687 --remaining_play_throughs_; | 698 --remaining_play_throughs_; |
688 DCHECK_GE(remaining_play_throughs_, 0); | 699 DCHECK_GE(remaining_play_throughs_, 0); |
689 if (decoder_deleted()) | 700 if (decoder_deleted()) |
690 return; | 701 return; |
691 decoder_->Reset(); | 702 decoder_->Reset(); |
692 SetState(CS_RESETTING); | 703 SetState(CS_RESETTING); |
693 } | 704 } |
694 | 705 |
695 void GLRenderingVDAClient::NotifyResetDone() { | 706 void GLRenderingVDAClient::NotifyResetDone() { |
696 if (decoder_deleted()) | 707 if (decoder_deleted()) |
697 return; | 708 return; |
698 | |
699 if (reset_after_frame_num_ == MID_STREAM_RESET) { | 709 if (reset_after_frame_num_ == MID_STREAM_RESET) { |
700 reset_after_frame_num_ = END_OF_STREAM_RESET; | 710 reset_after_frame_num_ = END_OF_STREAM_RESET; |
701 DecodeNextFragment(); | 711 DecodeNextFragment(); |
702 return; | 712 return; |
703 } else if (reset_after_frame_num_ == START_OF_STREAM_RESET) { | 713 } else if (reset_after_frame_num_ == START_OF_STREAM_RESET) { |
704 reset_after_frame_num_ = END_OF_STREAM_RESET; | 714 reset_after_frame_num_ = END_OF_STREAM_RESET; |
705 for (int i = 0; i < num_in_flight_decodes_; ++i) | 715 for (int i = 0; i < num_in_flight_decodes_; ++i) |
706 DecodeNextFragment(); | 716 DecodeNextFragment(); |
707 return; | 717 return; |
708 } | 718 } |
(...skipping 858 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1567 } | 1577 } |
1568 if (it->first == "v" || it->first == "vmodule") | 1578 if (it->first == "v" || it->first == "vmodule") |
1569 continue; | 1579 continue; |
1570 LOG(FATAL) << "Unexpected switch: " << it->first << ":" << it->second; | 1580 LOG(FATAL) << "Unexpected switch: " << it->first << ":" << it->second; |
1571 } | 1581 } |
1572 | 1582 |
1573 base::ShadowingAtExitManager at_exit_manager; | 1583 base::ShadowingAtExitManager at_exit_manager; |
1574 | 1584 |
1575 return RUN_ALL_TESTS(); | 1585 return RUN_ALL_TESTS(); |
1576 } | 1586 } |
OLD | NEW |