tag | 471fd267de38ed5890d344c4b6f7332e26c6e9ef | |
---|---|---|
tagger | The Android Open Source Project <initial-contribution@android.com> | Mon Sep 23 16:20:31 2024 -0700 |
object | f23428eee6e00fc1fc49704d3f4187be2f7926fb |
frc_350822020 (12368934,com.google.android.go.media.swcodec,com.google.android.media.swcodec)
commit | f23428eee6e00fc1fc49704d3f4187be2f7926fb | [log] [tgz] |
---|---|---|
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | Wed May 22 16:57:52 2024 +0000 |
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | Wed May 22 16:57:52 2024 +0000 |
tree | f6993faaf4c4cafa82ec54d1ca60d1999f0895db | |
parent | 99abf85abbeefeb1aaa2e47e383c1675917201a8 [diff] | |
parent | 8d83e45eb564772f9cd03b5be56ca495cf0eb82d [diff] |
Snap for 11873904 from 8d83e45eb564772f9cd03b5be56ca495cf0eb82d to aml-frc-release Change-Id: Ibab09aee5bd0bc90f067d25340f55ebe54a4edbc
BitReader is a helper type to extract strings of bits from a slice of bytes.
Here is how you read first a single bit, then three bits and finally four bits from a byte buffer:
use bitreader::BitReader; let slice_of_u8 = &[0b1000_1111]; let mut reader = BitReader::new(slice_of_u8); // You obviously should use try! or some other error handling mechanism here let a_single_bit = reader.read_u8(1).unwrap(); // 1 let more_bits = reader.read_u8(3).unwrap(); // 0 let last_bits_of_byte = reader.read_u8(4).unwrap(); // 0b1111
You can naturally read bits from longer buffer of data than just a single byte.
As you read bits, the internal cursor of BitReader moves on along the stream of bits. Big endian format is assumed when reading the multi-byte values. BitReader supports reading maximum of 64 bits at a time (with read_u64).
Licensed under the Apache License, Version 2.0 or the MIT license, at your option.