1 /* Copyright (C) 2001-2019 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, 8 modified or distributed except as expressly authorized under the terms 9 of the license contained in the file LICENSE in this distribution. 10 11 Refer to licensing information at http://www.artifex.com or contact 12 Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato, 13 CA 94945, U.S.A., +1(415)492-9861, for further information. 14 */ 15 16 17 /* Definitions for PNGPredictor filters */ 18 /* Requires strimpl.h */ 19 20 #ifndef spngpx_INCLUDED 21 # define spngpx_INCLUDED 22 23 #include "scommon.h" 24 25 /* 26 * Define the maximum value for Colors. The PNG specification probably 27 * defines this as 16, but some PS3 CET files require it to be as large as 28 * 53. The only cost of larger values is a larger stream state structure. 29 * In fact some CET files (09-34.ps) require 250 inks, so bump this to the 30 * current maximum of 256. 31 */ 32 #define s_PNG_max_Colors 256 33 34 /* PNGPredictorDecode / PNGPredictorEncode */ 35 typedef struct stream_PNGP_state_s { 36 stream_state_common; 37 /* The client sets the following before initialization. */ 38 int Colors; /* # of colors, 1..s_PNG_max_Colors */ 39 int BitsPerComponent; /* 1, 2, 4, 8, 16 */ 40 uint Columns; /* >0 */ 41 int Predictor; /* 10-15, only relevant for Encode */ 42 /* The init procedure computes the following. */ 43 uint row_count; /* # of bytes per row */ 44 byte end_mask; /* mask for left-over bits in last byte */ 45 int bpp; /* bytes per pixel */ 46 byte *prev_row; /* previous row */ 47 int case_index; /* switch index for case dispatch, */ 48 /* set dynamically when decoding */ 49 /* The following are updated dynamically. */ 50 long row_left; /* # of bytes left in row */ 51 byte prev[2 * s_PNG_max_Colors]; /* previous samples */ 52 } stream_PNGP_state; 53 54 #define private_st_PNGP_state() /* in sPNGP.c */\ 55 gs_private_st_ptrs1(st_PNGP_state, stream_PNGP_state,\ 56 "PNGPredictorEncode/Decode state", pngp_enum_ptrs, pngp_reloc_ptrs,\ 57 prev_row) 58 #define s_PNGP_set_defaults_inline(ss)\ 59 ((ss)->Colors = 1, (ss)->BitsPerComponent = 8, (ss)->Columns = 1,\ 60 (ss)->Predictor = 15,\ 61 /* Clear pointers */\ 62 (ss)->prev_row = 0) 63 extern const stream_template s_PNGPD_template; 64 extern const stream_template s_PNGPE_template; 65 66 #endif /* spngpx_INCLUDED */ 67