Repository navigation
fix(kernel): derive the GIF decoder from the specification, and add an encoder - #525
Merged
Merged
Conversation
…n encoder The GIF decoder was written with no specification in hand and cited none. Three defects followed, two of them silent. The specification is now held and the decoder is derived from it, and an encoder comes with it. Closes #490. Ordinary GIF files were refused with "Invalid GIF LZW code". Appendix F clause 4 says the code length increases whenever the code value would exceed it; a width of n expresses 0 to 2^n-1, so the width must grow as the next code reaches 2^n. This grew at 2^n+1, kept reading at the narrower width after the encoder had widened, and threw. Only images whose dictionary never passed the boundary decoded, which is why a flat colour worked and anything with detail did not. Interlaced images were never deinterlaced. Appendix E gives the four-pass row order and nothing read the interlace flag. No error, just a scrambled picture. A code not yet in the table put its repeated byte at the front. That code stands for the previous string followed by that string's own first byte. One pixel per occurrence: on a 48x48 image of three-pixel bars, 120 of 2304, each on a bar boundary. The suite could not catch any of it. The fixture helper in ImageFormatTests emitted literal codes at a fixed width and never widened them, which is not a conformant stream, so the fixture and the defect held each other up. Correcting the helper is what made two existing tests fail until the decoder was right. Two truncation guards come with it, both raising the documented InvalidDataException rather than an indexing exception: a file ending before the LZW minimum code size, and a sub-block whose declared length runs past the end. The encoder is written from the Appendix B grammar. It builds the palette from the colours present and refuses an image with more than 256 rather than quantising, which is the line the rest of the image path draws: discarding colour is the caller's decision. The licence grant is royalty-free for using the format in software on condition that ownership of the format and its service mark is acknowledged in user and technical documentation. That acknowledgement is now in NOTICE, the repository README and every package README, which is the documentation that ships. There is no newer GIF specification to avoid it with; the intended successor, GIF24, became PNG. Rebuilt on main rather than rebased: six commits each touching the changelog made the replay noisier than the result. The tree is the branch's, the changelog entry sits under Unreleased where the release commit left it, and the four table span entries the 2.3.2 release promoted to shipped are not reintroduced.
A Graphic Control Extension's transparency (section 23: "the first graphic rendering block to follow") never closed. A Plain Text Extension or any other Graphic-Rendering-range label (section 12) left a stale transparent index standing for a later, unrelated image, and a second, conforming extension with the flag clear did not reset it either. Both measured failures are fixed and pinned by two known-answer tests built from hand-assembled fixtures. Three test-coverage holes, each proved by a surviving mutation, are closed: - The decoder's 12-bit code-width cap was reachable by no in-process test past 9 bits (codeSize < 11 or < 10 left the whole suite green). Two oracle-gated tests now cross-check against Pillow in both directions on a table-filling raster, gated through the existing OracleGate/ExternalTool pair so a missing tool skips locally and fails CI. eng/gif-oracle.py is the Pillow-side encode/decode helper, mirroring eng/barcode-decode.py's shape. - The dimension guard's own test reached a different guard first once ImageLimits.ValidateDimensions was removed (both throw InvalidDataException), so the mutation went undetected. The fixture now carries a real colour table and the assertions read the exact message, plus the 0x0/0x2/2x0 low-end cases the overflow case doesn't cover. - GifEncoder's global-colour-table size field had no coverage at the 2^k+1 palette sizes where its growth loop is one entry short. Added round trips at 3, 5, 9, 17, 33, 65 and 129 colours. Also: the GIF licence acknowledgement moves to NOTICE (full text) and the Kernel README (short form) only, per the ISO clause 3 obligation binding the package that actually contains the codec, not every package that merely depends on it; the root README and the other seven package READMEs are reverted. Several CHANGELOG and comment claims are corrected against the tree (a before-state that never held the acknowledgement, a per-occurrence cost that is actually the string's length, an unreproducible corpus sweep now labelled as such, and two "no room for Clear/EOI" claims that had the wrong code missing room). GifEncoder's over-65535 refusal now names its own dimension and runs before the palette check; its LzwEncode stream is disposed. Closes #490.
Two GIF transparency-scope tests passed for the wrong reason: the fixture they shared wrote a Plain Text Extension unconditionally, so its own scope-closing reset masked the second mechanism the tests claimed to pin. Generalized the fixture to take the middle extension's label (or none), isolated the two mechanisms, and added two more cases for the untested sides of the label boundary: a Special-Purpose label that must not close scope, and a Graphic-Rendering label other than Plain Text that must. Mutation results (applied and reverted in a detached copy, never in this worktree): - Delete `else transparentIndex = -1;` (GifImageLoader.cs): FAILS Decode_gceWithTransparencyFlagClear_resetsAStaleIndexFromAnEarlierExtension (1508/1509); reverted, 1509/1509. - `label <= 0x7F` -> `label <= 0xFF`: FAILS Decode_specialPurposeExtension_doesNotCloseAPendingTransparentIndex (1508/1509); reverted, 1509/1509. - `label <= 0x7F` -> `label == 0x01`: FAILS Decode_graphicRenderingExtensionOtherThanPlainText_closesAPendingTransparentIndex (1508/1509); reverted, 1509/1509. All three re-run on the final tree in a second detached copy with the same results. Corrected several claims found wrong by an external review, each verified before editing: - "A flat colour never builds a dictionary large enough to reach a width boundary" (CHANGELOG, GifSpecificationTests x2) is false in general. Measured against this branch's own LZW encoder (reflection probe against the built VellumPdf.Kernel.dll): a flat raster crosses a width boundary at 7/29/121 pixels for minimum code sizes 2/3/4. The 40 flat files in the #490 sweep decoded because Pillow always writes minimum code size 8 regardless of declared palette (measured on 1x1 and 160x120 rasters with colors=2..256), which keeps a 160x120 image's 19,200 pixels under the 512-entry boundary. Rewrote all three copies to say this. - CHANGELOG said all eight packages "shipped GIF code"; only VellumPdf.Kernel does (src/Directory.Build.targets already says so). Corrected to explain why NOTICE still ships in all eight regardless. - GifSpecificationTests said "no independent codec runs in this suite", written before this same branch added GifPillowOracleTests to the same project. CHANGELOG said no generator/corpus is checked in under eng/, true only of the external 200-file sweep, not eng/gif-oracle.py. Fixed both, and gave the Pillow oracle its own Added-section bullet, bounded to the one raster it actually checks rather than "every file". - GifSpecificationTests cited section 20.c.i for the Local Color Table Flag; verified against docs/iso/free/GIF89a-spec.txt (pdftotext), it is 20.c.vi. Also normalized "clause 3"/"section 12" citation vocabulary in NOTICE and CHANGELOG to "section", matching the spec's own numbering. - NOTICE said the GIF licence grant "requires this acknowledgement", overstating clause 3: it requires acknowledging ownership, and offers (not requires) the specific wording quoted. Also corrected the banner route's gating condition (distribution without documentation, not "having a screen") and added a completeness note to the Liberation fonts section per the settled review conflict (its copyright lines are upstream's own text, verbatim, and were correctly left untouched). - Restructured GifImageLoader.Load's and GifEncoder.Encode's XML docs to match the TextStyle.FontSize shape this repository requires: refusal and exception type in remarks, a "Do not rely on" paragraph for accepted but unstable behaviour (the pixel overrun; the palette ordering), full <exception> coverage. - GifEncoder's minimum-code-size-floor comment cited Appendix F under COMPRESSION item 4; verified against the spec text, the actual authority is ESTABLISH CODE SIZE. Copied GifSpecificationTests' correct citation and reasoning over it. - Hardened eng/gif-oracle.py's cmd_encode to round-trip its own Pillow output and fail (exit 4) if quantization was lossy, since the table-filling fixture sits at exactly 256 distinct colours (verified by counting them) with zero palette slack. - Fixed two more absolute claims: GifImageLoader.cs said the Trailer byte "never reaches here" as an extension label, but 0x3B <= 0x7F, so a non-conformant 0x21 0x3B pair would still match; and "the independent decoders tried accept it" named no decoder — named Pillow 12.3.0 and confirmed by building the overrun fixture and decoding it with Pillow directly. - Corrected a test doc's claim that removing the dimension guard would raise OverflowException; measured with the guard actually deleted, the fixture's own truncation (BuildGifDescriptorOnly ends right after the packed byte) throws first, for every dimension pairing in the theory. - Re-baselined the CI oracle-invocation floor for "python": the two new GifPillowOracleTests each launch python once (confirmed by reading RunOracle, called once per test), so the floor moves from 121 to 123 (90% of 135+2, floor(0.9*137)=123), and the step comment now names both python3 consumers. Also: an out-of-bounds palette index is spec-malformed (GIF89a 22.a) but left black rather than refused; documented as a deliberate departure rather than an unexplained gap. Wrapped an overlong comment line, fixed a mis-attributed "transparent to it too" claim to cite the actual scope-delimiter rule, dropped "in order to", and cut two of three "worth ..." constructions in GifSpecificationTests/MalformedInputTests. Not done: the LOW items about documenting a missing-EOI stream and adding GIF fixture generation are left for a follow-up; the review notes them as low priority and this round already covers every HIGH and MEDIUM item.
Six documented GIF refusals had no value-level test: length below 13
bytes ("GIF data too small."), the signature check ("Not a GIF
file."), a missing colour table ("GIF has no colour table."), a
truncated image descriptor ("Truncated GIF image descriptor."), a
local colour table running past end of file ("GIF local colour table
extends beyond end of file."), and an unresolvable LZW code ("Invalid
GIF LZW code."). Each now has a test asserting the exact message, and
each is proven by mutation in a detached copy (rebuilt before every
run): disabling length<13 raises IndexOutOfRangeException; disabling
the signature check falls through to "GIF contains no image
descriptor."; disabling the no-colour-table guard on this fixture
still throws, but a different message ("GIF image data ends before
the LZW minimum code size."), proving the guard's own message was
unpinned; disabling the truncated-descriptor guard raises
IndexOutOfRangeException; disabling the local-table-bounds guard
raises ArgumentOutOfRangeException; disabling the invalid-LZW-code
guard falls through to the output-length mismatch message. All six
mutations were killed by exactly the test written for them, with no
other GIF test affected, and restoring each guard and rebuilding
returned the suite to green. The two guards missing from
GifImageLoader.cs's own "Rejected:" list and its Load() <exception>
tag ("no colour table" and "truncated image descriptor") are now in
both.
Seven sentences from the previous round attached a correct figure to
the wrong subject:
- GifSpecificationTests.cs's class doc and the
Decode_imageWhoseDictionaryPassesTheWidthBoundary doc both claimed
a flat colour reaches its LZW width boundary in 7 pixels at "the
narrower code size this fixture uses" (minimum code size 3). 7 is
the code-size-2 figure; code size 3's boundary is 29, and neither
was previously measured in this file despite the "(measured
below)" claim.
- The same doc's "any boundary the defect below could reach" is
scoped to code size 8 and to the fixtures actually built here (up
to 160x120, 19,200 pixels); a flat raster at that code size does
cross a boundary, at 32,641 pixels.
- Two copies of the mid-stream-Clear regression test's doc said the
fixture helper's old defect fails at "exactly eight values: 6, 7,
22, 23, 54, 55, 118 and 119." It fails at four: 7, 23, 55 and 119,
which is exactly the theory's own InlineData; 6, 22, 54 and 118
decode correctly under the defect.
- "Below 2, the starting width still fits Clear and End of
Information" is true only at minimum code size 1; at 0 the
starting width is 1 bit, too narrow even for End of Information
(2).
- CHANGELOG.md attributed the 7/29/121-pixel boundary figures to
"this package's own encoder". GifEncoder derives its minimum code
size from the palette actually present, so a flat raster it
encodes is always code size 2; the size-3 and size-4 figures come
from the test suite's own LZW fixture helper, which can pick an
arbitrary minimum code size.
- GifPillowOracleTests.cs said narrowing the decoder's code-width cap
to 11 or 10 "passes the whole Kernel suite." That file's own two
tests are part of the Kernel suite and now catch exactly that
narrowing; the correct scope is every in-process test before this
file existed.
All seven figures were re-measured against the actual subject before
the sentence was rewritten (a small standalone probe against the
built decoder, not the shipped test fixtures), not just re-copied
from the round-2 review.
Also fixed, from the same review:
- CHANGELOG.md's Appendix F check-list named a code-width assertion
the test file's own comments call worthless (a matched drift in
encoder and reader would pass it); replaced with the table-bound
check that actually discriminates.
- GifSpecificationTests.cs mis-stated section 12 as three ranges that
can all close a pending Graphic Control Extension's scope; only
Graphic-Rendering does.
- Directory.Build.targets said "clause 3" where the specification's
own word is "section", and gave a non sequitur as the reason every
package still needs its own copy of NOTICE; replaced with the
reason CHANGELOG.md already gives.
- The GifImageLoader.cs comment on Appendix F's numbering no longer
needs to caution against a bare "clause 4": nothing in the tree
writes that any more.
- NOTICE dropped "or may be distributed" from its own paraphrase of
section 3's second acknowledgement route, and lost the sentence
naming NOTICE itself as the documentation the first route relies
on; both restored.
- CONTRIBUTING.md, docs/architecture.md and OracleGate.cs all said
REQUIRE_BARCODE_ORACLE fails only barcode-oracle dependencies.
GifPillowOracleTests now also gates on the bare string "python", so
REQUIRE_BARCODE_ORACLE=1 also escalates a missing interpreter for
the GIF oracle; documented rather than changed, since it only
strengthens the gate.
- ci.yml described the pinned Python interpreter and Pillow as
barcode-only in three places; Pillow is now also the GIF oracle's
independent codec.
- A new value-level test pins the alpha bytes a Special Purpose
extension's non-closing behaviour produces (0, 255, 0, 255, 0, 255,
0) rather than only that a mask exists.
- A new test pins the documented leniency of leaving an
out-of-range palette index black rather than refusing the image.
- Minor: a false "none of them 2^k+1" claim, a false claim that
Windows has no python3 alias, an overstated "to pin the boundary",
and docs/kernel-guide.md's images section now mentions GifEncoder.
Baseline reproduced: 1,509 Kernel tests before this round, 7,083
total; this round adds 7 (six guard tests plus one leniency test),
giving 7,090 total, 0 failed, in both Debug and Release.
Three independent reviewers found five sentences from the previous round still wrong; three of them attach a correct figure to the wrong source. - CHANGELOG.md and a GifSpecificationTests.cs comment said a code at or beyond the next free table entry cannot be resolved by any decoder. A code equal to it is the KwKwK case, and GifImageLoader.cs resolves it deliberately; the assertion the comment explains is <=, not <, for exactly that reason. Both now say "beyond" alone. Neither the decoder nor the assertion changed. - The class doc claimed no raster in the file exceeds 160x120's 19,200 pixels. Encode_writesACodeStreamAppendixFAccepts builds one at 150x150, 22,500 pixels; the doc now names that raster and its actual 10,141 pixel margin under the 32,641 boundary, measured against the same table and width rule EncodeLzw uses, and stops citing the external corpus for a size that belongs to this file. - Two comments attributed the suite's own 7, 29 and 121 pixel figures to "CHANGELOG.md's corpus measurement". The changelog's own text says they come from the suite's LZW fixture helper, not the corpus; both comments now cite that instead, and the 32,641 figure is attributed the same way rather than to a changelog paragraph that never states it. - A regression test's doc said the fixture helper's superseded defect produces "different bytes that still decode" outside its four failing values. Comparing all 130 outputs byte for byte against the corrected helper shows the other 126, including the four named as examples, are byte-identical, which makes the doc's own conclusion stronger, not weaker; it now says so. - A doc claimed only the refused 257-colour palette is 2^k+1 among the file's fixture palettes. 2 is also one more than a power of two (2^0+1); the doc now names both and explains why only 257 exercises the table-size boundary the test covers. Also, while in these files: ci.yml's REQUIRE_BARCODE_ORACLE comment still described it as zxing-cpp only, though it also gates the GIF oracle's python dependency by matching on the bare dependency name (OracleGate.cs); and kernel-guide.md said five image formats can be loaded when there are eight public loaders, so the table now lists all of them. 7,090 tests, 0 failed, in both Debug and Release, matching baseline.
A prose review of the previous round found three statements that do not match the code. Growing the loader table from five formats to eight falsified the sentence directly beneath it, which said everything but JPEG is re-encoded with FlateDecode. CCITT, JBIG2 and JPEG 2000 all default to Passthrough and are embedded verbatim under their own PDF filter, as ImageLoadOptions and both loaders say. The correction was right and it invalidated a neighbouring sentence that had been true while the table was shorter, which no search for copies of the corrected claim would have found. The palette paragraph denied and conceded the same fact in consecutive sentences: it said no fixture in the file uses a 2^k+1 palette, then named 2 as one of two such values, and this file builds two-colour palettes twice. Both are true once k is stated: 2 is k of 0, which fits N of 0 exactly with no smaller N to be one past, so it is not the boundary the theory is about. "The largest raster in this file" is 22,500 pixels only among rasters that reach LZW. The dimension-refusal theory allocates 65,536-pixel buffers that are refused before the palette is built. Scoped accordingly. 7,090 tests pass, Debug and Release, every reported assembly path inside this worktree. Format and clean-room clean.
The previous commit fixed a sentence that the enlarged loader table had falsified, and the replacement was falsified by the same table. It said everything but four named formats is decoded to a raster and re-encoded with Flate. TIFF is a counterexample on three of its compressions, all by default: Group 3 and Group 4 return a CCITTFaxDecode passthrough and a JPEG strip returns a DCTDecode passthrough, and the Group 4 and JPEG paths do not consult the decode mode at all. The loader's own class doc says so. So the filter now sits in the table, one cell per row, and no sentence quantifies over rows. Adding a loader cannot falsify a neighbouring paragraph again, which is the failure this is the second attempt at. Two facts the prose was glossing are now stated: the filter column is the default and DecodeToRaster changes three of the four passthrough formats but not TIFF's Group 4 or JPEG strips, and the JBIG2 and JPEG 2000 passthroughs are not byte-for-byte, because one splits a globals stream and drops end-of-file segments and the other wraps the codestream in a minimal JP2 container. The palette paragraph also still contradicted itself, one value later than before. It said no fixture elsewhere sits on the 2^k+1 boundary and then that 257 is the only one that does. Both are now stated: 2 is k of 0 and not on the boundary, 257 is on it at k of 8 and is refused before the table is sized, so neither can exercise it. 7,090 tests pass, Debug and Release, every reported assembly path inside this worktree. Format and clean-room clean.
Tim81
force-pushed
the
feat/gif-rebased
branch
from
September 13, 2026 09:45
f8a72ba to
0c29c96
Compare
Tim81
added a commit
that referenced
this pull request
Sep 14, 2026
The branch predates three merges and needed more than a replay. GifImageLoader is no longer touched. This branch documented the pre-#525 decoder — only the first frame read, the logical screen ignored, a null raising NullReferenceException — and #525 rewrote that loader from the GIF89a specification and wrote its own boundary documentation against the decoder that now exists. Main's version describes the current code; this branch's described code that no longer runs, so the conflict resolves to main and the member drops out of the diff. The four caller-facing warnings it carried, about the null argument, the first-frame-only read, the ignored logical screen and the limits being internal constants, are not lost: they are saved for verification against the current decoder and belong with #498 and the rest of the GIF work rather than in a rebase. CONTRIBUTING.md drops out too. This branch and #503 each added the same twenty-seven lines, byte-identical, and git recognised the block as already applied. The CHANGELOG entry landed in the wrong section. A three-way merge placed all fifty-three lines inside the released 2.3.2 section, matching context against the file's old shape, where they would have rewritten history for a version that already shipped. They are under Unreleased now, in their own Documentation heading beside the other entries waiting on 2.3.3. Documentation only after the rebase: zero non-comment source lines changed across nine files. 7,099 tests pass in Release, format and clean-room clean.
Tim81
added a commit
that referenced
this pull request
Sep 14, 2026
Two lenses ran over this branch for the first time and returned five high and fourteen medium findings between them. The two highest were the same sentence read from both sides. The CHANGELOG said the timestamp client reports a timeout, a refused connection and a rejected request as one exception type. The member added in the same commit says the opposite, that they arrive as three and that the type is the discriminator. Measured against a loopback authority: an unreachable authority gives HttpRequestException, a timeout and a failing status give InvalidOperationException, and a rejection or a malformed body gives CryptographicException. A reader who trusted the CHANGELOG would have written exactly the one catch clause the member warns against. The CHANGELOG also claimed the GIF loader's logical-screen and animation boundaries were now stated on the member. They are not, and cannot be: the rebase dropped that file, because #525 rewrote the loader from the specification. Both halves of the sentence were false, so the paragraph is gone. Its neighbouring count went with it: six of eight loaders had no exception tag at the 2.3.2 tag, but only five do on main, since #525 gave GIF its own. CCITT was going to be left out of a pull request titled for what the image loaders refuse. That was the wrong call and it is in, measured rather than read: a null argument gives ArgumentException rather than being dereferenced, a non-positive columns or rows is named as itself because both are checked before the pixel cap, and a raster asked of a Group 4 stream or a 2-D row in a mixed-mode one gives NotSupportedException with no fallback. Its two unreachable throws stay undocumented on purpose: Load supplies the default options, so the ArgumentNullException on options cannot fire, and the non-positive branch of ValidateDimensions sits behind the argument checks above it. All five of main's undocumented loaders now carry tags. The quantifiers went the way they usually go here. "Every other loader refuses anything above 100,000,000" was falsified a hundred lines away in its own diff: TiffImageLoader validates its own directory and then hands a JPEG-compressed strip to JpegImageLoader, and the image it returns carries the JPEG's dimensions. Reproduced with a 125-byte TIFF declaring 8 by 8 whose single strip is a 15-byte JPEG declaring 65535 by 65535, returned at 4,294,836,225 pixels. The sentence now names the property that makes it true and the loader that escapes it. PNG said its options parameter selects the decode mode. It never reads DecodeMode; the only member it reads is BitDepth. TIFF said the same and reads DecodeMode on one path, a CCITT-compressed strip, so that member now says which. TIFF also said two exception types where it documents three, and its ColorMap defect is exactly the third that escapes the other two. Four passages were removed rather than corrected. The per-edge constant had a paragraph of its own in three files, marked Attention and tracing an internal route from the MMR decoder through the JBIG2 loader, for a limit that never runs on a default call; a caller can act on "there is no per-edge limit, so one edge of 1,000,001 under the total loads", which is what those three files now say and what a 1,000,001 by 1 bitmap does. Counts of throw sites went, being implementation facts that the next throw falsifies. Two byte counts went, since a figure in a doc comment needs a fixture a reader can rebuild and two probes measured 125 and 145 bytes for the same construction. And the CHANGELOG's account of its own earlier drafts went, because nobody outside the review saw them. Smaller corrections, each measured: a reserved reference set to null is stored as it stands and reported at write time as never assigned, which is not what the caller did; a null reference gives NullReferenceException rather than ArgumentNullException; the objects written before a failed write stay in the caller's stream, eighteen bytes of them in the probe, rather than the output being abandoned; both delegating overloads that carried no exception tag now have them; a BMP under 54 bytes is reported as truncated whatever variant it would have been; and Aztec asks for no quiet zone, so the barcode matrix no longer says a symbology's specification requires one. The blank line this branch had deleted inside the released 2.3.2 section is back, so the CHANGELOG diff is additive only. 0 warnings, format clean, clean-room clean, 7,099 tests passing in Release.
Tim81
added a commit
that referenced
this pull request
Sep 14, 2026
The branch predates three merges and needed more than a replay. GifImageLoader is no longer touched. This branch documented the pre-#525 decoder — only the first frame read, the logical screen ignored, a null raising NullReferenceException — and #525 rewrote that loader from the GIF89a specification and wrote its own boundary documentation against the decoder that now exists. Main's version describes the current code; this branch's described code that no longer runs, so the conflict resolves to main and the member drops out of the diff. The four caller-facing warnings it carried, about the null argument, the first-frame-only read, the ignored logical screen and the limits being internal constants, are not lost: they are saved for verification against the current decoder and belong with #498 and the rest of the GIF work rather than in a rebase. CONTRIBUTING.md drops out too. This branch and #503 each added the same twenty-seven lines, byte-identical, and git recognised the block as already applied. The CHANGELOG entry landed in the wrong section. A three-way merge placed all fifty-three lines inside the released 2.3.2 section, matching context against the file's old shape, where they would have rewritten history for a version that already shipped. They are under Unreleased now, in their own Documentation heading beside the other entries waiting on 2.3.3. Documentation only after the rebase: zero non-comment source lines changed across nine files. 7,099 tests pass in Release, format and clean-room clean. # Conflicts: # CHANGELOG.md
Tim81
added a commit
that referenced
this pull request
Sep 14, 2026
Two lenses ran over this branch for the first time and returned five high and fourteen medium findings between them. The two highest were the same sentence read from both sides. The CHANGELOG said the timestamp client reports a timeout, a refused connection and a rejected request as one exception type. The member added in the same commit says the opposite, that they arrive as three and that the type is the discriminator. Measured against a loopback authority: an unreachable authority gives HttpRequestException, a timeout and a failing status give InvalidOperationException, and a rejection or a malformed body gives CryptographicException. A reader who trusted the CHANGELOG would have written exactly the one catch clause the member warns against. The CHANGELOG also claimed the GIF loader's logical-screen and animation boundaries were now stated on the member. They are not, and cannot be: the rebase dropped that file, because #525 rewrote the loader from the specification. Both halves of the sentence were false, so the paragraph is gone. Its neighbouring count went with it: six of eight loaders had no exception tag at the 2.3.2 tag, but only five do on main, since #525 gave GIF its own. CCITT was going to be left out of a pull request titled for what the image loaders refuse. That was the wrong call and it is in, measured rather than read: a null argument gives ArgumentException rather than being dereferenced, a non-positive columns or rows is named as itself because both are checked before the pixel cap, and a raster asked of a Group 4 stream or a 2-D row in a mixed-mode one gives NotSupportedException with no fallback. Its two unreachable throws stay undocumented on purpose: Load supplies the default options, so the ArgumentNullException on options cannot fire, and the non-positive branch of ValidateDimensions sits behind the argument checks above it. All five of main's undocumented loaders now carry tags. The quantifiers went the way they usually go here. "Every other loader refuses anything above 100,000,000" was falsified a hundred lines away in its own diff: TiffImageLoader validates its own directory and then hands a JPEG-compressed strip to JpegImageLoader, and the image it returns carries the JPEG's dimensions. Reproduced with a 125-byte TIFF declaring 8 by 8 whose single strip is a 15-byte JPEG declaring 65535 by 65535, returned at 4,294,836,225 pixels. The sentence now names the property that makes it true and the loader that escapes it. PNG said its options parameter selects the decode mode. It never reads DecodeMode; the only member it reads is BitDepth. TIFF said the same and reads DecodeMode on one path, a CCITT-compressed strip, so that member now says which. TIFF also said two exception types where it documents three, and its ColorMap defect is exactly the third that escapes the other two. Four passages were removed rather than corrected. The per-edge constant had a paragraph of its own in three files, marked Attention and tracing an internal route from the MMR decoder through the JBIG2 loader, for a limit that never runs on a default call; a caller can act on "there is no per-edge limit, so one edge of 1,000,001 under the total loads", which is what those three files now say and what a 1,000,001 by 1 bitmap does. Counts of throw sites went, being implementation facts that the next throw falsifies. Two byte counts went, since a figure in a doc comment needs a fixture a reader can rebuild and two probes measured 125 and 145 bytes for the same construction. And the CHANGELOG's account of its own earlier drafts went, because nobody outside the review saw them. Smaller corrections, each measured: a reserved reference set to null is stored as it stands and reported at write time as never assigned, which is not what the caller did; a null reference gives NullReferenceException rather than ArgumentNullException; the objects written before a failed write stay in the caller's stream, eighteen bytes of them in the probe, rather than the output being abandoned; both delegating overloads that carried no exception tag now have them; a BMP under 54 bytes is reported as truncated whatever variant it would have been; and Aztec asks for no quiet zone, so the barcode matrix no longer says a symbology's specification requires one. The blank line this branch had deleted inside the released 2.3.2 section is back, so the CHANGELOG diff is additive only. 0 warnings, format clean, clean-room clean, 7,099 tests passing in Release. # Conflicts: # CHANGELOG.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replaces #492, which pointed at
feat/gif-from-spec. That branch could not carry the work forward:rebasing it over main conflicted repeatedly on
CHANGELOG.md, so the tree was rebuilt on main and thebranch history restarted. #492 had no comments and no reviews, so nothing is lost by moving.
Closes #490.
What this does
Derives the GIF decoder from the GIF89a specification and adds
GifEncoder. Four commits: the originalwork plus three correction rounds driven by nine Opus reviewers across three passes.
Three specification defects fixed in the decoder, each measured rather than inferred:
conformant stream truncated or hit an early End of Information. Over a 200-file external corpus this
was 71 refusals through a single throw.
interlaced and all 48 were wrong.
Transparency scope is now bounded by the specification's own block ranges. Section 12 defines three
label ranges and section 23 scopes a Graphic Control Extension to the first graphic-rendering block
that follows. The decoder previously carried a transparent index past blocks that close its scope. All
six required behaviours are verified case by case.
Bounds checks on the colour tables, the sub-blocks, the extension blocks and the pixel count, each
refusing with a named message rather than an index-out-of-range.
The licence acknowledgement
The GIF89a specification grants a royalty-free licence on condition that CompuServe's ownership of the
format and its service mark is acknowledged in User and Technical Documentation. The grant offers
wording for that rather than requiring the exact words.
NOTICEnow ships in all eight packages, which it did not before:PackageLicenseExpressionemits anSPDX identifier rather than a file, and the README rule packs one README and never
NOTICE. Theacknowledgement text itself sits in the Kernel README, the package that actually contains the codec, and
in
NOTICE. Verified in the artefacts rather than the repository:dotnet packand then opening alleight
.nupkgfiles as zips.Tests
7,090 passing, none failing, Debug and Release, and also under
REQUIRE_ORACLES=1so the oraclesgenuinely execute rather than skip.
Every guard is proven by mutation, not by coverage. Each new test was checked by disabling its
guard, confirming the test fails, restoring it and confirming it passes, with a rebuild between every
mutation. That discipline found two real gaps the first round missed: a transparency-scope reset whose
test was satisfied by a different mechanism in the same fixture, and a label boundary that could move in
either direction undetected. It also found six refusals that the documentation asserted and no test
pinned, including one where a malformed file decoded to a one-pixel image instead of being refused.
A Pillow oracle runs in both directions, reading a file this encoder wrote and writing a file this
decoder reads, on a raster chosen to force both sides past nine-bit codes. It skips cleanly without
Pillow, fails under
REQUIRE_ORACLES, and cannot pass vacuously.Where this decoder and Pillow disagree, the specification is with this decoder. Pillow does not
implement block scope and reports a transparency index for fixtures where section 23 says the scope has
closed. Recorded in the tests so a later pass does not "fix" the decoder to match the oracle.
Two things a reader should know
The external corpus is not reproducible from a clone. The 200-file sweep ran outside the repository
and no generator for it is checked in, so every figure derived from it is disclosed as such in the
CHANGELOG. What is reproducible is
eng/gif-oracle.pyand the two in-process oracle cases.The oracle invocation floor moved from 121 to 123. That assertion exists to catch oracles quietly
disengaging, so the two new Python launches were measured by logging invocations at both commits rather
than assumed.
Gates
Build with warnings as errors, the full suite in Debug and Release,
dotnet format --verify-no-changes,and
eng/clean-room-check.ps1, all green and all verified on the final commit rather than on the workin progress.
🤖 Generated with Claude Code
https://claude.ai/code/session_013fvSmjcPtC5Ef3K9CWwVGU