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

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

Issue 809883004: Revert hardware decoder changes causing ChromeOS HW test crash. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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
« no previous file with comments | « content/common/gpu/media/v4l2_video_device.cc ('k') | media/base/video_frame.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 // 4 //
5 // The bulk of this file is support code; sorry about that. Here's an overview 5 // The bulk of this file is support code; sorry about that. Here's an overview
6 // to hopefully help readers of this code: 6 // to hopefully help readers of this code:
7 // - RenderingHelper is charged with interacting with X11/{EGL/GLES2,GLX/GL} or 7 // - RenderingHelper is charged with interacting with X11/{EGL/GLES2,GLX/GL} or
8 // Win/EGL. 8 // Win/EGL.
9 // - ClientState is an enum for the state of the decode client used by the test. 9 // - ClientState is an enum for the state of the decode client used by the test.
10 // - ClientStateNotification is a barrier abstraction that allows the test code 10 // - ClientStateNotification is a barrier abstraction that allows the test code
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 namespace { 71 namespace {
72 72
73 // Values optionally filled in from flags; see main() below. 73 // Values optionally filled in from flags; see main() below.
74 // The syntax of multiple test videos is: 74 // The syntax of multiple test videos is:
75 // test-video1;test-video2;test-video3 75 // test-video1;test-video2;test-video3
76 // where only the first video is required and other optional videos would be 76 // where only the first video is required and other optional videos would be
77 // decoded by concurrent decoders. 77 // decoded by concurrent decoders.
78 // The syntax of each test-video is: 78 // The syntax of each test-video is:
79 // filename:width:height:numframes:numfragments:minFPSwithRender:minFPSnoRender 79 // filename:width:height:numframes:numfragments:minFPSwithRender:minFPSnoRender
80 // where only the first field is required. Value details: 80 // where only the first field is required. Value details:
81 // - |filename| must be an h264 Annex B (NAL) stream or an IVF VP8/9 stream. 81 // - |filename| must be an h264 Annex B (NAL) stream or an IVF VP8 stream.
82 // - |width| and |height| are in pixels. 82 // - |width| and |height| are in pixels.
83 // - |numframes| is the number of picture frames in the file. 83 // - |numframes| is the number of picture frames in the file.
84 // - |numfragments| NALU (h264) or frame (VP8/9) count in the stream. 84 // - |numfragments| NALU (h264) or frame (VP8) count in the stream.
85 // - |minFPSwithRender| and |minFPSnoRender| are minimum frames/second speeds 85 // - |minFPSwithRender| and |minFPSnoRender| are minimum frames/second speeds
86 // expected to be achieved with and without rendering to the screen, resp. 86 // expected to be achieved with and without rendering to the screen, resp.
87 // (the latter tests just decode speed). 87 // (the latter tests just decode speed).
88 // - |profile| is the media::VideoCodecProfile set during Initialization. 88 // - |profile| is the media::VideoCodecProfile set during Initialization.
89 // An empty value for a numeric field means "ignore". 89 // An empty value for a numeric field means "ignore".
90 const base::FilePath::CharType* g_test_video_data = 90 const base::FilePath::CharType* g_test_video_data =
91 // FILE_PATH_LITERAL("test-25fps.vp8:320:240:250:250:50:175:11"); 91 // FILE_PATH_LITERAL("test-25fps.vp8:320:240:250:250:50:175:11");
92 FILE_PATH_LITERAL("test-25fps.h264:320:240:250:258:50:175:1"); 92 FILE_PATH_LITERAL("test-25fps.h264:320:240:250:258:50:175:1");
93 93
94 // The file path of the test output log. This is used to communicate the test 94 // The file path of the test output log. This is used to communicate the test
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 // Compute & return the first encoded bytes (including a start frame) to send 292 // Compute & return the first encoded bytes (including a start frame) to send
293 // to the decoder, starting at |start_pos| and returning one fragment. Skips 293 // to the decoder, starting at |start_pos| and returning one fragment. Skips
294 // to the first decodable position. 294 // to the first decodable position.
295 std::string GetBytesForFirstFragment(size_t start_pos, size_t* end_pos); 295 std::string GetBytesForFirstFragment(size_t start_pos, size_t* end_pos);
296 // Compute & return the encoded bytes of next fragment to send to the decoder 296 // Compute & return the encoded bytes of next fragment to send to the decoder
297 // (based on |start_pos|). 297 // (based on |start_pos|).
298 std::string GetBytesForNextFragment(size_t start_pos, size_t* end_pos); 298 std::string GetBytesForNextFragment(size_t start_pos, size_t* end_pos);
299 // Helpers for GetBytesForNextFragment above. 299 // Helpers for GetBytesForNextFragment above.
300 void GetBytesForNextNALU(size_t start_pos, size_t* end_pos); // For h.264. 300 void GetBytesForNextNALU(size_t start_pos, size_t* end_pos); // For h.264.
301 std::string GetBytesForNextFrame( 301 std::string GetBytesForNextFrame(
302 size_t start_pos, size_t* end_pos); // For VP8/9. 302 size_t start_pos, size_t* end_pos); // For VP8.
303 303
304 // Request decode of the next fragment in the encoded data. 304 // Request decode of the next fragment in the encoded data.
305 void DecodeNextFragment(); 305 void DecodeNextFragment();
306 306
307 size_t window_id_; 307 size_t window_id_;
308 RenderingHelper* rendering_helper_; 308 RenderingHelper* rendering_helper_;
309 gfx::Size frame_size_; 309 gfx::Size frame_size_;
310 std::string encoded_data_; 310 std::string encoded_data_;
311 const int num_in_flight_decodes_; 311 const int num_in_flight_decodes_;
312 int outstanding_decodes_; 312 int outstanding_decodes_;
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 *end_pos = start_pos; 675 *end_pos = start_pos;
676 while (*end_pos + 4 < encoded_data_.size()) { 676 while (*end_pos + 4 < encoded_data_.size()) {
677 if ((encoded_data_[*end_pos + 4] & 0x1f) == 0x7) // SPS start frame 677 if ((encoded_data_[*end_pos + 4] & 0x1f) == 0x7) // SPS start frame
678 return GetBytesForNextFragment(*end_pos, end_pos); 678 return GetBytesForNextFragment(*end_pos, end_pos);
679 GetBytesForNextNALU(*end_pos, end_pos); 679 GetBytesForNextNALU(*end_pos, end_pos);
680 num_skipped_fragments_++; 680 num_skipped_fragments_++;
681 } 681 }
682 *end_pos = start_pos; 682 *end_pos = start_pos;
683 return std::string(); 683 return std::string();
684 } 684 }
685 DCHECK_LE(profile_, media::VP9PROFILE_MAX); 685 DCHECK_LE(profile_, media::VP8PROFILE_MAX);
686 return GetBytesForNextFragment(start_pos, end_pos); 686 return GetBytesForNextFragment(start_pos, end_pos);
687 } 687 }
688 688
689 std::string GLRenderingVDAClient::GetBytesForNextFragment( 689 std::string GLRenderingVDAClient::GetBytesForNextFragment(
690 size_t start_pos, size_t* end_pos) { 690 size_t start_pos, size_t* end_pos) {
691 if (profile_ < media::H264PROFILE_MAX) { 691 if (profile_ < media::H264PROFILE_MAX) {
692 *end_pos = start_pos; 692 *end_pos = start_pos;
693 GetBytesForNextNALU(*end_pos, end_pos); 693 GetBytesForNextNALU(*end_pos, end_pos);
694 if (start_pos != *end_pos) { 694 if (start_pos != *end_pos) {
695 num_queued_fragments_++; 695 num_queued_fragments_++;
696 } 696 }
697 return encoded_data_.substr(start_pos, *end_pos - start_pos); 697 return encoded_data_.substr(start_pos, *end_pos - start_pos);
698 } 698 }
699 DCHECK_LE(profile_, media::VP9PROFILE_MAX); 699 DCHECK_LE(profile_, media::VP8PROFILE_MAX);
700 return GetBytesForNextFrame(start_pos, end_pos); 700 return GetBytesForNextFrame(start_pos, end_pos);
701 } 701 }
702 702
703 void GLRenderingVDAClient::GetBytesForNextNALU( 703 void GLRenderingVDAClient::GetBytesForNextNALU(
704 size_t start_pos, size_t* end_pos) { 704 size_t start_pos, size_t* end_pos) {
705 *end_pos = start_pos; 705 *end_pos = start_pos;
706 if (*end_pos + 4 > encoded_data_.size()) 706 if (*end_pos + 4 > encoded_data_.size())
707 return; 707 return;
708 CHECK(LookingAtNAL(encoded_data_, start_pos)); 708 CHECK(LookingAtNAL(encoded_data_, start_pos));
709 *end_pos += 4; 709 *end_pos += 4;
(...skipping 28 matching lines...) Expand all
738 parser.SetStream(data, size); 738 parser.SetStream(data, size);
739 media::H264NALU nalu; 739 media::H264NALU nalu;
740 media::H264Parser::Result result = parser.AdvanceToNextNALU(&nalu); 740 media::H264Parser::Result result = parser.AdvanceToNextNALU(&nalu);
741 if (result != media::H264Parser::kOk) { 741 if (result != media::H264Parser::kOk) {
742 // Let the VDA figure out there's something wrong with the stream. 742 // Let the VDA figure out there's something wrong with the stream.
743 return false; 743 return false;
744 } 744 }
745 745
746 return nalu.nal_unit_type == media::H264NALU::kSPS; 746 return nalu.nal_unit_type == media::H264NALU::kSPS;
747 } else if (profile >= media::VP8PROFILE_MIN && 747 } else if (profile >= media::VP8PROFILE_MIN &&
748 profile <= media::VP9PROFILE_MAX) { 748 profile <= media::VP8PROFILE_MAX) {
749 return (size > 0 && !(data[0] & 0x01)); 749 return (size > 0 && !(data[0] & 0x01));
750 } 750 }
751 // Shouldn't happen at this point. 751 // Shouldn't happen at this point.
752 LOG(FATAL) << "Invalid profile: " << profile; 752 LOG(FATAL) << "Invalid profile: " << profile;
753 return false; 753 return false;
754 } 754 }
755 755
756 void GLRenderingVDAClient::DecodeNextFragment() { 756 void GLRenderingVDAClient::DecodeNextFragment() {
757 if (decoder_deleted()) 757 if (decoder_deleted())
758 return; 758 return;
(...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after
1472 if (it->first == "ozone-platform" || it->first == "ozone-use-surfaceless") 1472 if (it->first == "ozone-platform" || it->first == "ozone-use-surfaceless")
1473 continue; 1473 continue;
1474 LOG(FATAL) << "Unexpected switch: " << it->first << ":" << it->second; 1474 LOG(FATAL) << "Unexpected switch: " << it->first << ":" << it->second;
1475 } 1475 }
1476 1476
1477 base::ShadowingAtExitManager at_exit_manager; 1477 base::ShadowingAtExitManager at_exit_manager;
1478 content::RenderingHelper::InitializeOneOff(); 1478 content::RenderingHelper::InitializeOneOff();
1479 1479
1480 return RUN_ALL_TESTS(); 1480 return RUN_ALL_TESTS();
1481 } 1481 }
OLDNEW
« no previous file with comments | « content/common/gpu/media/v4l2_video_device.cc ('k') | media/base/video_frame.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698