fix(libSceJpegDec): stop callback refills after EOI #18370
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/18370"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by Ondra97 on 2026-11-11T12:36:51Z.
What
sceJpegDecDecodeWithInputControlcan reject a complete valid JPEG while filling a 2 KiB input block: it requests another callback after copying EOI, then propagates that callback's error. Check the existing incremental end detector after each copied callback chunk and stop refilling when it has found EOI. This fixes both the parse and decode paths.The existing detector still handles marker lengths, entropy byte stuffing and restart markers. This follows the bundled libjpeg-turbo input contract. Exact native refill counts and read-ahead remain unmeasured; bytes offered in the same callback still follow the existing buffering policy.
Regressions compare pixels with the direct decode path for short grayscale and large RGB images, with 1/7/65536-byte callback chunks. They cover an error after EOI, an error before its final byte with unchanged output, repeated decoding without another callback, restart markers, false EOI bytes inside APP1, and trailing bytes in the same callback. The existing missing-frame EOI fixture still returns decode error; its callback count changes from three to one because refilling now stops at EOI.
Tested
Windows 11 Pro 10.0.26300; AMD Ryzen 9 7900X; 32 GB RAM; NVIDIA RTX 4070 Ti SUPER (unused by these codec tests). WinLibs MinGW-w64 GCC 15.2.0 r7, CMake 4.3.1, Ninja, Release.
Base reproduction:
aece3f1a226c61c1e4d493132bbc3ec82cdbd48e. Final tested commit:c8388f97ab26a188bd07751a2f5ba2afce058bc6, based on1e43d62f13896d5e6ec91d1c2c409a684b73ea8d.Fresh full-project configuration with
BUILD_TESTING=ON,ANYPS5_RELINKER_ONLY=OFFand exact current submodules. Focused build and runtime commands:All five selected tests passed: four runtime tests and the public-header audit. Conventions and
git diff --checkpassed. Independent read-only review found no introduced defect in the incremental marker handling. Linux, macOS, console, titles, progressive/multi-scan runtime fixtures and the full CTest suite were not tested.Hosted Windows job 130526826046 passed for head
c8388f97ab26a188bd07751a2f5ba2afce058bc6; its changed-test selection ranguest_jpeg_dec_input_controlsuccessfully (1/1). Conventions, library portability, intake and eligibility also passed. Linux and unrelated jobs were skipped.Pre-opening
python tools/pr_overlap.py --repo boykopovar/AnyPS5 --branch codex/fix-jpeg-input-end-boundary --jobs 6checked 1,977 open PR heads and reported no overlap. The existing Y8 and Delete PRs were also compared statically; neither changes this refill logic.Additional integration validation: current main
0effa485f96a4fcf8fef433a09cdd862c65b7767plus #18361 (2464b95fe12373ab2a4b46024b6b29390d615935), #18370 (c8388f97ab26a188bd07751a2f5ba2afce058bc6) and #18387 (887c2c6e51e6b926a773abaa43e9f15b71af1efc), composed locally as7b8bc0d80db09dee5e39bcdf5159d8b8791d9db9. A fresh full-project build passed all 10 focused PNG/JPEG runtime CTests andpublic_headers(11/11). A separate temporary PNG probe passed in fresh processes through both raw and production-NID-resolved exports with an isolated patched libc/kernel/PNG closure. It checks level-0 stored RGB/RGBA streams, literal decoded pixels, 1/7/full-image callback chunks with an error only after IEND, repeated decode without another callback and row padding. This is synthetic Windows integration coverage; no title or console run is claimed. Probe source and reproduction commands are included in #18387.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-11T16:22:05Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
c8388f97ab:tools/check_conventions.pypassed;git diff --checkclean.guest_jpeg_dec_input_control_testsbuilt cleanly.guest_jpeg_dec_input_control):core/libs/prx/libSceJpegDec/Export.cppreverted tomainand the new tests kept, the suite fails: Restoring the change makes it pass again.Looks Good To Me