/src/ghostpdl/jpegxr/flags.c
Line | Count | Source |
1 | | |
2 | | /************************************************************************* |
3 | | * |
4 | | * This software module was originally contributed by Microsoft |
5 | | * Corporation in the course of development of the |
6 | | * ITU-T T.832 | ISO/IEC 29199-2 ("JPEG XR") format standard for |
7 | | * reference purposes and its performance may not have been optimized. |
8 | | * |
9 | | * This software module is an implementation of one or more |
10 | | * tools as specified by the JPEG XR standard. |
11 | | * |
12 | | * ITU/ISO/IEC give You a royalty-free, worldwide, non-exclusive |
13 | | * copyright license to copy, distribute, and make derivative works |
14 | | * of this software module or modifications thereof for use in |
15 | | * products claiming conformance to the JPEG XR standard as |
16 | | * specified by ITU-T T.832 | ISO/IEC 29199-2. |
17 | | * |
18 | | * ITU/ISO/IEC give users the same free license to this software |
19 | | * module or modifications thereof for research purposes and further |
20 | | * ITU/ISO/IEC standardization. |
21 | | * |
22 | | * Those intending to use this software module in products are advised |
23 | | * that its use may infringe existing patents. ITU/ISO/IEC have no |
24 | | * liability for use of this software module or modifications thereof. |
25 | | * |
26 | | * Copyright is not released for products that do not conform to |
27 | | * to the JPEG XR standard as specified by ITU-T T.832 | |
28 | | * ISO/IEC 29199-2. |
29 | | * |
30 | | ******** Section to be removed when the standard is published ************ |
31 | | * |
32 | | * Assurance that the contributed software module can be used |
33 | | * (1) in the ITU-T "T.JXR" | ISO/IEC 29199 ("JPEG XR") standard once the |
34 | | * standard has been adopted; and |
35 | | * (2) to develop the JPEG XR standard: |
36 | | * |
37 | | * Microsoft Corporation and any subsequent contributors to the development |
38 | | * of this software grant ITU/ISO/IEC all rights necessary to include |
39 | | * the originally developed software module or modifications thereof in the |
40 | | * JPEG XR standard and to permit ITU/ISO/IEC to offer such a royalty-free, |
41 | | * worldwide, non-exclusive copyright license to copy, distribute, and make |
42 | | * derivative works of this software module or modifications thereof for |
43 | | * use in products claiming conformance to the JPEG XR standard as |
44 | | * specified by ITU-T T.832 | ISO/IEC 29199-2, and to the extent that |
45 | | * such originally developed software module or portions of it are included |
46 | | * in an ITU/ISO/IEC standard. To the extent that the original contributors |
47 | | * may own patent rights that would be required to make, use, or sell the |
48 | | * originally developed software module or portions thereof included in the |
49 | | * ITU/ISO/IEC standard in a conforming product, the contributors will |
50 | | * assure ITU/ISO/IEC that they are willing to negotiate licenses under |
51 | | * reasonable and non-discriminatory terms and conditions with |
52 | | * applicants throughout the world and in accordance with their patent |
53 | | * rights declarations made to ITU/ISO/IEC (if any). |
54 | | * |
55 | | * Microsoft, any subsequent contributors, and ITU/ISO/IEC additionally |
56 | | * gives You a free license to this software module or modifications |
57 | | * thereof for the sole purpose of developing the JPEG XR standard. |
58 | | * |
59 | | ******** end of section to be removed when the standard is published ***** |
60 | | * |
61 | | * Microsoft Corporation retains full right to modify and use the code |
62 | | * for its own purpose, to assign or donate the code to a third party, |
63 | | * and to inhibit third parties from using the code for products that |
64 | | * do not conform to the JPEG XR standard as specified by ITU-T T.832 | |
65 | | * ISO/IEC 29199-2. |
66 | | * |
67 | | * This copyright notice must be included in all copies or derivative |
68 | | * works. |
69 | | * |
70 | | * Copyright (c) ITU-T/ISO/IEC 2008, 2009. |
71 | | ***********************************************************************/ |
72 | | |
73 | | #ifdef _MSC_VER |
74 | | #pragma comment (user,"$Id: flags.c,v 1.10 2012-02-16 16:36:25 thor Exp $") |
75 | | #endif |
76 | | |
77 | | # include "jxr_priv.h" |
78 | | # include <assert.h> |
79 | | |
80 | | unsigned jxr_get_IMAGE_WIDTH(jxr_image_t image) |
81 | 0 | { |
82 | 0 | return image->width1 + 1; |
83 | 0 | } |
84 | | |
85 | | unsigned jxr_get_IMAGE_HEIGHT(jxr_image_t image) |
86 | 0 | { |
87 | 0 | return image->height1 + 1; |
88 | 0 | } |
89 | | |
90 | | unsigned jxr_get_EXTENDED_IMAGE_WIDTH(jxr_image_t image) |
91 | 0 | { |
92 | 0 | return image->extended_width; |
93 | 0 | } |
94 | | |
95 | | unsigned jxr_get_EXTENDED_IMAGE_HEIGHT(jxr_image_t image) |
96 | 0 | { |
97 | 0 | return image->extended_height; |
98 | 0 | } |
99 | | |
100 | | int jxr_get_TILING_FLAG(jxr_image_t image) |
101 | 0 | { |
102 | 0 | if (TILING_FLAG(image)) |
103 | 0 | return 1; |
104 | 0 | else |
105 | 0 | return 0; |
106 | 0 | } |
107 | | |
108 | | unsigned jxr_get_TILE_COLUMNS(jxr_image_t image) |
109 | 0 | { |
110 | 0 | return image->tile_columns + 1; |
111 | 0 | } |
112 | | |
113 | | unsigned jxr_get_TILE_ROWS(jxr_image_t image) |
114 | 0 | { |
115 | 0 | return image->tile_rows + 1; |
116 | 0 | } |
117 | | |
118 | | int jxr_get_TILE_WIDTH(jxr_image_t image, unsigned column) |
119 | 0 | { |
120 | 0 | if (column > image->tile_columns) { |
121 | 0 | return 0; |
122 | 0 | } else if (column == image->tile_columns) { |
123 | 0 | if (column == 0) |
124 | 0 | return EXTENDED_WIDTH_BLOCKS(image); |
125 | 0 | else |
126 | 0 | return EXTENDED_WIDTH_BLOCKS(image) - image->tile_column_position[column-1]; |
127 | 0 | } else { |
128 | 0 | return image->tile_column_width[column]; |
129 | 0 | } |
130 | 0 | } |
131 | | |
132 | | int jxr_get_TILE_HEIGHT(jxr_image_t image, unsigned row) |
133 | 0 | { |
134 | 0 | if (row > image->tile_rows) { |
135 | 0 | return 0; |
136 | 0 | } else if (row == image->tile_rows) { |
137 | 0 | if (row == 0) |
138 | 0 | return EXTENDED_HEIGHT_BLOCKS(image); |
139 | 0 | else |
140 | 0 | return EXTENDED_HEIGHT_BLOCKS(image) - image->tile_row_position[row-1]; |
141 | 0 | } else { |
142 | 0 | return image->tile_row_height[row]; |
143 | 0 | } |
144 | 0 | } |
145 | | |
146 | | int jxr_get_ALPHACHANNEL_FLAG(jxr_image_t image) |
147 | 0 | { |
148 | 0 | if (ALPHACHANNEL_FLAG(image)) |
149 | 0 | return 1; |
150 | 0 | else |
151 | 0 | return 0; |
152 | 0 | } |
153 | | |
154 | | void jxr_set_ALPHA_IMAGE_PLANE_FLAG(jxr_image_t image, int flag, int premultiplied) |
155 | 0 | { |
156 | 0 | assert(flag == 0 || flag == 1); |
157 | 0 | assert(premultiplied == 0 || premultiplied == 1); |
158 | |
|
159 | 0 | if (flag == 1) { |
160 | 0 | image->header_flags2 |= 0x01; |
161 | 0 | } else { |
162 | 0 | image->header_flags2 &= ~0x01; |
163 | 0 | } |
164 | 0 | if (premultiplied) { |
165 | 0 | image->header_flags2 |= 0x02; |
166 | 0 | } else { |
167 | 0 | image->header_flags2 &= ~0x02; |
168 | 0 | } |
169 | 0 | } |
170 | | |
171 | | int jxr_get_ALPHA_PREMULTIPLIED_FLAG(jxr_image_t image) |
172 | 0 | { |
173 | 0 | if (image->header_flags2 & 0x02) |
174 | 0 | return 1; |
175 | 0 | return 0; |
176 | 0 | } |
177 | | |
178 | | int jxr_get_ALPHA_PRESENCE_FLAG(jxr_image_t image) |
179 | 0 | { |
180 | 0 | if (image->header_flags2 & 0x01) |
181 | 0 | return 1; |
182 | 0 | return 0; |
183 | 0 | } |
184 | | |
185 | | /* |
186 | | * $Log: flags.c,v $ |
187 | | * Revision 1.10 2012-02-16 16:36:25 thor |
188 | | * Heavily reworked, but not yet tested. |
189 | | * |
190 | | * Revision 1.9 2011-04-28 08:45:42 thor |
191 | | * Fixed compiler warnings, ported to gcc 4.4, removed obsolete files. |
192 | | * |
193 | | * Revision 1.8 2011-03-04 12:12:12 thor |
194 | | * Bumped to 1.16. Fixed RGB-YOnly handling, including the handling of |
195 | | * YOnly for which a new -f flag has been added. |
196 | | * |
197 | | * Revision 1.7 2010-03-31 07:50:58 thor |
198 | | * Replaced by the latest MS version. |
199 | | * |
200 | | * |
201 | | * Revision 1.7 2009/05/29 12:00:00 microsoft |
202 | | * Reference Software v1.6 updates. |
203 | | * |
204 | | * Revision 1.6 2009/04/13 12:00:00 microsoft |
205 | | * Reference Software v1.5 updates. |
206 | | * |
207 | | * Revision 1.5 2008/03/06 02:05:48 steve |
208 | | * Distributed quantization |
209 | | * |
210 | | * Revision 1.4 2008/02/26 23:52:44 steve |
211 | | * Remove ident for MS compilers. |
212 | | * |
213 | | * Revision 1.3 2008/02/26 23:28:53 steve |
214 | | * Remove C99 requirements from the API. |
215 | | * |
216 | | * Revision 1.2 2007/11/26 01:47:15 steve |
217 | | * Add copyright notices per MS request. |
218 | | * |
219 | | * Revision 1.1 2007/06/06 17:19:12 steve |
220 | | * Introduce to CVS. |
221 | | * |
222 | | */ |
223 | | |