jpeg-32: compat32 package for jpeg

This package contains C software to implement JPEG image encoding, decoding,
and transcoding.  JPEG is a standardized compression method for full-color
and gray-scale images.

Note: This package is intended to crosscompile jpeg for i386 on x86_64
This commit is contained in:
Naveen Narayanan 2019-07-09 22:14:08 +02:00
parent 3c3a9b99ef
commit baf35c3575
12 changed files with 593 additions and 0 deletions

24
jpeg-32/DESCR Normal file
View File

@ -0,0 +1,24 @@
Independent JPEG Group's free JPEG software
-------------------------------------------
This package contains C software to implement JPEG image encoding, decoding,
and transcoding. JPEG is a standardized compression method for full-color
and gray-scale images.
The distributed programs provide conversion between JPEG "JFIF" format and
image files in PBMPLUS PPM/PGM, GIF, BMP, and Targa file formats. The
core compression and decompression library can easily be reused in other
programs, such as image viewers. The package is highly portable C code;
we have tested it on many machines ranging from PCs to Crays.
We are releasing this software for both noncommercial and commercial use.
Companies are welcome to use it as the basis for JPEG-related products.
We do not ask a royalty, although we do ask for an acknowledgement in
product literature (see the README file in the distribution for details).
We hope to make this software industrial-quality --- although, as with
anything that's free, we offer no warranty and accept no liability.
For more information, contact jpeg-info@uc.ag.
Note: This package is intended to crosscompile jpeg for i386 on x86_64

41
jpeg-32/Makefile Normal file
View File

@ -0,0 +1,41 @@
# $NetBSD: Makefile,v 1.55 2019/03/10 11:22:43 spz Exp $
DISTNAME= jpegsrc.v9c
ABI= 32
PKGNAME= compat${ABI}_${DISTNAME:S/src.v/-/}
CATEGORIES= graphics
MASTER_SITES= http://www.ijg.org/files/
DIST_SUBDIR= jpeg-9c-v2
PKGREVISION= 1
MAINTAINER= pkgsrc-users@NetBSD.org
HOMEPAGE= http://www.ijg.org/
COMMENT= IJG's jpeg compression utilities
CONFLICTS= libjpeg-turbo-[0-9]*
#WRKSRC= ${WRKDIR}/${PKGNAME_NOREV}
WRKSRC= ${WRKDIR}/jpeg-9c
USE_LIBTOOL= yes
GNU_CONFIGURE= yes
LIBABISUFFIX?= /32
CFLAGS+= -m32
CONFIGURE_ARGS+= --disable-ld-version-script
CONFIGURE_ARGS+= --libdir=${PREFIX}/lib${LIBABISUFFIX}
INSTALLATION_DIRS= bin include share/doc/jpeg
PKGCONFIG_OVERRIDE= libjpeg.pc.in
TEST_TARGET= test
post-extract:
${CP} ${FILESDIR}/jpegexiforient.c ${WRKSRC}
remove-non-libraries:
echo "Removing non-compat library package content"
find ${DESTDIR}${PREFIX} -path ${DESTDIR}${PREFIX}/lib${LIBABISUFFIX} -prune -o -type f -exec ${RM} {} +
post-install: remove-non-libraries
.include "../../mk/bsd.pkg.mk"

7
jpeg-32/PLIST Normal file
View File

@ -0,0 +1,7 @@
@comment $NetBSD$
lib/32/libjpeg.la
lib/32/pkgconfig/libjpeg.pc
@pkgdir share/doc/jpeg
@pkgdir man/man1
@pkgdir include
@pkgdir bin

14
jpeg-32/buildlink3.mk Normal file
View File

