/* * Copyright (c) 2021 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 "logging/rtc_event_log/events/rtc_event_field_extraction.h" #include <algorithm> #include <cstdint> #include <limits> #include "rtc_base/checks.h" namespace webrtc_event_logging { // The bitwidth required to encode values in the range // [0, `max_pos_magnitude`] using an unsigned representation. uint8_t UnsignedBitWidth(uint64_t max_magnitude) { … } // The bitwidth required to encode signed values in the range // [-`max_neg_magnitude`, `max_pos_magnitude`] using a signed // 2-complement representation. uint8_t SignedBitWidth(uint64_t max_pos_magnitude, uint64_t max_neg_magnitude) { … } // Return the maximum integer of a given bit width. uint64_t MaxUnsignedValueOfBitWidth(uint64_t bit_width) { … } // Computes the delta between `previous` and `current`, under the assumption // that `bit_mask` is the largest value before wrap-around occurs. The bitmask // must be of the form 2^x-1. (We use the wrap-around to more efficiently // compress counters that wrap around at different bit widths than the // backing C++ data type.) uint64_t UnsignedDelta(uint64_t previous, uint64_t current, uint64_t bit_mask) { … } } // namespace webrtc_event_logging