From 4ef825014d579132f53ce63c991d15fe58fd2c20 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Fri, 24 Aug 2012 17:03:09 +0100 Subject: [PATCH] extract is sequential again a hack in seq.c will skip ahead if the very first read is not at line 0 --- ChangeLog | 2 -- TODO | 3 --- libvips/conversion/extract.c | 2 ++ libvips/conversion/sequential.c | 28 ++++++++++++++++++++++++++-- 4 files changed, 28 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 854ec995..db28a956 100644 --- a/ChangeLog +++ b/ChangeLog @@ -13,8 +13,6 @@ - VipsSequential has an integrated cache and stalls out of order threads - add a line cache ... sizes up dynamically with request size - tilecache / linecache use a hash table not a linear list -- due to out of order stalling, extract_area is no longer a sequential - operation, sadly 20/7/12 started 7.30.0 - support "rs" mode in vips7 diff --git a/TODO b/TODO index 3a88051f..e4e24aca 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,3 @@ -- sometimes still errors in .jpg - - blocking bugs ============= diff --git a/libvips/conversion/extract.c b/libvips/conversion/extract.c index a14df039..f3c6c68d 100644 --- a/libvips/conversion/extract.c +++ b/libvips/conversion/extract.c @@ -191,6 +191,8 @@ vips_extract_area_class_init( VipsExtractAreaClass *class ) vobject_class->description = _( "extract an area from an image" ); vobject_class->build = vips_extract_area_build; + operation_class->flags = VIPS_OPERATION_SEQUENTIAL; + VIPS_ARG_IMAGE( class, "input", 0, _( "Input" ), _( "Input image" ), diff --git a/libvips/conversion/sequential.c b/libvips/conversion/sequential.c index afea8876..09865122 100644 --- a/libvips/conversion/sequential.c +++ b/libvips/conversion/sequential.c @@ -115,8 +115,10 @@ retry: VIPS_DEBUG_MSG( "thread %p has lock ...\n", g_thread_self() ); - if( r->top > sequential->y_pos ) { - /* This is for stuff in the future, stall. + if( r->top > sequential->y_pos && + sequential->y_pos > 0 ) { + /* We have started reading (y_pos > 0) and this request is for + * stuff beyond that, stall. */ VIPS_DEBUG_MSG( "thread %p stalling ...\n", g_thread_self() ); g_cond_wait( sequential->ready, sequential->lock ); @@ -126,6 +128,28 @@ retry: goto retry; } + /* This is a request for something some way down the image, and we've + * not read anything yet. Probably the operation is something like + * extract_area and we should skip the initial part of the image. In + * fact we read to cache. + */ + if( r->top > sequential->y_pos ) { + VipsRect area; + + VIPS_DEBUG_MSG( "thread %p skipping to line %d ...\n", + g_thread_self(), + r->top ); + + area.left = 0; + area.top = sequential->y_pos; + area.width = 1; + area.height = r->top - sequential->y_pos; + if( vips_region_prepare( ir, &area ) ) + return( -1 ); + + sequential->y_pos = VIPS_RECT_BOTTOM( &area ); + } + /* This is a request for old or present pixels -- serve from cache. * This may trigger further, sequential reads. */