Files
android/libwvdrmengine/cdm/metrics/src/distribution.cpp
Adam Stone b19f0d106f Fixes widevine metrics proto serialization
Changes to a much more efficient and more reusable protobuf format for
metrics.

Test: Widevine tests, Google Play and MediaDrm CTS test.
Bug: 73724218

Change-Id: I3299051d7a16bcd7758c8f272415ca40e10c1313
2018-03-22 16:36:18 -07:00

32 lines
736 B
C++

// Copyright 2017 Google Inc. All Rights Reserved.
//
// This file contains the definitions for the Distribution class members.
#include "distribution.h"
#include <float.h>
namespace wvcdm {
namespace metrics {
Distribution::Distribution()
: count_(0ULL),
min_(FLT_MAX),
max_(-FLT_MAX),
mean_(0.0),
sum_squared_deviation_(0.0) {}
void Distribution::Record(float value) {
// Using method of provisional means.
float deviation = value - mean_;
mean_ = mean_ + (deviation / ++count_);
sum_squared_deviation_ =
sum_squared_deviation_ + (deviation * (value - mean_));
min_ = min_ < value ? min_ : value;
max_ = max_ > value ? max_ : value;
}
} // namespace metrics
} // namespace wvcdm