[gdk-pixbuf: 1/2] Speed up saving PNGs by skipping a null transform



commit b83e18e4a5d3c83910996988fe2ca275beb16d81
Author: Brion Vibber <brion pobox com>
Date:   Thu Sep 6 07:29:41 2018 -0700

    Speed up saving PNGs by skipping a null transform
    
    Calling png_set_shift to set the number of significant bits of input
    triggers a transform operation inside libpng which shifts bits around,
    even if it's a null operation of 8 bits to 8 bits.
    
    I measured this slowdown as about 30% of total saving runtime on a
    large 7680x2160 screenshot.
    
    In addition, only 8 bits per channel are supported in gdk-pixbuf so
    this is never actually needed in practice...
    
    Skipping the png_set_shift call altogether doesn't change output and
    speeds it up nicely.
    
    Fixes #90

 gdk-pixbuf/io-png.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
---
diff --git a/gdk-pixbuf/io-png.c b/gdk-pixbuf/io-png.c
index dfe9e1e7d..c1e215064 100644
--- a/gdk-pixbuf/io-png.c
+++ b/gdk-pixbuf/io-png.c
@@ -1129,13 +1129,13 @@ static gboolean real_save_png (GdkPixbuf        *pixbuf,
                              PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE,
                              PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
        }
+       /* Note bpc is always 8 */
        sig_bit.red = bpc;
        sig_bit.green = bpc;
        sig_bit.blue = bpc;
        sig_bit.alpha = bpc;
        png_set_sBIT (png_ptr, info_ptr, &sig_bit);
        png_write_info (png_ptr, info_ptr);
-       png_set_shift (png_ptr, &sig_bit);
        png_set_packing (png_ptr);
 
        for (y = 0, ptr = pixels; y < h; y++, ptr += rowstride) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]