blob: b2f88a4661b0632372b62b20fcbfeec626f2a919 [file] [log] [blame]
Kári Tristan Helgason169005d2018-05-22 13:34:14 +02001/*
2 * Copyright (c) 2018 The WebRTC project authors. All Rights Reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11#include "api/test/videocodec_test_stats.h"
12
Jonas Olsson366a50c2018-09-06 13:41:30 +020013#include "rtc_base/strings/string_builder.h"
14
Kári Tristan Helgason169005d2018-05-22 13:34:14 +020015namespace webrtc {
16namespace test {
17
Rasmus Brandt7d72d0f2019-03-26 16:56:14 +010018VideoCodecTestStats::FrameStatistics::FrameStatistics(size_t frame_number,
19 size_t rtp_timestamp,
20 size_t spatial_idx)
21 : frame_number(frame_number),
22 rtp_timestamp(rtp_timestamp),
23 spatial_idx(spatial_idx) {}
24
Kári Tristan Helgason169005d2018-05-22 13:34:14 +020025std::string VideoCodecTestStats::FrameStatistics::ToString() const {
Jonas Olsson366a50c2018-09-06 13:41:30 +020026 rtc::StringBuilder ss;
Kári Tristan Helgason169005d2018-05-22 13:34:14 +020027 ss << "frame_number " << frame_number;
28 ss << " decoded_width " << decoded_width;
29 ss << " decoded_height " << decoded_height;
30 ss << " spatial_idx " << spatial_idx;
31 ss << " temporal_idx " << temporal_idx;
32 ss << " inter_layer_predicted " << inter_layer_predicted;
33 ss << " non_ref_for_inter_layer_pred " << non_ref_for_inter_layer_pred;
Niels Möller8f7ce222019-03-21 15:43:58 +010034 ss << " frame_type " << static_cast<int>(frame_type);
Kári Tristan Helgason169005d2018-05-22 13:34:14 +020035 ss << " length_bytes " << length_bytes;
36 ss << " qp " << qp;
37 ss << " psnr " << psnr;
38 ss << " psnr_y " << psnr_y;
39 ss << " psnr_u " << psnr_u;
40 ss << " psnr_v " << psnr_v;
41 ss << " ssim " << ssim;
42 ss << " encode_time_us " << encode_time_us;
43 ss << " decode_time_us " << decode_time_us;
44 ss << " rtp_timestamp " << rtp_timestamp;
45 ss << " target_bitrate_kbps " << target_bitrate_kbps;
Sergey Silkin44cec0b2019-07-11 14:20:38 +020046 ss << " target_framerate_fps " << target_framerate_fps;
Jonas Olsson84df1c72018-09-14 16:59:32 +020047 return ss.Release();
Kári Tristan Helgason169005d2018-05-22 13:34:14 +020048}
49
Kári Tristan Helgason169005d2018-05-22 13:34:14 +020050std::string VideoCodecTestStats::VideoStatistics::ToString(
51 std::string prefix) const {
Jonas Olsson366a50c2018-09-06 13:41:30 +020052 rtc::StringBuilder ss;
Kári Tristan Helgason169005d2018-05-22 13:34:14 +020053 ss << prefix << "target_bitrate_kbps: " << target_bitrate_kbps;
54 ss << "\n" << prefix << "input_framerate_fps: " << input_framerate_fps;
55 ss << "\n" << prefix << "spatial_idx: " << spatial_idx;
56 ss << "\n" << prefix << "temporal_idx: " << temporal_idx;
57 ss << "\n" << prefix << "width: " << width;
58 ss << "\n" << prefix << "height: " << height;
59 ss << "\n" << prefix << "length_bytes: " << length_bytes;
60 ss << "\n" << prefix << "bitrate_kbps: " << bitrate_kbps;
61 ss << "\n" << prefix << "framerate_fps: " << framerate_fps;
62 ss << "\n" << prefix << "enc_speed_fps: " << enc_speed_fps;
63 ss << "\n" << prefix << "dec_speed_fps: " << dec_speed_fps;
64 ss << "\n" << prefix << "avg_delay_sec: " << avg_delay_sec;
65 ss << "\n"
66 << prefix << "max_key_frame_delay_sec: " << max_key_frame_delay_sec;
67 ss << "\n"
68 << prefix << "max_delta_frame_delay_sec: " << max_delta_frame_delay_sec;
69 ss << "\n"
70 << prefix << "time_to_reach_target_bitrate_sec: "
71 << time_to_reach_target_bitrate_sec;
72 ss << "\n"
73 << prefix << "avg_key_frame_size_bytes: " << avg_key_frame_size_bytes;
74 ss << "\n"
75 << prefix << "avg_delta_frame_size_bytes: " << avg_delta_frame_size_bytes;
76 ss << "\n" << prefix << "avg_qp: " << avg_qp;
77 ss << "\n" << prefix << "avg_psnr: " << avg_psnr;
78 ss << "\n" << prefix << "min_psnr: " << min_psnr;
79 ss << "\n" << prefix << "avg_ssim: " << avg_ssim;
80 ss << "\n" << prefix << "min_ssim: " << min_ssim;
81 ss << "\n" << prefix << "num_input_frames: " << num_input_frames;
82 ss << "\n" << prefix << "num_encoded_frames: " << num_encoded_frames;
83 ss << "\n" << prefix << "num_decoded_frames: " << num_decoded_frames;
84 ss << "\n"
85 << prefix
86 << "num_dropped_frames: " << num_input_frames - num_encoded_frames;
87 ss << "\n" << prefix << "num_key_frames: " << num_key_frames;
88 ss << "\n" << prefix << "num_spatial_resizes: " << num_spatial_resizes;
89 ss << "\n" << prefix << "max_nalu_size_bytes: " << max_nalu_size_bytes;
Jonas Olsson84df1c72018-09-14 16:59:32 +020090 return ss.Release();
Kári Tristan Helgason169005d2018-05-22 13:34:14 +020091}
92
Kári Tristan Helgason169005d2018-05-22 13:34:14 +020093} // namespace test
94} // namespace webrtc