diff options
author | Robin Watts <robin.watts@artifex.com> | 2013-01-07 16:00:07 +0000 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2013-05-22 15:27:16 +0100 |
commit | 2e0aa06503b8641408842176152bd0019fe6b8cb (patch) | |
tree | 53e441fbe57b574fea0724893603ee5668c0471b | |
parent | 12011c9168471b2dd8012165c9d127a46b7c6bcb (diff) | |
download | mupdf-2e0aa06503b8641408842176152bd0019fe6b8cb.tar.xz |
Update OpenJPEG to v2.0.0.
-rw-r--r-- | Makethird | 11 | ||||
-rw-r--r-- | fitz/image_jpx.c | 99 | ||||
-rw-r--r-- | scripts/opj_config.h | 4 | ||||
m--------- | thirdparty/openjpeg | 0 | ||||
-rw-r--r-- | win32/libmupdf.vcproj | 6 | ||||
-rw-r--r-- | win32/libthirdparty.vcproj | 302 |
6 files changed, 304 insertions, 118 deletions
@@ -186,7 +186,7 @@ endif # --- OpenJPEG --- ifneq "$(wildcard $(OPENJPEG_DIR)/README)" "" -CFLAGS += -I$(OPENJPEG_DIR)/libopenjpeg +CFLAGS += -I$(OPENJPEG_DIR)/src/lib/openjp2 -DOPJ_STATIC -DOPJ_HAVE_STDINT_H -DHAVE_SSIZE_T -DHAVE_INTTYPES_H LIBS := $(filter-out -lopenjpeg, $(LIBS)) OPENJPEG_LIB := $(OUT)/libopenjpeg.a @@ -196,14 +196,15 @@ OPENJPEG_SRC := \ cio.c \ dwt.c \ event.c \ + function_list.c \ image.c \ + invert.c \ j2k.c \ - j2k_lib.c \ jp2.c \ - jpt.c \ mct.c \ mqc.c \ openjpeg.c \ + opj_clock.c \ phix_manager.c \ pi.c \ ppix_manager.c \ @@ -216,8 +217,8 @@ OPENJPEG_SRC := \ tpix_manager.c \ $(OPENJPEG_LIB): $(addprefix $(OUT)/opj_, $(OPENJPEG_SRC:%.c=%.o)) -$(OUT)/opj_%.o: $(OPENJPEG_DIR)/libopenjpeg/%.c | $(OUT) - $(CC_CMD) -DOPJ_STATIC +$(OUT)/opj_%.o: $(OPENJPEG_DIR)/src/lib/openjp2/%.c | $(OUT) + $(CC_CMD) else SYS_OPENJPEG_CFLAGS := $(SYS_OPENJPEG_CFLAGS) CFLAGS += $(SYS_OPENJPEG_CFLAGS) diff --git a/fitz/image_jpx.c b/fitz/image_jpx.c index ac232220..f680b50c 100644 --- a/fitz/image_jpx.c +++ b/fitz/image_jpx.c @@ -20,50 +20,111 @@ static void fz_opj_info_callback(const char *msg, void *client_data) /* fz_warn("openjpeg info: %s", msg); */ } +typedef struct stream_block_s +{ + unsigned char *data; + int size; + int pos; +} stream_block; + +OPJ_SIZE_T stream_read(void * p_buffer, OPJ_SIZE_T p_nb_bytes, void * p_user_data) +{ + stream_block *sb = (stream_block *)p_user_data; + int len; + + len = sb->size - sb->pos; + if (len < 0) + len = 0; + if (len > p_nb_bytes) + len = p_nb_bytes; + memcpy(p_buffer, sb->data + sb->pos, len); + sb->pos += len; + return len; +} + +OPJ_OFF_T stream_skip(OPJ_OFF_T skip, void * p_user_data) +{ + stream_block *sb = (stream_block *)p_user_data; + + if (skip > sb->size - sb->pos) + skip = sb->size - sb->pos; + sb->pos += skip; + return sb->pos; +} + +OPJ_BOOL stream_seek(OPJ_OFF_T seek_pos, void * p_user_data) +{ + stream_block *sb = (stream_block *)p_user_data; + + if (seek_pos > sb->size) + return OPJ_FALSE; + sb->pos = seek_pos; + return OPJ_TRUE; +} + fz_pixmap * fz_load_jpx(fz_context *ctx, unsigned char *data, int size, fz_colorspace *defcs, int indexed) { fz_pixmap *img; fz_colorspace *origcs; - opj_event_mgr_t evtmgr; opj_dparameters_t params; - opj_dinfo_t *info; - opj_cio_t *cio; + opj_codec_t *codec; opj_image_t *jpx; + opj_stream_t *stream; fz_colorspace *colorspace; unsigned char *p; int format; int a, n, w, h, depth, sgnd; int x, y, k, v; + stream_block sb; if (size < 2) fz_throw(ctx, "not enough data to determine image format"); /* Check for SOC marker -- if found we have a bare J2K stream */ if (data[0] == 0xFF && data[1] == 0x4F) - format = CODEC_J2K; + format = OPJ_CODEC_J2K; else - format = CODEC_JP2; - - memset(&evtmgr, 0, sizeof(evtmgr)); - evtmgr.error_handler = fz_opj_error_callback; - evtmgr.warning_handler = fz_opj_warning_callback; - evtmgr.info_handler = fz_opj_info_callback; + format = OPJ_CODEC_JP2; opj_set_default_decoder_parameters(¶ms); if (indexed) params.flags |= OPJ_DPARAMETERS_IGNORE_PCLR_CMAP_CDEF_FLAG; - info = opj_create_decompress(format); - opj_set_event_mgr((opj_common_ptr)info, &evtmgr, ctx); - opj_setup_decoder(info, ¶ms); + codec = opj_create_decompress(format); + opj_set_info_handler(codec, fz_opj_info_callback, ctx); + opj_set_warning_handler(codec, fz_opj_warning_callback, ctx); + opj_set_error_handler(codec, fz_opj_error_callback, ctx); + if (!opj_setup_decoder(codec, ¶ms)) + { + fz_throw(ctx, "j2k decode failed"); + } + + stream = opj_stream_default_create(OPJ_TRUE); + sb.data = data; + sb.pos = 0; + sb.size = size; - cio = opj_cio_open((opj_common_ptr)info, data, size); + opj_stream_set_read_function(stream, stream_read); + opj_stream_set_skip_function(stream, stream_skip); + opj_stream_set_seek_function(stream, stream_seek); + opj_stream_set_user_data(stream, &sb); - jpx = opj_decode(info, cio); + if (!opj_read_header(stream, codec, &jpx)) + { + opj_stream_destroy(stream); + opj_destroy_codec(codec); + fz_throw(ctx, "Failed to read JPX header"); + } + + if (!opj_decode(codec, stream, jpx)) + { + opj_stream_destroy(stream); + opj_destroy_codec(codec); + fz_throw(ctx, "Failed to decode JPX image"); + } - opj_cio_close(cio); - opj_destroy_decompress(info); + opj_destroy_codec(codec); if (!jpx) fz_throw(ctx, "opj_decode failed"); @@ -93,8 +154,8 @@ fz_load_jpx(fz_context *ctx, unsigned char *data, int size, fz_colorspace *defcs depth = jpx->comps[0].prec; sgnd = jpx->comps[0].sgnd; - if (jpx->color_space == CLRSPC_SRGB && n == 4) { n = 3; a = 1; } - else if (jpx->color_space == CLRSPC_SYCC && n == 4) { n = 3; a = 1; } + if (jpx->color_space == OPJ_CLRSPC_SRGB && n == 4) { n = 3; a = 1; } + else if (jpx->color_space == OPJ_CLRSPC_SYCC && n == 4) { n = 3; a = 1; } else if (n == 2) { n = 1; a = 1; } else if (n > 4) { n = 4; a = 1; } else { a = 0; } diff --git a/scripts/opj_config.h b/scripts/opj_config.h index db37745d..39b38228 100644 --- a/scripts/opj_config.h +++ b/scripts/opj_config.h @@ -17,6 +17,10 @@ * === DO NOT FORGET TO CHANGE 'config.nix' APPROPRIATELY. ==== */ +#define USE_JPIP +#define USE JPWL +#define OPJ_PACKAGE_VERSION "2.0.0" + /* DO NOT DEFINE BOTH VERSIONS OF LCMS */ /* define to 1 if you have both liblcms and lcms.h installed */ #undef HAVE_LIBLCMS1 diff --git a/thirdparty/openjpeg b/thirdparty/openjpeg -Subproject d5693f4ec8635d81defc92619c02134b6b785b0 +Subproject 8f7358dc09a144250bad08a504a26bf7dd3a055 diff --git a/win32/libmupdf.vcproj b/win32/libmupdf.vcproj index f073bbee..996b48aa 100644 --- a/win32/libmupdf.vcproj +++ b/win32/libmupdf.vcproj @@ -40,7 +40,7 @@ <Tool Name="VCCLCompilerTool" Optimization="0" - AdditionalIncludeDirectories="..\scripts;..\fitz;..\ucdn;..\pdf;..\thirdparty\jbig2dec;..\thirdparty\jpeg;..\thirdparty\openjpeg\libopenjpeg;..\thirdparty\zlib;..\thirdparty\freetype\include" + AdditionalIncludeDirectories="..\scripts;..\fitz;..\ucdn;..\pdf;..\thirdparty\jbig2dec;..\thirdparty\jpeg;..\thirdparty\openjpeg\src\lib\openjp2;..\thirdparty\zlib;..\thirdparty\freetype\include" PreprocessorDefinitions="DEBUG=1" MinimalRebuild="true" BasicRuntimeChecks="3" @@ -105,7 +105,7 @@ Name="VCCLCompilerTool" Optimization="2" EnableIntrinsicFunctions="true" - AdditionalIncludeDirectories="..\scripts;..\fitz;..\ucdn;..\pdf;..\thirdparty\jbig2dec;..\thirdparty\jpeg;..\thirdparty\openjpeg\libopenjpeg;..\thirdparty\zlib;..\thirdparty\freetype\include" + AdditionalIncludeDirectories="..\scripts;..\fitz;..\ucdn;..\pdf;..\thirdparty\jbig2dec;..\thirdparty\jpeg;..\thirdparty\openjpeg\src\lib\openjp2;..\thirdparty\zlib;..\thirdparty\freetype\include" RuntimeLibrary="0" EnableFunctionLevelLinking="true" WarningLevel="3" @@ -165,7 +165,7 @@ <Tool Name="VCCLCompilerTool" Optimization="0" - AdditionalIncludeDirectories="..\scripts;..\fitz;..\ucdn;..\pdf;..\thirdparty\jbig2dec;..\thirdparty\jpeg;..\thirdparty\openjpeg\libopenjpeg;..\thirdparty\zlib;..\thirdparty\freetype\include" + AdditionalIncludeDirectories="..\scripts;..\fitz;..\ucdn;..\pdf;..\thirdparty\jbig2dec;..\thirdparty\jpeg;..\thirdparty\openjpeg\src\lib\openjp2;..\thirdparty\zlib;..\thirdparty\freetype\include" PreprocessorDefinitions="MEMENTO=1;DEBUG=1" MinimalRebuild="true" BasicRuntimeChecks="3" diff --git a/win32/libthirdparty.vcproj b/win32/libthirdparty.vcproj index f38fefeb..32576cfe 100644 --- a/win32/libthirdparty.vcproj +++ b/win32/libthirdparty.vcproj @@ -441,98 +441,218 @@ <Filter Name="libopenjpeg" > - <File - RelativePath="..\thirdparty\openjpeg\libopenjpeg\bio.c" - > - </File> - <File - RelativePath="..\thirdparty\openjpeg\libopenjpeg\cidx_manager.c" - > - </File> - <File - RelativePath="..\thirdparty\openjpeg\libopenjpeg\cio.c" - > - </File> - <File - RelativePath="..\thirdparty\openjpeg\libopenjpeg\dwt.c" - > - </File> - <File - RelativePath="..\thirdparty\openjpeg\libopenjpeg\event.c" - > - </File> - <File - RelativePath="..\thirdparty\openjpeg\libopenjpeg\image.c" - > - </File> - <File - RelativePath="..\thirdparty\openjpeg\libopenjpeg\j2k.c" - > - </File> - <File - RelativePath="..\thirdparty\openjpeg\libopenjpeg\j2k_lib.c" - > - </File> - <File - RelativePath="..\thirdparty\openjpeg\libopenjpeg\jp2.c" - > - </File> - <File - RelativePath="..\thirdparty\openjpeg\libopenjpeg\jpt.c" - > - </File> - <File - RelativePath="..\thirdparty\openjpeg\libopenjpeg\mct.c" - > - </File> - <File - RelativePath="..\thirdparty\openjpeg\libopenjpeg\mqc.c" - > - </File> - <File - RelativePath="..\thirdparty\openjpeg\libopenjpeg\openjpeg.c" - > - </File> - <File - RelativePath="..\thirdparty\openjpeg\libopenjpeg\phix_manager.c" - > - </File> - <File - RelativePath="..\thirdparty\openjpeg\libopenjpeg\pi.c" - > - </File> - <File - RelativePath="..\thirdparty\openjpeg\libopenjpeg\ppix_manager.c" - > - </File> - <File - RelativePath="..\thirdparty\openjpeg\libopenjpeg\raw.c" - > - </File> - <File - RelativePath="..\thirdparty\openjpeg\libopenjpeg\t1.c" - > - </File> - <File - RelativePath="..\thirdparty\openjpeg\libopenjpeg\t2.c" - > - </File> - <File - RelativePath="..\thirdparty\openjpeg\libopenjpeg\tcd.c" - > - </File> - <File - RelativePath="..\thirdparty\openjpeg\libopenjpeg\tgt.c" - > - </File> - <File - RelativePath="..\thirdparty\openjpeg\libopenjpeg\thix_manager.c" - > - </File> - <File - RelativePath="..\thirdparty\openjpeg\libopenjpeg\tpix_manager.c" + <Filter + Name="openjp2" > - </File> + <File + RelativePath="..\thirdparty\openjpeg\src\lib\openjp2\bio.c" + > + </File> + <File + RelativePath="..\thirdparty\openjpeg\src\lib\openjp2\bio.h" + > + </File> + <File + RelativePath="..\thirdparty\openjpeg\src\lib\openjp2\cidx_manager.c" + > + </File> + <File + RelativePath="..\thirdparty\openjpeg\src\lib\openjp2\cidx_manager.h" + > + </File> + <File + RelativePath="..\thirdparty\openjpeg\src\lib\openjp2\cio.c" + > + </File> + <File + RelativePath="..\thirdparty\openjpeg\src\lib\openjp2\cio.h" + > + </File> + <File + RelativePath="..\thirdparty\openjpeg\src\lib\openjp2\dwt.c" + > + </File> + <File + RelativePath="..\thirdparty\openjpeg\src\lib\openjp2\dwt.h" + > + </File> + <File + RelativePath="..\thirdparty\openjpeg\src\lib\openjp2\event.c" + > + </File> + <File + RelativePath="..\thirdparty\openjpeg\src\lib\openjp2\event.h" + > + </File> + <File + RelativePath="..\thirdparty\openjpeg\src\lib\openjp2\function_list.c" + > + </File> + <File + RelativePath="..\thirdparty\openjpeg\src\lib\openjp2\function_list.h" + > + </File> + <File + RelativePath="..\thirdparty\openjpeg\src\lib\openjp2\image.c" + > + </File> + <File + RelativePath="..\thirdparty\openjpeg\src\lib\openjp2\image.h" + > + </File> + <File + RelativePath="..\thirdparty\openjpeg\src\lib\openjp2\indexbox_manager.h" + > + </File> + <File + RelativePath="..\thirdparty\openjpeg\src\lib\openjp2\invert.c" + > + </File> + <File + RelativePath="..\thirdparty\openjpeg\src\lib\openjp2\invert.h" + > + </File> + <File + RelativePath="..\thirdparty\openjpeg\src\lib\openjp2\j2k.c" + > + </File> + <File + RelativePath="..\thirdparty\openjpeg\src\lib\openjp2\j2k.h" + > + </File> + <File + RelativePath="..\thirdparty\openjpeg\src\lib\openjp2\jp2.c" + > + </File> + <File + RelativePath="..\thirdparty\openjpeg\src\lib\openjp2\jp2.h" + > + </File> + <File + RelativePath="..\thirdparty\openjpeg\src\lib\openjp2\mct.c" + > + </File> + <File + RelativePath="..\thirdparty\openjpeg\src\lib\openjp2\mct.h" + > + </File> + <File + RelativePath="..\thirdparty\openjpeg\src\lib\openjp2\mqc.c" + > + </File> + <File + RelativePath="..\thirdparty\openjpeg\src\lib\openjp2\mqc.h" + > + </File> + <File + RelativePath="..\thirdparty\openjpeg\src\lib\openjp2\openjpeg.c" + > + </File> + <File + RelativePath="..\thirdparty\openjpeg\src\lib\openjp2\openjpeg.h" + > + </File> + <File + RelativePath="..\thirdparty\openjpeg\src\lib\openjp2\opj_clock.c" + > + </File> + <File + RelativePath="..\thirdparty\openjpeg\src\lib\openjp2\opj_clock.h" + > + </File> + <File + RelativePath="..\thirdparty\openjpeg\src\lib\openjp2\opj_includes.h" + > + </File> + <File + RelativePath="..\thirdparty\openjpeg\src\lib\openjp2\opj_intmath.h" + > + </File> + <File + RelativePath="..\thirdparty\openjpeg\src\lib\openjp2\opj_inttypes.h" + > + </File> + <File + RelativePath="..\thirdparty\openjpeg\src\lib\openjp2\opj_malloc.h" + > + </File> + <File + RelativePath="..\thirdparty\openjpeg\src\lib\openjp2\opj_stdint.h" + > + </File> + <File + RelativePath="..\thirdparty\openjpeg\src\lib\openjp2\phix_manager.c" + > + </File> + <File + RelativePath="..\thirdparty\openjpeg\src\lib\openjp2\pi.c" + > + </File> + <File + RelativePath="..\thirdparty\openjpeg\src\lib\openjp2\pi.h" + > + </File> + <File + RelativePath="..\thirdparty\openjpeg\src\lib\openjp2\ppix_manager.c" + > + </File> + <File + RelativePath="..\thirdparty\openjpeg\src\lib\openjp2\raw.c" + > + </File> + <File + RelativePath="..\thirdparty\openjpeg\src\lib\openjp2\raw.h" + > + </File> + <File + RelativePath="..\thirdparty\openjpeg\src\lib\openjp2\t1.c" + > + </File> + <File + RelativePath="..\thirdparty\openjpeg\src\lib\openjp2\t1.h" + > + </File> + <File + RelativePath="..\thirdparty\openjpeg\src\lib\openjp2\t1_generate_luts.c" + > + </File> + <File + RelativePath="..\thirdparty\openjpeg\src\lib\openjp2\t1_luts.h" + > + </File> + <File + RelativePath="..\thirdparty\openjpeg\src\lib\openjp2\t2.c" + > + </File> + <File + RelativePath="..\thirdparty\openjpeg\src\lib\openjp2\t2.h" + > + </File> + <File + RelativePath="..\thirdparty\openjpeg\src\lib\openjp2\tcd.c" + > + </File> + <File + RelativePath="..\thirdparty\openjpeg\src\lib\openjp2\tcd.h" + > + </File> + <File + RelativePath="..\thirdparty\openjpeg\src\lib\openjp2\tgt.c" + > + </File> + <File + RelativePath="..\thirdparty\openjpeg\src\lib\openjp2\tgt.h" + > + </File> + <File + RelativePath="..\thirdparty\openjpeg\src\lib\openjp2\thix_manager.c" + > + </File> + <File + RelativePath="..\thirdparty\openjpeg\src\lib\openjp2\tpix_manager.c" + > + </File> + </Filter> </Filter> <Filter Name="libfreetype" |