reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame^] | 1 | #ifdef __cplusplus |
| 2 | extern "C" { |
| 3 | #endif |
| 4 | |
| 5 | /** Extended interfaces for JPEG, JPEG2000 and JBIG2 decoders **/ |
| 6 | typedef struct |
| 7 | { |
| 8 | /** Initialize the decoding context, with memory allocator provided by FPDFEMB. |
| 9 | Implementation should return a pointer to the decoding context. |
| 10 | */ |
| 11 | void* (*Init)(void* (*alloc_func)(unsigned int), void (*free_func)(void*)); |
| 12 | |
| 13 | /** Finish with the decoding. */ |
| 14 | void (*Finish)(void* pContext); |
| 15 | |
| 16 | /** Input JPEG encoded data from the source. |
| 17 | This function may be called multiple times during decoding progress. |
| 18 | */ |
| 19 | void (*Input)(void* pContext, const unsigned char* src_buf, unsigned long src_size); |
| 20 | |
| 21 | /** Read the header information. Return non-zero for success, 0 for failure */ |
| 22 | int (*ReadHeader)(void* pContext); |
| 23 | |
| 24 | /** Get info from the decoder, including image width, height and number of components */ |
| 25 | void (*GetInfo)(void* pContext, int* width, int* height, int* nComps); |
| 26 | |
| 27 | /** Read one scanline from decoded image */ |
| 28 | int (*ReadScanline)(void* pContext, unsigned char* dest_buf); |
| 29 | |
| 30 | /** Get number of available source bytes left in the input stream */ |
| 31 | unsigned long (*GetAvailInput)(void* pContext); |
| 32 | } FPDFEMB_JPEG_DECODER; |
| 33 | |
| 34 | void FPDFEMB_SetJpegDecoder(FPDFEMB_JPEG_DECODER* pDecoder); |
| 35 | |
| 36 | typedef struct |
| 37 | { |
| 38 | /** Initialize the decoder with the full source data. |
| 39 | Implementation should return a pointer to the context. |
| 40 | */ |
| 41 | void* (*Init)(const unsigned char* src_buf, unsigned long src_size); |
| 42 | |
| 43 | /** Destroy the context */ |
| 44 | void (*Finish)(void* context); |
| 45 | |
| 46 | /** Get image info from the context, including width, height, number of components |
| 47 | in original codestream, and number of components in output image. For some |
| 48 | particular type of encoded image, like paletted image, these two numbers of |
| 49 | components may vary. |
| 50 | */ |
| 51 | void (*GetInfo)(void* context, unsigned long* width, unsigned long* height, |
| 52 | unsigned long* codestream_nComps, unsigned long* output_nComps); |
| 53 | |
| 54 | /** Do the real data decoding, output to a pre-allocated buffer. |
| 55 | bTranslateColor indicates whether the decoder should use JPEG2000 embedded |
| 56 | color space info to translate image into sRGB color space. |
| 57 | "offsets" array describes the byte order of all components. For example, |
| 58 | {2,1,0} means the first components is output to last byte. |
| 59 | */ |
| 60 | void (*Decode)(void* context, unsigned char* dest_buf, int pitch, |
| 61 | int bTranslateColor, unsigned char* offsets); |
| 62 | } FPDFEMB_JPEG2000_DECODER; |
| 63 | |
| 64 | void FPDFEMB_SetJpeg2000Decoder(FPDFEMB_JPEG2000_DECODER* pDecoder); |
| 65 | |
| 66 | typedef struct |
| 67 | { |
| 68 | /** Do the whole decoding process. Supplied parameters include width, height, source image |
| 69 | data and size, global data and size (can be shared among different images), destination |
| 70 | buffer and scanline pitch in dest buffer. |
| 71 | */ |
| 72 | void (*Decode)(unsigned long width, unsigned long height, const unsigned char* src_buf, |
| 73 | unsigned long src_size, const unsigned char* global_buf, unsigned long global_size, |
| 74 | unsigned char* dest_buf, int dest_pitch); |
| 75 | } FPDFEMB_JBIG2_DECODER; |
| 76 | |
| 77 | void FPDFEMB_SetJbig2Decoder(FPDFEMB_JBIG2_DECODER* pDecoder); |
| 78 | |
| 79 | #ifdef __cplusplus |
| 80 | }; |
| 81 | #endif |