std/jpeg: remove components_{w,h}_in_blocks fields

This commit is contained in:
Nigel Tao committed 2023-05-17 22:10:42 +10:00
1 parent 917aeb1748
commit de5dc68b40
2 files changed
+5 -62

No files matched your search

+2 -28
View File
@@ -8809,8 +8809,6 @@ struct wuffs_jpeg__decoder__struct {
uint8_t f_components_h[4];
uint8_t f_components_v[4];
uint8_t f_components_tq[4];
uint32_t f_components_width_in_blocks[4];
uint32_t f_components_height_in_blocks[4];
uint32_t f_components_workbuf_strides[4];
uint64_t f_components_workbuf_offsets[5];
uint32_t f_scan_num_components;
@@ -37975,28 +37973,6 @@ wuffs_jpeg__decoder__decode_sof(
goto exit;
}
}
v_i = 0;
while (v_i < self->private_impl.f_num_components) {
if (self->private_impl.f_components_h[v_i] == 1) {
self->private_impl.f_components_width_in_blocks[v_i] = ((self->private_impl.f_width + 7) / 8);
} else if (self->private_impl.f_components_h[v_i] == 2) {
self->private_impl.f_components_width_in_blocks[v_i] = ((self->private_impl.f_width + 15) / 16);
} else if (self->private_impl.f_components_h[v_i] == 3) {
self->private_impl.f_components_width_in_blocks[v_i] = ((self->private_impl.f_width + 23) / 24);
} else {
self->private_impl.f_components_width_in_blocks[v_i] = ((self->private_impl.f_width + 31) / 32);
}
if (self->private_impl.f_components_v[v_i] == 1) {
self->private_impl.f_components_height_in_blocks[v_i] = ((self->private_impl.f_height + 7) / 8);
} else if (self->private_impl.f_components_v[v_i] == 2) {
self->private_impl.f_components_height_in_blocks[v_i] = ((self->private_impl.f_height + 15) / 16);
} else if (self->private_impl.f_components_v[v_i] == 3) {
self->private_impl.f_components_height_in_blocks[v_i] = ((self->private_impl.f_height + 23) / 24);
} else {
self->private_impl.f_components_height_in_blocks[v_i] = ((self->private_impl.f_height + 31) / 32);
}
v_i += 1;
}
if (self->private_impl.f_max_incl_components_h == 1) {
self->private_impl.f_width_in_mcus = ((self->private_impl.f_width + 7) / 8);
} else if (self->private_impl.f_max_incl_components_h == 2) {
@@ -39129,16 +39105,14 @@ wuffs_jpeg__decoder__prepare_scan(
}
self->private_impl.f_scan_ah = (v_c >> 4);
self->private_impl.f_scan_al = (v_c & 15);
self->private_impl.f_scan_width_in_mcus = self->private_impl.f_width_in_mcus;
self->private_impl.f_scan_height_in_mcus = self->private_impl.f_height_in_mcus;
if (self->private_impl.f_scan_num_components == 1) {
self->private_impl.f_scan_width_in_mcus = self->private_impl.f_components_width_in_blocks[self->private_impl.f_scan_comps_cselector[0]];
self->private_impl.f_scan_height_in_mcus = self->private_impl.f_components_height_in_blocks[self->private_impl.f_scan_comps_cselector[0]];
self->private_impl.f_scan_comps_bx_offset[0] = 0;
self->private_impl.f_scan_comps_by_offset[0] = 0;
self->private_impl.f_mcu_num_blocks = 1;
self->private_impl.f_mcu_blocks_sselector[0] = 0;
} else {
self->private_impl.f_scan_width_in_mcus = self->private_impl.f_width_in_mcus;
self->private_impl.f_scan_height_in_mcus = self->private_impl.f_height_in_mcus;
v_total_hv = 0;
v_i = 0;
v_b = 0;
+3 -34
View File
@@ -60,9 +60,6 @@ pub struct decoder? implements base.image_decoder(
components_v : array[4] base.u8[..= 4],
components_tq : array[4] base.u8[..= 3],
components_width_in_blocks : array[4] base.u32[..= 0x2000],
components_height_in_blocks : array[4] base.u32[..= 0x2000],
// components_workbuf_offsets, indexed by (b) and (b + 1), is the i and
// j bounds in the workbuf[i .. j] slice holding the post-IDCT values.
// components_workbuf_strides[b] is the stride between its rows.
@@ -484,33 +481,6 @@ pri func decoder.decode_sof?(src: base.io_reader) {
}
}
i = 0
while i < this.num_components {
assert i < 4 via "a < b: a < c; c <= b"(c: this.num_components)
if this.components_h[i] == 1 {
this.components_width_in_blocks[i] = (this.width + 0x07) / 0x08
} else if this.components_h[i] == 2 {
this.components_width_in_blocks[i] = (this.width + 0x0F) / 0x10
} else if this.components_h[i] == 3 {
this.components_width_in_blocks[i] = (this.width + 0x17) / 0x18
} else {
this.components_width_in_blocks[i] = (this.width + 0x1F) / 0x20
}
if this.components_v[i] == 1 {
this.components_height_in_blocks[i] = (this.height + 0x07) / 0x08
} else if this.components_v[i] == 2 {
this.components_height_in_blocks[i] = (this.height + 0x0F) / 0x10
} else if this.components_v[i] == 3 {
this.components_height_in_blocks[i] = (this.height + 0x17) / 0x18
} else {
this.components_height_in_blocks[i] = (this.height + 0x1F) / 0x20
}
i += 1
} endwhile
if this.max_incl_components_h == 1 {
this.width_in_mcus = (this.width + 0x07) / 0x08
} else if this.max_incl_components_h == 2 {
@@ -1192,17 +1162,16 @@ pri func decoder.prepare_scan?(src: base.io_reader) {
// that (Ss, Se, Ah, Al) is (0, 63, 0, 0) but libjpeg treats otherwise as a
// warning (JWRN_NOT_SEQUENTIAL), not an error.
this.scan_width_in_mcus = this.width_in_mcus
this.scan_height_in_mcus = this.height_in_mcus
if this.scan_num_components == 1 {
this.scan_width_in_mcus = this.components_width_in_blocks[this.scan_comps_cselector[0]]
this.scan_height_in_mcus = this.components_height_in_blocks[this.scan_comps_cselector[0]]
this.scan_comps_bx_offset[0] = 0
this.scan_comps_by_offset[0] = 0
this.mcu_num_blocks = 1
this.mcu_blocks_sselector[0] = 0
} else {
this.scan_width_in_mcus = this.width_in_mcus
this.scan_height_in_mcus = this.height_in_mcus
total_hv = 0
i = 0
b = 0