more auto unpack hacking

This commit is contained in:
John Cupitt 2014-01-23 13:19:37 +00:00
parent c3b16d6ff2
commit affb274d85
7 changed files with 93 additions and 49 deletions

52
TODO
View File

@ -1,3 +1,55 @@
- try:
$ vips falsecolour k2.jpg x.jpg
vips warning: VipsJpeg: read gave 896 warnings
vips warning: VipsJpeg: Application transferred too many scanlines
seems to read twice?
problem in 7.38 too
- check_uncoded() left to do:
conversion/falsecolour.c
conversion/flatten.c
conversion/recomb.c
convolution/sharpen.c
deprecated/im_gradcor.c
deprecated/im_lab_morph.c
deprecated/im_maxpos_avg.c
deprecated/im_measure.c
deprecated/im_vips2mask.c
deprecated/im_zerox.c
deprecated/rename.c
deprecated/tone.c
deprecated/vips7compat.c
foreign/csv.c
foreign/ppm.c
freqfilt/fwfft.c
freqfilt/invfft.c
histogram/hist_local.c
histogram/histogram.c
histogram/hist_plot.c
histogram/maplut.c
histogram/stdif.c
inplace/flood.c
inplace/im_draw_mask.c
inplace/inplace_dispatch.c
iofuncs/error.c
morphology/hitmiss.c
resample/quadratic.c
- 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

