#include #include #include #include #include "fce.c" #define Xres 800 #define Yres 600 #ifdef FCE_COMPILE_I8 # define FCE_TYPE unsigned char # define T(f) f##_i8 #elif defined FCE_COMPILE_F32 # define FCE_TYPE float # define T(f) f##_f32 #elif defined FCE_COMPILE_I16 # define FCE_TYPE unsigned short # define T(f) f##_i16 #endif BITMAP *bmp, *bmp2; volatile int tck; void tick() { tck++; } END_OF_FUNCTION(tick); int main( int argc, char **argv ) { allegro_init(); install_keyboard(); install_timer(); LOCK_VARIABLE( tck ); LOCK_FUNCTION( tick ); assert( !install_int( tick, 1 ) ); set_color_depth( 32 ); assert( argc>1 ); assert( (bmp=load_bitmap(argv[1],NULL)) ); assert( (bmp2=load_bitmap(argv[1],NULL)) ); set_gfx_mode( GFX_AUTODETECT_WINDOWED, Xres, Yres, 0, 0 ); { int ord = 65, wsamples=0x200; FCE_FLOAT *vector, *iweight; FCE_TYPE *as, *ad; int pass; T(fce_plan) *p; assert( bmp = load_bitmap( argv[1], NULL ) ); assert( vector = (FCE_FLOAT*)malloc(ord*sizeof(FCE_FLOAT)) ); // assert( iweight= (FCE_FLOAT*)malloc(wsamples*sizeof(FCE_FLOAT)) ); assert( as = (FCE_TYPE*)malloc(bmp->w*bmp->h*sizeof(FCE_TYPE)) ); assert( ad = (FCE_TYPE*)malloc(bmp->w*bmp->h*sizeof(FCE_TYPE)) ); for ( pass=0; pass<5; pass++ ) { { int x, y; for ( y=0; yh; y++ ) for ( x=0; xw; x++ ) as[y*bmp->w+x] = getr32( _getpixel32(bmp2, x, y)); } // init_lookup_vector( vector, ord, 1., 0.9 ); // init _lookup_iweight( iweight, wsamples, 10., 0.9, 10., 0.9 ); p = T(fce_plan_2d)( as, ad, bmp->w, bmp->h ); // fce_kernel_f32( p, vector, ord ); T(fce_gauss_kernel_f32)( p, ord, ord/4., 0.5 ); // blit( bmp2, screen, 0, 0, 0, 0, bmp->w, bmp->h ); { int tt, h, m, s; tck = 0; while ( !tck ); tck = 0; T(fce_execute_plan)( p ); // fce_convolve_2d_adapt_i8( as, ad, NULL, bmp->w, bmp->h, vector, ord, iweight, wsamples ); tt = tck; h = tt/(3600*1000); tt %= 3600*1000; m = tt/(60*1000); tt %= 60*1000; s = tt/1000; tt %= 1000; printf("Time spent by convolution: %02d:%02d:%02d.%03d\n", h, m, s, tt); } { int x, y, c; for ( y=0; yh; y++ ) for ( x=0; xw; x++ ) { c = ad[y*bmp->w+x]; _putpixel32( bmp, x, y, makecol32(c,c,c) ); } } blit( bmp, screen, 0, 0, 0, 0, bmp->w, bmp->h ); save_bitmap( "out.bmp", bmp, NULL ); } } return 0; } END_OF_MAIN();