Skip to content

Commit

Permalink
Test for the first stream bit (#117)
Browse files Browse the repository at this point in the history
* Test for the first stream bit

* Formatting
  • Loading branch information
Melirius authored Nov 21, 2024
1 parent 6c065e0 commit e0559a2
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/structs/vpx_bool_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS”

use std::io::{Read, Result};

use crate::lepton_error;
use crate::lepton_error::{err_exit_code, ExitCode};
use crate::metrics::{Metrics, ModelComponent};
use crate::structs::branch::Branch;
use crate::structs::simple_hash::SimpleHash;
Expand All @@ -43,7 +45,7 @@ pub struct VPXBoolReader<R> {
}

impl<R: Read> VPXBoolReader<R> {
pub fn new(reader: R) -> Result<Self> {
pub fn new(reader: R) -> lepton_error::Result<Self> {
let mut r = VPXBoolReader {
upstream_reader: reader,
value: 1 << (BITS_IN_VALUE - 1), // guard bit
Expand All @@ -53,7 +55,10 @@ impl<R: Read> VPXBoolReader<R> {
};

let mut dummy_branch = Branch::new();
r.get_bit(&mut dummy_branch, ModelComponent::Dummy)?; // marker bit
let bit = r.get_bit(&mut dummy_branch, ModelComponent::Dummy)?; // marker false bit
if bit {
return err_exit_code(ExitCode::StreamInconsistent, "StreamInconsistent");
}

return Ok(r);
}
Expand Down

0 comments on commit e0559a2

Please sign in to comment.