xref: /plan9/sys/src/cmd/gs/src/sjpx.h (revision 593dc095aefb2a85c828727bbfa9da139a49bdf4)
1 /* Copyright (C) 2003-2004 artofcode LLC.  All rights reserved.
2 
3   This software is provided AS-IS with no warranty, either express or
4   implied.
5 
6   This software is distributed under license and may not be copied,
7   modified or distributed except as expressly authorized under the terms
8   of the license contained in the file LICENSE in this distribution.
9 
10   For more information about licensing, please refer to
11   http://www.ghostscript.com/licensing/. For information on
12   commercial licensing, go to http://www.artifex.com/licensing/ or
13   contact Artifex Software, Inc., 101 Lucas Valley Road #110,
14   San Rafael, CA  94903, U.S.A., +1(415)492-9861.
15 */
16 
17 /* $Id: sjpx.h,v 1.5 2005/05/17 20:56:46 giles Exp $ */
18 /* Definitions for JPXDecode filter (JPEG 2000) */
19 /* we link to the JasPer library for the actual decoding */
20 
21 #ifndef sjpx_INCLUDED
22 #  define sjpx_INCLUDED
23 
24 /* Requires scommon.h; strimpl.h if any templates are referenced */
25 
26 #include "scommon.h"
27 #include <jasper/jasper.h>
28 
29 /* Our local state consists of pointers to the JasPer library's
30  * stream and image structs for sending and retrieving the
31  * image data. There's no way to feed a jasper stream with
32  * incremental buffers, so we also must spool the entire
33  * compressed stream into our own buffer before handing it
34  * to the library. We also keep track of how much of the
35  * decoded image we have returned.
36  */
37 typedef struct stream_jpxd_state_s
38 {
39     stream_state_common;	/* a define from scommon.h */
40     jas_image_t *image;
41     jas_stream_t *stream;
42     long offset; /* offset into the image bitmap of the next
43                     byte to be returned */
44     const gs_memory_t *jpx_memory;
45     unsigned char *buffer; /* temporary buffer for compressed data */
46     long bufsize; /* total size of the buffer */
47     long buffill; /* number of bytes written into the buffer */
48 }
49 stream_jpxd_state;
50 
51 #define private_st_jpxd_state()	\
52   gs_private_st_simple(st_jpxd_state, stream_jpxd_state,\
53     "JPXDecode filter state")
54 extern const stream_template s_jpxd_template;
55 
56 #endif /* sjpx_INCLUDED */
57