webrtc/test/statistics.cc
Sergey Silkin 3be2a55e7f Reland "Updated analysis in videoprocessor."
This is a reland of 1880c7162b
Original change's description:
> Updated analysis in videoprocessor.
>
> - Run analysis after all frames are processed. Before part of it was
> done at bitrate change points;
> - Analysis is done for whole stream as well as for each rate update
> interval;
> - Changed units from number of frames to time units for some metrics
> and thresholds. E.g. 'num frames to hit tagret bitrate' is changed to
> 'time to reach target bitrate, sec';
> - Changed data type of FrameStatistic::max_nalu_length (renamed to
> max_nalu_size_bytes) from rtc::Optional to size_t. There it no need to
> use such advanced data type in such low level data structure.
>
> Bug: webrtc:8524
> Change-Id: Ic9f6eab5b15ee12a80324b1f9c101de1bf3c702f
> Reviewed-on: https://webrtc-review.googlesource.com/31901
> Commit-Queue: Sergey Silkin <ssilkin@webrtc.org>
> Reviewed-by: Stefan Holmer <stefan@webrtc.org>
> Reviewed-by: Åsa Persson <asapersson@webrtc.org>
> Reviewed-by: Rasmus Brandt <brandtr@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#21653}

TBR=brandtr@webrtc.org, stefan@webrtc.org

Bug: webrtc:8524
Change-Id: Ie0ad7790689422ffa61da294967fc492a13b75ae
Reviewed-on: https://webrtc-review.googlesource.com/40202
Commit-Queue: Sergey Silkin <ssilkin@webrtc.org>
Reviewed-by: Sergey Silkin <ssilkin@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#21668}
2018-01-18 08:37:27 +00:00

58 lines
1.3 KiB
C++

/*
* Copyright (c) 2013 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.
*/
#include "test/statistics.h"
#include <math.h>
#include <algorithm>
namespace webrtc {
namespace test {
Statistics::Statistics()
: sum_(0.0),
sum_squared_(0.0),
max_(std::numeric_limits<double>::min()),
min_(std::numeric_limits<double>::max()),
count_(0) {}
void Statistics::AddSample(double sample) {
sum_ += sample;
sum_squared_ += sample * sample;
max_ = std::max(max_, sample);
min_ = std::min(min_, sample);
++count_;
}
double Statistics::Max() const {
return max_;
}
double Statistics::Mean() const {
if (count_ == 0)
return 0.0;
return sum_ / count_;
}
double Statistics::Min() const {
return min_;
}
double Statistics::Variance() const {
if (count_ == 0)
return 0.0;
return sum_squared_ / count_ - Mean() * Mean();
}
double Statistics::StandardDeviation() const {
return sqrt(Variance());
}
} // namespace test
} // namespace webrtc