add giflib 5.0 patch

Package-Manager: portage-2.2.0_alpha188
RepoMan-Options: --force
This commit is contained in:
Mario Fetka 2013-11-20 08:50:07 +01:00
parent a4a6bb7979
commit a3d652e22e
4 changed files with 306 additions and 3 deletions

View File

@ -2,6 +2,11 @@
# Copyright 1999-2013 Gentoo Foundation; Distributed under the GPL v2
# $Header: $
20 Nov 2013; Mario Fetka <mario.fetka@gmail.com>
+files/libgdiplus-2.10.9-giflib-quantizebuffer.patch,
libgdiplus-2.6.7-r1.ebuild:
add giflib 5.0 patch
*libgdiplus-2.6.7-r1 (20 Apr 2013)
20 Apr 2013; Mario Fetka <mario.fetka@gmail.com>

View File

@ -1,6 +1,7 @@
AUX libgdiplus-2.10.1-libpng15.patch 5491 SHA256 ae18bac02341af98ed17b14ee510c33cc87d0637a9cf56fedaf21603aa04198c SHA512 292e8f83cd5a10c99a543a0fe85a9b2770e29627f60afd7e6ab7824b135870d9bfb20c8919ec9104110e645a039f69e7378d9295c330423a2725bb8840ceeffd WHIRLPOOL c33f9e5a164585411421d369ef728fd963367735bf8352567112603f7ce37b91246df517c005f25eb1153911b28af310400aaffec8605a939cdabaa2f5025cf6
AUX libgdiplus-2.10.9-giflib-quantizebuffer.patch 12869 SHA256 84d08006e21b667fd668d921b0d8db88f46e46cbed97d88372e092cf196c8e99 SHA512 3ad5ebd2bf9ef980dd273df9b036284d2217cee9ba09dbb6fa9d5b54da132eab0460597a63c53947d7d3f16b1079284413139937cc58b4694b102d1061e776c9 WHIRLPOOL b385e193652af68934d9400262554f7c9a42018a5a34b2452b859a4f2ad50c663313456efecbe86ce34a0fa9e7e55d4df50c44c8224b0dddfe16807e6dc26215
AUX libgdiplus-2.6.7-fix-overflows.patch 7963 SHA256 5e0143cf657d9dee39e4e2226816c5acf12616e329f469a7d468f2baf1630627 SHA512 e272c9e4c1b13b1b6b001a02cc8bc9196d5378ded866a6305958ecf949dee74d650416815fd47dd5d637b898f43f207fd7816bbe7778feec4926cf370388a574 WHIRLPOOL 3df48630e3203e99a2352f0d7442ff225ea7879cb0580d39a8cb39a27548a07613367b4f4907db14530967e48d9a0605aaecfbb324f3558087b0e0ed21a2c23c
DIST libgdiplus-2.6.7.tar.bz2 1960822 SHA256 7ebe427d6486cdab56fb6715e2d14a484e8ffe5cb6f183e133abca7d4f8f7144 SHA512 e476eded32280f7f87c1c98f7c2148cbe99d4134fb66e7af2fe49b21579a306c22f337b37c26babcf921bd21c2a17fe7aecd850c358dd8701ec8ede2e921f61c WHIRLPOOL 2149d6224c7898b6c65c042fafe8f08db2953f9b4502ea06cea0dd4f50b1bd73b64cb5568422f8b59e9b19e0cec2994db0655b1962cdb504001bd6c3ef4b2e7c
EBUILD libgdiplus-2.6.7-r1.ebuild 1276 SHA256 92e4414cc733bcd91758f3aa076dabba47dcd18dc8d1785f6d3df71b091fdc59 SHA512 74c574973dcfc8aab5c1afc729059a6e58287b5c935283b8e6827506f5eae05ff858c634f386bf136a7bcf6507b930330b3b506ba392af8f6db6bf1eeabb279d WHIRLPOOL 1a0e2b7297c4881721f4cf1a85a5d609a2cfaadb2371540d60002b46b9da368548101f8e37cf428dfef7423fed233826df1ed55a08a5510f697bf217a6a945a7
MISC ChangeLog 381 SHA256 6067986c223d2bc45b9df5dcd6592ff11d1cbd64c4dd3e43e4dca8b08d49999d SHA512 60a799f1adf37c314a0366744aed43d33b9b8f73ac274dd912ecdef04a7b725d03df96f113c37978259bffb70a2d5d639911dac05fe93f0c44578847bf35aab9 WHIRLPOOL 335b10c47d33d81be74cd7dc6e73b37ecf992f61d55abf749fd7a7133097ef333a5aff326b8ae19c6e090f72800b213a3210a2b0d89e9dd6ad56eed9151988dc
EBUILD libgdiplus-2.6.7-r1.ebuild 1337 SHA256 25cb46096b6e0507d7d704dcfca255eab42f52ae7118e6218650c9e56c005886 SHA512 bd979dfab9c9a9be618762dac80f2eba3140b20373dea6711380556e775aa504822625fda6c9fcf65f115258b18a8f32a9ede7e29158a09c89113c662fadf652 WHIRLPOOL e3030a497a7a98ddc1e8db1a459a5572d290032983af47db7fb34f912266cde2d12b0845b968dde2c63646699b39268b7152270e64a487aa209cf54c07661b30
MISC ChangeLog 542 SHA256 9b2ccc24eea8f9dcaf7d7e6fd88a59bd3e18e55b905ea0ec03476b908c4ccda5 SHA512 c9eea79357ee8d78d9f55061385dc5c8e1fb5d5c198527b2c69e0b6a853a3efcbbfcf6e52254b69d7202f08f1804819fbc1b36c7a4ea4aad34c1917b9391ccec WHIRLPOOL e3f7ffbf399b95f31bf211b6966ba34580195907c95d49f3a0a8f3f36f07321e9295ae18d9a9bff41aee5690a026920cb59e88474c96a2e114f89a1c44e72bd9
MISC metadata.xml 160 SHA256 1bc3e313a948415fff0dfa63a5610943327146bfe16bfeca603379bf9706a687 SHA512 087fcbf85988f071b9ce3491d0b6e1a767758e970950ef4247759ef48bcc4335c973dcc53b69fd712ac7e9704614878506fa342ba09edcf1c067e9ee478f94d7 WHIRLPOOL 65533bc6b7e60c26732efd476ed2c3aa0938bbea25140b8402ab2e05f0ac34c7a6d838ed7af763b2ec0a34317fcd8baf814f7c7ea8718ca5901160083d9525b8

