rename VipsStream* variables
The convention is now: VipStreami *streami; We had `input` in many places, a left-over from the old VipStreamInput name.
This commit is contained in:
parent
998b5eea45
commit
f5a4f41edf
@ -112,16 +112,16 @@ jpeg2vips( const char *name, IMAGE *out, gboolean header_only )
|
|||||||
|
|
||||||
#ifdef HAVE_JPEG
|
#ifdef HAVE_JPEG
|
||||||
{
|
{
|
||||||
VipsStreami *input;
|
VipsStreami *streami;
|
||||||
|
|
||||||
if( !(input = vips_streami_new_from_filename( filename )) )
|
if( !(streami = vips_streami_new_from_filename( filename )) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
if( vips__jpeg_read_stream( input, out,
|
if( vips__jpeg_read_stream( streami, out,
|
||||||
header_only, shrink, fail_on_warn, FALSE ) ) {
|
header_only, shrink, fail_on_warn, FALSE ) ) {
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( streami );
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( streami );
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
vips_error( "im_jpeg2vips",
|
vips_error( "im_jpeg2vips",
|
||||||
|
@ -84,16 +84,16 @@ png2vips( const char *name, IMAGE *out, gboolean header_only )
|
|||||||
|
|
||||||
#ifdef HAVE_PNG
|
#ifdef HAVE_PNG
|
||||||
{
|
{
|
||||||
VipsStreami *input;
|
VipsStreami *streami;
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
if( !(input = vips_streami_new_from_filename( filename )) )
|
if( !(streami = 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( streami, out );
|
||||||
else
|
else
|
||||||
result = vips__png_read_stream( input, out, TRUE );
|
result = vips__png_read_stream( streami, out, TRUE );
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( streami );
|
||||||
|
|
||||||
if( result )
|
if( result )
|
||||||
return( result );
|
return( result );
|
||||||
|
@ -56,13 +56,13 @@
|
|||||||
static gboolean
|
static gboolean
|
||||||
im_istifftiled( const char *filename )
|
im_istifftiled( const char *filename )
|
||||||
{
|
{
|
||||||
VipsStreami *input;
|
VipsStreami *streami;
|
||||||
gboolean result;
|
gboolean result;
|
||||||
|
|
||||||
if( !(input = vips_streami_new_from_filename( filename )) )
|
if( !(streami = vips_streami_new_from_filename( filename )) )
|
||||||
return( FALSE );
|
return( FALSE );
|
||||||
result = vips__istiff_stream( input );
|
result = vips__istiff_stream( streami );
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( streami );
|
||||||
|
|
||||||
return( result );
|
return( result );
|
||||||
}
|
}
|
||||||
@ -71,15 +71,16 @@ 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 )
|
||||||
{
|
{
|
||||||
VipsStreami *input;
|
VipsStreami *streami;
|
||||||
|
|
||||||
if( !(input = vips_streami_new_from_filename( filename )) )
|
if( !(streami = 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( streami,
|
||||||
VIPS_UNREF( input );
|
out, page, n, autorotate ) ) {
|
||||||
|
VIPS_UNREF( streami );
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( streami );
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
@ -88,15 +89,15 @@ 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 )
|
||||||
{
|
{
|
||||||
VipsStreami *input;
|
VipsStreami *streami;
|
||||||
|
|
||||||
if( !(input = vips_streami_new_from_filename( filename )) )
|
if( !(streami = 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( streami, out, page, n, autorotate ) ) {
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( streami );
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( streami );
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
|
@ -52,16 +52,16 @@ webp2vips( const char *name, IMAGE *out, gboolean header_only )
|
|||||||
|
|
||||||
#ifdef HAVE_LIBWEBP
|
#ifdef HAVE_LIBWEBP
|
||||||
{
|
{
|
||||||
VipsStreami *input;
|
VipsStreami *streami;
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
if( !(input = vips_streami_new_from_filename( filename )) )
|
if( !(streami = 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( streami, out, 0, 1, 1 );
|
||||||
else
|
else
|
||||||
result = vips__webp_read_stream( input, out, 0, 1, 1 );
|
result = vips__webp_read_stream( streami, out, 0, 1, 1 );
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( streami );
|
||||||
|
|
||||||
if( result )
|
if( result )
|
||||||
return( result );
|
return( result );
|
||||||
@ -82,12 +82,12 @@ vips__iswebp( const char *filename )
|
|||||||
gboolean result;
|
gboolean result;
|
||||||
|
|
||||||
#ifdef HAVE_LIBWEBP
|
#ifdef HAVE_LIBWEBP
|
||||||
VipsStreami *input;
|
VipsStreami *streami;
|
||||||
|
|
||||||
if( !(input = vips_streami_new_from_filename( filename )) )
|
if( !(streami = vips_streami_new_from_filename( filename )) )
|
||||||
return( FALSE );
|
return( FALSE );
|
||||||
result = vips__png_ispng_stream( input );
|
result = vips__png_ispng_stream( streami );
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( streami );
|
||||||
#else /*!HAVE_LIBWEBP*/
|
#else /*!HAVE_LIBWEBP*/
|
||||||
result = -1;
|
result = -1;
|
||||||
#endif /*HAVE_LIBWEBP*/
|
#endif /*HAVE_LIBWEBP*/
|
||||||
|
@ -193,7 +193,7 @@ typedef struct _ReadJpeg {
|
|||||||
|
|
||||||
/* The stream we read from.
|
/* The stream we read from.
|
||||||
*/
|
*/
|
||||||
VipsStreami *input;
|
VipsStreami *streami;
|
||||||
|
|
||||||
} ReadJpeg;
|
} ReadJpeg;
|
||||||
|
|
||||||
@ -208,7 +208,7 @@ typedef struct {
|
|||||||
|
|
||||||
/* Private stuff during read.
|
/* Private stuff during read.
|
||||||
*/
|
*/
|
||||||
VipsStreami *input;
|
VipsStreami *streami;
|
||||||
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_streami_read( src->input,
|
if( (read = vips_streami_read( src->streami,
|
||||||
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;
|
||||||
@ -277,11 +277,11 @@ readjpeg_open_input( ReadJpeg *jpeg )
|
|||||||
{
|
{
|
||||||
j_decompress_ptr cinfo = &jpeg->cinfo;
|
j_decompress_ptr cinfo = &jpeg->cinfo;
|
||||||
|
|
||||||
if( jpeg->input &&
|
if( jpeg->streami &&
|
||||||
!cinfo->src ) {
|
!cinfo->src ) {
|
||||||
Source *src;
|
Source *src;
|
||||||
|
|
||||||
if( vips_streami_rewind( jpeg->input ) )
|
if( vips_streami_rewind( jpeg->streami ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
cinfo->src = (struct jpeg_source_mgr *)
|
cinfo->src = (struct jpeg_source_mgr *)
|
||||||
@ -290,7 +290,7 @@ readjpeg_open_input( ReadJpeg *jpeg )
|
|||||||
sizeof( Source ) );
|
sizeof( Source ) );
|
||||||
|
|
||||||
src = (Source *) cinfo->src;
|
src = (Source *) cinfo->src;
|
||||||
src->input = jpeg->input;
|
src->streami = jpeg->streami;
|
||||||
src->pub.init_source = stream_init_source;
|
src->pub.init_source = stream_init_source;
|
||||||
src->pub.fill_input_buffer = stream_fill_input_buffer;
|
src->pub.fill_input_buffer = stream_fill_input_buffer;
|
||||||
src->pub.resync_to_restart = jpeg_resync_to_restart;
|
src->pub.resync_to_restart = jpeg_resync_to_restart;
|
||||||
@ -326,7 +326,7 @@ readjpeg_free( ReadJpeg *jpeg )
|
|||||||
*/
|
*/
|
||||||
jpeg_destroy_decompress( &jpeg->cinfo );
|
jpeg_destroy_decompress( &jpeg->cinfo );
|
||||||
|
|
||||||
VIPS_UNREF( jpeg->input );
|
VIPS_UNREF( jpeg->streami );
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
@ -338,13 +338,13 @@ readjpeg_close_cb( VipsObject *object, ReadJpeg *jpeg )
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
input_minimise_cb( VipsImage *image, VipsStreami *input )
|
readjpeg_minimise_cb( VipsImage *image, ReadJpeg *jpeg )
|
||||||
{
|
{
|
||||||
vips_streami_minimise( input );
|
vips_streami_minimise( jpeg->streami );
|
||||||
}
|
}
|
||||||
|
|
||||||
static ReadJpeg *
|
static ReadJpeg *
|
||||||
readjpeg_new( VipsStreami *input, VipsImage *out,
|
readjpeg_new( VipsStreami *streami, VipsImage *out,
|
||||||
int shrink, gboolean fail, gboolean autorotate )
|
int shrink, gboolean fail, gboolean autorotate )
|
||||||
{
|
{
|
||||||
ReadJpeg *jpeg;
|
ReadJpeg *jpeg;
|
||||||
@ -352,8 +352,8 @@ readjpeg_new( VipsStreami *input, VipsImage *out,
|
|||||||
if( !(jpeg = VIPS_NEW( out, ReadJpeg )) )
|
if( !(jpeg = VIPS_NEW( out, ReadJpeg )) )
|
||||||
return( NULL );
|
return( NULL );
|
||||||
|
|
||||||
jpeg->input = input;
|
jpeg->streami = streami;
|
||||||
g_object_ref( input );
|
g_object_ref( streami );
|
||||||
jpeg->shrink = shrink;
|
jpeg->shrink = shrink;
|
||||||
jpeg->fail = fail;
|
jpeg->fail = fail;
|
||||||
jpeg->cinfo.err = jpeg_std_error( &jpeg->eman.pub );
|
jpeg->cinfo.err = jpeg_std_error( &jpeg->eman.pub );
|
||||||
@ -379,7 +379,7 @@ readjpeg_new( VipsStreami *input, VipsImage *out,
|
|||||||
g_signal_connect( out, "close",
|
g_signal_connect( out, "close",
|
||||||
G_CALLBACK( readjpeg_close_cb ), jpeg );
|
G_CALLBACK( readjpeg_close_cb ), jpeg );
|
||||||
g_signal_connect( out, "minimise",
|
g_signal_connect( out, "minimise",
|
||||||
G_CALLBACK( input_minimise_cb ), input );
|
G_CALLBACK( readjpeg_minimise_cb ), jpeg );
|
||||||
|
|
||||||
return( jpeg );
|
return( jpeg );
|
||||||
}
|
}
|
||||||
@ -559,7 +559,7 @@ read_jpeg_header( ReadJpeg *jpeg, VipsImage *out )
|
|||||||
xres, yres );
|
xres, yres );
|
||||||
|
|
||||||
VIPS_SETSTR( out->filename,
|
VIPS_SETSTR( out->filename,
|
||||||
vips_stream_filename( VIPS_STREAM( jpeg->input ) ) );
|
vips_stream_filename( VIPS_STREAM( jpeg->streami ) ) );
|
||||||
|
|
||||||
vips_image_pipelinev( out, VIPS_DEMAND_STYLE_FATSTRIP, NULL );
|
vips_image_pipelinev( out, VIPS_DEMAND_STYLE_FATSTRIP, NULL );
|
||||||
|
|
||||||
@ -959,12 +959,12 @@ vips__jpeg_read( ReadJpeg *jpeg, VipsImage *out, gboolean header_only )
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
vips__jpeg_read_stream( VipsStreami *input, VipsImage *out,
|
vips__jpeg_read_stream( VipsStreami *streami, VipsImage *out,
|
||||||
gboolean header_only, int shrink, int fail, gboolean autorotate )
|
gboolean header_only, int shrink, int fail, gboolean autorotate )
|
||||||
{
|
{
|
||||||
ReadJpeg *jpeg;
|
ReadJpeg *jpeg;
|
||||||
|
|
||||||
if( !(jpeg = readjpeg_new( input, out, shrink, fail, autorotate )) )
|
if( !(jpeg = readjpeg_new( streami, out, shrink, fail, autorotate )) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
if( setjmp( jpeg->eman.jmp ) )
|
if( setjmp( jpeg->eman.jmp ) )
|
||||||
@ -975,19 +975,21 @@ vips__jpeg_read_stream( VipsStreami *input, VipsImage *out,
|
|||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
if( header_only )
|
if( header_only )
|
||||||
vips_streami_minimise( input );
|
vips_streami_minimise( streami );
|
||||||
else if( vips_streami_decode( input ) )
|
else {
|
||||||
return( -1 );
|
if( vips_streami_decode( streami ) )
|
||||||
|
return( -1 );
|
||||||
|
}
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
vips__isjpeg_stream( VipsStreami *input )
|
vips__isjpeg_stream( VipsStreami *streami )
|
||||||
{
|
{
|
||||||
const unsigned char *p;
|
const unsigned char *p;
|
||||||
|
|
||||||
if( (p = vips_streami_sniff( input, 2 )) &&
|
if( (p = vips_streami_sniff( streami, 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;
|
||||||
|
|
||||||
VipsStreami *input;
|
VipsStreami *streami;
|
||||||
|
|
||||||
} VipsForeignLoadJpegStream;
|
} VipsForeignLoadJpegStream;
|
||||||
|
|
||||||
@ -168,7 +168,7 @@ vips_foreign_load_jpeg_stream_header( VipsForeignLoad *load )
|
|||||||
VipsForeignLoadJpeg *jpeg = (VipsForeignLoadJpeg *) load;
|
VipsForeignLoadJpeg *jpeg = (VipsForeignLoadJpeg *) load;
|
||||||
VipsForeignLoadJpegStream *stream = (VipsForeignLoadJpegStream *) load;
|
VipsForeignLoadJpegStream *stream = (VipsForeignLoadJpegStream *) load;
|
||||||
|
|
||||||
if( vips__jpeg_read_stream( stream->input,
|
if( vips__jpeg_read_stream( stream->streami,
|
||||||
load->out, TRUE, jpeg->shrink, load->fail, jpeg->autorotate ) )
|
load->out, TRUE, jpeg->shrink, load->fail, jpeg->autorotate ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
@ -181,7 +181,7 @@ vips_foreign_load_jpeg_stream_load( VipsForeignLoad *load )
|
|||||||
VipsForeignLoadJpeg *jpeg = (VipsForeignLoadJpeg *) load;
|
VipsForeignLoadJpeg *jpeg = (VipsForeignLoadJpeg *) load;
|
||||||
VipsForeignLoadJpegStream *stream = (VipsForeignLoadJpegStream *) load;
|
VipsForeignLoadJpegStream *stream = (VipsForeignLoadJpegStream *) load;
|
||||||
|
|
||||||
if( vips__jpeg_read_stream( stream->input,
|
if( vips__jpeg_read_stream( stream->streami,
|
||||||
load->real, FALSE, jpeg->shrink, load->fail,
|
load->real, FALSE, jpeg->shrink, load->fail,
|
||||||
jpeg->autorotate ) )
|
jpeg->autorotate ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
@ -190,9 +190,9 @@ vips_foreign_load_jpeg_stream_load( VipsForeignLoad *load )
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
vips_foreign_load_jpeg_stream_is_a( VipsStreami *input )
|
vips_foreign_load_jpeg_stream_is_a( VipsStreami *streami )
|
||||||
{
|
{
|
||||||
return( vips__isjpeg_stream( input ) );
|
return( vips__isjpeg_stream( streami ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -217,7 +217,7 @@ vips_foreign_load_jpeg_stream_class_init(
|
|||||||
_( "Input" ),
|
_( "Input" ),
|
||||||
_( "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, streami ),
|
||||||
VIPS_TYPE_STREAMI );
|
VIPS_TYPE_STREAMI );
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -242,13 +242,13 @@ 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 )
|
||||||
{
|
{
|
||||||
VipsStreami *input;
|
VipsStreami *streami;
|
||||||
gboolean result;
|
gboolean result;
|
||||||
|
|
||||||
if( !(input = vips_streami_new_from_filename( filename )) )
|
if( !(streami = vips_streami_new_from_filename( filename )) )
|
||||||
return( FALSE );
|
return( FALSE );
|
||||||
result = vips__isjpeg_stream( input );
|
result = vips__isjpeg_stream( streami );
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( streami );
|
||||||
|
|
||||||
return( result );
|
return( result );
|
||||||
}
|
}
|
||||||
@ -259,16 +259,16 @@ vips_foreign_load_jpeg_file_header( VipsForeignLoad *load )
|
|||||||
VipsForeignLoadJpeg *jpeg = (VipsForeignLoadJpeg *) load;
|
VipsForeignLoadJpeg *jpeg = (VipsForeignLoadJpeg *) load;
|
||||||
VipsForeignLoadJpegFile *file = (VipsForeignLoadJpegFile *) load;
|
VipsForeignLoadJpegFile *file = (VipsForeignLoadJpegFile *) load;
|
||||||
|
|
||||||
VipsStreami *input;
|
VipsStreami *streami;
|
||||||
|
|
||||||
if( !(input = vips_streami_new_from_filename( file->filename )) )
|
if( !(streami = vips_streami_new_from_filename( file->filename )) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
if( vips__jpeg_read_stream( input, load->out,
|
if( vips__jpeg_read_stream( streami, load->out,
|
||||||
TRUE, jpeg->shrink, load->fail, jpeg->autorotate ) ) {
|
TRUE, jpeg->shrink, load->fail, jpeg->autorotate ) ) {
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( streami );
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( streami );
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
@ -279,16 +279,16 @@ vips_foreign_load_jpeg_file_load( VipsForeignLoad *load )
|
|||||||
VipsForeignLoadJpeg *jpeg = (VipsForeignLoadJpeg *) load;
|
VipsForeignLoadJpeg *jpeg = (VipsForeignLoadJpeg *) load;
|
||||||
VipsForeignLoadJpegFile *file = (VipsForeignLoadJpegFile *) load;
|
VipsForeignLoadJpegFile *file = (VipsForeignLoadJpegFile *) load;
|
||||||
|
|
||||||
VipsStreami *input;
|
VipsStreami *streami;
|
||||||
|
|
||||||
if( !(input = vips_streami_new_from_filename( file->filename )) )
|
if( !(streami = vips_streami_new_from_filename( file->filename )) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
if( vips__jpeg_read_stream( input, load->real,
|
if( vips__jpeg_read_stream( streami, load->real,
|
||||||
FALSE, jpeg->shrink, load->fail, jpeg->autorotate ) ) {
|
FALSE, jpeg->shrink, load->fail, jpeg->autorotate ) ) {
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( streami );
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( streami );
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
@ -345,13 +345,13 @@ 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 )
|
||||||
{
|
{
|
||||||
VipsStreami *input;
|
VipsStreami *streami;
|
||||||
gboolean result;
|
gboolean result;
|
||||||
|
|
||||||
if( !(input = vips_streami_new_from_memory( buf, len )) )
|
if( !(streami = vips_streami_new_from_memory( buf, len )) )
|
||||||
return( FALSE );
|
return( FALSE );
|
||||||
result = vips__isjpeg_stream( input );
|
result = vips__isjpeg_stream( streami );
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( streami );
|
||||||
|
|
||||||
return( result );
|
return( result );
|
||||||
}
|
}
|
||||||
@ -362,16 +362,16 @@ vips_foreign_load_jpeg_buffer_header( VipsForeignLoad *load )
|
|||||||
VipsForeignLoadJpeg *jpeg = (VipsForeignLoadJpeg *) load;
|
VipsForeignLoadJpeg *jpeg = (VipsForeignLoadJpeg *) load;
|
||||||
VipsForeignLoadJpegBuffer *buffer = (VipsForeignLoadJpegBuffer *) load;
|
VipsForeignLoadJpegBuffer *buffer = (VipsForeignLoadJpegBuffer *) load;
|
||||||
|
|
||||||
VipsStreami *input;
|
VipsStreami *streami;
|
||||||
|
|
||||||
if( !(input = vips_streami_new_from_blob( buffer->blob )) )
|
if( !(streami = vips_streami_new_from_blob( buffer->blob )) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
if( vips__jpeg_read_stream( input, load->out,
|
if( vips__jpeg_read_stream( streami, load->out,
|
||||||
TRUE, jpeg->shrink, load->fail, jpeg->autorotate ) ) {
|
TRUE, jpeg->shrink, load->fail, jpeg->autorotate ) ) {
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( streami );
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( streami );
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
@ -382,16 +382,16 @@ vips_foreign_load_jpeg_buffer_load( VipsForeignLoad *load )
|
|||||||
VipsForeignLoadJpeg *jpeg = (VipsForeignLoadJpeg *) load;
|
VipsForeignLoadJpeg *jpeg = (VipsForeignLoadJpeg *) load;
|
||||||
VipsForeignLoadJpegBuffer *buffer = (VipsForeignLoadJpegBuffer *) load;
|
VipsForeignLoadJpegBuffer *buffer = (VipsForeignLoadJpegBuffer *) load;
|
||||||
|
|
||||||
VipsStreami *input;
|
VipsStreami *streami;
|
||||||
|
|
||||||
if( !(input = vips_streami_new_from_blob( buffer->blob )) )
|
if( !(streami = vips_streami_new_from_blob( buffer->blob )) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
if( vips__jpeg_read_stream( input, load->real,
|
if( vips__jpeg_read_stream( streami, load->real,
|
||||||
FALSE, jpeg->shrink, load->fail, jpeg->autorotate ) ) {
|
FALSE, jpeg->shrink, load->fail, jpeg->autorotate ) ) {
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( streami );
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( streami );
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
|
@ -219,7 +219,7 @@ vips_foreign_save_jpeg_init( VipsForeignSaveJpeg *jpeg )
|
|||||||
typedef struct _VipsForeignSaveJpegStream {
|
typedef struct _VipsForeignSaveJpegStream {
|
||||||
VipsForeignSaveJpeg parent_object;
|
VipsForeignSaveJpeg parent_object;
|
||||||
|
|
||||||
VipsStreamo *output;
|
VipsStreamo *streamo;
|
||||||
|
|
||||||
} VipsForeignSaveJpegStream;
|
} VipsForeignSaveJpegStream;
|
||||||
|
|
||||||
@ -240,7 +240,7 @@ vips_foreign_save_jpeg_stream_build( VipsObject *object )
|
|||||||
build( object ) )
|
build( object ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
if( vips__jpeg_write_stream( save->ready, stream->output,
|
if( vips__jpeg_write_stream( save->ready, stream->streamo,
|
||||||
jpeg->Q, jpeg->profile, jpeg->optimize_coding,
|
jpeg->Q, jpeg->profile, jpeg->optimize_coding,
|
||||||
jpeg->interlace, save->strip, jpeg->no_subsample,
|
jpeg->interlace, save->strip, jpeg->no_subsample,
|
||||||
jpeg->trellis_quant, jpeg->overshoot_deringing,
|
jpeg->trellis_quant, jpeg->overshoot_deringing,
|
||||||
@ -264,11 +264,11 @@ vips_foreign_save_jpeg_stream_class_init(
|
|||||||
object_class->description = _( "save image to jpeg stream" );
|
object_class->description = _( "save image to jpeg stream" );
|
||||||
object_class->build = vips_foreign_save_jpeg_stream_build;
|
object_class->build = vips_foreign_save_jpeg_stream_build;
|
||||||
|
|
||||||
VIPS_ARG_OBJECT( class, "output", 1,
|
VIPS_ARG_OBJECT( class, "streamo", 1,
|
||||||
_( "Output" ),
|
_( "Streamo" ),
|
||||||
_( "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, streamo ),
|
||||||
VIPS_TYPE_STREAMO );
|
VIPS_TYPE_STREAMO );
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -299,23 +299,23 @@ vips_foreign_save_jpeg_file_build( VipsObject *object )
|
|||||||
VipsForeignSaveJpeg *jpeg = (VipsForeignSaveJpeg *) object;
|
VipsForeignSaveJpeg *jpeg = (VipsForeignSaveJpeg *) object;
|
||||||
VipsForeignSaveJpegFile *file = (VipsForeignSaveJpegFile *) object;
|
VipsForeignSaveJpegFile *file = (VipsForeignSaveJpegFile *) object;
|
||||||
|
|
||||||
VipsStreamo *output;
|
VipsStreamo *streamo;
|
||||||
|
|
||||||
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_streamo_new_to_filename( file->filename )) )
|
if( !(streamo = vips_streamo_new_to_filename( file->filename )) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
if( vips__jpeg_write_stream( save->ready, output,
|
if( vips__jpeg_write_stream( save->ready, streamo,
|
||||||
jpeg->Q, jpeg->profile, jpeg->optimize_coding,
|
jpeg->Q, jpeg->profile, jpeg->optimize_coding,
|
||||||
jpeg->interlace, save->strip, jpeg->no_subsample,
|
jpeg->interlace, save->strip, jpeg->no_subsample,
|
||||||
jpeg->trellis_quant, jpeg->overshoot_deringing,
|
jpeg->trellis_quant, jpeg->overshoot_deringing,
|
||||||
jpeg->optimize_scans, jpeg->quant_table ) ) {
|
jpeg->optimize_scans, jpeg->quant_table ) ) {
|
||||||
VIPS_UNREF( output );
|
VIPS_UNREF( streamo );
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
VIPS_UNREF( output );
|
VIPS_UNREF( streamo );
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
@ -367,30 +367,30 @@ vips_foreign_save_jpeg_buffer_build( VipsObject *object )
|
|||||||
VipsForeignSaveJpeg *jpeg = (VipsForeignSaveJpeg *) object;
|
VipsForeignSaveJpeg *jpeg = (VipsForeignSaveJpeg *) object;
|
||||||
VipsForeignSaveJpegBuffer *file = (VipsForeignSaveJpegBuffer *) object;
|
VipsForeignSaveJpegBuffer *file = (VipsForeignSaveJpegBuffer *) object;
|
||||||
|
|
||||||
VipsStreamo *output;
|
VipsStreamo *streamo;
|
||||||
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_streamo_new_to_memory()) )
|
if( !(streamo = vips_streamo_new_to_memory()) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
if( vips__jpeg_write_stream( save->ready, output,
|
if( vips__jpeg_write_stream( save->ready, streamo,
|
||||||
jpeg->Q, jpeg->profile, jpeg->optimize_coding,
|
jpeg->Q, jpeg->profile, jpeg->optimize_coding,
|
||||||
jpeg->interlace, save->strip, jpeg->no_subsample,
|
jpeg->interlace, save->strip, jpeg->no_subsample,
|
||||||
jpeg->trellis_quant, jpeg->overshoot_deringing,
|
jpeg->trellis_quant, jpeg->overshoot_deringing,
|
||||||
jpeg->optimize_scans, jpeg->quant_table ) ) {
|
jpeg->optimize_scans, jpeg->quant_table ) ) {
|
||||||
VIPS_UNREF( output );
|
VIPS_UNREF( streamo );
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
g_object_get( output, "blob", &blob, NULL );
|
g_object_get( streamo, "blob", &blob, NULL );
|
||||||
g_object_set( file, "buffer", blob, NULL );
|
g_object_set( file, "buffer", blob, NULL );
|
||||||
vips_area_unref( VIPS_AREA( blob ) );
|
vips_area_unref( VIPS_AREA( blob ) );
|
||||||
|
|
||||||
VIPS_UNREF( output );
|
VIPS_UNREF( streamo );
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
@ -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;
|
||||||
|
|
||||||
VipsStreamo *output;
|
VipsStreamo *streamo;
|
||||||
VipsBlob *blob;
|
VipsBlob *blob;
|
||||||
const unsigned char *obuf;
|
const unsigned char *obuf;
|
||||||
size_t olen;
|
size_t olen;
|
||||||
@ -447,19 +447,19 @@ vips_foreign_save_jpeg_mime_build( VipsObject *object )
|
|||||||
build( object ) )
|
build( object ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
if( !(output = vips_streamo_new_to_memory()) )
|
if( !(streamo = vips_streamo_new_to_memory()) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
if( vips__jpeg_write_stream( save->ready, output,
|
if( vips__jpeg_write_stream( save->ready, streamo,
|
||||||
jpeg->Q, jpeg->profile, jpeg->optimize_coding,
|
jpeg->Q, jpeg->profile, jpeg->optimize_coding,
|
||||||
jpeg->interlace, save->strip, jpeg->no_subsample,
|
jpeg->interlace, save->strip, jpeg->no_subsample,
|
||||||
jpeg->trellis_quant, jpeg->overshoot_deringing,
|
jpeg->trellis_quant, jpeg->overshoot_deringing,
|
||||||
jpeg->optimize_scans, jpeg->quant_table ) ) {
|
jpeg->optimize_scans, jpeg->quant_table ) ) {
|
||||||
VIPS_UNREF( output );
|
VIPS_UNREF( streamo );
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
g_object_get( output, "blob", &blob, NULL );
|
g_object_get( streamo, "blob", &blob, NULL );
|
||||||
|
|
||||||
obuf = vips_blob_get( blob, &olen );
|
obuf = vips_blob_get( blob, &olen );
|
||||||
printf( "Content-length: %zu\r\n", olen );
|
printf( "Content-length: %zu\r\n", olen );
|
||||||
@ -470,7 +470,7 @@ vips_foreign_save_jpeg_mime_build( VipsObject *object )
|
|||||||
|
|
||||||
vips_area_unref( VIPS_AREA( blob ) );
|
vips_area_unref( VIPS_AREA( blob ) );
|
||||||
|
|
||||||
VIPS_UNREF( output );
|
VIPS_UNREF( streamo );
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
@ -612,7 +612,7 @@ vips_jpegsave( VipsImage *in, const char *filename, ... )
|
|||||||
/**
|
/**
|
||||||
* vips_jpegsave_stream: (method)
|
* vips_jpegsave_stream: (method)
|
||||||
* @in: image to save
|
* @in: image to save
|
||||||
* @output: save image to this stream
|
* @streamo: save image to this stream
|
||||||
* @...: %NULL-terminated list of optional named arguments
|
* @...: %NULL-terminated list of optional named arguments
|
||||||
*
|
*
|
||||||
* Optional arguments:
|
* Optional arguments:
|
||||||
@ -635,13 +635,13 @@ 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, VipsStreamo *output, ... )
|
vips_jpegsave_stream( VipsImage *in, VipsStreamo *streamo, ... )
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
va_start( ap, output );
|
va_start( ap, streamo );
|
||||||
result = vips_call_split( "jpegsave_stream", ap, in, output );
|
result = vips_call_split( "jpegsave_stream", ap, in, streamo );
|
||||||
va_end( ap );
|
va_end( ap );
|
||||||
|
|
||||||
return( result );
|
return( result );
|
||||||
|
@ -156,7 +156,7 @@ int vips__rad_israd( VipsStreami *streami );
|
|||||||
int vips__rad_header( VipsStreami *streami, VipsImage *out );
|
int vips__rad_header( VipsStreami *streami, VipsImage *out );
|
||||||
int vips__rad_load( VipsStreami *streami, VipsImage *out );
|
int vips__rad_load( VipsStreami *streami, VipsImage *out );
|
||||||
|
|
||||||
int vips__rad_save( VipsImage *in, VipsStreamo *output );
|
int vips__rad_save( VipsImage *in, VipsStreamo *streamo );
|
||||||
|
|
||||||
extern const char *vips__rad_suffs[];
|
extern const char *vips__rad_suffs[];
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ typedef struct _VipsForeignLoadPngStream {
|
|||||||
|
|
||||||
/* Load from a stream.
|
/* Load from a stream.
|
||||||
*/
|
*/
|
||||||
VipsStreami *input;
|
VipsStreami *streami;
|
||||||
|
|
||||||
} VipsForeignLoadPngStream;
|
} VipsForeignLoadPngStream;
|
||||||
|
|
||||||
@ -74,7 +74,7 @@ vips_foreign_load_png_stream_get_flags( VipsForeignLoad *load )
|
|||||||
VipsForeignFlags flags;
|
VipsForeignFlags flags;
|
||||||
|
|
||||||
flags = 0;
|
flags = 0;
|
||||||
if( vips__png_isinterlaced_stream( stream->input ) )
|
if( vips__png_isinterlaced_stream( stream->streami ) )
|
||||||
flags |= VIPS_FOREIGN_PARTIAL;
|
flags |= VIPS_FOREIGN_PARTIAL;
|
||||||
else
|
else
|
||||||
flags |= VIPS_FOREIGN_SEQUENTIAL;
|
flags |= VIPS_FOREIGN_SEQUENTIAL;
|
||||||
@ -87,7 +87,7 @@ vips_foreign_load_png_stream_header( VipsForeignLoad *load )
|
|||||||
{
|
{
|
||||||
VipsForeignLoadPngStream *stream = (VipsForeignLoadPngStream *) load;
|
VipsForeignLoadPngStream *stream = (VipsForeignLoadPngStream *) load;
|
||||||
|
|
||||||
if( vips__png_header_stream( stream->input, load->out ) )
|
if( vips__png_header_stream( stream->streami, load->out ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
@ -98,7 +98,7 @@ vips_foreign_load_png_stream_load( VipsForeignLoad *load )
|
|||||||
{
|
{
|
||||||
VipsForeignLoadPngStream *stream = (VipsForeignLoadPngStream *) load;
|
VipsForeignLoadPngStream *stream = (VipsForeignLoadPngStream *) load;
|
||||||
|
|
||||||
if( vips__png_read_stream( stream->input, load->real, load->fail ) )
|
if( vips__png_read_stream( stream->streami, load->real, load->fail ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
@ -122,11 +122,11 @@ vips_foreign_load_png_stream_class_init( VipsForeignLoadPngStreamClass *class )
|
|||||||
load_class->header = vips_foreign_load_png_stream_header;
|
load_class->header = vips_foreign_load_png_stream_header;
|
||||||
load_class->load = vips_foreign_load_png_stream_load;
|
load_class->load = vips_foreign_load_png_stream_load;
|
||||||
|
|
||||||
VIPS_ARG_OBJECT( class, "input", 1,
|
VIPS_ARG_OBJECT( class, "streami", 1,
|
||||||
_( "Input" ),
|
_( "Streami" ),
|
||||||
_( "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, streami ),
|
||||||
VIPS_TYPE_STREAMI );
|
VIPS_TYPE_STREAMI );
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -153,13 +153,13 @@ G_DEFINE_TYPE( VipsForeignLoadPng, vips_foreign_load_png,
|
|||||||
static gboolean
|
static gboolean
|
||||||
vips_foreign_load_png_is_a( const char *filename )
|
vips_foreign_load_png_is_a( const char *filename )
|
||||||
{
|
{
|
||||||
VipsStreami *input;
|
VipsStreami *streami;
|
||||||
gboolean result;
|
gboolean result;
|
||||||
|
|
||||||
if( !(input = vips_streami_new_from_filename( filename )) )
|
if( !(streami = vips_streami_new_from_filename( filename )) )
|
||||||
return( FALSE );
|
return( FALSE );
|
||||||
result = vips__png_ispng_stream( input );
|
result = vips__png_ispng_stream( streami );
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( streami );
|
||||||
|
|
||||||
return( result );
|
return( result );
|
||||||
}
|
}
|
||||||
@ -167,19 +167,19 @@ vips_foreign_load_png_is_a( const char *filename )
|
|||||||
static VipsForeignFlags
|
static VipsForeignFlags
|
||||||
vips_foreign_load_png_get_flags_filename( const char *filename )
|
vips_foreign_load_png_get_flags_filename( const char *filename )
|
||||||
{
|
{
|
||||||
VipsStreami *input;
|
VipsStreami *streami;
|
||||||
VipsForeignFlags flags;
|
VipsForeignFlags flags;
|
||||||
|
|
||||||
if( !(input = vips_streami_new_from_filename( filename )) )
|
if( !(streami = vips_streami_new_from_filename( filename )) )
|
||||||
return( 0 );
|
return( 0 );
|
||||||
|
|
||||||
flags = 0;
|
flags = 0;
|
||||||
if( vips__png_isinterlaced_stream( input ) )
|
if( vips__png_isinterlaced_stream( streami ) )
|
||||||
flags |= VIPS_FOREIGN_PARTIAL;
|
flags |= VIPS_FOREIGN_PARTIAL;
|
||||||
else
|
else
|
||||||
flags |= VIPS_FOREIGN_SEQUENTIAL;
|
flags |= VIPS_FOREIGN_SEQUENTIAL;
|
||||||
|
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( streami );
|
||||||
|
|
||||||
return( flags );
|
return( flags );
|
||||||
}
|
}
|
||||||
@ -197,15 +197,15 @@ vips_foreign_load_png_header( VipsForeignLoad *load )
|
|||||||
{
|
{
|
||||||
VipsForeignLoadPng *png = (VipsForeignLoadPng *) load;
|
VipsForeignLoadPng *png = (VipsForeignLoadPng *) load;
|
||||||
|
|
||||||
VipsStreami *input;
|
VipsStreami *streami;
|
||||||
|
|
||||||
if( !(input = vips_streami_new_from_filename( png->filename )) )
|
if( !(streami = vips_streami_new_from_filename( png->filename )) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
if( vips__png_header_stream( input, load->out ) ) {
|
if( vips__png_header_stream( streami, load->out ) ) {
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( streami );
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( streami );
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
@ -215,15 +215,15 @@ vips_foreign_load_png_load( VipsForeignLoad *load )
|
|||||||
{
|
{
|
||||||
VipsForeignLoadPng *png = (VipsForeignLoadPng *) load;
|
VipsForeignLoadPng *png = (VipsForeignLoadPng *) load;
|
||||||
|
|
||||||
VipsStreami *input;
|
VipsStreami *streami;
|
||||||
|
|
||||||
if( !(input = vips_streami_new_from_filename( png->filename )) )
|
if( !(streami = 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( streami, load->real, load->fail ) ) {
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( streami );
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( streami );
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
@ -285,13 +285,13 @@ G_DEFINE_TYPE( VipsForeignLoadPngBuffer, vips_foreign_load_png_buffer,
|
|||||||
static gboolean
|
static gboolean
|
||||||
vips_foreign_load_png_buffer_is_a_buffer( const void *buf, size_t len )
|
vips_foreign_load_png_buffer_is_a_buffer( const void *buf, size_t len )
|
||||||
{
|
{
|
||||||
VipsStreami *input;
|
VipsStreami *streami;
|
||||||
gboolean result;
|
gboolean result;
|
||||||
|
|
||||||
if( !(input = vips_streami_new_from_memory( buf, len )) )
|
if( !(streami = vips_streami_new_from_memory( buf, len )) )
|
||||||
return( FALSE );
|
return( FALSE );
|
||||||
result = vips__png_ispng_stream( input );
|
result = vips__png_ispng_stream( streami );
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( streami );
|
||||||
|
|
||||||
return( result );
|
return( result );
|
||||||
}
|
}
|
||||||
@ -301,20 +301,20 @@ vips_foreign_load_png_buffer_get_flags( VipsForeignLoad *load )
|
|||||||
{
|
{
|
||||||
VipsForeignLoadPngBuffer *buffer = (VipsForeignLoadPngBuffer *) load;
|
VipsForeignLoadPngBuffer *buffer = (VipsForeignLoadPngBuffer *) load;
|
||||||
|
|
||||||
VipsStreami *input;
|
VipsStreami *streami;
|
||||||
VipsForeignFlags flags;
|
VipsForeignFlags flags;
|
||||||
|
|
||||||
if( !(input = vips_streami_new_from_memory( buffer->buf->data,
|
if( !(streami = vips_streami_new_from_memory( buffer->buf->data,
|
||||||
buffer->buf->length )) )
|
buffer->buf->length )) )
|
||||||
return( 0 );
|
return( 0 );
|
||||||
|
|
||||||
flags = 0;
|
flags = 0;
|
||||||
if( vips__png_isinterlaced_stream( input ) )
|
if( vips__png_isinterlaced_stream( streami ) )
|
||||||
flags |= VIPS_FOREIGN_PARTIAL;
|
flags |= VIPS_FOREIGN_PARTIAL;
|
||||||
else
|
else
|
||||||
flags |= VIPS_FOREIGN_SEQUENTIAL;
|
flags |= VIPS_FOREIGN_SEQUENTIAL;
|
||||||
|
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( streami );
|
||||||
|
|
||||||
return( flags );
|
return( flags );
|
||||||
}
|
}
|
||||||
@ -324,16 +324,16 @@ vips_foreign_load_png_buffer_header( VipsForeignLoad *load )
|
|||||||
{
|
{
|
||||||
VipsForeignLoadPngBuffer *buffer = (VipsForeignLoadPngBuffer *) load;
|
VipsForeignLoadPngBuffer *buffer = (VipsForeignLoadPngBuffer *) load;
|
||||||
|
|
||||||
VipsStreami *input;
|
VipsStreami *streami;
|
||||||
|
|
||||||
if( !(input = vips_streami_new_from_memory( buffer->buf->data,
|
if( !(streami = 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( streami, load->out ) ) {
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( streami );
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( streami );
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
@ -343,16 +343,16 @@ vips_foreign_load_png_buffer_load( VipsForeignLoad *load )
|
|||||||
{
|
{
|
||||||
VipsForeignLoadPngBuffer *buffer = (VipsForeignLoadPngBuffer *) load;
|
VipsForeignLoadPngBuffer *buffer = (VipsForeignLoadPngBuffer *) load;
|
||||||
|
|
||||||
VipsStreami *input;
|
VipsStreami *streami;
|
||||||
|
|
||||||
if( !(input = vips_streami_new_from_memory( buffer->buf->data,
|
if( !(streami = 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( streami, load->real, load->fail ) ) {
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( streami );
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( streami );
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
@ -458,7 +458,7 @@ vips_pngload_buffer( void *buf, size_t len, VipsImage **out, ... )
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* vips_pngload_stream:
|
* vips_pngload_stream:
|
||||||
* @input: stream to load from
|
* @streami: stream to load from
|
||||||
* @out: (out): image to write
|
* @out: (out): image to write
|
||||||
* @...: %NULL-terminated list of optional named arguments
|
* @...: %NULL-terminated list of optional named arguments
|
||||||
*
|
*
|
||||||
@ -469,13 +469,13 @@ vips_pngload_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_pngload_stream( VipsStreami *input, VipsImage **out, ... )
|
vips_pngload_stream( VipsStreami *streami, VipsImage **out, ... )
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
va_start( ap, out );
|
va_start( ap, out );
|
||||||
result = vips_call_split( "pngload_stream", ap, input, out );
|
result = vips_call_split( "pngload_stream", ap, streami, out );
|
||||||
va_end( ap );
|
va_end( ap );
|
||||||
|
|
||||||
return( result );
|
return( result );
|
||||||
|
@ -182,7 +182,7 @@ vips_foreign_save_png_init( VipsForeignSavePng *png )
|
|||||||
typedef struct _VipsForeignSavePngStream {
|
typedef struct _VipsForeignSavePngStream {
|
||||||
VipsForeignSavePng parent_object;
|
VipsForeignSavePng parent_object;
|
||||||
|
|
||||||
VipsStreamo *output;
|
VipsStreamo *streamo;
|
||||||
} VipsForeignSavePngStream;
|
} VipsForeignSavePngStream;
|
||||||
|
|
||||||
typedef VipsForeignSavePngClass VipsForeignSavePngStreamClass;
|
typedef VipsForeignSavePngClass VipsForeignSavePngStreamClass;
|
||||||
@ -201,7 +201,7 @@ vips_foreign_save_png_stream_build( VipsObject *object )
|
|||||||
build( object ) )
|
build( object ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
if( vips__png_write_stream( save->ready, stream->output,
|
if( vips__png_write_stream( save->ready, stream->streamo,
|
||||||
png->compression, png->interlace, png->profile, png->filter,
|
png->compression, png->interlace, png->profile, png->filter,
|
||||||
save->strip, png->palette, png->colours, png->Q, png->dither ) )
|
save->strip, png->palette, png->colours, png->Q, png->dither ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
@ -222,11 +222,11 @@ vips_foreign_save_png_stream_class_init( VipsForeignSavePngStreamClass *class )
|
|||||||
object_class->description = _( "save image to png stream" );
|
object_class->description = _( "save image to png stream" );
|
||||||
object_class->build = vips_foreign_save_png_stream_build;
|
object_class->build = vips_foreign_save_png_stream_build;
|
||||||
|
|
||||||
VIPS_ARG_OBJECT( class, "output", 1,
|
VIPS_ARG_OBJECT( class, "streamo", 1,
|
||||||
_( "Output" ),
|
_( "Streamo" ),
|
||||||
_( "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, streamo ),
|
||||||
VIPS_TYPE_STREAMO );
|
VIPS_TYPE_STREAMO );
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -254,23 +254,23 @@ 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;
|
||||||
|
|
||||||
VipsStreamo *output;
|
VipsStreamo *streamo;
|
||||||
|
|
||||||
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_streamo_new_to_filename(
|
if( !(streamo = vips_streamo_new_to_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, streamo,
|
||||||
png->compression, png->interlace,
|
png->compression, png->interlace,
|
||||||
png->profile, png->filter, save->strip, png->palette,
|
png->profile, png->filter, save->strip, png->palette,
|
||||||
png->colours, png->Q, png->dither ) ) {
|
png->colours, png->Q, png->dither ) ) {
|
||||||
VIPS_UNREF( output );
|
VIPS_UNREF( streamo );
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
VIPS_UNREF( output );
|
VIPS_UNREF( streamo );
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
@ -319,29 +319,29 @@ vips_foreign_save_png_buffer_build( VipsObject *object )
|
|||||||
VipsForeignSavePng *png = (VipsForeignSavePng *) object;
|
VipsForeignSavePng *png = (VipsForeignSavePng *) object;
|
||||||
VipsForeignSavePngBuffer *buffer = (VipsForeignSavePngBuffer *) object;
|
VipsForeignSavePngBuffer *buffer = (VipsForeignSavePngBuffer *) object;
|
||||||
|
|
||||||
VipsStreamo *output;
|
VipsStreamo *streamo;
|
||||||
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_streamo_new_to_memory()) )
|
if( !(streamo = vips_streamo_new_to_memory()) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
if( vips__png_write_stream( save->ready, output,
|
if( vips__png_write_stream( save->ready, streamo,
|
||||||
png->compression, png->interlace, png->profile, png->filter,
|
png->compression, png->interlace, png->profile, png->filter,
|
||||||
save->strip, png->palette, png->colours, png->Q,
|
save->strip, png->palette, png->colours, png->Q,
|
||||||
png->dither ) ) {
|
png->dither ) ) {
|
||||||
VIPS_UNREF( output );
|
VIPS_UNREF( streamo );
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
g_object_get( output, "blob", &blob, NULL );
|
g_object_get( streamo, "blob", &blob, NULL );
|
||||||
g_object_set( buffer, "buffer", blob, NULL );
|
g_object_set( buffer, "buffer", blob, NULL );
|
||||||
vips_area_unref( VIPS_AREA( blob ) );
|
vips_area_unref( VIPS_AREA( blob ) );
|
||||||
|
|
||||||
VIPS_UNREF( output );
|
VIPS_UNREF( streamo );
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
@ -501,7 +501,7 @@ vips_pngsave_buffer( VipsImage *in, void **buf, size_t *len, ... )
|
|||||||
/**
|
/**
|
||||||
* vips_pngsave_stream: (method)
|
* vips_pngsave_stream: (method)
|
||||||
* @in: image to save
|
* @in: image to save
|
||||||
* @output: save image to this stream
|
* @streamo: save image to this stream
|
||||||
* @...: %NULL-terminated list of optional named arguments
|
* @...: %NULL-terminated list of optional named arguments
|
||||||
*
|
*
|
||||||
* Optional arguments:
|
* Optional arguments:
|
||||||
@ -522,13 +522,13 @@ 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, VipsStreamo *output, ... )
|
vips_pngsave_stream( VipsImage *in, VipsStreamo *streamo, ... )
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
va_start( ap, output );
|
va_start( ap, streamo );
|
||||||
result = vips_call_split( "pngsave_stream", ap, in, output );
|
result = vips_call_split( "pngsave_stream", ap, in, streamo );
|
||||||
va_end( ap );
|
va_end( ap );
|
||||||
|
|
||||||
return( result );
|
return( result );
|
||||||
|
@ -977,7 +977,7 @@ vips__rad_load( VipsStreami *streami, VipsImage *out )
|
|||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
VipsImage *in;
|
VipsImage *in;
|
||||||
VipsStreamo *output;
|
VipsStreamo *streamo;
|
||||||
|
|
||||||
char format[256];
|
char format[256];
|
||||||
double expos;
|
double expos;
|
||||||
@ -992,13 +992,13 @@ static void
|
|||||||
write_destroy( Write *write )
|
write_destroy( Write *write )
|
||||||
{
|
{
|
||||||
VIPS_FREE( write->line );
|
VIPS_FREE( write->line );
|
||||||
VIPS_UNREF( write->output );
|
VIPS_UNREF( write->streamo );
|
||||||
|
|
||||||
vips_free( write );
|
vips_free( write );
|
||||||
}
|
}
|
||||||
|
|
||||||
static Write *
|
static Write *
|
||||||
write_new( VipsImage *in, VipsStreamo *output )
|
write_new( VipsImage *in, VipsStreamo *streamo )
|
||||||
{
|
{
|
||||||
Write *write;
|
Write *write;
|
||||||
int i;
|
int i;
|
||||||
@ -1007,8 +1007,8 @@ write_new( VipsImage *in, VipsStreamo *output )
|
|||||||
return( NULL );
|
return( NULL );
|
||||||
|
|
||||||
write->in = in;
|
write->in = in;
|
||||||
write->output = output;
|
write->streamo = streamo;
|
||||||
g_object_ref( output );
|
g_object_ref( streamo );
|
||||||
|
|
||||||
strcpy( write->format, COLRFMT );
|
strcpy( write->format, COLRFMT );
|
||||||
write->expos = 1.0;
|
write->expos = 1.0;
|
||||||
@ -1082,25 +1082,25 @@ vips2rad_put_header( Write *write )
|
|||||||
{
|
{
|
||||||
vips2rad_make_header( write );
|
vips2rad_make_header( write );
|
||||||
|
|
||||||
vips_streamo_writef( write->output, "#?RADIANCE\n" );
|
vips_streamo_writef( write->streamo, "#?RADIANCE\n" );
|
||||||
vips_streamo_writef( write->output, "%s%s\n", FMTSTR, write->format );
|
vips_streamo_writef( write->streamo, "%s%s\n", FMTSTR, write->format );
|
||||||
vips_streamo_writef( write->output, "%s%e\n", EXPOSSTR, write->expos );
|
vips_streamo_writef( write->streamo, "%s%e\n", EXPOSSTR, write->expos );
|
||||||
vips_streamo_writef( write->output,
|
vips_streamo_writef( write->streamo,
|
||||||
"%s %f %f %f\n", COLCORSTR,
|
"%s %f %f %f\n", COLCORSTR,
|
||||||
write->colcor[RED], write->colcor[GRN], write->colcor[BLU] );
|
write->colcor[RED], write->colcor[GRN], write->colcor[BLU] );
|
||||||
vips_streamo_writef( write->output,
|
vips_streamo_writef( write->streamo,
|
||||||
"SOFTWARE=vips %s\n", vips_version_string() );
|
"SOFTWARE=vips %s\n", vips_version_string() );
|
||||||
vips_streamo_writef( write->output,
|
vips_streamo_writef( write->streamo,
|
||||||
"%s%f\n", ASPECTSTR, write->aspect );
|
"%s%f\n", ASPECTSTR, write->aspect );
|
||||||
vips_streamo_writef( write->output,
|
vips_streamo_writef( write->streamo,
|
||||||
"%s %.4f %.4f %.4f %.4f %.4f %.4f %.4f %.4f\n",
|
"%s %.4f %.4f %.4f %.4f %.4f %.4f %.4f %.4f\n",
|
||||||
PRIMARYSTR,
|
PRIMARYSTR,
|
||||||
write->prims[RED][CIEX], write->prims[RED][CIEY],
|
write->prims[RED][CIEX], write->prims[RED][CIEY],
|
||||||
write->prims[GRN][CIEX], write->prims[GRN][CIEY],
|
write->prims[GRN][CIEX], write->prims[GRN][CIEY],
|
||||||
write->prims[BLU][CIEX], write->prims[BLU][CIEY],
|
write->prims[BLU][CIEX], write->prims[BLU][CIEY],
|
||||||
write->prims[WHT][CIEX], write->prims[WHT][CIEY] );
|
write->prims[WHT][CIEX], write->prims[WHT][CIEY] );
|
||||||
vips_streamo_writef( write->output, "\n" );
|
vips_streamo_writef( write->streamo, "\n" );
|
||||||
vips_streamo_writef( write->output,
|
vips_streamo_writef( write->streamo,
|
||||||
"%s", resolu2str( resolu_buf, &write->rs ) );
|
"%s", resolu2str( resolu_buf, &write->rs ) );
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
@ -1115,7 +1115,7 @@ scanline_write( Write *write, COLR *scanline, int width )
|
|||||||
width > MAXELEN ) {
|
width > MAXELEN ) {
|
||||||
/* Too large or small for RLE ... do a simple write.
|
/* Too large or small for RLE ... do a simple write.
|
||||||
*/
|
*/
|
||||||
if( vips_streamo_write( write->output,
|
if( vips_streamo_write( write->streamo,
|
||||||
scanline, sizeof( COLR ) * width ) )
|
scanline, sizeof( COLR ) * width ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
@ -1126,7 +1126,7 @@ scanline_write( Write *write, COLR *scanline, int width )
|
|||||||
*/
|
*/
|
||||||
rle_scanline_write( scanline, width, write->line, &length );
|
rle_scanline_write( scanline, width, write->line, &length );
|
||||||
|
|
||||||
if( vips_streamo_write( write->output, write->line, length ) )
|
if( vips_streamo_write( write->streamo, write->line, length ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1159,7 +1159,7 @@ vips2rad_put_data( Write *write )
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
vips__rad_save( VipsImage *in, VipsStreamo *output )
|
vips__rad_save( VipsImage *in, VipsStreamo *streamo )
|
||||||
{
|
{
|
||||||
Write *write;
|
Write *write;
|
||||||
|
|
||||||
@ -1170,7 +1170,7 @@ vips__rad_save( VipsImage *in, VipsStreamo *output )
|
|||||||
if( vips_image_pio_input( in ) ||
|
if( vips_image_pio_input( in ) ||
|
||||||
vips_check_coding_rad( "vips2rad", in ) )
|
vips_check_coding_rad( "vips2rad", in ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
if( !(write = write_new( in, output )) )
|
if( !(write = write_new( in, streamo )) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
if( vips2rad_put_header( write ) ||
|
if( vips2rad_put_header( write ) ||
|
||||||
@ -1179,7 +1179,7 @@ vips__rad_save( VipsImage *in, VipsStreamo *output )
|
|||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
vips_streamo_finish( output );
|
vips_streamo_finish( streamo );
|
||||||
|
|
||||||
write_destroy( write );
|
write_destroy( write );
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ typedef struct _VipsForeignLoadRadStream {
|
|||||||
|
|
||||||
/* Load from a stream.
|
/* Load from a stream.
|
||||||
*/
|
*/
|
||||||
VipsStreami *input;
|
VipsStreami *streami;
|
||||||
|
|
||||||
} VipsForeignLoadRadStream;
|
} VipsForeignLoadRadStream;
|
||||||
|
|
||||||
@ -79,7 +79,7 @@ vips_foreign_load_rad_stream_header( VipsForeignLoad *load )
|
|||||||
{
|
{
|
||||||
VipsForeignLoadRadStream *stream = (VipsForeignLoadRadStream *) load;
|
VipsForeignLoadRadStream *stream = (VipsForeignLoadRadStream *) load;
|
||||||
|
|
||||||
if( vips__rad_header( stream->input, load->out ) )
|
if( vips__rad_header( stream->streami, load->out ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
@ -90,7 +90,7 @@ vips_foreign_load_rad_stream_load( VipsForeignLoad *load )
|
|||||||
{
|
{
|
||||||
VipsForeignLoadRadStream *stream = (VipsForeignLoadRadStream *) load;
|
VipsForeignLoadRadStream *stream = (VipsForeignLoadRadStream *) load;
|
||||||
|
|
||||||
if( vips__rad_load( stream->input, load->real ) )
|
if( vips__rad_load( stream->streami, load->real ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
@ -114,11 +114,11 @@ vips_foreign_load_rad_stream_class_init( VipsForeignLoadRadStreamClass *class )
|
|||||||
load_class->header = vips_foreign_load_rad_stream_header;
|
load_class->header = vips_foreign_load_rad_stream_header;
|
||||||
load_class->load = vips_foreign_load_rad_stream_load;
|
load_class->load = vips_foreign_load_rad_stream_load;
|
||||||
|
|
||||||
VIPS_ARG_OBJECT( class, "input", 1,
|
VIPS_ARG_OBJECT( class, "streami", 1,
|
||||||
_( "Input" ),
|
_( "Streami" ),
|
||||||
_( "Stream to load from" ),
|
_( "Stream to load from" ),
|
||||||
VIPS_ARGUMENT_REQUIRED_INPUT,
|
VIPS_ARGUMENT_REQUIRED_INPUT,
|
||||||
G_STRUCT_OFFSET( VipsForeignLoadRadStream, input ),
|
G_STRUCT_OFFSET( VipsForeignLoadRadStream, streami ),
|
||||||
VIPS_TYPE_STREAMI );
|
VIPS_TYPE_STREAMI );
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -265,13 +265,13 @@ G_DEFINE_TYPE( VipsForeignLoadRadBuffer, vips_foreign_load_rad_buffer,
|
|||||||
static gboolean
|
static gboolean
|
||||||
vips_foreign_load_rad_buffer_is_a_buffer( const void *buf, size_t len )
|
vips_foreign_load_rad_buffer_is_a_buffer( const void *buf, size_t len )
|
||||||
{
|
{
|
||||||
VipsStreami *input;
|
VipsStreami *streami;
|
||||||
gboolean result;
|
gboolean result;
|
||||||
|
|
||||||
if( !(input = vips_streami_new_from_memory( buf, len )) )
|
if( !(streami = vips_streami_new_from_memory( buf, len )) )
|
||||||
return( FALSE );
|
return( FALSE );
|
||||||
result = vips__rad_israd( input );
|
result = vips__rad_israd( streami );
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( streami );
|
||||||
|
|
||||||
return( result );
|
return( result );
|
||||||
}
|
}
|
||||||
@ -289,16 +289,16 @@ vips_foreign_load_rad_buffer_header( VipsForeignLoad *load )
|
|||||||
{
|
{
|
||||||
VipsForeignLoadRadBuffer *buffer = (VipsForeignLoadRadBuffer *) load;
|
VipsForeignLoadRadBuffer *buffer = (VipsForeignLoadRadBuffer *) load;
|
||||||
|
|
||||||
VipsStreami *input;
|
VipsStreami *streami;
|
||||||
|
|
||||||
if( !(input = vips_streami_new_from_memory( buffer->buf->data,
|
if( !(streami = vips_streami_new_from_memory( buffer->buf->data,
|
||||||
buffer->buf->length )) )
|
buffer->buf->length )) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
if( vips__rad_header( input, load->out ) ) {
|
if( vips__rad_header( streami, load->out ) ) {
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( streami );
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( streami );
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
@ -308,16 +308,16 @@ vips_foreign_load_rad_buffer_load( VipsForeignLoad *load )
|
|||||||
{
|
{
|
||||||
VipsForeignLoadRadBuffer *buffer = (VipsForeignLoadRadBuffer *) load;
|
VipsForeignLoadRadBuffer *buffer = (VipsForeignLoadRadBuffer *) load;
|
||||||
|
|
||||||
VipsStreami *input;
|
VipsStreami *streami;
|
||||||
|
|
||||||
if( !(input = vips_streami_new_from_memory( buffer->buf->data,
|
if( !(streami = vips_streami_new_from_memory( buffer->buf->data,
|
||||||
buffer->buf->length )) )
|
buffer->buf->length )) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
if( vips__rad_load( input, load->real ) ) {
|
if( vips__rad_load( streami, load->real ) ) {
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( streami );
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( streami );
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
@ -431,7 +431,7 @@ vips_radload_buffer( void *buf, size_t len, VipsImage **out, ... )
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* vips_radload_stream:
|
* vips_radload_stream:
|
||||||
* @input: stream to load from
|
* @streami: stream to load from
|
||||||
* @out: (out): output image
|
* @out: (out): output image
|
||||||
* @...: %NULL-terminated list of optional named arguments
|
* @...: %NULL-terminated list of optional named arguments
|
||||||
*
|
*
|
||||||
@ -442,13 +442,13 @@ vips_radload_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_radload_stream( VipsStreami *input, VipsImage **out, ... )
|
vips_radload_stream( VipsStreami *streami, VipsImage **out, ... )
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
va_start( ap, out );
|
va_start( ap, out );
|
||||||
result = vips_call_split( "radload_stream", ap, input, out );
|
result = vips_call_split( "radload_stream", ap, streami, out );
|
||||||
va_end( ap );
|
va_end( ap );
|
||||||
|
|
||||||
return( result );
|
return( result );
|
||||||
|
@ -122,19 +122,19 @@ vips_foreign_save_rad_file_build( VipsObject *object )
|
|||||||
VipsForeignSave *save = (VipsForeignSave *) object;
|
VipsForeignSave *save = (VipsForeignSave *) object;
|
||||||
VipsForeignSaveRadFile *file = (VipsForeignSaveRadFile *) object;
|
VipsForeignSaveRadFile *file = (VipsForeignSaveRadFile *) object;
|
||||||
|
|
||||||
VipsStreamo *output;
|
VipsStreamo *streamo;
|
||||||
|
|
||||||
if( VIPS_OBJECT_CLASS( vips_foreign_save_rad_file_parent_class )->
|
if( VIPS_OBJECT_CLASS( vips_foreign_save_rad_file_parent_class )->
|
||||||
build( object ) )
|
build( object ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
if( !(output = vips_streamo_new_to_filename( file->filename )) )
|
if( !(streamo = vips_streamo_new_to_filename( file->filename )) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
if( vips__rad_save( save->ready, output ) ) {
|
if( vips__rad_save( save->ready, streamo ) ) {
|
||||||
VIPS_UNREF( output );
|
VIPS_UNREF( streamo );
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
VIPS_UNREF( output );
|
VIPS_UNREF( streamo );
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
@ -168,7 +168,7 @@ vips_foreign_save_rad_file_init( VipsForeignSaveRadFile *file )
|
|||||||
typedef struct _VipsForeignSaveRadStream {
|
typedef struct _VipsForeignSaveRadStream {
|
||||||
VipsForeignSaveRad parent_object;
|
VipsForeignSaveRad parent_object;
|
||||||
|
|
||||||
VipsStreamo *output;
|
VipsStreamo *streamo;
|
||||||
} VipsForeignSaveRadStream;
|
} VipsForeignSaveRadStream;
|
||||||
|
|
||||||
typedef VipsForeignSaveRadClass VipsForeignSaveRadStreamClass;
|
typedef VipsForeignSaveRadClass VipsForeignSaveRadStreamClass;
|
||||||
@ -186,7 +186,7 @@ vips_foreign_save_rad_stream_build( VipsObject *object )
|
|||||||
build( object ) )
|
build( object ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
if( vips__rad_save( save->ready, stream->output ) )
|
if( vips__rad_save( save->ready, stream->streamo ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
@ -205,11 +205,11 @@ vips_foreign_save_rad_stream_class_init( VipsForeignSaveRadStreamClass *class )
|
|||||||
object_class->description = _( "save image to Radiance stream" );
|
object_class->description = _( "save image to Radiance stream" );
|
||||||
object_class->build = vips_foreign_save_rad_stream_build;
|
object_class->build = vips_foreign_save_rad_stream_build;
|
||||||
|
|
||||||
VIPS_ARG_OBJECT( class, "output", 1,
|
VIPS_ARG_OBJECT( class, "streamo", 1,
|
||||||
_( "Output" ),
|
_( "Streamo" ),
|
||||||
_( "Stream to save to" ),
|
_( "Stream to save to" ),
|
||||||
VIPS_ARGUMENT_REQUIRED_INPUT,
|
VIPS_ARGUMENT_REQUIRED_INPUT,
|
||||||
G_STRUCT_OFFSET( VipsForeignSaveRadStream, output ),
|
G_STRUCT_OFFSET( VipsForeignSaveRadStream, streamo ),
|
||||||
VIPS_TYPE_STREAMO );
|
VIPS_TYPE_STREAMO );
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -235,26 +235,26 @@ vips_foreign_save_rad_buffer_build( VipsObject *object )
|
|||||||
{
|
{
|
||||||
VipsForeignSave *save = (VipsForeignSave *) object;
|
VipsForeignSave *save = (VipsForeignSave *) object;
|
||||||
|
|
||||||
VipsStreamo *output;
|
VipsStreamo *streamo;
|
||||||
VipsBlob *blob;
|
VipsBlob *blob;
|
||||||
|
|
||||||
if( VIPS_OBJECT_CLASS( vips_foreign_save_rad_buffer_parent_class )->
|
if( VIPS_OBJECT_CLASS( vips_foreign_save_rad_buffer_parent_class )->
|
||||||
build( object ) )
|
build( object ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
if( !(output = vips_streamo_new_to_memory()) )
|
if( !(streamo = vips_streamo_new_to_memory()) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
if( vips__rad_save( save->ready, output ) ) {
|
if( vips__rad_save( save->ready, streamo ) ) {
|
||||||
VIPS_UNREF( output );
|
VIPS_UNREF( streamo );
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
g_object_get( output, "blob", &blob, NULL );
|
g_object_get( streamo, "blob", &blob, NULL );
|
||||||
g_object_set( save, "buffer", blob, NULL );
|
g_object_set( save, "buffer", blob, NULL );
|
||||||
vips_area_unref( VIPS_AREA( blob ) );
|
vips_area_unref( VIPS_AREA( blob ) );
|
||||||
|
|
||||||
VIPS_UNREF( output );
|
VIPS_UNREF( streamo );
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
@ -362,7 +362,7 @@ vips_radsave_buffer( VipsImage *in, void **buf, size_t *len, ... )
|
|||||||
/**
|
/**
|
||||||
* vips_radsave_stream: (method)
|
* vips_radsave_stream: (method)
|
||||||
* @in: image to save
|
* @in: image to save
|
||||||
* @output: save image to this stream
|
* @streamo: save image to this stream
|
||||||
* @...: %NULL-terminated list of optional named arguments
|
* @...: %NULL-terminated list of optional named arguments
|
||||||
*
|
*
|
||||||
* As vips_radsave(), but save to a stream.
|
* As vips_radsave(), but save to a stream.
|
||||||
@ -372,13 +372,13 @@ vips_radsave_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_radsave_stream( VipsImage *in, VipsStreamo *output, ... )
|
vips_radsave_stream( VipsImage *in, VipsStreamo *streamo, ... )
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
va_start( ap, output );
|
va_start( ap, streamo );
|
||||||
result = vips_call_split( "radsave_stream", ap, in, output );
|
result = vips_call_split( "radsave_stream", ap, in, streamo );
|
||||||
va_end( ap );
|
va_end( ap );
|
||||||
|
|
||||||
return( result );
|
return( result );
|
||||||
|
@ -461,7 +461,7 @@ typedef struct _VipsForeignLoadSvgStream {
|
|||||||
|
|
||||||
/* Load from a stream.
|
/* Load from a stream.
|
||||||
*/
|
*/
|
||||||
VipsStreami *input;
|
VipsStreami *streami;
|
||||||
|
|
||||||
} VipsForeignLoadSvgStream;
|
} VipsForeignLoadSvgStream;
|
||||||
|
|
||||||
@ -471,12 +471,12 @@ G_DEFINE_TYPE( VipsForeignLoadSvgStream, vips_foreign_load_svg_stream,
|
|||||||
vips_foreign_load_svg_get_type() );
|
vips_foreign_load_svg_get_type() );
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
vips_foreign_load_svg_stream_is_a( VipsStreami *input )
|
vips_foreign_load_svg_stream_is_a( VipsStreami *streami )
|
||||||
{
|
{
|
||||||
unsigned char *data;
|
unsigned char *data;
|
||||||
size_t bytes_read;
|
size_t bytes_read;
|
||||||
|
|
||||||
if( (bytes_read = vips_streami_sniff_at_most( input,
|
if( (bytes_read = vips_streami_sniff_at_most( streami,
|
||||||
&data, SVG_HEADER_SIZE )) <= 0 )
|
&data, SVG_HEADER_SIZE )) <= 0 )
|
||||||
return( FALSE );
|
return( FALSE );
|
||||||
|
|
||||||
@ -495,10 +495,10 @@ vips_foreign_load_svg_stream_header( VipsForeignLoad *load )
|
|||||||
|
|
||||||
GInputStream *gstream;
|
GInputStream *gstream;
|
||||||
|
|
||||||
if( vips_streami_rewind( stream->input ) )
|
if( vips_streami_rewind( stream->streami ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
gstream = g_input_stream_new_from_vips( stream->input );
|
gstream = g_input_stream_new_from_vips( stream->streami );
|
||||||
if( !(svg->page = rsvg_handle_new_from_stream_sync(
|
if( !(svg->page = rsvg_handle_new_from_stream_sync(
|
||||||
gstream, NULL, flags, NULL, &error )) ) {
|
gstream, NULL, flags, NULL, &error )) ) {
|
||||||
g_object_unref( gstream );
|
g_object_unref( gstream );
|
||||||
@ -515,9 +515,9 @@ vips_foreign_load_svg_stream_load( VipsForeignLoad *load )
|
|||||||
{
|
{
|
||||||
VipsForeignLoadSvgStream *stream = (VipsForeignLoadSvgStream *) load;
|
VipsForeignLoadSvgStream *stream = (VipsForeignLoadSvgStream *) load;
|
||||||
|
|
||||||
if( vips_streami_rewind( stream->input ) ||
|
if( vips_streami_rewind( stream->streami ) ||
|
||||||
vips_foreign_load_svg_load( load ) ||
|
vips_foreign_load_svg_load( load ) ||
|
||||||
vips_streami_decode( stream->input ) )
|
vips_streami_decode( stream->streami ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
@ -540,11 +540,11 @@ vips_foreign_load_svg_stream_class_init( VipsForeignLoadSvgStreamClass *class )
|
|||||||
load_class->header = vips_foreign_load_svg_stream_header;
|
load_class->header = vips_foreign_load_svg_stream_header;
|
||||||
load_class->load = vips_foreign_load_svg_stream_load;
|
load_class->load = vips_foreign_load_svg_stream_load;
|
||||||
|
|
||||||
VIPS_ARG_OBJECT( class, "input", 1,
|
VIPS_ARG_OBJECT( class, "streami", 1,
|
||||||
_( "Input" ),
|
_( "Streami" ),
|
||||||
_( "Stream to load from" ),
|
_( "Stream to load from" ),
|
||||||
VIPS_ARGUMENT_REQUIRED_INPUT,
|
VIPS_ARGUMENT_REQUIRED_INPUT,
|
||||||
G_STRUCT_OFFSET( VipsForeignLoadSvgStream, input ),
|
G_STRUCT_OFFSET( VipsForeignLoadSvgStream, streami ),
|
||||||
VIPS_TYPE_STREAMI );
|
VIPS_TYPE_STREAMI );
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -805,7 +805,7 @@ vips_svgload_buffer( void *buf, size_t len, VipsImage **out, ... )
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* vips_svgload_stream:
|
* vips_svgload_stream:
|
||||||
* @input: stream to load from
|
* @streami: stream to load from
|
||||||
* @out: (out): image to write
|
* @out: (out): image to write
|
||||||
* @...: %NULL-terminated list of optional named arguments
|
* @...: %NULL-terminated list of optional named arguments
|
||||||
*
|
*
|
||||||
@ -816,13 +816,13 @@ vips_svgload_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_svgload_stream( VipsStreami *input, VipsImage **out, ... )
|
vips_svgload_stream( VipsStreami *streami, VipsImage **out, ... )
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
va_start( ap, out );
|
va_start( ap, out );
|
||||||
result = vips_call_split( "svgload_stream", ap, input, out );
|
result = vips_call_split( "svgload_stream", ap, streami, out );
|
||||||
va_end( ap );
|
va_end( ap );
|
||||||
|
|
||||||
return( result );
|
return( 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 )
|
||||||
{
|
{
|
||||||
VipsStreami *input = VIPS_STREAMI( st );
|
VipsStreami *streami = VIPS_STREAMI( st );
|
||||||
|
|
||||||
return( vips_streami_read( input, data, size ) );
|
return( vips_streami_read( streami, data, size ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
static tsize_t
|
static tsize_t
|
||||||
@ -154,17 +154,17 @@ 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 )
|
||||||
{
|
{
|
||||||
VipsStreami *input = VIPS_STREAMI( st );
|
VipsStreami *streami = VIPS_STREAMI( st );
|
||||||
|
|
||||||
return( vips_streami_seek( input, position, whence ) );
|
return( vips_streami_seek( streami, position, whence ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
openin_stream_close( thandle_t st )
|
openin_stream_close( thandle_t st )
|
||||||
{
|
{
|
||||||
VipsStreami *input = VIPS_STREAMI( st );
|
VipsStreami *streami = VIPS_STREAMI( st );
|
||||||
|
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( streami );
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
@ -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 )
|
||||||
{
|
{
|
||||||
VipsStreami *input = VIPS_STREAMI( st );
|
VipsStreami *streami = 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_streami_size( input ) );
|
return( vips_streami_size( streami ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
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( VipsStreami *input )
|
vips__tiff_openin_stream( VipsStreami *streami )
|
||||||
{
|
{
|
||||||
TIFF *tiff;
|
TIFF *tiff;
|
||||||
|
|
||||||
@ -205,11 +205,11 @@ vips__tiff_openin_stream( VipsStreami *input )
|
|||||||
printf( "vips__tiff_openin_stream:\n" );
|
printf( "vips__tiff_openin_stream:\n" );
|
||||||
#endif /*DEBUG*/
|
#endif /*DEBUG*/
|
||||||
|
|
||||||
if( vips_streami_rewind( input ) )
|
if( vips_streami_rewind( streami ) )
|
||||||
return( NULL );
|
return( NULL );
|
||||||
|
|
||||||
if( !(tiff = TIFFClientOpen( "stream input", "rm",
|
if( !(tiff = TIFFClientOpen( "stream input", "rm",
|
||||||
(thandle_t) input,
|
(thandle_t) streami,
|
||||||
openin_stream_read,
|
openin_stream_read,
|
||||||
openin_stream_write,
|
openin_stream_write,
|
||||||
openin_stream_seek,
|
openin_stream_seek,
|
||||||
@ -224,7 +224,7 @@ vips__tiff_openin_stream( VipsStreami *input )
|
|||||||
|
|
||||||
/* Unreffed on close(), see above.
|
/* Unreffed on close(), see above.
|
||||||
*/
|
*/
|
||||||
g_object_ref( input );
|
g_object_ref( streami );
|
||||||
|
|
||||||
return( tiff );
|
return( tiff );
|
||||||
}
|
}
|
||||||
|
@ -37,13 +37,12 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif /*__cplusplus*/
|
#endif /*__cplusplus*/
|
||||||
|
|
||||||
TIFF *vips__tiff_openin_stream( VipsStreami *input );
|
TIFF *vips__tiff_openin_stream( VipsStreami *streami );
|
||||||
|
|
||||||
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,
|
||||||
gboolean bigtiff, void **out_data, size_t *out_length );
|
gboolean bigtiff, void **out_data, size_t *out_length );
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif /*__cplusplus*/
|
#endif /*__cplusplus*/
|
||||||
|
@ -300,7 +300,7 @@ typedef void (*scanline_process_fn)( struct _Rtiff *,
|
|||||||
typedef struct _Rtiff {
|
typedef struct _Rtiff {
|
||||||
/* Parameters.
|
/* Parameters.
|
||||||
*/
|
*/
|
||||||
VipsStreami *input;
|
VipsStreami *streami;
|
||||||
VipsImage *out;
|
VipsImage *out;
|
||||||
int page;
|
int page;
|
||||||
int n;
|
int n;
|
||||||
@ -488,7 +488,7 @@ static void
|
|||||||
rtiff_free( Rtiff *rtiff )
|
rtiff_free( Rtiff *rtiff )
|
||||||
{
|
{
|
||||||
VIPS_FREEF( TIFFClose, rtiff->tiff );
|
VIPS_FREEF( TIFFClose, rtiff->tiff );
|
||||||
VIPS_UNREF( rtiff->input );
|
VIPS_UNREF( rtiff->streami );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -500,12 +500,12 @@ rtiff_close_cb( VipsObject *object, Rtiff *rtiff )
|
|||||||
static void
|
static void
|
||||||
rtiff_minimise_cb( VipsImage *image, Rtiff *rtiff )
|
rtiff_minimise_cb( VipsImage *image, Rtiff *rtiff )
|
||||||
{
|
{
|
||||||
if( rtiff->input )
|
if( rtiff->streami )
|
||||||
vips_streami_minimise( rtiff->input );
|
vips_streami_minimise( rtiff->streami );
|
||||||
}
|
}
|
||||||
|
|
||||||
static Rtiff *
|
static Rtiff *
|
||||||
rtiff_new( VipsStreami *input, VipsImage *out,
|
rtiff_new( VipsStreami *streami, VipsImage *out,
|
||||||
int page, int n, gboolean autorotate )
|
int page, int n, gboolean autorotate )
|
||||||
{
|
{
|
||||||
Rtiff *rtiff;
|
Rtiff *rtiff;
|
||||||
@ -513,8 +513,8 @@ rtiff_new( VipsStreami *input, VipsImage *out,
|
|||||||
if( !(rtiff = VIPS_NEW( out, Rtiff )) )
|
if( !(rtiff = VIPS_NEW( out, Rtiff )) )
|
||||||
return( NULL );
|
return( NULL );
|
||||||
|
|
||||||
g_object_ref( input );
|
g_object_ref( streami );
|
||||||
rtiff->input = input;
|
rtiff->streami = streami;
|
||||||
rtiff->out = out;
|
rtiff->out = out;
|
||||||
rtiff->page = page;
|
rtiff->page = page;
|
||||||
rtiff->n = n;
|
rtiff->n = n;
|
||||||
@ -551,7 +551,7 @@ rtiff_new( VipsStreami *input, VipsImage *out,
|
|||||||
return( NULL );
|
return( NULL );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !(rtiff->tiff = vips__tiff_openin_stream( input )) )
|
if( !(rtiff->tiff = vips__tiff_openin_stream( streami )) )
|
||||||
return( NULL );
|
return( NULL );
|
||||||
|
|
||||||
return( rtiff );
|
return( rtiff );
|
||||||
@ -1369,7 +1369,7 @@ rtiff_set_header( Rtiff *rtiff, VipsImage *out )
|
|||||||
out->Ysize = rtiff->header.height * rtiff->n;
|
out->Ysize = rtiff->header.height * rtiff->n;
|
||||||
|
|
||||||
VIPS_SETSTR( out->filename,
|
VIPS_SETSTR( out->filename,
|
||||||
vips_stream_filename( VIPS_STREAM( rtiff->input ) ) );
|
vips_stream_filename( VIPS_STREAM( rtiff->streami ) ) );
|
||||||
|
|
||||||
if( rtiff->n > 1 )
|
if( rtiff->n > 1 )
|
||||||
vips_image_set_int( out,
|
vips_image_set_int( out,
|
||||||
@ -2383,14 +2383,14 @@ 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( VipsStreami *input, TiffPropertyFn fn )
|
vips__testtiff_stream( VipsStreami *streami, TiffPropertyFn fn )
|
||||||
{
|
{
|
||||||
TIFF *tif;
|
TIFF *tif;
|
||||||
gboolean property;
|
gboolean property;
|
||||||
|
|
||||||
vips__tiff_init();
|
vips__tiff_init();
|
||||||
|
|
||||||
if( !(tif = vips__tiff_openin_stream( input )) ) {
|
if( !(tif = vips__tiff_openin_stream( streami )) ) {
|
||||||
vips_error_clear();
|
vips_error_clear();
|
||||||
return( FALSE );
|
return( FALSE );
|
||||||
}
|
}
|
||||||
@ -2403,26 +2403,26 @@ vips__testtiff_stream( VipsStreami *input, TiffPropertyFn fn )
|
|||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
vips__istiff_stream( VipsStreami *input )
|
vips__istiff_stream( VipsStreami *streami )
|
||||||
{
|
{
|
||||||
return( vips__testtiff_stream( input, NULL ) );
|
return( vips__testtiff_stream( streami, NULL ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
vips__istifftiled_stream( VipsStreami *input )
|
vips__istifftiled_stream( VipsStreami *streami )
|
||||||
{
|
{
|
||||||
return( vips__testtiff_stream( input, TIFFIsTiled ) );
|
return( vips__testtiff_stream( streami, TIFFIsTiled ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
vips__tiff_read_header_stream( VipsStreami *input, VipsImage *out,
|
vips__tiff_read_header_stream( VipsStreami *streami, VipsImage *out,
|
||||||
int page, int n, gboolean autorotate )
|
int page, int n, gboolean autorotate )
|
||||||
{
|
{
|
||||||
Rtiff *rtiff;
|
Rtiff *rtiff;
|
||||||
|
|
||||||
vips__tiff_init();
|
vips__tiff_init();
|
||||||
|
|
||||||
if( !(rtiff = rtiff_new( input, out, page, n, autorotate )) ||
|
if( !(rtiff = rtiff_new( streami, out, page, n, autorotate )) ||
|
||||||
rtiff_header_read_all( rtiff ) )
|
rtiff_header_read_all( rtiff ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
@ -2434,13 +2434,13 @@ vips__tiff_read_header_stream( VipsStreami *input, VipsImage *out,
|
|||||||
/* We never call vips_streami_decode() since we need to be able to
|
/* We never call vips_streami_decode() since we need to be able to
|
||||||
* seek() the whole way through the file. Just minimise instead,
|
* seek() the whole way through the file. Just minimise instead,
|
||||||
*/
|
*/
|
||||||
vips_streami_minimise( input );
|
vips_streami_minimise( streami );
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
vips__tiff_read_stream( VipsStreami *input, VipsImage *out,
|
vips__tiff_read_stream( VipsStreami *streami, VipsImage *out,
|
||||||
int page, int n, gboolean autorotate )
|
int page, int n, gboolean autorotate )
|
||||||
{
|
{
|
||||||
Rtiff *rtiff;
|
Rtiff *rtiff;
|
||||||
@ -2452,7 +2452,7 @@ vips__tiff_read_stream( VipsStreami *input, VipsImage *out,
|
|||||||
|
|
||||||
vips__tiff_init();
|
vips__tiff_init();
|
||||||
|
|
||||||
if( !(rtiff = rtiff_new( input, out, page, n, autorotate )) ||
|
if( !(rtiff = rtiff_new( streami, out, page, n, autorotate )) ||
|
||||||
rtiff_header_read_all( rtiff ) )
|
rtiff_header_read_all( rtiff ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
@ -2468,7 +2468,7 @@ vips__tiff_read_stream( VipsStreami *input, VipsImage *out,
|
|||||||
/* We never call vips_streami_decode() since we need to be able to
|
/* We never call vips_streami_decode() since we need to be able to
|
||||||
* seek() the whole way through the file. Just minimise instead,
|
* seek() the whole way through the file. Just minimise instead,
|
||||||
*/
|
*/
|
||||||
vips_streami_minimise( input );
|
vips_streami_minimise( streami );
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
|
@ -141,13 +141,13 @@ 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 )
|
||||||
{
|
{
|
||||||
VipsStreami *input;
|
VipsStreami *streami;
|
||||||
gboolean result;
|
gboolean result;
|
||||||
|
|
||||||
if( !(input = vips_streami_new_from_filename( filename )) )
|
if( !(streami = vips_streami_new_from_filename( filename )) )
|
||||||
return( FALSE );
|
return( FALSE );
|
||||||
result = vips__istiff_stream( input );
|
result = vips__istiff_stream( streami );
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( streami );
|
||||||
|
|
||||||
return( result );
|
return( result );
|
||||||
}
|
}
|
||||||
@ -155,19 +155,19 @@ 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 )
|
||||||
{
|
{
|
||||||
VipsStreami *input;
|
VipsStreami *streami;
|
||||||
VipsForeignFlags flags;
|
VipsForeignFlags flags;
|
||||||
|
|
||||||
if( !(input = vips_streami_new_from_filename( filename )) )
|
if( !(streami = vips_streami_new_from_filename( filename )) )
|
||||||
return( 0 );
|
return( 0 );
|
||||||
|
|
||||||
flags = 0;
|
flags = 0;
|
||||||
if( vips__istifftiled_stream( input ) )
|
if( vips__istifftiled_stream( streami ) )
|
||||||
flags |= VIPS_FOREIGN_PARTIAL;
|
flags |= VIPS_FOREIGN_PARTIAL;
|
||||||
else
|
else
|
||||||
flags |= VIPS_FOREIGN_SEQUENTIAL;
|
flags |= VIPS_FOREIGN_SEQUENTIAL;
|
||||||
|
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( streami );
|
||||||
|
|
||||||
return( flags );
|
return( flags );
|
||||||
}
|
}
|
||||||
@ -187,16 +187,16 @@ vips_foreign_load_tiff_file_header( VipsForeignLoad *load )
|
|||||||
VipsForeignLoadTiff *tiff = (VipsForeignLoadTiff *) load;
|
VipsForeignLoadTiff *tiff = (VipsForeignLoadTiff *) load;
|
||||||
VipsForeignLoadTiffFile *file = (VipsForeignLoadTiffFile *) load;
|
VipsForeignLoadTiffFile *file = (VipsForeignLoadTiffFile *) load;
|
||||||
|
|
||||||
VipsStreami *input;
|
VipsStreami *streami;
|
||||||
|
|
||||||
if( !(input = vips_streami_new_from_filename( file->filename )) )
|
if( !(streami = 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( streami, load->out,
|
||||||
tiff->page, tiff->n, tiff->autorotate ) ) {
|
tiff->page, tiff->n, tiff->autorotate ) ) {
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( streami );
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( streami );
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
@ -207,16 +207,16 @@ vips_foreign_load_tiff_file_load( VipsForeignLoad *load )
|
|||||||
VipsForeignLoadTiff *tiff = (VipsForeignLoadTiff *) load;
|
VipsForeignLoadTiff *tiff = (VipsForeignLoadTiff *) load;
|
||||||
VipsForeignLoadTiffFile *file = (VipsForeignLoadTiffFile *) load;
|
VipsForeignLoadTiffFile *file = (VipsForeignLoadTiffFile *) load;
|
||||||
|
|
||||||
VipsStreami *input;
|
VipsStreami *streami;
|
||||||
|
|
||||||
if( !(input = vips_streami_new_from_filename( file->filename )) )
|
if( !(streami = vips_streami_new_from_filename( file->filename )) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
if( vips__tiff_read_stream( input, load->real,
|
if( vips__tiff_read_stream( streami, load->real,
|
||||||
tiff->page, tiff->n, tiff->autorotate ) ) {
|
tiff->page, tiff->n, tiff->autorotate ) ) {
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( streami );
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( streami );
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
@ -280,13 +280,13 @@ 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 )
|
||||||
{
|
{
|
||||||
VipsStreami *input;
|
VipsStreami *streami;
|
||||||
gboolean result;
|
gboolean result;
|
||||||
|
|
||||||
if( !(input = vips_streami_new_from_memory( buf, len )) )
|
if( !(streami = vips_streami_new_from_memory( buf, len )) )
|
||||||
return( FALSE );
|
return( FALSE );
|
||||||
result = vips__istiff_stream( input );
|
result = vips__istiff_stream( streami );
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( streami );
|
||||||
|
|
||||||
return( result );
|
return( result );
|
||||||
}
|
}
|
||||||
@ -296,18 +296,18 @@ vips_foreign_load_tiff_buffer_get_flags( VipsForeignLoad *load )
|
|||||||
{
|
{
|
||||||
VipsForeignLoadTiffBuffer *buffer = (VipsForeignLoadTiffBuffer *) load;
|
VipsForeignLoadTiffBuffer *buffer = (VipsForeignLoadTiffBuffer *) load;
|
||||||
|
|
||||||
VipsStreami *input;
|
VipsStreami *streami;
|
||||||
VipsForeignFlags flags;
|
VipsForeignFlags flags;
|
||||||
|
|
||||||
if( !(input = vips_streami_new_from_memory(
|
if( !(streami = 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;
|
||||||
if( vips__istifftiled_stream( input ) )
|
if( vips__istifftiled_stream( streami ) )
|
||||||
flags |= VIPS_FOREIGN_PARTIAL;
|
flags |= VIPS_FOREIGN_PARTIAL;
|
||||||
else
|
else
|
||||||
flags |= VIPS_FOREIGN_SEQUENTIAL;
|
flags |= VIPS_FOREIGN_SEQUENTIAL;
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( streami );
|
||||||
|
|
||||||
return( flags );
|
return( flags );
|
||||||
}
|
}
|
||||||
@ -318,17 +318,17 @@ vips_foreign_load_tiff_buffer_header( VipsForeignLoad *load )
|
|||||||
VipsForeignLoadTiff *tiff = (VipsForeignLoadTiff *) load;
|
VipsForeignLoadTiff *tiff = (VipsForeignLoadTiff *) load;
|
||||||
VipsForeignLoadTiffBuffer *buffer = (VipsForeignLoadTiffBuffer *) load;
|
VipsForeignLoadTiffBuffer *buffer = (VipsForeignLoadTiffBuffer *) load;
|
||||||
|
|
||||||
VipsStreami *input;
|
VipsStreami *streami;
|
||||||
|
|
||||||
if( !(input = vips_streami_new_from_memory(
|
if( !(streami = 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( streami, load->out,
|
||||||
tiff->page, tiff->n, tiff->autorotate ) ) {
|
tiff->page, tiff->n, tiff->autorotate ) ) {
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( streami );
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( streami );
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
@ -339,17 +339,17 @@ vips_foreign_load_tiff_buffer_load( VipsForeignLoad *load )
|
|||||||
VipsForeignLoadTiff *tiff = (VipsForeignLoadTiff *) load;
|
VipsForeignLoadTiff *tiff = (VipsForeignLoadTiff *) load;
|
||||||
VipsForeignLoadTiffBuffer *buffer = (VipsForeignLoadTiffBuffer *) load;
|
VipsForeignLoadTiffBuffer *buffer = (VipsForeignLoadTiffBuffer *) load;
|
||||||
|
|
||||||
VipsStreami *input;
|
VipsStreami *streami;
|
||||||
|
|
||||||
if( !(input = vips_streami_new_from_memory(
|
if( !(streami = 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( streami, load->real,
|
||||||
tiff->page, tiff->n, tiff->autorotate ) ) {
|
tiff->page, tiff->n, tiff->autorotate ) ) {
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( streami );
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( streami );
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
@ -391,7 +391,7 @@ typedef struct _VipsForeignLoadTiffStream {
|
|||||||
|
|
||||||
/* Load from a stream.
|
/* Load from a stream.
|
||||||
*/
|
*/
|
||||||
VipsStreami *input;
|
VipsStreami *streami;
|
||||||
|
|
||||||
} VipsForeignLoadTiffStream;
|
} VipsForeignLoadTiffStream;
|
||||||
|
|
||||||
@ -408,7 +408,7 @@ vips_foreign_load_tiff_stream_get_flags( VipsForeignLoad *load )
|
|||||||
VipsForeignFlags flags;
|
VipsForeignFlags flags;
|
||||||
|
|
||||||
flags = 0;
|
flags = 0;
|
||||||
if( vips__istifftiled_stream( stream->input ) )
|
if( vips__istifftiled_stream( stream->streami ) )
|
||||||
flags |= VIPS_FOREIGN_PARTIAL;
|
flags |= VIPS_FOREIGN_PARTIAL;
|
||||||
else
|
else
|
||||||
flags |= VIPS_FOREIGN_SEQUENTIAL;
|
flags |= VIPS_FOREIGN_SEQUENTIAL;
|
||||||
@ -422,7 +422,7 @@ vips_foreign_load_tiff_stream_header( VipsForeignLoad *load )
|
|||||||
VipsForeignLoadTiff *tiff = (VipsForeignLoadTiff *) load;
|
VipsForeignLoadTiff *tiff = (VipsForeignLoadTiff *) load;
|
||||||
VipsForeignLoadTiffStream *stream = (VipsForeignLoadTiffStream *) load;
|
VipsForeignLoadTiffStream *stream = (VipsForeignLoadTiffStream *) load;
|
||||||
|
|
||||||
if( vips__tiff_read_header_stream( stream->input, load->out,
|
if( vips__tiff_read_header_stream( stream->streami, load->out,
|
||||||
tiff->page, tiff->n, tiff->autorotate ) )
|
tiff->page, tiff->n, tiff->autorotate ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
@ -435,7 +435,7 @@ vips_foreign_load_tiff_stream_load( VipsForeignLoad *load )
|
|||||||
VipsForeignLoadTiff *tiff = (VipsForeignLoadTiff *) load;
|
VipsForeignLoadTiff *tiff = (VipsForeignLoadTiff *) load;
|
||||||
VipsForeignLoadTiffStream *stream = (VipsForeignLoadTiffStream *) load;
|
VipsForeignLoadTiffStream *stream = (VipsForeignLoadTiffStream *) load;
|
||||||
|
|
||||||
if( vips__tiff_read_stream( stream->input, load->real,
|
if( vips__tiff_read_stream( stream->streami, load->real,
|
||||||
tiff->page, tiff->n, tiff->autorotate ) )
|
tiff->page, tiff->n, tiff->autorotate ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
@ -461,11 +461,11 @@ vips_foreign_load_tiff_stream_class_init(
|
|||||||
load_class->header = vips_foreign_load_tiff_stream_header;
|
load_class->header = vips_foreign_load_tiff_stream_header;
|
||||||
load_class->load = vips_foreign_load_tiff_stream_load;
|
load_class->load = vips_foreign_load_tiff_stream_load;
|
||||||
|
|
||||||
VIPS_ARG_OBJECT( class, "input", 1,
|
VIPS_ARG_OBJECT( class, "streami", 1,
|
||||||
_( "Input" ),
|
_( "Streami" ),
|
||||||
_( "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, streami ),
|
||||||
VIPS_TYPE_STREAMI );
|
VIPS_TYPE_STREAMI );
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -584,7 +584,7 @@ vips_tiffload_buffer( void *buf, size_t len, VipsImage **out, ... )
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* vips_tiffload_stream:
|
* vips_tiffload_stream:
|
||||||
* @input: stream to load
|
* @streami: stream to load
|
||||||
* @out: (out): image to write
|
* @out: (out): image to write
|
||||||
* @...: %NULL-terminated list of optional named arguments
|
* @...: %NULL-terminated list of optional named arguments
|
||||||
*
|
*
|
||||||
@ -602,13 +602,13 @@ 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( VipsStreami *input, VipsImage **out, ... )
|
vips_tiffload_stream( VipsStreami *streami, VipsImage **out, ... )
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
va_start( ap, out );
|
va_start( ap, out );
|
||||||
result = vips_call_split( "tiffload_stream", ap, input, out );
|
result = vips_call_split( "tiffload_stream", ap, streami, out );
|
||||||
va_end( ap );
|
va_end( ap );
|
||||||
|
|
||||||
return( result );
|
return( result );
|
||||||
|
@ -693,7 +693,7 @@ typedef struct {
|
|||||||
|
|
||||||
/* Build the output area here.
|
/* Build the output area here.
|
||||||
*/
|
*/
|
||||||
VipsStreamo *output;
|
VipsStreamo *streamo;
|
||||||
|
|
||||||
/* 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_streamo_write( dest->output,
|
if( vips_streamo_write( dest->streamo,
|
||||||
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_streamo_write( dest->output,
|
if( vips_streamo_write( dest->streamo,
|
||||||
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_streamo_finish( dest->output );
|
vips_streamo_finish( dest->streamo );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set dest to one of our objects.
|
/* Set dest to one of our objects.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
stream_dest( j_compress_ptr cinfo, VipsStreamo *output )
|
stream_dest( j_compress_ptr cinfo, VipsStreamo *streamo )
|
||||||
{
|
{
|
||||||
Dest *dest;
|
Dest *dest;
|
||||||
|
|
||||||
@ -761,11 +761,11 @@ stream_dest( j_compress_ptr cinfo, VipsStreamo *output )
|
|||||||
dest->pub.init_destination = init_destination;
|
dest->pub.init_destination = init_destination;
|
||||||
dest->pub.empty_output_buffer = empty_output_buffer;
|
dest->pub.empty_output_buffer = empty_output_buffer;
|
||||||
dest->pub.term_destination = term_destination;
|
dest->pub.term_destination = term_destination;
|
||||||
dest->output = output;
|
dest->streamo = streamo;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
vips__jpeg_write_stream( VipsImage *in, VipsStreamo *output,
|
vips__jpeg_write_stream( VipsImage *in, VipsStreamo *streamo,
|
||||||
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,
|
||||||
@ -789,7 +789,7 @@ vips__jpeg_write_stream( VipsImage *in, VipsStreamo *output,
|
|||||||
|
|
||||||
/* Attach output.
|
/* Attach output.
|
||||||
*/
|
*/
|
||||||
stream_dest( &write->cinfo, output );
|
stream_dest( &write->cinfo, streamo );
|
||||||
|
|
||||||
/* Convert! Write errors come back here as an error return.
|
/* Convert! Write errors come back here as an error return.
|
||||||
*/
|
*/
|
||||||
|
@ -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 ) {
|
||||||
VipsStreami *input;
|
VipsStreami *streami;
|
||||||
TIFF *in;
|
TIFF *in;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
@ -1721,22 +1721,22 @@ wtiff_gather( Wtiff *wtiff )
|
|||||||
#endif /*DEBUG*/
|
#endif /*DEBUG*/
|
||||||
|
|
||||||
if( layer->lname ) {
|
if( layer->lname ) {
|
||||||
if( !(input =
|
if( !(streami =
|
||||||
vips_streami_new_from_filename(
|
vips_streami_new_from_filename(
|
||||||
layer->lname )) )
|
layer->lname )) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if( !(input = vips_streami_new_from_memory(
|
if( !(streami = vips_streami_new_from_memory(
|
||||||
layer->buf, layer->len )) )
|
layer->buf, layer->len )) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !(in = vips__tiff_openin_stream( input )) ) {
|
if( !(in = vips__tiff_openin_stream( streami )) ) {
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( streami );
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( streami );
|
||||||
|
|
||||||
if( wtiff_copy_tiff( wtiff, wtiff->layer->tif, in ) ) {
|
if( wtiff_copy_tiff( wtiff, wtiff->layer->tif, in ) ) {
|
||||||
TIFFClose( in );
|
TIFFClose( in );
|
||||||
|
@ -510,7 +510,7 @@ vips_webp_add_metadata( VipsWebPWrite *write, VipsImage *image, gboolean strip )
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
vips__webp_write_stream( VipsImage *image, VipsStreamo *output,
|
vips__webp_write_stream( VipsImage *image, VipsStreamo *streamo,
|
||||||
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, VipsStreamo *output,
|
|||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( vips_streamo_write( output,
|
if( vips_streamo_write( streamo,
|
||||||
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_streamo_finish( output );
|
vips_streamo_finish( streamo );
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
VipsStreami *input;
|
VipsStreami *streami;
|
||||||
|
|
||||||
/* 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.
|
||||||
@ -195,7 +195,7 @@ read_destroy( Read *read )
|
|||||||
|
|
||||||
if( read->pPng )
|
if( read->pPng )
|
||||||
png_destroy_read_struct( &read->pPng, &read->pInfo, NULL );
|
png_destroy_read_struct( &read->pPng, &read->pInfo, NULL );
|
||||||
VIPS_UNREF( read->input );
|
VIPS_UNREF( read->streami );
|
||||||
VIPS_FREE( read->row_pointer );
|
VIPS_FREE( read->row_pointer );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,8 +208,8 @@ read_close_cb( VipsImage *out, Read *read )
|
|||||||
static void
|
static void
|
||||||
read_minimise_cb( VipsImage *image, Read *read )
|
read_minimise_cb( VipsImage *image, Read *read )
|
||||||
{
|
{
|
||||||
if( read->input )
|
if( read->streami )
|
||||||
vips_streami_minimise( read->input );
|
vips_streami_minimise( read->streami );
|
||||||
}
|
}
|
||||||
|
|
||||||
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_streami_read( read->input,
|
bytes_read = vips_streami_read( read->streami,
|
||||||
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( VipsStreami *input, VipsImage *out, gboolean fail )
|
read_new( VipsStreami *streami, VipsImage *out, gboolean fail )
|
||||||
{
|
{
|
||||||
Read *read;
|
Read *read;
|
||||||
|
|
||||||
@ -263,8 +263,8 @@ read_new( VipsStreami *input, VipsImage *out, gboolean fail )
|
|||||||
read->pPng = NULL;
|
read->pPng = NULL;
|
||||||
read->pInfo = NULL;
|
read->pInfo = NULL;
|
||||||
read->row_pointer = NULL;
|
read->row_pointer = NULL;
|
||||||
read->input = input;
|
read->streami = streami;
|
||||||
g_object_ref( input );
|
g_object_ref( streami );
|
||||||
|
|
||||||
g_signal_connect( out, "close",
|
g_signal_connect( out, "close",
|
||||||
G_CALLBACK( read_close_cb ), read );
|
G_CALLBACK( read_close_cb ), read );
|
||||||
@ -290,7 +290,7 @@ read_new( VipsStreami *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_streami_rewind( input ) )
|
if( vips_streami_rewind( streami ) )
|
||||||
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 );
|
||||||
|
|
||||||
@ -482,7 +482,7 @@ png2vips_header( Read *read, VipsImage *out )
|
|||||||
Xres, Yres );
|
Xres, Yres );
|
||||||
|
|
||||||
VIPS_SETSTR( out->filename,
|
VIPS_SETSTR( out->filename,
|
||||||
vips_stream_filename( VIPS_STREAM( read->input ) ) );
|
vips_stream_filename( VIPS_STREAM( read->streami ) ) );
|
||||||
|
|
||||||
/* 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.
|
||||||
@ -694,11 +694,11 @@ png2vips_image( Read *read, VipsImage *out )
|
|||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
vips__png_ispng_stream( VipsStreami *input )
|
vips__png_ispng_stream( VipsStreami *streami )
|
||||||
{
|
{
|
||||||
const unsigned char *p;
|
const unsigned char *p;
|
||||||
|
|
||||||
if( (p = vips_streami_sniff( input, 8 )) &&
|
if( (p = vips_streami_sniff( streami, 8 )) &&
|
||||||
!png_sig_cmp( (png_bytep) p, 0, 8 ) )
|
!png_sig_cmp( (png_bytep) p, 0, 8 ) )
|
||||||
return( TRUE );
|
return( TRUE );
|
||||||
|
|
||||||
@ -706,27 +706,27 @@ vips__png_ispng_stream( VipsStreami *input )
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
vips__png_header_stream( VipsStreami *input, VipsImage *out )
|
vips__png_header_stream( VipsStreami *streami, VipsImage *out )
|
||||||
{
|
{
|
||||||
Read *read;
|
Read *read;
|
||||||
|
|
||||||
if( !(read = read_new( input, out, TRUE )) ||
|
if( !(read = read_new( streami, out, TRUE )) ||
|
||||||
png2vips_header( read, out ) )
|
png2vips_header( read, out ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
vips_streami_minimise( input );
|
vips_streami_minimise( streami );
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
vips__png_read_stream( VipsStreami *input, VipsImage *out, gboolean fail )
|
vips__png_read_stream( VipsStreami *streami, VipsImage *out, gboolean fail )
|
||||||
{
|
{
|
||||||
Read *read;
|
Read *read;
|
||||||
|
|
||||||
if( !(read = read_new( input, out, fail )) ||
|
if( !(read = read_new( streami, out, fail )) ||
|
||||||
png2vips_image( read, out ) ||
|
png2vips_image( read, out ) ||
|
||||||
vips_streami_decode( input ) )
|
vips_streami_decode( streami ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
@ -736,7 +736,7 @@ vips__png_read_stream( VipsStreami *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( VipsStreami *input )
|
vips__png_isinterlaced_stream( VipsStreami *streami )
|
||||||
{
|
{
|
||||||
VipsImage *image;
|
VipsImage *image;
|
||||||
Read *read;
|
Read *read;
|
||||||
@ -744,7 +744,7 @@ vips__png_isinterlaced_stream( VipsStreami *input )
|
|||||||
|
|
||||||
image = vips_image_new();
|
image = vips_image_new();
|
||||||
|
|
||||||
if( !(read = read_new( input, image, TRUE )) ) {
|
if( !(read = read_new( streami, image, TRUE )) ) {
|
||||||
g_object_unref( image );
|
g_object_unref( image );
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
@ -762,7 +762,7 @@ typedef struct {
|
|||||||
VipsImage *in;
|
VipsImage *in;
|
||||||
VipsImage *memory;
|
VipsImage *memory;
|
||||||
|
|
||||||
VipsStreamo *output;
|
VipsStreamo *streamo;
|
||||||
|
|
||||||
png_structp pPng;
|
png_structp pPng;
|
||||||
png_infop pInfo;
|
png_infop pInfo;
|
||||||
@ -773,9 +773,9 @@ static void
|
|||||||
write_finish( Write *write )
|
write_finish( Write *write )
|
||||||
{
|
{
|
||||||
VIPS_UNREF( write->memory );
|
VIPS_UNREF( write->memory );
|
||||||
if( write->output )
|
if( write->streamo )
|
||||||
vips_streamo_finish( write->output );
|
vips_streamo_finish( write->streamo );
|
||||||
VIPS_UNREF( write->output );
|
VIPS_UNREF( write->streamo );
|
||||||
if( write->pPng )
|
if( write->pPng )
|
||||||
png_destroy_write_struct( &write->pPng, &write->pInfo );
|
png_destroy_write_struct( &write->pPng, &write->pInfo );
|
||||||
}
|
}
|
||||||
@ -791,12 +791,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_streamo_write( write->output, data, length ) )
|
if( vips_streamo_write( write->streamo, data, length ) )
|
||||||
png_error( pPng, "not enough data" );
|
png_error( pPng, "not enough data" );
|
||||||
}
|
}
|
||||||
|
|
||||||
static Write *
|
static Write *
|
||||||
write_new( VipsImage *in, VipsStreamo *output )
|
write_new( VipsImage *in, VipsStreamo *streamo )
|
||||||
{
|
{
|
||||||
Write *write;
|
Write *write;
|
||||||
|
|
||||||
@ -805,8 +805,8 @@ write_new( VipsImage *in, VipsStreamo *output )
|
|||||||
memset( write, 0, sizeof( Write ) );
|
memset( write, 0, sizeof( Write ) );
|
||||||
write->in = in;
|
write->in = in;
|
||||||
write->memory = NULL;
|
write->memory = NULL;
|
||||||
write->output = output;
|
write->streamo = streamo;
|
||||||
g_object_ref( output );
|
g_object_ref( streamo );
|
||||||
g_signal_connect( in, "close",
|
g_signal_connect( in, "close",
|
||||||
G_CALLBACK( write_destroy ), write );
|
G_CALLBACK( write_destroy ), write );
|
||||||
|
|
||||||
@ -1169,14 +1169,14 @@ write_vips( Write *write,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
vips__png_write_stream( VipsImage *in, VipsStreamo *output,
|
vips__png_write_stream( VipsImage *in, VipsStreamo *streamo,
|
||||||
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 )
|
||||||
{
|
{
|
||||||
Write *write;
|
Write *write;
|
||||||
|
|
||||||
if( !(write = write_new( in, output )) )
|
if( !(write = write_new( in, streamo )) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
if( write_vips( write,
|
if( write_vips( write,
|
||||||
|
@ -81,7 +81,7 @@
|
|||||||
/* What we track during a read.
|
/* What we track during a read.
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
VipsStreami *input;
|
VipsStreami *streami;
|
||||||
|
|
||||||
/* 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( VipsStreami *input )
|
vips__iswebp_stream( VipsStreami *streami )
|
||||||
{
|
{
|
||||||
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_streami_sniff( input, 12 )) &&
|
if( (p = vips_streami_sniff( streami, 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 );
|
||||||
@ -333,7 +333,7 @@ read_free( Read *read )
|
|||||||
VIPS_FREEF( WebPDemuxDelete, read->demux );
|
VIPS_FREEF( WebPDemuxDelete, read->demux );
|
||||||
WebPFreeDecBuffer( &read->config.output );
|
WebPFreeDecBuffer( &read->config.output );
|
||||||
|
|
||||||
VIPS_UNREF( read->input );
|
VIPS_UNREF( read->streami );
|
||||||
VIPS_FREE( read->delays );
|
VIPS_FREE( read->delays );
|
||||||
VIPS_FREE( read );
|
VIPS_FREE( read );
|
||||||
|
|
||||||
@ -341,15 +341,15 @@ read_free( Read *read )
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Read *
|
static Read *
|
||||||
read_new( VipsStreami *input, int page, int n, double scale )
|
read_new( VipsStreami *streami, int page, int n, double scale )
|
||||||
{
|
{
|
||||||
Read *read;
|
Read *read;
|
||||||
|
|
||||||
if( !(read = VIPS_NEW( NULL, Read )) )
|
if( !(read = VIPS_NEW( NULL, Read )) )
|
||||||
return( NULL );
|
return( NULL );
|
||||||
|
|
||||||
read->input = input;
|
read->streami = streami;
|
||||||
g_object_ref( input );
|
g_object_ref( streami );
|
||||||
read->page = page;
|
read->page = page;
|
||||||
read->n = n;
|
read->n = n;
|
||||||
read->scale = scale;
|
read->scale = scale;
|
||||||
@ -364,7 +364,7 @@ read_new( VipsStreami *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_streami_map( input, &read->data.size )) ) {
|
vips_streami_map( streami, &read->data.size )) ) {
|
||||||
read_free( read );
|
read_free( read );
|
||||||
return( NULL );
|
return( NULL );
|
||||||
}
|
}
|
||||||
@ -541,7 +541,7 @@ read_header( Read *read, VipsImage *out )
|
|||||||
1.0, 1.0 );
|
1.0, 1.0 );
|
||||||
vips_image_pipelinev( out, VIPS_DEMAND_STYLE_THINSTRIP, NULL );
|
vips_image_pipelinev( out, VIPS_DEMAND_STYLE_THINSTRIP, NULL );
|
||||||
VIPS_SETSTR( out->filename,
|
VIPS_SETSTR( out->filename,
|
||||||
vips_stream_filename( VIPS_STREAM( read->input ) ) );
|
vips_stream_filename( VIPS_STREAM( read->streami ) ) );
|
||||||
|
|
||||||
if( !WebPDemuxGetFrame( read->demux, 1, &read->iter ) ) {
|
if( !WebPDemuxGetFrame( read->demux, 1, &read->iter ) ) {
|
||||||
vips_error( "webp",
|
vips_error( "webp",
|
||||||
@ -754,12 +754,12 @@ read_image( Read *read, VipsImage *out )
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
vips__webp_read_header_stream( VipsStreami *input, VipsImage *out,
|
vips__webp_read_header_stream( VipsStreami *streami, VipsImage *out,
|
||||||
int page, int n, double scale )
|
int page, int n, double scale )
|
||||||
{
|
{
|
||||||
Read *read;
|
Read *read;
|
||||||
|
|
||||||
if( !(read = read_new( input, page, n, scale )) )
|
if( !(read = read_new( streami, page, n, scale )) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
if( read_header( read, out ) ) {
|
if( read_header( read, out ) ) {
|
||||||
@ -773,12 +773,12 @@ vips__webp_read_header_stream( VipsStreami *input, VipsImage *out,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
vips__webp_read_stream( VipsStreami *input, VipsImage *out,
|
vips__webp_read_stream( VipsStreami *streami, VipsImage *out,
|
||||||
int page, int n, double scale )
|
int page, int n, double scale )
|
||||||
{
|
{
|
||||||
Read *read;
|
Read *read;
|
||||||
|
|
||||||
if( !(read = read_new( input, page, n, scale )) )
|
if( !(read = read_new( streami, page, n, scale )) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
if( read_image( read, out ) ) {
|
if( read_image( read, out ) ) {
|
||||||
|
@ -156,7 +156,7 @@ vips_foreign_load_webp_init( VipsForeignLoadWebp *webp )
|
|||||||
typedef struct _VipsForeignLoadWebpStream {
|
typedef struct _VipsForeignLoadWebpStream {
|
||||||
VipsForeignLoadWebp parent_object;
|
VipsForeignLoadWebp parent_object;
|
||||||
|
|
||||||
VipsStreami *input;
|
VipsStreami *streami;
|
||||||
|
|
||||||
} VipsForeignLoadWebpStream;
|
} VipsForeignLoadWebpStream;
|
||||||
|
|
||||||
@ -171,7 +171,7 @@ vips_foreign_load_webp_stream_header( VipsForeignLoad *load )
|
|||||||
VipsForeignLoadWebp *webp = (VipsForeignLoadWebp *) load;
|
VipsForeignLoadWebp *webp = (VipsForeignLoadWebp *) load;
|
||||||
VipsForeignLoadWebpStream *stream = (VipsForeignLoadWebpStream *) load;
|
VipsForeignLoadWebpStream *stream = (VipsForeignLoadWebpStream *) load;
|
||||||
|
|
||||||
if( vips__webp_read_header_stream( stream->input, load->out,
|
if( vips__webp_read_header_stream( stream->streami, load->out,
|
||||||
webp->page, webp->n, webp->scale ) )
|
webp->page, webp->n, webp->scale ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
@ -184,7 +184,7 @@ vips_foreign_load_webp_stream_load( VipsForeignLoad *load )
|
|||||||
VipsForeignLoadWebp *webp = (VipsForeignLoadWebp *) load;
|
VipsForeignLoadWebp *webp = (VipsForeignLoadWebp *) load;
|
||||||
VipsForeignLoadWebpStream *stream = (VipsForeignLoadWebpStream *) load;
|
VipsForeignLoadWebpStream *stream = (VipsForeignLoadWebpStream *) load;
|
||||||
|
|
||||||
if( vips__webp_read_stream( stream->input, load->real,
|
if( vips__webp_read_stream( stream->streami, load->real,
|
||||||
webp->page, webp->n, webp->scale ) )
|
webp->page, webp->n, webp->scale ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
@ -214,11 +214,11 @@ vips_foreign_load_webp_stream_class_init(
|
|||||||
load_class->header = vips_foreign_load_webp_stream_header;
|
load_class->header = vips_foreign_load_webp_stream_header;
|
||||||
load_class->load = vips_foreign_load_webp_stream_load;
|
load_class->load = vips_foreign_load_webp_stream_load;
|
||||||
|
|
||||||
VIPS_ARG_OBJECT( class, "input", 1,
|
VIPS_ARG_OBJECT( class, "streami", 1,
|
||||||
_( "Input" ),
|
_( "Streami" ),
|
||||||
_( "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, streami ),
|
||||||
VIPS_TYPE_STREAMI );
|
VIPS_TYPE_STREAMI );
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -251,13 +251,13 @@ 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 )
|
||||||
{
|
{
|
||||||
VipsStreami *input;
|
VipsStreami *streami;
|
||||||
gboolean result;
|
gboolean result;
|
||||||
|
|
||||||
if( !(input = vips_streami_new_from_filename( filename )) )
|
if( !(streami = vips_streami_new_from_filename( filename )) )
|
||||||
return( FALSE );
|
return( FALSE );
|
||||||
result = vips__iswebp_stream( input );
|
result = vips__iswebp_stream( streami );
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( streami );
|
||||||
|
|
||||||
return( result );
|
return( result );
|
||||||
}
|
}
|
||||||
@ -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;
|
||||||
|
|
||||||
VipsStreami *input;
|
VipsStreami *streami;
|
||||||
|
|
||||||
/* BC for the old API.
|
/* BC for the old API.
|
||||||
*/
|
*/
|
||||||
@ -277,14 +277,14 @@ 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_streami_new_from_filename( file->filename )) )
|
if( !(streami = 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( streami, load->out,
|
||||||
webp->page, webp->n, webp->scale ) ) {
|
webp->page, webp->n, webp->scale ) ) {
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( streami );
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( streami );
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
@ -295,16 +295,16 @@ vips_foreign_load_webp_file_load( VipsForeignLoad *load )
|
|||||||
VipsForeignLoadWebp *webp = (VipsForeignLoadWebp *) load;
|
VipsForeignLoadWebp *webp = (VipsForeignLoadWebp *) load;
|
||||||
VipsForeignLoadWebpFile *file = (VipsForeignLoadWebpFile *) load;
|
VipsForeignLoadWebpFile *file = (VipsForeignLoadWebpFile *) load;
|
||||||
|
|
||||||
VipsStreami *input;
|
VipsStreami *streami;
|
||||||
|
|
||||||
if( !(input = vips_streami_new_from_filename( file->filename )) )
|
if( !(streami = vips_streami_new_from_filename( file->filename )) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
if( vips__webp_read_stream( input, load->real,
|
if( vips__webp_read_stream( streami, load->real,
|
||||||
webp->page, webp->n, webp->scale ) ) {
|
webp->page, webp->n, webp->scale ) ) {
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( streami );
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( streami );
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
@ -363,13 +363,13 @@ 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 )
|
||||||
{
|
{
|
||||||
VipsStreami *input;
|
VipsStreami *streami;
|
||||||
gboolean result;
|
gboolean result;
|
||||||
|
|
||||||
if( !(input = vips_streami_new_from_memory( buf, len )) )
|
if( !(streami = vips_streami_new_from_memory( buf, len )) )
|
||||||
return( FALSE );
|
return( FALSE );
|
||||||
result = vips__iswebp_stream( input );
|
result = vips__iswebp_stream( streami );
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( streami );
|
||||||
|
|
||||||
return( result );
|
return( result );
|
||||||
}
|
}
|
||||||
@ -380,17 +380,17 @@ vips_foreign_load_webp_buffer_header( VipsForeignLoad *load )
|
|||||||
VipsForeignLoadWebp *webp = (VipsForeignLoadWebp *) load;
|
VipsForeignLoadWebp *webp = (VipsForeignLoadWebp *) load;
|
||||||
VipsForeignLoadWebpBuffer *buffer = (VipsForeignLoadWebpBuffer *) load;
|
VipsForeignLoadWebpBuffer *buffer = (VipsForeignLoadWebpBuffer *) load;
|
||||||
|
|
||||||
VipsStreami *input;
|
VipsStreami *streami;
|
||||||
|
|
||||||
if( !(input = vips_streami_new_from_memory( buffer->buf->data,
|
if( !(streami = 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( streami, load->out,
|
||||||
webp->page, webp->n, webp->scale ) ) {
|
webp->page, webp->n, webp->scale ) ) {
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( streami );
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( streami );
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
@ -401,17 +401,17 @@ vips_foreign_load_webp_buffer_load( VipsForeignLoad *load )
|
|||||||
VipsForeignLoadWebp *webp = (VipsForeignLoadWebp *) load;
|
VipsForeignLoadWebp *webp = (VipsForeignLoadWebp *) load;
|
||||||
VipsForeignLoadWebpBuffer *buffer = (VipsForeignLoadWebpBuffer *) load;
|
VipsForeignLoadWebpBuffer *buffer = (VipsForeignLoadWebpBuffer *) load;
|
||||||
|
|
||||||
VipsStreami *input;
|
VipsStreami *streami;
|
||||||
|
|
||||||
if( !(input = vips_streami_new_from_memory( buffer->buf->data,
|
if( !(streami = 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( streami, load->real,
|
||||||
webp->page, webp->n, webp->scale ) ) {
|
webp->page, webp->n, webp->scale ) ) {
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( streami );
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( streami );
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
@ -542,7 +542,7 @@ vips_webpload_buffer( void *buf, size_t len, VipsImage **out, ... )
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* vips_webpload_stream:
|
* vips_webpload_stream:
|
||||||
* @input: stream to load from
|
* @streami: stream to load from
|
||||||
* @out: (out): image to write
|
* @out: (out): image to write
|
||||||
* @...: %NULL-terminated list of optional named arguments
|
* @...: %NULL-terminated list of optional named arguments
|
||||||
*
|
*
|
||||||
@ -559,13 +559,13 @@ 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( VipsStreami *input, VipsImage **out, ... )
|
vips_webpload_stream( VipsStreami *streami, VipsImage **out, ... )
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
va_start( ap, out );
|
va_start( ap, out );
|
||||||
result = vips_call_split( "webpload_stream", ap, input, out );
|
result = vips_call_split( "webpload_stream", ap, streami, out );
|
||||||
va_end( ap );
|
va_end( ap );
|
||||||
|
|
||||||
return( result );
|
return( result );
|
||||||
|
@ -222,7 +222,7 @@ vips_foreign_save_webp_init( VipsForeignSaveWebp *webp )
|
|||||||
typedef struct _VipsForeignSaveWebpStream {
|
typedef struct _VipsForeignSaveWebpStream {
|
||||||
VipsForeignSaveWebp parent_object;
|
VipsForeignSaveWebp parent_object;
|
||||||
|
|
||||||
VipsStreamo *output;
|
VipsStreamo *streamo;
|
||||||
|
|
||||||
} VipsForeignSaveWebpStream;
|
} VipsForeignSaveWebpStream;
|
||||||
|
|
||||||
@ -243,7 +243,7 @@ vips_foreign_save_webp_stream_build( VipsObject *object )
|
|||||||
build( object ) )
|
build( object ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
if( vips__webp_write_stream( save->ready, stream->output,
|
if( vips__webp_write_stream( save->ready, stream->streamo,
|
||||||
webp->Q, webp->lossless, webp->preset,
|
webp->Q, webp->lossless, webp->preset,
|
||||||
webp->smart_subsample, webp->near_lossless,
|
webp->smart_subsample, webp->near_lossless,
|
||||||
webp->alpha_q, webp->reduction_effort,
|
webp->alpha_q, webp->reduction_effort,
|
||||||
@ -268,11 +268,11 @@ vips_foreign_save_webp_stream_class_init(
|
|||||||
object_class->description = _( "save image to webp stream" );
|
object_class->description = _( "save image to webp stream" );
|
||||||
object_class->build = vips_foreign_save_webp_stream_build;
|
object_class->build = vips_foreign_save_webp_stream_build;
|
||||||
|
|
||||||
VIPS_ARG_OBJECT( class, "output", 1,
|
VIPS_ARG_OBJECT( class, "streamo", 1,
|
||||||
_( "Output" ),
|
_( "streamo" ),
|
||||||
_( "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, streamo ),
|
||||||
VIPS_TYPE_STREAMO );
|
VIPS_TYPE_STREAMO );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -303,24 +303,24 @@ vips_foreign_save_webp_file_build( VipsObject *object )
|
|||||||
VipsForeignSaveWebp *webp = (VipsForeignSaveWebp *) object;
|
VipsForeignSaveWebp *webp = (VipsForeignSaveWebp *) object;
|
||||||
VipsForeignSaveWebpFile *file = (VipsForeignSaveWebpFile *) object;
|
VipsForeignSaveWebpFile *file = (VipsForeignSaveWebpFile *) object;
|
||||||
|
|
||||||
VipsStreamo *output;
|
VipsStreamo *streamo;
|
||||||
|
|
||||||
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_streamo_new_to_filename( file->filename )) )
|
if( !(streamo = vips_streamo_new_to_filename( file->filename )) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
if( vips__webp_write_stream( save->ready, output,
|
if( vips__webp_write_stream( save->ready, streamo,
|
||||||
webp->Q, webp->lossless, webp->preset,
|
webp->Q, webp->lossless, webp->preset,
|
||||||
webp->smart_subsample, webp->near_lossless,
|
webp->smart_subsample, webp->near_lossless,
|
||||||
webp->alpha_q, webp->reduction_effort,
|
webp->alpha_q, webp->reduction_effort,
|
||||||
webp->min_size, webp->kmin, webp->kmax,
|
webp->min_size, webp->kmin, webp->kmax,
|
||||||
save->strip ) ) {
|
save->strip ) ) {
|
||||||
VIPS_UNREF( output );
|
VIPS_UNREF( streamo );
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
VIPS_UNREF( output );
|
VIPS_UNREF( streamo );
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
@ -373,27 +373,27 @@ vips_foreign_save_webp_buffer_build( VipsObject *object )
|
|||||||
VipsForeignSaveWebpBuffer *buffer =
|
VipsForeignSaveWebpBuffer *buffer =
|
||||||
(VipsForeignSaveWebpBuffer *) object;
|
(VipsForeignSaveWebpBuffer *) object;
|
||||||
|
|
||||||
VipsStreamo *output;
|
VipsStreamo *streamo;
|
||||||
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_streamo_new_to_memory()) )
|
if( !(streamo = vips_streamo_new_to_memory()) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
if( vips__webp_write_stream( save->ready, output,
|
if( vips__webp_write_stream( save->ready, streamo,
|
||||||
webp->Q, webp->lossless, webp->preset,
|
webp->Q, webp->lossless, webp->preset,
|
||||||
webp->smart_subsample, webp->near_lossless,
|
webp->smart_subsample, webp->near_lossless,
|
||||||
webp->alpha_q, webp->reduction_effort,
|
webp->alpha_q, webp->reduction_effort,
|
||||||
webp->min_size, webp->kmin, webp->kmax,
|
webp->min_size, webp->kmin, webp->kmax,
|
||||||
save->strip ) ) {
|
save->strip ) ) {
|
||||||
VIPS_UNREF( output );
|
VIPS_UNREF( streamo );
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
g_object_get( output, "blob", &blob, NULL );
|
g_object_get( streamo, "blob", &blob, NULL );
|
||||||
g_object_set( buffer, "buffer", blob, NULL );
|
g_object_set( buffer, "buffer", blob, NULL );
|
||||||
vips_area_unref( VIPS_AREA( blob ) );
|
vips_area_unref( VIPS_AREA( blob ) );
|
||||||
|
|
||||||
@ -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;
|
||||||
|
|
||||||
VipsStreamo *output;
|
VipsStreamo *streamo;
|
||||||
VipsBlob *blob;
|
VipsBlob *blob;
|
||||||
void *data;
|
void *data;
|
||||||
size_t len;
|
size_t len;
|
||||||
@ -452,20 +452,20 @@ vips_foreign_save_webp_mime_build( VipsObject *object )
|
|||||||
build( object ) )
|
build( object ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
if( !(output = vips_streamo_new_to_memory()) )
|
if( !(streamo = vips_streamo_new_to_memory()) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
if( vips__webp_write_stream( save->ready, output,
|
if( vips__webp_write_stream( save->ready, streamo,
|
||||||
webp->Q, webp->lossless, webp->preset,
|
webp->Q, webp->lossless, webp->preset,
|
||||||
webp->smart_subsample, webp->near_lossless,
|
webp->smart_subsample, webp->near_lossless,
|
||||||
webp->alpha_q, webp->reduction_effort,
|
webp->alpha_q, webp->reduction_effort,
|
||||||
webp->min_size, webp->kmin, webp->kmax,
|
webp->min_size, webp->kmin, webp->kmax,
|
||||||
save->strip ) ) {
|
save->strip ) ) {
|
||||||
VIPS_UNREF( output );
|
VIPS_UNREF( streamo );
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
g_object_get( output, "blob", &blob, NULL );
|
g_object_get( streamo, "blob", &blob, NULL );
|
||||||
data = VIPS_AREA( blob )->data;
|
data = VIPS_AREA( blob )->data;
|
||||||
len = VIPS_AREA( blob )->length;
|
len = VIPS_AREA( blob )->length;
|
||||||
vips_area_unref( VIPS_AREA( blob ) );
|
vips_area_unref( VIPS_AREA( blob ) );
|
||||||
@ -476,7 +476,7 @@ vips_foreign_save_webp_mime_build( VipsObject *object )
|
|||||||
(void) fwrite( data, sizeof( char ), len, stdout );
|
(void) fwrite( data, sizeof( char ), len, stdout );
|
||||||
fflush( stdout );
|
fflush( stdout );
|
||||||
|
|
||||||
VIPS_UNREF( output );
|
VIPS_UNREF( streamo );
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
@ -671,7 +671,7 @@ vips_webpsave_mime( VipsImage *in, ... )
|
|||||||
/**
|
/**
|
||||||
* vips_webpsave_stream: (method)
|
* vips_webpsave_stream: (method)
|
||||||
* @in: image to save
|
* @in: image to save
|
||||||
* @output: save image to this stream
|
* @streamo: save image to this stream
|
||||||
* @...: %NULL-terminated list of optional named arguments
|
* @...: %NULL-terminated list of optional named arguments
|
||||||
*
|
*
|
||||||
* Optional arguments:
|
* Optional arguments:
|
||||||
@ -695,13 +695,13 @@ 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, VipsStreamo *output, ... )
|
vips_webpsave_stream( VipsImage *in, VipsStreamo *streamo, ... )
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
va_start( ap, output );
|
va_start( ap, streamo );
|
||||||
result = vips_call_split( "webpsave_stream", ap, in, output );
|
result = vips_call_split( "webpsave_stream", ap, in, streamo );
|
||||||
va_end( ap );
|
va_end( ap );
|
||||||
|
|
||||||
return( result );
|
return( result );
|
||||||
|
@ -580,7 +580,7 @@ int vips_radsave( VipsImage *in, const char *filename, ... )
|
|||||||
__attribute__((sentinel));
|
__attribute__((sentinel));
|
||||||
int vips_radsave_buffer( VipsImage *in, void **buf, size_t *len, ... )
|
int vips_radsave_buffer( VipsImage *in, void **buf, size_t *len, ... )
|
||||||
__attribute__((sentinel));
|
__attribute__((sentinel));
|
||||||
int vips_radsave_stream( VipsImage *in, VipsStreamo *output, ... )
|
int vips_radsave_stream( VipsImage *in, VipsStreamo *streamo, ... )
|
||||||
__attribute__((sentinel));
|
__attribute__((sentinel));
|
||||||
|
|
||||||
int vips_pdfload( const char *filename, VipsImage **out, ... )
|
int vips_pdfload( const char *filename, VipsImage **out, ... )
|
||||||
|
@ -2166,7 +2166,7 @@ vips_image_new_from_buffer( const void *buf, size_t len,
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* vips_image_new_from_stream: (constructor)
|
* vips_image_new_from_stream: (constructor)
|
||||||
* @input: (transfer none): stream to fetch image from
|
* @streami: (transfer none): stream to fetch image from
|
||||||
* @option_string: set of extra options as a string
|
* @option_string: set of extra options as a string
|
||||||
* @...: %NULL-terminated list of optional named arguments
|
* @...: %NULL-terminated list of optional named arguments
|
||||||
*
|
*
|
||||||
@ -2182,7 +2182,8 @@ vips_image_new_from_buffer( const void *buf, size_t len,
|
|||||||
* Returns: (transfer full): the new #VipsImage, or %NULL on error.
|
* Returns: (transfer full): the new #VipsImage, or %NULL on error.
|
||||||
*/
|
*/
|
||||||
VipsImage *
|
VipsImage *
|
||||||
vips_image_new_from_stream( VipsStreami *input, const char *option_string, ... )
|
vips_image_new_from_stream( VipsStreami *streami,
|
||||||
|
const char *option_string, ... )
|
||||||
{
|
{
|
||||||
const char *operation_name;
|
const char *operation_name;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
@ -2191,12 +2192,12 @@ vips_image_new_from_stream( VipsStreami *input, const char *option_string, ... )
|
|||||||
|
|
||||||
vips_check_init();
|
vips_check_init();
|
||||||
|
|
||||||
if( !(operation_name = vips_foreign_find_load_stream( input )) )
|
if( !(operation_name = vips_foreign_find_load_stream( streami )) )
|
||||||
return( NULL );
|
return( NULL );
|
||||||
|
|
||||||
va_start( ap, option_string );
|
va_start( ap, option_string );
|
||||||
result = vips_call_split_option_string( operation_name,
|
result = vips_call_split_option_string( operation_name,
|
||||||
option_string, ap, input, &out );
|
option_string, ap, streami, &out );
|
||||||
va_end( ap );
|
va_end( ap );
|
||||||
|
|
||||||
if( result )
|
if( result )
|
||||||
@ -2704,7 +2705,7 @@ vips_image_write_to_buffer( VipsImage *in,
|
|||||||
* vips_image_write_to_stream: (method)
|
* vips_image_write_to_stream: (method)
|
||||||
* @in: image to write
|
* @in: image to write
|
||||||
* @suffix: format to write
|
* @suffix: format to write
|
||||||
* @output: stream to write to
|
* @streamo: stream to write to
|
||||||
* @...: %NULL-terminated list of optional named arguments
|
* @...: %NULL-terminated list of optional named arguments
|
||||||
*
|
*
|
||||||
* Writes @in to @output in format @suffix.
|
* Writes @in to @output in format @suffix.
|
||||||
@ -2722,7 +2723,7 @@ vips_image_write_to_buffer( VipsImage *in,
|
|||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
vips_image_write_to_stream( VipsImage *in,
|
vips_image_write_to_stream( VipsImage *in,
|
||||||
const char *suffix, VipsStreamo *output, ... )
|
const char *suffix, VipsStreamo *streamo, ... )
|
||||||
{
|
{
|
||||||
char filename[VIPS_PATH_MAX];
|
char filename[VIPS_PATH_MAX];
|
||||||
char option_string[VIPS_PATH_MAX];
|
char option_string[VIPS_PATH_MAX];
|
||||||
@ -2734,9 +2735,9 @@ vips_image_write_to_stream( VipsImage *in,
|
|||||||
if( !(operation_name = vips_foreign_find_save_stream( filename )) )
|
if( !(operation_name = vips_foreign_find_save_stream( filename )) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
va_start( ap, output );
|
va_start( ap, streamo );
|
||||||
result = vips_call_split_option_string( operation_name, option_string,
|
result = vips_call_split_option_string( operation_name, option_string,
|
||||||
ap, in, output );
|
ap, in, streamo );
|
||||||
va_end( ap );
|
va_end( ap );
|
||||||
|
|
||||||
if( result )
|
if( result )
|
||||||
|
@ -1908,19 +1908,19 @@ vips_object_set_argument_from_string( VipsObject *object,
|
|||||||
vips__filename_split8( value, filename, option_string );
|
vips__filename_split8( value, filename, option_string );
|
||||||
|
|
||||||
if( strcmp( "stdin", filename ) == 0 ) {
|
if( strcmp( "stdin", filename ) == 0 ) {
|
||||||
VipsStreami *input;
|
VipsStreami *streami;
|
||||||
|
|
||||||
if( !(input =
|
if( !(streami =
|
||||||
vips_streami_new_from_descriptor( 0 )) )
|
vips_streami_new_from_descriptor( 0 )) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
if( !(out = vips_image_new_from_stream( input,
|
if( !(out = vips_image_new_from_stream( streami,
|
||||||
option_string,
|
option_string,
|
||||||
"access", access,
|
"access", access,
|
||||||
NULL )) ) {
|
NULL )) ) {
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( streami );
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
VIPS_UNREF( input );
|
VIPS_UNREF( streami );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if( !(out = vips_image_new_from_file( value,
|
if( !(out = vips_image_new_from_file( value,
|
||||||
@ -1938,23 +1938,23 @@ vips_object_set_argument_from_string( VipsObject *object,
|
|||||||
g_object_unref( out );
|
g_object_unref( out );
|
||||||
}
|
}
|
||||||
else if( g_type_is_a( otype, VIPS_TYPE_STREAMI ) ) {
|
else if( g_type_is_a( otype, VIPS_TYPE_STREAMI ) ) {
|
||||||
VipsStreami *input;
|
VipsStreami *streami;
|
||||||
|
|
||||||
if( !value ) {
|
if( !value ) {
|
||||||
vips_object_no_value( object, name );
|
vips_object_no_value( object, name );
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !(input = vips_streami_new_from_options( value )) )
|
if( !(streami = vips_streami_new_from_options( value )) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
g_value_init( &gvalue, VIPS_TYPE_STREAMI );
|
g_value_init( &gvalue, VIPS_TYPE_STREAMI );
|
||||||
g_value_set_object( &gvalue, input );
|
g_value_set_object( &gvalue, streami );
|
||||||
|
|
||||||
/* Setting gvalue will have upped @out's count again,
|
/* Setting gvalue will have upped @out's count again,
|
||||||
* go back to 1 so that gvalue has the only ref.
|
* go back to 1 so that gvalue has the only ref.
|
||||||
*/
|
*/
|
||||||
g_object_unref( input );
|
g_object_unref( streami );
|
||||||
}
|
}
|
||||||
else if( g_type_is_a( otype, VIPS_TYPE_ARRAY_IMAGE ) ) {
|
else if( g_type_is_a( otype, VIPS_TYPE_ARRAY_IMAGE ) ) {
|
||||||
/* We have to have a special case for this, we can't just rely
|
/* We have to have a special case for this, we can't just rely
|
||||||
@ -2210,19 +2210,19 @@ vips_object_get_argument_to_string( VipsObject *object,
|
|||||||
vips__filename_split8( arg, filename, option_string );
|
vips__filename_split8( arg, filename, option_string );
|
||||||
|
|
||||||
if( vips_isprefix( ".", filename ) ) {
|
if( vips_isprefix( ".", filename ) ) {
|
||||||
VipsStreamo *output;
|
VipsStreamo *streamo;
|
||||||
|
|
||||||
if( !(output = vips_streamo_new_to_descriptor( 1 )) )
|
if( !(streamo = vips_streamo_new_to_descriptor( 1 )) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
g_object_get( object, name, &in, NULL );
|
g_object_get( object, name, &in, NULL );
|
||||||
if( vips_image_write_to_stream( in,
|
if( vips_image_write_to_stream( in,
|
||||||
arg, output, NULL ) ) {
|
arg, streamo, NULL ) ) {
|
||||||
VIPS_UNREF( in );
|
VIPS_UNREF( in );
|
||||||
VIPS_UNREF( output );
|
VIPS_UNREF( streamo );
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
VIPS_UNREF( in );
|
VIPS_UNREF( in );
|
||||||
VIPS_UNREF( output );
|
VIPS_UNREF( streamo );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* Pull out the image and write it.
|
/* Pull out the image and write it.
|
||||||
|
@ -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;
|
||||||
|
|
||||||
VipsStreami *input;
|
VipsStreami *streami;
|
||||||
char *option_string;
|
char *option_string;
|
||||||
} VipsThumbnailStream;
|
} VipsThumbnailStream;
|
||||||
|
|
||||||
@ -1275,8 +1275,8 @@ vips_thumbnail_stream_get_info( VipsThumbnail *thumbnail )
|
|||||||
g_info( "thumbnailing stream" );
|
g_info( "thumbnailing stream" );
|
||||||
|
|
||||||
if( !(thumbnail->loader = vips_foreign_find_load_stream(
|
if( !(thumbnail->loader = vips_foreign_find_load_stream(
|
||||||
stream->input )) ||
|
stream->streami )) ||
|
||||||
!(image = vips_image_new_from_stream( stream->input,
|
!(image = vips_image_new_from_stream( stream->streami,
|
||||||
stream->option_string, NULL )) )
|
stream->option_string, NULL )) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
@ -1296,7 +1296,7 @@ vips_thumbnail_stream_open( VipsThumbnail *thumbnail, double factor )
|
|||||||
|
|
||||||
if( vips_isprefix( "VipsForeignLoadJpeg", thumbnail->loader ) ) {
|
if( vips_isprefix( "VipsForeignLoadJpeg", thumbnail->loader ) ) {
|
||||||
return( vips_image_new_from_stream(
|
return( vips_image_new_from_stream(
|
||||||
stream->input,
|
stream->streami,
|
||||||
stream->option_string,
|
stream->option_string,
|
||||||
"access", VIPS_ACCESS_SEQUENTIAL,
|
"access", VIPS_ACCESS_SEQUENTIAL,
|
||||||
"shrink", (int) factor,
|
"shrink", (int) factor,
|
||||||
@ -1305,7 +1305,7 @@ vips_thumbnail_stream_open( VipsThumbnail *thumbnail, double factor )
|
|||||||
else if( vips_isprefix( "VipsForeignLoadOpenslide",
|
else if( vips_isprefix( "VipsForeignLoadOpenslide",
|
||||||
thumbnail->loader ) ) {
|
thumbnail->loader ) ) {
|
||||||
return( vips_image_new_from_stream(
|
return( vips_image_new_from_stream(
|
||||||
stream->input,
|
stream->streami,
|
||||||
stream->option_string,
|
stream->option_string,
|
||||||
"access", VIPS_ACCESS_SEQUENTIAL,
|
"access", VIPS_ACCESS_SEQUENTIAL,
|
||||||
"level", (int) factor,
|
"level", (int) factor,
|
||||||
@ -1315,7 +1315,7 @@ vips_thumbnail_stream_open( VipsThumbnail *thumbnail, double factor )
|
|||||||
vips_isprefix( "VipsForeignLoadSvg", thumbnail->loader ) ||
|
vips_isprefix( "VipsForeignLoadSvg", thumbnail->loader ) ||
|
||||||
vips_isprefix( "VipsForeignLoadWebp", thumbnail->loader ) ) {
|
vips_isprefix( "VipsForeignLoadWebp", thumbnail->loader ) ) {
|
||||||
return( vips_image_new_from_stream(
|
return( vips_image_new_from_stream(
|
||||||
stream->input,
|
stream->streami,
|
||||||
stream->option_string,
|
stream->option_string,
|
||||||
"access", VIPS_ACCESS_SEQUENTIAL,
|
"access", VIPS_ACCESS_SEQUENTIAL,
|
||||||
"scale", 1.0 / factor,
|
"scale", 1.0 / factor,
|
||||||
@ -1323,7 +1323,7 @@ vips_thumbnail_stream_open( VipsThumbnail *thumbnail, double factor )
|
|||||||
}
|
}
|
||||||
else if( vips_isprefix( "VipsForeignLoadTiff", thumbnail->loader ) ) {
|
else if( vips_isprefix( "VipsForeignLoadTiff", thumbnail->loader ) ) {
|
||||||
return( vips_image_new_from_stream(
|
return( vips_image_new_from_stream(
|
||||||
stream->input,
|
stream->streami,
|
||||||
stream->option_string,
|
stream->option_string,
|
||||||
"access", VIPS_ACCESS_SEQUENTIAL,
|
"access", VIPS_ACCESS_SEQUENTIAL,
|
||||||
"page", (int) factor,
|
"page", (int) factor,
|
||||||
@ -1331,7 +1331,7 @@ vips_thumbnail_stream_open( VipsThumbnail *thumbnail, double factor )
|
|||||||
}
|
}
|
||||||
else if( vips_isprefix( "VipsForeignLoadHeif", thumbnail->loader ) ) {
|
else if( vips_isprefix( "VipsForeignLoadHeif", thumbnail->loader ) ) {
|
||||||
return( vips_image_new_from_stream(
|
return( vips_image_new_from_stream(
|
||||||
stream->input,
|
stream->streami,
|
||||||
stream->option_string,
|
stream->option_string,
|
||||||
"access", VIPS_ACCESS_SEQUENTIAL,
|
"access", VIPS_ACCESS_SEQUENTIAL,
|
||||||
"thumbnail", (int) factor,
|
"thumbnail", (int) factor,
|
||||||
@ -1339,7 +1339,7 @@ vips_thumbnail_stream_open( VipsThumbnail *thumbnail, double factor )
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return( vips_image_new_from_stream(
|
return( vips_image_new_from_stream(
|
||||||
stream->input,
|
stream->streami,
|
||||||
stream->option_string,
|
stream->option_string,
|
||||||
"access", VIPS_ACCESS_SEQUENTIAL,
|
"access", VIPS_ACCESS_SEQUENTIAL,
|
||||||
NULL ) );
|
NULL ) );
|
||||||
@ -1362,11 +1362,11 @@ vips_thumbnail_stream_class_init( VipsThumbnailClass *class )
|
|||||||
thumbnail_class->get_info = vips_thumbnail_stream_get_info;
|
thumbnail_class->get_info = vips_thumbnail_stream_get_info;
|
||||||
thumbnail_class->open = vips_thumbnail_stream_open;
|
thumbnail_class->open = vips_thumbnail_stream_open;
|
||||||
|
|
||||||
VIPS_ARG_OBJECT( class, "input", 1,
|
VIPS_ARG_OBJECT( class, "streami", 1,
|
||||||
_( "Input" ),
|
_( "Streami" ),
|
||||||
_( "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, streami ),
|
||||||
VIPS_TYPE_STREAMI );
|
VIPS_TYPE_STREAMI );
|
||||||
|
|
||||||
VIPS_ARG_STRING( class, "option_string", 20,
|
VIPS_ARG_STRING( class, "option_string", 20,
|
||||||
@ -1385,7 +1385,7 @@ vips_thumbnail_stream_init( VipsThumbnailStream *stream )
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* vips_thumbnail_stream:
|
* vips_thumbnail_stream:
|
||||||
* @input: stream to thumbnail
|
* @streami: stream to thumbnail
|
||||||
* @out: (out): output image
|
* @out: (out): output image
|
||||||
* @width: target width in pixels
|
* @width: target width in pixels
|
||||||
* @...: %NULL-terminated list of optional named arguments
|
* @...: %NULL-terminated list of optional named arguments
|
||||||
@ -1408,13 +1408,13 @@ 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( VipsStreami *input, VipsImage **out, int width, ... )
|
vips_thumbnail_stream( VipsStreami *streami, VipsImage **out, int width, ... )
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
va_start( ap, width );
|
va_start( ap, width );
|
||||||
result = vips_call_split( "thumbnail_stream", ap, input, out, width );
|
result = vips_call_split( "thumbnail_stream", ap, streami, out, width );
|
||||||
va_end( ap );
|
va_end( ap );
|
||||||
|
|
||||||
return( result );
|
return( result );
|
||||||
|
Loading…
Reference in New Issue
Block a user