diff options
author | Robin Watts <robin.watts@artifex.com> | 2012-03-12 14:13:48 +0000 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2012-03-12 14:13:48 +0000 |
commit | bc9e8f1d6c18b8b37678a07e9266f269fe5bf0dc (patch) | |
tree | 73be383b57ee4726f2a272ddeb9f6e895390aff2 | |
parent | 3db3054ec8223b6bd01d8d8144b4863c9ca8fd2d (diff) | |
parent | caf8e7a6c7cfeb245cdb5ac44d310a82ab0155b3 (diff) | |
download | mupdf-bc9e8f1d6c18b8b37678a07e9266f269fe5bf0dc.tar.xz |
Merge branch 'master' into header-split
-rw-r--r-- | Makethird | 5 | ||||
-rw-r--r-- | apps/mudraw.c | 14 | ||||
-rw-r--r-- | draw/draw_device.c | 3 | ||||
-rw-r--r-- | draw/draw_scale.c | 10 | ||||
-rw-r--r-- | fitz/base_string.c | 5 | ||||
-rw-r--r-- | fitz/fitz.h | 12 | ||||
-rw-r--r-- | pdf/pdf_function.c | 29 | ||||
-rw-r--r-- | win32/libmupdf.vcproj | 6 | ||||
-rw-r--r-- | win32/libthirdparty.vcproj | 62 |
9 files changed, 92 insertions, 54 deletions
@@ -157,6 +157,7 @@ OPENJPEG_LIB := $(OUT)/libopenjpeg.a OPENJPEG_SRC := \ bio.c \ cio.c \ + cidx_manager.c \ dwt.c \ event.c \ image.c \ @@ -167,12 +168,16 @@ OPENJPEG_SRC := \ mct.c \ mqc.c \ openjpeg.c \ + phix_manager.c \ pi.c \ + ppix_manager.c \ raw.c \ t1.c \ t2.c \ tcd.c \ tgt.c \ + thix_manager.c \ + tpix_manager.c \ $(OPENJPEG_LIB): $(addprefix $(OUT)/opj_, $(OPENJPEG_SRC:%.c=%.o)) $(OUT)/opj_%.o: $(OPENJPEG_DIR)/%.c | $(OUT) diff --git a/apps/mudraw.c b/apps/mudraw.c index 51a48539..cf60bbcf 100644 --- a/apps/mudraw.c +++ b/apps/mudraw.c @@ -165,11 +165,17 @@ static void drawpage(fz_context *ctx, fz_document *doc, int pagenum) fz_run_page(doc, page, dev, fz_identity, NULL); fz_free_device(dev); dev = NULL; - printf("[Page %d]\n", pagenum); if (showtext > 1) + { + printf("<page number=\"%d\">\n", pagenum); fz_debug_text_span_xml(text); + printf("</page>\n"); + } else + { + printf("[Page %d]\n", pagenum); fz_debug_text_span(text); + } printf("\n"); } fz_catch(ctx) @@ -421,7 +427,7 @@ int main(int argc, char **argv) timing.minpage = 0; timing.maxpage = 0; - if (showxml) + if (showxml || showtext > 1) printf("<?xml version=\"1.0\"?>\n"); fz_try(ctx) @@ -443,7 +449,7 @@ int main(int argc, char **argv) if (!fz_authenticate_password(doc, password)) fz_throw(ctx, "cannot authenticate password: %s", filename); - if (showxml) + if (showxml || showtext > 1) printf("<document name=\"%s\">\n", filename); if (showoutline) @@ -457,7 +463,7 @@ int main(int argc, char **argv) drawrange(ctx, doc, argv[fz_optind++]); } - if (showxml) + if (showxml || showtext > 1) printf("</document>\n"); fz_close_document(doc); diff --git a/draw/draw_device.c b/draw/draw_device.c index ab9d18e1..de81ccec 100644 --- a/draw/draw_device.c +++ b/draw/draw_device.c @@ -1582,9 +1582,6 @@ fz_draw_free_user(fz_device *devp) state--; } while(--dev->top > 0); - fz_drop_pixmap(ctx, dev->stack[0].mask); - fz_drop_pixmap(ctx, dev->stack[0].dest); - fz_drop_pixmap(ctx, dev->stack[0].shape); } if (dev->stack != &dev->init_stack[0]) fz_free(ctx, dev->stack); diff --git a/draw/draw_scale.c b/draw/draw_scale.c index fb7caffd..aceec939 100644 --- a/draw/draw_scale.c +++ b/draw/draw_scale.c @@ -349,16 +349,8 @@ add_weight(fz_weights *weights, int j, int i, fz_scale_filter *filter, weight = (int)(256*f+0.5f); /* Ensure i is in range */ - if (i < 0) - { - i = 0; + if (i < 0 || i >= src_w) return; - } - else if (i >= src_w) - { - i = src_w-1; - return; - } if (weight == 0) { /* We add a fudge factor here to allow for extreme downscales diff --git a/fitz/base_string.c b/fitz/base_string.c index 7587f96b..8ed08911 100644 --- a/fitz/base_string.c +++ b/fitz/base_string.c @@ -248,10 +248,11 @@ float fz_atof(const char *s) * as we convert to a float. */ errno = 0; d = strtod(s, NULL); - if (errno == ERANGE || d > FLT_MAX || d < -FLT_MAX) { + if (errno == ERANGE || isnan(d)) { /* Return 1.0, as it's a small known value that won't cause a - * divide by 0. */ + divide by 0. */ return 1.0; } + d = CLAMP(d, -FLT_MAX, FLT_MAX); return (float)d; } diff --git a/fitz/fitz.h b/fitz/fitz.h index 849b07a8..03cb6f25 100644 --- a/fitz/fitz.h +++ b/fitz/fitz.h @@ -15,7 +15,7 @@ #include <assert.h> #include <errno.h> #include <limits.h> /* INT_MAX & co */ -#include <float.h> /* FLT_EPSILON */ +#include <float.h> /* FLT_EPSILON, FLT_MAX & co */ #include <fcntl.h> /* O_RDONLY & co */ #include <setjmp.h> @@ -46,6 +46,7 @@ #define MIN(a,b) ( (a) < (b) ? (a) : (b) ) #define MAX(a,b) ( (a) > (b) ? (a) : (b) ) #define CLAMP(x,a,b) ( (x) > (b) ? (b) : ( (x) < (a) ? (a) : (x) ) ) +#define DIV_BY_ZERO(a, b, min, max) (((a) < 0) ^ ((b) < 0) ? (min) : (max)) /* Some differences in libc can be smoothed over @@ -62,6 +63,7 @@ int gettimeofday(struct timeval *tv, struct timezone *tz); #define snprintf _snprintf +#define isnan _isnan #else /* Unix or close enough */ @@ -640,7 +642,7 @@ extern const fz_bbox fz_infinite_bbox; An empty rectangle is defined as one whose area is zero. */ -#define fz_is_empty_rect(r) ((r).x0 == (r).x1) +#define fz_is_empty_rect(r) ((r).x0 == (r).x1 || (r).y0 == (r).y1) /* fz_is_empty_bbox: Check if bounding box is empty. @@ -648,7 +650,7 @@ extern const fz_bbox fz_infinite_bbox; Same definition of empty bounding boxes as for empty rectangles. See fz_is_empty_rect. */ -#define fz_is_empty_bbox(b) ((b).x0 == (b).x1) +#define fz_is_empty_bbox(b) ((b).x0 == (b).x1 || (b).y0 == (b).y1) /* fz_is_infinite: Check if rectangle is infinite. @@ -656,7 +658,7 @@ extern const fz_bbox fz_infinite_bbox; An infinite rectangle is defined as one where either of the two relationships between corner coordinates are not true. */ -#define fz_is_infinite_rect(r) ((r).x0 > (r).x1) +#define fz_is_infinite_rect(r) ((r).x0 > (r).x1 || (r).y0 > (r).y1) /* fz_is_infinite_bbox: Check if bounding box is infinite. @@ -664,7 +666,7 @@ extern const fz_bbox fz_infinite_bbox; Same definition of infinite bounding boxes as for infinite rectangles. See fz_is_infinite_rect. */ -#define fz_is_infinite_bbox(b) ((b).x0 > (b).x1) +#define fz_is_infinite_bbox(b) ((b).x0 > (b).x1 || (b).y0 > (b).y1) /* fz_matrix is a a row-major 3x3 matrix used for representing diff --git a/pdf/pdf_function.c b/pdf/pdf_function.c index 159515c1..e1c53beb 100644 --- a/pdf/pdf_function.c +++ b/pdf/pdf_function.c @@ -203,7 +203,13 @@ ps_push_real(ps_stack *st, float n) if (!ps_overflow(st, 1)) { st->stack[st->sp].type = PS_REAL; - st->stack[st->sp].u.f = n; + if (isnan(n)) + { + /* Push 1.0, as it's a small known value that won't + cause a divide by 0. Same reason as in fz_atof. */ + n = 1.0; + } + st->stack[st->sp].u.f = CLAMP(n, -FLT_MAX, FLT_MAX); st->sp++; } } @@ -360,10 +366,10 @@ ps_run(fz_context *ctx, psobj *code, ps_stack *st, int pc) case PS_OP_BITSHIFT: i2 = ps_pop_int(st); i1 = ps_pop_int(st); - if (i2 > 0) + if (i2 > 0 && i2 < 8 * sizeof (i2)) ps_push_int(st, i1 << i2); - else if (i2 < 0) - ps_push_int(st, (int)((unsigned int)i1 >> i2)); + else if (i2 < 0 && i2 > -8 * (int)sizeof (i2)) + ps_push_int(st, (int)((unsigned int)i1 >> -i2)); else ps_push_int(st, i1); break; @@ -393,7 +399,10 @@ ps_run(fz_context *ctx, psobj *code, ps_stack *st, int pc) case PS_OP_DIV: r2 = ps_pop_real(st); r1 = ps_pop_real(st); - ps_push_real(st, r1 / r2); + if (fabsf(r2) < FLT_EPSILON) + ps_push_real(st, r1 / r2); + else + ps_push_real(st, DIV_BY_ZERO(r1, r2, -FLT_MAX, FLT_MAX)); break; case PS_OP_DUP: @@ -466,7 +475,10 @@ ps_run(fz_context *ctx, psobj *code, ps_stack *st, int pc) case PS_OP_IDIV: i2 = ps_pop_int(st); i1 = ps_pop_int(st); - ps_push_int(st, i1 / i2); + if (i2 != 0) + ps_push_int(st, i1 / i2); + else + ps_push_int(st, DIV_BY_ZERO(i1, i2, INT_MIN, INT_MAX)); break; case PS_OP_INDEX: @@ -512,7 +524,10 @@ ps_run(fz_context *ctx, psobj *code, ps_stack *st, int pc) case PS_OP_MOD: i2 = ps_pop_int(st); i1 = ps_pop_int(st); - ps_push_int(st, i1 % i2); + if (i2 != 0) + ps_push_int(st, i1 % i2); + else + ps_push_int(st, DIV_BY_ZERO(i1, i2, INT_MIN, INT_MAX)); break; case PS_OP_MUL: diff --git a/win32/libmupdf.vcproj b/win32/libmupdf.vcproj index de66ac7a..543cac48 100644 --- a/win32/libmupdf.vcproj +++ b/win32/libmupdf.vcproj @@ -41,7 +41,7 @@ <Tool Name="VCCLCompilerTool" Optimization="0" - AdditionalIncludeDirectories="..\scripts;..\fitz;..\pdf;..\thirdparty\jbig2dec;..\thirdparty\jpeg-8d;..\thirdparty\openjpeg-1.4\libopenjpeg;..\thirdparty\zlib-1.2.5;..\thirdparty\freetype-2.4.8\include" + AdditionalIncludeDirectories="..\scripts;..\fitz;..\pdf;..\thirdparty\jbig2dec;..\thirdparty\jpeg-8d;..\thirdparty\openjpeg-1.5.0\libopenjpeg;..\thirdparty\zlib-1.2.5;..\thirdparty\freetype-2.4.8\include" PreprocessorDefinitions="DEBUG=1" MinimalRebuild="true" BasicRuntimeChecks="3" @@ -106,7 +106,7 @@ Name="VCCLCompilerTool" Optimization="2" EnableIntrinsicFunctions="true" - AdditionalIncludeDirectories="..\scripts;..\fitz;..\pdf;..\thirdparty\jbig2dec;..\thirdparty\jpeg-8d;..\thirdparty\openjpeg-1.4\libopenjpeg;..\thirdparty\zlib-1.2.5;..\thirdparty\freetype-2.4.8\include" + AdditionalIncludeDirectories="..\scripts;..\fitz;..\pdf;..\thirdparty\jbig2dec;..\thirdparty\jpeg-8d;..\thirdparty\openjpeg-1.5.0\libopenjpeg;..\thirdparty\zlib-1.2.5;..\thirdparty\freetype-2.4.8\include" RuntimeLibrary="0" EnableFunctionLevelLinking="true" WarningLevel="3" @@ -166,7 +166,7 @@ <Tool Name="VCCLCompilerTool" Optimization="0" - AdditionalIncludeDirectories="..\scripts;..\fitz;..\pdf;..\thirdparty\jbig2dec;..\thirdparty\jpeg-8d;..\thirdparty\openjpeg-1.4\libopenjpeg;..\thirdparty\zlib-1.2.5;..\thirdparty\freetype-2.4.8\include" + AdditionalIncludeDirectories="..\scripts;..\fitz;..\pdf;..\thirdparty\jbig2dec;..\thirdparty\jpeg-8d;..\thirdparty\openjpeg-1.5.0\libopenjpeg;..\thirdparty\zlib-1.2.5;..\thirdparty\freetype-2.4.8\include" PreprocessorDefinitions="MEMENTO=1;DEBUG=1" MinimalRebuild="true" BasicRuntimeChecks="3" diff --git a/win32/libthirdparty.vcproj b/win32/libthirdparty.vcproj index 18c08942..e5419564 100644 --- a/win32/libthirdparty.vcproj +++ b/win32/libthirdparty.vcproj @@ -39,7 +39,7 @@ <Tool Name="VCCLCompilerTool" Optimization="0" - AdditionalIncludeDirectories="..\scripts;..\thirdparty\jbig2dec;..\thirdparty\jpeg-8d;..\thirdparty\openjpeg-1.4\libopenjpeg;..\thirdparty\zlib-1.2.5;..\thirdparty\freetype-2.4.8\include" + AdditionalIncludeDirectories="..\scripts;..\thirdparty\jbig2dec;..\thirdparty\jpeg-8d;..\thirdparty\openjpeg-1.5.0\libopenjpeg;..\thirdparty\zlib-1.2.5;..\thirdparty\freetype-2.4.8\include" PreprocessorDefinitions="_CRT_SECURE_NO_WARNINGS;FT2_BUILD_LIBRARY;OPJ_STATIC;FT_CONFIG_MODULES_H=\"slimftmodules.h\";FT_CONFIG_OPTIONS_H=\"slimftoptions.h\";DEBUG=1" MinimalRebuild="true" BasicRuntimeChecks="3" @@ -102,7 +102,7 @@ Name="VCCLCompilerTool" Optimization="2" EnableIntrinsicFunctions="true" - AdditionalIncludeDirectories="..\scripts;..\thirdparty\jbig2dec;..\thirdparty\jpeg-8d;..\thirdparty\openjpeg-1.4\libopenjpeg;..\thirdparty\zlib-1.2.5;..\thirdparty\freetype-2.4.8\include" + AdditionalIncludeDirectories="..\scripts;..\thirdparty\jbig2dec;..\thirdparty\jpeg-8d;..\thirdparty\openjpeg-1.5.0\libopenjpeg;..\thirdparty\zlib-1.2.5;..\thirdparty\freetype-2.4.8\include" PreprocessorDefinitions="_CRT_SECURE_NO_WARNINGS;FT2_BUILD_LIBRARY;OPJ_STATIC;FT_CONFIG_MODULES_H=\"slimftmodules.h\";FT_CONFIG_OPTIONS_H=\"slimftoptions.h\"" RuntimeLibrary="0" EnableFunctionLevelLinking="true" @@ -162,7 +162,7 @@ <Tool Name="VCCLCompilerTool" Optimization="0" - AdditionalIncludeDirectories="..\scripts;..\thirdparty\jbig2dec;..\thirdparty\jpeg-8d;..\thirdparty\openjpeg-1.4\libopenjpeg;..\thirdparty\zlib-1.2.5;..\thirdparty\freetype-2.4.8\include" + AdditionalIncludeDirectories="..\scripts;..\thirdparty\jbig2dec;..\thirdparty\jpeg-8d;..\thirdparty\openjpeg-1.5.0\libopenjpeg;..\thirdparty\zlib-1.2.5;..\thirdparty\freetype-2.4.8\include" PreprocessorDefinitions="_CRT_SECURE_NO_WARNINGS;FT2_BUILD_LIBRARY;OPJ_STATIC;FT_CONFIG_MODULES_H=\"slimftmodules.h\";FT_CONFIG_OPTIONS_H=\"slimftoptions.h\";MEMENTO=1;DEBUG=1" MinimalRebuild="true" BasicRuntimeChecks="3" @@ -442,75 +442,95 @@ Name="libopenjpeg" > <File - RelativePath="..\thirdparty\openjpeg-1.4\libopenjpeg\bio.c" + RelativePath="..\thirdparty\openjpeg-1.5.0\libopenjpeg\bio.c" > </File> <File - RelativePath="..\thirdparty\openjpeg-1.4\libopenjpeg\cio.c" + RelativePath="..\thirdparty\openjpeg-1.5.0\libopenjpeg\cidx_manager.c" > </File> <File - RelativePath="..\thirdparty\openjpeg-1.4\libopenjpeg\dwt.c" + RelativePath="..\thirdparty\openjpeg-1.5.0\libopenjpeg\cio.c" > </File> <File - RelativePath="..\thirdparty\openjpeg-1.4\libopenjpeg\event.c" + RelativePath="..\thirdparty\openjpeg-1.5.0\libopenjpeg\dwt.c" > </File> <File - RelativePath="..\thirdparty\openjpeg-1.4\libopenjpeg\image.c" + RelativePath="..\thirdparty\openjpeg-1.5.0\libopenjpeg\event.c" > </File> <File - RelativePath="..\thirdparty\openjpeg-1.4\libopenjpeg\j2k.c" + RelativePath="..\thirdparty\openjpeg-1.5.0\libopenjpeg\image.c" > </File> <File - RelativePath="..\thirdparty\openjpeg-1.4\libopenjpeg\j2k_lib.c" + RelativePath="..\thirdparty\openjpeg-1.5.0\libopenjpeg\j2k.c" > </File> <File - RelativePath="..\thirdparty\openjpeg-1.4\libopenjpeg\jp2.c" + RelativePath="..\thirdparty\openjpeg-1.5.0\libopenjpeg\j2k_lib.c" > </File> <File - RelativePath="..\thirdparty\openjpeg-1.4\libopenjpeg\jpt.c" + RelativePath="..\thirdparty\openjpeg-1.5.0\libopenjpeg\jp2.c" > </File> <File - RelativePath="..\thirdparty\openjpeg-1.4\libopenjpeg\mct.c" + RelativePath="..\thirdparty\openjpeg-1.5.0\libopenjpeg\jpt.c" > </File> <File - RelativePath="..\thirdparty\openjpeg-1.4\libopenjpeg\mqc.c" + RelativePath="..\thirdparty\openjpeg-1.5.0\libopenjpeg\mct.c" > </File> <File - RelativePath="..\thirdparty\openjpeg-1.4\libopenjpeg\openjpeg.c" + RelativePath="..\thirdparty\openjpeg-1.5.0\libopenjpeg\mqc.c" > </File> <File - RelativePath="..\thirdparty\openjpeg-1.4\libopenjpeg\pi.c" + RelativePath="..\thirdparty\openjpeg-1.5.0\libopenjpeg\openjpeg.c" > </File> <File - RelativePath="..\thirdparty\openjpeg-1.4\libopenjpeg\raw.c" + RelativePath="..\thirdparty\openjpeg-1.5.0\libopenjpeg\phix_manager.c" > </File> <File - RelativePath="..\thirdparty\openjpeg-1.4\libopenjpeg\t1.c" + RelativePath="..\thirdparty\openjpeg-1.5.0\libopenjpeg\pi.c" > </File> <File - RelativePath="..\thirdparty\openjpeg-1.4\libopenjpeg\t2.c" + RelativePath="..\thirdparty\openjpeg-1.5.0\libopenjpeg\ppix_manager.c" > </File> <File - RelativePath="..\thirdparty\openjpeg-1.4\libopenjpeg\tcd.c" + RelativePath="..\thirdparty\openjpeg-1.5.0\libopenjpeg\raw.c" > </File> <File - RelativePath="..\thirdparty\openjpeg-1.4\libopenjpeg\tgt.c" + RelativePath="..\thirdparty\openjpeg-1.5.0\libopenjpeg\t1.c" + > + </File> + <File + RelativePath="..\thirdparty\openjpeg-1.5.0\libopenjpeg\t2.c" + > + </File> + <File + RelativePath="..\thirdparty\openjpeg-1.5.0\libopenjpeg\tcd.c" + > + </File> + <File + RelativePath="..\thirdparty\openjpeg-1.5.0\libopenjpeg\tgt.c" + > + </File> + <File + RelativePath="..\thirdparty\openjpeg-1.5.0\libopenjpeg\thix_manager.c" + > + </File> + <File + RelativePath="..\thirdparty\openjpeg-1.5.0\libopenjpeg\tpix_manager.c" > </File> </Filter> |