diff options
Diffstat (limited to 'editor/pamflip')
-rw-r--r-- | editor/pamflip/config.h | 7 | ||||
-rw-r--r-- | editor/pamflip/pamflip.c | 11 | ||||
-rw-r--r-- | editor/pamflip/pamflip_sse.c | 9 |
3 files changed, 16 insertions, 11 deletions
diff --git a/editor/pamflip/config.h b/editor/pamflip/config.h new file mode 100644 index 00000000..42aefb6e --- /dev/null +++ b/editor/pamflip/config.h @@ -0,0 +1,7 @@ +#ifndef SSE_PBM_XY_FLIP + #if WANT_SSE && HAVE_WORKING_SSE2 + #define SSE_PBM_XY_FLIP 1 + #else + #define SSE_PBM_XY_FLIP 0 + #endif +#endif diff --git a/editor/pamflip/pamflip.c b/editor/pamflip/pamflip.c index ade05601..149ab310 100644 --- a/editor/pamflip/pamflip.c +++ b/editor/pamflip/pamflip.c @@ -72,19 +72,12 @@ #include "nstring.h" #include "bitreverse.h" +#include "config.h" /* Defines SSE_PBM_XY_FLIP */ #include "flip.h" #include "pamflip_sse.h" enum xformType {LEFTRIGHT, TOPBOTTOM, TRANSPOSE}; -#ifndef SIMD_PBM_TRANSPOSITION - #if WANT_SSE && defined(__SSE2__) - #define SIMD_PBM_TRANSPOSITION 1 - #else - #define SIMD_PBM_TRANSPOSITION 0 - #endif -#endif - static void parseXformOpt(const char * const xformOpt, unsigned int * const xformCountP, @@ -1149,7 +1142,7 @@ transformPbm(struct pam * const inpamP, /* This is a column-for-row type of transformation, which requires complex traversal of an in-memory image. */ - if (SIMD_PBM_TRANSPOSITION == 1) + if (SSE_PBM_XY_FLIP) pamflip_transformRowsToColumnsPbmSse(inpamP, outpamP, xform); else transformPbmGen(inpamP, outpamP, xform); diff --git a/editor/pamflip/pamflip_sse.c b/editor/pamflip/pamflip_sse.c index eccbe965..e0929f65 100644 --- a/editor/pamflip/pamflip_sse.c +++ b/editor/pamflip/pamflip_sse.c @@ -24,6 +24,7 @@ #include "mallocvar.h" #include "pam.h" +#include "config.h" /* Defines SSE_PBM_XY_FLIP */ #include "flip.h" #include "pamflip_sse.h" @@ -32,7 +33,7 @@ (i.e. <emmintrin.h> exists). */ -#if WANT_SSE && defined(__SSE2__) +#if SSE_PBM_XY_FLIP /*---------------------------------------------------------------------------- This is a specialized routine for row-for-column PBM transformations. @@ -59,7 +60,11 @@ As an enhancement, we clear the output raster to zero (=white) in the beginning and flip only the 8x16 blocks that contain non-zero bits (=any amount of black pixels). When we add padding to the edges, we initialize - it all to zero to prevent unnecessary transpositions. + it all to zero to prevent unnecessary transpositions. Because most + real-world documents are largely white, this saves much execution time. If + you are porting this code to an environment in which non-zero bits are the + majority, for example, BMP where zero means black, you should seriously + consider modifying this. All instructions unique to GCC/SSE are in transpose16Bitrows(). It is possible to write a non-SSE version by providing a generic |