blob: 63e15768dc4356decfed406abb3281d62ead76af [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#ifndef API_TEST_VIDEOCODEC_TEST_STATS_H_
12#define API_TEST_VIDEOCODEC_TEST_STATS_H_
13
Yves Gerey3e707812018-11-28 15:47:4914#include <stddef.h>
15#include <stdint.h>
Jonas Olssona4d87372019-07-05 17:08:3316
Kári Tristan Helgason169005d2018-05-22 11:34:1417#include <string>
18#include <vector>
19
Niels Möller8f7ce222019-03-21 14:43:5820#include "api/video/video_frame_type.h"
Kári Tristan Helgason169005d2018-05-22 11:34:1421
22namespace webrtc {
23namespace test {
24
25// Statistics for a sequence of processed frames. This class is not thread safe.
26class VideoCodecTestStats {
27 public:
28 // Statistics for one processed frame.
29 struct FrameStatistics {
Sergey Silkin02fed022018-09-25 11:48:1930 FrameStatistics(size_t frame_number,
31 size_t rtp_timestamp,
32 size_t spatial_idx);
Kári Tristan Helgason169005d2018-05-22 11:34:1433
34 std::string ToString() const;
35
36 size_t frame_number = 0;
37 size_t rtp_timestamp = 0;
38
39 // Encoding.
40 int64_t encode_start_ns = 0;
41 int encode_return_code = 0;
42 bool encoding_successful = false;
43 size_t encode_time_us = 0;
44 size_t target_bitrate_kbps = 0;
Sergey Silkin44cec0b2019-07-11 12:20:3845 double target_framerate_fps = 0.0;
Kári Tristan Helgason169005d2018-05-22 11:34:1446 size_t length_bytes = 0;
Niels Möller8f7ce222019-03-21 14:43:5847 VideoFrameType frame_type = VideoFrameType::kVideoFrameDelta;
Kári Tristan Helgason169005d2018-05-22 11:34:1448
49 // Layering.
50 size_t spatial_idx = 0;
51 size_t temporal_idx = 0;
52 bool inter_layer_predicted = false;
53 bool non_ref_for_inter_layer_pred = true;
54
55 // H264 specific.
56 size_t max_nalu_size_bytes = 0;
57
58 // Decoding.
59 int64_t decode_start_ns = 0;
60 int decode_return_code = 0;
61 bool decoding_successful = false;
62 size_t decode_time_us = 0;
63 size_t decoded_width = 0;
64 size_t decoded_height = 0;
65
66 // Quantization.
67 int qp = -1;
68
69 // Quality.
70 float psnr_y = 0.0f;
71 float psnr_u = 0.0f;
72 float psnr_v = 0.0f;
73 float psnr = 0.0f; // 10 * log10(255^2 / (mse_y + mse_u + mse_v)).
74 float ssim = 0.0f; // 0.8 * ssim_y + 0.1 * (ssim_u + ssim_v).
75 };
76
77 struct VideoStatistics {
Kári Tristan Helgason169005d2018-05-22 11:34:1478 std::string ToString(std::string prefix) const;
79
80 size_t target_bitrate_kbps = 0;
81 float input_framerate_fps = 0.0f;
82
83 size_t spatial_idx = 0;
84 size_t temporal_idx = 0;
85
86 size_t width = 0;
87 size_t height = 0;
88
89 size_t length_bytes = 0;
90 size_t bitrate_kbps = 0;
91 float framerate_fps = 0;
92
93 float enc_speed_fps = 0.0f;
94 float dec_speed_fps = 0.0f;
95
96 float avg_delay_sec = 0.0f;
97 float max_key_frame_delay_sec = 0.0f;
98 float max_delta_frame_delay_sec = 0.0f;
99 float time_to_reach_target_bitrate_sec = 0.0f;
100
101 float avg_key_frame_size_bytes = 0.0f;
102 float avg_delta_frame_size_bytes = 0.0f;
103 float avg_qp = 0.0f;
104
105 float avg_psnr_y = 0.0f;
106 float avg_psnr_u = 0.0f;
107 float avg_psnr_v = 0.0f;
108 float avg_psnr = 0.0f;
109 float min_psnr = 0.0f;
110 float avg_ssim = 0.0f;
111 float min_ssim = 0.0f;
112
113 size_t num_input_frames = 0;
114 size_t num_encoded_frames = 0;
115 size_t num_decoded_frames = 0;
116 size_t num_key_frames = 0;
117 size_t num_spatial_resizes = 0;
118 size_t max_nalu_size_bytes = 0;
119 };
120
121 virtual ~VideoCodecTestStats() = default;
122
Rasmus Brandt7d72d0f2019-03-26 15:56:14123 virtual std::vector<FrameStatistics> GetFrameStatistics() = 0;
Kári Tristan Helgason169005d2018-05-22 11:34:14124
125 virtual std::vector<VideoStatistics> SliceAndCalcLayerVideoStatistic(
126 size_t first_frame_num,
127 size_t last_frame_num) = 0;
Kári Tristan Helgason169005d2018-05-22 11:34:14128};
129
130} // namespace test
131} // namespace webrtc
132
133#endif // API_TEST_VIDEOCODEC_TEST_STATS_H_