Skip to content

Commit 122b9cb

Browse files
committed
Merge remote-tracking branch 'upstream/master' into lossy
* upstream/master: (30 commits) Add initial NEWS. Whoops, thanks wilkesybear Fix configury: AC_SEARCH_LIBS is required. Multithreaded resize detects whether -U is necessary. Thread updates. It is very important that we have only one kd3_sort_lock. Improve threaded configury, and fix SIMD configury error. Implemented work stealing 'thread pool,' as proposed by Dr. Kohler Remove debug line from configure, change default thread count to 8 Make threads a maybe in configure, renamed from 'threaded' or 'threading' to 'threads' Correct error in issue #39: Frame selection '#0-' is parsed correctly. Warn if SIMD defaults to off. Add configury for SIMD. Use macros to abstract scale_color vector operations. In --resize-method mix, construct a `mix` array in advance. Use SIMD vector types. Prepare for SIMD: Input screen is floating-point colors. Use ac_check_lib instead of naked call to LIBS for pthread Wrap POSIX lines with the env variable that controls threaded resize Changes to (dis)allow threaded gifsicle in configure script ...
2 parents 4f90608 + 73ee93f commit 122b9cb

File tree

15 files changed

+530
-177
lines changed

15 files changed

+530
-177
lines changed

.travis.yml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,22 @@
11
language: c
22
env:
3-
- CC="gcc"
4-
- CC="gcc -std=c89"
5-
- CC="clang"
3+
global:
4+
# The next declaration is the encrypted COVERITY_SCAN_TOKEN, created
5+
# via the "travis encrypt" command using the project repo's public key
6+
- secure: "NEQUeZwTTJ+1Pdy2CpNte1nJLYRY2H8+dpvnGS2HP6U/Ok6ZQm4Zxic+ufhabuymbCV7Jvwwy6Gaj8+ObIDahhzAsiMRXSymnvFHELAnq7DiikJ2HqBvFhPzPI2/vDmEP37msGW1dloipLhdKMeuYYP++BpApnC6KVRVJDXg5JI="
7+
matrix:
8+
- CC="gcc"
9+
- CC="gcc -std=c89"
10+
- CC="clang"
611
script: ./configure && make check
712
before_script: ./bootstrap.sh
13+
14+
addons:
15+
coverity_scan:
16+
project:
17+
name: "kohler/gifsicle"
18+
description: "Build submitted via Travis CI"
19+
notification_email: [email protected]
20+
build_command_prepend: "./configure; make clean"
21+
build_command: "make -j 4"
22+
branch_pattern: coverity_scan

Makefile.am

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ EXTRA_DIST = COPYING README.md gifsicle.spec \
2222
test/010-warnings.testie \
2323
test/011-resizemix.testie
2424

25-
gifsicle:
25+
gifsicle: config.h
2626
@cd src && $(MAKE) gifsicle
27-
gifdiff:
27+
gifdiff: config.h
2828
@cd src && $(MAKE) gifdiff
29-
gifview:
29+
gifview: config.h
3030
@cd src && $(MAKE) gifview
3131

3232
srclinks:

NEWS

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
11
Gifsicle NEWS
2+
3+
Version 1.89
4+
5+
* Add SIMD support for resizing. When enabled this improves resize
6+
performance enormously for complex resize methods.
7+
8+
* Add thread support for resizing. `-j[NTHREADS]` tells gifsicle to use
9+
up to NTHREADS threads to resize an input image. There are several
10+
caveats---multiple threads can be only used on unoptimized images.
11+
Thanks to Github user `wilkesybear`.
12+
13+
* Minor bug fixes.
14+
215

316
Version 1.88 1.Jul.2015
417

configure.ac

Lines changed: 127 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -11,53 +11,35 @@ AC_C_CONST
1111
AC_C_INLINE
1212

