1 /*---------------------------------------------------------------------------*
2 Project: TwlSDK - SSP - include
3 File: jpegenc.h
4
5 Copyright 2007-2009 Nintendo. All rights reserved.
6
7 These coded instructions, statements, and computer programs contain
8 proprietary information of Nintendo of America Inc. and/or Nintendo
9 Company Ltd., and are protected by Federal copyright law. They may
10 not be disclosed to third parties or copied or duplicated in any form,
11 in whole or in part, without the prior written consent of Nintendo.
12
13 $Date:: 2009-07-06#$
14 $Rev: 10865 $
15 $Author: kitase_hirotake $
16 *---------------------------------------------------------------------------*/
17
18 #ifndef TWL_SSP_JPEGENC_H_
19 #define TWL_SSP_JPEGENC_H_
20
21 #include <twl/ssp/common/ssp_jpeg_type.h>
22 #include <twl/ssp/ARM9/exifenc.h>
23
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27
28 #include <twl/types.h>
29
30 /*---------------------------------------------------------------------------*
31 Name: SSP_GetJpegEncoderBufferSize
32
33 Description: Returns the work size required for encoding.
34
35 Arguments: width: Image width
36 height: Image height
37 sampling: Sampling (1 or 2)
38 option: Options (bitwise logical OR)
39 SSP_JPEG_RGB555: Encode from the RGB555 format.
40 SSP_JPEG_YUV422: Encode from the YUV422 format.
41 If unspecified, the format is considered to be RGB555.
42 SSP_JPEG_THUMBNAIL: Encode with a thumbnail.
43
44 Returns: The required memory size.
45 *---------------------------------------------------------------------------*/
46 u32 SSP_GetJpegEncoderBufferSize(u32 width, u32 height, u32 sampling, u32 option);
47
48 /*---------------------------------------------------------------------------*
49 Name: SSP_StartJpegEncoder
50
51 Description: Encodes a JPEG.
52 When sampling is 1, the width and height must be multiples of 8.
53 When sampling is 2, the width and height must be multiples of 16.
54 src, dst, and wrk must be 4-byte aligned.
55
56 Arguments: src: Image data (RGB555/YUV422 data from the upper left to the lower right)
57 dst: Location to put the encoded JPEG data
58 limit: Size limit for dst (encoding will fail if this is exceeded)
59 wrk: Work area
60 width: Image width
61 height: Image height
62 quality: Encoding quality (1-100)
63 sampling: Main image sampling (1=YUV444, 2=YUV420, 3=YUV422. Thumbnails are internally fixed to 3)
64 option: Options (bitwise logical OR)
65 SSP_JPEG_RGB555: Encode from the RGB555 format.
66 SSP_JPEG_YUV422: Encode from the YUV422 format.
67 If unspecified, the format is considered to be RGB555.
68 SSP_JPEG_THUMBNAIL: Encode with a thumbnail.
69
70 Returns: Encoded JPEG size (when this is 0, encoding failed).
71 *---------------------------------------------------------------------------*/
72 u32 SSP_StartJpegEncoder(const void* src, u8 *dst, u32 limit, u8 *wrk,
73 u32 width, u32 height,
74 u32 quality, u32 sampling, u32 option);
75
76 /*---------------------------------------------------------------------------*
77 Name: SSP_StartJpegEncoderEx
78
79 Description: Specifies whether to use a signature and encodes a JPEG.
80 When sampling is 1, the width and height must be multiples of 8.
81 When sampling is 2, the width and height must be multiples of 16.
82 src, dst, and wrk must be 4-byte aligned.
83
84 Arguments: src: Image data (RGB555/YUV422 data from the upper left to the lower right)
85 dst: Location to put the encoded JPEG data
86 limit: Size limit for dst (encoding will fail if this is exceeded)
87 wrk: Work area
88 width: Image width
89 height: Image height
90 quality: Encoding quality (1-100)
91 sampling: Main image sampling (1=YUV444, 2=YUV420, 3=YUV422. Thumbnails are internally fixed to 3)
92 option: Options (bitwise logical OR)
93 SSP_JPEG_RGB555: Encode from the RGB555 format.
94 SSP_JPEG_YUV422: Encode from the YUV422 format.
95 If unspecified, the format is considered to be RGB555.
96 SSP_JPEG_THUMBNAIL: Encode with a thumbnail.
97 sign: Specify TRUE to add a signature
98
99 Returns: Encoded JPEG size (when this is 0, encoding failed).
100 *---------------------------------------------------------------------------*/
SSP_StartJpegEncoderEx(const void * src,u8 * dst,u32 limit,u8 * wrk,u32 width,u32 height,u32 quality,u32 sampling,u32 option,BOOL sign)101 static inline u32 SSP_StartJpegEncoderEx(const void* src, u8 *dst, u32 limit, u8 *wrk,
102 u32 width, u32 height,
103 u32 quality, u32 sampling, u32 option, BOOL sign)
104 {
105 u32 result;
106 BOOL old_sign;
107
108 old_sign = SSP_SetJpegEncoderSignMode(sign);
109 result = SSP_StartJpegEncoder(src, dst, limit, wrk, width, height, quality, sampling, option);
110 (void)SSP_SetJpegEncoderSignMode(old_sign);
111
112 return result;
113 }
114
115 /*---------------------------------------------------------------------------*
116 Name: SSP_ConvertJpegEncodeData
117
118 Description: Converts input data into a format used to perform JPEG encoding.
119 The input data can be cleared after this function has finished.
120 When sampling is 1, the width and height must be multiples of 8.
121 When sampling is 2, the width and height must be multiples of 16.
122 src, dst, and wrk must be 4-byte aligned.
123
124 Arguments: src: Image data (RGB555/YUV422 data from the upper left to the lower right)
125 wrk: Work area
126 width: Image width
127 height: Image height
128 sampling: Main image sampling (1=YUV444, 2=YUV420, 3=YUV422. Thumbnails are internally fixed to 3)
129 option: Options (bitwise logical OR)
130 SSP_JPEG_RGB555: Encode from the RGB555 format.
131 SSP_JPEG_YUV422: Encode from the YUV422 format.
132 If unspecified, the format is considered to be RGB555.
133 SSP_JPEG_THUMBNAIL: Encode with a thumbnail.
134
135 Returns: TRUE on success.
136 *---------------------------------------------------------------------------*/
137 BOOL SSP_ConvertJpegEncodeData(const void* src, u8 *wrk,
138 u32 width, u32 height, u32 sampling, u32 option);
139
140 /*---------------------------------------------------------------------------*
141 Name: SSP_StartJpegEncoderWithEncodeData
142
143 Description: Encodes a JPEG from data that was converted in advance for encoding.
144 You must call the SSP_ConvertJpegEncodeData function before this one.
145 When sampling is 1, the width and height must be multiples of 8.
146 When sampling is 2, the width and height must be multiples of 16.
147 The dst and wrk values must be 4-byte aligned.
148
149 Arguments: dst: Location to put the encoded JPEG data
150 limit: Size limit for dst (encoding will fail if this is exceeded)
151 wrk: Work area
152 width: Image width
153 height: Image height
154 quality: Encoding quality (1-100)
155 sampling: Main image sampling (1=YUV444, 2=YUV420, 3=YUV422. Thumbnails are internally fixed to 3)
156 option: Options (bitwise logical OR)
157 SSP_JPEG_RGB555: Encode from the RGB555 format.
158 SSP_JPEG_YUV422: Encode from the YUV422 format.
159 If unspecified, the format is considered to be RGB555.
160 SSP_JPEG_THUMBNAIL: Encode with a thumbnail.
161
162 Returns: Encoded JPEG size (when this is 0, encoding failed).
163 *---------------------------------------------------------------------------*/
164 u32 SSP_StartJpegEncoderWithEncodeData(u8 *dst, u32 limit, u8 *wrk,
165 u32 width, u32 height,
166 u32 quality, u32 sampling, u32 option);
167
168 /*---------------------------------------------------------------------------*
169 Name: SSP_StartJpegEncoderWithEncodeDataEx
170
171 Description: Specifies whether to use a signature and encodes a JPEG from data that was converted in advance for encoding.
172 You must call the SSP_ConvertJpegEncodeData function before this one.
173 When sampling is 1, the width and height must be multiples of 8.
174 When sampling is 2, the width and height must be multiples of 16.
175 The dst and wrk values must be 4-byte aligned.
176
177 Arguments: dst: Location to put the encoded JPEG data
178 limit: Size limit for dst (encoding will fail if this is exceeded)
179 wrk: Work area
180 width: Image width
181 height: Image height
182 quality: Encoding quality (1-100)
183 sampling: Main image sampling (1=YUV444, 2=YUV420, 3=YUV422. Thumbnails are internally fixed to 3)
184 option: Options (bitwise logical OR)
185 SSP_JPEG_RGB555: Encode from the RGB555 format.
186 SSP_JPEG_YUV422: Encode from the YUV422 format.
187 If unspecified, the format is considered to be RGB555.
188 SSP_JPEG_THUMBNAIL: Encode with a thumbnail.
189 sign: Specify TRUE to add a signature
190
191 Returns: Encoded JPEG size (when this is 0, encoding failed).
192 *---------------------------------------------------------------------------*/
SSP_StartJpegEncoderWithEncodeDataEx(u8 * dst,u32 limit,u8 * wrk,u32 width,u32 height,u32 quality,u32 sampling,u32 option,BOOL sign)193 static inline u32 SSP_StartJpegEncoderWithEncodeDataEx(u8 *dst, u32 limit, u8 *wrk,
194 u32 width, u32 height,
195 u32 quality, u32 sampling, u32 option, BOOL sign)
196 {
197 u32 result;
198 BOOL old_sign;
199
200 old_sign = SSP_SetJpegEncoderSignMode(sign);
201 result = SSP_StartJpegEncoderWithEncodeData(dst, limit, wrk, width, height, quality, sampling, option);
202 (void)SSP_SetJpegEncoderSignMode(old_sign);
203
204 return result;
205 }
206
207 /*---------------------------------------------------------------------------*
208 Name: SSP_GetJpegEncoderLiteBufferSize
209
210 Description: Returns the work size required for encoding (reduced-memory version).
211 This work size is used by SSP_StartJpegEncoderLite.
212
213 Arguments: option: Options (bitwise logical OR)
214 SSP_JPEG_RGB555: Encode from the RGB555 format.
215 SSP_JPEG_YUV422: Encode from the YUV422 format.
216 If unspecified, the format is considered to be RGB555.
217 SSP_JPEG_THUMBNAIL: Encode with a thumbnail.
218
219 Returns: The required memory size.
220 *---------------------------------------------------------------------------*/
221 u32 SSP_GetJpegEncoderLiteBufferSize(u32 option);
222
223 /*---------------------------------------------------------------------------*
224 Name: SSP_StartJpegEncoderLite
225
226 Description: Encodes a JPEG (reduced-memory version).
227 Note: This is unrelated to SSP_StartJpegEncoderEx.
228 When sampling is 1, the width and height must be multiples of 8.
229 When sampling is 2, the width and height must be multiples of 16.
230 The width value must be a multiple of 16, and the height value must be a multiple of 8 if sampling is 3.
231 src, dst, and wrk must be 4-byte aligned.
232
233 Arguments: src: Image data (RGB555/YUV422 data from the upper left to the lower right)
234 dst: Location to put the encoded JPEG data
235 limit: Size limit for dst (encoding will fail if this is exceeded)
236 wrk: Work area
237 width: Image width
238 height: Image height
239 quality: Encoding quality (1-100)
240 sampling: Main image sampling (1=YUV444, 2=YUV420, 3=YUV422. Thumbnails are internally fixed to 3)
241 option: Options (bitwise logical OR)
242 SSP_JPEG_RGB555: Encode from the RGB555 format.
243 SSP_JPEG_YUV422: Encode from the YUV422 format.
244 Failure to specify a format will result in an error.
245 SSP_JPEG_THUMBNAIL: Encode with a thumbnail.
246
247 Returns: Encoded JPEG size (when this is 0, encoding failed).
248 *---------------------------------------------------------------------------*/
249 u32 SSP_StartJpegEncoderLite(const void* src, u8 *dst, u32 limit, u8 *wrk,
250 u32 width, u32 height,
251 u32 quality, u32 sampling, u32 option);
252
253 /*---------------------------------------------------------------------------*
254 Name: SSP_StartJpegEncoderLiteEx
255
256 Description: Encodes a JPEG (reduced-memory version).
257 Note: This is unrelated to SSP_StartJpegEncoderEx.
258 When sampling is 1, the width and height must be multiples of 8.
259 When sampling is 2, the width and height must be multiples of 16.
260 The width value must be a multiple of 16, and the height value must be a multiple of 8 if sampling is 3.
261 src, dst, and wrk must be 4-byte aligned.
262
263 Arguments: src: Image data (RGB555/YUV422 data from the upper left to the lower right)
264 dst: Location to put the encoded JPEG data
265 limit: Size limit for dst (encoding will fail if this is exceeded)
266 wrk: Work area
267 width: Image width
268 height: Image height
269 quality: Encoding quality (1-100)
270 sampling: Main image sampling (1=YUV444, 2=YUV420, 3=YUV422. Thumbnails are internally fixed to 3)
271 option: Options (bitwise logical OR)
272 SSP_JPEG_RGB555: Encode from the RGB555 format.
273 SSP_JPEG_YUV422: Encode from the YUV422 format.
274 Failure to specify a format will result in an error.
275 SSP_JPEG_THUMBNAIL: Encode with a thumbnail.
276 sign: Specify TRUE to add a signature
277
278 Returns: Encoded JPEG size (when this is 0, encoding failed).
279 *---------------------------------------------------------------------------*/
SSP_StartJpegEncoderLiteEx(const void * src,u8 * dst,u32 limit,u8 * wrk,u32 width,u32 height,u32 quality,u32 sampling,u32 option,BOOL sign)280 static inline u32 SSP_StartJpegEncoderLiteEx(const void* src, u8 *dst, u32 limit, u8 *wrk,
281 u32 width, u32 height,
282 u32 quality, u32 sampling, u32 option, BOOL sign)
283 {
284 u32 result;
285 BOOL old_sign;
286
287 old_sign = SSP_SetJpegEncoderSignMode(sign);
288 result = SSP_StartJpegEncoderLite(src, dst, limit, wrk, width, height, quality, sampling, option);
289 (void)SSP_SetJpegEncoderSignMode(old_sign);
290
291 return result;
292 }
293
294 /*---------------------------------------------------------------------------*
295 Name: SSP_GetJpegEncoderFastBufferSize
296
297 Description: Returns the work size required for encoding (High-speed version).
298 This work size is used by SSP_StartJpegEncoderFast.
299
300 Arguments: option: Options (bitwise logical OR)
301 SSP_JPEG_RGB555: Encode from the RGB555 format.
302 SSP_JPEG_YUV422: Encode from the YUV422 format.
303 If unspecified, the format is considered to be RGB555.
304 SSP_JPEG_THUMBNAIL: Encode with a thumbnail.
305
306 Returns: The required memory size.
307 *---------------------------------------------------------------------------*/
308 u32 SSP_GetJpegEncoderFastBufferSize(u32 option);
309
310 /*---------------------------------------------------------------------------*
311 Name: SSP_StartJpegEncoderFast
312
313 Description: Encodes a JPEG (High-speed version).
314 Note: This is unrelated to SSP_StartJpegEncoderEx.
315 When sampling is 1, the width and height must be multiples of 8.
316 When sampling is 2, the width and height must be multiples of 16.
317 The width value must be a multiple of 16, and the height value must be a multiple of 8 if sampling is 3.
318 src, dst, and wrk must be 4-byte aligned.
319
320 Arguments: src: Image data (RGB555/YUV422 data from the upper left to the lower right)
321 dst: Location to put the encoded JPEG data
322 limit: Size limit for dst (encoding will fail if this is exceeded)
323 wrk: Work area
324 width: Image width
325 height: Image height
326 quality: Encoding quality (1-100)
327 sampling: Main image sampling (1=YUV444, 2=YUV420, 3=YUV422. Thumbnails are internally fixed to 3)
328 option: Options (bitwise logical OR)
329 SSP_JPEG_RGB555: Encode from the RGB555 format.
330 SSP_JPEG_YUV422: Encode from the YUV422 format.
331 Failure to specify a format will result in an error.
332 SSP_JPEG_THUMBNAIL: Encode with a thumbnail.
333
334 Returns: Encoded JPEG size (when this is 0, encoding failed).
335 *---------------------------------------------------------------------------*/
336 u32 SSP_StartJpegEncoderFast(const void* src, u8 *dst, u32 limit, u8 *wrk,
337 u32 width, u32 height,
338 u32 quality, u32 sampling, u32 option);
339
340 /*---------------------------------------------------------------------------*
341 Name: SSP_StartJpegEncoderFastEx
342
343 Description: Encodes a JPEG (High-speed version).
344 Note: This is unrelated to SSP_StartJpegEncoderEx.
345 When sampling is 1, the width and height must be multiples of 8.
346 When sampling is 2, the width and height must be multiples of 16.
347 The width value must be a multiple of 16, and the height value must be a multiple of 8 if sampling is 3.
348 src, dst, and wrk must be 4-byte aligned.
349
350 Arguments: src: Image data (RGB555/YUV422 data from the upper left to the lower right)
351 dst: Location to put the encoded JPEG data
352 limit: Size limit for dst (encoding will fail if this is exceeded)
353 wrk: Work area
354 width: Image width
355 height: Image height
356 quality: Encoding quality (1-100)
357 sampling: Main image sampling (1=YUV444, 2=YUV420, 3=YUV422. Thumbnails are internally fixed to 3)
358 option: Options (bitwise logical OR)
359 SSP_JPEG_RGB555: Encode from the RGB555 format.
360 SSP_JPEG_YUV422: Encode from the YUV422 format.
361 Failure to specify a format will result in an error.
362 SSP_JPEG_THUMBNAIL: Encode with a thumbnail.
363 sign: Specify TRUE to add a signature
364
365 Returns: Encoded JPEG size (when this is 0, encoding failed).
366 *---------------------------------------------------------------------------*/
367 u32 SSP_StartJpegEncoderFastEx(const void* src, u8 *dst, u32 limit, u8 *wrk,
368 u32 width, u32 height,
369 u32 quality, u32 sampling, u32 option, BOOL sign);
370
371
372 #ifdef __cplusplus
373 } /* extern "C" */
374 #endif
375
376 /* TWL_SSP_JPEGENC_H_ */
377 #endif
378