mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-25 16:55:11 +01:00
Have wuffsfmt put underscores in long numbers
This commit is contained in:
1 parent
22be1c0da0
commit
b40671ec84
11 files changed
+636
-592
No files matched your search
@@ -39,7 +39,7 @@ pub const decoder_workbuf_len_max_incl_worst_case base.u64 = 0
|
||||
// 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 = [0xFFFFFFFF, 1, 2, 4, 0]
|
||||
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]
|
||||
|
||||
|
||||
+12
-12
@@ -97,8 +97,8 @@ pub struct config_decoder? implements base.image_decoder(
|
||||
gc_has_transparent_index : base.bool,
|
||||
gc_transparent_index : base.u8,
|
||||
gc_disposal : base.u8,
|
||||
// There are 7056000 flicks per centisecond.
|
||||
gc_duration : base.u64[..= 0xFFFF * 7056000],
|
||||
// There are 7_056000 flicks per centisecond.
|
||||
gc_duration : base.u64[..= 0xFFFF * 7_056000],
|
||||
|
||||
frame_config_io_position : base.u64,
|
||||
num_decoded_frame_configs_value : base.u64,
|
||||
@@ -157,7 +157,7 @@ pub func config_decoder.decode_image_config?(dst: nptr base.image_config, src: b
|
||||
(this.frame_rect_y1 == this.height)
|
||||
} else if ffio {
|
||||
// Use opaque black, not transparent black.
|
||||
this.black_color_u32_argb_premul = 0xFF000000
|
||||
this.black_color_u32_argb_premul = 0xFF00_0000
|
||||
}
|
||||
|
||||
if this.background_color_u32_argb_premul == 77 {
|
||||
@@ -168,7 +168,7 @@ pub func config_decoder.decode_image_config?(dst: nptr base.image_config, src: b
|
||||
// TODO: a Wuffs (not just C) name for the
|
||||
// WUFFS_BASE__PIXEL_FORMAT__INDEXED__BGRA_BINARY magic pixfmt constant.
|
||||
args.dst.set!(
|
||||
pixfmt: 0x47040008,
|
||||
pixfmt: 0x4704_0008,
|
||||
pixsub: 0,
|
||||
width: this.width,
|
||||
height: this.height,
|
||||
@@ -180,9 +180,9 @@ pub func config_decoder.decode_image_config?(dst: nptr base.image_config, src: b
|
||||
}
|
||||
|
||||
pub func config_decoder.set_report_metadata!(fourcc: base.u32, report: base.bool) {
|
||||
if args.fourcc == 0x49434350 { // "ICCP"
|
||||
if args.fourcc == 0x4943_4350 { // "ICCP"
|
||||
this.report_metadata_iccp = args.report
|
||||
} else if args.fourcc == 0x584D5020 { // "XMP "
|
||||
} else if args.fourcc == 0x584D_5020 { // "XMP "
|
||||
this.report_metadata_xmp = args.report
|
||||
}
|
||||
}
|
||||
@@ -204,7 +204,7 @@ pub func config_decoder.ack_metadata_chunk?(src: base.io_reader) {
|
||||
|
||||
this.metadata_chunk_length_value = args.src.peek_u8_as_u64()
|
||||
if this.metadata_chunk_length_value > 0 {
|
||||
if this.metadata_fourcc_value == 0x584D5020 { // "XMP "
|
||||
if this.metadata_fourcc_value == 0x584D_5020 { // "XMP "
|
||||
// The +1 is because XMP metadata's encoding includes each
|
||||
// block's leading byte (the block size) as part of the
|
||||
// metadata passed to the caller.
|
||||
@@ -461,7 +461,7 @@ pri func config_decoder.decode_lsd?(src: base.io_reader) {
|
||||
// Convert from RGB (in memory order) to ARGB (in native u32 order)
|
||||
// to BGRA (in memory order).
|
||||
argb = args.src.read_u24be_as_u32?()
|
||||
argb |= 0xFF000000
|
||||
argb |= 0xFF00_0000
|
||||
this.palettes[0][(4 * i) + 0] = ((argb >> 0) & 0xFF) as base.u8
|
||||
this.palettes[0][(4 * i) + 1] = ((argb >> 8) & 0xFF) as base.u8
|
||||
this.palettes[0][(4 * i) + 2] = ((argb >> 16) & 0xFF) as base.u8
|
||||
@@ -617,7 +617,7 @@ pri func config_decoder.decode_ae?(src: base.io_reader) {
|
||||
}
|
||||
this.metadata_chunk_length_value = args.src.peek_u8_as_u64()
|
||||
args.src.skip32_fast!(actual: 1, worst_case: 1)
|
||||
this.metadata_fourcc_value = 0x49434350 // "ICCP"
|
||||
this.metadata_fourcc_value = 0x4943_4350 // "ICCP"
|
||||
this.metadata_io_position = args.src.position() ~sat+ this.metadata_chunk_length_value
|
||||
this.call_sequence = 1
|
||||
return base."@metadata reported"
|
||||
@@ -637,7 +637,7 @@ pri func config_decoder.decode_ae?(src: base.io_reader) {
|
||||
} else {
|
||||
args.src.skip32_fast!(actual: 1, worst_case: 1)
|
||||
}
|
||||
this.metadata_fourcc_value = 0x584D5020 // "XMP "
|
||||
this.metadata_fourcc_value = 0x584D_5020 // "XMP "
|
||||
this.metadata_io_position = args.src.position() ~sat+ this.metadata_chunk_length_value
|
||||
this.call_sequence = 1
|
||||
return base."@metadata reported"
|
||||
@@ -680,9 +680,9 @@ pri func config_decoder.decode_gc?(src: base.io_reader) {
|
||||
this.gc_disposal = 0
|
||||
}
|
||||
|
||||
// There are 7056000 flicks per centisecond.
|
||||
// There are 7_056000 flicks per centisecond.
|
||||
gc_duration_centiseconds = args.src.read_u16le?()
|
||||
this.gc_duration = (gc_duration_centiseconds as base.u64) * 7056000
|
||||
this.gc_duration = (gc_duration_centiseconds as base.u64) * 7_056000
|
||||
this.gc_transparent_index = args.src.read_u8?()
|
||||
|
||||
c = args.src.read_u8?()
|
||||
|
||||
+17
-17
@@ -112,8 +112,8 @@ pub struct decoder? implements base.image_decoder(
|
||||
gc_has_transparent_index : base.bool,
|
||||
gc_transparent_index : base.u8,
|
||||
gc_disposal : base.u8,
|
||||
// There are 7056000 flicks per centisecond.
|
||||
gc_duration : base.u64[..= 0xFFFF * 7056000],
|
||||
// There are 7_056000 flicks per centisecond.
|
||||
gc_duration : base.u64[..= 0xFFFF * 7_056000],
|
||||
|
||||
frame_config_io_position : base.u64,
|
||||
num_decoded_frame_configs_value : base.u64,
|
||||
@@ -196,7 +196,7 @@ pub func decoder.decode_image_config?(dst: nptr base.image_config, src: base.io_
|
||||
(this.frame_rect_y1 == this.height)
|
||||
} else if ffio {
|
||||
// Use opaque black, not transparent black.
|
||||
this.black_color_u32_argb_premul = 0xFF000000
|
||||
this.black_color_u32_argb_premul = 0xFF00_0000
|
||||
}
|
||||
|
||||
if this.background_color_u32_argb_premul == 77 {
|
||||
@@ -207,7 +207,7 @@ pub func decoder.decode_image_config?(dst: nptr base.image_config, src: base.io_
|
||||
// TODO: a Wuffs (not just C) name for the
|
||||
// WUFFS_BASE__PIXEL_FORMAT__INDEXED__BGRA_BINARY magic pixfmt constant.
|
||||
args.dst.set!(
|
||||
pixfmt: 0x47040008,
|
||||
pixfmt: 0x4704_0008,
|
||||
pixsub: 0,
|
||||
width: this.width,
|
||||
height: this.height,
|
||||
@@ -219,9 +219,9 @@ pub func decoder.decode_image_config?(dst: nptr base.image_config, src: base.io_
|
||||
}
|
||||
|
||||
pub func decoder.set_report_metadata!(fourcc: base.u32, report: base.bool) {
|
||||
if args.fourcc == 0x49434350 { // "ICCP"
|
||||
if args.fourcc == 0x4943_4350 { // "ICCP"
|
||||
this.report_metadata_iccp = args.report
|
||||
} else if args.fourcc == 0x584D5020 { // "XMP "
|
||||
} else if args.fourcc == 0x584D_5020 { // "XMP "
|
||||
this.report_metadata_xmp = args.report
|
||||
}
|
||||
}
|
||||
@@ -243,7 +243,7 @@ pub func decoder.ack_metadata_chunk?(src: base.io_reader) {
|
||||
|
||||
this.metadata_chunk_length_value = args.src.peek_u8_as_u64()
|
||||
if this.metadata_chunk_length_value > 0 {
|
||||
if this.metadata_fourcc_value == 0x584D5020 { // "XMP "
|
||||
if this.metadata_fourcc_value == 0x584D_5020 { // "XMP "
|
||||
// The +1 is because XMP metadata's encoding includes each
|
||||
// block's leading byte (the block size) as part of the
|
||||
// metadata passed to the caller.
|
||||
@@ -536,7 +536,7 @@ pri func decoder.decode_lsd?(src: base.io_reader) {
|
||||
// Convert from RGB (in memory order) to ARGB (in native u32 order)
|
||||
// to BGRA (in memory order).
|
||||
argb = args.src.read_u24be_as_u32?()
|
||||
argb |= 0xFF000000
|
||||
argb |= 0xFF00_0000
|
||||
this.palettes[0][(4 * i) + 0] = ((argb >> 0) & 0xFF) as base.u8
|
||||
this.palettes[0][(4 * i) + 1] = ((argb >> 8) & 0xFF) as base.u8
|
||||
this.palettes[0][(4 * i) + 2] = ((argb >> 16) & 0xFF) as base.u8
|
||||
@@ -692,7 +692,7 @@ pri func decoder.decode_ae?(src: base.io_reader) {
|
||||
}
|
||||
this.metadata_chunk_length_value = args.src.peek_u8_as_u64()
|
||||
args.src.skip32_fast!(actual: 1, worst_case: 1)
|
||||
this.metadata_fourcc_value = 0x49434350 // "ICCP"
|
||||
this.metadata_fourcc_value = 0x4943_4350 // "ICCP"
|
||||
this.metadata_io_position = args.src.position() ~sat+ this.metadata_chunk_length_value
|
||||
this.call_sequence = 1
|
||||
return base."@metadata reported"
|
||||
@@ -712,7 +712,7 @@ pri func decoder.decode_ae?(src: base.io_reader) {
|
||||
} else {
|
||||
args.src.skip32_fast!(actual: 1, worst_case: 1)
|
||||
}
|
||||
this.metadata_fourcc_value = 0x584D5020 // "XMP "
|
||||
this.metadata_fourcc_value = 0x584D_5020 // "XMP "
|
||||
this.metadata_io_position = args.src.position() ~sat+ this.metadata_chunk_length_value
|
||||
this.call_sequence = 1
|
||||
return base."@metadata reported"
|
||||
@@ -755,9 +755,9 @@ pri func decoder.decode_gc?(src: base.io_reader) {
|
||||
this.gc_disposal = 0
|
||||
}
|
||||
|
||||
// There are 7056000 flicks per centisecond.
|
||||
// There are 7_056000 flicks per centisecond.
|
||||
gc_duration_centiseconds = args.src.read_u16le?()
|
||||
this.gc_duration = (gc_duration_centiseconds as base.u64) * 7056000
|
||||
this.gc_duration = (gc_duration_centiseconds as base.u64) * 7_056000
|
||||
this.gc_transparent_index = args.src.read_u8?()
|
||||
|
||||
c = args.src.read_u8?()
|
||||
@@ -830,7 +830,7 @@ pri func decoder.decode_id_part1?(dst: ptr base.pixel_buffer, src: base.io_reade
|
||||
// Convert from RGB (in memory order) to ARGB (in native u32 order)
|
||||
// to BGRA (in memory order).
|
||||
argb = args.src.read_u24be_as_u32?()
|
||||
argb |= 0xFF000000
|
||||
argb |= 0xFF00_0000
|
||||
this.palettes[1][(4 * i) + 0] = ((argb >> 0) & 0xFF) as base.u8
|
||||
this.palettes[1][(4 * i) + 1] = ((argb >> 8) & 0xFF) as base.u8
|
||||
this.palettes[1][(4 * i) + 2] = ((argb >> 16) & 0xFF) as base.u8
|
||||
@@ -871,7 +871,7 @@ pri func decoder.decode_id_part1?(dst: ptr base.pixel_buffer, src: base.io_reade
|
||||
status = this.swizzler.prepare!(
|
||||
dst_pixfmt: args.dst.pixel_format(),
|
||||
dst_palette: dst_palette,
|
||||
src_pixfmt: this.util.make_pixel_format(repr: 0x47040008),
|
||||
src_pixfmt: this.util.make_pixel_format(repr: 0x4704_0008),
|
||||
src_palette: this.palettes[which_palette][..],
|
||||
blend: args.blend)
|
||||
if not status.is_ok() {
|
||||
@@ -1066,7 +1066,7 @@ pri func decoder.copy_to_image_buffer!(pb: ptr base.pixel_buffer, src: slice bas
|
||||
dst: dst, dst_palette: this.dst_palette[..], src: src)
|
||||
|
||||
src_ri ~sat+= n
|
||||
this.dst_x ~sat+= (n & 0xFFFFFFFF) as base.u32
|
||||
this.dst_x ~sat+= (n & 0xFFFF_FFFF) as base.u32
|
||||
|
||||
this.dirty_max_excl_y = this.dirty_max_excl_y.max(a: this.dst_y ~sat+ 1)
|
||||
}
|
||||
@@ -1094,7 +1094,7 @@ pri func decoder.copy_to_image_buffer!(pb: ptr base.pixel_buffer, src: slice bas
|
||||
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 < 0xFFFFFFFF via "a < b: a < c; c <= b"(c: replicate_y1)
|
||||
assert replicate_y0 < 0xFFFF_FFFF via "a < b: a < c; c <= b"(c: replicate_y1)
|
||||
replicate_dst = tab.row(y: replicate_y0)
|
||||
replicate_dst.copy_from_slice!(s: replicate_src)
|
||||
replicate_y0 += 1
|
||||
@@ -1124,7 +1124,7 @@ pri func decoder.copy_to_image_buffer!(pb: ptr base.pixel_buffer, src: slice bas
|
||||
n = n.min(a: args.src.length() - src_ri)
|
||||
|
||||
src_ri ~sat+= n
|
||||
this.dst_x ~sat+= (n & 0xFFFFFFFF) as base.u32
|
||||
this.dst_x ~sat+= (n & 0xFFFF_FFFF) as base.u32
|
||||
|
||||
if this.frame_rect_x1 <= this.dst_x {
|
||||
this.dst_x = this.frame_rect_x0
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
// Quirks are discussed in (/doc/note/quirks.md).
|
||||
//
|
||||
// The base38 encoding of "gif " is 0xF8586.
|
||||
// The base38 encoding of "gif " is 0xF_8586.
|
||||
|
||||
// When this quirk is enabled, when skipping over frames, the number of frames
|
||||
// visited isn't incremented when the last byte of the N'th frame is seen.
|
||||
@@ -32,7 +32,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 = (0xF8586 << 10) | 0
|
||||
pub const quirk_delay_num_decoded_frames base.u32 = (0xF_8586 << 10) | 0
|
||||
|
||||
// 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.
|
||||
@@ -44,7 +44,7 @@ pub const quirk_delay_num_decoded_frames base.u32 = (0xF8586 << 10) | 0
|
||||
//
|
||||
// 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 = (0xF8586 << 10) | 1
|
||||
pub const quirk_first_frame_local_palette_means_black_background base.u32 = (0xF_8586 << 10) | 1
|
||||
|
||||
// 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
|
||||
@@ -60,12 +60,12 @@ pub const quirk_first_frame_local_palette_means_black_background base.u32 = (0xF
|
||||
// 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 = (0xF8586 << 10) | 2
|
||||
pub const quirk_honor_background_color base.u32 = (0xF_8586 << 10) | 2
|
||||
|
||||
// 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 = (0xF8586 << 10) | 3
|
||||
pub const quirk_ignore_too_much_pixel_data base.u32 = (0xF_8586 << 10) | 3
|
||||
|
||||
// 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
|
||||
@@ -74,12 +74,12 @@ pub const quirk_ignore_too_much_pixel_data base.u32 = (0xF8586 << 10) | 3
|
||||
//
|
||||
// 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 = (0xF8586 << 10) | 4
|
||||
pub const quirk_image_bounds_are_strict base.u32 = (0xF_8586 << 10) | 4
|
||||
|
||||
// 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 = (0xF8586 << 10) | 5
|
||||
pub const quirk_reject_empty_frame base.u32 = (0xF_8586 << 10) | 5
|
||||
|
||||
// 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 = (0xF8586 << 10) | 6
|
||||
pub const quirk_reject_empty_palette base.u32 = (0xF_8586 << 10) | 6
|
||||
Reference in new issue
Block a user