@@ -410,6 +410,46 @@ impl<R: Read> Decoder<R> {
410
410
}
411
411
412
412
let frame = self . frame . as_ref ( ) . unwrap ( ) ;
413
+
414
+ // If we're decoding a progressive jpeg and a component is unfinished, render what we've got
415
+ if frame. coding_process == CodingProcess :: DctProgressive && self . coefficients . len ( ) == frame. components . len ( ) {
416
+ for ( i, component) in frame. components . iter ( ) . enumerate ( ) {
417
+ // Only dealing with unfinished components
418
+ if self . coefficients_finished [ i] == !0 {
419
+ continue ;
420
+ }
421
+
422
+ let quantization_table = match self . quantization_tables [ component. quantization_table_index ] . clone ( ) {
423
+ Some ( quantization_table) => quantization_table,
424
+ None => continue ,
425
+ } ;
426
+
427
+ // Get the worker prepared
428
+ if worker. is_none ( ) {
429
+ worker = Some ( PlatformWorker :: new ( ) ?) ;
430
+ }
431
+ let worker = worker. as_mut ( ) . unwrap ( ) ;
432
+ let row_data = RowData {
433
+ index : i,
434
+ component : component. clone ( ) ,
435
+ quantization_table,
436
+ } ;
437
+ worker. start ( row_data) ?;
438
+
439
+ // Send the rows over to the worker and collect the result
440
+ let coefficients_per_mcu_row = usize:: from ( component. block_size . width ) * usize:: from ( component. vertical_sampling_factor ) * 64 ;
441
+ for mcu_y in 0 ..frame. mcu_size . height {
442
+ let row_coefficients = {
443
+ let offset = usize:: from ( mcu_y) * coefficients_per_mcu_row;
444
+ self . coefficients [ i] [ offset .. offset + coefficients_per_mcu_row] . to_vec ( )
445
+ } ;
446
+
447
+ worker. append_row ( ( i, row_coefficients) ) ?;
448
+ }
449
+ planes[ i] = worker. get_result ( i) ?;
450
+ }
451
+ }
452
+
413
453
compute_image ( & frame. components , planes, frame. output_size , self . is_jfif , self . color_transform )
414
454
}
415
455
0 commit comments