PNG encode and decode
The PNG encoder writes 8-bit RGB or RGBA files from pitched RGBA or BGRA pixels. The decoder reads non-interlaced grayscale, palette, RGB and RGBA images into a checked guest buffer.
Repository notes through October 10, 2026
Encoding
Titles hand the encoder a rectangle of pixels that may have a row pitch larger than the width. PS5PCEM accepts pitched RGBA and BGRA and writes a standard 8-bit RGB or RGBA PNG. The caller selects the scanline filters and a compression level from 0 through 9. Output writes are bounded by the buffer the title provided.
The encoder is a software implementation of the file format. It does not call out to a system image library, and it does not claim a particular speed against the console's hardware encoder.
Decoding
libScePngDec parses PNG metadata and decodes non-interlaced grayscale, palette, RGB and RGBA images into checked guest RGBA or BGRA buffers. Scanline filters are applied, and palette transparency is honored. The destination is checked before pixels are written.
Adam7 interlaced input is recognized and refused rather than decoded into a wrong image. Interlaced icons and screenshots therefore do not silently become a garbled buffer.
Where it sits
PNG is one of the small firmware services a title hits during startup: icons, atlases and save thumbnails. It is independent of the AvPlayer movie path, which uses FFmpeg for H.264, and independent of the font rasterizer.
The October 9 firmware report groups the encoder with the clock and the AMPR completion-size queries. Those three closed import gaps. They do not, by themselves, change a measured frame time.
What is implemented
- Pitched RGBA and BGRA input to 8-bit RGB or RGBA PNG at compression levels 0–9.
- Decode of non-interlaced grayscale, palette, RGB and RGBA, including filters and palette alpha.
- Checked destination buffers and bounded encoder output.
What is still missing
- Adam7 interlaced PNG is recognized and not decoded.
- 16-bit and exotic ancillary chunks are outside the implemented subset.
- There is no hardware PNG block. Both sides run on the CPU.
Related mechanisms
What these pages are