/src/ghostpdl/jpegxr/api.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 | | * Microsoft Corporation retains full right to modify and use the code |
31 | | * for its own purpose, to assign or donate the code to a third party, |
32 | | * and to inhibit third parties from using the code for products that |
33 | | * do not conform to the JPEG XR standard as specified by ITU-T T.832 | |
34 | | * ISO/IEC 29199-2. |
35 | | * |
36 | | * This copyright notice must be included in all copies or derivative |
37 | | * works. |
38 | | * |
39 | | * Copyright (c) ITU-T/ISO/IEC 2008, 2009. |
40 | | ***********************************************************************/ |
41 | | |
42 | | #ifdef _MSC_VER |
43 | | #pragma comment (user,"$Id: api.c,v 1.18 2008/03/21 18:05:53 steve Exp $") |
44 | | #else |
45 | | #ident "$Id: api.c,v 1.18 2008/03/21 18:05:53 steve Exp $" |
46 | | #endif |
47 | | |
48 | | # include "jxr_priv.h" |
49 | | # include <assert.h> |
50 | | # include <stdlib.h> |
51 | | |
52 | | void _jxr_send_mb_to_output(jxr_image_t image, int mx, int my, int*data) |
53 | 0 | { |
54 | 0 | if (image->out_fun) |
55 | 0 | image->out_fun(image, mx, my, data); |
56 | 0 | } |
57 | | |
58 | | void jxr_set_block_output(jxr_image_t image, block_fun_t fun) |
59 | 0 | { |
60 | 0 | image->out_fun = fun; |
61 | 0 | } |
62 | | |
63 | | void _jxr_get_mb_from_input(jxr_image_t image, int mx, int my, int*data) |
64 | 0 | { |
65 | 0 | if (image->inp_fun) |
66 | 0 | image->inp_fun(image, mx, my, data); |
67 | 0 | } |
68 | | |
69 | | void jxr_set_block_input(jxr_image_t image, block_fun_t fun) |
70 | 0 | { |
71 | 0 | image->inp_fun = fun; |
72 | 0 | } |
73 | | |
74 | | void jxr_set_user_data(jxr_image_t image, void*data) |
75 | 0 | { |
76 | 0 | image->user_data = data; |
77 | 0 | } |
78 | | |
79 | | void* jxr_get_user_data(jxr_image_t image) |
80 | 0 | { |
81 | 0 | return image->user_data; |
82 | 0 | } |
83 | | |
84 | | int jxr_get_IMAGE_CHANNELS(jxr_image_t image) |
85 | 0 | { |
86 | 0 | return image->num_channels; |
87 | 0 | } |
88 | | |
89 | | void jxr_set_INTERNAL_CLR_FMT(jxr_image_t image, jxr_color_fmt_t fmt, int channels) |
90 | 0 | { |
91 | 0 | switch (fmt) { |
92 | 0 | case JXR_YONLY: |
93 | 0 | image->use_clr_fmt = fmt; |
94 | 0 | image->num_channels = 1; |
95 | 0 | break; |
96 | 0 | case JXR_YUV420: |
97 | 0 | case JXR_YUV422: |
98 | 0 | case JXR_YUV444: |
99 | 0 | image->use_clr_fmt = fmt; |
100 | 0 | image->num_channels = 3; |
101 | 0 | break; |
102 | 0 | case JXR_YUVK: |
103 | 0 | image->use_clr_fmt = fmt; |
104 | 0 | image->num_channels = 4; |
105 | 0 | break; |
106 | 0 | case JXR_OCF_NCOMPONENT: |
107 | 0 | image->use_clr_fmt = fmt; |
108 | 0 | image->num_channels = channels; |
109 | 0 | break; |
110 | 0 | default: |
111 | 0 | image->use_clr_fmt = fmt; |
112 | 0 | image->num_channels = channels; |
113 | 0 | break; |
114 | 0 | } |
115 | 0 | } |
116 | | |
117 | | void jxr_set_OUTPUT_CLR_FMT(jxr_image_t image, jxr_output_clr_fmt_t fmt) |
118 | 0 | { |
119 | 0 | image->output_clr_fmt = fmt; |
120 | | |
121 | 0 | switch (fmt) { |
122 | 0 | case JXR_OCF_YONLY: /* YONLY */ |
123 | 0 | image->header_flags_fmt |= 0x00; /* OUTPUT_CLR_FMT==0 */ |
124 | 0 | break; |
125 | 0 | case JXR_OCF_YUV420: /* YUV420 */ |
126 | 0 | image->header_flags_fmt |= 0x10; /* OUTPUT_CLR_FMT==1 */ |
127 | 0 | break; |
128 | 0 | case JXR_OCF_YUV422: /* YUV422 */ |
129 | 0 | image->header_flags_fmt |= 0x20; /* OUTPUT_CLR_FMT==2 */ |
130 | 0 | break; |
131 | 0 | case JXR_OCF_YUV444: /* YUV444 */ |
132 | 0 | image->header_flags_fmt |= 0x30; /* OUTPUT_CLR_FMT==3 */ |
133 | 0 | break; |
134 | 0 | case JXR_OCF_CMYK: /* CMYK */ |
135 | 0 | image->header_flags_fmt |= 0x40; /* OUTPUT_CLR_FMT=4 (CMYK) */ |
136 | 0 | break; |
137 | 0 | case JXR_OCF_CMYKDIRECT: /* CMYKDIRECT */ |
138 | 0 | image->header_flags_fmt |= 0x50; /* OUTPUT_CLR_FMT=5 (CMYKDIRECT) */ |
139 | 0 | break; |
140 | 0 | case JXR_OCF_RGB: /* RGB color */ |
141 | 0 | image->header_flags_fmt |= 0x70; /* OUTPUT_CLR_FMT=7 (RGB) */ |
142 | 0 | break; |
143 | 0 | case JXR_OCF_RGBE: /* RGBE color */ |
144 | 0 | image->header_flags_fmt |= 0x80; /* OUTPUT_CLR_FMT=8 (RGBE) */ |
145 | 0 | break; |
146 | 0 | case JXR_OCF_NCOMPONENT: /* N-channel color */ |
147 | 0 | image->header_flags_fmt |= 0x60; /* OUTPUT_CLR_FMT=6 (NCOMPONENT) */ |
148 | 0 | break; |
149 | 0 | default: |
150 | 0 | fprintf(stderr, "Unsupported external color format (%d)! \n", fmt); |
151 | 0 | break; |
152 | 0 | } |
153 | 0 | } |
154 | | |
155 | | jxr_output_clr_fmt_t jxr_get_OUTPUT_CLR_FMT(jxr_image_t image) |
156 | 0 | { |
157 | 0 | return image->output_clr_fmt; |
158 | 0 | } |
159 | | |
160 | | |
161 | | jxr_bitdepth_t jxr_get_OUTPUT_BITDEPTH(jxr_image_t image) |
162 | 0 | { |
163 | 0 | return (jxr_bitdepth_t) SOURCE_BITDEPTH(image); |
164 | 0 | } |
165 | | |
166 | | void jxr_set_OUTPUT_BITDEPTH(jxr_image_t image, jxr_bitdepth_t bd) |
167 | 0 | { |
168 | 0 | image->header_flags_fmt &= ~0x0f; |
169 | 0 | image->header_flags_fmt |= bd; |
170 | 0 | } |
171 | | |
172 | | void jxr_set_BANDS_PRESENT(jxr_image_t image, jxr_bands_present_t bp) |
173 | 0 | { |
174 | 0 | image->bands_present = bp; |
175 | 0 | image->bands_present_of_primary = image->bands_present; |
176 | 0 | } |
177 | | |
178 | | void jxr_set_FREQUENCY_MODE_CODESTREAM_FLAG(jxr_image_t image, int flag) |
179 | 0 | { |
180 | 0 | assert(flag >= 0 && flag <= 1); |
181 | 0 | image->header_flags1 &= ~0x40; |
182 | 0 | image->header_flags1 |= (flag << 6); |
183 | | |
184 | | /* Enable INDEX_TABLE_PRESENT_FLAG */ |
185 | 0 | if (flag) { |
186 | 0 | jxr_set_INDEX_TABLE_PRESENT_FLAG(image, 1); |
187 | 0 | } |
188 | 0 | } |
189 | | |
190 | | void jxr_set_INDEX_TABLE_PRESENT_FLAG(jxr_image_t image, int flag) |
191 | 0 | { |
192 | 0 | assert(flag >= 0 && flag <= 1); |
193 | 0 | image->header_flags1 &= ~0x04; |
194 | 0 | image->header_flags1 |= (flag << 2); |
195 | 0 | } |
196 | | |
197 | | void jxr_set_ALPHA_IMAGE_PLANE_FLAG(jxr_image_t image, int flag) |
198 | 0 | { |
199 | 0 | assert(flag == 0 || flag == 1); |
200 | 0 | if(flag == 1) |
201 | 0 | image->header_flags2 |= 0x01; |
202 | 0 | else |
203 | 0 | image->header_flags2 &= 0xfe; |
204 | 0 | } |
205 | | |
206 | | void jxr_set_PROFILE_IDC(jxr_image_t image, int profile_idc) |
207 | 0 | { |
208 | 0 | assert(profile_idc >= 0 && profile_idc <= 255); |
209 | 0 | image->profile_idc = (uint8_t) profile_idc; |
210 | 0 | } |
211 | | |
212 | | void jxr_set_LEVEL_IDC(jxr_image_t image, int level_idc) |
213 | 0 | { |
214 | 0 | assert(level_idc >= 0 && level_idc <= 255); |
215 | 0 | image->level_idc = (uint8_t) level_idc; |
216 | 0 | } |
217 | | |
218 | | void jxr_set_LONG_WORD_FLAG(jxr_image_t image, int flag) |
219 | 0 | { |
220 | 0 | assert(flag >= 0 && flag <= 1); |
221 | 0 | image->header_flags2 &= ~0x40; |
222 | 0 | image->header_flags2 |= (flag << 6); |
223 | 0 | } |
224 | | |
225 | | int jxr_test_PROFILE_IDC(jxr_image_t image, int flag) |
226 | 0 | { |
227 | | /* |
228 | | ** flag = 0 - encoder |
229 | | ** flag = 1 - decoder |
230 | | */ |
231 | 0 | jxr_bitdepth_t obd = jxr_get_OUTPUT_BITDEPTH(image); |
232 | 0 | jxr_output_clr_fmt_t ocf = jxr_get_OUTPUT_CLR_FMT(image); |
233 | |
|
234 | 0 | unsigned char profile = image->profile_idc; |
235 | | /* |
236 | | * For forward compatability |
237 | | * Though only specified profiles are currently applicable, decoder shouldn't reject other profiles. |
238 | | */ |
239 | 0 | if (flag) { |
240 | 0 | if (profile <= 44) |
241 | 0 | profile = 44; |
242 | 0 | else if (profile <= 55) |
243 | 0 | profile = 55; |
244 | 0 | else if (profile <= 66) |
245 | 0 | profile = 66; |
246 | 0 | else if (profile <= 111) |
247 | 0 | profile = 111; |
248 | 0 | } |
249 | |
|
250 | 0 | switch (profile) { |
251 | 0 | case 44: |
252 | 0 | if (OVERLAP_INFO(image) == 2) |
253 | 0 | return JXR_EC_BADFORMAT; |
254 | 0 | if (LONG_WORD_FLAG(image)) |
255 | 0 | return JXR_EC_BADFORMAT; |
256 | 0 | if (image->num_channels != 1 && image->num_channels != 3) |
257 | 0 | return JXR_EC_BADFORMAT; |
258 | 0 | if (image->alpha) |
259 | 0 | return JXR_EC_BADFORMAT; |
260 | 0 | if ((obd == JXR_BD16) || (obd == JXR_BD16S) || (obd == JXR_BD16F) || (obd == JXR_BD32S) || (obd == JXR_BD32F)) |
261 | 0 | return JXR_EC_BADFORMAT; |
262 | 0 | if ((ocf != JXR_OCF_RGB) && (ocf != JXR_OCF_YONLY)) |
263 | 0 | return JXR_EC_BADFORMAT; |
264 | 0 | break; |
265 | 0 | case 55: |
266 | 0 | if (image->num_channels != 1 && image->num_channels != 3) |
267 | 0 | return JXR_EC_BADFORMAT; |
268 | 0 | if (image->alpha) |
269 | 0 | return JXR_EC_BADFORMAT; |
270 | 0 | if ((obd == JXR_BD16F) || (obd == JXR_BD32S) || (obd == JXR_BD32F)) |
271 | 0 | return JXR_EC_BADFORMAT; |
272 | 0 | if ((ocf != JXR_OCF_RGB) && (ocf != JXR_OCF_YONLY)) |
273 | 0 | return JXR_EC_BADFORMAT; |
274 | 0 | break; |
275 | 0 | case 66: |
276 | 0 | if ((ocf == JXR_OCF_CMYKDIRECT) || (ocf == JXR_OCF_YUV420) || (ocf == JXR_OCF_YUV422) || (ocf == JXR_OCF_YUV444)) |
277 | 0 | return JXR_EC_BADFORMAT; |
278 | 0 | break; |
279 | 0 | case 111: |
280 | 0 | break; |
281 | 0 | default: |
282 | 0 | return JXR_EC_BADFORMAT; |
283 | 0 | break; |
284 | 0 | } |
285 | | |
286 | 0 | return JXR_EC_OK; |
287 | 0 | } |
288 | | |
289 | | int jxr_test_LEVEL_IDC(jxr_image_t image, int flag) |
290 | 0 | { |
291 | | /* |
292 | | ** flag = 0 - encoder |
293 | | ** flag = 1 - decoder |
294 | | */ |
295 | 0 | unsigned tr = image->tile_rows - 1; |
296 | 0 | unsigned tc = image->tile_columns - 1; |
297 | 0 | uint64_t h = (uint64_t) image->extended_height - 1; |
298 | 0 | uint64_t w = (uint64_t) image->extended_width - 1; |
299 | 0 | uint64_t n = (uint64_t) image->num_channels; |
300 | 0 | uint64_t buf_size = 1; |
301 | |
|
302 | 0 | unsigned i; |
303 | 0 | uint64_t max_tile_width = 0, max_tile_height = 0; |
304 | 0 | unsigned char level; |
305 | 0 | for (i = 0; i < image->tile_columns; i++) |
306 | 0 | max_tile_width = (uint64_t) (image->tile_column_width[i] > max_tile_width ? image->tile_column_width[i] : max_tile_width); |
307 | 0 | for (i = 0; i < image->tile_rows; i++) |
308 | 0 | max_tile_height = (uint64_t) (image->tile_row_height[i] > max_tile_height ? image->tile_row_height[i] : max_tile_height); |
309 | |
|
310 | 0 | if (image->alpha) |
311 | 0 | n += 1; |
312 | |
|
313 | 0 | switch (SOURCE_BITDEPTH(image)) { |
314 | 0 | case 1: /* BD8 */ |
315 | 0 | buf_size = n * (h + 1) * (w + 1); |
316 | 0 | break; |
317 | 0 | case 2: /* BD16 */ |
318 | 0 | case 3: /* BD16S */ |
319 | 0 | case 4: /* BD16F */ |
320 | 0 | buf_size = 2 * n * (h + 1) * (w + 1); |
321 | 0 | break; |
322 | 0 | case 6: /* BD32S */ |
323 | 0 | case 7: /* BD32F */ |
324 | 0 | buf_size = 4 * n * (h + 1) * (w + 1); |
325 | 0 | break; |
326 | 0 | case 0: /* BD1WHITE1 */ |
327 | 0 | case 15: /* BD1BLACK1 */ |
328 | 0 | buf_size = ((h + 8) >> 3) * ((w + 8) >> 3) * 8; |
329 | 0 | break; |
330 | 0 | case 8: /* BD5 */ |
331 | 0 | case 10: /* BD565 */ |
332 | 0 | buf_size = 2 * (h + 1) * (w + 1); |
333 | 0 | break; |
334 | 0 | case 9: /* BD10 */ |
335 | 0 | if (image->output_clr_fmt == JXR_OCF_RGB) |
336 | 0 | buf_size = 4 * (h + 1) * (w + 1); |
337 | 0 | else |
338 | 0 | buf_size = 2 * n * (h + 1) * (w + 1); |
339 | 0 | break; |
340 | 0 | default: /* RESERVED */ |
341 | 0 | return JXR_EC_BADFORMAT; |
342 | 0 | break; |
343 | 0 | } |
344 | | |
345 | 0 | level = image->level_idc; |
346 | | /* |
347 | | * For forward compatability |
348 | | * Though only specified levels are currently applicable, decoder shouldn't reject other levels. |
349 | | */ |
350 | 0 | if (flag) { |
351 | 0 | if (level >= 255) |
352 | 0 | level = 255; |
353 | 0 | else if (level >= 128) |
354 | 0 | level = 128; |
355 | 0 | else if (level >= 64) |
356 | 0 | level = 64; |
357 | 0 | else if (level >= 32) |
358 | 0 | level = 32; |
359 | 0 | else if (level >= 16) |
360 | 0 | level = 16; |
361 | 0 | else if (level >= 8) |
362 | 0 | level = 8; |
363 | 0 | else if (level >= 4) |
364 | 0 | level = 4; |
365 | 0 | } |
366 | |
|
367 | 0 | switch (level) { |
368 | 0 | case 4: |
369 | 0 | if ((w >> 10) || (h >> 10) || (tc >> 4) || (tr >> 4) || (max_tile_width >> 10) || (max_tile_height >> 10) || (buf_size >> 22)) |
370 | 0 | return JXR_EC_BADFORMAT; |
371 | 0 | break; |
372 | 0 | case 8: |
373 | 0 | if ((w >> 11) || (h >> 11) || (tc >> 5) || (tr >> 5) || (max_tile_width >> 11) || (max_tile_height >> 11) || (buf_size >> 24)) |
374 | 0 | return JXR_EC_BADFORMAT; |
375 | 0 | break; |
376 | 0 | case 16: |
377 | 0 | if ((w >> 12) || (h >> 12) || (tc >> 6) || (tr >> 6) || (max_tile_width >> 12) || (max_tile_height >> 12) || (buf_size >> 26)) |
378 | 0 | return JXR_EC_BADFORMAT; |
379 | 0 | break; |
380 | 0 | case 32: |
381 | 0 | if ((w >> 13) || (h >> 13) || (tc >> 7) || (tr >> 7) || (max_tile_width >> 12) || (max_tile_height >> 12) || (buf_size >> 28)) |
382 | 0 | return JXR_EC_BADFORMAT; |
383 | 0 | break; |
384 | 0 | case 64: |
385 | 0 | if ((w >> 14) || (h >> 14) || (tc >> 8) || (tr >> 8) || (max_tile_width >> 12) || (max_tile_height >> 12) || (buf_size >> 30)) |
386 | 0 | return JXR_EC_BADFORMAT; |
387 | 0 | break; |
388 | 0 | case 128: |
389 | 0 | if ((w >> 16) || (h >> 16) || (tc >> 10) || (tr >> 10) || (max_tile_width >> 12) || (max_tile_height >> 12) || (buf_size >> 32)) |
390 | 0 | return JXR_EC_BADFORMAT; |
391 | 0 | break; |
392 | 0 | case 255: /* width and height restriction is 2^32 */ |
393 | 0 | if ((w >> 32) || (h >> 32) || (tc >> 12) || (tr >> 12) || (max_tile_width >> 32) || (max_tile_height >> 32)) |
394 | 0 | return JXR_EC_BADFORMAT; |
395 | 0 | break; |
396 | 0 | default: |
397 | 0 | return JXR_EC_BADFORMAT; |
398 | 0 | break; |
399 | 0 | } |
400 | | |
401 | 0 | return JXR_EC_OK; |
402 | 0 | } |
403 | | |
404 | 0 | void jxr_set_container_parameters(jxr_image_t image, jxrc_t_pixelFormat pixel_format, unsigned wid, unsigned hei, unsigned separate, unsigned char image_presence, unsigned char alpha_presence, unsigned char alpha) { |
405 | 0 | image->container_width = wid; |
406 | 0 | image->container_height = hei; |
407 | 0 | image->container_separate_alpha = separate ? 1 : 0; |
408 | 0 | image->container_image_band_presence = image_presence; |
409 | 0 | image->container_alpha_band_presence = alpha_presence; |
410 | 0 | image->container_current_separate_alpha = alpha ? 1 : 0; |
411 | |
|
412 | 0 | switch (pixel_format) { |
413 | 0 | case JXRC_FMT_24bppRGB: |
414 | 0 | case JXRC_FMT_24bppBGR: |
415 | 0 | case JXRC_FMT_32bppBGR: |
416 | 0 | image->container_alpha = 0; |
417 | 0 | image->container_bpc = JXR_BD8; |
418 | 0 | image->container_color = JXR_OCF_RGB; |
419 | 0 | image->container_nc = 3; |
420 | 0 | break; |
421 | 0 | case JXRC_FMT_48bppRGB: |
422 | 0 | image->container_alpha = 0; |
423 | 0 | image->container_bpc = JXR_BD16; |
424 | 0 | image->container_color = JXR_OCF_RGB; |
425 | 0 | image->container_nc = 3; |
426 | 0 | break; |
427 | 0 | case JXRC_FMT_48bppRGBFixedPoint: |
428 | 0 | image->container_alpha = 0; |
429 | 0 | image->container_bpc = JXR_BD16S; |
430 | 0 | image->container_color = JXR_OCF_RGB; |
431 | 0 | image->container_nc = 3; |
432 | 0 | break; |
433 | 0 | case JXRC_FMT_48bppRGBHalf: |
434 | 0 | image->container_alpha = 0; |
435 | 0 | image->container_bpc = JXR_BD16F; |
436 | 0 | image->container_color = JXR_OCF_RGB; |
437 | 0 | image->container_nc = 3; |
438 | 0 | break; |
439 | 0 | case JXRC_FMT_96bppRGBFixedPoint: |
440 | 0 | image->container_alpha = 0; |
441 | 0 | image->container_bpc = JXR_BD32S; |
442 | 0 | image->container_color = JXR_OCF_RGB; |
443 | 0 | image->container_nc = 3; |
444 | 0 | break; |
445 | 0 | case JXRC_FMT_64bppRGBFixedPoint: |
446 | 0 | image->container_alpha = 0; |
447 | 0 | image->container_bpc = JXR_BD16S; |
448 | 0 | image->container_color = JXR_OCF_RGB; |
449 | 0 | image->container_nc = 3; |
450 | 0 | break; |
451 | 0 | case JXRC_FMT_64bppRGBHalf: |
452 | 0 | image->container_alpha = 0; |
453 | 0 | image->container_bpc = JXR_BD16F; |
454 | 0 | image->container_color = JXR_OCF_RGB; |
455 | 0 | image->container_nc = 3; |
456 | 0 | break; |
457 | 0 | case JXRC_FMT_128bppRGBFixedPoint: |
458 | 0 | image->container_alpha = 0; |
459 | 0 | image->container_bpc = JXR_BD32S; |
460 | 0 | image->container_color = JXR_OCF_RGB; |
461 | 0 | image->container_nc = 3; |
462 | 0 | break; |
463 | 0 | case JXRC_FMT_128bppRGBFloat: |
464 | 0 | image->container_alpha = 0; |
465 | 0 | image->container_bpc = JXR_BD32F; |
466 | 0 | image->container_color = JXR_OCF_RGB; |
467 | 0 | image->container_nc = 3; |
468 | 0 | break; |
469 | 0 | case JXRC_FMT_32bppBGRA: |
470 | 0 | image->container_alpha = 1; |
471 | 0 | image->container_bpc = JXR_BD8; |
472 | 0 | image->container_color = JXR_OCF_RGB; |
473 | 0 | image->container_nc = 4; |
474 | 0 | break; |
475 | 0 | case JXRC_FMT_64bppRGBA: |
476 | 0 | image->container_alpha = 1; |
477 | 0 | image->container_bpc = JXR_BD16; |
478 | 0 | image->container_color = JXR_OCF_RGB; |
479 | 0 | image->container_nc = 4; |
480 | 0 | break; |
481 | 0 | case JXRC_FMT_64bppRGBAFixedPoint: |
482 | 0 | image->container_alpha = 1; |
483 | 0 | image->container_bpc = JXR_BD16S; |
484 | 0 | image->container_color = JXR_OCF_RGB; |
485 | 0 | image->container_nc = 4; |
486 | 0 | break; |
487 | 0 | case JXRC_FMT_64bppRGBAHalf: |
488 | 0 | image->container_alpha = 1; |
489 | 0 | image->container_bpc = JXR_BD16F; |
490 | 0 | image->container_color = JXR_OCF_RGB; |
491 | 0 | image->container_nc = 4; |
492 | 0 | break; |
493 | 0 | case JXRC_FMT_128bppRGBAFixedPoint: |
494 | 0 | image->container_alpha = 1; |
495 | 0 | image->container_bpc = JXR_BD32S; |
496 | 0 | image->container_color = JXR_OCF_RGB; |
497 | 0 | image->container_nc = 4; |
498 | 0 | break; |
499 | 0 | case JXRC_FMT_128bppRGBAFloat: |
500 | 0 | image->container_alpha = 1; |
501 | 0 | image->container_bpc = JXR_BD32F; |
502 | 0 | image->container_color = JXR_OCF_RGB; |
503 | 0 | image->container_nc = 4; |
504 | 0 | break; |
505 | 0 | case JXRC_FMT_32bppPBGRA: |
506 | 0 | image->container_alpha = 1; |
507 | 0 | image->container_bpc = JXR_BD8; |
508 | 0 | image->container_color = JXR_OCF_RGB; |
509 | 0 | image->container_nc = 4; |
510 | 0 | break; |
511 | 0 | case JXRC_FMT_64bppPRGBA: |
512 | 0 | image->container_alpha = 1; |
513 | 0 | image->container_bpc = JXR_BD16; |
514 | 0 | image->container_color = JXR_OCF_RGB; |
515 | 0 | image->container_nc = 4; |
516 | 0 | break; |
517 | 0 | case JXRC_FMT_128bppPRGBAFloat: |
518 | 0 | image->container_alpha = 1; |
519 | 0 | image->container_bpc = JXR_BD32F; |
520 | 0 | image->container_color = JXR_OCF_RGB; |
521 | 0 | image->container_nc = 4; |
522 | 0 | break; |
523 | 0 | case JXRC_FMT_32bppCMYK: |
524 | 0 | image->container_alpha = 0; |
525 | 0 | image->container_bpc = JXR_BD8; |
526 | 0 | image->container_color = JXR_OCF_CMYK; |
527 | 0 | image->container_nc = 4; |
528 | 0 | break; |
529 | 0 | case JXRC_FMT_40bppCMYKAlpha: |
530 | 0 | image->container_alpha = 1; |
531 | 0 | image->container_bpc = JXR_BD8; |
532 | 0 | image->container_color = JXR_OCF_CMYK; |
533 | 0 | image->container_nc = 5; |
534 | 0 | break; |
535 | 0 | case JXRC_FMT_64bppCMYK: |
536 | 0 | image->container_alpha = 0; |
537 | 0 | image->container_bpc = JXR_BD16; |
538 | 0 | image->container_color = JXR_OCF_CMYK; |
539 | 0 | image->container_nc = 4; |
540 | 0 | break; |
541 | 0 | case JXRC_FMT_80bppCMYKAlpha: |
542 | 0 | image->container_alpha = 1; |
543 | 0 | image->container_bpc = JXR_BD16; |
544 | 0 | image->container_color = JXR_OCF_CMYK; |
545 | 0 | image->container_nc = 5; |
546 | 0 | break; |
547 | 0 | case JXRC_FMT_24bpp3Channels: |
548 | 0 | image->container_alpha = 0; |
549 | 0 | image->container_bpc = JXR_BD8; |
550 | 0 | image->container_color = JXR_OCF_NCOMPONENT; |
551 | 0 | image->container_nc = 3; |
552 | 0 | break; |
553 | 0 | case JXRC_FMT_32bpp4Channels: |
554 | 0 | image->container_alpha = 0; |
555 | 0 | image->container_bpc = JXR_BD8; |
556 | 0 | image->container_color = JXR_OCF_NCOMPONENT; |
557 | 0 | image->container_nc = 4; |
558 | 0 | break; |
559 | 0 | case JXRC_FMT_40bpp5Channels: |
560 | 0 | image->container_alpha = 0; |
561 | 0 | image->container_bpc = JXR_BD8; |
562 | 0 | image->container_color = JXR_OCF_NCOMPONENT; |
563 | 0 | image->container_nc = 5; |
564 | 0 | break; |
565 | 0 | case JXRC_FMT_48bpp6Channels: |
566 | 0 | image->container_alpha = 0; |
567 | 0 | image->container_bpc = JXR_BD8; |
568 | 0 | image->container_color = JXR_OCF_NCOMPONENT; |
569 | 0 | image->container_nc = 6; |
570 | 0 | break; |
571 | 0 | case JXRC_FMT_56bpp7Channels: |
572 | 0 | image->container_alpha = 0; |
573 | 0 | image->container_bpc = JXR_BD8; |
574 | 0 | image->container_color = JXR_OCF_NCOMPONENT; |
575 | 0 | image->container_nc = 7; |
576 | 0 | break; |
577 | 0 | case JXRC_FMT_64bpp8Channels: |
578 | 0 | image->container_alpha = 0; |
579 | 0 | image->container_bpc = JXR_BD8; |
580 | 0 | image->container_color = JXR_OCF_NCOMPONENT; |
581 | 0 | image->container_nc = 8; |
582 | 0 | break; |
583 | 0 | case JXRC_FMT_32bpp3ChannelsAlpha: |
584 | 0 | image->container_alpha = 1; |
585 | 0 | image->container_bpc = JXR_BD8; |
586 | 0 | image->container_color = JXR_OCF_NCOMPONENT; |
587 | 0 | image->container_nc = 4; |
588 | 0 | break; |
589 | 0 | case JXRC_FMT_40bpp4ChannelsAlpha: |
590 | 0 | image->container_alpha = 1; |
591 | 0 | image->container_bpc = JXR_BD8; |
592 | 0 | image->container_color = JXR_OCF_NCOMPONENT; |
593 | 0 | image->container_nc = 5; |
594 | 0 | break; |
595 | 0 | case JXRC_FMT_48bpp5ChannelsAlpha: |
596 | 0 | image->container_alpha = 1; |
597 | 0 | image->container_bpc = JXR_BD8; |
598 | 0 | image->container_color = JXR_OCF_NCOMPONENT; |
599 | 0 | image->container_nc = 6; |
600 | 0 | break; |
601 | 0 | case JXRC_FMT_56bpp6ChannelsAlpha: |
602 | 0 | image->container_alpha = 1; |
603 | 0 | image->container_bpc = JXR_BD8; |
604 | 0 | image->container_color = JXR_OCF_NCOMPONENT; |
605 | 0 | image->container_nc = 7; |
606 | 0 | break; |
607 | 0 | case JXRC_FMT_64bpp7ChannelsAlpha: |
608 | 0 | image->container_alpha = 1; |
609 | 0 | image->container_bpc = JXR_BD8; |
610 | 0 | image->container_color = JXR_OCF_NCOMPONENT; |
611 | 0 | image->container_nc = 8; |
612 | 0 | break; |
613 | 0 | case JXRC_FMT_72bpp8ChannelsAlpha: |
614 | 0 | image->container_alpha = 1; |
615 | 0 | image->container_bpc = JXR_BD8; |
616 | 0 | image->container_color = JXR_OCF_NCOMPONENT; |
617 | 0 | image->container_nc = 9; |
618 | 0 | break; |
619 | 0 | case JXRC_FMT_48bpp3Channels: |
620 | 0 | image->container_alpha = 0; |
621 | 0 | image->container_bpc = JXR_BD16; |
622 | 0 | image->container_color = JXR_OCF_NCOMPONENT; |
623 | 0 | image->container_nc = 3; |
624 | 0 | break; |
625 | 0 | case JXRC_FMT_64bpp4Channels: |
626 | 0 | image->container_alpha = 0; |
627 | 0 | image->container_bpc = JXR_BD16; |
628 | 0 | image->container_color = JXR_OCF_NCOMPONENT; |
629 | 0 | image->container_nc = 4; |
630 | 0 | break; |
631 | 0 | case JXRC_FMT_80bpp5Channels: |
632 | 0 | image->container_alpha = 0; |
633 | 0 | image->container_bpc = JXR_BD16; |
634 | 0 | image->container_color = JXR_OCF_NCOMPONENT; |
635 | 0 | image->container_nc = 5; |
636 | 0 | break; |
637 | 0 | case JXRC_FMT_96bpp6Channels: |
638 | 0 | image->container_alpha = 0; |
639 | 0 | image->container_bpc = JXR_BD16; |
640 | 0 | image->container_color = JXR_OCF_NCOMPONENT; |
641 | 0 | image->container_nc = 6; |
642 | 0 | break; |
643 | 0 | case JXRC_FMT_112bpp7Channels: |
644 | 0 | image->container_alpha = 0; |
645 | 0 | image->container_bpc = JXR_BD16; |
646 | 0 | image->container_color = JXR_OCF_NCOMPONENT; |
647 | 0 | image->container_nc = 7; |
648 | 0 | break; |
649 | 0 | case JXRC_FMT_128bpp8Channels: |
650 | 0 | image->container_alpha = 0; |
651 | 0 | image->container_bpc = JXR_BD16; |
652 | 0 | image->container_color = JXR_OCF_NCOMPONENT; |
653 | 0 | image->container_nc = 8; |
654 | 0 | break; |
655 | 0 | case JXRC_FMT_64bpp3ChannelsAlpha: |
656 | 0 | image->container_alpha = 1; |
657 | 0 | image->container_bpc = JXR_BD16; |
658 | 0 | image->container_color = JXR_OCF_NCOMPONENT; |
659 | 0 | image->container_nc = 4; |
660 | 0 | break; |
661 | 0 | case JXRC_FMT_80bpp4ChannelsAlpha: |
662 | 0 | image->container_alpha = 1; |
663 | 0 | image->container_bpc = JXR_BD16; |
664 | 0 | image->container_color = JXR_OCF_NCOMPONENT; |
665 | 0 | image->container_nc = 5; |
666 | 0 | break; |
667 | 0 | case JXRC_FMT_96bpp5ChannelsAlpha: |
668 | 0 | image->container_alpha = 1; |
669 | 0 | image->container_bpc = JXR_BD16; |
670 | 0 | image->container_color = JXR_OCF_NCOMPONENT; |
671 | 0 | image->container_nc = 6; |
672 | 0 | break; |
673 | 0 | case JXRC_FMT_112bpp6ChannelsAlpha: |
674 | 0 | image->container_alpha = 1; |
675 | 0 | image->container_bpc = JXR_BD16; |
676 | 0 | image->container_color = JXR_OCF_NCOMPONENT; |
677 | 0 | image->container_nc = 7; |
678 | 0 | break; |
679 | 0 | case JXRC_FMT_128bpp7ChannelsAlpha: |
680 | 0 | image->container_alpha = 1; |
681 | 0 | image->container_bpc = JXR_BD16; |
682 | 0 | image->container_color = JXR_OCF_NCOMPONENT; |
683 | 0 | image->container_nc = 8; |
684 | 0 | break; |
685 | 0 | case JXRC_FMT_144bpp8ChannelsAlpha: |
686 | 0 | image->container_alpha = 1; |
687 | 0 | image->container_bpc = JXR_BD16; |
688 | 0 | image->container_color = JXR_OCF_NCOMPONENT; |
689 | 0 | image->container_nc = 9; |
690 | 0 | break; |
691 | 0 | case JXRC_FMT_8bppGray: |
692 | 0 | image->container_alpha = 0; |
693 | 0 | image->container_bpc = JXR_BD8; |
694 | 0 | image->container_color = JXR_OCF_YONLY; |
695 | 0 | image->container_nc = 1; |
696 | 0 | break; |
697 | 0 | case JXRC_FMT_16bppGray: |
698 | 0 | image->container_alpha = 0; |
699 | 0 | image->container_bpc = JXR_BD16; |
700 | 0 | image->container_color = JXR_OCF_YONLY; |
701 | 0 | image->container_nc = 1; |
702 | 0 | break; |
703 | 0 | case JXRC_FMT_16bppGrayFixedPoint: |
704 | 0 | image->container_alpha = 0; |
705 | 0 | image->container_bpc = JXR_BD16S; |
706 | 0 | image->container_color = JXR_OCF_YONLY; |
707 | 0 | image->container_nc = 1; |
708 | 0 | break; |
709 | 0 | case JXRC_FMT_16bppGrayHalf: |
710 | 0 | image->container_alpha = 0; |
711 | 0 | image->container_bpc = JXR_BD16F; |
712 | 0 | image->container_color = JXR_OCF_YONLY; |
713 | 0 | image->container_nc = 1; |
714 | 0 | break; |
715 | 0 | case JXRC_FMT_32bppGrayFixedPoint: |
716 | 0 | image->container_alpha = 0; |
717 | 0 | image->container_bpc = JXR_BD32S; |
718 | 0 | image->container_color = JXR_OCF_YONLY; |
719 | 0 | image->container_nc = 1; |
720 | 0 | break; |
721 | 0 | case JXRC_FMT_32bppGrayFloat: |
722 | 0 | image->container_alpha = 0; |
723 | 0 | image->container_bpc = JXR_BD32F; |
724 | 0 | image->container_color = JXR_OCF_YONLY; |
725 | 0 | image->container_nc = 1; |
726 | 0 | break; |
727 | 0 | case JXRC_FMT_BlackWhite: |
728 | 0 | image->container_alpha = 0; |
729 | 0 | image->container_bpc = JXR_BD1WHITE1; /* or JXR_BD1BLACK1 */ |
730 | 0 | image->container_color = JXR_OCF_YONLY; |
731 | 0 | image->container_nc = 1; |
732 | 0 | break; |
733 | 0 | case JXRC_FMT_16bppBGR555: |
734 | 0 | image->container_alpha = 0; |
735 | 0 | image->container_bpc = JXR_BD5; |
736 | 0 | image->container_color = JXR_OCF_RGB; |
737 | 0 | image->container_nc = 3; |
738 | 0 | break; |
739 | 0 | case JXRC_FMT_16bppBGR565: |
740 | 0 | image->container_alpha = 0; |
741 | 0 | image->container_bpc = JXR_BD565; |
742 | 0 | image->container_color = JXR_OCF_RGB; |
743 | 0 | image->container_nc = 3; |
744 | 0 | break; |
745 | 0 | case JXRC_FMT_32bppBGR101010: |
746 | 0 | image->container_alpha = 0; |
747 | 0 | image->container_bpc = JXR_BD10; |
748 | 0 | image->container_color = JXR_OCF_RGB; |
749 | 0 | image->container_nc = 3; |
750 | 0 | break; |
751 | 0 | case JXRC_FMT_32bppRGBE: |
752 | 0 | image->container_alpha = 0; |
753 | 0 | image->container_bpc = JXR_BD8; |
754 | 0 | image->container_color = JXR_OCF_RGBE; |
755 | 0 | image->container_nc = 3; |
756 | 0 | break; |
757 | 0 | case JXRC_FMT_32bppCMYKDIRECT: |
758 | 0 | image->container_alpha = 0; |
759 | 0 | image->container_bpc = JXR_BD8; |
760 | 0 | image->container_color = JXR_OCF_CMYKDIRECT; |
761 | 0 | image->container_nc = 4; |
762 | 0 | break; |
763 | 0 | case JXRC_FMT_64bppCMYKDIRECT: |
764 | 0 | image->container_alpha = 0; |
765 | 0 | image->container_bpc = JXR_BD16; |
766 | 0 | image->container_color = JXR_OCF_CMYKDIRECT; |
767 | 0 | image->container_nc = 4; |
768 | 0 | break; |
769 | 0 | case JXRC_FMT_40bppCMYKDIRECTAlpha: |
770 | 0 | image->container_alpha = 1; |
771 | 0 | image->container_bpc = JXR_BD8; |
772 | 0 | image->container_color = JXR_OCF_CMYKDIRECT; |
773 | 0 | image->container_nc = 5; |
774 | 0 | break; |
775 | 0 | case JXRC_FMT_80bppCMYKDIRECTAlpha: |
776 | 0 | image->container_alpha = 1; |
777 | 0 | image->container_bpc = JXR_BD16; |
778 | 0 | image->container_color = JXR_OCF_CMYKDIRECT; |
779 | 0 | image->container_nc = 5; |
780 | 0 | break; |
781 | 0 | case JXRC_FMT_12bppYCC420: |
782 | 0 | image->container_alpha = 0; |
783 | 0 | image->container_bpc = JXR_BD8; |
784 | 0 | image->container_color = JXR_OCF_YUV420; |
785 | 0 | image->container_nc = 3; |
786 | 0 | break; |
787 | 0 | case JXRC_FMT_16bppYCC422: |
788 | 0 | image->container_alpha = 0; |
789 | 0 | image->container_bpc = JXR_BD8; |
790 | 0 | image->container_color = JXR_OCF_YUV422; |
791 | 0 | image->container_nc = 3; |
792 | 0 | break; |
793 | 0 | case JXRC_FMT_20bppYCC422: |
794 | 0 | image->container_alpha = 0; |
795 | 0 | image->container_bpc = JXR_BD10; |
796 | 0 | image->container_color = JXR_OCF_YUV422; |
797 | 0 | image->container_nc = 3; |
798 | 0 | break; |
799 | 0 | case JXRC_FMT_32bppYCC422: |
800 | 0 | image->container_alpha = 0; |
801 | 0 | image->container_bpc = JXR_BD16; |
802 | 0 | image->container_color = JXR_OCF_YUV422; |
803 | 0 | image->container_nc = 3; |
804 | 0 | break; |
805 | 0 | case JXRC_FMT_24bppYCC444: |
806 | 0 | image->container_alpha = 0; |
807 | 0 | image->container_bpc = JXR_BD8; |
808 | 0 | image->container_color = JXR_OCF_YUV444; |
809 | 0 | image->container_nc = 3; |
810 | 0 | break; |
811 | 0 | case JXRC_FMT_30bppYCC444: |
812 | 0 | image->container_alpha = 0; |
813 | 0 | image->container_bpc = JXR_BD10; |
814 | 0 | image->container_color = JXR_OCF_YUV444; |
815 | 0 | image->container_nc = 3; |
816 | 0 | break; |
817 | 0 | case JXRC_FMT_48bppYCC444: |
818 | 0 | image->container_alpha = 0; |
819 | 0 | image->container_bpc = JXR_BD16; |
820 | 0 | image->container_color = JXR_OCF_YUV444; |
821 | 0 | image->container_nc = 3; |
822 | 0 | break; |
823 | 0 | case JXRC_FMT_48bppYCC444FixedPoint: |
824 | 0 | image->container_alpha = 0; |
825 | 0 | image->container_bpc = JXR_BD16S; |
826 | 0 | image->container_color = JXR_OCF_YUV444; |
827 | 0 | image->container_nc = 3; |
828 | 0 | break; |
829 | 0 | case JXRC_FMT_20bppYCC420Alpha: |
830 | 0 | image->container_alpha = 1; |
831 | 0 | image->container_bpc = JXR_BD8; |
832 | 0 | image->container_color = JXR_OCF_YUV420; |
833 | 0 | image->container_nc = 4; |
834 | 0 | break; |
835 | 0 | case JXRC_FMT_24bppYCC422Alpha: |
836 | 0 | image->container_alpha = 1; |
837 | 0 | image->container_bpc = JXR_BD8; |
838 | 0 | image->container_color = JXR_OCF_YUV422; |
839 | 0 | image->container_nc = 4; |
840 | 0 | break; |
841 | 0 | case JXRC_FMT_30bppYCC422Alpha: |
842 | 0 | image->container_alpha = 1; |
843 | 0 | image->container_bpc = JXR_BD10; |
844 | 0 | image->container_color = JXR_OCF_YUV422; |
845 | 0 | image->container_nc = 4; |
846 | 0 | break; |
847 | 0 | case JXRC_FMT_48bppYCC422Alpha: |
848 | 0 | image->container_alpha = 1; |
849 | 0 | image->container_bpc = JXR_BD16; |
850 | 0 | image->container_color = JXR_OCF_YUV422; |
851 | 0 | image->container_nc = 4; |
852 | 0 | break; |
853 | 0 | case JXRC_FMT_32bppYCC444Alpha: |
854 | 0 | image->container_alpha = 1; |
855 | 0 | image->container_bpc = JXR_BD8; |
856 | 0 | image->container_color = JXR_OCF_YUV444; |
857 | 0 | image->container_nc = 4; |
858 | 0 | break; |
859 | 0 | case JXRC_FMT_40bppYCC444Alpha: |
860 | 0 | image->container_alpha = 1; |
861 | 0 | image->container_bpc = JXR_BD10; |
862 | 0 | image->container_color = JXR_OCF_YUV444; |
863 | 0 | image->container_nc = 4; |
864 | 0 | break; |
865 | 0 | case JXRC_FMT_64bppYCC444Alpha: |
866 | 0 | image->container_alpha = 1; |
867 | 0 | image->container_bpc = JXR_BD16; |
868 | 0 | image->container_color = JXR_OCF_YUV444; |
869 | 0 | image->container_nc = 4; |
870 | 0 | break; |
871 | 0 | case JXRC_FMT_64bppYCC444AlphaFixedPoint: |
872 | 0 | image->container_alpha = 1; |
873 | 0 | image->container_bpc = JXR_BD16S; |
874 | 0 | image->container_color = JXR_OCF_YUV444; |
875 | 0 | image->container_nc = 4; |
876 | 0 | break; |
877 | 0 | default: |
878 | | /* all Guids listed above*/ |
879 | 0 | assert(0); |
880 | 0 | break; |
881 | 0 | } |
882 | 0 | } |
883 | | |
884 | | void jxr_set_NUM_VER_TILES_MINUS1(jxr_image_t image, unsigned num) |
885 | 0 | { |
886 | 0 | assert( num > 0 && num < 4097 ); |
887 | 0 | image->tile_columns = num; |
888 | |
|
889 | 0 | if (num > 1) |
890 | 0 | jxr_set_TILING_FLAG(image, 1); |
891 | 0 | } |
892 | | |
893 | | void jxr_set_TILE_WIDTH_IN_MB(jxr_image_t image, unsigned* list) |
894 | 0 | { |
895 | 0 | unsigned idx, total_width = 0; |
896 | |
|
897 | 0 | assert(list != 0); |
898 | 0 | image->tile_column_width = list; |
899 | 0 | image->tile_column_position = image->tile_column_width + image->tile_columns; |
900 | |
|
901 | 0 | if (image->tile_column_width[0] == 0) { |
902 | 0 | total_width = 0; |
903 | 0 | for ( idx = 0 ; idx < image->tile_columns - 1 ; idx++ ) { |
904 | 0 | image->tile_column_width[idx] = (image->extended_width >> 4) / image->tile_columns; |
905 | 0 | image->tile_column_position[idx] = total_width; |
906 | 0 | total_width += image->tile_column_width[idx]; |
907 | 0 | } |
908 | 0 | image->tile_column_width[image->tile_columns - 1] = (image->extended_width >> 4) - total_width; |
909 | 0 | image->tile_column_position[image->tile_columns - 1] = total_width; |
910 | 0 | } |
911 | 0 | } |
912 | | |
913 | | void jxr_set_NUM_HOR_TILES_MINUS1(jxr_image_t image, unsigned num) |
914 | 0 | { |
915 | 0 | assert( num > 0 && num < 4097 ); |
916 | 0 | image->tile_rows = num; |
917 | |
|
918 | 0 | if (num > 1) |
919 | 0 | jxr_set_TILING_FLAG(image, 1); |
920 | 0 | } |
921 | | |
922 | | void jxr_set_TILE_HEIGHT_IN_MB(jxr_image_t image, unsigned* list) |
923 | 0 | { |
924 | 0 | unsigned idx, total_height = 0; |
925 | |
|
926 | 0 | assert(list != 0); |
927 | 0 | image->tile_row_height = list; |
928 | 0 | image->tile_row_position = image->tile_row_height + image->tile_rows; |
929 | |
|
930 | 0 | if (image->tile_row_height[0] == 0) { |
931 | 0 | total_height = 0; |
932 | 0 | for ( idx = 0 ; idx < image->tile_rows - 1 ; idx++ ) { |
933 | 0 | image->tile_row_height[idx] = (image->extended_height >> 4) / image->tile_rows; |
934 | 0 | image->tile_row_position[idx] = total_height; |
935 | 0 | total_height += image->tile_row_height[idx]; |
936 | 0 | } |
937 | 0 | image->tile_row_height[image->tile_rows - 1] = (image->extended_height >> 4) - total_height; |
938 | 0 | image->tile_row_position[image->tile_rows - 1] = total_height; |
939 | 0 | } |
940 | 0 | } |
941 | | |
942 | | void jxr_set_TILING_FLAG(jxr_image_t image, int flag) |
943 | 0 | { |
944 | 0 | assert(flag >= 0 && flag <= 1); |
945 | 0 | image->header_flags1 &= ~0x80; |
946 | 0 | image->header_flags1 |= (flag << 7); |
947 | | |
948 | | /* Enable INDEX_TABLE_PRESENT_FLAG */ |
949 | 0 | if (flag) { |
950 | 0 | jxr_set_INDEX_TABLE_PRESENT_FLAG(image, 1); |
951 | 0 | } |
952 | 0 | } |
953 | | |
954 | | void jxr_set_TRIM_FLEXBITS(jxr_image_t image, int trim_flexbits) |
955 | 0 | { |
956 | 0 | assert(trim_flexbits >= 0 && trim_flexbits < 16); |
957 | 0 | image->trim_flexbits = trim_flexbits; |
958 | 0 | } |
959 | | |
960 | | void jxr_set_OVERLAP_FILTER(jxr_image_t image, int flag) |
961 | 0 | { |
962 | 0 | assert(flag >= 0 && flag <= 3); |
963 | 0 | image->header_flags1 &= ~0x03; |
964 | 0 | image->header_flags1 |= flag&0x03; |
965 | 0 | } |
966 | | |
967 | | void jxr_set_DISABLE_TILE_OVERLAP(jxr_image_t image, int disable_tile_overlap) |
968 | 0 | { |
969 | 0 | image->disableTileOverlapFlag = disable_tile_overlap; |
970 | 0 | } |
971 | | |
972 | | void jxr_set_QP_LOSSLESS(jxr_image_t image) |
973 | 0 | { |
974 | 0 | unsigned char q[MAX_CHANNELS]; |
975 | 0 | int idx; |
976 | 0 | for (idx = 0 ; idx < MAX_CHANNELS ; idx += 1) |
977 | 0 | q[idx] = 0; |
978 | |
|
979 | 0 | jxr_set_QP_INDEPENDENT(image, q); |
980 | |
|
981 | 0 | if (image->num_channels == 1) { |
982 | 0 | image->dc_component_mode = JXR_CM_UNIFORM; |
983 | 0 | image->lp_component_mode = JXR_CM_UNIFORM; |
984 | 0 | image->hp_component_mode = JXR_CM_UNIFORM; |
985 | 0 | } else if (image->num_channels == 3) { |
986 | 0 | image->dc_component_mode = JXR_CM_SEPARATE; |
987 | 0 | image->lp_component_mode = JXR_CM_SEPARATE; |
988 | 0 | image->hp_component_mode = JXR_CM_SEPARATE; |
989 | 0 | } |
990 | 0 | } |
991 | | |
992 | | void jxr_set_QP_INDEPENDENT(jxr_image_t image, unsigned char*quant_per_channel) |
993 | 0 | { |
994 | | /* |
995 | | * SCALED_FLAG MUST be set false if lossless compressing. |
996 | | * SCALED_FLAG SHOULD be true otherwise. |
997 | | * |
998 | | * So assume that we are setting up for lossless compression |
999 | | * until we find a QP flag that indicates otherwlse. If that |
1000 | | * happens, turn SCALED_FLAG on. |
1001 | | */ |
1002 | 0 | int idx; |
1003 | |
|
1004 | 0 | image->scaled_flag = 0; |
1005 | |
|
1006 | 0 | if (image->bands_present != JXR_BP_ALL) |
1007 | 0 | image->scaled_flag = 1; |
1008 | |
|
1009 | 0 | if (image->num_channels == 1) { |
1010 | 0 | image->dc_component_mode = JXR_CM_UNIFORM; |
1011 | 0 | image->lp_component_mode = JXR_CM_UNIFORM; |
1012 | 0 | image->hp_component_mode = JXR_CM_UNIFORM; |
1013 | 0 | } else { |
1014 | 0 | image->dc_component_mode = JXR_CM_INDEPENDENT; |
1015 | 0 | image->lp_component_mode = JXR_CM_INDEPENDENT; |
1016 | 0 | image->hp_component_mode = JXR_CM_INDEPENDENT; |
1017 | 0 | } |
1018 | |
|
1019 | 0 | image->dc_frame_uniform = 1; |
1020 | 0 | image->lp_frame_uniform = 1; |
1021 | 0 | image->hp_frame_uniform = 1; |
1022 | 0 | image->lp_use_dc_qp = 0; |
1023 | 0 | image->hp_use_lp_qp = 0; |
1024 | |
|
1025 | 0 | image->num_lp_qps = 1; |
1026 | 0 | image->num_hp_qps = 1; |
1027 | |
|
1028 | 0 | for (idx = 0 ; idx < image->num_channels ; idx += 1) { |
1029 | 0 | if (quant_per_channel[idx] >= 1) |
1030 | 0 | image->scaled_flag = 1; |
1031 | |
|
1032 | 0 | image->dc_quant_ch[idx] = quant_per_channel[idx]; |
1033 | 0 | image->lp_quant_ch[idx][0] = quant_per_channel[idx]; |
1034 | 0 | image->hp_quant_ch[idx][0] = quant_per_channel[idx]; |
1035 | 0 | } |
1036 | 0 | } |
1037 | | |
1038 | | void jxr_set_QP_UNIFORM(jxr_image_t image, unsigned char quant) |
1039 | 0 | { |
1040 | 0 | int idx; |
1041 | |
|
1042 | 0 | image->scaled_flag = 0; |
1043 | |
|
1044 | 0 | image->dc_component_mode = JXR_CM_UNIFORM; |
1045 | 0 | image->lp_component_mode = JXR_CM_UNIFORM; |
1046 | 0 | image->hp_component_mode = JXR_CM_UNIFORM; |
1047 | |
|
1048 | 0 | image->dc_frame_uniform = 1; |
1049 | 0 | image->lp_frame_uniform = 1; |
1050 | 0 | image->hp_frame_uniform = 1; |
1051 | 0 | image->lp_use_dc_qp = 0; |
1052 | 0 | image->hp_use_lp_qp = 0; |
1053 | |
|
1054 | 0 | image->num_lp_qps = 1; |
1055 | 0 | image->num_hp_qps = 1; |
1056 | |
|
1057 | 0 | if (quant >= 1) |
1058 | 0 | image->scaled_flag = 1; |
1059 | 0 | if (image->bands_present != JXR_BP_ALL) |
1060 | 0 | image->scaled_flag = 1; |
1061 | |
|
1062 | 0 | for (idx = 0 ; idx < image->num_channels ; idx += 1) { |
1063 | 0 | image->dc_quant_ch[idx] = quant; |
1064 | 0 | image->lp_quant_ch[idx][0] = quant; |
1065 | 0 | image->hp_quant_ch[idx][0] = quant; |
1066 | 0 | } |
1067 | 0 | } |
1068 | | |
1069 | | void jxr_set_QP_SEPARATE(jxr_image_t image, unsigned char*quant_per_channel) |
1070 | 0 | { |
1071 | | /* |
1072 | | * SCALED_FLAG MUST be set false if lossless compressing. |
1073 | | * SCALED_FLAG SHOULD be true otherwise. |
1074 | | * |
1075 | | * So assume that we are setting up for lossless compression |
1076 | | * until we find a QP flag that indicates otherwlse. If that |
1077 | | * happens, turn SCALED_FLAG on. |
1078 | | */ |
1079 | 0 | int ch; |
1080 | |
|
1081 | 0 | image->scaled_flag = 0; |
1082 | |
|
1083 | 0 | if (image->bands_present != JXR_BP_ALL) |
1084 | 0 | image->scaled_flag = 1; |
1085 | | |
1086 | | /* XXXX Only thought out how to handle 1 channel. */ |
1087 | 0 | assert(image->num_channels >= 3); |
1088 | |
|
1089 | 0 | image->dc_component_mode = JXR_CM_SEPARATE; |
1090 | 0 | image->lp_component_mode = JXR_CM_SEPARATE; |
1091 | 0 | image->hp_component_mode = JXR_CM_SEPARATE; |
1092 | |
|
1093 | 0 | image->dc_frame_uniform = 1; |
1094 | 0 | image->lp_frame_uniform = 1; |
1095 | 0 | image->hp_frame_uniform = 1; |
1096 | 0 | image->lp_use_dc_qp = 0; |
1097 | 0 | image->hp_use_lp_qp = 0; |
1098 | |
|
1099 | 0 | if (quant_per_channel[0] >= 1) |
1100 | 0 | image->scaled_flag = 1; |
1101 | |
|
1102 | 0 | image->dc_quant_ch[0] = quant_per_channel[0]; |
1103 | 0 | image->lp_quant_ch[0][0] = quant_per_channel[0]; |
1104 | 0 | image->hp_quant_ch[0][0] = quant_per_channel[0]; |
1105 | |
|
1106 | 0 | if (quant_per_channel[1] >= 1) |
1107 | 0 | image->scaled_flag = 1; |
1108 | |
|
1109 | 0 | for (ch = 1 ; ch < image->num_channels ; ch += 1) { |
1110 | 0 | image->dc_quant_ch[ch] = quant_per_channel[1]; |
1111 | 0 | image->lp_quant_ch[ch][0] = quant_per_channel[1]; |
1112 | 0 | image->hp_quant_ch[ch][0] = quant_per_channel[1]; |
1113 | 0 | } |
1114 | 0 | } |
1115 | | |
1116 | | void jxr_set_QP_DISTRIBUTED(jxr_image_t image, struct jxr_tile_qp*qp) |
1117 | 0 | { |
1118 | 0 | image->dc_frame_uniform = 0; |
1119 | 0 | image->lp_frame_uniform = 0; |
1120 | 0 | image->hp_frame_uniform = 0; |
1121 | 0 | image->lp_use_dc_qp = 0; |
1122 | 0 | image->hp_use_lp_qp = 0; |
1123 | |
|
1124 | 0 | image->tile_quant = qp; |
1125 | 0 | } |
1126 | | |
1127 | | void jxr_set_pixel_format(jxr_image_t image, jxrc_t_pixelFormat pixelFormat) |
1128 | 0 | { |
1129 | 0 | image->ePixelFormat = pixelFormat; |
1130 | 0 | } |
1131 | | |
1132 | | void jxr_set_SHIFT_BITS(jxr_image_t image, unsigned char shift_bits) |
1133 | 0 | { |
1134 | 0 | image->shift_bits = shift_bits; |
1135 | 0 | } |
1136 | | |
1137 | | void jxr_set_FLOAT(jxr_image_t image, unsigned char len_mantissa, char exp_bias) |
1138 | 0 | { |
1139 | 0 | image->len_mantissa = len_mantissa; |
1140 | 0 | image->exp_bias = exp_bias; |
1141 | 0 | } |
1142 | | |
1143 | | /* |
1144 | | * $Log: api.c,v $ |
1145 | | * Revision 1.20 2009/05/29 12:00:00 microsoft |
1146 | | * Reference Software v1.6 updates. |
1147 | | * |
1148 | | * Revision 1.19 2009/04/13 12:00:00 microsoft |
1149 | | * Reference Software v1.5 updates. |
1150 | | * |
1151 | | * Revision 1.18 2008/03/21 18:05:53 steve |
1152 | | * Proper CMYK formatting on input. |
1153 | | * |
1154 | | * Revision 1.17 2008/03/06 02:05:48 steve |
1155 | | * Distributed quantization |
1156 | | * |
1157 | | * Revision 1.16 2008/03/05 04:04:30 steve |
1158 | | * Clarify constraints on USE_DC_QP in image plane header. |
1159 | | * |
1160 | | * Revision 1.15 2008/03/05 01:27:15 steve |
1161 | | * QP_UNIFORM may use USE_DC_LP optionally. |
1162 | | * |
1163 | | * Revision 1.14 2008/03/05 00:31:17 steve |
1164 | | * Handle UNIFORM/IMAGEPLANE_UNIFORM compression. |
1165 | | * |
1166 | | * Revision 1.13 2008/03/04 23:01:28 steve |
1167 | | * Cleanup QP API in preparation for distributed QP |
1168 | | * |
1169 | | * Revision 1.12 2008/03/02 19:56:27 steve |
1170 | | * Infrastructure to read write BD16 files. |
1171 | | * |
1172 | | * Revision 1.11 2008/02/26 23:52:44 steve |
1173 | | * Remove ident for MS compilers. |
1174 | | * |
1175 | | * Revision 1.10 2008/02/01 22:49:52 steve |
1176 | | * Handle compress of YUV444 color DCONLY |
1177 | | * |
1178 | | * Revision 1.9 2008/01/08 01:06:20 steve |
1179 | | * Add first pass overlap filtering. |
1180 | | * |
1181 | | * Revision 1.8 2008/01/07 16:19:10 steve |
1182 | | * Properly configure TRIM_FLEXBITS_FLAG bit. |
1183 | | * |
1184 | | * Revision 1.7 2008/01/06 01:29:28 steve |
1185 | | * Add support for TRIM_FLEXBITS in compression. |
1186 | | * |
1187 | | * Revision 1.6 2008/01/04 17:07:35 steve |
1188 | | * API interface for setting QP values. |
1189 | | * |
1190 | | * Revision 1.5 2007/11/30 01:50:58 steve |
1191 | | * Compression of DCONLY GRAY. |
1192 | | * |
1193 | | * Revision 1.4 2007/11/26 01:47:15 steve |
1194 | | * Add copyright notices per MS request. |
1195 | | * |
1196 | | * Revision 1.3 2007/11/08 02:52:32 steve |
1197 | | * Some progress in some encoding infrastructure. |
1198 | | * |
1199 | | * Revision 1.2 2007/09/08 01:01:43 steve |
1200 | | * YUV444 color parses properly. |
1201 | | * |
1202 | | * Revision 1.1 2007/06/06 17:19:12 steve |
1203 | | * Introduce to CVS. |
1204 | | * |
1205 | | */ |
1206 | | |