@ -0,0 +1,14 @@
# $NetBSD: buildlink3.mk,v 1.17 2013/01/24 21:52:28 wiz Exp $
BUILDLINK_TREE+= compat32_jpeg
.if !defined(COMPAT32_JPEG_BUILDLINK3_MK)
COMPAT32_JPEG_BUILDLINK3_MK:=
BUILDLINK_API_DEPENDS.compat32_jpeg+= compat32_jpeg>=8nb1
BUILDLINK_ABI_DEPENDS.compat32_jpeg+= compat32_jpeg>=9
BUILDLINK_PKGSRCDIR.compat32_jpeg?= ../../wip/jpeg-32
BUILDLINK_LIBDIRS.compat32_jpeg= lib/32
.endif # COMPAT32_JPEG_BUILDLINK3_MK
BUILDLINK_TREE+= -compat32_jpeg

11
jpeg-32/distinfo Normal file
View File

@ -0,0 +1,11 @@
$NetBSD: distinfo,v 1.24 2019/03/10 11:22:43 spz Exp $
SHA1 (jpeg-9c-v2/jpegsrc.v9c.tar.gz) = 2ce111c8c0ac828a44b13ad28c265e954a342d07
RMD160 (jpeg-9c-v2/jpegsrc.v9c.tar.gz) = c181cc66d03d96ffcca85724938551bb089fd519
SHA512 (jpeg-9c-v2/jpegsrc.v9c.tar.gz) = 2b581c60ae401a79bbbe748ff2deeda5acd50bfd2ea22e5926e36d34b9ebcffb6580b0ff48e972c1441583e30e21e1ea821ca0423f9c67ce08a31dffabdbe6b7
Size (jpeg-9c-v2/jpegsrc.v9c.tar.gz) = 1028134 bytes
SHA1 (patch-af) = 925604706574009aacd452dab2d736039b0654e9
SHA1 (patch-ag) = 46164c00386d1968356f1b61d144bc9168410654
SHA1 (patch-jmorecfg.h) = c00f81ba94e2ad6b55ca9892553eedbe4eca3ad1
SHA1 (patch-jpeglib.h) = 635453c5a2b1223ef5af729edcbfcfa3ed78a8b5
SHA1 (patch-rdtarga.c) = eaec399d67ffb5d33b32131d01a052132bb5bae2

View File

@ -0,0 +1,40 @@
#! /bin/sh
#
# $NetBSD: exifautotran,v 1.2 2010/01/04 19:43:39 joerg Exp $
#
# Based on http://www.jpegclub.org/exifautotran.txt
#
if [ "$#" = "0" ]
then
cat << EOF 1>&2
usage: exifautotran [list of files]
Transforms Exif files so that Orientation becomes 1
EOF
exit 1
fi
for i
do
case `jpegexiforient -n "$i"` in
1) transform="";;
2) transform="-flip horizontal";;
3) transform="-rotate 180";;
4) transform="-flip vertical";;
5) transform="-transpose";;
6) transform="-rotate 90";;
7) transform="-transverse";;
8) transform="-rotate 270";;
*) transform="";;
esac
if test -n "$transform"; then
echo Executing: jpegtran -copy all $transform $i
jpegtran -copy all $transform "$i" > tempfile
if test $? -ne 0; then
echo Error while transforming $i - skipped.
else
rm "$i"
mv tempfile "$i"
jpegexiforient -1 "$i" > /dev/null
fi
fi
done

View File

