Reword decode16 and DdsCompression::None docs, check the 16-bit buffer
length before narrowing for BC1-BC3, and test typeless DXGI codes, padded
16-bit rows, G16R16 masks and decode16 of BC1.
encode16 writes 16-bit pixels uncompressed as R16_UNORM, R16G16_UNORM or
R16G16B16A16_UNORM with the DX10 header, and fits BC4/BC5 endpoints and
indices against the 16-bit values; BC1-BC3 round to 8 bits first.
Texture::decode16 reads these formats (and legacy FourCC 36, wide channel
masks, BC4/BC5 interpolated at 16 bits) without losing precision.
The DX10 header's alpha mode (miscFlags2, low three bits) was never
read, so RGBA, BGRA, BC2 and BC3 files marked premultiplied were read
as straight alpha. They are refused as Unsupported, like the legacy
DXT2/DXT4 FourCCs. Alpha modes 0, 1, 3 and 4 and the formats without
alpha are unchanged.
BC4 is one block of 16 single-channel values and BC5 two of them, the
block BC3 already stores its alpha in, so the alpha block encoder and
decoder now serve all three (BC3's output stays the same).
Reading: ATI1 and BC4U, and DXGI 79 (typeless) and 80, open as gray;
ATI2 and BC5U, and DXGI 82 (typeless, as Pillow writes it) and 83,
open as RGB with blue 0. ATI2 follows Microsoft's mapping, red in the
first block. Signed BC4S/BC5S and DXGI 81/84 are refused, naming SNORM.
Writing: DdsCompression::Bc4 (bc4, ati1) from gray and Bc5 (bc5, ati2)
from RGB, with the DX10 header (BC4_UNORM, BC5_UNORM, one 2D texture),
mip chains included. The encode plan converts other layouts to gray
and RGB, so the fidelity warnings report colour to gray and dropped
alpha; BC5's dropped blue is documented under LossyCompression.
DdsCompression is now #[non_exhaustive] and ALL has six entries.
A power-iteration step that gives back the same axis bit for bit gives
it back on every later step, so stopping there keeps the output. Kept
only if the timings show a gain.
Encoding:
- colour blocks keep their colours and endpoint candidates on the stack
instead of in per-block vectors (the idea of storytold/photocraft#10669)
- a refinement round whose endpoint pair was already fitted ends the
search, which could not change the block any more
- a block of one colour skips the principal-axis search, whose result
for it is that colour at both ends
- the alpha block gathers its 16 values once, finds both ranges in one
pass and picks indices in a plain loop with the same tie-break
- the nearest palette colour is found the same way
- interior blocks are gathered as four rows of four texels, and
interior mip pixels average their 2x2 source pixels directly
Decoding:
- block-compressed data is decoded one row of blocks per task, copying
whole texel rows and checking bounds only on the right edge
- uncompressed rows are decoded one per task; when every channel is a
whole byte (RGBA, BGRA, BGRX, luminance), pixels are a byte shuffle
The f32 arithmetic and its order are unchanged; the digest oracle pins
the output.
craft-dds holds the header parsing, the uncompressed and BC1-BC3
readers and writers and the block encoder, with its own pixel layout
and error types and rayon behind a `parallel` feature. It parses the
header first (Texture::parse) so a caller can check the size against
its limits before anything is allocated.
craft-image-codecs reads and writes DDS through it, re-exports its
DdsCompression and DdsOptions and maps its errors onto CodecError with
the same messages, so its API and output stay the same. Apps that only
need DDS can depend on craft-dds without the other codecs and their
licences.