Update to 1.74.3

This commit is contained in:
Sandro Mani 2017-06-11 22:18:48 +02:00
parent 3b96caea14
commit 2d6007434f
4 changed files with 7 additions and 538 deletions

1
.gitignore vendored
View File

@ -5,3 +5,4 @@
/leptonica-1.74.0.tar.gz
/leptonica-1.74.1.tar.gz
/leptonica-1.74.2.tar.gz
/leptonica-1.74.3.tar.gz

View File

@ -1,533 +0,0 @@
diff -rupN leptonica-1.74.2/src/boxbasic.c leptonica-1.74.2-new/src/boxbasic.c
--- leptonica-1.74.2/src/boxbasic.c 2017-05-20 03:30:27.000000000 +0200
+++ leptonica-1.74.2-new/src/boxbasic.c 2017-06-03 08:19:42.489198160 +0200
@@ -1875,15 +1875,13 @@ BOXAA *baa;
if (!filename)
return (BOXAA *)ERROR_PTR("filename not defined", procName, NULL);
+
if ((fp = fopenReadStream(filename)) == NULL)
return (BOXAA *)ERROR_PTR("stream not opened", procName, NULL);
-
- if ((baa = boxaaReadStream(fp)) == NULL) {
- fclose(fp);
- return (BOXAA *)ERROR_PTR("boxaa not read", procName, NULL);
- }
-
+ baa = boxaaReadStream(fp);
fclose(fp);
+ if (!baa)
+ return (BOXAA *)ERROR_PTR("boxaa not read", procName, NULL);
return baa;
}
@@ -2102,15 +2100,13 @@ BOXA *boxa;
if (!filename)
return (BOXA *)ERROR_PTR("filename not defined", procName, NULL);
+
if ((fp = fopenReadStream(filename)) == NULL)
return (BOXA *)ERROR_PTR("stream not opened", procName, NULL);
-
- if ((boxa = boxaReadStream(fp)) == NULL) {
- fclose(fp);
- return (BOXA *)ERROR_PTR("boxa not read", procName, NULL);
- }
-
+ boxa = boxaReadStream(fp);
fclose(fp);
+ if (!boxa)
+ return (BOXA *)ERROR_PTR("boxa not read", procName, NULL);
return boxa;
}
diff -rupN leptonica-1.74.2/src/colormap.c leptonica-1.74.2-new/src/colormap.c
--- leptonica-1.74.2/src/colormap.c 2017-05-20 03:30:27.000000000 +0200
+++ leptonica-1.74.2-new/src/colormap.c 2017-06-03 08:19:42.490198085 +0200
@@ -1599,15 +1599,13 @@ PIXCMAP *cmap;
if (!filename)
return (PIXCMAP *)ERROR_PTR("filename not defined", procName, NULL);
+
if ((fp = fopenReadStream(filename)) == NULL)
return (PIXCMAP *)ERROR_PTR("stream not opened", procName, NULL);
-
- if ((cmap = pixcmapReadStream(fp)) == NULL) {
- fclose(fp);
- return (PIXCMAP *)ERROR_PTR("cmap not read", procName, NULL);
- }
-
+ cmap = pixcmapReadStream(fp);
fclose(fp);
+ if (!cmap)
+ return (PIXCMAP *)ERROR_PTR("cmap not read", procName, NULL);
return cmap;
}
diff -rupN leptonica-1.74.2/src/dnabasic.c leptonica-1.74.2-new/src/dnabasic.c
--- leptonica-1.74.2/src/dnabasic.c 2017-05-20 03:30:27.000000000 +0200
+++ leptonica-1.74.2-new/src/dnabasic.c 2017-06-03 08:19:42.491198011 +0200
@@ -989,13 +989,10 @@ L_DNA *da;
if ((fp = fopenReadStream(filename)) == NULL)
return (L_DNA *)ERROR_PTR("stream not opened", procName, NULL);
-
- if ((da = l_dnaReadStream(fp)) == NULL) {
- fclose(fp);
- return (L_DNA *)ERROR_PTR("da not read", procName, NULL);
- }
-
+ da = l_dnaReadStream(fp);
fclose(fp);
+ if (!da)
+ return (L_DNA *)ERROR_PTR("da not read", procName, NULL);
return da;
}
@@ -1553,13 +1550,10 @@ L_DNAA *daa;
if ((fp = fopenReadStream(filename)) == NULL)
return (L_DNAA *)ERROR_PTR("stream not opened", procName, NULL);
-
- if ((daa = l_dnaaReadStream(fp)) == NULL) {
- fclose(fp);
- return (L_DNAA *)ERROR_PTR("daa not read", procName, NULL);
- }
-
+ daa = l_dnaaReadStream(fp);
fclose(fp);
+ if (!daa)
+ return (L_DNAA *)ERROR_PTR("daa not read", procName, NULL);
return daa;
}
diff -rupN leptonica-1.74.2/src/fpix1.c leptonica-1.74.2-new/src/fpix1.c
--- leptonica-1.74.2/src/fpix1.c 2017-05-20 03:30:27.000000000 +0200
+++ leptonica-1.74.2-new/src/fpix1.c 2017-06-03 08:19:42.491198011 +0200
@@ -1705,15 +1705,13 @@ FPIX *fpix;
if (!filename)
return (FPIX *)ERROR_PTR("filename not defined", procName, NULL);
+
if ((fp = fopenReadStream(filename)) == NULL)
return (FPIX *)ERROR_PTR("stream not opened", procName, NULL);
-
- if ((fpix = fpixReadStream(fp)) == NULL) {
- fclose(fp);
- return (FPIX *)ERROR_PTR("fpix not read", procName, NULL);
- }
-
+ fpix = fpixReadStream(fp);
fclose(fp);
+ if (!fpix)
+ return (FPIX *)ERROR_PTR("fpix not read", procName, NULL);
return fpix;
}
@@ -2002,15 +2000,13 @@ DPIX *dpix;
if (!filename)
return (DPIX *)ERROR_PTR("filename not defined", procName, NULL);
+
if ((fp = fopenReadStream(filename)) == NULL)
return (DPIX *)ERROR_PTR("stream not opened", procName, NULL);
-
- if ((dpix = dpixReadStream(fp)) == NULL) {
- fclose(fp);
- return (DPIX *)ERROR_PTR("dpix not read", procName, NULL);
- }
-
+ dpix = dpixReadStream(fp);
fclose(fp);
+ if (!dpix)
+ return (DPIX *)ERROR_PTR("dpix not read", procName, NULL);
return dpix;
}
diff -rupN leptonica-1.74.2/src/gifio.c leptonica-1.74.2-new/src/gifio.c
--- leptonica-1.74.2/src/gifio.c 2017-05-20 03:30:27.000000000 +0200
+++ leptonica-1.74.2-new/src/gifio.c 2017-06-03 08:19:42.491198011 +0200
@@ -395,6 +395,7 @@ int giferr;
return ERROR_INT("failed to create GIF image handle", procName, 1);
}
+ pixSetPadBits(pix, 0);
result = pixToGif(pix, gif);
EGifCloseFile(gif, &giferr);
return result;
diff -rupN leptonica-1.74.2/src/jp2kio.c leptonica-1.74.2-new/src/jp2kio.c
--- leptonica-1.74.2/src/jp2kio.c 2017-05-20 03:30:27.000000000 +0200
+++ leptonica-1.74.2-new/src/jp2kio.c 2017-06-03 08:19:42.491198011 +0200
@@ -580,6 +580,7 @@ opj_image_t *image = NULL;
}
/* Convert to opj image format. */
+ pixSetPadBits(pixs, 0);
image = pixConvertToOpjImage(pixs);
pixDestroy(&pixs);
diff -rupN leptonica-1.74.2/src/jpegio.c leptonica-1.74.2-new/src/jpegio.c
--- leptonica-1.74.2/src/jpegio.c 2017-05-20 03:30:27.000000000 +0200
+++ leptonica-1.74.2-new/src/jpegio.c 2017-06-03 08:19:42.491198011 +0200
@@ -830,6 +830,7 @@ jmp_buf jmpbuf; /*
}
if (!pix)
return ERROR_INT("pix not made", procName, 1);
+ pixSetPadBits(pix, 0);
rewind(fp);
rowbuffer = NULL;
diff -rupN leptonica-1.74.2/src/numabasic.c leptonica-1.74.2-new/src/numabasic.c
--- leptonica-1.74.2/src/numabasic.c 2017-05-20 03:30:27.000000000 +0200
+++ leptonica-1.74.2-new/src/numabasic.c 2017-06-03 08:19:42.492197936 +0200
@@ -1091,13 +1091,10 @@ NUMA *na;
if ((fp = fopenReadStream(filename)) == NULL)
return (NUMA *)ERROR_PTR("stream not opened", procName, NULL);
-
- if ((na = numaReadStream(fp)) == NULL) {
- fclose(fp);
- return (NUMA *)ERROR_PTR("na not read", procName, NULL);
- }
-
+ na = numaReadStream(fp);
fclose(fp);
+ if (!na)
+ return (NUMA *)ERROR_PTR("na not read", procName, NULL);
return na;
}
@@ -1778,13 +1775,10 @@ NUMAA *naa;
if ((fp = fopenReadStream(filename)) == NULL)
return (NUMAA *)ERROR_PTR("stream not opened", procName, NULL);
-
- if ((naa = numaaReadStream(fp)) == NULL) {
- fclose(fp);
- return (NUMAA *)ERROR_PTR("naa not read", procName, NULL);
- }
-
+ naa = numaaReadStream(fp);
fclose(fp);
+ if (!naa)
+ return (NUMAA *)ERROR_PTR("naa not read", procName, NULL);
return naa;
}
diff -rupN leptonica-1.74.2/src/pix2.c leptonica-1.74.2-new/src/pix2.c
--- leptonica-1.74.2/src/pix2.c 2017-05-20 03:30:27.000000000 +0200
+++ leptonica-1.74.2-new/src/pix2.c 2017-06-03 08:19:42.492197936 +0200
@@ -1281,6 +1281,16 @@ l_uint32 *datas, *lines;
* (2) This sets the value of the pad bits (if any) in the last
* 32-bit word in each scanline.
* (3) For 32 bpp pix, there are no pad bits, so this is a no-op.
+ * (4) When writing formatted output, such as tiff, png or jpeg,
+ * the pad bits have no effect on the raster image that is
+ * generated by reading back from the file. However, in some
+ * cases, the compressed file itself will depend on the pad
+ * bits. This is seen, for example, in Windows with 2 and 4 bpp
+ * tiff-compressed images that have pad bits on each scanline.
+ * It is sometimes convenient to use a golden file with a
+ * byte-by-byte check to verify invariance. Consequently,
+ * and because setting the pad bits is cheap, the pad bits are
+ * set to 0 before writing these compressed files.
* </pre>
*/
l_int32
diff -rupN leptonica-1.74.2/src/pixabasic.c leptonica-1.74.2-new/src/pixabasic.c
--- leptonica-1.74.2/src/pixabasic.c 2017-05-20 03:30:27.000000000 +0200
+++ leptonica-1.74.2-new/src/pixabasic.c 2017-06-03 08:19:42.492197936 +0200
@@ -2402,15 +2402,13 @@ PIXA *pixa;
if (!filename)
return (PIXA *)ERROR_PTR("filename not defined", procName, NULL);
+
if ((fp = fopenReadStream(filename)) == NULL)
return (PIXA *)ERROR_PTR("stream not opened", procName, NULL);
-
- if ((pixa = pixaReadStream(fp)) == NULL) {
- fclose(fp);
- return (PIXA *)ERROR_PTR("pixa not read", procName, NULL);
- }
-
+ pixa = pixaReadStream(fp);
fclose(fp);
+ if (!pixa)
+ return (PIXA *)ERROR_PTR("pixa not read", procName, NULL);
return pixa;
}
@@ -2780,15 +2778,13 @@ PIXAA *paa;
if (!filename)
return (PIXAA *)ERROR_PTR("filename not defined", procName, NULL);
+
if ((fp = fopenReadStream(filename)) == NULL)
return (PIXAA *)ERROR_PTR("stream not opened", procName, NULL);
-
- if ((paa = pixaaReadStream(fp)) == NULL) {
- fclose(fp);
- return (PIXAA *)ERROR_PTR("paa not read", procName, NULL);
- }
-
+ paa = pixaaReadStream(fp);
fclose(fp);
+ if (!paa)
+ return (PIXAA *)ERROR_PTR("paa not read", procName, NULL);
return paa;
}
diff -rupN leptonica-1.74.2/src/pixcomp.c leptonica-1.74.2-new/src/pixcomp.c
--- leptonica-1.74.2/src/pixcomp.c 2017-05-20 03:30:27.000000000 +0200
+++ leptonica-1.74.2-new/src/pixcomp.c 2017-06-03 08:19:42.493197862 +0200
@@ -1601,15 +1601,13 @@ PIXAC *pixac;
if (!filename)
return (PIXAC *)ERROR_PTR("filename not defined", procName, NULL);
+
if ((fp = fopenReadStream(filename)) == NULL)
return (PIXAC *)ERROR_PTR("stream not opened", procName, NULL);
-
- if ((pixac = pixacompReadStream(fp)) == NULL) {
- fclose(fp);
- return (PIXAC *)ERROR_PTR("pixac not read", procName, NULL);
- }
-
+ pixac = pixacompReadStream(fp);
fclose(fp);
+ if (!pixac)
+ return (PIXAC *)ERROR_PTR("pixac not read", procName, NULL);
return pixac;
}
diff -rupN leptonica-1.74.2/src/pngio.c leptonica-1.74.2-new/src/pngio.c
--- leptonica-1.74.2/src/pngio.c 2017-05-20 03:30:27.000000000 +0200
+++ leptonica-1.74.2-new/src/pngio.c 2017-06-03 08:19:42.493197862 +0200
@@ -1070,6 +1070,7 @@ char *text;
cmflag = 1;
else
cmflag = 0;
+ pixSetPadBits(pix, 0);
/* Set the color type and bit depth. */
if (d == 32 && spp == 4) {
diff -rupN leptonica-1.74.2/src/ptabasic.c leptonica-1.74.2-new/src/ptabasic.c
--- leptonica-1.74.2/src/ptabasic.c 2017-05-20 03:30:27.000000000 +0200
+++ leptonica-1.74.2-new/src/ptabasic.c 2017-06-03 08:19:42.493197862 +0200
@@ -668,15 +668,13 @@ PTA *pta;
if (!filename)
return (PTA *)ERROR_PTR("filename not defined", procName, NULL);
+
if ((fp = fopenReadStream(filename)) == NULL)
return (PTA *)ERROR_PTR("stream not opened", procName, NULL);
-
- if ((pta = ptaReadStream(fp)) == NULL) {
- fclose(fp);
- return (PTA *)ERROR_PTR("pta not read", procName, NULL);
- }
-
+ pta = ptaReadStream(fp);
fclose(fp);
+ if (!pta)
+ return (PTA *)ERROR_PTR("pta not read", procName, NULL);
return pta;
}
@@ -1278,15 +1276,13 @@ PTAA *ptaa;
if (!filename)
return (PTAA *)ERROR_PTR("filename not defined", procName, NULL);
+
if ((fp = fopenReadStream(filename)) == NULL)
return (PTAA *)ERROR_PTR("stream not opened", procName, NULL);
-
- if ((ptaa = ptaaReadStream(fp)) == NULL) {
- fclose(fp);
- return (PTAA *)ERROR_PTR("ptaa not read", procName, NULL);
- }
-
+ ptaa = ptaaReadStream(fp);
fclose(fp);
+ if (!ptaa)
+ return (PTAA *)ERROR_PTR("ptaa not read", procName, NULL);
return ptaa;
}
diff -rupN leptonica-1.74.2/src/readfile.c leptonica-1.74.2-new/src/readfile.c
--- leptonica-1.74.2/src/readfile.c 2017-05-20 03:30:27.000000000 +0200
+++ leptonica-1.74.2-new/src/readfile.c 2017-06-03 08:19:42.493197862 +0200
@@ -200,12 +200,10 @@ PIX *pix;
L_ERROR("image file not found: %s\n", procName, filename);
return NULL;
}
- if ((pix = pixReadStream(fp, 0)) == NULL) {
- fclose(fp);
- return (PIX *)ERROR_PTR("pix not read", procName, NULL);
- }
+ pix = pixReadStream(fp, 0);
fclose(fp);
-
+ if (!pix)
+ return (PIX *)ERROR_PTR("pix not read", procName, NULL);
return pix;
}
diff -rupN leptonica-1.74.2/src/sarray1.c leptonica-1.74.2-new/src/sarray1.c
--- leptonica-1.74.2/src/sarray1.c 2017-05-20 03:30:27.000000000 +0200
+++ leptonica-1.74.2-new/src/sarray1.c 2017-06-03 08:19:42.494197787 +0200
@@ -1344,13 +1344,10 @@ SARRAY *sa;
if ((fp = fopenReadStream(filename)) == NULL)
return (SARRAY *)ERROR_PTR("stream not opened", procName, NULL);
-
- if ((sa = sarrayReadStream(fp)) == NULL) {
- fclose(fp);
- return (SARRAY *)ERROR_PTR("sa not read", procName, NULL);
- }
-
+ sa = sarrayReadStream(fp);
fclose(fp);
+ if (!sa)
+ return (SARRAY *)ERROR_PTR("sa not read", procName, NULL);
return sa;
}
@@ -1470,7 +1467,8 @@ l_int32
sarrayWrite(const char *filename,
SARRAY *sa)
{
-FILE *fp;
+l_int32 ret;
+FILE *fp;
PROCNAME("sarrayWrite");
@@ -1481,12 +1479,10 @@ FILE *fp;
if ((fp = fopenWriteStream(filename, "w")) == NULL)
return ERROR_INT("stream not opened", procName, 1);
- if (sarrayWriteStream(fp, sa)) {
- fclose(fp);
- return ERROR_INT("sa not written to stream", procName, 1);
- }
-
+ ret = sarrayWriteStream(fp, sa);
fclose(fp);
+ if (ret)
+ return ERROR_INT("sa not written to stream", procName, 1);
return 0;
}
diff -rupN leptonica-1.74.2/src/tiffio.c leptonica-1.74.2-new/src/tiffio.c
--- leptonica-1.74.2/src/tiffio.c 2017-05-20 03:30:27.000000000 +0200
+++ leptonica-1.74.2-new/src/tiffio.c 2017-06-03 08:19:42.494197787 +0200
@@ -87,6 +87,12 @@
*
* Note: To include all necessary functions, use libtiff version 3.7.4
* (or later)
+ * Note: On Windows with 2 bpp or 4 bpp images, the bytes in the
+ * tiff-compressed file depend on the pad bits (but not the
+ * decoded raster image when read). Because it is sometimes
+ * convenient to use a golden file with a byte-by-byte check
+ * to verify invariance, we set the pad bits to 0 before writing,
+ * in pixWriteToTiffStream().
* </pre>
*/
@@ -880,6 +886,7 @@ char *text;
if (!pix)
return ERROR_INT( "pix not defined", procName, 1 );
+ pixSetPadBits(pix, 0);
pixGetDimensions(pix, &w, &h, &d);
xres = pixGetXRes(pix);
yres = pixGetYRes(pix);
@@ -1186,9 +1193,7 @@ TIFF *tif;
if (!poffset)
return (PIX *)ERROR_PTR("&offset not defined", procName, NULL);
- TIFFSetWarningHandler(dummyHandler); /* disable warnings */
-
- if ((tif = TIFFOpen(fname, "r")) == NULL) {
+ if ((tif = openTiff(fname, "r")) == NULL) {
L_ERROR("tif open failed for %s\n", procName, fname);
return NULL;
}
diff -rupN leptonica-1.74.2/src/utils2.c leptonica-1.74.2-new/src/utils2.c
--- leptonica-1.74.2/src/utils2.c 2017-05-20 03:30:27.000000000 +0200
+++ leptonica-1.74.2-new/src/utils2.c 2017-06-03 08:19:42.494197787 +0200
@@ -1866,7 +1866,8 @@ l_uint32 attributes;
#ifndef _WIN32
ret += mkdir(tmpdir, 0777);
#else
- ret += (CreateDirectory(tmpdir, NULL) ? 0 : 1);
+ if (CreateDirectory(tmpdir, NULL) == 0)
+ ret += (GetLastError () != ERROR_ALREADY_EXISTS);
#endif
LEPT_FREE(dir);
dir = tmpdir;
diff -rupN leptonica-1.74.2/src/webpio.c leptonica-1.74.2-new/src/webpio.c
--- leptonica-1.74.2/src/webpio.c 2017-05-20 03:30:27.000000000 +0200
+++ leptonica-1.74.2-new/src/webpio.c 2017-06-03 08:19:42.494197787 +0200
@@ -255,7 +255,8 @@ pixWriteWebP(const char *filename,
l_int32 quality,
l_int32 lossless)
{
-FILE *fp;
+l_int32 ret;
+FILE *fp;
PROCNAME("pixWriteWebP");
@@ -266,11 +267,10 @@ FILE *fp;
if ((fp = fopenWriteStream(filename, "wb+")) == NULL)
return ERROR_INT("stream not opened", procName, 1);
- if (pixWriteStreamWebP(fp, pixs, quality, lossless) != 0) {
- fclose(fp);
- return ERROR_INT("pixs not compressed to stream", procName, 1);
- }
+ ret = pixWriteStreamWebP(fp, pixs, quality, lossless);
fclose(fp);
+ if (ret)
+ return ERROR_INT("pixs not compressed to stream", procName, 1);
return 0;
}
@@ -307,6 +307,7 @@ size_t filebytes, nbytes;
if (!pixs)
return ERROR_INT("pixs not defined", procName, 1);
+ pixSetPadBits(pixs, 0);
pixWriteMemWebP(&filedata, &filebytes, pixs, quality, lossless);
rewind(fp);
nbytes = fwrite(filedata, 1, filebytes, fp);
diff -rupN leptonica-1.74.2/src/writefile.c leptonica-1.74.2-new/src/writefile.c
--- leptonica-1.74.2/src/writefile.c 2017-05-20 03:30:27.000000000 +0200
+++ leptonica-1.74.2-new/src/writefile.c 2017-06-03 08:19:42.494197787 +0200
@@ -241,7 +241,8 @@ pixWrite(const char *fname,
PIX *pix,
l_int32 format)
{
-FILE *fp;
+l_int32 ret;
+FILE *fp;
PROCNAME("pixWrite");
@@ -285,11 +286,10 @@ FILE *fp;
#endif /* WRITE_AS_NAMED */
- if (pixWriteStream(fp, pix, format)) {
- fclose(fp);
- return ERROR_INT("pix not written to stream", procName, 1);
- }
+ ret = pixWriteStream(fp, pix, format);
fclose(fp);
+ if (ret)
+ return ERROR_INT("pix not written to stream", procName, 1);
return 0;
}

View File

@ -1,13 +1,11 @@
Name: leptonica
Version: 1.74.2
Release: 2%{?dist}
Version: 1.74.3
Release: 1%{?dist}
Summary: C library for efficient image processing and image analysis operations
License: Leptonica
URL: https://github.com/danbloomberg/leptonica
Source0: https://github.com/DanBloomberg/leptonica/archive/%{version}/%{name}-%{version}.tar.gz
# Backport of upstream commit 069bbc0897e8b939e93db8730b3f10b18e9d0885
Patch0: 069bbc0897e8b939e93db8730b3f10b18e9d0885.patch
BuildRequires: gcc
BuildRequires: automake
@ -98,6 +96,9 @@ make check
%changelog
* Sun Jun 11 2017 Sandro Mani <manisandro@gmail.com> - 1.74.3-1
- Update to 1.74.3
* Sat Jun 03 2017 Sandro Mani <manisandro@gmail.com> - 1.74.2-2
- Backport 069bbc0897e8b939e93db8730b3f10b18e9d0885

View File

@ -1 +1 @@
SHA512 (leptonica-1.74.2.tar.gz) = dff6db0f5fd536b68482a3c468206cd7f9436a9de47ccf080e1329cc0fa8f250df6f9a07288d72048cb123339b79cbbfe58ff6e272736fd273d393518348b22e
SHA512 (leptonica-1.74.3.tar.gz) = 4b699d8dcbfc911686a3451125fd507a70bfc045bde4f8474d51c3b360e9120742be2e4db45e576b28ff4ea7db05e2faab7c348850bb78641d385c25eb953b93