View File

@ -0,0 +1,296 @@
diff -uNr libgdiplus-2.10.9/src/gifcodec.c libgdiplus-2.10.9-funtoo/src/gifcodec.c
--- libgdiplus-2.10.9/src/gifcodec.c 2011-12-02 18:23:12.000000000 +0100
+++ libgdiplus-2.10.9-funtoo/src/gifcodec.c 2013-10-08 18:06:44.643554570 +0200
@@ -39,6 +39,293 @@
#include "gifcodec.h"
+#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;
+
+
+/****************************************************************************
+ * 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];
+}
+
+/******************************************************************************
+ * 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;
+}
+
+/******************************************************************************
+ * 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",
+ "libgdiplus");
+ }
+
+ /* 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;
+}
+
/* giflib declares this incorrectly as EgifOpen */
extern GifFileType *EGifOpen(void *userData, OutputFunc writeFunc);

View File

@ -23,7 +23,7 @@ RDEPEND=">=dev-libs/glib-2.16
x11-libs/libXt
>=x11-libs/cairo-1.8.4[X]
media-libs/libexif
>=media-libs/giflib-4.1.3
>=media-libs/giflib-5.0
virtual/jpeg
media-libs/tiff
!cairo? ( >=x11-libs/pango-1.20 )"
@ -38,6 +38,7 @@ src_prepare() {
# Fix integer overflows when loading images, see bug #334101
epatch "${FILESDIR}/${P}-fix-overflows.patch"
epatch "${FILESDIR}/${PN}-2.10.1-libpng15.patch"
epatch "${FILESDIR}/${PN}-2.10.9-giflib-quantizebuffer.patch"
}
src_configure() {