+ } else {
+ let mut bands_decoded = [[false; 10]; 3];
+ let mut num_decoded = 0;
+
+ let num_bands = [ pic_hdr.luma_bands, pic_hdr.chroma_bands, pic_hdr.chroma_bands ];
+
+ for plane in 0..3 {
+ for band in 0..num_bands[plane] {
+ if br.peek(8) == 0x01 { // skipped scalable bands
+ br.skip(8)?;
+ continue;
+ }
+ self.decode_band(&pic_hdr, dec, br, plane, band)?;
+ bands_decoded[plane][band] = true;
+ num_decoded += 1;
+ }
+ }
+ if (num_decoded < num_bands[0] + num_bands[1] + num_bands[2]) && (br.left() > 0) {
+ validate!(br.read(8)? == 0x00);
+ while br.peek(8) == 0x00 {
+ if br.skip(8).is_err() { // happens at the end of data
+ break;
+ }
+ }
+ validate!((br.tell() & 31) == 0);
+
+ for plane in 0..3 {
+ for band in 0..num_bands[plane] {
+ if bands_decoded[plane][band] || br.left() == 0 {
+ continue;
+ }
+ self.decode_band(&pic_hdr, dec, br, plane, band)?;
+ bands_decoded[plane][band] = true;
+ num_decoded += 1;
+ }
+ }
+ }
+