remove readbehind

This commit is contained in:
John Cupitt 2017-02-21 17:14:33 +00:00
parent a4d3c2a754
commit cb83918a3f
13 changed files with 49 additions and 83 deletions

4
TODO
View File

@ -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!

View File

@ -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",

View File

@ -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

View File

@ -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

View File

@ -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 ) )

View File

@ -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 );

View File

@ -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 );

View File

@ -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 );

View File

@ -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 );

View File

@ -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 );

View File

@ -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 ) {

View File

@ -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 );

View File

@ -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 );
}