xref: /plan9/sys/src/cmd/gs/src/zfjpx.c (revision 593dc095aefb2a85c828727bbfa9da139a49bdf4)
1 /* Copyright (C) 2003 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: zfjpx.c,v 1.2 2004/08/11 14:33:02 stefan Exp $ */
18 
19 /* this is the ps interpreter interface to the jbig2decode filter
20    used for (1bpp) scanned image compression. PDF only specifies
21    a decoder filter, and we don't currently implement anything else */
22 
23 #include "memory_.h"
24 #include "ghost.h"
25 #include "oper.h"
26 #include "gsstruct.h"
27 #include "gstypes.h"
28 #include "ialloc.h"
29 #include "idict.h"
30 #include "store.h"
31 #include "stream.h"
32 #include "strimpl.h"
33 #include "ifilter.h"
34 #include "sjpx.h"
35 
36 
37 /* <source> /JPXDecode <file> */
38 /* <source> <dict> /JPXDecode <file> */
39 private int
z_jpx_decode(i_ctx_t * i_ctx_p)40 z_jpx_decode(i_ctx_t * i_ctx_p)
41 {
42     os_ptr op = osp;
43     ref *sop = NULL;
44     stream_jpxd_state state;
45 
46     state.jpx_memory = imemory->non_gc_memory;
47     if (r_has_type(op, t_dictionary)) {
48         check_dict_read(*op);
49         if ( dict_find_string(op, "Colorspace", &sop) > 0) {
50 	    dlprintf("found Colorspace parameter (NYI)\n");
51         }
52     }
53 
54     /* we pass npop=0, since we've no arguments left to consume */
55     /* we pass 0 instead of the usual rspace(sop) which will allocate storage
56        for filter state from the same memory pool as the stream it's coding.
57        this causes no trouble because we maintain no pointers */
58     return filter_read(i_ctx_p, 0, &s_jpxd_template,
59 		       (stream_state *) & state, 0);
60 }
61 
62 
63 /* match the above routine to the corresponding filter name
64    this is how our 'private' routines get called externally */
65 const op_def zfjpx_op_defs[] = {
66     op_def_begin_filter(),
67     {"2JPXDecode", z_jpx_decode},
68     op_def_end(0)
69 };
70