more refactoring
This commit is contained in:
parent
72cbaa9ea3
commit
ee3270f8e9
@ -112,9 +112,9 @@ jpeg2vips( const char *name, IMAGE *out, gboolean header_only )
|
|||||||
|
|
||||||
#ifdef HAVE_JPEG
|
#ifdef HAVE_JPEG
|
||||||
{
|
{
|
||||||
VipsStreamInput *input;
|
VipsStreami *input;
|
||||||
|
|
||||||
if( !(input = vips_stream_input_new_from_filename( filename )) )
|
if( !(input = vips_streami_new_from_filename( filename )) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
if( vips__jpeg_read_stream( input, out,
|
if( vips__jpeg_read_stream( input, out,
|
||||||
header_only, shrink, fail_on_warn, FALSE ) ) {
|
header_only, shrink, fail_on_warn, FALSE ) ) {
|
||||||
|
@ -84,10 +84,10 @@ png2vips( const char *name, IMAGE *out, gboolean header_only )
|
|||||||
|
|
||||||
#ifdef HAVE_PNG
|
#ifdef HAVE_PNG
|
||||||
{
|
{
|
||||||
VipsStreamInput *input;
|
VipsStreami *input;
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
if( !(input = vips_stream_input_new_from_filename( filename )) )
|
if( !(input = vips_streami_new_from_filename( filename )) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
if( header_only )
|
if( header_only )
|
||||||
result = vips__png_header_stream( input, out );
|
result = vips__png_header_stream( input, out );
|
||||||
|
@ -56,10 +56,10 @@
|
|||||||
static gboolean
|
static gboolean
|
||||||
im_istifftiled( const char *filename )
|
im_istifftiled( const char *filename )
|
||||||
{
|
{
|
||||||
VipsStreamInput *input;
|
VipsStreami *input;
|
||||||
gboolean result;
|
gboolean result;
|
||||||
|
|
||||||
if( !(input = vips_stream_input_new_from_filename( filename )) )
|
if( !(input = vips_streami_new_from_filename( filename )) )
|
||||||
return( FALSE );
|
return( FALSE );
|
||||||
result = vips__istiff_stream( input );
|
result = vips__istiff_stream( input );
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( input );
|
||||||
@ -71,9 +71,9 @@ static int
|
|||||||
im_tiff_read_header( const char *filename, VipsImage *out,
|
im_tiff_read_header( const char *filename, VipsImage *out,
|
||||||
int page, int n, gboolean autorotate )
|
int page, int n, gboolean autorotate )
|
||||||
{
|
{
|
||||||
VipsStreamInput *input;
|
VipsStreami *input;
|
||||||
|
|
||||||
if( !(input = vips_stream_input_new_from_filename( filename )) )
|
if( !(input = vips_streami_new_from_filename( filename )) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
if( vips__tiff_read_header_stream( input, out, page, n, autorotate ) ) {
|
if( vips__tiff_read_header_stream( input, out, page, n, autorotate ) ) {
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( input );
|
||||||
@ -88,9 +88,9 @@ static int
|
|||||||
im_tiff_read( const char *filename, VipsImage *out,
|
im_tiff_read( const char *filename, VipsImage *out,
|
||||||
int page, int n, gboolean autorotate )
|
int page, int n, gboolean autorotate )
|
||||||
{
|
{
|
||||||
VipsStreamInput *input;
|
VipsStreami *input;
|
||||||
|
|
||||||
if( !(input = vips_stream_input_new_from_filename( filename )) )
|
if( !(input = vips_streami_new_from_filename( filename )) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
if( vips__tiff_read_stream( input, out, page, n, autorotate ) ) {
|
if( vips__tiff_read_stream( input, out, page, n, autorotate ) ) {
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( input );
|
||||||
|
@ -52,10 +52,10 @@ webp2vips( const char *name, IMAGE *out, gboolean header_only )
|
|||||||
|
|
||||||
#ifdef HAVE_LIBWEBP
|
#ifdef HAVE_LIBWEBP
|
||||||
{
|
{
|
||||||
VipsStreamInput *input;
|
VipsStreami *input;
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
if( !(input = vips_stream_input_new_from_filename( filename )) )
|
if( !(input = vips_streami_new_from_filename( filename )) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
if( header_only )
|
if( header_only )
|
||||||
result = vips__webp_read_header_stream( input, out, 0, 1, 1 );
|
result = vips__webp_read_header_stream( input, out, 0, 1, 1 );
|
||||||
@ -82,9 +82,9 @@ vips__iswebp( const char *filename )
|
|||||||
gboolean result;
|
gboolean result;
|
||||||
|
|
||||||
#ifdef HAVE_LIBWEBP
|
#ifdef HAVE_LIBWEBP
|
||||||
VipsStreamInput *input;
|
VipsStreami *input;
|
||||||
|
|
||||||
if( !(input = vips_stream_input_new_from_filename( filename )) )
|
if( !(input = vips_streami_new_from_filename( filename )) )
|
||||||
return( FALSE );
|
return( FALSE );
|
||||||
result = vips__png_ispng_stream( input );
|
result = vips__png_ispng_stream( input );
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( input );
|
||||||
|
@ -193,7 +193,7 @@ typedef struct _ReadJpeg {
|
|||||||
|
|
||||||
/* The stream we read from.
|
/* The stream we read from.
|
||||||
*/
|
*/
|
||||||
VipsStreamInput *input;
|
VipsStreami *input;
|
||||||
|
|
||||||
} ReadJpeg;
|
} ReadJpeg;
|
||||||
|
|
||||||
@ -208,7 +208,7 @@ typedef struct {
|
|||||||
|
|
||||||
/* Private stuff during read.
|
/* Private stuff during read.
|
||||||
*/
|
*/
|
||||||
VipsStreamInput *input;
|
VipsStreami *input;
|
||||||
unsigned char buf[STREAM_BUFFER_SIZE];
|
unsigned char buf[STREAM_BUFFER_SIZE];
|
||||||
|
|
||||||
} Source;
|
} Source;
|
||||||
@ -238,7 +238,7 @@ stream_fill_input_buffer( j_decompress_ptr cinfo )
|
|||||||
|
|
||||||
size_t read;
|
size_t read;
|
||||||
|
|
||||||
if( (read = vips_stream_input_read( src->input,
|
if( (read = vips_streami_read( src->input,
|
||||||
src->buf, STREAM_BUFFER_SIZE )) > 0 ) {
|
src->buf, STREAM_BUFFER_SIZE )) > 0 ) {
|
||||||
src->pub.next_input_byte = src->buf;
|
src->pub.next_input_byte = src->buf;
|
||||||
src->pub.bytes_in_buffer = read;
|
src->pub.bytes_in_buffer = read;
|
||||||
@ -281,7 +281,7 @@ readjpeg_open_input( ReadJpeg *jpeg )
|
|||||||
!cinfo->src ) {
|
!cinfo->src ) {
|
||||||
Source *src;
|
Source *src;
|
||||||
|
|
||||||
if( vips_stream_input_rewind( jpeg->input ) )
|
if( vips_streami_rewind( jpeg->input ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
cinfo->src = (struct jpeg_source_mgr *)
|
cinfo->src = (struct jpeg_source_mgr *)
|
||||||
@ -338,13 +338,13 @@ readjpeg_close_cb( VipsObject *object, ReadJpeg *jpeg )
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
input_minimise_cb( VipsImage *image, VipsStreamInput *input )
|
input_minimise_cb( VipsImage *image, VipsStreami *input )
|
||||||
{
|
{
|
||||||
vips_stream_input_minimise( input );
|
vips_streami_minimise( input );
|
||||||
}
|
}
|
||||||
|
|
||||||
static ReadJpeg *
|
static ReadJpeg *
|
||||||
readjpeg_new( VipsStreamInput *input, VipsImage *out,
|
readjpeg_new( VipsStreami *input, VipsImage *out,
|
||||||
int shrink, gboolean fail, gboolean autorotate )
|
int shrink, gboolean fail, gboolean autorotate )
|
||||||
{
|
{
|
||||||
ReadJpeg *jpeg;
|
ReadJpeg *jpeg;
|
||||||
@ -558,8 +558,7 @@ read_jpeg_header( ReadJpeg *jpeg, VipsImage *out )
|
|||||||
interpretation,
|
interpretation,
|
||||||
xres, yres );
|
xres, yres );
|
||||||
|
|
||||||
VIPS_SETSTR( out->filename,
|
VIPS_SETSTR( out->filename, VIPS_STREAM( jpeg->input )->filename );
|
||||||
vips_stream_filename( VIPS_STREAM( jpeg->input ) ) );
|
|
||||||
|
|
||||||
vips_image_pipelinev( out, VIPS_DEMAND_STYLE_FATSTRIP, NULL );
|
vips_image_pipelinev( out, VIPS_DEMAND_STYLE_FATSTRIP, NULL );
|
||||||
|
|
||||||
@ -746,7 +745,7 @@ read_jpeg_generate( VipsRegion *or,
|
|||||||
|
|
||||||
/* In pixel decode mode.
|
/* In pixel decode mode.
|
||||||
*/
|
*/
|
||||||
if( vips_stream_input_decode( jpeg->input ) )
|
if( vips_streami_decode( jpeg->input ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
VIPS_GATE_START( "read_jpeg_generate: work" );
|
VIPS_GATE_START( "read_jpeg_generate: work" );
|
||||||
@ -955,7 +954,7 @@ vips__jpeg_read( ReadJpeg *jpeg, VipsImage *out, gboolean header_only )
|
|||||||
vips_autorot_remove_angle( out );
|
vips_autorot_remove_angle( out );
|
||||||
}
|
}
|
||||||
|
|
||||||
vips_stream_input_minimise( jpeg->input );
|
vips_streami_minimise( jpeg->input );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if( read_jpeg_image( jpeg, out ) )
|
if( read_jpeg_image( jpeg, out ) )
|
||||||
@ -966,7 +965,7 @@ vips__jpeg_read( ReadJpeg *jpeg, VipsImage *out, gboolean header_only )
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
vips__jpeg_read_stream( VipsStreamInput *input, VipsImage *out,
|
vips__jpeg_read_stream( VipsStreami *input, VipsImage *out,
|
||||||
gboolean header_only, int shrink, int fail, gboolean autorotate )
|
gboolean header_only, int shrink, int fail, gboolean autorotate )
|
||||||
{
|
{
|
||||||
ReadJpeg *jpeg;
|
ReadJpeg *jpeg;
|
||||||
@ -987,11 +986,11 @@ vips__jpeg_read_stream( VipsStreamInput *input, VipsImage *out,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
vips__isjpeg_stream( VipsStreamInput *input )
|
vips__isjpeg_stream( VipsStreami *input )
|
||||||
{
|
{
|
||||||
const unsigned char *p;
|
const unsigned char *p;
|
||||||
|
|
||||||
if( (p = vips_stream_input_sniff( input, 2 )) &&
|
if( (p = vips_streami_sniff( input, 2 )) &&
|
||||||
p[0] == 0xff &&
|
p[0] == 0xff &&
|
||||||
p[1] == 0xd8 )
|
p[1] == 0xd8 )
|
||||||
return( 1 );
|
return( 1 );
|
||||||
|
@ -153,7 +153,7 @@ vips_foreign_load_jpeg_init( VipsForeignLoadJpeg *jpeg )
|
|||||||
typedef struct _VipsForeignLoadJpegStream {
|
typedef struct _VipsForeignLoadJpegStream {
|
||||||
VipsForeignLoadJpeg parent_object;
|
VipsForeignLoadJpeg parent_object;
|
||||||
|
|
||||||
VipsStreamInput *input;
|
VipsStreami *input;
|
||||||
|
|
||||||
} VipsForeignLoadJpegStream;
|
} VipsForeignLoadJpegStream;
|
||||||
|
|
||||||
@ -190,7 +190,7 @@ vips_foreign_load_jpeg_stream_load( VipsForeignLoad *load )
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
vips_foreign_load_jpeg_stream_is_a( VipsStreamInput *input )
|
vips_foreign_load_jpeg_stream_is_a( VipsStreami *input )
|
||||||
{
|
{
|
||||||
return( vips__isjpeg_stream( input ) );
|
return( vips__isjpeg_stream( input ) );
|
||||||
}
|
}
|
||||||
@ -218,7 +218,7 @@ vips_foreign_load_jpeg_stream_class_init(
|
|||||||
_( "Stream to load from" ),
|
_( "Stream to load from" ),
|
||||||
VIPS_ARGUMENT_REQUIRED_INPUT,
|
VIPS_ARGUMENT_REQUIRED_INPUT,
|
||||||
G_STRUCT_OFFSET( VipsForeignLoadJpegStream, input ),
|
G_STRUCT_OFFSET( VipsForeignLoadJpegStream, input ),
|
||||||
VIPS_TYPE_STREAM_INPUT );
|
VIPS_TYPE_STREAMI );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -242,10 +242,10 @@ G_DEFINE_TYPE( VipsForeignLoadJpegFile, vips_foreign_load_jpeg_file,
|
|||||||
static gboolean
|
static gboolean
|
||||||
vips_foreign_load_jpeg_file_is_a( const char *filename )
|
vips_foreign_load_jpeg_file_is_a( const char *filename )
|
||||||
{
|
{
|
||||||
VipsStreamInput *input;
|
VipsStreami *input;
|
||||||
gboolean result;
|
gboolean result;
|
||||||
|
|
||||||
if( !(input = vips_stream_input_new_from_filename( filename )) )
|
if( !(input = vips_streami_new_from_filename( filename )) )
|
||||||
return( FALSE );
|
return( FALSE );
|
||||||
result = vips__isjpeg_stream( input );
|
result = vips__isjpeg_stream( input );
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( input );
|
||||||
@ -259,9 +259,9 @@ vips_foreign_load_jpeg_file_header( VipsForeignLoad *load )
|
|||||||
VipsForeignLoadJpeg *jpeg = (VipsForeignLoadJpeg *) load;
|
VipsForeignLoadJpeg *jpeg = (VipsForeignLoadJpeg *) load;
|
||||||
VipsForeignLoadJpegFile *file = (VipsForeignLoadJpegFile *) load;
|
VipsForeignLoadJpegFile *file = (VipsForeignLoadJpegFile *) load;
|
||||||
|
|
||||||
VipsStreamInput *input;
|
VipsStreami *input;
|
||||||
|
|
||||||
if( !(input = vips_stream_input_new_from_filename( file->filename )) )
|
if( !(input = vips_streami_new_from_filename( file->filename )) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
if( vips__jpeg_read_stream( input, load->out,
|
if( vips__jpeg_read_stream( input, load->out,
|
||||||
TRUE, jpeg->shrink, load->fail, jpeg->autorotate ) ) {
|
TRUE, jpeg->shrink, load->fail, jpeg->autorotate ) ) {
|
||||||
@ -279,9 +279,9 @@ vips_foreign_load_jpeg_file_load( VipsForeignLoad *load )
|
|||||||
VipsForeignLoadJpeg *jpeg = (VipsForeignLoadJpeg *) load;
|
VipsForeignLoadJpeg *jpeg = (VipsForeignLoadJpeg *) load;
|
||||||
VipsForeignLoadJpegFile *file = (VipsForeignLoadJpegFile *) load;
|
VipsForeignLoadJpegFile *file = (VipsForeignLoadJpegFile *) load;
|
||||||
|
|
||||||
VipsStreamInput *input;
|
VipsStreami *input;
|
||||||
|
|
||||||
if( !(input = vips_stream_input_new_from_filename( file->filename )) )
|
if( !(input = vips_streami_new_from_filename( file->filename )) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
if( vips__jpeg_read_stream( input, load->real,
|
if( vips__jpeg_read_stream( input, load->real,
|
||||||
FALSE, jpeg->shrink, load->fail, jpeg->autorotate ) ) {
|
FALSE, jpeg->shrink, load->fail, jpeg->autorotate ) ) {
|
||||||
@ -345,10 +345,10 @@ G_DEFINE_TYPE( VipsForeignLoadJpegBuffer, vips_foreign_load_jpeg_buffer,
|
|||||||
static gboolean
|
static gboolean
|
||||||
vips_foreign_load_jpeg_buffer_is_a_buffer( const void *buf, size_t len )
|
vips_foreign_load_jpeg_buffer_is_a_buffer( const void *buf, size_t len )
|
||||||
{
|
{
|
||||||
VipsStreamInput *input;
|
VipsStreami *input;
|
||||||
gboolean result;
|
gboolean result;
|
||||||
|
|
||||||
if( !(input = vips_stream_input_new_from_memory( buf, len )) )
|
if( !(input = vips_streami_new_from_memory( buf, len )) )
|
||||||
return( FALSE );
|
return( FALSE );
|
||||||
result = vips__isjpeg_stream( input );
|
result = vips__isjpeg_stream( input );
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( input );
|
||||||
@ -362,9 +362,9 @@ vips_foreign_load_jpeg_buffer_header( VipsForeignLoad *load )
|
|||||||
VipsForeignLoadJpeg *jpeg = (VipsForeignLoadJpeg *) load;
|
VipsForeignLoadJpeg *jpeg = (VipsForeignLoadJpeg *) load;
|
||||||
VipsForeignLoadJpegBuffer *buffer = (VipsForeignLoadJpegBuffer *) load;
|
VipsForeignLoadJpegBuffer *buffer = (VipsForeignLoadJpegBuffer *) load;
|
||||||
|
|
||||||
VipsStreamInput *input;
|
VipsStreami *input;
|
||||||
|
|
||||||
if( !(input = vips_stream_input_new_from_blob( buffer->blob )) )
|
if( !(input = vips_streami_new_from_blob( buffer->blob )) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
if( vips__jpeg_read_stream( input, load->out,
|
if( vips__jpeg_read_stream( input, load->out,
|
||||||
TRUE, jpeg->shrink, load->fail, jpeg->autorotate ) ) {
|
TRUE, jpeg->shrink, load->fail, jpeg->autorotate ) ) {
|
||||||
@ -382,9 +382,9 @@ vips_foreign_load_jpeg_buffer_load( VipsForeignLoad *load )
|
|||||||
VipsForeignLoadJpeg *jpeg = (VipsForeignLoadJpeg *) load;
|
VipsForeignLoadJpeg *jpeg = (VipsForeignLoadJpeg *) load;
|
||||||
VipsForeignLoadJpegBuffer *buffer = (VipsForeignLoadJpegBuffer *) load;
|
VipsForeignLoadJpegBuffer *buffer = (VipsForeignLoadJpegBuffer *) load;
|
||||||
|
|
||||||
VipsStreamInput *input;
|
VipsStreami *input;
|
||||||
|
|
||||||
if( !(input = vips_stream_input_new_from_blob( buffer->blob )) )
|
if( !(input = vips_streami_new_from_blob( buffer->blob )) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
if( vips__jpeg_read_stream( input, load->real,
|
if( vips__jpeg_read_stream( input, load->real,
|
||||||
FALSE, jpeg->shrink, load->fail, jpeg->autorotate ) ) {
|
FALSE, jpeg->shrink, load->fail, jpeg->autorotate ) ) {
|
||||||
|
@ -219,7 +219,7 @@ vips_foreign_save_jpeg_init( VipsForeignSaveJpeg *jpeg )
|
|||||||
typedef struct _VipsForeignSaveJpegStream {
|
typedef struct _VipsForeignSaveJpegStream {
|
||||||
VipsForeignSaveJpeg parent_object;
|
VipsForeignSaveJpeg parent_object;
|
||||||
|
|
||||||
VipsStreamOutput *output;
|
VipsStreamo *output;
|
||||||
|
|
||||||
} VipsForeignSaveJpegStream;
|
} VipsForeignSaveJpegStream;
|
||||||
|
|
||||||
@ -269,7 +269,7 @@ vips_foreign_save_jpeg_stream_class_init(
|
|||||||
_( "Stream to save to" ),
|
_( "Stream to save to" ),
|
||||||
VIPS_ARGUMENT_REQUIRED_INPUT,
|
VIPS_ARGUMENT_REQUIRED_INPUT,
|
||||||
G_STRUCT_OFFSET( VipsForeignSaveJpegStream, output ),
|
G_STRUCT_OFFSET( VipsForeignSaveJpegStream, output ),
|
||||||
VIPS_TYPE_STREAM_OUTPUT );
|
VIPS_TYPE_STREAMO );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -299,13 +299,13 @@ vips_foreign_save_jpeg_file_build( VipsObject *object )
|
|||||||
VipsForeignSaveJpeg *jpeg = (VipsForeignSaveJpeg *) object;
|
VipsForeignSaveJpeg *jpeg = (VipsForeignSaveJpeg *) object;
|
||||||
VipsForeignSaveJpegFile *file = (VipsForeignSaveJpegFile *) object;
|
VipsForeignSaveJpegFile *file = (VipsForeignSaveJpegFile *) object;
|
||||||
|
|
||||||
VipsStreamOutput *output;
|
VipsStreamo *output;
|
||||||
|
|
||||||
if( VIPS_OBJECT_CLASS( vips_foreign_save_jpeg_file_parent_class )->
|
if( VIPS_OBJECT_CLASS( vips_foreign_save_jpeg_file_parent_class )->
|
||||||
build( object ) )
|
build( object ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
if( !(output = vips_stream_output_new_from_filename( file->filename )) )
|
if( !(output = vips_streamo_new_from_filename( file->filename )) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
if( vips__jpeg_write_stream( save->ready, output,
|
if( vips__jpeg_write_stream( save->ready, output,
|
||||||
jpeg->Q, jpeg->profile, jpeg->optimize_coding,
|
jpeg->Q, jpeg->profile, jpeg->optimize_coding,
|
||||||
@ -367,14 +367,14 @@ vips_foreign_save_jpeg_buffer_build( VipsObject *object )
|
|||||||
VipsForeignSaveJpeg *jpeg = (VipsForeignSaveJpeg *) object;
|
VipsForeignSaveJpeg *jpeg = (VipsForeignSaveJpeg *) object;
|
||||||
VipsForeignSaveJpegBuffer *file = (VipsForeignSaveJpegBuffer *) object;
|
VipsForeignSaveJpegBuffer *file = (VipsForeignSaveJpegBuffer *) object;
|
||||||
|
|
||||||
VipsStreamOutput *output;
|
VipsStreamo *output;
|
||||||
VipsBlob *blob;
|
VipsBlob *blob;
|
||||||
|
|
||||||
if( VIPS_OBJECT_CLASS( vips_foreign_save_jpeg_buffer_parent_class )->
|
if( VIPS_OBJECT_CLASS( vips_foreign_save_jpeg_buffer_parent_class )->
|
||||||
build( object ) )
|
build( object ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
if( !(output = vips_stream_output_new_memory()) )
|
if( !(output = vips_streamo_new_memory()) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
if( vips__jpeg_write_stream( save->ready, output,
|
if( vips__jpeg_write_stream( save->ready, output,
|
||||||
@ -438,7 +438,7 @@ vips_foreign_save_jpeg_mime_build( VipsObject *object )
|
|||||||
VipsForeignSave *save = (VipsForeignSave *) object;
|
VipsForeignSave *save = (VipsForeignSave *) object;
|
||||||
VipsForeignSaveJpeg *jpeg = (VipsForeignSaveJpeg *) object;
|
VipsForeignSaveJpeg *jpeg = (VipsForeignSaveJpeg *) object;
|
||||||
|
|
||||||
VipsStreamOutput *output;
|
VipsStreamo *output;
|
||||||
VipsBlob *blob;
|
VipsBlob *blob;
|
||||||
const unsigned char *obuf;
|
const unsigned char *obuf;
|
||||||
size_t olen;
|
size_t olen;
|
||||||
@ -447,7 +447,7 @@ vips_foreign_save_jpeg_mime_build( VipsObject *object )
|
|||||||
build( object ) )
|
build( object ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
if( !(output = vips_stream_output_new_memory()) )
|
if( !(output = vips_streamo_new_memory()) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
if( vips__jpeg_write_stream( save->ready, output,
|
if( vips__jpeg_write_stream( save->ready, output,
|
||||||
@ -635,7 +635,7 @@ vips_jpegsave( VipsImage *in, const char *filename, ... )
|
|||||||
* Returns: 0 on success, -1 on error.
|
* Returns: 0 on success, -1 on error.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
vips_jpegsave_stream( VipsImage *in, VipsStreamOutput *output, ... )
|
vips_jpegsave_stream( VipsImage *in, VipsStreamo *output, ... )
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
int result;
|
int result;
|
||||||
|
@ -127,7 +127,7 @@ vips_foreign_load_png_stream_class_init( VipsForeignLoadPngStreamClass *class )
|
|||||||
_( "Stream to load from" ),
|
_( "Stream to load from" ),
|
||||||
VIPS_ARGUMENT_REQUIRED_INPUT,
|
VIPS_ARGUMENT_REQUIRED_INPUT,
|
||||||
G_STRUCT_OFFSET( VipsForeignLoadPngStream, input ),
|
G_STRUCT_OFFSET( VipsForeignLoadPngStream, input ),
|
||||||
VIPS_TYPE_STREAM_INPUT );
|
VIPS_TYPE_STREAMI );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,7 +156,7 @@ vips_foreign_load_png_is_a( const char *filename )
|
|||||||
VipsStreami *input;
|
VipsStreami *input;
|
||||||
gboolean result;
|
gboolean result;
|
||||||
|
|
||||||
if( !(input = vips_stream_input_new_from_filename( filename )) )
|
if( !(input = vips_streami_new_from_filename( filename )) )
|
||||||
return( FALSE );
|
return( FALSE );
|
||||||
result = vips__png_ispng_stream( input );
|
result = vips__png_ispng_stream( input );
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( input );
|
||||||
@ -170,7 +170,7 @@ vips_foreign_load_png_get_flags_filename( const char *filename )
|
|||||||
VipsStreami *input;
|
VipsStreami *input;
|
||||||
VipsForeignFlags flags;
|
VipsForeignFlags flags;
|
||||||
|
|
||||||
if( !(input = vips_stream_input_new_from_filename( filename )) )
|
if( !(input = vips_streami_new_from_filename( filename )) )
|
||||||
return( 0 );
|
return( 0 );
|
||||||
|
|
||||||
flags = 0;
|
flags = 0;
|
||||||
@ -199,7 +199,7 @@ vips_foreign_load_png_header( VipsForeignLoad *load )
|
|||||||
|
|
||||||
VipsStreami *input;
|
VipsStreami *input;
|
||||||
|
|
||||||
if( !(input = vips_stream_input_new_from_filename( png->filename )) )
|
if( !(input = vips_streami_new_from_filename( png->filename )) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
if( vips__png_header_stream( input, load->out ) ) {
|
if( vips__png_header_stream( input, load->out ) ) {
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( input );
|
||||||
@ -217,7 +217,7 @@ vips_foreign_load_png_load( VipsForeignLoad *load )
|
|||||||
|
|
||||||
VipsStreami *input;
|
VipsStreami *input;
|
||||||
|
|
||||||
if( !(input = vips_stream_input_new_from_filename( png->filename )) )
|
if( !(input = vips_streami_new_from_filename( png->filename )) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
if( vips__png_read_stream( input, load->real, load->fail ) ) {
|
if( vips__png_read_stream( input, load->real, load->fail ) ) {
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( input );
|
||||||
@ -288,7 +288,7 @@ vips_foreign_load_png_buffer_is_a_buffer( const void *buf, size_t len )
|
|||||||
VipsStreami *input;
|
VipsStreami *input;
|
||||||
gboolean result;
|
gboolean result;
|
||||||
|
|
||||||
if( !(input = vips_stream_input_new_from_memory( buf, len )) )
|
if( !(input = vips_streami_new_from_memory( buf, len )) )
|
||||||
return( FALSE );
|
return( FALSE );
|
||||||
result = vips__png_ispng_stream( input );
|
result = vips__png_ispng_stream( input );
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( input );
|
||||||
@ -304,7 +304,7 @@ vips_foreign_load_png_buffer_get_flags( VipsForeignLoad *load )
|
|||||||
VipsStreami *input;
|
VipsStreami *input;
|
||||||
VipsForeignFlags flags;
|
VipsForeignFlags flags;
|
||||||
|
|
||||||
if( !(input = vips_stream_input_new_from_memory( buffer->buf->data,
|
if( !(input = vips_streami_new_from_memory( buffer->buf->data,
|
||||||
buffer->buf->length )) )
|
buffer->buf->length )) )
|
||||||
return( 0 );
|
return( 0 );
|
||||||
|
|
||||||
@ -326,7 +326,7 @@ vips_foreign_load_png_buffer_header( VipsForeignLoad *load )
|
|||||||
|
|
||||||
VipsStreami *input;
|
VipsStreami *input;
|
||||||
|
|
||||||
if( !(input = vips_stream_input_new_from_memory( buffer->buf->data,
|
if( !(input = vips_streami_new_from_memory( buffer->buf->data,
|
||||||
buffer->buf->length )) )
|
buffer->buf->length )) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
if( vips__png_header_stream( input, load->out ) ) {
|
if( vips__png_header_stream( input, load->out ) ) {
|
||||||
@ -345,7 +345,7 @@ vips_foreign_load_png_buffer_load( VipsForeignLoad *load )
|
|||||||
|
|
||||||
VipsStreami *input;
|
VipsStreami *input;
|
||||||
|
|
||||||
if( !(input = vips_stream_input_new_from_memory( buffer->buf->data,
|
if( !(input = vips_streami_new_from_memory( buffer->buf->data,
|
||||||
buffer->buf->length )) )
|
buffer->buf->length )) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
if( vips__png_read_stream( input, load->real, load->fail ) ) {
|
if( vips__png_read_stream( input, load->real, load->fail ) ) {
|
||||||
|
@ -182,7 +182,7 @@ vips_foreign_save_png_init( VipsForeignSavePng *png )
|
|||||||
typedef struct _VipsForeignSavePngStream {
|
typedef struct _VipsForeignSavePngStream {
|
||||||
VipsForeignSavePng parent_object;
|
VipsForeignSavePng parent_object;
|
||||||
|
|
||||||
VipsStreamOutput *output;
|
VipsStreamo *output;
|
||||||
} VipsForeignSavePngStream;
|
} VipsForeignSavePngStream;
|
||||||
|
|
||||||
typedef VipsForeignSavePngClass VipsForeignSavePngStreamClass;
|
typedef VipsForeignSavePngClass VipsForeignSavePngStreamClass;
|
||||||
@ -227,7 +227,7 @@ vips_foreign_save_png_stream_class_init( VipsForeignSavePngStreamClass *class )
|
|||||||
_( "Stream to save to" ),
|
_( "Stream to save to" ),
|
||||||
VIPS_ARGUMENT_REQUIRED_INPUT,
|
VIPS_ARGUMENT_REQUIRED_INPUT,
|
||||||
G_STRUCT_OFFSET( VipsForeignSavePngStream, output ),
|
G_STRUCT_OFFSET( VipsForeignSavePngStream, output ),
|
||||||
VIPS_TYPE_STREAM_OUTPUT );
|
VIPS_TYPE_STREAMO );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -254,13 +254,13 @@ vips_foreign_save_png_file_build( VipsObject *object )
|
|||||||
VipsForeignSavePng *png = (VipsForeignSavePng *) object;
|
VipsForeignSavePng *png = (VipsForeignSavePng *) object;
|
||||||
VipsForeignSavePngFile *png_file = (VipsForeignSavePngFile *) object;
|
VipsForeignSavePngFile *png_file = (VipsForeignSavePngFile *) object;
|
||||||
|
|
||||||
VipsStreamOutput *output;
|
VipsStreamo *output;
|
||||||
|
|
||||||
if( VIPS_OBJECT_CLASS( vips_foreign_save_png_file_parent_class )->
|
if( VIPS_OBJECT_CLASS( vips_foreign_save_png_file_parent_class )->
|
||||||
build( object ) )
|
build( object ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
if( !(output = vips_stream_output_new_from_filename(
|
if( !(output = vips_streamo_new_from_filename(
|
||||||
png_file->filename )) )
|
png_file->filename )) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
if( vips__png_write_stream( save->ready, output,
|
if( vips__png_write_stream( save->ready, output,
|
||||||
@ -319,14 +319,14 @@ vips_foreign_save_png_buffer_build( VipsObject *object )
|
|||||||
VipsForeignSavePng *png = (VipsForeignSavePng *) object;
|
VipsForeignSavePng *png = (VipsForeignSavePng *) object;
|
||||||
VipsForeignSavePngBuffer *buffer = (VipsForeignSavePngBuffer *) object;
|
VipsForeignSavePngBuffer *buffer = (VipsForeignSavePngBuffer *) object;
|
||||||
|
|
||||||
VipsStreamOutput *output;
|
VipsStreamo *output;
|
||||||
VipsBlob *blob;
|
VipsBlob *blob;
|
||||||
|
|
||||||
if( VIPS_OBJECT_CLASS( vips_foreign_save_png_buffer_parent_class )->
|
if( VIPS_OBJECT_CLASS( vips_foreign_save_png_buffer_parent_class )->
|
||||||
build( object ) )
|
build( object ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
if( !(output = vips_stream_output_new_memory()) )
|
if( !(output = vips_streamo_new_memory()) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
if( vips__png_write_stream( save->ready, output,
|
if( vips__png_write_stream( save->ready, output,
|
||||||
@ -522,7 +522,7 @@ vips_pngsave_buffer( VipsImage *in, void **buf, size_t *len, ... )
|
|||||||
* Returns: 0 on success, -1 on error.
|
* Returns: 0 on success, -1 on error.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
vips_pngsave_stream( VipsImage *in, VipsStreamOutput *output, ... )
|
vips_pngsave_stream( VipsImage *in, VipsStreamo *output, ... )
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
int result;
|
int result;
|
||||||
|
@ -138,9 +138,9 @@ vips__tiff_openout( const char *path, gboolean bigtiff )
|
|||||||
static tsize_t
|
static tsize_t
|
||||||
openin_stream_read( thandle_t st, tdata_t data, tsize_t size )
|
openin_stream_read( thandle_t st, tdata_t data, tsize_t size )
|
||||||
{
|
{
|
||||||
VipsStreamInput *input = VIPS_STREAM_INPUT( st );
|
VipsStreami *input = VIPS_STREAMI( st );
|
||||||
|
|
||||||
return( vips_stream_input_read( input, data, size ) );
|
return( vips_streami_read( input, data, size ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
static tsize_t
|
static tsize_t
|
||||||
@ -154,15 +154,15 @@ openin_stream_write( thandle_t st, tdata_t buffer, tsize_t size )
|
|||||||
static toff_t
|
static toff_t
|
||||||
openin_stream_seek( thandle_t st, toff_t position, int whence )
|
openin_stream_seek( thandle_t st, toff_t position, int whence )
|
||||||
{
|
{
|
||||||
VipsStreamInput *input = VIPS_STREAM_INPUT( st );
|
VipsStreami *input = VIPS_STREAMI( st );
|
||||||
|
|
||||||
return( vips_stream_input_seek( input, position, whence ) );
|
return( vips_streami_seek( input, position, whence ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
openin_stream_close( thandle_t st )
|
openin_stream_close( thandle_t st )
|
||||||
{
|
{
|
||||||
VipsStreamInput *input = VIPS_STREAM_INPUT( st );
|
VipsStreami *input = VIPS_STREAMI( st );
|
||||||
|
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( input );
|
||||||
|
|
||||||
@ -172,12 +172,12 @@ openin_stream_close( thandle_t st )
|
|||||||
static toff_t
|
static toff_t
|
||||||
openin_stream_size( thandle_t st )
|
openin_stream_size( thandle_t st )
|
||||||
{
|
{
|
||||||
VipsStreamInput *input = VIPS_STREAM_INPUT( st );
|
VipsStreami *input = VIPS_STREAMI( st );
|
||||||
|
|
||||||
/* libtiff will use this to get file size if tags like StripByteCounts
|
/* libtiff will use this to get file size if tags like StripByteCounts
|
||||||
* are missing.
|
* are missing.
|
||||||
*/
|
*/
|
||||||
return( vips_stream_input_size( input ) );
|
return( vips_streami_size( input ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -197,7 +197,7 @@ openin_stream_unmap( thandle_t st, tdata_t start, toff_t len )
|
|||||||
}
|
}
|
||||||
|
|
||||||
TIFF *
|
TIFF *
|
||||||
vips__tiff_openin_stream( VipsStreamInput *input )
|
vips__tiff_openin_stream( VipsStreami *input )
|
||||||
{
|
{
|
||||||
TIFF *tiff;
|
TIFF *tiff;
|
||||||
|
|
||||||
@ -207,7 +207,7 @@ vips__tiff_openin_stream( VipsStreamInput *input )
|
|||||||
|
|
||||||
/* Unreffed on close(), see above.
|
/* Unreffed on close(), see above.
|
||||||
*/
|
*/
|
||||||
if( vips_stream_input_rewind( input ) )
|
if( vips_streami_rewind( input ) )
|
||||||
return( NULL );
|
return( NULL );
|
||||||
|
|
||||||
g_object_ref( input );
|
g_object_ref( input );
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif /*__cplusplus*/
|
#endif /*__cplusplus*/
|
||||||
|
|
||||||
TIFF *vips__tiff_openin_stream( VipsStreamInput *input );
|
TIFF *vips__tiff_openin_stream( VipsStreami *input );
|
||||||
|
|
||||||
TIFF *vips__tiff_openout( const char *path, gboolean bigtiff );
|
TIFF *vips__tiff_openout( const char *path, gboolean bigtiff );
|
||||||
TIFF *vips__tiff_openout_buffer( VipsImage *image,
|
TIFF *vips__tiff_openout_buffer( VipsImage *image,
|
||||||
|
@ -300,7 +300,7 @@ typedef void (*scanline_process_fn)( struct _Rtiff *,
|
|||||||
typedef struct _Rtiff {
|
typedef struct _Rtiff {
|
||||||
/* Parameters.
|
/* Parameters.
|
||||||
*/
|
*/
|
||||||
VipsStreamInput *input;
|
VipsStreami *input;
|
||||||
VipsImage *out;
|
VipsImage *out;
|
||||||
int page;
|
int page;
|
||||||
int n;
|
int n;
|
||||||
@ -501,11 +501,11 @@ static void
|
|||||||
rtiff_minimise_cb( VipsImage *image, Rtiff *rtiff )
|
rtiff_minimise_cb( VipsImage *image, Rtiff *rtiff )
|
||||||
{
|
{
|
||||||
if( rtiff->input )
|
if( rtiff->input )
|
||||||
vips_stream_input_minimise( rtiff->input );
|
vips_streami_minimise( rtiff->input );
|
||||||
}
|
}
|
||||||
|
|
||||||
static Rtiff *
|
static Rtiff *
|
||||||
rtiff_new( VipsStreamInput *input, VipsImage *out,
|
rtiff_new( VipsStreami *input, VipsImage *out,
|
||||||
int page, int n, gboolean autorotate )
|
int page, int n, gboolean autorotate )
|
||||||
{
|
{
|
||||||
Rtiff *rtiff;
|
Rtiff *rtiff;
|
||||||
@ -1536,7 +1536,7 @@ rtiff_fill_region( VipsRegion *out,
|
|||||||
|
|
||||||
/* In pixel decode mode.
|
/* In pixel decode mode.
|
||||||
*/
|
*/
|
||||||
if( vips_stream_input_decode( rtiff->input ) )
|
if( vips_streami_decode( rtiff->input ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
/* Special case: we are filling a single tile exactly sized to match
|
/* Special case: we are filling a single tile exactly sized to match
|
||||||
@ -1867,7 +1867,7 @@ rtiff_stripwise_generate( VipsRegion *or,
|
|||||||
|
|
||||||
/* In pixel decode mode.
|
/* In pixel decode mode.
|
||||||
*/
|
*/
|
||||||
if( vips_stream_input_decode( rtiff->input ) )
|
if( vips_streami_decode( rtiff->input ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
/* And check that y_pos is correct. It should be, since we are inside
|
/* And check that y_pos is correct. It should be, since we are inside
|
||||||
@ -2389,7 +2389,7 @@ vips__tiff_read_header_orientation( Rtiff *rtiff, VipsImage *out )
|
|||||||
typedef gboolean (*TiffPropertyFn)( TIFF *tif );
|
typedef gboolean (*TiffPropertyFn)( TIFF *tif );
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
vips__testtiff_stream( VipsStreamInput *input, TiffPropertyFn fn )
|
vips__testtiff_stream( VipsStreami *input, TiffPropertyFn fn )
|
||||||
{
|
{
|
||||||
TIFF *tif;
|
TIFF *tif;
|
||||||
gboolean property;
|
gboolean property;
|
||||||
@ -2409,19 +2409,19 @@ vips__testtiff_stream( VipsStreamInput *input, TiffPropertyFn fn )
|
|||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
vips__istiff_stream( VipsStreamInput *input )
|
vips__istiff_stream( VipsStreami *input )
|
||||||
{
|
{
|
||||||
return( vips__testtiff_stream( input, NULL ) );
|
return( vips__testtiff_stream( input, NULL ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
vips__istifftiled_stream( VipsStreamInput *input )
|
vips__istifftiled_stream( VipsStreami *input )
|
||||||
{
|
{
|
||||||
return( vips__testtiff_stream( input, TIFFIsTiled ) );
|
return( vips__testtiff_stream( input, TIFFIsTiled ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
vips__tiff_read_header_stream( VipsStreamInput *input, VipsImage *out,
|
vips__tiff_read_header_stream( VipsStreami *input, VipsImage *out,
|
||||||
int page, int n, gboolean autorotate )
|
int page, int n, gboolean autorotate )
|
||||||
{
|
{
|
||||||
Rtiff *rtiff;
|
Rtiff *rtiff;
|
||||||
@ -2437,13 +2437,13 @@ vips__tiff_read_header_stream( VipsStreamInput *input, VipsImage *out,
|
|||||||
|
|
||||||
vips__tiff_read_header_orientation( rtiff, out );
|
vips__tiff_read_header_orientation( rtiff, out );
|
||||||
|
|
||||||
vips_stream_input_minimise( input );
|
vips_streami_minimise( input );
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
vips__tiff_read_stream( VipsStreamInput *input, VipsImage *out,
|
vips__tiff_read_stream( VipsStreami *input, VipsImage *out,
|
||||||
int page, int n, gboolean autorotate )
|
int page, int n, gboolean autorotate )
|
||||||
{
|
{
|
||||||
Rtiff *rtiff;
|
Rtiff *rtiff;
|
||||||
|
@ -141,10 +141,10 @@ G_DEFINE_TYPE( VipsForeignLoadTiffFile, vips_foreign_load_tiff_file,
|
|||||||
static gboolean
|
static gboolean
|
||||||
vips_foreign_load_tiff_file_is_a( const char *filename )
|
vips_foreign_load_tiff_file_is_a( const char *filename )
|
||||||
{
|
{
|
||||||
VipsStreamInput *input;
|
VipsStreami *input;
|
||||||
gboolean result;
|
gboolean result;
|
||||||
|
|
||||||
if( !(input = vips_stream_input_new_from_filename( filename )) )
|
if( !(input = vips_streami_new_from_filename( filename )) )
|
||||||
return( FALSE );
|
return( FALSE );
|
||||||
result = vips__istiff_stream( input );
|
result = vips__istiff_stream( input );
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( input );
|
||||||
@ -155,10 +155,10 @@ vips_foreign_load_tiff_file_is_a( const char *filename )
|
|||||||
static VipsForeignFlags
|
static VipsForeignFlags
|
||||||
vips_foreign_load_tiff_file_get_flags_filename( const char *filename )
|
vips_foreign_load_tiff_file_get_flags_filename( const char *filename )
|
||||||
{
|
{
|
||||||
VipsStreamInput *input;
|
VipsStreami *input;
|
||||||
VipsForeignFlags flags;
|
VipsForeignFlags flags;
|
||||||
|
|
||||||
if( !(input = vips_stream_input_new_from_filename( filename )) )
|
if( !(input = vips_streami_new_from_filename( filename )) )
|
||||||
return( 0 );
|
return( 0 );
|
||||||
|
|
||||||
flags = 0;
|
flags = 0;
|
||||||
@ -187,9 +187,9 @@ vips_foreign_load_tiff_file_header( VipsForeignLoad *load )
|
|||||||
VipsForeignLoadTiff *tiff = (VipsForeignLoadTiff *) load;
|
VipsForeignLoadTiff *tiff = (VipsForeignLoadTiff *) load;
|
||||||
VipsForeignLoadTiffFile *file = (VipsForeignLoadTiffFile *) load;
|
VipsForeignLoadTiffFile *file = (VipsForeignLoadTiffFile *) load;
|
||||||
|
|
||||||
VipsStreamInput *input;
|
VipsStreami *input;
|
||||||
|
|
||||||
if( !(input = vips_stream_input_new_from_filename( file->filename )) )
|
if( !(input = vips_streami_new_from_filename( file->filename )) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
if( vips__tiff_read_header_stream( input, load->out,
|
if( vips__tiff_read_header_stream( input, load->out,
|
||||||
tiff->page, tiff->n, tiff->autorotate ) ) {
|
tiff->page, tiff->n, tiff->autorotate ) ) {
|
||||||
@ -209,9 +209,9 @@ vips_foreign_load_tiff_file_load( VipsForeignLoad *load )
|
|||||||
VipsForeignLoadTiff *tiff = (VipsForeignLoadTiff *) load;
|
VipsForeignLoadTiff *tiff = (VipsForeignLoadTiff *) load;
|
||||||
VipsForeignLoadTiffFile *file = (VipsForeignLoadTiffFile *) load;
|
VipsForeignLoadTiffFile *file = (VipsForeignLoadTiffFile *) load;
|
||||||
|
|
||||||
VipsStreamInput *input;
|
VipsStreami *input;
|
||||||
|
|
||||||
if( !(input = vips_stream_input_new_from_filename( file->filename )) )
|
if( !(input = vips_streami_new_from_filename( file->filename )) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
if( vips__tiff_read_stream( input, load->real,
|
if( vips__tiff_read_stream( input, load->real,
|
||||||
tiff->page, tiff->n, tiff->autorotate ) ) {
|
tiff->page, tiff->n, tiff->autorotate ) ) {
|
||||||
@ -282,10 +282,10 @@ G_DEFINE_TYPE( VipsForeignLoadTiffBuffer, vips_foreign_load_tiff_buffer,
|
|||||||
static gboolean
|
static gboolean
|
||||||
vips_foreign_load_tiff_buffer_is_a_buffer( const void *buf, size_t len )
|
vips_foreign_load_tiff_buffer_is_a_buffer( const void *buf, size_t len )
|
||||||
{
|
{
|
||||||
VipsStreamInput *input;
|
VipsStreami *input;
|
||||||
gboolean result;
|
gboolean result;
|
||||||
|
|
||||||
if( !(input = vips_stream_input_new_from_memory( buf, len )) )
|
if( !(input = vips_streami_new_from_memory( buf, len )) )
|
||||||
return( FALSE );
|
return( FALSE );
|
||||||
result = vips__istiff_stream( input );
|
result = vips__istiff_stream( input );
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( input );
|
||||||
@ -298,10 +298,10 @@ vips_foreign_load_tiff_buffer_get_flags( VipsForeignLoad *load )
|
|||||||
{
|
{
|
||||||
VipsForeignLoadTiffBuffer *buffer = (VipsForeignLoadTiffBuffer *) load;
|
VipsForeignLoadTiffBuffer *buffer = (VipsForeignLoadTiffBuffer *) load;
|
||||||
|
|
||||||
VipsStreamInput *input;
|
VipsStreami *input;
|
||||||
VipsForeignFlags flags;
|
VipsForeignFlags flags;
|
||||||
|
|
||||||
if( !(input = vips_stream_input_new_from_memory(
|
if( !(input = vips_streami_new_from_memory(
|
||||||
buffer->buf->data, buffer->buf->length )) )
|
buffer->buf->data, buffer->buf->length )) )
|
||||||
return( FALSE );
|
return( FALSE );
|
||||||
flags = 0;
|
flags = 0;
|
||||||
@ -320,9 +320,9 @@ vips_foreign_load_tiff_buffer_header( VipsForeignLoad *load )
|
|||||||
VipsForeignLoadTiff *tiff = (VipsForeignLoadTiff *) load;
|
VipsForeignLoadTiff *tiff = (VipsForeignLoadTiff *) load;
|
||||||
VipsForeignLoadTiffBuffer *buffer = (VipsForeignLoadTiffBuffer *) load;
|
VipsForeignLoadTiffBuffer *buffer = (VipsForeignLoadTiffBuffer *) load;
|
||||||
|
|
||||||
VipsStreamInput *input;
|
VipsStreami *input;
|
||||||
|
|
||||||
if( !(input = vips_stream_input_new_from_memory(
|
if( !(input = vips_streami_new_from_memory(
|
||||||
buffer->buf->data, buffer->buf->length )) )
|
buffer->buf->data, buffer->buf->length )) )
|
||||||
return( FALSE );
|
return( FALSE );
|
||||||
if( vips__tiff_read_header_stream( input, load->out,
|
if( vips__tiff_read_header_stream( input, load->out,
|
||||||
@ -341,9 +341,9 @@ vips_foreign_load_tiff_buffer_load( VipsForeignLoad *load )
|
|||||||
VipsForeignLoadTiff *tiff = (VipsForeignLoadTiff *) load;
|
VipsForeignLoadTiff *tiff = (VipsForeignLoadTiff *) load;
|
||||||
VipsForeignLoadTiffBuffer *buffer = (VipsForeignLoadTiffBuffer *) load;
|
VipsForeignLoadTiffBuffer *buffer = (VipsForeignLoadTiffBuffer *) load;
|
||||||
|
|
||||||
VipsStreamInput *input;
|
VipsStreami *input;
|
||||||
|
|
||||||
if( !(input = vips_stream_input_new_from_memory(
|
if( !(input = vips_streami_new_from_memory(
|
||||||
buffer->buf->data, buffer->buf->length )) )
|
buffer->buf->data, buffer->buf->length )) )
|
||||||
return( FALSE );
|
return( FALSE );
|
||||||
if( vips__tiff_read_stream( input, load->real,
|
if( vips__tiff_read_stream( input, load->real,
|
||||||
@ -393,7 +393,7 @@ typedef struct _VipsForeignLoadTiffStream {
|
|||||||
|
|
||||||
/* Load from a stream.
|
/* Load from a stream.
|
||||||
*/
|
*/
|
||||||
VipsStreamInput *input;
|
VipsStreami *input;
|
||||||
|
|
||||||
} VipsForeignLoadTiffStream;
|
} VipsForeignLoadTiffStream;
|
||||||
|
|
||||||
@ -468,7 +468,7 @@ vips_foreign_load_tiff_stream_class_init(
|
|||||||
_( "Stream to load from" ),
|
_( "Stream to load from" ),
|
||||||
VIPS_ARGUMENT_REQUIRED_INPUT,
|
VIPS_ARGUMENT_REQUIRED_INPUT,
|
||||||
G_STRUCT_OFFSET( VipsForeignLoadTiffStream, input ),
|
G_STRUCT_OFFSET( VipsForeignLoadTiffStream, input ),
|
||||||
VIPS_TYPE_STREAM_INPUT );
|
VIPS_TYPE_STREAMI );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -604,7 +604,7 @@ vips_tiffload_buffer( void *buf, size_t len, VipsImage **out, ... )
|
|||||||
* Returns: 0 on success, -1 on error.
|
* Returns: 0 on success, -1 on error.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
vips_tiffload_stream( VipsStreamInput *input, VipsImage **out, ... )
|
vips_tiffload_stream( VipsStreami *input, VipsImage **out, ... )
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
int result;
|
int result;
|
||||||
|
@ -693,7 +693,7 @@ typedef struct {
|
|||||||
|
|
||||||
/* Build the output area here.
|
/* Build the output area here.
|
||||||
*/
|
*/
|
||||||
VipsStreamOutput *output;
|
VipsStreamo *output;
|
||||||
|
|
||||||
/* Our output buffer.
|
/* Our output buffer.
|
||||||
*/
|
*/
|
||||||
@ -708,7 +708,7 @@ empty_output_buffer( j_compress_ptr cinfo )
|
|||||||
{
|
{
|
||||||
Dest *dest = (Dest *) cinfo->dest;
|
Dest *dest = (Dest *) cinfo->dest;
|
||||||
|
|
||||||
if( vips_stream_output_write( dest->output,
|
if( vips_streamo_write( dest->output,
|
||||||
dest->buf, STREAM_BUFFER_SIZE ) )
|
dest->buf, STREAM_BUFFER_SIZE ) )
|
||||||
ERREXIT( cinfo, JERR_FILE_WRITE );
|
ERREXIT( cinfo, JERR_FILE_WRITE );
|
||||||
|
|
||||||
@ -736,17 +736,17 @@ term_destination( j_compress_ptr cinfo )
|
|||||||
{
|
{
|
||||||
Dest *dest = (Dest *) cinfo->dest;
|
Dest *dest = (Dest *) cinfo->dest;
|
||||||
|
|
||||||
if( vips_stream_output_write( dest->output,
|
if( vips_streamo_write( dest->output,
|
||||||
dest->buf, STREAM_BUFFER_SIZE - dest->pub.free_in_buffer ) )
|
dest->buf, STREAM_BUFFER_SIZE - dest->pub.free_in_buffer ) )
|
||||||
ERREXIT( cinfo, JERR_FILE_WRITE );
|
ERREXIT( cinfo, JERR_FILE_WRITE );
|
||||||
|
|
||||||
vips_stream_output_finish( dest->output );
|
vips_streamo_finish( dest->output );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set dest to one of our objects.
|
/* Set dest to one of our objects.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
stream_dest( j_compress_ptr cinfo, VipsStreamOutput *output )
|
stream_dest( j_compress_ptr cinfo, VipsStreamo *output )
|
||||||
{
|
{
|
||||||
Dest *dest;
|
Dest *dest;
|
||||||
|
|
||||||
@ -765,7 +765,7 @@ stream_dest( j_compress_ptr cinfo, VipsStreamOutput *output )
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
vips__jpeg_write_stream( VipsImage *in, VipsStreamOutput *output,
|
vips__jpeg_write_stream( VipsImage *in, VipsStreamo *output,
|
||||||
int Q, const char *profile,
|
int Q, const char *profile,
|
||||||
gboolean optimize_coding, gboolean progressive,
|
gboolean optimize_coding, gboolean progressive,
|
||||||
gboolean strip, gboolean no_subsample, gboolean trellis_quant,
|
gboolean strip, gboolean no_subsample, gboolean trellis_quant,
|
||||||
|
@ -1713,7 +1713,7 @@ wtiff_gather( Wtiff *wtiff )
|
|||||||
wtiff->layer->below )
|
wtiff->layer->below )
|
||||||
for( layer = wtiff->layer->below; layer;
|
for( layer = wtiff->layer->below; layer;
|
||||||
layer = layer->below ) {
|
layer = layer->below ) {
|
||||||
VipsStreamInput *input;
|
VipsStreami *input;
|
||||||
TIFF *in;
|
TIFF *in;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
@ -1722,12 +1722,12 @@ wtiff_gather( Wtiff *wtiff )
|
|||||||
|
|
||||||
if( layer->lname ) {
|
if( layer->lname ) {
|
||||||
if( !(input =
|
if( !(input =
|
||||||
vips_stream_input_new_from_filename(
|
vips_streami_new_from_filename(
|
||||||
layer->lname )) )
|
layer->lname )) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if( !(input = vips_stream_input_new_from_memory(
|
if( !(input = vips_streami_new_from_memory(
|
||||||
layer->buf, layer->len )) )
|
layer->buf, layer->len )) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
|
@ -510,7 +510,7 @@ vips_webp_add_metadata( VipsWebPWrite *write, VipsImage *image, gboolean strip )
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
vips__webp_write_stream( VipsImage *image, VipsStreamOutput *output,
|
vips__webp_write_stream( VipsImage *image, VipsStreamo *output,
|
||||||
int Q, gboolean lossless, VipsForeignWebpPreset preset,
|
int Q, gboolean lossless, VipsForeignWebpPreset preset,
|
||||||
gboolean smart_subsample, gboolean near_lossless,
|
gboolean smart_subsample, gboolean near_lossless,
|
||||||
int alpha_q, int reduction_effort,
|
int alpha_q, int reduction_effort,
|
||||||
@ -534,13 +534,13 @@ vips__webp_write_stream( VipsImage *image, VipsStreamOutput *output,
|
|||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( vips_stream_output_write( output,
|
if( vips_streamo_write( output,
|
||||||
write.memory_writer.mem, write.memory_writer.size ) ) {
|
write.memory_writer.mem, write.memory_writer.size ) ) {
|
||||||
vips_webp_write_unset( &write );
|
vips_webp_write_unset( &write );
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
vips_stream_output_finish( output );
|
vips_streamo_finish( output );
|
||||||
|
|
||||||
vips_webp_write_unset( &write );
|
vips_webp_write_unset( &write );
|
||||||
|
|
||||||
|
@ -173,7 +173,7 @@ typedef struct {
|
|||||||
png_infop pInfo;
|
png_infop pInfo;
|
||||||
png_bytep *row_pointer;
|
png_bytep *row_pointer;
|
||||||
|
|
||||||
VipsStreamInput *input;
|
VipsStreami *input;
|
||||||
|
|
||||||
/* read() to this buffer, copy to png as required. libpng does many
|
/* read() to this buffer, copy to png as required. libpng does many
|
||||||
* very small reads and we want to avoid a syscall for each one.
|
* very small reads and we want to avoid a syscall for each one.
|
||||||
@ -209,7 +209,7 @@ static void
|
|||||||
read_minimise_cb( VipsImage *image, Read *read )
|
read_minimise_cb( VipsImage *image, Read *read )
|
||||||
{
|
{
|
||||||
if( read->input )
|
if( read->input )
|
||||||
vips_stream_input_minimise( read->input );
|
vips_streami_minimise( read->input );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -230,7 +230,7 @@ vips_png_read_stream( png_structp pPng, png_bytep data, png_size_t length )
|
|||||||
if( read->bytes_in_buffer <= 0 ) {
|
if( read->bytes_in_buffer <= 0 ) {
|
||||||
ssize_t bytes_read;
|
ssize_t bytes_read;
|
||||||
|
|
||||||
bytes_read = vips_stream_input_read( read->input,
|
bytes_read = vips_streami_read( read->input,
|
||||||
read->input_buffer, INPUT_BUFFER_SIZE );
|
read->input_buffer, INPUT_BUFFER_SIZE );
|
||||||
if( bytes_read <= 0 )
|
if( bytes_read <= 0 )
|
||||||
png_error( pPng, "not enough data" );
|
png_error( pPng, "not enough data" );
|
||||||
@ -249,7 +249,7 @@ vips_png_read_stream( png_structp pPng, png_bytep data, png_size_t length )
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Read *
|
static Read *
|
||||||
read_new( VipsStreamInput *input, VipsImage *out, gboolean fail )
|
read_new( VipsStreami *input, VipsImage *out, gboolean fail )
|
||||||
{
|
{
|
||||||
Read *read;
|
Read *read;
|
||||||
|
|
||||||
@ -290,7 +290,7 @@ read_new( VipsStreamInput *input, VipsImage *out, gboolean fail )
|
|||||||
PNG_CRC_QUIET_USE, PNG_CRC_QUIET_USE );
|
PNG_CRC_QUIET_USE, PNG_CRC_QUIET_USE );
|
||||||
#endif /*FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION*/
|
#endif /*FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION*/
|
||||||
|
|
||||||
if( vips_stream_input_rewind( input ) )
|
if( vips_streami_rewind( input ) )
|
||||||
return( NULL );
|
return( NULL );
|
||||||
png_set_read_fn( read->pPng, read, vips_png_read_stream );
|
png_set_read_fn( read->pPng, read, vips_png_read_stream );
|
||||||
|
|
||||||
@ -481,8 +481,7 @@ png2vips_header( Read *read, VipsImage *out )
|
|||||||
VIPS_CODING_NONE, interpretation,
|
VIPS_CODING_NONE, interpretation,
|
||||||
Xres, Yres );
|
Xres, Yres );
|
||||||
|
|
||||||
VIPS_SETSTR( out->filename,
|
VIPS_SETSTR( out->filename, VIPS_STREAM( read->input )->filename );
|
||||||
vips_stream_filename( VIPS_STREAM( read->input ) ) );
|
|
||||||
|
|
||||||
/* Uninterlaced images will be read in seq mode. Interlaced images are
|
/* Uninterlaced images will be read in seq mode. Interlaced images are
|
||||||
* read via a huge memory buffer.
|
* read via a huge memory buffer.
|
||||||
@ -624,7 +623,7 @@ png2vips_generate( VipsRegion *or,
|
|||||||
|
|
||||||
/* In pixel decode mode.
|
/* In pixel decode mode.
|
||||||
*/
|
*/
|
||||||
if( vips_stream_input_decode( read->input ) )
|
if( vips_streami_decode( read->input ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
for( y = 0; y < r->height; y++ ) {
|
for( y = 0; y < r->height; y++ ) {
|
||||||
@ -699,11 +698,11 @@ png2vips_image( Read *read, VipsImage *out )
|
|||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
vips__png_ispng_stream( VipsStreamInput *input )
|
vips__png_ispng_stream( VipsStreami *input )
|
||||||
{
|
{
|
||||||
const unsigned char *p;
|
const unsigned char *p;
|
||||||
|
|
||||||
if( (p = vips_stream_input_sniff( input, 8 )) &&
|
if( (p = vips_streami_sniff( input, 8 )) &&
|
||||||
!png_sig_cmp( (png_bytep) p, 0, 8 ) )
|
!png_sig_cmp( (png_bytep) p, 0, 8 ) )
|
||||||
return( TRUE );
|
return( TRUE );
|
||||||
|
|
||||||
@ -711,7 +710,7 @@ vips__png_ispng_stream( VipsStreamInput *input )
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
vips__png_header_stream( VipsStreamInput *input, VipsImage *out )
|
vips__png_header_stream( VipsStreami *input, VipsImage *out )
|
||||||
{
|
{
|
||||||
Read *read;
|
Read *read;
|
||||||
|
|
||||||
@ -719,13 +718,13 @@ vips__png_header_stream( VipsStreamInput *input, VipsImage *out )
|
|||||||
png2vips_header( read, out ) )
|
png2vips_header( read, out ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
vips_stream_input_minimise( input );
|
vips_streami_minimise( input );
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
vips__png_read_stream( VipsStreamInput *input, VipsImage *out, gboolean fail )
|
vips__png_read_stream( VipsStreami *input, VipsImage *out, gboolean fail )
|
||||||
{
|
{
|
||||||
Read *read;
|
Read *read;
|
||||||
|
|
||||||
@ -740,7 +739,7 @@ vips__png_read_stream( VipsStreamInput *input, VipsImage *out, gboolean fail )
|
|||||||
* served partially from there. Non-interlaced PNGs may be read sequentially.
|
* served partially from there. Non-interlaced PNGs may be read sequentially.
|
||||||
*/
|
*/
|
||||||
gboolean
|
gboolean
|
||||||
vips__png_isinterlaced_stream( VipsStreamInput *input )
|
vips__png_isinterlaced_stream( VipsStreami *input )
|
||||||
{
|
{
|
||||||
VipsImage *image;
|
VipsImage *image;
|
||||||
Read *read;
|
Read *read;
|
||||||
@ -766,7 +765,7 @@ typedef struct {
|
|||||||
VipsImage *in;
|
VipsImage *in;
|
||||||
VipsImage *memory;
|
VipsImage *memory;
|
||||||
|
|
||||||
VipsStreamOutput *output;
|
VipsStreamo *output;
|
||||||
|
|
||||||
png_structp pPng;
|
png_structp pPng;
|
||||||
png_infop pInfo;
|
png_infop pInfo;
|
||||||
@ -778,7 +777,7 @@ write_finish( Write *write )
|
|||||||
{
|
{
|
||||||
VIPS_UNREF( write->memory );
|
VIPS_UNREF( write->memory );
|
||||||
if( write->output )
|
if( write->output )
|
||||||
vips_stream_output_finish( write->output );
|
vips_streamo_finish( write->output );
|
||||||
VIPS_UNREF( write->output );
|
VIPS_UNREF( write->output );
|
||||||
if( write->pPng )
|
if( write->pPng )
|
||||||
png_destroy_write_struct( &write->pPng, &write->pInfo );
|
png_destroy_write_struct( &write->pPng, &write->pInfo );
|
||||||
@ -795,12 +794,12 @@ user_write_data( png_structp pPng, png_bytep data, png_size_t length )
|
|||||||
{
|
{
|
||||||
Write *write = (Write *) png_get_io_ptr( pPng );
|
Write *write = (Write *) png_get_io_ptr( pPng );
|
||||||
|
|
||||||
if( vips_stream_output_write( write->output, data, length ) )
|
if( vips_streamo_write( write->output, data, length ) )
|
||||||
png_error( pPng, "not enough data" );
|
png_error( pPng, "not enough data" );
|
||||||
}
|
}
|
||||||
|
|
||||||
static Write *
|
static Write *
|
||||||
write_new( VipsImage *in, VipsStreamOutput *output )
|
write_new( VipsImage *in, VipsStreamo *output )
|
||||||
{
|
{
|
||||||
Write *write;
|
Write *write;
|
||||||
|
|
||||||
@ -1173,7 +1172,7 @@ write_vips( Write *write,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
vips__png_write_stream( VipsImage *in, VipsStreamOutput *output,
|
vips__png_write_stream( VipsImage *in, VipsStreamo *output,
|
||||||
int compression, int interlace,
|
int compression, int interlace,
|
||||||
const char *profile, VipsForeignPngFilter filter, gboolean strip,
|
const char *profile, VipsForeignPngFilter filter, gboolean strip,
|
||||||
gboolean palette, int colours, int Q, double dither )
|
gboolean palette, int colours, int Q, double dither )
|
||||||
|
@ -81,7 +81,7 @@
|
|||||||
/* What we track during a read.
|
/* What we track during a read.
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
VipsStreamInput *input;
|
VipsStreami *input;
|
||||||
|
|
||||||
/* The data we load, as a webp object.
|
/* The data we load, as a webp object.
|
||||||
*/
|
*/
|
||||||
@ -311,13 +311,13 @@ vips_image_paint_image( VipsImage *frame,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
vips__iswebp_stream( VipsStreamInput *input )
|
vips__iswebp_stream( VipsStreami *input )
|
||||||
{
|
{
|
||||||
const unsigned char *p;
|
const unsigned char *p;
|
||||||
|
|
||||||
/* WebP is "RIFF xxxx WEBP" at the start, so we need 12 bytes.
|
/* WebP is "RIFF xxxx WEBP" at the start, so we need 12 bytes.
|
||||||
*/
|
*/
|
||||||
if( (p = vips_stream_input_sniff( input, 12 )) &&
|
if( (p = vips_streami_sniff( input, 12 )) &&
|
||||||
vips_isprefix( "RIFF", (char *) p ) &&
|
vips_isprefix( "RIFF", (char *) p ) &&
|
||||||
vips_isprefix( "WEBP", (char *) p + 8 ) )
|
vips_isprefix( "WEBP", (char *) p + 8 ) )
|
||||||
return( 1 );
|
return( 1 );
|
||||||
@ -341,7 +341,7 @@ read_free( Read *read )
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Read *
|
static Read *
|
||||||
read_new( VipsStreamInput *input, int page, int n, double scale )
|
read_new( VipsStreami *input, int page, int n, double scale )
|
||||||
{
|
{
|
||||||
Read *read;
|
Read *read;
|
||||||
|
|
||||||
@ -364,7 +364,7 @@ read_new( VipsStreamInput *input, int page, int n, double scale )
|
|||||||
read->config.output.is_external_memory = 1;
|
read->config.output.is_external_memory = 1;
|
||||||
|
|
||||||
if( !(read->data.bytes =
|
if( !(read->data.bytes =
|
||||||
vips_stream_input_map( input, &read->data.size )) ) {
|
vips_streami_map( input, &read->data.size )) ) {
|
||||||
read_free( read );
|
read_free( read );
|
||||||
return( NULL );
|
return( NULL );
|
||||||
}
|
}
|
||||||
@ -752,7 +752,7 @@ read_image( Read *read, VipsImage *out )
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
vips__webp_read_header_stream( VipsStreamInput *input, VipsImage *out,
|
vips__webp_read_header_stream( VipsStreami *input, VipsImage *out,
|
||||||
int page, int n, double scale )
|
int page, int n, double scale )
|
||||||
{
|
{
|
||||||
Read *read;
|
Read *read;
|
||||||
@ -771,7 +771,7 @@ vips__webp_read_header_stream( VipsStreamInput *input, VipsImage *out,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
vips__webp_read_stream( VipsStreamInput *input, VipsImage *out,
|
vips__webp_read_stream( VipsStreami *input, VipsImage *out,
|
||||||
int page, int n, double scale )
|
int page, int n, double scale )
|
||||||
{
|
{
|
||||||
Read *read;
|
Read *read;
|
||||||
|
@ -156,7 +156,7 @@ vips_foreign_load_webp_init( VipsForeignLoadWebp *webp )
|
|||||||
typedef struct _VipsForeignLoadWebpStream {
|
typedef struct _VipsForeignLoadWebpStream {
|
||||||
VipsForeignLoadWebp parent_object;
|
VipsForeignLoadWebp parent_object;
|
||||||
|
|
||||||
VipsStreamInput *input;
|
VipsStreami *input;
|
||||||
|
|
||||||
} VipsForeignLoadWebpStream;
|
} VipsForeignLoadWebpStream;
|
||||||
|
|
||||||
@ -219,7 +219,7 @@ vips_foreign_load_webp_stream_class_init(
|
|||||||
_( "Stream to load from" ),
|
_( "Stream to load from" ),
|
||||||
VIPS_ARGUMENT_REQUIRED_INPUT,
|
VIPS_ARGUMENT_REQUIRED_INPUT,
|
||||||
G_STRUCT_OFFSET( VipsForeignLoadWebpStream, input ),
|
G_STRUCT_OFFSET( VipsForeignLoadWebpStream, input ),
|
||||||
VIPS_TYPE_STREAM_INPUT );
|
VIPS_TYPE_STREAMI );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -251,10 +251,10 @@ vips_foreign_load_webp_file_get_flags_filename( const char *filename )
|
|||||||
static gboolean
|
static gboolean
|
||||||
vips_foreign_load_webp_file_is_a( const char *filename )
|
vips_foreign_load_webp_file_is_a( const char *filename )
|
||||||
{
|
{
|
||||||
VipsStreamInput *input;
|
VipsStreami *input;
|
||||||
gboolean result;
|
gboolean result;
|
||||||
|
|
||||||
if( !(input = vips_stream_input_new_from_filename( filename )) )
|
if( !(input = vips_streami_new_from_filename( filename )) )
|
||||||
return( FALSE );
|
return( FALSE );
|
||||||
result = vips__iswebp_stream( input );
|
result = vips__iswebp_stream( input );
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( input );
|
||||||
@ -268,7 +268,7 @@ vips_foreign_load_webp_file_header( VipsForeignLoad *load )
|
|||||||
VipsForeignLoadWebp *webp = (VipsForeignLoadWebp *) load;
|
VipsForeignLoadWebp *webp = (VipsForeignLoadWebp *) load;
|
||||||
VipsForeignLoadWebpFile *file = (VipsForeignLoadWebpFile *) load;
|
VipsForeignLoadWebpFile *file = (VipsForeignLoadWebpFile *) load;
|
||||||
|
|
||||||
VipsStreamInput *input;
|
VipsStreami *input;
|
||||||
|
|
||||||
/* BC for the old API.
|
/* BC for the old API.
|
||||||
*/
|
*/
|
||||||
@ -277,7 +277,7 @@ vips_foreign_load_webp_file_header( VipsForeignLoad *load )
|
|||||||
webp->shrink != 0 )
|
webp->shrink != 0 )
|
||||||
webp->scale = 1.0 / webp->shrink;
|
webp->scale = 1.0 / webp->shrink;
|
||||||
|
|
||||||
if( !(input = vips_stream_input_new_from_filename( file->filename )) )
|
if( !(input = vips_streami_new_from_filename( file->filename )) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
if( vips__webp_read_header_stream( input, load->out,
|
if( vips__webp_read_header_stream( input, load->out,
|
||||||
webp->page, webp->n, webp->scale ) ) {
|
webp->page, webp->n, webp->scale ) ) {
|
||||||
@ -297,9 +297,9 @@ vips_foreign_load_webp_file_load( VipsForeignLoad *load )
|
|||||||
VipsForeignLoadWebp *webp = (VipsForeignLoadWebp *) load;
|
VipsForeignLoadWebp *webp = (VipsForeignLoadWebp *) load;
|
||||||
VipsForeignLoadWebpFile *file = (VipsForeignLoadWebpFile *) load;
|
VipsForeignLoadWebpFile *file = (VipsForeignLoadWebpFile *) load;
|
||||||
|
|
||||||
VipsStreamInput *input;
|
VipsStreami *input;
|
||||||
|
|
||||||
if( !(input = vips_stream_input_new_from_filename( file->filename )) )
|
if( !(input = vips_streami_new_from_filename( file->filename )) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
if( vips__webp_read_stream( input, load->real,
|
if( vips__webp_read_stream( input, load->real,
|
||||||
webp->page, webp->n, webp->scale ) ) {
|
webp->page, webp->n, webp->scale ) ) {
|
||||||
@ -365,10 +365,10 @@ G_DEFINE_TYPE( VipsForeignLoadWebpBuffer, vips_foreign_load_webp_buffer,
|
|||||||
static gboolean
|
static gboolean
|
||||||
vips_foreign_load_webp_buffer_is_a_buffer( const void *buf, size_t len )
|
vips_foreign_load_webp_buffer_is_a_buffer( const void *buf, size_t len )
|
||||||
{
|
{
|
||||||
VipsStreamInput *input;
|
VipsStreami *input;
|
||||||
gboolean result;
|
gboolean result;
|
||||||
|
|
||||||
if( !(input = vips_stream_input_new_from_memory( buf, len )) )
|
if( !(input = vips_streami_new_from_memory( buf, len )) )
|
||||||
return( FALSE );
|
return( FALSE );
|
||||||
result = vips__iswebp_stream( input );
|
result = vips__iswebp_stream( input );
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( input );
|
||||||
@ -382,9 +382,9 @@ vips_foreign_load_webp_buffer_header( VipsForeignLoad *load )
|
|||||||
VipsForeignLoadWebp *webp = (VipsForeignLoadWebp *) load;
|
VipsForeignLoadWebp *webp = (VipsForeignLoadWebp *) load;
|
||||||
VipsForeignLoadWebpBuffer *buffer = (VipsForeignLoadWebpBuffer *) load;
|
VipsForeignLoadWebpBuffer *buffer = (VipsForeignLoadWebpBuffer *) load;
|
||||||
|
|
||||||
VipsStreamInput *input;
|
VipsStreami *input;
|
||||||
|
|
||||||
if( !(input = vips_stream_input_new_from_memory( buffer->buf->data,
|
if( !(input = vips_streami_new_from_memory( buffer->buf->data,
|
||||||
buffer->buf->length )) )
|
buffer->buf->length )) )
|
||||||
return( FALSE );
|
return( FALSE );
|
||||||
if( vips__webp_read_header_stream( input, load->out,
|
if( vips__webp_read_header_stream( input, load->out,
|
||||||
@ -403,9 +403,9 @@ vips_foreign_load_webp_buffer_load( VipsForeignLoad *load )
|
|||||||
VipsForeignLoadWebp *webp = (VipsForeignLoadWebp *) load;
|
VipsForeignLoadWebp *webp = (VipsForeignLoadWebp *) load;
|
||||||
VipsForeignLoadWebpBuffer *buffer = (VipsForeignLoadWebpBuffer *) load;
|
VipsForeignLoadWebpBuffer *buffer = (VipsForeignLoadWebpBuffer *) load;
|
||||||
|
|
||||||
VipsStreamInput *input;
|
VipsStreami *input;
|
||||||
|
|
||||||
if( !(input = vips_stream_input_new_from_memory( buffer->buf->data,
|
if( !(input = vips_streami_new_from_memory( buffer->buf->data,
|
||||||
buffer->buf->length )) )
|
buffer->buf->length )) )
|
||||||
return( FALSE );
|
return( FALSE );
|
||||||
if( vips__webp_read_stream( input, load->real,
|
if( vips__webp_read_stream( input, load->real,
|
||||||
@ -561,7 +561,7 @@ vips_webpload_buffer( void *buf, size_t len, VipsImage **out, ... )
|
|||||||
* Returns: 0 on success, -1 on error.
|
* Returns: 0 on success, -1 on error.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
vips_webpload_stream( VipsStreamInput *input, VipsImage **out, ... )
|
vips_webpload_stream( VipsStreami *input, VipsImage **out, ... )
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
int result;
|
int result;
|
||||||
|
@ -222,7 +222,7 @@ vips_foreign_save_webp_init( VipsForeignSaveWebp *webp )
|
|||||||
typedef struct _VipsForeignSaveWebpStream {
|
typedef struct _VipsForeignSaveWebpStream {
|
||||||
VipsForeignSaveWebp parent_object;
|
VipsForeignSaveWebp parent_object;
|
||||||
|
|
||||||
VipsStreamOutput *output;
|
VipsStreamo *output;
|
||||||
|
|
||||||
} VipsForeignSaveWebpStream;
|
} VipsForeignSaveWebpStream;
|
||||||
|
|
||||||
@ -273,7 +273,7 @@ vips_foreign_save_webp_stream_class_init(
|
|||||||
_( "Stream to save to" ),
|
_( "Stream to save to" ),
|
||||||
VIPS_ARGUMENT_REQUIRED_INPUT,
|
VIPS_ARGUMENT_REQUIRED_INPUT,
|
||||||
G_STRUCT_OFFSET( VipsForeignSaveWebpStream, output ),
|
G_STRUCT_OFFSET( VipsForeignSaveWebpStream, output ),
|
||||||
VIPS_TYPE_STREAM_OUTPUT );
|
VIPS_TYPE_STREAMO );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -303,13 +303,13 @@ vips_foreign_save_webp_file_build( VipsObject *object )
|
|||||||
VipsForeignSaveWebp *webp = (VipsForeignSaveWebp *) object;
|
VipsForeignSaveWebp *webp = (VipsForeignSaveWebp *) object;
|
||||||
VipsForeignSaveWebpFile *file = (VipsForeignSaveWebpFile *) object;
|
VipsForeignSaveWebpFile *file = (VipsForeignSaveWebpFile *) object;
|
||||||
|
|
||||||
VipsStreamOutput *output;
|
VipsStreamo *output;
|
||||||
|
|
||||||
if( VIPS_OBJECT_CLASS( vips_foreign_save_webp_file_parent_class )->
|
if( VIPS_OBJECT_CLASS( vips_foreign_save_webp_file_parent_class )->
|
||||||
build( object ) )
|
build( object ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
if( !(output = vips_stream_output_new_from_filename( file->filename )) )
|
if( !(output = vips_streamo_new_from_filename( file->filename )) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
if( vips__webp_write_stream( save->ready, output,
|
if( vips__webp_write_stream( save->ready, output,
|
||||||
webp->Q, webp->lossless, webp->preset,
|
webp->Q, webp->lossless, webp->preset,
|
||||||
@ -373,14 +373,14 @@ vips_foreign_save_webp_buffer_build( VipsObject *object )
|
|||||||
VipsForeignSaveWebpBuffer *buffer =
|
VipsForeignSaveWebpBuffer *buffer =
|
||||||
(VipsForeignSaveWebpBuffer *) object;
|
(VipsForeignSaveWebpBuffer *) object;
|
||||||
|
|
||||||
VipsStreamOutput *output;
|
VipsStreamo *output;
|
||||||
VipsBlob *blob;
|
VipsBlob *blob;
|
||||||
|
|
||||||
if( VIPS_OBJECT_CLASS( vips_foreign_save_webp_buffer_parent_class )->
|
if( VIPS_OBJECT_CLASS( vips_foreign_save_webp_buffer_parent_class )->
|
||||||
build( object ) )
|
build( object ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
if( !(output = vips_stream_output_new_memory()) )
|
if( !(output = vips_streamo_new_memory()) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
if( vips__webp_write_stream( save->ready, output,
|
if( vips__webp_write_stream( save->ready, output,
|
||||||
@ -443,7 +443,7 @@ vips_foreign_save_webp_mime_build( VipsObject *object )
|
|||||||
VipsForeignSave *save = (VipsForeignSave *) object;
|
VipsForeignSave *save = (VipsForeignSave *) object;
|
||||||
VipsForeignSaveWebp *webp = (VipsForeignSaveWebp *) object;
|
VipsForeignSaveWebp *webp = (VipsForeignSaveWebp *) object;
|
||||||
|
|
||||||
VipsStreamOutput *output;
|
VipsStreamo *output;
|
||||||
VipsBlob *blob;
|
VipsBlob *blob;
|
||||||
void *data;
|
void *data;
|
||||||
size_t len;
|
size_t len;
|
||||||
@ -452,7 +452,7 @@ vips_foreign_save_webp_mime_build( VipsObject *object )
|
|||||||
build( object ) )
|
build( object ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
if( !(output = vips_stream_output_new_memory()) )
|
if( !(output = vips_streamo_new_memory()) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
if( vips__webp_write_stream( save->ready, output,
|
if( vips__webp_write_stream( save->ready, output,
|
||||||
@ -695,7 +695,7 @@ vips_webpsave_mime( VipsImage *in, ... )
|
|||||||
* Returns: 0 on success, -1 on error.
|
* Returns: 0 on success, -1 on error.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
vips_webpsave_stream( VipsImage *in, VipsStreamOutput *output, ... )
|
vips_webpsave_stream( VipsImage *in, VipsStreamo *output, ... )
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
int result;
|
int result;
|
||||||
|
@ -86,7 +86,7 @@ typedef struct _VipsStreamClass {
|
|||||||
|
|
||||||
GType vips_stream_get_type( void );
|
GType vips_stream_get_type( void );
|
||||||
|
|
||||||
const char *vips_stream_filename( VipsStream *stream );
|
const char *vips_stream_name( VipsStream *stream );
|
||||||
|
|
||||||
#define VIPS_TYPE_STREAMI (vips_streami_get_type())
|
#define VIPS_TYPE_STREAMI (vips_streami_get_type())
|
||||||
#define VIPS_STREAMI( obj ) \
|
#define VIPS_STREAMI( obj ) \
|
||||||
|
@ -152,7 +152,7 @@ vips_stream_init( VipsStream *stream )
|
|||||||
const char *
|
const char *
|
||||||
vips_stream_name( VipsStream *stream )
|
vips_stream_name( VipsStream *stream )
|
||||||
{
|
{
|
||||||
return( VIPS_STREAM( STREAM )->filename ?
|
return( stream->filename ?
|
||||||
VIPS_STREAM( STREAM )->filename :
|
stream->filename :
|
||||||
VIPS_OBJECT( STREAM )->nickname );
|
VIPS_OBJECT( stream )->nickname );
|
||||||
}
|
}
|
||||||
|
@ -96,14 +96,10 @@
|
|||||||
|
|
||||||
G_DEFINE_TYPE( VipsStreami, vips_streami, VIPS_TYPE_STREAM );
|
G_DEFINE_TYPE( VipsStreami, vips_streami, VIPS_TYPE_STREAM );
|
||||||
|
|
||||||
static int
|
static void
|
||||||
vips_streami_sanity( VipsStreami *streami )
|
vips_streami_sanity( VipsStreami *streami )
|
||||||
{
|
{
|
||||||
VipsStream *stream = VIPS_STREAM( streami );
|
|
||||||
|
|
||||||
if( streami->blob ) {
|
if( streami->blob ) {
|
||||||
VipsArea *area = VIPS_AREA( streami->blob );
|
|
||||||
|
|
||||||
/* Not a pipe (can map and seek).
|
/* Not a pipe (can map and seek).
|
||||||
*/
|
*/
|
||||||
g_assert( !streami->is_pipe );
|
g_assert( !streami->is_pipe );
|
||||||
@ -226,8 +222,8 @@ vips_streami_open( VipsStreami *streami )
|
|||||||
stream->tracked_descriptor = fd;
|
stream->tracked_descriptor = fd;
|
||||||
stream->descriptor = fd;
|
stream->descriptor = fd;
|
||||||
|
|
||||||
if( stream->length == -1 &&
|
if( streami->length == -1 &&
|
||||||
(stream->length = vips_file_length( fd )) == -1 )
|
(streami->length = vips_file_length( fd )) == -1 )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
VIPS_DEBUG_MSG( "vips_streami_open: "
|
VIPS_DEBUG_MSG( "vips_streami_open: "
|
||||||
@ -255,7 +251,7 @@ vips_streami_build( VipsObject *object )
|
|||||||
|
|
||||||
if( vips_object_argument_isset( object, "filename" ) &&
|
if( vips_object_argument_isset( object, "filename" ) &&
|
||||||
vips_object_argument_isset( object, "descriptor" ) ) {
|
vips_object_argument_isset( object, "descriptor" ) ) {
|
||||||
vips_error( STREAM_NAME( stream ),
|
vips_error( vips_stream_name( stream ),
|
||||||
"%s", _( "don't set 'filename' and 'descriptor'" ) );
|
"%s", _( "don't set 'filename' and 'descriptor'" ) );
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
@ -596,7 +592,8 @@ vips_streami_read( VipsStreami *streami, void *buffer, size_t length )
|
|||||||
ssize_t n;
|
ssize_t n;
|
||||||
|
|
||||||
if( (n = class->read( streami, buffer, length )) == -1 ) {
|
if( (n = class->read( streami, buffer, length )) == -1 ) {
|
||||||
vips_error_system( errno, STREAM_NAME( streami ),
|
vips_error_system( errno,
|
||||||
|
vips_stream_name( VIPS_STREAM( streami ) ),
|
||||||
"%s", _( "read error" ) );
|
"%s", _( "read error" ) );
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
|
@ -1254,7 +1254,7 @@ vips_thumbnail_buffer( void *buf, size_t len, VipsImage **out, int width, ... )
|
|||||||
typedef struct _VipsThumbnailStream {
|
typedef struct _VipsThumbnailStream {
|
||||||
VipsThumbnail parent_object;
|
VipsThumbnail parent_object;
|
||||||
|
|
||||||
VipsStreamInput *input;
|
VipsStreami *input;
|
||||||
char *option_string;
|
char *option_string;
|
||||||
} VipsThumbnailStream;
|
} VipsThumbnailStream;
|
||||||
|
|
||||||
@ -1367,7 +1367,7 @@ vips_thumbnail_stream_class_init( VipsThumbnailClass *class )
|
|||||||
_( "Stream to load from" ),
|
_( "Stream to load from" ),
|
||||||
VIPS_ARGUMENT_REQUIRED_INPUT,
|
VIPS_ARGUMENT_REQUIRED_INPUT,
|
||||||
G_STRUCT_OFFSET( VipsThumbnailStream, input ),
|
G_STRUCT_OFFSET( VipsThumbnailStream, input ),
|
||||||
VIPS_TYPE_STREAM_INPUT );
|
VIPS_TYPE_STREAMI );
|
||||||
|
|
||||||
VIPS_ARG_STRING( class, "option_string", 20,
|
VIPS_ARG_STRING( class, "option_string", 20,
|
||||||
_( "Extra options" ),
|
_( "Extra options" ),
|
||||||
@ -1408,7 +1408,7 @@ vips_thumbnail_stream_init( VipsThumbnailStream *stream )
|
|||||||
* Returns: 0 on success, -1 on error.
|
* Returns: 0 on success, -1 on error.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
vips_thumbnail_stream( VipsStreamInput *input, VipsImage **out, int width, ... )
|
vips_thumbnail_stream( VipsStreami *input, VipsImage **out, int width, ... )
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
int result;
|
int result;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user