@@ -177,7 +177,7 @@ typedef struct {
177
177
178
178
/* The horizontal lines we gather. hline[3] writes to band 3 in the
179
179
* intermediate image. max_line is the length of the longest hline:
180
- * over 256 and we need to use an int intermediate for 8-bit images.
180
+ * over 256 and we need to use an int intermediate for integer images.
181
181
*/
182
182
int n_hline ;
183
183
HLine hline [MAX_LINES ];
@@ -933,33 +933,39 @@ vips_conva_hgenerate(VipsRegion *out_region,
933
933
break ;
934
934
935
935
case VIPS_FORMAT_USHORT :
936
- HCONV (unsigned short, unsigned int ) ;
936
+ if (conva -> max_line < 256 )
937
+ HCONV (unsigned short , unsigned short );
938
+ else
939
+ HCONV (unsigned short , unsigned int );
937
940
break ;
938
941
939
942
case VIPS_FORMAT_SHORT :
940
- HCONV (signed short, signed int ) ;
943
+ if (conva -> max_line < 256 )
944
+ HCONV (signed short , signed short );
945
+ else
946
+ HCONV (signed short , signed int );
941
947
break ;
942
948
943
949
case VIPS_FORMAT_UINT :
944
- HCONV (unsigned int , unsigned int ) ;
950
+ if (conva -> max_line < 256 )
951
+ HCONV (unsigned int , unsigned short );
952
+ else
953
+ HCONV (unsigned int , unsigned int );
945
954
break ;
946
955
947
956
case VIPS_FORMAT_INT :
948
- HCONV (signed int , signed int ) ;
957
+ if (conva -> max_line < 256 )
958
+ HCONV (signed int , signed short );
959
+ else
960
+ HCONV (signed int , signed int );
949
961
break ;
950
962
951
963
case VIPS_FORMAT_FLOAT :
952
- HCONV (float , float );
953
- break ;
954
-
955
- case VIPS_FORMAT_DOUBLE :
956
- HCONV (double , double );
957
- break ;
958
-
959
964
case VIPS_FORMAT_COMPLEX :
960
965
HCONV (float , float );
961
966
break ;
962
967
968
+ case VIPS_FORMAT_DOUBLE :
963
969
case VIPS_FORMAT_DPCOMPLEX :
964
970
HCONV (double , double );
965
971
break ;
@@ -993,7 +999,7 @@ vips_conva_horizontal(VipsConva *conva, VipsImage *in, VipsImage **out)
993
999
}
994
1000
(* out )-> Bands *= conva -> n_hline ;
995
1001
996
- /* Short u? char lines can use u? short intermediate.
1002
+ /* Short {u,}{ char,short,int} lines can use {u,} short as intermediate.
997
1003
*/
998
1004
if (vips_band_format_isuint (in -> BandFmt ))
999
1005
(* out )-> BandFmt = conva -> max_line < 256
@@ -1175,34 +1181,41 @@ vips_conva_vgenerate(VipsRegion *out_region,
1175
1181
break ;
1176
1182
1177
1183
case VIPS_FORMAT_USHORT :
1178
- VCONV (unsigned int ,
1179
- unsigned int , unsigned short, CLIP_USHORT ) ;
1184
+ if (conva -> max_line < 256 )
1185
+ VCONV (unsigned int ,
1186
+ unsigned short , unsigned short , CLIP_USHORT );
1187
+ else
1188
+ VCONV (unsigned int ,
1189
+ unsigned int , unsigned short , CLIP_USHORT );
1180
1190
break ;
1181
1191
1182
1192
case VIPS_FORMAT_SHORT :
1183
- VCONV (signed int , signed int , signed short, CLIP_SHORT ) ;
1193
+ if (conva -> max_line < 256 )
1194
+ VCONV (signed int , signed short , signed short , CLIP_SHORT );
1195
+ else
1196
+ VCONV (signed int , signed int , signed short , CLIP_SHORT );
1184
1197
break ;
1185
1198
1186
1199
case VIPS_FORMAT_UINT :
1187
- VCONV (unsigned int , unsigned int , unsigned int , CLIP_NONE ) ;
1200
+ if (conva -> max_line < 256 )
1201
+ VCONV (unsigned int , unsigned short , unsigned int , CLIP_SHORT );
1202
+ else
1203
+ VCONV (unsigned int , unsigned int , unsigned int , CLIP_NONE );
1188
1204
break ;
1189
1205
1190
1206
case VIPS_FORMAT_INT :
1191
- VCONV (signed int , signed int , signed int , CLIP_NONE ) ;
1207
+ if (conva -> max_line < 256 )
1208
+ VCONV (signed int , signed short , signed int , CLIP_NONE );
1209
+ else
1210
+ VCONV (signed int , signed int , signed int , CLIP_NONE );
1192
1211
break ;
1193
1212
1194
1213
case VIPS_FORMAT_FLOAT :
1195
- VCONV (float , float , float , CLIP_NONE );
1196
- break ;
1197
-
1198
- case VIPS_FORMAT_DOUBLE :
1199
- VCONV (double , double , double , CLIP_NONE );
1200
- break ;
1201
-
1202
1214
case VIPS_FORMAT_COMPLEX :
1203
1215
VCONV (float , float , float , CLIP_NONE );
1204
1216
break ;
1205
1217
1218
+ case VIPS_FORMAT_DOUBLE :
1206
1219
case VIPS_FORMAT_DPCOMPLEX :
1207
1220
VCONV (double , double , double , CLIP_NONE );
1208
1221
break ;
0 commit comments