Report minimum PSNR in VideoQualityTest and save corresponding frame to file

BUG=none

Review-Url: https://codereview.webrtc.org/2976373002
Cr-Commit-Position: refs/heads/master@{#19130}
This commit is contained in:
ilnik
2017-07-25 05:45:03 -07:00
committed by Commit Bot
parent d3f3c3497b
commit 59cac99c9a
2 changed files with 43 additions and 0 deletions

View File

@ -110,6 +110,7 @@ if (rtc_include_tests) {
"../test:test_renderer",
"../test:test_support",
"../test:video_test_common",
"../test:video_test_support",
"../voice_engine",
"//testing/gtest",
"//webrtc/test:rtp_test_utils",

View File

@ -45,6 +45,7 @@
#include "webrtc/test/run_loop.h"
#include "webrtc/test/statistics.h"
#include "webrtc/test/testsupport/fileutils.h"
#include "webrtc/test/testsupport/frame_writer.h"
#include "webrtc/test/vcm_capturer.h"
#include "webrtc/test/video_renderer.h"
#include "webrtc/voice_engine/include/voe_base.h"
@ -803,6 +804,11 @@ class VideoAnalyzer : public PacketReceiver,
PrintResult("fec_bitrate", fec_bitrate_bps_, " bps");
PrintResult("send_bandwidth", send_bandwidth_bps_, " bps");
if (worst_frame_) {
printf("RESULT min_psnr: %s = %lf dB\n", test_label_.c_str(),
worst_frame_->psnr);
}
if (receive_stream_ != nullptr) {
PrintResult("decode_time", decode_time_ms_, " ms");
}
@ -818,6 +824,29 @@ class VideoAnalyzer : public PacketReceiver,
// will be flaky.
PrintResult("memory_usage", memory_usage_, " bytes");
#endif
// TODO(ilnik): enable frame writing for android, once jpeg frame writer
// is implemented.
#if !defined(WEBRTC_ANDROID)
if (worst_frame_) {
test::Y4mFrameWriterImpl frame_writer(test_label_ + ".y4m",
worst_frame_->frame.width(),
worst_frame_->frame.height(), 1);
bool res = frame_writer.Init();
RTC_DCHECK(res);
size_t length =
CalcBufferSize(VideoType::kI420, worst_frame_->frame.width(),
worst_frame_->frame.height());
rtc::Buffer extracted_buffer(length);
size_t extracted_length =
ExtractBuffer(worst_frame_->frame.video_frame_buffer()->ToI420(),
length, extracted_buffer.data());
RTC_DCHECK_EQ(extracted_length, frame_writer.FrameLength());
res = frame_writer.WriteFrame(extracted_buffer.data());
RTC_DCHECK(res);
frame_writer.Close();
}
#endif
// Disable quality check for quick test, as quality checks may fail
// because too few samples were collected.
@ -837,6 +866,11 @@ class VideoAnalyzer : public PacketReceiver,
}
rtc::CritScope crit(&comparison_lock_);
if (psnr >= 0.0 && (!worst_frame_ || worst_frame_->psnr > psnr)) {
worst_frame_.emplace(FrameWithPsnr{psnr, *comparison.render});
}
if (graph_data_output_file_) {
samples_.push_back(Sample(
comparison.dropped, comparison.input_time_ms, comparison.send_time_ms,
@ -1040,6 +1074,14 @@ class VideoAnalyzer : public PacketReceiver,
test::Statistics send_bandwidth_bps_ GUARDED_BY(comparison_lock_);
test::Statistics memory_usage_ GUARDED_BY(comparison_lock_);
struct FrameWithPsnr {
double psnr;
VideoFrame frame;
};
// Rendered frame with worst PSNR is saved for further analysis.
rtc::Optional<FrameWithPsnr> worst_frame_ GUARDED_BY(comparison_lock_);
size_t last_fec_bytes_;
const int frames_to_process_;