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

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
« no previous file with comments | « content/common/gpu/media/omx_video_decode_accelerator.cc ('k') | media/base/bitstream_buffer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // Re-start decoding from the beginning of the stream to avoid needing to
625 // know how to find I-frames and so on in this test.
626 encoded_data_next_pos_to_decode_ = 0;
627 }
628
603 media::PictureBuffer* picture_buffer = 629 media::PictureBuffer* picture_buffer =
604 picture_buffers_by_id_[picture.picture_buffer_id()]; 630 picture_buffers_by_id_[picture.picture_buffer_id()];
605 CHECK(picture_buffer); 631 CHECK(picture_buffer);
606 rendering_helper_->RenderTexture(picture_buffer->texture_id()); 632 rendering_helper_->RenderTexture(picture_buffer->texture_id());
607 633
608 decoder_->ReusePictureBuffer(picture.picture_buffer_id()); 634 decoder_->ReusePictureBuffer(picture.picture_buffer_id());
609 } 635 }
610 636
611 void EglRenderingVDAClient::NotifyInitializeDone() { 637 void EglRenderingVDAClient::NotifyInitializeDone() {
612 SetState(CS_INITIALIZED); 638 SetState(CS_INITIALIZED);
(...skipping 16 matching lines...) Expand all
629 return; 655 return;
630 SetState(CS_FLUSHED); 656 SetState(CS_FLUSHED);
631 if (decoder_deleted()) 657 if (decoder_deleted())
632 return; 658 return;
633 decoder_->Reset(); 659 decoder_->Reset();
634 } 660 }
635 661
636 void EglRenderingVDAClient::NotifyResetDone() { 662 void EglRenderingVDAClient::NotifyResetDone() {
637 if (decoder_deleted()) 663 if (decoder_deleted())
638 return; 664 return;
665 if (reset_after_frame_num_ == MID_STREAM_RESET) {
666 reset_after_frame_num_ = END_OF_STREAM_RESET;
667 return;
668 }
639 SetState(CS_RESET); 669 SetState(CS_RESET);
640 if (!decoder_deleted()) 670 if (!decoder_deleted())
641 DeleteDecoder(); 671 DeleteDecoder();
642 } 672 }
643 673
644 void EglRenderingVDAClient::NotifyError(VideoDecodeAccelerator::Error error) { 674 void EglRenderingVDAClient::NotifyError(VideoDecodeAccelerator::Error error) {
645 SetState(CS_ERROR); 675 SetState(CS_ERROR);
646 } 676 }
647 677
648 static bool LookingAtNAL(const std::string& encoded, size_t pos) { 678 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() { 754 double EglRenderingVDAClient::frames_per_second() {
725 base::TimeDelta delta = last_frame_delivered_ticks_ - initialize_done_ticks_; 755 base::TimeDelta delta = last_frame_delivered_ticks_ - initialize_done_ticks_;
726 if (delta.InSecondsF() == 0) 756 if (delta.InSecondsF() == 0)
727 return 0; 757 return 0;
728 return num_decoded_frames_ / delta.InSecondsF(); 758 return num_decoded_frames_ / delta.InSecondsF();
729 } 759 }
730 760
731 // Test parameters: 761 // Test parameters:
732 // - Number of NALUs per Decode() call. 762 // - Number of NALUs per Decode() call.
733 // - Number of concurrent decoders. 763 // - Number of concurrent decoders.
734 // - When to delete the decoder. N<0 means after -N Decode() calls have been 764 // - reset_after_frame_num: see EglRenderingVDAClient ctor.
735 // made, N>=0 means interpret as ClientState. 765 // - delete_decoder_phase: see EglRenderingVDAClient ctor.
736 class OmxVideoDecodeAcceleratorTest 766 class OmxVideoDecodeAcceleratorTest
737 : public ::testing::TestWithParam<Tuple3<int, int, ClientState> > { 767 : public ::testing::TestWithParam<
768 Tuple4<int, int, ResetPoint, ClientState> > {
738 }; 769 };
739 770
740 // Wait for |note| to report a state and if it's not |expected_state| then 771 // Wait for |note| to report a state and if it's not |expected_state| then
741 // assert |client| has deleted its decoder. 772 // assert |client| has deleted its decoder.
742 static void AssertWaitForStateOrDeleted(ClientStateNotification* note, 773 static void AssertWaitForStateOrDeleted(ClientStateNotification* note,
743 EglRenderingVDAClient* client, 774 EglRenderingVDAClient* client,
744 ClientState expected_state) { 775 ClientState expected_state) {
745 ClientState state = note->Wait(); 776 ClientState state = note->Wait();
746 if (state == expected_state) return; 777 if (state == expected_state) return;
747 ASSERT_TRUE(client->decoder_deleted()) 778 ASSERT_TRUE(client->decoder_deleted())
748 << "Decoder not deleted but Wait() returned " << state 779 << "Decoder not deleted but Wait() returned " << state
749 << ", instead of " << expected_state; 780 << ", instead of " << expected_state;
750 } 781 }
751 782
752 // We assert the exact number of concurrent decoders we expect to succeed and 783 // We assert the exact number of concurrent decoders we expect to succeed and
753 // that one more than that fails initialization. 784 // that one more than that fails initialization.
754 enum { kMaxSupportedNumConcurrentDecoders = 5 }; 785 enum { kMaxSupportedNumConcurrentDecoders = 5 };
755 786
756 // Test the most straightforward case possible: data is decoded from a single 787 // Test the most straightforward case possible: data is decoded from a single
757 // chunk and rendered to the screen. 788 // chunk and rendered to the screen.
758 TEST_P(OmxVideoDecodeAcceleratorTest, TestSimpleDecode) { 789 TEST_P(OmxVideoDecodeAcceleratorTest, TestSimpleDecode) {
759 // Can be useful for debugging VLOGs from OVDA. 790 // Can be useful for debugging VLOGs from OVDA.
760 // logging::SetMinLogLevel(-1); 791 // logging::SetMinLogLevel(-1);
761 792
762 // Required for Thread to work. Not used otherwise. 793 // Required for Thread to work. Not used otherwise.
763 base::ShadowingAtExitManager at_exit_manager; 794 base::ShadowingAtExitManager at_exit_manager;
764 795
765 const int num_NALUs_per_decode = GetParam().a; 796 const int num_NALUs_per_decode = GetParam().a;
766 const size_t num_concurrent_decoders = GetParam().b; 797 const size_t num_concurrent_decoders = GetParam().b;
767 const int delete_decoder_state = GetParam().c; 798 const int reset_after_frame_num = GetParam().c;
799 const int delete_decoder_state = GetParam().d;
768 800
769 std::string test_video_file; 801 std::string test_video_file;
770 int frame_width, frame_height; 802 int frame_width, frame_height;
771 int num_frames, num_NALUs, min_fps_render, min_fps_no_render; 803 int num_frames, num_NALUs, min_fps_render, min_fps_no_render;
772 ParseTestVideoData(test_video_data, &test_video_file, &frame_width, 804 ParseTestVideoData(test_video_data, &test_video_file, &frame_width,
773 &frame_height, &num_frames, &num_NALUs, 805 &frame_height, &num_frames, &num_NALUs,
774 &min_fps_render, &min_fps_no_render); 806 &min_fps_render, &min_fps_no_render);
775 min_fps_render /= num_concurrent_decoders; 807 min_fps_render /= num_concurrent_decoders;
776 min_fps_no_render /= num_concurrent_decoders; 808 min_fps_no_render /= num_concurrent_decoders;
777 809
810 // If we reset mid-stream and start playback over, account for frames that are
811 // decoded twice in our expectations.
812 if (num_frames > 0 && reset_after_frame_num >= 0)
813 num_frames += reset_after_frame_num;
814
778 // Suppress EGL surface swapping in all but a few tests, to cut down overall 815 // Suppress EGL surface swapping in all but a few tests, to cut down overall
779 // test runtime. 816 // test runtime.
780 const bool suppress_swap_to_display = num_NALUs_per_decode > 1; 817 const bool suppress_swap_to_display = num_NALUs_per_decode > 1;
781 818
782 std::vector<ClientStateNotification*> notes(num_concurrent_decoders, NULL); 819 std::vector<ClientStateNotification*> notes(num_concurrent_decoders, NULL);
783 std::vector<EglRenderingVDAClient*> clients(num_concurrent_decoders, NULL); 820 std::vector<EglRenderingVDAClient*> clients(num_concurrent_decoders, NULL);
784 821
785 // Read in the video data. 822 // Read in the video data.
786 std::string data_str; 823 std::string data_str;
787 CHECK(file_util::ReadFileToString(FilePath(test_video_file), &data_str)); 824 CHECK(file_util::ReadFileToString(FilePath(test_video_file), &data_str));
(...skipping 12 matching lines...) Expand all
800 frame_width, frame_height, &done)); 837 frame_width, frame_height, &done));
801 done.Wait(); 838 done.Wait();
802 839
803 // First kick off all the decoders. 840 // First kick off all the decoders.
804 for (size_t index = 0; index < num_concurrent_decoders; ++index) { 841 for (size_t index = 0; index < num_concurrent_decoders; ++index) {
805 ClientStateNotification* note = new ClientStateNotification(); 842 ClientStateNotification* note = new ClientStateNotification();
806 notes[index] = note; 843 notes[index] = note;
807 EglRenderingVDAClient* client = new EglRenderingVDAClient( 844 EglRenderingVDAClient* client = new EglRenderingVDAClient(
808 &rendering_helper, index, 845 &rendering_helper, index,
809 note, data_str, num_NALUs_per_decode, 846 note, data_str, num_NALUs_per_decode,
810 delete_decoder_state); 847 reset_after_frame_num, delete_decoder_state);
811 clients[index] = client; 848 clients[index] = client;
812 849
813 rendering_thread.message_loop()->PostTask( 850 rendering_thread.message_loop()->PostTask(
814 FROM_HERE, 851 FROM_HERE,
815 base::Bind(&EglRenderingVDAClient::CreateDecoder, 852 base::Bind(&EglRenderingVDAClient::CreateDecoder,
816 base::Unretained(client))); 853 base::Unretained(client)));
817 854
818 ASSERT_EQ(note->Wait(), CS_DECODER_SET); 855 ASSERT_EQ(note->Wait(), CS_DECODER_SET);
819 } 856 }
820 // Then wait for all the decodes to finish. 857 // Then wait for all the decodes to finish.
(...skipping 26 matching lines...) Expand all
847 << num_concurrent_decoders; 884 << num_concurrent_decoders;
848 // Finally assert that decoding went as expected. 885 // Finally assert that decoding went as expected.
849 for (size_t i = 0; i < num_concurrent_decoders && !saw_init_failure; ++i) { 886 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 887 // We can only make performance/correctness assertions if the decoder was
851 // allowed to finish. 888 // allowed to finish.
852 if (delete_decoder_state < CS_FLUSHED) 889 if (delete_decoder_state < CS_FLUSHED)
853 continue; 890 continue;
854 EglRenderingVDAClient* client = clients[i]; 891 EglRenderingVDAClient* client = clients[i];
855 if (num_frames > 0) 892 if (num_frames > 0)
856 EXPECT_EQ(client->num_decoded_frames(), num_frames); 893 EXPECT_EQ(client->num_decoded_frames(), num_frames);
857 if (num_NALUs > 0) { 894 if (num_NALUs > 0 && reset_after_frame_num < 0) {
858 EXPECT_EQ(client->num_done_bitstream_buffers(), 895 EXPECT_EQ(client->num_done_bitstream_buffers(),
859 ceil(static_cast<double>(num_NALUs) / num_NALUs_per_decode)); 896 ceil(static_cast<double>(num_NALUs) / num_NALUs_per_decode));
860 } 897 }
861 LOG(INFO) << "Decoder " << i << " fps: " << client->frames_per_second(); 898 LOG(INFO) << "Decoder " << i << " fps: " << client->frames_per_second();
862 int min_fps = suppress_swap_to_display ? min_fps_no_render : min_fps_render; 899 int min_fps = suppress_swap_to_display ? min_fps_no_render : min_fps_render;
863 if (min_fps > 0) 900 if (min_fps > 0)
864 EXPECT_GT(client->frames_per_second(), min_fps); 901 EXPECT_GT(client->frames_per_second(), min_fps);
865 } 902 }
866 903
867 rendering_thread.message_loop()->PostTask( 904 rendering_thread.message_loop()->PostTask(
868 FROM_HERE, 905 FROM_HERE,
869 base::Bind(&STLDeleteElements<std::vector<EglRenderingVDAClient*> >, 906 base::Bind(&STLDeleteElements<std::vector<EglRenderingVDAClient*> >,
870 &clients)); 907 &clients));
871 rendering_thread.message_loop()->PostTask( 908 rendering_thread.message_loop()->PostTask(
872 FROM_HERE, 909 FROM_HERE,
873 base::Bind(&STLDeleteElements<std::vector<ClientStateNotification*> >, 910 base::Bind(&STLDeleteElements<std::vector<ClientStateNotification*> >,
874 &notes)); 911 &notes));
875 rendering_thread.message_loop()->PostTask( 912 rendering_thread.message_loop()->PostTask(
876 FROM_HERE, 913 FROM_HERE,
877 base::Bind(&RenderingHelper::UnInitialize, 914 base::Bind(&RenderingHelper::UnInitialize,
878 base::Unretained(&rendering_helper), 915 base::Unretained(&rendering_helper),
879 &done)); 916 &done));
880 done.Wait(); 917 done.Wait();
881 rendering_thread.Stop(); 918 rendering_thread.Stop();
882 }; 919 };
883 920
921 // Test that Reset() mid-stream works fine and doesn't affect decoding even when
922 // Decode() calls are made during the reset.
923 INSTANTIATE_TEST_CASE_P(
924 MidStreamReset, OmxVideoDecodeAcceleratorTest,
925 ::testing::Values(
926 MakeTuple(1, 1, static_cast<ResetPoint>(100), CS_RESET)));
927
928 // Test that Destroy() mid-stream works fine (primarily this is testing that no
929 // crashes occur).
884 INSTANTIATE_TEST_CASE_P( 930 INSTANTIATE_TEST_CASE_P(
885 TearDownTiming, OmxVideoDecodeAcceleratorTest, 931 TearDownTiming, OmxVideoDecodeAcceleratorTest,
886 ::testing::Values( 932 ::testing::Values(
887 MakeTuple(1, 1, CS_DECODER_SET), MakeTuple(1, 1, CS_INITIALIZED), 933 MakeTuple(1, 1, END_OF_STREAM_RESET, CS_DECODER_SET),
888 MakeTuple(1, 1, CS_FLUSHED), MakeTuple(1, 1, CS_RESET), 934 MakeTuple(1, 1, END_OF_STREAM_RESET, CS_INITIALIZED),
889 MakeTuple(1, 1, static_cast<ClientState>(-1)), 935 MakeTuple(1, 1, END_OF_STREAM_RESET, CS_FLUSHED),
890 MakeTuple(1, 1, static_cast<ClientState>(-10)), 936 MakeTuple(1, 1, END_OF_STREAM_RESET, CS_RESET),
891 MakeTuple(1, 1, static_cast<ClientState>(-100)))); 937 MakeTuple(1, 1, END_OF_STREAM_RESET, static_cast<ClientState>(-1)),
938 MakeTuple(1, 1, END_OF_STREAM_RESET, static_cast<ClientState>(-10)),
939 MakeTuple(1, 1, END_OF_STREAM_RESET, static_cast<ClientState>(-100))));
892 940
893 // TODO(fischman): using 1st param of 16 and higher below breaks decode - visual 941 // Test that decoding various variation works: multiple concurrent decoders and
894 // artifacts are introduced as well as spurious frames are delivered (more 942 // 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( 943 INSTANTIATE_TEST_CASE_P(
899 DecodeVariations, OmxVideoDecodeAcceleratorTest, 944 DecodeVariations, OmxVideoDecodeAcceleratorTest,
900 ::testing::Values( 945 ::testing::Values(
901 MakeTuple(1, 1, CS_RESET), MakeTuple(1, 3, CS_RESET), 946 MakeTuple(1, 1, END_OF_STREAM_RESET, CS_RESET),
902 MakeTuple(2, 1, CS_RESET), MakeTuple(3, 1, CS_RESET), 947 MakeTuple(1, 3, END_OF_STREAM_RESET, CS_RESET),
903 MakeTuple(5, 1, CS_RESET), MakeTuple(8, 1, CS_RESET), 948 MakeTuple(2, 1, END_OF_STREAM_RESET, CS_RESET),
904 MakeTuple(15, 1, CS_RESET))); 949 MakeTuple(3, 1, END_OF_STREAM_RESET, CS_RESET),
950 MakeTuple(5, 1, END_OF_STREAM_RESET, CS_RESET),
951 MakeTuple(8, 1, END_OF_STREAM_RESET, CS_RESET),
952 // TODO(fischman): decoding more than 15 NALUs at once breaks decode -
953 // visual artifacts are introduced as well as spurious frames are
954 // delivered (more pictures are returned than NALUs are fed to the
955 // decoder). Increase the "15" below when
956 // http://code.google.com/p/chrome-os-partner/issues/detail?id=4378 is
957 // fixed.
958 MakeTuple(15, 1, END_OF_STREAM_RESET, CS_RESET)));
905 959
906 // Find out how many concurrent decoders can go before we exhaust system 960 // Find out how many concurrent decoders can go before we exhaust system
907 // resources. 961 // resources.
908 INSTANTIATE_TEST_CASE_P( 962 INSTANTIATE_TEST_CASE_P(
909 ResourceExhaustion, OmxVideoDecodeAcceleratorTest, 963 ResourceExhaustion, OmxVideoDecodeAcceleratorTest,
910 ::testing::Values( 964 ::testing::Values(
911 // +0 hack below to promote enum to int. 965 // +0 hack below to promote enum to int.
912 MakeTuple(1, kMaxSupportedNumConcurrentDecoders + 0, CS_RESET), 966 MakeTuple(1, kMaxSupportedNumConcurrentDecoders + 0,
913 MakeTuple(1, kMaxSupportedNumConcurrentDecoders + 1, CS_RESET))); 967 END_OF_STREAM_RESET, CS_RESET),
968 MakeTuple(1, kMaxSupportedNumConcurrentDecoders + 1,
969 END_OF_STREAM_RESET, CS_RESET)));
914 970
915 // TODO(fischman, vrk): add more tests! In particular: 971 // TODO(fischman, vrk): add more tests! In particular:
916 // - Test life-cycle: Seek/Stop/Pause/Play/RePlay for a single decoder. 972 // - Test life-cycle: Seek/Stop/Pause/Play/RePlay for a single decoder.
917 // - Test alternate configurations 973 // - Test alternate configurations
918 // - Test failure conditions. 974 // - Test failure conditions.
919 // - Test frame size changes mid-stream 975 // - Test frame size changes mid-stream
920 976
921 } // namespace 977 } // namespace
922 978
923 int main(int argc, char **argv) { 979 int main(int argc, char **argv) {
924 testing::InitGoogleTest(&argc, argv); // Removes gtest-specific args. 980 testing::InitGoogleTest(&argc, argv); // Removes gtest-specific args.
925 CommandLine cmd_line(argc, argv); // Must run after InitGoogleTest. 981 CommandLine cmd_line(argc, argv); // Must run after InitGoogleTest.
926 CommandLine::SwitchMap switches = cmd_line.GetSwitches(); 982 CommandLine::SwitchMap switches = cmd_line.GetSwitches();
927 for (CommandLine::SwitchMap::const_iterator it = switches.begin(); 983 for (CommandLine::SwitchMap::const_iterator it = switches.begin();
928 it != switches.end(); ++it) { 984 it != switches.end(); ++it) {
929 if (it->first == "test_video_data") { 985 if (it->first == "test_video_data") {
930 test_video_data = it->second.c_str(); 986 test_video_data = it->second.c_str();
931 continue; 987 continue;
932 } 988 }
933 LOG(FATAL) << "Unexpected switch: " << it->first << ":" << it->second; 989 LOG(FATAL) << "Unexpected switch: " << it->first << ":" << it->second;
934 } 990 }
935 991
936 return RUN_ALL_TESTS(); 992 return RUN_ALL_TESTS();
937 } 993 }
OLDNEW
« no previous file with comments | « content/common/gpu/media/omx_video_decode_accelerator.cc ('k') | media/base/bitstream_buffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698