blob: f082b1e9359e240d7aa3e6ee1b990075e9ac2f5a [file] [log] [blame]
Kári Tristan Helgason169005d2018-05-22 11:34:141/*
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 11:41:3013#include "rtc_base/strings/string_builder.h"
14
Kári Tristan Helgason169005d2018-05-22 11:34:1415namespace webrtc {
16namespace test {
17
Rasmus Brandt7d72d0f2019-03-26 15:56:1418VideoCodecTestStats::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 11:34:1425std::string VideoCodecTestStats::FrameStatistics::ToString() const {
Jonas Olsson366a50c2018-09-06 11:41:3026 rtc::StringBuilder ss;
Sergey Silkin706ef1b2021-07-07 12:23:0727 for (const auto& entry : ToMap()) {
28 if (ss.size() > 0) {
29 ss << " ";
30 }
31 ss << entry.first << " " << entry.second;
32 }
Jonas Olsson84df1c72018-09-14 14:59:3233 return ss.Release();
Kári Tristan Helgason169005d2018-05-22 11:34:1434}
35
Sergey Silkin706ef1b2021-07-07 12:23:0736std::map<std::string, std::string> VideoCodecTestStats::FrameStatistics::ToMap()
37 const {
38 std::map<std::string, std::string> map;
39 map["frame_number"] = std::to_string(frame_number);
40 map["decoded_width"] = std::to_string(decoded_width);
41 map["decoded_height"] = std::to_string(decoded_height);
42 map["spatial_idx"] = std::to_string(spatial_idx);
43 map["temporal_idx"] = std::to_string(temporal_idx);
44 map["inter_layer_predicted"] = std::to_string(inter_layer_predicted);
45 map["non_ref_for_inter_layer_pred"] =
46 std::to_string(non_ref_for_inter_layer_pred);
47 map["frame_type"] = std::to_string(static_cast<int>(frame_type));
48 map["length_bytes"] = std::to_string(length_bytes);
49 map["qp"] = std::to_string(qp);
50 map["psnr"] = std::to_string(psnr);
51 map["psnr_y"] = std::to_string(psnr_y);
52 map["psnr_u"] = std::to_string(psnr_u);
53 map["psnr_v"] = std::to_string(psnr_v);
54 map["ssim"] = std::to_string(ssim);
55 map["encode_time_us"] = std::to_string(encode_time_us);
56 map["decode_time_us"] = std::to_string(decode_time_us);
57 map["rtp_timestamp"] = std::to_string(rtp_timestamp);
58 map["target_bitrate_kbps"] = std::to_string(target_bitrate_kbps);
59 map["target_framerate_fps"] = std::to_string(target_framerate_fps);
60 return map;
61}
62
Kári Tristan Helgason169005d2018-05-22 11:34:1463std::string VideoCodecTestStats::VideoStatistics::ToString(
64 std::string prefix) const {
Jonas Olsson366a50c2018-09-06 11:41:3065 rtc::StringBuilder ss;
Sergey Silkin706ef1b2021-07-07 12:23:0766 for (const auto& entry : ToMap()) {
67 if (ss.size() > 0) {
68 ss << "\n";
69 }
70 ss << prefix << entry.first << ": " << entry.second;
71 }
Jonas Olsson84df1c72018-09-14 14:59:3272 return ss.Release();
Kári Tristan Helgason169005d2018-05-22 11:34:1473}
74
Sergey Silkin706ef1b2021-07-07 12:23:0775std::map<std::string, std::string> VideoCodecTestStats::VideoStatistics::ToMap()
76 const {
77 std::map<std::string, std::string> map;
78 map["target_bitrate_kbps"] = std::to_string(target_bitrate_kbps);
79 map["input_framerate_fps"] = std::to_string(input_framerate_fps);
80 map["spatial_idx"] = std::to_string(spatial_idx);
81 map["temporal_idx"] = std::to_string(temporal_idx);
82 map["width"] = std::to_string(width);
83 map["height"] = std::to_string(height);
84 map["length_bytes"] = std::to_string(length_bytes);
85 map["bitrate_kbps"] = std::to_string(bitrate_kbps);
86 map["framerate_fps"] = std::to_string(framerate_fps);
87 map["enc_speed_fps"] = std::to_string(enc_speed_fps);
88 map["dec_speed_fps"] = std::to_string(dec_speed_fps);
Sergey Silkina6bab602022-02-17 10:29:0289 map["avg_encode_latency_sec"] = std::to_string(avg_encode_latency_sec);
90 map["max_encode_latency_sec"] = std::to_string(max_encode_latency_sec);
91 map["avg_decode_latency_sec"] = std::to_string(avg_decode_latency_sec);
92 map["max_decode_latency_sec"] = std::to_string(max_decode_latency_sec);
Sergey Silkin706ef1b2021-07-07 12:23:0793 map["avg_delay_sec"] = std::to_string(avg_delay_sec);
94 map["max_key_frame_delay_sec"] = std::to_string(max_key_frame_delay_sec);
95 map["max_delta_frame_delay_sec"] = std::to_string(max_delta_frame_delay_sec);
96 map["time_to_reach_target_bitrate_sec"] =
97 std::to_string(time_to_reach_target_bitrate_sec);
Sergey Silkin1fdafae2021-08-17 09:39:3798 map["avg_bitrate_mismatch_pct"] = std::to_string(avg_bitrate_mismatch_pct);
99 map["avg_framerate_mismatch_pct"] =
100 std::to_string(avg_framerate_mismatch_pct);
Sergey Silkin706ef1b2021-07-07 12:23:07101 map["avg_key_frame_size_bytes"] = std::to_string(avg_key_frame_size_bytes);
102 map["avg_delta_frame_size_bytes"] =
103 std::to_string(avg_delta_frame_size_bytes);
104 map["avg_qp"] = std::to_string(avg_qp);
105 map["avg_psnr"] = std::to_string(avg_psnr);
106 map["min_psnr"] = std::to_string(min_psnr);
107 map["avg_ssim"] = std::to_string(avg_ssim);
108 map["min_ssim"] = std::to_string(min_ssim);
109 map["num_input_frames"] = std::to_string(num_input_frames);
110 map["num_encoded_frames"] = std::to_string(num_encoded_frames);
111 map["num_decoded_frames"] = std::to_string(num_decoded_frames);
112 map["num_dropped_frames"] =
113 std::to_string(num_input_frames - num_encoded_frames);
114 map["num_key_frames"] = std::to_string(num_key_frames);
115 map["num_spatial_resizes"] = std::to_string(num_spatial_resizes);
116 map["max_nalu_size_bytes"] = std::to_string(max_nalu_size_bytes);
117 return map;
118}
119
Kári Tristan Helgason169005d2018-05-22 11:34:14120} // namespace test
121} // namespace webrtc