xref: /aosp_15_r20/external/webrtc/test/scenario/performance_stats.cc (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1*d9f75844SAndroid Build Coastguard Worker /*
2*d9f75844SAndroid Build Coastguard Worker  *  Copyright 2019 The WebRTC project authors. All Rights Reserved.
3*d9f75844SAndroid Build Coastguard Worker  *
4*d9f75844SAndroid Build Coastguard Worker  *  Use of this source code is governed by a BSD-style license
5*d9f75844SAndroid Build Coastguard Worker  *  that can be found in the LICENSE file in the root of the source
6*d9f75844SAndroid Build Coastguard Worker  *  tree. An additional intellectual property rights grant can be found
7*d9f75844SAndroid Build Coastguard Worker  *  in the file PATENTS.  All contributing project authors may
8*d9f75844SAndroid Build Coastguard Worker  *  be found in the AUTHORS file in the root of the source tree.
9*d9f75844SAndroid Build Coastguard Worker  */
10*d9f75844SAndroid Build Coastguard Worker #include "test/scenario/performance_stats.h"
11*d9f75844SAndroid Build Coastguard Worker 
12*d9f75844SAndroid Build Coastguard Worker #include <algorithm>
13*d9f75844SAndroid Build Coastguard Worker 
14*d9f75844SAndroid Build Coastguard Worker namespace webrtc {
15*d9f75844SAndroid Build Coastguard Worker namespace test {
AddFrameInfo(const VideoFrameBuffer & frame,Timestamp at_time)16*d9f75844SAndroid Build Coastguard Worker void VideoFramesStats::AddFrameInfo(const VideoFrameBuffer& frame,
17*d9f75844SAndroid Build Coastguard Worker                                     Timestamp at_time) {
18*d9f75844SAndroid Build Coastguard Worker   ++count;
19*d9f75844SAndroid Build Coastguard Worker   RTC_DCHECK(at_time.IsFinite());
20*d9f75844SAndroid Build Coastguard Worker   pixels.AddSample(frame.width() * frame.height());
21*d9f75844SAndroid Build Coastguard Worker   resolution.AddSample(std::max(frame.width(), frame.height()));
22*d9f75844SAndroid Build Coastguard Worker   frames.AddEvent(at_time);
23*d9f75844SAndroid Build Coastguard Worker }
24*d9f75844SAndroid Build Coastguard Worker 
AddStats(const VideoFramesStats & other)25*d9f75844SAndroid Build Coastguard Worker void VideoFramesStats::AddStats(const VideoFramesStats& other) {
26*d9f75844SAndroid Build Coastguard Worker   count += other.count;
27*d9f75844SAndroid Build Coastguard Worker   pixels.AddSamples(other.pixels);
28*d9f75844SAndroid Build Coastguard Worker   resolution.AddSamples(other.resolution);
29*d9f75844SAndroid Build Coastguard Worker   frames.AddEvents(other.frames);
30*d9f75844SAndroid Build Coastguard Worker }
31*d9f75844SAndroid Build Coastguard Worker 
AddStats(const VideoQualityStats & other)32*d9f75844SAndroid Build Coastguard Worker void VideoQualityStats::AddStats(const VideoQualityStats& other) {
33*d9f75844SAndroid Build Coastguard Worker   capture.AddStats(other.capture);
34*d9f75844SAndroid Build Coastguard Worker   render.AddStats(other.render);
35*d9f75844SAndroid Build Coastguard Worker   lost_count += other.lost_count;
36*d9f75844SAndroid Build Coastguard Worker   freeze_count += other.freeze_count;
37*d9f75844SAndroid Build Coastguard Worker   capture_to_decoded_delay.AddSamples(other.capture_to_decoded_delay);
38*d9f75844SAndroid Build Coastguard Worker   end_to_end_delay.AddSamples(other.end_to_end_delay);
39*d9f75844SAndroid Build Coastguard Worker   psnr.AddSamples(other.psnr);
40*d9f75844SAndroid Build Coastguard Worker   psnr_with_freeze.AddSamples(other.psnr_with_freeze);
41*d9f75844SAndroid Build Coastguard Worker   skipped_between_rendered.AddSamples(other.skipped_between_rendered);
42*d9f75844SAndroid Build Coastguard Worker   freeze_duration.AddSamples(other.freeze_duration);
43*d9f75844SAndroid Build Coastguard Worker   time_between_freezes.AddSamples(other.time_between_freezes);
44*d9f75844SAndroid Build Coastguard Worker }
45*d9f75844SAndroid Build Coastguard Worker 
46*d9f75844SAndroid Build Coastguard Worker }  // namespace test
47*d9f75844SAndroid Build Coastguard Worker }  // namespace webrtc
48