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