From 578c03b02f34ad0d898da82ec71a439cebc56df0 Mon Sep 17 00:00:00 2001 From: Melirius Date: Wed, 20 Nov 2024 21:53:18 +0100 Subject: [PATCH 1/2] Test for the first stream bit --- src/structs/vpx_bool_reader.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/structs/vpx_bool_reader.rs b/src/structs/vpx_bool_reader.rs index d9f5cbe..9732adc 100644 --- a/src/structs/vpx_bool_reader.rs +++ b/src/structs/vpx_bool_reader.rs @@ -27,6 +27,8 @@ use std::io::{Read, Result}; use crate::metrics::{Metrics, ModelComponent}; use crate::structs::branch::Branch; use crate::structs::simple_hash::SimpleHash; +use crate::lepton_error; +use crate::lepton_error::{err_exit_code, ExitCode}; const BITS_IN_BYTE: u32 = 8; const BITS_IN_VALUE: u32 = 64; @@ -43,7 +45,7 @@ pub struct VPXBoolReader { } impl VPXBoolReader { - pub fn new(reader: R) -> Result { + pub fn new(reader: R) -> lepton_error::Result { let mut r = VPXBoolReader { upstream_reader: reader, value: 1 << (BITS_IN_VALUE - 1), // guard bit @@ -53,7 +55,10 @@ impl VPXBoolReader { }; 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); } From 6eece5a4ff6d8487c52a8047d92989146af2fa47 Mon Sep 17 00:00:00 2001 From: Melirius Date: Wed, 20 Nov 2024 22:03:46 +0100 Subject: [PATCH 2/2] Formatting --- src/structs/vpx_bool_reader.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/structs/vpx_bool_reader.rs b/src/structs/vpx_bool_reader.rs index 9732adc..d2aff36 100644 --- a/src/structs/vpx_bool_reader.rs +++ b/src/structs/vpx_bool_reader.rs @@ -24,11 +24,11 @@ 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; -use crate::lepton_error; -use crate::lepton_error::{err_exit_code, ExitCode}; const BITS_IN_BYTE: u32 = 8; const BITS_IN_VALUE: u32 = 64;