From e4ab251fd14ebcb035886f50bbba98a94ad1e15a Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Mon, 6 Mar 2017 14:51:45 +0000 Subject: [PATCH] small cleanups make embed less chatty with --vips-cache-trace shrink can use linecache now found a fail case on the work machine --- TODO | 45 ++++++++++++++++++++++++++++++++++++++ libvips/conversion/embed.c | 13 ++++++----- libvips/resample/shrinkv.c | 15 ++++--------- 3 files changed, 56 insertions(+), 17 deletions(-) diff --git a/TODO b/TODO index 481b0734..69bb5215 100644 --- a/TODO +++ b/TODO @@ -1,3 +1,48 @@ +- fails with out of order + + $ vips resize blackbug.png x.jpg 0.25 + + where + + $ vipsheader blackbug.png + blackbug.png: 2048x1536 uchar, 4 bands, srgb, pngload + + makes two caches: + height 8 tiles for the input sequential + height 10 tilecache, 39 tiles, for the shrinkv + + vips_shrinkv_gen sees: + + vips_shrinkv_gen: generating 2048 x 10 at 0 x 250 + vips_shrinkv_gen: generating 2048 x 10 at 0 x 500 + vips_shrinkv_gen: generating 2048 x 10 at 0 x 510 + vips_shrinkv_gen: generating 2048 x 10 at 0 x 260 + vips_shrinkv_gen: generating 2048 x 10 at 0 x 10 + + (vips:15685): VIPS-WARNING **: error in tile 0 x 16 + + concurrency=4 seems to always work + concurrency=5 fails 50% + concurrency=6 almost always fails + +- argh + +#!/usr/bin/env python + +import sys + +import gi +gi.require_version('Vips', '8.0') +from gi.repository import Vips + +x = Vips.Image.new_from_file(sys.argv[1], access = Vips.Access.SEQUENTIAL) +x = x.resize(0.1) +x.write_to_file(sys.argv[2]) + + fails with out of order ... why? + + + - vips_object_class_install_argument() should check for duplicate priorities, it's been behind a few nasty bugs diff --git a/libvips/conversion/embed.c b/libvips/conversion/embed.c index 52d23825..f6a535c5 100644 --- a/libvips/conversion/embed.c +++ b/libvips/conversion/embed.c @@ -357,16 +357,17 @@ vips_embed_build( VipsObject *object ) embed->height == embed->in->Ysize ) return( vips_image_write( embed->in, conversion->out ) ); - if( !(embed->ink = vips__vector_to_ink( - class->nickname, embed->in, - VIPS_AREA( embed->background )->data, NULL, - VIPS_AREA( embed->background )->n )) ) - return( -1 ); - if( !vips_object_argument_isset( object, "extend" ) && vips_object_argument_isset( object, "background" ) ) embed->extend = VIPS_EXTEND_BACKGROUND; + if( embed->extend == VIPS_EXTEND_BACKGROUND ) + if( !(embed->ink = vips__vector_to_ink( + class->nickname, embed->in, + VIPS_AREA( embed->background )->data, NULL, + VIPS_AREA( embed->background )->n )) ) + return( -1 ); + switch( embed->extend ) { case VIPS_EXTEND_REPEAT: { diff --git a/libvips/resample/shrinkv.c b/libvips/resample/shrinkv.c index 087db3ef..32697dd9 100644 --- a/libvips/resample/shrinkv.c +++ b/libvips/resample/shrinkv.c @@ -275,9 +275,9 @@ vips_shrinkv_gen( VipsRegion *or, void *vseq, */ #ifdef DEBUG +#endif /*DEBUG*/ printf( "vips_shrinkv_gen: generating %d x %d at %d x %d\n", r->width, r->height, r->left, r->top ); -#endif /*DEBUG*/ for( y = 0; y < r->height; y++ ) { memset( seq->sum, 0, shrink->sizeof_line_buffer ); @@ -417,18 +417,11 @@ vips_shrinkv_build( VipsObject *object ) * happen for a very tall, thin image with a very large shrink factor. */ if( vips_image_get_typeof( in, VIPS_META_SEQUENTIAL ) ) { - int tile_width; - int tile_height; - int n_lines; - g_info( "shrinkv sequential line cache" ); - vips_get_tile_size( in, - &tile_width, &tile_height, &n_lines ); - if( vips_tilecache( in, &t[3], - "tile_width", in->Xsize, - "tile_height", 10, - "max_tiles", 1 + n_lines / 10, + + if( vips_linecache( in, &t[3], "access", VIPS_ACCESS_SEQUENTIAL, + "tile_height", 10, "threaded", FALSE, NULL ) ) return( -1 );