complex lut was broken

This commit is contained in:
John Cupitt 2014-05-21 17:34:53 +01:00
parent 087eb233f7
commit c3caa595a2
3 changed files with 47 additions and 45 deletions

11
TODO
View File

@ -1,14 +1,3 @@
- should we decode to LAB, rather than LABS, by default?
causing all sorts of problems
- have a decode-to-float flag?
- when do we want LABS? for speed in conv ... have a special unpacker there?
any time we won't be breaking bands apart or using a constant, I guess?
- change measure to use the regular decoder
- quickly wrap the useful bits of mosaicing/

View File

@ -862,14 +862,22 @@ vips_complexform_buffer( VipsArithmetic *arithmetic,
* below.
*/
switch( vips_image_get_format( im ) ) {
case VIPS_FORMAT_CHAR: CFORM( signed char, float ); break;
case VIPS_FORMAT_UCHAR: CFORM( unsigned char, float ); break;
case VIPS_FORMAT_SHORT: CFORM( signed short, float ); break;
case VIPS_FORMAT_USHORT:CFORM( unsigned short, float ); break;
case VIPS_FORMAT_INT: CFORM( signed int, float ); break;
case VIPS_FORMAT_UINT: CFORM( unsigned int, float ); break;
case VIPS_FORMAT_FLOAT: CFORM( float, float ); break;
case VIPS_FORMAT_DOUBLE: CFORM( double, double ); break;
case VIPS_FORMAT_UCHAR:
CFORM( unsigned char, float ); break;
case VIPS_FORMAT_CHAR:
CFORM( signed char, float ); break;
case VIPS_FORMAT_USHORT:
CFORM( unsigned short, float ); break;
case VIPS_FORMAT_SHORT:
CFORM( signed short, float ); break;
case VIPS_FORMAT_UINT:
CFORM( unsigned int, float ); break;
case VIPS_FORMAT_INT:
CFORM( signed int, float ); break;
case VIPS_FORMAT_FLOAT:
CFORM( float, float ); break;
case VIPS_FORMAT_DOUBLE:
CFORM( double, double ); break;
default:
g_assert( 0 );
@ -889,7 +897,7 @@ vips_complexform_buffer( VipsArithmetic *arithmetic,
#define D VIPS_FORMAT_DOUBLE
#define DX VIPS_FORMAT_DPCOMPLEX
/* Type promotion for division. Sign and value preserving. Make sure
/* Type promotion for form complex. Sign and value preserving. Make sure
* these match the case statement in complexform_buffer() above.
*/
static int vips_complexform_format_table[10] = {

View File

@ -529,6 +529,33 @@ static int bandfmt_maplut[10] = {
} \
}
#define PACK_TABLEC( TYPE ) { \
TYPE *data = (TYPE *) lut->data; \
int x, b; \
\
for( x = 0; x < maplut->sz; x++ ) \
for( b = 0; b < maplut->nb; b++ ) { \
TYPE *q = (TYPE *) maplut->table[b]; \
\
if( maplut->band >= 0 && \
lut->Bands == 1 ) { \
if( b == maplut->band ) { \
q[2 * x] = data[2 * x]; \
q[2 * x + 1] = data[2 * x + 1]; \
} \
else { \
q[2 * x] = x; \
q[2 * x + 1] = 0; \
} \
} \
else { \
q[2 * x] = data[2 * (x * lut->Bands + b)]; \
q[2 * x + 1] = \
data[2 * (x * lut->Bands + b) + 1]; \
} \
} \
}
static int
vips_maplut_build( VipsObject *object )
{
@ -614,29 +641,7 @@ vips_maplut_build( VipsObject *object )
case VIPS_FORMAT_CHAR:
PACK_TABLE( char ); break;
case VIPS_FORMAT_USHORT:
{
unsigned short *data = (unsigned short *) lut->data;
int x, b;
for( x = 0; x < maplut->sz; x++ )
for( b = 0; b < maplut->nb; b++ ) {
unsigned short *q = (unsigned short *) maplut->table[b];
if( maplut->band >= 0 &&
lut->Bands == 1 ) {
if( b == maplut->band )
q[x] = data[x];
else
q[x] = x;
}
else
q[x] = data[x * lut->Bands + b];
}
}
//PACK_TABLE( unsigned short ); break;
break;
PACK_TABLE( unsigned short ); break;
case VIPS_FORMAT_SHORT:
PACK_TABLE( short ); break;
case VIPS_FORMAT_UINT:
@ -648,9 +653,9 @@ vips_maplut_build( VipsObject *object )
case VIPS_FORMAT_DOUBLE:
PACK_TABLE( double ); break;
case VIPS_FORMAT_COMPLEX:
PACK_TABLE( float ); break;
PACK_TABLEC( float ); break;
case VIPS_FORMAT_DPCOMPLEX:
PACK_TABLE( double ); break;
PACK_TABLEC( double ); break;
default:
g_assert( 0 );
}