use crate::consts::{
CONST_N141_IS_511, CONST_N142_IS_15, CONST_N145_IS_19, CONST_N147_IS_5, CONST_N540_IS_5,
};
use crate::expand::{RExpandData, Result};
use crate::support::BitRead;
use std::io::Write;
impl<R: BitRead, W: Write> RExpandData<R, W> {
pub fn get_next_item(&mut self) -> Result<u16> {
if self.items_until_next_header == 0 {
self.items_until_next_header = self.get_bits(16)? as usize;
self.fn253(
cast!(CONST_N145_IS_19 as i16),
cast!(CONST_N147_IS_5 as i16),
3,
)?;
self.fn255()?;
self.fn253(
cast!(CONST_N142_IS_15 as i16),
cast!(CONST_N540_IS_5 as i16),
-1,
)?;
}
self.items_until_next_header -= 1;
let mut run_length276 = self.dat_arr240[(self.bits182 >> 4) as usize];
if cast!(run_length276 as usize) >= CONST_N141_IS_511 {
let mut var283 = 1_u16 << 3;
loop {
if 0 != self.bits182 & var283 {
run_length276 = self.dat_arr190[cast!(run_length276 as usize)]
} else {
run_length276 = self.dat_arr189[cast!(run_length276 as usize)]
}
var283 >>= 1;
if (cast!(run_length276 as usize)) < CONST_N141_IS_511 {
break;
}
}
}
let bits = i16::from(self.dat_arr180[cast!(run_length276 as usize)]);
self.read_bits(bits)?;
Ok(run_length276)
}
}