From cb83918a3f4b0135c06915a3a6fcc43689f6db77 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Tue, 21 Feb 2017 17:14:33 +0000 Subject: [PATCH] remove readbehind --- TODO | 4 ---- libvips/deprecated/im_jpeg2vips.c | 2 +- libvips/deprecated/im_png2vips.c | 2 +- libvips/deprecated/im_tiff2vips.c | 2 +- libvips/foreign/jpeg2vips.c | 18 +++++------------- libvips/foreign/jpegload.c | 11 ++++------- libvips/foreign/pforeign.h | 17 +++++++---------- libvips/foreign/pngload.c | 5 ++--- libvips/foreign/radiance.c | 2 +- libvips/foreign/radload.c | 3 +-- libvips/foreign/tiff2vips.c | 30 +++++++++++------------------- libvips/foreign/tiffload.c | 6 ++---- libvips/foreign/vipspng.c | 30 +++++++++++++----------------- 13 files changed, 49 insertions(+), 83 deletions(-) diff --git a/TODO b/TODO index 3f902ecb..8734bec6 100644 --- a/TODO +++ b/TODO @@ -1,10 +1,6 @@ - seq no longer stalls ahead threads ... instead, we rely on sinkdisk interlocks to limit how far ahead or behind threads can get - the readbehind option to many loaders is no longer needed - - check pforeign.h - - vips linecache has access there twice! diff --git a/libvips/deprecated/im_jpeg2vips.c b/libvips/deprecated/im_jpeg2vips.c index 2e3e5d09..11696663 100644 --- a/libvips/deprecated/im_jpeg2vips.c +++ b/libvips/deprecated/im_jpeg2vips.c @@ -111,7 +111,7 @@ jpeg2vips( const char *name, IMAGE *out, gboolean header_only ) #ifdef HAVE_JPEG if( vips__jpeg_read_file( filename, out, - header_only, shrink, fail_on_warn, TRUE, FALSE ) ) + header_only, shrink, fail_on_warn, FALSE ) ) return( -1 ); #else vips_error( "im_jpeg2vips", diff --git a/libvips/deprecated/im_png2vips.c b/libvips/deprecated/im_png2vips.c index a1b24579..61eb7fef 100644 --- a/libvips/deprecated/im_png2vips.c +++ b/libvips/deprecated/im_png2vips.c @@ -87,7 +87,7 @@ png2vips( const char *name, IMAGE *out, gboolean header_only ) return( -1 ); } else { - if( vips__png_read( filename, out, TRUE ) ) + if( vips__png_read( filename, out ) ) return( -1 ); } #else diff --git a/libvips/deprecated/im_tiff2vips.c b/libvips/deprecated/im_tiff2vips.c index 74479115..d94019e9 100644 --- a/libvips/deprecated/im_tiff2vips.c +++ b/libvips/deprecated/im_tiff2vips.c @@ -98,7 +98,7 @@ tiff2vips( const char *name, IMAGE *out, gboolean header_only ) return( -1 ); } else { - if( vips__tiff_read( filename, out, page, 1, FALSE, TRUE ) ) + if( vips__tiff_read( filename, out, page, 1, FALSE ) ) return( -1 ); } #else diff --git a/libvips/foreign/jpeg2vips.c b/libvips/foreign/jpeg2vips.c index b38baacc..8c63d3ec 100644 --- a/libvips/foreign/jpeg2vips.c +++ b/libvips/foreign/jpeg2vips.c @@ -152,10 +152,6 @@ typedef struct _ReadJpeg { */ gboolean fail; - /* Use a read behind buffer. - */ - gboolean readbehind; - /* Used for file input only. */ char *filename; @@ -216,8 +212,7 @@ readjpeg_close( VipsObject *object, ReadJpeg *jpeg ) } static ReadJpeg * -readjpeg_new( VipsImage *out, - int shrink, gboolean fail, gboolean readbehind, gboolean autorotate ) +readjpeg_new( VipsImage *out, int shrink, gboolean fail, gboolean autorotate ) { ReadJpeg *jpeg; @@ -227,7 +222,6 @@ readjpeg_new( VipsImage *out, jpeg->out = out; jpeg->shrink = shrink; jpeg->fail = fail; - jpeg->readbehind = readbehind; jpeg->filename = NULL; jpeg->cinfo.err = jpeg_std_error( &jpeg->eman.pub ); jpeg->eman.pub.error_exit = vips__new_error_exit; @@ -744,13 +738,12 @@ vips__jpeg_read( ReadJpeg *jpeg, VipsImage *out, gboolean header_only ) */ int vips__jpeg_read_file( const char *filename, VipsImage *out, - gboolean header_only, int shrink, gboolean fail, gboolean readbehind, - gboolean autorotate ) + gboolean header_only, int shrink, gboolean fail, gboolean autorotate ) { ReadJpeg *jpeg; if( !(jpeg = readjpeg_new( out, - shrink, fail, readbehind, autorotate )) ) + shrink, fail, autorotate )) ) return( -1 ); /* Here for longjmp() from vips__new_error_exit() during startup. @@ -951,13 +944,12 @@ readjpeg_buffer (ReadJpeg *jpeg, const void *buf, size_t len) int vips__jpeg_read_buffer( const void *buf, size_t len, VipsImage *out, - gboolean header_only, int shrink, int fail, gboolean readbehind, - gboolean autorotate ) + gboolean header_only, int shrink, int fail, gboolean autorotate ) { ReadJpeg *jpeg; if( !(jpeg = readjpeg_new( out, - shrink, fail, readbehind, autorotate )) ) + shrink, fail, autorotate )) ) return( -1 ); if( setjmp( jpeg->eman.jmp ) ) diff --git a/libvips/foreign/jpegload.c b/libvips/foreign/jpegload.c index bc0e2559..4868b950 100644 --- a/libvips/foreign/jpegload.c +++ b/libvips/foreign/jpegload.c @@ -182,7 +182,7 @@ vips_foreign_load_jpeg_file_header( VipsForeignLoad *load ) VipsForeignLoadJpegFile *file = (VipsForeignLoadJpegFile *) load; if( vips__jpeg_read_file( file->filename, load->out, - TRUE, jpeg->shrink, load->fail, FALSE, jpeg->autorotate ) ) + TRUE, jpeg->shrink, load->fail, jpeg->autorotate ) ) return( -1 ); return( 0 ); @@ -195,8 +195,7 @@ vips_foreign_load_jpeg_file_load( VipsForeignLoad *load ) VipsForeignLoadJpegFile *file = (VipsForeignLoadJpegFile *) load; if( vips__jpeg_read_file( file->filename, load->real, - FALSE, jpeg->shrink, load->fail, - load->access == VIPS_ACCESS_SEQUENTIAL, jpeg->autorotate ) ) + FALSE, jpeg->shrink, load->fail, jpeg->autorotate ) ) return( -1 ); return( 0 ); @@ -262,8 +261,7 @@ vips_foreign_load_jpeg_buffer_header( VipsForeignLoad *load ) VipsForeignLoadJpegBuffer *buffer = (VipsForeignLoadJpegBuffer *) load; if( vips__jpeg_read_buffer( buffer->buf->data, buffer->buf->length, - load->out, TRUE, jpeg->shrink, load->fail, FALSE, - jpeg->autorotate ) ) + load->out, TRUE, jpeg->shrink, load->fail, jpeg->autorotate ) ) return( -1 ); return( 0 ); @@ -276,8 +274,7 @@ vips_foreign_load_jpeg_buffer_load( VipsForeignLoad *load ) VipsForeignLoadJpegBuffer *buffer = (VipsForeignLoadJpegBuffer *) load; if( vips__jpeg_read_buffer( buffer->buf->data, buffer->buf->length, - load->real, FALSE, jpeg->shrink, load->fail, - load->access == VIPS_ACCESS_SEQUENTIAL, jpeg->autorotate ) ) + load->real, FALSE, jpeg->shrink, load->fail, jpeg->autorotate ) ) return( -1 ); return( 0 ); diff --git a/libvips/foreign/pforeign.h b/libvips/foreign/pforeign.h index 796c1d38..4aa39c74 100644 --- a/libvips/foreign/pforeign.h +++ b/libvips/foreign/pforeign.h @@ -68,7 +68,7 @@ int vips__tiff_write_buf( VipsImage *in, int vips__tiff_read_header( const char *filename, VipsImage *out, int page, int n, gboolean autorotate ); int vips__tiff_read( const char *filename, VipsImage *out, - int page, int n, gboolean autorotate, gboolean readbehind ); + int page, int n, gboolean autorotate ); gboolean vips__istiff( const char *filename ); gboolean vips__istifftiled( const char *filename ); @@ -79,7 +79,7 @@ gboolean vips__istifftiled_buffer( const void *buf, size_t len ); int vips__tiff_read_header_buffer( const void *buf, size_t len, VipsImage *out, int page, int n, gboolean autorotate ); int vips__tiff_read_buffer( const void *buf, size_t len, VipsImage *out, - int page, int n, gboolean autorotate, gboolean readbehind ); + int page, int n, gboolean autorotate ); extern const char *vips__foreign_tiff_suffs[]; @@ -149,7 +149,7 @@ int vips__ppm_save( VipsImage *in, const char *filename, int vips__rad_israd( const char *filename ); int vips__rad_header( const char *filename, VipsImage *out ); -int vips__rad_load( const char *filename, VipsImage *out, gboolean readbehind ); +int vips__rad_load( const char *filename, VipsImage *out ); int vips__rad_save( VipsImage *in, const char *filename ); int vips__rad_save_buf( VipsImage *in, void **obuf, size_t *olen ); @@ -172,21 +172,18 @@ int vips__jpeg_write_buffer( VipsImage *in, int vips__isjpeg_buffer( const void *buf, size_t len ); int vips__isjpeg( const char *filename ); int vips__jpeg_read_file( const char *name, VipsImage *out, - gboolean header_only, int shrink, gboolean fail, gboolean readbehind, - gboolean autorotate ); + gboolean header_only, int shrink, gboolean fail, gboolean autorotate ); int vips__jpeg_read_buffer( const void *buf, size_t len, VipsImage *out, - gboolean header_only, int shrink, int fail, gboolean readbehind, - gboolean autorotate ); + gboolean header_only, int shrink, int fail, gboolean autorotate ); int vips__png_header( const char *name, VipsImage *out ); -int vips__png_read( const char *name, VipsImage *out, gboolean readbehind ); +int vips__png_read( const char *name, VipsImage *out ); gboolean vips__png_ispng_buffer( const void *buf, size_t len ); int vips__png_ispng( const char *filename ); gboolean vips__png_isinterlaced( const char *filename ); gboolean vips__png_isinterlaced_buffer( const void *buffer, size_t length ); extern const char *vips__png_suffs[]; -int vips__png_read_buffer( const void *buffer, size_t length, - VipsImage *out, gboolean readbehind ); +int vips__png_read_buffer( const void *buffer, size_t length, VipsImage *out ); int vips__png_header_buffer( const void *buffer, size_t length, VipsImage *out ); diff --git a/libvips/foreign/pngload.c b/libvips/foreign/pngload.c index 7d10605d..01ffb7f1 100644 --- a/libvips/foreign/pngload.c +++ b/libvips/foreign/pngload.c @@ -106,8 +106,7 @@ vips_foreign_load_png_load( VipsForeignLoad *load ) { VipsForeignLoadPng *png = (VipsForeignLoadPng *) load; - if( vips__png_read( png->filename, load->real, - load->access == VIPS_ACCESS_SEQUENTIAL ) ) + if( vips__png_read( png->filename, load->real ) ) return( -1 ); return( 0 ); @@ -202,7 +201,7 @@ vips_foreign_load_png_buffer_load( VipsForeignLoad *load ) VipsForeignLoadPngBuffer *buffer = (VipsForeignLoadPngBuffer *) load; if( vips__png_read_buffer( buffer->buf->data, buffer->buf->length, - load->real, load->access == VIPS_ACCESS_SEQUENTIAL ) ) + load->real ) ) return( -1 ); return( 0 ); diff --git a/libvips/foreign/radiance.c b/libvips/foreign/radiance.c index ea939756..d6cddeb2 100644 --- a/libvips/foreign/radiance.c +++ b/libvips/foreign/radiance.c @@ -1134,7 +1134,7 @@ rad2vips_generate( VipsRegion *or, } int -vips__rad_load( const char *filename, VipsImage *out, gboolean readbehind ) +vips__rad_load( const char *filename, VipsImage *out ) { VipsImage **t = (VipsImage **) vips_object_local_array( VIPS_OBJECT( out ), 3 ); diff --git a/libvips/foreign/radload.c b/libvips/foreign/radload.c index 518ae8a8..e35a322b 100644 --- a/libvips/foreign/radload.c +++ b/libvips/foreign/radload.c @@ -100,8 +100,7 @@ vips_foreign_load_rad_load( VipsForeignLoad *load ) { VipsForeignLoadRad *rad = (VipsForeignLoadRad *) load; - if( vips__rad_load( rad->filename, load->real, - load->access == VIPS_ACCESS_SEQUENTIAL ) ) + if( vips__rad_load( rad->filename, load->real ) ) return( -1 ); return( 0 ); diff --git a/libvips/foreign/tiff2vips.c b/libvips/foreign/tiff2vips.c index f24b17ca..27414c4c 100644 --- a/libvips/foreign/tiff2vips.c +++ b/libvips/foreign/tiff2vips.c @@ -274,7 +274,6 @@ typedef struct _Rtiff { int page; int n; gboolean autorotate; - gboolean readbehind; /* The TIFF we read. */ @@ -1965,8 +1964,7 @@ rtiff_close( VipsObject *object, Rtiff *rtiff ) } static Rtiff * -rtiff_new( VipsImage *out, - int page, int n, gboolean autorotate, gboolean readbehind ) +rtiff_new( VipsImage *out, int page, int n, gboolean autorotate ) { Rtiff *rtiff; @@ -1978,7 +1976,6 @@ rtiff_new( VipsImage *out, rtiff->page = page; rtiff->n = n; rtiff->autorotate = autorotate; - rtiff->readbehind = readbehind; rtiff->tiff = NULL; rtiff->current_page = -1; rtiff->sfn = NULL; @@ -2183,11 +2180,11 @@ rtiff_header_read_all( Rtiff *rtiff ) static Rtiff * rtiff_new_filename( const char *filename, VipsImage *out, - int page, int n, gboolean autorotate, gboolean readbehind ) + int page, int n, gboolean autorotate ) { Rtiff *rtiff; - if( !(rtiff = rtiff_new( out, page, n, autorotate, readbehind )) || + if( !(rtiff = rtiff_new( out, page, n, autorotate )) || !(rtiff->tiff = vips__tiff_openin( filename )) || rtiff_header_read_all( rtiff ) ) return( NULL ); @@ -2199,11 +2196,11 @@ rtiff_new_filename( const char *filename, VipsImage *out, static Rtiff * rtiff_new_buffer( const void *buf, size_t len, VipsImage *out, - int page, int n, gboolean autorotate, gboolean readbehind ) + int page, int n, gboolean autorotate ) { Rtiff *rtiff; - if( !(rtiff = rtiff_new( out, page, n, autorotate, readbehind )) || + if( !(rtiff = rtiff_new( out, page, n, autorotate )) || !(rtiff->tiff = vips__tiff_openin_buffer( out, buf, len )) || rtiff_header_read_all( rtiff ) ) return( NULL ); @@ -2234,7 +2231,7 @@ istiffpyramid( const char *name ) int vips__tiff_read( const char *filename, VipsImage *out, - int page, int n, gboolean autorotate, gboolean readbehind ) + int page, int n, gboolean autorotate ) { Rtiff *rtiff; @@ -2245,8 +2242,7 @@ vips__tiff_read( const char *filename, VipsImage *out, vips__tiff_init(); - if( !(rtiff = rtiff_new_filename( filename, - out, page, n, autorotate, readbehind )) ) + if( !(rtiff = rtiff_new_filename( filename, out, page, n, autorotate )) ) return( -1 ); if( rtiff->header.tiled ) { @@ -2292,8 +2288,7 @@ vips__tiff_read_header( const char *filename, VipsImage *out, vips__tiff_init(); - if( !(rtiff = rtiff_new_filename( filename, out, - page, n, autorotate, FALSE )) ) + if( !(rtiff = rtiff_new_filename( filename, out, page, n, autorotate )) ) return( -1 ); if( rtiff_set_header( rtiff, out ) ) @@ -2361,8 +2356,7 @@ vips__tiff_read_header_buffer( const void *buf, size_t len, VipsImage *out, vips__tiff_init(); - if( !(rtiff = rtiff_new_buffer( buf, len, out, - page, n, autorotate, FALSE )) ) + if( !(rtiff = rtiff_new_buffer( buf, len, out, page, n, autorotate )) ) return( -1 ); if( rtiff_set_header( rtiff, out ) ) @@ -2375,8 +2369,7 @@ vips__tiff_read_header_buffer( const void *buf, size_t len, VipsImage *out, int vips__tiff_read_buffer( const void *buf, size_t len, - VipsImage *out, int page, int n, gboolean autorotate, - gboolean readbehind ) + VipsImage *out, int page, int n, gboolean autorotate ) { Rtiff *rtiff; @@ -2387,8 +2380,7 @@ vips__tiff_read_buffer( const void *buf, size_t len, vips__tiff_init(); - if( !(rtiff = rtiff_new_buffer( buf, len, out, - page, n, autorotate, readbehind )) ) + if( !(rtiff = rtiff_new_buffer( buf, len, out, page, n, autorotate )) ) return( -1 ); if( rtiff->header.tiled ) { diff --git a/libvips/foreign/tiffload.c b/libvips/foreign/tiffload.c index d4152b6f..76d2a365 100644 --- a/libvips/foreign/tiffload.c +++ b/libvips/foreign/tiffload.c @@ -183,8 +183,7 @@ vips_foreign_load_tiff_file_load( VipsForeignLoad *load ) VipsForeignLoadTiffFile *file = (VipsForeignLoadTiffFile *) load; if( vips__tiff_read( file->filename, load->real, - tiff->page, tiff->n, tiff->autorotate, - load->access == VIPS_ACCESS_SEQUENTIAL ) ) + tiff->page, tiff->n, tiff->autorotate ) ) return( -1 ); return( 0 ); @@ -284,8 +283,7 @@ vips_foreign_load_tiff_buffer_load( VipsForeignLoad *load ) if( vips__tiff_read_buffer( buffer->buf->data, buffer->buf->length, load->real, - tiff->page, tiff->n, tiff->autorotate, - load->access == VIPS_ACCESS_SEQUENTIAL ) ) + tiff->page, tiff->n, tiff->autorotate ) ) return( -1 ); return( 0 ); diff --git a/libvips/foreign/vipspng.c b/libvips/foreign/vipspng.c index 3004f282..336d3a05 100644 --- a/libvips/foreign/vipspng.c +++ b/libvips/foreign/vipspng.c @@ -138,7 +138,6 @@ user_warning_function( png_structp png_ptr, png_const_charp warning_msg ) typedef struct { char *name; VipsImage *out; - gboolean readbehind; int y_pos; png_structp pPng; @@ -175,7 +174,7 @@ read_close_cb( VipsImage *out, Read *read ) } static Read * -read_new( VipsImage *out, gboolean readbehind ) +read_new( VipsImage *out ) { Read *read; @@ -183,7 +182,6 @@ read_new( VipsImage *out, gboolean readbehind ) return( NULL ); read->name = NULL; - read->readbehind = readbehind; read->out = out; read->y_pos = 0; read->pPng = NULL; @@ -221,11 +219,11 @@ read_new( VipsImage *out, gboolean readbehind ) } static Read * -read_new_filename( VipsImage *out, const char *name, gboolean readbehind ) +read_new_filename( VipsImage *out, const char *name ) { Read *read; - if( !(read = read_new( out, readbehind )) ) + if( !(read = read_new( out )) ) return( NULL ); read->name = vips_strdup( VIPS_OBJECT( out ), name ); @@ -428,7 +426,7 @@ vips__png_header( const char *name, VipsImage *out ) { Read *read; - if( !(read = read_new_filename( out, name, FALSE )) || + if( !(read = read_new_filename( out, name )) || png2vips_header( read, out ) ) return( -1 ); @@ -557,7 +555,7 @@ vips__png_isinterlaced( const char *filename ) int interlace_type; image = vips_image_new(); - if( !(read = read_new_filename( image, filename, FALSE )) ) { + if( !(read = read_new_filename( image, filename )) ) { g_object_unref( image ); return( -1 ); } @@ -601,7 +599,7 @@ png2vips_image( Read *read, VipsImage *out ) } int -vips__png_read( const char *filename, VipsImage *out, gboolean readbehind ) +vips__png_read( const char *filename, VipsImage *out ) { Read *read; @@ -609,7 +607,7 @@ vips__png_read( const char *filename, VipsImage *out, gboolean readbehind ) printf( "vips__png_read: reading \"%s\"\n", filename ); #endif /*DEBUG*/ - if( !(read = read_new_filename( out, filename, readbehind )) || + if( !(read = read_new_filename( out, filename )) || png2vips_image( read, out ) ) return( -1 ); @@ -656,12 +654,11 @@ vips_png_read_buffer( png_structp pPng, png_bytep data, png_size_t length ) } static Read * -read_new_buffer( VipsImage *out, const void *buffer, size_t length, - gboolean readbehind ) +read_new_buffer( VipsImage *out, const void *buffer, size_t length ) { Read *read; - if( !(read = read_new( out, readbehind )) ) + if( !(read = read_new( out )) ) return( NULL ); read->length = length; @@ -687,7 +684,7 @@ vips__png_header_buffer( const void *buffer, size_t length, VipsImage *out ) { Read *read; - if( !(read = read_new_buffer( out, buffer, length, FALSE )) || + if( !(read = read_new_buffer( out, buffer, length )) || png2vips_header( read, out ) ) return( -1 ); @@ -695,12 +692,11 @@ vips__png_header_buffer( const void *buffer, size_t length, VipsImage *out ) } int -vips__png_read_buffer( const void *buffer, size_t length, VipsImage *out, - gboolean readbehind ) +vips__png_read_buffer( const void *buffer, size_t length, VipsImage *out ) { Read *read; - if( !(read = read_new_buffer( out, buffer, length, readbehind )) || + if( !(read = read_new_buffer( out, buffer, length )) || png2vips_image( read, out ) ) return( -1 ); @@ -719,7 +715,7 @@ vips__png_isinterlaced_buffer( const void *buffer, size_t length ) image = vips_image_new(); - if( !(read = read_new_buffer( image, buffer, length, FALSE )) ) { + if( !(read = read_new_buffer( image, buffer, length )) ) { g_object_unref( image ); return( -1 ); }