turn off seq mode in vips7

the new sequential mode readers for tiff/jpg/png were not working well
from the vips7 command-line: they either decompressed twice, or handed
over a sequential mode image

it should now work as well as it did pre-seq.
This commit is contained in:
John Cupitt 2012-07-12 09:05:14 +01:00
parent 17b2592883
commit 25ad2b7a53
6 changed files with 89 additions and 4 deletions

View File

@ -17,6 +17,7 @@
- added VIPS_OPERATION_SEQUENTIAL flag
- vips8 command-line interface uses this to turn sequential mode on
automatically when possible
- better handling of input files in vips7 command-line interface
18/6/12 started 7.28.9
- slightly more memory debugging output

28
TODO
View File

@ -1,3 +1,31 @@
- try:
$ vips list classes | grep -i open
** DEBUG_FATAL
VipsFormatExr (exr), OpenEXR, (.exr) is_a load get_flags
VipsFormatOpenslide (im_openslide), Openslide, (.svs, .vms, .vmu, .ndpi, .mrxs, .tif) is_a load get_flags
VipsForeignLoadOpenexr (openexrload), load an OpenEXR image (.exr), priority=0, is_a, get_flags, get_flags_filename, header, load
im_exr2vips (im_exr2vips), convert an OpenEXR file to VIPS, from package "format"
im_binfile (im_binfile), open a headerless binary file, from package "iofuncs"
why the im_ in "VipsFormatOpenslide (im_openslide)"?
we configured without openslide, why is it there at all?
test with openslide available
- try
vips im_extract_bands /tmp/input.tiff /tmp/out.tif 0 3
with a huhuhuhge image, hits 4gb and sits there, no error?
- test "rs" mode
can't see the code for "rd" mode?

View File

@ -51,8 +51,8 @@
#include <jerror.h>
#include "../foreign/jpeg.h"
int
im_jpeg2vips( const char *name, IMAGE *out )
static int
jpeg2vips( const char *name, IMAGE *out, gboolean header_only )
{
char filename[FILENAME_MAX];
char mode[FILENAME_MAX];
@ -97,12 +97,41 @@ im_jpeg2vips( const char *name, IMAGE *out )
* order to avoid the foreign.c mechanisms for load-via-disc and stuff
* like that.
*/
if( vips__jpeg_read_file( filename, out, FALSE, shrink, fail_on_warn ) )
/* We need to be compatible with the pre-sequential mode
* im_jpeg2vips(). This returned a "t" if given a "p" image, since it
* used writeline.
*
* If we're writing the image to a "p", switch it to a "t".
*/
if( !header_only &&
out->dtype == VIPS_IMAGE_PARTIAL ) {
if( vips__image_wio_output( out ) )
return( -1 );
}
if( vips__jpeg_read_file( filename, out,
header_only, shrink, fail_on_warn ) )
return( -1 );
return( 0 );
}
int
im_jpeg2vips( const char *name, IMAGE *out )
{
return( jpeg2vips( name, out, FALSE ) );
}
/* By having a separate header func, we get lazy.c to open via disc/mem.
*/
static int
im_jpeg2vips_header( const char *name, IMAGE *out )
{
return( jpeg2vips( name, out, TRUE ) );
}
int
im_bufjpeg2vips( void *buf, size_t len, IMAGE *out, gboolean header_only )
{
@ -151,6 +180,7 @@ vips_format_jpeg_class_init( VipsFormatJpegClass *class )
object_class->description = _( "JPEG" );
format_class->is_a = isjpeg;
format_class->header = im_jpeg2vips_header;
format_class->load = im_jpeg2vips;
format_class->save = im_vips2jpeg;
format_class->suffs = jpeg_suffs;

View File

@ -61,6 +61,18 @@ im_png2vips( const char *name, IMAGE *out )
;
}
/* We need to be compatible with the pre-sequential mode
* im_png2vips(). This returned a "t" if given a "p" image, since it
* used writeline.
*
* If we're writing the image to a "p", switch it to a "t".
*/
if( out->dtype == VIPS_IMAGE_PARTIAL ) {
if( vips__image_wio_output( out ) )
return( -1 );
}
if( vips__png_read( filename, out ) )
return( -1 );

View File

@ -70,6 +70,20 @@ im_tiff2vips( const char *name, IMAGE *out )
;
}
/* We need to be compatible with the pre-sequential mode
* im_tiff2vips(). This returned a "t" if given a "p" image, since it
* used writeline.
*
* If we're writing the image to a "p", switch it to a "t". And only
* for non-tiled (strip) images which we write with writeline.
*/
if( !vips__istifftiled( filename ) &&
out->dtype == VIPS_IMAGE_PARTIAL ) {
if( vips__image_wio_output( out ) )
return( -1 );
}
if( vips__tiff_read( filename, out, page ) )
return( -1 );

View File

@ -243,7 +243,7 @@ vips_operation_summary( VipsObject *object, VipsBuf *buf )
VipsOperation *operation = VIPS_OPERATION( object );
VipsObjectClass *object_class = VIPS_OBJECT_GET_CLASS( object );
vips_buf_appendf( buf, "%s", object_class->nickname );
vips_buf_appendf( buf, "- %s", object_class->nickname );
vips_argument_map( VIPS_OBJECT( operation ),
vips_operation_vips_operation_print_summary_arg, buf, NULL );