# SSP_StartJpegEncoder

## Syntax

    u32 SSP_StartJpegEncoder(const void* src, u8 *dst, u32 limit, u8 *wrk, u32 width, u32 height, u32 quality, u32 sampling, u32 option);

## Arguments

src | Image data to be encoded. (RGB555 or YUV422)
dst | Buffer that stores encoded results.
limit | Represents the dst size. Encoding fails if this size is exceeded.
wrk | Work buffer. The `SSP_GetJpegEncoderBufferSize` function calculates the required size.
width | Width (in pixels) of the image to encode.
height | Height (in pixels) of the image to encode.
quality | Encode quality. Values can be from 1 to 100, where 100 represents the highest quality and the largest size.
sampling | Main image output formats (`SSP_JPEG_OUTPUT_YUV444`, `SSP_JPEG_OUTPUT_YUV420`, or `SSP_JPEG_OUTPUT_YUV422`).
option | Encoding options (`SSP_JPEG_RGB555`, `SSP_JPEG_YUV422`, or `SSP_JPEG_THUMBNAIL`).

## Return Values

Returns the size of the created JPEG file when successful.
Returns 0 when it fails.

## Description

Encodes image data as a JPEG file. RGB555 and YUV422 images can be encoded. When you specify YUV422 image data as src, you must specify `SSP_JPEG_YUV422` in option. If you want to encode a thumbnail icon, you must specify `SSP_JPEG_THUMBNAIL` in option.
Therefore, to encode a YUV422 image along with a thumbnail icon, you must specify `SSP_JPEG_YUV422|SSP_JPEG_THUMBNAIL` in option.
The height and width of images that can be encoded using this function differs depending on the value of sampling.
If `SSP_JPEG_OUTPUT_YUV444` is specified, both the height and width of the image must be a multiple of 8.
If `SSP_JPEG_OUTPUT_YUV420` is specified, both the height and width of the image must be a multiple of 16.
If `SSP_JPEG_OUTPUT_YUV422` is specified, the height must be a multiple of 8, and the width a multiple of 16.
Note:
Regardless of whether this function succeeds or fails at encoding, after completion the values set by the `SSP_SetJpegEncoderDateTime`,`SSP_SetJpegEncoderDateTimeNow`,`SSP_SetJpegEncoderMakerNote`, and `SSP_SetJpegEncoderMakerNoteEx` functions are cleared.
If the `SSP_SetJpegEncoderDateTime` or `SSP_SetJpegEncoderDateTimeNow` functions are not called, the `RTC_GetDateTime` function is called internally.

## See Also

`SSP_SetJpegEncoderDateTime`
`SSP_SetJpegEncoderDateTimeNow`
`SSP_GetJpegEncoderBufferSize`

## Revision History

2008/11/04 Added a description of values cleared after completion of this function.
2008/10/15 Added a description of the limitations on the height and width of images that can be encoded.
2008/10/09 Added a description of RSF file settings.
2008/09/15 Initial version.

CONFIDENTIAL