move vips_image_decode() into the public API

This commit is contained in:
John Cupitt 2014-02-03 14:29:57 +00:00
parent b72818a2b8
commit fb489bad53
23 changed files with 53 additions and 60 deletions

View File

@ -1,5 +1,5 @@
21/1/14 started 7.39.0
- auto-decode for (almost) all operations
- auto-decode for (almost) all operations, see vips_image_decode()
- background render thread cleans up and quits neatly
- colourspace has a source_space option
- operations can be tagged as "deprecated"

17
TODO
View File

@ -1,21 +1,4 @@
- check_uncoded() left to do:
resample/quadratic.c
- move vips__image_decode() into the public API
- we vips_image_write() a lot, could we do this by
int
vips_image_write( in, out )
{
g_object_ref( in)
vips_object_local( out,in )
}
i.e. do everything at pipe build time
- inplace
can we set a region for the pixels we will modify?

View File

@ -539,7 +539,7 @@ vips_arithmetic_build( VipsObject *object )
/* Decode RAD/LABQ etc.
*/
for( i = 0; i < arithmetic->n; i++ )
if( vips__image_decode( arithmetic->in[i], &decode[i] ) )
if( vips_image_decode( arithmetic->in[i], &decode[i] ) )
return( -1 );
/* Cast our input images up to a common format, bands and size.

View File

@ -123,7 +123,7 @@ vips_statistic_build( VipsObject *object )
statistic->ready = statistic->in;
if( vips__image_decode( statistic->ready, &t[0] ) )
if( vips_image_decode( statistic->ready, &t[0] ) )
return( -1 );
statistic->ready = t[0];

View File

@ -628,13 +628,13 @@ vips_colour_difference_build( VipsObject *object )
extra = NULL;
if( left ) {
if( vips__image_decode( left, &t[0] ) )
if( vips_image_decode( left, &t[0] ) )
return( -1 );
left = t[0];
}
if( right ) {
if( vips__image_decode( right, &t[1] ) )
if( vips_image_decode( right, &t[1] ) )
return( -1 );
right = t[1];
}

View File

@ -146,7 +146,7 @@ vips_bandary_build( VipsObject *object )
size = (VipsImage **) vips_object_local_array( object, bandary->n );
for( i = 0; i < bandary->n; i++ )
if( vips__image_decode( bandary->in[i], &decode[i] ) )
if( vips_image_decode( bandary->in[i], &decode[i] ) )
return( -1 );
if( vips__formatalike_vec( decode, format, bandary->n ) ||
vips__sizealike_vec( format, size, bandary->n ) )

View File

@ -446,7 +446,7 @@ vips_cast_build( VipsObject *object )
if( in->BandFmt == cast->format )
return( vips_image_write( in, conversion->out ) );
if( vips__image_decode( in, &t[0] ) )
if( vips_image_decode( in, &t[0] ) )
return( -1 );
in = t[0];

View File

@ -349,7 +349,7 @@ vips_falsecolour_build( VipsObject *object )
* want to work for images which aren't in a recognised space, like
* MULTIBAND.
*/
if( vips__image_decode( falsecolour->in, &t[1] ) ||
if( vips_image_decode( falsecolour->in, &t[1] ) ||
vips_extract_band( t[1], &t[2], 0, NULL ) ||
vips_cast( t[2], &t[3], VIPS_FORMAT_UCHAR, NULL ) ||
vips_maplut( t[3], &t[4], t[0], NULL ) ||

View File

@ -311,7 +311,7 @@ vips_flatten_build( VipsObject *object )
in = flatten->in;
if( vips__image_decode( in, &t[0] ) )
if( vips_image_decode( in, &t[0] ) )
return( -1 );
in = t[0];

View File

@ -150,7 +150,7 @@ vips_recomb_build( VipsObject *object )
in = recomb->in;
if( vips__image_decode( in, &t[0] ) )
if( vips_image_decode( in, &t[0] ) )
return( -1 );
in = t[0];

View File

@ -94,7 +94,7 @@ vips_conv_build( VipsObject *object )
/* Unpack for processing.
*/
if( vips__image_decode( in, &t[0] ) )
if( vips_image_decode( in, &t[0] ) )
return( -1 );
in = t[0];

View File

@ -303,7 +303,7 @@ vips_fwfft_build( VipsObject *object )
in = freqfilt->in;
if( vips__image_decode( in, &t[0] ) )
if( vips_image_decode( in, &t[0] ) )
return( -1 );
in = t[0];

View File

@ -216,7 +216,7 @@ vips_invfft_build( VipsObject *object )
in = freqfilt->in;
if( vips__image_decode( in, &t[0] ) )
if( vips_image_decode( in, &t[0] ) )
return( -1 );
in = t[0];

View File

@ -236,7 +236,7 @@ vips_hist_local_build( VipsObject *object )
in = local->in;
if( vips__image_decode( in, &t[0] ) )
if( vips_image_decode( in, &t[0] ) )
return( -1 );
in = t[0];

View File

@ -143,7 +143,7 @@ vips_histogram_build( VipsObject *object )
g_object_set( histogram, "out", vips_image_new(), NULL );
for( i = 0; i < histogram->n; i++ )
if( vips__image_decode( histogram->in[i], &decode[i] ) ||
if( vips_image_decode( histogram->in[i], &decode[i] ) ||
vips_check_hist( class->nickname, decode[i] ) )
return( -1 );

View File

@ -224,7 +224,7 @@ vips_stdif_build( VipsObject *object )
in = stdif->in;
if( vips__image_decode( in, &t[0] ) )
if( vips_image_decode( in, &t[0] ) )
return( -1 );
in = t[0];

View File

@ -430,6 +430,8 @@ VipsImage *vips_image_new_temp_file( const char *format );
int vips_image_write( VipsImage *image, VipsImage *out );
int vips_image_write_to_file( VipsImage *image, const char *filename );
int vips_image_decode( VipsImage *in, VipsImage **out );
gboolean vips_image_isMSBfirst( VipsImage *image );
gboolean vips_image_isfile( VipsImage *image );
gboolean vips_image_ispartial( VipsImage *image );

View File

@ -297,8 +297,6 @@ IMAGE *vips__deprecated_open_write( const char *filename );
int vips__input_interpolate_init( im_object *obj, char *str );
int vips__image_decode( VipsImage *in, VipsImage **out );
#ifdef __cplusplus
}
#endif /*__cplusplus*/

View File

@ -1997,6 +1997,37 @@ vips_image_write_to_file( VipsImage *image, const char *filename )
return( 0 );
}
/**
* vips_image_decode:
* @in: image to decode
* @out: write to this image
*
* A convenience function to unpack to a format that we can compute with.
* @out->Coding is always VIPS_CODING_NONE.
*
* See also: vips_LabQ2LabS(), vips_rad2float().
*
* Returns: 0 on success, or -1 on error.
*/
int
vips_image_decode( VipsImage *in, VipsImage **out )
{
if( in->Coding == VIPS_CODING_LABQ ) {
if( vips_LabQ2LabS( in, out, NULL ) )
return( -1 );
}
else if( in->Coding == VIPS_CODING_RAD ) {
if( vips_rad2float( in, out, NULL ) )
return( -1 );
}
else {
if( vips_copy( in, out, NULL ) )
return( -1 );
}
return( 0 );
}
/**
* vips_image_isMSBfirst:
* @image: image to test

View File

@ -93,7 +93,7 @@ vips_morph_build( VipsObject *object )
in = morphology->in;
if( vips__image_decode( in, &t[0] ) )
if( vips_image_decode( in, &t[0] ) )
return( -1 );
in = t[0];

View File

@ -341,7 +341,7 @@ vips_rank_build( VipsObject *object )
in = morphology->in;
if( vips__image_decode( in, &t[0] ) )
if( vips_image_decode( in, &t[0] ) )
return( -1 );
in = t[0];

View File

@ -375,27 +375,6 @@ vips_affine_gen( VipsRegion *or, void *seq, void *a, void *b, gboolean *stop )
return( 0 );
}
/* Unpack to a format that we can compute with.
*/
int
vips__image_decode( VipsImage *in, VipsImage **out )
{
if( in->Coding == VIPS_CODING_LABQ ) {
if( vips_LabQ2LabS( in, out, NULL ) )
return( -1 );
}
else if( in->Coding == VIPS_CODING_RAD ) {
if( vips_rad2float( in, out, NULL ) )
return( -1 );
}
else {
if( vips_copy( in, out, NULL ) )
return( -1 );
}
return( 0 );
}
static int
vips_affine_build( VipsObject *object )
{
@ -485,7 +464,7 @@ vips_affine_build( VipsObject *object )
return( -1 );
}
if( vips__image_decode( in, &t[0] ) )
if( vips_image_decode( in, &t[0] ) )
return( -1 );
in = t[0];

View File

@ -347,7 +347,7 @@ vips_shrink_build( VipsObject *object )
/* Unpack for processing.
*/
if( vips__image_decode( in, &t[0] ) )
if( vips_image_decode( in, &t[0] ) )
return( -1 );
in = t[0];