nn::jpeg::CTR::JpegMpDecoder::StartJpegDecoderShrink Member Function

Syntax

#include <nn/jpeg.h>

size_t StartJpegDecoderShrink(
     void * dst,
     size_t dstSize,
     const u8 * src,
     size_t srcSize,
     u32 maxWidth,
     u32 maxHeight,
     PixelFormat dstPixelFormat,
     bool decodeThumbnail,
     u32 shrinkLevel
);

Arguments

Name Description
out dst Specifies the buffer that stores the decoded result.
The alignment of this buffer must match the output pixel format specified by the dstPixelFormat argument.
in dstSize Specifies the size of dst in bytes.
Specify the return value of GetDstBufferSize. The maxWidth and maxHeight arguments of GetDstBufferSize specify the maximum image dimensions of the decoding results (after shrinking).
You can specify the function arguments maxWidth, maxHeight, dstPixelFormat and shrinkLevel as shown in this example:
GetDstBufferSize ( maxWidth >> shrinkLevel, maxHeight >> shrinkLevel, dstPixelFormat )
However, when using the SetOutputBufferWidth function, specify the larger of that specified width and (maxWidth >> shrinkLevel).
in src Specifies the JPEG data to decode.
in srcSize Specifies the size of src in bytes.
in maxWidth Specifies the maximum width (in pixels) of an image that can be decoded. (Up to 65536)
Must be a multiple of the bitwise result of (1 << shrinkLevel).
After decoding successfully completes, use the GetLastWidth function to get the original image width and the GetLastOutputBufferWidth function to get the decoded result width.
in maxHeight Specifies the maximum height (in pixels) of an image that can be decoded. (Up to 65536)
Must be a multiple of the bitwise result of (1 << shrinkLevel).
After decoding successfully completes, use the GetLastHeight function to get the original image height and the GetLastOutputBufferHeight function to get the decoded result height.
in dstPixelFormat Specifies the output pixel format.
in decodeThumbnail Specify true to decode the thumbnail.
Specify false to decode the main image.
in shrinkLevel Specifies the shrink level. You can specify values of 1 through 4.
Specify 1 to shrink both the original height and width of the image by 1/2.
Specify 2 to shrink both original dimensions by 1/4, 3 for 1/8, and 4 for 1/16.

Return Values

When the function succeeds, the resulting buffer size (in bytes) is returned.
If the function fails it returns 0.
Use the GetLastError function to get the reason for failure.

Description

Decodes a JPEG image and outputs it after shrinking.

The height and width of the output image are 1/2, 1/4, 1/8, or 1/16 of the original dimensions depending on the value of the shrinkLevel argument. (Fractions are rounded up.)

The alignment specified by the dst argument is the same as for StartJpegDecoder.

The values specified for maxWidth and maxHeight (which define the largest image for which decoding is permitted) must be multiples of the bitwise result of (1 << shrinkLevel) for the given shrink level.
To be specific, you need to satisfy these conditions:
・When shrinkLevel is set to 1, specify a multiple of 2.
・When shrinkLevel is set to 2, specify a multiple of 4.
・When shrinkLevel is set to 3, specify a multiple of 8.
・When shrinkLevel is set to 4, specify a multiple of 16.
The actual image size does not need to be a multiple of the bitwise result of (1 << shrinkLevel).

After this function completes successfully, call the GetLastWidth and GetLastHeight functions to get the original image dimensions (before shrinking). Call the GetLastOutputBufferWidth and GetLastOutputBufferHeight functions to get the dimensions of the decoded result (output to a buffer after shrinking).

Processing time is not related to whether the original image size is a multiple of 8 or 16 pixels. Larger original and decoded image sizes take longer to process.

Revision History

2010/08/16
Initial version.

CONFIDENTIAL