blob: d2dd303ee006be96e64460a132249433b9d77fb8 [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
11#ifndef WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_STATS_H_
12#define WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_STATS_H_
kjellander@webrtc.org35a17562011-10-06 06:44:54 +000013
14#include <vector>
15
kjellander6f8ce062015-11-16 13:52:24 -080016#include "webrtc/common_video/include/video_image.h"
kjellander@webrtc.org35a17562011-10-06 06:44:54 +000017
18namespace webrtc {
19namespace test {
20
21// Contains statistics of a single frame that has been processed.
22struct FrameStatistic {
pbos@webrtc.org7f7162a2013-07-30 15:18:31 +000023 FrameStatistic();
24
kjellander@webrtc.org35a17562011-10-06 06:44:54 +000025 bool encoding_successful;
26 bool decoding_successful;
27 int encode_return_code;
28 int decode_return_code;
29 int encode_time_in_us;
30 int decode_time_in_us;
asaperssonabc00802017-02-23 01:33:04 -080031 int qp;
kjellander@webrtc.org35a17562011-10-06 06:44:54 +000032 int frame_number;
pbos@webrtc.org7f7162a2013-07-30 15:18:31 +000033 // How many packets were discarded of the encoded frame data (if any).
kjellander@webrtc.org35a17562011-10-06 06:44:54 +000034 int packets_dropped;
pkasting@chromium.org4591fbd2014-11-20 22:28:14 +000035 size_t total_packets;
kjellander@webrtc.org35a17562011-10-06 06:44:54 +000036
37 // Current bit rate. Calculated out of the size divided with the time
38 // interval per frame.
39 int bit_rate_in_kbps;
40
41 // Copied from EncodedImage
pkasting@chromium.org4591fbd2014-11-20 22:28:14 +000042 size_t encoded_frame_length_in_bytes;
pbos22993e12015-10-19 02:39:06 -070043 webrtc::FrameType frame_type;
kjellander@webrtc.org35a17562011-10-06 06:44:54 +000044};
45
46// Handles statistics from a single video processing run.
47// Contains calculation methods for interesting metrics from these stats.
48class Stats {
49 public:
50 typedef std::vector<FrameStatistic>::iterator FrameStatisticsIterator;
51
52 Stats();
53 virtual ~Stats();
54
55 // Add a new statistic data object.
56 // The frame number must be incrementing and start at zero in order to use
57 // it as an index for the frame_statistics_ vector.
58 // Returns the newly created statistic object.
59 FrameStatistic& NewFrame(int frame_number);
60
61 // Prints a summary of all the statistics that have been gathered during the
62 // processing
63 void PrintSummary();
64
65 std::vector<FrameStatistic> stats_;
66};
67
68} // namespace test
69} // namespace webrtc
70
kjellander@webrtc.org5b97b122011-12-08 07:42:18 +000071#endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_STATS_H_