1313
build_gifview=maybe
14-
AC_ARG_ENABLE(gifview,
15-
[ --disable-gifview do not build gifview, a GIF viewer for X11],
16-
if test "x$enableval" != xyes ; then
17-
build_gifview=no
18-
fi)
14+
AC_ARG_ENABLE([gifview],
15+
[AS_HELP_STRING([--disable-gifview], [do not build gifview X11 viewer])],
16+
[if test "x$enableval" != xyes; then build_gifview=no; fi])
1917

2018
build_gifdiff=yes
21-
AC_ARG_ENABLE(gifdiff,
22-
[ --disable-gifdiff do not build gifdiff, a utility for comparing GIFs],
23-
if test "x$enableval" != xyes ; then
24-
build_gifdiff=no
25-
fi)
19+
AC_ARG_ENABLE([gifdiff],
20+
[AS_HELP_STRING([--disable-gifdiff], [do not build gifdiff comparison utility])],
21+
[if test "x$enableval" != xyes; then build_gifdiff=no; fi])
2622

27-
use_dmalloc=
28-
AC_ARG_ENABLE(dmalloc,
29-
[ --enable-dmalloc build with debugging malloc library],
30-
if test "x$enableval" = xyes ; then
31-
use_dmalloc=yes
32-
fi)
33-
34-
AC_ARG_ENABLE(warnings,
35-
[ --enable-warnings compile with -W -Wall],
36-
if test "x$enableval" = xyes ; then
37-
CC="$CC -W -Wall"
38-
fi)
23+
AC_ARG_ENABLE([warnings],
24+
[AS_HELP_STRING([--enable-warnings], [compile with -W -Wall])],
25+
[if test "x$enableval" = xyes; then CC="$CC -W -Wall"; fi])
3926

27+
WERROR=
4028
AC_ARG_ENABLE([werror],
41-
[ --enable-werror compile with -Werror],
42-
if test "x$enableval" = xyes ; then
43-
WERROR="-Werror"
44-
fi)
29+
[AS_HELP_STRING([--enable-werror], [compile with -Werror])],
30+
[if test "x$enableval" = xyes; then WERROR="-Werror"; fi])
4531
AC_SUBST([WERROR])
4632

47-
AC_ARG_ENABLE(all,
48-
[ --enable-all --enable-gifview --enable-gifdiff --enable-warnings],
49-
if test "x$enableval" = xyes ; then
50-
build_gifview=yes
51-
build_gifdiff=yes
52-
CC="$CC -W -Wall"
53-
fi)
33+
use_dmalloc=
34+
AC_ARG_ENABLE([dmalloc],
35+
[AS_HELP_STRING([--enable-dmalloc], [build with debugging malloc library])],
36+
[if test "x$enableval" = xyes; then use_dmalloc=yes; fi])
5437

5538
ungif=
56-
AC_ARG_ENABLE(ungif,
57-
[ --enable-ungif build without compression],
58-
if test "x$enableval" = xyes ; then
59-
ungif=yes
60-
fi)
39+
AC_ARG_ENABLE([ungif],
40+
[AS_HELP_STRING([--enable-ungif], [build without LZW compression])],
41+
[if test "x$enableval" = xyes; then ungif=yes; fi])
42+
6143

