Skip to content
This repository has been archived by the owner on Mar 3, 2023. It is now read-only.

Commit

Permalink
mcu_prog: Check for existence of decode tables before proceeding.
Browse files Browse the repository at this point in the history
Should make  #8 (comment) decode gracefully
  • Loading branch information
etemesi254 committed Aug 29, 2022
1 parent 4fa8aa3 commit f5111a7
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/mcu_prog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ use crate::marker::Marker;
use crate::misc::read_byte;
use crate::worker::post_process_prog;
use crate::{ColorSpace, Decoder};
use crate::decoder::MAX_COMPONENTS;

impl Decoder
{
Expand Down Expand Up @@ -260,6 +261,7 @@ impl Decoder
self.check_component_dimensions()?;
stream.reset();
self.components.iter_mut().for_each(|x| x.dc_pred = 0);
self.check_tables()?;

if self.num_scans == 1
{
Expand Down Expand Up @@ -293,6 +295,7 @@ impl Decoder

let mut j = 0;


while i < mcu_height
{
while j < mcu_width
Expand All @@ -309,9 +312,9 @@ impl Decoder

if self.spec_start == 0
{
let pos = self.components[k].dc_huff_table;

let dc_table = self.dc_huffman_tables.get(pos).unwrap().as_ref().unwrap();
let pos = self.components[k].dc_huff_table & (MAX_COMPONENTS-1);
let dc_table =self.dc_huffman_tables[pos]
.as_ref().unwrap();

let dc_pred = &mut self.components[k].dc_pred;
if self.succ_high == 0
Expand Down

0 comments on commit f5111a7

Please sign in to comment.