Bug Hunting Session
Bug 97662 - CPU burned re-compressing JPEGs to make them bigger ...
Summary: CPU burned re-compressing JPEGs to make them bigger ...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Printing and PDF export (show other bugs)
Version:
(earliest affected)
5.1.0.1 rc
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard: target:5.2.0 target:5.1.2
Keywords:
Depends on:
Blocks:
 
Reported: 2016-02-08 21:05 UTC by Michael Meeks
Modified: 2018-04-04 17:24 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments
sample document with low & high quality jpegs. (6.39 MB, application/vnd.oasis.opendocument.presentation)
2016-02-08 21:19 UTC, Michael Meeks
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Meeks 2016-02-08 21:05:05 UTC
It appears that our heuristics to avoid image de-compression and/or re-compression could use some improvement. The re-compression is particularly expensive since we not only jpeg but also png compress the result - cf. pdfwriter_impl2.cxx. Also it seems we re-compress jpegs we just de-compressed potentially at a higher 'quality' - thus carefully preserving any de-compression artifacts, but not adding quality; not ideal - and very slow with it.
Comment 1 Michael Meeks 2016-02-08 21:19:47 UTC
Created attachment 122465 [details]
sample document with low & high quality jpegs.
Comment 2 Michael Meeks 2016-02-08 21:36:48 UTC
I've knocked up a quick band-aid here - it will make some PDFs both
smaller and faster to export, and others somewhat larger but still
faster to export; for this sample document of a highly quality JPEG
and a low-quality JPEG we have (with default settings)

libreoffice 5.0		2.543 Mb
with the fix            1.861 Mb

With some CPU saving too.

Ideally we'd adapt to the DPI scaling too; and even more ideally -
we'd expose the underlying Graphic from the PDFExtOutDevData to the
pdfwriter_impl2.cxx's PDFWriterImpl::implWriteBitmapEx - to ensure
that we never make the image larger even in that case.

cf.

https://gerrit.libreoffice.org/22219 tdf#97662 - Try to preserve original compressed JPEGs harder.
Comment 3 Commit Notification 2016-02-09 00:11:24 UTC
Michael Meeks committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=76ec54e8c9f3580450bca85236a4f5af0c328588

tdf#97662 - Try to preserve original compressed JPEGs harder.

It will be available in 5.2.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 4 Michael Meeks 2016-02-09 22:40:02 UTC
Mostly fixed ... =)
Comment 5 Commit Notification 2016-02-24 13:15:00 UTC
Marco Cecchetti committed a patch related to this issue.
It has been pushed to "libreoffice-5-1":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=2ee228e179d98630bc69cef8b13a55c0edbe9e1b&h=libreoffice-5-1

tdf#97662 - Try to preserve original compressed JPEGs harder.

It will be available in 5.1.2.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 6 Commit Notification 2016-02-24 14:43:57 UTC
Marco Cecchetti committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=8a039afb1f3f345c748b2e7cc9b76ca030c23abb

tdf#97662 - Try to preserve original compressed JPEGs harder.

It will be available in 5.2.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 7 Commit Notification 2016-02-24 15:10:16 UTC
Marco Cecchetti committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=eab3c3ab9da5f0282df43d2f4bfbf17f7a4f8fe3

tdf#97662 - Avoid JPEG compressing de-compressed PNG.

It will be available in 5.2.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.