File: stats.h

package info (click to toggle)
firefox-esr 91.13.0esr-1~deb11u1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 3,375,652 kB
  • sloc: cpp: 5,762,054; javascript: 5,481,714; ansic: 3,121,191; python: 851,492; asm: 331,172; xml: 178,949; java: 155,554; sh: 63,704; makefile: 20,127; perl: 12,825; yacc: 4,583; cs: 3,846; objc: 3,026; lex: 1,720; exp: 762; pascal: 635; php: 436; lisp: 260; awk: 231; ruby: 103; sed: 53; sql: 46; csh: 45
file content (83 lines) | stat: -rw-r--r-- 2,154 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
 *  Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree. An additional intellectual property rights grant can be found
 *  in the file PATENTS.  All contributing project authors may
 *  be found in the AUTHORS file in the root of the source tree.
 */

#ifndef MODULES_VIDEO_CODING_CODECS_TEST_STATS_H_
#define MODULES_VIDEO_CODING_CODECS_TEST_STATS_H_

#include <vector>

#include "common_types.h"  // NOLINT(build/include)

namespace webrtc {
namespace test {

// Statistics for one processed frame.
struct FrameStatistic {
  explicit FrameStatistic(int frame_number) : frame_number(frame_number) {}
  const int frame_number = 0;

  // Encoding.
  int64_t encode_start_ns = 0;
  int encode_return_code = 0;
  bool encoding_successful = false;
  int encode_time_us = 0;
  int bitrate_kbps = 0;
  size_t encoded_frame_size_bytes = 0;
  webrtc::FrameType frame_type = kVideoFrameDelta;

  // H264 specific.
  rtc::Optional<size_t> max_nalu_length;

  // Decoding.
  int64_t decode_start_ns = 0;
  int decode_return_code = 0;
  bool decoding_successful = false;
  int decode_time_us = 0;
  int decoded_width = 0;
  int decoded_height = 0;

  // Quantization.
  int qp = -1;

  // How many packets were discarded of the encoded frame data (if any).
  int packets_dropped = 0;
  size_t total_packets = 0;
  size_t manipulated_length = 0;

  // Quality.
  float psnr = 0.0;
  float ssim = 0.0;
};

// Statistics for a sequence of processed frames. This class is not thread safe.
class Stats {
 public:
  Stats() = default;
  ~Stats() = default;

  // Creates a FrameStatistic for the next frame to be processed.
  FrameStatistic* AddFrame();

  // Returns the FrameStatistic corresponding to |frame_number|.
  FrameStatistic* GetFrame(int frame_number);

  size_t size() const;

  // TODO(brandtr): Add output as CSV.
  void PrintSummary() const;

 private:
  std::vector<FrameStatistic> stats_;
};

}  // namespace test
}  // namespace webrtc

#endif  // MODULES_VIDEO_CODING_CODECS_TEST_STATS_H_