From 8d03a67e6ea3990dedc37b7eabdbcd8bd41c9ebc Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Sat, 28 May 2022 15:05:55 +1000 Subject: [PATCH] Re-do image decoders' call sequence state machine --- .../image-decoders-call-sequence-diagram.png | Bin 0 -> 49038 bytes .../image-decoders-call-sequence-diagram.svg | 96 ++++++ doc/std/image-decoders-call-sequence.md | 118 +++++++ doc/std/image-decoders.md | 53 +-- doc/std/metadata.md | 48 +++ release/c/wuffs-unsupported-snapshot.c | 323 ++++++++++-------- std/bmp/decode_bmp.wuffs | 59 ++-- std/gif/decode_gif.wuffs | 138 +++----- std/nie/decode_nie.wuffs | 59 ++-- std/png/decode_png.wuffs | 105 ++---- std/tga/decode_tga.wuffs | 59 ++-- std/wbmp/decode_wbmp.wuffs | 59 ++-- 12 files changed, 606 insertions(+), 511 deletions(-) create mode 100644 doc/std/image-decoders-call-sequence-diagram.png create mode 100644 doc/std/image-decoders-call-sequence-diagram.svg create mode 100644 doc/std/image-decoders-call-sequence.md create mode 100644 doc/std/metadata.md diff --git a/doc/std/image-decoders-call-sequence-diagram.png b/doc/std/image-decoders-call-sequence-diagram.png new file mode 100644 index 0000000000000000000000000000000000000000..cf4816b659c3d81003b365ba8c86996c35985be9 GIT binary patch literal 49038 zcmeAS@N?(olHy`uVBq!ia0y~yU{(NO4kiW$h7h5N_6!XBLp@y_Ln>~)nads_a{Tvk z*I<)Qsl|#L)o)aLny7RHel|a%VR$hj$#+e}gc}FglEmM{Iv(g)q~v?VNxw;9Z}|kZ z4u#NH2cQ0zn;i3Fp&?iG@w;!oe|~d#^X~HP*2eF5d@d|6TXu9l0|+z(M=jt0F&Gpg zz?6UvnBouvQw<4>AlhLAh=eI&XkrC(4}zS`09C>O)xp9ImP1j(fNCgI396w`B@8Hr zLX|K;b)XoE*Io)egU?<{Jp*+bMj#&GUbSjfQBhG)aPZ;RA3lC8EH3{1=~L3|&d$!8 zH*boHifU-EF4(kb(jv{it=qSoC-H(p{s3=kYU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=49Sv#-?bZbbpix{;S3j3^P6 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/doc/std/image-decoders-call-sequence.md b/doc/std/image-decoders-call-sequence.md new file mode 100644 index 00000000..884b26d0 --- /dev/null +++ b/doc/std/image-decoders-call-sequence.md @@ -0,0 +1,118 @@ +# Image Decoders Call Sequence + +As discussed in the [Image Decoders](./image-decoders.md) document, here's the +canonical sequence of API calls to decode an animated image (with N frames): + +1. DIC (`decode_image_config`) +1. DFC (`decode_frame_config`) #0 +1. DF (`decode_frame`) #0 +1. DFC (`decode_frame_config`) #1 +1. DF (`decode_frame`) #1 +1. ... +1. DFC (`decode_frame_config`) #N-1 +1. DF (`decode_frame`) #N-1 +1. DFC (`decode_frame_config`) #N returning an `"@end of data"` status value. + +The final DFC call returns `"@end of data"` even if the animation loops. + +Decoding a still (non-animated) image is equivalent to N being 1. + +These three methods (DIC, DFC, DF) are all +[coroutines](/doc/note/coroutines.md) and may return I/O related suspension +status values. Those coroutines should be resumed by calling the same method +again, before moving to the next one in the sequence. + +Encountering an error (such as the input not being valid in that image file +format) is sticky (any further calls will return that same error). + + +## Implicit Calls + +These three methods (DIC, DFC, DF) are all also optional in some sense. +Referring to the ordered list at the top of this page, any `decode_etc` call +jumps forward to the next matching method in that canonical sequence, +implicitly calling any jumped over method with the same `io_reader` but null +values for other arguments. + +For example, starting with a freshly initialized image decoder, if it's a first +party image and you already know its width, height and pixel format (so you can +prepare a perfectly sized pixel buffer without having to call DIC or DFC), it +is valid to call DF, going straight to the DF #0 stage. This implicitly calls +DIC and DFC #0. + +Even if you didn't know the width, height and pixel format, it is still valid +to call DF with a smaller-dimensioned pixel buffer (which just means the +decoded image will be clipped) or with a different pixel format (the decoder +will convert). + +After that, it is valid to call DFC, going to the DFC #1 stage (or get "@end of +data" for still images), which would not make any implicit calls. + +After that, it is valid to call DFC, going to the DFC #2 stage, implicitly +calling DF #1. + +And so on. + +For example, starting at the DF #N-1 stage, it is valid to call DF again, which +will return "@end of data" because it first implicitly calls DF #N, which +returns "@end of data". + +Implicitly calling DF (skipping over the pixel data) is typically much faster +than explicitly calling DF (decompressing the pixel data). For example, +starting with a freshly initialized image decoder, if you just want to *count* +the number of animation frames, without needing each frame's decoded pixels, +just call DFC (and not DF) in a loop until "#end of data". + + +## State Machine + +It's not part of Wuffs' public API, but Wuffs' standard library's image decoder +implementations all have a private `call_sequence` field to track this state +machine. Broadly speaking, an image decoder starts in an initial state (labeled +`0x00`). The DIC call moves to state `0x20`. Subsequent DFC and DF calls bounce +between states `0x40` and `0x20` until the last DFC moves the final state +`0x60`. These are the bold-labeled states in the left hand column of the +diagram below: + +![Image Decoders Call Sequence +Diagram](./image-decoders-call-sequence-diagram.png) + +The original Google Docs document for that diagram [is +here](https://docs.google.com/document/d/1bbH9cpgxsMP8M5U4NsTotr-wSlyH85tiDKSJSF1HVXc/edit?usp=sharing). + +The italic-labeled states (whose numeric labels all have the `0x10` bit set) in +the right hand column are side-track states when [metadata](./metadata.md) is +encountered, and are discussed below. If the caller never opts in to seeing +metadata (opting in by calling `set_report_metadata`) then the decoder never +enters these `(base_value | 0x10)` states. + +The `0x08` bit is used when calling `restart_frame`, discussed below. The low +three bits are reserved but currently unused. + +The primary purposes of the `call_sequence` field is track when we've reached +"@end of data" and to reject method calls that occur out of sequence. Such +method calls result in the `"#bad call sequence"` error status value. For +example, a DIC call is illegal after a DIC, DFC or DF call. Similarly, a TMM +(`tell_me_more`) call is illegal unless the decoder is in a right hand column +state. + + +## Restarts + +Image decoding typically runs sequentially: the first frame (#0) is decoded, +then the second (#1), then the third (#2), etc. However, decoding can sometimes +happen in random access instead of sequential order. Playing a looping +animation may require rewinding back to the first frame. Replaying an animation +may be able to re-use previousy cached frames at times, so a decoder may be +asked to jump ahead. While Wuffs is designed for sequential decoding (as it +does not assume that its input byte stream is rewindable or seekable), using +Wuffs to implement other graphics APIs can involve [random access to animation +frames](https://github.com/google/skia/blob/ee6f41262b2ef86b5f06b33473379ac887401451/include/codec/SkCodec.h#L314-L319). + +The RF `restart_frame` method supports these usage patterns, setting up the +decoder so that it's just about to decode the I'th frame configuration (when +the `io_reader` is also placed at `io_position` previously returned by the I'th +DFC). + +The RF method can only be called when the image configuration has already been +decoded. Equivalently, only when the `call_sequence` is at least `0x20`. diff --git a/doc/std/image-decoders.md b/doc/std/image-decoders.md index 6a59abac..74f9fb6a 100644 --- a/doc/std/image-decoders.md +++ b/doc/std/image-decoders.md @@ -61,7 +61,9 @@ will implicitly parse and verify the image header, before parsing the first frame's header. Similarly, you can call only `decode_frame` N times, without calling `decode_image_config` or `decode_frame_config`, if you already know metadata like N and each frame's rectangle bounds by some other means (e.g. -this is a first party, statically known image). +this is a first party, statically known image). The [Image Decoders Call +Sequence](./image-decoders-call-sequence.md) document has more implementation +information. Specifically, starting with an unknown (but re-windable) animated image, if you want to just find N (i.e. count the number of frames), you can loop calling @@ -89,52 +91,8 @@ associated stream will also need to be rewound. ## Metadata -Images can also contain metadata (e.g. color profiles, time stamps). By -default, Wuffs' image decoders skip over metadata, but calling -`set_report_metadata` will opt in to having `decode_image_config` return early -when encountering metadata in the file. Calling `set_report_metadata` can be -done multiple times, each with a different -[FourCC](/doc/note/base38-and-fourcc.md) code such as `0x49434350` "ICCP" or -`0x584D5020` "XMP ", to indicate what sorts of metadata the caller is -interested in. Conversely, when the parser encounters metadata (and returns a -"@metadata reported" [status](/doc/note/statuses.md)), call `tell_me_more` to -see what sort of metadata it is. - -Some metadata is short and `tell_me_more` will also fill in its `minfo: nptr -more_information` out parameter with "parsed metadata". For example, Gamma -Correction metadata is a single numerical value and Primary Chromaticities -metadata is only eight numbers. From C++ code, call the `metadata_parsed__gama` -or `metadata_parsed__chrm` methods to retrieve these value. - -Some metadata is long (or at least variable length) and needs processing by a -separate parser. For example, processing XMP metadata usually involves some -sort of XML parser, regardless of what particular image format that XMP -metadata was embedded in. Wuffs decoders will return "raw metadata" instead of -parsing it themselves. Raw metadata is further sub-divided into two categories: -"raw passthrough" and "raw transform". Either way, note that raw metadata might -also be arranged in multiple (non-contiguous) chunks of the source data. - -"Raw passthrough" means that the bytes in the wire format can be sent "as is" -to the separate parser. Call `tell_me_more` in a loop (the `dst: io_writer` -argument will be ignored) and `metadata_raw_passthrough__range` to identify a -range (a chunk) of the input stream. Divert the bytes in that range to the -separate parser (which should advance the `io_buffer` to the end of that range) -and repeat the loop as long as `tell_me_more` returned a "$even more -information" status. - -"Raw transform" means that the bytes in the wire format have to be further -processed (e.g. decompressed) before sending them on to the separate parser. -That processing is done by the `image_decoder` callee, not the caller. Pass a -writable `dst io_buffer` to `tell_me_more` (where writable means that it has a -positive `writer_length`) and implementations should fill in that buffer with -post-transformed (e.g. decompressed) data to send onwards. Like any -`io_transformer`-like coroutine, this should be in a loop, as it may suspend -with "$short read" and "$short write" statuses. - -Either way, break the loop (after handling the `dst` and `minfo` out -parameters) when `tell_me_more` returns a NULL status, meaning ok, when the -metadata is complete. Afterwards, call the original action (e.g. -`decode_image_config`) again to resume after the "@metadata reported" detour. +The [Metadata](./metadata.md) document has more API information, applicable to +Wuffs' decoders but not specific to Wuffs' image decoders. ## API Listing @@ -171,6 +129,7 @@ In Wuffs syntax, the `base.image_decoder` methods are: - [example/gifplayer](/example/gifplayer) - [example/imageviewer](/example/imageviewer) - [example/sdl-imageviewer](/example/sdl-imageviewer) +- [script/print-average-pixel](/script/print-average-pixel.cc) Examples in other repositories: diff --git a/doc/std/metadata.md b/doc/std/metadata.md new file mode 100644 index 00000000..2ec954ee --- /dev/null +++ b/doc/std/metadata.md @@ -0,0 +1,48 @@ +# Metadata + +Files can also contain metadata (e.g. for image files, EXIF information, color +profiles and time stamps). By default, Wuffs' decoders skip over metadata, but +calling `set_report_metadata` will opt in to having `decode_etc` methods return +early when encountering metadata in the file. Calling `set_report_metadata` can +be done multiple times, each with a different +[FourCC](/doc/note/base38-and-fourcc.md) code such as `0x49434350` "ICCP" or +`0x584D5020` "XMP ", to indicate what sorts of metadata the caller is +interested in. Conversely, when the parser encounters metadata (and returns a +"@metadata reported" [status](/doc/note/statuses.md)), call `tell_me_more` to +see what sort of metadata it is. + +Some metadata is short and `tell_me_more` will also fill in its `minfo: nptr +more_information` out parameter with "parsed metadata". For example, Gamma +Correction metadata is a single numerical value and Primary Chromaticities +metadata is only eight numbers. From C++ code, call the `metadata_parsed__gama` +or `metadata_parsed__chrm` methods to retrieve these value. + +Some metadata is long (or at least variable length) and needs processing by a +separate parser. For example, processing XMP metadata usually involves some +sort of XML parser, regardless of what particular image format that XMP +metadata was embedded in. Wuffs decoders will return "raw metadata" instead of +parsing it themselves. Raw metadata is further sub-divided into two categories: +"raw passthrough" and "raw transform". Either way, note that raw metadata might +also be arranged in multiple (non-contiguous) chunks of the source data. + +"Raw passthrough" means that the bytes in the wire format can be sent "as is" +to the separate parser. Call `tell_me_more` in a loop (the `dst: io_writer` +argument will be ignored) and `metadata_raw_passthrough__range` to identify a +range (a chunk) of the input stream. Divert the bytes in that range to the +separate parser (which should advance the `io_buffer` to the end of that range) +and repeat the loop as long as `tell_me_more` returned a "$even more +information" status. + +"Raw transform" means that the bytes in the wire format have to be further +processed (e.g. decompressed) before sending them on to the separate parser. +That processing is done by the decoder callee, not the caller. Pass a writable +`dst io_buffer` to `tell_me_more` (where writable means that it has a positive +`writer_length`) and implementations should fill in that buffer with +post-transformed (e.g. decompressed) data to send onwards. Like any +`io_transformer`-like coroutine, this should be in a loop, as it may suspend +with "$short read" and "$short write" statuses. + +Either way, break the loop (after handling the `dst` and `minfo` out +parameters) when `tell_me_more` returns a NULL status, meaning ok, when the +metadata is complete. Afterwards, call the original action (e.g. `decode_etc`) +again to resume after the "@metadata reported" detour. diff --git a/release/c/wuffs-unsupported-snapshot.c b/release/c/wuffs-unsupported-snapshot.c index 2b5971e3..a34439e5 100644 --- a/release/c/wuffs-unsupported-snapshot.c +++ b/release/c/wuffs-unsupported-snapshot.c @@ -8178,9 +8178,8 @@ struct wuffs_gif__decoder__struct { uint64_t f_metadata_io_position; bool f_quirks[7]; bool f_delayed_num_decoded_frames; - bool f_end_of_data; - bool f_restarted; bool f_previous_lzw_decode_ended_abruptly; + bool f_seen_header; bool f_has_global_palette; uint8_t f_interlace; bool f_seen_num_animation_loops_value; @@ -9649,6 +9648,7 @@ struct wuffs_png__decoder__struct { bool f_seen_gama; bool f_seen_iccp; bool f_seen_idat; + bool f_seen_ihdr; bool f_seen_plte; bool f_seen_srgb; bool f_seen_trns; @@ -23507,7 +23507,7 @@ wuffs_bmp__decoder__decode_image_config( self->private_impl.f_frame_config_io_position, (self->private_impl.f_channel_masks[3] == 0)); } - self->private_impl.f_call_sequence = 3; + self->private_impl.f_call_sequence = 32; ok: self->private_impl.p_decode_image_config[0] = 0; @@ -23574,7 +23574,8 @@ wuffs_bmp__decoder__decode_frame_config( switch (coro_susp_point) { WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0; - if (self->private_impl.f_call_sequence < 3) { + if (self->private_impl.f_call_sequence == 32) { + } else if (self->private_impl.f_call_sequence < 32) { if (a_src) { a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); } @@ -23586,13 +23587,13 @@ wuffs_bmp__decoder__decode_frame_config( if (status.repr) { goto suspend; } - } else if (self->private_impl.f_call_sequence == 3) { + } else if (self->private_impl.f_call_sequence == 40) { if (self->private_impl.f_frame_config_io_position != wuffs_base__u64__sat_add((a_src ? a_src->meta.pos : 0), ((uint64_t)(iop_a_src - io0_a_src)))) { status = wuffs_base__make_status(wuffs_base__error__bad_restart); goto exit; } - } else if (self->private_impl.f_call_sequence == 4) { - self->private_impl.f_call_sequence = 255; + } else if (self->private_impl.f_call_sequence == 64) { + self->private_impl.f_call_sequence = 96; status = wuffs_base__make_status(wuffs_base__note__end_of_data); goto ok; } else { @@ -23615,7 +23616,7 @@ wuffs_bmp__decoder__decode_frame_config( false, 4278190080); } - self->private_impl.f_call_sequence = 4; + self->private_impl.f_call_sequence = 64; ok: self->private_impl.p_decode_frame_config[0] = 0; @@ -23687,7 +23688,8 @@ wuffs_bmp__decoder__decode_frame( switch (coro_susp_point) { WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0; - if (self->private_impl.f_call_sequence < 4) { + if (self->private_impl.f_call_sequence == 64) { + } else if (self->private_impl.f_call_sequence < 64) { if (a_src) { a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); } @@ -23699,7 +23701,6 @@ wuffs_bmp__decoder__decode_frame( if (status.repr) { goto suspend; } - } else if (self->private_impl.f_call_sequence == 4) { } else { status = wuffs_base__make_status(wuffs_base__note__end_of_data); goto ok; @@ -23799,7 +23800,7 @@ wuffs_bmp__decoder__decode_frame( iop_a_src += self->private_data.s_decode_frame[0].scratch; self->private_impl.f_pending_pad = 0; } - self->private_impl.f_call_sequence = 255; + self->private_impl.f_call_sequence = 96; ok: self->private_impl.p_decode_frame[0] = 0; @@ -24542,7 +24543,7 @@ wuffs_bmp__decoder__num_decoded_frame_configs( return 0; } - if (self->private_impl.f_call_sequence > 3) { + if (self->private_impl.f_call_sequence > 32) { return 1; } return 0; @@ -24561,7 +24562,7 @@ wuffs_bmp__decoder__num_decoded_frames( return 0; } - if (self->private_impl.f_call_sequence > 4) { + if (self->private_impl.f_call_sequence > 64) { return 1; } return 0; @@ -24584,13 +24585,13 @@ wuffs_bmp__decoder__restart_frame( : wuffs_base__error__initialize_not_called); } - if (self->private_impl.f_call_sequence < 3) { + if (self->private_impl.f_call_sequence < 32) { return wuffs_base__make_status(wuffs_base__error__bad_call_sequence); } if (a_index != 0) { return wuffs_base__make_status(wuffs_base__error__bad_argument); } - self->private_impl.f_call_sequence = 3; + self->private_impl.f_call_sequence = 40; self->private_impl.f_frame_config_io_position = a_io_position; return wuffs_base__make_status(NULL); } @@ -31379,7 +31380,10 @@ wuffs_gif__decoder__decode_image_config( switch (coro_susp_point) { WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0; - if (self->private_impl.f_call_sequence == 0) { + if (self->private_impl.f_call_sequence != 0) { + status = wuffs_base__make_status(wuffs_base__error__bad_call_sequence); + goto exit; + } else if ( ! self->private_impl.f_seen_header) { WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1); status = wuffs_gif__decoder__decode_header(self, a_src); if (status.repr) { @@ -31390,9 +31394,7 @@ wuffs_gif__decoder__decode_image_config( if (status.repr) { goto suspend; } - } else if (self->private_impl.f_call_sequence != 2) { - status = wuffs_base__make_status(wuffs_base__error__bad_call_sequence); - goto exit; + self->private_impl.f_seen_header = true; } WUFFS_BASE__COROUTINE_SUSPENSION_POINT(3); status = wuffs_gif__decoder__decode_up_to_id_part1(self, a_src); @@ -31422,7 +31424,7 @@ wuffs_gif__decoder__decode_image_config( self->private_impl.f_frame_config_io_position, v_ffio); } - self->private_impl.f_call_sequence = 3; + self->private_impl.f_call_sequence = 32; goto ok; ok: @@ -31511,7 +31513,7 @@ wuffs_gif__decoder__tell_me_more( switch (coro_susp_point) { WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0; - if (self->private_impl.f_call_sequence != 1) { + if ((self->private_impl.f_call_sequence & 16) == 0) { status = wuffs_base__make_status(wuffs_base__error__bad_call_sequence); goto exit; } @@ -31582,7 +31584,7 @@ wuffs_gif__decoder__tell_me_more( self->private_impl.f_metadata_io_position, self->private_impl.f_metadata_io_position); } - self->private_impl.f_call_sequence = 2; + self->private_impl.f_call_sequence &= 239; self->private_impl.f_metadata_fourcc = 0; self->private_impl.f_metadata_io_position = 0; status = wuffs_base__make_status(NULL); @@ -31717,16 +31719,17 @@ wuffs_gif__decoder__restart_frame( : wuffs_base__error__initialize_not_called); } - if (self->private_impl.f_call_sequence < 3) { + if (self->private_impl.f_call_sequence < 32) { return wuffs_base__make_status(wuffs_base__error__bad_call_sequence); + } else if (a_io_position == 0) { + return wuffs_base__make_status(wuffs_base__error__bad_argument); } self->private_impl.f_delayed_num_decoded_frames = false; - self->private_impl.f_end_of_data = false; - self->private_impl.f_restarted = true; self->private_impl.f_frame_config_io_position = a_io_position; self->private_impl.f_num_decoded_frame_configs_value = a_index; self->private_impl.f_num_decoded_frames_value = a_index; wuffs_gif__decoder__reset_gc(self); + self->private_impl.f_call_sequence = 40; return wuffs_base__make_status(NULL); } @@ -31781,50 +31784,64 @@ wuffs_gif__decoder__decode_frame_config( self->private_impl.f_ignore_metadata = true; self->private_impl.f_dirty_max_excl_y = 0; - if ( ! self->private_impl.f_end_of_data) { - if (self->private_impl.f_call_sequence == 0) { - if (a_src) { - a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); - } - WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1); - status = wuffs_gif__decoder__decode_image_config(self, NULL, a_src); - if (a_src) { - iop_a_src = a_src->data.ptr + a_src->meta.ri; - } - if (status.repr) { - goto suspend; - } - } else if (self->private_impl.f_call_sequence != 3) { - if (self->private_impl.f_call_sequence == 4) { - if (a_src) { - a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); - } - WUFFS_BASE__COROUTINE_SUSPENSION_POINT(2); - status = wuffs_gif__decoder__skip_frame(self, a_src); - if (a_src) { - iop_a_src = a_src->data.ptr + a_src->meta.ri; - } - if (status.repr) { - goto suspend; - } - } - if (a_src) { - a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); - } - WUFFS_BASE__COROUTINE_SUSPENSION_POINT(3); - status = wuffs_gif__decoder__decode_up_to_id_part1(self, a_src); - if (a_src) { - iop_a_src = a_src->data.ptr + a_src->meta.ri; - } - if (status.repr) { - goto suspend; - } + if ((self->private_impl.f_call_sequence & 16) != 0) { + status = wuffs_base__make_status(wuffs_base__error__bad_call_sequence); + goto exit; + } else if (self->private_impl.f_call_sequence == 32) { + } else if (self->private_impl.f_call_sequence < 32) { + if (a_src) { + a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); } - } - if (self->private_impl.f_end_of_data) { + WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1); + status = wuffs_gif__decoder__decode_image_config(self, NULL, a_src); + if (a_src) { + iop_a_src = a_src->data.ptr + a_src->meta.ri; + } + if (status.repr) { + goto suspend; + } + } else if (self->private_impl.f_call_sequence == 40) { + if (self->private_impl.f_frame_config_io_position != wuffs_base__u64__sat_add((a_src ? a_src->meta.pos : 0), ((uint64_t)(iop_a_src - io0_a_src)))) { + status = wuffs_base__make_status(wuffs_base__error__bad_restart); + goto exit; + } + } else if (self->private_impl.f_call_sequence == 64) { + if (a_src) { + a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); + } + WUFFS_BASE__COROUTINE_SUSPENSION_POINT(2); + status = wuffs_gif__decoder__skip_frame(self, a_src); + if (a_src) { + iop_a_src = a_src->data.ptr + a_src->meta.ri; + } + if (status.repr) { + goto suspend; + } + if (self->private_impl.f_call_sequence >= 96) { + status = wuffs_base__make_status(wuffs_base__note__end_of_data); + goto ok; + } + } else { status = wuffs_base__make_status(wuffs_base__note__end_of_data); goto ok; } + if ((self->private_impl.f_num_decoded_frame_configs_value > 0) || (self->private_impl.f_call_sequence == 40)) { + if (a_src) { + a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); + } + WUFFS_BASE__COROUTINE_SUSPENSION_POINT(3); + status = wuffs_gif__decoder__decode_up_to_id_part1(self, a_src); + if (a_src) { + iop_a_src = a_src->data.ptr + a_src->meta.ri; + } + if (status.repr) { + goto suspend; + } + if (self->private_impl.f_call_sequence >= 96) { + status = wuffs_base__make_status(wuffs_base__note__end_of_data); + goto ok; + } + } v_background_color = self->private_impl.f_black_color_u32_argb_premul; if ( ! self->private_impl.f_gc_has_transparent_index) { v_background_color = self->private_impl.f_background_color_u32_argb_premul; @@ -31856,7 +31873,7 @@ wuffs_gif__decoder__decode_frame_config( v_background_color); } wuffs_base__u64__sat_add_indirect(&self->private_impl.f_num_decoded_frame_configs_value, 1); - self->private_impl.f_call_sequence = 4; + self->private_impl.f_call_sequence = 64; ok: self->private_impl.p_decode_frame_config[0] = 0; @@ -31957,6 +31974,7 @@ wuffs_gif__decoder__skip_frame( wuffs_base__u64__sat_add_indirect(&self->private_impl.f_num_decoded_frames_value, 1); } wuffs_gif__decoder__reset_gc(self); + self->private_impl.f_call_sequence = 32; goto ok; ok: @@ -32013,12 +32031,16 @@ wuffs_gif__decoder__decode_frame( WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0; self->private_impl.f_ignore_metadata = true; - if (self->private_impl.f_call_sequence != 4) { + if (self->private_impl.f_call_sequence == 64) { + } else if (self->private_impl.f_call_sequence < 64) { WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1); status = wuffs_gif__decoder__decode_frame_config(self, NULL, a_src); if (status.repr) { goto suspend; } + } else { + status = wuffs_base__make_status(wuffs_base__note__end_of_data); + goto ok; } if (self->private_impl.f_quirks[5] && ((self->private_impl.f_frame_rect_x0 == self->private_impl.f_frame_rect_x1) || (self->private_impl.f_frame_rect_y0 == self->private_impl.f_frame_rect_y1))) { status = wuffs_base__make_status(wuffs_gif__error__bad_frame_size); @@ -32036,8 +32058,8 @@ wuffs_gif__decoder__decode_frame( } wuffs_base__u64__sat_add_indirect(&self->private_impl.f_num_decoded_frames_value, 1); wuffs_gif__decoder__reset_gc(self); + self->private_impl.f_call_sequence = 32; - goto ok; ok: self->private_impl.p_decode_frame[0] = 0; goto exit; @@ -32061,7 +32083,6 @@ wuffs_gif__decoder__decode_frame( static wuffs_base__empty_struct wuffs_gif__decoder__reset_gc( wuffs_gif__decoder* self) { - self->private_impl.f_call_sequence = 5; self->private_impl.f_gc_has_transparent_index = false; self->private_impl.f_gc_transparent_index = 0; self->private_impl.f_gc_disposal = 0; @@ -32094,15 +32115,8 @@ wuffs_gif__decoder__decode_up_to_id_part1( switch (coro_susp_point) { WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0; - if ( ! self->private_impl.f_restarted) { - if (self->private_impl.f_call_sequence != 2) { - self->private_impl.f_frame_config_io_position = wuffs_base__u64__sat_add((a_src ? a_src->meta.pos : 0), ((uint64_t)(iop_a_src - io0_a_src))); - } - } else if (self->private_impl.f_frame_config_io_position != wuffs_base__u64__sat_add((a_src ? a_src->meta.pos : 0), ((uint64_t)(iop_a_src - io0_a_src)))) { - status = wuffs_base__make_status(wuffs_base__error__bad_restart); - goto exit; - } else { - self->private_impl.f_restarted = false; + if ((self->private_impl.f_frame_config_io_position == 0) || (self->private_impl.f_num_decoded_frame_configs_value > 0)) { + self->private_impl.f_frame_config_io_position = wuffs_base__u64__sat_add((a_src ? a_src->meta.pos : 0), ((uint64_t)(iop_a_src - io0_a_src))); } while (true) { { @@ -32148,7 +32162,7 @@ wuffs_gif__decoder__decode_up_to_id_part1( self->private_impl.f_delayed_num_decoded_frames = false; wuffs_base__u64__sat_add_indirect(&self->private_impl.f_num_decoded_frames_value, 1); } - self->private_impl.f_end_of_data = true; + self->private_impl.f_call_sequence = 96; goto label__0__break; } } @@ -32784,13 +32798,13 @@ wuffs_gif__decoder__decode_ae( } else if (v_is_iccp && self->private_impl.f_report_metadata_iccp) { self->private_impl.f_metadata_fourcc = 1229144912; self->private_impl.f_metadata_io_position = wuffs_base__u64__sat_add((a_src ? a_src->meta.pos : 0), ((uint64_t)(iop_a_src - io0_a_src))); - self->private_impl.f_call_sequence = 1; + self->private_impl.f_call_sequence = 16; status = wuffs_base__make_status(wuffs_base__note__metadata_reported); goto ok; } else if (v_is_xmp && self->private_impl.f_report_metadata_xmp) { self->private_impl.f_metadata_fourcc = 1481461792; self->private_impl.f_metadata_io_position = wuffs_base__u64__sat_add((a_src ? a_src->meta.pos : 0), ((uint64_t)(iop_a_src - io0_a_src))); - self->private_impl.f_call_sequence = 1; + self->private_impl.f_call_sequence = 16; status = wuffs_base__make_status(wuffs_base__note__metadata_reported); goto ok; } @@ -33105,7 +33119,7 @@ wuffs_gif__decoder__decode_id_part0( self->private_impl.f_frame_rect_y1 += self->private_impl.f_frame_rect_y0; self->private_impl.f_dst_x = self->private_impl.f_frame_rect_x0; self->private_impl.f_dst_y = self->private_impl.f_frame_rect_y0; - if ((self->private_impl.f_call_sequence == 0) && ! self->private_impl.f_quirks[4]) { + if ((self->private_impl.f_num_decoded_frame_configs_value == 0) && ! self->private_impl.f_quirks[4]) { self->private_impl.f_width = wuffs_base__u32__max(self->private_impl.f_width, self->private_impl.f_frame_rect_x1); self->private_impl.f_height = wuffs_base__u32__max(self->private_impl.f_height, self->private_impl.f_frame_rect_y1); } @@ -36694,7 +36708,7 @@ wuffs_nie__decoder__decode_image_config( 16, false); } - self->private_impl.f_call_sequence = 3; + self->private_impl.f_call_sequence = 32; goto ok; ok: @@ -36762,7 +36776,8 @@ wuffs_nie__decoder__decode_frame_config( switch (coro_susp_point) { WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0; - if (self->private_impl.f_call_sequence < 3) { + if (self->private_impl.f_call_sequence == 32) { + } else if (self->private_impl.f_call_sequence < 32) { if (a_src) { a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); } @@ -36774,13 +36789,13 @@ wuffs_nie__decoder__decode_frame_config( if (status.repr) { goto suspend; } - } else if (self->private_impl.f_call_sequence == 3) { + } else if (self->private_impl.f_call_sequence == 40) { if (16 != wuffs_base__u64__sat_add((a_src ? a_src->meta.pos : 0), ((uint64_t)(iop_a_src - io0_a_src)))) { status = wuffs_base__make_status(wuffs_base__error__bad_restart); goto exit; } - } else if (self->private_impl.f_call_sequence == 4) { - self->private_impl.f_call_sequence = 255; + } else if (self->private_impl.f_call_sequence == 64) { + self->private_impl.f_call_sequence = 96; status = wuffs_base__make_status(wuffs_base__note__end_of_data); goto ok; } else { @@ -36803,7 +36818,7 @@ wuffs_nie__decoder__decode_frame_config( false, 0); } - self->private_impl.f_call_sequence = 4; + self->private_impl.f_call_sequence = 64; ok: self->private_impl.p_decode_frame_config[0] = 0; @@ -36864,13 +36879,13 @@ wuffs_nie__decoder__decode_frame( switch (coro_susp_point) { WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0; - if (self->private_impl.f_call_sequence < 4) { + if (self->private_impl.f_call_sequence == 64) { + } else if (self->private_impl.f_call_sequence < 64) { WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1); status = wuffs_nie__decoder__decode_frame_config(self, NULL, a_src); if (status.repr) { goto suspend; } - } else if (self->private_impl.f_call_sequence == 4) { } else { status = wuffs_base__make_status(wuffs_base__note__end_of_data); goto ok; @@ -36911,7 +36926,7 @@ wuffs_nie__decoder__decode_frame( WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(2); } label__0__break:; - self->private_impl.f_call_sequence = 255; + self->private_impl.f_call_sequence = 96; ok: self->private_impl.p_decode_frame[0] = 0; @@ -37061,7 +37076,7 @@ wuffs_nie__decoder__num_decoded_frame_configs( return 0; } - if (self->private_impl.f_call_sequence > 3) { + if (self->private_impl.f_call_sequence > 32) { return 1; } return 0; @@ -37080,7 +37095,7 @@ wuffs_nie__decoder__num_decoded_frames( return 0; } - if (self->private_impl.f_call_sequence > 4) { + if (self->private_impl.f_call_sequence > 64) { return 1; } return 0; @@ -37103,13 +37118,13 @@ wuffs_nie__decoder__restart_frame( : wuffs_base__error__initialize_not_called); } - if (self->private_impl.f_call_sequence < 3) { + if (self->private_impl.f_call_sequence < 32) { return wuffs_base__make_status(wuffs_base__error__bad_call_sequence); } if ((a_index != 0) || (a_io_position != 16)) { return wuffs_base__make_status(wuffs_base__error__bad_argument); } - self->private_impl.f_call_sequence = 3; + self->private_impl.f_call_sequence = 40; return wuffs_base__make_status(NULL); } @@ -39576,16 +39591,10 @@ wuffs_png__decoder__decode_image_config( switch (coro_susp_point) { WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0; - if (self->private_impl.f_call_sequence == 2) { - if (self->private_impl.f_metadata_fourcc != 0) { - self->private_impl.f_call_sequence = 1; - status = wuffs_base__make_status(wuffs_base__note__metadata_reported); - goto ok; - } - } else if (self->private_impl.f_call_sequence != 0) { + if (self->private_impl.f_call_sequence != 0) { status = wuffs_base__make_status(wuffs_base__error__bad_call_sequence); goto exit; - } else { + } else if ( ! self->private_impl.f_seen_ihdr) { { WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1); uint64_t t_0; @@ -39718,6 +39727,11 @@ wuffs_png__decoder__decode_image_config( status = wuffs_base__make_status(wuffs_png__error__bad_checksum); goto exit; } + self->private_impl.f_seen_ihdr = true; + } else if (self->private_impl.f_metadata_fourcc != 0) { + self->private_impl.f_call_sequence = 16; + status = wuffs_base__make_status(wuffs_base__note__metadata_reported); + goto ok; } while (true) { while (((uint64_t)(io2_a_src - iop_a_src)) < 8) { @@ -39775,7 +39789,7 @@ wuffs_png__decoder__decode_image_config( } label__2__break:; if (self->private_impl.f_metadata_fourcc != 0) { - self->private_impl.f_call_sequence = 1; + self->private_impl.f_call_sequence = 16; status = wuffs_base__make_status(wuffs_base__note__metadata_reported); goto ok; } @@ -39840,7 +39854,7 @@ wuffs_png__decoder__decode_image_config( self->private_impl.f_first_disposal = 0; self->private_impl.f_first_overwrite_instead_of_blend = false; } - self->private_impl.f_call_sequence = 3; + self->private_impl.f_call_sequence = 32; ok: self->private_impl.p_decode_image_config[0] = 0; @@ -41801,10 +41815,11 @@ wuffs_png__decoder__decode_frame_config( switch (coro_susp_point) { WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0; - if (self->private_impl.f_call_sequence == 255) { - status = wuffs_base__make_status(wuffs_base__note__end_of_data); - goto ok; - } else if (self->private_impl.f_call_sequence < 3) { + if ((self->private_impl.f_call_sequence & 16) != 0) { + status = wuffs_base__make_status(wuffs_base__error__bad_call_sequence); + goto exit; + } else if (self->private_impl.f_call_sequence == 32) { + } else if (self->private_impl.f_call_sequence < 32) { if (a_src) { a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); } @@ -41816,12 +41831,12 @@ wuffs_png__decoder__decode_frame_config( if (status.repr) { goto suspend; } - } else if (self->private_impl.f_call_sequence == 3) { + } else if (self->private_impl.f_call_sequence == 40) { if (self->private_impl.f_frame_config_io_position != wuffs_base__u64__sat_add((a_src ? a_src->meta.pos : 0), ((uint64_t)(iop_a_src - io0_a_src)))) { status = wuffs_base__make_status(wuffs_base__error__bad_restart); goto exit; } - } else if (self->private_impl.f_call_sequence == 4) { + } else if (self->private_impl.f_call_sequence == 64) { if (a_src) { a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); } @@ -41833,10 +41848,13 @@ wuffs_png__decoder__decode_frame_config( if (status.repr) { goto suspend; } - if (self->private_impl.f_call_sequence == 255) { + if (self->private_impl.f_call_sequence >= 96) { status = wuffs_base__make_status(wuffs_base__note__end_of_data); goto ok; } + } else { + status = wuffs_base__make_status(wuffs_base__note__end_of_data); + goto ok; } if (self->private_impl.f_num_decoded_frame_configs_value == 0) { self->private_impl.f_frame_rect_x0 = self->private_impl.f_first_rect_x0; @@ -41964,7 +41982,7 @@ wuffs_png__decoder__decode_frame_config( 0); } wuffs_base__u32__sat_add_indirect(&self->private_impl.f_num_decoded_frame_configs_value, 1); - self->private_impl.f_call_sequence = 4; + self->private_impl.f_call_sequence = 64; ok: self->private_impl.p_decode_frame_config[0] = 0; @@ -42121,9 +42139,9 @@ wuffs_png__decoder__skip_frame( label__0__break:; wuffs_base__u32__sat_add_indirect(&self->private_impl.f_num_decoded_frames_value, 1); if (self->private_impl.f_num_decoded_frames_value < self->private_impl.f_num_animation_frames_value) { - self->private_impl.f_call_sequence = 5; + self->private_impl.f_call_sequence = 32; } else { - self->private_impl.f_call_sequence = 255; + self->private_impl.f_call_sequence = 96; } ok: @@ -42195,10 +42213,13 @@ wuffs_png__decoder__decode_frame( switch (coro_susp_point) { WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0; - if (self->private_impl.f_call_sequence == 255) { + if ((self->private_impl.f_call_sequence & 16) != 0) { + status = wuffs_base__make_status(wuffs_base__error__bad_call_sequence); + goto exit; + } else if (self->private_impl.f_call_sequence >= 96) { status = wuffs_base__make_status(wuffs_base__note__end_of_data); goto ok; - } else if (self->private_impl.f_call_sequence != 4) { + } else if (self->private_impl.f_call_sequence != 64) { if (a_src) { a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); } @@ -42391,9 +42412,9 @@ wuffs_png__decoder__decode_frame( label__2__break:; wuffs_base__u32__sat_add_indirect(&self->private_impl.f_num_decoded_frames_value, 1); if (self->private_impl.f_num_decoded_frames_value < self->private_impl.f_num_animation_frames_value) { - self->private_impl.f_call_sequence = 5; + self->private_impl.f_call_sequence = 32; } else { - self->private_impl.f_call_sequence = 255; + self->private_impl.f_call_sequence = 96; } ok: @@ -42842,12 +42863,12 @@ wuffs_png__decoder__restart_frame( : wuffs_base__error__initialize_not_called); } - if (self->private_impl.f_call_sequence < 3) { + if (self->private_impl.f_call_sequence < 32) { return wuffs_base__make_status(wuffs_base__error__bad_call_sequence); } else if ((a_index >= ((uint64_t)(self->private_impl.f_num_animation_frames_value))) || ((a_index == 0) && (a_io_position != self->private_impl.f_first_config_io_position))) { return wuffs_base__make_status(wuffs_base__error__bad_argument); } - self->private_impl.f_call_sequence = 3; + self->private_impl.f_call_sequence = 40; if (self->private_impl.f_interlace_pass >= 1) { self->private_impl.f_interlace_pass = 1; } @@ -42960,7 +42981,7 @@ wuffs_png__decoder__tell_me_more( switch (coro_susp_point) { WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0; - if (self->private_impl.f_call_sequence != 1) { + if ((self->private_impl.f_call_sequence & 16) == 0) { status = wuffs_base__make_status(wuffs_base__error__bad_call_sequence); goto exit; } @@ -43355,7 +43376,7 @@ wuffs_png__decoder__tell_me_more( } self->private_impl.f_metadata_is_zlib_compressed = true; } - self->private_impl.f_call_sequence = 2; + self->private_impl.f_call_sequence &= 239; status = wuffs_base__make_status(NULL); goto ok; } @@ -43380,7 +43401,7 @@ wuffs_png__decoder__tell_me_more( self->private_impl.f_metadata_x = 0; self->private_impl.f_metadata_y = 0; self->private_impl.f_metadata_z = 0; - self->private_impl.f_call_sequence = 2; + self->private_impl.f_call_sequence &= 239; status = wuffs_base__make_status(NULL); goto ok; @@ -44371,7 +44392,7 @@ wuffs_tga__decoder__decode_image_config( self->private_impl.f_frame_config_io_position, self->private_impl.f_opaque); } - self->private_impl.f_call_sequence = 3; + self->private_impl.f_call_sequence = 32; goto ok; ok: @@ -44440,7 +44461,8 @@ wuffs_tga__decoder__decode_frame_config( switch (coro_susp_point) { WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0; - if (self->private_impl.f_call_sequence < 3) { + if (self->private_impl.f_call_sequence == 32) { + } else if (self->private_impl.f_call_sequence < 32) { if (a_src) { a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); } @@ -44452,13 +44474,13 @@ wuffs_tga__decoder__decode_frame_config( if (status.repr) { goto suspend; } - } else if (self->private_impl.f_call_sequence == 3) { + } else if (self->private_impl.f_call_sequence == 40) { if (self->private_impl.f_frame_config_io_position != wuffs_base__u64__sat_add((a_src ? a_src->meta.pos : 0), ((uint64_t)(iop_a_src - io0_a_src)))) { status = wuffs_base__make_status(wuffs_base__error__bad_restart); goto exit; } - } else if (self->private_impl.f_call_sequence == 4) { - self->private_impl.f_call_sequence = 255; + } else if (self->private_impl.f_call_sequence == 64) { + self->private_impl.f_call_sequence = 96; status = wuffs_base__make_status(wuffs_base__note__end_of_data); goto ok; } else { @@ -44481,7 +44503,7 @@ wuffs_tga__decoder__decode_frame_config( false, 4278190080); } - self->private_impl.f_call_sequence = 4; + self->private_impl.f_call_sequence = 64; ok: self->private_impl.p_decode_frame_config[0] = 0; @@ -44582,7 +44604,8 @@ wuffs_tga__decoder__decode_frame( switch (coro_susp_point) { WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0; - if (self->private_impl.f_call_sequence < 4) { + if (self->private_impl.f_call_sequence == 64) { + } else if (self->private_impl.f_call_sequence < 64) { if (a_src) { a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); } @@ -44594,7 +44617,6 @@ wuffs_tga__decoder__decode_frame( if (status.repr) { goto suspend; } - } else if (self->private_impl.f_call_sequence == 4) { } else { status = wuffs_base__make_status(wuffs_base__note__end_of_data); goto ok; @@ -44821,7 +44843,7 @@ wuffs_tga__decoder__decode_frame( goto label__resume__break; } label__resume__break:; - self->private_impl.f_call_sequence = 255; + self->private_impl.f_call_sequence = 96; ok: self->private_impl.p_decode_frame[0] = 0; @@ -44902,7 +44924,7 @@ wuffs_tga__decoder__num_decoded_frame_configs( return 0; } - if (self->private_impl.f_call_sequence > 3) { + if (self->private_impl.f_call_sequence > 32) { return 1; } return 0; @@ -44921,7 +44943,7 @@ wuffs_tga__decoder__num_decoded_frames( return 0; } - if (self->private_impl.f_call_sequence > 4) { + if (self->private_impl.f_call_sequence > 64) { return 1; } return 0; @@ -44944,13 +44966,13 @@ wuffs_tga__decoder__restart_frame( : wuffs_base__error__initialize_not_called); } - if (self->private_impl.f_call_sequence < 3) { + if (self->private_impl.f_call_sequence < 32) { return wuffs_base__make_status(wuffs_base__error__bad_call_sequence); } if (a_index != 0) { return wuffs_base__make_status(wuffs_base__error__bad_argument); } - self->private_impl.f_call_sequence = 3; + self->private_impl.f_call_sequence = 40; self->private_impl.f_frame_config_io_position = a_io_position; return wuffs_base__make_status(NULL); } @@ -45270,7 +45292,7 @@ wuffs_wbmp__decoder__decode_image_config( self->private_impl.f_frame_config_io_position, true); } - self->private_impl.f_call_sequence = 3; + self->private_impl.f_call_sequence = 32; goto ok; ok: @@ -45340,7 +45362,8 @@ wuffs_wbmp__decoder__decode_frame_config( switch (coro_susp_point) { WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0; - if (self->private_impl.f_call_sequence < 3) { + if (self->private_impl.f_call_sequence == 32) { + } else if (self->private_impl.f_call_sequence < 32) { if (a_src) { a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); } @@ -45352,13 +45375,13 @@ wuffs_wbmp__decoder__decode_frame_config( if (status.repr) { goto suspend; } - } else if (self->private_impl.f_call_sequence == 3) { + } else if (self->private_impl.f_call_sequence == 40) { if (self->private_impl.f_frame_config_io_position != wuffs_base__u64__sat_add((a_src ? a_src->meta.pos : 0), ((uint64_t)(iop_a_src - io0_a_src)))) { status = wuffs_base__make_status(wuffs_base__error__bad_restart); goto exit; } - } else if (self->private_impl.f_call_sequence == 4) { - self->private_impl.f_call_sequence = 255; + } else if (self->private_impl.f_call_sequence == 64) { + self->private_impl.f_call_sequence = 96; status = wuffs_base__make_status(wuffs_base__note__end_of_data); goto ok; } else { @@ -45381,7 +45404,7 @@ wuffs_wbmp__decoder__decode_frame_config( false, 4278190080); } - self->private_impl.f_call_sequence = 4; + self->private_impl.f_call_sequence = 64; ok: self->private_impl.p_decode_frame_config[0] = 0; @@ -45470,7 +45493,8 @@ wuffs_wbmp__decoder__decode_frame( switch (coro_susp_point) { WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0; - if (self->private_impl.f_call_sequence < 4) { + if (self->private_impl.f_call_sequence == 64) { + } else if (self->private_impl.f_call_sequence < 64) { if (a_src) { a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); } @@ -45482,7 +45506,6 @@ wuffs_wbmp__decoder__decode_frame( if (status.repr) { goto suspend; } - } else if (self->private_impl.f_call_sequence == 4) { } else { status = wuffs_base__make_status(wuffs_base__note__end_of_data); goto ok; @@ -45545,7 +45568,7 @@ wuffs_wbmp__decoder__decode_frame( v_dst_y += 1; } } - self->private_impl.f_call_sequence = 255; + self->private_impl.f_call_sequence = 96; ok: self->private_impl.p_decode_frame[0] = 0; @@ -45623,7 +45646,7 @@ wuffs_wbmp__decoder__num_decoded_frame_configs( return 0; } - if (self->private_impl.f_call_sequence > 3) { + if (self->private_impl.f_call_sequence > 32) { return 1; } return 0; @@ -45642,7 +45665,7 @@ wuffs_wbmp__decoder__num_decoded_frames( return 0; } - if (self->private_impl.f_call_sequence > 4) { + if (self->private_impl.f_call_sequence > 64) { return 1; } return 0; @@ -45665,13 +45688,13 @@ wuffs_wbmp__decoder__restart_frame( : wuffs_base__error__initialize_not_called); } - if (self->private_impl.f_call_sequence < 3) { + if (self->private_impl.f_call_sequence < 32) { return wuffs_base__make_status(wuffs_base__error__bad_call_sequence); } if (a_index != 0) { return wuffs_base__make_status(wuffs_base__error__bad_argument); } - self->private_impl.f_call_sequence = 3; + self->private_impl.f_call_sequence = 40; self->private_impl.f_frame_config_io_position = a_io_position; return wuffs_base__make_status(NULL); } diff --git a/std/bmp/decode_bmp.wuffs b/std/bmp/decode_bmp.wuffs index bae1eed1..f6bc1608 100644 --- a/std/bmp/decode_bmp.wuffs +++ b/std/bmp/decode_bmp.wuffs @@ -33,31 +33,8 @@ pub struct decoder? implements base.image_decoder( width : base.u32[..= 0x7FFF_FFFF], height : base.u32[..= 0x7FFF_FFFF], - // Call sequence states: - // - 0x00: initial state. - // - 0x03: image config decoded. - // - 0x04: frame config decoded. - // - 0xFF: end-of-data, usually after (the non-animated) frame decoded. - // - // State transitions: - // - // - 0x00 -> 0x03: via DIC - // - 0x00 -> 0x04: via DFC with implicit DIC - // - 0x00 -> 0xFF: via DF with implicit DIC and DFC - // - // - 0x03 -> 0x04: via DFC - // - 0x03 -> 0xFF: via DF with implicit DFC - // - // - 0x04 -> 0xFF: via DFC - // - 0x04 -> 0xFF: via DF - // - // - ???? -> 0x03: via RF for ???? > 0x00 - // - // Where: - // - DF is decode_frame - // - DFC is decode_frame_config, implicit means nullptr args.dst - // - DIC is decode_image_config, implicit means nullptr args.dst - // - RF is restart_frame + // The call sequence state machine is discussed in + // (/doc/std/image-decoders-call-sequence.md). call_sequence : base.u8, top_down : base.bool, @@ -115,7 +92,7 @@ pub func decoder.decode_image_config?(dst: nptr base.image_config, src: base.io_ var dst_pixfmt : base.u32 var byte_width : base.u32 - if (this.call_sequence <> 0) or (this.io_redirect_fourcc == 1) { + if (this.call_sequence <> 0x00) or (this.io_redirect_fourcc == 1) { return base."#bad call sequence" } else if this.io_redirect_fourcc <> 0 { return base."@I/O redirect" @@ -389,18 +366,20 @@ pub func decoder.decode_image_config?(dst: nptr base.image_config, src: base.io_ first_frame_is_opaque: this.channel_masks[3] == 0) } - this.call_sequence = 3 + this.call_sequence = 0x20 } pub func decoder.decode_frame_config?(dst: nptr base.frame_config, src: base.io_reader) { - if this.call_sequence < 3 { + if this.call_sequence == 0x20 { + // No-op. + } else if this.call_sequence < 0x20 { this.decode_image_config?(dst: nullptr, src: args.src) - } else if this.call_sequence == 3 { + } else if this.call_sequence == 0x28 { if this.frame_config_io_position <> args.src.position() { return base."#bad restart" } - } else if this.call_sequence == 4 { - this.call_sequence = 0xFF + } else if this.call_sequence == 0x40 { + this.call_sequence = 0x60 return base."@end of data" } else { return base."@end of data" @@ -421,16 +400,16 @@ pub func decoder.decode_frame_config?(dst: nptr base.frame_config, src: base.io_ background_color: 0xFF00_0000) } - this.call_sequence = 4 + this.call_sequence = 0x40 } pub func decoder.decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reader, blend: base.pixel_blend, workbuf: slice base.u8, opts: nptr base.decode_frame_options) { var status : base.status - if this.call_sequence < 4 { - this.decode_frame_config?(dst: nullptr, src: args.src) - } else if this.call_sequence == 4 { + if this.call_sequence == 0x40 { // No-op. + } else if this.call_sequence < 0x40 { + this.decode_frame_config?(dst: nullptr, src: args.src) } else { return base."@end of data" } @@ -480,7 +459,7 @@ pub func decoder.decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reader, this.pending_pad = 0 } - this.call_sequence = 0xFF + this.call_sequence = 0x60 } pri func decoder.swizzle_none!(dst: ptr base.pixel_buffer, src: base.io_reader) base.status { @@ -1116,27 +1095,27 @@ pub func decoder.num_animation_loops() base.u32 { } pub func decoder.num_decoded_frame_configs() base.u64 { - if this.call_sequence > 3 { + if this.call_sequence > 0x20 { return 1 } return 0 } pub func decoder.num_decoded_frames() base.u64 { - if this.call_sequence > 4 { + if this.call_sequence > 0x40 { return 1 } return 0 } pub func decoder.restart_frame!(index: base.u64, io_position: base.u64) base.status { - if this.call_sequence < 3 { + if this.call_sequence < 0x20 { return base."#bad call sequence" } if args.index <> 0 { return base."#bad argument" } - this.call_sequence = 3 + this.call_sequence = 0x28 this.frame_config_io_position = args.io_position return ok } diff --git a/std/gif/decode_gif.wuffs b/std/gif/decode_gif.wuffs index d872de9a..34bc6735 100644 --- a/std/gif/decode_gif.wuffs +++ b/std/gif/decode_gif.wuffs @@ -16,50 +16,13 @@ pub struct decoder? implements base.image_decoder( width : base.u32, height : base.u32, - // Call sequence states: - // - 0x00: initial state. - // - 0x01: metadata reported; image config decode is in progress. - // - 0x02: metadata finished; image config decode is in progress. - // - 0x03: image config decoded, including the first frame's bounds, but - // not the first frame's pixels. - // - 0x04: frame config decoded. - // - 0x05: frame decoded. + // The call sequence state machine is discussed in + // (/doc/std/image-decoders-call-sequence.md). // - // GIF is unusual (distinguishing state 0x03 / state 0x05) in that the - // first frame's bounds can affect the overall image bounds (as per + // A GIF's first frame's bounds affects the overall image bounds (per // test/data/artificial/gif-frame-out-of-bounds.gif.make-artificial.txt). - // Decoding the first frame's bounds is part of DIC even though, - // conceptually, it should be part of the first DFC. - // - // State transitions: - // - // - 0x00 -> 0x01: via DIC (metadata reported) - // - 0x00 -> 0x03: via DIC (metadata not reported) - // - 0x00 -> 0x04: via DFC with implicit DIC - // - 0x00 -> 0x05: via DF with implicit DIC and DFC - // - // - 0x01 -> 0x02: via TMM - // - // - 0x02 -> 0x01: via DIC (metadata reported) - // - 0x02 -> 0x03: via DIC (metadata not reported) - // - // - 0x03 -> 0x04: via DFC - // - 0x03 -> 0x05: via DF with implicit DFC - // - // - 0x04 -> 0x04: via DFC with implicit DF - // - 0x04 -> 0x05: via DF - // - // - 0x05 -> 0x04: via DFC - // - 0x05 -> 0x05: via DF with implicit DFC - // - // - ???? -> 0x05: via RF for ???? > 0x00 - // - // Where: - // - DF is decode_frame, implicit means skip_frame - // - DFC is decode_frame_config, implicit means nullptr args.dst - // - DIC is decode_image_config, implicit means nullptr args.dst - // - RF is restart_frame - // - TMM is tell_me_more + // Decoding the first frame's bounds is part of decode_image_config even + // though it's conceptually part of the first decode_frame_config. call_sequence : base.u8, ignore_metadata : base.bool, @@ -71,9 +34,8 @@ pub struct decoder? implements base.image_decoder( quirks : array[QUIRKS_COUNT] base.bool, delayed_num_decoded_frames : base.bool, - end_of_data : base.bool, - restarted : base.bool, previous_lzw_decode_ended_abruptly : base.bool, + seen_header : base.bool, has_global_palette : base.bool, @@ -128,7 +90,7 @@ pub struct decoder? implements base.image_decoder( ) pub func decoder.set_quirk_enabled!(quirk: base.u32, enabled: base.bool) { - if (this.call_sequence == 0) and (args.quirk >= QUIRKS_BASE) { + if (this.call_sequence == 0x00) and (args.quirk >= QUIRKS_BASE) { args.quirk -= QUIRKS_BASE if args.quirk < QUIRKS_COUNT { this.quirks[args.quirk] = args.enabled @@ -139,17 +101,16 @@ pub func decoder.set_quirk_enabled!(quirk: base.u32, enabled: base.bool) { pub func decoder.decode_image_config?(dst: nptr base.image_config, src: base.io_reader) { var ffio : base.bool - if this.call_sequence == 0 { + if this.call_sequence <> 0x00 { + return base."#bad call sequence" + } else if not this.seen_header { this.decode_header?(src: args.src) this.decode_lsd?(src: args.src) - } else if this.call_sequence <> 2 { - return base."#bad call sequence" + this.seen_header = true } this.decode_up_to_id_part1?(src: args.src) - // 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.quirks[QUIRK_HONOR_BACKGROUND_COLOR - QUIRKS_BASE] { ffio = ffio and @@ -176,7 +137,7 @@ pub func decoder.decode_image_config?(dst: nptr base.image_config, src: base.io_ first_frame_is_opaque: ffio) } - this.call_sequence = 3 + this.call_sequence = 0x20 } pub func decoder.set_report_metadata!(fourcc: base.u32, report: base.bool) { @@ -190,7 +151,7 @@ pub func decoder.set_report_metadata!(fourcc: base.u32, report: base.bool) { pub func decoder.tell_me_more?(dst: base.io_writer, minfo: nptr base.more_information, src: base.io_reader) { var chunk_length : base.u64 - if this.call_sequence <> 1 { + if (this.call_sequence & 0x10) == 0 { return base."#bad call sequence" } if this.metadata_fourcc == 0 { @@ -267,7 +228,7 @@ pub func decoder.tell_me_more?(dst: base.io_writer, minfo: nptr base.more_inform y: this.metadata_io_position, z: this.metadata_io_position) } - this.call_sequence = 2 + this.call_sequence &= 0xEF this.metadata_fourcc = 0 this.metadata_io_position = 0 return ok @@ -319,16 +280,17 @@ pub func decoder.workbuf_len() base.range_ii_u64 { } pub func decoder.restart_frame!(index: base.u64, io_position: base.u64) base.status { - if this.call_sequence < 3 { + if this.call_sequence < 0x20 { return base."#bad call sequence" + } else if args.io_position == 0 { + return base."#bad argument" } this.delayed_num_decoded_frames = false - this.end_of_data = false - this.restarted = true this.frame_config_io_position = args.io_position this.num_decoded_frame_configs_value = args.index this.num_decoded_frames_value = args.index this.reset_gc!() + this.call_sequence = 0x28 return ok } @@ -340,21 +302,30 @@ pub func decoder.decode_frame_config?(dst: nptr base.frame_config, src: base.io_ this.dirty_max_excl_y = 0 - if not this.end_of_data { - if this.call_sequence == 0 { - this.decode_image_config?(dst: nullptr, src: args.src) - } else if this.call_sequence <> 3 { - if this.call_sequence == 4 { - this.skip_frame?(src: args.src) - } - this.decode_up_to_id_part1?(src: args.src) + if (this.call_sequence & 0x10) <> 0 { + return base."#bad call sequence" + } else if this.call_sequence == 0x20 { + // No-op. + } else if this.call_sequence < 0x20 { + this.decode_image_config?(dst: nullptr, src: args.src) + } else if this.call_sequence == 0x28 { + if this.frame_config_io_position <> args.src.position() { + return base."#bad restart" } + } else if this.call_sequence == 0x40 { + this.skip_frame?(src: args.src) + if this.call_sequence >= 0x60 { + return base."@end of data" + } + } else { + return base."@end of data" } - // This is a new "if", not an "else", because the calls above can modify - // this.end_of_data. - if this.end_of_data { - return base."@end of data" + if (this.num_decoded_frame_configs_value > 0) or (this.call_sequence == 0x28) { + this.decode_up_to_id_part1?(src: args.src) + if this.call_sequence >= 0x60 { + return base."@end of data" + } } background_color = this.black_color_u32_argb_premul @@ -396,7 +367,7 @@ pub func decoder.decode_frame_config?(dst: nptr base.frame_config, src: base.io_ } this.num_decoded_frame_configs_value ~sat+= 1 - this.call_sequence = 4 + this.call_sequence = 0x40 } pri func decoder.skip_frame?(src: base.io_reader) { @@ -424,13 +395,18 @@ pri func decoder.skip_frame?(src: base.io_reader) { this.num_decoded_frames_value ~sat+= 1 } this.reset_gc!() + this.call_sequence = 0x20 } // TODO: honor args.opts. pub func decoder.decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reader, blend: base.pixel_blend, workbuf: slice base.u8, opts: nptr base.decode_frame_options) { this.ignore_metadata = true - if this.call_sequence <> 4 { + if this.call_sequence == 0x40 { + // No-op. + } else if this.call_sequence < 0x40 { this.decode_frame_config?(dst: nullptr, src: args.src) + } else { + return base."@end of data" } if this.quirks[QUIRK_REJECT_EMPTY_FRAME - QUIRKS_BASE] and ((this.frame_rect_x0 == this.frame_rect_x1) or (this.frame_rect_y0 == this.frame_rect_y1)) { @@ -441,10 +417,10 @@ pub func decoder.decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reader, this.num_decoded_frames_value ~sat+= 1 this.reset_gc!() + this.call_sequence = 0x20 } pri func decoder.reset_gc!() { - this.call_sequence = 5 // The Image Descriptor is mandatory, but the Graphic Control extension is // optional. Reset the GC related fields for the next decode_frame call. this.gc_has_transparent_index = false @@ -456,14 +432,8 @@ pri func decoder.reset_gc!() { pri func decoder.decode_up_to_id_part1?(src: base.io_reader) { var block_type : base.u8 - if not this.restarted { - if this.call_sequence <> 2 { - this.frame_config_io_position = args.src.position() - } - } else if this.frame_config_io_position <> args.src.position() { - return base."#bad restart" - } else { - this.restarted = false + if (this.frame_config_io_position == 0) or (this.num_decoded_frame_configs_value > 0) { + this.frame_config_io_position = args.src.position() } while true { @@ -494,7 +464,7 @@ pri func decoder.decode_up_to_id_part1?(src: base.io_reader) { this.delayed_num_decoded_frames = false this.num_decoded_frames_value ~sat+= 1 } - this.end_of_data = true + this.call_sequence = 0x60 break } } endwhile @@ -698,13 +668,13 @@ pri func decoder.decode_ae?(src: base.io_reader) { } else if is_iccp and this.report_metadata_iccp { this.metadata_fourcc = 'ICCP'be this.metadata_io_position = args.src.position() - this.call_sequence = 1 + this.call_sequence = 0x10 return base."@metadata reported" } else if is_xmp and this.report_metadata_xmp { this.metadata_fourcc = 'XMP 'be this.metadata_io_position = args.src.position() - this.call_sequence = 1 + this.call_sequence = 0x10 return base."@metadata reported" } @@ -759,7 +729,7 @@ pri func decoder.decode_gc?(src: base.io_reader) { // // See the spec section 20 "Image Descriptor" on page 11. // -// The code is split into three parts (part0, part 1 and part12 because +// The code is split into three parts (part0, part 1 and part2 because // determining the overall image's width and height also requires decoding the // first frame's bounds (part0), but doesn't require decoding the first frame's // pixels (the other two parts). Decoding the actual pixels is split into two @@ -782,7 +752,7 @@ pri func 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.quirks[QUIRK_IMAGE_BOUNDS_ARE_STRICT - QUIRKS_BASE]) { + if (this.num_decoded_frame_configs_value == 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) } diff --git a/std/nie/decode_nie.wuffs b/std/nie/decode_nie.wuffs index 879c92da..7706c6df 100644 --- a/std/nie/decode_nie.wuffs +++ b/std/nie/decode_nie.wuffs @@ -24,31 +24,8 @@ pub struct decoder? implements base.image_decoder( width : base.u32[..= 0x7FFF_FFFF], height : base.u32[..= 0x7FFF_FFFF], - // Call sequence states: - // - 0x00: initial state. - // - 0x03: image config decoded. - // - 0x04: frame config decoded. - // - 0xFF: end-of-data, usually after (the non-animated) frame decoded. - // - // State transitions: - // - // - 0x00 -> 0x03: via DIC - // - 0x00 -> 0x04: via DFC with implicit DIC - // - 0x00 -> 0xFF: via DF with implicit DIC and DFC - // - // - 0x03 -> 0x04: via DFC - // - 0x03 -> 0xFF: via DF with implicit DFC - // - // - 0x04 -> 0xFF: via DFC - // - 0x04 -> 0xFF: via DF - // - // - ???? -> 0x03: via RF for ???? > 0x00 - // - // Where: - // - DF is decode_frame - // - DFC is decode_frame_config, implicit means nullptr args.dst - // - DIC is decode_image_config, implicit means nullptr args.dst - // - RF is restart_frame + // The call sequence state machine is discussed in + // (/doc/std/image-decoders-call-sequence.md). call_sequence : base.u8, dst_x : base.u32, @@ -64,7 +41,7 @@ pub func decoder.set_quirk_enabled!(quirk: base.u32, enabled: base.bool) { pub func decoder.decode_image_config?(dst: nptr base.image_config, src: base.io_reader) { var a : base.u32 - if this.call_sequence <> 0 { + if this.call_sequence <> 0x00 { return base."#bad call sequence" } @@ -108,18 +85,20 @@ pub func decoder.decode_image_config?(dst: nptr base.image_config, src: base.io_ first_frame_is_opaque: false) } - this.call_sequence = 3 + this.call_sequence = 0x20 } pub func decoder.decode_frame_config?(dst: nptr base.frame_config, src: base.io_reader) { - if this.call_sequence < 3 { + if this.call_sequence == 0x20 { + // No-op. + } else if this.call_sequence < 0x20 { this.decode_image_config?(dst: nullptr, src: args.src) - } else if this.call_sequence == 3 { + } else if this.call_sequence == 0x28 { if 16 <> args.src.position() { return base."#bad restart" } - } else if this.call_sequence == 4 { - this.call_sequence = 0xFF + } else if this.call_sequence == 0x40 { + this.call_sequence = 0x60 return base."@end of data" } else { return base."@end of data" @@ -140,16 +119,16 @@ pub func decoder.decode_frame_config?(dst: nptr base.frame_config, src: base.io_ background_color: 0x0000_0000) } - this.call_sequence = 4 + this.call_sequence = 0x40 } pub func decoder.decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reader, blend: base.pixel_blend, workbuf: slice base.u8, opts: nptr base.decode_frame_options) { var status : base.status - if this.call_sequence < 4 { - this.decode_frame_config?(dst: nullptr, src: args.src) - } else if this.call_sequence == 4 { + if this.call_sequence == 0x40 { // No-op. + } else if this.call_sequence < 0x40 { + this.decode_frame_config?(dst: nullptr, src: args.src) } else { return base."@end of data" } @@ -177,7 +156,7 @@ pub func decoder.decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reader, yield? base."$short read" } endwhile - this.call_sequence = 0xFF + this.call_sequence = 0x60 } pri func decoder.swizzle!(dst: ptr base.pixel_buffer, src: base.io_reader) base.status { @@ -246,27 +225,27 @@ pub func decoder.num_animation_loops() base.u32 { } pub func decoder.num_decoded_frame_configs() base.u64 { - if this.call_sequence > 3 { + if this.call_sequence > 0x20 { return 1 } return 0 } pub func decoder.num_decoded_frames() base.u64 { - if this.call_sequence > 4 { + if this.call_sequence > 0x40 { return 1 } return 0 } pub func decoder.restart_frame!(index: base.u64, io_position: base.u64) base.status { - if this.call_sequence < 3 { + if this.call_sequence < 0x20 { return base."#bad call sequence" } if (args.index <> 0) or (args.io_position <> 16) { return base."#bad argument" } - this.call_sequence = 3 + this.call_sequence = 0x28 return ok } diff --git a/std/png/decode_png.wuffs b/std/png/decode_png.wuffs index 0326ba86..62e0e622 100644 --- a/std/png/decode_png.wuffs +++ b/std/png/decode_png.wuffs @@ -33,49 +33,8 @@ pub struct decoder? implements base.image_decoder( overall_workbuf_length : base.u64[..= 0x0007_FFFF_F100_0007], pass_workbuf_length : base.u64[..= 0x0007_FFFF_F100_0007], - // Call sequence states: - // - 0x00: initial state. - // - 0x01: metadata reported; image config decode is in progress. - // - 0x02: metadata finished; image config decode is in progress. - // - 0x03: image config decoded. - // - 0x04: frame config decoded. - // - 0x05: frame decoded. - // - 0xFF: end-of-data, after the final frame decoded. - // - // State transitions: - // - // - 0x00 -> 0x01: via DIC (metadata reported) - // - 0x00 -> 0x03: via DIC (metadata not reported) - // - 0x00 -> 0x04: via DFC with implicit DIC - // - 0x00 -> 0x05: via DF with implicit DIC and DFC - // - 0x00 -> 0xFF: via DF with implicit DIC and DFC - // - // - 0x01 -> 0x02: via TMM - // - // - 0x02 -> 0x01: via DIC (metadata reported) - // - 0x02 -> 0x03: via DIC (metadata not reported) - // - // - 0x03 -> 0x04: via DFC - // - 0x03 -> 0x05: via DF with implicit DFC - // - 0x03 -> 0xFF: via DF with implicit DFC - // - // - 0x04 -> 0x04: via DFC with implicit DF - // - 0x04 -> 0x05: via DF - // - 0x04 -> 0xFF: via DFC with implicit DF - // - 0x04 -> 0xFF: via DF - // - // - 0x05 -> 0x04: via DFC - // - 0x05 -> 0x05: via DF with implicit DFC - // - 0x05 -> 0xFF: via DF with implicit DFC - // - // - ???? -> 0x03: via RF for ???? > 0x00 - // - // Where: - // - DF is decode_frame, implicit means skip_frame - // - DFC is decode_frame_config, implicit means nullptr args.dst - // - DIC is decode_image_config, implicit means nullptr args.dst - // - RF is restart_frame - // - TMM is tell_me_more + // The call sequence state machine is discussed in + // (/doc/std/image-decoders-call-sequence.md). call_sequence : base.u8, report_metadata_chrm : base.bool, @@ -99,6 +58,7 @@ pub struct decoder? implements base.image_decoder( seen_gama : base.bool, seen_iccp : base.bool, seen_idat : base.bool, + seen_ihdr : base.bool, seen_plte : base.bool, seen_srgb : base.bool, seen_trns : base.bool, @@ -209,14 +169,9 @@ pub func decoder.decode_image_config?(dst: nptr base.image_config, src: base.io_ var checksum_want : base.u32 var status : base.status - if this.call_sequence == 2 { - if this.metadata_fourcc <> 0 { - this.call_sequence = 1 - return base."@metadata reported" - } - } else if this.call_sequence <> 0 { + if this.call_sequence <> 0x00 { return base."#bad call sequence" - } else { + } else if not this.seen_ihdr { magic = args.src.read_u64le?() if magic <> '\x89PNG\x0D\x0A\x1A\x0A'le { return "#bad header" @@ -255,6 +210,10 @@ pub func decoder.decode_image_config?(dst: nptr base.image_config, src: base.io_ if (not this.ignore_checksum) and (checksum_have <> checksum_want) { return "#bad checksum" } + this.seen_ihdr = true + } else if this.metadata_fourcc <> 0 { + this.call_sequence = 0x10 + return base."@metadata reported" } // Read up until an IDAT or fdAT chunk. @@ -318,7 +277,7 @@ pub func decoder.decode_image_config?(dst: nptr base.image_config, src: base.io_ // If we have metadata, delay reading (skipping) the ancillary chunk's // CRC-32 checksum until the end of tell_me_more. if this.metadata_fourcc <> 0 { - this.call_sequence = 1 + this.call_sequence = 0x10 return base."@metadata reported" } @@ -359,7 +318,7 @@ pub func decoder.decode_image_config?(dst: nptr base.image_config, src: base.io_ this.first_overwrite_instead_of_blend = false } - this.call_sequence = 3 + this.call_sequence = 0x20 } pri func decoder.decode_ihdr?(src: base.io_reader) { @@ -969,19 +928,23 @@ pri func decoder.decode_trns?(src: base.io_reader) { } pub func decoder.decode_frame_config?(dst: nptr base.frame_config, src: base.io_reader) { - if this.call_sequence == 0xFF { - return base."@end of data" - } else if this.call_sequence < 3 { + if (this.call_sequence & 0x10) <> 0 { + return base."#bad call sequence" + } else if this.call_sequence == 0x20 { + // No-op. + } else if this.call_sequence < 0x20 { this.decode_image_config?(dst: nullptr, src: args.src) - } else if this.call_sequence == 3 { + } else if this.call_sequence == 0x28 { if this.frame_config_io_position <> args.src.position() { return base."#bad restart" } - } else if this.call_sequence == 4 { + } else if this.call_sequence == 0x40 { this.skip_frame?(src: args.src) - if this.call_sequence == 0xFF { + if this.call_sequence >= 0x60 { return base."@end of data" } + } else { + return base."@end of data" } if this.num_decoded_frame_configs_value == 0 { @@ -1028,7 +991,7 @@ pub func decoder.decode_frame_config?(dst: nptr base.frame_config, src: base.io_ } this.num_decoded_frame_configs_value ~sat+= 1 - this.call_sequence = 4 + this.call_sequence = 0x40 } pri func decoder.skip_frame?(src: base.io_reader) { @@ -1099,9 +1062,9 @@ pri func decoder.skip_frame?(src: base.io_reader) { this.num_decoded_frames_value ~sat+= 1 if this.num_decoded_frames_value < this.num_animation_frames_value { - this.call_sequence = 5 + this.call_sequence = 0x20 } else { - this.call_sequence = 0xFF + this.call_sequence = 0x60 } } @@ -1111,9 +1074,11 @@ pub func decoder.decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reader, var pass_width : base.u32[..= 0x00FF_FFFF] var pass_height : base.u32[..= 0x00FF_FFFF] - if this.call_sequence == 0xFF { + if (this.call_sequence & 0x10) <> 0 { + return base."#bad call sequence" + } else if this.call_sequence >= 0x60 { return base."@end of data" - } else if this.call_sequence <> 4 { + } else if this.call_sequence <> 0x40 { this.decode_frame_config?(dst: nullptr, src: args.src) } @@ -1243,9 +1208,9 @@ pub func decoder.decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reader, this.num_decoded_frames_value ~sat+= 1 if this.num_decoded_frames_value < this.num_animation_frames_value { - this.call_sequence = 5 + this.call_sequence = 0x20 } else { - this.call_sequence = 0xFF + this.call_sequence = 0x60 } } @@ -1374,13 +1339,13 @@ pub func decoder.num_decoded_frames() base.u64 { } pub func decoder.restart_frame!(index: base.u64, io_position: base.u64) base.status { - if this.call_sequence < 3 { + if this.call_sequence < 0x20 { return base."#bad call sequence" } else if (args.index >= (this.num_animation_frames_value as base.u64)) or ((args.index == 0) and (args.io_position <> this.first_config_io_position)) { return base."#bad argument" } - this.call_sequence = 3 + this.call_sequence = 0x28 if this.interlace_pass >= 1 { this.interlace_pass = 1 } @@ -1415,7 +1380,7 @@ pub func decoder.tell_me_more?(dst: base.io_writer, minfo: nptr base.more_inform var r_mark : base.u64 var zlib_status : base.status - if this.call_sequence <> 1 { + if (this.call_sequence & 0x10) == 0 { return base."#bad call sequence" } if this.metadata_fourcc == 0 { @@ -1677,7 +1642,7 @@ pub func decoder.tell_me_more?(dst: base.io_writer, minfo: nptr base.more_inform this.metadata_is_zlib_compressed = true } - this.call_sequence = 2 + this.call_sequence &= 0xEF return ok } break.goto_done @@ -1696,7 +1661,7 @@ pub func decoder.tell_me_more?(dst: base.io_writer, minfo: nptr base.more_inform this.metadata_y = 0 this.metadata_z = 0 - this.call_sequence = 2 + this.call_sequence &= 0xEF return ok } diff --git a/std/tga/decode_tga.wuffs b/std/tga/decode_tga.wuffs index e052e63c..17d2bf11 100644 --- a/std/tga/decode_tga.wuffs +++ b/std/tga/decode_tga.wuffs @@ -22,31 +22,8 @@ pub struct decoder? implements base.image_decoder( width : base.u32[..= 0xFFFF], height : base.u32[..= 0xFFFF], - // Call sequence states: - // - 0x00: initial state. - // - 0x03: image config decoded. - // - 0x04: frame config decoded. - // - 0xFF: end-of-data, usually after (the non-animated) frame decoded. - // - // State transitions: - // - // - 0x00 -> 0x03: via DIC - // - 0x00 -> 0x04: via DFC with implicit DIC - // - 0x00 -> 0xFF: via DF with implicit DIC and DFC - // - // - 0x03 -> 0x04: via DFC - // - 0x03 -> 0xFF: via DF with implicit DFC - // - // - 0x04 -> 0xFF: via DFC - // - 0x04 -> 0xFF: via DF - // - // - ???? -> 0x03: via RF for ???? > 0x00 - // - // Where: - // - DF is decode_frame - // - DFC is decode_frame_config, implicit means nullptr args.dst - // - DIC is decode_image_config, implicit means nullptr args.dst - // - RF is restart_frame + // The call sequence state machine is discussed in + // (/doc/std/image-decoders-call-sequence.md). call_sequence : base.u8, header_id_length : base.u8, @@ -82,7 +59,7 @@ pub func decoder.decode_image_config?(dst: nptr base.image_config, src: base.io_ var c5 : base.u32[..= 0x1F] var i : base.u32 - if this.call_sequence <> 0 { + if this.call_sequence <> 0x00 { return base."#bad call sequence" } @@ -245,18 +222,20 @@ pub func decoder.decode_image_config?(dst: nptr base.image_config, src: base.io_ first_frame_is_opaque: this.opaque) } - this.call_sequence = 3 + this.call_sequence = 0x20 } pub func decoder.decode_frame_config?(dst: nptr base.frame_config, src: base.io_reader) { - if this.call_sequence < 3 { + if this.call_sequence == 0x20 { + // No-op. + } else if this.call_sequence < 0x20 { this.decode_image_config?(dst: nullptr, src: args.src) - } else if this.call_sequence == 3 { + } else if this.call_sequence == 0x28 { if this.frame_config_io_position <> args.src.position() { return base."#bad restart" } - } else if this.call_sequence == 4 { - this.call_sequence = 0xFF + } else if this.call_sequence == 0x40 { + this.call_sequence = 0x60 return base."@end of data" } else { return base."@end of data" @@ -277,7 +256,7 @@ pub func decoder.decode_frame_config?(dst: nptr base.frame_config, src: base.io_ background_color: 0xFF00_0000) } - this.call_sequence = 4 + this.call_sequence = 0x40 } pub func decoder.decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reader, blend: base.pixel_blend, workbuf: slice base.u8, opts: nptr base.decode_frame_options) { @@ -302,10 +281,10 @@ pub func decoder.decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reader, var c : base.u32 var c5 : base.u32[..= 0x1F] - if this.call_sequence < 4 { - this.decode_frame_config?(dst: nullptr, src: args.src) - } else if this.call_sequence == 4 { + if this.call_sequence == 0x40 { // No-op. + } else if this.call_sequence < 0x40 { + this.decode_frame_config?(dst: nullptr, src: args.src) } else { return base."@end of data" } @@ -545,7 +524,7 @@ pub func decoder.decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reader, break.resume } endwhile.resume - this.call_sequence = 0xFF + this.call_sequence = 0x60 } pub func decoder.frame_dirty_rect() base.rect_ie_u32 { @@ -561,27 +540,27 @@ pub func decoder.num_animation_loops() base.u32 { } pub func decoder.num_decoded_frame_configs() base.u64 { - if this.call_sequence > 3 { + if this.call_sequence > 0x20 { return 1 } return 0 } pub func decoder.num_decoded_frames() base.u64 { - if this.call_sequence > 4 { + if this.call_sequence > 0x40 { return 1 } return 0 } pub func decoder.restart_frame!(index: base.u64, io_position: base.u64) base.status { - if this.call_sequence < 3 { + if this.call_sequence < 0x20 { return base."#bad call sequence" } if args.index <> 0 { return base."#bad argument" } - this.call_sequence = 3 + this.call_sequence = 0x28 this.frame_config_io_position = args.io_position return ok } diff --git a/std/wbmp/decode_wbmp.wuffs b/std/wbmp/decode_wbmp.wuffs index 5d664532..5f673bd8 100644 --- a/std/wbmp/decode_wbmp.wuffs +++ b/std/wbmp/decode_wbmp.wuffs @@ -20,31 +20,8 @@ pub struct decoder? implements base.image_decoder( width : base.u32, height : base.u32, - // Call sequence states: - // - 0x00: initial state. - // - 0x03: image config decoded. - // - 0x04: frame config decoded. - // - 0xFF: end-of-data, usually after (the non-animated) frame decoded. - // - // State transitions: - // - // - 0x00 -> 0x03: via DIC - // - 0x00 -> 0x04: via DFC with implicit DIC - // - 0x00 -> 0xFF: via DF with implicit DIC and DFC - // - // - 0x03 -> 0x04: via DFC - // - 0x03 -> 0xFF: via DF with implicit DFC - // - // - 0x04 -> 0xFF: via DFC - // - 0x04 -> 0xFF: via DF - // - // - ???? -> 0x03: via RF for ???? > 0x00 - // - // Where: - // - DF is decode_frame - // - DFC is decode_frame_config, implicit means nullptr args.dst - // - DIC is decode_image_config, implicit means nullptr args.dst - // - RF is restart_frame + // The call sequence state machine is discussed in + // (/doc/std/image-decoders-call-sequence.md). call_sequence : base.u8, frame_config_io_position : base.u64, @@ -62,7 +39,7 @@ pub func decoder.decode_image_config?(dst: nptr base.image_config, src: base.io_ var x32 : base.u32 var x64 : base.u64 - if this.call_sequence <> 0 { + if this.call_sequence <> 0x00 { return base."#bad call sequence" } @@ -116,18 +93,20 @@ pub func decoder.decode_image_config?(dst: nptr base.image_config, src: base.io_ first_frame_is_opaque: true) } - this.call_sequence = 3 + this.call_sequence = 0x20 } pub func decoder.decode_frame_config?(dst: nptr base.frame_config, src: base.io_reader) { - if this.call_sequence < 3 { + if this.call_sequence == 0x20 { + // No-op. + } else if this.call_sequence < 0x20 { this.decode_image_config?(dst: nullptr, src: args.src) - } else if this.call_sequence == 3 { + } else if this.call_sequence == 0x28 { if this.frame_config_io_position <> args.src.position() { return base."#bad restart" } - } else if this.call_sequence == 4 { - this.call_sequence = 0xFF + } else if this.call_sequence == 0x40 { + this.call_sequence = 0x60 return base."@end of data" } else { return base."@end of data" @@ -148,7 +127,7 @@ pub func decoder.decode_frame_config?(dst: nptr base.frame_config, src: base.io_ background_color: 0xFF00_0000) } - this.call_sequence = 4 + this.call_sequence = 0x40 } pub func decoder.decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reader, blend: base.pixel_blend, workbuf: slice base.u8, opts: nptr base.decode_frame_options) { @@ -164,10 +143,10 @@ pub func decoder.decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reader, var src : array[1] base.u8 var c : base.u8 - if this.call_sequence < 4 { - this.decode_frame_config?(dst: nullptr, src: args.src) - } else if this.call_sequence == 4 { + if this.call_sequence == 0x40 { // No-op. + } else if this.call_sequence < 0x40 { + this.decode_frame_config?(dst: nullptr, src: args.src) } else { return base."@end of data" } @@ -246,7 +225,7 @@ pub func decoder.decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reader, } endwhile } - this.call_sequence = 0xFF + this.call_sequence = 0x60 } pub func decoder.frame_dirty_rect() base.rect_ie_u32 { @@ -262,27 +241,27 @@ pub func decoder.num_animation_loops() base.u32 { } pub func decoder.num_decoded_frame_configs() base.u64 { - if this.call_sequence > 3 { + if this.call_sequence > 0x20 { return 1 } return 0 } pub func decoder.num_decoded_frames() base.u64 { - if this.call_sequence > 4 { + if this.call_sequence > 0x40 { return 1 } return 0 } pub func decoder.restart_frame!(index: base.u64, io_position: base.u64) base.status { - if this.call_sequence < 3 { + if this.call_sequence < 0x20 { return base."#bad call sequence" } if args.index <> 0 { return base."#bad argument" } - this.call_sequence = 3 + this.call_sequence = 0x28 this.frame_config_io_position = args.io_position return ok }