mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-24 00:52:18 +01:00
Redo Wuffs structs' quirk bool fields
This commit is contained in:
1 parent
532e18c4a5
commit
e39f3cbf42
7 files changed
+162
-290
No files matched your search
+10
-27
@@ -68,13 +68,7 @@ pub struct config_decoder? implements base.image_decoder(
|
||||
metadata_chunk_length_value : base.u64,
|
||||
metadata_io_position : base.u64,
|
||||
|
||||
quirk_enabled_delay_num_decoded_frames : base.bool,
|
||||
quirk_enabled_first_frame_local_palette_means_black_background : base.bool,
|
||||
quirk_enabled_honor_background_color : base.bool,
|
||||
quirk_enabled_ignore_too_much_pixel_data : base.bool,
|
||||
quirk_enabled_image_bounds_are_strict : base.bool,
|
||||
quirk_enabled_reject_empty_frame : base.bool,
|
||||
quirk_enabled_reject_empty_palette : base.bool,
|
||||
quirks : array[QUIRKS_COUNT] base.bool,
|
||||
|
||||
delayed_num_decoded_frames : base.bool,
|
||||
end_of_data : base.bool,
|
||||
@@ -115,21 +109,10 @@ pub struct config_decoder? implements base.image_decoder(
|
||||
)
|
||||
|
||||
pub func config_decoder.set_quirk_enabled!(quirk: base.u32, enabled: base.bool) {
|
||||
if this.call_sequence == 0 {
|
||||
if args.quirk == QUIRK_DELAY_NUM_DECODED_FRAMES {
|
||||
this.quirk_enabled_delay_num_decoded_frames = args.enabled
|
||||
} else if args.quirk == QUIRK_FIRST_FRAME_LOCAL_PALETTE_MEANS_BLACK_BACKGROUND {
|
||||
this.quirk_enabled_first_frame_local_palette_means_black_background = args.enabled
|
||||
} else if args.quirk == QUIRK_HONOR_BACKGROUND_COLOR {
|
||||
this.quirk_enabled_honor_background_color = args.enabled
|
||||
} else if args.quirk == QUIRK_IGNORE_TOO_MUCH_PIXEL_DATA {
|
||||
this.quirk_enabled_ignore_too_much_pixel_data = args.enabled
|
||||
} else if args.quirk == QUIRK_IMAGE_BOUNDS_ARE_STRICT {
|
||||
this.quirk_enabled_image_bounds_are_strict = args.enabled
|
||||
} else if args.quirk == QUIRK_REJECT_EMPTY_FRAME {
|
||||
this.quirk_enabled_reject_empty_frame = args.enabled
|
||||
} else if args.quirk == QUIRK_REJECT_EMPTY_PALETTE {
|
||||
this.quirk_enabled_reject_empty_palette = args.enabled
|
||||
if (this.call_sequence == 0) and (args.quirk >= QUIRKS_BASE) {
|
||||
args.quirk -= QUIRKS_BASE
|
||||
if args.quirk < QUIRKS_COUNT {
|
||||
this.quirks[args.quirk] = args.enabled
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -149,7 +132,7 @@ pub func config_decoder.decode_image_config?(dst: nptr base.image_config, src: b
|
||||
// TODO: if this.end_of_data, return an error and/or set dst to zero?
|
||||
|
||||
ffio = not this.gc_has_transparent_index
|
||||
if not this.quirk_enabled_honor_background_color {
|
||||
if not this.quirks[QUIRK_HONOR_BACKGROUND_COLOR - QUIRKS_BASE] {
|
||||
ffio = ffio and
|
||||
(this.frame_rect_x0 == 0) and
|
||||
(this.frame_rect_y0 == 0) and
|
||||
@@ -301,7 +284,7 @@ pub func config_decoder.decode_frame_config?(dst: nptr base.frame_config, src: b
|
||||
|
||||
// If the quirk is enabled and the first frame has a local color
|
||||
// palette, its background color is black.
|
||||
if this.quirk_enabled_first_frame_local_palette_means_black_background and
|
||||
if this.quirks[QUIRK_FIRST_FRAME_LOCAL_PALETTE_MEANS_BLACK_BACKGROUND - QUIRKS_BASE] and
|
||||
(this.num_decoded_frame_configs_value == 0) {
|
||||
|
||||
while args.src.available() <= 0,
|
||||
@@ -356,7 +339,7 @@ pri func config_decoder.skip_frame?(src: base.io_reader) {
|
||||
// Skip the blocks of LZW-compressed data.
|
||||
this.skip_blocks?(src: args.src)
|
||||
|
||||
if this.quirk_enabled_delay_num_decoded_frames {
|
||||
if this.quirks[QUIRK_DELAY_NUM_DECODED_FRAMES - QUIRKS_BASE] {
|
||||
this.delayed_num_decoded_frames = true
|
||||
} else {
|
||||
this.num_decoded_frames_value ~sat+= 1
|
||||
@@ -469,7 +452,7 @@ pri func config_decoder.decode_lsd?(src: base.io_reader) {
|
||||
i += 1
|
||||
} endwhile
|
||||
|
||||
if this.quirk_enabled_honor_background_color {
|
||||
if this.quirks[QUIRK_HONOR_BACKGROUND_COLOR - QUIRKS_BASE] {
|
||||
if (background_color_index <> 0) and
|
||||
((background_color_index as base.u32) < num_palette_entries) {
|
||||
|
||||
@@ -715,7 +698,7 @@ pri func config_decoder.decode_id_part0?(src: base.io_reader) {
|
||||
// and the bottom right extent of the first frame. See
|
||||
// test/data/artificial/gif-frame-out-of-bounds.gif.make-artificial.txt for
|
||||
// more discussion.
|
||||
if (this.call_sequence == 0) and (not this.quirk_enabled_image_bounds_are_strict) {
|
||||
if (this.call_sequence == 0) and (not this.quirks[QUIRK_IMAGE_BOUNDS_ARE_STRICT - QUIRKS_BASE]) {
|
||||
this.width = this.width.max(a: this.frame_rect_x1)
|
||||
this.height = this.height.max(a: this.frame_rect_y1)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user