|
21 | 21 | * - deprecate @centre option, it's now always on
|
22 | 22 | * - fix pixel shift
|
23 | 23 | * - speed up the mask construction for uchar/ushort images
|
| 24 | + * - remove unnecessary round-to-nearest behaviour |
24 | 25 | */
|
25 | 26 |
|
26 | 27 | /*
|
@@ -117,15 +118,14 @@ typedef struct _VipsReducev {
|
117 | 118 | double voffset;
|
118 | 119 |
|
119 | 120 | /* Precalculated interpolation matrices. int (used for pel
|
120 |
| - * sizes up to short), and double (for all others). We go to |
121 |
| - * scale + 1 so we can round-to-nearest safely. |
| 121 | + * sizes up to short), and double (for all others). |
122 | 122 | */
|
123 |
| - int *matrixi[VIPS_TRANSFORM_SCALE + 1]; |
124 |
| - double *matrixf[VIPS_TRANSFORM_SCALE + 1]; |
| 123 | + int *matrixi[VIPS_TRANSFORM_SCALE]; |
| 124 | + double *matrixf[VIPS_TRANSFORM_SCALE]; |
125 | 125 |
|
126 | 126 | /* And another set for orc: we want 2.6 precision.
|
127 | 127 | */
|
128 |
| - int *matrixo[VIPS_TRANSFORM_SCALE + 1]; |
| 128 | + int *matrixo[VIPS_TRANSFORM_SCALE]; |
129 | 129 |
|
130 | 130 | /* The passes we generate for this mask.
|
131 | 131 | */
|
@@ -154,7 +154,7 @@ vips_reducev_finalize( GObject *gobject )
|
154 | 154 | for( int i = 0; i < reducev->n_pass; i++ )
|
155 | 155 | VIPS_FREEF( vips_vector_free, reducev->pass[i].vector );
|
156 | 156 | reducev->n_pass = 0;
|
157 |
| - for( int i = 0; i < VIPS_TRANSFORM_SCALE + 1; i++ ) { |
| 157 | + for( int i = 0; i < VIPS_TRANSFORM_SCALE; i++ ) { |
158 | 158 | VIPS_FREE( reducev->matrixf[i] );
|
159 | 159 | VIPS_FREE( reducev->matrixi[i] );
|
160 | 160 | VIPS_FREE( reducev->matrixo[i] );
|
@@ -550,14 +550,13 @@ vips_reducev_gen( VipsRegion *out_region, void *vseq,
|
550 | 550 | double Y = (r->top + 0.5) * reducev->vshrink - 0.5 -
|
551 | 551 | reducev->voffset;
|
552 | 552 |
|
553 |
| - for( int y = 0; y < r->height; y ++ ) { |
| 553 | + for( int y = 0; y < r->height; y++ ) { |
554 | 554 | VipsPel *q =
|
555 | 555 | VIPS_REGION_ADDR( out_region, r->left, r->top + y );
|
556 | 556 | const int py = (int) Y;
|
557 | 557 | VipsPel *p = VIPS_REGION_ADDR( ir, r->left, py );
|
558 |
| - const int sy = Y * VIPS_TRANSFORM_SCALE * 2; |
559 |
| - const int siy = sy & (VIPS_TRANSFORM_SCALE * 2 - 1); |
560 |
| - const int ty = (siy + 1) >> 1; |
| 558 | + const int sy = Y * VIPS_TRANSFORM_SCALE; |
| 559 | + const int ty = sy & (VIPS_TRANSFORM_SCALE - 1); |
561 | 560 | const int *cyi = reducev->matrixi[ty];
|
562 | 561 | const double *cyf = reducev->matrixf[ty];
|
563 | 562 | const int lskip = VIPS_REGION_LSKIP( ir );
|
@@ -675,13 +674,12 @@ vips_reducev_vector_gen( VipsRegion *out_region, void *vseq,
|
675 | 674 | double Y = (r->top + 0.5) * reducev->vshrink - 0.5 -
|
676 | 675 | reducev->voffset;
|
677 | 676 |
|
678 |
| - for( int y = 0; y < r->height; y ++ ) { |
| 677 | + for( int y = 0; y < r->height; y++ ) { |
679 | 678 | VipsPel *q =
|
680 | 679 | VIPS_REGION_ADDR( out_region, r->left, r->top + y );
|
681 | 680 | const int py = (int) Y;
|
682 |
| - const int sy = Y * VIPS_TRANSFORM_SCALE * 2; |
683 |
| - const int siy = sy & (VIPS_TRANSFORM_SCALE * 2 - 1); |
684 |
| - const int ty = (siy + 1) >> 1; |
| 681 | + const int sy = Y * VIPS_TRANSFORM_SCALE; |
| 682 | + const int ty = sy & (VIPS_TRANSFORM_SCALE - 1); |
685 | 683 | const int *cyo = reducev->matrixo[ty];
|
686 | 684 |
|
687 | 685 | #ifdef DEBUG_PIXELS
|
@@ -742,7 +740,7 @@ vips_reducev_raw( VipsReducev *reducev, VipsImage *in, VipsImage **out )
|
742 | 740 | */
|
743 | 741 | if( in->BandFmt == VIPS_FORMAT_UCHAR &&
|
744 | 742 | vips_vector_isenabled() )
|
745 |
| - for( int y = 0; y < VIPS_TRANSFORM_SCALE + 1; y++ ) { |
| 743 | + for( int y = 0; y < VIPS_TRANSFORM_SCALE; y++ ) { |
746 | 744 | reducev->matrixo[y] =
|
747 | 745 | VIPS_ARRAY( NULL, reducev->n_point, int );
|
748 | 746 | if( !reducev->matrixo[y] )
|
@@ -854,7 +852,7 @@ vips_reducev_build( VipsObject *object )
|
854 | 852 |
|
855 | 853 | /* Build the tables of pre-computed coefficients.
|
856 | 854 | */
|
857 |
| - for( int y = 0; y < VIPS_TRANSFORM_SCALE + 1; y++ ) { |
| 855 | + for( int y = 0; y < VIPS_TRANSFORM_SCALE; y++ ) { |
858 | 856 | reducev->matrixf[y] =
|
859 | 857 | VIPS_ARRAY( NULL, reducev->n_point, double );
|
860 | 858 | reducev->matrixi[y] =
|
|
0 commit comments