@ -0,0 +1,293 @@
/* $NetBSD: jpegexiforient.c,v 1.2 2010/01/04 19:43:39 joerg Exp $ */
/*
* jpegexiforient.c
*
* This is a utility program to get and set the Exif Orientation Tag.
* It can be used together with jpegtran in scripts for automatic
* orientation correction of digital camera pictures.
*
* The Exif orientation value gives the orientation of the camera
* relative to the scene when the image was captured. The relation
* of the '0th row' and '0th column' to visual position is shown as
* below.
*
* Value | 0th Row | 0th Column
* ------+-------------+-----------
* 1 | top | left side
* 2 | top | rigth side
* 3 | bottom | rigth side
* 4 | bottom | left side
* 5 | left side | top
* 6 | right side | top
* 7 | right side | bottom
* 8 | left side | bottom
*
* For convenience, here is what the letter F would look like if it were
* tagged correctly and displayed by a program that ignores the orientation
* tag:
*
* 1 2 3 4 5 6 7 8
*
* 888888 888888 88 88 8888888888 88 88 8888888888
* 88 88 88 88 88 88 88 88 88 88 88 88
* 8888 8888 8888 8888 88 8888888888 8888888888 88
* 88 88 88 88
* 88 88 888888 888888
*
*/
#include <stdio.h>
#include <stdlib.h>
static FILE * myfile; /* My JPEG file */
static unsigned char exif_data[65536L];
/* Return next input byte, or EOF if no more */
#define NEXTBYTE() getc(myfile)
/* Error exit handler */
#define ERREXIT(msg) (exit(0))
/* Read one byte, testing for EOF */
static int
read_1_byte (void)
{
int c;
c = NEXTBYTE();
if (c == EOF)
ERREXIT("Premature EOF in JPEG file");
return c;
}
/* Read 2 bytes, convert to unsigned int */
/* All 2-byte quantities in JPEG markers are MSB first */
static unsigned int
read_2_bytes (void)
{
int c1, c2;
c1 = NEXTBYTE();
if (c1 == EOF)
ERREXIT("Premature EOF in JPEG file");
c2 = NEXTBYTE();
if (c2 == EOF)
ERREXIT("Premature EOF in JPEG file");
return (((unsigned int) c1) << 8) + ((unsigned int) c2);
}
static const char * progname; /* program name for error messages */
static void
usage (void)
/* complain about bad command line */
{
fprintf(stderr, "jpegexiforient reads or writes the Exif Orientation Tag ");
fprintf(stderr, "in a JPEG Exif file.\n");
fprintf(stderr, "Usage: %s [switches] jpegfile\n", progname);
fprintf(stderr, "Switches:\n");
fprintf(stderr, " -n Do not output the trailing newline\n");
fprintf(stderr, " -1 .. -8 Set orientation value 1 .. 8\n");
}
/*
* The main program.
*/
int
main (int argc, char **argv)
{
int n_flag, set_flag;
unsigned int length, i;
int is_motorola; /* Flag for byte order */
unsigned int offset, number_of_tags, tagnum;
progname = argv[0];
if (progname == NULL || progname[0] == 0)
progname = "jpegexiforient"; /* in case C library doesn't provide it */
if (argc < 2) { usage(); return 0; }
n_flag = 0; set_flag = 0;
i = 1;
while (argv[i][0] == '-') {
switch (argv[i][1]) {
case 'n':
n_flag = 1;
break;
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
set_flag = argv[i][1] - '0';
break;
default:
usage(); return 0;
}
if (++i >= argc) { usage(); return 0; }
}
if (set_flag) {
if ((myfile = fopen(argv[i], "rb+")) == NULL) {
fprintf(stderr, "%s: can't open %s\n", progname, argv[i]);
return 0;
}
} else {
if ((myfile = fopen(argv[i], "rb")) == NULL) {
fprintf(stderr, "%s: can't open %s\n", progname, argv[i]);
return 0;
}
}
/* Read File head, check for JPEG SOI + Exif APP1 */
for (i = 0; i < 4; i++)
exif_data[i] = (unsigned char) read_1_byte();
if (exif_data[0] != 0xFF ||
exif_data[1] != 0xD8 ||
exif_data[2] != 0xFF ||
exif_data[3] != 0xE1)
return 0;
/* Get the marker parameter length count */
length = read_2_bytes();
/* Length includes itself, so must be at least 2 */
/* Following Exif data length must be at least 6 */
if (length < 8)
return 0;
length -= 8;
/* Read Exif head, check for "Exif" */
for (i = 0; i < 6; i++)
exif_data[i] = (unsigned char) read_1_byte();
if (exif_data[0] != 0x45 ||
exif_data[1] != 0x78 ||
exif_data[2] != 0x69 ||
exif_data[3] != 0x66 ||
exif_data[4] != 0 ||
exif_data[5] != 0)
return 0;
/* Read Exif body */
for (i = 0; i < length; i++)
exif_data[i] = (unsigned char) read_1_byte();
if (length < 12) return 0; /* Length of an IFD entry */
/* Discover byte order */
if (exif_data[0] == 0x49 && exif_data[1] == 0x49)
is_motorola = 0;
else if (exif_data[0] == 0x4D && exif_data[1] == 0x4D)
is_motorola = 1;
else
return 0;
/* Check Tag Mark */
if (is_motorola) {
if (exif_data[2] != 0) return 0;
if (exif_data[3] != 0x2A) return 0;
} else {
if (exif_data[3] != 0) return 0;
if (exif_data[2] != 0x2A) return 0;
}
/* Get first IFD offset (offset to IFD0) */
if (is_motorola) {
if (exif_data[4] != 0) return 0;
if (exif_data[5] != 0) return 0;
offset = exif_data[6];
offset <<= 8;
offset += exif_data[7];
} else {
if (exif_data[7] != 0) return 0;
if (exif_data[6] != 0) return 0;
offset = exif_data[5];
offset <<= 8;
offset += exif_data[4];
}
if (offset > length - 2) return 0; /* check end of data segment */
/* Get the number of directory entries contained in this IFD */
if (is_motorola) {
number_of_tags = exif_data[offset];
number_of_tags <<= 8;
number_of_tags += exif_data[offset+1];
} else {
number_of_tags = exif_data[offset+1];
number_of_tags <<= 8;
number_of_tags += exif_data[offset];
}
if (number_of_tags == 0) return 0;
offset += 2;
/* Search for Orientation Tag in IFD0 */
for (;;) {
if (offset > length - 12) return 0; /* check end of data segment */
/* Get Tag number */
if (is_motorola) {
tagnum = exif_data[offset];
tagnum <<= 8;
tagnum += exif_data[offset+1];
} else {
tagnum = exif_data[offset+1];
tagnum <<= 8;
tagnum += exif_data[offset];
}
if (tagnum == 0x0112) break; /* found Orientation Tag */
if (--number_of_tags == 0) return 0;
offset += 12;
}
if (set_flag) {
/* Set the Orientation value */
if (is_motorola) {
exif_data[offset+2] = 0; /* Format = unsigned short (2 octets) */
exif_data[offset+3] = 3;
exif_data[offset+4] = 0; /* Number Of Components = 1 */
exif_data[offset+5] = 0;
exif_data[offset+6] = 0;
exif_data[offset+7] = 1;
exif_data[offset+8] = 0;
exif_data[offset+9] = (unsigned char)set_flag;
exif_data[offset+10] = 0;
exif_data[offset+11] = 0;
} else {
exif_data[offset+2] = 3; /* Format = unsigned short (2 octets) */
exif_data[offset+3] = 0;
exif_data[offset+4] = 1; /* Number Of Components = 1 */
exif_data[offset+5] = 0;
exif_data[offset+6] = 0;
exif_data[offset+7] = 0;
exif_data[offset+8] = (unsigned char)set_flag;
exif_data[offset+9] = 0;
exif_data[offset+10] = 0;
exif_data[offset+11] = 0;
}
fseek(myfile, (4 + 2 + 6 + 2) + offset, SEEK_SET);
fwrite(exif_data + 2 + offset, 1, 10, myfile);
} else {
/* Get the Orientation value */
if (is_motorola) {
if (exif_data[offset+8] != 0) return 0;
set_flag = exif_data[offset+9];
} else {
if (exif_data[offset+9] != 0) return 0;
set_flag = exif_data[offset+8];
}
if (set_flag > 8) return 0;
}
/* Write out Orientation value */
if (n_flag)
printf("%c", '0' + set_flag);
else
printf("%c\n", '0' + set_flag);
/* All done. */
return 0;
}

