Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 |
| 11 // to be written sequentially and wait for the decode client to see certain | 11 // to be written sequentially and wait for the decode client to see certain |
| 12 // state transitions. | 12 // state transitions. |
| 13 // - GLRenderingVDAClient is a VideoDecodeAccelerator::Client implementation | 13 // - GLRenderingVDAClient is a VideoDecodeAccelerator::Client implementation |
| 14 // - Finally actual TEST cases are at the bottom of this file, using the above | 14 // - Finally actual TEST cases are at the bottom of this file, using the above |
| 15 // infrastructure. | 15 // infrastructure. |
| 16 | 16 |
| 17 #include <fcntl.h> | 17 #include <fcntl.h> |
| 18 #include <sys/stat.h> | 18 #include <sys/stat.h> |
| 19 #include <sys/types.h> | 19 #include <sys/types.h> |
| 20 #include <algorithm> | |
| 20 #include <deque> | 21 #include <deque> |
| 22 #include <map> | |
| 21 | 23 |
| 22 // Include gtest.h out of order because <X11/X.h> #define's Bool & None, which | 24 // Include gtest.h out of order because <X11/X.h> #define's Bool & None, which |
| 23 // gtest uses as struct names (inside a namespace). This means that | 25 // gtest uses as struct names (inside a namespace). This means that |
| 24 // #include'ing gtest after anything that pulls in X.h fails to compile. | 26 // #include'ing gtest after anything that pulls in X.h fails to compile. |
| 25 // This is http://code.google.com/p/googletest/issues/detail?id=371 | 27 // This is http://code.google.com/p/googletest/issues/detail?id=371 |
| 26 #include "testing/gtest/include/gtest/gtest.h" | 28 #include "testing/gtest/include/gtest/gtest.h" |
| 27 | 29 |
| 28 #include "base/at_exit.h" | 30 #include "base/at_exit.h" |
| 29 #include "base/bind.h" | 31 #include "base/bind.h" |
| 30 #include "base/command_line.h" | 32 #include "base/command_line.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 81 // - |numfragments| NALU (h264) or frame (VP8) count in the stream. | 83 // - |numfragments| NALU (h264) or frame (VP8) count in the stream. |
| 82 // - |minFPSwithRender| and |minFPSnoRender| are minimum frames/second speeds | 84 // - |minFPSwithRender| and |minFPSnoRender| are minimum frames/second speeds |
| 83 // expected to be achieved with and without rendering to the screen, resp. | 85 // expected to be achieved with and without rendering to the screen, resp. |
| 84 // (the latter tests just decode speed). | 86 // (the latter tests just decode speed). |
| 85 // - |profile| is the media::VideoCodecProfile set during Initialization. | 87 // - |profile| is the media::VideoCodecProfile set during Initialization. |
| 86 // An empty value for a numeric field means "ignore". | 88 // An empty value for a numeric field means "ignore". |
| 87 const base::FilePath::CharType* g_test_video_data = | 89 const base::FilePath::CharType* g_test_video_data = |
| 88 // FILE_PATH_LITERAL("test-25fps.vp8:320:240:250:250:50:175:11"); | 90 // FILE_PATH_LITERAL("test-25fps.vp8:320:240:250:250:50:175:11"); |
| 89 FILE_PATH_LITERAL("test-25fps.h264:320:240:250:258:50:175:1"); | 91 FILE_PATH_LITERAL("test-25fps.h264:320:240:250:258:50:175:1"); |
| 90 | 92 |
| 91 // The path of the frame delivery time log. We can enable the log and specify | 93 // The file path of the test output log. This is used to communicate the test |
| 92 // the filename by the "--frame_delivery_log" switch. | 94 // results to CrOS autotests. We can enable the log and specify the filename by |
| 93 const base::FilePath::CharType* g_frame_delivery_log = NULL; | 95 // the "--output_log" switch. |
| 96 const base::FilePath::CharType* g_output_log = NULL; | |
| 94 | 97 |
| 95 // The value is set by the switch "--rendering_fps". | 98 // The value is set by the switch "--rendering_fps". |
| 96 double g_rendering_fps = 0; | 99 double g_rendering_fps = 0; |
| 97 | 100 |
| 98 // Disable rendering, the value is set by the switch "--disable_rendering". | 101 // Disable rendering, the value is set by the switch "--disable_rendering". |
| 99 bool g_disable_rendering = false; | 102 bool g_disable_rendering = false; |
| 100 | 103 |
| 101 // Magic constants for differentiating the reasons for NotifyResetDone being | 104 // Magic constants for differentiating the reasons for NotifyResetDone being |
| 102 // called. | 105 // called. |
| 103 enum ResetPoint { | 106 enum ResetPoint { |
| 104 START_OF_STREAM_RESET = -3, | 107 START_OF_STREAM_RESET = -3, |
| 105 MID_STREAM_RESET = -2, | 108 MID_STREAM_RESET = -2, |
| 106 END_OF_STREAM_RESET = -1 | 109 END_OF_STREAM_RESET = -1 |
| 107 }; | 110 }; |
| 108 | 111 |
| 109 const int kMaxResetAfterFrameNum = 100; | 112 const int kMaxResetAfterFrameNum = 100; |
| 110 const int kMaxFramesToDelayReuse = 64; | 113 const int kMaxFramesToDelayReuse = 64; |
| 111 const base::TimeDelta kReuseDelay = base::TimeDelta::FromSeconds(1); | 114 const base::TimeDelta kReuseDelay = base::TimeDelta::FromSeconds(1); |
| 115 // Simulate WebRTC and call VDA::Decode 30 times per second. | |
| 116 const int kWebRtcDecodeCallsPerSecond = 30; | |
| 112 | 117 |
| 113 struct TestVideoFile { | 118 struct TestVideoFile { |
| 114 explicit TestVideoFile(base::FilePath::StringType file_name) | 119 explicit TestVideoFile(base::FilePath::StringType file_name) |
| 115 : file_name(file_name), | 120 : file_name(file_name), |
| 116 width(-1), | 121 width(-1), |
| 117 height(-1), | 122 height(-1), |
| 118 num_frames(-1), | 123 num_frames(-1), |
| 119 num_fragments(-1), | 124 num_fragments(-1), |
| 120 min_fps_render(-1), | 125 min_fps_render(-1), |
| 121 min_fps_no_render(-1), | 126 min_fps_no_render(-1), |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 136 }; | 141 }; |
| 137 | 142 |
| 138 // Presumed minimal display size. | 143 // Presumed minimal display size. |
| 139 // We subtract one pixel from the width because some ARM chromebooks do not | 144 // We subtract one pixel from the width because some ARM chromebooks do not |
| 140 // support two fullscreen app running at the same time. See crbug.com/270064. | 145 // support two fullscreen app running at the same time. See crbug.com/270064. |
| 141 const gfx::Size kThumbnailsDisplaySize(1366 - 1, 768); | 146 const gfx::Size kThumbnailsDisplaySize(1366 - 1, 768); |
| 142 const gfx::Size kThumbnailsPageSize(1600, 1200); | 147 const gfx::Size kThumbnailsPageSize(1600, 1200); |
| 143 const gfx::Size kThumbnailSize(160, 120); | 148 const gfx::Size kThumbnailSize(160, 120); |
| 144 const int kMD5StringLength = 32; | 149 const int kMD5StringLength = 32; |
| 145 | 150 |
| 146 // Parse |data| into its constituent parts, set the various output fields | |
| 147 // accordingly, and read in video stream. CHECK-fails on unexpected or | |
| 148 // missing required data. Unspecified optional fields are set to -1. | |
| 149 void ParseAndReadTestVideoData(base::FilePath::StringType data, | |
| 150 size_t num_concurrent_decoders, | |
| 151 int reset_point, | |
| 152 std::vector<TestVideoFile*>* test_video_files) { | |
| 153 std::vector<base::FilePath::StringType> entries; | |
| 154 base::SplitString(data, ';', &entries); | |
| 155 CHECK_GE(entries.size(), 1U) << data; | |
| 156 for (size_t index = 0; index < entries.size(); ++index) { | |
| 157 std::vector<base::FilePath::StringType> fields; | |
| 158 base::SplitString(entries[index], ':', &fields); | |
| 159 CHECK_GE(fields.size(), 1U) << entries[index]; | |
| 160 CHECK_LE(fields.size(), 8U) << entries[index]; | |
| 161 TestVideoFile* video_file = new TestVideoFile(fields[0]); | |
| 162 if (!fields[1].empty()) | |
| 163 CHECK(base::StringToInt(fields[1], &video_file->width)); | |
| 164 if (!fields[2].empty()) | |
| 165 CHECK(base::StringToInt(fields[2], &video_file->height)); | |
| 166 if (!fields[3].empty()) { | |
| 167 CHECK(base::StringToInt(fields[3], &video_file->num_frames)); | |
| 168 // If we reset mid-stream and start playback over, account for frames | |
| 169 // that are decoded twice in our expectations. | |
| 170 if (video_file->num_frames > 0 && reset_point == MID_STREAM_RESET) { | |
| 171 // Reset should not go beyond the last frame; reset after the first | |
| 172 // frame for short videos. | |
| 173 video_file->reset_after_frame_num = kMaxResetAfterFrameNum; | |
| 174 if (video_file->num_frames <= kMaxResetAfterFrameNum) | |
| 175 video_file->reset_after_frame_num = 1; | |
| 176 video_file->num_frames += video_file->reset_after_frame_num; | |
| 177 } else { | |
| 178 video_file->reset_after_frame_num = reset_point; | |
| 179 } | |
| 180 } | |
| 181 if (!fields[4].empty()) | |
| 182 CHECK(base::StringToInt(fields[4], &video_file->num_fragments)); | |
| 183 if (!fields[5].empty()) { | |
| 184 CHECK(base::StringToInt(fields[5], &video_file->min_fps_render)); | |
| 185 video_file->min_fps_render /= num_concurrent_decoders; | |
| 186 } | |
| 187 if (!fields[6].empty()) { | |
| 188 CHECK(base::StringToInt(fields[6], &video_file->min_fps_no_render)); | |
| 189 video_file->min_fps_no_render /= num_concurrent_decoders; | |
| 190 } | |
| 191 if (!fields[7].empty()) | |
| 192 CHECK(base::StringToInt(fields[7], &video_file->profile)); | |
| 193 | |
| 194 // Read in the video data. | |
| 195 base::FilePath filepath(video_file->file_name); | |
| 196 CHECK(base::ReadFileToString(filepath, &video_file->data_str)) | |
| 197 << "test_video_file: " << filepath.MaybeAsASCII(); | |
| 198 | |
| 199 test_video_files->push_back(video_file); | |
| 200 } | |
| 201 } | |
| 202 | |
| 203 // Read in golden MD5s for the thumbnailed rendering of this video | 151 // Read in golden MD5s for the thumbnailed rendering of this video |
| 204 void ReadGoldenThumbnailMD5s(const TestVideoFile* video_file, | 152 void ReadGoldenThumbnailMD5s(const TestVideoFile* video_file, |
| 205 std::vector<std::string>* md5_strings) { | 153 std::vector<std::string>* md5_strings) { |
| 206 base::FilePath filepath(video_file->file_name); | 154 base::FilePath filepath(video_file->file_name); |
| 207 filepath = filepath.AddExtension(FILE_PATH_LITERAL(".md5")); | 155 filepath = filepath.AddExtension(FILE_PATH_LITERAL(".md5")); |
| 208 std::string all_md5s; | 156 std::string all_md5s; |
| 209 base::ReadFileToString(filepath, &all_md5s); | 157 base::ReadFileToString(filepath, &all_md5s); |
| 210 base::SplitString(all_md5s, '\n', md5_strings); | 158 base::SplitString(all_md5s, '\n', md5_strings); |
| 211 // Check these are legitimate MD5s. | 159 // Check these are legitimate MD5s. |
| 212 for (std::vector<std::string>::iterator md5_string = md5_strings->begin(); | 160 for (std::vector<std::string>::iterator md5_string = md5_strings->begin(); |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 406 // |delete_decoder_state| indicates when the underlying decoder should be | 354 // |delete_decoder_state| indicates when the underlying decoder should be |
| 407 // Destroy()'d and deleted and can take values: N<0: delete after -N Decode() | 355 // Destroy()'d and deleted and can take values: N<0: delete after -N Decode() |
| 408 // calls have been made, N>=0 means interpret as ClientState. | 356 // calls have been made, N>=0 means interpret as ClientState. |
| 409 // Both |reset_after_frame_num| & |delete_decoder_state| apply only to the | 357 // Both |reset_after_frame_num| & |delete_decoder_state| apply only to the |
| 410 // last play-through (governed by |num_play_throughs|). | 358 // last play-through (governed by |num_play_throughs|). |
| 411 // |rendering_fps| indicates the target rendering fps. 0 means no target fps | 359 // |rendering_fps| indicates the target rendering fps. 0 means no target fps |
| 412 // and it would render as fast as possible. | 360 // and it would render as fast as possible. |
| 413 // |suppress_rendering| indicates GL rendering is suppressed or not. | 361 // |suppress_rendering| indicates GL rendering is suppressed or not. |
| 414 // After |delay_reuse_after_frame_num| frame has been delivered, the client | 362 // After |delay_reuse_after_frame_num| frame has been delivered, the client |
| 415 // will start delaying the call to ReusePictureBuffer() for kReuseDelay. | 363 // will start delaying the call to ReusePictureBuffer() for kReuseDelay. |
| 364 // |decode_calls_per_second| is the number of VDA::Decode calls per second. | |
| 365 // If |decode_calls_per_second| > 0, |num_in_flight_decodes| must be 1. | |
| 416 GLRenderingVDAClient(RenderingHelper* rendering_helper, | 366 GLRenderingVDAClient(RenderingHelper* rendering_helper, |
| 417 int rendering_window_id, | 367 int rendering_window_id, |
| 418 ClientStateNotification<ClientState>* note, | 368 ClientStateNotification<ClientState>* note, |
| 419 const std::string& encoded_data, | 369 const std::string& encoded_data, |
| 420 int num_in_flight_decodes, | 370 int num_in_flight_decodes, |
| 421 int num_play_throughs, | 371 int num_play_throughs, |
| 422 int reset_after_frame_num, | 372 int reset_after_frame_num, |
| 423 int delete_decoder_state, | 373 int delete_decoder_state, |
| 424 int frame_width, | 374 int frame_width, |
| 425 int frame_height, | 375 int frame_height, |
| 426 int profile, | 376 int profile, |
| 427 double rendering_fps, | 377 double rendering_fps, |
| 428 bool suppress_rendering, | 378 bool suppress_rendering, |
| 429 int delay_reuse_after_frame_num); | 379 int delay_reuse_after_frame_num, |
| 380 int decode_calls_per_second); | |
| 430 virtual ~GLRenderingVDAClient(); | 381 virtual ~GLRenderingVDAClient(); |
| 431 void CreateDecoder(); | 382 void CreateAndStartDecoder(); |
| 432 | 383 |
| 433 // VideoDecodeAccelerator::Client implementation. | 384 // VideoDecodeAccelerator::Client implementation. |
| 434 // The heart of the Client. | 385 // The heart of the Client. |
| 435 virtual void ProvidePictureBuffers(uint32 requested_num_of_buffers, | 386 virtual void ProvidePictureBuffers(uint32 requested_num_of_buffers, |
| 436 const gfx::Size& dimensions, | 387 const gfx::Size& dimensions, |
| 437 uint32 texture_target) OVERRIDE; | 388 uint32 texture_target) OVERRIDE; |
| 438 virtual void DismissPictureBuffer(int32 picture_buffer_id) OVERRIDE; | 389 virtual void DismissPictureBuffer(int32 picture_buffer_id) OVERRIDE; |
| 439 virtual void PictureReady(const media::Picture& picture) OVERRIDE; | 390 virtual void PictureReady(const media::Picture& picture) OVERRIDE; |
| 440 // Simple state changes. | 391 // Simple state changes. |
| 441 virtual void NotifyInitializeDone() OVERRIDE; | 392 virtual void NotifyInitializeDone() OVERRIDE; |
| 442 virtual void NotifyEndOfBitstreamBuffer(int32 bitstream_buffer_id) OVERRIDE; | 393 virtual void NotifyEndOfBitstreamBuffer(int32 bitstream_buffer_id) OVERRIDE; |
| 443 virtual void NotifyFlushDone() OVERRIDE; | 394 virtual void NotifyFlushDone() OVERRIDE; |
| 444 virtual void NotifyResetDone() OVERRIDE; | 395 virtual void NotifyResetDone() OVERRIDE; |
| 445 virtual void NotifyError(VideoDecodeAccelerator::Error error) OVERRIDE; | 396 virtual void NotifyError(VideoDecodeAccelerator::Error error) OVERRIDE; |
| 446 | 397 |
| 447 void OutputFrameDeliveryTimes(base::PlatformFile output); | 398 void OutputFrameDeliveryTimes(base::PlatformFile output); |
| 448 | 399 |
| 449 void NotifyFrameDropped(int32 picture_buffer_id); | 400 void NotifyFrameDropped(int32 picture_buffer_id); |
| 450 | 401 |
| 451 // Simple getters for inspecting the state of the Client. | 402 // Simple getters for inspecting the state of the Client. |
| 452 int num_done_bitstream_buffers() { return num_done_bitstream_buffers_; } | 403 int num_done_bitstream_buffers() { return num_done_bitstream_buffers_; } |
| 453 int num_skipped_fragments() { return num_skipped_fragments_; } | 404 int num_skipped_fragments() { return num_skipped_fragments_; } |
| 454 int num_queued_fragments() { return num_queued_fragments_; } | 405 int num_queued_fragments() { return num_queued_fragments_; } |
| 455 int num_decoded_frames(); | 406 int num_decoded_frames(); |
| 456 double frames_per_second(); | 407 double frames_per_second(); |
| 408 // Return the median of the decode time in milliseconds. | |
| 409 int decode_time_median(); | |
| 457 bool decoder_deleted() { return !decoder_.get(); } | 410 bool decoder_deleted() { return !decoder_.get(); } |
| 458 | 411 |
| 459 private: | 412 private: |
| 460 typedef std::map<int, media::PictureBuffer*> PictureBufferById; | 413 typedef std::map<int, media::PictureBuffer*> PictureBufferById; |
| 461 | 414 |
| 462 void SetState(ClientState new_state); | 415 void SetState(ClientState new_state); |
| 463 | 416 |
| 464 // Delete the associated decoder helper. | 417 // Delete the associated decoder helper. |
| 465 void DeleteDecoder(); | 418 void DeleteDecoder(); |
| 466 | 419 |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 497 int num_queued_fragments_; | 450 int num_queued_fragments_; |
| 498 int num_decoded_frames_; | 451 int num_decoded_frames_; |
| 499 int num_done_bitstream_buffers_; | 452 int num_done_bitstream_buffers_; |
| 500 PictureBufferById picture_buffers_by_id_; | 453 PictureBufferById picture_buffers_by_id_; |
| 501 base::TimeTicks initialize_done_ticks_; | 454 base::TimeTicks initialize_done_ticks_; |
| 502 int profile_; | 455 int profile_; |
| 503 bool suppress_rendering_; | 456 bool suppress_rendering_; |
| 504 std::vector<base::TimeTicks> frame_delivery_times_; | 457 std::vector<base::TimeTicks> frame_delivery_times_; |
| 505 int delay_reuse_after_frame_num_; | 458 int delay_reuse_after_frame_num_; |
| 506 scoped_ptr<ThrottlingVDAClient> throttling_client_; | 459 scoped_ptr<ThrottlingVDAClient> throttling_client_; |
| 460 // A map from bitstream buffer id to the decode start time of the buffer. | |
| 461 std::map<int, base::TimeTicks> decode_start_time_; | |
| 462 // The decode time of all decoded frames. | |
| 463 std::vector<base::TimeDelta> decode_time_; | |
| 464 // The number of VDA::Decode calls per second. This is to simulate webrtc. | |
| 465 int decode_calls_per_second_; | |
| 507 | 466 |
| 508 DISALLOW_IMPLICIT_CONSTRUCTORS(GLRenderingVDAClient); | 467 DISALLOW_IMPLICIT_CONSTRUCTORS(GLRenderingVDAClient); |
| 509 }; | 468 }; |
| 510 | 469 |
| 511 GLRenderingVDAClient::GLRenderingVDAClient( | 470 GLRenderingVDAClient::GLRenderingVDAClient( |
| 512 RenderingHelper* rendering_helper, | 471 RenderingHelper* rendering_helper, |
| 513 int rendering_window_id, | 472 int rendering_window_id, |
| 514 ClientStateNotification<ClientState>* note, | 473 ClientStateNotification<ClientState>* note, |
| 515 const std::string& encoded_data, | 474 const std::string& encoded_data, |
| 516 int num_in_flight_decodes, | 475 int num_in_flight_decodes, |
| 517 int num_play_throughs, | 476 int num_play_throughs, |
| 518 int reset_after_frame_num, | 477 int reset_after_frame_num, |
| 519 int delete_decoder_state, | 478 int delete_decoder_state, |
| 520 int frame_width, | 479 int frame_width, |
| 521 int frame_height, | 480 int frame_height, |
| 522 int profile, | 481 int profile, |
| 523 double rendering_fps, | 482 double rendering_fps, |
| 524 bool suppress_rendering, | 483 bool suppress_rendering, |
| 525 int delay_reuse_after_frame_num) | 484 int delay_reuse_after_frame_num, |
| 485 int decode_calls_per_second) | |
| 526 : rendering_helper_(rendering_helper), | 486 : rendering_helper_(rendering_helper), |
| 527 rendering_window_id_(rendering_window_id), | 487 rendering_window_id_(rendering_window_id), |
| 528 encoded_data_(encoded_data), | 488 encoded_data_(encoded_data), |
| 529 num_in_flight_decodes_(num_in_flight_decodes), | 489 num_in_flight_decodes_(num_in_flight_decodes), |
| 530 outstanding_decodes_(0), | 490 outstanding_decodes_(0), |
| 531 encoded_data_next_pos_to_decode_(0), | 491 encoded_data_next_pos_to_decode_(0), |
| 532 next_bitstream_buffer_id_(0), | 492 next_bitstream_buffer_id_(0), |
| 533 note_(note), | 493 note_(note), |
| 534 remaining_play_throughs_(num_play_throughs), | 494 remaining_play_throughs_(num_play_throughs), |
| 535 reset_after_frame_num_(reset_after_frame_num), | 495 reset_after_frame_num_(reset_after_frame_num), |
| 536 delete_decoder_state_(delete_decoder_state), | 496 delete_decoder_state_(delete_decoder_state), |
| 537 state_(CS_CREATED), | 497 state_(CS_CREATED), |
| 538 num_skipped_fragments_(0), | 498 num_skipped_fragments_(0), |
| 539 num_queued_fragments_(0), | 499 num_queued_fragments_(0), |
| 540 num_decoded_frames_(0), | 500 num_decoded_frames_(0), |
| 541 num_done_bitstream_buffers_(0), | 501 num_done_bitstream_buffers_(0), |
| 542 profile_(profile), | 502 profile_(profile), |
| 543 suppress_rendering_(suppress_rendering), | 503 suppress_rendering_(suppress_rendering), |
| 544 delay_reuse_after_frame_num_(delay_reuse_after_frame_num) { | 504 delay_reuse_after_frame_num_(delay_reuse_after_frame_num), |
| 505 decode_calls_per_second_(decode_calls_per_second) { | |
| 545 CHECK_GT(num_in_flight_decodes, 0); | 506 CHECK_GT(num_in_flight_decodes, 0); |
| 546 CHECK_GT(num_play_throughs, 0); | 507 CHECK_GT(num_play_throughs, 0); |
| 547 CHECK_GE(rendering_fps, 0); | 508 CHECK_GE(rendering_fps, 0); |
| 509 // |num_in_flight_decodes_| is unsupported if |decode_calls_per_second_| > 0. | |
| 510 if (decode_calls_per_second_ > 0) | |
| 511 CHECK_EQ(1, num_in_flight_decodes_); | |
| 548 if (rendering_fps > 0) | 512 if (rendering_fps > 0) |
| 549 throttling_client_.reset(new ThrottlingVDAClient( | 513 throttling_client_.reset(new ThrottlingVDAClient( |
| 550 this, | 514 this, |
| 551 rendering_fps, | 515 rendering_fps, |
| 552 base::Bind(&GLRenderingVDAClient::NotifyFrameDropped, | 516 base::Bind(&GLRenderingVDAClient::NotifyFrameDropped, |
| 553 base::Unretained(this)))); | 517 base::Unretained(this)))); |
| 554 } | 518 } |
| 555 | 519 |
| 556 GLRenderingVDAClient::~GLRenderingVDAClient() { | 520 GLRenderingVDAClient::~GLRenderingVDAClient() { |
| 557 DeleteDecoder(); // Clean up in case of expected error. | 521 DeleteDecoder(); // Clean up in case of expected error. |
| 558 CHECK(decoder_deleted()); | 522 CHECK(decoder_deleted()); |
| 559 STLDeleteValues(&picture_buffers_by_id_); | 523 STLDeleteValues(&picture_buffers_by_id_); |
| 560 SetState(CS_DESTROYED); | 524 SetState(CS_DESTROYED); |
| 561 } | 525 } |
| 562 | 526 |
| 563 static bool DoNothingReturnTrue() { return true; } | 527 static bool DoNothingReturnTrue() { return true; } |
| 564 | 528 |
| 565 void GLRenderingVDAClient::CreateDecoder() { | 529 void GLRenderingVDAClient::CreateAndStartDecoder() { |
| 566 CHECK(decoder_deleted()); | 530 CHECK(decoder_deleted()); |
| 567 CHECK(!decoder_.get()); | 531 CHECK(!decoder_.get()); |
| 568 | 532 |
| 569 VideoDecodeAccelerator::Client* client = this; | 533 VideoDecodeAccelerator::Client* client = this; |
| 570 base::WeakPtr<VideoDecodeAccelerator::Client> weak_client = AsWeakPtr(); | 534 base::WeakPtr<VideoDecodeAccelerator::Client> weak_client = AsWeakPtr(); |
| 571 if (throttling_client_) { | 535 if (throttling_client_) { |
| 572 client = throttling_client_.get(); | 536 client = throttling_client_.get(); |
| 573 weak_client = throttling_client_->AsWeakPtr(); | 537 weak_client = throttling_client_->AsWeakPtr(); |
| 574 } | 538 } |
| 575 #if defined(OS_WIN) | 539 #if defined(OS_WIN) |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 638 picture_buffers_by_id_.erase(it); | 602 picture_buffers_by_id_.erase(it); |
| 639 } | 603 } |
| 640 | 604 |
| 641 void GLRenderingVDAClient::PictureReady(const media::Picture& picture) { | 605 void GLRenderingVDAClient::PictureReady(const media::Picture& picture) { |
| 642 // We shouldn't be getting pictures delivered after Reset has completed. | 606 // We shouldn't be getting pictures delivered after Reset has completed. |
| 643 CHECK_LT(state_, CS_RESET); | 607 CHECK_LT(state_, CS_RESET); |
| 644 | 608 |
| 645 if (decoder_deleted()) | 609 if (decoder_deleted()) |
| 646 return; | 610 return; |
| 647 | 611 |
| 648 frame_delivery_times_.push_back(base::TimeTicks::Now()); | 612 base::TimeTicks now = base::TimeTicks::Now(); |
| 613 frame_delivery_times_.push_back(now); | |
| 614 // Save the decode time of this picture. | |
| 615 std::map<int, base::TimeTicks>::iterator it = | |
| 616 decode_start_time_.find(picture.bitstream_buffer_id()); | |
| 617 ASSERT_NE(decode_start_time_.end(), it); | |
| 618 decode_time_.push_back(now - it->second); | |
| 619 decode_start_time_.erase(it); | |
| 649 | 620 |
| 650 CHECK_LE(picture.bitstream_buffer_id(), next_bitstream_buffer_id_); | 621 CHECK_LE(picture.bitstream_buffer_id(), next_bitstream_buffer_id_); |
| 651 ++num_decoded_frames_; | 622 ++num_decoded_frames_; |
| 652 | 623 |
| 653 // Mid-stream reset applies only to the last play-through per constructor | 624 // Mid-stream reset applies only to the last play-through per constructor |
| 654 // comment. | 625 // comment. |
| 655 if (remaining_play_throughs_ == 1 && | 626 if (remaining_play_throughs_ == 1 && |
| 656 reset_after_frame_num_ == num_decoded_frames()) { | 627 reset_after_frame_num_ == num_decoded_frames()) { |
| 657 reset_after_frame_num_ = MID_STREAM_RESET; | 628 reset_after_frame_num_ = MID_STREAM_RESET; |
| 658 decoder_->Reset(); | 629 decoder_->Reset(); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 695 } | 666 } |
| 696 | 667 |
| 697 void GLRenderingVDAClient::NotifyEndOfBitstreamBuffer( | 668 void GLRenderingVDAClient::NotifyEndOfBitstreamBuffer( |
| 698 int32 bitstream_buffer_id) { | 669 int32 bitstream_buffer_id) { |
| 699 // TODO(fischman): this test currently relies on this notification to make | 670 // TODO(fischman): this test currently relies on this notification to make |
| 700 // forward progress during a Reset(). But the VDA::Reset() API doesn't | 671 // forward progress during a Reset(). But the VDA::Reset() API doesn't |
| 701 // guarantee this, so stop relying on it (and remove the notifications from | 672 // guarantee this, so stop relying on it (and remove the notifications from |
| 702 // VaapiVideoDecodeAccelerator::FinishReset()). | 673 // VaapiVideoDecodeAccelerator::FinishReset()). |
| 703 ++num_done_bitstream_buffers_; | 674 ++num_done_bitstream_buffers_; |
| 704 --outstanding_decodes_; | 675 --outstanding_decodes_; |
| 705 DecodeNextFragment(); | 676 if (decode_calls_per_second_ == 0) |
| 677 DecodeNextFragment(); | |
| 706 } | 678 } |
| 707 | 679 |
| 708 void GLRenderingVDAClient::NotifyFlushDone() { | 680 void GLRenderingVDAClient::NotifyFlushDone() { |
| 709 if (decoder_deleted()) | 681 if (decoder_deleted()) |
| 710 return; | 682 return; |
| 711 SetState(CS_FLUSHED); | 683 SetState(CS_FLUSHED); |
| 712 --remaining_play_throughs_; | 684 --remaining_play_throughs_; |
| 713 DCHECK_GE(remaining_play_throughs_, 0); | 685 DCHECK_GE(remaining_play_throughs_, 0); |
| 714 if (decoder_deleted()) | 686 if (decoder_deleted()) |
| 715 return; | 687 return; |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 877 | 849 |
| 878 // Populate the shared memory buffer w/ the fragment, duplicate its handle, | 850 // Populate the shared memory buffer w/ the fragment, duplicate its handle, |
| 879 // and hand it off to the decoder. | 851 // and hand it off to the decoder. |
| 880 base::SharedMemory shm; | 852 base::SharedMemory shm; |
| 881 CHECK(shm.CreateAndMapAnonymous(next_fragment_size)); | 853 CHECK(shm.CreateAndMapAnonymous(next_fragment_size)); |
| 882 memcpy(shm.memory(), next_fragment_bytes.data(), next_fragment_size); | 854 memcpy(shm.memory(), next_fragment_bytes.data(), next_fragment_size); |
| 883 base::SharedMemoryHandle dup_handle; | 855 base::SharedMemoryHandle dup_handle; |
| 884 CHECK(shm.ShareToProcess(base::Process::Current().handle(), &dup_handle)); | 856 CHECK(shm.ShareToProcess(base::Process::Current().handle(), &dup_handle)); |
| 885 media::BitstreamBuffer bitstream_buffer( | 857 media::BitstreamBuffer bitstream_buffer( |
| 886 next_bitstream_buffer_id_, dup_handle, next_fragment_size); | 858 next_bitstream_buffer_id_, dup_handle, next_fragment_size); |
| 859 decode_start_time_[next_bitstream_buffer_id_] = base::TimeTicks::Now(); | |
| 887 // Mask against 30 bits, to avoid (undefined) wraparound on signed integer. | 860 // Mask against 30 bits, to avoid (undefined) wraparound on signed integer. |
| 888 next_bitstream_buffer_id_ = (next_bitstream_buffer_id_ + 1) & 0x3FFFFFFF; | 861 next_bitstream_buffer_id_ = (next_bitstream_buffer_id_ + 1) & 0x3FFFFFFF; |
| 889 decoder_->Decode(bitstream_buffer); | 862 decoder_->Decode(bitstream_buffer); |
| 890 ++outstanding_decodes_; | 863 ++outstanding_decodes_; |
| 891 encoded_data_next_pos_to_decode_ = end_pos; | 864 encoded_data_next_pos_to_decode_ = end_pos; |
| 892 | 865 |
| 893 if (!remaining_play_throughs_ && | 866 if (!remaining_play_throughs_ && |
| 894 -delete_decoder_state_ == next_bitstream_buffer_id_) { | 867 -delete_decoder_state_ == next_bitstream_buffer_id_) { |
| 895 DeleteDecoder(); | 868 DeleteDecoder(); |
| 896 } | 869 } |
| 870 | |
| 871 if (decode_calls_per_second_ > 0) { | |
| 872 base::MessageLoop::current()->PostDelayedTask( | |
| 873 FROM_HERE, | |
| 874 base::Bind(&GLRenderingVDAClient::DecodeNextFragment, AsWeakPtr()), | |
| 875 base::TimeDelta::FromSeconds(1) / decode_calls_per_second_); | |
| 876 } | |
| 897 } | 877 } |
| 898 | 878 |
| 899 int GLRenderingVDAClient::num_decoded_frames() { | 879 int GLRenderingVDAClient::num_decoded_frames() { |
| 900 return throttling_client_ ? throttling_client_->num_decoded_frames() | 880 return throttling_client_ ? throttling_client_->num_decoded_frames() |
| 901 : num_decoded_frames_; | 881 : num_decoded_frames_; |
| 902 } | 882 } |
| 903 | 883 |
| 904 double GLRenderingVDAClient::frames_per_second() { | 884 double GLRenderingVDAClient::frames_per_second() { |
| 905 base::TimeDelta delta = frame_delivery_times_.back() - initialize_done_ticks_; | 885 base::TimeDelta delta = frame_delivery_times_.back() - initialize_done_ticks_; |
| 906 if (delta.InSecondsF() == 0) | 886 if (delta.InSecondsF() == 0) |
| 907 return 0; | 887 return 0; |
| 908 return num_decoded_frames() / delta.InSecondsF(); | 888 return num_decoded_frames() / delta.InSecondsF(); |
| 909 } | 889 } |
| 910 | 890 |
| 891 int GLRenderingVDAClient::decode_time_median() { | |
| 892 if (decode_time_.size() == 0) | |
| 893 return 0; | |
| 894 std::sort(decode_time_.begin(), decode_time_.end()); | |
| 895 int index = decode_time_.size() / 2; | |
| 896 if (decode_time_.size() % 2 != 0) | |
| 897 return decode_time_[index].InMilliseconds(); | |
| 898 | |
| 899 return (decode_time_[index] + decode_time_[index - 1]).InMilliseconds() / 2; | |
| 900 } | |
| 901 | |
| 902 class VideoDecodeAcceleratorTest : public ::testing::Test { | |
| 903 protected: | |
| 904 VideoDecodeAcceleratorTest(); | |
| 905 virtual void SetUp(); | |
| 906 virtual void TearDown(); | |
| 907 | |
| 908 // Parse |data| into its constituent parts, set the various output fields | |
| 909 // accordingly, and read in video stream. CHECK-fails on unexpected or | |
| 910 // missing required data. Unspecified optional fields are set to -1. | |
| 911 void ParseAndReadTestVideoData(base::FilePath::StringType data, | |
| 912 std::vector<TestVideoFile*>* test_video_files); | |
| 913 | |
| 914 // Update the parameters of |test_video_files| according to | |
| 915 // |num_concurrent_decoders| and |reset_point|. Ex: the expected number of | |
| 916 // frames should be adjusted if decoder is reset in the middle of the stream. | |
| 917 void UpdateTestVideoFileParams( | |
| 918 const std::vector<TestVideoFile*>& test_video_files, | |
|
Ami GONE FROM CHROMIUM
2013/11/05 16:41:03
|test_video_files| is an output parameter, so it s
| |
| 919 size_t num_concurrent_decoders, | |
| 920 int reset_point); | |
| 921 | |
| 922 void InitializeRenderingHelper(const RenderingHelperParams& helper_params); | |
| 923 void CreateAndStartDecoder(GLRenderingVDAClient* client, | |
| 924 ClientStateNotification<ClientState>* note); | |
| 925 void WaitUntilDecodeFinish(ClientStateNotification<ClientState>* note); | |
| 926 void WaitUntilIdle(); | |
| 927 void OutputLogFile(const base::FilePath::CharType* log_path, | |
| 928 const std::string& content); | |
| 929 | |
| 930 std::vector<TestVideoFile*> test_video_files_; | |
| 931 RenderingHelper rendering_helper_; | |
| 932 scoped_refptr<base::MessageLoopProxy> rendering_loop_proxy_; | |
| 933 | |
| 934 private: | |
| 935 base::Thread rendering_thread_; | |
| 936 // Required for Thread to work. Not used otherwise. | |
| 937 base::ShadowingAtExitManager at_exit_manager_; | |
| 938 | |
| 939 DISALLOW_COPY_AND_ASSIGN(VideoDecodeAcceleratorTest); | |
| 940 }; | |
| 941 | |
| 942 VideoDecodeAcceleratorTest::VideoDecodeAcceleratorTest() | |
| 943 : rendering_thread_("GLRenderingVDAClientThread") {} | |
| 944 | |
| 945 void VideoDecodeAcceleratorTest::SetUp() { | |
| 946 ParseAndReadTestVideoData(g_test_video_data, &test_video_files_); | |
| 947 | |
| 948 // Initialize the rendering thread. | |
| 949 base::Thread::Options options; | |
| 950 options.message_loop_type = base::MessageLoop::TYPE_DEFAULT; | |
| 951 #if defined(OS_WIN) | |
| 952 // For windows the decoding thread initializes the media foundation decoder | |
| 953 // which uses COM. We need the thread to be a UI thread. | |
| 954 options.message_loop_type = base::MessageLoop::TYPE_UI; | |
| 955 #endif // OS_WIN | |
| 956 | |
| 957 rendering_thread_.StartWithOptions(options); | |
| 958 rendering_loop_proxy_ = rendering_thread_.message_loop_proxy(); | |
| 959 } | |
| 960 | |
| 961 void VideoDecodeAcceleratorTest::TearDown() { | |
| 962 rendering_loop_proxy_->PostTask( | |
| 963 FROM_HERE, | |
| 964 base::Bind(&STLDeleteElements<std::vector<TestVideoFile*> >, | |
| 965 &test_video_files_)); | |
| 966 | |
| 967 base::WaitableEvent done(false, false); | |
| 968 rendering_loop_proxy_->PostTask( | |
| 969 FROM_HERE, | |
| 970 base::Bind(&RenderingHelper::UnInitialize, | |
| 971 base::Unretained(&rendering_helper_), | |
| 972 &done)); | |
| 973 done.Wait(); | |
| 974 | |
| 975 rendering_thread_.Stop(); | |
| 976 } | |
| 977 | |
| 978 void VideoDecodeAcceleratorTest::ParseAndReadTestVideoData( | |
| 979 base::FilePath::StringType data, | |
| 980 std::vector<TestVideoFile*>* test_video_files) { | |
| 981 std::vector<base::FilePath::StringType> entries; | |
| 982 base::SplitString(data, ';', &entries); | |
| 983 CHECK_GE(entries.size(), 1U) << data; | |
| 984 for (size_t index = 0; index < entries.size(); ++index) { | |
| 985 std::vector<base::FilePath::StringType> fields; | |
| 986 base::SplitString(entries[index], ':', &fields); | |
| 987 CHECK_GE(fields.size(), 1U) << entries[index]; | |
| 988 CHECK_LE(fields.size(), 8U) << entries[index]; | |
| 989 TestVideoFile* video_file = new TestVideoFile(fields[0]); | |
| 990 if (!fields[1].empty()) | |
| 991 CHECK(base::StringToInt(fields[1], &video_file->width)); | |
| 992 if (!fields[2].empty()) | |
| 993 CHECK(base::StringToInt(fields[2], &video_file->height)); | |
| 994 if (!fields[3].empty()) | |
| 995 CHECK(base::StringToInt(fields[3], &video_file->num_frames)); | |
| 996 if (!fields[4].empty()) | |
| 997 CHECK(base::StringToInt(fields[4], &video_file->num_fragments)); | |
| 998 if (!fields[5].empty()) | |
| 999 CHECK(base::StringToInt(fields[5], &video_file->min_fps_render)); | |
| 1000 if (!fields[6].empty()) | |
| 1001 CHECK(base::StringToInt(fields[6], &video_file->min_fps_no_render)); | |
| 1002 if (!fields[7].empty()) | |
| 1003 CHECK(base::StringToInt(fields[7], &video_file->profile)); | |
| 1004 | |
| 1005 // Read in the video data. | |
| 1006 base::FilePath filepath(video_file->file_name); | |
| 1007 CHECK(base::ReadFileToString(filepath, &video_file->data_str)) | |
| 1008 << "test_video_file: " << filepath.MaybeAsASCII(); | |
| 1009 | |
| 1010 test_video_files->push_back(video_file); | |
| 1011 } | |
| 1012 } | |
| 1013 | |
| 1014 void VideoDecodeAcceleratorTest::UpdateTestVideoFileParams( | |
| 1015 const std::vector<TestVideoFile*>& test_video_files, | |
| 1016 size_t num_concurrent_decoders, | |
| 1017 int reset_point) { | |
| 1018 for (size_t i = 0; i < test_video_files.size(); i++) { | |
| 1019 TestVideoFile* video_file = test_video_files[i]; | |
| 1020 if (video_file->num_frames > 0 && reset_point == MID_STREAM_RESET) { | |
| 1021 // Reset should not go beyond the last frame; reset after the first | |
| 1022 // frame for short videos. | |
| 1023 video_file->reset_after_frame_num = kMaxResetAfterFrameNum; | |
| 1024 if (video_file->num_frames <= kMaxResetAfterFrameNum) | |
| 1025 video_file->reset_after_frame_num = 1; | |
| 1026 video_file->num_frames += video_file->reset_after_frame_num; | |
| 1027 } | |
| 1028 if (video_file->min_fps_render != -1) | |
| 1029 video_file->min_fps_render /= num_concurrent_decoders; | |
| 1030 if (video_file->min_fps_no_render != -1) | |
| 1031 video_file->min_fps_no_render /= num_concurrent_decoders; | |
| 1032 } | |
| 1033 } | |
| 1034 | |
| 1035 void VideoDecodeAcceleratorTest::InitializeRenderingHelper( | |
| 1036 const RenderingHelperParams& helper_params) { | |
| 1037 base::WaitableEvent done(false, false); | |
| 1038 rendering_loop_proxy_->PostTask( | |
| 1039 FROM_HERE, | |
| 1040 base::Bind(&RenderingHelper::Initialize, | |
| 1041 base::Unretained(&rendering_helper_), | |
| 1042 helper_params, | |
| 1043 &done)); | |
| 1044 done.Wait(); | |
| 1045 } | |
| 1046 | |
| 1047 void VideoDecodeAcceleratorTest::CreateAndStartDecoder( | |
| 1048 GLRenderingVDAClient* client, | |
| 1049 ClientStateNotification<ClientState>* note) { | |
| 1050 rendering_loop_proxy_->PostTask( | |
| 1051 FROM_HERE, | |
| 1052 base::Bind(&GLRenderingVDAClient::CreateAndStartDecoder, | |
| 1053 base::Unretained(client))); | |
| 1054 ASSERT_EQ(note->Wait(), CS_DECODER_SET); | |
| 1055 } | |
| 1056 | |
| 1057 void VideoDecodeAcceleratorTest::WaitUntilDecodeFinish( | |
| 1058 ClientStateNotification<ClientState>* note) { | |
| 1059 for (int i = 0; i < CS_MAX; i++) { | |
| 1060 if (note->Wait() == CS_DESTROYED) | |
| 1061 break; | |
| 1062 } | |
| 1063 } | |
| 1064 | |
| 1065 void VideoDecodeAcceleratorTest::WaitUntilIdle() { | |
| 1066 base::WaitableEvent done(false, false); | |
| 1067 rendering_loop_proxy_->PostTask( | |
| 1068 FROM_HERE, | |
| 1069 base::Bind(&base::WaitableEvent::Signal, base::Unretained(&done))); | |
| 1070 done.Wait(); | |
| 1071 } | |
| 1072 | |
| 1073 void VideoDecodeAcceleratorTest::OutputLogFile( | |
| 1074 const base::FilePath::CharType* log_path, | |
| 1075 const std::string& content) { | |
| 1076 base::PlatformFile file = base::CreatePlatformFile( | |
| 1077 base::FilePath(log_path), | |
| 1078 base::PLATFORM_FILE_CREATE_ALWAYS | base::PLATFORM_FILE_WRITE, | |
| 1079 NULL, | |
| 1080 NULL); | |
| 1081 base::WritePlatformFileAtCurrentPos(file, content.data(), content.length()); | |
| 1082 base::ClosePlatformFile(file); | |
| 1083 } | |
| 1084 | |
| 911 // Test parameters: | 1085 // Test parameters: |
| 912 // - Number of concurrent decoders. | 1086 // - Number of concurrent decoders. |
| 913 // - Number of concurrent in-flight Decode() calls per decoder. | 1087 // - Number of concurrent in-flight Decode() calls per decoder. |
| 914 // - Number of play-throughs. | 1088 // - Number of play-throughs. |
| 915 // - reset_after_frame_num: see GLRenderingVDAClient ctor. | 1089 // - reset_after_frame_num: see GLRenderingVDAClient ctor. |
| 916 // - delete_decoder_phase: see GLRenderingVDAClient ctor. | 1090 // - delete_decoder_phase: see GLRenderingVDAClient ctor. |
| 917 // - whether to test slow rendering by delaying ReusePictureBuffer(). | 1091 // - whether to test slow rendering by delaying ReusePictureBuffer(). |
| 918 // - whether the video frames are rendered as thumbnails. | 1092 // - whether the video frames are rendered as thumbnails. |
| 919 class VideoDecodeAcceleratorTest | 1093 class VideoDecodeAcceleratorParamTest |
| 920 : public ::testing::TestWithParam< | 1094 : public VideoDecodeAcceleratorTest, |
| 921 Tuple7<int, int, int, ResetPoint, ClientState, bool, bool> > { | 1095 public ::testing::WithParamInterface< |
| 1096 Tuple7<int, int, int, ResetPoint, ClientState, bool, bool> > { | |
| 922 }; | 1097 }; |
| 923 | 1098 |
| 924 // Helper so that gtest failures emit a more readable version of the tuple than | 1099 // Helper so that gtest failures emit a more readable version of the tuple than |
| 925 // its byte representation. | 1100 // its byte representation. |
| 926 ::std::ostream& operator<<( | 1101 ::std::ostream& operator<<( |
| 927 ::std::ostream& os, | 1102 ::std::ostream& os, |
| 928 const Tuple7<int, int, int, ResetPoint, ClientState, bool, bool>& t) { | 1103 const Tuple7<int, int, int, ResetPoint, ClientState, bool, bool>& t) { |
| 929 return os << t.a << ", " << t.b << ", " << t.c << ", " << t.d << ", " << t.e | 1104 return os << t.a << ", " << t.b << ", " << t.c << ", " << t.d << ", " << t.e |
| 930 << ", " << t.f << ", " << t.g; | 1105 << ", " << t.f << ", " << t.g; |
| 931 } | 1106 } |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 943 << ", instead of " << expected_state; | 1118 << ", instead of " << expected_state; |
| 944 } | 1119 } |
| 945 | 1120 |
| 946 // We assert a minimal number of concurrent decoders we expect to succeed. | 1121 // We assert a minimal number of concurrent decoders we expect to succeed. |
| 947 // Different platforms can support more concurrent decoders, so we don't assert | 1122 // Different platforms can support more concurrent decoders, so we don't assert |
| 948 // failure above this. | 1123 // failure above this. |
| 949 enum { kMinSupportedNumConcurrentDecoders = 3 }; | 1124 enum { kMinSupportedNumConcurrentDecoders = 3 }; |
| 950 | 1125 |
| 951 // Test the most straightforward case possible: data is decoded from a single | 1126 // Test the most straightforward case possible: data is decoded from a single |
| 952 // chunk and rendered to the screen. | 1127 // chunk and rendered to the screen. |
| 953 TEST_P(VideoDecodeAcceleratorTest, TestSimpleDecode) { | 1128 TEST_P(VideoDecodeAcceleratorParamTest, TestSimpleDecode) { |
| 954 // Required for Thread to work. Not used otherwise. | |
| 955 base::ShadowingAtExitManager at_exit_manager; | |
| 956 | |
| 957 const size_t num_concurrent_decoders = GetParam().a; | 1129 const size_t num_concurrent_decoders = GetParam().a; |
| 958 const size_t num_in_flight_decodes = GetParam().b; | 1130 const size_t num_in_flight_decodes = GetParam().b; |
| 959 const int num_play_throughs = GetParam().c; | 1131 const int num_play_throughs = GetParam().c; |
| 960 const int reset_point = GetParam().d; | 1132 const int reset_point = GetParam().d; |
| 961 const int delete_decoder_state = GetParam().e; | 1133 const int delete_decoder_state = GetParam().e; |
| 962 bool test_reuse_delay = GetParam().f; | 1134 bool test_reuse_delay = GetParam().f; |
| 963 const bool render_as_thumbnails = GetParam().g; | 1135 const bool render_as_thumbnails = GetParam().g; |
| 964 | 1136 |
| 965 std::vector<TestVideoFile*> test_video_files; | 1137 UpdateTestVideoFileParams( |
| 966 ParseAndReadTestVideoData(g_test_video_data, | 1138 test_video_files_, num_concurrent_decoders, reset_point); |
| 967 num_concurrent_decoders, | |
| 968 reset_point, | |
| 969 &test_video_files); | |
| 970 | 1139 |
| 971 // Suppress GL rendering for all tests when the "--disable_rendering" is set. | 1140 // Suppress GL rendering for all tests when the "--disable_rendering" is set. |
| 972 const bool suppress_rendering = g_disable_rendering; | 1141 const bool suppress_rendering = g_disable_rendering; |
| 973 | 1142 |
| 974 std::vector<ClientStateNotification<ClientState>*> | 1143 std::vector<ClientStateNotification<ClientState>*> |
| 975 notes(num_concurrent_decoders, NULL); | 1144 notes(num_concurrent_decoders, NULL); |
| 976 std::vector<GLRenderingVDAClient*> clients(num_concurrent_decoders, NULL); | 1145 std::vector<GLRenderingVDAClient*> clients(num_concurrent_decoders, NULL); |
| 977 | 1146 |
| 978 // Initialize the rendering helper. | |
| 979 base::Thread rendering_thread("GLRenderingVDAClientThread"); | |
| 980 base::Thread::Options options; | |
| 981 options.message_loop_type = base::MessageLoop::TYPE_DEFAULT; | |
| 982 #if defined(OS_WIN) | |
| 983 // For windows the decoding thread initializes the media foundation decoder | |
| 984 // which uses COM. We need the thread to be a UI thread. | |
| 985 options.message_loop_type = base::MessageLoop::TYPE_UI; | |
| 986 #endif // OS_WIN | |
| 987 | |
| 988 rendering_thread.StartWithOptions(options); | |
| 989 RenderingHelper rendering_helper; | |
| 990 | |
| 991 base::WaitableEvent done(false, false); | |
| 992 RenderingHelperParams helper_params; | 1147 RenderingHelperParams helper_params; |
| 993 helper_params.num_windows = num_concurrent_decoders; | 1148 helper_params.num_windows = num_concurrent_decoders; |
| 994 helper_params.render_as_thumbnails = render_as_thumbnails; | 1149 helper_params.render_as_thumbnails = render_as_thumbnails; |
| 995 if (render_as_thumbnails) { | 1150 if (render_as_thumbnails) { |
| 996 // Only one decoder is supported with thumbnail rendering | 1151 // Only one decoder is supported with thumbnail rendering |
| 997 CHECK_EQ(num_concurrent_decoders, 1U); | 1152 CHECK_EQ(num_concurrent_decoders, 1U); |
| 998 gfx::Size frame_size(test_video_files[0]->width, | 1153 gfx::Size frame_size(test_video_files_[0]->width, |
| 999 test_video_files[0]->height); | 1154 test_video_files_[0]->height); |
| 1000 helper_params.frame_dimensions.push_back(frame_size); | 1155 helper_params.frame_dimensions.push_back(frame_size); |
| 1001 helper_params.window_dimensions.push_back(kThumbnailsDisplaySize); | 1156 helper_params.window_dimensions.push_back(kThumbnailsDisplaySize); |
| 1002 helper_params.thumbnails_page_size = kThumbnailsPageSize; | 1157 helper_params.thumbnails_page_size = kThumbnailsPageSize; |
| 1003 helper_params.thumbnail_size = kThumbnailSize; | 1158 helper_params.thumbnail_size = kThumbnailSize; |
| 1004 } else { | 1159 } else { |
| 1005 for (size_t index = 0; index < test_video_files.size(); ++index) { | 1160 for (size_t index = 0; index < test_video_files_.size(); ++index) { |
| 1006 gfx::Size frame_size(test_video_files[index]->width, | 1161 gfx::Size frame_size(test_video_files_[index]->width, |
| 1007 test_video_files[index]->height); | 1162 test_video_files_[index]->height); |
| 1008 helper_params.frame_dimensions.push_back(frame_size); | 1163 helper_params.frame_dimensions.push_back(frame_size); |
| 1009 helper_params.window_dimensions.push_back(frame_size); | 1164 helper_params.window_dimensions.push_back(frame_size); |
| 1010 } | 1165 } |
| 1011 } | 1166 } |
| 1012 rendering_thread.message_loop()->PostTask( | 1167 InitializeRenderingHelper(helper_params); |
| 1013 FROM_HERE, | |
| 1014 base::Bind(&RenderingHelper::Initialize, | |
| 1015 base::Unretained(&rendering_helper), | |
| 1016 helper_params, | |
| 1017 &done)); | |
| 1018 done.Wait(); | |
| 1019 | 1168 |
| 1020 // First kick off all the decoders. | 1169 // First kick off all the decoders. |
| 1021 for (size_t index = 0; index < num_concurrent_decoders; ++index) { | 1170 for (size_t index = 0; index < num_concurrent_decoders; ++index) { |
| 1022 TestVideoFile* video_file = | 1171 TestVideoFile* video_file = |
| 1023 test_video_files[index % test_video_files.size()]; | 1172 test_video_files_[index % test_video_files_.size()]; |
| 1024 ClientStateNotification<ClientState>* note = | 1173 ClientStateNotification<ClientState>* note = |
| 1025 new ClientStateNotification<ClientState>(); | 1174 new ClientStateNotification<ClientState>(); |
| 1026 notes[index] = note; | 1175 notes[index] = note; |
| 1027 | 1176 |
| 1028 int delay_after_frame_num = std::numeric_limits<int>::max(); | 1177 int delay_after_frame_num = std::numeric_limits<int>::max(); |
| 1029 if (test_reuse_delay && | 1178 if (test_reuse_delay && |
| 1030 kMaxFramesToDelayReuse * 2 < video_file->num_frames) { | 1179 kMaxFramesToDelayReuse * 2 < video_file->num_frames) { |
| 1031 delay_after_frame_num = video_file->num_frames - kMaxFramesToDelayReuse; | 1180 delay_after_frame_num = video_file->num_frames - kMaxFramesToDelayReuse; |
| 1032 } | 1181 } |
| 1033 | 1182 |
| 1034 GLRenderingVDAClient* client = | 1183 GLRenderingVDAClient* client = |
| 1035 new GLRenderingVDAClient(&rendering_helper, | 1184 new GLRenderingVDAClient(&rendering_helper_, |
| 1036 index, | 1185 index, |
| 1037 note, | 1186 note, |
| 1038 video_file->data_str, | 1187 video_file->data_str, |
| 1039 num_in_flight_decodes, | 1188 num_in_flight_decodes, |
| 1040 num_play_throughs, | 1189 num_play_throughs, |
| 1041 video_file->reset_after_frame_num, | 1190 video_file->reset_after_frame_num, |
| 1042 delete_decoder_state, | 1191 delete_decoder_state, |
| 1043 video_file->width, | 1192 video_file->width, |
| 1044 video_file->height, | 1193 video_file->height, |
| 1045 video_file->profile, | 1194 video_file->profile, |
| 1046 g_rendering_fps, | 1195 g_rendering_fps, |
| 1047 suppress_rendering, | 1196 suppress_rendering, |
| 1048 delay_after_frame_num); | 1197 delay_after_frame_num, |
| 1198 0); | |
| 1049 clients[index] = client; | 1199 clients[index] = client; |
| 1050 | 1200 |
| 1051 rendering_thread.message_loop()->PostTask( | 1201 CreateAndStartDecoder(client, note); |
| 1052 FROM_HERE, | |
| 1053 base::Bind(&GLRenderingVDAClient::CreateDecoder, | |
| 1054 base::Unretained(client))); | |
| 1055 | |
| 1056 ASSERT_EQ(note->Wait(), CS_DECODER_SET); | |
| 1057 } | 1202 } |
| 1058 // Then wait for all the decodes to finish. | 1203 // Then wait for all the decodes to finish. |
| 1059 // Only check performance & correctness later if we play through only once. | 1204 // Only check performance & correctness later if we play through only once. |
| 1060 bool skip_performance_and_correctness_checks = num_play_throughs > 1; | 1205 bool skip_performance_and_correctness_checks = num_play_throughs > 1; |
| 1061 for (size_t i = 0; i < num_concurrent_decoders; ++i) { | 1206 for (size_t i = 0; i < num_concurrent_decoders; ++i) { |
| 1062 ClientStateNotification<ClientState>* note = notes[i]; | 1207 ClientStateNotification<ClientState>* note = notes[i]; |
| 1063 ClientState state = note->Wait(); | 1208 ClientState state = note->Wait(); |
| 1064 if (state != CS_INITIALIZED) { | 1209 if (state != CS_INITIALIZED) { |
| 1065 skip_performance_and_correctness_checks = true; | 1210 skip_performance_and_correctness_checks = true; |
| 1066 // We expect initialization to fail only when more than the supported | 1211 // We expect initialization to fail only when more than the supported |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 1095 AssertWaitForStateOrDeleted(note, clients[i], CS_DESTROYED)); | 1240 AssertWaitForStateOrDeleted(note, clients[i], CS_DESTROYED)); |
| 1096 } | 1241 } |
| 1097 // Finally assert that decoding went as expected. | 1242 // Finally assert that decoding went as expected. |
| 1098 for (size_t i = 0; i < num_concurrent_decoders && | 1243 for (size_t i = 0; i < num_concurrent_decoders && |
| 1099 !skip_performance_and_correctness_checks; ++i) { | 1244 !skip_performance_and_correctness_checks; ++i) { |
| 1100 // We can only make performance/correctness assertions if the decoder was | 1245 // We can only make performance/correctness assertions if the decoder was |
| 1101 // allowed to finish. | 1246 // allowed to finish. |
| 1102 if (delete_decoder_state < CS_FLUSHED) | 1247 if (delete_decoder_state < CS_FLUSHED) |
| 1103 continue; | 1248 continue; |
| 1104 GLRenderingVDAClient* client = clients[i]; | 1249 GLRenderingVDAClient* client = clients[i]; |
| 1105 TestVideoFile* video_file = test_video_files[i % test_video_files.size()]; | 1250 TestVideoFile* video_file = test_video_files_[i % test_video_files_.size()]; |
| 1106 if (video_file->num_frames > 0) { | 1251 if (video_file->num_frames > 0) { |
| 1107 // Expect the decoded frames may be more than the video frames as frames | 1252 // Expect the decoded frames may be more than the video frames as frames |
| 1108 // could still be returned until resetting done. | 1253 // could still be returned until resetting done. |
| 1109 if (video_file->reset_after_frame_num > 0) | 1254 if (video_file->reset_after_frame_num > 0) |
| 1110 EXPECT_GE(client->num_decoded_frames(), video_file->num_frames); | 1255 EXPECT_GE(client->num_decoded_frames(), video_file->num_frames); |
| 1111 else | 1256 else |
| 1112 EXPECT_EQ(client->num_decoded_frames(), video_file->num_frames); | 1257 EXPECT_EQ(client->num_decoded_frames(), video_file->num_frames); |
| 1113 } | 1258 } |
| 1114 if (reset_point == END_OF_STREAM_RESET) { | 1259 if (reset_point == END_OF_STREAM_RESET) { |
| 1115 EXPECT_EQ(video_file->num_fragments, client->num_skipped_fragments() + | 1260 EXPECT_EQ(video_file->num_fragments, client->num_skipped_fragments() + |
| 1116 client->num_queued_fragments()); | 1261 client->num_queued_fragments()); |
| 1117 EXPECT_EQ(client->num_done_bitstream_buffers(), | 1262 EXPECT_EQ(client->num_done_bitstream_buffers(), |
| 1118 client->num_queued_fragments()); | 1263 client->num_queued_fragments()); |
| 1119 } | 1264 } |
| 1120 LOG(INFO) << "Decoder " << i << " fps: " << client->frames_per_second(); | 1265 LOG(INFO) << "Decoder " << i << " fps: " << client->frames_per_second(); |
| 1121 if (!render_as_thumbnails) { | 1266 if (!render_as_thumbnails) { |
| 1122 int min_fps = suppress_rendering ? | 1267 int min_fps = suppress_rendering ? |
| 1123 video_file->min_fps_no_render : video_file->min_fps_render; | 1268 video_file->min_fps_no_render : video_file->min_fps_render; |
| 1124 if (min_fps > 0 && !test_reuse_delay) | 1269 if (min_fps > 0 && !test_reuse_delay) |
| 1125 EXPECT_GT(client->frames_per_second(), min_fps); | 1270 EXPECT_GT(client->frames_per_second(), min_fps); |
| 1126 } | 1271 } |
| 1127 } | 1272 } |
| 1128 | 1273 |
| 1129 if (render_as_thumbnails) { | 1274 if (render_as_thumbnails) { |
| 1130 std::vector<unsigned char> rgb; | 1275 std::vector<unsigned char> rgb; |
| 1131 bool alpha_solid; | 1276 bool alpha_solid; |
| 1132 rendering_thread.message_loop()->PostTask( | 1277 base::WaitableEvent done(false, false); |
| 1278 rendering_loop_proxy_->PostTask( | |
| 1133 FROM_HERE, | 1279 FROM_HERE, |
| 1134 base::Bind(&RenderingHelper::GetThumbnailsAsRGB, | 1280 base::Bind(&RenderingHelper::GetThumbnailsAsRGB, |
| 1135 base::Unretained(&rendering_helper), | 1281 base::Unretained(&rendering_helper_), |
| 1136 &rgb, &alpha_solid, &done)); | 1282 &rgb, &alpha_solid, &done)); |
| 1137 done.Wait(); | 1283 done.Wait(); |
| 1138 | 1284 |
| 1139 std::vector<std::string> golden_md5s; | 1285 std::vector<std::string> golden_md5s; |
| 1140 std::string md5_string = base::MD5String( | 1286 std::string md5_string = base::MD5String( |
| 1141 base::StringPiece(reinterpret_cast<char*>(&rgb[0]), rgb.size())); | 1287 base::StringPiece(reinterpret_cast<char*>(&rgb[0]), rgb.size())); |
| 1142 ReadGoldenThumbnailMD5s(test_video_files[0], &golden_md5s); | 1288 ReadGoldenThumbnailMD5s(test_video_files_[0], &golden_md5s); |
| 1143 std::vector<std::string>::iterator match = | 1289 std::vector<std::string>::iterator match = |
| 1144 find(golden_md5s.begin(), golden_md5s.end(), md5_string); | 1290 find(golden_md5s.begin(), golden_md5s.end(), md5_string); |
| 1145 if (match == golden_md5s.end()) { | 1291 if (match == golden_md5s.end()) { |
| 1146 // Convert raw RGB into PNG for export. | 1292 // Convert raw RGB into PNG for export. |
| 1147 std::vector<unsigned char> png; | 1293 std::vector<unsigned char> png; |
| 1148 gfx::PNGCodec::Encode(&rgb[0], | 1294 gfx::PNGCodec::Encode(&rgb[0], |
| 1149 gfx::PNGCodec::FORMAT_RGB, | 1295 gfx::PNGCodec::FORMAT_RGB, |
| 1150 kThumbnailsPageSize, | 1296 kThumbnailsPageSize, |
| 1151 kThumbnailsPageSize.width() * 3, | 1297 kThumbnailsPageSize.width() * 3, |
| 1152 true, | 1298 true, |
| 1153 std::vector<gfx::PNGCodec::Comment>(), | 1299 std::vector<gfx::PNGCodec::Comment>(), |
| 1154 &png); | 1300 &png); |
| 1155 | 1301 |
| 1156 LOG(ERROR) << "Unknown thumbnails MD5: " << md5_string; | 1302 LOG(ERROR) << "Unknown thumbnails MD5: " << md5_string; |
| 1157 | 1303 |
| 1158 base::FilePath filepath(test_video_files[0]->file_name); | 1304 base::FilePath filepath(test_video_files_[0]->file_name); |
| 1159 filepath = filepath.AddExtension(FILE_PATH_LITERAL(".bad_thumbnails")); | 1305 filepath = filepath.AddExtension(FILE_PATH_LITERAL(".bad_thumbnails")); |
| 1160 filepath = filepath.AddExtension(FILE_PATH_LITERAL(".png")); | 1306 filepath = filepath.AddExtension(FILE_PATH_LITERAL(".png")); |
| 1161 int num_bytes = file_util::WriteFile(filepath, | 1307 int num_bytes = file_util::WriteFile(filepath, |
| 1162 reinterpret_cast<char*>(&png[0]), | 1308 reinterpret_cast<char*>(&png[0]), |
| 1163 png.size()); | 1309 png.size()); |
| 1164 ASSERT_EQ(num_bytes, static_cast<int>(png.size())); | 1310 ASSERT_EQ(num_bytes, static_cast<int>(png.size())); |
| 1165 } | 1311 } |
| 1166 ASSERT_NE(match, golden_md5s.end()); | 1312 ASSERT_NE(match, golden_md5s.end()); |
| 1167 EXPECT_EQ(alpha_solid, true) << "RGBA frame had incorrect alpha"; | 1313 EXPECT_EQ(alpha_solid, true) << "RGBA frame had incorrect alpha"; |
| 1168 } | 1314 } |
| 1169 | 1315 |
| 1170 // Output the frame delivery time to file | 1316 // Output the frame delivery time to file |
| 1171 // We can only make performance/correctness assertions if the decoder was | 1317 // We can only make performance/correctness assertions if the decoder was |
| 1172 // allowed to finish. | 1318 // allowed to finish. |
| 1173 if (g_frame_delivery_log != NULL && delete_decoder_state >= CS_FLUSHED) { | 1319 if (g_output_log != NULL && delete_decoder_state >= CS_FLUSHED) { |
| 1174 base::PlatformFile output_file = base::CreatePlatformFile( | 1320 base::PlatformFile output_file = base::CreatePlatformFile( |
| 1175 base::FilePath(g_frame_delivery_log), | 1321 base::FilePath(g_output_log), |
| 1176 base::PLATFORM_FILE_CREATE_ALWAYS | base::PLATFORM_FILE_WRITE, | 1322 base::PLATFORM_FILE_CREATE_ALWAYS | base::PLATFORM_FILE_WRITE, |
| 1177 NULL, | 1323 NULL, |
| 1178 NULL); | 1324 NULL); |
| 1179 for (size_t i = 0; i < num_concurrent_decoders; ++i) { | 1325 for (size_t i = 0; i < num_concurrent_decoders; ++i) { |
| 1180 clients[i]->OutputFrameDeliveryTimes(output_file); | 1326 clients[i]->OutputFrameDeliveryTimes(output_file); |
| 1181 } | 1327 } |
| 1182 base::ClosePlatformFile(output_file); | 1328 base::ClosePlatformFile(output_file); |
| 1183 } | 1329 } |
| 1184 | 1330 |
| 1185 rendering_thread.message_loop()->PostTask( | 1331 rendering_loop_proxy_->PostTask( |
| 1186 FROM_HERE, | 1332 FROM_HERE, |
| 1187 base::Bind(&STLDeleteElements<std::vector<GLRenderingVDAClient*> >, | 1333 base::Bind(&STLDeleteElements<std::vector<GLRenderingVDAClient*> >, |
| 1188 &clients)); | 1334 &clients)); |
| 1189 rendering_thread.message_loop()->PostTask( | 1335 rendering_loop_proxy_->PostTask( |
| 1190 FROM_HERE, | 1336 FROM_HERE, |
| 1191 base::Bind(&STLDeleteElements< | 1337 base::Bind(&STLDeleteElements< |
| 1192 std::vector<ClientStateNotification<ClientState>*> >, | 1338 std::vector<ClientStateNotification<ClientState>*> >, |
| 1193 ¬es)); | 1339 ¬es)); |
| 1194 rendering_thread.message_loop()->PostTask( | 1340 WaitUntilIdle(); |
| 1195 FROM_HERE, | |
| 1196 base::Bind(&STLDeleteElements<std::vector<TestVideoFile*> >, | |
| 1197 &test_video_files)); | |
| 1198 rendering_thread.message_loop()->PostTask( | |
| 1199 FROM_HERE, | |
| 1200 base::Bind(&RenderingHelper::UnInitialize, | |
| 1201 base::Unretained(&rendering_helper), | |
| 1202 &done)); | |
| 1203 done.Wait(); | |
| 1204 rendering_thread.Stop(); | |
| 1205 }; | 1341 }; |
| 1206 | 1342 |
| 1207 // Test that replay after EOS works fine. | 1343 // Test that replay after EOS works fine. |
| 1208 INSTANTIATE_TEST_CASE_P( | 1344 INSTANTIATE_TEST_CASE_P( |
| 1209 ReplayAfterEOS, VideoDecodeAcceleratorTest, | 1345 ReplayAfterEOS, VideoDecodeAcceleratorParamTest, |
| 1210 ::testing::Values( | 1346 ::testing::Values( |
| 1211 MakeTuple(1, 1, 4, END_OF_STREAM_RESET, CS_RESET, false, false))); | 1347 MakeTuple(1, 1, 4, END_OF_STREAM_RESET, CS_RESET, false, false))); |
| 1212 | 1348 |
| 1213 // This hangs on Exynos, preventing further testing and wasting test machine | 1349 // This hangs on Exynos, preventing further testing and wasting test machine |
| 1214 // time. | 1350 // time. |
| 1215 // TODO(ihf): Enable again once http://crbug.com/269754 is fixed. | 1351 // TODO(ihf): Enable again once http://crbug.com/269754 is fixed. |
| 1216 #if defined(ARCH_CPU_X86_FAMILY) | 1352 #if defined(ARCH_CPU_X86_FAMILY) |
| 1217 // Test that Reset() before the first Decode() works fine. | 1353 // Test that Reset() before the first Decode() works fine. |
| 1218 INSTANTIATE_TEST_CASE_P( | 1354 INSTANTIATE_TEST_CASE_P( |
| 1219 ResetBeforeDecode, VideoDecodeAcceleratorTest, | 1355 ResetBeforeDecode, VideoDecodeAcceleratorParamTest, |
| 1220 ::testing::Values( | 1356 ::testing::Values( |
| 1221 MakeTuple(1, 1, 1, START_OF_STREAM_RESET, CS_RESET, false, false))); | 1357 MakeTuple(1, 1, 1, START_OF_STREAM_RESET, CS_RESET, false, false))); |
| 1222 #endif // ARCH_CPU_X86_FAMILY | 1358 #endif // ARCH_CPU_X86_FAMILY |
| 1223 | 1359 |
| 1224 // Test that Reset() mid-stream works fine and doesn't affect decoding even when | 1360 // Test that Reset() mid-stream works fine and doesn't affect decoding even when |
| 1225 // Decode() calls are made during the reset. | 1361 // Decode() calls are made during the reset. |
| 1226 INSTANTIATE_TEST_CASE_P( | 1362 INSTANTIATE_TEST_CASE_P( |
| 1227 MidStreamReset, VideoDecodeAcceleratorTest, | 1363 MidStreamReset, VideoDecodeAcceleratorParamTest, |
| 1228 ::testing::Values( | 1364 ::testing::Values( |
| 1229 MakeTuple(1, 1, 1, MID_STREAM_RESET, CS_RESET, false, false))); | 1365 MakeTuple(1, 1, 1, MID_STREAM_RESET, CS_RESET, false, false))); |
| 1230 | 1366 |
| 1231 INSTANTIATE_TEST_CASE_P( | 1367 INSTANTIATE_TEST_CASE_P( |
| 1232 SlowRendering, VideoDecodeAcceleratorTest, | 1368 SlowRendering, VideoDecodeAcceleratorParamTest, |
| 1233 ::testing::Values( | 1369 ::testing::Values( |
| 1234 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_RESET, true, false))); | 1370 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_RESET, true, false))); |
| 1235 | 1371 |
| 1236 // Test that Destroy() mid-stream works fine (primarily this is testing that no | 1372 // Test that Destroy() mid-stream works fine (primarily this is testing that no |
| 1237 // crashes occur). | 1373 // crashes occur). |
| 1238 INSTANTIATE_TEST_CASE_P( | 1374 INSTANTIATE_TEST_CASE_P( |
| 1239 TearDownTiming, VideoDecodeAcceleratorTest, | 1375 TearDownTiming, VideoDecodeAcceleratorParamTest, |
| 1240 ::testing::Values( | 1376 ::testing::Values( |
| 1241 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_DECODER_SET, false, false), | 1377 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_DECODER_SET, false, false), |
| 1242 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_INITIALIZED, false, false), | 1378 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_INITIALIZED, false, false), |
| 1243 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_FLUSHING, false, false), | 1379 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_FLUSHING, false, false), |
| 1244 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_FLUSHED, false, false), | 1380 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_FLUSHED, false, false), |
| 1245 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_RESETTING, false, false), | 1381 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_RESETTING, false, false), |
| 1246 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_RESET, false, false), | 1382 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_RESET, false, false), |
| 1247 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, | 1383 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, |
| 1248 static_cast<ClientState>(-1), false, false), | 1384 static_cast<ClientState>(-1), false, false), |
| 1249 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, | 1385 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, |
| 1250 static_cast<ClientState>(-10), false, false), | 1386 static_cast<ClientState>(-10), false, false), |
| 1251 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, | 1387 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, |
| 1252 static_cast<ClientState>(-100), false, false))); | 1388 static_cast<ClientState>(-100), false, false))); |
| 1253 | 1389 |
| 1254 // Test that decoding various variation works with multiple in-flight decodes. | 1390 // Test that decoding various variation works with multiple in-flight decodes. |
| 1255 INSTANTIATE_TEST_CASE_P( | 1391 INSTANTIATE_TEST_CASE_P( |
| 1256 DecodeVariations, VideoDecodeAcceleratorTest, | 1392 DecodeVariations, VideoDecodeAcceleratorParamTest, |
| 1257 ::testing::Values( | 1393 ::testing::Values( |
| 1258 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_RESET, false, false), | 1394 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_RESET, false, false), |
| 1259 MakeTuple(1, 10, 1, END_OF_STREAM_RESET, CS_RESET, false, false), | 1395 MakeTuple(1, 10, 1, END_OF_STREAM_RESET, CS_RESET, false, false), |
| 1260 // Tests queuing. | 1396 // Tests queuing. |
| 1261 MakeTuple(1, 15, 1, END_OF_STREAM_RESET, CS_RESET, false, false))); | 1397 MakeTuple(1, 15, 1, END_OF_STREAM_RESET, CS_RESET, false, false))); |
| 1262 | 1398 |
| 1263 // Find out how many concurrent decoders can go before we exhaust system | 1399 // Find out how many concurrent decoders can go before we exhaust system |
| 1264 // resources. | 1400 // resources. |
| 1265 INSTANTIATE_TEST_CASE_P( | 1401 INSTANTIATE_TEST_CASE_P( |
| 1266 ResourceExhaustion, VideoDecodeAcceleratorTest, | 1402 ResourceExhaustion, VideoDecodeAcceleratorParamTest, |
| 1267 ::testing::Values( | 1403 ::testing::Values( |
| 1268 // +0 hack below to promote enum to int. | 1404 // +0 hack below to promote enum to int. |
| 1269 MakeTuple(kMinSupportedNumConcurrentDecoders + 0, 1, 1, | 1405 MakeTuple(kMinSupportedNumConcurrentDecoders + 0, 1, 1, |
| 1270 END_OF_STREAM_RESET, CS_RESET, false, false), | 1406 END_OF_STREAM_RESET, CS_RESET, false, false), |
| 1271 MakeTuple(kMinSupportedNumConcurrentDecoders + 1, 1, 1, | 1407 MakeTuple(kMinSupportedNumConcurrentDecoders + 1, 1, 1, |
| 1272 END_OF_STREAM_RESET, CS_RESET, false, false))); | 1408 END_OF_STREAM_RESET, CS_RESET, false, false))); |
| 1273 | 1409 |
| 1274 // Thumbnailing test | 1410 // Thumbnailing test |
| 1275 INSTANTIATE_TEST_CASE_P( | 1411 INSTANTIATE_TEST_CASE_P( |
| 1276 Thumbnail, VideoDecodeAcceleratorTest, | 1412 Thumbnail, VideoDecodeAcceleratorParamTest, |
| 1277 ::testing::Values( | 1413 ::testing::Values( |
| 1278 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_RESET, false, true))); | 1414 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_RESET, false, true))); |
| 1279 | 1415 |
| 1416 // Measure the median of the decode time when VDA::Decode is called 30 times per | |
| 1417 // second. | |
| 1418 TEST_F(VideoDecodeAcceleratorTest, TestDecodeTimeMedian) { | |
| 1419 RenderingHelperParams helper_params; | |
| 1420 helper_params.num_windows = 1; | |
| 1421 helper_params.render_as_thumbnails = false; | |
| 1422 gfx::Size frame_size(test_video_files_[0]->width, | |
| 1423 test_video_files_[0]->height); | |
| 1424 helper_params.frame_dimensions.push_back(frame_size); | |
| 1425 helper_params.window_dimensions.push_back(frame_size); | |
| 1426 InitializeRenderingHelper(helper_params); | |
| 1427 | |
| 1428 ClientStateNotification<ClientState>* note = | |
| 1429 new ClientStateNotification<ClientState>(); | |
| 1430 GLRenderingVDAClient* client = | |
| 1431 new GLRenderingVDAClient(&rendering_helper_, | |
| 1432 0, | |
| 1433 note, | |
| 1434 test_video_files_[0]->data_str, | |
| 1435 1, | |
| 1436 1, | |
| 1437 test_video_files_[0]->reset_after_frame_num, | |
| 1438 CS_RESET, | |
| 1439 test_video_files_[0]->width, | |
| 1440 test_video_files_[0]->height, | |
| 1441 test_video_files_[0]->profile, | |
| 1442 g_rendering_fps, | |
| 1443 true, | |
| 1444 std::numeric_limits<int>::max(), | |
| 1445 kWebRtcDecodeCallsPerSecond); | |
| 1446 CreateAndStartDecoder(client, note); | |
| 1447 WaitUntilDecodeFinish(note); | |
| 1448 | |
| 1449 int decode_time_median = client->decode_time_median(); | |
| 1450 std::string output_string = | |
| 1451 base::StringPrintf("Decode time median: %d ms", decode_time_median); | |
| 1452 LOG(INFO) << output_string; | |
| 1453 ASSERT_GT(decode_time_median, 0); | |
| 1454 | |
| 1455 if (g_output_log != NULL) | |
| 1456 OutputLogFile(g_output_log, output_string); | |
| 1457 | |
| 1458 rendering_loop_proxy_->DeleteSoon(FROM_HERE, client); | |
| 1459 rendering_loop_proxy_->DeleteSoon(FROM_HERE, note); | |
| 1460 WaitUntilIdle(); | |
| 1461 }; | |
| 1462 | |
| 1280 // TODO(fischman, vrk): add more tests! In particular: | 1463 // TODO(fischman, vrk): add more tests! In particular: |
| 1281 // - Test life-cycle: Seek/Stop/Pause/Play for a single decoder. | 1464 // - Test life-cycle: Seek/Stop/Pause/Play for a single decoder. |
| 1282 // - Test alternate configurations | 1465 // - Test alternate configurations |
| 1283 // - Test failure conditions. | 1466 // - Test failure conditions. |
| 1284 // - Test frame size changes mid-stream | 1467 // - Test frame size changes mid-stream |
| 1285 | 1468 |
| 1286 } // namespace | 1469 } // namespace |
| 1287 } // namespace content | 1470 } // namespace content |
| 1288 | 1471 |
| 1289 int main(int argc, char **argv) { | 1472 int main(int argc, char **argv) { |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 1300 CommandLine* cmd_line = CommandLine::ForCurrentProcess(); | 1483 CommandLine* cmd_line = CommandLine::ForCurrentProcess(); |
| 1301 DCHECK(cmd_line); | 1484 DCHECK(cmd_line); |
| 1302 | 1485 |
| 1303 CommandLine::SwitchMap switches = cmd_line->GetSwitches(); | 1486 CommandLine::SwitchMap switches = cmd_line->GetSwitches(); |
| 1304 for (CommandLine::SwitchMap::const_iterator it = switches.begin(); | 1487 for (CommandLine::SwitchMap::const_iterator it = switches.begin(); |
| 1305 it != switches.end(); ++it) { | 1488 it != switches.end(); ++it) { |
| 1306 if (it->first == "test_video_data") { | 1489 if (it->first == "test_video_data") { |
| 1307 content::g_test_video_data = it->second.c_str(); | 1490 content::g_test_video_data = it->second.c_str(); |
| 1308 continue; | 1491 continue; |
| 1309 } | 1492 } |
| 1310 if (it->first == "frame_delivery_log") { | 1493 // TODO(wuchengli): remove frame_deliver_log after CrOS test get updated. |
|
Ami GONE FROM CHROMIUM
2013/11/05 16:41:03
Could point to the pending CL in this TODO.
| |
| 1311 content::g_frame_delivery_log = it->second.c_str(); | 1494 if (it->first == "frame_delivery_log" || it->first == "output_log") { |
| 1495 content::g_output_log = it->second.c_str(); | |
| 1312 continue; | 1496 continue; |
| 1313 } | 1497 } |
| 1314 if (it->first == "rendering_fps") { | 1498 if (it->first == "rendering_fps") { |
| 1315 // On Windows, CommandLine::StringType is wstring. We need to convert | 1499 // On Windows, CommandLine::StringType is wstring. We need to convert |
| 1316 // it to std::string first | 1500 // it to std::string first |
| 1317 std::string input(it->second.begin(), it->second.end()); | 1501 std::string input(it->second.begin(), it->second.end()); |
| 1318 CHECK(base::StringToDouble(input, &content::g_rendering_fps)); | 1502 CHECK(base::StringToDouble(input, &content::g_rendering_fps)); |
| 1319 continue; | 1503 continue; |
| 1320 } | 1504 } |
| 1321 if (it->first == "disable_rendering") { | 1505 if (it->first == "disable_rendering") { |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 1334 #elif defined(OS_CHROMEOS) | 1518 #elif defined(OS_CHROMEOS) |
| 1335 #if defined(ARCH_CPU_ARMEL) | 1519 #if defined(ARCH_CPU_ARMEL) |
| 1336 content::ExynosVideoDecodeAccelerator::PreSandboxInitialization(); | 1520 content::ExynosVideoDecodeAccelerator::PreSandboxInitialization(); |
| 1337 #elif defined(ARCH_CPU_X86_FAMILY) | 1521 #elif defined(ARCH_CPU_X86_FAMILY) |
| 1338 content::VaapiWrapper::PreSandboxInitialization(); | 1522 content::VaapiWrapper::PreSandboxInitialization(); |
| 1339 #endif // ARCH_CPU_ARMEL | 1523 #endif // ARCH_CPU_ARMEL |
| 1340 #endif // OS_CHROMEOS | 1524 #endif // OS_CHROMEOS |
| 1341 | 1525 |
| 1342 return RUN_ALL_TESTS(); | 1526 return RUN_ALL_TESTS(); |
| 1343 } | 1527 } |
| OLD | NEW |