Jpegdec services

From Nintendo Switch Brew
Revision as of 22:53, 30 March 2025 by Behemoth (talk | contribs) (update the latest two jpegdec commands)
Jump to navigation Jump to search

Jpegdec is a refactored sysmodule added with [4.0.0+] for handling all JPEG decoding associated with capture services.

caps:dc

This is "nn::capsrv::sf::IDecoderControlService".

Cmd Name
3001 #DecodeJpeg
4001 [17.0.0+] #ShrinkJpeg
4002 [18.0.0+] #ShrinkJpegEx

DecodeJpeg

Takes an input u32 width, an input u32 height, an input ScreenShotDecodeOption, a type-0x46 output buffer, a type-0x5 input buffer, and no output.

The type-0x46 buffer contains the RGBA8 image data. The type-0x5 buffer contains the input JPEG data.

ShrinkJpeg

Takes an input u32 width, an input u32 height, an input ScreenShotDecodeOption, a type-0x46 output buffer, a type-0x5 input buffer, and an output u64 size.

Iterates the JPEG quality levels in order 98, 95, 90, 80, 70, 60, 50, 40, 30, 20, 10 to 0, tries to compress the input JPEG in the type-0x5, into the output buffer as a JPEG with the current quality and scaled_width = width/2 and scaled_height = height/2. If it succeeds, or the failure isn't because the supplied buffer isn't large enough, returns, else retries with the next lower quality preset until 0.

ShrinkJpegEx

Takes an input u32 width, an input u32 height, an input u8 quality, an input ScreenShotDecodeOption, a type-0x46 output buffer, a type-0x5 input buffer, and an output u64 size.

Tries to compress the JPEG in the type-0x5 buffer into the type-0x46 buffer with the supplied width, height and quality as output settings.