24
jpeg-32/patches/patch-af Normal file
View File

@ -0,0 +1,24 @@
$NetBSD: patch-af,v 1.6 2016/02/01 09:22:53 wiz Exp $
Build and install jpegexiforient.
--- Makefile.am.orig 2012-05-09 13:13:36.000000000 +0000
+++ Makefile.am
@@ -76,7 +76,7 @@ if HAVE_LD_VERSION_SCRIPT
endif
# Executables to build
-bin_PROGRAMS = cjpeg djpeg jpegtran rdjpgcom wrjpgcom
+bin_PROGRAMS = cjpeg djpeg jpegtran rdjpgcom wrjpgcom jpegexiforient
# Executable sources & libs
cjpeg_SOURCES = cjpeg.c rdppm.c rdgif.c rdtarga.c rdrle.c rdbmp.c \
@@ -89,6 +89,8 @@ jpegtran_SOURCES = jpegtran.c rdswitch.c
jpegtran_LDADD = libjpeg.la
rdjpgcom_SOURCES = rdjpgcom.c
wrjpgcom_SOURCES = wrjpgcom.c
+jpegexiforient_SOURCES = jpegexiforient.c
+jpegexiforient_LDADD = libjpeg.la
# Manual pages to install
man_MANS = $(DISTMANS)

