summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--media-libs/gd/ChangeLog10
-rw-r--r--media-libs/gd/Manifest23
-rw-r--r--media-libs/gd/files/gd-2.1.1-webp-pre.patch28
-rw-r--r--media-libs/gd/files/gd-2.1.1-webp.patch409
-rw-r--r--media-libs/gd/gd-2.1.1-r1.ebuild62
5 files changed, 526 insertions, 6 deletions
diff --git a/media-libs/gd/ChangeLog b/media-libs/gd/ChangeLog
index 986015b5528c..ae5d957685fa 100644
--- a/media-libs/gd/ChangeLog
+++ b/media-libs/gd/ChangeLog
@@ -1,6 +1,14 @@
# ChangeLog for media-libs/gd
# Copyright 1999-2015 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/media-libs/gd/ChangeLog,v 1.108 2015/04/09 05:36:35 vapier Exp $
+# $Header: /var/cvsroot/gentoo-x86/media-libs/gd/ChangeLog,v 1.109 2015/04/09 05:37:20 vapier Exp $
+
+*gd-2.1.1-r1 (09 Apr 2015)
+
+ 09 Apr 2015; Mike Frysinger <vapier@gentoo.org>
+ +files/gd-2.1.1-webp-pre.patch, +files/gd-2.1.1-webp.patch,
+ +gd-2.1.1-r1.ebuild:
+ Backport upstream changes to move from libvpx to libwebp #545956 by Paweł
+ Hajdan, Jr..
08 Apr 2005; Mike Frysinger <vapier@gentoo.org> gd-2.1.1.ebuild:
Force older version of libvpx as the API has changed #545956 by Paweł Hajdan,
diff --git a/media-libs/gd/Manifest b/media-libs/gd/Manifest
index 9583e07ce1be..5906f41121c8 100644
--- a/media-libs/gd/Manifest
+++ b/media-libs/gd/Manifest
@@ -6,17 +6,30 @@ AUX gd-2.0.35-libpng-pkg-config.patch 4240 SHA256 26c4f66f6e74de830ab5c7276502e6
AUX gd-2.0.35-libpng14.patch 347 SHA256 b9f5e121ae652e211c866e1982bc6c37303d43b2a3df420be7069ca5fbb04bc4 SHA512 3ef9e82c09244512b4761a2ab669ae864b822344febfe203fb121cb43b7f99a933c7d5b44aea8b2d8a638010f5280a3ed2ac9d1ea526b25ad6f3d26b2586ba3d WHIRLPOOL 96df4515905928773542c7e3f4e9c3acdccd397b4e832973f33c6d45ab135f8798e3118be04d452da31d0f42e07ae4322efd720d264076fbe81020288ee6425e
AUX gd-2.0.35-maxcolors.patch 348 SHA256 c5dbbc7c1acd9e602fea8bf893333ca6258e7801761b6c899c7da62cd88cbc3b SHA512 c6474c9b2c3ad80d1a0fc8a345c4dbe86c51a73db3534c690a5d5e255ac6f20b474537f4f84aa8f083fc475a57b4bf0916f2d3120e94066f7729113355ee6aad WHIRLPOOL cd110bcca79501834890d80e19623f8e40dc2ed9fd49aac7109a30cbc9a966347c40502decb922b737acaf5c16a83c64f29e2215498596a419998bb5e6afd8f7
AUX gd-2.1.1-headers.patch 806 SHA256 6d148f2322398204842b8e2b212130ab91fd3a2402e780b6de0cf5f943ccab7b SHA512 b82bdd717bf7fa2b774331b5ea376252020775132ed124bc4a58873dd3a78e250d4c22c740eff0b10483e102d1521227705a1d2fda476eb9e8388df17a30fc2e WHIRLPOOL b3a46e253b24a34298b94ae7a88fbb23da0e257a184782e20ea657c48935c4457fb302ee2a27c4527d55ec1a81d3e345947198ee8cb53cdc6629ad3a44ad8610
+AUX gd-2.1.1-webp-pre.patch 728 SHA256 61dbf326558ee9591227c8d89006acabd286920dd1ba3ef8d23a7310f8e28b14 SHA512 10ea9828e69a8aa9d8d8eb8f5882c33ca9b345a311da45a16652eeb0d2df0fcbd31a540f64b938d779ddc906489b74940a6040db9b2d81a18c02a4b745d42bc8 WHIRLPOOL 2b60d70eba71d8435d5c3b8aea0405c8317ccdfac81457757b0bf0362ab9fe12b205a84c4ccff8cf183a99c2e4a54c4320b1c237c9213c6908c0aeabdd4fa6f2
+AUX gd-2.1.1-webp.patch 10507 SHA256 42bee351091e741c6b14381c76aacbe15434b0aae84a40c8e09f92b19fc28074 SHA512 249e1ef0488b038047a6c59aa4aea727a27b7fe4a18d5ec41786feba494044370a57d82c7423bf1dd8a257e12c927bfbc4d94ce68e15505b72d14f960e563a94 WHIRLPOOL 95b733c7ef7c88449efe866fffcc55cc9708aca824f8ebac55f588a1cb95c47281d343624a97d596df1bdd2cb41b2980e02dbe79f34ca37f0d2835078c2d2fb1
DIST gd-2.0.35.tar.bz2 1212730 SHA256 bf222490749d2a9a9ac3593b01eb55aed98461ff81202414707f61b42aa300f9 SHA512 eef8150adc040bed920155337211864a41ae3c4532e852ad443a3a3b9ffdc7fd3130698041b7b19b0b1207e78a80c263c6da26eba7208cdeeff78283c7d0d281 WHIRLPOOL 9eca23a184106652ef5c19ee3b5c18e23d742e21103c66907bf829910b95aa92eea7620c5579bf493c14730bc0327a4d662ffaf9bf9a5538127b8c10cc9c6b84
DIST libgd-2.1.1.tar.xz 2039132 SHA256 9ada1ed45594abc998ebc942cef12b032fbad672e73efc22bc9ff54f5df2b285 SHA512 48f444402a4b89e412870f9091b92eb26136c5c0d795722262ad973c7d4103476204a2de36133a2634b8f410d6bccdcf60afb829a74ac2fddfb96aff2cd2567b WHIRLPOOL a38cf1f060db35d247b54038e731484e6230cd8a9da263a8c4823aaf6b3ce455c0747bbbde60f131d85a48340e39a5c8d6273fa51366cbe2436530520211a238
EBUILD gd-2.0.35-r3.ebuild 2178 SHA256 ed123dac454522595faf717457793cab4b5ded7fb461612c0833863bef2313c9 SHA512 179fcb75f4d62e3b6fa025d5ed660698bf677628cd6f14b28a9626f3f79bb3afb18ac60765e46e8a07cc9c149d7c63583ada89bc14bc7cf0b4ef109262614432 WHIRLPOOL 0d419bf2fdd0e00a38d95079eeda90f4300a59f21cfaa2efa766d56a1545acbf81838937d7aabd520108bbf9e5db57f0e28330d3d903372bafad1a73b52a7e1d
EBUILD gd-2.0.35-r4.ebuild 3571 SHA256 f6e1d679a6f1a979fe22a15fca524dea81c56695af7c7f35eff4a17056318978 SHA512 d361e7599cfe9cb0f03e2bace75d21cbfd0c603542ed425a2de1f90fdd35b31436ffb814e826488f32d596bdc9e2ea53dbd0cee87eb0b3a90110f6dc55710351 WHIRLPOOL e69170a5f0978a0c10e14dd27ff0daad3644e23f9f71f1f46eee4e76514873f8e261145ec254434f426c713ce49ac7018c9626e3aa4ee36b4017e9b0105a4041
-EBUILD gd-2.1.1.ebuild 2081 SHA256 adc8845ff59150f7f4881d5a9ffb22adb6f6fba84d15b72fefadad197e994818 SHA512 532e05fba38eb50825774b7c38a9a20c9f43590b6e21584bbeb5f2ae00ca055cb3c2d34ab14463088507089bf71d447984690ce53ab5fd6aec1489fb9e5ed27b WHIRLPOOL 0c00ae721c3abba910a5d32a419008f881a9e0759cd9daed2a5e417511c2d1ac65f14d76976713d307b33bab72d905807eead01350c2db2a669a51cacfbdb991
-MISC ChangeLog 19534 SHA256 5cb69df576b62f6781e6b1abb7dfff7f5acf0fbbe33b3a72346363d77a3e9899 SHA512 b65f2de9e1b0fc1b4eb925fc26672da6d7dd6fae1b80246af36f41f91c1d84b8b25f15c1ac47483eaa4e7718a1d0ef0f9bdd9ede842b634b7d598ecb5a8ec298 WHIRLPOOL a0ae4ce9b40a6a52432fee8d27ad64ecb02f76fdf74cd1c34461927e1e29bd75e53e556a8a63583295e47fe809559be4fddca6031ec7237bee5681da92f7cd15
+EBUILD gd-2.1.1-r1.ebuild 2207 SHA256 4fde733631cc571474e2818feb8d391021c1e799bb359566066d3b1f7db2d734 SHA512 e13b0ac56be8b36afd7bc2ef5413c95b97b84c8699b030d19b6f3996d4b918d137ed1f849cf03f485158364a8384ce2e850aa585a657314ab57cb0b567a3fc10 WHIRLPOOL 6209aef11a66f0ecc80b1df054787f6ad2055843bef5b86c06127aa30b4679c5b04d33b7ce3dbe91d691692e2a57838e86970236281180287dd4c0b93ada6ee2
+EBUILD gd-2.1.1.ebuild 2094 SHA256 812eb44358104e2e3d16784731a4c657ad3b07c654f84d070ccabd8eadaee357 SHA512 f521a56900d6e347e6a479b1043b81fd656e570c99bb0121fc599c1ca5aa7f9aafd95fb2aef076bb891146e26ae5195a9f8a9a106ce73436c27cf2c836539d98 WHIRLPOOL 77f6dbd279a0734fbc66ed9c9449fd9255bd76321aed3bd7c3a9d7f321745f4d9454ecc4c9130b73e5d5f6329c617beb8eddf8dee02330e3991560c520fc07c6
+MISC ChangeLog 19944 SHA256 bc5f4ceca47021c4b9ad538b12a43d91cb7bce0ed37c9c29952ba61282ca43ee SHA512 9487b850f55ee358535a904bb7f50e85b2ca9b49db12f181b516b781dd808d3fc8942a156fc9c099dd4d133933ce498844c543b156d1c48a433c84c5ed02e0f0 WHIRLPOOL e7f1df54a74acdaed08a3932c7f1fed465a50a8f2e8a841f8965dafcb46be34016a284915383412ffd1e7253e436f5c57edb938f989f05910de8991f914aec17
MISC metadata.xml 1404 SHA256 464820e152ab174b394ec5cb70eff4d25de5aeb9333a754ace4bed387b80a586 SHA512 c7740d681f3ba8d59da914002c61b9110a2050cf3b5c82ef68a765a2674ce2f2e5f11de9861ddba4ed13b888d072029c63fc9df2a59537ce2b4f2f7dfd4c0a9d WHIRLPOOL 5cbf925c5a258d8089c7601ee8050bdbc02bc423b55b36759a32d83d3476b042c1379bd7cf42a46e5273afb3c67e47aac7b28512cb20c9342b9de225cae19fe3
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2
-iEYEAREIAAYFAlUN2UIACgkQX3X2B8XHTonmagCcD17lNJFaZrc3YM6UrpRfQdR+
-1oQAn2SU52UK0odIrvPhprXIU9l2Rc0D
-=05Ma
+iQIcBAEBCAAGBQJVJhARAAoJEPGu1DbS6WIAH5UP/1BRR9R0lOdvn96EnE6FLBa5
+L8c9RO63eFlWO5m10G55X0CZh/AiK0WbAQ/15tvX1Y+Y4h616oojD8FHc888jnlp
+zBUYOIyt4n1zrYTSmS37b31tlJOjliKeu0rxYKxTKt3q93/g61TZ+m2rPAnp5Wwf
+CldkldpuaWTP1haejW149rylQD2fqX2fBoyLclr9r+LlW8SC3V5ZR2drMOILK30Y
+mF+d/9BFzycdezw11gLPf91hAMzyDoH64ZsQ9JR22UWalsAY3m67dZAFS28B7DYT
+mSfbgJ/vnspPhzlgVdnNDTzYW37d6qUXHsXwfiUs1qoJNmGbERfg7A9dkyoqNpRn
+CBH3bM7RGdPJEliUv25kCRzhn2Oe4PqjNH4HpTq5w/S31tR6sOXTG+HwOMvMx5N4
+bYzVvTjLl/4Z1/ElvkFeLXAhMrzHVfvut9F55dfhxZ/KAOGuZiMSDQ+IVJCvsH5D
+t7D6hjnb0ZAGNAZBBC6BgTD7HwxHuGaYqXTly461/30iye45scBUhD1W4oBdIPWw
+k+KK276De0mpkyjnbTI4TF6S12vMwQxcd5Ph9fWqj9qmx1nKLMZJgtIGIxJ31sZG
+2B/qCgMj6TEjrh5Nk73x/cI3dwB5gjFHU8y883oZOV+HF56gyzjwS3Ldmg4lWhB0
+LkyZimzk5M9vX08fV1kk
+=T8Sy
-----END PGP SIGNATURE-----
diff --git a/media-libs/gd/files/gd-2.1.1-webp-pre.patch b/media-libs/gd/files/gd-2.1.1-webp-pre.patch
new file mode 100644
index 000000000000..766a4cbda24e
--- /dev/null
+++ b/media-libs/gd/files/gd-2.1.1-webp-pre.patch
@@ -0,0 +1,28 @@
+https://bugs.gentoo.org/545956
+
+From c7e5dc617c7466c44935cdefbe7e79de319f98ca Mon Sep 17 00:00:00 2001
+From: Pierre Joye <pierre.php@gmail.com>
+Date: Sat, 17 Jan 2015 08:20:17 +0100
+Subject: [PATCH] fix #111, invalid default quantization
+
+---
+ src/gd_webp.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/src/gd_webp.c b/src/gd_webp.c
+index fae3861..a3ae1ac 100644
+--- a/src/gd_webp.c
++++ b/src/gd_webp.c
+@@ -185,6 +185,9 @@ BGD_DECLARE(void) gdImageWebpCtx (gdImagePtr im, gdIOCtx * outfile, int quantiza
+ gd_error("gd-webp error: cannot allocate Y buffer");
+ return;
+ }
++ if (quantization == -1) {
++ quantization = 80;
++ }
+ vp8_quality = mapQualityToVP8QP(quantization);
+
+ U = Y + width * height;
+--
+2.3.5
+
diff --git a/media-libs/gd/files/gd-2.1.1-webp.patch b/media-libs/gd/files/gd-2.1.1-webp.patch
new file mode 100644
index 000000000000..93d91552fe45
--- /dev/null
+++ b/media-libs/gd/files/gd-2.1.1-webp.patch
@@ -0,0 +1,409 @@
+https://bugs.gentoo.org/545956
+
+From a79232c5fa692c3b6e3f5bc95ecfc455424c3f54 Mon Sep 17 00:00:00 2001
+From: Pierre Joye <pierre.php@gmail.com>
+Date: Tue, 20 Jan 2015 04:55:11 +0100
+Subject: [PATCH] fix #129, drop VPX usage in favor of libwebp
+
+---
+ configure.ac | 80 +++++------------
+ src/gd_webp.c | 231 +++++++++++++++++++++-----------------------------
+ tests/Makefile.am | 2 +-
+ tests/webp/bug00111.c | 2 +-
+ 4 files changed, 122 insertions(+), 193 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index 1024a3a..8923186 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -317,63 +317,6 @@ if test "$with_xpm" != no; then
+ fi
+ AM_CONDITIONAL([HAVE_LIBXPM], test "$with_xpm" = yes)
+
+-dnl check for libvpx by default
+-AC_ARG_WITH(vpx,dnl
+-[ --with-vpx=DIR where to find the vpx library])
+-
+-case $with_vpx in
+-no) ;;
+-yes|"")
+- PKG_CHECK_MODULES([LIBVPX], vpx, [with_vpx=yes],
+- [
+- PKG_CHECK_MODULES([LIBVPX], libvpx, [with_vpx=yes],
+- [
+- if test "$with_vpx" = yes; then
+- AC_MSG_ERROR([VPX support requested, but not found])
+- fi
+- with_vpx=no
+- ])
+- ])
+- ;;
+-*)
+- save_LIBS="$LIBS"
+- save_CPPFLAGS="$CPPFLAGS"
+-
+- if test -d "$with_vpx"; then
+- LIBVPX_CFLAGS="-I$with_vpx/include"
+- LIBVPX_LIBS="-L$with_vpx/lib -lvpx"
+- fi
+-
+- CPPFLAGS="$CPPFLAGS $LIBVPX_CFLAGS"
+- LIBS="$LIBS $LIBVPX_LIBS"
+-
+- AC_CHECK_LIB(vpx,vpx_codec_destroy,
+- [
+- if test -z "$LIBVPX_LIBS"; then
+- LIBVPX_LIBS="-lvpx"
+- fi
+- with_vpx=yes
+- ],[
+- if test "$with_vpx" != ""; then
+- AC_MSG_ERROR([vpx support requested, but not found])
+- else
+- with_vpx=no
+- fi
+- ])
+-
+- CPPFLAGS="$save_CPPFLAGS"
+- LIBS="$save_LIBS"
+- ;;
+-esac
+-
+-if test "$with_vpx" != no; then
+- CPPFLAGS="$CPPFLAGS $LIBVPX_CFLAGS"
+- LIBS="$LIBS $LIBVPX_LIBS"
+- FEATURES="GD_VPX $FEATURES"
+- AC_DEFINE(HAVE_LIBVPX, 1, [ Define if you have the VPX library. ])
+-fi
+-AM_CONDITIONAL([HAVE_LIBVPX], test "$with_vpx" = yes)
+-
+ dnl check for libtiff by default
+ AC_ARG_WITH(tiff,dnl
+ [ --with-tiff=DIR where to find the TIFF library])
+@@ -437,6 +380,27 @@ if test "$mingw_cv_win32_host" = yes; then
+ AC_DEFINE([BGDWIN32], [], [Define is you are building for Win32 API])
+ fi
+
++
++dnl check for libwebp by default
++AC_ARG_WITH(webp,dnl
++[ --with-webp=DIR where to find the webp library],
++ [if test -d "$withval"; then
++ LDFLAGS="$LDFLAGS -L$withval/lib"
++ CFLAGS="$CFLAGS -I$withval/include"
++ fi],
++ withval=yes)
++
++if test "$withval" != no; then
++ AC_CHECK_LIB(webp,WebPGetInfo,
++ [LIBS="-lwebp $LIBS"
++ FEATURES="GD_WEBP $FEATURES"
++ AC_DEFINE(HAVE_LIBWEBP, 1, [ Define if you have the webp library. ])])
++ with_webp=yes
++else
++ with_webp=no
++fi
++AM_CONDITIONAL([HAVE_LIBWEBP], test "$with_webp" = yes)
++
+ dnl report configuration
+ AC_MSG_RESULT([
+ ** Configuration summary for $PACKAGE $VERSION:
+@@ -444,7 +408,7 @@ AC_MSG_RESULT([
+ Support for Zlib: $with_zlib
+ Support for PNG library: $with_png
+ Support for JPEG library: $ac_cv_lib_jpeg_jpeg_set_defaults
+- Support for VPX library: $with_vpx
++ Support for WebP library: $with_webp
+ Support for TIFF library: $with_tiff
+ Support for Freetype 2.x library: $with_freetype
+ Support for Fontconfig library: $with_fontconfig
+diff --git a/src/gd_webp.c b/src/gd_webp.c
+index a3ae1ac..c44bd80 100644
+--- a/src/gd_webp.c
++++ b/src/gd_webp.c
+@@ -2,33 +2,21 @@
+ #include "config.h"
+ #endif /* HAVE_CONFIG_H */
+
++
++#ifdef HAVE_LIBWEBP
+ #include <stdio.h>
+ #include <math.h>
+ #include <string.h>
+ #include <stdlib.h>
+ #include "gd.h"
+ #include "gd_errors.h"
+-
+-#ifdef HAVE_LIBVPX
+-#include "webpimg.h"
+ #include "gdhelpers.h"
++#include "webp/decode.h"
++#include "webp/encode.h"
+
+-extern void gd_YUV420toRGBA(uint8* Y,
+- uint8* U,
+- uint8* V,
+- gdImagePtr im);
+-
+-extern void gd_RGBAToYUV420(gdImagePtr im2,
+- uint8* Y,
+- uint8* U,
+- uint8* V);
+-
+-const char * gdWebpGetVersionString()
+-{
+- return "not defined";
+-}
++#define GD_WEBP_ALLOC_STEP (4*1024)
+
+-BGD_DECLARE(gdImagePtr) gdImageCreateFromWebp (FILE * inFile)
++gdImagePtr gdImageCreateFromWebp (FILE * inFile)
+ {
+ gdImagePtr im;
+ gdIOCtx *in = gdNewFileCtx(inFile);
+@@ -38,42 +26,16 @@ BGD_DECLARE(gdImagePtr) gdImageCreateFromWebp (FILE * inFile)
+ return im;
+ }
+
+-BGD_DECLARE(gdImagePtr) gdImageCreateFromWebpPtr (int size, void *data)
++gdImagePtr gdImageCreateFromWebpCtx (gdIOCtx * infile)
+ {
+- int width, height, ret;
+- unsigned char *Y = NULL;
+- unsigned char *U = NULL;
+- unsigned char *V = NULL;
+- gdImagePtr im;
+-
+- ret = WebPDecode(data, size, &Y, &U, &V, &width, &height);
+- if (ret != webp_success) {
+- if (Y) free(Y);
+- if (U) free(U);
+- if (V) free(V);
+- gd_error("WebP decode: fail to decode input data");
+- return NULL;
+- }
+- im = gdImageCreateTrueColor(width, height);
+- if (!im) {
+- return NULL;
+- }
+- gd_YUV420toRGBA(Y, U, V, im);
+- return im;
+-}
+-
+-#define GD_WEBP_ALLOC_STEP (4*1024)
+-
+-BGD_DECLARE(gdImagePtr) gdImageCreateFromWebpCtx (gdIOCtx * infile)
+-{
+- int width, height, ret;
+- unsigned char *filedata = NULL;
++ int width, height;
++ uint8_t *filedata = NULL;
++ uint8_t *argb = NULL;
+ unsigned char *read, *temp;
+- unsigned char *Y = NULL;
+- unsigned char *U = NULL;
+- unsigned char *V = NULL;
+ size_t size = 0, n;
+ gdImagePtr im;
++ int x, y;
++ uint8_t *p;
+
+ do {
+ temp = gdRealloc(filedata, size+GD_WEBP_ALLOC_STEP);
+@@ -89,23 +51,97 @@ BGD_DECLARE(gdImagePtr) gdImageCreateFromWebpCtx (gdIOCtx * infile)
+ }
+
+ n = gdGetBuf(read, GD_WEBP_ALLOC_STEP, infile);
+- size += n;
+- } while (n>0);
++ if (n>0 && n!=EOF) {
++ size += n;
++ }
++ } while (n>0 && n!=EOF);
+
+- ret = WebPDecode(filedata, size, &Y, &U, &V, &width, &height);
+- gdFree(filedata);
+- if (ret != webp_success) {
+- if (Y) free(Y);
+- if (U) free(U);
+- if (V) free(V);
+- gd_error("WebP decode: fail to decode input data");
++ if (WebPGetInfo(filedata,size, &width, &height) == 0) {
++ gd_error("gd-webp cannot get webp info");
+ return NULL;
+ }
++
+ im = gdImageCreateTrueColor(width, height);
+- gd_YUV420toRGBA(Y, U, V, im);
++ if (!im) {
++ return NULL;
++ }
++ argb = WebPDecodeARGB(filedata, size, &width, &height);
++ if (!argb) {
++ gd_error("gd-webp cannot allocate temporary buffer");
++ gdFree(argb);
++ return NULL;
++ }
++ for (y = 0, p = argb; y < height; y++) {
++ for (x = 0; x < width; x++) {
++ register uint8_t a = gdAlphaMax - (*(p++) >> 1);
++ register uint8_t r = *(p++);
++ register uint8_t g = *(p++);
++ register uint8_t b = *(p++);
++ im->tpixels[y][x] = gdTrueColorAlpha(r, g, b, a);
++ }
++ }
++ gdFree(filedata);
++ free(argb);
++ im->saveAlphaFlag = 1;
+ return im;
+ }
+
++void gdImageWebpCtx (gdImagePtr im, gdIOCtx * outfile, int quantization)
++{
++ uint8_t *argb;
++ int x, y;
++ uint8_t *p;
++ uint8_t *out;
++ size_t out_size;
++
++ if (im == NULL) {
++ return;
++ }
++
++ if (!gdImageTrueColor(im)) {
++ gd_error("Paletter image not supported by webp");
++ return;
++ }
++
++ if (quantization == -1) {
++ quantization = 80;
++ }
++
++ argb = (uint8_t *)gdMalloc(gdImageSX(im) * 4 * gdImageSY(im));
++ if (!argb) {
++ return;
++ }
++ p = argb;
++ for (y = 0; y < gdImageSY(im); y++) {
++ for (x = 0; x < gdImageSX(im); x++) {
++ register int c;
++ register char a;
++ c = im->tpixels[y][x];
++ a = gdTrueColorGetAlpha(c);
++ if (a == 127) {
++ a = 0;
++ } else {
++ a = 255 - ((a << 1) + (a >> 6));
++ }
++ *(p++) = gdTrueColorGetRed(c);
++ *(p++) = gdTrueColorGetGreen(c);
++ *(p++) = gdTrueColorGetBlue(c);
++ *(p++) = a;
++ }
++ }
++ out_size = WebPEncodeRGBA(argb, gdImageSX(im), gdImageSY(im), gdImageSX(im) * 4, quantization, &out);
++ printf("outsize: %i\n", out_size);
++ if (out_size == 0) {
++ gd_error("gd-webp encoding failed");
++ goto freeargb;
++ }
++ gdPutBuf(out, out_size, outfile);
++ free(out);
++
++freeargb:
++ gdFree(argb);
++}
++
+ BGD_DECLARE(void) gdImageWebpEx (gdImagePtr im, FILE * outFile, int quantization)
+ {
+ gdIOCtx *out = gdNewFileCtx(outFile);
+@@ -116,7 +152,7 @@ BGD_DECLARE(void) gdImageWebpEx (gdImagePtr im, FILE * outFile, int quantization
+ BGD_DECLARE(void) gdImageWebp (gdImagePtr im, FILE * outFile)
+ {
+ gdIOCtx *out = gdNewFileCtx(outFile);
+- gdImageWebpCtx(im, out, -1);
++ gdImageWebpCtx(im, out, -1);
+ out->gd_free(out);
+ }
+
+@@ -140,75 +176,4 @@ BGD_DECLARE(void *) gdImageWebpPtrEx (gdImagePtr im, int *size, int quantization
+ out->gd_free(out);
+ return rv;
+ }
+-
+-/*
+- * Maps normalized QP (quality) to VP8 QP
+- */
+-int mapQualityToVP8QP(int quality) {
+-#define MIN_QUALITY 0
+-#define MAX_QUALITY 100
+-#define MIN_VP8QP 1
+-#define MAX_VP8QP 63
+- const float scale = MAX_VP8QP - MIN_VP8QP;
+- const float vp8qp =
+- scale * (MAX_QUALITY - quality) / (MAX_QUALITY - MIN_QUALITY) + MIN_VP8QP;
+- if (quality < MIN_QUALITY || quality > MAX_QUALITY) {
+- gd_error("Wrong quality value %d.", quality);
+- return -1;
+- }
+-
+- return (int)(vp8qp + 0.5);
+-}
+-
+-/* This routine is based in part on code from Dale Lutz (Safe Software Inc.)
+- * and in part on demo code from Chapter 15 of "PNG: The Definitive Guide"
+- * (http://www.cdrom.com/pub/png/pngbook.html).
+- */
+-BGD_DECLARE(void) gdImageWebpCtx (gdImagePtr im, gdIOCtx * outfile, int quantization)
+-{
+- int width = im->sx;
+- int height = im->sy;
+-
+- int yuv_width, yuv_height, yuv_nbytes, ret;
+- int vp8_quality;
+- unsigned char *Y = NULL,
+- *U = NULL,
+- *V = NULL;
+- unsigned char *filedata = NULL;
+-
+- /* Conversion to Y,U,V buffer */
+- yuv_width = (width + 1) >> 1;
+- yuv_height = (height + 1) >> 1;
+- yuv_nbytes = width * height + 2 * yuv_width * yuv_height;
+-
+- if ((Y = (unsigned char *)gdCalloc(yuv_nbytes, sizeof(unsigned char))) == NULL) {
+- gd_error("gd-webp error: cannot allocate Y buffer");
+- return;
+- }
+- if (quantization == -1) {
+- quantization = 80;
+- }
+- vp8_quality = mapQualityToVP8QP(quantization);
+-
+- U = Y + width * height;
+- V = U + yuv_width * yuv_height;
+- gd_RGBAToYUV420(im, Y, U, V);
+-
+- /* Encode Y,U,V and write data to file */
+- ret = WebPEncode(Y, U, V, width, height, width, yuv_width, yuv_height, yuv_width,
+- vp8_quality, &filedata, &yuv_nbytes, NULL);
+- gdFree(Y);
+-
+- if (ret != webp_success) {
+- if (filedata) {
+- free(filedata);
+- }
+- gd_error("gd-webp error: WebP Encoder failed");
+- return;
+- }
+-
+- gdPutBuf (filedata, yuv_nbytes, outfile);
+- free(filedata);
+-}
+-
+-#endif /* HAVE_LIBVPX */
++#endif /* HAVE_LIBWEBP */
+--
+2.3.5
+
diff --git a/media-libs/gd/gd-2.1.1-r1.ebuild b/media-libs/gd/gd-2.1.1-r1.ebuild
new file mode 100644
index 000000000000..2ff41003491e
--- /dev/null
+++ b/media-libs/gd/gd-2.1.1-r1.ebuild
@@ -0,0 +1,62 @@
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/media-libs/gd/gd-2.1.1-r1.ebuild,v 1.1 2015/04/09 05:37:20 vapier Exp $
+
+EAPI="5"
+
+inherit libtool multilib-minimal eutils autotools
+
+DESCRIPTION="A graphics library for fast image creation"
+HOMEPAGE="http://libgd.org/ http://www.boutell.com/gd/"
+SRC_URI="mirror://bitbucket/libgd/gd-libgd/downloads/lib${P}.tar.xz"
+
+LICENSE="gd IJG HPND BSD"
+SLOT="2/3"
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~ppc-aix ~amd64-fbsd ~sparc-fbsd ~x86-fbsd ~x86-freebsd ~x86-interix ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~sparc-solaris ~x64-solaris ~x86-solaris"
+IUSE="fontconfig jpeg png static-libs truetype webp xpm zlib"
+
+# fontconfig has prefixed font paths, details see bug #518970
+REQUIRED_USE="prefix? ( fontconfig )"
+
+RDEPEND="fontconfig? ( >=media-libs/fontconfig-2.10.92[${MULTILIB_USEDEP}] )
+ jpeg? ( >=virtual/jpeg-0-r2:0[${MULTILIB_USEDEP}] )
+ png? ( >=media-libs/libpng-1.6.10:0[${MULTILIB_USEDEP}] )
+ truetype? ( >=media-libs/freetype-2.5.0.1[${MULTILIB_USEDEP}] )
+ webp? ( media-libs/libwebp[${MULTILIB_USEDEP}] )
+ xpm? ( >=x11-libs/libXpm-3.5.10-r1[${MULTILIB_USEDEP}] >=x11-libs/libXt-1.1.4[${MULTILIB_USEDEP}] )
+ zlib? ( >=sys-libs/zlib-1.2.8-r1[${MULTILIB_USEDEP}] )"
+DEPEND="${RDEPEND}
+ >=virtual/pkgconfig-0-r1[${MULTILIB_USEDEP}]"
+
+S="${WORKDIR}/lib${P}"
+
+src_prepare() {
+ epatch "${FILESDIR}/${P}-headers.patch" #540376
+ epatch "${FILESDIR}/${P}-webp-pre.patch" #545956
+ epatch "${FILESDIR}/${P}-webp.patch" #545956
+
+ #elibtoolize # for shared library on Solaris
+ eautoreconf
+}
+
+multilib_src_configure() {
+ # we aren't actually {en,dis}abling X here ... the configure
+ # script uses it just to add explicit -I/-L paths which we
+ # don't care about on Gentoo systems.
+ ECONF_SOURCE=${S} \
+ econf \
+ --without-x \
+ $(use_enable static-libs static) \
+ $(use_with fontconfig) \
+ $(use_with png) \
+ $(use_with truetype freetype) \
+ $(use_with jpeg) \
+ $(use_with webp) \
+ $(use_with xpm) \
+ $(use_with zlib)
+}
+
+multilib_src_install_all() {
+ dodoc NEWS README
+ prune_libtool_files
+}