load-jpx.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663
  1. // Copyright (C) 2004-2023 Artifex Software, Inc.
  2. //
  3. // This file is part of MuPDF.
  4. //
  5. // MuPDF is free software: you can redistribute it and/or modify it under the
  6. // terms of the GNU Affero General Public License as published by the Free
  7. // Software Foundation, either version 3 of the License, or (at your option)
  8. // any later version.
  9. //
  10. // MuPDF is distributed in the hope that it will be useful, but WITHOUT ANY
  11. // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  12. // FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
  13. // details.
  14. //
  15. // You should have received a copy of the GNU Affero General Public License
  16. // along with MuPDF. If not, see <https://www.gnu.org/licenses/agpl-3.0.en.html>
  17. //
  18. // Alternative licensing terms are available from the licensor.
  19. // For commercial licensing, see <https://www.artifex.com/> or contact
  20. // Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
  21. // CA 94129, USA, for further information.
  22. #include "mupdf/fitz.h"
  23. #include "pixmap-imp.h"
  24. #include <assert.h>
  25. #include <string.h>
  26. #if FZ_ENABLE_JPX
  27. static void
  28. jpx_ycc_to_rgb(fz_context *ctx, fz_pixmap *pix, int cbsign, int crsign)
  29. {
  30. int w = pix->w;
  31. int h = pix->h;
  32. int stride = pix->stride;
  33. int x, y;
  34. for (y = 0; y < h; y++)
  35. {
  36. unsigned char * row = &pix->samples[stride * y];
  37. for (x = 0; x < w; x++)
  38. {
  39. int ycc[3];
  40. ycc[0] = row[x * 3 + 0];
  41. ycc[1] = row[x * 3 + 1];
  42. ycc[2] = row[x * 3 + 2];
  43. /* consciously skip Y */
  44. if (cbsign)
  45. ycc[1] -= 128;
  46. if (crsign)
  47. ycc[2] -= 128;
  48. row[x * 3 + 0] = fz_clampi(ycc[0] + 1.402f * ycc[2], 0, 255);
  49. row[x * 3 + 1] = fz_clampi(ycc[0] - 0.34413f * ycc[1] - 0.71414f * ycc[2], 0, 255);
  50. row[x * 3 + 2] = fz_clampi(ycc[0] + 1.772f * ycc[1], 0, 255);
  51. }
  52. }
  53. }
  54. #include <openjpeg.h>
  55. typedef struct
  56. {
  57. int width;
  58. int height;
  59. fz_colorspace *cs;
  60. int xres;
  61. int yres;
  62. } fz_jpxd;
  63. typedef struct
  64. {
  65. const unsigned char *data;
  66. OPJ_SIZE_T size;
  67. OPJ_SIZE_T pos;
  68. } stream_block;
  69. /* OpenJPEG does not provide a safe mechanism to intercept
  70. * allocations. In the latest version all allocations go
  71. * though opj_malloc etc, but no context is passed around.
  72. *
  73. * In order to ensure that allocations throughout mupdf
  74. * are done consistently, we implement opj_malloc etc as
  75. * functions that call down to fz_malloc etc. These
  76. * require context variables, so we lock and unlock around
  77. * calls to openjpeg. Any attempt to call through
  78. * without setting these will be detected.
  79. *
  80. * It is therefore vital that any fz_lock/fz_unlock
  81. * handlers are shared between all the fz_contexts in
  82. * use at a time.
  83. */
  84. /* Potentially we can write different versions
  85. * of get_context and set_context for different
  86. * threading systems.
  87. */
  88. static fz_context *opj_secret = NULL;
  89. static void set_opj_context(fz_context *ctx)
  90. {
  91. opj_secret = ctx;
  92. }
  93. static fz_context *get_opj_context(void)
  94. {
  95. return opj_secret;
  96. }
  97. void opj_lock(fz_context *ctx)
  98. {
  99. fz_ft_lock(ctx);
  100. set_opj_context(ctx);
  101. }
  102. void opj_unlock(fz_context *ctx)
  103. {
  104. set_opj_context(NULL);
  105. fz_ft_unlock(ctx);
  106. }
  107. void *opj_malloc(size_t size)
  108. {
  109. fz_context *ctx = get_opj_context();
  110. assert(ctx != NULL);
  111. return Memento_label(fz_malloc_no_throw(ctx, size), "opj_malloc");
  112. }
  113. void *opj_calloc(size_t n, size_t size)
  114. {
  115. fz_context *ctx = get_opj_context();
  116. assert(ctx != NULL);
  117. return fz_calloc_no_throw(ctx, n, size);
  118. }
  119. void *opj_realloc(void *ptr, size_t size)
  120. {
  121. fz_context *ctx = get_opj_context();
  122. assert(ctx != NULL);
  123. return fz_realloc_no_throw(ctx, ptr, size);
  124. }
  125. void opj_free(void *ptr)
  126. {
  127. fz_context *ctx = get_opj_context();
  128. assert(ctx != NULL);
  129. fz_free(ctx, ptr);
  130. }
  131. static void * opj_aligned_malloc_n(size_t alignment, size_t size)
  132. {
  133. uint8_t *ptr;
  134. size_t off;
  135. if (size == 0)
  136. return NULL;
  137. size += alignment + sizeof(uint8_t);
  138. ptr = opj_malloc(size);
  139. if (ptr == NULL)
  140. return NULL;
  141. off = alignment-(((int)(intptr_t)ptr) & (alignment - 1));
  142. ptr[off-1] = (uint8_t)off;
  143. return ptr + off;
  144. }
  145. void * opj_aligned_malloc(size_t size)
  146. {
  147. return opj_aligned_malloc_n(16, size);
  148. }
  149. void * opj_aligned_32_malloc(size_t size)
  150. {
  151. return opj_aligned_malloc_n(32, size);
  152. }
  153. void opj_aligned_free(void* ptr_)
  154. {
  155. uint8_t *ptr = (uint8_t *)ptr_;
  156. uint8_t off;
  157. if (ptr == NULL)
  158. return;
  159. off = ptr[-1];
  160. opj_free((void *)(((unsigned char *)ptr) - off));
  161. }
  162. #if 0
  163. /* UNUSED currently, and moderately tricky, so deferred until required */
  164. void * opj_aligned_realloc(void *ptr, size_t size)
  165. {
  166. return opj_realloc(ptr, size);
  167. }
  168. #endif
  169. static void fz_opj_error_callback(const char *msg, void *client_data)
  170. {
  171. fz_context *ctx = (fz_context *)client_data;
  172. char buf[200];
  173. size_t n;
  174. fz_strlcpy(buf, msg, sizeof buf);
  175. n = strlen(buf);
  176. if (buf[n-1] == '\n')
  177. buf[n-1] = 0;
  178. fz_warn(ctx, "openjpeg error: %s", buf);
  179. }
  180. static void fz_opj_warning_callback(const char *msg, void *client_data)
  181. {
  182. fz_context *ctx = (fz_context *)client_data;
  183. char buf[200];
  184. size_t n;
  185. fz_strlcpy(buf, msg, sizeof buf);
  186. n = strlen(buf);
  187. if (buf[n-1] == '\n')
  188. buf[n-1] = 0;
  189. fz_warn(ctx, "openjpeg warning: %s", buf);
  190. }
  191. static void fz_opj_info_callback(const char *msg, void *client_data)
  192. {
  193. /* fz_warn("openjpeg info: %s", msg); */
  194. }
  195. static OPJ_SIZE_T fz_opj_stream_read(void * p_buffer, OPJ_SIZE_T p_nb_bytes, void * p_user_data)
  196. {
  197. stream_block *sb = (stream_block *)p_user_data;
  198. OPJ_SIZE_T len;
  199. len = sb->size - sb->pos;
  200. if (len == 0)
  201. return (OPJ_SIZE_T)-1; /* End of file! */
  202. if (len > p_nb_bytes)
  203. len = p_nb_bytes;
  204. memcpy(p_buffer, sb->data + sb->pos, len);
  205. sb->pos += len;
  206. return len;
  207. }
  208. static OPJ_OFF_T fz_opj_stream_skip(OPJ_OFF_T skip, void * p_user_data)
  209. {
  210. stream_block *sb = (stream_block *)p_user_data;
  211. if (skip > (OPJ_OFF_T)(sb->size - sb->pos))
  212. skip = (OPJ_OFF_T)(sb->size - sb->pos);
  213. sb->pos += skip;
  214. return sb->pos;
  215. }
  216. static OPJ_BOOL fz_opj_stream_seek(OPJ_OFF_T seek_pos, void * p_user_data)
  217. {
  218. stream_block *sb = (stream_block *)p_user_data;
  219. if (seek_pos > (OPJ_OFF_T)sb->size)
  220. return OPJ_FALSE;
  221. sb->pos = seek_pos;
  222. return OPJ_TRUE;
  223. }
  224. static int32_t
  225. safe_mul32(fz_context *ctx, int32_t a, int32_t b)
  226. {
  227. int64_t res = ((int64_t)a) * b;
  228. int32_t res32 = (int32_t)res;
  229. if ((res32) != res)
  230. fz_throw(ctx, FZ_ERROR_LIMIT, "Overflow while decoding jpx");
  231. return res32;
  232. }
  233. static int32_t
  234. safe_mla32(fz_context *ctx, int32_t a, int32_t b, int32_t c)
  235. {
  236. int64_t res = ((int64_t)a) * b + c;
  237. int32_t res32 = (int32_t)res;
  238. if ((res32) != res)
  239. fz_throw(ctx, FZ_ERROR_LIMIT, "Overflow while decoding jpx");
  240. return res32;
  241. }
  242. static inline void
  243. template_copy_comp(unsigned char *dst0, int w, int h, int stride, const OPJ_INT32 *src, int32_t ox, int32_t oy, OPJ_UINT32 cdx, OPJ_UINT32 cdy, OPJ_UINT32 cw, OPJ_UINT32 ch, OPJ_UINT32 sgnd, OPJ_UINT32 prec, int comps)
  244. {
  245. int x, y;
  246. for (y = ch; oy + cdy <= 0 && y > 0; y--)
  247. {
  248. oy += cdy;
  249. dst0 += cdy * stride;
  250. src += cw;
  251. }
  252. for (; y > 0; y--)
  253. {
  254. int32_t dymin = oy;
  255. int32_t dywid = cdy;
  256. unsigned char *dst1 = dst0 + ox * comps;
  257. int32_t oox = ox;
  258. const OPJ_INT32 *src0 = src;
  259. if (dymin < 0)
  260. dywid += dymin, dst1 -= dymin * stride, dymin = 0;
  261. if (dymin >= h)
  262. break;
  263. if (dymin + dywid > h)
  264. dywid = h - dymin;
  265. for (x = cw; oox + cdx <= 0 && x > 0; x--)
  266. {
  267. oox += cdx;
  268. dst1 += cdx * comps;
  269. src0++;
  270. }
  271. for (; x > 0; x--)
  272. {
  273. OPJ_INT32 v;
  274. int32_t xx, yy;
  275. int32_t dxmin = oox;
  276. int32_t dxwid = cdx;
  277. unsigned char *dst2;
  278. v = *src0++;
  279. if (sgnd)
  280. v = v + (1 << (prec - 1));
  281. if (prec > 8)
  282. v = v >> (prec - 8);
  283. else if (prec < 8)
  284. v = v << (8 - prec);
  285. if (dxmin < 0)
  286. dxwid += dxmin, dst1 -= dxmin * comps, dxmin = 0;
  287. if (dxmin >= w)
  288. break;
  289. if (dxmin + dxwid > w)
  290. dxwid = w - dxmin;
  291. dst2 = dst1;
  292. for (yy = dywid; yy > 0; yy--)
  293. {
  294. unsigned char *dst3 = dst2;
  295. for (xx = dxwid; xx > 0; xx--)
  296. {
  297. *dst3 = v;
  298. dst3 += comps;
  299. }
  300. dst2 += stride;
  301. }
  302. dst1 += comps * cdx;
  303. oox += cdx;
  304. }
  305. dst0 += stride * cdy;
  306. src += cw;
  307. oy += cdy;
  308. }
  309. }
  310. static void
  311. copy_jpx_to_pixmap(fz_context *ctx, fz_pixmap *img, opj_image_t *jpx)
  312. {
  313. unsigned char *dst;
  314. int stride, comps;
  315. int w = img->w;
  316. int h = img->h;
  317. int k;
  318. stride = fz_pixmap_stride(ctx, img);
  319. comps = fz_pixmap_components(ctx, img);
  320. dst = fz_pixmap_samples(ctx, img);
  321. for (k = 0; k < comps; k++)
  322. {
  323. opj_image_comp_t *comp = &(jpx->comps[k]);
  324. OPJ_UINT32 cdx = comp->dx;
  325. OPJ_UINT32 cdy = comp->dy;
  326. OPJ_UINT32 cw = comp->w;
  327. OPJ_UINT32 ch = comp->h;
  328. int32_t oy = safe_mul32(ctx, comp->y0, cdy) - jpx->y0;
  329. int32_t ox = safe_mul32(ctx, comp->x0, cdx) - jpx->x0;
  330. unsigned char *dst0 = dst + oy * stride;
  331. int prec = comp->prec;
  332. int sgnd = comp->sgnd;
  333. if (comp->data == NULL)
  334. fz_throw(ctx, FZ_ERROR_FORMAT, "No data for JP2 image component %d", k);
  335. if (fz_colorspace_is_indexed(ctx, img->colorspace))
  336. {
  337. prec = 8; /* Don't do any scaling! */
  338. sgnd = 0;
  339. }
  340. /* Check that none of the following will overflow. */
  341. (void)safe_mla32(ctx, ch, cdy, oy);
  342. (void)safe_mla32(ctx, cw, cdx, ox);
  343. if (cdx == 1 && cdy == 1)
  344. template_copy_comp(dst0, w, h, stride, comp->data, ox, oy, 1 /*cdx*/, 1 /*cdy*/, cw, ch, sgnd, prec, comps);
  345. else
  346. template_copy_comp(dst0, w, h, stride, comp->data, ox, oy, cdx, cdy, cw, ch, sgnd, prec, comps);
  347. dst++;
  348. }
  349. }
  350. static fz_pixmap *
  351. jpx_read_image(fz_context *ctx, fz_jpxd *state, const unsigned char *data, size_t size, fz_colorspace *defcs, int onlymeta)
  352. {
  353. fz_pixmap *img = NULL;
  354. opj_dparameters_t params;
  355. opj_codec_t *codec;
  356. opj_image_t *jpx;
  357. opj_stream_t *stream;
  358. OPJ_CODEC_FORMAT format;
  359. int a, n, k;
  360. int w, h;
  361. stream_block sb;
  362. OPJ_UINT32 i;
  363. fz_var(img);
  364. if (size < 2)
  365. fz_throw(ctx, FZ_ERROR_FORMAT, "not enough data to determine image format");
  366. /* Check for SOC marker -- if found we have a bare J2K stream */
  367. if (data[0] == 0xFF && data[1] == 0x4F)
  368. format = OPJ_CODEC_J2K;
  369. else
  370. format = OPJ_CODEC_JP2;
  371. opj_set_default_decoder_parameters(&params);
  372. if (fz_colorspace_is_indexed(ctx, defcs))
  373. params.flags |= OPJ_DPARAMETERS_IGNORE_PCLR_CMAP_CDEF_FLAG;
  374. codec = opj_create_decompress(format);
  375. opj_set_info_handler(codec, fz_opj_info_callback, ctx);
  376. opj_set_warning_handler(codec, fz_opj_warning_callback, ctx);
  377. opj_set_error_handler(codec, fz_opj_error_callback, ctx);
  378. if (!opj_setup_decoder(codec, &params))
  379. {
  380. opj_destroy_codec(codec);
  381. fz_throw(ctx, FZ_ERROR_LIBRARY, "j2k decode failed");
  382. }
  383. stream = opj_stream_default_create(OPJ_TRUE);
  384. sb.data = data;
  385. sb.pos = 0;
  386. sb.size = size;
  387. opj_stream_set_read_function(stream, fz_opj_stream_read);
  388. opj_stream_set_skip_function(stream, fz_opj_stream_skip);
  389. opj_stream_set_seek_function(stream, fz_opj_stream_seek);
  390. opj_stream_set_user_data(stream, &sb, NULL);
  391. /* Set the length to avoid an assert */
  392. opj_stream_set_user_data_length(stream, size);
  393. if (!opj_read_header(stream, codec, &jpx))
  394. {
  395. opj_stream_destroy(stream);
  396. opj_destroy_codec(codec);
  397. fz_throw(ctx, FZ_ERROR_LIBRARY, "Failed to read JPX header");
  398. }
  399. if (!opj_decode(codec, stream, jpx))
  400. {
  401. opj_stream_destroy(stream);
  402. opj_destroy_codec(codec);
  403. opj_image_destroy(jpx);
  404. fz_throw(ctx, FZ_ERROR_LIBRARY, "Failed to decode JPX image");
  405. }
  406. opj_stream_destroy(stream);
  407. opj_destroy_codec(codec);
  408. /* jpx should never be NULL here, but check anyway */
  409. if (!jpx)
  410. fz_throw(ctx, FZ_ERROR_LIBRARY, "opj_decode failed");
  411. /* Count number of alpha and color channels */
  412. n = a = 0;
  413. for (i = 0; i < jpx->numcomps; ++i)
  414. {
  415. if (jpx->comps[i].alpha)
  416. ++a;
  417. else
  418. ++n;
  419. }
  420. for (k = 1; k < n + a; k++)
  421. {
  422. if (!jpx->comps[k].data)
  423. {
  424. opj_image_destroy(jpx);
  425. fz_throw(ctx, FZ_ERROR_FORMAT, "image components are missing data");
  426. }
  427. }
  428. w = state->width = jpx->x1 - jpx->x0;
  429. h = state->height = jpx->y1 - jpx->y0;
  430. state->xres = 72; /* openjpeg does not read the JPEG 2000 resc box */
  431. state->yres = 72; /* openjpeg does not read the JPEG 2000 resc box */
  432. if (w < 0 || h < 0)
  433. {
  434. opj_image_destroy(jpx);
  435. fz_throw(ctx, FZ_ERROR_LIMIT, "Unbelievable size for jpx");
  436. }
  437. state->cs = NULL;
  438. if (defcs)
  439. {
  440. if (defcs->n == n)
  441. state->cs = fz_keep_colorspace(ctx, defcs);
  442. else
  443. fz_warn(ctx, "jpx file and dict colorspace do not match");
  444. }
  445. #if FZ_ENABLE_ICC
  446. if (!state->cs && jpx->icc_profile_buf && jpx->icc_profile_len > 0)
  447. {
  448. fz_buffer *cbuf = NULL;
  449. fz_var(cbuf);
  450. fz_try(ctx)
  451. {
  452. cbuf = fz_new_buffer_from_copied_data(ctx, jpx->icc_profile_buf, jpx->icc_profile_len);
  453. state->cs = fz_new_icc_colorspace(ctx, FZ_COLORSPACE_NONE, 0, NULL, cbuf);
  454. }
  455. fz_always(ctx)
  456. fz_drop_buffer(ctx, cbuf);
  457. fz_catch(ctx)
  458. {
  459. fz_rethrow_if(ctx, FZ_ERROR_SYSTEM);
  460. fz_report_error(ctx);
  461. fz_warn(ctx, "ignoring embedded ICC profile in JPX");
  462. }
  463. if (state->cs && state->cs->n != n)
  464. {
  465. fz_warn(ctx, "invalid number of components in ICC profile, ignoring ICC profile in JPX");
  466. fz_drop_colorspace(ctx, state->cs);
  467. state->cs = NULL;
  468. }
  469. }
  470. #endif
  471. if (!state->cs)
  472. {
  473. switch (n)
  474. {
  475. case 1: state->cs = fz_keep_colorspace(ctx, fz_device_gray(ctx)); break;
  476. case 3: state->cs = fz_keep_colorspace(ctx, fz_device_rgb(ctx)); break;
  477. case 4: state->cs = fz_keep_colorspace(ctx, fz_device_cmyk(ctx)); break;
  478. default:
  479. {
  480. opj_image_destroy(jpx);
  481. fz_throw(ctx, FZ_ERROR_FORMAT, "unsupported number of components: %d", n);
  482. }
  483. }
  484. }
  485. if (onlymeta)
  486. {
  487. opj_image_destroy(jpx);
  488. return NULL;
  489. }
  490. fz_try(ctx)
  491. {
  492. a = !!a; /* ignore any superfluous alpha channels */
  493. img = fz_new_pixmap(ctx, state->cs, w, h, NULL, a);
  494. fz_clear_pixmap_with_value(ctx, img, 0);
  495. copy_jpx_to_pixmap(ctx, img, jpx);
  496. if (jpx->color_space == OPJ_CLRSPC_SYCC && n == 3 && a == 0)
  497. jpx_ycc_to_rgb(ctx, img, 1, 1);
  498. if (a)
  499. fz_premultiply_pixmap(ctx, img);
  500. }
  501. fz_always(ctx)
  502. {
  503. fz_drop_colorspace(ctx, state->cs);
  504. opj_image_destroy(jpx);
  505. }
  506. fz_catch(ctx)
  507. {
  508. fz_drop_pixmap(ctx, img);
  509. fz_rethrow(ctx);
  510. }
  511. return img;
  512. }
  513. fz_pixmap *
  514. fz_load_jpx(fz_context *ctx, const unsigned char *data, size_t size, fz_colorspace *defcs)
  515. {
  516. fz_jpxd state = { 0 };
  517. fz_pixmap *pix = NULL;
  518. fz_try(ctx)
  519. {
  520. opj_lock(ctx);
  521. pix = jpx_read_image(ctx, &state, data, size, defcs, 0);
  522. }
  523. fz_always(ctx)
  524. opj_unlock(ctx);
  525. fz_catch(ctx)
  526. fz_rethrow(ctx);
  527. return pix;
  528. }
  529. void
  530. fz_load_jpx_info(fz_context *ctx, const unsigned char *data, size_t size, int *wp, int *hp, int *xresp, int *yresp, fz_colorspace **cspacep)
  531. {
  532. fz_jpxd state = { 0 };
  533. fz_try(ctx)
  534. {
  535. opj_lock(ctx);
  536. jpx_read_image(ctx, &state, data, size, NULL, 1);
  537. }
  538. fz_always(ctx)
  539. opj_unlock(ctx);
  540. fz_catch(ctx)
  541. fz_rethrow(ctx);
  542. *cspacep = state.cs;
  543. *wp = state.width;
  544. *hp = state.height;
  545. *xresp = state.xres;
  546. *yresp = state.yres;
  547. }
  548. #else /* FZ_ENABLE_JPX */
  549. fz_pixmap *
  550. fz_load_jpx(fz_context *ctx, const unsigned char *data, size_t size, fz_colorspace *defcs)
  551. {
  552. fz_throw(ctx, FZ_ERROR_UNSUPPORTED, "JPX support disabled");
  553. }
  554. void
  555. fz_load_jpx_info(fz_context *ctx, const unsigned char *data, size_t size, int *wp, int *hp, int *xresp, int *yresp, fz_colorspace **cspacep)
  556. {
  557. fz_throw(ctx, FZ_ERROR_UNSUPPORTED, "JPX support disabled");
  558. }
  559. #endif