(bs: &mut BitWriter, dod: i64)
| 223 | // --------------------------------------------------------------------------- |
| 224 | |
| 225 | fn encode_dod(bs: &mut BitWriter, dod: i64) { |
| 226 | if dod == 0 { |
| 227 | bs.write_bit(false); |
| 228 | } else if (-64..=63).contains(&dod) { |
| 229 | bs.write_bits(0b10, 2); |
| 230 | bs.write_bits((dod as u64) & 0x7F, 7); |
| 231 | } else if (-256..=255).contains(&dod) { |
| 232 | bs.write_bits(0b110, 3); |
| 233 | bs.write_bits((dod as u64) & 0x1FF, 9); |
| 234 | } else if (-2048..=2047).contains(&dod) { |
| 235 | bs.write_bits(0b1110, 4); |
| 236 | bs.write_bits((dod as u64) & 0xFFF, 12); |
| 237 | } else { |
| 238 | bs.write_bits(0b1111, 4); |
| 239 | bs.write_bits(dod as u64, 64); |
| 240 | } |
| 241 | } |
| 242 | |
| 243 | fn decode_dod(reader: &mut BitReader<'_>) -> Result<i64, CodecError> { |
| 244 | let bit = reader.read_bit()?; |
no test coverage detected