add Kleis's patches
and add minimise support to radiance load
This commit is contained in:
parent
edca486f19
commit
3d344b4b5f
@ -971,8 +971,12 @@ vips__jpeg_read_stream( VipsStreami *input, VipsImage *out,
|
||||
return( -1 );
|
||||
|
||||
if( readjpeg_open_input( jpeg ) ||
|
||||
vips__jpeg_read( jpeg, out, header_only ) ||
|
||||
vips_streami_decode( jpeg->input ) )
|
||||
vips__jpeg_read( jpeg, out, header_only ) )
|
||||
return( -1 );
|
||||
|
||||
if( header_only )
|
||||
vips_streami_minimise( input );
|
||||
else if( vips_streami_decode( input ) )
|
||||
return( -1 );
|
||||
|
||||
return( 0 );
|
||||
|
@ -744,6 +744,13 @@ read_destroy( VipsObject *object, Read *read )
|
||||
VIPS_UNREF( read->streamib );
|
||||
}
|
||||
|
||||
static void
|
||||
read_minimise_cb( VipsObject *object, Read *read )
|
||||
{
|
||||
if( read->streamib )
|
||||
vips_streami_minimise( read->streamib->streami );
|
||||
}
|
||||
|
||||
static Read *
|
||||
read_new( VipsStreami *streami, VipsImage *out )
|
||||
{
|
||||
@ -771,6 +778,8 @@ read_new( VipsStreami *streami, VipsImage *out )
|
||||
|
||||
g_signal_connect( out, "close",
|
||||
G_CALLBACK( read_destroy ), read );
|
||||
g_signal_connect( out, "minimise",
|
||||
G_CALLBACK( read_minimise_cb ), read );
|
||||
|
||||
return( read );
|
||||
}
|
||||
@ -889,6 +898,7 @@ vips__rad_header( VipsStreami *streami, VipsImage *out )
|
||||
return( -1 );
|
||||
if( rad2vips_get_header( read, read->out ) )
|
||||
return( -1 );
|
||||
vips_streami_minimise( streami );
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
@ -711,10 +711,11 @@ vips__png_header_stream( VipsStreami *input, VipsImage *out )
|
||||
Read *read;
|
||||
|
||||
if( !(read = read_new( input, out, TRUE )) ||
|
||||
png2vips_header( read, out ) ||
|
||||
vips_streami_decode( input ) )
|
||||
png2vips_header( read, out ) )
|
||||
return( -1 );
|
||||
|
||||
vips_streami_minimise( input );
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
|
@ -239,30 +239,27 @@ vips_streami_build( VipsObject *object )
|
||||
streami->length = VIPS_MIN( length, G_MAXSSIZE );
|
||||
}
|
||||
|
||||
/* If there's a descriptor for streami, test its properties.
|
||||
/* Can we seek this input?
|
||||
*
|
||||
* We need to call the method directly rather than via
|
||||
* vips_streami_seek() etc. or we might trigger seek emulation.
|
||||
*/
|
||||
if( stream->descriptor != -1 ) {
|
||||
/* Can we seek? If not, this is some kind of pipe.
|
||||
*
|
||||
* We must call the class method directly: if we go via
|
||||
* vips_streami_seek() we'll trigger seek emulation on pipes.
|
||||
if( class->seek( streami, 0, SEEK_CUR ) == -1 ) {
|
||||
/* Not seekable. This must be some kind of pipe.
|
||||
*/
|
||||
if( class->seek( streami, 0, SEEK_CUR ) == -1 ) {
|
||||
VIPS_DEBUG_MSG( " not seekable\n" );
|
||||
streami->is_pipe = TRUE;
|
||||
}
|
||||
|
||||
/* Try and get the length, as long as we're seekable.
|
||||
*/
|
||||
if( !streami->is_pipe &&
|
||||
(streami->length = vips_streami_size( streami )) == -1 )
|
||||
return( -1 );
|
||||
VIPS_DEBUG_MSG( " not seekable\n" );
|
||||
streami->is_pipe = TRUE;
|
||||
}
|
||||
else {
|
||||
/* We should be able to get the length of seekable objects.
|
||||
*/
|
||||
if( (streami->length = vips_streami_size( streami )) == -1 )
|
||||
return( -1 );
|
||||
|
||||
/* If we can seek, we won't need to save header bytes.
|
||||
*/
|
||||
if( !streami->is_pipe )
|
||||
/* If we can seek, we won't need to save header bytes.
|
||||
*/
|
||||
VIPS_FREEF( g_byte_array_unref, streami->header_bytes );
|
||||
}
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
@ -711,7 +708,7 @@ vips_streami_read( VipsStreami *streami, void *buffer, size_t length )
|
||||
*/
|
||||
static const int vips_pipe_read_limit = 1024 * 1024 * 1024;
|
||||
|
||||
/* Read to a position. -1 means read to end of stream. Does not chenge
|
||||
/* Read to a position. -1 means read to end of stream. Does not change
|
||||
* read_position.
|
||||
*/
|
||||
static int
|
||||
|
91
test/test-suite/images/sample.hdr
Normal file
91
test/test-suite/images/sample.hdr
Normal file
File diff suppressed because one or more lines are too long
@ -2,7 +2,7 @@
|
||||
|
||||
# test the various restartable loaders
|
||||
|
||||
# webp uses streans, but it needs to mmap the input, so you can't close() the
|
||||
# webp uses streams, but it needs to mmap the input, so you can't close() the
|
||||
# fd on minimise
|
||||
|
||||
# set -x
|
||||
@ -21,3 +21,7 @@ fi
|
||||
if test_supported tiffload; then
|
||||
./test_descriptors $test_images/sample.tif
|
||||
fi
|
||||
|
||||
if test_supported radload; then
|
||||
./test_descriptors $test_images/sample.hdr
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user