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 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
569 | 569 |
570 void EglRenderingVDAClient::CreateDecoder() { | 570 void EglRenderingVDAClient::CreateDecoder() { |
571 CHECK(decoder_deleted()); | 571 CHECK(decoder_deleted()); |
572 decoder_ = new OmxVideoDecodeAccelerator(this); | 572 decoder_ = new OmxVideoDecodeAccelerator(this); |
573 decoder_->SetEglState(egl_display(), egl_context()); | 573 decoder_->SetEglState(egl_display(), egl_context()); |
574 SetState(CS_DECODER_SET); | 574 SetState(CS_DECODER_SET); |
575 if (decoder_deleted()) | 575 if (decoder_deleted()) |
576 return; | 576 return; |
577 | 577 |
578 // Configure the decoder. | 578 // Configure the decoder. |
579 media::VideoDecodeAccelerator::Profile profile = | 579 media::VideoDecodeAccelerator::Profile profile = media::H264PROFILE_BASELINE; |
580 media::VideoDecodeAccelerator::H264PROFILE_BASELINE; | |
581 if (profile_ != -1) | 580 if (profile_ != -1) |
582 profile = static_cast<media::VideoDecodeAccelerator::Profile>(profile_); | 581 profile = static_cast<media::VideoDecodeAccelerator::Profile>(profile_); |
583 CHECK(decoder_->Initialize(profile)); | 582 CHECK(decoder_->Initialize(profile)); |
584 } | 583 } |
585 | 584 |
586 void EglRenderingVDAClient::ProvidePictureBuffers( | 585 void EglRenderingVDAClient::ProvidePictureBuffers( |
587 uint32 requested_num_of_buffers, | 586 uint32 requested_num_of_buffers, |
588 const gfx::Size& dimensions) { | 587 const gfx::Size& dimensions) { |
589 if (decoder_deleted()) | 588 if (decoder_deleted()) |
590 return; | 589 return; |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
796 static void AssertWaitForStateOrDeleted(ClientStateNotification* note, | 795 static void AssertWaitForStateOrDeleted(ClientStateNotification* note, |
797 EglRenderingVDAClient* client, | 796 EglRenderingVDAClient* client, |
798 ClientState expected_state) { | 797 ClientState expected_state) { |
799 ClientState state = note->Wait(); | 798 ClientState state = note->Wait(); |
800 if (state == expected_state) return; | 799 if (state == expected_state) return; |
801 ASSERT_TRUE(client->decoder_deleted()) | 800 ASSERT_TRUE(client->decoder_deleted()) |
802 << "Decoder not deleted but Wait() returned " << state | 801 << "Decoder not deleted but Wait() returned " << state |
803 << ", instead of " << expected_state; | 802 << ", instead of " << expected_state; |
804 } | 803 } |
805 | 804 |
806 // We assert the exact number of concurrent decoders we expect to succeed and | 805 // We assert a minimal number of concurrent decoders we expect to succeed. |
807 // that one more than that fails initialization. | 806 // Different platforms can support more concurrent decoders, so we don't assert |
808 enum { kMaxSupportedNumConcurrentDecoders = 3 }; | 807 // failure above this. |
808 enum { kMinSupportedNumConcurrentDecoders = 3 }; | |
809 | 809 |
810 // Test the most straightforward case possible: data is decoded from a single | 810 // Test the most straightforward case possible: data is decoded from a single |
811 // chunk and rendered to the screen. | 811 // chunk and rendered to the screen. |
812 TEST_P(OmxVideoDecodeAcceleratorTest, TestSimpleDecode) { | 812 TEST_P(OmxVideoDecodeAcceleratorTest, TestSimpleDecode) { |
813 // Can be useful for debugging VLOGs from OVDA. | 813 // Can be useful for debugging VLOGs from OVDA. |
814 // logging::SetMinLogLevel(-1); | 814 // logging::SetMinLogLevel(-1); |
815 | 815 |
816 // Required for Thread to work. Not used otherwise. | 816 // Required for Thread to work. Not used otherwise. |
817 base::ShadowingAtExitManager at_exit_manager; | 817 base::ShadowingAtExitManager at_exit_manager; |
818 | 818 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
882 // Then wait for all the decodes to finish. | 882 // Then wait for all the decodes to finish. |
883 bool saw_init_failure = false; | 883 bool saw_init_failure = false; |
884 for (size_t i = 0; i < num_concurrent_decoders; ++i) { | 884 for (size_t i = 0; i < num_concurrent_decoders; ++i) { |
885 ClientStateNotification* note = notes[i]; | 885 ClientStateNotification* note = notes[i]; |
886 ClientState state = note->Wait(); | 886 ClientState state = note->Wait(); |
887 if (state != CS_INITIALIZED) { | 887 if (state != CS_INITIALIZED) { |
888 saw_init_failure = true; | 888 saw_init_failure = true; |
889 // We expect initialization to fail only when more than the supported | 889 // We expect initialization to fail only when more than the supported |
890 // number of decoders is instantiated. Assert here that something else | 890 // number of decoders is instantiated. Assert here that something else |
891 // didn't trigger failure. | 891 // didn't trigger failure. |
892 ASSERT_GT(num_concurrent_decoders, kMaxSupportedNumConcurrentDecoders); | 892 ASSERT_GT(num_concurrent_decoders, kMinSupportedNumConcurrentDecoders); |
893 continue; | 893 continue; |
894 } | 894 } |
895 ASSERT_EQ(state, CS_INITIALIZED); | 895 ASSERT_EQ(state, CS_INITIALIZED); |
896 // InitializeDone kicks off decoding inside the client, so we just need to | 896 // InitializeDone kicks off decoding inside the client, so we just need to |
897 // wait for Flush. | 897 // wait for Flush. |
898 ASSERT_NO_FATAL_FAILURE( | 898 ASSERT_NO_FATAL_FAILURE( |
899 AssertWaitForStateOrDeleted(note, clients[i], CS_FLUSHING)); | 899 AssertWaitForStateOrDeleted(note, clients[i], CS_FLUSHING)); |
900 ASSERT_NO_FATAL_FAILURE( | 900 ASSERT_NO_FATAL_FAILURE( |
901 AssertWaitForStateOrDeleted(note, clients[i], CS_FLUSHED)); | 901 AssertWaitForStateOrDeleted(note, clients[i], CS_FLUSHED)); |
902 // FlushDone requests Reset(). | 902 // FlushDone requests Reset(). |
903 ASSERT_NO_FATAL_FAILURE( | 903 ASSERT_NO_FATAL_FAILURE( |
904 AssertWaitForStateOrDeleted(note, clients[i], CS_RESETTING)); | 904 AssertWaitForStateOrDeleted(note, clients[i], CS_RESETTING)); |
905 ASSERT_NO_FATAL_FAILURE( | 905 ASSERT_NO_FATAL_FAILURE( |
906 AssertWaitForStateOrDeleted(note, clients[i], CS_RESET)); | 906 AssertWaitForStateOrDeleted(note, clients[i], CS_RESET)); |
907 // ResetDone requests Destroy(). | 907 // ResetDone requests Destroy(). |
908 ASSERT_NO_FATAL_FAILURE( | 908 ASSERT_NO_FATAL_FAILURE( |
909 AssertWaitForStateOrDeleted(note, clients[i], CS_DESTROYED)); | 909 AssertWaitForStateOrDeleted(note, clients[i], CS_DESTROYED)); |
910 } | 910 } |
911 ASSERT_EQ(saw_init_failure, | |
912 num_concurrent_decoders > kMaxSupportedNumConcurrentDecoders) | |
913 << num_concurrent_decoders; | |
914 // Finally assert that decoding went as expected. | 911 // Finally assert that decoding went as expected. |
915 for (size_t i = 0; i < num_concurrent_decoders && !saw_init_failure; ++i) { | 912 for (size_t i = 0; i < num_concurrent_decoders && !saw_init_failure; ++i) { |
916 // We can only make performance/correctness assertions if the decoder was | 913 // We can only make performance/correctness assertions if the decoder was |
917 // allowed to finish. | 914 // allowed to finish. |
918 if (delete_decoder_state < CS_FLUSHED) | 915 if (delete_decoder_state < CS_FLUSHED) |
919 continue; | 916 continue; |
920 EglRenderingVDAClient* client = clients[i]; | 917 EglRenderingVDAClient* client = clients[i]; |
921 if (num_frames > 0) | 918 if (num_frames > 0) |
922 EXPECT_EQ(client->num_decoded_frames(), num_frames); | 919 EXPECT_EQ(client->num_decoded_frames(), num_frames); |
923 if (num_NALUs > 0 && reset_after_frame_num < 0) { | 920 if (num_NALUs > 0 && reset_after_frame_num < 0) { |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
990 // http://code.google.com/p/chrome-os-partner/issues/detail?id=4378 is | 987 // http://code.google.com/p/chrome-os-partner/issues/detail?id=4378 is |
991 // fixed. | 988 // fixed. |
992 MakeTuple(15, 1, 1, END_OF_STREAM_RESET, CS_RESET))); | 989 MakeTuple(15, 1, 1, END_OF_STREAM_RESET, CS_RESET))); |
993 | 990 |
994 // Find out how many concurrent decoders can go before we exhaust system | 991 // Find out how many concurrent decoders can go before we exhaust system |
995 // resources. | 992 // resources. |
996 INSTANTIATE_TEST_CASE_P( | 993 INSTANTIATE_TEST_CASE_P( |
997 ResourceExhaustion, OmxVideoDecodeAcceleratorTest, | 994 ResourceExhaustion, OmxVideoDecodeAcceleratorTest, |
998 ::testing::Values( | 995 ::testing::Values( |
999 // +0 hack below to promote enum to int. | 996 // +0 hack below to promote enum to int. |
1000 MakeTuple(1, kMaxSupportedNumConcurrentDecoders + 0, 1, | 997 MakeTuple(1, kMinSupportedNumConcurrentDecoders + 0, 1, |
1001 END_OF_STREAM_RESET, CS_RESET), | 998 END_OF_STREAM_RESET, CS_RESET), |
1002 MakeTuple(1, kMaxSupportedNumConcurrentDecoders + 1, 1, | 999 MakeTuple(1, kMinSupportedNumConcurrentDecoders + 1, 1, |
1003 END_OF_STREAM_RESET, CS_RESET))); | 1000 END_OF_STREAM_RESET, CS_RESET))); |
1004 | 1001 |
1005 // TODO(fischman, vrk): add more tests! In particular: | 1002 // TODO(fischman, vrk): add more tests! In particular: |
scherkus (not reviewing)
2011/12/06 00:27:44
!!!!!!
Ami GONE FROM CHROMIUM
2011/12/07 00:03:04
Seriously? Have you /seen/ the amount of tests al
| |
1006 // - Test life-cycle: Seek/Stop/Pause/Play/RePlay for a single decoder. | 1003 // - Test life-cycle: Seek/Stop/Pause/Play/RePlay for a single decoder. |
1007 // - Test alternate configurations | 1004 // - Test alternate configurations |
1008 // - Test failure conditions. | 1005 // - Test failure conditions. |
1009 // - Test frame size changes mid-stream | 1006 // - Test frame size changes mid-stream |
1010 | 1007 |
1011 } // namespace | 1008 } // namespace |
1012 | 1009 |
1013 int main(int argc, char **argv) { | 1010 int main(int argc, char **argv) { |
1014 testing::InitGoogleTest(&argc, argv); // Removes gtest-specific args. | 1011 testing::InitGoogleTest(&argc, argv); // Removes gtest-specific args. |
1015 CommandLine cmd_line(argc, argv); // Must run after InitGoogleTest. | 1012 CommandLine cmd_line(argc, argv); // Must run after InitGoogleTest. |
1016 CommandLine::SwitchMap switches = cmd_line.GetSwitches(); | 1013 CommandLine::SwitchMap switches = cmd_line.GetSwitches(); |
1017 for (CommandLine::SwitchMap::const_iterator it = switches.begin(); | 1014 for (CommandLine::SwitchMap::const_iterator it = switches.begin(); |
1018 it != switches.end(); ++it) { | 1015 it != switches.end(); ++it) { |
1019 if (it->first == "test_video_data") { | 1016 if (it->first == "test_video_data") { |
1020 test_video_data = it->second.c_str(); | 1017 test_video_data = it->second.c_str(); |
1021 continue; | 1018 continue; |
1022 } | 1019 } |
1023 LOG(FATAL) << "Unexpected switch: " << it->first << ":" << it->second; | 1020 LOG(FATAL) << "Unexpected switch: " << it->first << ":" << it->second; |
1024 } | 1021 } |
1025 | 1022 |
1026 return RUN_ALL_TESTS(); | 1023 return RUN_ALL_TESTS(); |
1027 } | 1024 } |
OLD | NEW |