move META_SEQ support into foreign load

simplifies loaders a bit
This commit is contained in:
John Cupitt 2018-01-01 11:14:27 +00:00
parent 86e07236b9
commit 6f2861df5b
5 changed files with 16 additions and 26 deletions

View File

@ -18,6 +18,8 @@
* - transform cmyk->rgb if there's an embedded profile
* 16/6/17
* - add page_height
* 1/1/18
* - META_SEQ support moved here
*/
/*
@ -874,6 +876,7 @@ vips_foreign_load_build( VipsObject *object )
VipsForeignLoadClass *fclass = VIPS_FOREIGN_LOAD_GET_CLASS( object );
VipsForeignFlags flags;
gboolean sequential;
#ifdef DEBUG
printf( "vips_foreign_load_build:\n" );
@ -893,11 +896,14 @@ vips_foreign_load_build( VipsObject *object )
g_object_set( load, "flags", flags, NULL );
/* If the loader can do sequential mode and sequential has been
* requested, we need to block caching.
/* Seq access has been requested and the loader supports seq.
*/
if( (load->flags & VIPS_FOREIGN_SEQUENTIAL) &&
load->access != VIPS_ACCESS_RANDOM )
sequential = (load->flags & VIPS_FOREIGN_SEQUENTIAL) &&
load->access != VIPS_ACCESS_RANDOM;
/* We must block caching of seq loads.
*/
if( sequential )
load->nocache = TRUE;
if( VIPS_OBJECT_CLASS( vips_foreign_load_parent_class )->
@ -952,11 +958,11 @@ vips_foreign_load_build( VipsObject *object )
return( -1 );
}
/* If random access has been requested, make sure that we don't have a
* SEQ tag left from a sequential loader.
/* Tell downstream if we are reading sequentially.
*/
if( load->access == VIPS_ACCESS_RANDOM )
(void) vips_image_remove( load->out, VIPS_META_SEQUENTIAL );
if( sequential )
vips_image_set_area( load->out,
VIPS_META_SEQUENTIAL, NULL, NULL );
return( 0 );
}

View File

@ -523,10 +523,6 @@ read_jpeg_header( ReadJpeg *jpeg, VipsImage *out )
(VipsCallbackFn) vips_free, data, data_length );
}
/* Tell downstream we are reading sequentially.
*/
vips_image_set_area( out, VIPS_META_SEQUENTIAL, NULL, NULL );
return( 0 );
}

View File

@ -1082,10 +1082,6 @@ rad2vips_get_header( Read *read, VipsImage *out )
vips_image_set_double( out,
prims_name[i][j], read->prims[i][j] );
/* Tell downstream we are reading sequentially.
*/
vips_image_set_area( out, VIPS_META_SEQUENTIAL, NULL, NULL );
return( 0 );
}

View File

@ -1345,11 +1345,6 @@ rtiff_set_header( Rtiff *rtiff, VipsImage *out )
vips_image_set_int( out,
VIPS_META_ORIENTATION, rtiff->header.orientation );
/* Tell downstream if we are reading sequentially.
*/
if( !rtiff->header.tiled )
vips_image_set_area( out, VIPS_META_SEQUENTIAL, NULL, NULL );
return( 0 );
}

View File

@ -397,19 +397,16 @@ png2vips_header( Read *read, VipsImage *out )
/* Uninterlaced images will be read in seq mode. Interlaced images are
* read via a huge memory buffer.
*/
if( interlace_type == PNG_INTERLACE_NONE ) {
vips_image_set_area( out, VIPS_META_SEQUENTIAL, NULL, NULL );
if( interlace_type == PNG_INTERLACE_NONE )
/* Sequential mode needs thinstrip to work with things like
* vips_shrink().
*/
vips_image_pipelinev( out, VIPS_DEMAND_STYLE_THINSTRIP, NULL );
}
else
vips_image_pipelinev( out, VIPS_DEMAND_STYLE_ANY, NULL );
/* Fetch the ICC profile. @name is useless, something like "icc" or
* "ICC Profile" etc. Ignore it.
* "ICC Profile" etc. Ignore it.
*
* @profile was png_charpp in libpngs < 1.5, png_bytepp is the
* modern one. Ignore the warning, if any.