ssimms / pdfapi2

Create, modify, and examine PDF files in Perl
Other
15 stars 20 forks source link

Use XS to speed up png-rgba reprocessing #26

Closed robscovell-ts closed 4 years ago

coveralls commented 4 years ago

Coverage Status

Coverage increased (+0.7%) to 57.596% when pulling d0119ad306f731c71ec8edc985eb3fd2b524ab1d on robscovell-ts:master into 12ac3a46fb080e20c946ae0d858b4efd35c26974 on ssimms:master.

PhilterPaper commented 4 years ago

Rob, I'm trying to get a handle on what your new code does. It looks like it's taking the RGBA (or GA) string returned from libpng, and splitting it into arrays rather than packed strings RGB and A? I ask because that requires extra Perl operations to pack the arrays -- is the cost trivial (compared to doing it in C)? Second, is this handling the full range of bits-per-sample (1, 2, 4, 8, or 16), or just 8? Third, is this code doing more than just splitting the channels -- I see an "unfilter" call and "paeth_predictor". Do they provide a useful speedup?

I requested that the libpng owner (Ben Bullock) add an XS channel split, but so far it doesn't appear that he's gotten anywhere with it. I support PDF::Builder, which has long used the libpng functionality, but had to make as many as 8 "vec" calls per pixel (a lot of overhead on a multimegapixel image!). I was hoping that perhaps your code, if it does all I need and is general purpose, could be incorporated into the libpng library and thus be usable by PDF::Builder too. (I don't know if Ben would want unfilter.) Otherwise, with very minor changes, PDF::Builder::XS could have this as its own copy (full credit to you, of course). I'd rather not have to maintain a separate XS subproduct, but if that's what it takes, I could do it.

robscovell-ts commented 4 years ago

XS code pulled out into separate module here: https://github.com/robscovell-ts/pdfapi2xs

PhilterPaper commented 4 years ago

It sounds like it's restricted to 8 bps and RGBA only... is that correct? If so, it's unusable for PDF::Builder, which is a disappointment. Also, are things like "unfilter" specific to PDF::API2/PDF::Builder, and not general purpose? If so, the libpng author may not be interested.