Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test for the first stream bit #117

Merged
merged 2 commits into from
Nov 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading