leb128.h (1073B)
1 /* 2 * Copyright (c) 2023 The WebRTC project authors. All Rights Reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #ifndef MODULES_RTP_RTCP_SOURCE_LEB128_H_ 12 #define MODULES_RTP_RTCP_SOURCE_LEB128_H_ 13 14 #include <cstdint> 15 16 namespace webrtc { 17 18 // Returns number of bytes needed to store `value` in leb128 format. 19 int Leb128Size(uint64_t value); 20 21 // Reads leb128 encoded value and advance read_at by number of bytes consumed. 22 // Sets read_at to nullptr on error. 23 uint64_t ReadLeb128(const uint8_t*& read_at, const uint8_t* end); 24 25 // Encodes `value` in leb128 format. Assumes buffer has size of at least 26 // Leb128Size(value). Returns number of bytes consumed. 27 int WriteLeb128(uint64_t value, uint8_t* buffer); 28 29 } // namespace webrtc 30 31 #endif // MODULES_RTP_RTCP_SOURCE_LEB128_H_