RequireTruncatedTransparency called Decode and ignored the result, so any
result passed. Assert that Decode returns no image for the input cut in the
middle of its tRNS chunk, which is what the decoder returns today.
Checked with a mutant Decode that returns an image for this input: the test
aborts on the mutant, and the previous version of the test passes it.
RequireTruncatedTransparency compared the input buffer with a copy of
itself after calling Decode. Decode takes a read-only span, so that
comparison cannot fail and it tells the reader nothing. Remove it and
the copy it used. The decode call stays for now; the next commit makes
it an assertion.
sceJpegDecParseHeader and sceJpegDecDecode threw for every down scale
other than 1. SharpProspero's JpegDec.cs documents the factors 1, 2, 4
and 8 and output dimensions that account for the down scale.
Decoder::Jpeg gains DecodeScaled, which decodes through libjpeg-turbo's
scaled inverse DCT, and ScaledDimension, its rounded-up output size.
sceJpegDecParseHeader reports the scaled output size; sceJpegDecDecode
checks the pitch and image buffer against it, writes the scaled image
and packs the output size into its result. A down scale of 1 still
decodes as before. Decode modes other than 0, other down scales and a
down-scaled CMYK or YCCK image still throw.
The libraries are x86-64 code that runs under Rosetta 2 on Apple silicon,
so the full build selects x86-64 itself: CMAKE_OSX_ARCHITECTURES defaults to
x86_64, CMake is told the host processor is x86_64 instead of arm64, and
libjpeg-turbo, which is configured by its own CMake run, gets the same
values. Configuring the full build for another architecture fails with an
error.
Apple clang's libc++ needs -fexperimental-library for the C++20 library
features the sources use.
The prx libraries find each other through their run path. dyld does not
know $ORIGIN, so on macOS it is @loader_path.
A filter_type naming a subset of the PNG filters used only the first
filter of the mask, because stb's writer is either fully adaptive or
forced to one filter. Decoder::Png::Encode now takes the set of allowed
filter types, filters the rows and writes the chunks itself, and keeps
stb for deflate only. Output for the all-filters and single-filter
cases is unchanged.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
scePngEncQueryMemorySize, scePngEncCreate, scePngEncEncode and
scePngEncDelete encode R8G8B8A8 and B8G8R8A8 images with a pitch into
RGB or RGBA PNGs using the shared encoder in core/Decoder/Png.
Decoder::Png::Encode takes optional compression level and filter
options so the encode parameters are honoured.
Co-Authored-By: Claude <[email protected]>