6244
dnl
6345
dnl Choose programs to build. Always build gifsicle
@@ -69,50 +51,52 @@ OTHERMANS=""
6951
if test "x$build_gifview" = xyes -o "x$build_gifview" = xmaybe; then
7052
AC_PATH_XTRA
7153
if test "x$no_x" = xyes; then
72-
if test "x$build_gifview" = xyes; then
73-
AC_MSG_ERROR([
54+
if test "x$build_gifview" = xyes; then
55+
AC_MSG_ERROR([
7456
******************************************************************************
7557
Cannot find X, but you explicitly requested that gifview be built.
7658
You may need to install an X11 development package to get the X headers,
7759
supply a '--with-x' option, or simply '--disable-gifview'.])
78-
else
79-
AC_MSG_WARN([Not compiling gifview since X is not available.])
80-
build_gifview=no
81-
fi
60+
else
61+
AC_MSG_WARN([Not compiling gifview since X is not available.])
62+
build_gifview=no
63+
fi
8264
else
83-
build_gifview=yes
65+
build_gifview=yes
8466
fi
8567
fi
8668

8769
if test "x$build_gifview" = xyes ; then
88-
OTHERPROGRAMS="$OTHERPROGRAMS gifview"'$(EXEEXT)'
89-
OTHERMANS="$OTHERMANS gifview.1"
90-
AC_CACHE_CHECK(for gettimeofday prototype, ac_cv_gettimeofday,
91-
[AC_TRY_COMPILE([#include <time.h>
92-
#include <sys/time.h>],
93-
[gettimeofday((void *)0, (void *)0);],
94-
[AC_TRY_COMPILE([#include <time.h>
95-
#include <sys/time.h>],
96-
[gettimeofday((void *)0);],
97-
ac_cv_gettimeofday=0,
98-
ac_cv_gettimeofday=2)],
99-
ac_cv_gettimeofday=1)])
100-
AC_DEFINE_UNQUOTED(GETTIMEOFDAY_PROTO, $ac_cv_gettimeofday, [Define to the number of arguments to gettimeofday (gifview only).])
70+
OTHERPROGRAMS="$OTHERPROGRAMS gifview"'$(EXEEXT)'
71+
OTHERMANS="$OTHERMANS gifview.1"
72+
AC_CHECK_HEADERS([time.h sys/time.h])
73+
AC_CACHE_CHECK([for gettimeofday prototype], [ac_cv_gettimeofday],
74+
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
75+
[[#include <time.h>
76+
#include <sys/time.h>]],
77+
[[gettimeofday((void*) 0, (void*) 0)]])],
78+
[ac_cv_gettimeofday=2],
79+
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
80+
[[#include <time.h>
81+
#include <sys/time.h>]],
82+
[[gettimeofday((void*) 0)]])],
83+
[ac_cv_gettimeofday=1], [ac_cv_gettimeofday=0])])])
84+
AC_DEFINE_UNQUOTED([GETTIMEOFDAY_PROTO], [$ac_cv_gettimeofday], [Define to the number of arguments to gettimeofday.])
10185
else
102-
AC_DEFINE_UNQUOTED(X_DISPLAY_MISSING, 1, [Define if X is not available.])
86+
AC_DEFINE_UNQUOTED(X_DISPLAY_MISSING, 1, [Define if X is not available.])
10387
fi
10488

10589
if test "x$build_gifdiff" = xyes ; then
106-
OTHERPROGRAMS="$OTHERPROGRAMS gifdiff"'$(EXEEXT)'
107-
OTHERMANS="$OTHERMANS gifdiff.1"
90+
OTHERPROGRAMS="$OTHERPROGRAMS gifdiff"'$(EXEEXT)'
91+
OTHERMANS="$OTHERMANS gifdiff.1"
10892
fi
10993

110-
AC_SUBST(OTHERPROGRAMS)dnl
111-
AC_SUBST(OTHERMANS)dnl
94+
AC_SUBST(OTHERPROGRAMS)
95+
AC_SUBST(OTHERMANS)
11296

11397

11498
dnl
115-
dnl Set up `ungif' support
99+
dnl Set up ungif support
116100
dnl
117101

118102
if test "x$ungif" = xyes -o "x$GIFSICLE_UNGIF" = xyes ; then
@@ -138,7 +122,7 @@ AC_REPLACE_FUNCS([strerror])
138122
AC_CHECK_FUNCS([strtoul mkstemp])
139123
AC_SEARCH_LIBS([pow], [m], [AC_DEFINE([HAVE_POW], [1], [Define to 1 if you have the `pow' function.])])
140124

141-
AC_CHECK_HEADERS([sys/select.h inttypes.h unistd.h])
125+
AC_CHECK_HEADERS([sys/select.h sys/stat.h inttypes.h unistd.h])
142126

143127

