Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Side by Side Diff: content/common/gpu/media/omx_video_decode_accelerator_unittest.cc

Issue 7524032: Added support for Decode() calls during Reset(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 429
430 ClientState ClientStateNotification::Wait() { 430 ClientState ClientStateNotification::Wait() {
431 base::AutoLock auto_lock(lock_); 431 base::AutoLock auto_lock(lock_);
432 while (pending_states_for_notification_.empty()) 432 while (pending_states_for_notification_.empty())
433 cv_.Wait(); 433 cv_.Wait();
434 ClientState ret = pending_states_for_notification_.front(); 434 ClientState ret = pending_states_for_notification_.front();
435 pending_states_for_notification_.pop(); 435 pending_states_for_notification_.pop();
436 return ret; 436 return ret;
437 } 437 }
438 438
439 // Magic constants for differentiating the reasons for NotifyResetDone being
440 // called.
441 enum ResetPoint {
442 MID_STREAM_RESET = -2,
443 END_OF_STREAM_RESET = -1
444 };
445
439 // Client that can accept callbacks from a VideoDecodeAccelerator and is used by 446 // Client that can accept callbacks from a VideoDecodeAccelerator and is used by
440 // the TESTs below. 447 // the TESTs below.
441 class EglRenderingVDAClient : public VideoDecodeAccelerator::Client { 448 class EglRenderingVDAClient : public VideoDecodeAccelerator::Client {
442 public: 449 public:
443 // Doesn't take ownership of |note| or |encoded_data|, which must outlive 450 // Doesn't take ownership of |rendering_helper| or |note|, which must outlive
444 // |*this|. 451 // |*this|.
452 // |reset_after_frame_num| can be a frame number >=0 indicating a mid-stream
453 // Reset() should be done after that frame number is delivered, or
454 // END_OF_STREAM_RESET to indicate no mid-stream Reset().
455 // |delete_decoder_state| indicates when the underlying decoder should be
456 // Destroy()'d and deleted and can take values: N<0: delete after -N Decode()
457 // calls have been made, N>=0 means interpret as ClientState.
445 EglRenderingVDAClient(RenderingHelper* rendering_helper, 458 EglRenderingVDAClient(RenderingHelper* rendering_helper,
446 int rendering_window_id, 459 int rendering_window_id,
447 ClientStateNotification* note, 460 ClientStateNotification* note,
448 const std::string& encoded_data, 461 const std::string& encoded_data,
449 int num_NALUs_per_decode, 462 int num_NALUs_per_decode,
463 int reset_after_frame_num,
450 int delete_decoder_state); 464 int delete_decoder_state);
451 virtual ~EglRenderingVDAClient(); 465 virtual ~EglRenderingVDAClient();
452 void CreateDecoder(); 466 void CreateDecoder();
453 467
454 // VideoDecodeAccelerator::Client implementation. 468 // VideoDecodeAccelerator::Client implementation.
455 // The heart of the Client. 469 // The heart of the Client.
456 virtual void ProvidePictureBuffers( 470 virtual void ProvidePictureBuffers(
457 uint32 requested_num_of_buffers, 471 uint32 requested_num_of_buffers,
458 const gfx::Size& dimensions); 472 const gfx::Size& dimensions);
459 virtual void DismissPictureBuffer(int32 picture_buffer_id); 473 virtual void DismissPictureBuffer(int32 picture_buffer_id);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 506
493 RenderingHelper* rendering_helper_; 507 RenderingHelper* rendering_helper_;
494 int rendering_window_id_; 508 int rendering_window_id_;
495 std::string encoded_data_; 509 std::string encoded_data_;
496 const int num_NALUs_per_decode_; 510 const int num_NALUs_per_decode_;
497 size_t encoded_data_next_pos_to_decode_; 511 size_t encoded_data_next_pos_to_decode_;
498 int next_bitstream_buffer_id_; 512 int next_bitstream_buffer_id_;
499 ClientStateNotification* note_; 513 ClientStateNotification* note_;
500 scoped_refptr<OmxVideoDecodeAccelerator> decoder_; 514 scoped_refptr<OmxVideoDecodeAccelerator> decoder_;
501 std::set<int> outstanding_texture_ids_; 515 std::set<int> outstanding_texture_ids_;
516 int reset_after_frame_num_;
502 int delete_decoder_state_; 517 int delete_decoder_state_;
503 ClientState state_; 518 ClientState state_;
504 int num_decoded_frames_; 519 int num_decoded_frames_;
505 int num_done_bitstream_buffers_; 520 int num_done_bitstream_buffers_;
506 PictureBufferById picture_buffers_by_id_; 521 PictureBufferById picture_buffers_by_id_;
507 base::TimeTicks initialize_done_ticks_; 522 base::TimeTicks initialize_done_ticks_;
508 base::TimeTicks last_frame_delivered_ticks_; 523 base::TimeTicks last_frame_delivered_ticks_;
509 }; 524 };
510 525
511 EglRenderingVDAClient::EglRenderingVDAClient(RenderingHelper* rendering_helper, 526 EglRenderingVDAClient::EglRenderingVDAClient(
512 int rendering_window_id, 527 RenderingHelper* rendering_helper,
513 ClientStateNotification* note, 528 int rendering_window_id,
514 const std::string& encoded_data, 529 ClientStateNotification* note,
515 int num_NALUs_per_decode, 530 const std::string& encoded_data,
516 int delete_decoder_state) 531 int num_NALUs_per_decode,
532 int reset_after_frame_num,
533 int delete_decoder_state)
517 : rendering_helper_(rendering_helper), 534 : rendering_helper_(rendering_helper),
518 rendering_window_id_(rendering_window_id), 535 rendering_window_id_(rendering_window_id),
519 encoded_data_(encoded_data), num_NALUs_per_decode_(num_NALUs_per_decode), 536 encoded_data_(encoded_data), num_NALUs_per_decode_(num_NALUs_per_decode),
520 encoded_data_next_pos_to_decode_(0), next_bitstream_buffer_id_(0), 537 encoded_data_next_pos_to_decode_(0), next_bitstream_buffer_id_(0),
521 note_(note), delete_decoder_state_(delete_decoder_state), 538 note_(note), reset_after_frame_num_(reset_after_frame_num),
539 delete_decoder_state_(delete_decoder_state),
522 state_(CS_CREATED), 540 state_(CS_CREATED),
523 num_decoded_frames_(0), num_done_bitstream_buffers_(0) { 541 num_decoded_frames_(0), num_done_bitstream_buffers_(0) {
524 CHECK_GT(num_NALUs_per_decode, 0); 542 CHECK_GT(num_NALUs_per_decode, 0);
525 } 543 }
526 544
527 EglRenderingVDAClient::~EglRenderingVDAClient() { 545 EglRenderingVDAClient::~EglRenderingVDAClient() {
528 DeleteDecoder(); // Clean up in case of expected error. 546 DeleteDecoder(); // Clean up in case of expected error.
529 CHECK(decoder_deleted()); 547 CHECK(decoder_deleted());
530 STLDeleteValues(&picture_buffers_by_id_); 548 STLDeleteValues(&picture_buffers_by_id_);
531 SetState(CS_DESTROYED); 549 SetState(CS_DESTROYED);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 last_frame_delivered_ticks_ = base::TimeTicks::Now(); 611 last_frame_delivered_ticks_ = base::TimeTicks::Now();
594 612
595 // Because we feed the decoder a limited number of NALUs at a time, we can be 613 // Because we feed the decoder a limited number of NALUs at a time, we can be
596 // sure that the bitstream buffer from which a frame comes has a limited 614 // sure that the bitstream buffer from which a frame comes has a limited
597 // range. Assert that. 615 // range. Assert that.
598 CHECK_GE((picture.bitstream_buffer_id() + 1) * num_NALUs_per_decode_, 616 CHECK_GE((picture.bitstream_buffer_id() + 1) * num_NALUs_per_decode_,
599 num_decoded_frames_); 617 num_decoded_frames_);
600 CHECK_LE(picture.bitstream_buffer_id(), next_bitstream_buffer_id_); 618 CHECK_LE(picture.bitstream_buffer_id(), next_bitstream_buffer_id_);
601 ++num_decoded_frames_; 619 ++num_decoded_frames_;
602 620
621 if (reset_after_frame_num_ == num_decoded_frames_) {
622 reset_after_frame_num_ = MID_STREAM_RESET;
623 decoder_->Reset();
624 encoded_data_next_pos_to_decode_ = 0;
vrk (LEFT CHROMIUM) 2011/07/29 17:06:44 Comment that we start playback over from the begin
Ami GONE FROM CHROMIUM 2011/07/29 17:17:09 Done.
625 }
626
603 media::PictureBuffer* picture_buffer = 627 media::PictureBuffer* picture_buffer =
604 picture_buffers_by_id_[picture.picture_buffer_id()]; 628 picture_buffers_by_id_[picture.picture_buffer_id()];
605 CHECK(picture_buffer); 629 CHECK(picture_buffer);
606 rendering_helper_->RenderTexture(picture_buffer->texture_id()); 630 rendering_helper_->RenderTexture(picture_buffer->texture_id());
607 631
608 decoder_->ReusePictureBuffer(picture.picture_buffer_id()); 632 decoder_->ReusePictureBuffer(picture.picture_buffer_id());
609 } 633 }
610 634
611 void EglRenderingVDAClient::NotifyInitializeDone() { 635 void EglRenderingVDAClient::NotifyInitializeDone() {
612 SetState(CS_INITIALIZED); 636 SetState(CS_INITIALIZED);
(...skipping 16 matching lines...) Expand all
629 return; 653 return;
630 SetState(CS_FLUSHED); 654 SetState(CS_FLUSHED);
631 if (decoder_deleted()) 655 if (decoder_deleted())
632 return; 656 return;
633 decoder_->Reset(); 657 decoder_->Reset();
634 } 658 }
635 659
636 void EglRenderingVDAClient::NotifyResetDone() { 660 void EglRenderingVDAClient::NotifyResetDone() {
637 if (decoder_deleted()) 661 if (decoder_deleted())
638 return; 662 return;
663 if (reset_after_frame_num_ == MID_STREAM_RESET) {
664 reset_after_frame_num_ = END_OF_STREAM_RESET;
665 return;
666 }
639 SetState(CS_RESET); 667 SetState(CS_RESET);
640 if (!decoder_deleted()) 668 if (!decoder_deleted())
641 DeleteDecoder(); 669 DeleteDecoder();
642 } 670 }
643 671
644 void EglRenderingVDAClient::NotifyError(VideoDecodeAccelerator::Error error) { 672 void EglRenderingVDAClient::NotifyError(VideoDecodeAccelerator::Error error) {
645 SetState(CS_ERROR); 673 SetState(CS_ERROR);
646 } 674 }
647 675
648 static bool LookingAtNAL(const std::string& encoded, size_t pos) { 676 static bool LookingAtNAL(const std::string& encoded, size_t pos) {
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
724 double EglRenderingVDAClient::frames_per_second() { 752 double EglRenderingVDAClient::frames_per_second() {
725 base::TimeDelta delta = last_frame_delivered_ticks_ - initialize_done_ticks_; 753 base::TimeDelta delta = last_frame_delivered_ticks_ - initialize_done_ticks_;
726 if (delta.InSecondsF() == 0) 754 if (delta.InSecondsF() == 0)
727 return 0; 755 return 0;
728 return num_decoded_frames_ / delta.InSecondsF(); 756 return num_decoded_frames_ / delta.InSecondsF();
729 } 757 }
730 758
731 // Test parameters: 759 // Test parameters:
732 // - Number of NALUs per Decode() call. 760 // - Number of NALUs per Decode() call.
733 // - Number of concurrent decoders. 761 // - Number of concurrent decoders.
734 // - When to delete the decoder. N<0 means after -N Decode() calls have been 762 // - reset_after_frame_num: see EglRenderingVDAClient ctor.
735 // made, N>=0 means interpret as ClientState. 763 // - delete_decoder_phase: see EglRenderingVDAClient ctor.
736 class OmxVideoDecodeAcceleratorTest 764 class OmxVideoDecodeAcceleratorTest
737 : public ::testing::TestWithParam<Tuple3<int, int, ClientState> > { 765 : public ::testing::TestWithParam<
766 Tuple4<int, int, ResetPoint, ClientState> > {
738 }; 767 };
739 768
740 // Wait for |note| to report a state and if it's not |expected_state| then 769 // Wait for |note| to report a state and if it's not |expected_state| then
741 // assert |client| has deleted its decoder. 770 // assert |client| has deleted its decoder.
742 static void AssertWaitForStateOrDeleted(ClientStateNotification* note, 771 static void AssertWaitForStateOrDeleted(ClientStateNotification* note,
743 EglRenderingVDAClient* client, 772 EglRenderingVDAClient* client,
744 ClientState expected_state) { 773 ClientState expected_state) {
745 ClientState state = note->Wait(); 774 ClientState state = note->Wait();
746 if (state == expected_state) return; 775 if (state == expected_state) return;
747 ASSERT_TRUE(client->decoder_deleted()) 776 ASSERT_TRUE(client->decoder_deleted())
748 << "Decoder not deleted but Wait() returned " << state 777 << "Decoder not deleted but Wait() returned " << state
749 << ", instead of " << expected_state; 778 << ", instead of " << expected_state;
750 } 779 }
751 780
752 // We assert the exact number of concurrent decoders we expect to succeed and 781 // We assert the exact number of concurrent decoders we expect to succeed and
753 // that one more than that fails initialization. 782 // that one more than that fails initialization.
754 enum { kMaxSupportedNumConcurrentDecoders = 5 }; 783 enum { kMaxSupportedNumConcurrentDecoders = 5 };
755 784
756 // Test the most straightforward case possible: data is decoded from a single 785 // Test the most straightforward case possible: data is decoded from a single
757 // chunk and rendered to the screen. 786 // chunk and rendered to the screen.
758 TEST_P(OmxVideoDecodeAcceleratorTest, TestSimpleDecode) { 787 TEST_P(OmxVideoDecodeAcceleratorTest, TestSimpleDecode) {
759 // Can be useful for debugging VLOGs from OVDA. 788 // Can be useful for debugging VLOGs from OVDA.
760 // logging::SetMinLogLevel(-1); 789 // logging::SetMinLogLevel(-1);
761 790
762 // Required for Thread to work. Not used otherwise. 791 // Required for Thread to work. Not used otherwise.
763 base::ShadowingAtExitManager at_exit_manager; 792 base::ShadowingAtExitManager at_exit_manager;
764 793
765 const int num_NALUs_per_decode = GetParam().a; 794 const int num_NALUs_per_decode = GetParam().a;
766 const size_t num_concurrent_decoders = GetParam().b; 795 const size_t num_concurrent_decoders = GetParam().b;
767 const int delete_decoder_state = GetParam().c; 796 const int reset_after_frame_num = GetParam().c;
797 const int delete_decoder_state = GetParam().d;
768 798
769 std::string test_video_file; 799 std::string test_video_file;
770 int frame_width, frame_height; 800 int frame_width, frame_height;
771 int num_frames, num_NALUs, min_fps_render, min_fps_no_render; 801 int num_frames, num_NALUs, min_fps_render, min_fps_no_render;
772 ParseTestVideoData(test_video_data, &test_video_file, &frame_width, 802 ParseTestVideoData(test_video_data, &test_video_file, &frame_width,
773 &frame_height, &num_frames, &num_NALUs, 803 &frame_height, &num_frames, &num_NALUs,
774 &min_fps_render, &min_fps_no_render); 804 &min_fps_render, &min_fps_no_render);
775 min_fps_render /= num_concurrent_decoders; 805 min_fps_render /= num_concurrent_decoders;
776 min_fps_no_render /= num_concurrent_decoders; 806 min_fps_no_render /= num_concurrent_decoders;
777 807
808 // If we reset mid-stream and start playback over, account for frames that are
809 // decoded twice in our expectations.
810 if (num_frames > 0 && reset_after_frame_num >= 0)
811 num_frames += reset_after_frame_num;
812
778 // Suppress EGL surface swapping in all but a few tests, to cut down overall 813 // Suppress EGL surface swapping in all but a few tests, to cut down overall
779 // test runtime. 814 // test runtime.
780 const bool suppress_swap_to_display = num_NALUs_per_decode > 1; 815 const bool suppress_swap_to_display = num_NALUs_per_decode > 1;
781 816
782 std::vector<ClientStateNotification*> notes(num_concurrent_decoders, NULL); 817 std::vector<ClientStateNotification*> notes(num_concurrent_decoders, NULL);
783 std::vector<EglRenderingVDAClient*> clients(num_concurrent_decoders, NULL); 818 std::vector<EglRenderingVDAClient*> clients(num_concurrent_decoders, NULL);
784 819
785 // Read in the video data. 820 // Read in the video data.
786 std::string data_str; 821 std::string data_str;
787 CHECK(file_util::ReadFileToString(FilePath(test_video_file), &data_str)); 822 CHECK(file_util::ReadFileToString(FilePath(test_video_file), &data_str));
(...skipping 12 matching lines...) Expand all
800 frame_width, frame_height, &done)); 835 frame_width, frame_height, &done));
801 done.Wait(); 836 done.Wait();
802 837
803 // First kick off all the decoders. 838 // First kick off all the decoders.
804 for (size_t index = 0; index < num_concurrent_decoders; ++index) { 839 for (size_t index = 0; index < num_concurrent_decoders; ++index) {
805 ClientStateNotification* note = new ClientStateNotification(); 840 ClientStateNotification* note = new ClientStateNotification();
806 notes[index] = note; 841 notes[index] = note;
807 EglRenderingVDAClient* client = new EglRenderingVDAClient( 842 EglRenderingVDAClient* client = new EglRenderingVDAClient(
808 &rendering_helper, index, 843 &rendering_helper, index,
809 note, data_str, num_NALUs_per_decode, 844 note, data_str, num_NALUs_per_decode,
810 delete_decoder_state); 845 reset_after_frame_num, delete_decoder_state);
811 clients[index] = client; 846 clients[index] = client;
812 847
813 rendering_thread.message_loop()->PostTask( 848 rendering_thread.message_loop()->PostTask(
814 FROM_HERE, 849 FROM_HERE,
815 base::Bind(&EglRenderingVDAClient::CreateDecoder, 850 base::Bind(&EglRenderingVDAClient::CreateDecoder,
816 base::Unretained(client))); 851 base::Unretained(client)));
817 852
818 ASSERT_EQ(note->Wait(), CS_DECODER_SET); 853 ASSERT_EQ(note->Wait(), CS_DECODER_SET);
819 } 854 }
820 // Then wait for all the decodes to finish. 855 // Then wait for all the decodes to finish.
(...skipping 26 matching lines...) Expand all
847 << num_concurrent_decoders; 882 << num_concurrent_decoders;
848 // Finally assert that decoding went as expected. 883 // Finally assert that decoding went as expected.
849 for (size_t i = 0; i < num_concurrent_decoders && !saw_init_failure; ++i) { 884 for (size_t i = 0; i < num_concurrent_decoders && !saw_init_failure; ++i) {
850 // We can only make performance/correctness assertions if the decoder was 885 // We can only make performance/correctness assertions if the decoder was
851 // allowed to finish. 886 // allowed to finish.
852 if (delete_decoder_state < CS_FLUSHED) 887 if (delete_decoder_state < CS_FLUSHED)
853 continue; 888 continue;
854 EglRenderingVDAClient* client = clients[i]; 889 EglRenderingVDAClient* client = clients[i];
855 if (num_frames > 0) 890 if (num_frames > 0)
856 EXPECT_EQ(client->num_decoded_frames(), num_frames); 891 EXPECT_EQ(client->num_decoded_frames(), num_frames);
857 if (num_NALUs > 0) { 892 if (num_NALUs > 0 && reset_after_frame_num < 0) {
858 EXPECT_EQ(client->num_done_bitstream_buffers(), 893 EXPECT_EQ(client->num_done_bitstream_buffers(),
859 ceil(static_cast<double>(num_NALUs) / num_NALUs_per_decode)); 894 ceil(static_cast<double>(num_NALUs) / num_NALUs_per_decode));
860 } 895 }
861 LOG(INFO) << "Decoder " << i << " fps: " << client->frames_per_second(); 896 LOG(INFO) << "Decoder " << i << " fps: " << client->frames_per_second();
862 int min_fps = suppress_swap_to_display ? min_fps_no_render : min_fps_render; 897 int min_fps = suppress_swap_to_display ? min_fps_no_render : min_fps_render;
863 if (min_fps > 0) 898 if (min_fps > 0)
864 EXPECT_GT(client->frames_per_second(), min_fps); 899 EXPECT_GT(client->frames_per_second(), min_fps);
865 } 900 }
866 901
867 rendering_thread.message_loop()->PostTask( 902 rendering_thread.message_loop()->PostTask(
868 FROM_HERE, 903 FROM_HERE,
869 base::Bind(&STLDeleteElements<std::vector<EglRenderingVDAClient*> >, 904 base::Bind(&STLDeleteElements<std::vector<EglRenderingVDAClient*> >,
870 &clients)); 905 &clients));
871 rendering_thread.message_loop()->PostTask( 906 rendering_thread.message_loop()->PostTask(
872 FROM_HERE, 907 FROM_HERE,
873 base::Bind(&STLDeleteElements<std::vector<ClientStateNotification*> >, 908 base::Bind(&STLDeleteElements<std::vector<ClientStateNotification*> >,
874 &notes)); 909 &notes));
875 rendering_thread.message_loop()->PostTask( 910 rendering_thread.message_loop()->PostTask(
876 FROM_HERE, 911 FROM_HERE,
877 base::Bind(&RenderingHelper::UnInitialize, 912 base::Bind(&RenderingHelper::UnInitialize,
878 base::Unretained(&rendering_helper), 913 base::Unretained(&rendering_helper),
879 &done)); 914 &done));
880 done.Wait(); 915 done.Wait();
881 rendering_thread.Stop(); 916 rendering_thread.Stop();
882 }; 917 };
883 918
919 // Test that Reset() mid-stream works fine and doesn't affect decoding even when
920 // Decode() calls are made during the reset.
921 INSTANTIATE_TEST_CASE_P(
922 MidStreamReset, OmxVideoDecodeAcceleratorTest,
923 ::testing::Values(
924 MakeTuple(1, 1, static_cast<ResetPoint>(100), CS_RESET)));
925
926 // Test that Destroy() mid-stream works fine (primarily this is testing that no
927 // crashes occur).
884 INSTANTIATE_TEST_CASE_P( 928 INSTANTIATE_TEST_CASE_P(
885 TearDownTiming, OmxVideoDecodeAcceleratorTest, 929 TearDownTiming, OmxVideoDecodeAcceleratorTest,
886 ::testing::Values( 930 ::testing::Values(
887 MakeTuple(1, 1, CS_DECODER_SET), MakeTuple(1, 1, CS_INITIALIZED), 931 MakeTuple(1, 1, END_OF_STREAM_RESET, CS_DECODER_SET),
888 MakeTuple(1, 1, CS_FLUSHED), MakeTuple(1, 1, CS_RESET), 932 MakeTuple(1, 1, END_OF_STREAM_RESET, CS_INITIALIZED),
889 MakeTuple(1, 1, static_cast<ClientState>(-1)), 933 MakeTuple(1, 1, END_OF_STREAM_RESET, CS_FLUSHED),
890 MakeTuple(1, 1, static_cast<ClientState>(-10)), 934 MakeTuple(1, 1, END_OF_STREAM_RESET, CS_RESET),
891 MakeTuple(1, 1, static_cast<ClientState>(-100)))); 935 MakeTuple(1, 1, END_OF_STREAM_RESET, static_cast<ClientState>(-1)),
936 MakeTuple(1, 1, END_OF_STREAM_RESET, static_cast<ClientState>(-10)),
937 MakeTuple(1, 1, END_OF_STREAM_RESET, static_cast<ClientState>(-100))));
892 938
893 // TODO(fischman): using 1st param of 16 and higher below breaks decode - visual 939 // Test that decoding various variation works: multiple concurrent decoders and
894 // artifacts are introduced as well as spurious frames are delivered (more 940 // multiple NALUs per Decode() call.
895 // pictures are returned than NALUs are fed to the decoder). Increase the "15"
896 // below when http://code.google.com/p/chrome-os-partner/issues/detail?id=4378
897 // is fixed.
898 INSTANTIATE_TEST_CASE_P( 941 INSTANTIATE_TEST_CASE_P(
899 DecodeVariations, OmxVideoDecodeAcceleratorTest, 942 DecodeVariations, OmxVideoDecodeAcceleratorTest,
900 ::testing::Values( 943 ::testing::Values(
901 MakeTuple(1, 1, CS_RESET), MakeTuple(1, 3, CS_RESET), 944 MakeTuple(1, 1, END_OF_STREAM_RESET, CS_RESET),
902 MakeTuple(2, 1, CS_RESET), MakeTuple(3, 1, CS_RESET), 945 MakeTuple(1, 3, END_OF_STREAM_RESET, CS_RESET),
903 MakeTuple(5, 1, CS_RESET), MakeTuple(8, 1, CS_RESET), 946 MakeTuple(2, 1, END_OF_STREAM_RESET, CS_RESET),
904 MakeTuple(15, 1, CS_RESET))); 947 MakeTuple(3, 1, END_OF_STREAM_RESET, CS_RESET),
948 MakeTuple(5, 1, END_OF_STREAM_RESET, CS_RESET),
949 MakeTuple(8, 1, END_OF_STREAM_RESET, CS_RESET),
950 // TODO(fischman): decoding more than 15 NALUs at once breaks decode -
951 // visual artifacts are introduced as well as spurious frames are
952 // delivered (more pictures are returned than NALUs are fed to the
953 // decoder). Increase the "15" below when
954 // http://code.google.com/p/chrome-os-partner/issues/detail?id=4378 is
955 // fixed.
956 MakeTuple(15, 1, END_OF_STREAM_RESET, CS_RESET)));
905 957
906 // Find out how many concurrent decoders can go before we exhaust system 958 // Find out how many concurrent decoders can go before we exhaust system
907 // resources. 959 // resources.
908 INSTANTIATE_TEST_CASE_P( 960 INSTANTIATE_TEST_CASE_P(
909 ResourceExhaustion, OmxVideoDecodeAcceleratorTest, 961 ResourceExhaustion, OmxVideoDecodeAcceleratorTest,
910 ::testing::Values( 962 ::testing::Values(
911 // +0 hack below to promote enum to int. 963 // +0 hack below to promote enum to int.
912 MakeTuple(1, kMaxSupportedNumConcurrentDecoders + 0, CS_RESET), 964 MakeTuple(1, kMaxSupportedNumConcurrentDecoders + 0,
913 MakeTuple(1, kMaxSupportedNumConcurrentDecoders + 1, CS_RESET))); 965 END_OF_STREAM_RESET, CS_RESET),
966 MakeTuple(1, kMaxSupportedNumConcurrentDecoders + 1,
967 END_OF_STREAM_RESET, CS_RESET)));
914 968
915 // TODO(fischman, vrk): add more tests! In particular: 969 // TODO(fischman, vrk): add more tests! In particular:
916 // - Test life-cycle: Seek/Stop/Pause/Play/RePlay for a single decoder. 970 // - Test life-cycle: Seek/Stop/Pause/Play/RePlay for a single decoder.
917 // - Test alternate configurations 971 // - Test alternate configurations
918 // - Test failure conditions. 972 // - Test failure conditions.
919 // - Test frame size changes mid-stream 973 // - Test frame size changes mid-stream
920 974
921 } // namespace 975 } // namespace
922 976
923 int main(int argc, char **argv) { 977 int main(int argc, char **argv) {
924 testing::InitGoogleTest(&argc, argv); // Removes gtest-specific args. 978 testing::InitGoogleTest(&argc, argv); // Removes gtest-specific args.
925 CommandLine cmd_line(argc, argv); // Must run after InitGoogleTest. 979 CommandLine cmd_line(argc, argv); // Must run after InitGoogleTest.
926 CommandLine::SwitchMap switches = cmd_line.GetSwitches(); 980 CommandLine::SwitchMap switches = cmd_line.GetSwitches();
927 for (CommandLine::SwitchMap::const_iterator it = switches.begin(); 981 for (CommandLine::SwitchMap::const_iterator it = switches.begin();
928 it != switches.end(); ++it) { 982 it != switches.end(); ++it) {
929 if (it->first == "test_video_data") { 983 if (it->first == "test_video_data") {
930 test_video_data = it->second.c_str(); 984 test_video_data = it->second.c_str();
931 continue; 985 continue;
932 } 986 }
933 LOG(FATAL) << "Unexpected switch: " << it->first << ":" << it->second; 987 LOG(FATAL) << "Unexpected switch: " << it->first << ":" << it->second;
934 } 988 }
935 989
936 return RUN_ALL_TESTS(); 990 return RUN_ALL_TESTS();
937 } 991 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698