Merge pull request #815 from lovell/premultiply-match-types
(Un)premultiply: ~10-15% speedup by matching clipped alpha type with IN/OUT
This commit is contained in:
commit
bb0772da51
@ -78,7 +78,7 @@ G_DEFINE_TYPE( VipsPremultiply, vips_premultiply, VIPS_TYPE_CONVERSION );
|
||||
for( x = 0; x < width; x++ ) { \
|
||||
IN alpha = p[bands - 1]; \
|
||||
IN clip_alpha = VIPS_CLIP( 0, alpha, max_alpha ); \
|
||||
double nalpha = (double) clip_alpha / max_alpha; \
|
||||
OUT nalpha = (OUT) clip_alpha / max_alpha; \
|
||||
\
|
||||
for( i = 0; i < bands - 1; i++ ) \
|
||||
q[i] = p[i] * nalpha; \
|
||||
@ -98,7 +98,7 @@ G_DEFINE_TYPE( VipsPremultiply, vips_premultiply, VIPS_TYPE_CONVERSION );
|
||||
for( x = 0; x < width; x++ ) { \
|
||||
IN alpha = p[3]; \
|
||||
IN clip_alpha = VIPS_CLIP( 0, alpha, max_alpha ); \
|
||||
double nalpha = (double) clip_alpha / max_alpha; \
|
||||
OUT nalpha = (OUT) clip_alpha / max_alpha; \
|
||||
\
|
||||
q[0] = p[0] * nalpha; \
|
||||
q[1] = p[1] * nalpha; \
|
||||
|
@ -75,8 +75,8 @@ G_DEFINE_TYPE( VipsUnpremultiply, vips_unpremultiply, VIPS_TYPE_CONVERSION );
|
||||
\
|
||||
for( x = 0; x < width; x++ ) { \
|
||||
IN alpha = p[bands - 1]; \
|
||||
int clip_alpha = VIPS_CLIP( 0, alpha, max_alpha ); \
|
||||
double nalpha = (double) clip_alpha / max_alpha; \
|
||||
IN clip_alpha = VIPS_CLIP( 0, alpha, max_alpha ); \
|
||||
OUT nalpha = (OUT) clip_alpha / max_alpha; \
|
||||
\
|
||||
if( clip_alpha == 0 ) \
|
||||
for( i = 0; i < bands - 1; i++ ) \
|
||||
@ -99,8 +99,8 @@ G_DEFINE_TYPE( VipsUnpremultiply, vips_unpremultiply, VIPS_TYPE_CONVERSION );
|
||||
\
|
||||
for( x = 0; x < width; x++ ) { \
|
||||
IN alpha = p[3]; \
|
||||
int clip_alpha = VIPS_CLIP( 0, alpha, max_alpha ); \
|
||||
double nalpha = (double) clip_alpha / max_alpha; \
|
||||
IN clip_alpha = VIPS_CLIP( 0, alpha, max_alpha ); \
|
||||
OUT nalpha = (OUT) clip_alpha / max_alpha; \
|
||||
\
|
||||
if( clip_alpha == 0 ) { \
|
||||
q[0] = 0; \
|
||||
|
Loading…
Reference in New Issue
Block a user