Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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, and GLES2. | 7 // - RenderingHelper is charged with interacting with X11, EGL, and GLES2. |
| 8 // - ClientState is an enum for the state of the decode client used by the test. | 8 // - ClientState is an enum for the state of the decode client used by the test. |
| 9 // - ClientStateNotification is a barrier abstraction that allows the test code | 9 // - ClientStateNotification is a barrier abstraction that allows the test code |
| 10 // to be written sequentially and wait for the decode client to see certain | 10 // to be written sequentially and wait for the decode client to see certain |
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 455 // Reset() should be done after that frame number is delivered, or | 455 // Reset() should be done after that frame number is delivered, or |
| 456 // END_OF_STREAM_RESET to indicate no mid-stream Reset(). | 456 // END_OF_STREAM_RESET to indicate no mid-stream Reset(). |
| 457 // |delete_decoder_state| indicates when the underlying decoder should be | 457 // |delete_decoder_state| indicates when the underlying decoder should be |
| 458 // Destroy()'d and deleted and can take values: N<0: delete after -N Decode() | 458 // Destroy()'d and deleted and can take values: N<0: delete after -N Decode() |
| 459 // calls have been made, N>=0 means interpret as ClientState. | 459 // calls have been made, N>=0 means interpret as ClientState. |
| 460 EglRenderingVDAClient(RenderingHelper* rendering_helper, | 460 EglRenderingVDAClient(RenderingHelper* rendering_helper, |
| 461 int rendering_window_id, | 461 int rendering_window_id, |
| 462 ClientStateNotification* note, | 462 ClientStateNotification* note, |
| 463 const std::string& encoded_data, | 463 const std::string& encoded_data, |
| 464 int num_NALUs_per_decode, | 464 int num_NALUs_per_decode, |
| 465 int num_in_flight_decodes, | |
| 465 int reset_after_frame_num, | 466 int reset_after_frame_num, |
| 466 int delete_decoder_state); | 467 int delete_decoder_state); |
| 467 virtual ~EglRenderingVDAClient(); | 468 virtual ~EglRenderingVDAClient(); |
| 468 void CreateDecoder(); | 469 void CreateDecoder(); |
| 469 | 470 |
| 470 // VideoDecodeAccelerator::Client implementation. | 471 // VideoDecodeAccelerator::Client implementation. |
| 471 // The heart of the Client. | 472 // The heart of the Client. |
| 472 virtual void ProvidePictureBuffers( | 473 virtual void ProvidePictureBuffers( |
| 473 uint32 requested_num_of_buffers, | 474 uint32 requested_num_of_buffers, |
| 474 const gfx::Size& dimensions); | 475 const gfx::Size& dimensions); |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 503 // to ship to the decoder (based on |start_pos| & |num_NALUs_per_decode_|). | 504 // to ship to the decoder (based on |start_pos| & |num_NALUs_per_decode_|). |
| 504 void GetRangeForNextNALUs(size_t start_pos, size_t* end_pos); | 505 void GetRangeForNextNALUs(size_t start_pos, size_t* end_pos); |
| 505 | 506 |
| 506 // Request decode of the next batch of NALUs in the encoded data. | 507 // Request decode of the next batch of NALUs in the encoded data. |
| 507 void DecodeNextNALUs(); | 508 void DecodeNextNALUs(); |
| 508 | 509 |
| 509 RenderingHelper* rendering_helper_; | 510 RenderingHelper* rendering_helper_; |
| 510 int rendering_window_id_; | 511 int rendering_window_id_; |
| 511 std::string encoded_data_; | 512 std::string encoded_data_; |
| 512 const int num_NALUs_per_decode_; | 513 const int num_NALUs_per_decode_; |
| 514 const int num_in_flight_decodes_; | |
| 515 int outstanding_decodes_; | |
| 513 size_t encoded_data_next_pos_to_decode_; | 516 size_t encoded_data_next_pos_to_decode_; |
| 514 int next_bitstream_buffer_id_; | 517 int next_bitstream_buffer_id_; |
| 515 ClientStateNotification* note_; | 518 ClientStateNotification* note_; |
| 516 scoped_refptr<OmxVideoDecodeAccelerator> decoder_; | 519 scoped_refptr<OmxVideoDecodeAccelerator> decoder_; |
| 517 std::set<int> outstanding_texture_ids_; | 520 std::set<int> outstanding_texture_ids_; |
| 518 int reset_after_frame_num_; | 521 int reset_after_frame_num_; |
| 519 int delete_decoder_state_; | 522 int delete_decoder_state_; |
| 520 ClientState state_; | 523 ClientState state_; |
| 521 int num_decoded_frames_; | 524 int num_decoded_frames_; |
| 522 int num_done_bitstream_buffers_; | 525 int num_done_bitstream_buffers_; |
| 523 PictureBufferById picture_buffers_by_id_; | 526 PictureBufferById picture_buffers_by_id_; |
| 524 base::TimeTicks initialize_done_ticks_; | 527 base::TimeTicks initialize_done_ticks_; |
| 525 base::TimeTicks last_frame_delivered_ticks_; | 528 base::TimeTicks last_frame_delivered_ticks_; |
| 526 }; | 529 }; |
| 527 | 530 |
| 528 EglRenderingVDAClient::EglRenderingVDAClient( | 531 EglRenderingVDAClient::EglRenderingVDAClient( |
| 529 RenderingHelper* rendering_helper, | 532 RenderingHelper* rendering_helper, |
| 530 int rendering_window_id, | 533 int rendering_window_id, |
| 531 ClientStateNotification* note, | 534 ClientStateNotification* note, |
| 532 const std::string& encoded_data, | 535 const std::string& encoded_data, |
| 533 int num_NALUs_per_decode, | 536 int num_NALUs_per_decode, |
| 537 int num_in_flight_decodes, | |
| 534 int reset_after_frame_num, | 538 int reset_after_frame_num, |
| 535 int delete_decoder_state) | 539 int delete_decoder_state) |
| 536 : rendering_helper_(rendering_helper), | 540 : rendering_helper_(rendering_helper), |
| 537 rendering_window_id_(rendering_window_id), | 541 rendering_window_id_(rendering_window_id), |
| 538 encoded_data_(encoded_data), num_NALUs_per_decode_(num_NALUs_per_decode), | 542 encoded_data_(encoded_data), num_NALUs_per_decode_(num_NALUs_per_decode), |
| 543 num_in_flight_decodes_(num_in_flight_decodes), outstanding_decodes_(0), | |
| 539 encoded_data_next_pos_to_decode_(0), next_bitstream_buffer_id_(0), | 544 encoded_data_next_pos_to_decode_(0), next_bitstream_buffer_id_(0), |
| 540 note_(note), reset_after_frame_num_(reset_after_frame_num), | 545 note_(note), reset_after_frame_num_(reset_after_frame_num), |
| 541 delete_decoder_state_(delete_decoder_state), | 546 delete_decoder_state_(delete_decoder_state), |
| 542 state_(CS_CREATED), | 547 state_(CS_CREATED), |
| 543 num_decoded_frames_(0), num_done_bitstream_buffers_(0) { | 548 num_decoded_frames_(0), num_done_bitstream_buffers_(0) { |
| 544 CHECK_GT(num_NALUs_per_decode, 0); | 549 CHECK_GT(num_NALUs_per_decode, 0); |
| 550 CHECK_GT(num_in_flight_decodes, 0); | |
| 545 } | 551 } |
| 546 | 552 |
| 547 EglRenderingVDAClient::~EglRenderingVDAClient() { | 553 EglRenderingVDAClient::~EglRenderingVDAClient() { |
| 548 DeleteDecoder(); // Clean up in case of expected error. | 554 DeleteDecoder(); // Clean up in case of expected error. |
| 549 CHECK(decoder_deleted()); | 555 CHECK(decoder_deleted()); |
| 550 STLDeleteValues(&picture_buffers_by_id_); | 556 STLDeleteValues(&picture_buffers_by_id_); |
| 551 SetState(CS_DESTROYED); | 557 SetState(CS_DESTROYED); |
| 552 } | 558 } |
| 553 | 559 |
| 554 void EglRenderingVDAClient::CreateDecoder() { | 560 void EglRenderingVDAClient::CreateDecoder() { |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 632 picture_buffers_by_id_[picture.picture_buffer_id()]; | 638 picture_buffers_by_id_[picture.picture_buffer_id()]; |
| 633 CHECK(picture_buffer); | 639 CHECK(picture_buffer); |
| 634 rendering_helper_->RenderTexture(picture_buffer->texture_id()); | 640 rendering_helper_->RenderTexture(picture_buffer->texture_id()); |
| 635 | 641 |
| 636 decoder_->ReusePictureBuffer(picture.picture_buffer_id()); | 642 decoder_->ReusePictureBuffer(picture.picture_buffer_id()); |
| 637 } | 643 } |
| 638 | 644 |
| 639 void EglRenderingVDAClient::NotifyInitializeDone() { | 645 void EglRenderingVDAClient::NotifyInitializeDone() { |
| 640 SetState(CS_INITIALIZED); | 646 SetState(CS_INITIALIZED); |
| 641 initialize_done_ticks_ = base::TimeTicks::Now(); | 647 initialize_done_ticks_ = base::TimeTicks::Now(); |
| 642 DecodeNextNALUs(); | 648 for (int i = 0; i < num_in_flight_decodes_; ++i) |
| 649 DecodeNextNALUs(); | |
| 643 } | 650 } |
| 644 | 651 |
| 645 void EglRenderingVDAClient::NotifyEndOfStream() { | 652 void EglRenderingVDAClient::NotifyEndOfStream() { |
| 646 SetState(CS_DONE); | 653 SetState(CS_DONE); |
| 647 } | 654 } |
| 648 | 655 |
| 649 void EglRenderingVDAClient::NotifyEndOfBitstreamBuffer( | 656 void EglRenderingVDAClient::NotifyEndOfBitstreamBuffer( |
| 650 int32 bitstream_buffer_id) { | 657 int32 bitstream_buffer_id) { |
| 651 ++num_done_bitstream_buffers_; | 658 ++num_done_bitstream_buffers_; |
| 659 --outstanding_decodes_; | |
| 652 DecodeNextNALUs(); | 660 DecodeNextNALUs(); |
| 653 } | 661 } |
| 654 | 662 |
| 655 void EglRenderingVDAClient::NotifyFlushDone() { | 663 void EglRenderingVDAClient::NotifyFlushDone() { |
| 656 if (decoder_deleted()) | 664 if (decoder_deleted()) |
| 657 return; | 665 return; |
| 658 SetState(CS_FLUSHED); | 666 SetState(CS_FLUSHED); |
| 659 if (decoder_deleted()) | 667 if (decoder_deleted()) |
| 660 return; | 668 return; |
| 661 decoder_->Reset(); | 669 decoder_->Reset(); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 723 *end_pos = encoded_data_.size(); | 731 *end_pos = encoded_data_.size(); |
| 724 return; | 732 return; |
| 725 } | 733 } |
| 726 } | 734 } |
| 727 } | 735 } |
| 728 | 736 |
| 729 void EglRenderingVDAClient::DecodeNextNALUs() { | 737 void EglRenderingVDAClient::DecodeNextNALUs() { |
| 730 if (decoder_deleted()) | 738 if (decoder_deleted()) |
| 731 return; | 739 return; |
| 732 if (encoded_data_next_pos_to_decode_ == encoded_data_.size()) { | 740 if (encoded_data_next_pos_to_decode_ == encoded_data_.size()) { |
| 733 decoder_->Flush(); | 741 if (outstanding_decodes_ == 0) { |
| 734 SetState(CS_FLUSHING); | 742 decoder_->Flush(); |
| 743 SetState(CS_FLUSHING); | |
| 744 } | |
| 735 return; | 745 return; |
| 736 } | 746 } |
| 737 size_t start_pos = encoded_data_next_pos_to_decode_; | 747 size_t start_pos = encoded_data_next_pos_to_decode_; |
| 738 size_t end_pos; | 748 size_t end_pos; |
| 739 GetRangeForNextNALUs(start_pos, &end_pos); | 749 GetRangeForNextNALUs(start_pos, &end_pos); |
| 740 | 750 |
| 741 // Populate the shared memory buffer w/ the NALU, duplicate its handle, and | 751 // Populate the shared memory buffer w/ the NALU, duplicate its handle, and |
| 742 // hand it off to the decoder. | 752 // hand it off to the decoder. |
| 743 base::SharedMemory shm; | 753 base::SharedMemory shm; |
| 744 CHECK(shm.CreateAndMapAnonymous(end_pos - start_pos)) | 754 CHECK(shm.CreateAndMapAnonymous(end_pos - start_pos)) |
| 745 << start_pos << ", " << end_pos; | 755 << start_pos << ", " << end_pos; |
| 746 memcpy(shm.memory(), encoded_data_.data() + start_pos, end_pos - start_pos); | 756 memcpy(shm.memory(), encoded_data_.data() + start_pos, end_pos - start_pos); |
| 747 base::SharedMemoryHandle dup_handle; | 757 base::SharedMemoryHandle dup_handle; |
| 748 CHECK(shm.ShareToProcess(base::Process::Current().handle(), &dup_handle)); | 758 CHECK(shm.ShareToProcess(base::Process::Current().handle(), &dup_handle)); |
| 749 media::BitstreamBuffer bitstream_buffer( | 759 media::BitstreamBuffer bitstream_buffer( |
| 750 next_bitstream_buffer_id_++, dup_handle, end_pos - start_pos); | 760 next_bitstream_buffer_id_++, dup_handle, end_pos - start_pos); |
| 751 decoder_->Decode(bitstream_buffer); | 761 decoder_->Decode(bitstream_buffer); |
| 762 ++outstanding_decodes_; | |
| 752 encoded_data_next_pos_to_decode_ = end_pos; | 763 encoded_data_next_pos_to_decode_ = end_pos; |
| 753 | 764 |
| 754 if (-delete_decoder_state_ == next_bitstream_buffer_id_) | 765 if (-delete_decoder_state_ == next_bitstream_buffer_id_) |
| 755 DeleteDecoder(); | 766 DeleteDecoder(); |
| 756 } | 767 } |
| 757 | 768 |
| 758 double EglRenderingVDAClient::frames_per_second() { | 769 double EglRenderingVDAClient::frames_per_second() { |
| 759 base::TimeDelta delta = last_frame_delivered_ticks_ - initialize_done_ticks_; | 770 base::TimeDelta delta = last_frame_delivered_ticks_ - initialize_done_ticks_; |
| 760 if (delta.InSecondsF() == 0) | 771 if (delta.InSecondsF() == 0) |
| 761 return 0; | 772 return 0; |
| 762 return num_decoded_frames_ / delta.InSecondsF(); | 773 return num_decoded_frames_ / delta.InSecondsF(); |
| 763 } | 774 } |
| 764 | 775 |
| 765 // Test parameters: | 776 // Test parameters: |
| 766 // - Number of NALUs per Decode() call. | 777 // - Number of NALUs per Decode() call. |
| 778 // - Number of concurrent in-flight Decode() calls per decoder. | |
|
vrk (LEFT CHROMIUM)
2011/08/12 20:56:59
nit: order of params is wrong (should be 3rd param
| |
| 767 // - Number of concurrent decoders. | 779 // - Number of concurrent decoders. |
| 768 // - reset_after_frame_num: see EglRenderingVDAClient ctor. | 780 // - reset_after_frame_num: see EglRenderingVDAClient ctor. |
| 769 // - delete_decoder_phase: see EglRenderingVDAClient ctor. | 781 // - delete_decoder_phase: see EglRenderingVDAClient ctor. |
| 770 class OmxVideoDecodeAcceleratorTest | 782 class OmxVideoDecodeAcceleratorTest |
| 771 : public ::testing::TestWithParam< | 783 : public ::testing::TestWithParam< |
| 772 Tuple4<int, int, ResetPoint, ClientState> > { | 784 Tuple5<int, int, int, ResetPoint, ClientState> > { |
| 773 }; | 785 }; |
| 774 | 786 |
| 775 // Wait for |note| to report a state and if it's not |expected_state| then | 787 // Wait for |note| to report a state and if it's not |expected_state| then |
| 776 // assert |client| has deleted its decoder. | 788 // assert |client| has deleted its decoder. |
| 777 static void AssertWaitForStateOrDeleted(ClientStateNotification* note, | 789 static void AssertWaitForStateOrDeleted(ClientStateNotification* note, |
| 778 EglRenderingVDAClient* client, | 790 EglRenderingVDAClient* client, |
| 779 ClientState expected_state) { | 791 ClientState expected_state) { |
| 780 ClientState state = note->Wait(); | 792 ClientState state = note->Wait(); |
| 781 if (state == expected_state) return; | 793 if (state == expected_state) return; |
| 782 ASSERT_TRUE(client->decoder_deleted()) | 794 ASSERT_TRUE(client->decoder_deleted()) |
| 783 << "Decoder not deleted but Wait() returned " << state | 795 << "Decoder not deleted but Wait() returned " << state |
| 784 << ", instead of " << expected_state; | 796 << ", instead of " << expected_state; |
| 785 } | 797 } |
| 786 | 798 |
| 787 // We assert the exact number of concurrent decoders we expect to succeed and | 799 // We assert the exact number of concurrent decoders we expect to succeed and |
| 788 // that one more than that fails initialization. | 800 // that one more than that fails initialization. |
| 789 enum { kMaxSupportedNumConcurrentDecoders = 5 }; | 801 enum { kMaxSupportedNumConcurrentDecoders = 5 }; |
| 790 | 802 |
| 791 // Test the most straightforward case possible: data is decoded from a single | 803 // Test the most straightforward case possible: data is decoded from a single |
| 792 // chunk and rendered to the screen. | 804 // chunk and rendered to the screen. |
| 793 TEST_P(OmxVideoDecodeAcceleratorTest, TestSimpleDecode) { | 805 TEST_P(OmxVideoDecodeAcceleratorTest, TestSimpleDecode) { |
| 794 // Can be useful for debugging VLOGs from OVDA. | 806 // Can be useful for debugging VLOGs from OVDA. |
| 795 // logging::SetMinLogLevel(-1); | 807 // logging::SetMinLogLevel(-1); |
| 796 | 808 |
| 797 // Required for Thread to work. Not used otherwise. | 809 // Required for Thread to work. Not used otherwise. |
| 798 base::ShadowingAtExitManager at_exit_manager; | 810 base::ShadowingAtExitManager at_exit_manager; |
| 799 | 811 |
| 800 const int num_NALUs_per_decode = GetParam().a; | 812 const int num_NALUs_per_decode = GetParam().a; |
| 801 const size_t num_concurrent_decoders = GetParam().b; | 813 const size_t num_concurrent_decoders = GetParam().b; |
| 802 const int reset_after_frame_num = GetParam().c; | 814 const size_t num_in_flight_decodes = GetParam().c; |
| 803 const int delete_decoder_state = GetParam().d; | 815 const int reset_after_frame_num = GetParam().d; |
| 816 const int delete_decoder_state = GetParam().e; | |
| 804 | 817 |
| 805 std::string test_video_file; | 818 std::string test_video_file; |
| 806 int frame_width, frame_height; | 819 int frame_width, frame_height; |
| 807 int num_frames, num_NALUs, min_fps_render, min_fps_no_render; | 820 int num_frames, num_NALUs, min_fps_render, min_fps_no_render; |
| 808 ParseTestVideoData(test_video_data, &test_video_file, &frame_width, | 821 ParseTestVideoData(test_video_data, &test_video_file, &frame_width, |
| 809 &frame_height, &num_frames, &num_NALUs, | 822 &frame_height, &num_frames, &num_NALUs, |
| 810 &min_fps_render, &min_fps_no_render); | 823 &min_fps_render, &min_fps_no_render); |
| 811 min_fps_render /= num_concurrent_decoders; | 824 min_fps_render /= num_concurrent_decoders; |
| 812 min_fps_no_render /= num_concurrent_decoders; | 825 min_fps_no_render /= num_concurrent_decoders; |
| 813 | 826 |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 841 frame_width, frame_height, &done)); | 854 frame_width, frame_height, &done)); |
| 842 done.Wait(); | 855 done.Wait(); |
| 843 | 856 |
| 844 // First kick off all the decoders. | 857 // First kick off all the decoders. |
| 845 for (size_t index = 0; index < num_concurrent_decoders; ++index) { | 858 for (size_t index = 0; index < num_concurrent_decoders; ++index) { |
| 846 ClientStateNotification* note = new ClientStateNotification(); | 859 ClientStateNotification* note = new ClientStateNotification(); |
| 847 notes[index] = note; | 860 notes[index] = note; |
| 848 EglRenderingVDAClient* client = new EglRenderingVDAClient( | 861 EglRenderingVDAClient* client = new EglRenderingVDAClient( |
| 849 &rendering_helper, index, | 862 &rendering_helper, index, |
| 850 note, data_str, num_NALUs_per_decode, | 863 note, data_str, num_NALUs_per_decode, |
| 864 num_in_flight_decodes, | |
| 851 reset_after_frame_num, delete_decoder_state); | 865 reset_after_frame_num, delete_decoder_state); |
| 852 clients[index] = client; | 866 clients[index] = client; |
| 853 | 867 |
| 854 rendering_thread.message_loop()->PostTask( | 868 rendering_thread.message_loop()->PostTask( |
| 855 FROM_HERE, | 869 FROM_HERE, |
| 856 base::Bind(&EglRenderingVDAClient::CreateDecoder, | 870 base::Bind(&EglRenderingVDAClient::CreateDecoder, |
| 857 base::Unretained(client))); | 871 base::Unretained(client))); |
| 858 | 872 |
| 859 ASSERT_EQ(note->Wait(), CS_DECODER_SET); | 873 ASSERT_EQ(note->Wait(), CS_DECODER_SET); |
| 860 } | 874 } |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 924 &done)); | 938 &done)); |
| 925 done.Wait(); | 939 done.Wait(); |
| 926 rendering_thread.Stop(); | 940 rendering_thread.Stop(); |
| 927 }; | 941 }; |
| 928 | 942 |
| 929 // Test that Reset() mid-stream works fine and doesn't affect decoding even when | 943 // Test that Reset() mid-stream works fine and doesn't affect decoding even when |
| 930 // Decode() calls are made during the reset. | 944 // Decode() calls are made during the reset. |
| 931 INSTANTIATE_TEST_CASE_P( | 945 INSTANTIATE_TEST_CASE_P( |
| 932 MidStreamReset, OmxVideoDecodeAcceleratorTest, | 946 MidStreamReset, OmxVideoDecodeAcceleratorTest, |
| 933 ::testing::Values( | 947 ::testing::Values( |
| 934 MakeTuple(1, 1, static_cast<ResetPoint>(100), CS_RESET))); | 948 MakeTuple(1, 1, 1, static_cast<ResetPoint>(100), CS_RESET))); |
| 935 | 949 |
| 936 // Test that Destroy() mid-stream works fine (primarily this is testing that no | 950 // Test that Destroy() mid-stream works fine (primarily this is testing that no |
| 937 // crashes occur). | 951 // crashes occur). |
| 938 INSTANTIATE_TEST_CASE_P( | 952 INSTANTIATE_TEST_CASE_P( |
| 939 TearDownTiming, OmxVideoDecodeAcceleratorTest, | 953 TearDownTiming, OmxVideoDecodeAcceleratorTest, |
| 940 ::testing::Values( | 954 ::testing::Values( |
| 941 MakeTuple(1, 1, END_OF_STREAM_RESET, CS_DECODER_SET), | 955 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_DECODER_SET), |
| 942 MakeTuple(1, 1, END_OF_STREAM_RESET, CS_INITIALIZED), | 956 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_INITIALIZED), |
| 943 MakeTuple(1, 1, END_OF_STREAM_RESET, CS_FLUSHING), | 957 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_FLUSHING), |
| 944 MakeTuple(1, 1, END_OF_STREAM_RESET, CS_FLUSHED), | 958 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_FLUSHED), |
| 945 MakeTuple(1, 1, END_OF_STREAM_RESET, CS_RESETTING), | 959 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_RESETTING), |
| 946 MakeTuple(1, 1, END_OF_STREAM_RESET, CS_RESET), | 960 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_RESET), |
| 947 MakeTuple(1, 1, END_OF_STREAM_RESET, static_cast<ClientState>(-1)), | 961 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, static_cast<ClientState>(-1)), |
| 948 MakeTuple(1, 1, END_OF_STREAM_RESET, static_cast<ClientState>(-10)), | 962 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, static_cast<ClientState>(-10)), |
| 949 MakeTuple(1, 1, END_OF_STREAM_RESET, static_cast<ClientState>(-100)))); | 963 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, |
| 964 static_cast<ClientState>(-100)))); | |
| 950 | 965 |
| 951 // Test that decoding various variation works: multiple concurrent decoders and | 966 // Test that decoding various variation works: multiple concurrent decoders and |
| 952 // multiple NALUs per Decode() call. | 967 // multiple NALUs per Decode() call. |
| 953 INSTANTIATE_TEST_CASE_P( | 968 INSTANTIATE_TEST_CASE_P( |
| 954 DecodeVariations, OmxVideoDecodeAcceleratorTest, | 969 DecodeVariations, OmxVideoDecodeAcceleratorTest, |
| 955 ::testing::Values( | 970 ::testing::Values( |
| 956 MakeTuple(1, 1, END_OF_STREAM_RESET, CS_RESET), | 971 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_RESET), |
| 957 MakeTuple(1, 3, END_OF_STREAM_RESET, CS_RESET), | 972 MakeTuple(1, 1, 10, END_OF_STREAM_RESET, CS_RESET), |
| 958 MakeTuple(2, 1, END_OF_STREAM_RESET, CS_RESET), | 973 MakeTuple(1, 1, 15, END_OF_STREAM_RESET, CS_RESET), // Tests queuing. |
| 959 MakeTuple(3, 1, END_OF_STREAM_RESET, CS_RESET), | 974 MakeTuple(1, 3, 1, END_OF_STREAM_RESET, CS_RESET), |
| 960 MakeTuple(5, 1, END_OF_STREAM_RESET, CS_RESET), | 975 MakeTuple(2, 1, 1, END_OF_STREAM_RESET, CS_RESET), |
| 961 MakeTuple(8, 1, END_OF_STREAM_RESET, CS_RESET), | 976 MakeTuple(3, 1, 1, END_OF_STREAM_RESET, CS_RESET), |
| 977 MakeTuple(5, 1, 1, END_OF_STREAM_RESET, CS_RESET), | |
| 978 MakeTuple(8, 1, 1, END_OF_STREAM_RESET, CS_RESET), | |
| 962 // TODO(fischman): decoding more than 15 NALUs at once breaks decode - | 979 // TODO(fischman): decoding more than 15 NALUs at once breaks decode - |
| 963 // visual artifacts are introduced as well as spurious frames are | 980 // visual artifacts are introduced as well as spurious frames are |
| 964 // delivered (more pictures are returned than NALUs are fed to the | 981 // delivered (more pictures are returned than NALUs are fed to the |
| 965 // decoder). Increase the "15" below when | 982 // decoder). Increase the "15" below when |
| 966 // http://code.google.com/p/chrome-os-partner/issues/detail?id=4378 is | 983 // http://code.google.com/p/chrome-os-partner/issues/detail?id=4378 is |
| 967 // fixed. | 984 // fixed. |
| 968 MakeTuple(15, 1, END_OF_STREAM_RESET, CS_RESET))); | 985 MakeTuple(15, 1, 1, END_OF_STREAM_RESET, CS_RESET))); |
| 969 | 986 |
| 970 // Find out how many concurrent decoders can go before we exhaust system | 987 // Find out how many concurrent decoders can go before we exhaust system |
| 971 // resources. | 988 // resources. |
| 972 INSTANTIATE_TEST_CASE_P( | 989 INSTANTIATE_TEST_CASE_P( |
| 973 ResourceExhaustion, OmxVideoDecodeAcceleratorTest, | 990 ResourceExhaustion, OmxVideoDecodeAcceleratorTest, |
| 974 ::testing::Values( | 991 ::testing::Values( |
| 975 // +0 hack below to promote enum to int. | 992 // +0 hack below to promote enum to int. |
| 976 MakeTuple(1, kMaxSupportedNumConcurrentDecoders + 0, | 993 MakeTuple(1, kMaxSupportedNumConcurrentDecoders + 0, 1, |
| 977 END_OF_STREAM_RESET, CS_RESET), | 994 END_OF_STREAM_RESET, CS_RESET), |
| 978 MakeTuple(1, kMaxSupportedNumConcurrentDecoders + 1, | 995 MakeTuple(1, kMaxSupportedNumConcurrentDecoders + 1, 1, |
| 979 END_OF_STREAM_RESET, CS_RESET))); | 996 END_OF_STREAM_RESET, CS_RESET))); |
| 980 | 997 |
| 981 // TODO(fischman, vrk): add more tests! In particular: | 998 // TODO(fischman, vrk): add more tests! In particular: |
| 982 // - Test life-cycle: Seek/Stop/Pause/Play/RePlay for a single decoder. | 999 // - Test life-cycle: Seek/Stop/Pause/Play/RePlay for a single decoder. |
| 983 // - Test alternate configurations | 1000 // - Test alternate configurations |
| 984 // - Test failure conditions. | 1001 // - Test failure conditions. |
| 985 // - Test frame size changes mid-stream | 1002 // - Test frame size changes mid-stream |
| 986 | 1003 |
| 987 } // namespace | 1004 } // namespace |
| 988 | 1005 |
| 989 int main(int argc, char **argv) { | 1006 int main(int argc, char **argv) { |
| 990 testing::InitGoogleTest(&argc, argv); // Removes gtest-specific args. | 1007 testing::InitGoogleTest(&argc, argv); // Removes gtest-specific args. |
| 991 CommandLine cmd_line(argc, argv); // Must run after InitGoogleTest. | 1008 CommandLine cmd_line(argc, argv); // Must run after InitGoogleTest. |
| 992 CommandLine::SwitchMap switches = cmd_line.GetSwitches(); | 1009 CommandLine::SwitchMap switches = cmd_line.GetSwitches(); |
| 993 for (CommandLine::SwitchMap::const_iterator it = switches.begin(); | 1010 for (CommandLine::SwitchMap::const_iterator it = switches.begin(); |
| 994 it != switches.end(); ++it) { | 1011 it != switches.end(); ++it) { |
| 995 if (it->first == "test_video_data") { | 1012 if (it->first == "test_video_data") { |
| 996 test_video_data = it->second.c_str(); | 1013 test_video_data = it->second.c_str(); |
| 997 continue; | 1014 continue; |
| 998 } | 1015 } |
| 999 LOG(FATAL) << "Unexpected switch: " << it->first << ":" << it->second; | 1016 LOG(FATAL) << "Unexpected switch: " << it->first << ":" << it->second; |
| 1000 } | 1017 } |
| 1001 | 1018 |
| 1002 return RUN_ALL_TESTS(); | 1019 return RUN_ALL_TESTS(); |
| 1003 } | 1020 } |
| OLD | NEW |