Skip to content

Commit 293263c

Browse files
committed
Format preprocessor macros more consistently
Within the libjpeg API code, it seems to be more the convention than not to separate the macro name and value by two or more spaces, which improves general readability. Making this consistent across all of libjpeg-turbo is less about my individual preferences and more about making it easy to automatically detect variations from our chosen formatting convention. I intend to release the script I'm using to validate this stuff, once it matures and stabilizes a bit.
1 parent 09497c1 commit 293263c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+1763
-1700
lines changed

jcarith.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ typedef arith_entropy_encoder *arith_entropy_ptr;
6363
* in the lower bits (mask 0x7F).
6464
*/
6565

66-
#define DC_STAT_BINS 64
67-
#define AC_STAT_BINS 256
66+
#define DC_STAT_BINS 64
67+
#define AC_STAT_BINS 256
6868

6969
/* NOTE: Uncomment the following #define if you want to use the
7070
* given formula for calculating the AC conditioning parameter Kx

jccolor.c

+42-42
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,13 @@ typedef my_color_converter *my_cconvert_ptr;
9393
#undef RGB_BLUE
9494
#undef RGB_PIXELSIZE
9595

96-
#define RGB_RED EXT_RGB_RED
97-
#define RGB_GREEN EXT_RGB_GREEN
98-
#define RGB_BLUE EXT_RGB_BLUE
99-
#define RGB_PIXELSIZE EXT_RGB_PIXELSIZE
100-
#define rgb_ycc_convert_internal extrgb_ycc_convert_internal
101-
#define rgb_gray_convert_internal extrgb_gray_convert_internal
102-
#define rgb_rgb_convert_internal extrgb_rgb_convert_internal
96+
#define RGB_RED EXT_RGB_RED
97+
#define RGB_GREEN EXT_RGB_GREEN
98+
#define RGB_BLUE EXT_RGB_BLUE
99+
#define RGB_PIXELSIZE EXT_RGB_PIXELSIZE
100+
#define rgb_ycc_convert_internal extrgb_ycc_convert_internal
101+
#define rgb_gray_convert_internal extrgb_gray_convert_internal
102+
#define rgb_rgb_convert_internal extrgb_rgb_convert_internal
103103
#include "jccolext.c"
104104
#undef RGB_RED
105105
#undef RGB_GREEN
@@ -109,13 +109,13 @@ typedef my_color_converter *my_cconvert_ptr;
109109
#undef rgb_gray_convert_internal
110110
#undef rgb_rgb_convert_internal
111111

112-
#define RGB_RED EXT_RGBX_RED
113-
#define RGB_GREEN EXT_RGBX_GREEN
114-
#define RGB_BLUE EXT_RGBX_BLUE
115-
#define RGB_PIXELSIZE EXT_RGBX_PIXELSIZE
116-
#define rgb_ycc_convert_internal extrgbx_ycc_convert_internal
117-
#define rgb_gray_convert_internal extrgbx_gray_convert_internal
118-
#define rgb_rgb_convert_internal extrgbx_rgb_convert_internal
112+
#define RGB_RED EXT_RGBX_RED
113+
#define RGB_GREEN EXT_RGBX_GREEN
114+
#define RGB_BLUE EXT_RGBX_BLUE
115+
#define RGB_PIXELSIZE EXT_RGBX_PIXELSIZE
116+
#define rgb_ycc_convert_internal extrgbx_ycc_convert_internal
117+
#define rgb_gray_convert_internal extrgbx_gray_convert_internal
118+
#define rgb_rgb_convert_internal extrgbx_rgb_convert_internal
119119
#include "jccolext.c"
120120
#undef RGB_RED
121121
#undef RGB_GREEN
@@ -125,13 +125,13 @@ typedef my_color_converter *my_cconvert_ptr;
125125
#undef rgb_gray_convert_internal
126126
#undef rgb_rgb_convert_internal
127127

128-
#define RGB_RED EXT_BGR_RED
129-
#define RGB_GREEN EXT_BGR_GREEN
130-
#define RGB_BLUE EXT_BGR_BLUE
131-
#define RGB_PIXELSIZE EXT_BGR_PIXELSIZE
132-
#define rgb_ycc_convert_internal extbgr_ycc_convert_internal
133-
#define rgb_gray_convert_internal extbgr_gray_convert_internal
134-
#define rgb_rgb_convert_internal extbgr_rgb_convert_internal
128+
#define RGB_RED EXT_BGR_RED
129+
#define RGB_GREEN EXT_BGR_GREEN
130+
#define RGB_BLUE EXT_BGR_BLUE
131+
#define RGB_PIXELSIZE EXT_BGR_PIXELSIZE
132+
#define rgb_ycc_convert_internal extbgr_ycc_convert_internal
133+
#define rgb_gray_convert_internal extbgr_gray_convert_internal
134+
#define rgb_rgb_convert_internal extbgr_rgb_convert_internal
135135
#include "jccolext.c"
136136
#undef RGB_RED
137137
#undef RGB_GREEN
@@ -141,13 +141,13 @@ typedef my_color_converter *my_cconvert_ptr;
141141
#undef rgb_gray_convert_internal
142142
#undef rgb_rgb_convert_internal
143143

144-
#define RGB_RED EXT_BGRX_RED
145-
#define RGB_GREEN EXT_BGRX_GREEN
146-
#define RGB_BLUE EXT_BGRX_BLUE
147-
#define RGB_PIXELSIZE EXT_BGRX_PIXELSIZE
148-
#define rgb_ycc_convert_internal extbgrx_ycc_convert_internal
149-
#define rgb_gray_convert_internal extbgrx_gray_convert_internal
150-
#define rgb_rgb_convert_internal extbgrx_rgb_convert_internal
144+
#define RGB_RED EXT_BGRX_RED
145+
#define RGB_GREEN EXT_BGRX_GREEN
146+
#define RGB_BLUE EXT_BGRX_BLUE
147+
#define RGB_PIXELSIZE EXT_BGRX_PIXELSIZE
148+
#define rgb_ycc_convert_internal extbgrx_ycc_convert_internal
149+
#define rgb_gray_convert_internal extbgrx_gray_convert_internal
150+
#define rgb_rgb_convert_internal extbgrx_rgb_convert_internal
151151
#include "jccolext.c"
152152
#undef RGB_RED
153153
#undef RGB_GREEN
@@ -157,13 +157,13 @@ typedef my_color_converter *my_cconvert_ptr;
157157
#undef rgb_gray_convert_internal
158158
#undef rgb_rgb_convert_internal
159159

160-
#define RGB_RED EXT_XBGR_RED
161-
#define RGB_GREEN EXT_XBGR_GREEN
162-
#define RGB_BLUE EXT_XBGR_BLUE
163-
#define RGB_PIXELSIZE EXT_XBGR_PIXELSIZE
164-
#define rgb_ycc_convert_internal extxbgr_ycc_convert_internal
165-
#define rgb_gray_convert_internal extxbgr_gray_convert_internal
166-
#define rgb_rgb_convert_internal extxbgr_rgb_convert_internal
160+
#define RGB_RED EXT_XBGR_RED
161+
#define RGB_GREEN EXT_XBGR_GREEN
162+
#define RGB_BLUE EXT_XBGR_BLUE
163+
#define RGB_PIXELSIZE EXT_XBGR_PIXELSIZE
164+
#define rgb_ycc_convert_internal extxbgr_ycc_convert_internal
165+
#define rgb_gray_convert_internal extxbgr_gray_convert_internal
166+
#define rgb_rgb_convert_internal extxbgr_rgb_convert_internal
167167
#include "jccolext.c"
168168
#undef RGB_RED
169169
#undef RGB_GREEN
@@ -173,13 +173,13 @@ typedef my_color_converter *my_cconvert_ptr;
173173
#undef rgb_gray_convert_internal
174174
#undef rgb_rgb_convert_internal
175175

176-
#define RGB_RED EXT_XRGB_RED
177-
#define RGB_GREEN EXT_XRGB_GREEN
178-
#define RGB_BLUE EXT_XRGB_BLUE
179-
#define RGB_PIXELSIZE EXT_XRGB_PIXELSIZE
180-
#define rgb_ycc_convert_internal extxrgb_ycc_convert_internal
181-
#define rgb_gray_convert_internal extxrgb_gray_convert_internal
182-
#define rgb_rgb_convert_internal extxrgb_rgb_convert_internal
176+
#define RGB_RED EXT_XRGB_RED
177+
#define RGB_GREEN EXT_XRGB_GREEN
178+
#define RGB_BLUE EXT_XRGB_BLUE
179+
#define RGB_PIXELSIZE EXT_XRGB_PIXELSIZE
180+
#define rgb_ycc_convert_internal extxrgb_ycc_convert_internal
181+
#define rgb_gray_convert_internal extxrgb_gray_convert_internal
182+
#define rgb_rgb_convert_internal extxrgb_rgb_convert_internal
183183
#include "jccolext.c"
184184
#undef RGB_RED
185185
#undef RGB_GREEN

jcdctmgr.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ start_pass_fdctmgr(j_compress_ptr cinfo)
283283
* scalefactor[k] = cos(k*PI/16) * sqrt(2) for k=1..7
284284
* We apply a further scale factor of 8.
285285
*/
286-
#define CONST_BITS 14
286+
#define CONST_BITS 14
287287
static const INT16 aanscales[DCTSIZE2] = {
288288
/* precomputed values scaled up by 14 bits */
289289
16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520,

jchuff.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@
4747
#endif
4848

4949
#ifdef USE_CLZ_INTRINSIC
50-
#define JPEG_NBITS_NONZERO(x) (32 - __builtin_clz(x))
51-
#define JPEG_NBITS(x) (x ? JPEG_NBITS_NONZERO(x) : 0)
50+
#define JPEG_NBITS_NONZERO(x) (32 - __builtin_clz(x))
51+
#define JPEG_NBITS(x) (x ? JPEG_NBITS_NONZERO(x) : 0)
5252
#else
5353
#include "jpeg_nbits_table.h"
54-
#define JPEG_NBITS(x) (jpeg_nbits_table[x])
55-
#define JPEG_NBITS_NONZERO(x) JPEG_NBITS(x)
54+
#define JPEG_NBITS(x) (jpeg_nbits_table[x])
55+
#define JPEG_NBITS_NONZERO(x) JPEG_NBITS(x)
5656
#endif
5757

5858

@@ -425,7 +425,7 @@ dump_buffer(working_state *state)
425425
* scanning order-- 1, 8, 16, etc.), then this will produce an encoded block
426426
* larger than 200 bytes.
427427
*/
428-
#define BUFSIZE (DCTSIZE2 * 4)
428+
#define BUFSIZE (DCTSIZE2 * 4)
429429

