Capitalize Wuffs const names

This commit is contained in:
Nigel Tao committed 2020-04-13 15:52:36 +10:00
1 parent 623811086f
commit 74871344f0
20 files changed
+338 -335

No files matched your search

+13 -13
View File
@@ -24,7 +24,7 @@ pub status "#bad palette"
pri status "#internal error: inconsistent ri/wi"
pub const decoder_workbuf_len_max_incl_worst_case base.u64 = 0
pub const DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE base.u64 = 0
// See the spec appendix E "Interlaced Images" on page 29. The first element
// represents either that the frame was non-interlaced, or that all interlace
@@ -34,31 +34,31 @@ pub const decoder_workbuf_len_max_incl_worst_case base.u64 = 0
// For interlaced frames, the decoder.interlace field starts at 4 and is
// decremented towards 0.
//
// interlace_start[0] is a special case. For non-interlaced frames, that
// INTERLACE_START[0] is a special case. For non-interlaced frames, that
// element is never accessed. For interlaced frames, that element is only
// accessed after all interlace stages are complete. Being the maximum base.u32
// value means that, after all interlace stages are complete, dst_y will be set
// to that maximum value (and therefore outside the frame rect).
pri const interlace_start array[5] base.u32 = [0xFFFF_FFFF, 1, 2, 4, 0]
pri const interlace_delta array[5] base.u8 = [1, 2, 4, 8, 8]
pri const interlace_count array[5] base.u8 = [0, 1, 2, 4, 8]
pri const INTERLACE_START array[5] base.u32 = [0xFFFF_FFFF, 1, 2, 4, 0]
pri const INTERLACE_DELTA array[5] base.u8 = [1, 2, 4, 8, 8]
pri const INTERLACE_COUNT array[5] base.u8 = [0, 1, 2, 4, 8]
// animexts1dot0 is "ANIMEXTS1.0" as bytes.
pri const animexts1dot0 array[11] base.u8 = [
// ANIMEXTS1DOT0 is "ANIMEXTS1.0" as bytes.
pri const ANIMEXTS1DOT0 array[11] base.u8 = [
0x41, 0x4E, 0x49, 0x4D, 0x45, 0x58, 0x54, 0x53, 0x31, 0x2E, 0x30,
]
// netscape2dot0 is "NETSCAPE2.0" as bytes.
pri const netscape2dot0 array[11] base.u8 = [
// NETSCAPE2DOT0 is "NETSCAPE2.0" as bytes.
pri const NETSCAPE2DOT0 array[11] base.u8 = [
0x4E, 0x45, 0x54, 0x53, 0x43, 0x41, 0x50, 0x45, 0x32, 0x2E, 0x30,
]
// iccrgbg1012 is "ICCRGBG1012" as bytes.
pri const iccrgbg1012 array[11] base.u8 = [
// ICCRGBG1012 Is "ICCRGBG1012" as bytes.
pri const ICCRGBG1012 array[11] base.u8 = [
0x49, 0x43, 0x43, 0x52, 0x47, 0x42, 0x47, 0x31, 0x30, 0x31, 0x32,
]
// xmpdataxmp is "XMP DataXMP" as bytes.
pri const xmpdataxmp array[11] base.u8 = [
// XMPDATAXMP IS "XMP DataXMP" as bytes.
pri const XMPDATAXMP array[11] base.u8 = [
0x58, 0x4D, 0x50, 0x20, 0x44, 0x61, 0x74, 0x61, 0x58, 0x4D, 0x50,
]
+12 -12
View File
@@ -83,7 +83,7 @@ pub struct config_decoder? implements base.image_decoder(
has_global_palette : base.bool,
// interlace indexes the interlace_start and interlace_delta arrays.
// interlace indexes the INTERLACE_START and INTERLACE_DELTA arrays.
interlace : base.u8[..= 4],
// Absent an ANIMEXTS1.0 or NETSCAPE2.0 extension, the implicit number of
@@ -116,19 +116,19 @@ 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 {
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 {
} 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 {
} 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 {
} 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 {
} 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 {
} else if args.quirk == QUIRK_REJECT_EMPTY_FRAME {
this.quirk_enabled_reject_empty_frame = args.enabled
} else if args.quirk == quirk_reject_empty_palette {
} else if args.quirk == QUIRK_REJECT_EMPTY_PALETTE {
this.quirk_enabled_reject_empty_palette = args.enabled
}
}
@@ -567,10 +567,10 @@ pri func config_decoder.decode_ae?(src: base.io_reader) {
block_size = 0 // Re-purpose the block_size variable as a counter.
while block_size < 11 {
c = args.src.read_u8?()
is_animexts = is_animexts and (c == animexts1dot0[block_size])
is_netscape = is_netscape and (c == netscape2dot0[block_size])
is_iccp = is_iccp and (c == iccrgbg1012[block_size])
is_xmp = is_xmp and (c == xmpdataxmp[block_size])
is_animexts = is_animexts and (c == ANIMEXTS1DOT0[block_size])
is_netscape = is_netscape and (c == NETSCAPE2DOT0[block_size])
is_iccp = is_iccp and (c == ICCRGBG1012[block_size])
is_xmp = is_xmp and (c == XMPDATAXMP[block_size])
block_size += 1
} endwhile
+19 -19
View File
@@ -98,7 +98,7 @@ pub struct decoder? implements base.image_decoder(
has_global_palette : base.bool,
// interlace indexes the interlace_start and interlace_delta arrays.
// interlace indexes the INTERLACE_START and INTERLACE_DELTA arrays.
interlace : base.u8[..= 4],
// Absent an ANIMEXTS1.0 or NETSCAPE2.0 extension, the implicit number of
@@ -155,19 +155,19 @@ pub struct decoder? implements base.image_decoder(
pub func decoder.set_quirk_enabled!(quirk: base.u32, enabled: base.bool) {
if this.call_sequence == 0 {
if args.quirk == quirk_delay_num_decoded_frames {
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 {
} 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 {
} 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 {
} 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 {
} 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 {
} else if args.quirk == QUIRK_REJECT_EMPTY_FRAME {
this.quirk_enabled_reject_empty_frame = args.enabled
} else if args.quirk == quirk_reject_empty_palette {
} else if args.quirk == QUIRK_REJECT_EMPTY_PALETTE {
this.quirk_enabled_reject_empty_palette = args.enabled
}
}
@@ -306,8 +306,8 @@ pub func decoder.frame_dirty_rect() base.rect_ie_u32 {
pub func decoder.workbuf_len() base.range_ii_u64 {
//#WHEN PREPROC201
return this.util.make_range_ii_u64(
min_incl: decoder_workbuf_len_max_incl_worst_case,
max_incl: decoder_workbuf_len_max_incl_worst_case)
min_incl: DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE,
max_incl: DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE)
//#WHEN PREPROC201 decode_config.wuffs
//## return this.util.empty_range_ii_u64()
//#DONE PREPROC201
@@ -642,10 +642,10 @@ pri func decoder.decode_ae?(src: base.io_reader) {
block_size = 0 // Re-purpose the block_size variable as a counter.
while block_size < 11 {
c = args.src.read_u8?()
is_animexts = is_animexts and (c == animexts1dot0[block_size])
is_netscape = is_netscape and (c == netscape2dot0[block_size])
is_iccp = is_iccp and (c == iccrgbg1012[block_size])
is_xmp = is_xmp and (c == xmpdataxmp[block_size])
is_animexts = is_animexts and (c == ANIMEXTS1DOT0[block_size])
is_netscape = is_netscape and (c == NETSCAPE2DOT0[block_size])
is_iccp = is_iccp and (c == ICCRGBG1012[block_size])
is_xmp = is_xmp and (c == XMPDATAXMP[block_size])
block_size += 1
} endwhile
@@ -1090,7 +1090,7 @@ pri func decoder.copy_to_image_buffer!(pb: ptr base.pixel_buffer, src: slice bas
replicate_src = tab.row(y: this.dst_y)
replicate_y0 = this.dst_y ~sat+ 1
replicate_y1 = this.dst_y ~sat+ (interlace_count[this.interlace] as base.u32)
replicate_y1 = this.dst_y ~sat+ (INTERLACE_COUNT[this.interlace] as base.u32)
replicate_y1 = replicate_y1.min(a: this.frame_rect_y1)
while replicate_y0 < replicate_y1 {
assert replicate_y0 < 0xFFFF_FFFF via "a < b: a < c; c <= b"(c: replicate_y1)
@@ -1101,10 +1101,10 @@ pri func decoder.copy_to_image_buffer!(pb: ptr base.pixel_buffer, src: slice bas
this.dirty_max_excl_y = this.dirty_max_excl_y.max(a: replicate_y1)
}
this.dst_y ~sat+= interlace_delta[this.interlace] as base.u32
this.dst_y ~sat+= INTERLACE_DELTA[this.interlace] as base.u32
while (this.interlace > 0) and (this.dst_y >= this.frame_rect_y1) {
this.interlace -= 1
this.dst_y = this.frame_rect_y0 ~sat+ interlace_start[this.interlace]
this.dst_y = this.frame_rect_y0 ~sat+ INTERLACE_START[this.interlace]
} endwhile
continue
}
@@ -1127,10 +1127,10 @@ pri func decoder.copy_to_image_buffer!(pb: ptr base.pixel_buffer, src: slice bas
if this.frame_rect_x1 <= this.dst_x {
this.dst_x = this.frame_rect_x0
this.dst_y ~sat+= interlace_delta[this.interlace] as base.u32
this.dst_y ~sat+= INTERLACE_DELTA[this.interlace] as base.u32
while (this.interlace > 0) and (this.dst_y >= this.frame_rect_y1) {
this.interlace -= 1
this.dst_y = this.frame_rect_y0 ~sat+ interlace_start[this.interlace]
this.dst_y = this.frame_rect_y0 ~sat+ INTERLACE_START[this.interlace]
} endwhile
continue
}
+8 -8
View File
@@ -35,7 +35,7 @@
// see the N+1'th frame's header (or the end-of-animation terminator), so that
// e.g. the API for visiting the N'th frame can also return whether it's the
// final frame. Enabling this quirk allows for matching that behavior.
pub const quirk_delay_num_decoded_frames base.u32 = 0x3E16_1800 | 0x00
pub const QUIRK_DELAY_NUM_DECODED_FRAMES base.u32 = 0x3E16_1800 | 0x00
// When this quirk is enabled, the background color of the first frame is set
// to black whenever that first frame has a local (frame-specific) palette.
@@ -43,11 +43,11 @@ pub const quirk_delay_num_decoded_frames base.u32 = 0x3E16_1800 | 0x00
// whether or not that first frame is opaque: whether that local palette
// contains a transparent color.
//
// This has no effect unless quirk_honor_background_color is also enabled.
// This has no effect unless QUIRK_HONOR_BACKGROUND_COLOR is also enabled.
//
// There isn't really much of a rationale for this, other than it matches the
// behavior of another GIF implementation.
pub const quirk_first_frame_local_palette_means_black_background base.u32 = 0x3E16_1800 | 0x01
pub const QUIRK_FIRST_FRAME_LOCAL_PALETTE_MEANS_BLACK_BACKGROUND base.u32 = 0x3E16_1800 | 0x01
// When this quirk is enabled, the background color is taken from the GIF
// instead of always being transparent black. If the background color index in
@@ -63,12 +63,12 @@ pub const quirk_first_frame_local_palette_means_black_background base.u32 = 0x3E
// processing WUFFS_BASE__ANIMATION_DISPOSAL__RESTORE_BACKGROUND. In both
// cases, the caller of Wuffs, not Wuffs itself, is responsible for filling the
// pixel buffer with that color.
pub const quirk_honor_background_color base.u32 = 0x3E16_1800 | 0x02
pub const QUIRK_HONOR_BACKGROUND_COLOR base.u32 = 0x3E16_1800 | 0x02
// When this quirk is enabled, silently ignore e.g. a frame that reports a
// width and height of 6 pixels each, followed by 50 pixel values. In that
// case, we process the first 36 pixel values and discard the excess 14.
pub const quirk_ignore_too_much_pixel_data base.u32 = 0x3E16_1800 | 0x03
pub const QUIRK_IGNORE_TOO_MUCH_PIXEL_DATA base.u32 = 0x3E16_1800 | 0x03
// When this quirk is enabled, if the initial frame bounds extends beyond the
// image bounds, then the image bounds stay unchanged. By default (with this
@@ -77,12 +77,12 @@ pub const quirk_ignore_too_much_pixel_data base.u32 = 0x3E16_1800 | 0x03
//
// For more discussion, see
// https://github.com/google/wuffs/blob/master/test/data/artificial/gif-frame-out-of-bounds.gif.make-artificial.txt
pub const quirk_image_bounds_are_strict base.u32 = 0x3E16_1800 | 0x04
pub const QUIRK_IMAGE_BOUNDS_ARE_STRICT base.u32 = 0x3E16_1800 | 0x04
// When this quirk is enabled, a frame with zero width or height is rejected
// during decode_frame (but accepted during decode_frame_config).
pub const quirk_reject_empty_frame base.u32 = 0x3E16_1800 | 0x05
pub const QUIRK_REJECT_EMPTY_FRAME base.u32 = 0x3E16_1800 | 0x05
// When this quirk is enabled, a frame with no explicit palette is rejected,
// instead of implicitly having a palette with every entry being opaque black.
pub const quirk_reject_empty_palette base.u32 = 0x3E16_1800 | 0x06
pub const QUIRK_REJECT_EMPTY_PALETTE base.u32 = 0x3E16_1800 | 0x06