From d6dbfea064a641fa06808d78736c98de633bb246 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Wed, 4 Feb 2015 16:48:25 +0000 Subject: [PATCH] much faster RGB16 -> sRGB path --- ChangeLog | 1 + TODO | 4 ---- libvips/colour/colourspace.c | 17 +++++++++++++++-- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 98767845..0b6aebee 100644 --- a/ChangeLog +++ b/ChangeLog @@ -18,6 +18,7 @@ - add lower-level operation cache access - turn on leak testing in test suite - don't use isnormal() to test for crazy FP numbers, thanks Murat +- much faster RGB16 -> sRGB path 24/12/14 started 7.42.1 - add gobject-2.0 to Requires: in vips and vips-cpp .pc files diff --git a/TODO b/TODO index 7d5c2e51..87846da4 100644 --- a/TODO +++ b/TODO @@ -1,5 +1,3 @@ - - - use vips_resize() in vipsthumbnail? should the sharpening filter be selectable? @@ -24,8 +22,6 @@ - fix up aconv -- more python tests - - can we pick the vipsthumbnail int shrink factor more intelligently? - rewrite im_conv() etc. as vips_conv(), also the mosaicing functions diff --git a/libvips/colour/colourspace.c b/libvips/colour/colourspace.c index 6e514b1f..cbefe3e7 100644 --- a/libvips/colour/colourspace.c +++ b/libvips/colour/colourspace.c @@ -14,6 +14,8 @@ * - oops, don't treat RGB16 as sRGB * 9/9/14 * - mono <-> rgb converters were not handling extra bands, thanks James + * 4/2/15 + * - much faster RGB16->sRGB path */ /* @@ -71,6 +73,17 @@ vips_scRGB2RGB16( VipsImage *in, VipsImage **out, ... ) return( vips_scRGB2sRGB( in, out, "depth", 16, NULL ) ); } +static int +vips_RGB162sRGB( VipsImage *in, VipsImage **out, ... ) +{ + if( vips_msb( in, out, NULL ) ) + return( -1 ); + + (*out)->Type = VIPS_INTERPRETATION_sRGB; + + return( 0 ); +} + /* Process the first @n bands with @fn, detach and reattach remaining bands. */ static int @@ -335,8 +348,8 @@ static VipsColourRoute vips_colour_routes[] = { { RGB16, CMC, { vips_sRGB2scRGB, vips_scRGB2XYZ, vips_XYZ2Lab, vips_Lab2LCh, vips_LCh2CMC, NULL } }, { RGB16, scRGB, { vips_sRGB2scRGB, NULL } }, - { RGB16, sRGB, { vips_sRGB2scRGB, vips_scRGB2sRGB, NULL } }, - { RGB16, BW, { vips_sRGB2scRGB, vips_scRGB2sRGB, vips_sRGB2BW, NULL } }, + { RGB16, sRGB, { vips_RGB162sRGB, NULL } }, + { RGB16, BW, { vips_RGB162sRGB, vips_sRGB2BW, NULL } }, { RGB16, LABS, { vips_sRGB2scRGB, vips_scRGB2XYZ, vips_XYZ2Lab, vips_Lab2LabS, NULL } }, { RGB16, GREY16, { vips_RGB162GREY16, NULL } },