From 0629a5de7f73606c852516a420afdee4c469da9d Mon Sep 17 00:00:00 2001 From: Kleis Auke Wolthuizen Date: Wed, 30 Nov 2022 10:41:05 +0100 Subject: [PATCH] Ensure consistent formatting of `->format_table` (#3199) --- libvips/arithmetic/abs.c | 4 ++-- libvips/arithmetic/add.c | 4 ++-- libvips/arithmetic/boolean.c | 4 ++-- libvips/arithmetic/complex.c | 18 +++++++++--------- libvips/arithmetic/divide.c | 6 +++--- libvips/arithmetic/hist_find.c | 4 ++-- libvips/arithmetic/hist_find_indexed.c | 4 ++-- libvips/arithmetic/hist_find_ndim.c | 4 ++-- libvips/arithmetic/hough.c | 4 ++-- libvips/arithmetic/invert.c | 4 ++-- libvips/arithmetic/linear.c | 4 ++-- libvips/arithmetic/math.c | 4 ++-- libvips/arithmetic/math2.c | 6 +++--- libvips/arithmetic/multiply.c | 6 +++--- libvips/arithmetic/project.c | 4 ++-- libvips/arithmetic/relational.c | 4 ++-- libvips/arithmetic/remainder.c | 6 +++--- libvips/arithmetic/round.c | 4 ++-- libvips/arithmetic/sign.c | 4 ++-- libvips/arithmetic/subtract.c | 4 ++-- libvips/arithmetic/sum.c | 4 ++-- libvips/conversion/bandbool.c | 4 ++-- libvips/conversion/gamma.c | 20 ++++++++++---------- libvips/convolution/fastcor.c | 6 +++--- libvips/convolution/spcor.c | 6 +++--- libvips/foreign/cgifsave.c | 8 ++++++-- libvips/foreign/dzsave.c | 6 +++--- libvips/foreign/fitssave.c | 6 +++--- libvips/foreign/foreign.c | 6 +++--- libvips/foreign/heifsave.c | 9 ++++++--- libvips/foreign/jpegsave.c | 6 +++--- libvips/foreign/jxlsave.c | 6 +++--- libvips/foreign/matrixsave.c | 6 +++--- libvips/foreign/niftisave.c | 6 +++--- libvips/foreign/pngsave.c | 6 +++--- libvips/foreign/ppmsave.c | 6 +++--- libvips/foreign/radsave.c | 6 +++--- libvips/foreign/spngsave.c | 13 +++++++------ libvips/foreign/tiffsave.c | 6 +++--- libvips/foreign/vips2magick.c | 6 +++--- libvips/foreign/webpsave.c | 6 +++--- libvips/histogram/hist_cum.c | 4 ++-- libvips/histogram/maplut.c | 6 +++--- 43 files changed, 134 insertions(+), 126 deletions(-) diff --git a/libvips/arithmetic/abs.c b/libvips/arithmetic/abs.c index 1c4bcb26..594f6dd8 100644 --- a/libvips/arithmetic/abs.c +++ b/libvips/arithmetic/abs.c @@ -244,8 +244,8 @@ vips_abs_buffer( VipsArithmetic *arithmetic, /* Format doesn't change with abs, other than complex -> real. */ static const VipsBandFormat vips_abs_format_table[10] = { -/* UC C US S UI I F X D DX */ - UC, C, US, S, UI, I, F, F, D, D + /* Band format: UC C US S UI I F X D DX */ + /* Promotion: */ UC, C, US, S, UI, I, F, F, D, D }; static void diff --git a/libvips/arithmetic/add.c b/libvips/arithmetic/add.c index e2e262b8..8e7335dd 100644 --- a/libvips/arithmetic/add.c +++ b/libvips/arithmetic/add.c @@ -158,8 +158,8 @@ add_buffer( VipsArithmetic *arithmetic, VipsPel *out, VipsPel **in, int width ) * match the case statement in add_buffer() above. */ static const VipsBandFormat vips_add_format_table[10] = { -/* UC C US S UI I F X D DX */ - US, S, UI, I, UI, I, F, X, D, DX + /* Band format: UC C US S UI I F X D DX */ + /* Promotion: */ US, S, UI, I, UI, I, F, X, D, DX }; static void diff --git a/libvips/arithmetic/boolean.c b/libvips/arithmetic/boolean.c index 80a66f62..50d87c35 100644 --- a/libvips/arithmetic/boolean.c +++ b/libvips/arithmetic/boolean.c @@ -224,8 +224,8 @@ vips_boolean_buffer( VipsArithmetic *arithmetic, /* Type conversions for boolean. */ static const VipsBandFormat vips_boolean_format_table[10] = { -/* UC C US S UI I F X D DX */ - UC, C, US, S, UI, I, I, I, I, I, + /* Band format: UC C US S UI I F X D DX */ + /* Promotion: */ UC, C, US, S, UI, I, I, I, I, I }; static void diff --git a/libvips/arithmetic/complex.c b/libvips/arithmetic/complex.c index 71aacf57..0367ea63 100644 --- a/libvips/arithmetic/complex.c +++ b/libvips/arithmetic/complex.c @@ -234,8 +234,8 @@ vips_complex_buffer( VipsArithmetic *arithmetic, #define DX VIPS_FORMAT_DPCOMPLEX static const VipsBandFormat vips_complex_format_table[10] = { -/* UC C US S UI I F X D DX */ - X, X, X, X, X, X, X, X, DX, DX + /* Band format: UC C US S UI I F X D DX */ + /* Promotion: */ X, X, X, X, X, X, X, X, DX, DX }; static void @@ -527,8 +527,8 @@ vips_complex2_buffer( VipsArithmetic *arithmetic, #define DX VIPS_FORMAT_DPCOMPLEX static const VipsBandFormat vips_complex2_format_table[10] = { -/* UC C US S UI I F X D DX */ - X, X, X, X, X, X, X, X, DX, DX + /* Band format: UC C US S UI I F X D DX */ + /* Promotion: */ X, X, X, X, X, X, X, X, DX, DX }; static void @@ -741,8 +741,8 @@ vips_complexget_buffer( VipsArithmetic *arithmetic, #define DX VIPS_FORMAT_DPCOMPLEX static const VipsBandFormat vips_complexget_format_table[10] = { -/* UC C US S UI I F X D DX */ - UC, C, US, S, UI, I, F, F, D, D + /* Band format: UC C US S UI I F X D DX */ + /* Promotion: */ UC, C, US, S, UI, I, F, F, D, D }; static void @@ -951,9 +951,9 @@ vips_complexform_buffer( VipsArithmetic *arithmetic, /* Type promotion for form complex. Sign and value preserving. Make sure * these match the case statement in complexform_buffer() above. */ -static int vips_complexform_format_table[10] = { -/* UC C US S UI I F X D DX */ - X, X, X, X, X, X, X, X, DX,DX +static VipsBandFormat vips_complexform_format_table[10] = { + /* Band format: UC C US S UI I F X D DX */ + /* Promotion: */ X, X, X, X, X, X, X, X, DX, DX }; static void diff --git a/libvips/arithmetic/divide.c b/libvips/arithmetic/divide.c index b7b5dbb3..8f52e309 100644 --- a/libvips/arithmetic/divide.c +++ b/libvips/arithmetic/divide.c @@ -210,9 +210,9 @@ vips_divide_buffer( VipsArithmetic *arithmetic, /* Type promotion for division. Sign and value preserving. Make sure * these match the case statement in divide_buffer() above. */ -static int vips_divide_format_table[10] = { -/* UC C US S UI I F X D DX */ - F, F, F, F, F, F, F, X, D, DX +static VipsBandFormat vips_divide_format_table[10] = { + /* Band format: UC C US S UI I F X D DX */ + /* Promotion: */ F, F, F, F, F, F, F, X, D, DX }; static void diff --git a/libvips/arithmetic/hist_find.c b/libvips/arithmetic/hist_find.c index feb75165..025de35a 100644 --- a/libvips/arithmetic/hist_find.c +++ b/libvips/arithmetic/hist_find.c @@ -386,8 +386,8 @@ vips_hist_find_scan( VipsStatistic *statistic, void *seq, /* Type mapping: go to uchar or ushort. */ static const VipsBandFormat vips_hist_find_format_table[10] = { -/* UC C US S UI I F X D DX */ - UC, UC, US, US, US, US, US, US, US, US + /* Band format: UC C US S UI I F X D DX */ + /* Promotion: */ UC, UC, US, US, US, US, US, US, US, US }; static void diff --git a/libvips/arithmetic/hist_find_indexed.c b/libvips/arithmetic/hist_find_indexed.c index d69ef461..8ee45e3d 100644 --- a/libvips/arithmetic/hist_find_indexed.c +++ b/libvips/arithmetic/hist_find_indexed.c @@ -130,8 +130,8 @@ histogram_new( VipsHistFindIndexed *indexed ) /* Type mapping: go to uchar or ushort. */ static const VipsBandFormat vips_hist_find_indexed_format[10] = { -/* UC C US S UI I F X D DX */ - UC, UC, US, US, US, US, US, US, US, US + /* Band format: UC C US S UI I F X D DX */ + /* Promotion: */ UC, UC, US, US, US, US, US, US, US, US }; static int diff --git a/libvips/arithmetic/hist_find_ndim.c b/libvips/arithmetic/hist_find_ndim.c index d340cfac..87d7d7c9 100644 --- a/libvips/arithmetic/hist_find_ndim.c +++ b/libvips/arithmetic/hist_find_ndim.c @@ -286,8 +286,8 @@ vips_hist_find_ndim_scan( VipsStatistic *statistic, void *seq, /* Type mapping: go to uchar or ushort. */ static const VipsBandFormat vips_hist_find_ndim_format_table[10] = { -/* UC C US S UI I F X D DX */ - UC, UC, US, US, US, US, US, US, US, US + /* Band format: UC C US S UI I F X D DX */ + /* Promotion: */ UC, UC, US, US, US, US, US, US, US, US }; static void diff --git a/libvips/arithmetic/hough.c b/libvips/arithmetic/hough.c index 0adafe17..42b10087 100644 --- a/libvips/arithmetic/hough.c +++ b/libvips/arithmetic/hough.c @@ -152,8 +152,8 @@ vips_hough_scan( VipsStatistic *statistic, /* Input image is cast to this format. */ static const VipsBandFormat vips_hough_format_table[10] = { -/* UC C US S UI I F X D DX */ - UC, UC, UC, UC, UC, UC, UC, UC, UC, UC + /* Band format: UC C US S UI I F X D DX */ + /* Promotion: */ UC, UC, UC, UC, UC, UC, UC, UC, UC, UC }; static void diff --git a/libvips/arithmetic/invert.c b/libvips/arithmetic/invert.c index 6eca6c0e..7631bea0 100644 --- a/libvips/arithmetic/invert.c +++ b/libvips/arithmetic/invert.c @@ -151,8 +151,8 @@ vips_invert_buffer( VipsArithmetic *arithmetic, /* Format doesn't change with invert. */ static const VipsBandFormat vips_invert_format_table[10] = { -/* UC C US S UI I F X D DX */ - UC, C, US, S, UI, I, F, X, D, DX + /* Band format: UC C US S UI I F X D DX */ + /* Promotion: */ UC, C, US, S, UI, I, F, X, D, DX }; static void diff --git a/libvips/arithmetic/linear.c b/libvips/arithmetic/linear.c index 869f78f7..bddde889 100644 --- a/libvips/arithmetic/linear.c +++ b/libvips/arithmetic/linear.c @@ -401,8 +401,8 @@ vips_linear_buffer( VipsArithmetic *arithmetic, /* Format doesn't change with linear. */ static const VipsBandFormat vips_linear_format_table[10] = { -/* UC C US S UI I F X D DX */ - F, F, F, F, F, F, F, X, D, DX + /* Band format: UC C US S UI I F X D DX */ + /* Promotion: */ F, F, F, F, F, F, F, X, D, DX }; static void diff --git a/libvips/arithmetic/math.c b/libvips/arithmetic/math.c index e28c8f6e..bed7ac92 100644 --- a/libvips/arithmetic/math.c +++ b/libvips/arithmetic/math.c @@ -206,8 +206,8 @@ vips_math_buffer( VipsArithmetic *arithmetic, #define DX VIPS_FORMAT_DPCOMPLEX static const VipsBandFormat vips_math_format_table[10] = { -/* UC C US S UI I F X D DX */ - F, F, F, F, F, F, F, X, D, DX + /* Band format: UC C US S UI I F X D DX */ + /* Promotion: */ F, F, F, F, F, F, F, X, D, DX }; static void diff --git a/libvips/arithmetic/math2.c b/libvips/arithmetic/math2.c index 9ee0815c..9c0b4063 100644 --- a/libvips/arithmetic/math2.c +++ b/libvips/arithmetic/math2.c @@ -206,9 +206,9 @@ vips_math2_buffer( VipsArithmetic *arithmetic, /* Type promotion for math2. Keep in sync with math2_buffer() above. */ -static int vips_math2_format_table[10] = { -/* UC C US S UI I F X D DX */ - F, F, F, F, F, F, F, X, D, DX +static const VipsBandFormat vips_math2_format_table[10] = { + /* Band format: UC C US S UI I F X D DX */ + /* Promotion: */ F, F, F, F, F, F, F, X, D, DX }; static void diff --git a/libvips/arithmetic/multiply.c b/libvips/arithmetic/multiply.c index 8785fe86..f42d0928 100644 --- a/libvips/arithmetic/multiply.c +++ b/libvips/arithmetic/multiply.c @@ -158,9 +158,9 @@ vips_multiply_buffer( VipsArithmetic *arithmetic, /* Type promotion for multiplication. Sign and value preserving. Make sure * these match the case statement in multiply_buffer() above. */ -static int vips_multiply_format_table[10] = { -/* UC C US S UI I F X D DX */ - US, S, UI, I, UI, I, F, X, D, DX +static const VipsBandFormat vips_multiply_format_table[10] = { + /* Band format: UC C US S UI I F X D DX */ + /* Promotion: */ US, S, UI, I, UI, I, F, X, D, DX }; static void diff --git a/libvips/arithmetic/project.c b/libvips/arithmetic/project.c index 82759ba8..1330cd93 100644 --- a/libvips/arithmetic/project.c +++ b/libvips/arithmetic/project.c @@ -87,8 +87,8 @@ G_DEFINE_TYPE( VipsProject, vips_project, VIPS_TYPE_STATISTIC ); #define N VIPS_FORMAT_NOTSET static const VipsBandFormat vips_project_format_table[10] = { -/* UC C US S UI I F X D DX */ - UI, I, UI, I, UI, I, D, N, D, N + /* Band format: UC C US S UI I F X D DX */ + /* Promotion: */ UI, I, UI, I, UI, I, D, N, D, N }; static Histogram * diff --git a/libvips/arithmetic/relational.c b/libvips/arithmetic/relational.c index cd017cd2..8eb902fc 100644 --- a/libvips/arithmetic/relational.c +++ b/libvips/arithmetic/relational.c @@ -198,8 +198,8 @@ vips_relational_buffer( VipsArithmetic *arithmetic, #define DX VIPS_FORMAT_DPCOMPLEX static const VipsBandFormat vips_relational_format_table[10] = { -/* UC C US S UI I F X D DX */ - UC, UC, UC, UC, UC, UC, UC, UC, UC, UC + /* Band format: UC C US S UI I F X D DX */ + /* Promotion: */ UC, UC, UC, UC, UC, UC, UC, UC, UC, UC }; static void diff --git a/libvips/arithmetic/remainder.c b/libvips/arithmetic/remainder.c index a3e1c7d4..97c2b344 100644 --- a/libvips/arithmetic/remainder.c +++ b/libvips/arithmetic/remainder.c @@ -154,9 +154,9 @@ vips_remainder_buffer( VipsArithmetic *arithmetic, /* Type promotion for remainder. Keep in sync with remainder_buffer() above. */ -static int vips_remainder_format_table[10] = { -/* UC C US S UI I F X D DX */ - UC, C, US, S, UI, I, F, X, D, DX +static const VipsBandFormat vips_remainder_format_table[10] = { + /* Band format: UC C US S UI I F X D DX */ + /* Promotion: */ UC, C, US, S, UI, I, F, X, D, DX }; static void diff --git a/libvips/arithmetic/round.c b/libvips/arithmetic/round.c index ae87216c..328ab515 100644 --- a/libvips/arithmetic/round.c +++ b/libvips/arithmetic/round.c @@ -143,8 +143,8 @@ vips_round_buffer( VipsArithmetic *arithmetic, #define DX VIPS_FORMAT_DPCOMPLEX static const VipsBandFormat vips_round_format_table[10] = { -/* UC C US S UI I F X D DX */ - UC, C, US, S, UI, I, F, X, D, DX + /* Band format: UC C US S UI I F X D DX */ + /* Promotion: */ UC, C, US, S, UI, I, F, X, D, DX }; static void diff --git a/libvips/arithmetic/sign.c b/libvips/arithmetic/sign.c index 2cb7578c..16795c6d 100644 --- a/libvips/arithmetic/sign.c +++ b/libvips/arithmetic/sign.c @@ -138,8 +138,8 @@ vips_sign_buffer( VipsArithmetic *arithmetic, #define DX VIPS_FORMAT_DPCOMPLEX static const VipsBandFormat vips_sign_format_table[10] = { -/* UC C US S UI I F X D DX */ - C, C, C, C, C, C, C, X, C, DX + /* Band format: UC C US S UI I F X D DX */ + /* Promotion: */ C, C, C, C, C, C, C, X, C, DX }; static void diff --git a/libvips/arithmetic/subtract.c b/libvips/arithmetic/subtract.c index 2e3c599a..38090771 100644 --- a/libvips/arithmetic/subtract.c +++ b/libvips/arithmetic/subtract.c @@ -148,8 +148,8 @@ vips_subtract_buffer( VipsArithmetic *arithmetic, * match the case statement in vips_subtract_buffer() above. */ static const VipsBandFormat vips_subtract_format_table[10] = { -/* UC C US S UI I F X D DX */ - S, S, I, I, I, I, F, X, D, DX + /* Band format: UC C US S UI I F X D DX */ + /* Promotion: */ S, S, I, I, I, I, F, X, D, DX }; static void diff --git a/libvips/arithmetic/sum.c b/libvips/arithmetic/sum.c index b0eb961c..0f6c113a 100644 --- a/libvips/arithmetic/sum.c +++ b/libvips/arithmetic/sum.c @@ -127,8 +127,8 @@ sum_buffer( VipsArithmetic *arithmetic, VipsPel *out, VipsPel **in, int width ) * match the case statement in sum_buffer() above. */ static const VipsBandFormat vips_sum_format_table[10] = { -/* UC C US S UI I F X D DX */ - UI, I, UI, I, UI, I, F, X, D, DX + /* Band format: UC C US S UI I F X D DX */ + /* Promotion: */ UI, I, UI, I, UI, I, F, X, D, DX }; static void diff --git a/libvips/conversion/bandbool.c b/libvips/conversion/bandbool.c index 987586e5..16428f87 100644 --- a/libvips/conversion/bandbool.c +++ b/libvips/conversion/bandbool.c @@ -190,8 +190,8 @@ vips_bandbool_buffer( VipsBandarySequence *seq, /* Format conversions for boolean. */ static const VipsBandFormat vips_bandbool_format_table[10] = { -/* UC C US S UI I F X D DX */ - UC, C, US, S, UI, I, I, I, I, I, + /* Band format: UC C US S UI I F X D DX */ + /* Promotion: */ UC, C, US, S, UI, I, I, I, I, I }; static void diff --git a/libvips/conversion/gamma.c b/libvips/conversion/gamma.c index e73b0e6e..0f86f1d9 100644 --- a/libvips/conversion/gamma.c +++ b/libvips/conversion/gamma.c @@ -69,16 +69,16 @@ G_DEFINE_TYPE( VipsGamma, vips_gamma, VIPS_TYPE_CONVERSION ); /* For each input format, what we normalise the pow() about. */ static double vips_gamma_maxval[10] = { -/* UC */ UCHAR_MAX, -/* C */ SCHAR_MAX, -/* US */ USHRT_MAX, -/* S */ SHRT_MAX, -/* UI */ UINT_MAX, -/* I */ INT_MAX, -/* F */ 1.0, -/* X */ 1.0, -/* D */ 1.0, -/* DX */ 1.0 + /* UC */ UCHAR_MAX, + /* C */ SCHAR_MAX, + /* US */ USHRT_MAX, + /* S */ SHRT_MAX, + /* UI */ UINT_MAX, + /* I */ INT_MAX, + /* F */ 1.0, + /* X */ 1.0, + /* D */ 1.0, + /* DX */ 1.0 }; static int diff --git a/libvips/convolution/fastcor.c b/libvips/convolution/fastcor.c index f079e42b..10f29de8 100644 --- a/libvips/convolution/fastcor.c +++ b/libvips/convolution/fastcor.c @@ -200,9 +200,9 @@ vips_fastcor_correlation( VipsCorrelation *correlation, /* Type promotion for multiplication. Sign and value preserving. Make sure * these match the case statement in multiply_buffer() above. */ -static int vips_fastcor_format_table[10] = { -/* UC C US S UI I F X D DX */ - UI, UI, UI, UI, UI, UI,F, X, D, DX +static const VipsBandFormat vips_fastcor_format_table[10] = { + /* Band format: UC C US S UI I F X D DX */ + /* Promotion: */ UI, UI, UI, UI, UI, UI, F, X, D, DX }; static void diff --git a/libvips/convolution/spcor.c b/libvips/convolution/spcor.c index 1c74f84d..371f00a8 100644 --- a/libvips/convolution/spcor.c +++ b/libvips/convolution/spcor.c @@ -300,9 +300,9 @@ vips_spcor_correlation( VipsCorrelation *correlation, #define D VIPS_FORMAT_DOUBLE #define DX VIPS_FORMAT_DPCOMPLEX -static int vips_spcor_format_table[10] = { -/* UC C US S UI I F X D DX */ - F, F, F, F, F, F, F, F, F, F +static const VipsBandFormat vips_spcor_format_table[10] = { + /* Band format: UC C US S UI I F X D DX */ + /* Promotion: */ F, F, F, F, F, F, F, F, F, F }; static void diff --git a/libvips/foreign/cgifsave.c b/libvips/foreign/cgifsave.c index df986c29..32ece4e5 100644 --- a/libvips/foreign/cgifsave.c +++ b/libvips/foreign/cgifsave.c @@ -770,8 +770,12 @@ vips_foreign_save_cgif_build( VipsObject *object ) static const char *vips__save_cgif_suffs[] = { ".gif", NULL }; #define UC VIPS_FORMAT_UCHAR -static int bandfmt_gif[10] = { - UC, UC, UC, UC, UC, UC, UC, UC, UC, UC + +/* Type promotion for save ... just always go to uchar. + */ +static VipsBandFormat bandfmt_gif[10] = { + /* Band format: UC C US S UI I F X D DX */ + /* Promotion: */ UC, UC, UC, UC, UC, UC, UC, UC, UC, UC }; static void diff --git a/libvips/foreign/dzsave.c b/libvips/foreign/dzsave.c index 89f87070..70b9e35a 100644 --- a/libvips/foreign/dzsave.c +++ b/libvips/foreign/dzsave.c @@ -2681,9 +2681,9 @@ vips_foreign_save_dz_build( VipsObject *object ) #define D VIPS_FORMAT_DOUBLE #define DX VIPS_FORMAT_DPCOMPLEX -static int bandfmt_dz[10] = { -/* UC C US S UI I F X D DX */ - UC, C, US, S, UI, I, F, F, D, D +static VipsBandFormat bandfmt_dz[10] = { + /* Band format: UC C US S UI I F X D DX */ + /* Promotion: */ UC, C, US, S, UI, I, F, F, D, D }; static const char *dz_suffs[] = { ".dz", ".szi", NULL }; diff --git a/libvips/foreign/fitssave.c b/libvips/foreign/fitssave.c index fc58852a..ea83f167 100644 --- a/libvips/foreign/fitssave.c +++ b/libvips/foreign/fitssave.c @@ -109,9 +109,9 @@ vips_foreign_save_fits_build( VipsObject *object ) #define D VIPS_FORMAT_DOUBLE #define DX VIPS_FORMAT_DPCOMPLEX -static int bandfmt_fits[10] = { -/* UC C US S UI I F X D DX */ - UC, UC, US, US, UI, UI, F, X, D, DX +static VipsBandFormat bandfmt_fits[10] = { + /* Band format: UC C US S UI I F X D DX */ + /* Promotion: */ UC, UC, US, US, UI, UI, F, X, D, DX }; static void diff --git a/libvips/foreign/foreign.c b/libvips/foreign/foreign.c index bfb65f55..5fe67441 100644 --- a/libvips/foreign/foreign.c +++ b/libvips/foreign/foreign.c @@ -1748,9 +1748,9 @@ vips_foreign_save_build( VipsObject *object ) #define D VIPS_FORMAT_DOUBLE #define DX VIPS_FORMAT_DPCOMPLEX -static int vips_foreign_save_format_table[10] = { -// UC C US S UI I F X D DX - UC, C, US, S, UI, I, F, X, D, DX +static VipsBandFormat vips_foreign_save_format_table[10] = { + /* Band format: UC C US S UI I F X D DX */ + /* Promotion: */ UC, C, US, S, UI, I, F, X, D, DX }; static void diff --git a/libvips/foreign/heifsave.c b/libvips/foreign/heifsave.c index b7aebed3..304c137a 100644 --- a/libvips/foreign/heifsave.c +++ b/libvips/foreign/heifsave.c @@ -577,9 +577,12 @@ vips_foreign_save_heif_build( VipsObject *object ) #define UC VIPS_FORMAT_UCHAR #define US VIPS_FORMAT_USHORT -static int vips_heif_bandfmt[10] = { -/* UC C US S UI I F X D DX */ - UC, UC, US, US, US, US, US, US, US, US +/* Except for 8-bit inputs, we send everything else to 16. We decide on 8-bit + * vs. 12 bit save based on Type in_build(), see above. + */ +static VipsBandFormat vips_heif_bandfmt[10] = { + /* Band format: UC C US S UI I F X D DX */ + /* Promotion: */ UC, UC, US, US, US, US, US, US, US, US }; static void diff --git a/libvips/foreign/jpegsave.c b/libvips/foreign/jpegsave.c index 66576e71..df0d7b36 100644 --- a/libvips/foreign/jpegsave.c +++ b/libvips/foreign/jpegsave.c @@ -118,9 +118,9 @@ G_DEFINE_ABSTRACT_TYPE( VipsForeignSaveJpeg, vips_foreign_save_jpeg, /* Type promotion for save ... just always go to uchar. */ -static int bandfmt_jpeg[10] = { - /* UC C US S UI I F X D DX */ - UC, UC, UC, UC, UC, UC, UC, UC, UC, UC +static VipsBandFormat bandfmt_jpeg[10] = { + /* Band format: UC C US S UI I F X D DX */ + /* Promotion: */ UC, UC, UC, UC, UC, UC, UC, UC, UC, UC }; static int diff --git a/libvips/foreign/jxlsave.c b/libvips/foreign/jxlsave.c index 20258b38..3139c154 100644 --- a/libvips/foreign/jxlsave.c +++ b/libvips/foreign/jxlsave.c @@ -484,9 +484,9 @@ vips_foreign_save_jxl_build( VipsObject *object ) /* Type promotion for save ... unsigned ints + float + double. */ -static int bandfmt_jxl[10] = { - /* UC C US S UI I F X D DX */ - UC, UC, US, US, F, F, F, F, F, F +static VipsBandFormat bandfmt_jxl[10] = { + /* Band format: UC C US S UI I F X D DX */ + /* Promotion: */ UC, UC, US, US, F, F, F, F, F, F }; static void diff --git a/libvips/foreign/matrixsave.c b/libvips/foreign/matrixsave.c index 30e9a729..37407304 100644 --- a/libvips/foreign/matrixsave.c +++ b/libvips/foreign/matrixsave.c @@ -153,9 +153,9 @@ vips_foreign_save_matrix_build( VipsObject *object ) #define D VIPS_FORMAT_DOUBLE #define DX VIPS_FORMAT_DPCOMPLEX -static int bandfmt_matrix[10] = { -/* UC C US S UI I F X D DX */ - D, D, D, D, D, D, D, D, D, D +static VipsBandFormat bandfmt_matrix[10] = { + /* Band format: UC C US S UI I F X D DX */ + /* Promotion: */ D, D, D, D, D, D, D, D, D, D }; static const char *vips_foreign_save_matrix_suffs[] = { diff --git a/libvips/foreign/niftisave.c b/libvips/foreign/niftisave.c index 988023b1..47845feb 100644 --- a/libvips/foreign/niftisave.c +++ b/libvips/foreign/niftisave.c @@ -407,9 +407,9 @@ vips_foreign_save_nifti_build( VipsObject *object ) #define D VIPS_FORMAT_DOUBLE #define DX VIPS_FORMAT_DPCOMPLEX -static int vips_nifti_bandfmt[10] = { -/* UC C US S UI I F X D DX */ - UC, C, US, S, UI, I, F, X, D, DX +static VipsBandFormat vips_nifti_bandfmt[10] = { + /* Band format: UC C US S UI I F X D DX */ + /* Promotion: */ UC, C, US, S, UI, I, F, X, D, DX }; static void diff --git a/libvips/foreign/pngsave.c b/libvips/foreign/pngsave.c index eea9966e..250b7213 100644 --- a/libvips/foreign/pngsave.c +++ b/libvips/foreign/pngsave.c @@ -182,9 +182,9 @@ vips_foreign_save_png_build( VipsObject *object ) /* Except for 8-bit inputs, we send everything else to 16. We decide on png8 * vs. png16 based on Type in_build(), see above. */ -static int bandfmt_png[10] = { -/* UC C US S UI I F X D DX */ - UC, UC, US, US, US, US, US, US, US, US +static VipsBandFormat bandfmt_png[10] = { + /* Band format: UC C US S UI I F X D DX */ + /* Promotion: */ UC, UC, US, US, US, US, US, US, US, US }; static void diff --git a/libvips/foreign/ppmsave.c b/libvips/foreign/ppmsave.c index 3812abde..2f66956f 100644 --- a/libvips/foreign/ppmsave.c +++ b/libvips/foreign/ppmsave.c @@ -444,9 +444,9 @@ vips_foreign_save_ppm_build( VipsObject *object ) #define D VIPS_FORMAT_DOUBLE #define DX VIPS_FORMAT_DPCOMPLEX -static int bandfmt_ppm[10] = { -/* UC C US S UI I F X D DX */ - UC, UC, US, US, UI, UI, F, F, F, F +static VipsBandFormat bandfmt_ppm[10] = { + /* Band format: UC C US S UI I F X D DX */ + /* Promotion: */ UC, UC, US, US, UI, UI, F, F, F, F }; static void diff --git a/libvips/foreign/radsave.c b/libvips/foreign/radsave.c index f63981a5..3d169b8d 100644 --- a/libvips/foreign/radsave.c +++ b/libvips/foreign/radsave.c @@ -76,9 +76,9 @@ G_DEFINE_ABSTRACT_TYPE( VipsForeignSaveRad, vips_foreign_save_rad, #define D VIPS_FORMAT_DOUBLE #define DX VIPS_FORMAT_DPCOMPLEX -static int vips_foreign_save_rad_format_table[10] = { -/* UC C US S UI I F X D DX */ - F, F, F, F, F, F, F, F, F, F +static VipsBandFormat vips_foreign_save_rad_format_table[10] = { + /* Band format: UC C US S UI I F X D DX */ + /* Promotion: */ F, F, F, F, F, F, F, F, F, F }; static void diff --git a/libvips/foreign/spngsave.c b/libvips/foreign/spngsave.c index 13022897..dfa66159 100644 --- a/libvips/foreign/spngsave.c +++ b/libvips/foreign/spngsave.c @@ -650,14 +650,15 @@ vips_foreign_save_spng_build( VipsObject *object ) return( 0 ); } -/* Except for 8-bit inputs, we send everything else to 16. We decide on spng8 - * vs. spng16 based on Type in_build(), see above. - */ #define UC VIPS_FORMAT_UCHAR #define US VIPS_FORMAT_USHORT -static int bandfmt_spng[10] = { -/* UC C US S UI I F X D DX */ - UC, UC, US, US, US, US, US, US, US, US + +/* Except for 8-bit inputs, we send everything else to 16. We decide on png8 + * vs. png16 based on Type in_build(), see above. + */ +static VipsBandFormat bandfmt_spng[10] = { + /* Band format: UC C US S UI I F X D DX */ + /* Promotion: */ UC, UC, US, US, US, US, US, US, US, US }; static void diff --git a/libvips/foreign/tiffsave.c b/libvips/foreign/tiffsave.c index 6595bf4c..caa38f4d 100644 --- a/libvips/foreign/tiffsave.c +++ b/libvips/foreign/tiffsave.c @@ -137,9 +137,9 @@ vips_foreign_save_tiff_dispose( GObject *gobject ) /* Type promotion for jpeg-in-tiff save ... just always go to uchar. */ -static int bandfmt_jpeg[10] = { -/* UC C US S UI I F X D DX */ - UC, UC, UC, UC, UC, UC, UC, UC, UC, UC +static VipsBandFormat bandfmt_jpeg[10] = { + /* Band format: UC C US S UI I F X D DX */ + /* Promotion: */ UC, UC, UC, UC, UC, UC, UC, UC, UC, UC }; static int diff --git a/libvips/foreign/vips2magick.c b/libvips/foreign/vips2magick.c index 14d08d1b..ef981276 100644 --- a/libvips/foreign/vips2magick.c +++ b/libvips/foreign/vips2magick.c @@ -445,9 +445,9 @@ static const char *vips__save_magick_gif_suffs[] = { ".gif", NULL }; #define F VIPS_FORMAT_FLOAT #define D VIPS_FORMAT_DOUBLE -static int bandfmt_magick[10] = { -/* UC C US S UI I F X D DX */ - UC, UC, US, US, UI, UI, F, F, D, D +static VipsBandFormat bandfmt_magick[10] = { + /* Band format: UC C US S UI I F X D DX */ + /* Promotion: */ UC, UC, US, US, UI, UI, F, F, D, D }; static void diff --git a/libvips/foreign/webpsave.c b/libvips/foreign/webpsave.c index a73b8096..1b388f8b 100644 --- a/libvips/foreign/webpsave.c +++ b/libvips/foreign/webpsave.c @@ -724,9 +724,9 @@ static const char *vips__save_webp_suffs[] = { ".webp", NULL }; /* Type promotion for save ... just always go to uchar. */ -static int bandfmt_webp[10] = { -/* UC C US S UI I F X D DX */ - UC, UC, UC, UC, UC, UC, UC, UC, UC, UC +static VipsBandFormat bandfmt_webp[10] = { + /* Band format: UC C US S UI I F X D DX */ + /* Promotion: */ UC, UC, UC, UC, UC, UC, UC, UC, UC, UC }; static void diff --git a/libvips/histogram/hist_cum.c b/libvips/histogram/hist_cum.c index 84baa288..bb2c783d 100644 --- a/libvips/histogram/hist_cum.c +++ b/libvips/histogram/hist_cum.c @@ -134,8 +134,8 @@ vips_hist_cum_process( VipsHistogram *histogram, #define DX VIPS_FORMAT_DPCOMPLEX static const VipsBandFormat vips_hist_cum_format_table[10] = { -/* UC C US S UI I F X D DX */ - UI, I, UI, I, UI, I, F, F, D, D + /* Band format: UC C US S UI I F X D DX */ + /* Promotion: */ UI, I, UI, I, UI, I, F, F, D, D }; static void diff --git a/libvips/histogram/maplut.c b/libvips/histogram/maplut.c index d72c7bd4..2598b3b0 100644 --- a/libvips/histogram/maplut.c +++ b/libvips/histogram/maplut.c @@ -498,9 +498,9 @@ vips_maplut_stop( void *vseq, void *a, void *b ) /* Type mapping: go to uchar / ushort / uint to make an index. */ -static int bandfmt_maplut[10] = { -/* UC C US S UI I F X D DX */ - UC, UC, US, US, UI, UI, UI, UI, UI, UI +static const VipsBandFormat bandfmt_maplut[10] = { + /* Band format: UC C US S UI I F X D DX */ + /* Promotion: */ UC, UC, US, US, UI, UI, UI, UI, UI, UI }; /* Repack lut into a set of band arrays. If we're just passing one band of the