blob: 8022f277c83c34886e2f11624543d42ac6b3c72f [file] [log] [blame]
kjellander@webrtc.org35a17562011-10-06 06:44:54 +00001/*
2 * Copyright (c) 2011 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 */
kjellander@webrtc.org5b97b122011-12-08 07:42:18 +000010
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef MODULES_VIDEO_CODING_CODECS_TEST_STATS_H_
12#define MODULES_VIDEO_CODING_CODECS_TEST_STATS_H_
kjellander@webrtc.org35a17562011-10-06 06:44:54 +000013
14#include <vector>
15
Mirko Bonadei71207422017-09-15 13:58:09 +020016#include "common_types.h" // NOLINT(build/include)
kjellander@webrtc.org35a17562011-10-06 06:44:54 +000017
18namespace webrtc {
19namespace test {
20
brandtr8935d972017-09-06 01:53:22 -070021// Statistics for one processed frame.
kjellander@webrtc.org35a17562011-10-06 06:44:54 +000022struct FrameStatistic {
brandtr8935d972017-09-06 01:53:22 -070023 explicit FrameStatistic(int frame_number) : frame_number(frame_number) {}
24 const int frame_number = 0;
25
26 // Encoding.
27 int64_t encode_start_ns = 0;
asapersson68b91d72017-06-04 23:43:41 -070028 int encode_return_code = 0;
brandtr8935d972017-09-06 01:53:22 -070029 bool encoding_successful = false;
30 int encode_time_us = 0;
31 int bitrate_kbps = 0;
32 size_t encoded_frame_size_bytes = 0;
33 webrtc::FrameType frame_type = kVideoFrameDelta;
34
35 // Decoding.
36 int64_t decode_start_ns = 0;
asapersson68b91d72017-06-04 23:43:41 -070037 int decode_return_code = 0;
brandtr8935d972017-09-06 01:53:22 -070038 bool decoding_successful = false;
39 int decode_time_us = 0;
40 int decoded_width = 0;
41 int decoded_height = 0;
42
43 // Quantization.
asapersson68b91d72017-06-04 23:43:41 -070044 int qp = -1;
brandtr8935d972017-09-06 01:53:22 -070045
pbos@webrtc.org7f7162a2013-07-30 15:18:31 +000046 // How many packets were discarded of the encoded frame data (if any).
asapersson68b91d72017-06-04 23:43:41 -070047 int packets_dropped = 0;
48 size_t total_packets = 0;
brandtr8935d972017-09-06 01:53:22 -070049 size_t manipulated_length = 0;
kjellander@webrtc.org35a17562011-10-06 06:44:54 +000050};
51
brandtr8935d972017-09-06 01:53:22 -070052// Statistics for a sequence of processed frames. This class is not thread safe.
kjellander@webrtc.org35a17562011-10-06 06:44:54 +000053class Stats {
54 public:
brandtr8935d972017-09-06 01:53:22 -070055 Stats() = default;
56 ~Stats() = default;
kjellander@webrtc.org35a17562011-10-06 06:44:54 +000057
brandtr8935d972017-09-06 01:53:22 -070058 // Creates a FrameStatistic for the next frame to be processed.
59 FrameStatistic* AddFrame();
kjellander@webrtc.org35a17562011-10-06 06:44:54 +000060
brandtr8935d972017-09-06 01:53:22 -070061 // Returns the FrameStatistic corresponding to |frame_number|.
62 FrameStatistic* GetFrame(int frame_number);
kjellander@webrtc.org35a17562011-10-06 06:44:54 +000063
brandtr8935d972017-09-06 01:53:22 -070064 size_t size() const;
kjellander@webrtc.org35a17562011-10-06 06:44:54 +000065
brandtr8935d972017-09-06 01:53:22 -070066 // TODO(brandtr): Add output as CSV.
67 void PrintSummary() const;
68
69 private:
kjellander@webrtc.org35a17562011-10-06 06:44:54 +000070 std::vector<FrameStatistic> stats_;
71};
72
73} // namespace test
74} // namespace webrtc
75
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020076#endif // MODULES_VIDEO_CODING_CODECS_TEST_STATS_H_