ref: 70c7f1967f43a94f9f0d6808d6ab5700a120d2fc
parent: 3837ea918bcb27bc70af71d5a5323187d51a309c
author: Chris Liddell <[email protected]>
date: Fri Apr 17 08:19:26 EDT 2015
Bug 695890: Update jbig2dec for modern libpng libpng 1.5.x and newer hide the internals, and only allow values to be set and retrieved via define API calls. Also tidy up a couple of (benign) compiler warnings. No cluster diffs.
--- a/jbig2_arith.c
+++ b/jbig2_arith.c
@@ -422,9 +422,14 @@
for (i = 0; i < 256; i++)
{
- bool D;
+#ifdef JBIG2_DEBUG_ARITH
+ bool D =
+#else
+ (void)
+#endif
- D = jbig2_arith_decode (as, &cx);
+ jbig2_arith_decode (as, &cx);
+
#ifdef JBIG2_DEBUG_ARITH
fprintf(stderr, "%3d: D = %d, ", i, D);
jbig2_arith_trace (as, cx);
--- a/jbig2_image_pbm.c
+++ b/jbig2_image_pbm.c
@@ -145,7 +145,7 @@
}
/* the pbm data is byte-aligned, so we can
do a simple block read */
- fread(image->data, 1, image->height*image->stride, in);
+ (void)fread(image->data, 1, image->height*image->stride, in);
if (feof(in)) {
fprintf(stderr, "unexpected end of pbm file.\n");
jbig2_image_release(ctx, image);
--- a/jbig2_image_png.c
+++ b/jbig2_image_png.c
@@ -26,7 +26,11 @@
#include <stdio.h>
#include <stdlib.h>
#include <png.h>
+
+#if PNG_LIBPNG_VER_MAJOR == 1 && PNG_LIBPNG_VER_MINOR < 5
#include <pngstruct.h>
+#endif
+
#define CVT_PTR(ptr) (ptr)
#include "jbig2.h"
@@ -39,8 +43,13 @@
jbig2_png_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
{
png_size_t check;
+#if PNG_LIBPNG_VER_MAJOR == 1 && PNG_LIBPNG_VER_MINOR < 5
+ png_FILE_p f = (png_FILE_p)png_ptr->io_ptr;
+#else
+ png_FILE_p f = (png_FILE_p)png_get_io_ptr(png_ptr);
+#endif
- check = fwrite(data, 1, length, (png_FILE_p)png_ptr->io_ptr);
+ check = fwrite(data, 1, length, f);
if (check != length) {
png_error(png_ptr, "Write Error");
}
@@ -49,10 +58,14 @@
static void
jbig2_png_flush(png_structp png_ptr)
{
- png_FILE_p io_ptr;
- io_ptr = (png_FILE_p)CVT_PTR((png_ptr->io_ptr));
- if (io_ptr != NULL)
- fflush(io_ptr);
+#if PNG_LIBPNG_VER_MAJOR == 1 && PNG_LIBPNG_VER_MINOR < 5
+ png_FILE_p f = (png_FILE_p)png_ptr->io_ptr;
+#else
+ png_FILE_p f = (png_FILE_p)png_get_io_ptr(png_ptr);
+#endif
+
+ if (f != NULL)
+ fflush(f);
}
int jbig2_image_write_png_file(Jbig2Image *image, char *filename)
--- a/jbig2_refinement.c
+++ b/jbig2_refinement.c
@@ -38,6 +38,7 @@
#include "jbig2_generic.h"
#include "jbig2_image.h"
+#if 0 /* currently not used */
static int
jbig2_decode_refinement_template0(Jbig2Ctx *ctx,
Jbig2Segment *segment,
@@ -49,6 +50,7 @@
return jbig2_error(ctx, JBIG2_SEVERITY_FATAL, segment->number,
"refinement region template 0 NYI");
}
+#endif
static int
jbig2_decode_refinement_template0_unopt(Jbig2Ctx *ctx,
@@ -159,6 +161,7 @@
return 0;
}
+#if 0 /* currently not used */
static int
jbig2_decode_refinement_template1(Jbig2Ctx *ctx,
Jbig2Segment *segment,
@@ -241,6 +244,7 @@
return 0;
}
+#endif
typedef uint32_t (*ContextBuilder)(const Jbig2RefinementRegionParams *,
--- a/jbig2_text.c
+++ b/jbig2_text.c
@@ -412,6 +412,7 @@
case JBIG2_CORNER_TOPLEFT: x = S; y = T; break;
case JBIG2_CORNER_TOPRIGHT: x = S - IB->width + 1; y = T; break;
case JBIG2_CORNER_BOTTOMLEFT: x = S; y = T - IB->height + 1; break;
+ default:
case JBIG2_CORNER_BOTTOMRIGHT: x = S - IB->width + 1; y = T - IB->height + 1; break;
}
} else { /* TRANSPOSED */
@@ -419,6 +420,7 @@
case JBIG2_CORNER_TOPLEFT: x = T; y = S; break;
case JBIG2_CORNER_TOPRIGHT: x = T - IB->width + 1; y = S; break;
case JBIG2_CORNER_BOTTOMLEFT: x = T; y = S - IB->height + 1; break;
+ default:
case JBIG2_CORNER_BOTTOMRIGHT: x = T - IB->width + 1; y = S - IB->height + 1; break;
}
}