std/jpeg: decode progressive JPEGs

"script/confirm-matches-djpeg.sh test/data/*.jpeg" is now all matches.
This commit is contained in:
Nigel Tao committed 2023-06-01 12:16:14 +10:00
1 parent 1cd3604351
commit d7ddc153ba
8 files changed
+1903 -227

No files matched your search

+14 -6
View File
@@ -12,12 +12,15 @@
// See the License for the specific language governing permissions and
// limitations under the License.
pri func decoder.decode_mcu!() base.u32 {
pri func decoder.decode_mcu!() base.u32,
choosy,
{
var ret : base.u32
var bits : base.u64
var n_bits : base.u32
var csel : base.u8[..= 3]
var csel : base.u8[..= 3]
var r : base.io_reader
var pos : base.u32
@@ -45,7 +48,8 @@ pri func decoder.decode_mcu!() base.u32 {
var ac_rrrr : base.u32[..= 15]
var ac_ssss : base.u32[..= 15]
var z : base.u32[..= 78] // 78 = 63 + 15.
var z : base.u32[..= 78] // 78 = 63 + 15.
bits = this.bitstream_bits
n_bits = this.bitstream_n_bits
@@ -114,7 +118,8 @@ pri func decoder.decode_mcu!() base.u32 {
n_bits ~mod-= dc_symbol
csel = this.scan_comps_cselector[this.mcu_blocks_sselector[this.mcu_current_block]]
this.mcu_previous_dc_values[csel] ~mod+= (dc_value & 0xFFFF) as base.u16
this.mcu_blocks[this.mcu_current_block][0] = this.mcu_previous_dc_values[csel]
this.mcu_blocks[this.mcu_current_block][0] =
this.mcu_previous_dc_values[csel]
this.mcu_zig_index = 1
break.dc_component
@@ -178,12 +183,15 @@ pri func decoder.decode_mcu!() base.u32 {
bits ~mod<<= ac_ssss
n_bits ~mod-= ac_ssss
z = this.mcu_zig_index + ac_rrrr
this.mcu_blocks[this.mcu_current_block][UNZIG[z]] = (ac_value & 0xFFFF) as base.u16
this.mcu_blocks[this.mcu_current_block][UNZIG[z]] =
(ac_value & 0xFFFF) as base.u16
if (z + 1) > 63 {
break.ac_components
}
this.mcu_zig_index = z + 1
} else if (ac_rrrr < 15) or ((this.mcu_zig_index + 16) > 63) {
} else if ac_rrrr < 15 {
break.ac_components
} else if (this.mcu_zig_index + 16) > 63 {
break.ac_components
} else {
this.mcu_zig_index = this.mcu_zig_index + 16