@ -130,7 +130,7 @@ vips_hist_find_indexed_build( VipsObject *object )
VipsObjectClass *class = VIPS_OBJECT_GET_CLASS( object );
VipsStatistic *statistic = VIPS_STATISTIC( object );
VipsHistFindIndexed *indexed = (VipsHistFindIndexed *) object;
VipsImage **t = (VipsImage **) vips_object_local_array( object, 1 );
VipsImage **t = (VipsImage **) vips_object_local_array( object, 2 );
g_object_set( object,
"out", vips_image_new(),

View File

@ -50,6 +50,7 @@
#include <vips/vips.h>
#include <vips/debug.h>
#include <vips/internal.h>
#include "statistic.h"
@ -109,9 +110,7 @@ vips_statistic_build( VipsObject *object )
{
VipsStatistic *statistic = VIPS_STATISTIC( object );
VipsStatisticClass *sclass = VIPS_STATISTIC_GET_CLASS( statistic );
VipsObjectClass *class = VIPS_OBJECT_GET_CLASS( object );
const char *domain = class->nickname;
VipsImage **t = (VipsImage **) vips_object_local_array( object, 1 );
VipsImage **t = (VipsImage **) vips_object_local_array( object, 2 );
#ifdef DEBUG
printf( "vips_statistic_build: " );
@ -122,20 +121,20 @@ vips_statistic_build( VipsObject *object )
if( VIPS_OBJECT_CLASS( vips_statistic_parent_class )->build( object ) )
return( -1 );
statistic->ready = statistic->in;
if( vips__image_decode( statistic->ready, &t[0] ) )
return( -1 );
statistic->ready = t[0];
/* If there's a format table, cast the input.
*/
if( sclass->format_table ) {
if( vips_cast( statistic->in, &t[0],
if( vips_cast( statistic->ready, &t[1],
sclass->format_table[statistic->in->BandFmt], NULL ) )
return( -1 );
statistic->ready = t[0];
statistic->ready = t[1];
}
else
statistic->ready = statistic->in;
if( vips_image_pio_input( statistic->ready ) ||
vips_check_uncoded( domain, statistic->ready ) )
return( -1 );
if( vips_sink( statistic->ready,
vips_statistic_scan_start,

View File

@ -627,30 +627,18 @@ vips_colour_difference_build( VipsObject *object )
right = difference->right;
extra = NULL;
/* Unpack LABQ images,
*/
if( left &&
left->Coding == VIPS_CODING_LABQ ) {
if( vips_LabQ2Lab( left, &t[0], NULL ) )
if( left ) {
if( vips__image_decode( left, &t[0] ) )
return( -1 );
left = t[0];
}
if( right &&
right->Coding == VIPS_CODING_LABQ ) {
if( vips_LabQ2Lab( right, &t[1], NULL ) )
if( right ) {
if( vips__image_decode( right, &t[1] ) )
return( -1 );
right = t[1];
}
if( left &&
vips_check_uncoded( VIPS_OBJECT_CLASS( class )->nickname,
left ) )
return( -1 );
if( right &&
vips_check_uncoded( VIPS_OBJECT_CLASS( class )->nickname,
right ) )
return( -1 );
/* Detach and reattach extra bands, if any. If both left and right
* have extra bands, give up.
*/

View File

@ -123,6 +123,7 @@ vips_bandary_build( VipsObject *object )
VipsBandary *bandary = (VipsBandary *) object;
int i;
VipsImage **decode;
VipsImage **format;
VipsImage **size;
@ -139,14 +140,15 @@ vips_bandary_build( VipsObject *object )
"%s", _( "too many input images" ) );
return( -1 );
}
for( i = 0; i < bandary->n; i++ )
if( vips_image_pio_input( bandary->in[i] ) ||
vips_check_uncoded( class->nickname, bandary->in[i] ) )
return( -1 );
decode = (VipsImage **) vips_object_local_array( object, bandary->n );
format = (VipsImage **) vips_object_local_array( object, bandary->n );
size = (VipsImage **) vips_object_local_array( object, bandary->n );
if( vips__formatalike_vec( bandary->in, format, bandary->n ) ||
for( i = 0; i < bandary->n; 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 ) )
return( -1 );
bandary->ready = size;

View File

@ -429,36 +429,41 @@ vips_cast_gen( VipsRegion *or, void *vseq, void *a, void *b,
static int
vips_cast_build( VipsObject *object )
{
VipsObjectClass *class = VIPS_OBJECT_GET_CLASS( object );
VipsConversion *conversion = VIPS_CONVERSION( object );
VipsCast *cast = (VipsCast *) object;
VipsImage **t = (VipsImage **)
vips_object_local_array( object, 2 );
VipsImage *in;
if( VIPS_OBJECT_CLASS( vips_cast_parent_class )->build( object ) )
return( -1 );
in = cast->in;
/* Trivial case: fall back to copy().
*/
if( cast->in->BandFmt == cast->format )
return( vips_image_write( cast->in, conversion->out ) );
if( in->BandFmt == cast->format )
return( vips_image_write( in, conversion->out ) );
if( vips_check_uncoded( class->nickname, cast->in ) ||
vips_image_pio_input( cast->in ) )
if( vips__image_decode( in, &t[0] ) )
return( -1 );
in = t[0];
if( vips_image_pipelinev( conversion->out,
VIPS_DEMAND_STYLE_THINSTRIP, cast->in, NULL ) )
VIPS_DEMAND_STYLE_THINSTRIP, in, NULL ) )
return( -1 );
conversion->out->BandFmt = cast->format;
g_signal_connect( cast->in, "preeval",
g_signal_connect( in, "preeval",
G_CALLBACK( vips_cast_preeval ), cast );
g_signal_connect( cast->in, "posteval",
g_signal_connect( in, "posteval",
G_CALLBACK( vips_cast_posteval ), cast );
if( vips_image_generate( conversion->out,
vips_cast_start, vips_cast_gen, vips_cast_stop,
cast->in, cast ) )
in, cast ) )
return( -1 );
return( 0 );

View File

@ -329,10 +329,9 @@ static unsigned char vips_falsecolour_pet[][3] = {
static int
vips_falsecolour_build( VipsObject *object )
{
VipsObjectClass *class = VIPS_OBJECT_GET_CLASS( object );
VipsConversion *conversion = VIPS_CONVERSION( object );
VipsFalsecolour *falsecolour = (VipsFalsecolour *) object;
VipsImage **t = (VipsImage **) vips_object_local_array( object, 4 );
VipsImage **t = (VipsImage **) vips_object_local_array( object, 5 );
if( VIPS_OBJECT_CLASS( vips_falsecolour_parent_class )->
build( object ) )
@ -345,10 +344,9 @@ vips_falsecolour_build( VipsObject *object )
/* Force to mono 8-bit.
*/
if( vips_check_uncoded( class->nickname, falsecolour->in ) ||
vips_extract_band( falsecolour->in, &t[1], 0, NULL ) ||
vips_cast( t[1], &t[2], VIPS_FORMAT_UCHAR, NULL ) ||
vips_maplut( falsecolour->in, &t[3], t[0], NULL ) ||
if( vips_colourspace( falsecolour->in, &t[1],
VIPS_INTERPRETATION_B_W, NULL ) ||
vips_maplut( t[1], &t[3], t[0], NULL ) ||
vips_image_write( t[3], conversion->out ) )
return( -1 );