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 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
305 // |delete_decoder_state| indicates when the underlying decoder should be | 305 // |delete_decoder_state| indicates when the underlying decoder should be |
306 // Destroy()'d and deleted and can take values: N<0: delete after -N Decode() | 306 // Destroy()'d and deleted and can take values: N<0: delete after -N Decode() |
307 // calls have been made, N>=0 means interpret as ClientState. | 307 // calls have been made, N>=0 means interpret as ClientState. |
308 // Both |reset_after_frame_num| & |delete_decoder_state| apply only to the | 308 // Both |reset_after_frame_num| & |delete_decoder_state| apply only to the |
309 // last play-through (governed by |num_play_throughs|). | 309 // last play-through (governed by |num_play_throughs|). |
310 // |suppress_rendering| indicates GL rendering is supressed or not. | 310 // |suppress_rendering| indicates GL rendering is supressed or not. |
311 // After |delay_reuse_after_frame_num| frame has been delivered, the client | 311 // After |delay_reuse_after_frame_num| frame has been delivered, the client |
312 // will start delaying the call to ReusePictureBuffer() for kReuseDelay. | 312 // will start delaying the call to ReusePictureBuffer() for kReuseDelay. |
313 // |decode_calls_per_second| is the number of VDA::Decode calls per second. | 313 // |decode_calls_per_second| is the number of VDA::Decode calls per second. |
314 // If |decode_calls_per_second| > 0, |num_in_flight_decodes| must be 1. | 314 // If |decode_calls_per_second| > 0, |num_in_flight_decodes| must be 1. |
315 // When |test_full_flush| is true, request the VDA to return all buffers it | |
316 // owns on Flush(), and verify that. | |
315 GLRenderingVDAClient(size_t window_id, | 317 GLRenderingVDAClient(size_t window_id, |
316 RenderingHelper* rendering_helper, | 318 RenderingHelper* rendering_helper, |
317 ClientStateNotification<ClientState>* note, | 319 ClientStateNotification<ClientState>* note, |
318 const std::string& encoded_data, | 320 const std::string& encoded_data, |
319 int num_in_flight_decodes, | 321 int num_in_flight_decodes, |
320 int num_play_throughs, | 322 int num_play_throughs, |
321 int reset_after_frame_num, | 323 int reset_after_frame_num, |
322 int delete_decoder_state, | 324 int delete_decoder_state, |
323 int frame_width, | 325 int frame_width, |
324 int frame_height, | 326 int frame_height, |
325 media::VideoCodecProfile profile, | 327 media::VideoCodecProfile profile, |
326 int fake_decoder, | 328 int fake_decoder, |
327 bool suppress_rendering, | 329 bool suppress_rendering, |
328 int delay_reuse_after_frame_num, | 330 int delay_reuse_after_frame_num, |
329 int decode_calls_per_second, | 331 int decode_calls_per_second, |
330 bool render_as_thumbnails); | 332 bool render_as_thumbnails, |
333 bool test_full_flush); | |
331 ~GLRenderingVDAClient() override; | 334 ~GLRenderingVDAClient() override; |
332 void CreateAndStartDecoder(); | 335 void CreateAndStartDecoder(); |
333 | 336 |
334 // VideoDecodeAccelerator::Client implementation. | 337 // VideoDecodeAccelerator::Client implementation. |
335 // The heart of the Client. | 338 // The heart of the Client. |
336 void ProvidePictureBuffers(uint32_t requested_num_of_buffers, | 339 void ProvidePictureBuffers(uint32_t requested_num_of_buffers, |
337 const gfx::Size& dimensions, | 340 const gfx::Size& dimensions, |
338 uint32_t texture_target) override; | 341 uint32_t texture_target) override; |
339 void DismissPictureBuffer(int32_t picture_buffer_id) override; | 342 void DismissPictureBuffer(int32_t picture_buffer_id) override; |
340 void PictureReady(const media::Picture& picture) override; | 343 void PictureReady(const media::Picture& picture) override; |
(...skipping 23 matching lines...) Expand all Loading... | |
364 scoped_ptr<media::VideoDecodeAccelerator> CreateV4L2VDA(); | 367 scoped_ptr<media::VideoDecodeAccelerator> CreateV4L2VDA(); |
365 scoped_ptr<media::VideoDecodeAccelerator> CreateV4L2SliceVDA(); | 368 scoped_ptr<media::VideoDecodeAccelerator> CreateV4L2SliceVDA(); |
366 scoped_ptr<media::VideoDecodeAccelerator> CreateVaapiVDA(); | 369 scoped_ptr<media::VideoDecodeAccelerator> CreateVaapiVDA(); |
367 | 370 |
368 void BindImage(uint32_t client_texture_id, | 371 void BindImage(uint32_t client_texture_id, |
369 uint32_t texture_target, | 372 uint32_t texture_target, |
370 scoped_refptr<gl::GLImage> image); | 373 scoped_refptr<gl::GLImage> image); |
371 | 374 |
372 void SetState(ClientState new_state); | 375 void SetState(ClientState new_state); |
373 void FinishInitialization(); | 376 void FinishInitialization(); |
377 void ReturnTexture(int32_t picture_buffer_id); | |
374 void ReturnPicture(int32_t picture_buffer_id); | 378 void ReturnPicture(int32_t picture_buffer_id); |
375 | 379 |
376 // Delete the associated decoder helper. | 380 // Delete the associated decoder helper. |
377 void DeleteDecoder(); | 381 void DeleteDecoder(); |
378 | 382 |
379 // Compute & return the first encoded bytes (including a start frame) to send | 383 // Compute & return the first encoded bytes (including a start frame) to send |
380 // to the decoder, starting at |start_pos| and returning one fragment. Skips | 384 // to the decoder, starting at |start_pos| and returning one fragment. Skips |
381 // to the first decodable position. | 385 // to the first decodable position. |
382 std::string GetBytesForFirstFragment(size_t start_pos, size_t* end_pos); | 386 std::string GetBytesForFirstFragment(size_t start_pos, size_t* end_pos); |
383 // Compute & return the encoded bytes of next fragment to send to the decoder | 387 // Compute & return the encoded bytes of next fragment to send to the decoder |
(...skipping 20 matching lines...) Expand all Loading... | |
404 scoped_ptr<base::WeakPtrFactory<VideoDecodeAccelerator> > | 408 scoped_ptr<base::WeakPtrFactory<VideoDecodeAccelerator> > |
405 weak_decoder_factory_; | 409 weak_decoder_factory_; |
406 int remaining_play_throughs_; | 410 int remaining_play_throughs_; |
407 int reset_after_frame_num_; | 411 int reset_after_frame_num_; |
408 int delete_decoder_state_; | 412 int delete_decoder_state_; |
409 ClientState state_; | 413 ClientState state_; |
410 int num_skipped_fragments_; | 414 int num_skipped_fragments_; |
411 int num_queued_fragments_; | 415 int num_queued_fragments_; |
412 int num_decoded_frames_; | 416 int num_decoded_frames_; |
413 int num_done_bitstream_buffers_; | 417 int num_done_bitstream_buffers_; |
418 int num_pictures_at_client_; | |
414 base::TimeTicks initialize_done_ticks_; | 419 base::TimeTicks initialize_done_ticks_; |
415 media::VideoCodecProfile profile_; | 420 media::VideoCodecProfile profile_; |
416 int fake_decoder_; | 421 int fake_decoder_; |
417 GLenum texture_target_; | 422 GLenum texture_target_; |
418 bool suppress_rendering_; | 423 bool suppress_rendering_; |
419 std::vector<base::TimeTicks> frame_delivery_times_; | 424 std::vector<base::TimeTicks> frame_delivery_times_; |
420 int delay_reuse_after_frame_num_; | 425 int delay_reuse_after_frame_num_; |
421 // A map from bitstream buffer id to the decode start time of the buffer. | 426 // A map from bitstream buffer id to the decode start time of the buffer. |
422 std::map<int, base::TimeTicks> decode_start_time_; | 427 std::map<int, base::TimeTicks> decode_start_time_; |
423 // The decode time of all decoded frames. | 428 // The decode time of all decoded frames. |
424 std::vector<base::TimeDelta> decode_time_; | 429 std::vector<base::TimeDelta> decode_time_; |
425 // The number of VDA::Decode calls per second. This is to simulate webrtc. | 430 // The number of VDA::Decode calls per second. This is to simulate webrtc. |
426 int decode_calls_per_second_; | 431 int decode_calls_per_second_; |
427 bool render_as_thumbnails_; | 432 bool render_as_thumbnails_; |
433 bool test_full_flush_; | |
434 std::list<int> delayed_picture_buffer_ids_to_return_; | |
428 | 435 |
429 // A map of the textures that are currently active for the decoder, i.e., | 436 // A map of the textures that are currently active for the decoder, i.e., |
430 // have been created via AssignPictureBuffers() and not dismissed via | 437 // have been created via AssignPictureBuffers() and not dismissed via |
431 // DismissPictureBuffer(). The keys in the map are the IDs of the | 438 // DismissPictureBuffer(). The keys in the map are the IDs of the |
432 // corresponding picture buffers, and the values are TextureRefs to the | 439 // corresponding picture buffers, and the values are TextureRefs to the |
433 // textures. | 440 // textures. |
434 TextureRefMap active_textures_; | 441 TextureRefMap active_textures_; |
435 | 442 |
436 // A map of the textures that are still pending in the renderer. | 443 // A map of the textures that are still pending in the renderer. |
437 // We check this to ensure all frames are rendered before entering the | 444 // We check this to ensure all frames are rendered before entering the |
(...skipping 14 matching lines...) Expand all Loading... | |
452 int num_play_throughs, | 459 int num_play_throughs, |
453 int reset_after_frame_num, | 460 int reset_after_frame_num, |
454 int delete_decoder_state, | 461 int delete_decoder_state, |
455 int frame_width, | 462 int frame_width, |
456 int frame_height, | 463 int frame_height, |
457 media::VideoCodecProfile profile, | 464 media::VideoCodecProfile profile, |
458 int fake_decoder, | 465 int fake_decoder, |
459 bool suppress_rendering, | 466 bool suppress_rendering, |
460 int delay_reuse_after_frame_num, | 467 int delay_reuse_after_frame_num, |
461 int decode_calls_per_second, | 468 int decode_calls_per_second, |
462 bool render_as_thumbnails) | 469 bool render_as_thumbnails, |
470 bool test_full_flush) | |
463 : window_id_(window_id), | 471 : window_id_(window_id), |
464 rendering_helper_(rendering_helper), | 472 rendering_helper_(rendering_helper), |
465 frame_size_(frame_width, frame_height), | 473 frame_size_(frame_width, frame_height), |
466 encoded_data_(encoded_data), | 474 encoded_data_(encoded_data), |
467 num_in_flight_decodes_(num_in_flight_decodes), | 475 num_in_flight_decodes_(num_in_flight_decodes), |
468 outstanding_decodes_(0), | 476 outstanding_decodes_(0), |
469 encoded_data_next_pos_to_decode_(0), | 477 encoded_data_next_pos_to_decode_(0), |
470 next_bitstream_buffer_id_(0), | 478 next_bitstream_buffer_id_(0), |
471 note_(note), | 479 note_(note), |
472 remaining_play_throughs_(num_play_throughs), | 480 remaining_play_throughs_(num_play_throughs), |
473 reset_after_frame_num_(reset_after_frame_num), | 481 reset_after_frame_num_(reset_after_frame_num), |
474 delete_decoder_state_(delete_decoder_state), | 482 delete_decoder_state_(delete_decoder_state), |
475 state_(CS_CREATED), | 483 state_(CS_CREATED), |
476 num_skipped_fragments_(0), | 484 num_skipped_fragments_(0), |
477 num_queued_fragments_(0), | 485 num_queued_fragments_(0), |
478 num_decoded_frames_(0), | 486 num_decoded_frames_(0), |
479 num_done_bitstream_buffers_(0), | 487 num_done_bitstream_buffers_(0), |
488 num_pictures_at_client_(0), | |
480 fake_decoder_(fake_decoder), | 489 fake_decoder_(fake_decoder), |
481 texture_target_(0), | 490 texture_target_(0), |
482 suppress_rendering_(suppress_rendering), | 491 suppress_rendering_(suppress_rendering), |
483 delay_reuse_after_frame_num_(delay_reuse_after_frame_num), | 492 delay_reuse_after_frame_num_(delay_reuse_after_frame_num), |
484 decode_calls_per_second_(decode_calls_per_second), | 493 decode_calls_per_second_(decode_calls_per_second), |
485 render_as_thumbnails_(render_as_thumbnails), | 494 render_as_thumbnails_(render_as_thumbnails), |
495 test_full_flush_(test_full_flush), | |
486 next_picture_buffer_id_(1) { | 496 next_picture_buffer_id_(1) { |
487 LOG_ASSERT(num_in_flight_decodes > 0); | 497 LOG_ASSERT(num_in_flight_decodes > 0); |
488 LOG_ASSERT(num_play_throughs > 0); | 498 LOG_ASSERT(num_play_throughs > 0); |
489 // |num_in_flight_decodes_| is unsupported if |decode_calls_per_second_| > 0. | 499 // |num_in_flight_decodes_| is unsupported if |decode_calls_per_second_| > 0. |
490 if (decode_calls_per_second_ > 0) | 500 if (decode_calls_per_second_ > 0) |
491 LOG_ASSERT(1 == num_in_flight_decodes_); | 501 LOG_ASSERT(1 == num_in_flight_decodes_); |
492 | 502 |
493 // Default to H264 baseline if no profile provided. | 503 // Default to H264 baseline if no profile provided. |
494 profile_ = (profile != media::VIDEO_CODEC_PROFILE_UNKNOWN | 504 profile_ = (profile != media::VIDEO_CODEC_PROFILE_UNKNOWN |
495 ? profile | 505 ? profile |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
642 .second); | 652 .second); |
643 | 653 |
644 buffers.push_back( | 654 buffers.push_back( |
645 media::PictureBuffer(picture_buffer_id, dimensions, texture_id)); | 655 media::PictureBuffer(picture_buffer_id, dimensions, texture_id)); |
646 } | 656 } |
647 decoder_->AssignPictureBuffers(buffers); | 657 decoder_->AssignPictureBuffers(buffers); |
648 } | 658 } |
649 | 659 |
650 void GLRenderingVDAClient::DismissPictureBuffer(int32_t picture_buffer_id) { | 660 void GLRenderingVDAClient::DismissPictureBuffer(int32_t picture_buffer_id) { |
651 LOG_ASSERT(1U == active_textures_.erase(picture_buffer_id)); | 661 LOG_ASSERT(1U == active_textures_.erase(picture_buffer_id)); |
662 EXPECT_GT(num_pictures_at_client_, 0); | |
663 --num_pictures_at_client_; | |
652 } | 664 } |
653 | 665 |
654 void GLRenderingVDAClient::PictureReady(const media::Picture& picture) { | 666 void GLRenderingVDAClient::PictureReady(const media::Picture& picture) { |
655 // We shouldn't be getting pictures delivered after Reset has completed. | 667 // We shouldn't be getting pictures delivered after Reset has completed. |
656 LOG_ASSERT(state_ < CS_RESET); | 668 LOG_ASSERT(state_ < CS_RESET); |
657 | 669 |
658 if (decoder_deleted()) | 670 if (decoder_deleted()) |
659 return; | 671 return; |
660 | 672 |
673 EXPECT_GT(num_pictures_at_client_, 0); | |
674 --num_pictures_at_client_; | |
675 | |
676 if (picture.bitstream_buffer_id() == -1) { | |
677 // The picture does not contain any decoded data, reuse it immediately. | |
678 ReturnPicture(picture.picture_buffer_id()); | |
679 return; | |
680 } | |
681 | |
661 base::TimeTicks now = base::TimeTicks::Now(); | 682 base::TimeTicks now = base::TimeTicks::Now(); |
662 | 683 |
663 frame_delivery_times_.push_back(now); | 684 frame_delivery_times_.push_back(now); |
664 | 685 |
665 // Save the decode time of this picture. | 686 // Save the decode time of this picture. |
666 std::map<int, base::TimeTicks>::iterator it = | 687 std::map<int, base::TimeTicks>::iterator it = |
667 decode_start_time_.find(picture.bitstream_buffer_id()); | 688 decode_start_time_.find(picture.bitstream_buffer_id()); |
668 ASSERT_NE(decode_start_time_.end(), it); | 689 ASSERT_NE(decode_start_time_.end(), it); |
669 decode_time_.push_back(now - it->second); | 690 decode_time_.push_back(now - it->second); |
670 decode_start_time_.erase(it); | 691 decode_start_time_.erase(it); |
(...skipping 11 matching lines...) Expand all Loading... | |
682 // know how to find I-frames and so on in this test. | 703 // know how to find I-frames and so on in this test. |
683 encoded_data_next_pos_to_decode_ = 0; | 704 encoded_data_next_pos_to_decode_ = 0; |
684 } | 705 } |
685 | 706 |
686 TextureRefMap::iterator texture_it = | 707 TextureRefMap::iterator texture_it = |
687 active_textures_.find(picture.picture_buffer_id()); | 708 active_textures_.find(picture.picture_buffer_id()); |
688 ASSERT_NE(active_textures_.end(), texture_it); | 709 ASSERT_NE(active_textures_.end(), texture_it); |
689 | 710 |
690 scoped_refptr<VideoFrameTexture> video_frame = new VideoFrameTexture( | 711 scoped_refptr<VideoFrameTexture> video_frame = new VideoFrameTexture( |
691 texture_target_, texture_it->second->texture_id(), | 712 texture_target_, texture_it->second->texture_id(), |
692 base::Bind(&GLRenderingVDAClient::ReturnPicture, AsWeakPtr(), | 713 base::Bind(&GLRenderingVDAClient::ReturnTexture, AsWeakPtr(), |
693 picture.picture_buffer_id())); | 714 picture.picture_buffer_id())); |
694 ASSERT_TRUE(pending_textures_.insert(*texture_it).second); | 715 ASSERT_TRUE(pending_textures_.insert(*texture_it).second); |
695 | 716 |
696 if (render_as_thumbnails_) { | 717 if (render_as_thumbnails_) { |
697 rendering_helper_->RenderThumbnail(video_frame->texture_target(), | 718 rendering_helper_->RenderThumbnail(video_frame->texture_target(), |
698 video_frame->texture_id()); | 719 video_frame->texture_id()); |
699 } else if (!suppress_rendering_) { | 720 } else if (!suppress_rendering_) { |
700 rendering_helper_->QueueVideoFrame(window_id_, video_frame); | 721 rendering_helper_->QueueVideoFrame(window_id_, video_frame); |
701 } | 722 } |
702 } | 723 } |
703 | 724 |
704 void GLRenderingVDAClient::ReturnPicture(int32_t picture_buffer_id) { | 725 void GLRenderingVDAClient::ReturnTexture(int32_t picture_buffer_id) { |
705 if (decoder_deleted()) | 726 if (decoder_deleted()) |
706 return; | 727 return; |
728 | |
707 LOG_ASSERT(1U == pending_textures_.erase(picture_buffer_id)); | 729 LOG_ASSERT(1U == pending_textures_.erase(picture_buffer_id)); |
708 | 730 |
709 if (pending_textures_.empty() && state_ == CS_RESETTING) { | 731 if (pending_textures_.empty() && state_ == CS_RESETTING) { |
710 SetState(CS_RESET); | 732 SetState(CS_RESET); |
711 DeleteDecoder(); | 733 DeleteDecoder(); |
712 return; | 734 return; |
713 } | 735 } |
714 | 736 |
737 ReturnPicture(picture_buffer_id); | |
738 } | |
739 | |
740 void GLRenderingVDAClient::ReturnPicture(int32_t picture_buffer_id) { | |
741 if (test_full_flush_ && state_ == CS_FLUSHING) { | |
742 delayed_picture_buffer_ids_to_return_.push_back(picture_buffer_id); | |
743 return; | |
744 } | |
745 | |
715 if (num_decoded_frames_ > delay_reuse_after_frame_num_) { | 746 if (num_decoded_frames_ > delay_reuse_after_frame_num_) { |
716 base::MessageLoop::current()->PostDelayedTask( | 747 base::MessageLoop::current()->PostDelayedTask( |
717 FROM_HERE, | 748 FROM_HERE, |
718 base::Bind(&VideoDecodeAccelerator::ReusePictureBuffer, | 749 base::Bind(&VideoDecodeAccelerator::ReusePictureBuffer, |
719 weak_decoder_factory_->GetWeakPtr(), | 750 weak_decoder_factory_->GetWeakPtr(), |
720 picture_buffer_id), | 751 picture_buffer_id), |
721 kReuseDelay); | 752 kReuseDelay); |
722 } else { | 753 } else { |
723 decoder_->ReusePictureBuffer(picture_buffer_id); | 754 decoder_->ReusePictureBuffer(picture_buffer_id); |
724 } | 755 } |
756 | |
757 ++num_pictures_at_client_; | |
725 } | 758 } |
726 | 759 |
727 void GLRenderingVDAClient::NotifyEndOfBitstreamBuffer( | 760 void GLRenderingVDAClient::NotifyEndOfBitstreamBuffer( |
728 int32_t bitstream_buffer_id) { | 761 int32_t bitstream_buffer_id) { |
729 // TODO(fischman): this test currently relies on this notification to make | 762 // TODO(fischman): this test currently relies on this notification to make |
730 // forward progress during a Reset(). But the VDA::Reset() API doesn't | 763 // forward progress during a Reset(). But the VDA::Reset() API doesn't |
731 // guarantee this, so stop relying on it (and remove the notifications from | 764 // guarantee this, so stop relying on it (and remove the notifications from |
732 // VaapiVideoDecodeAccelerator::FinishReset()). | 765 // VaapiVideoDecodeAccelerator::FinishReset()). |
733 ++num_done_bitstream_buffers_; | 766 ++num_done_bitstream_buffers_; |
734 --outstanding_decodes_; | 767 --outstanding_decodes_; |
735 | 768 |
736 // Flush decoder after all BitstreamBuffers are processed. | 769 // Flush decoder after all BitstreamBuffers are processed. |
737 if (encoded_data_next_pos_to_decode_ == encoded_data_.size()) { | 770 if (encoded_data_next_pos_to_decode_ == encoded_data_.size()) { |
738 // TODO(owenlin): We should not have to check the number of | 771 // TODO(owenlin): We should not have to check the number of |
739 // |outstanding_decodes_|. |decoder_| should be able to accept Flush() | 772 // |outstanding_decodes_|. |decoder_| should be able to accept Flush() |
740 // before it's done with outstanding decodes. (crbug.com/528183) | 773 // before it's done with outstanding decodes. (crbug.com/528183) |
741 if (outstanding_decodes_ == 0) { | 774 if (outstanding_decodes_ == 0) { |
742 decoder_->Flush(); | 775 decoder_->Flush(test_full_flush_); |
743 SetState(CS_FLUSHING); | 776 SetState(CS_FLUSHING); |
744 } | 777 } |
745 } else if (decode_calls_per_second_ == 0) { | 778 } else if (decode_calls_per_second_ == 0) { |
746 DecodeNextFragment(); | 779 DecodeNextFragment(); |
747 } | 780 } |
748 } | 781 } |
749 | 782 |
750 void GLRenderingVDAClient::NotifyFlushDone() { | 783 void GLRenderingVDAClient::NotifyFlushDone() { |
751 if (decoder_deleted()) | 784 if (decoder_deleted()) |
752 return; | 785 return; |
753 | 786 |
754 SetState(CS_FLUSHED); | 787 SetState(CS_FLUSHED); |
788 | |
789 if (test_full_flush_) { | |
790 EXPECT_EQ(num_pictures_at_client_, 0); | |
kcwu
2016/03/22 09:47:42
EXPECT_EQ(0, num_pictures_at_client_);
expected fi
| |
791 for (auto& picture_buffer_id : delayed_picture_buffer_ids_to_return_) | |
792 ReturnPicture(picture_buffer_id); | |
793 delayed_picture_buffer_ids_to_return_.clear(); | |
794 } | |
795 | |
755 --remaining_play_throughs_; | 796 --remaining_play_throughs_; |
756 DCHECK_GE(remaining_play_throughs_, 0); | 797 DCHECK_GE(remaining_play_throughs_, 0); |
757 if (decoder_deleted()) | 798 if (decoder_deleted()) |
758 return; | 799 return; |
759 decoder_->Reset(); | 800 decoder_->Reset(); |
760 SetState(CS_RESETTING); | 801 SetState(CS_RESETTING); |
761 } | 802 } |
762 | 803 |
763 void GLRenderingVDAClient::NotifyResetDone() { | 804 void GLRenderingVDAClient::NotifyResetDone() { |
764 if (decoder_deleted()) | 805 if (decoder_deleted()) |
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1187 // Test parameters: | 1228 // Test parameters: |
1188 // - Number of concurrent decoders. The value takes effect when there is only | 1229 // - Number of concurrent decoders. The value takes effect when there is only |
1189 // one input stream; otherwise, one decoder per input stream will be | 1230 // one input stream; otherwise, one decoder per input stream will be |
1190 // instantiated. | 1231 // instantiated. |
1191 // - Number of concurrent in-flight Decode() calls per decoder. | 1232 // - Number of concurrent in-flight Decode() calls per decoder. |
1192 // - Number of play-throughs. | 1233 // - Number of play-throughs. |
1193 // - reset_after_frame_num: see GLRenderingVDAClient ctor. | 1234 // - reset_after_frame_num: see GLRenderingVDAClient ctor. |
1194 // - delete_decoder_phase: see GLRenderingVDAClient ctor. | 1235 // - delete_decoder_phase: see GLRenderingVDAClient ctor. |
1195 // - whether to test slow rendering by delaying ReusePictureBuffer(). | 1236 // - whether to test slow rendering by delaying ReusePictureBuffer(). |
1196 // - whether the video frames are rendered as thumbnails. | 1237 // - whether the video frames are rendered as thumbnails. |
1238 // - whether to test VDA::Flush(true) | |
1197 class VideoDecodeAcceleratorParamTest | 1239 class VideoDecodeAcceleratorParamTest |
1198 : public VideoDecodeAcceleratorTest, | 1240 : public VideoDecodeAcceleratorTest, |
1199 public ::testing::WithParamInterface< | 1241 public ::testing::WithParamInterface< |
1200 base::Tuple<int, int, int, ResetPoint, ClientState, bool, bool> > { | 1242 base:: |
1243 Tuple<int, int, int, ResetPoint, ClientState, bool, bool, bool>> { | |
1201 }; | 1244 }; |
1202 | 1245 |
1203 // Wait for |note| to report a state and if it's not |expected_state| then | 1246 // Wait for |note| to report a state and if it's not |expected_state| then |
1204 // assert |client| has deleted its decoder. | 1247 // assert |client| has deleted its decoder. |
1205 static void AssertWaitForStateOrDeleted( | 1248 static void AssertWaitForStateOrDeleted( |
1206 ClientStateNotification<ClientState>* note, | 1249 ClientStateNotification<ClientState>* note, |
1207 GLRenderingVDAClient* client, | 1250 GLRenderingVDAClient* client, |
1208 ClientState expected_state) { | 1251 ClientState expected_state) { |
1209 ClientState state = note->Wait(); | 1252 ClientState state = note->Wait(); |
1210 if (state == expected_state) return; | 1253 if (state == expected_state) return; |
(...skipping 10 matching lines...) Expand all Loading... | |
1221 // Test the most straightforward case possible: data is decoded from a single | 1264 // Test the most straightforward case possible: data is decoded from a single |
1222 // chunk and rendered to the screen. | 1265 // chunk and rendered to the screen. |
1223 TEST_P(VideoDecodeAcceleratorParamTest, TestSimpleDecode) { | 1266 TEST_P(VideoDecodeAcceleratorParamTest, TestSimpleDecode) { |
1224 size_t num_concurrent_decoders = base::get<0>(GetParam()); | 1267 size_t num_concurrent_decoders = base::get<0>(GetParam()); |
1225 const size_t num_in_flight_decodes = base::get<1>(GetParam()); | 1268 const size_t num_in_flight_decodes = base::get<1>(GetParam()); |
1226 int num_play_throughs = base::get<2>(GetParam()); | 1269 int num_play_throughs = base::get<2>(GetParam()); |
1227 const int reset_point = base::get<3>(GetParam()); | 1270 const int reset_point = base::get<3>(GetParam()); |
1228 const int delete_decoder_state = base::get<4>(GetParam()); | 1271 const int delete_decoder_state = base::get<4>(GetParam()); |
1229 bool test_reuse_delay = base::get<5>(GetParam()); | 1272 bool test_reuse_delay = base::get<5>(GetParam()); |
1230 const bool render_as_thumbnails = base::get<6>(GetParam()); | 1273 const bool render_as_thumbnails = base::get<6>(GetParam()); |
1274 const bool test_full_flush = base::get<7>(GetParam()); | |
1231 | 1275 |
1232 if (test_video_files_.size() > 1) | 1276 if (test_video_files_.size() > 1) |
1233 num_concurrent_decoders = test_video_files_.size(); | 1277 num_concurrent_decoders = test_video_files_.size(); |
1234 | 1278 |
1235 if (g_num_play_throughs > 0) | 1279 if (g_num_play_throughs > 0) |
1236 num_play_throughs = g_num_play_throughs; | 1280 num_play_throughs = g_num_play_throughs; |
1237 | 1281 |
1238 UpdateTestVideoFileParams( | 1282 UpdateTestVideoFileParams( |
1239 num_concurrent_decoders, reset_point, &test_video_files_); | 1283 num_concurrent_decoders, reset_point, &test_video_files_); |
1240 | 1284 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1279 num_play_throughs, | 1323 num_play_throughs, |
1280 video_file->reset_after_frame_num, | 1324 video_file->reset_after_frame_num, |
1281 delete_decoder_state, | 1325 delete_decoder_state, |
1282 video_file->width, | 1326 video_file->width, |
1283 video_file->height, | 1327 video_file->height, |
1284 video_file->profile, | 1328 video_file->profile, |
1285 g_fake_decoder, | 1329 g_fake_decoder, |
1286 suppress_rendering, | 1330 suppress_rendering, |
1287 delay_after_frame_num, | 1331 delay_after_frame_num, |
1288 0, | 1332 0, |
1289 render_as_thumbnails); | 1333 render_as_thumbnails, |
1334 test_full_flush); | |
1290 | 1335 |
1291 clients[index] = client; | 1336 clients[index] = client; |
1292 helper_params.window_sizes.push_back( | 1337 helper_params.window_sizes.push_back( |
1293 render_as_thumbnails | 1338 render_as_thumbnails |
1294 ? kThumbnailsPageSize | 1339 ? kThumbnailsPageSize |
1295 : gfx::Size(video_file->width, video_file->height)); | 1340 : gfx::Size(video_file->width, video_file->height)); |
1296 } | 1341 } |
1297 | 1342 |
1298 InitializeRenderingHelper(helper_params); | 1343 InitializeRenderingHelper(helper_params); |
1299 | 1344 |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1431 &clients)); | 1476 &clients)); |
1432 g_env->GetRenderingTaskRunner()->PostTask( | 1477 g_env->GetRenderingTaskRunner()->PostTask( |
1433 FROM_HERE, | 1478 FROM_HERE, |
1434 base::Bind(&STLDeleteElements< | 1479 base::Bind(&STLDeleteElements< |
1435 std::vector<ClientStateNotification<ClientState>*>>, | 1480 std::vector<ClientStateNotification<ClientState>*>>, |
1436 ¬es)); | 1481 ¬es)); |
1437 WaitUntilIdle(); | 1482 WaitUntilIdle(); |
1438 }; | 1483 }; |
1439 | 1484 |
1440 // Test that replay after EOS works fine. | 1485 // Test that replay after EOS works fine. |
1441 INSTANTIATE_TEST_CASE_P( | 1486 INSTANTIATE_TEST_CASE_P(ReplayAfterEOS, |
1442 ReplayAfterEOS, VideoDecodeAcceleratorParamTest, | 1487 VideoDecodeAcceleratorParamTest, |
1443 ::testing::Values( | 1488 ::testing::Values(MakeTuple(1, |
1444 MakeTuple(1, 1, 4, END_OF_STREAM_RESET, CS_RESET, false, false))); | 1489 1, |
1490 4, | |
1491 END_OF_STREAM_RESET, | |
1492 CS_RESET, | |
1493 false, | |
1494 false, | |
1495 false))); | |
1445 | 1496 |
1446 // Test that Reset() before the first Decode() works fine. | 1497 // Test that Reset() before the first Decode() works fine. |
1447 INSTANTIATE_TEST_CASE_P( | 1498 INSTANTIATE_TEST_CASE_P(ResetBeforeDecode, |
1448 ResetBeforeDecode, VideoDecodeAcceleratorParamTest, | 1499 VideoDecodeAcceleratorParamTest, |
1449 ::testing::Values( | 1500 ::testing::Values(MakeTuple(1, |
1450 MakeTuple(1, 1, 1, START_OF_STREAM_RESET, CS_RESET, false, false))); | 1501 1, |
1502 1, | |
1503 START_OF_STREAM_RESET, | |
1504 CS_RESET, | |
1505 false, | |
1506 false, | |
1507 false))); | |
1451 | 1508 |
1452 // Test Reset() immediately after Decode() containing config info. | 1509 // Test Reset() immediately after Decode() containing config info. |
1453 INSTANTIATE_TEST_CASE_P( | 1510 INSTANTIATE_TEST_CASE_P( |
1454 ResetAfterFirstConfigInfo, VideoDecodeAcceleratorParamTest, | 1511 ResetAfterFirstConfigInfo, |
1455 ::testing::Values( | 1512 VideoDecodeAcceleratorParamTest, |
1456 MakeTuple( | 1513 ::testing::Values(MakeTuple(1, |
1457 1, 1, 1, RESET_AFTER_FIRST_CONFIG_INFO, CS_RESET, false, false))); | 1514 1, |
1515 1, | |
1516 RESET_AFTER_FIRST_CONFIG_INFO, | |
1517 CS_RESET, | |
1518 false, | |
1519 false, | |
1520 false))); | |
1458 | 1521 |
1459 // Test that Reset() mid-stream works fine and doesn't affect decoding even when | 1522 // Test that Reset() mid-stream works fine and doesn't affect decoding even when |
1460 // Decode() calls are made during the reset. | 1523 // Decode() calls are made during the reset. |
1461 INSTANTIATE_TEST_CASE_P( | 1524 INSTANTIATE_TEST_CASE_P( |
1462 MidStreamReset, VideoDecodeAcceleratorParamTest, | 1525 MidStreamReset, |
1526 VideoDecodeAcceleratorParamTest, | |
1463 ::testing::Values( | 1527 ::testing::Values( |
1464 MakeTuple(1, 1, 1, MID_STREAM_RESET, CS_RESET, false, false))); | 1528 MakeTuple(1, 1, 1, MID_STREAM_RESET, CS_RESET, false, false, false))); |
1529 | |
1530 // Test that the VDA returns all buffers to us on Flush(true). | |
1531 INSTANTIATE_TEST_CASE_P( | |
1532 FullFlush, | |
1533 VideoDecodeAcceleratorParamTest, | |
1534 ::testing::Values( | |
1535 MakeTuple(1, 1, 1, MID_STREAM_RESET, CS_RESET, false, false, true))); | |
1465 | 1536 |
1466 INSTANTIATE_TEST_CASE_P( | 1537 INSTANTIATE_TEST_CASE_P( |
1467 SlowRendering, VideoDecodeAcceleratorParamTest, | 1538 SlowRendering, |
1539 VideoDecodeAcceleratorParamTest, | |
1468 ::testing::Values( | 1540 ::testing::Values( |
1469 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_RESET, true, false))); | 1541 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_RESET, true, false, false))); |
1470 | 1542 |
1471 // Test that Destroy() mid-stream works fine (primarily this is testing that no | 1543 // Test that Destroy() mid-stream works fine (primarily this is testing that no |
1472 // crashes occur). | 1544 // crashes occur). |
1473 INSTANTIATE_TEST_CASE_P( | 1545 INSTANTIATE_TEST_CASE_P( |
1474 TearDownTiming, VideoDecodeAcceleratorParamTest, | 1546 TearDownTiming, |
1547 VideoDecodeAcceleratorParamTest, | |
1475 ::testing::Values( | 1548 ::testing::Values( |
1476 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_DECODER_SET, false, false), | 1549 MakeTuple(1, |
1477 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_INITIALIZED, false, false), | 1550 1, |
1478 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_FLUSHING, false, false), | 1551 1, |
1479 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_FLUSHED, false, false), | 1552 END_OF_STREAM_RESET, |
1480 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_RESETTING, false, false), | 1553 CS_DECODER_SET, |
1481 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_RESET, false, false), | 1554 false, |
1482 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, | 1555 false, |
1483 static_cast<ClientState>(-1), false, false), | 1556 false), |
1484 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, | 1557 MakeTuple(1, |
1485 static_cast<ClientState>(-10), false, false), | 1558 1, |
1486 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, | 1559 1, |
1487 static_cast<ClientState>(-100), false, false))); | 1560 END_OF_STREAM_RESET, |
1561 CS_INITIALIZED, | |
1562 false, | |
1563 false, | |
1564 false), | |
1565 MakeTuple(1, | |
1566 1, | |
1567 1, | |
1568 END_OF_STREAM_RESET, | |
1569 CS_FLUSHING, | |
1570 false, | |
1571 false, | |
1572 false), | |
1573 MakeTuple(1, | |
1574 1, | |
1575 1, | |
1576 END_OF_STREAM_RESET, | |
1577 CS_FLUSHED, | |
1578 false, | |
1579 false, | |
1580 false), | |
1581 MakeTuple(1, | |
1582 1, | |
1583 1, | |
1584 END_OF_STREAM_RESET, | |
1585 CS_RESETTING, | |
1586 false, | |
1587 false, | |
1588 false), | |
1589 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_RESET, false, false, false), | |
1590 MakeTuple(1, | |
1591 1, | |
1592 1, | |
1593 END_OF_STREAM_RESET, | |
1594 static_cast<ClientState>(-1), | |
1595 false, | |
1596 false, | |
1597 false), | |
1598 MakeTuple(1, | |
1599 1, | |
1600 1, | |
1601 END_OF_STREAM_RESET, | |
1602 static_cast<ClientState>(-10), | |
1603 false, | |
1604 false, | |
1605 false), | |
1606 MakeTuple(1, | |
1607 1, | |
1608 1, | |
1609 END_OF_STREAM_RESET, | |
1610 static_cast<ClientState>(-100), | |
1611 false, | |
1612 false, | |
1613 false))); | |
1488 | 1614 |
1489 // Test that decoding various variation works with multiple in-flight decodes. | 1615 // Test that decoding various variation works with multiple in-flight decodes. |
1490 INSTANTIATE_TEST_CASE_P( | 1616 INSTANTIATE_TEST_CASE_P( |
1491 DecodeVariations, VideoDecodeAcceleratorParamTest, | 1617 DecodeVariations, |
1618 VideoDecodeAcceleratorParamTest, | |
1492 ::testing::Values( | 1619 ::testing::Values( |
1493 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_RESET, false, false), | 1620 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_RESET, false, false, false), |
1494 MakeTuple(1, 10, 1, END_OF_STREAM_RESET, CS_RESET, false, false), | 1621 MakeTuple(1, 10, 1, END_OF_STREAM_RESET, CS_RESET, false, false, false), |
1495 // Tests queuing. | 1622 // Tests queuing. |
1496 MakeTuple(1, 15, 1, END_OF_STREAM_RESET, CS_RESET, false, false))); | 1623 MakeTuple(1, |
1624 15, | |
1625 1, | |
1626 END_OF_STREAM_RESET, | |
1627 CS_RESET, | |
1628 false, | |
1629 false, | |
1630 false))); | |
1497 | 1631 |
1498 // Find out how many concurrent decoders can go before we exhaust system | 1632 // Find out how many concurrent decoders can go before we exhaust system |
1499 // resources. | 1633 // resources. |
1500 INSTANTIATE_TEST_CASE_P( | 1634 INSTANTIATE_TEST_CASE_P(ResourceExhaustion, |
1501 ResourceExhaustion, VideoDecodeAcceleratorParamTest, | 1635 VideoDecodeAcceleratorParamTest, |
1502 ::testing::Values( | 1636 ::testing::Values( |
1503 // +0 hack below to promote enum to int. | 1637 // +0 hack below to promote enum to int. |
1504 MakeTuple(kMinSupportedNumConcurrentDecoders + 0, 1, 1, | 1638 MakeTuple(kMinSupportedNumConcurrentDecoders + 0, |
1505 END_OF_STREAM_RESET, CS_RESET, false, false), | 1639 1, |
1506 MakeTuple(kMinSupportedNumConcurrentDecoders + 1, 1, 1, | 1640 1, |
1507 END_OF_STREAM_RESET, CS_RESET, false, false))); | 1641 END_OF_STREAM_RESET, |
1642 CS_RESET, | |
1643 false, | |
1644 false, | |
1645 false), | |
1646 MakeTuple(kMinSupportedNumConcurrentDecoders + 1, | |
1647 1, | |
1648 1, | |
1649 END_OF_STREAM_RESET, | |
1650 CS_RESET, | |
1651 false, | |
1652 false, | |
1653 false))); | |
1508 | 1654 |
1509 // Thumbnailing test | 1655 // Thumbnailing test |
1510 INSTANTIATE_TEST_CASE_P( | 1656 INSTANTIATE_TEST_CASE_P( |
1511 Thumbnail, VideoDecodeAcceleratorParamTest, | 1657 Thumbnail, |
1658 VideoDecodeAcceleratorParamTest, | |
1512 ::testing::Values( | 1659 ::testing::Values( |
1513 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_RESET, false, true))); | 1660 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_RESET, false, true, false))); |
1514 | 1661 |
1515 // Measure the median of the decode time when VDA::Decode is called 30 times per | 1662 // Measure the median of the decode time when VDA::Decode is called 30 times per |
1516 // second. | 1663 // second. |
1517 TEST_F(VideoDecodeAcceleratorTest, TestDecodeTimeMedian) { | 1664 TEST_F(VideoDecodeAcceleratorTest, TestDecodeTimeMedian) { |
1518 RenderingHelperParams helper_params; | 1665 RenderingHelperParams helper_params; |
1519 | 1666 |
1520 // Disable rendering by setting the rendering_fps = 0. | 1667 // Disable rendering by setting the rendering_fps = 0. |
1521 helper_params.rendering_fps = 0; | 1668 helper_params.rendering_fps = 0; |
1522 helper_params.warm_up_iterations = 0; | 1669 helper_params.warm_up_iterations = 0; |
1523 helper_params.render_as_thumbnails = false; | 1670 helper_params.render_as_thumbnails = false; |
1524 | 1671 |
1525 ClientStateNotification<ClientState>* note = | 1672 ClientStateNotification<ClientState>* note = |
1526 new ClientStateNotification<ClientState>(); | 1673 new ClientStateNotification<ClientState>(); |
1527 GLRenderingVDAClient* client = | 1674 GLRenderingVDAClient* client = |
1528 new GLRenderingVDAClient(0, | 1675 new GLRenderingVDAClient(0, |
1529 &rendering_helper_, | 1676 &rendering_helper_, |
1530 note, | 1677 note, |
1531 test_video_files_[0]->data_str, | 1678 test_video_files_[0]->data_str, |
1532 1, | 1679 1, |
1533 1, | 1680 1, |
1534 test_video_files_[0]->reset_after_frame_num, | 1681 test_video_files_[0]->reset_after_frame_num, |
1535 CS_RESET, | 1682 CS_RESET, |
1536 test_video_files_[0]->width, | 1683 test_video_files_[0]->width, |
1537 test_video_files_[0]->height, | 1684 test_video_files_[0]->height, |
1538 test_video_files_[0]->profile, | 1685 test_video_files_[0]->profile, |
1539 g_fake_decoder, | 1686 g_fake_decoder, |
1540 true, | 1687 true, |
1541 std::numeric_limits<int>::max(), | 1688 std::numeric_limits<int>::max(), |
1542 kWebRtcDecodeCallsPerSecond, | 1689 kWebRtcDecodeCallsPerSecond, |
1543 false /* render_as_thumbnail */); | 1690 false /* render_as_thumbnail */, |
1691 false /* test_full_flush */); | |
1544 helper_params.window_sizes.push_back( | 1692 helper_params.window_sizes.push_back( |
1545 gfx::Size(test_video_files_[0]->width, test_video_files_[0]->height)); | 1693 gfx::Size(test_video_files_[0]->width, test_video_files_[0]->height)); |
1546 InitializeRenderingHelper(helper_params); | 1694 InitializeRenderingHelper(helper_params); |
1547 CreateAndStartDecoder(client, note); | 1695 CreateAndStartDecoder(client, note); |
1548 WaitUntilDecodeFinish(note); | 1696 WaitUntilDecodeFinish(note); |
1549 | 1697 |
1550 base::TimeDelta decode_time_median = client->decode_time_median(); | 1698 base::TimeDelta decode_time_median = client->decode_time_median(); |
1551 std::string output_string = | 1699 std::string output_string = |
1552 base::StringPrintf("Decode time median: %" PRId64 " us", | 1700 base::StringPrintf("Decode time median: %" PRId64 " us", |
1553 decode_time_median.InMicroseconds()); | 1701 decode_time_median.InMicroseconds()); |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1647 content::VaapiWrapper::PreSandboxInitialization(); | 1795 content::VaapiWrapper::PreSandboxInitialization(); |
1648 #endif | 1796 #endif |
1649 | 1797 |
1650 content::g_env = | 1798 content::g_env = |
1651 reinterpret_cast<content::VideoDecodeAcceleratorTestEnvironment*>( | 1799 reinterpret_cast<content::VideoDecodeAcceleratorTestEnvironment*>( |
1652 testing::AddGlobalTestEnvironment( | 1800 testing::AddGlobalTestEnvironment( |
1653 new content::VideoDecodeAcceleratorTestEnvironment())); | 1801 new content::VideoDecodeAcceleratorTestEnvironment())); |
1654 | 1802 |
1655 return RUN_ALL_TESTS(); | 1803 return RUN_ALL_TESTS(); |
1656 } | 1804 } |
OLD | NEW |