129 const auto reason =
Evaluate(value);
135 return (std::max)(0., (std::min)(100., pixels / value.
screenPixels * 100.));
160 if (!std::isfinite(value.
seconds))
return false;
163 auto& record =
records[identity];
164 if (record.observations && value.
seconds <= record.last.seconds)
return false;
166 const double delta = value.
seconds - record.last.seconds;
172 if (record.firstVisibleSeconds < 0) record.firstVisibleSeconds = value.
seconds;
173 record.lastVisibleSeconds = value.
seconds;
174 record.peakScreenPercentage = (std::max)(record.peakScreenPercentage, screen);
176 double areaSeconds = 0;
177 if (exposureInterval)
179 const auto& previous = record.last;
180 const double previousScreen =
ScreenPercentage(previous, previous.visiblePixels);
181 areaSeconds = (previousScreen + screen) * .5 * delta;
182 record.measuredSeconds += delta;
183 if (previous.visiblePixels > 0 && value.
visiblePixels > 0) record.visibleSeconds += delta;
184 record.screenPercentageSeconds += areaSeconds;
187 record.aboveMinimumScreenPercentageSeconds += areaSeconds;
188 record.readableScreenPercentageSeconds += (
ScreenPercentage(previous, previous.clearPixels) +
190 if (previous.anglePixels >= 0 && value.
anglePixels >= 0)
191 record.angleScreenPercentageSeconds += (
ScreenPercentage(previous, previous.anglePixels) +
197 record.continuousSeconds = contiguous ? record.continuousSeconds + delta : 0;
198 record.continuousScreenPercentageSeconds = contiguous ? record.continuousScreenPercentageSeconds + areaSeconds : 0;
201 record.eligibleSeconds += delta;
202 record.eligibleScreenPercentageSeconds += areaSeconds;
207 record.qualified =
true;
208 record.qualifiedSeconds += previousStreakQualified ? delta : record.continuousSeconds;
209 record.qualifiedScreenPercentageSeconds += previousStreakQualified ? areaSeconds : record.continuousScreenPercentageSeconds;
212 record.longestSeconds = (std::max)(record.longestSeconds, record.continuousSeconds);
213 record.reason = result;
215 record.exposureOpen = measured;
216 ++record.observations;
223 item.second.continuousSeconds = 0;
224 item.second.continuousScreenPercentageSeconds = 0;
225 item.second.exposureOpen =
false;
226 item.second.reason = reason;
236 item.second.continuousSeconds = 0;
237 item.second.continuousScreenPercentageSeconds = 0;
238 item.second.exposureOpen =
false;
244 std::map<CreativeKey, CreativeSummary>
Summaries()
const
246 std::map<CreativeKey, CreativeSummary> out;
247 for (
const auto& item :
records)
249 const auto& key = item.first;
const auto& record = item.second;
250 auto& summary = out[{key.kind, key.creative, key.creativeHash}];
251 ++summary.observedPlacements;
252 if (record.firstVisibleSeconds >= 0)
254 ++summary.visiblePlacements;
255 if (summary.firstVisibleSeconds < 0 || record.firstVisibleSeconds < summary.firstVisibleSeconds)
256 summary.firstVisibleSeconds = record.firstVisibleSeconds;
257 summary.lastVisibleSeconds = (std::max)(summary.lastVisibleSeconds, record.lastVisibleSeconds);
259 summary.qualifiedPlacements += record.qualified;
260 summary.measuredSeconds += record.measuredSeconds; summary.visibleSeconds += record.visibleSeconds;
261 summary.screenPercentageSeconds += record.screenPercentageSeconds;
262 summary.aboveMinimumScreenPercentageSeconds += record.aboveMinimumScreenPercentageSeconds;
263 summary.readableScreenPercentageSeconds += record.readableScreenPercentageSeconds;
264 summary.angleScreenPercentageSeconds += record.angleScreenPercentageSeconds;
265 summary.eligibleScreenPercentageSeconds += record.eligibleScreenPercentageSeconds;
266 summary.qualifiedScreenPercentageSeconds += record.qualifiedScreenPercentageSeconds;
267 summary.peakScreenPercentage = (std::max)(summary.peakScreenPercentage, record.peakScreenPercentage);
std::map< CreativeKey, CreativeSummary > Summaries() const
void Interrupt(double now, Reason reason)
const std::map< Placement, Record > & Records() const
std::map< Placement, Record > records
bool Observe(const Placement &key, const Observation &value)
bool ExposureMeasured(const Observation &value)
double ScreenPercentage(const Observation &value, double pixels)
Reason Evaluate(const Observation &value)
const char * Name(Reason reason)
typedef void(S_CALLTYPE *SteamAPIWarningMessageHook_t)(int
bool operator<(const CreativeKey &other) const
uint64_t visiblePlacements
double aboveMinimumScreenPercentageSeconds
double lastVisibleSeconds
double firstVisibleSeconds
double screenPercentageSeconds
double qualifiedScreenPercentageSeconds
double eligibleScreenPercentageSeconds
uint64_t qualifiedPlacements
double peakScreenPercentage
double angleScreenPercentageSeconds
double readableScreenPercentageSeconds
uint64_t observedPlacements
double sourceFillFraction
double projectedHeightPixels
std::array< float, 4 > sourceBounds
double animationAlphaFraction
double sourceMeanLuminance
double projectedWidthPixels
double artworkReferencePixels
double animationAnalyzedFraction
double animationMeanLuminance
double artworkVisiblePixels
bool operator<(const Placement &other) const
static constexpr double MinimumScreenFraction
static constexpr double PollSeconds
static constexpr float MinimumContrastRetention
static constexpr double MinimumVisibleFraction
static constexpr double MinimumMeasurementScreenFraction
static constexpr unsigned Version
static constexpr double MinimumContinuousSeconds
static constexpr float MaximumCloudOpacity
static constexpr double MaximumObservationGap
static constexpr double MaximumAngleDegrees
static constexpr float MinimumContrast
double qualifiedScreenPercentageSeconds
double peakScreenPercentage
double firstVisibleSeconds
double aboveMinimumScreenPercentageSeconds
double lastVisibleSeconds
double continuousScreenPercentageSeconds
double eligibleScreenPercentageSeconds
double angleScreenPercentageSeconds
double readableScreenPercentageSeconds
double screenPercentageSeconds