430430
#define LOAD_BUFFER() { \
431431
if (state->free_in_buffer < BUFSIZE) { \
@@ -882,7 +882,7 @@ encode_mcu_gather(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
882882
GLOBAL(void)
883883
jpeg_gen_optimal_table(j_compress_ptr cinfo, JHUFF_TBL *htbl, long freq[])
884884
{
885-
#define MAX_CLEN 32 /* assumed maximum initial code length */
885+
#define MAX_CLEN 32 /* assumed maximum initial code length */
886886
UINT8 bits[MAX_CLEN + 1]; /* bits[k] = # of symbols with code length k */
887887
int codesize[257]; /* codesize[k] = code length of symbol k */
888888
int others[257]; /* next symbol in current branch of tree */

jchuff.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
*/
2121

2222
#if BITS_IN_JSAMPLE == 8
23-
#define MAX_COEF_BITS 10
23+
#define MAX_COEF_BITS 10
2424
#else
25-
#define MAX_COEF_BITS 14
25+
#define MAX_COEF_BITS 14
2626
#endif
2727

2828
/* Derived data constructed for each Huffman table */

jcmaster.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,9 @@ validate_script(j_compress_ptr cinfo)
242242
* which might cause problems for some decoders.
243243
*/
244244
#if BITS_IN_JSAMPLE == 8
245-
#define MAX_AH_AL 10
245+
#define MAX_AH_AL 10
246246
#else
247-
#define MAX_AH_AL 13
247+
#define MAX_AH_AL 13
248248
#endif
249249
if (Ss < 0 || Ss >= DCTSIZE2 || Se < Ss || Se >= DCTSIZE2 ||
250250
Ah < 0 || Ah > MAX_AH_AL || Al < 0 || Al > MAX_AH_AL)

jconfig.h.in

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
/* Version ID for the JPEG library.
22
* Might be useful for tests like "#if JPEG_LIB_VERSION >= 60".
33
*/
4-
#define JPEG_LIB_VERSION @JPEG_LIB_VERSION@
4+
#define JPEG_LIB_VERSION @JPEG_LIB_VERSION@
55

66
/* libjpeg-turbo version */
7-
#define LIBJPEG_TURBO_VERSION @VERSION@
7+
#define LIBJPEG_TURBO_VERSION @VERSION@
88

99
/* libjpeg-turbo version in integer form */
10-
#define LIBJPEG_TURBO_VERSION_NUMBER @LIBJPEG_TURBO_VERSION_NUMBER@
10+
#define LIBJPEG_TURBO_VERSION_NUMBER @LIBJPEG_TURBO_VERSION_NUMBER@
1111

1212
/* Support arithmetic encoding */
1313
#cmakedefine C_ARITH_CODING_SUPPORTED

jconfigint.h.in

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
/* libjpeg-turbo build number */
2-
#define BUILD "@BUILD@"
2+
#define BUILD "@BUILD@"
33

44
/* Compiler's inline keyword */
55
#undef inline
66

77
/* How to obtain function inlining. */
8-
#define INLINE @INLINE@
8+
#define INLINE @INLINE@
99

1010
/* Define to the full name of this package. */
11-
#define PACKAGE_NAME "@CMAKE_PROJECT_NAME@"
11+
#define PACKAGE_NAME "@CMAKE_PROJECT_NAME@"
1212

1313
/* Version number of package */
14-
#define VERSION "@VERSION@"
14+
#define VERSION "@VERSION@"
1515

1616
#ifndef _WIN32
1717

1818
/* The size of `size_t', as computed by sizeof. */
19-
#define SIZEOF_SIZE_T @SIZE_T@
19+
#define SIZEOF_SIZE_T @SIZE_T@
2020

2121
#endif

jcphuff.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@
4545
#endif
4646

4747
#ifdef USE_CLZ_INTRINSIC
48-
#define JPEG_NBITS_NONZERO(x) (32 - __builtin_clz(x))
49-
#define JPEG_NBITS(x) (x ? JPEG_NBITS_NONZERO(x) : 0)
48+
#define JPEG_NBITS_NONZERO(x) (32 - __builtin_clz(x))
49+
#define JPEG_NBITS(x) (x ? JPEG_NBITS_NONZERO(x) : 0)
5050
#else
5151
#include "jpeg_nbits_table.h"
52-
#define JPEG_NBITS(x) (jpeg_nbits_table[x])
53-
#define JPEG_NBITS_NONZERO(x) JPEG_NBITS(x)
52+
#define JPEG_NBITS(x) (jpeg_nbits_table[x])
53+
#define JPEG_NBITS_NONZERO(x) JPEG_NBITS(x)
5454
#endif
5555

5656

jcstest.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@
3535
#include <setjmp.h>
3636

3737
#ifndef JCS_EXTENSIONS
38-
#define JCS_EXT_RGB 6
38+
#define JCS_EXT_RGB 6
3939
#endif
4040
#if !defined(JCS_EXTENSIONS) || !defined(JCS_ALPHA_EXTENSIONS)
41-
#define JCS_EXT_RGBA 12
41+
#define JCS_EXT_RGBA 12
4242
#endif
4343

4444
static char lasterror[JMSG_LENGTH_MAX] = "No error";

jdarith.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#include "jpeglib.h"
2222

2323

24-
#define NEG_1 ((unsigned int)-1)
24+
#define NEG_1 ((unsigned int)-1)
2525

2626

2727
/* Expanded entropy decoder object for arithmetic decoding. */
@@ -63,8 +63,8 @@ typedef arith_entropy_decoder *arith_entropy_ptr;
6363
* in the lower bits (mask 0x7F).
6464
*/
6565

66-
#define DC_STAT_BINS 64
67-
#define AC_STAT_BINS 256
66+
#define DC_STAT_BINS 64
67+
#define AC_STAT_BINS 256
6868

6969

7070
LOCAL(int)

0 commit comments

Comments
 (0)