144128
dnl
@@ -166,7 +150,7 @@ elif test "$ac_cv_u_int_t" = yes; then
166150
AC_DEFINE([HAVE_U_INT_TYPES], [1], [Define if you have u_intXX_t types but not uintXX_t types.])
167151
fi
168152

169-
AC_CHECK_TYPES([uintptr_t, int64_t], [], [],
153+
AC_CHECK_TYPES([uintptr_t, int64_t, uint64_t], [], [],
170154
[#if HAVE_INTTYPES_H
171155
# include <inttypes.h>
172156
#endif
@@ -175,11 +159,88 @@ AC_CHECK_TYPES([uintptr_t, int64_t], [], [],
175159
#endif
176160
])
177161

162+
AC_CHECK_SIZEOF([float])
178163
AC_CHECK_SIZEOF([unsigned int])
179164
AC_CHECK_SIZEOF([unsigned long])
180165
AC_CHECK_SIZEOF([void *])
181166

182167

168+
dnl
169+
dnl vector types
170+
dnl
171+
172+
AC_MSG_CHECKING([for usable vector_size vector types])
173+
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
174+
[AC_INCLUDES_DEFAULT
175+
[typedef float float4 __attribute__((vector_size (4 * sizeof(float))));]],
176+
[[float4 a;
177+
a[0] = a[1] = a[2] = a[3] = (float) rand();
178+
a *= (float) 3;
179+
printf("%f\n", a[0]);]])],
180+
[AC_DEFINE([HAVE_VECTOR_SIZE_VECTOR_TYPES], 1, [Define to 1 if `vector_size' vector types are usable.])
181+
ac_cv_vector_size_vector_types=yes], [ac_cv_vector_size_vector_types=no])
182+
AC_MSG_RESULT([$ac_cv_vector_size_vector_types])
183+
184+
AC_MSG_CHECKING([for usable ext_vector_type vector types])
185+
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
186+
[AC_INCLUDES_DEFAULT
187+
[typedef float float4 __attribute__((ext_vector_type (4)));]],
188+
[[float4 a;
189+
a[0] = a[1] = a[2] = a[3] = (float) rand();
190+
a *= (float) 3;
191+
printf("%f\n", a[0]);]])],
192+
[AC_DEFINE([HAVE_EXT_VECTOR_TYPE_VECTOR_TYPES], 1, [Define to 1 if `ext_vector_type' vector types are usable.])
193+
ac_cv_ext_vector_type_vector_types=yes], [ac_cv_ext_vector_type_vector_types=no])
194+
AC_MSG_RESULT([$ac_cv_ext_vector_type_vector_types])
195+
196+
AC_ARG_ENABLE([simd],
197+
[AS_HELP_STRING([--disable-simd], [do not use SIMD instructions])],
198+
[], [enable_simd=maybe])
199+
200+
if test $ac_cv_vector_size_vector_types = no -a $ac_cv_ext_vector_type_vector_types = no; then
201+
if test x$enable_simd = xmaybe; then
202+
AC_MSG_WARN([
203+
Not using SIMD since your compiler's support for SIMD types is inadequate.
204+
])
205+
elif test x$enable_simd != xno; then
206+
AC_MSG_ERROR([
207+
******************************************************************************
208+
`--enable-simd' was supplied, but this compiler does not support SIMD types.])
209+
fi
210+
enable_simd=no
211+
fi
212+
if test x"$enable_simd" != xno; then
213+
AC_DEFINE([HAVE_SIMD], [1], [Define to 1 if SIMD types should be used.])
214+
fi
215+
216+
217+
dnl
218+
dnl threads
219+
dnl
220+
221+
AC_SEARCH_LIBS([pthread_create], [pthread], [have_threads=yes], [have_threads=no])
222+
AC_MSG_CHECKING([for __sync_add_and_fetch])
223+
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
224+
[AC_INCLUDES_DEFAULT
225+
extern volatile int x;],
226+
[[printf("%d", __sync_add_and_fetch(&x, 1));]])],
227+
[AC_DEFINE([HAVE___SYNC_ADD_AND_FETCH], 1, [Define to 1 if you have the `__sync_add_and_fetch' function.])
228+
result=yes], [result=no])
229+
AC_MSG_RESULT([$result])
230+
231+
AC_ARG_ENABLE([threads],
232+
[AS_HELP_STRING([--disable-threads], [do not include multithreading])],
233+
[], [enable_threads=maybe])
234+
235+
if test "x$have_threads" = xno -a "x$enable_threads" = xyes; then
236+
AC_MSG_ERROR([
237+
******************************************************************************
238+
Threading support is not available on this platform.])
239+
elif test "x$have_threads" = xyes -a "x$enable_threads" != xno; then
240+
AC_DEFINE([ENABLE_THREADS], [1], [Define to 1 if multithreading support is available.])
241+
fi
242+
243+
183244
dnl
184245
dnl verbatim portions of the header
185246
dnl

src/gifdiff.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,10 @@ apply_image(int is_second, Gif_Stream *gfs, int imageno, uint16_t background)
118118
Gif_Colormap *gfcm = gfi->local ? gfi->local : gfs->global;
119119

120120
/* set up colormap */
121-
for (i = 0; i < 256; i++)
121+
for (i = 0; i < gfcm->ncol; ++i)
122+
map[i] = gfcm->col[i].pixel;
123+
for (i = gfcm->ncol; i < 256; ++i)
122124
map[i] = 1;
123-
if (gfs)
124-
for (i = 0; i < gfcm->ncol; i++)
125-
map[i] = gfcm->col[i].pixel;
126125
if (gfi->transparent >= 0 && gfi->transparent < 256)
127126
map[gfi->transparent] = TRANSP;
128127

@@ -458,7 +457,7 @@ gifread_error(Gif_Stream* gfs, Gif_Image* gfi,
458457
static int same_error_count = 0;
459458
int which_image = Gif_ImageNumber(gfs, gfi);
460459
const char *filename = gfs->landmark;
461-
if (gfs && which_image < 0)
460+
if (which_image < 0)
462461
which_image = gfs->nimages;
463462

464463
if (gifread_error_count == 0) {

src/giffunc.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,10 @@ Gif_Colormap *
8787
Gif_NewFullColormap(int count, int capacity)
8888
{
8989
Gif_Colormap *gfcm = Gif_New(Gif_Colormap);
90-
if (!gfcm || capacity <= 0 || count < 0)
90+
if (!gfcm || capacity <= 0 || count < 0) {
91+
Gif_Delete(gfcm);
9192
return 0;
93+
}
9294
if (count > capacity)
9395
capacity = count;
9496
gfcm->ncol = count;

src/gifread.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ Gif_FullUncompressImage(Gif_Stream* gfs, Gif_Image* gfi,
548548
gfc.handler = h;
549549
gfc.errors[0] = gfc.errors[1] = 0;
550550

551-
if (gfi && gfc.prefix && gfc.suffix && gfc.length && gfi->compressed) {
551+
if (gfc.prefix && gfc.suffix && gfc.length && gfi->compressed) {
552552
make_data_reader(&grr, gfi->compressed, gfi->compressed_len);
553553
ok = uncompress_image(&gfc, gfi, &grr);
554554
}
@@ -802,7 +802,6 @@ read_gif(Gif_Reader *grr, int read_flags,
802802

803803
gfs = Gif_NewStream();
804804
gfi = Gif_NewImage();
805-
gfs->landmark = landmark;
806805

807806
gfc.stream = gfs;
808807
gfc.prefix = Gif_NewArray(Gif_Code, GIF_MAX_CODE);
@@ -814,6 +813,7 @@ read_gif(Gif_Reader *grr, int read_flags,
814813

815814
if (!gfs || !gfi || !gfc.prefix || !gfc.suffix || !gfc.length)
816815
goto done;
816+
gfs->landmark = landmark;
817817

818818
GIF_DEBUG(("\nGIF"));
819819
if (!read_logical_screen_descriptor(gfs, grr))

0 commit comments

Comments
 (0)