Skip to content

Commit

Permalink
Add missing emit_eobrun
Browse files Browse the repository at this point in the history
  • Loading branch information
tirr-c committed Nov 24, 2024
1 parent 684129f commit 6b67b8d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions crates/jxl-jbr/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ impl JpegBitstreamData {

#[derive(Debug)]
pub struct JpegBitstreamHeader {
#[allow(unused)]
is_gray: bool,
markers: Vec<u8>,
app_markers: Vec<AppMarker>,
Expand Down Expand Up @@ -1142,6 +1141,7 @@ impl JpegBitstreamReconstructor<'_, '_> {

let mut state = ScanState::new(comps.len());
let mut block_idx = 0u32;
let mut last_ac_table = None;
for y8 in 0..h8 {
for x8 in 0..w8 {
let mcu_idx = x8 + w8 * y8;
Expand All @@ -1152,7 +1152,6 @@ impl JpegBitstreamReconstructor<'_, '_> {
let hf_coeff = self.parsed.pass_groups[group_idx as usize].each_ref().map(|g| g.as_subgrid());
let lf_quant = &self.parsed.lf_groups[lf_group_idx as usize].lf_coeff.as_ref().unwrap().lf_quant.image().unwrap().image_channels();

let mut last_ac_table = None;
for ((cidx, c), (&hs, &vs)) in comps.iter().enumerate().zip(std::iter::zip(&hsamples, &vsamples)) {
let dc_table = self
.dc_tables[c.dc_tbl_idx as usize]
Expand Down Expand Up @@ -1291,6 +1290,7 @@ impl JpegBitstreamReconstructor<'_, '_> {
}
}

state.emit_eobrun(last_ac_table.unwrap());
state.flush_bit_writer(self.padding_bitstream.as_mut(), &mut writer)?;

Ok(())
Expand All @@ -1309,6 +1309,7 @@ impl JpegBitstreamReconstructor<'_, '_> {

let mut state = ScanState::new(comps.len());
let mut block_idx = 0u32;
let mut last_ac_table = None;
for y8 in 0..h8 {
for x8 in 0..w8 {
let mcu_idx = x8 + w8 * y8;
Expand All @@ -1319,7 +1320,6 @@ impl JpegBitstreamReconstructor<'_, '_> {
let hf_coeff = self.parsed.pass_groups[group_idx as usize].each_ref().map(|g| g.as_subgrid());
let lf_quant = &self.parsed.lf_groups[lf_group_idx as usize].lf_coeff.as_ref().unwrap().lf_quant.image().unwrap().image_channels();

let mut last_ac_table = None;
for (c, (&hs, &vs)) in comps.iter().zip(std::iter::zip(&hsamples, &vsamples)) {
let ac_table = self
.ac_tables[c.ac_tbl_idx as usize]
Expand Down Expand Up @@ -1462,6 +1462,7 @@ impl JpegBitstreamReconstructor<'_, '_> {
}
}

state.emit_eobrun(last_ac_table.unwrap());
state.flush_bit_writer(self.padding_bitstream.as_mut(), &mut writer)?;

Ok(())
Expand Down

0 comments on commit 6b67b8d

Please sign in to comment.