summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen de Groot <yngwin@gentoo.org>2010-02-08 23:37:36 +0000
committerBen de Groot <yngwin@gentoo.org>2010-02-08 23:37:36 +0000
commit027ce856995ff38366bf454d8f87394f868fd714 (patch)
tree27f728f51ff9a11f3192ec361ae51169ad4eeeab /app-text
parentVersion bump. (diff)
downloadgentoo-2-027ce856995ff38366bf454d8f87394f868fd714.tar.gz
gentoo-2-027ce856995ff38366bf454d8f87394f868fd714.tar.bz2
gentoo-2-027ce856995ff38366bf454d8f87394f868fd714.zip
Remove obsoleted versions. Add cairo image downscale issue patch, which has been applied to upstream git (bug 303817).
(Portage version: 2.2_rc62/cvs/Linux x86_64)
Diffstat (limited to 'app-text')
-rw-r--r--app-text/poppler/ChangeLog15
-rw-r--r--app-text/poppler/files/poppler-0.10.5-xpdf-3.02pl3.patch760
-rw-r--r--app-text/poppler/files/poppler-0.12.3-cairo-image-downscale.patch517
-rw-r--r--app-text/poppler/files/poppler-0.6.1-xpdf-3.02pl2.patch644
-rw-r--r--app-text/poppler/files/poppler-0.8.3-page-init.patch13
-rw-r--r--app-text/poppler/files/poppler-CVE-2009-1188.patch11
-rw-r--r--app-text/poppler/poppler-0.10.5-r1.ebuild63
-rw-r--r--app-text/poppler/poppler-0.12.3-r3.ebuild8
-rw-r--r--app-text/poppler/poppler-0.12.3-r4.ebuild (renamed from app-text/poppler/poppler-0.12.3-r2.ebuild)9
-rw-r--r--app-text/poppler/poppler-0.8.7.ebuild6
10 files changed, 544 insertions, 1502 deletions
diff --git a/app-text/poppler/ChangeLog b/app-text/poppler/ChangeLog
index 9ff2093b5466..6bdb3180e0a9 100644
--- a/app-text/poppler/ChangeLog
+++ b/app-text/poppler/ChangeLog
@@ -1,6 +1,19 @@
# ChangeLog for app-text/poppler
# Copyright 1999-2010 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/app-text/poppler/ChangeLog,v 1.216 2010/02/08 18:17:23 nixnut Exp $
+# $Header: /var/cvsroot/gentoo-x86/app-text/poppler/ChangeLog,v 1.217 2010/02/08 23:37:34 yngwin Exp $
+
+*poppler-0.12.3-r4 (08 Feb 2010)
+
+ 08 Feb 2010; Ben de Groot <yngwin@gentoo.org>
+ -files/poppler-0.6.1-xpdf-3.02pl2.patch,
+ -files/poppler-0.8.3-page-init.patch, poppler-0.8.7.ebuild,
+ -poppler-0.10.5-r1.ebuild, -files/poppler-0.10.5-xpdf-3.02pl3.patch,
+ -poppler-0.12.3-r2.ebuild, poppler-0.12.3-r3.ebuild,
+ +poppler-0.12.3-r4.ebuild,
+ +files/poppler-0.12.3-cairo-image-downscale.patch,
+ -files/poppler-CVE-2009-1188.patch:
+ Remove obsoleted versions. Add cairo image downscale issue patch, which
+ has been applied to upstream git (bug 303817).
08 Feb 2010; nixnut <nixnut@gentoo.org> poppler-0.12.3-r3.ebuild:
ppc stable #290464
diff --git a/app-text/poppler/files/poppler-0.10.5-xpdf-3.02pl3.patch b/app-text/poppler/files/poppler-0.10.5-xpdf-3.02pl3.patch
deleted file mode 100644
index 8957c429f8a8..000000000000
--- a/app-text/poppler/files/poppler-0.10.5-xpdf-3.02pl3.patch
+++ /dev/null
@@ -1,760 +0,0 @@
-diff --git a/poppler/JBIG2Stream.cc b/poppler/JBIG2Stream.cc
-index 938927e..33cd427 100644
---- a/poppler/JBIG2Stream.cc
-+++ b/poppler/JBIG2Stream.cc
-@@ -438,12 +438,14 @@ void JBIG2HuffmanDecoder::buildTable(JBIG2HuffmanTable *table, Guint len) {
- table[i] = table[len];
-
- // assign prefixes
-- i = 0;
-- prefix = 0;
-- table[i++].prefix = prefix++;
-- for (; table[i].rangeLen != jbig2HuffmanEOT; ++i) {
-- prefix <<= table[i].prefixLen - table[i-1].prefixLen;
-- table[i].prefix = prefix++;
-+ if (table[0].rangeLen != jbig2HuffmanEOT) {
-+ i = 0;
-+ prefix = 0;
-+ table[i++].prefix = prefix++;
-+ for (; table[i].rangeLen != jbig2HuffmanEOT; ++i) {
-+ prefix <<= table[i].prefixLen - table[i-1].prefixLen;
-+ table[i].prefix = prefix++;
-+ }
- }
- }
-
-@@ -507,7 +509,7 @@ int JBIG2MMRDecoder::get2DCode() {
- }
- if (p->bits < 0) {
- error(str->getPos(), "Bad two dim code in JBIG2 MMR stream");
-- return 0;
-+ return EOF;
- }
- bufLen -= p->bits;
- return p->n;
-@@ -779,6 +781,8 @@ void JBIG2Bitmap::clearToOne() {
- inline void JBIG2Bitmap::getPixelPtr(int x, int y, JBIG2BitmapPtr *ptr) {
- if (y < 0 || y >= h || x >= w) {
- ptr->p = NULL;
-+ ptr->shift = 0; // make gcc happy
-+ ptr->x = 0; // make gcc happy
- } else if (x < 0) {
- ptr->p = &data[y * line];
- ptr->shift = 7;
-@@ -823,6 +827,10 @@ void JBIG2Bitmap::combine(JBIG2Bitmap *bitmap, int x, int y,
- Guint src0, src1, src, dest, s1, s2, m1, m2, m3;
- GBool oneByte;
-
-+ // check for the pathological case where y = -2^31
-+ if (y < -0x7fffffff) {
-+ return;
-+ }
- if (y < 0) {
- y0 = -y;
- } else {
-@@ -1325,6 +1333,13 @@ void JBIG2Stream::readSegments() {
- // keep track of the start of the segment data
- segDataPos = getPos();
-
-+ // check for missing page information segment
-+ if (!pageBitmap && ((segType >= 4 && segType <= 7) ||
-+ (segType >= 20 && segType <= 43))) {
-+ error(getPos(), "First JBIG2 segment associated with a page must be a page information segment");
-+ goto syntaxError;
-+ }
-+
- // read the segment data
- switch (segType) {
- case 0:
-@@ -1479,6 +1494,8 @@ GBool JBIG2Stream::readSymbolDictSeg(Guint segNum, Guint length,
- Guint i, j, k;
- Guchar *p;
-
-+ symWidths = NULL;
-+
- // symbol dictionary flags
- if (!readUWord(&flags)) {
- goto eofError;
-@@ -1539,7 +1556,13 @@ GBool JBIG2Stream::readSymbolDictSeg(Guint segNum, Guint length,
- // part of it
- if ((seg = findSegment(refSegs[i]))) {
- if (seg->getType() == jbig2SegSymbolDict) {
-- numInputSyms += ((JBIG2SymbolDict *)seg)->getSize();
-+ j = ((JBIG2SymbolDict *)seg)->getSize();
-+ if (numInputSyms > UINT_MAX - j) {
-+ error(getPos(), "Too many input symbols in JBIG2 symbol dictionary");
-+ delete codeTables;
-+ goto eofError;
-+ }
-+ numInputSyms += j;
- } else if (seg->getType() == jbig2SegCodeTable) {
- codeTables->append(seg);
- }
-@@ -1548,13 +1571,18 @@ GBool JBIG2Stream::readSymbolDictSeg(Guint segNum, Guint length,
- return gFalse;
- }
- }
-+ if (numInputSyms > UINT_MAX - numNewSyms) {
-+ error(getPos(), "Too many input symbols in JBIG2 symbol dictionary");
-+ delete codeTables;
-+ goto eofError;
-+ }
-
- // compute symbol code length
-- symCodeLen = 0;
-- i = 1;
-- while (i < numInputSyms + numNewSyms) {
-+ symCodeLen = 1;
-+ i = (numInputSyms + numNewSyms) >> 1;
-+ while (i) {
- ++symCodeLen;
-- i <<= 1;
-+ i >>= 1;
- }
-
- // get the input symbol bitmaps
-@@ -1585,6 +1613,9 @@ GBool JBIG2Stream::readSymbolDictSeg(Guint segNum, Guint length,
- } else if (huffDH == 1) {
- huffDHTable = huffTableE;
- } else {
-+ if (i >= (Guint)codeTables->getLength()) {
-+ goto codeTableError;
-+ }
- huffDHTable = ((JBIG2CodeTable *)codeTables->get(i++))->getHuffTable();
- }
- if (huffDW == 0) {
-@@ -1592,17 +1623,26 @@ GBool JBIG2Stream::readSymbolDictSeg(Guint segNum, Guint length,
- } else if (huffDW == 1) {
- huffDWTable = huffTableC;
- } else {
-+ if (i >= (Guint)codeTables->getLength()) {
-+ goto codeTableError;
-+ }
- huffDWTable = ((JBIG2CodeTable *)codeTables->get(i++))->getHuffTable();
- }
- if (huffBMSize == 0) {
- huffBMSizeTable = huffTableA;
- } else {
-+ if (i >= (Guint)codeTables->getLength()) {
-+ goto codeTableError;
-+ }
- huffBMSizeTable =
- ((JBIG2CodeTable *)codeTables->get(i++))->getHuffTable();
- }
- if (huffAggInst == 0) {
- huffAggInstTable = huffTableA;
- } else {
-+ if (i >= (Guint)codeTables->getLength()) {
-+ goto codeTableError;
-+ }
- huffAggInstTable =
- ((JBIG2CodeTable *)codeTables->get(i++))->getHuffTable();
- }
-@@ -1635,7 +1675,6 @@ GBool JBIG2Stream::readSymbolDictSeg(Guint segNum, Guint length,
- }
-
- // allocate symbol widths storage
-- symWidths = NULL;
- if (huff && !refAgg) {
- symWidths = (Guint *)gmallocn(numNewSyms, sizeof(Guint));
- }
-@@ -1677,6 +1716,10 @@ GBool JBIG2Stream::readSymbolDictSeg(Guint segNum, Guint length,
- goto syntaxError;
- }
- symWidth += dw;
-+ if (i >= numNewSyms) {
-+ error(getPos(), "Too many symbols in JBIG2 symbol dictionary");
-+ goto syntaxError;
-+ }
-
- // using a collective bitmap, so don't read a bitmap here
- if (huff && !refAgg) {
-@@ -1713,6 +1756,10 @@ GBool JBIG2Stream::readSymbolDictSeg(Guint segNum, Guint length,
- arithDecoder->decodeInt(&refDX, iardxStats);
- arithDecoder->decodeInt(&refDY, iardyStats);
- }
-+ if (symID >= numInputSyms + i) {
-+ error(getPos(), "Invalid symbol ID in JBIG2 symbol dictionary");
-+ goto syntaxError;
-+ }
- refBitmap = bitmaps[symID];
- bitmaps[numInputSyms + i] =
- readGenericRefinementRegion(symWidth, symHeight,
-@@ -1779,6 +1826,13 @@ GBool JBIG2Stream::readSymbolDictSeg(Guint segNum, Guint length,
- } else {
- arithDecoder->decodeInt(&run, iaexStats);
- }
-+ if (i + run > numInputSyms + numNewSyms ||
-+ (ex && j + run > numExSyms)) {
-+ error(getPos(), "Too many exported symbols in JBIG2 symbol dictionary");
-+ for ( ; j < numExSyms; ++j) symbolDict->setBitmap(j, NULL);
-+ delete symbolDict;
-+ goto syntaxError;
-+ }
- if (ex) {
- for (cnt = 0; cnt < run; ++cnt) {
- symbolDict->setBitmap(j++, bitmaps[i++]->copy());
-@@ -1788,10 +1842,11 @@ GBool JBIG2Stream::readSymbolDictSeg(Guint segNum, Guint length,
- }
- ex = !ex;
- }
-- for ( ; j < numExSyms; ++j) {
-- // this should never happen but happens on PDF we don't parse
-- // correctly like bug #19702
-- symbolDict->setBitmap(j, NULL);
-+ if (j != numExSyms) {
-+ error(getPos(), "Too few symbols in JBIG2 symbol dictionary");
-+ for ( ; j < numExSyms; ++j) symbolDict->setBitmap(j, NULL);
-+ delete symbolDict;
-+ goto syntaxError;
- }
-
- for (i = 0; i < numNewSyms; ++i) {
-@@ -1815,6 +1870,10 @@ GBool JBIG2Stream::readSymbolDictSeg(Guint segNum, Guint length,
-
- return gTrue;
-
-+ codeTableError:
-+ error(getPos(), "Missing code table in JBIG2 symbol dictionary");
-+ delete codeTables;
-+
- syntaxError:
- for (i = 0; i < numNewSyms; ++i) {
- if (bitmaps[numInputSyms + i]) {
-@@ -1917,6 +1976,8 @@ void JBIG2Stream::readTextRegionSeg(Guint segNum, GBool imm,
- }
- } else {
- error(getPos(), "Invalid segment reference in JBIG2 text region");
-+ delete codeTables;
-+ return;
- }
- }
- symCodeLen = 0;
-@@ -1951,6 +2012,9 @@ void JBIG2Stream::readTextRegionSeg(Guint segNum, GBool imm,
- } else if (huffFS == 1) {
- huffFSTable = huffTableG;
- } else {
-+ if (i >= (Guint)codeTables->getLength()) {
-+ goto codeTableError;
-+ }
- huffFSTable = ((JBIG2CodeTable *)codeTables->get(i++))->getHuffTable();
- }
- if (huffDS == 0) {
-@@ -1960,6 +2024,9 @@ void JBIG2Stream::readTextRegionSeg(Guint segNum, GBool imm,
- } else if (huffDS == 2) {
- huffDSTable = huffTableJ;
- } else {
-+ if (i >= (Guint)codeTables->getLength()) {
-+ goto codeTableError;
-+ }
- huffDSTable = ((JBIG2CodeTable *)codeTables->get(i++))->getHuffTable();
- }
- if (huffDT == 0) {
-@@ -1969,6 +2036,9 @@ void JBIG2Stream::readTextRegionSeg(Guint segNum, GBool imm,
- } else if (huffDT == 2) {
- huffDTTable = huffTableM;
- } else {
-+ if (i >= (Guint)codeTables->getLength()) {
-+ goto codeTableError;
-+ }
- huffDTTable = ((JBIG2CodeTable *)codeTables->get(i++))->getHuffTable();
- }
- if (huffRDW == 0) {
-@@ -1976,6 +2046,9 @@ void JBIG2Stream::readTextRegionSeg(Guint segNum, GBool imm,
- } else if (huffRDW == 1) {
- huffRDWTable = huffTableO;
- } else {
-+ if (i >= (Guint)codeTables->getLength()) {
-+ goto codeTableError;
-+ }
- huffRDWTable = ((JBIG2CodeTable *)codeTables->get(i++))->getHuffTable();
- }
- if (huffRDH == 0) {
-@@ -1983,6 +2056,9 @@ void JBIG2Stream::readTextRegionSeg(Guint segNum, GBool imm,
- } else if (huffRDH == 1) {
- huffRDHTable = huffTableO;
- } else {
-+ if (i >= (Guint)codeTables->getLength()) {
-+ goto codeTableError;
-+ }
- huffRDHTable = ((JBIG2CodeTable *)codeTables->get(i++))->getHuffTable();
- }
- if (huffRDX == 0) {
-@@ -1990,6 +2066,9 @@ void JBIG2Stream::readTextRegionSeg(Guint segNum, GBool imm,
- } else if (huffRDX == 1) {
- huffRDXTable = huffTableO;
- } else {
-+ if (i >= (Guint)codeTables->getLength()) {
-+ goto codeTableError;
-+ }
- huffRDXTable = ((JBIG2CodeTable *)codeTables->get(i++))->getHuffTable();
- }
- if (huffRDY == 0) {
-@@ -1997,11 +2076,17 @@ void JBIG2Stream::readTextRegionSeg(Guint segNum, GBool imm,
- } else if (huffRDY == 1) {
- huffRDYTable = huffTableO;
- } else {
-+ if (i >= (Guint)codeTables->getLength()) {
-+ goto codeTableError;
-+ }
- huffRDYTable = ((JBIG2CodeTable *)codeTables->get(i++))->getHuffTable();
- }
- if (huffRSize == 0) {
- huffRSizeTable = huffTableA;
- } else {
-+ if (i >= (Guint)codeTables->getLength()) {
-+ goto codeTableError;
-+ }
- huffRSizeTable =
- ((JBIG2CodeTable *)codeTables->get(i++))->getHuffTable();
- }
-@@ -2098,8 +2183,15 @@ void JBIG2Stream::readTextRegionSeg(Guint segNum, GBool imm,
-
- return;
-
-+ codeTableError:
-+ error(getPos(), "Missing code table in JBIG2 text region");
-+ gfree(codeTables);
-+ delete syms;
-+ return;
-+
- eofError:
- error(getPos(), "Unexpected EOF in JBIG2 stream");
-+ return;
- }
-
- JBIG2Bitmap *JBIG2Stream::readTextRegion(GBool huff, GBool refine,
-@@ -2134,6 +2226,10 @@ JBIG2Bitmap *JBIG2Stream::readTextRegion(GBool huff, GBool refine,
-
- // allocate the bitmap
- bitmap = new JBIG2Bitmap(0, w, h);
-+ if (!bitmap->isOk()) {
-+ delete bitmap;
-+ return NULL;
-+ }
- if (defPixel) {
- bitmap->clearToOne();
- } else {
-@@ -2226,7 +2322,7 @@ JBIG2Bitmap *JBIG2Stream::readTextRegion(GBool huff, GBool refine,
- decodeSuccess = decodeSuccess && arithDecoder->decodeInt(&rdy, iardyStats);
- }
-
-- if (decodeSuccess)
-+ if (decodeSuccess && syms[symID])
- {
- refDX = ((rdw >= 0) ? rdw : rdw - 1) / 2 + rdx;
- refDY = ((rdh >= 0) ? rdh : rdh - 1) / 2 + rdy;
-@@ -2577,7 +2673,9 @@ void JBIG2Stream::readGenericRegionSeg(Guint segNum, GBool imm,
-
- // read the bitmap
- bitmap = readGenericBitmap(mmr, w, h, templ, tpgdOn, gFalse,
-- NULL, atx, aty, mmr ? 0 : length - 18);
-+ NULL, atx, aty, mmr ? length - 18 : 0);
-+ if (!bitmap)
-+ return;
-
- // combine the region bitmap into the page bitmap
- if (imm) {
-@@ -2599,6 +2697,43 @@ void JBIG2Stream::readGenericRegionSeg(Guint segNum, GBool imm,
- error(getPos(), "Unexpected EOF in JBIG2 stream");
- }
-
-+inline void JBIG2Stream::mmrAddPixels(int a1, int blackPixels,
-+ int *codingLine, int *a0i, int w) {
-+ if (a1 > codingLine[*a0i]) {
-+ if (a1 > w) {
-+ error(getPos(), "JBIG2 MMR row is wrong length ({0:d})", a1);
-+ a1 = w;
-+ }
-+ if ((*a0i & 1) ^ blackPixels) {
-+ ++*a0i;
-+ }
-+ codingLine[*a0i] = a1;
-+ }
-+}
-+
-+inline void JBIG2Stream::mmrAddPixelsNeg(int a1, int blackPixels,
-+ int *codingLine, int *a0i, int w) {
-+ if (a1 > codingLine[*a0i]) {
-+ if (a1 > w) {
-+ error(getPos(), "JBIG2 MMR row is wrong length ({0:d})", a1);
-+ a1 = w;
-+ }
-+ if ((*a0i & 1) ^ blackPixels) {
-+ ++*a0i;
-+ }
-+ codingLine[*a0i] = a1;
-+ } else if (a1 < codingLine[*a0i]) {
-+ if (a1 < 0) {
-+ error(getPos(), "Invalid JBIG2 MMR code");
-+ a1 = 0;
-+ }
-+ while (*a0i > 0 && a1 <= codingLine[*a0i - 1]) {
-+ --*a0i;
-+ }
-+ codingLine[*a0i] = a1;
-+ }
-+}
-+
- JBIG2Bitmap *JBIG2Stream::readGenericBitmap(GBool mmr, int w, int h,
- int templ, GBool tpgdOn,
- GBool useSkip, JBIG2Bitmap *skip,
-@@ -2611,9 +2746,13 @@ JBIG2Bitmap *JBIG2Stream::readGenericBitmap(GBool mmr, int w, int h,
- JBIG2BitmapPtr atPtr0 = {0}, atPtr1 = {0}, atPtr2 = {0}, atPtr3 = {0};
- int *refLine, *codingLine;
- int code1, code2, code3;
-- int x, y, a0, pix, i, refI, codingI;
-+ int x, y, a0i, b1i, blackPixels, pix, i;
-
- bitmap = new JBIG2Bitmap(0, w, h);
-+ if (!bitmap->isOk()) {
-+ delete bitmap;
-+ return NULL;
-+ }
- bitmap->clearToZero();
-
- //----- MMR decode
-@@ -2621,9 +2760,18 @@ JBIG2Bitmap *JBIG2Stream::readGenericBitmap(GBool mmr, int w, int h,
- if (mmr) {
-
- mmrDecoder->reset();
-+ if (w > INT_MAX - 2) {
-+ error(getPos(), "Bad width in JBIG2 generic bitmap");
-+ // force a call to gmalloc(-1), which will throw an exception
-+ w = -3;
-+ }
-+ // 0 <= codingLine[0] < codingLine[1] < ... < codingLine[n] = w
-+ // ---> max codingLine size = w + 1
-+ // refLine has one extra guard entry at the end
-+ // ---> max refLine size = w + 2
-+ codingLine = (int *)gmallocn(w + 1, sizeof(int));
- refLine = (int *)gmallocn(w + 2, sizeof(int));
-- codingLine = (int *)gmallocn(w + 2, sizeof(int));
-- codingLine[0] = codingLine[1] = w;
-+ codingLine[0] = w;
-
- for (y = 0; y < h; ++y) {
-
-@@ -2631,128 +2779,157 @@ JBIG2Bitmap *JBIG2Stream::readGenericBitmap(GBool mmr, int w, int h,
- for (i = 0; codingLine[i] < w; ++i) {
- refLine[i] = codingLine[i];
- }
-- refLine[i] = refLine[i + 1] = w;
-+ refLine[i++] = w;
-+ refLine[i] = w;
-
- // decode a line
-- refI = 0; // b1 = refLine[refI]
-- codingI = 0; // a1 = codingLine[codingI]
-- a0 = 0;
-- do {
-+ codingLine[0] = 0;
-+ a0i = 0;
-+ b1i = 0;
-+ blackPixels = 0;
-+ // invariant:
-+ // refLine[b1i-1] <= codingLine[a0i] < refLine[b1i] < refLine[b1i+1] <= w
-+ // exception at left edge:
-+ // codingLine[a0i = 0] = refLine[b1i = 0] = 0 is possible
-+ // exception at right edge:
-+ // refLine[b1i] = refLine[b1i+1] = w is possible
-+ while (codingLine[a0i] < w) {
- code1 = mmrDecoder->get2DCode();
- switch (code1) {
- case twoDimPass:
-- if (refLine[refI] < w) {
-- a0 = refLine[refI + 1];
-- refI += 2;
-- }
-- break;
-+ mmrAddPixels(refLine[b1i + 1], blackPixels, codingLine, &a0i, w);
-+ if (refLine[b1i + 1] < w) {
-+ b1i += 2;
-+ }
-+ break;
- case twoDimHoriz:
-- if (codingI & 1) {
-- code1 = 0;
-- do {
-- code1 += code3 = mmrDecoder->getBlackCode();
-- } while (code3 >= 64);
-- code2 = 0;
-- do {
-- code2 += code3 = mmrDecoder->getWhiteCode();
-- } while (code3 >= 64);
-- } else {
-- code1 = 0;
-- do {
-- code1 += code3 = mmrDecoder->getWhiteCode();
-- } while (code3 >= 64);
-- code2 = 0;
-- do {
-- code2 += code3 = mmrDecoder->getBlackCode();
-- } while (code3 >= 64);
-- }
-- if (code1 > 0 || code2 > 0) {
-- a0 = codingLine[codingI++] = a0 + code1;
-- a0 = codingLine[codingI++] = a0 + code2;
-- while (refLine[refI] <= a0 && refLine[refI] < w) {
-- refI += 2;
-- }
-- }
-- break;
-- case twoDimVert0:
-- a0 = codingLine[codingI++] = refLine[refI];
-- if (refLine[refI] < w) {
-- ++refI;
-- }
-- break;
-- case twoDimVertR1:
-- a0 = codingLine[codingI++] = refLine[refI] + 1;
-- if (refLine[refI] < w) {
-- ++refI;
-- while (refLine[refI] <= a0 && refLine[refI] < w) {
-- refI += 2;
-- }
-- }
-- break;
-- case twoDimVertR2:
-- a0 = codingLine[codingI++] = refLine[refI] + 2;
-- if (refLine[refI] < w) {
-- ++refI;
-- while (refLine[refI] <= a0 && refLine[refI] < w) {
-- refI += 2;
-- }
-- }
-- break;
-+ code1 = code2 = 0;
-+ if (blackPixels) {
-+ do {
-+ code1 += code3 = mmrDecoder->getBlackCode();
-+ } while (code3 >= 64);
-+ do {
-+ code2 += code3 = mmrDecoder->getWhiteCode();
-+ } while (code3 >= 64);
-+ } else {
-+ do {
-+ code1 += code3 = mmrDecoder->getWhiteCode();
-+ } while (code3 >= 64);
-+ do {
-+ code2 += code3 = mmrDecoder->getBlackCode();
-+ } while (code3 >= 64);
-+ }
-+ mmrAddPixels(codingLine[a0i] + code1, blackPixels,
-+ codingLine, &a0i, w);
-+ if (codingLine[a0i] < w) {
-+ mmrAddPixels(codingLine[a0i] + code2, blackPixels ^ 1,
-+ codingLine, &a0i, w);
-+ }
-+ while (refLine[b1i] <= codingLine[a0i] && refLine[b1i] < w) {
-+ b1i += 2;
-+ }
-+ break;
- case twoDimVertR3:
-- a0 = codingLine[codingI++] = refLine[refI] + 3;
-- if (refLine[refI] < w) {
-- ++refI;
-- while (refLine[refI] <= a0 && refLine[refI] < w) {
-- refI += 2;
-- }
-- }
-- break;
-- case twoDimVertL1:
-- a0 = codingLine[codingI++] = refLine[refI] - 1;
-- if (refI > 0) {
-- --refI;
-- } else {
-- ++refI;
-- }
-- while (refLine[refI] <= a0 && refLine[refI] < w) {
-- refI += 2;
-- }
-- break;
-- case twoDimVertL2:
-- a0 = codingLine[codingI++] = refLine[refI] - 2;
-- if (refI > 0) {
-- --refI;
-- } else {
-- ++refI;
-- }
-- while (refLine[refI] <= a0 && refLine[refI] < w) {
-- refI += 2;
-- }
-- break;
-+ mmrAddPixels(refLine[b1i] + 3, blackPixels, codingLine, &a0i, w);
-+ blackPixels ^= 1;
-+ if (codingLine[a0i] < w) {
-+ ++b1i;
-+ while (refLine[b1i] <= codingLine[a0i] && refLine[b1i] < w) {
-+ b1i += 2;
-+ }
-+ }
-+ break;
-+ case twoDimVertR2:
-+ mmrAddPixels(refLine[b1i] + 2, blackPixels, codingLine, &a0i, w);
-+ blackPixels ^= 1;
-+ if (codingLine[a0i] < w) {
-+ ++b1i;
-+ while (refLine[b1i] <= codingLine[a0i] && refLine[b1i] < w) {
-+ b1i += 2;
-+ }
-+ }
-+ break;
-+ case twoDimVertR1:
-+ mmrAddPixels(refLine[b1i] + 1, blackPixels, codingLine, &a0i, w);
-+ blackPixels ^= 1;
-+ if (codingLine[a0i] < w) {
-+ ++b1i;
-+ while (refLine[b1i] <= codingLine[a0i] && refLine[b1i] < w) {
-+ b1i += 2;
-+ }
-+ }
-+ break;
-+ case twoDimVert0:
-+ mmrAddPixels(refLine[b1i], blackPixels, codingLine, &a0i, w);
-+ blackPixels ^= 1;
-+ if (codingLine[a0i] < w) {
-+ ++b1i;
-+ while (refLine[b1i] <= codingLine[a0i] && refLine[b1i] < w) {
-+ b1i += 2;
-+ }
-+ }
-+ break;
- case twoDimVertL3:
-- a0 = codingLine[codingI++] = refLine[refI] - 3;
-- if (refI > 0) {
-- --refI;
-- } else {
-- ++refI;
-- }
-- while (refLine[refI] <= a0 && refLine[refI] < w) {
-- refI += 2;
-- }
-- break;
-+ mmrAddPixelsNeg(refLine[b1i] - 3, blackPixels, codingLine, &a0i, w);
-+ blackPixels ^= 1;
-+ if (codingLine[a0i] < w) {
-+ if (b1i > 0) {
-+ --b1i;
-+ } else {
-+ ++b1i;
-+ }
-+ while (refLine[b1i] <= codingLine[a0i] && refLine[b1i] < w) {
-+ b1i += 2;
-+ }
-+ }
-+ break;
-+ case twoDimVertL2:
-+ mmrAddPixelsNeg(refLine[b1i] - 2, blackPixels, codingLine, &a0i, w);
-+ blackPixels ^= 1;
-+ if (codingLine[a0i] < w) {
-+ if (b1i > 0) {
-+ --b1i;
-+ } else {
-+ ++b1i;
-+ }
-+ while (refLine[b1i] <= codingLine[a0i] && refLine[b1i] < w) {
-+ b1i += 2;
-+ }
-+ }
-+ break;
-+ case twoDimVertL1:
-+ mmrAddPixelsNeg(refLine[b1i] - 1, blackPixels, codingLine, &a0i, w);
-+ blackPixels ^= 1;
-+ if (codingLine[a0i] < w) {
-+ if (b1i > 0) {
-+ --b1i;
-+ } else {
-+ ++b1i;
-+ }
-+ while (refLine[b1i] <= codingLine[a0i] && refLine[b1i] < w) {
-+ b1i += 2;
-+ }
-+ }
-+ break;
-+ case EOF:
-+ mmrAddPixels(w, 0, codingLine, &a0i, w);
-+ break;
- default:
- error(getPos(), "Illegal code in JBIG2 MMR bitmap data");
-+ mmrAddPixels(w, 0, codingLine, &a0i, w);
- break;
- }
-- } while (a0 < w);
-- codingLine[codingI++] = w;
-+ }
-
- // convert the run lengths to a bitmap line
- i = 0;
-- while (codingLine[i] < w) {
-+ while (1) {
- for (x = codingLine[i]; x < codingLine[i+1]; ++x) {
- bitmap->setPixel(x, y);
- }
-+ if (codingLine[i+1] >= w || codingLine[i+2] >= w) {
-+ break;
-+ }
- i += 2;
- }
- }
-@@ -2800,7 +2977,9 @@ JBIG2Bitmap *JBIG2Stream::readGenericBitmap(GBool mmr, int w, int h,
- ltp = !ltp;
- }
- if (ltp) {
-- bitmap->duplicateRow(y, y-1);
-+ if (y > 0) {
-+ bitmap->duplicateRow(y, y-1);
-+ }
- continue;
- }
- }
-@@ -3111,6 +3290,10 @@ JBIG2Bitmap *JBIG2Stream::readGenericRefinementRegion(int w, int h,
- tpgrCX2 = refBitmap->nextPixel(&tpgrCXPtr2);
- tpgrCX2 = (tpgrCX2 << 1) | refBitmap->nextPixel(&tpgrCXPtr2);
- tpgrCX2 = (tpgrCX2 << 1) | refBitmap->nextPixel(&tpgrCXPtr2);
-+ } else {
-+ tpgrCXPtr0.p = tpgrCXPtr1.p = tpgrCXPtr2.p = NULL; // make gcc happy
-+ tpgrCXPtr0.shift = tpgrCXPtr1.shift = tpgrCXPtr2.shift = 0;
-+ tpgrCXPtr0.x = tpgrCXPtr1.x = tpgrCXPtr2.x = 0;
- }
-
- for (x = 0; x < w; ++x) {
-@@ -3182,6 +3365,10 @@ JBIG2Bitmap *JBIG2Stream::readGenericRefinementRegion(int w, int h,
- tpgrCX2 = refBitmap->nextPixel(&tpgrCXPtr2);
- tpgrCX2 = (tpgrCX2 << 1) | refBitmap->nextPixel(&tpgrCXPtr2);
- tpgrCX2 = (tpgrCX2 << 1) | refBitmap->nextPixel(&tpgrCXPtr2);
-+ } else {
-+ tpgrCXPtr0.p = tpgrCXPtr1.p = tpgrCXPtr2.p = NULL; // make gcc happy
-+ tpgrCXPtr0.shift = tpgrCXPtr1.shift = tpgrCXPtr2.shift = 0;
-+ tpgrCXPtr0.x = tpgrCXPtr1.x = tpgrCXPtr2.x = 0;
- }
-
- for (x = 0; x < w; ++x) {
-@@ -3247,6 +3434,12 @@ void JBIG2Stream::readPageInfoSeg(Guint length) {
- }
- pageBitmap = new JBIG2Bitmap(0, pageW, curPageH);
-
-+ if (!pageBitmap->isOk()) {
-+ delete pageBitmap;
-+ pageBitmap = NULL;
-+ return;
-+ }
-+
- // default pixel value
- if (pageDefPixel) {
- pageBitmap->clearToOne();
-diff --git a/poppler/JBIG2Stream.h b/poppler/JBIG2Stream.h
-index 7a73938..ca1fee7 100644
---- a/poppler/JBIG2Stream.h
-+++ b/poppler/JBIG2Stream.h
-@@ -76,6 +76,10 @@ private:
- Guint *refSegs, Guint nRefSegs);
- void readGenericRegionSeg(Guint segNum, GBool imm,
- GBool lossless, Guint length);
-+ void mmrAddPixels(int a1, int blackPixels,
-+ int *codingLine, int *a0i, int w);
-+ void mmrAddPixelsNeg(int a1, int blackPixels,
-+ int *codingLine, int *a0i, int w);
- JBIG2Bitmap *readGenericBitmap(GBool mmr, int w, int h,
- int templ, GBool tpgdOn,
- GBool useSkip, JBIG2Bitmap *skip,
diff --git a/app-text/poppler/files/poppler-0.12.3-cairo-image-downscale.patch b/app-text/poppler/files/poppler-0.12.3-cairo-image-downscale.patch
new file mode 100644
index 000000000000..61fb8d9b987c
--- /dev/null
+++ b/app-text/poppler/files/poppler-0.12.3-cairo-image-downscale.patch
@@ -0,0 +1,517 @@
+diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
+index 9a0f3be..42ac3a8 100644
+--- a/poppler/CairoOutputDev.cc
++++ b/poppler/CairoOutputDev.cc
+@@ -58,6 +58,7 @@
+ #include <splash/SplashBitmap.h>
+ #include "CairoOutputDev.h"
+ #include "CairoFontEngine.h"
++#include "CairoRescaleBox.h"
+ //------------------------------------------------------------------------
+
+ // #define LOG_CAIRO
+@@ -1331,6 +1332,82 @@ void CairoOutputDev::endMaskClip(GfxState *state) {
+ clearSoftMask(state);
+ }
+
++cairo_surface_t *CairoOutputDev::downscaleSurface(cairo_surface_t *orig_surface) {
++ cairo_surface_t *dest_surface;
++ unsigned char *dest_buffer;
++ int dest_stride;
++ unsigned char *orig_buffer;
++ int orig_width, orig_height;
++ int orig_stride;
++ GBool res;
++
++ if (printing)
++ return NULL;
++
++ cairo_matrix_t matrix;
++ cairo_get_matrix(cairo, &matrix);
++
++ /* this whole computation should be factored out */
++ double xScale = matrix.xx;
++ double yScale = matrix.yy;
++ int tx, tx2, ty, ty2; /* the integer co-oridinates of the resulting image */
++ int scaledHeight;
++ int scaledWidth;
++ if (xScale >= 0) {
++ tx = splashRound(matrix.x0 - 0.01);
++ tx2 = splashRound(matrix.x0 + xScale + 0.01) - 1;
++ } else {
++ tx = splashRound(matrix.x0 + 0.01) - 1;
++ tx2 = splashRound(matrix.x0 + xScale - 0.01);
++ }
++ scaledWidth = abs(tx2 - tx) + 1;
++ //scaledWidth = splashRound(fabs(xScale));
++ if (scaledWidth == 0) {
++ // technically, this should draw nothing, but it generally seems
++ // better to draw a one-pixel-wide stripe rather than throwing it
++ // away
++ scaledWidth = 1;
++ }
++ if (yScale >= 0) {
++ ty = splashFloor(matrix.y0 + 0.01);
++ ty2 = splashCeil(matrix.y0 + yScale - 0.01);
++ } else {
++ ty = splashCeil(matrix.y0 - 0.01);
++ ty2 = splashFloor(matrix.y0 + yScale + 0.01);
++ }
++ scaledHeight = abs(ty2 - ty);
++ if (scaledHeight == 0) {
++ scaledHeight = 1;
++ }
++
++ orig_width = cairo_image_surface_get_width (orig_surface);
++ orig_height = cairo_image_surface_get_height (orig_surface);
++ if (scaledWidth >= orig_width || scaledHeight >= orig_height)
++ return NULL;
++
++ dest_surface = cairo_surface_create_similar (orig_surface,
++ cairo_surface_get_content (orig_surface),
++ scaledWidth, scaledHeight);
++ dest_buffer = cairo_image_surface_get_data (dest_surface);
++ dest_stride = cairo_image_surface_get_stride (dest_surface);
++
++ orig_buffer = cairo_image_surface_get_data (orig_surface);
++ orig_stride = cairo_image_surface_get_stride (orig_surface);
++
++ res = downscale_box_filter((uint32_t *)orig_buffer,
++ orig_stride, orig_width, orig_height,
++ scaledWidth, scaledHeight, 0, 0,
++ scaledWidth, scaledHeight,
++ (uint32_t *)dest_buffer, dest_stride);
++ if (!res) {
++ cairo_surface_destroy (dest_surface);
++ return NULL;
++ }
++
++ return dest_surface;
++
++}
++
+ void CairoOutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str,
+ int width, int height, GBool invert,
+ GBool interpolate, GBool inlineImg) {
+@@ -2094,6 +2171,18 @@ void CairoOutputDev::drawImage(GfxState *state, Object *ref, Stream *str,
+ }
+ gfree(lookup);
+
++ cairo_surface_t *scaled_surface;
++
++ scaled_surface = downscaleSurface (image);
++ if (scaled_surface) {
++ if (cairo_surface_status (scaled_surface))
++ goto cleanup;
++ cairo_surface_destroy (image);
++ image = scaled_surface;
++ width = cairo_image_surface_get_width (image);
++ height = cairo_image_surface_get_height (image);
++ }
++
+ cairo_surface_mark_dirty (image);
+ pattern = cairo_pattern_create_for_surface (image);
+ cairo_surface_destroy (image);
+diff --git a/poppler/CairoOutputDev.h b/poppler/CairoOutputDev.h
+index fb9c0d7..266f0cb 100644
+--- a/poppler/CairoOutputDev.h
++++ b/poppler/CairoOutputDev.h
+@@ -268,6 +268,7 @@ public:
+
+ protected:
+ void doPath(cairo_t *cairo, GfxState *state, GfxPath *path);
++ cairo_surface_t *downscaleSurface(cairo_surface_t *orig_surface);
+
+ GfxRGB fill_color, stroke_color;
+ cairo_pattern_t *fill_pattern, *stroke_pattern;
+diff --git a/poppler/CairoRescaleBox.cc b/poppler/CairoRescaleBox.cc
+new file mode 100644
+index 0000000..dce5ddd
+--- /dev/null
++++ b/poppler/CairoRescaleBox.cc
+@@ -0,0 +1,352 @@
++/* -*- Mode: c; c-basic-offset: 4; tab-width: 8; indent-tabs-mode: t; -*- */
++/*
++ * Copyright © 2009 Mozilla Corporation
++ *
++ * Permission to use, copy, modify, distribute, and sell this software and its
++ * documentation for any purpose is hereby granted without fee, provided that
++ * the above copyright notice appear in all copies and that both that
++ * copyright notice and this permission notice appear in supporting
++ * documentation, and that the name of Mozilla Corporation not be used in
++ * advertising or publicity pertaining to distribution of the software without
++ * specific, written prior permission. Mozilla Corporation makes no
++ * representations about the suitability of this software for any purpose. It
++ * is provided "as is" without express or implied warranty.
++ *
++ * MOZILLA CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
++ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT
++ * SHALL MOZILLA CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR
++ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
++ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
++ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
++ * OF THIS SOFTWARE.
++ *
++ * Author: Jeff Muizelaar, Mozilla Corp.
++ */
++
++/* This implements a box filter that supports non-integer box sizes */
++
++#ifdef HAVE_CONFIG_H
++#include <config.h>
++#endif
++
++#include <stdint.h>
++#include <stdio.h>
++#include <assert.h>
++#include <stdlib.h>
++#include <math.h>
++#include "goo/gmem.h"
++#include "CairoRescaleBox.h"
++
++typedef unsigned short int uint16_t;
++typedef unsigned int uint32_t;
++
++/* we work in fixed point where 1. == 1 << 24 */
++#define FIXED_SHIFT 24
++
++static void downsample_row_box_filter (
++ int start, int width,
++ uint32_t *src, uint32_t *dest,
++ int coverage[], int pixel_coverage)
++{
++ /* we need an array of the pixel contribution of each destination pixel on the boundaries.
++ * we invert the value to get the value on the other size of the box */
++ /*
++
++ value = a * contribution * 1/box_size
++ value += a * 1/box_size
++ value += a * 1/box_size
++ value += a * 1/box_size
++ value += a * (1 - contribution) * 1/box_size
++ a * (1/box_size - contribution * 1/box_size)
++
++ box size is constant
++
++
++ value = a * contribtion_a * 1/box_size + b * contribution_b * 1/box_size
++ contribution_b = (1 - contribution_a)
++ = (1 - contribution_a_next)
++ */
++
++ /* box size = ceil(src_width/dest_width) */
++ int x = 0;
++
++ /* skip to start */
++ /* XXX: it might be possible to do this directly instead of iteratively, however
++ * the iterative solution is simple */
++ while (x < start)
++ {
++ int box = 1 << FIXED_SHIFT;
++ int start_coverage = coverage[x];
++ box -= start_coverage;
++ src++;
++ while (box >= pixel_coverage)
++ {
++ src++;
++ box -= pixel_coverage;
++ }
++ x++;
++ }
++
++ while (x < start + width)
++ {
++ uint32_t a = 0;
++ uint32_t r = 0;
++ uint32_t g = 0;
++ uint32_t b = 0;
++ int box = 1 << FIXED_SHIFT;
++ int start_coverage = coverage[x];
++
++ a = ((*src >> 24) & 0xff) * start_coverage;
++ r = ((*src >> 16) & 0xff) * start_coverage;
++ g = ((*src >> 8) & 0xff) * start_coverage;
++ b = ((*src >> 0) & 0xff) * start_coverage;
++ src++;
++ x++;
++ box -= start_coverage;
++
++ while (box >= pixel_coverage)
++ {
++ a += ((*src >> 24) & 0xff) * pixel_coverage;
++ r += ((*src >> 16) & 0xff) * pixel_coverage;
++ g += ((*src >> 8) & 0xff) * pixel_coverage;
++ b += ((*src >> 0) & 0xff) * pixel_coverage;
++ src++;
++
++ box -= pixel_coverage;
++ }
++
++ /* multiply by whatever is leftover
++ * this ensures that we don't bias down.
++ * i.e. start_coverage + n*pixel_coverage + box == 1 << 24 */
++ if (box > 0)
++ {
++ a += ((*src >> 24) & 0xff) * box;
++ r += ((*src >> 16) & 0xff) * box;
++ g += ((*src >> 8) & 0xff) * box;
++ b += ((*src >> 0) & 0xff) * box;
++ }
++
++ a >>= FIXED_SHIFT;
++ r >>= FIXED_SHIFT;
++ g >>= FIXED_SHIFT;
++ b >>= FIXED_SHIFT;
++
++ *dest = (a << 24) | (r << 16) | (g << 8) | b;
++ dest++;
++ }
++}
++
++static void downsample_columns_box_filter (
++ int n,
++ int start_coverage,
++ int pixel_coverage,
++ uint32_t *src, uint32_t *dest)
++{
++ int stride = n;
++ while (n--) {
++ uint32_t a = 0;
++ uint32_t r = 0;
++ uint32_t g = 0;
++ uint32_t b = 0;
++ uint32_t *column_src = src;
++ int box = 1 << FIXED_SHIFT;
++
++ a = ((*column_src >> 24) & 0xff) * start_coverage;
++ r = ((*column_src >> 16) & 0xff) * start_coverage;
++ g = ((*column_src >> 8) & 0xff) * start_coverage;
++ b = ((*column_src >> 0) & 0xff) * start_coverage;
++ column_src += stride;
++ box -= start_coverage;
++
++ while (box >= pixel_coverage)
++ {
++ a += ((*column_src >> 24) & 0xff) * pixel_coverage;
++ r += ((*column_src >> 16) & 0xff) * pixel_coverage;
++ g += ((*column_src >> 8) & 0xff) * pixel_coverage;
++ b += ((*column_src >> 0) & 0xff) * pixel_coverage;
++ column_src += stride;
++ box -= pixel_coverage;
++ }
++
++ if (box > 0) {
++ a += ((*column_src >> 24) & 0xff) * box;
++ r += ((*column_src >> 16) & 0xff) * box;
++ g += ((*column_src >> 8) & 0xff) * box;
++ b += ((*column_src >> 0) & 0xff) * box;
++ }
++
++ a >>= FIXED_SHIFT;
++ r >>= FIXED_SHIFT;
++ g >>= FIXED_SHIFT;
++ b >>= FIXED_SHIFT;
++
++ *dest = (a << 24) | (r << 16) | (g << 8) | b;
++ dest++;
++ src++;
++ }
++}
++
++static int compute_coverage (int coverage[], int src_length, int dest_length)
++{
++ int i;
++ /* num = src_length/dest_length
++ total = sum(pixel) / num
++
++ pixel * 1/num == pixel * dest_length / src_length
++ */
++ /* the average contribution of each source pixel */
++ int ratio = ((1 << 24)*(long long int)dest_length)/src_length;
++ /* because ((1 << 24)*(long long int)dest_length) won't always be divisible by src_length
++ * we'll need someplace to put the other bits.
++ *
++ * We want to ensure a + n*ratio < 1<<24
++ *
++ * 1<<24
++ * */
++
++ double scale = (double)src_length/dest_length;
++
++ /* for each destination pixel compute the coverage of the left most pixel included in the box */
++ /* I have a proof of this, which this margin is too narrow to contain */
++ for (i=0; i<dest_length; i++)
++ {
++ float left_side = i*scale;
++ float right_side = (i+1)*scale;
++ float right_fract = right_side - floor (right_side);
++ float left_fract = ceil (left_side) - left_side;
++ int overage;
++ /* find out how many source pixels will be used to fill the box */
++ int count = floor (right_side) - ceil (left_side);
++ /* what's the maximum value this expression can become?
++ floor((i+1)*scale) - ceil(i*scale)
++
++ (i+1)*scale - i*scale == scale
++
++ since floor((i+1)*scale) <= (i+1)*scale
++ and ceil(i*scale) >= i*scale
++
++ floor((i+1)*scale) - ceil(i*scale) <= scale
++
++ further since: floor((i+1)*scale) - ceil(i*scale) is an integer
++
++ therefore:
++ floor((i+1)*scale) - ceil(i*scale) <= floor(scale)
++ */
++
++ if (left_fract == 0.)
++ count--;
++
++ /* compute how much the right-most pixel contributes */
++ overage = ratio*(right_fract);
++
++ /* the remainder is the the amount that the left-most pixel
++ * contributes */
++ coverage[i] = (1<<24) - (count * ratio + overage);
++ }
++
++ return ratio;
++}
++
++GBool downscale_box_filter(uint32_t *orig, int orig_stride, unsigned orig_width, unsigned orig_height,
++ signed scaled_width, signed scaled_height,
++ uint16_t start_column, uint16_t start_row,
++ uint16_t width, uint16_t height,
++ uint32_t *dest, int dst_stride)
++{
++ int pixel_coverage_x, pixel_coverage_y;
++ int dest_y;
++ int src_y = 0;
++ uint32_t *scanline = orig;
++ int *x_coverage = NULL;
++ int *y_coverage = NULL;
++ uint32_t *temp_buf = NULL;
++ GBool retval = gFalse;
++
++ x_coverage = (int *)gmallocn3 (orig_width, 1, sizeof(int));
++ y_coverage = (int *)gmallocn3 (orig_height, 1, sizeof(int));
++
++ /* we need to allocate enough room for ceil(src_height/dest_height)+1
++ Example:
++ src_height = 140
++ dest_height = 50
++ src_height/dest_height = 2.8
++
++ |-------------| 2.8 pixels
++ |----|----|----|----| 4 pixels
++ need to sample 3 pixels
++
++ |-------------| 2.8 pixels
++ |----|----|----|----| 4 pixels
++ need to sample 4 pixels
++ */
++
++ temp_buf = (uint32_t *)gmallocn3 ((orig_height + scaled_height-1)/scaled_height+1, scaled_width, sizeof(uint32_t));
++
++ if (!x_coverage || !y_coverage || !scanline || !temp_buf)
++ goto cleanup;
++
++ pixel_coverage_x = compute_coverage (x_coverage, orig_width, scaled_width);
++ pixel_coverage_y = compute_coverage (y_coverage, orig_height, scaled_height);
++
++ assert (width + start_column <= scaled_width);
++
++ /* skip the rows at the beginning */
++ for (dest_y = 0; dest_y < start_row; dest_y++)
++ {
++ int box = 1 << FIXED_SHIFT;
++ int start_coverage_y = y_coverage[dest_y];
++ box -= start_coverage_y;
++ src_y++;
++ while (box >= pixel_coverage_y)
++ {
++ box -= pixel_coverage_y;
++ src_y++;
++ }
++ }
++
++ for (; dest_y < start_row + height; dest_y++)
++ {
++ int columns = 0;
++ int box = 1 << FIXED_SHIFT;
++ int start_coverage_y = y_coverage[dest_y];
++
++ scanline = orig + src_y * orig_stride / 4;
++ downsample_row_box_filter (start_column, width, scanline, temp_buf + width * columns, x_coverage, pixel_coverage_x);
++ columns++;
++ src_y++;
++ box -= start_coverage_y;
++
++ while (box >= pixel_coverage_y)
++ {
++ scanline = orig + src_y * orig_stride / 4;
++ downsample_row_box_filter (start_column, width, scanline, temp_buf + width * columns, x_coverage, pixel_coverage_x);
++ columns++;
++ src_y++;
++ box -= pixel_coverage_y;
++ }
++
++ /* downsample any leftovers */
++ if (box > 0)
++ {
++ scanline = orig + src_y * orig_stride / 4;
++ downsample_row_box_filter (start_column, width, scanline, temp_buf + width * columns, x_coverage, pixel_coverage_x);
++ columns++;
++ }
++
++ /* now scale the rows we just downsampled in the y direction */
++ downsample_columns_box_filter (width, start_coverage_y, pixel_coverage_y, temp_buf, dest);
++ dest += dst_stride / 4;
++
++// assert(width*columns <= ((orig_height + scaled_height-1)/scaled_height+1) * width);
++ }
++// assert (src_y<=orig_height);
++
++ retval = gTrue;
++
++cleanup:
++ free (x_coverage);
++ free (y_coverage);
++ free (temp_buf);
++
++ return gTrue;
++}
+diff --git a/poppler/CairoRescaleBox.h b/poppler/CairoRescaleBox.h
+new file mode 100644
+index 0000000..5349c87
+--- /dev/null
++++ b/poppler/CairoRescaleBox.h
+@@ -0,0 +1,12 @@
++#ifndef CAIRO_RESCALE_BOX_H
++#define CAIRO_RESCALE_BOX_H
++
++#include "goo/gtypes.h"
++
++GBool downscale_box_filter(unsigned int *orig, int orig_stride, unsigned orig_width, unsigned orig_height,
++ signed scaled_width, signed scaled_height,
++ unsigned short int start_column, unsigned short int start_row,
++ unsigned short int width, unsigned short int height,
++ unsigned int *dest, int dst_stride);
++
++#endif /* CAIRO_RESCALE_BOX_H */
+diff --git a/poppler/Makefile.am b/poppler/Makefile.am
+index ec79e31..096ea76 100644
+--- a/poppler/Makefile.am
++++ b/poppler/Makefile.am
+@@ -47,7 +47,9 @@ libpoppler_cairo_la_SOURCES = \
+ CairoFontEngine.cc \
+ CairoFontEngine.h \
+ CairoOutputDev.cc \
+- CairoOutputDev.h
++ CairoOutputDev.h \
++ CairoRescaleBox.cc \
++ CairoRescaleBox.h
+
+ endif
+
diff --git a/app-text/poppler/files/poppler-0.6.1-xpdf-3.02pl2.patch b/app-text/poppler/files/poppler-0.6.1-xpdf-3.02pl2.patch
deleted file mode 100644
index d88b5a3e6416..000000000000
--- a/app-text/poppler/files/poppler-0.6.1-xpdf-3.02pl2.patch
+++ /dev/null
@@ -1,644 +0,0 @@
-Index: Stream.cc
-===================================================================
---- poppler/Stream.cc.orig
-+++ poppler/Stream.cc
-@@ -1251,23 +1251,26 @@ CCITTFaxStream::CCITTFaxStream(Stream *s
- columns = columnsA;
- if (columns < 1) {
- columns = 1;
-- }
-- if (columns + 4 <= 0) {
-- columns = INT_MAX - 4;
-+ } else if (columns > INT_MAX - 2) {
-+ columns = INT_MAX - 2;
- }
- rows = rowsA;
- endOfBlock = endOfBlockA;
- black = blackA;
-- refLine = (short *)gmallocn(columns + 3, sizeof(short));
-- codingLine = (short *)gmallocn(columns + 2, sizeof(short));
-+ // 0 <= codingLine[0] < codingLine[1] < ... < codingLine[n] = columns
-+ // ---> max codingLine size = columns + 1
-+ // refLine has one extra guard entry at the end
-+ // ---> max refLine size = columns + 2
-+ codingLine = (int *)gmallocn(columns + 1, sizeof(int));
-+ refLine = (int *)gmallocn(columns + 2, sizeof(int));
-
- eof = gFalse;
- row = 0;
- nextLine2D = encoding < 0;
- inputBits = 0;
-- codingLine[0] = 0;
-- codingLine[1] = refLine[2] = columns;
-- a0 = 1;
-+ codingLine[0] = columns;
-+ a0i = 0;
-+ outputBits = 0;
-
- buf = EOF;
- }
-@@ -1286,9 +1289,9 @@ void CCITTFaxStream::reset() {
- row = 0;
- nextLine2D = encoding < 0;
- inputBits = 0;
-- codingLine[0] = 0;
-- codingLine[1] = columns;
-- a0 = 1;
-+ codingLine[0] = columns;
-+ a0i = 0;
-+ outputBits = 0;
- buf = EOF;
-
- // skip any initial zero bits and end-of-line marker, and get the 2D
-@@ -1305,211 +1308,230 @@ void CCITTFaxStream::reset() {
- }
- }
-
-+inline void CCITTFaxStream::addPixels(int a1, int blackPixels) {
-+ if (a1 > codingLine[a0i]) {
-+ if (a1 > columns) {
-+ error(getPos(), "CCITTFax row is wrong length (%d)", a1);
-+ err = gTrue;
-+ a1 = columns;
-+ }
-+ if ((a0i & 1) ^ blackPixels) {
-+ ++a0i;
-+ }
-+ codingLine[a0i] = a1;
-+ }
-+}
-+
-+inline void CCITTFaxStream::addPixelsNeg(int a1, int blackPixels) {
-+ if (a1 > codingLine[a0i]) {
-+ if (a1 > columns) {
-+ error(getPos(), "CCITTFax row is wrong length (%d)", a1);
-+ err = gTrue;
-+ a1 = columns;
-+ }
-+ if ((a0i & 1) ^ blackPixels) {
-+ ++a0i;
-+ }
-+ codingLine[a0i] = a1;
-+ } else if (a1 < codingLine[a0i]) {
-+ if (a1 < 0) {
-+ error(getPos(), "Invalid CCITTFax code");
-+ err = gTrue;
-+ a1 = 0;
-+ }
-+ while (a0i > 0 && a1 <= codingLine[a0i - 1]) {
-+ --a0i;
-+ }
-+ codingLine[a0i] = a1;
-+ }
-+}
-+
- int CCITTFaxStream::lookChar() {
- short code1, code2, code3;
-- int a0New;
-- GBool err, gotEOL;
-- int ret;
-- int bits, i;
-+ int b1i, blackPixels, i, bits;
-+ GBool gotEOL;
-
-- // if at eof just return EOF
-- if (eof && codingLine[a0] >= columns) {
-- return EOF;
-+ if (buf != EOF) {
-+ return buf;
- }
-
- // read the next row
-- err = gFalse;
-- if (codingLine[a0] >= columns) {
-+ if (outputBits == 0) {
-+
-+ // if at eof just return EOF
-+ if (eof) {
-+ return EOF;
-+ }
-+
-+ err = gFalse;
-
- // 2-D encoding
- if (nextLine2D) {
-- // state:
-- // a0New = current position in coding line (0 <= a0New <= columns)
-- // codingLine[a0] = last change in coding line
-- // (black-to-white if a0 is even,
-- // white-to-black if a0 is odd)
-- // refLine[b1] = next change in reference line of opposite color
-- // to a0
-- // invariants:
-- // 0 <= codingLine[a0] <= a0New
-- // <= refLine[b1] <= refLine[b1+1] <= columns
-- // 0 <= a0 <= columns+1
-- // refLine[0] = 0
-- // refLine[n] = refLine[n+1] = columns
-- // -- for some 1 <= n <= columns+1
-- // end condition:
-- // 0 = codingLine[0] <= codingLine[1] < codingLine[2] < ...
-- // < codingLine[n-1] < codingLine[n] = columns
-- // -- where 1 <= n <= columns+1
- for (i = 0; codingLine[i] < columns; ++i) {
- refLine[i] = codingLine[i];
- }
-- refLine[i] = refLine[i + 1] = columns;
-- b1 = 1;
-- a0New = codingLine[a0 = 0] = 0;
-- do {
-+ refLine[i++] = columns;
-+ refLine[i] = columns;
-+ codingLine[0] = 0;
-+ a0i = 0;
-+ b1i = 0;
-+ blackPixels = 0;
-+ // invariant:
-+ // refLine[b1i-1] <= codingLine[a0i] < refLine[b1i] < refLine[b1i+1]
-+ // <= columns
-+ // exception at left edge:
-+ // codingLine[a0i = 0] = refLine[b1i = 0] = 0 is possible
-+ // exception at right edge:
-+ // refLine[b1i] = refLine[b1i+1] = columns is possible
-+ while (codingLine[a0i] < columns) {
- code1 = getTwoDimCode();
- switch (code1) {
- case twoDimPass:
-- if (refLine[b1] < columns) {
-- a0New = refLine[b1 + 1];
-- b1 += 2;
-+ addPixels(refLine[b1i + 1], blackPixels);
-+ if (refLine[b1i + 1] < columns) {
-+ b1i += 2;
- }
- break;
- case twoDimHoriz:
-- if ((a0 & 1) == 0) {
-- code1 = code2 = 0;
-+ code1 = code2 = 0;
-+ if (blackPixels) {
- do {
-- code1 += code3 = getWhiteCode();
-+ code1 += code3 = getBlackCode();
- } while (code3 >= 64);
- do {
-- code2 += code3 = getBlackCode();
-+ code2 += code3 = getWhiteCode();
- } while (code3 >= 64);
- } else {
-- code1 = code2 = 0;
- do {
-- code1 += code3 = getBlackCode();
-+ code1 += code3 = getWhiteCode();
- } while (code3 >= 64);
- do {
-- code2 += code3 = getWhiteCode();
-+ code2 += code3 = getBlackCode();
- } while (code3 >= 64);
- }
-- if (code1 > 0 || code2 > 0) {
-- if (a0New + code1 <= columns) {
-- codingLine[a0 + 1] = a0New + code1;
-- } else {
-- codingLine[a0 + 1] = columns;
-- }
-- ++a0;
-- if (codingLine[a0] + code2 <= columns) {
-- codingLine[a0 + 1] = codingLine[a0] + code2;
-- } else {
-- codingLine[a0 + 1] = columns;
-- }
-- ++a0;
-- a0New = codingLine[a0];
-- while (refLine[b1] <= a0New && refLine[b1] < columns) {
-- b1 += 2;
-+ addPixels(codingLine[a0i] + code1, blackPixels);
-+ if (codingLine[a0i] < columns) {
-+ addPixels(codingLine[a0i] + code2, blackPixels ^ 1);
-+ }
-+ while (refLine[b1i] <= codingLine[a0i] && refLine[b1i] < columns) {
-+ b1i += 2;
-+ }
-+ break;
-+ case twoDimVertR3:
-+ addPixels(refLine[b1i] + 3, blackPixels);
-+ blackPixels ^= 1;
-+ if (codingLine[a0i] < columns) {
-+ ++b1i;
-+ while (refLine[b1i] <= codingLine[a0i] && refLine[b1i] < columns) {
-+ b1i += 2;
- }
- }
- break;
-- case twoDimVert0:
-- if (refLine[b1] < columns) {
-- a0New = codingLine[++a0] = refLine[b1];
-- ++b1;
-- while (refLine[b1] <= a0New && refLine[b1] < columns) {
-- b1 += 2;
-+ case twoDimVertR2:
-+ addPixels(refLine[b1i] + 2, blackPixels);
-+ blackPixels ^= 1;
-+ if (codingLine[a0i] < columns) {
-+ ++b1i;
-+ while (refLine[b1i] <= codingLine[a0i] && refLine[b1i] < columns) {
-+ b1i += 2;
- }
-- } else {
-- a0New = codingLine[++a0] = columns;
- }
- break;
- case twoDimVertR1:
-- if (refLine[b1] + 1 < columns) {
-- a0New = codingLine[++a0] = refLine[b1] + 1;
-- ++b1;
-- while (refLine[b1] <= a0New && refLine[b1] < columns) {
-- b1 += 2;
-+ addPixels(refLine[b1i] + 1, blackPixels);
-+ blackPixels ^= 1;
-+ if (codingLine[a0i] < columns) {
-+ ++b1i;
-+ while (refLine[b1i] <= codingLine[a0i] && refLine[b1i] < columns) {
-+ b1i += 2;
- }
-- } else {
-- a0New = codingLine[++a0] = columns;
- }
- break;
-- case twoDimVertL1:
-- if (refLine[b1] - 1 > a0New || (a0 == 0 && refLine[b1] == 1)) {
-- a0New = codingLine[++a0] = refLine[b1] - 1;
-- --b1;
-- while (refLine[b1] <= a0New && refLine[b1] < columns) {
-- b1 += 2;
-+ case twoDimVert0:
-+ addPixels(refLine[b1i], blackPixels);
-+ blackPixels ^= 1;
-+ if (codingLine[a0i] < columns) {
-+ ++b1i;
-+ while (refLine[b1i] <= codingLine[a0i] && refLine[b1i] < columns) {
-+ b1i += 2;
- }
- }
- break;
-- case twoDimVertR2:
-- if (refLine[b1] + 2 < columns) {
-- a0New = codingLine[++a0] = refLine[b1] + 2;
-- ++b1;
-- while (refLine[b1] <= a0New && refLine[b1] < columns) {
-- b1 += 2;
-+ case twoDimVertL3:
-+ addPixelsNeg(refLine[b1i] - 3, blackPixels);
-+ blackPixels ^= 1;
-+ if (codingLine[a0i] < columns) {
-+ if (b1i > 0) {
-+ --b1i;
-+ } else {
-+ ++b1i;
-+ }
-+ while (refLine[b1i] <= codingLine[a0i] && refLine[b1i] < columns) {
-+ b1i += 2;
- }
-- } else {
-- a0New = codingLine[++a0] = columns;
- }
- break;
- case twoDimVertL2:
-- if (refLine[b1] - 2 > a0New || (a0 == 0 && refLine[b1] == 2)) {
-- a0New = codingLine[++a0] = refLine[b1] - 2;
-- --b1;
-- while (refLine[b1] <= a0New && refLine[b1] < columns) {
-- b1 += 2;
-+ addPixelsNeg(refLine[b1i] - 2, blackPixels);
-+ blackPixels ^= 1;
-+ if (codingLine[a0i] < columns) {
-+ if (b1i > 0) {
-+ --b1i;
-+ } else {
-+ ++b1i;
- }
-- }
-- break;
-- case twoDimVertR3:
-- if (refLine[b1] + 3 < columns) {
-- a0New = codingLine[++a0] = refLine[b1] + 3;
-- ++b1;
-- while (refLine[b1] <= a0New && refLine[b1] < columns) {
-- b1 += 2;
-+ while (refLine[b1i] <= codingLine[a0i] && refLine[b1i] < columns) {
-+ b1i += 2;
- }
-- } else {
-- a0New = codingLine[++a0] = columns;
- }
- break;
-- case twoDimVertL3:
-- if (refLine[b1] - 3 > a0New || (a0 == 0 && refLine[b1] == 3)) {
-- a0New = codingLine[++a0] = refLine[b1] - 3;
-- --b1;
-- while (refLine[b1] <= a0New && refLine[b1] < columns) {
-- b1 += 2;
-+ case twoDimVertL1:
-+ addPixelsNeg(refLine[b1i] - 1, blackPixels);
-+ blackPixels ^= 1;
-+ if (codingLine[a0i] < columns) {
-+ if (b1i > 0) {
-+ --b1i;
-+ } else {
-+ ++b1i;
-+ }
-+ while (refLine[b1i] <= codingLine[a0i] && refLine[b1i] < columns) {
-+ b1i += 2;
- }
- }
- break;
- case EOF:
-+ addPixels(columns, 0);
- eof = gTrue;
-- codingLine[a0 = 0] = columns;
-- return EOF;
-+ break;
- default:
- error(getPos(), "Bad 2D code %04x in CCITTFax stream", code1);
-+ addPixels(columns, 0);
- err = gTrue;
- break;
- }
-- } while (codingLine[a0] < columns);
-+ }
-
- // 1-D encoding
- } else {
-- codingLine[a0 = 0] = 0;
-- while (1) {
-+ codingLine[0] = 0;
-+ a0i = 0;
-+ blackPixels = 0;
-+ while (codingLine[a0i] < columns) {
- code1 = 0;
-- do {
-- code1 += code3 = getWhiteCode();
-- } while (code3 >= 64);
-- codingLine[a0+1] = codingLine[a0] + code1;
-- ++a0;
-- if (codingLine[a0] >= columns) {
-- break;
-- }
-- code2 = 0;
-- do {
-- code2 += code3 = getBlackCode();
-- } while (code3 >= 64);
-- codingLine[a0+1] = codingLine[a0] + code2;
-- ++a0;
-- if (codingLine[a0] >= columns) {
-- break;
-+ if (blackPixels) {
-+ do {
-+ code1 += code3 = getBlackCode();
-+ } while (code3 >= 64);
-+ } else {
-+ do {
-+ code1 += code3 = getWhiteCode();
-+ } while (code3 >= 64);
- }
-+ addPixels(codingLine[a0i] + code1, blackPixels);
-+ blackPixels ^= 1;
- }
- }
-
-- if (codingLine[a0] != columns) {
-- error(getPos(), "CCITTFax row is wrong length (%d)", codingLine[a0]);
-- // force the row to be the correct length
-- while (codingLine[a0] > columns) {
-- --a0;
-- }
-- codingLine[++a0] = columns;
-- err = gTrue;
-- }
--
- // byte-align the row
- if (byteAlign) {
- inputBits &= ~7;
-@@ -1568,14 +1590,17 @@ int CCITTFaxStream::lookChar() {
- // this if we know the stream contains end-of-line markers because
- // the "just plow on" technique tends to work better otherwise
- } else if (err && endOfLine) {
-- do {
-+ while (1) {
-+ code1 = lookBits(13);
- if (code1 == EOF) {
- eof = gTrue;
- return EOF;
- }
-+ if ((code1 >> 1) == 0x001) {
-+ break;
-+ }
- eatBits(1);
-- code1 = lookBits(13);
-- } while ((code1 >> 1) != 0x001);
-+ }
- eatBits(12);
- if (encoding > 0) {
- eatBits(1);
-@@ -1583,11 +1608,11 @@ int CCITTFaxStream::lookChar() {
- }
- }
-
-- a0 = 0;
-- outputBits = codingLine[1] - codingLine[0];
-- if (outputBits == 0) {
-- a0 = 1;
-- outputBits = codingLine[2] - codingLine[1];
-+ // set up for output
-+ if (codingLine[0] > 0) {
-+ outputBits = codingLine[a0i = 0];
-+ } else {
-+ outputBits = codingLine[a0i = 1];
- }
-
- ++row;
-@@ -1595,39 +1620,43 @@ int CCITTFaxStream::lookChar() {
-
- // get a byte
- if (outputBits >= 8) {
-- ret = ((a0 & 1) == 0) ? 0xff : 0x00;
-- if ((outputBits -= 8) == 0) {
-- ++a0;
-- if (codingLine[a0] < columns) {
-- outputBits = codingLine[a0 + 1] - codingLine[a0];
-- }
-+ buf = (a0i & 1) ? 0x00 : 0xff;
-+ outputBits -= 8;
-+ if (outputBits == 0 && codingLine[a0i] < columns) {
-+ ++a0i;
-+ outputBits = codingLine[a0i] - codingLine[a0i - 1];
- }
- } else {
- bits = 8;
-- ret = 0;
-+ buf = 0;
- do {
- if (outputBits > bits) {
-- i = bits;
-- bits = 0;
-- if ((a0 & 1) == 0) {
-- ret |= 0xff >> (8 - i);
-+ buf <<= bits;
-+ if (!(a0i & 1)) {
-+ buf |= 0xff >> (8 - bits);
- }
-- outputBits -= i;
-+ outputBits -= bits;
-+ bits = 0;
- } else {
-- i = outputBits;
-- bits -= outputBits;
-- if ((a0 & 1) == 0) {
-- ret |= (0xff >> (8 - i)) << bits;
-+ buf <<= outputBits;
-+ if (!(a0i & 1)) {
-+ buf |= 0xff >> (8 - outputBits);
- }
-+ bits -= outputBits;
- outputBits = 0;
-- ++a0;
-- if (codingLine[a0] < columns) {
-- outputBits = codingLine[a0 + 1] - codingLine[a0];
-+ if (codingLine[a0i] < columns) {
-+ ++a0i;
-+ outputBits = codingLine[a0i] - codingLine[a0i - 1];
-+ } else if (bits > 0) {
-+ buf <<= bits;
-+ bits = 0;
- }
- }
-- } while (bits > 0 && codingLine[a0] < columns);
-+ } while (bits);
-+ }
-+ if (black) {
-+ buf ^= 0xff;
- }
-- buf = black ? (ret ^ 0xff) : ret;
- return buf;
- }
-
-@@ -1669,6 +1698,9 @@ short CCITTFaxStream::getWhiteCode() {
- code = 0; // make gcc happy
- if (endOfBlock) {
- code = lookBits(12);
-+ if (code == EOF) {
-+ return 1;
-+ }
- if ((code >> 5) == 0) {
- p = &whiteTab1[code];
- } else {
-@@ -1681,6 +1713,9 @@ short CCITTFaxStream::getWhiteCode() {
- } else {
- for (n = 1; n <= 9; ++n) {
- code = lookBits(n);
-+ if (code == EOF) {
-+ return 1;
-+ }
- if (n < 9) {
- code <<= 9 - n;
- }
-@@ -1692,6 +1727,9 @@ short CCITTFaxStream::getWhiteCode() {
- }
- for (n = 11; n <= 12; ++n) {
- code = lookBits(n);
-+ if (code == EOF) {
-+ return 1;
-+ }
- if (n < 12) {
- code <<= 12 - n;
- }
-@@ -1717,6 +1755,9 @@ short CCITTFaxStream::getBlackCode() {
- code = 0; // make gcc happy
- if (endOfBlock) {
- code = lookBits(13);
-+ if (code == EOF) {
-+ return 1;
-+ }
- if ((code >> 7) == 0) {
- p = &blackTab1[code];
- } else if ((code >> 9) == 0 && (code >> 7) != 0) {
-@@ -1731,6 +1772,9 @@ short CCITTFaxStream::getBlackCode() {
- } else {
- for (n = 2; n <= 6; ++n) {
- code = lookBits(n);
-+ if (code == EOF) {
-+ return 1;
-+ }
- if (n < 6) {
- code <<= 6 - n;
- }
-@@ -1742,6 +1786,9 @@ short CCITTFaxStream::getBlackCode() {
- }
- for (n = 7; n <= 12; ++n) {
- code = lookBits(n);
-+ if (code == EOF) {
-+ return 1;
-+ }
- if (n < 12) {
- code <<= 12 - n;
- }
-@@ -1755,6 +1802,9 @@ short CCITTFaxStream::getBlackCode() {
- }
- for (n = 10; n <= 13; ++n) {
- code = lookBits(n);
-+ if (code == EOF) {
-+ return 1;
-+ }
- if (n < 13) {
- code <<= 13 - n;
- }
-@@ -1971,6 +2021,12 @@ void DCTStream::reset() {
- // allocate a buffer for the whole image
- bufWidth = ((width + mcuWidth - 1) / mcuWidth) * mcuWidth;
- bufHeight = ((height + mcuHeight - 1) / mcuHeight) * mcuHeight;
-+ if (bufWidth <= 0 || bufHeight <= 0 ||
-+ bufWidth > INT_MAX / bufWidth / (int)sizeof(int)) {
-+ error(getPos(), "Invalid image size in DCT stream");
-+ y = height;
-+ return;
-+ }
- for (i = 0; i < numComps; ++i) {
- frameBuf[i] = (int *)gmallocn(bufWidth * bufHeight, sizeof(int));
- memset(frameBuf[i], 0, bufWidth * bufHeight * sizeof(int));
-@@ -3041,6 +3097,11 @@ GBool DCTStream::readScanInfo() {
- }
- scanInfo.firstCoeff = str->getChar();
- scanInfo.lastCoeff = str->getChar();
-+ if (scanInfo.firstCoeff < 0 || scanInfo.lastCoeff > 63 ||
-+ scanInfo.firstCoeff > scanInfo.lastCoeff) {
-+ error(getPos(), "Bad DCT coefficient numbers in scan info block");
-+ return gFalse;
-+ }
- c = str->getChar();
- scanInfo.ah = (c >> 4) & 0x0f;
- scanInfo.al = c & 0x0f;
-Index: Stream.h
-===================================================================
---- poppler/Stream.h.orig
-+++ poppler/Stream.h
-@@ -526,13 +526,15 @@ private:
- int row; // current row
- int inputBuf; // input buffer
- int inputBits; // number of bits in input buffer
-- short *refLine; // reference line changing elements
-- int b1; // index into refLine
-- short *codingLine; // coding line changing elements
-- int a0; // index into codingLine
-+ int *codingLine; // coding line changing elements
-+ int *refLine; // reference line changing elements
-+ int a0i; // index into codingLine
-+ GBool err; // error on current line
- int outputBits; // remaining ouput bits
- int buf; // character buffer
-
-+ void addPixels(int a1, int black);
-+ void addPixelsNeg(int a1, int black);
- short getTwoDimCode();
- short getWhiteCode();
- short getBlackCode();
-
diff --git a/app-text/poppler/files/poppler-0.8.3-page-init.patch b/app-text/poppler/files/poppler-0.8.3-page-init.patch
deleted file mode 100644
index 84f4b4edfb79..000000000000
--- a/app-text/poppler/files/poppler-0.8.3-page-init.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-diff --git a/poppler/Page.cc b/poppler/Page.cc
-index b28a3ee..72a706b 100644
---- a/poppler/Page.cc
-+++ b/poppler/Page.cc
-@@ -230,7 +230,7 @@ GBool PageAttrs::readBox(Dict *dict, char *key, PDFRectangle *box) {
-
- Page::Page(XRef *xrefA, int numA, Dict *pageDict, PageAttrs *attrsA, Form *form) {
- Object tmp;
--
-+ pageWidgets = NULL; //Security fix
- ok = gTrue;
- xref = xrefA;
- num = numA;
diff --git a/app-text/poppler/files/poppler-CVE-2009-1188.patch b/app-text/poppler/files/poppler-CVE-2009-1188.patch
deleted file mode 100644
index 70f98a0f5723..000000000000
--- a/app-text/poppler/files/poppler-CVE-2009-1188.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- a/splash/SplashBitmap.cc
-+++ b/splash/SplashBitmap.cc
-@@ -62,7 +62,7 @@ SplashBitmap::SplashBitmap(int widthA, int heightA, int rowPad,
- }
- rowSize += rowPad - 1;
- rowSize -= rowSize % rowPad;
-- data = (SplashColorPtr)gmalloc(rowSize * height);
-+ data = (SplashColorPtr)gmallocn(rowSize, height);
- if (!topDown) {
- data += (height - 1) * rowSize;
- rowSize = -rowSize;
diff --git a/app-text/poppler/poppler-0.10.5-r1.ebuild b/app-text/poppler/poppler-0.10.5-r1.ebuild
deleted file mode 100644
index 3f4c6617d430..000000000000
--- a/app-text/poppler/poppler-0.10.5-r1.ebuild
+++ /dev/null
@@ -1,63 +0,0 @@
-# Copyright 1999-2009 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/app-text/poppler/poppler-0.10.5-r1.ebuild,v 1.6 2009/04/22 11:10:59 armin76 Exp $
-
-EAPI=2
-
-inherit libtool eutils
-
-DESCRIPTION="PDF rendering library based on the xpdf-3.0 code base"
-HOMEPAGE="http://poppler.freedesktop.org/"
-SRC_URI="http://poppler.freedesktop.org/${P}.tar.gz"
-
-LICENSE="GPL-2"
-SLOT="0"
-KEYWORDS="alpha amd64 arm hppa ia64 ppc ppc64 s390 sh sparc x86 ~x86-fbsd"
-IUSE="doc"
-
-RDEPEND="
- >=media-libs/freetype-2.1.8
- >=media-libs/fontconfig-2
- app-text/poppler-data
- >=media-libs/jpeg-6b
- media-libs/openjpeg
- sys-libs/zlib
- dev-libs/libxml2
- !app-text/pdftohtml
- !dev-libs/poppler-qt3
- !dev-libs/poppler-qt4
- !dev-libs/poppler
- !dev-libs/poppler-glib
- !app-text/poppler-utils
- "
-DEPEND="
- ${RDEPEND}
- dev-util/pkgconfig
- doc? ( >=dev-util/gtk-doc-1.0 )
- "
-
-src_prepare () {
- epatch "${FILESDIR}/poppler-0.10.5-xpdf-3.02pl3.patch"
- epatch "${FILESDIR}/poppler-CVE-2009-1188.patch"
-}
-
-src_configure() {
- econf --disable-static \
- --disable-poppler-qt4 \
- --disable-poppler-glib \
- --disable-poppler-qt \
- --disable-gtk-test \
- --disable-cairo-output \
- --enable-xpdf-headers \
- --enable-libjpeg \
- --enable-libopenjpeg \
- --enable-zlib \
- $(use_enable doc gtk-doc) \
- || die "configuration failed"
-}
-
-src_install() {
- emake DESTDIR="${D}" install || die "make install failed"
- dodoc README AUTHORS ChangeLog NEWS README-XPDF TODO
- rm -f $(find "${D}" -name '*.la')
-}
diff --git a/app-text/poppler/poppler-0.12.3-r3.ebuild b/app-text/poppler/poppler-0.12.3-r3.ebuild
index 7d723e1b5258..4b86074d937f 100644
--- a/app-text/poppler/poppler-0.12.3-r3.ebuild
+++ b/app-text/poppler/poppler-0.12.3-r3.ebuild
@@ -1,6 +1,6 @@
# Copyright 1999-2010 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/app-text/poppler/poppler-0.12.3-r3.ebuild,v 1.9 2010/02/08 18:17:23 nixnut Exp $
+# $Header: /var/cvsroot/gentoo-x86/app-text/poppler/poppler-0.12.3-r3.ebuild,v 1.10 2010/02/08 23:37:34 yngwin Exp $
EAPI="2"
@@ -38,9 +38,9 @@ RDEPEND="${COMMON_DEPEND}
cjk? ( >=app-text/poppler-data-0.2.1 )"
src_prepare() {
- epatch "${FILESDIR}/${P}-cmake-disable-tests.patch"
- epatch "${FILESDIR}/${P}-fix-headers-installation.patch"
- epatch "${FILESDIR}/${P}-gdk.patch"
+ epatch "${FILESDIR}"/${P}-cmake-disable-tests.patch
+ epatch "${FILESDIR}"/${P}-fix-headers-installation.patch
+ epatch "${FILESDIR}"/${P}-gdk.patch
epatch "${FILESDIR}"/${P}-darwin-gtk-link.patch
}
diff --git a/app-text/poppler/poppler-0.12.3-r2.ebuild b/app-text/poppler/poppler-0.12.3-r4.ebuild
index c8da5e1efc39..bda96d3a10e1 100644
--- a/app-text/poppler/poppler-0.12.3-r2.ebuild
+++ b/app-text/poppler/poppler-0.12.3-r4.ebuild
@@ -1,6 +1,6 @@
# Copyright 1999-2010 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/app-text/poppler/poppler-0.12.3-r2.ebuild,v 1.1 2010/01/24 22:20:04 yngwin Exp $
+# $Header: /var/cvsroot/gentoo-x86/app-text/poppler/poppler-0.12.3-r4.ebuild,v 1.1 2010/02/08 23:37:34 yngwin Exp $
EAPI="2"
@@ -38,8 +38,11 @@ RDEPEND="${COMMON_DEPEND}
cjk? ( >=app-text/poppler-data-0.2.1 )"
src_prepare() {
- epatch "${FILESDIR}/${P}-cmake-disable-tests.patch"
- epatch "${FILESDIR}/${P}-fix-headers-installation.patch"
+ epatch "${FILESDIR}"/${P}-cmake-disable-tests.patch
+ epatch "${FILESDIR}"/${P}-fix-headers-installation.patch
+ epatch "${FILESDIR}"/${P}-gdk.patch
+ epatch "${FILESDIR}"/${P}-darwin-gtk-link.patch
+ epatch "${FILESDIR}"/${P}-cairo-image-downscale.patch #303817
}
src_configure() {
diff --git a/app-text/poppler/poppler-0.8.7.ebuild b/app-text/poppler/poppler-0.8.7.ebuild
index 3c0013756993..d8c46fea55e2 100644
--- a/app-text/poppler/poppler-0.8.7.ebuild
+++ b/app-text/poppler/poppler-0.8.7.ebuild
@@ -1,6 +1,6 @@
-# Copyright 1999-2009 Gentoo Foundation
+# Copyright 1999-2010 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/app-text/poppler/poppler-0.8.7.ebuild,v 1.10 2009/04/01 14:42:17 loki_val Exp $
+# $Header: /var/cvsroot/gentoo-x86/app-text/poppler/poppler-0.8.7.ebuild,v 1.11 2010/02/08 23:37:34 yngwin Exp $
inherit libtool eutils
@@ -10,7 +10,7 @@ SRC_URI="http://poppler.freedesktop.org/${P}.tar.gz"
LICENSE="GPL-2"
SLOT="0"
-KEYWORDS="alpha amd64 arm hppa ia64 m68k ~mips ppc ppc64 s390 sh sparc ~sparc-fbsd x86 ~x86-fbsd"
+KEYWORDS="m68k ~mips"
IUSE="cjk jpeg zlib"
RDEPEND="