more gen/it hacks
This commit is contained in:
parent
57f24c63d6
commit
20d83b9af2
4
TODO
4
TODO
@ -4,6 +4,10 @@
|
|||||||
|
|
||||||
also, same problem as maxpos_avg re. uninit data?
|
also, same problem as maxpos_avg re. uninit data?
|
||||||
|
|
||||||
|
- im_spcor2() has a potential leak in the start function
|
||||||
|
|
||||||
|
- zerox_gen() passes an int as a void*, hmm
|
||||||
|
|
||||||
Python binding
|
Python binding
|
||||||
==============
|
==============
|
||||||
|
|
||||||
|
@ -109,9 +109,9 @@ typedef struct {
|
|||||||
|
|
||||||
} spcor2_w_inf;
|
} spcor2_w_inf;
|
||||||
|
|
||||||
static spcor2_seq *spcor2_start( IMAGE *r, IMAGE *f );
|
static void *spcor2_start( IMAGE *r, void *a, void *b );
|
||||||
static int spcor2_gen( REGION *r, spcor2_seq *seq, void *unrequired, spcor2_w_inf *w_inf );
|
static int spcor2_gen( REGION *r, void *seq, void *a, void *b );
|
||||||
static int spcor2_stop( spcor2_seq *seq );
|
static int spcor2_stop( void *seq, void *a, void *b );
|
||||||
|
|
||||||
#define LOOP(IN) \
|
#define LOOP(IN) \
|
||||||
{ \
|
{ \
|
||||||
@ -156,8 +156,10 @@ static int spcor2_stop( spcor2_seq *seq );
|
|||||||
/* spcor generate function.
|
/* spcor generate function.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
spcor_gen( REGION *or, REGION *ir, IMAGE *in, SpcorInfo *inf )
|
spcor_gen( REGION *or, void *seq, void *a, void *b )
|
||||||
{
|
{
|
||||||
|
REGION *ir = (REGION *) seq;
|
||||||
|
SpcorInfo *inf = (SpcorInfo *) b;
|
||||||
IMAGE *ref = inf->ref;
|
IMAGE *ref = inf->ref;
|
||||||
Rect irect;
|
Rect irect;
|
||||||
Rect *r = &or->valid;
|
Rect *r = &or->valid;
|
||||||
@ -399,14 +401,15 @@ im_spcor2_raw(
|
|||||||
|
|
||||||
im_free_dmask( w_stats );
|
im_free_dmask( w_stats );
|
||||||
|
|
||||||
return im_generate( r, (void*)spcor2_start, spcor2_gen, spcor2_stop, f, w_inf );
|
return im_generate( r, spcor2_start, spcor2_gen, spcor2_stop, f, w_inf );
|
||||||
|
|
||||||
#undef FUNCTION_NAME
|
#undef FUNCTION_NAME
|
||||||
}
|
}
|
||||||
|
|
||||||
static spcor2_seq *
|
static void *
|
||||||
spcor2_start( IMAGE *r, IMAGE *f ){
|
spcor2_start( IMAGE *r, void *a, void *b ){
|
||||||
|
|
||||||
|
IMAGE *f= (IMAGE *) a;
|
||||||
REGION *reg= im_region_create( f );
|
REGION *reg= im_region_create( f );
|
||||||
spcor2_seq *seq;
|
spcor2_seq *seq;
|
||||||
|
|
||||||
@ -427,11 +430,11 @@ spcor2_start( IMAGE *r, IMAGE *f ){
|
|||||||
static int
|
static int
|
||||||
spcor2_gen(
|
spcor2_gen(
|
||||||
REGION *r,
|
REGION *r,
|
||||||
spcor2_seq *seq,
|
void *vseq, void *a, void *b
|
||||||
void *unrequired,
|
|
||||||
spcor2_w_inf *w_inf
|
|
||||||
){
|
){
|
||||||
|
|
||||||
|
spcor2_seq *seq= (spcor2_seq *) vseq;
|
||||||
|
spcor2_w_inf *w_inf= (spcor2_w_inf *) b;
|
||||||
Rect need= {
|
Rect need= {
|
||||||
r-> valid. left,
|
r-> valid. left,
|
||||||
r-> valid. top,
|
r-> valid. top,
|
||||||
@ -521,7 +524,9 @@ spcor2_gen(
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
spcor2_stop( spcor2_seq *seq ){
|
spcor2_stop( void *vseq, void *a, void *b ){
|
||||||
|
|
||||||
|
spcor2_seq *seq= (spcor2_seq *) vseq;
|
||||||
|
|
||||||
im_region_free( seq-> f );
|
im_region_free( seq-> f );
|
||||||
im_free( seq-> f_cols );
|
im_free( seq-> f_cols );
|
||||||
|
@ -86,22 +86,23 @@ typedef struct seq_info {
|
|||||||
} SeqInfo;
|
} SeqInfo;
|
||||||
|
|
||||||
static int
|
static int
|
||||||
stop_stretch( SeqInfo *seq )
|
stretch_stop( void *vseq, void *a, void *b )
|
||||||
{
|
{
|
||||||
if( seq->ir ) {
|
SeqInfo *seq = (SeqInfo *) vseq;
|
||||||
im_region_free( seq->ir );
|
|
||||||
seq->ir = NULL;
|
IM_FREEF( im_region_free, seq->ir );
|
||||||
}
|
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *
|
static void *
|
||||||
start_stretch( IMAGE *out, IMAGE *in, StretchInfo *sin )
|
stretch_start( IMAGE *out, void *a, void *b )
|
||||||
{
|
{
|
||||||
SeqInfo *seq = IM_NEW( out, SeqInfo );
|
IMAGE *in = (IMAGE *) a;
|
||||||
|
StretchInfo *sin = (StretchInfo *) b;
|
||||||
|
SeqInfo *seq;
|
||||||
|
|
||||||
if( !seq )
|
if( !(seq = IM_NEW( out, SeqInfo )) )
|
||||||
return( NULL );
|
return( NULL );
|
||||||
|
|
||||||
seq->sin = sin;
|
seq->sin = sin;
|
||||||
@ -110,7 +111,7 @@ start_stretch( IMAGE *out, IMAGE *in, StretchInfo *sin )
|
|||||||
seq->buf = IM_ARRAY( out, 4*seq->lsk, unsigned short );
|
seq->buf = IM_ARRAY( out, 4*seq->lsk, unsigned short );
|
||||||
|
|
||||||
if( !seq->buf || !seq->ir ) {
|
if( !seq->buf || !seq->ir ) {
|
||||||
stop_stretch( seq );
|
stretch_stop( seq, NULL, NULL );
|
||||||
return( NULL );
|
return( NULL );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,8 +192,10 @@ make_yline( StretchInfo *sin, int lsk, int boff,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
stretch_gen( REGION *or, SeqInfo *seq, IMAGE *in, StretchInfo *sin )
|
stretch_gen( REGION *or, void *vseq, void *a, void *b )
|
||||||
{
|
{
|
||||||
|
SeqInfo *seq = (SeqInfo *) vseq;
|
||||||
|
StretchInfo *sin = (StretchInfo *) b;
|
||||||
REGION *ir = seq->ir;
|
REGION *ir = seq->ir;
|
||||||
Rect *r = &or->valid;
|
Rect *r = &or->valid;
|
||||||
Rect r1;
|
Rect r1;
|
||||||
@ -265,11 +268,12 @@ im_stretch3( IMAGE *in, IMAGE *out, double dx, double dy )
|
|||||||
/* Check our args.
|
/* Check our args.
|
||||||
*/
|
*/
|
||||||
if( in->Coding != IM_CODING_NONE || in->BandFmt != IM_BANDFMT_USHORT ) {
|
if( in->Coding != IM_CODING_NONE || in->BandFmt != IM_BANDFMT_USHORT ) {
|
||||||
im_errormsg( "im_stretch3: not uncoded unsigned short" );
|
im_error( "im_stretch3", _( "not uncoded unsigned short" ) );
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
if( dx < 0 || dx >= 1.0 || dy < 0 || dy >= 1.0 ) {
|
if( dx < 0 || dx >= 1.0 || dy < 0 || dy >= 1.0 ) {
|
||||||
im_errormsg( "im_stretch3: displacements out of range [0,1)" );
|
im_error( "im_stretch3",
|
||||||
|
_( "displacements out of range [0,1)" ) );
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
if( im_piocheck( in, out ) )
|
if( im_piocheck( in, out ) )
|
||||||
@ -316,7 +320,7 @@ im_stretch3( IMAGE *in, IMAGE *out, double dx, double dy )
|
|||||||
sin->yoff = (dy * 33.0) + 0.5;
|
sin->yoff = (dy * 33.0) + 0.5;
|
||||||
|
|
||||||
if( im_generate( out,
|
if( im_generate( out,
|
||||||
start_stretch, stretch_gen, stop_stretch, in, sin ) )
|
stretch_start, stretch_gen, stretch_stop, in, sin ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
|
@ -67,7 +67,7 @@
|
|||||||
#define loop( TYPE ) \
|
#define loop( TYPE ) \
|
||||||
for( i = 0; i < ne; i++ ) { \
|
for( i = 0; i < ne; i++ ) { \
|
||||||
TYPE p1 = ((TYPE *)p)[i]; \
|
TYPE p1 = ((TYPE *)p)[i]; \
|
||||||
TYPE p2 = ((TYPE *)p)[i + b]; \
|
TYPE p2 = ((TYPE *)p)[i + ba]; \
|
||||||
\
|
\
|
||||||
if( flag == 1 && p1 > 0 && p2 <= 0 ) \
|
if( flag == 1 && p1 > 0 && p2 <= 0 ) \
|
||||||
q[i] = 255; \
|
q[i] = 255; \
|
||||||
@ -80,8 +80,11 @@
|
|||||||
/* Zerox generate function.
|
/* Zerox generate function.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
zerox_gen( REGION *or, REGION *ir, IMAGE *in, int flag )
|
zerox_gen( REGION *or, void *seq, void *a, void *b )
|
||||||
{
|
{
|
||||||
|
REGION *ir = (REGION *) seq;
|
||||||
|
IMAGE *in = (IMAGE *) a;
|
||||||
|
int flag = (int) b;
|
||||||
Rect irect;
|
Rect irect;
|
||||||
Rect *r = &or->valid;
|
Rect *r = &or->valid;
|
||||||
|
|
||||||
@ -90,8 +93,8 @@ zerox_gen( REGION *or, REGION *ir, IMAGE *in, int flag )
|
|||||||
int le = r->left;
|
int le = r->left;
|
||||||
int to = r->top;
|
int to = r->top;
|
||||||
int bo = IM_RECT_BOTTOM( r );
|
int bo = IM_RECT_BOTTOM( r );
|
||||||
int b = in->Bands;
|
int ba = in->Bands;
|
||||||
int ne = b * r->width;
|
int ne = ba * r->width;
|
||||||
|
|
||||||
int i, y;
|
int i, y;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user