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

Side by Side Diff: webrtc/video/video_quality_test.cc

Issue 2990563002: Add Jpeg frame writer for test support. (Closed)
Patch Set: Implemented Sprang@ comments. Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/video/BUILD.gn ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "webrtc/video/video_quality_test.h" 10 #include "webrtc/video/video_quality_test.h"
(...skipping 15 matching lines...) Expand all
26 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h" 26 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h"
27 #include "webrtc/modules/rtp_rtcp/source/rtp_format.h" 27 #include "webrtc/modules/rtp_rtcp/source/rtp_format.h"
28 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h" 28 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h"
29 #include "webrtc/modules/video_coding/codecs/h264/include/h264.h" 29 #include "webrtc/modules/video_coding/codecs/h264/include/h264.h"
30 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h" 30 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h"
31 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8_common_types.h" 31 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8_common_types.h"
32 #include "webrtc/modules/video_coding/codecs/vp9/include/vp9.h" 32 #include "webrtc/modules/video_coding/codecs/vp9/include/vp9.h"
33 #include "webrtc/rtc_base/checks.h" 33 #include "webrtc/rtc_base/checks.h"
34 #include "webrtc/rtc_base/cpu_time.h" 34 #include "webrtc/rtc_base/cpu_time.h"
35 #include "webrtc/rtc_base/event.h" 35 #include "webrtc/rtc_base/event.h"
36 #include "webrtc/rtc_base/flags.h"
36 #include "webrtc/rtc_base/format_macros.h" 37 #include "webrtc/rtc_base/format_macros.h"
38 #include "webrtc/rtc_base/logging.h"
37 #include "webrtc/rtc_base/memory_usage.h" 39 #include "webrtc/rtc_base/memory_usage.h"
38 #include "webrtc/rtc_base/optional.h" 40 #include "webrtc/rtc_base/optional.h"
41 #include "webrtc/rtc_base/pathutils.h"
39 #include "webrtc/rtc_base/platform_file.h" 42 #include "webrtc/rtc_base/platform_file.h"
40 #include "webrtc/rtc_base/timeutils.h" 43 #include "webrtc/rtc_base/timeutils.h"
41 #include "webrtc/system_wrappers/include/cpu_info.h" 44 #include "webrtc/system_wrappers/include/cpu_info.h"
42 #include "webrtc/system_wrappers/include/field_trial.h" 45 #include "webrtc/system_wrappers/include/field_trial.h"
43 #include "webrtc/test/gtest.h" 46 #include "webrtc/test/gtest.h"
44 #include "webrtc/test/layer_filtering_transport.h" 47 #include "webrtc/test/layer_filtering_transport.h"
45 #include "webrtc/test/run_loop.h" 48 #include "webrtc/test/run_loop.h"
46 #include "webrtc/test/statistics.h" 49 #include "webrtc/test/statistics.h"
47 #include "webrtc/test/testsupport/fileutils.h" 50 #include "webrtc/test/testsupport/fileutils.h"
48 #include "webrtc/test/testsupport/frame_writer.h" 51 #include "webrtc/test/testsupport/frame_writer.h"
52 #include "webrtc/test/testsupport/test_output.h"
49 #include "webrtc/test/vcm_capturer.h" 53 #include "webrtc/test/vcm_capturer.h"
50 #include "webrtc/test/video_renderer.h" 54 #include "webrtc/test/video_renderer.h"
51 #include "webrtc/voice_engine/include/voe_base.h" 55 #include "webrtc/voice_engine/include/voe_base.h"
52 56
53 #include "webrtc/test/rtp_file_writer.h" 57 #include "webrtc/test/rtp_file_writer.h"
54 58
59 DEFINE_bool(save_worst_frame,
60 false,
61 "Enable saving a frame with the lowest PSNR to a jpeg file in the "
62 "test_output_dir");
63
55 namespace { 64 namespace {
56 65
57 constexpr int kSendStatsPollingIntervalMs = 1000; 66 constexpr int kSendStatsPollingIntervalMs = 1000;
58 67
59 constexpr size_t kMaxComparisons = 10; 68 constexpr size_t kMaxComparisons = 10;
60 constexpr char kSyncGroup[] = "av_sync"; 69 constexpr char kSyncGroup[] = "av_sync";
61 constexpr int kOpusMinBitrateBps = 6000; 70 constexpr int kOpusMinBitrateBps = 6000;
62 constexpr int kOpusBitrateFbBps = 32000; 71 constexpr int kOpusBitrateFbBps = 32000;
63 constexpr int kFramesSentInQuickTest = 1; 72 constexpr int kFramesSentInQuickTest = 1;
64 constexpr uint32_t kThumbnailSendSsrcStart = 0xE0000; 73 constexpr uint32_t kThumbnailSendSsrcStart = 0xE0000;
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after
817 dropped_frames_); 826 dropped_frames_);
818 printf("RESULT cpu_usage: %s = %lf %%\n", test_label_.c_str(), 827 printf("RESULT cpu_usage: %s = %lf %%\n", test_label_.c_str(),
819 GetCpuUsagePercent()); 828 GetCpuUsagePercent());
820 829
821 #if defined(WEBRTC_WIN) 830 #if defined(WEBRTC_WIN)
822 // On Linux and Mac in Resident Set some unused pages may be counted. 831 // On Linux and Mac in Resident Set some unused pages may be counted.
823 // Therefore this metric will depend on order in which tests are run and 832 // Therefore this metric will depend on order in which tests are run and
824 // will be flaky. 833 // will be flaky.
825 PrintResult("memory_usage", memory_usage_, " bytes"); 834 PrintResult("memory_usage", memory_usage_, " bytes");
826 #endif 835 #endif
827 // TODO(ilnik): enable frame writing for android, once jpeg frame writer
828 // is implemented.
829 836
830 #if !defined(WEBRTC_ANDROID) 837 // LibJpeg is not available on iOS.
831 if (worst_frame_) { 838 #if !defined(WEBRTC_IOS)
832 test::Y4mFrameWriterImpl frame_writer(test_label_ + ".y4m", 839 // Saving only the worst frame for manual analysis. Intention here is to
833 worst_frame_->frame.width(), 840 // only detect video corruptions and not to track picture quality. Thus,
834 worst_frame_->frame.height(), 1); 841 // jpeg is used here.
835 bool res = frame_writer.Init(); 842 if (FLAG_save_worst_frame && worst_frame_) {
836 RTC_DCHECK(res); 843 std::string output_dir;
837 size_t length = 844 test::GetTestOutputDir(&output_dir);
838 CalcBufferSize(VideoType::kI420, worst_frame_->frame.width(), 845 std::string output_path =
839 worst_frame_->frame.height()); 846 rtc::Pathname(output_dir, test_label_ + ".jpg").pathname();
840 rtc::Buffer extracted_buffer(length); 847 LOG(LS_INFO) << "Saving worst frame to " << output_path;
841 size_t extracted_length = 848 test::JpegFrameWriter frame_writer(output_path);
842 ExtractBuffer(worst_frame_->frame.video_frame_buffer()->ToI420(), 849 RTC_CHECK(frame_writer.WriteFrame(worst_frame_->frame,
843 length, extracted_buffer.data()); 850 100 /*best quality*/));
844 RTC_DCHECK_EQ(extracted_length, frame_writer.FrameLength());
845 res = frame_writer.WriteFrame(extracted_buffer.data());
846 RTC_DCHECK(res);
847 frame_writer.Close();
848 } 851 }
849 #endif 852 #endif
850 853
851 // Disable quality check for quick test, as quality checks may fail 854 // Disable quality check for quick test, as quality checks may fail
852 // because too few samples were collected. 855 // because too few samples were collected.
853 if (!is_quick_test_enabled_) { 856 if (!is_quick_test_enabled_) {
854 EXPECT_GT(psnr_.Mean(), avg_psnr_threshold_); 857 EXPECT_GT(psnr_.Mean(), avg_psnr_threshold_);
855 EXPECT_GT(ssim_.Mean(), avg_ssim_threshold_); 858 EXPECT_GT(ssim_.Mean(), avg_ssim_threshold_);
856 } 859 }
857 } 860 }
(...skipping 1261 matching lines...) Expand 10 before | Expand all | Expand 10 after
2119 if (!params_.logging.encoded_frame_base_path.empty()) { 2122 if (!params_.logging.encoded_frame_base_path.empty()) {
2120 std::ostringstream str; 2123 std::ostringstream str;
2121 str << receive_logs_++; 2124 str << receive_logs_++;
2122 std::string path = 2125 std::string path =
2123 params_.logging.encoded_frame_base_path + "." + str.str() + ".recv.ivf"; 2126 params_.logging.encoded_frame_base_path + "." + str.str() + ".recv.ivf";
2124 stream->EnableEncodedFrameRecording(rtc::CreatePlatformFile(path), 2127 stream->EnableEncodedFrameRecording(rtc::CreatePlatformFile(path),
2125 100000000); 2128 100000000);
2126 } 2129 }
2127 } 2130 }
2128 } // namespace webrtc 2131 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/video/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698