Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 #include <stdio.h> | 10 #include <stdio.h> |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 34 #include "webrtc/test/testsupport/fileutils.h" | 34 #include "webrtc/test/testsupport/fileutils.h" |
| 35 #include "webrtc/test/video_renderer.h" | 35 #include "webrtc/test/video_renderer.h" |
| 36 #include "webrtc/video/video_quality_test.h" | 36 #include "webrtc/video/video_quality_test.h" |
| 37 | 37 |
| 38 namespace webrtc { | 38 namespace webrtc { |
| 39 | 39 |
| 40 static const int kSendStatsPollingIntervalMs = 1000; | 40 static const int kSendStatsPollingIntervalMs = 1000; |
| 41 static const int kPayloadTypeH264 = 122; | 41 static const int kPayloadTypeH264 = 122; |
| 42 static const int kPayloadTypeVP8 = 123; | 42 static const int kPayloadTypeVP8 = 123; |
| 43 static const int kPayloadTypeVP9 = 124; | 43 static const int kPayloadTypeVP9 = 124; |
| 44 static const size_t kMaxComparisons = 10; | |
| 44 | 45 |
| 45 class VideoAnalyzer : public PacketReceiver, | 46 class VideoAnalyzer : public PacketReceiver, |
| 46 public Transport, | 47 public Transport, |
| 47 public rtc::VideoSinkInterface<VideoFrame>, | 48 public rtc::VideoSinkInterface<VideoFrame>, |
| 48 public VideoCaptureInput, | 49 public VideoCaptureInput, |
| 49 public EncodedFrameObserver { | 50 public EncodedFrameObserver { |
| 50 public: | 51 public: |
| 51 VideoAnalyzer(test::LayerFilteringTransport* transport, | 52 VideoAnalyzer(test::LayerFilteringTransport* transport, |
| 52 const std::string& test_label, | 53 const std::string& test_label, |
| 53 double avg_psnr_threshold, | 54 double avg_psnr_threshold, |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 401 // TODO(ivica): Make this work for > 2 streams. | 402 // TODO(ivica): Make this work for > 2 streams. |
| 402 auto it = encoded_frame_sizes_.find(reference_timestamp); | 403 auto it = encoded_frame_sizes_.find(reference_timestamp); |
| 403 if (it == encoded_frame_sizes_.end()) | 404 if (it == encoded_frame_sizes_.end()) |
| 404 it = encoded_frame_sizes_.find(reference_timestamp - 1); | 405 it = encoded_frame_sizes_.find(reference_timestamp - 1); |
| 405 size_t encoded_size = it == encoded_frame_sizes_.end() ? 0 : it->second; | 406 size_t encoded_size = it == encoded_frame_sizes_.end() ? 0 : it->second; |
| 406 if (it != encoded_frame_sizes_.end()) | 407 if (it != encoded_frame_sizes_.end()) |
| 407 encoded_frame_sizes_.erase(it); | 408 encoded_frame_sizes_.erase(it); |
| 408 | 409 |
| 409 VideoFrame reference_copy; | 410 VideoFrame reference_copy; |
| 410 VideoFrame render_copy; | 411 VideoFrame render_copy; |
| 411 reference_copy.CopyFrame(reference); | |
| 412 render_copy.CopyFrame(render); | |
| 413 | 412 |
| 414 rtc::CritScope crit(&comparison_lock_); | 413 rtc::CritScope crit(&comparison_lock_); |
| 414 if (comparisons_.size() < kMaxComparisons) { | |
| 415 reference_copy.CopyFrame(reference); | |
| 416 render_copy.CopyFrame(render); | |
| 417 } | |
|
sprang_webrtc
2016/08/11 10:43:50
else {
reference_copy.set_ntp_time_ms(reference.
stefan-webrtc
2016/08/11 10:49:47
Done.
| |
| 415 comparisons_.push_back(FrameComparison(reference_copy, render_copy, dropped, | 418 comparisons_.push_back(FrameComparison(reference_copy, render_copy, dropped, |
| 416 send_time_ms, recv_time_ms, | 419 send_time_ms, recv_time_ms, |
| 417 render_time_ms, encoded_size)); | 420 render_time_ms, encoded_size)); |
| 418 comparison_available_event_.Set(); | 421 comparison_available_event_.Set(); |
| 419 } | 422 } |
| 420 | 423 |
| 421 static bool PollStatsThread(void* obj) { | 424 static bool PollStatsThread(void* obj) { |
| 422 return static_cast<VideoAnalyzer*>(obj)->PollStats(); | 425 return static_cast<VideoAnalyzer*>(obj)->PollStats(); |
| 423 } | 426 } |
| 424 | 427 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 539 test_label_.c_str(), dropped_frames_before_first_encode_); | 542 test_label_.c_str(), dropped_frames_before_first_encode_); |
| 540 printf("RESULT dropped_frames_before_rendering: %s = %d frames\n", | 543 printf("RESULT dropped_frames_before_rendering: %s = %d frames\n", |
| 541 test_label_.c_str(), dropped_frames_before_rendering_); | 544 test_label_.c_str(), dropped_frames_before_rendering_); |
| 542 | 545 |
| 543 EXPECT_GT(psnr_.Mean(), avg_psnr_threshold_); | 546 EXPECT_GT(psnr_.Mean(), avg_psnr_threshold_); |
| 544 EXPECT_GT(ssim_.Mean(), avg_ssim_threshold_); | 547 EXPECT_GT(ssim_.Mean(), avg_ssim_threshold_); |
| 545 } | 548 } |
| 546 | 549 |
| 547 void PerformFrameComparison(const FrameComparison& comparison) { | 550 void PerformFrameComparison(const FrameComparison& comparison) { |
| 548 // Perform expensive psnr and ssim calculations while not holding lock. | 551 // Perform expensive psnr and ssim calculations while not holding lock. |
| 549 double psnr = I420PSNR(&comparison.reference, &comparison.render); | 552 double psnr = -1.0; |
| 550 double ssim = I420SSIM(&comparison.reference, &comparison.render); | 553 double ssim = -1.0; |
| 554 if (!comparison.reference.IsZeroSize()) { | |
| 555 psnr = I420PSNR(&comparison.reference, &comparison.render); | |
| 556 ssim = I420SSIM(&comparison.reference, &comparison.render); | |
| 557 } | |
| 551 | 558 |
| 552 int64_t input_time_ms = comparison.reference.ntp_time_ms(); | 559 int64_t input_time_ms = comparison.reference.ntp_time_ms(); |
| 553 | 560 |
| 554 rtc::CritScope crit(&comparison_lock_); | 561 rtc::CritScope crit(&comparison_lock_); |
| 555 if (graph_data_output_file_) { | 562 if (graph_data_output_file_) { |
| 556 samples_.push_back( | 563 samples_.push_back( |
| 557 Sample(comparison.dropped, input_time_ms, comparison.send_time_ms, | 564 Sample(comparison.dropped, input_time_ms, comparison.send_time_ms, |
| 558 comparison.recv_time_ms, comparison.render_time_ms, | 565 comparison.recv_time_ms, comparison.render_time_ms, |
| 559 comparison.encoded_frame_size, psnr, ssim)); | 566 comparison.encoded_frame_size, psnr, ssim)); |
| 560 } | 567 } |
| 561 psnr_.AddSample(psnr); | 568 if (psnr >= 0.0) |
| 562 ssim_.AddSample(ssim); | 569 psnr_.AddSample(psnr); |
| 570 if (ssim >= 0.0) | |
| 571 ssim_.AddSample(ssim); | |
| 563 | 572 |
| 564 if (comparison.dropped) { | 573 if (comparison.dropped) { |
| 565 ++dropped_frames_; | 574 ++dropped_frames_; |
| 566 return; | 575 return; |
| 567 } | 576 } |
| 568 if (last_render_time_ != 0) | 577 if (last_render_time_ != 0) |
| 569 rendered_delta_.AddSample(comparison.render_time_ms - last_render_time_); | 578 rendered_delta_.AddSample(comparison.render_time_ms - last_render_time_); |
| 570 last_render_time_ = comparison.render_time_ms; | 579 last_render_time_ = comparison.render_time_ms; |
| 571 | 580 |
| 572 sender_time_.AddSample(comparison.send_time_ms - input_time_ms); | 581 sender_time_.AddSample(comparison.send_time_ms - input_time_ms); |
| (...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1156 video_send_stream_->Stop(); | 1165 video_send_stream_->Stop(); |
| 1157 receive_stream->Stop(); | 1166 receive_stream->Stop(); |
| 1158 | 1167 |
| 1159 call->DestroyVideoReceiveStream(receive_stream); | 1168 call->DestroyVideoReceiveStream(receive_stream); |
| 1160 call->DestroyVideoSendStream(video_send_stream_); | 1169 call->DestroyVideoSendStream(video_send_stream_); |
| 1161 | 1170 |
| 1162 transport.StopSending(); | 1171 transport.StopSending(); |
| 1163 } | 1172 } |
| 1164 | 1173 |
| 1165 } // namespace webrtc | 1174 } // namespace webrtc |
| OLD | NEW |