diff options
author | Matúš Kukan <matus.kukan@collabora.com> | 2014-11-12 21:25:55 +0100 |
---|---|---|
committer | Matúš Kukan <matus.kukan@collabora.com> | 2014-11-12 21:43:53 +0100 |
commit | b5fc498c6f74469c5134cd5fd297ae9ee9772724 (patch) | |
tree | c7523a0a91fda5ec58a89f4490cb03796ebe8ff1 | |
parent | 3ac44c1b44bcb0a73fddc2642615660af9e673e8 (diff) |
package: Do not bother with deflating big jpeg images
It takes a lot of time and we can save 1% of size if at all. Rather
store them uncompressed in the zip file.
Maybe we should not deflate jpeg files at all. For some small ones,
about 100KB - 200KB, I've seen 2% savings.
With png, we can save a bit more, although it's still only about 4% - 8%.
Change-Id: I43a3e3812882e4ce85e7af9d0aaab454d98c4860
-rw-r--r-- | package/source/zippackage/ZipPackageStream.cxx | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/package/source/zippackage/ZipPackageStream.cxx b/package/source/zippackage/ZipPackageStream.cxx index 5eaa6e951220..157a90591bde 100644 --- a/package/source/zippackage/ZipPackageStream.cxx +++ b/package/source/zippackage/ZipPackageStream.cxx @@ -772,6 +772,17 @@ bool ZipPackageStream::saveChild( pTempEntry->nCrc = -1; pTempEntry->nCompressedSize = pTempEntry->nSize = -1; } + uno::Reference< io::XSeekable > xSeek(xStream, uno::UNO_QUERY); + sal_Int32 nStreamLength = 0; + if (xSeek.is()) + nStreamLength = xSeek->getLength(); + + // It's not worth to deflate big jpegs to save ~1% in a slow process + if (msMediaType.endsWith("/jpeg") && nStreamLength && nStreamLength > 500000) + { + ImplSetStoredData(*pTempEntry, xStream); + xSeek->seek(0); + } try { @@ -799,8 +810,7 @@ bool ZipPackageStream::saveChild( { bParallelDeflate = true; // Do not deflate small streams in a thread - uno::Reference< io::XSeekable > xSeek( xStream, uno::UNO_QUERY ); - if (xSeek.is() && xSeek->getLength() < 100000) + if (nStreamLength && nStreamLength < 100000) bParallelDeflate = false; if (bParallelDeflate) |