/*---------------------------------------------------------------------------* Project: TwlSDK - SSP - include File: jpegenc.h Copyright 2007-2008 Nintendo. All rights reserved. These coded instructions, statements, and computer programs contain proprietary information of Nintendo of America Inc. and/or Nintendo Company Ltd., and are protected by Federal copyright law. They may not be disclosed to third parties or copied or duplicated in any form, in whole or in part, without the prior written consent of Nintendo. $Date:: 2008-12-03#$ $Rev: 9496 $ $Author: kitase_hirotake $ *---------------------------------------------------------------------------*/ #ifndef TWL_SSP_JPEGENC_H_ #define TWL_SSP_JPEGENC_H_ #include #include #ifdef __cplusplus extern "C" { #endif #include /*---------------------------------------------------------------------------* Name: SSP_GetJpegEncoderBufferSize Description: Returns the work size required for encoding. Arguments: width: Image width height: Image height sampling: Sampling (1 or 2) option: Options (bitwise logical OR) SSP_JPEG_RGB555: Encode from the RGB555 format. SSP_JPEG_YUV422: Encode from the YUV422 format. If unspecified, the format is considered to be RGB555. SSP_JPEG_THUMBNAIL: Encode with a thumbnail. Returns: The required memory size. *---------------------------------------------------------------------------*/ u32 SSP_GetJpegEncoderBufferSize(u32 width, u32 height, u32 sampling, u32 option); /*---------------------------------------------------------------------------* Name: SSP_StartJpegEncoder Description: Encodes a JPEG. The width and height must be multiples of 8 if sampling is 1 and multiples of 16 if sampling is 2. src, dst, and wrk must be 4-byte aligned. Arguments: src: Image data (RGB555/YUV422 data from the upper left to the lower right) dst: Location to put the encoded JPEG data limit: Size limit for dst (encoding will fail if this is exceeded) wrk: Work area width: Image width height: Image height quality: Encoding quality (1-100) sampling: Main image sampling (1=YUV444, 2=YUV420, 3=YUV422. Thumbnails are internally fixed to 3) option: Options (bitwise logical OR) SSP_JPEG_RGB555: Encode from the RGB555 format. SSP_JPEG_YUV422: Encode from the YUV422 format. If unspecified, the format is considered to be RGB555. SSP_JPEG_THUMBNAIL: Encode with a thumbnail. Returns: Encoded JPEG size (when this is 0, encoding failed) *---------------------------------------------------------------------------*/ u32 SSP_StartJpegEncoder(const void* src, u8 *dst, u32 limit, u8 *wrk, u32 width, u32 height, u32 quality, u32 sampling, u32 option); /*---------------------------------------------------------------------------* Name: SSP_StartJpegEncoderEx Description: Specifies whether to use a signature and encodes a JPEG. The width and height must be multiples of 8 if sampling is 1 and multiples of 16 if sampling is 2. src, dst, and wrk must be 4-byte aligned. Arguments: src: Image data (RGB555/YUV422 data from the upper left to the lower right) dst: Location to put the encoded JPEG data limit: Size limit for dst (encoding will fail if this is exceeded) wrk: Work area width: Image width height: Image height quality: Encoding quality (1-100) sampling: Main image sampling (1=YUV444, 2=YUV420, 3=YUV422. Thumbnails are internally fixed to 3) option: Options (bitwise logical OR) SSP_JPEG_RGB555: Encode from the RGB555 format. SSP_JPEG_YUV422: Encode from the YUV422 format. If unspecified, the format is considered to be RGB555. SSP_JPEG_THUMBNAIL: Encode with a thumbnail. sign: Specify TRUE to add a signature. Returns: Encoded JPEG size (when this is 0, encoding failed) *---------------------------------------------------------------------------*/ static inline u32 SSP_StartJpegEncoderEx(const void* src, u8 *dst, u32 limit, u8 *wrk, u32 width, u32 height, u32 quality, u32 sampling, u32 option, BOOL sign) { u32 result; (void)SSP_SetJpegEncoderSignMode(sign); result = SSP_StartJpegEncoder(src, dst, limit, wrk, width, height, quality, sampling, option); (void)SSP_SetJpegEncoderSignMode(FALSE); return result; } /*---------------------------------------------------------------------------* Name: SSP_ConvertJpegEncodeData Description: Converts input data into a format used to perform JPEG encoding. The input data can be cleared after this function has finished. The width and height must be multiples of 8 if sampling is 1 and multiples of 16 if sampling is 2. src, dst, and wrk must be 4-byte aligned. Arguments: src: Image data (RGB555/YUV422 data from the upper left to the lower right) wrk: Work area width: Image width height: Image height sampling: Main image sampling (1=YUV444, 2=YUV420, 3=YUV422. Thumbnails are internally fixed to 3) option: Options (bitwise logical OR) SSP_JPEG_RGB555: Encode from the RGB555 format. SSP_JPEG_YUV422: Encode from the YUV422 format. If unspecified, the format is considered to be RGB555. SSP_JPEG_THUMBNAIL: Encode with a thumbnail. Returns: TRUE on success. *---------------------------------------------------------------------------*/ BOOL SSP_ConvertJpegEncodeData(const void* src, u8 *wrk, u32 width, u32 height, u32 sampling, u32 option); /*---------------------------------------------------------------------------* Name: SSP_StartJpegEncoderWithEncodeData Description: Encodes a JPEG from data that was converted in advance for encoding. You must call the SSP_ConvertJpegEncodeData function before this one. The width and height must be multiples of 8 if sampling is 1 and multiples of 16 if sampling is 2. dst and wrk must be 4-byte aligned. Arguments: dst: Location to put the encoded JPEG data limit: Size limit for dst (encoding will fail if this is exceeded) wrk: Work area width: Image width height: Image height quality: Encoding quality (1-100) sampling: Main image sampling (1=YUV444, 2=YUV420, 3=YUV422. Thumbnails are internally fixed to 3) option: Options (bitwise logical OR) SSP_JPEG_RGB555: Encode from the RGB555 format. SSP_JPEG_YUV422: Encode from the YUV422 format. If unspecified, the format is considered to be RGB555. SSP_JPEG_THUMBNAIL: Encode with a thumbnail. Returns: Encoded JPEG size (when this is 0, encoding failed) *---------------------------------------------------------------------------*/ u32 SSP_StartJpegEncoderWithEncodeData(u8 *dst, u32 limit, u8 *wrk, u32 width, u32 height, u32 quality, u32 sampling, u32 option); /*---------------------------------------------------------------------------* Name: SSP_StartJpegEncoderWithEncodeDataEx Description: Specifies whether to use a signature and encodes a JPEG from data that was converted in advance for encoding. You must call the SSP_ConvertJpegEncodeData function before this one. The width and height must be multiples of 8 if sampling is 1 and multiples of 16 if sampling is 2. dst and wrk must be 4-byte aligned. Arguments: dst: Location to put the encoded JPEG data limit: Size limit for dst (encoding will fail if this is exceeded) wrk: Work area width: Image width height: Image height quality: Encoding quality (1-100) sampling: Main image sampling (1=YUV444, 2=YUV420, 3=YUV422. Thumbnails are internally fixed to 3) option: Options (bitwise logical OR) SSP_JPEG_RGB555: Encode from the RGB555 format. SSP_JPEG_YUV422: Encode from the YUV422 format. If unspecified, the format is considered to be RGB555. SSP_JPEG_THUMBNAIL: Encode with a thumbnail. sign: Specify TRUE to add a signature. Returns: Encoded JPEG size (when this is 0, encoding failed) *---------------------------------------------------------------------------*/ static inline u32 SSP_StartJpegEncoderWithEncodeDataEx(u8 *dst, u32 limit, u8 *wrk, u32 width, u32 height, u32 quality, u32 sampling, u32 option, BOOL sign) { u32 result; (void)SSP_SetJpegEncoderSignMode(sign); result = SSP_StartJpegEncoderWithEncodeData(dst, limit, wrk, width, height, quality, sampling, option); (void)SSP_SetJpegEncoderSignMode(FALSE); return result; } #ifdef __cplusplus } /* extern "C" */ #endif /* TWL_SSP_JPEGENC_H_ */ #endif