kjellander@webrtc.org | 35a1756 | 2011-10-06 06:44:54 +0000 | [diff] [blame] | 1 | /* |
| 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.org | 5b97b12 | 2011-12-08 07:42:18 +0000 | [diff] [blame] | 10 | |
| 11 | #ifndef WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_STATS_H_ |
| 12 | #define WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_STATS_H_ |
kjellander@webrtc.org | 35a1756 | 2011-10-06 06:44:54 +0000 | [diff] [blame] | 13 | |
| 14 | #include <vector> |
| 15 | |
pbos@webrtc.org | a440732 | 2013-07-16 12:32:05 +0000 | [diff] [blame] | 16 | #include "webrtc/common_video/interface/video_image.h" |
kjellander@webrtc.org | 35a1756 | 2011-10-06 06:44:54 +0000 | [diff] [blame] | 17 | |
| 18 | namespace webrtc { |
| 19 | namespace test { |
| 20 | |
| 21 | // Contains statistics of a single frame that has been processed. |
| 22 | struct FrameStatistic { |
pbos@webrtc.org | 7f7162a | 2013-07-30 15:18:31 +0000 | [diff] [blame] | 23 | FrameStatistic(); |
| 24 | |
kjellander@webrtc.org | 35a1756 | 2011-10-06 06:44:54 +0000 | [diff] [blame] | 25 | 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; |
| 31 | int frame_number; |
pbos@webrtc.org | 7f7162a | 2013-07-30 15:18:31 +0000 | [diff] [blame] | 32 | // How many packets were discarded of the encoded frame data (if any). |
kjellander@webrtc.org | 35a1756 | 2011-10-06 06:44:54 +0000 | [diff] [blame] | 33 | int packets_dropped; |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 34 | size_t total_packets; |
kjellander@webrtc.org | 35a1756 | 2011-10-06 06:44:54 +0000 | [diff] [blame] | 35 | |
| 36 | // Current bit rate. Calculated out of the size divided with the time |
| 37 | // interval per frame. |
| 38 | int bit_rate_in_kbps; |
| 39 | |
| 40 | // Copied from EncodedImage |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 41 | size_t encoded_frame_length_in_bytes; |
kjellander@webrtc.org | 35a1756 | 2011-10-06 06:44:54 +0000 | [diff] [blame] | 42 | webrtc::VideoFrameType frame_type; |
| 43 | }; |
| 44 | |
| 45 | // Handles statistics from a single video processing run. |
| 46 | // Contains calculation methods for interesting metrics from these stats. |
| 47 | class Stats { |
| 48 | public: |
| 49 | typedef std::vector<FrameStatistic>::iterator FrameStatisticsIterator; |
| 50 | |
| 51 | Stats(); |
| 52 | virtual ~Stats(); |
| 53 | |
| 54 | // Add a new statistic data object. |
| 55 | // The frame number must be incrementing and start at zero in order to use |
| 56 | // it as an index for the frame_statistics_ vector. |
| 57 | // Returns the newly created statistic object. |
| 58 | FrameStatistic& NewFrame(int frame_number); |
| 59 | |
| 60 | // Prints a summary of all the statistics that have been gathered during the |
| 61 | // processing |
| 62 | void PrintSummary(); |
| 63 | |
| 64 | std::vector<FrameStatistic> stats_; |
| 65 | }; |
| 66 | |
| 67 | } // namespace test |
| 68 | } // namespace webrtc |
| 69 | |
kjellander@webrtc.org | 5b97b12 | 2011-12-08 07:42:18 +0000 | [diff] [blame] | 70 | #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_STATS_H_ |