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 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #ifndef MODULES_VIDEO_CODING_CODECS_TEST_STATS_H_ |
| 12 | #define 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 | |
Mirko Bonadei | 7120742 | 2017-09-15 13:58:09 +0200 | [diff] [blame^] | 16 | #include "common_types.h" // NOLINT(build/include) |
kjellander@webrtc.org | 35a1756 | 2011-10-06 06:44:54 +0000 | [diff] [blame] | 17 | |
| 18 | namespace webrtc { |
| 19 | namespace test { |
| 20 | |
brandtr | 8935d97 | 2017-09-06 01:53:22 -0700 | [diff] [blame] | 21 | // Statistics for one processed frame. |
kjellander@webrtc.org | 35a1756 | 2011-10-06 06:44:54 +0000 | [diff] [blame] | 22 | struct FrameStatistic { |
brandtr | 8935d97 | 2017-09-06 01:53:22 -0700 | [diff] [blame] | 23 | 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; |
asapersson | 68b91d7 | 2017-06-04 23:43:41 -0700 | [diff] [blame] | 28 | int encode_return_code = 0; |
brandtr | 8935d97 | 2017-09-06 01:53:22 -0700 | [diff] [blame] | 29 | 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; |
asapersson | 68b91d7 | 2017-06-04 23:43:41 -0700 | [diff] [blame] | 37 | int decode_return_code = 0; |
brandtr | 8935d97 | 2017-09-06 01:53:22 -0700 | [diff] [blame] | 38 | bool decoding_successful = false; |
| 39 | int decode_time_us = 0; |
| 40 | int decoded_width = 0; |
| 41 | int decoded_height = 0; |
| 42 | |
| 43 | // Quantization. |
asapersson | 68b91d7 | 2017-06-04 23:43:41 -0700 | [diff] [blame] | 44 | int qp = -1; |
brandtr | 8935d97 | 2017-09-06 01:53:22 -0700 | [diff] [blame] | 45 | |
pbos@webrtc.org | 7f7162a | 2013-07-30 15:18:31 +0000 | [diff] [blame] | 46 | // How many packets were discarded of the encoded frame data (if any). |
asapersson | 68b91d7 | 2017-06-04 23:43:41 -0700 | [diff] [blame] | 47 | int packets_dropped = 0; |
| 48 | size_t total_packets = 0; |
brandtr | 8935d97 | 2017-09-06 01:53:22 -0700 | [diff] [blame] | 49 | size_t manipulated_length = 0; |
kjellander@webrtc.org | 35a1756 | 2011-10-06 06:44:54 +0000 | [diff] [blame] | 50 | }; |
| 51 | |
brandtr | 8935d97 | 2017-09-06 01:53:22 -0700 | [diff] [blame] | 52 | // Statistics for a sequence of processed frames. This class is not thread safe. |
kjellander@webrtc.org | 35a1756 | 2011-10-06 06:44:54 +0000 | [diff] [blame] | 53 | class Stats { |
| 54 | public: |
brandtr | 8935d97 | 2017-09-06 01:53:22 -0700 | [diff] [blame] | 55 | Stats() = default; |
| 56 | ~Stats() = default; |
kjellander@webrtc.org | 35a1756 | 2011-10-06 06:44:54 +0000 | [diff] [blame] | 57 | |
brandtr | 8935d97 | 2017-09-06 01:53:22 -0700 | [diff] [blame] | 58 | // Creates a FrameStatistic for the next frame to be processed. |
| 59 | FrameStatistic* AddFrame(); |
kjellander@webrtc.org | 35a1756 | 2011-10-06 06:44:54 +0000 | [diff] [blame] | 60 | |
brandtr | 8935d97 | 2017-09-06 01:53:22 -0700 | [diff] [blame] | 61 | // Returns the FrameStatistic corresponding to |frame_number|. |
| 62 | FrameStatistic* GetFrame(int frame_number); |
kjellander@webrtc.org | 35a1756 | 2011-10-06 06:44:54 +0000 | [diff] [blame] | 63 | |
brandtr | 8935d97 | 2017-09-06 01:53:22 -0700 | [diff] [blame] | 64 | size_t size() const; |
kjellander@webrtc.org | 35a1756 | 2011-10-06 06:44:54 +0000 | [diff] [blame] | 65 | |
brandtr | 8935d97 | 2017-09-06 01:53:22 -0700 | [diff] [blame] | 66 | // TODO(brandtr): Add output as CSV. |
| 67 | void PrintSummary() const; |
| 68 | |
| 69 | private: |
kjellander@webrtc.org | 35a1756 | 2011-10-06 06:44:54 +0000 | [diff] [blame] | 70 | std::vector<FrameStatistic> stats_; |
| 71 | }; |
| 72 | |
| 73 | } // namespace test |
| 74 | } // namespace webrtc |
| 75 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 76 | #endif // MODULES_VIDEO_CODING_CODECS_TEST_STATS_H_ |