1 /* Copyright (C) 2001-2006 Artifex Software, Inc.
2    All Rights Reserved.
3 
4    This software is provided AS-IS with no warranty, either express or
5    implied.
6 
7    This software is distributed under license and may not be copied, modified
8    or distributed except as expressly authorized under the terms of that
9    license.  Refer to licensing information at http://www.artifex.com/
10    or contact Artifex Software, Inc.,  7 Mt. Lassen Drive - Suite A-134,
11    San Rafael, CA  94903, U.S.A., +1(415)492-9861, for further information.
12 */
13 
14 /* $Id: spngpx.h 8823 2008-07-07 08:56:59Z ken $ */
15 /* Definitions for PNGPredictor filters */
16 /* Requires strimpl.h */
17 
18 #ifndef spngpx_INCLUDED
19 #  define spngpx_INCLUDED
20 
21 /*
22  * Define the maximum value for Colors.  The PNG specification probably
23  * defines this as 16, but some PS3 CET files require it to be as large as
24  * 53.  The only cost of larger values is a larger stream state structure.
25  * In fact some CET files (09-34.ps) require 250 inks, so bump this to the
26  * current maximum of 256.
27  */
28 #define s_PNG_max_Colors 256
29 
30 /* PNGPredictorDecode / PNGPredictorEncode */
31 typedef struct stream_PNGP_state_s {
32     stream_state_common;
33     /* The client sets the following before initialization. */
34     int Colors;			/* # of colors, 1..s_PNG_max_Colors */
35     int BitsPerComponent;	/* 1, 2, 4, 8, 16 */
36     uint Columns;		/* >0 */
37     int Predictor;		/* 10-15, only relevant for Encode */
38     /* The init procedure computes the following. */
39     uint row_count;		/* # of bytes per row */
40     byte end_mask;		/* mask for left-over bits in last byte */
41     int bpp;			/* bytes per pixel */
42     byte *prev_row;		/* previous row */
43     int case_index;		/* switch index for case dispatch, */
44 				/* set dynamically when decoding */
45     /* The following are updated dynamically. */
46     long row_left;		/* # of bytes left in row */
47     byte prev[2 * s_PNG_max_Colors]; /* previous samples */
48 } stream_PNGP_state;
49 
50 #define private_st_PNGP_state()	/* in sPNGP.c */\
51   gs_private_st_ptrs1(st_PNGP_state, stream_PNGP_state,\
52     "PNGPredictorEncode/Decode state", pngp_enum_ptrs, pngp_reloc_ptrs,\
53     prev_row)
54 #define s_PNGP_set_defaults_inline(ss)\
55   ((ss)->Colors = 1, (ss)->BitsPerComponent = 8, (ss)->Columns = 1,\
56    (ss)->Predictor = 15,\
57 		/* Clear pointers */\
58    (ss)->prev_row = 0)
59 extern const stream_template s_PNGPD_template;
60 extern const stream_template s_PNGPE_template;
61 
62 #endif /* spngpx_INCLUDED */
63