1 /*---------------------------------------------------------------------------* 2 Project: JPEG Library for Wii U 3 File: jpeg.h 4 5 Copyright (C) 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 *---------------------------------------------------------------------------*/ 14 15 /*---------------------------------------------------------------------------* 16 This file is a front-end implementation for 'IJG libjpeg' developed by the 17 Independent JPEG Group (IJG). We are requested to state that: 18 "this software is based in part on the work of the Independent JPEG Group". 19 *---------------------------------------------------------------------------*/ 20 21 #ifndef _CAFE_JPEG_H 22 #define _CAFE_JPEG_H 23 24 #ifdef __cplusplus 25 extern "C" { 26 #endif 27 28 /*---------------------------------------------------------------------------* 29 Structure and constants 30 *---------------------------------------------------------------------------*/ 31 typedef enum { 32 JPEG_STATUS_OK = 0, 33 JPEG_STATUS_ARGS = -1, 34 JPEG_STATUS_UNSUPPORTED = -2, 35 JPEG_STATUS_INVALID = -3, 36 JPEG_STATUS_OUT_OF_MEMORY = -6, 37 JPEG_STATUS_SHORT_OUTPUT = -7, 38 JPEG_STATUS_HEAP_ERROR = -18, 39 JPEG_STATUS_FATAL = -19 40 } JPEGStatus; 41 42 typedef struct { 43 s32 width; 44 s32 height; 45 s32 numCh; // Number of color channel of input 46 } JPEGImageDim; 47 48 /*---------------------------------------------------------------------------* 49 Functions for encoding 50 *---------------------------------------------------------------------------*/ 51 JPEGStatus 52 JPEGEncEncodeSurface ( 53 void *pDestBuf, // Buffer for encoded JPEG. 54 u32 destBufSize, // Its size in byte. 55 u32 *pActualDestSize, // Byte-size of buffer filled with JPEG data. 56 const u32 *pTexBuf, // Texture buffer to be encoded. 57 const JPEGImageDim *pTexDim, // Its dimension. 58 s32 quality, // Encoding quality (1..100). 59 void *pWorkArea, // Temporal workspace. 60 u32 workAreaSize // Its size in byte. 61 ); 62 63 JPEGStatus 64 JPEGEncGetSurfaceInfo ( 65 u32 *pDestHeapSize, // Heep size required to encode JPEG 66 const JPEGImageDim *pImageDim // Dimension of source surface. 67 ); 68 69 /*---------------------------------------------------------------------------* 70 Functions for decoding 71 *---------------------------------------------------------------------------*/ 72 JPEGStatus 73 JPEGDecDecodeImage( 74 u32 *pDestBuf, // Buffer for decoded surface. 75 u32 destBufSize, // Its size in byte. 76 const void *pJpegBuf, // JPEG buffer to be decoded. 77 u32 jpegBufSize, // Its size in byte. 78 s32 resolution, // JPEG scaling parameter (1, 2, 4, or 8). 79 // Resulted surface will be scaled '1 / resolution'. 80 void *pWorkArea, // Temporal workspace. 81 u32 workAreaSize // Its size in byte. 82 ); 83 84 JPEGStatus 85 JPEGDecGetImageInfo( 86 JPEGImageDim *pDestDim, // Decoded JPEG dimension (width, height and channels) 87 u32 *pDestHeapSize, // Heep size required to decode JPEG 88 const void *pJpegBuf, // JPEG buffer to be decoded. 89 u32 jpegBufSize, // Its size in bytes 90 s32 resolution // JPEG scaling parameter (1, 2, 4, 8). 91 ); 92 93 94 /*---------------------------------------------------------- 95 * !!! Please do not use following deprecated functions !!! 96 *----------------------------------------------------------*/ 97 JPEGStatus JPEGEncEncode( 98 void *pWorkArea, 99 u32 workAreaSize, 100 u32 *pTexBuf, 101 JPEGImageDim *pTexDim, 102 s32 quality, 103 void *pDestBuf, 104 u32 destBufSize, 105 u32 *pActualDestSize); 106 JPEGStatus JPEGEncGetInfo ( 107 JPEGImageDim *pImageDim, 108 u32 *pDestHeapSize); 109 JPEGStatus JPEGDecDecode( 110 void *pWorkArea, 111 u32 workAreaSize, 112 void *const pJpegBuf, 113 u32 jpegBufSize, 114 s32 resolution, 115 u32 *pDestBuf, 116 u32 destBufSize); 117 JPEGStatus JPEGDecGetInfo( 118 void *const pJpegBuf, 119 u32 jpegBufSize, 120 s32 resolution, 121 JPEGImageDim *pDestDim, 122 u32 *pDestHeapSize); 123 124 #ifdef __cplusplus 125 } 126 #endif 127 128 #endif // _CAFE_JPEG_H 129