summaryrefslogtreecommitdiff
path: root/extra/giflib/giflib-4.2.1-quantize.patch
diff options
context:
space:
mode:
authorNicolás Reynolds <fauno@endefensadelsl.org>2014-01-01 16:37:20 -0300
committerNicolás Reynolds <fauno@endefensadelsl.org>2014-01-01 16:37:20 -0300
commit6124dfa10e2a69fc79efc85f611c8db582caf711 (patch)
treee9706ae64164967e8448140e9cb6534dfbb0a2a3 /extra/giflib/giflib-4.2.1-quantize.patch
parent385fda403f286573a778ee525fe56a86d11fc967 (diff)
parent5a81550adad5ccde4ad6924cfee2b2ef96d02c98 (diff)
Merge branch 'master' of gparabola:abslibre/abslibre-pre-mips64el
Conflicts: community/almanah/PKGBUILD community/audit/PKGBUILD community/bird/PKGBUILD community/blobby2/PKGBUILD community/blueman/PKGBUILD community/bomberclone/PKGBUILD community/botan/PKGBUILD community/cantata/PKGBUILD community/cinnamon-desktop/PKGBUILD community/cinnamon-settings-daemon/PKGBUILD community/cinnamon/PKGBUILD community/clearsilver/PKGBUILD community/clinica/PKGBUILD community/confuse/PKGBUILD community/deadbeef/PKGBUILD community/dvdrtools/PKGBUILD community/etl/PKGBUILD community/extremetuxracer/PKGBUILD community/fcitx-mozc/PKGBUILD community/flashrom/PKGBUILD community/freedroidrpg/PKGBUILD community/gcolor2/PKGBUILD community/geary/PKGBUILD community/glob2/PKGBUILD community/gnash/PKGBUILD community/gnome-commander/PKGBUILD community/gnome-settings-daemon-updates/PKGBUILD community/gnuchess/PKGBUILD community/haskell-bytestring-show/PKGBUILD community/haskell-hslogger/PKGBUILD community/haskell-vector/PKGBUILD community/hedgewars/PKGBUILD community/hitori/PKGBUILD community/inputattach/PKGBUILD community/jack2/PKGBUILD community/kid3/PKGBUILD community/lcdproc/PKGBUILD community/libcec/PKGBUILD community/libvirt/PKGBUILD community/libwww/PKGBUILD community/lightdm/PKGBUILD community/lincity-ng/PKGBUILD community/linux-tools/PKGBUILD community/linuxtv-dvb-apps/PKGBUILD community/lockdev/PKGBUILD community/log4cpp/PKGBUILD community/love/PKGBUILD community/luajit/PKGBUILD community/lxc/PKGBUILD community/metamail/PKGBUILD community/mingw32-binutils/PKGBUILD community/mingw32-gcc/PKGBUILD community/mingw32-pthreads/PKGBUILD community/mongodb/PKGBUILD community/nemo/PKGBUILD community/par2cmdline/PKGBUILD community/pdfedit/PKGBUILD community/perl-json-xs/PKGBUILD community/pidgin-talkfilters/PKGBUILD community/pokerth/PKGBUILD community/setconf/PKGBUILD community/stfl/PKGBUILD community/talkfilters/PKGBUILD community/tre/PKGBUILD community/ubuntuone-client-gnome/PKGBUILD community/ubuntuone-client/PKGBUILD community/vor/PKGBUILD community/warmux/PKGBUILD community/wdm/PKGBUILD community/xbmc-pvr-addons/PKGBUILD core/gcc/PKGBUILD core/lvm2/PKGBUILD core/systemd/PKGBUILD core/sysvinit-tools/PKGBUILD extra/aubio/PKGBUILD extra/avidemux/PKGBUILD extra/bluez4/PKGBUILD extra/boost/PKGBUILD extra/calligra/PKGBUILD extra/caribou/PKGBUILD extra/chemtool/PKGBUILD extra/cinepaint/PKGBUILD extra/conky/PKGBUILD extra/cups/PKGBUILD extra/enlightenment16/PKGBUILD extra/exo/PKGBUILD extra/fakechroot/PKGBUILD extra/farstream-0.1/PKGBUILD extra/ffmpeg-compat/PKGBUILD extra/fltk/PKGBUILD extra/git/PKGBUILD extra/gpart/PKGBUILD extra/gstreamer0.10-base/PKGBUILD extra/gstreamer0.10-ffmpeg/PKGBUILD extra/gstreamer0.10-good/PKGBUILD extra/gstreamer0.10-ugly/PKGBUILD extra/gtk-vnc/PKGBUILD extra/haveged/PKGBUILD extra/icewm/PKGBUILD extra/imagemagick/PKGBUILD extra/kactivities/PKGBUILD extra/kdeaccessibility-jovie/PKGBUILD extra/kdeaccessibility-kaccessible/PKGBUILD extra/kdeaccessibility-kmag/PKGBUILD extra/kdeaccessibility-kmousetool/PKGBUILD extra/kdeaccessibility-kmouth/PKGBUILD extra/kdeadmin-kcron/PKGBUILD extra/kdeadmin-ksystemlog/PKGBUILD extra/kdeadmin-kuser/PKGBUILD extra/kdeartwork/PKGBUILD extra/kdebase-konsole/PKGBUILD extra/kdebase-workspace/PKGBUILD extra/kdebase/PKGBUILD extra/kdebindings-kimono/PKGBUILD extra/kdebindings-korundum/PKGBUILD extra/kdebindings-kross/PKGBUILD extra/kdebindings-perlkde/PKGBUILD extra/kdebindings-perlqt/PKGBUILD extra/kdebindings-python/PKGBUILD extra/kdebindings-qtruby/PKGBUILD extra/kdebindings-qyoto/PKGBUILD extra/kdebindings-smokegen/PKGBUILD extra/kdebindings-smokekde/PKGBUILD extra/kdebindings-smokeqt/PKGBUILD extra/kdeedu-analitza/PKGBUILD extra/kdeedu-blinken/PKGBUILD extra/kdeedu-cantor/PKGBUILD extra/kdeedu-kalgebra/PKGBUILD extra/kdeedu-kalzium/PKGBUILD extra/kdeedu-kanagram/PKGBUILD extra/kdeedu-kbruch/PKGBUILD extra/kdeedu-kgeography/PKGBUILD extra/kdeedu-khangman/PKGBUILD extra/kdeedu-kig/PKGBUILD extra/kdeedu-kiten/PKGBUILD extra/kdeedu-klettres/PKGBUILD extra/kdeedu-kmplot/PKGBUILD extra/kdeedu-kstars/PKGBUILD extra/kdeedu-ktouch/PKGBUILD extra/kdeedu-kturtle/PKGBUILD extra/kdeedu-kwordquiz/PKGBUILD extra/kdeedu-marble/PKGBUILD extra/kdeedu-pairs/PKGBUILD extra/kdeedu-parley/PKGBUILD extra/kdeedu-rocs/PKGBUILD extra/kdeedu-step/PKGBUILD extra/kdegames-bomber/PKGBUILD extra/kdegames-bovo/PKGBUILD extra/kdegames-granatier/PKGBUILD extra/kdegames-kapman/PKGBUILD extra/kdegames-katomic/PKGBUILD extra/kdegames-kblackbox/PKGBUILD extra/kdegames-kblocks/PKGBUILD extra/kdegames-kbounce/PKGBUILD extra/kdegames-kbreakout/PKGBUILD extra/kdegames-kdiamond/PKGBUILD extra/kdegames-kfourinline/PKGBUILD extra/kdegames-kgoldrunner/PKGBUILD extra/kdegames-kigo/PKGBUILD extra/kdegames-killbots/PKGBUILD extra/kdegames-kiriki/PKGBUILD extra/kdegames-kjumpingcube/PKGBUILD extra/kdegames-klickety/PKGBUILD extra/kdegames-klines/PKGBUILD extra/kdegames-kmahjongg/PKGBUILD extra/kdegames-kmines/PKGBUILD extra/kdegames-knavalbattle/PKGBUILD extra/kdegames-knetwalk/PKGBUILD extra/kdegames-kolf/PKGBUILD extra/kdegames-kollision/PKGBUILD extra/kdegames-konquest/PKGBUILD extra/kdegames-kpatience/PKGBUILD extra/kdegames-kreversi/PKGBUILD extra/kdegames-kshisen/PKGBUILD extra/kdegames-ksirk/PKGBUILD extra/kdegames-ksnakeduel/PKGBUILD extra/kdegames-kspaceduel/PKGBUILD extra/kdegames-ksquares/PKGBUILD extra/kdegames-ksudoku/PKGBUILD extra/kdegames-ktuberling/PKGBUILD extra/kdegames-kubrick/PKGBUILD extra/kdegames-lskat/PKGBUILD extra/kdegames-palapeli/PKGBUILD extra/kdegames-picmi/PKGBUILD extra/kdegraphics-gwenview/PKGBUILD extra/kdegraphics-kamera/PKGBUILD extra/kdegraphics-kcolorchooser/PKGBUILD extra/kdegraphics-kgamma/PKGBUILD extra/kdegraphics-kolourpaint/PKGBUILD extra/kdegraphics-kruler/PKGBUILD extra/kdegraphics-ksaneplugin/PKGBUILD extra/kdegraphics-ksnapshot/PKGBUILD extra/kdegraphics-mobipocket/PKGBUILD extra/kdegraphics-okular/PKGBUILD extra/kdegraphics-strigi-analyzer/PKGBUILD extra/kdegraphics-svgpart/PKGBUILD extra/kdegraphics-thumbnailers/PKGBUILD extra/kdemultimedia-audiocd-kio/PKGBUILD extra/kdemultimedia-dragonplayer/PKGBUILD extra/kdemultimedia-ffmpegthumbs/PKGBUILD extra/kdemultimedia-juk/PKGBUILD extra/kdemultimedia-kmix/PKGBUILD extra/kdemultimedia-kscd/PKGBUILD extra/kdemultimedia-mplayerthumbs/PKGBUILD extra/kdenetwork-filesharing/PKGBUILD extra/kdenetwork-kdnssd/PKGBUILD extra/kdenetwork-kget/PKGBUILD extra/kdenetwork-kppp/PKGBUILD extra/kdenetwork-krdc/PKGBUILD extra/kdenetwork-krfb/PKGBUILD extra/kdenetwork-strigi-analyzers/PKGBUILD extra/kdepim-runtime/PKGBUILD extra/kdepim/PKGBUILD extra/kdepimlibs/PKGBUILD extra/kdeplasma-addons/PKGBUILD extra/kdesdk-cervisia/PKGBUILD extra/kdesdk-dev-scripts/PKGBUILD extra/kdesdk-dev-utils/PKGBUILD extra/kdesdk-dolphin-plugins/PKGBUILD extra/kdesdk-kapptemplate/PKGBUILD extra/kdesdk-kate/PKGBUILD extra/kdesdk-kcachegrind/PKGBUILD extra/kdesdk-kioslaves/PKGBUILD extra/kdesdk-kompare/PKGBUILD extra/kdesdk-lokalize/PKGBUILD extra/kdesdk-okteta/PKGBUILD extra/kdesdk-poxml/PKGBUILD extra/kdesdk-strigi-analyzers/PKGBUILD extra/kdesdk-thumbnailers/PKGBUILD extra/kdesdk-umbrello/PKGBUILD extra/kdetoys-amor/PKGBUILD extra/kdetoys-kteatime/PKGBUILD extra/kdetoys-ktux/PKGBUILD extra/kdeutils-filelight/PKGBUILD extra/kdeutils-kcalc/PKGBUILD extra/kdeutils-kcharselect/PKGBUILD extra/kdeutils-kdf/PKGBUILD extra/kdeutils-kfloppy/PKGBUILD extra/kdeutils-kgpg/PKGBUILD extra/kdeutils-kremotecontrol/PKGBUILD extra/kdeutils-ktimer/PKGBUILD extra/kdeutils-kwallet/PKGBUILD extra/kdeutils-print-manager/PKGBUILD extra/kdeutils-superkaramba/PKGBUILD extra/kdeutils-sweeper/PKGBUILD extra/kdewebdev/PKGBUILD extra/kino/PKGBUILD extra/libdrm/PKGBUILD extra/libiec61883/PKGBUILD extra/libkcddb/PKGBUILD extra/libkcompactdisc/PKGBUILD extra/libkdcraw/PKGBUILD extra/libkdeedu/PKGBUILD extra/libkdegames/PKGBUILD extra/libkexiv2/PKGBUILD extra/libkipi/PKGBUILD extra/libkmahjongg/PKGBUILD extra/libksane/PKGBUILD extra/libmikmod/PKGBUILD extra/libmp4v2/PKGBUILD extra/libnet/PKGBUILD extra/libpst/PKGBUILD extra/libsidplay/PKGBUILD extra/libsigsegv/PKGBUILD extra/libvpx/PKGBUILD extra/libxmi/PKGBUILD extra/lua51/PKGBUILD extra/mariadb/PKGBUILD extra/maxima/PKGBUILD extra/mesa/PKGBUILD extra/mjpegtools/PKGBUILD extra/mkvtoolnix/PKGBUILD extra/nepomuk-core/PKGBUILD extra/nepomuk-widgets/PKGBUILD extra/obexd/PKGBUILD extra/opencv/PKGBUILD extra/perl-dbd-mysql/PKGBUILD extra/phonon-gstreamer/PKGBUILD extra/phonon-vlc/PKGBUILD extra/phonon/PKGBUILD extra/plotutils/PKGBUILD extra/postgresql/PKGBUILD extra/pycrypto/PKGBUILD extra/python/PKGBUILD extra/qt4/PKGBUILD extra/qt5/PKGBUILD extra/rcs/PKGBUILD extra/rdesktop/PKGBUILD extra/rtmpdump/PKGBUILD extra/ruby/PKGBUILD extra/signon/PKGBUILD extra/sqlite/PKGBUILD extra/vigra/PKGBUILD extra/vim/PKGBUILD extra/vlc/PKGBUILD extra/w3m/PKGBUILD extra/wcslib/PKGBUILD extra/windowmaker/PKGBUILD extra/x264/PKGBUILD extra/xaos/PKGBUILD extra/xmlto/PKGBUILD libre/angband-libre/PKGBUILD libre/hplip-libre/PKGBUILD libre/kdebase-konqueror-libre/PKGBUILD libre/kdebase-runtime-libre/PKGBUILD libre/kdelibs-libre/PKGBUILD libre/kdenetwork-kopete-libre/PKGBUILD libre/kdepim-libre/PKGBUILD libre/kdeutils-ark-libre/PKGBUILD libre/linux-libre/PKGBUILD libre/mc-libre/PKGBUILD libre/xbmc-libre/PKGBUILD nonprism/kdenetwork-kopete-libre-nonprism/PKGBUILD nonprism/kdepim-runtime-nonprism/PKGBUILD pcr/libquvi-scripts-current/PKGBUILD
Diffstat (limited to 'extra/giflib/giflib-4.2.1-quantize.patch')
-rw-r--r--extra/giflib/giflib-4.2.1-quantize.patch679
1 files changed, 0 insertions, 679 deletions
diff --git a/extra/giflib/giflib-4.2.1-quantize.patch b/extra/giflib/giflib-4.2.1-quantize.patch
deleted file mode 100644
index f6745d2c0..000000000
--- a/extra/giflib/giflib-4.2.1-quantize.patch
+++ /dev/null
@@ -1,679 +0,0 @@
-From 7b01ed05d6c16172bd11a62d9b334f0eb7c5fc1e Mon Sep 17 00:00:00 2001
-From: "Eric S. Raymond" <esr@thyrsus.com>
-Date: Sun, 3 Jun 2012 07:59:30 -0400
-Subject: [PATCH] Return QuantizeBuffer() to the core library.
-
-Fulfils SourceForge FR 3531618.
----
- NEWS | 2 +
- lib/Makefile.am | 3 +-
- lib/gif_lib.h | 9 ++
- lib/quantize.c | 309 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- util/rgb2gif.c | 302 ------------------------------------------------------
- 5 files changed, 322 insertions(+), 303 deletions(-)
- create mode 100644 lib/quantize.c
-
-index 813a2f8..ae6d5fa 100644
---- a/lib/Makefile.am
-+++ b/lib/Makefile.am
-@@ -13,7 +13,8 @@ libgif_la_SOURCES = dgif_lib.c \
- gif_hash.h \
- gifalloc.c \
- gif_err.c \
-- gif_lib_private.h
-+ gif_lib_private.h \
-+ quantize.c
-
- libgif_la_LDFLAGS = -version-info @SHLIBVERSION@ $(LT_LDFLAGS)
- libgif_la_LIBADD = @DEVS@
-diff --git a/lib/gif_lib.h b/lib/gif_lib.h
-index e942089..73bc437 100644
---- a/lib/gif_lib.h
-+++ b/lib/gif_lib.h
-@@ -207,6 +207,15 @@ int DGifGetLZCodes(GifFileType *GifFile, int *GifCode);
-
-
- /******************************************************************************
-+ * O.K., here are the routines from GIF_LIB file QUANTIZE.C.
-+******************************************************************************/
-+int QuantizeBuffer(unsigned int Width, unsigned int Height,
-+ int *ColorMapSize, GifByteType * RedInput,
-+ GifByteType * GreenInput, GifByteType * BlueInput,
-+ GifByteType * OutputBuffer,
-+ GifColorType * OutputColorMap);
-+
-+/******************************************************************************
- * O.K., here are the routines from GIF_LIB file GIF_ERR.C.
- ******************************************************************************/
- extern int GifError(void); /* new in 2012 - ESR */
-diff --git a/lib/quantize.c b/lib/quantize.c
-new file mode 100644
-index 0000000..feb1dc7
---- /dev/null
-+++ b/lib/quantize.c
-@@ -0,0 +1,309 @@
-+/*****************************************************************************
-+ *
-+ * quantize.c - quantize a high resolution image into lower one
-+ *
-+ * Based on: "Color Image Quantization for frame buffer Display", by
-+ * Paul Heckbert SIGGRAPH 1982 page 297-307.
-+ *
-+ * This doesn't really belong in the core library, was undocumented,
-+ * and was removed in 4.2. Then it turned out some client apps were
-+ * actually using it, so it was restored in 5.0.
-+ *
-+ *****************************************************************************/
-+
-+#include <stdlib.h>
-+#include <stdio.h>
-+#include "gif_lib.h"
-+#include "gif_lib_private.h"
-+
-+#define ABS(x) ((x) > 0 ? (x) : (-(x)))
-+
-+#define COLOR_ARRAY_SIZE 32768
-+#define BITS_PER_PRIM_COLOR 5
-+#define MAX_PRIM_COLOR 0x1f
-+
-+static int SortRGBAxis;
-+
-+typedef struct QuantizedColorType {
-+ GifByteType RGB[3];
-+ GifByteType NewColorIndex;
-+ long Count;
-+ struct QuantizedColorType *Pnext;
-+} QuantizedColorType;
-+
-+typedef struct NewColorMapType {
-+ GifByteType RGBMin[3], RGBWidth[3];
-+ unsigned int NumEntries; /* # of QuantizedColorType in linked list below */
-+ unsigned long Count; /* Total number of pixels in all the entries */
-+ QuantizedColorType *QuantizedColors;
-+} NewColorMapType;
-+
-+static int SubdivColorMap(NewColorMapType * NewColorSubdiv,
-+ unsigned int ColorMapSize,
-+ unsigned int *NewColorMapSize);
-+static int SortCmpRtn(const void *Entry1, const void *Entry2);
-+
-+/******************************************************************************
-+ * Quantize high resolution image into lower one. Input image consists of a
-+ * 2D array for each of the RGB colors with size Width by Height. There is no
-+ * Color map for the input. Output is a quantized image with 2D array of
-+ * indexes into the output color map.
-+ * Note input image can be 24 bits at the most (8 for red/green/blue) and
-+ * the output has 256 colors at the most (256 entries in the color map.).
-+ * ColorMapSize specifies size of color map up to 256 and will be updated to
-+ * real size before returning.
-+ * Also non of the parameter are allocated by this routine.
-+ * This function returns GIF_OK if succesfull, GIF_ERROR otherwise.
-+ ******************************************************************************/
-+int
-+QuantizeBuffer(unsigned int Width,
-+ unsigned int Height,
-+ int *ColorMapSize,
-+ GifByteType * RedInput,
-+ GifByteType * GreenInput,
-+ GifByteType * BlueInput,
-+ GifByteType * OutputBuffer,
-+ GifColorType * OutputColorMap) {
-+
-+ unsigned int Index, NumOfEntries;
-+ int i, j, MaxRGBError[3];
-+ unsigned int NewColorMapSize;
-+ long Red, Green, Blue;
-+ NewColorMapType NewColorSubdiv[256];
-+ QuantizedColorType *ColorArrayEntries, *QuantizedColor;
-+
-+ ColorArrayEntries = (QuantizedColorType *)malloc(
-+ sizeof(QuantizedColorType) * COLOR_ARRAY_SIZE);
-+ if (ColorArrayEntries == NULL) {
-+ _GifError = E_GIF_ERR_NOT_ENOUGH_MEM;
-+ return GIF_ERROR;
-+ }
-+
-+ for (i = 0; i < COLOR_ARRAY_SIZE; i++) {
-+ ColorArrayEntries[i].RGB[0] = i >> (2 * BITS_PER_PRIM_COLOR);
-+ ColorArrayEntries[i].RGB[1] = (i >> BITS_PER_PRIM_COLOR) &
-+ MAX_PRIM_COLOR;
-+ ColorArrayEntries[i].RGB[2] = i & MAX_PRIM_COLOR;
-+ ColorArrayEntries[i].Count = 0;
-+ }
-+
-+ /* Sample the colors and their distribution: */
-+ for (i = 0; i < (int)(Width * Height); i++) {
-+ Index = ((RedInput[i] >> (8 - BITS_PER_PRIM_COLOR)) <<
-+ (2 * BITS_PER_PRIM_COLOR)) +
-+ ((GreenInput[i] >> (8 - BITS_PER_PRIM_COLOR)) <<
-+ BITS_PER_PRIM_COLOR) +
-+ (BlueInput[i] >> (8 - BITS_PER_PRIM_COLOR));
-+ ColorArrayEntries[Index].Count++;
-+ }
-+
-+ /* Put all the colors in the first entry of the color map, and call the
-+ * recursive subdivision process. */
-+ for (i = 0; i < 256; i++) {
-+ NewColorSubdiv[i].QuantizedColors = NULL;
-+ NewColorSubdiv[i].Count = NewColorSubdiv[i].NumEntries = 0;
-+ for (j = 0; j < 3; j++) {
-+ NewColorSubdiv[i].RGBMin[j] = 0;
-+ NewColorSubdiv[i].RGBWidth[j] = 255;
-+ }
-+ }
-+
-+ /* Find the non empty entries in the color table and chain them: */
-+ for (i = 0; i < COLOR_ARRAY_SIZE; i++)
-+ if (ColorArrayEntries[i].Count > 0)
-+ break;
-+ QuantizedColor = NewColorSubdiv[0].QuantizedColors = &ColorArrayEntries[i];
-+ NumOfEntries = 1;
-+ while (++i < COLOR_ARRAY_SIZE)
-+ if (ColorArrayEntries[i].Count > 0) {
-+ QuantizedColor->Pnext = &ColorArrayEntries[i];
-+ QuantizedColor = &ColorArrayEntries[i];
-+ NumOfEntries++;
-+ }
-+ QuantizedColor->Pnext = NULL;
-+
-+ NewColorSubdiv[0].NumEntries = NumOfEntries; /* Different sampled colors */
-+ NewColorSubdiv[0].Count = ((long)Width) * Height; /* Pixels */
-+ NewColorMapSize = 1;
-+ if (SubdivColorMap(NewColorSubdiv, *ColorMapSize, &NewColorMapSize) !=
-+ GIF_OK) {
-+ free((char *)ColorArrayEntries);
-+ return GIF_ERROR;
-+ }
-+ if (NewColorMapSize < *ColorMapSize) {
-+ /* And clear rest of color map: */
-+ for (i = NewColorMapSize; i < *ColorMapSize; i++)
-+ OutputColorMap[i].Red = OutputColorMap[i].Green =
-+ OutputColorMap[i].Blue = 0;
-+ }
-+
-+ /* Average the colors in each entry to be the color to be used in the
-+ * output color map, and plug it into the output color map itself. */
-+ for (i = 0; i < NewColorMapSize; i++) {
-+ if ((j = NewColorSubdiv[i].NumEntries) > 0) {
-+ QuantizedColor = NewColorSubdiv[i].QuantizedColors;
-+ Red = Green = Blue = 0;
-+ while (QuantizedColor) {
-+ QuantizedColor->NewColorIndex = i;
-+ Red += QuantizedColor->RGB[0];
-+ Green += QuantizedColor->RGB[1];
-+ Blue += QuantizedColor->RGB[2];
-+ QuantizedColor = QuantizedColor->Pnext;
-+ }
-+ OutputColorMap[i].Red = (Red << (8 - BITS_PER_PRIM_COLOR)) / j;
-+ OutputColorMap[i].Green = (Green << (8 - BITS_PER_PRIM_COLOR)) / j;
-+ OutputColorMap[i].Blue = (Blue << (8 - BITS_PER_PRIM_COLOR)) / j;
-+ }
-+ }
-+
-+ /* Finally scan the input buffer again and put the mapped index in the
-+ * output buffer. */
-+ MaxRGBError[0] = MaxRGBError[1] = MaxRGBError[2] = 0;
-+ for (i = 0; i < (int)(Width * Height); i++) {
-+ Index = ((RedInput[i] >> (8 - BITS_PER_PRIM_COLOR)) <<
-+ (2 * BITS_PER_PRIM_COLOR)) +
-+ ((GreenInput[i] >> (8 - BITS_PER_PRIM_COLOR)) <<
-+ BITS_PER_PRIM_COLOR) +
-+ (BlueInput[i] >> (8 - BITS_PER_PRIM_COLOR));
-+ Index = ColorArrayEntries[Index].NewColorIndex;
-+ OutputBuffer[i] = Index;
-+ if (MaxRGBError[0] < ABS(OutputColorMap[Index].Red - RedInput[i]))
-+ MaxRGBError[0] = ABS(OutputColorMap[Index].Red - RedInput[i]);
-+ if (MaxRGBError[1] < ABS(OutputColorMap[Index].Green - GreenInput[i]))
-+ MaxRGBError[1] = ABS(OutputColorMap[Index].Green - GreenInput[i]);
-+ if (MaxRGBError[2] < ABS(OutputColorMap[Index].Blue - BlueInput[i]))
-+ MaxRGBError[2] = ABS(OutputColorMap[Index].Blue - BlueInput[i]);
-+ }
-+
-+#ifdef DEBUG
-+ fprintf(stderr,
-+ "Quantization L(0) errors: Red = %d, Green = %d, Blue = %d.\n",
-+ MaxRGBError[0], MaxRGBError[1], MaxRGBError[2]);
-+#endif /* DEBUG */
-+
-+ free((char *)ColorArrayEntries);
-+
-+ *ColorMapSize = NewColorMapSize;
-+
-+ return GIF_OK;
-+}
-+
-+/******************************************************************************
-+ * Routine to subdivide the RGB space recursively using median cut in each
-+ * axes alternatingly until ColorMapSize different cubes exists.
-+ * The biggest cube in one dimension is subdivide unless it has only one entry.
-+ * Returns GIF_ERROR if failed, otherwise GIF_OK.
-+ ******************************************************************************/
-+static int
-+SubdivColorMap(NewColorMapType * NewColorSubdiv,
-+ unsigned int ColorMapSize,
-+ unsigned int *NewColorMapSize) {
-+
-+ int MaxSize;
-+ unsigned int i, j, Index = 0, NumEntries, MinColor, MaxColor;
-+ long Sum, Count;
-+ QuantizedColorType *QuantizedColor, **SortArray;
-+
-+ while (ColorMapSize > *NewColorMapSize) {
-+ /* Find candidate for subdivision: */
-+ MaxSize = -1;
-+ for (i = 0; i < *NewColorMapSize; i++) {
-+ for (j = 0; j < 3; j++) {
-+ if ((((int)NewColorSubdiv[i].RGBWidth[j]) > MaxSize) &&
-+ (NewColorSubdiv[i].NumEntries > 1)) {
-+ MaxSize = NewColorSubdiv[i].RGBWidth[j];
-+ Index = i;
-+ SortRGBAxis = j;
-+ }
-+ }
-+ }
-+
-+ if (MaxSize == -1)
-+ return GIF_OK;
-+
-+ /* Split the entry Index into two along the axis SortRGBAxis: */
-+
-+ /* Sort all elements in that entry along the given axis and split at
-+ * the median. */
-+ SortArray = (QuantizedColorType **)malloc(
-+ sizeof(QuantizedColorType *) *
-+ NewColorSubdiv[Index].NumEntries);
-+ if (SortArray == NULL)
-+ return GIF_ERROR;
-+ for (j = 0, QuantizedColor = NewColorSubdiv[Index].QuantizedColors;
-+ j < NewColorSubdiv[Index].NumEntries && QuantizedColor != NULL;
-+ j++, QuantizedColor = QuantizedColor->Pnext)
-+ SortArray[j] = QuantizedColor;
-+
-+ qsort(SortArray, NewColorSubdiv[Index].NumEntries,
-+ sizeof(QuantizedColorType *), SortCmpRtn);
-+
-+ /* Relink the sorted list into one: */
-+ for (j = 0; j < NewColorSubdiv[Index].NumEntries - 1; j++)
-+ SortArray[j]->Pnext = SortArray[j + 1];
-+ SortArray[NewColorSubdiv[Index].NumEntries - 1]->Pnext = NULL;
-+ NewColorSubdiv[Index].QuantizedColors = QuantizedColor = SortArray[0];
-+ free((char *)SortArray);
-+
-+ /* Now simply add the Counts until we have half of the Count: */
-+ Sum = NewColorSubdiv[Index].Count / 2 - QuantizedColor->Count;
-+ NumEntries = 1;
-+ Count = QuantizedColor->Count;
-+ while ((Sum -= QuantizedColor->Pnext->Count) >= 0 &&
-+ QuantizedColor->Pnext != NULL &&
-+ QuantizedColor->Pnext->Pnext != NULL) {
-+ QuantizedColor = QuantizedColor->Pnext;
-+ NumEntries++;
-+ Count += QuantizedColor->Count;
-+ }
-+ /* Save the values of the last color of the first half, and first
-+ * of the second half so we can update the Bounding Boxes later.
-+ * Also as the colors are quantized and the BBoxes are full 0..255,
-+ * they need to be rescaled.
-+ */
-+ MaxColor = QuantizedColor->RGB[SortRGBAxis]; /* Max. of first half */
-+ MinColor = QuantizedColor->Pnext->RGB[SortRGBAxis]; /* of second */
-+ MaxColor <<= (8 - BITS_PER_PRIM_COLOR);
-+ MinColor <<= (8 - BITS_PER_PRIM_COLOR);
-+
-+ /* Partition right here: */
-+ NewColorSubdiv[*NewColorMapSize].QuantizedColors =
-+ QuantizedColor->Pnext;
-+ QuantizedColor->Pnext = NULL;
-+ NewColorSubdiv[*NewColorMapSize].Count = Count;
-+ NewColorSubdiv[Index].Count -= Count;
-+ NewColorSubdiv[*NewColorMapSize].NumEntries =
-+ NewColorSubdiv[Index].NumEntries - NumEntries;
-+ NewColorSubdiv[Index].NumEntries = NumEntries;
-+ for (j = 0; j < 3; j++) {
-+ NewColorSubdiv[*NewColorMapSize].RGBMin[j] =
-+ NewColorSubdiv[Index].RGBMin[j];
-+ NewColorSubdiv[*NewColorMapSize].RGBWidth[j] =
-+ NewColorSubdiv[Index].RGBWidth[j];
-+ }
-+ NewColorSubdiv[*NewColorMapSize].RGBWidth[SortRGBAxis] =
-+ NewColorSubdiv[*NewColorMapSize].RGBMin[SortRGBAxis] +
-+ NewColorSubdiv[*NewColorMapSize].RGBWidth[SortRGBAxis] - MinColor;
-+ NewColorSubdiv[*NewColorMapSize].RGBMin[SortRGBAxis] = MinColor;
-+
-+ NewColorSubdiv[Index].RGBWidth[SortRGBAxis] =
-+ MaxColor - NewColorSubdiv[Index].RGBMin[SortRGBAxis];
-+
-+ (*NewColorMapSize)++;
-+ }
-+
-+ return GIF_OK;
-+}
-+
-+/****************************************************************************
-+ * Routine called by qsort to compare to entries.
-+ ****************************************************************************/
-+static int
-+SortCmpRtn(const void *Entry1,
-+ const void *Entry2) {
-+
-+ return (*((QuantizedColorType **) Entry1))->RGB[SortRGBAxis] -
-+ (*((QuantizedColorType **) Entry2))->RGB[SortRGBAxis];
-+}
-+
-+/* end */
-diff --git a/util/rgb2gif.c b/util/rgb2gif.c
-index 56386c7..46d9654 100644
---- a/util/rgb2gif.c
-+++ b/util/rgb2gif.c
-@@ -69,308 +69,6 @@ static void SaveGif(GifByteType *OutputBuffer,
- static void QuitGifError(GifFileType *GifFile);
-
- /******************************************************************************
-- * Code to quantize high resolution image into lower one. You may want to
-- * peek into the following article this code is based on:
-- * "Color Image Quantization for frame buffer Display", by Paul Heckbert
-- * SIGGRAPH 1982 page 297-307.
-- ******************************************************************************
-- * History:
-- * 5 Jan 90 - Version 1.0 by Gershon Elber.
-- *****************************************************************************/
--
--#define ABS(x) ((x) > 0 ? (x) : (-(x)))
--
--#define COLOR_ARRAY_SIZE 32768
--#define BITS_PER_PRIM_COLOR 5
--#define MAX_PRIM_COLOR 0x1f
--
--static int SortRGBAxis;
--
--typedef struct QuantizedColorType {
-- GifByteType RGB[3];
-- GifByteType NewColorIndex;
-- long Count;
-- struct QuantizedColorType *Pnext;
--} QuantizedColorType;
--
--typedef struct NewColorMapType {
-- GifByteType RGBMin[3], RGBWidth[3];
-- unsigned int NumEntries; /* # of QuantizedColorType in linked list below */
-- unsigned long Count; /* Total number of pixels in all the entries */
-- QuantizedColorType *QuantizedColors;
--} NewColorMapType;
--
--static int SubdivColorMap(NewColorMapType * NewColorSubdiv,
-- unsigned int ColorMapSize,
-- unsigned int *NewColorMapSize);
--static int SortCmpRtn(const void *Entry1, const void *Entry2);
--
--/******************************************************************************
-- * Quantize high resolution image into lower one. Input image consists of a
-- * 2D array for each of the RGB colors with size Width by Height. There is no
-- * Color map for the input. Output is a quantized image with 2D array of
-- * indexes into the output color map.
-- * Note input image can be 24 bits at the most (8 for red/green/blue) and
-- * the output has 256 colors at the most (256 entries in the color map.).
-- * ColorMapSize specifies size of color map up to 256 and will be updated to
-- * real size before returning.
-- * Also non of the parameter are allocated by this routine.
-- * This function returns GIF_OK if succesfull, GIF_ERROR otherwise.
-- ******************************************************************************/
--static int
--QuantizeBuffer(unsigned int Width,
-- unsigned int Height,
-- int *ColorMapSize,
-- GifByteType * RedInput,
-- GifByteType * GreenInput,
-- GifByteType * BlueInput,
-- GifByteType * OutputBuffer,
-- GifColorType * OutputColorMap) {
--
-- unsigned int Index, NumOfEntries;
-- int i, j, MaxRGBError[3];
-- unsigned int NewColorMapSize;
-- long Red, Green, Blue;
-- NewColorMapType NewColorSubdiv[256];
-- QuantizedColorType *ColorArrayEntries, *QuantizedColor;
--
-- ColorArrayEntries = (QuantizedColorType *)malloc(
-- sizeof(QuantizedColorType) * COLOR_ARRAY_SIZE);
-- if (ColorArrayEntries == NULL) {
-- return GIF_ERROR;
-- }
--
-- for (i = 0; i < COLOR_ARRAY_SIZE; i++) {
-- ColorArrayEntries[i].RGB[0] = i >> (2 * BITS_PER_PRIM_COLOR);
-- ColorArrayEntries[i].RGB[1] = (i >> BITS_PER_PRIM_COLOR) &
-- MAX_PRIM_COLOR;
-- ColorArrayEntries[i].RGB[2] = i & MAX_PRIM_COLOR;
-- ColorArrayEntries[i].Count = 0;
-- }
--
-- /* Sample the colors and their distribution: */
-- for (i = 0; i < (int)(Width * Height); i++) {
-- Index = ((RedInput[i] >> (8 - BITS_PER_PRIM_COLOR)) <<
-- (2 * BITS_PER_PRIM_COLOR)) +
-- ((GreenInput[i] >> (8 - BITS_PER_PRIM_COLOR)) <<
-- BITS_PER_PRIM_COLOR) +
-- (BlueInput[i] >> (8 - BITS_PER_PRIM_COLOR));
-- ColorArrayEntries[Index].Count++;
-- }
--
-- /* Put all the colors in the first entry of the color map, and call the
-- * recursive subdivision process. */
-- for (i = 0; i < 256; i++) {
-- NewColorSubdiv[i].QuantizedColors = NULL;
-- NewColorSubdiv[i].Count = NewColorSubdiv[i].NumEntries = 0;
-- for (j = 0; j < 3; j++) {
-- NewColorSubdiv[i].RGBMin[j] = 0;
-- NewColorSubdiv[i].RGBWidth[j] = 255;
-- }
-- }
--
-- /* Find the non empty entries in the color table and chain them: */
-- for (i = 0; i < COLOR_ARRAY_SIZE; i++)
-- if (ColorArrayEntries[i].Count > 0)
-- break;
-- QuantizedColor = NewColorSubdiv[0].QuantizedColors = &ColorArrayEntries[i];
-- NumOfEntries = 1;
-- while (++i < COLOR_ARRAY_SIZE)
-- if (ColorArrayEntries[i].Count > 0) {
-- QuantizedColor->Pnext = &ColorArrayEntries[i];
-- QuantizedColor = &ColorArrayEntries[i];
-- NumOfEntries++;
-- }
-- QuantizedColor->Pnext = NULL;
--
-- NewColorSubdiv[0].NumEntries = NumOfEntries; /* Different sampled colors */
-- NewColorSubdiv[0].Count = ((long)Width) * Height; /* Pixels */
-- NewColorMapSize = 1;
-- if (SubdivColorMap(NewColorSubdiv, *ColorMapSize, &NewColorMapSize) !=
-- GIF_OK) {
-- free((char *)ColorArrayEntries);
-- return GIF_ERROR;
-- }
-- if (NewColorMapSize < *ColorMapSize) {
-- /* And clear rest of color map: */
-- for (i = NewColorMapSize; i < *ColorMapSize; i++)
-- OutputColorMap[i].Red = OutputColorMap[i].Green =
-- OutputColorMap[i].Blue = 0;
-- }
--
-- /* Average the colors in each entry to be the color to be used in the
-- * output color map, and plug it into the output color map itself. */
-- for (i = 0; i < NewColorMapSize; i++) {
-- if ((j = NewColorSubdiv[i].NumEntries) > 0) {
-- QuantizedColor = NewColorSubdiv[i].QuantizedColors;
-- Red = Green = Blue = 0;
-- while (QuantizedColor) {
-- QuantizedColor->NewColorIndex = i;
-- Red += QuantizedColor->RGB[0];
-- Green += QuantizedColor->RGB[1];
-- Blue += QuantizedColor->RGB[2];
-- QuantizedColor = QuantizedColor->Pnext;
-- }
-- OutputColorMap[i].Red = (Red << (8 - BITS_PER_PRIM_COLOR)) / j;
-- OutputColorMap[i].Green = (Green << (8 - BITS_PER_PRIM_COLOR)) / j;
-- OutputColorMap[i].Blue = (Blue << (8 - BITS_PER_PRIM_COLOR)) / j;
-- } else
-- fprintf(stderr,
-- "\n%s: Null entry in quantized color map - that's weird.\n",
-- PROGRAM_NAME);
-- }
--
-- /* Finally scan the input buffer again and put the mapped index in the
-- * output buffer. */
-- MaxRGBError[0] = MaxRGBError[1] = MaxRGBError[2] = 0;
-- for (i = 0; i < (int)(Width * Height); i++) {
-- Index = ((RedInput[i] >> (8 - BITS_PER_PRIM_COLOR)) <<
-- (2 * BITS_PER_PRIM_COLOR)) +
-- ((GreenInput[i] >> (8 - BITS_PER_PRIM_COLOR)) <<
-- BITS_PER_PRIM_COLOR) +
-- (BlueInput[i] >> (8 - BITS_PER_PRIM_COLOR));
-- Index = ColorArrayEntries[Index].NewColorIndex;
-- OutputBuffer[i] = Index;
-- if (MaxRGBError[0] < ABS(OutputColorMap[Index].Red - RedInput[i]))
-- MaxRGBError[0] = ABS(OutputColorMap[Index].Red - RedInput[i]);
-- if (MaxRGBError[1] < ABS(OutputColorMap[Index].Green - GreenInput[i]))
-- MaxRGBError[1] = ABS(OutputColorMap[Index].Green - GreenInput[i]);
-- if (MaxRGBError[2] < ABS(OutputColorMap[Index].Blue - BlueInput[i]))
-- MaxRGBError[2] = ABS(OutputColorMap[Index].Blue - BlueInput[i]);
-- }
--
--#ifdef DEBUG
-- fprintf(stderr,
-- "Quantization L(0) errors: Red = %d, Green = %d, Blue = %d.\n",
-- MaxRGBError[0], MaxRGBError[1], MaxRGBError[2]);
--#endif /* DEBUG */
--
-- free((char *)ColorArrayEntries);
--
-- *ColorMapSize = NewColorMapSize;
--
-- return GIF_OK;
--}
--
--/******************************************************************************
-- * Routine to subdivide the RGB space recursively using median cut in each
-- * axes alternatingly until ColorMapSize different cubes exists.
-- * The biggest cube in one dimension is subdivide unless it has only one entry.
-- * Returns GIF_ERROR if failed, otherwise GIF_OK.
-- ******************************************************************************/
--static int
--SubdivColorMap(NewColorMapType * NewColorSubdiv,
-- unsigned int ColorMapSize,
-- unsigned int *NewColorMapSize) {
--
-- int MaxSize;
-- unsigned int i, j, Index = 0, NumEntries, MinColor, MaxColor;
-- long Sum, Count;
-- QuantizedColorType *QuantizedColor, **SortArray;
--
-- while (ColorMapSize > *NewColorMapSize) {
-- /* Find candidate for subdivision: */
-- MaxSize = -1;
-- for (i = 0; i < *NewColorMapSize; i++) {
-- for (j = 0; j < 3; j++) {
-- if ((((int)NewColorSubdiv[i].RGBWidth[j]) > MaxSize) &&
-- (NewColorSubdiv[i].NumEntries > 1)) {
-- MaxSize = NewColorSubdiv[i].RGBWidth[j];
-- Index = i;
-- SortRGBAxis = j;
-- }
-- }
-- }
--
-- if (MaxSize == -1)
-- return GIF_OK;
--
-- /* Split the entry Index into two along the axis SortRGBAxis: */
--
-- /* Sort all elements in that entry along the given axis and split at
-- * the median. */
-- SortArray = (QuantizedColorType **)malloc(
-- sizeof(QuantizedColorType *) *
-- NewColorSubdiv[Index].NumEntries);
-- if (SortArray == NULL)
-- return GIF_ERROR;
-- for (j = 0, QuantizedColor = NewColorSubdiv[Index].QuantizedColors;
-- j < NewColorSubdiv[Index].NumEntries && QuantizedColor != NULL;
-- j++, QuantizedColor = QuantizedColor->Pnext)
-- SortArray[j] = QuantizedColor;
--
-- qsort(SortArray, NewColorSubdiv[Index].NumEntries,
-- sizeof(QuantizedColorType *), SortCmpRtn);
--
-- /* Relink the sorted list into one: */
-- for (j = 0; j < NewColorSubdiv[Index].NumEntries - 1; j++)
-- SortArray[j]->Pnext = SortArray[j + 1];
-- SortArray[NewColorSubdiv[Index].NumEntries - 1]->Pnext = NULL;
-- NewColorSubdiv[Index].QuantizedColors = QuantizedColor = SortArray[0];
-- free((char *)SortArray);
--
-- /* Now simply add the Counts until we have half of the Count: */
-- Sum = NewColorSubdiv[Index].Count / 2 - QuantizedColor->Count;
-- NumEntries = 1;
-- Count = QuantizedColor->Count;
-- while (QuantizedColor->Pnext != NULL &&
-- (Sum -= QuantizedColor->Pnext->Count) >= 0 &&
-- QuantizedColor->Pnext->Pnext != NULL) {
-- QuantizedColor = QuantizedColor->Pnext;
-- NumEntries++;
-- Count += QuantizedColor->Count;
-- }
-- /* Save the values of the last color of the first half, and first
-- * of the second half so we can update the Bounding Boxes later.
-- * Also as the colors are quantized and the BBoxes are full 0..255,
-- * they need to be rescaled.
-- */
-- MaxColor = QuantizedColor->RGB[SortRGBAxis]; /* Max. of first half */
-- /* coverity[var_deref_op] */
-- MinColor = QuantizedColor->Pnext->RGB[SortRGBAxis]; /* of second */
-- MaxColor <<= (8 - BITS_PER_PRIM_COLOR);
-- MinColor <<= (8 - BITS_PER_PRIM_COLOR);
--
-- /* Partition right here: */
-- NewColorSubdiv[*NewColorMapSize].QuantizedColors =
-- QuantizedColor->Pnext;
-- QuantizedColor->Pnext = NULL;
-- NewColorSubdiv[*NewColorMapSize].Count = Count;
-- NewColorSubdiv[Index].Count -= Count;
-- NewColorSubdiv[*NewColorMapSize].NumEntries =
-- NewColorSubdiv[Index].NumEntries - NumEntries;
-- NewColorSubdiv[Index].NumEntries = NumEntries;
-- for (j = 0; j < 3; j++) {
-- NewColorSubdiv[*NewColorMapSize].RGBMin[j] =
-- NewColorSubdiv[Index].RGBMin[j];
-- NewColorSubdiv[*NewColorMapSize].RGBWidth[j] =
-- NewColorSubdiv[Index].RGBWidth[j];
-- }
-- NewColorSubdiv[*NewColorMapSize].RGBWidth[SortRGBAxis] =
-- NewColorSubdiv[*NewColorMapSize].RGBMin[SortRGBAxis] +
-- NewColorSubdiv[*NewColorMapSize].RGBWidth[SortRGBAxis] - MinColor;
-- NewColorSubdiv[*NewColorMapSize].RGBMin[SortRGBAxis] = MinColor;
--
-- NewColorSubdiv[Index].RGBWidth[SortRGBAxis] =
-- MaxColor - NewColorSubdiv[Index].RGBMin[SortRGBAxis];
--
-- (*NewColorMapSize)++;
-- }
--
-- return GIF_OK;
--}
--
--/****************************************************************************
-- * Routine called by qsort to compare two entries.
-- ****************************************************************************/
--static int
--SortCmpRtn(const void *Entry1,
-- const void *Entry2) {
--
-- return (*((QuantizedColorType **) Entry1))->RGB[SortRGBAxis] -
-- (*((QuantizedColorType **) Entry2))->RGB[SortRGBAxis];
--}
--/******************************************************************************
- * Interpret the command line and scan the given GIF file.
- ******************************************************************************/
- int main(int argc, char **argv)
---
-1.8.3.2
-