File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -83,7 +83,10 @@ impl<'a> JpegDecoder<'a> {
8383
8484 Ok ( JFIF {
8585 quantization_tables,
86- huffman_tables,
86+ huffman_tables : {
87+ ensure ! ( huffman_tables. len( ) == 4 ) ;
88+ huffman_tables
89+ } ,
8790 start_of_frame : start_of_frame. ok_or_else ( || anyhow ! ( "expected start of frame" ) ) ?,
8891 start_of_scan : start_of_scan. ok_or_else ( || anyhow ! ( "expected start of scan" ) ) ?,
8992 image_data : image_data. ok_or_else ( || anyhow ! ( "expected image data" ) ) ?,
@@ -158,7 +161,17 @@ impl<'a> JpegDecoder<'a> {
158161
159162 let huffman_table = HuffmanTable {
160163 flag,
161- element_range : Range {
164+ code_lengths : {
165+ let code_lengths = Range {
166+ start : self . cursor ,
167+ end : self . cursor + 16 ,
168+ } ;
169+
170+ self . cursor += 16 ;
171+
172+ code_lengths
173+ } ,
174+ symbols : Range {
162175 start : self . cursor ,
163176 end : offset + length,
164177 } ,
Original file line number Diff line number Diff line change @@ -41,7 +41,8 @@ impl QuantizationTable {
4141#[ derive( Debug ) ]
4242pub struct HuffmanTable {
4343 pub flag : u8 ,
44- pub element_range : Range < usize > ,
44+ pub code_lengths : Range < usize > ,
45+ pub symbols : Range < usize > ,
4546}
4647
4748#[ derive( Debug ) ]
You can’t perform that action at this time.
0 commit comments