decode method
void
decode()
Implementation
void decode() {
final componentsLength = components.length;
JpegComponent? component;
void Function(JpegComponent, List<int>) decodeFn;
if (progressive!) {
if (spectralStart == 0) {
decodeFn = successivePrev == 0 ? _decodeDCFirst : _decodeDCSuccessive;
} else {
decodeFn = successivePrev == 0 ? _decodeACFirst : _decodeACSuccessive;
}
} else {
decodeFn = _decodeBaseline;
}
var mcu = 0;
int? mcuExpected;
if (componentsLength == 1) {
mcuExpected =
(components[0].blocksPerLine * components[0].blocksPerColumn);
} else {
mcuExpected = (mcusPerLine * frame.mcusPerColumn);
}
if (resetInterval == null || resetInterval == 0) {
resetInterval = mcuExpected;
}
int h, v;
while (mcu < mcuExpected) {
// reset interval stuff
for (var i = 0; i < componentsLength; i++) {
components[i].pred = 0;
}
eobrun = 0;
if (componentsLength == 1) {
component = components[0];
for (var n = 0; n < resetInterval!; n++) {
_decodeBlock(component, decodeFn, mcu);
mcu++;
}
} else {
for (var n = 0; n < resetInterval!; n++) {
for (var i = 0; i < componentsLength; i++) {
component = components[i];
h = component.hSamples;
v = component.vSamples;
for (var j = 0; j < v; j++) {
for (var k = 0; k < h; k++) {
_decodeMcu(component, decodeFn, mcu, j, k);
}
}
}
mcu++;
}
}
// find marker
bitsCount = 0;
final m1 = input[0];
final m2 = input[1];
if (m1 == 0xff) {
if (m2 >= Jpeg.M_RST0 && m2 <= Jpeg.M_RST7) {
input.offset += 2;
} else {
break;
}
}
}
}