62
jpeg-32/patches/patch-ag Normal file
View File

@ -0,0 +1,62 @@
$NetBSD: patch-ag,v 1.4 2016/02/01 09:22:53 wiz Exp $
Build and install jpegexiforient.
--- Makefile.in.orig 2015-09-10 08:04:54.000000000 +0000
+++ Makefile.in
@@ -99,7 +99,7 @@ host_triplet = @host@
target_triplet = @target@
@HAVE_LD_VERSION_SCRIPT_TRUE@am__append_1 = -Wl,--version-script=$(srcdir)/libjpeg.map
bin_PROGRAMS = cjpeg$(EXEEXT) djpeg$(EXEEXT) jpegtran$(EXEEXT) \
- rdjpgcom$(EXEEXT) wrjpgcom$(EXEEXT)
+ rdjpgcom$(EXEEXT) wrjpgcom$(EXEEXT) jpegexiforient$(EXEEXT)
subdir = .
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.ac
@@ -184,6 +184,9 @@ rdjpgcom_LDADD = $(LDADD)
am_wrjpgcom_OBJECTS = wrjpgcom.$(OBJEXT)
wrjpgcom_OBJECTS = $(am_wrjpgcom_OBJECTS)
wrjpgcom_LDADD = $(LDADD)
+am_jpegexiforient_OBJECTS = jpegexiforient.$(OBJEXT)
+jpegexiforient_OBJECTS = $(am_jpegexiforient_OBJECTS)
+jpegexiforient_DEPENDENCIES = libjpeg.la
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
@@ -219,7 +222,8 @@ am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V
am__v_CCLD_0 = @echo " CCLD " $@;
am__v_CCLD_1 =
SOURCES = $(libjpeg_la_SOURCES) $(cjpeg_SOURCES) $(djpeg_SOURCES) \
- $(jpegtran_SOURCES) $(rdjpgcom_SOURCES) $(wrjpgcom_SOURCES)
+ $(jpegtran_SOURCES) $(rdjpgcom_SOURCES) $(wrjpgcom_SOURCES) \
+ $(jpegexiforient_SOURCES)
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
@@ -461,6 +465,8 @@ jpegtran_SOURCES = jpegtran.c rdswitch.c
jpegtran_LDADD = libjpeg.la
rdjpgcom_SOURCES = rdjpgcom.c
wrjpgcom_SOURCES = wrjpgcom.c
+jpegexiforient_SOURCES = jpegexiforient.c
+jpegexiforient_LDADD = libjpeg.la
# Manual pages to install
man_MANS = $(DISTMANS)
@@ -640,6 +646,9 @@ rdjpgcom$(EXEEXT): $(rdjpgcom_OBJECTS) $
wrjpgcom$(EXEEXT): $(wrjpgcom_OBJECTS) $(wrjpgcom_DEPENDENCIES) $(EXTRA_wrjpgcom_DEPENDENCIES)
@rm -f wrjpgcom$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(wrjpgcom_OBJECTS) $(wrjpgcom_LDADD) $(LIBS)
+jpegexiforient$(EXEEXT): $(jpegexiforient_OBJECTS) $(jpegexiforient_DEPENDENCIES)
+ @rm -f jpegexiforient$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(jpegexiforient_OBJECTS) $(jpegexiforient_LDADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
@@ -693,6 +702,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jidctfst.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jidctint.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jmemmgr.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jpegexiforient.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jpegtran.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jquant1.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jquant2.Plo@am__quote@

View File

@ -0,0 +1,28 @@
$NetBSD: patch-jmorecfg.h,v 1.3 2014/01/28 21:19:00 wiz Exp $
Fix problem with booleans by reverting to the old definition.
--- jmorecfg.h.orig 2013-09-17 07:20:20.000000000 +0000
+++ jmorecfg.h
@@ -303,19 +303,14 @@ typedef void noreturn_t;
* Defining HAVE_BOOLEAN before including jpeglib.h should make it work.
*/
-#ifndef HAVE_BOOLEAN
-#if defined FALSE || defined TRUE || defined QGLOBAL_H
-/* Qt3 defines FALSE and TRUE as "const" variables in qglobal.h */
-typedef int boolean;
#ifndef FALSE /* in case these macros already exist */
#define FALSE 0 /* values of boolean */
#endif
#ifndef TRUE
#define TRUE 1
#endif
-#else
-typedef enum { FALSE = 0, TRUE = 1 } boolean;
-#endif
+#ifndef HAVE_BOOLEAN
+typedef int boolean;
#endif

View File

@ -0,0 +1,12 @@
$NetBSD: patch-jpeglib.h,v 1.1 2013/10/11 14:54:06 joerg Exp $
--- jpeglib.h.orig 2013-10-11 13:06:28.000000000 +0000
+++ jpeglib.h
@@ -26,6 +26,7 @@
#endif
#include "jmorecfg.h" /* seldom changed options */
+#include <stdio.h>
#ifdef __cplusplus
#ifndef DONT_USE_EXTERN_C

View File

@ -0,0 +1,37 @@
$NetBSD: patch-rdtarga.c,v 1.1 2019/03/10 11:22:43 spz Exp $
fix for CVE-2018-11813 from
https://github.com/mozilla/mozjpeg/commit/909a8cfc7bca9b2e6707425bdb74da997e8fa499
--- rdtarga.c.orig 2017-09-16 11:12:46.000000000 +0000
+++ rdtarga.c
@@ -125,11 +125,10 @@ METHODDEF(void)
read_non_rle_pixel (tga_source_ptr sinfo)
/* Read one Targa pixel from the input file; no RLE expansion */
{
- register FILE *infile = sinfo->pub.input_file;
register int i;
for (i = 0; i < sinfo->pixel_size; i++) {
- sinfo->tga_pixel[i] = (U_CHAR) getc(infile);
+ sinfo->tga_pixel[i] = (U_CHAR) read_byte(sinfo);
}
}
@@ -138,7 +137,6 @@ METHODDEF(void)
read_rle_pixel (tga_source_ptr sinfo)
/* Read one Targa pixel from the input file, expanding RLE data as needed */
{
- register FILE *infile = sinfo->pub.input_file;
register int i;
/* Duplicate previously read pixel? */
@@ -160,7 +158,7 @@ read_rle_pixel (tga_source_ptr sinfo)
/* Read next pixel */
for (i = 0; i < sinfo->pixel_size; i++) {
- sinfo->tga_pixel[i] = (U_CHAR) getc(infile);
+ sinfo->tga_pixel[i] = (U_CHAR) read_byte(sinfo);
}
}