blob: 464535d208f1fbc12235f4173206110e4cc205df [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
pbos@webrtc.orga4407322013-07-16 12:32:05 +000016#include "webrtc/common_video/interface/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 {
23 FrameStatistic() :
24 encoding_successful(false), decoding_successful(false),
25 encode_return_code(0), decode_return_code(0),
26 encode_time_in_us(0), decode_time_in_us(0),
27 frame_number(0), packets_dropped(0), total_packets(0),
kjellander@webrtc.org5b97b122011-12-08 07:42:18 +000028 bit_rate_in_kbps(0), encoded_frame_length_in_bytes(0),
29 frame_type(kDeltaFrame) {
kjellander@webrtc.org35a17562011-10-06 06:44:54 +000030 };
31 bool encoding_successful;
32 bool decoding_successful;
33 int encode_return_code;
34 int decode_return_code;
35 int encode_time_in_us;
36 int decode_time_in_us;
37 int frame_number;
38 // How many packets were discarded of the encoded frame data (if any)
39 int packets_dropped;
40 int total_packets;
41
42 // Current bit rate. Calculated out of the size divided with the time
43 // interval per frame.
44 int bit_rate_in_kbps;
45
46 // Copied from EncodedImage
47 int encoded_frame_length_in_bytes;
48 webrtc::VideoFrameType frame_type;
49};
50
51// Handles statistics from a single video processing run.
52// Contains calculation methods for interesting metrics from these stats.
53class Stats {
54 public:
55 typedef std::vector<FrameStatistic>::iterator FrameStatisticsIterator;
56
57 Stats();
58 virtual ~Stats();
59
60 // Add a new statistic data object.
61 // The frame number must be incrementing and start at zero in order to use
62 // it as an index for the frame_statistics_ vector.
63 // Returns the newly created statistic object.
64 FrameStatistic& NewFrame(int frame_number);
65
66 // Prints a summary of all the statistics that have been gathered during the
67 // processing
68 void PrintSummary();
69
70 std::vector<FrameStatistic> stats_;
71};
72
73} // namespace test
74} // namespace webrtc
75
kjellander@webrtc.org5b97b122011-12-08 07:42:18 +000076#endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_STATS_H_