Skip to content

Commit b43fea9

Browse files
authored
Improve configurability. Issue #104. (#105)
1 parent 0571f0a commit b43fea9

File tree

4 files changed

+98
-74
lines changed

4 files changed

+98
-74
lines changed

scripts/bimg_decode.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ project "bimg_decode"
3030

3131
if _OPTIONS["with-libheif"] then
3232
defines {
33-
"BIMG_DECODE_HEIF=1",
33+
"BIMG_CONFIG_PARSE_HEIF=1",
3434
}
3535
end
3636

src/config.h

Lines changed: 51 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -8,56 +8,68 @@
88

99
#include <bx/bx.h>
1010

11-
#ifndef BIMG_DECODE_ENABLE
12-
# define BIMG_DECODE_ENABLE 1
13-
#endif // BIMG_DECODE_ENABLE
11+
#ifndef BIMG_CONFIG_DECODE_ENABLE
12+
# define BIMG_CONFIG_DECODE_ENABLE 1
13+
#endif // BIMG_CONFIG_DECODE_ENABLE
1414

15-
#ifndef BIMG_DECODE_BC1
16-
# define BIMG_DECODE_BC1 BIMG_DECODE_ENABLE
17-
#endif // BIMG_DECODE_BC1
15+
#ifndef BIMG_CONFIG_DECODE_BC1
16+
# define BIMG_CONFIG_DECODE_BC1 BIMG_CONFIG_DECODE_ENABLE
17+
#endif // BIMG_CONFIG_DECODE_BC1
1818

19-
#ifndef BIMG_DECODE_BC2
20-
# define BIMG_DECODE_BC2 BIMG_DECODE_ENABLE
21-
#endif // BIMG_DECODE_BC2
19+
#ifndef BIMG_CONFIG_DECODE_BC2
20+
# define BIMG_CONFIG_DECODE_BC2 BIMG_CONFIG_DECODE_ENABLE
21+
#endif // BIMG_CONFIG_DECODE_BC2
2222

23-
#ifndef BIMG_DECODE_BC3
24-
# define BIMG_DECODE_BC3 BIMG_DECODE_ENABLE
25-
#endif // BIMG_DECODE_BC3
23+
#ifndef BIMG_CONFIG_DECODE_BC3
24+
# define BIMG_CONFIG_DECODE_BC3 BIMG_CONFIG_DECODE_ENABLE
25+
#endif // BIMG_CONFIG_DECODE_BC3
2626

27-
#ifndef BIMG_DECODE_BC4
28-
# define BIMG_DECODE_BC4 BIMG_DECODE_ENABLE
29-
#endif // BIMG_DECODE_BC4
27+
#ifndef BIMG_CONFIG_DECODE_BC4
28+
# define BIMG_CONFIG_DECODE_BC4 BIMG_CONFIG_DECODE_ENABLE
29+
#endif // BIMG_CONFIG_DECODE_BC4
3030

31-
#ifndef BIMG_DECODE_BC5
32-
# define BIMG_DECODE_BC5 BIMG_DECODE_ENABLE
33-
#endif // BIMG_DECODE_BC5
31+
#ifndef BIMG_CONFIG_DECODE_BC5
32+
# define BIMG_CONFIG_DECODE_BC5 BIMG_CONFIG_DECODE_ENABLE
33+
#endif // BIMG_CONFIG_DECODE_BC5
3434

35-
#ifndef BIMG_DECODE_BC6
36-
# define BIMG_DECODE_BC6 BIMG_DECODE_ENABLE
37-
#endif // BIMG_DECODE_BC6
35+
#ifndef BIMG_CONFIG_DECODE_BC6
36+
# define BIMG_CONFIG_DECODE_BC6 BIMG_CONFIG_DECODE_ENABLE
37+
#endif // BIMG_CONFIG_DECODE_BC6
3838

39-
#ifndef BIMG_DECODE_BC7
40-
# define BIMG_DECODE_BC7 BIMG_DECODE_ENABLE
41-
#endif // BIMG_DECODE_BC7
39+
#ifndef BIMG_CONFIG_DECODE_BC7
40+
# define BIMG_CONFIG_DECODE_BC7 BIMG_CONFIG_DECODE_ENABLE
41+
#endif // BIMG_CONFIG_DECODE_BC7
4242

43-
#ifndef BIMG_DECODE_ATC
44-
# define BIMG_DECODE_ATC BIMG_DECODE_ENABLE
45-
#endif // BIMG_DECODE_ATC
43+
#ifndef BIMG_CONFIG_DECODE_ATC
44+
# define BIMG_CONFIG_DECODE_ATC BIMG_CONFIG_DECODE_ENABLE
45+
#endif // BIMG_CONFIG_DECODE_ATC
4646

47-
#ifndef BIMG_DECODE_ASTC
48-
# define BIMG_DECODE_ASTC BIMG_DECODE_ENABLE
49-
#endif // BIMG_DECODE_ASTC
47+
#ifndef BIMG_CONFIG_DECODE_ASTC
48+
# define BIMG_CONFIG_DECODE_ASTC BIMG_CONFIG_DECODE_ENABLE
49+
#endif // BIMG_CONFIG_DECODE_ASTC
5050

51-
#ifndef BIMG_DECODE_ETC1
52-
# define BIMG_DECODE_ETC1 BIMG_DECODE_ENABLE
53-
#endif // BIMG_DECODE_ETC1
51+
#ifndef BIMG_CONFIG_DECODE_ETC1
52+
# define BIMG_CONFIG_DECODE_ETC1 BIMG_CONFIG_DECODE_ENABLE
53+
#endif // BIMG_CONFIG_DECODE_ETC1
5454

55-
#ifndef BIMG_DECODE_ETC2
56-
# define BIMG_DECODE_ETC2 BIMG_DECODE_ENABLE
57-
#endif // BIMG_DECODE_ETC2
55+
#ifndef BIMG_CONFIG_DECODE_ETC2
56+
# define BIMG_CONFIG_DECODE_ETC2 BIMG_CONFIG_DECODE_ENABLE
57+
#endif // BIMG_CONFIG_DECODE_ETC2
5858

59-
#ifndef BIMG_DECODE_HEIF
60-
# define BIMG_DECODE_HEIF 0
61-
#endif // BIMG_DECODE_HEIF
59+
#ifndef BIMG_CONFIG_PARSE_EXR
60+
# define BIMG_CONFIG_PARSE_EXR 1
61+
#endif // BIMG_CONFIG_PARSE_EXR
62+
63+
#ifndef BIMG_CONFIG_PARSE_HEIF
64+
# define BIMG_CONFIG_PARSE_HEIF 0
65+
#endif // BIMG_CONFIG_PARSE_HEIF
66+
67+
#ifndef BIMG_CONFIG_PARSE_JPEG
68+
# define BIMG_CONFIG_PARSE_JPEG 1
69+
#endif // BIMG_CONFIG_PARSE_JPEG
70+
71+
#ifndef BIMG_CONFIG_PARSE_PNG
72+
# define BIMG_CONFIG_PARSE_PNG 1
73+
#endif // BIMG_CONFIG_PARSE_PNG
6274

6375
#endif // BIMG_CONFIG_H_HEADER_GUARD

src/image.cpp

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1394,7 +1394,7 @@ namespace bimg
13941394

13951395
static void decodeBlockDxt(uint8_t _dst[16*4], const uint8_t _src[8])
13961396
{
1397-
if (!BX_ENABLED(BIMG_DECODE_BC2 || BIMG_DECODE_BC3) )
1397+
if (!BX_ENABLED(BIMG_CONFIG_DECODE_BC2 || BIMG_CONFIG_DECODE_BC3) )
13981398
{
13991399
return;
14001400
}
@@ -1430,7 +1430,7 @@ namespace bimg
14301430

14311431
static void decodeBlockDxt1(uint8_t _dst[16*4], const uint8_t _src[8])
14321432
{
1433-
if (!BX_ENABLED(BIMG_DECODE_BC1 || BIMG_DECODE_BC2 || BIMG_DECODE_BC3) )
1433+
if (!BX_ENABLED(BIMG_CONFIG_DECODE_BC1 || BIMG_CONFIG_DECODE_BC2 || BIMG_CONFIG_DECODE_BC3) )
14341434
{
14351435
return;
14361436
}
@@ -1486,7 +1486,7 @@ namespace bimg
14861486

14871487
static void decodeBlockDxt23A(uint8_t _dst[16*4], const uint8_t _src[8])
14881488
{
1489-
if (!BX_ENABLED(BIMG_DECODE_BC2) )
1489+
if (!BX_ENABLED(BIMG_CONFIG_DECODE_BC2) )
14901490
{
14911491
return;
14921492
}
@@ -1500,7 +1500,7 @@ namespace bimg
15001500

15011501
static void decodeBlockDxt45A(uint8_t _dst[16*4], const uint8_t _src[8])
15021502
{
1503-
if (!BX_ENABLED(BIMG_DECODE_BC3 || BIMG_DECODE_BC4 || BIMG_DECODE_BC5) )
1503+
if (!BX_ENABLED(BIMG_CONFIG_DECODE_BC3 || BIMG_CONFIG_DECODE_BC4 || BIMG_CONFIG_DECODE_BC5) )
15041504
{
15051505
return;
15061506
}
@@ -1880,7 +1880,7 @@ namespace bimg
18801880

18811881
static void decodeBlockBc6h(uint16_t _dst[16*3], const uint8_t _src[16], bool _signed)
18821882
{
1883-
if (!BX_ENABLED(BIMG_DECODE_BC6) )
1883+
if (!BX_ENABLED(BIMG_CONFIG_DECODE_BC6) )
18841884
{
18851885
return;
18861886
}
@@ -2305,7 +2305,7 @@ namespace bimg
23052305

23062306
static void decodeBlockBc6h(float _dst[16*4], const uint8_t _src[16])
23072307
{
2308-
if (!BX_ENABLED(BIMG_DECODE_BC6) )
2308+
if (!BX_ENABLED(BIMG_CONFIG_DECODE_BC6) )
23092309
{
23102310
return;
23112311
}
@@ -2358,7 +2358,7 @@ namespace bimg
23582358

23592359
static void decodeBlockBc7(uint8_t _dst[16*4], const uint8_t _src[16])
23602360
{
2361-
if (!BX_ENABLED(BIMG_DECODE_BC7) )
2361+
if (!BX_ENABLED(BIMG_CONFIG_DECODE_BC7) )
23622362
{
23632363
return;
23642364
}
@@ -2552,7 +2552,7 @@ namespace bimg
25522552
//
25532553
static void decodeBlockATC(uint8_t _dst[16*4], const uint8_t _src[8])
25542554
{
2555-
if (!BX_ENABLED(BIMG_DECODE_ATC) )
2555+
if (!BX_ENABLED(BIMG_CONFIG_DECODE_ATC) )
25562556
{
25572557
return;
25582558
}
@@ -2864,7 +2864,7 @@ namespace bimg
28642864

28652865
static void decodeBlockEtc12(uint8_t _dst[16*4], const uint8_t _src[8])
28662866
{
2867-
if (!BX_ENABLED(BIMG_DECODE_ETC1 || BIMG_DECODE_ETC2) )
2867+
if (!BX_ENABLED(BIMG_CONFIG_DECODE_ETC1 || BIMG_CONFIG_DECODE_ETC2) )
28682868
{
28692869
return;
28702870
}
@@ -3003,7 +3003,7 @@ namespace bimg
30033003

30043004
void decodeBlockEtc2Alpha(uint8_t _dst[16 * 4], const uint8_t _src[8])
30053005
{
3006-
if (!BX_ENABLED(BIMG_DECODE_ETC2))
3006+
if (!BX_ENABLED(BIMG_CONFIG_DECODE_ETC2))
30073007
{
30083008
return;
30093009
}
@@ -4565,7 +4565,7 @@ namespace bimg
45654565
switch (_srcFormat)
45664566
{
45674567
case TextureFormat::BC1:
4568-
if (BX_ENABLED(BIMG_DECODE_BC1) )
4568+
if (BX_ENABLED(BIMG_CONFIG_DECODE_BC1) )
45694569
{
45704570
for (uint32_t yy = 0; yy < height; ++yy)
45714571
{
@@ -4584,13 +4584,13 @@ namespace bimg
45844584
}
45854585
else
45864586
{
4587-
BX_WARN(false, "BC1 decoder is disabled (BIMG_DECODE_BC1).");
4587+
BX_WARN(false, "BC1 decoder is disabled (BIMG_CONFIG_DECODE_BC1).");
45884588
imageCheckerboard(_dst, _width, _height, 16, UINT32_C(0xff000000), UINT32_C(0xff00ff00) );
45894589
}
45904590
break;
45914591

45924592
case TextureFormat::BC2:
4593-
if (BX_ENABLED(BIMG_DECODE_BC2) )
4593+
if (BX_ENABLED(BIMG_CONFIG_DECODE_BC2) )
45944594
{
45954595
for (uint32_t yy = 0; yy < height; ++yy)
45964596
{
@@ -4611,13 +4611,13 @@ namespace bimg
46114611
}
46124612
else
46134613
{
4614-
BX_WARN(false, "BC2 decoder is disabled (BIMG_DECODE_BC2).");
4614+
BX_WARN(false, "BC2 decoder is disabled (BIMG_CONFIG_DECODE_BC2).");
46154615
imageCheckerboard(_dst, _width, _height, 16, UINT32_C(0xff000000), UINT32_C(0xff00ff00) );
46164616
}
46174617
break;
46184618

46194619
case TextureFormat::BC3:
4620-
if (BX_ENABLED(BIMG_DECODE_BC3) )
4620+
if (BX_ENABLED(BIMG_CONFIG_DECODE_BC3) )
46214621
{
46224622
for (uint32_t yy = 0; yy < height; ++yy)
46234623
{
@@ -4638,13 +4638,13 @@ namespace bimg
46384638
}
46394639
else
46404640
{
4641-
BX_WARN(false, "BC3 decoder is disabled (BIMG_DECODE_BC3).");
4641+
BX_WARN(false, "BC3 decoder is disabled (BIMG_CONFIG_DECODE_BC3).");
46424642
imageCheckerboard(_dst, _width, _height, 16, UINT32_C(0xff000000), UINT32_C(0xff00ff00) );
46434643
}
46444644
break;
46454645

46464646
case TextureFormat::BC4:
4647-
if (BX_ENABLED(BIMG_DECODE_BC4) )
4647+
if (BX_ENABLED(BIMG_CONFIG_DECODE_BC4) )
46484648
{
46494649
for (uint32_t yy = 0; yy < height; ++yy)
46504650
{
@@ -4663,13 +4663,13 @@ namespace bimg
46634663
}
46644664
else
46654665
{
4666-
BX_WARN(false, "BC4 decoder is disabled (BIMG_DECODE_BC4).");
4666+
BX_WARN(false, "BC4 decoder is disabled (BIMG_CONFIG_DECODE_BC4).");
46674667
imageCheckerboard(_dst, _width, _height, 16, UINT32_C(0xff000000), UINT32_C(0xff00ff00) );
46684668
}
46694669
break;
46704670

46714671
case TextureFormat::BC5:
4672-
if (BX_ENABLED(BIMG_DECODE_BC5) )
4672+
if (BX_ENABLED(BIMG_CONFIG_DECODE_BC5) )
46734673
{
46744674
for (uint32_t yy = 0; yy < height; ++yy)
46754675
{
@@ -4699,13 +4699,13 @@ namespace bimg
46994699
}
47004700
else
47014701
{
4702-
BX_WARN(false, "BC5 decoder is disabled (BIMG_DECODE_BC5).");
4702+
BX_WARN(false, "BC5 decoder is disabled (BIMG_CONFIG_DECODE_BC5).");
47034703
imageCheckerboard(_dst, _width, _height, 16, UINT32_C(0xff000000), UINT32_C(0xff00ff00) );
47044704
}
47054705
break;
47064706

47074707
case TextureFormat::BC6H:
4708-
if (BX_ENABLED(BIMG_DECODE_BC6) )
4708+
if (BX_ENABLED(BIMG_CONFIG_DECODE_BC6) )
47094709
{
47104710
ImageContainer* rgba32f = imageAlloc(_allocator
47114711
, TextureFormat::RGBA32F
@@ -4722,13 +4722,13 @@ namespace bimg
47224722
}
47234723
else
47244724
{
4725-
BX_WARN(false, "BC6 decoder is disabled (BIMG_DECODE_BC6).");
4725+
BX_WARN(false, "BC6 decoder is disabled (BIMG_CONFIG_DECODE_BC6).");
47264726
imageCheckerboard(_dst, _width, _height, 16, UINT32_C(0xff000000), UINT32_C(0xff00ff00) );
47274727
}
47284728
break;
47294729

47304730
case TextureFormat::BC7:
4731-
if (BX_ENABLED(BIMG_DECODE_BC7) )
4731+
if (BX_ENABLED(BIMG_CONFIG_DECODE_BC7) )
47324732
{
47334733
for (uint32_t yy = 0; yy < height; ++yy)
47344734
{
@@ -4747,14 +4747,14 @@ namespace bimg
47474747
}
47484748
else
47494749
{
4750-
BX_WARN(false, "BC7 decoder is disabled (BIMG_DECODE_BC7).");
4750+
BX_WARN(false, "BC7 decoder is disabled (BIMG_CONFIG_DECODE_BC7).");
47514751
imageCheckerboard(_dst, _width, _height, 16, UINT32_C(0xff000000), UINT32_C(0xff00ff00) );
47524752
}
47534753
break;
47544754

47554755
case TextureFormat::ETC1:
47564756
case TextureFormat::ETC2:
4757-
if (BX_ENABLED(BIMG_DECODE_ETC1 || BIMG_DECODE_ETC2) )
4757+
if (BX_ENABLED(BIMG_CONFIG_DECODE_ETC1 || BIMG_CONFIG_DECODE_ETC2) )
47584758
{
47594759
for (uint32_t yy = 0; yy < height; ++yy)
47604760
{
@@ -4773,13 +4773,13 @@ namespace bimg
47734773
}
47744774
else
47754775
{
4776-
BX_WARN(false, "ETC1/ETC2 decoder is disabled (BIMG_DECODE_ETC1/ETC2).");
4776+
BX_WARN(false, "ETC1/ETC2 decoder is disabled (BIMG_CONFIG_DECODE_ETC1/ETC2).");
47774777
imageCheckerboard(_dst, _width, _height, 16, UINT32_C(0xff000000), UINT32_C(0xff00ff00) );
47784778
}
47794779
break;
47804780

47814781
case TextureFormat::ETC2A:
4782-
if (BX_ENABLED(BIMG_DECODE_ETC2))
4782+
if (BX_ENABLED(BIMG_CONFIG_DECODE_ETC2))
47834783
{
47844784
for (uint32_t yy = 0; yy < height; ++yy)
47854785
{
@@ -4800,7 +4800,7 @@ namespace bimg
48004800
}
48014801
else
48024802
{
4803-
BX_WARN(false, "ETC2 decoder is disabled (BIMG_DECODE_ETC2).");
4803+
BX_WARN(false, "ETC2 decoder is disabled (BIMG_CONFIG_DECODE_ETC2).");
48044804
imageCheckerboard(_dst, _width, _height, 16, UINT32_C(0xff000000), UINT32_C(0xff00ff00));
48054805
}
48064806
break;
@@ -4997,7 +4997,7 @@ namespace bimg
49974997
case TextureFormat::ASTC10x10:
49984998
case TextureFormat::ASTC12x10:
49994999
case TextureFormat::ASTC12x12:
5000-
if (BX_ENABLED(BIMG_DECODE_ASTC) )
5000+
if (BX_ENABLED(BIMG_CONFIG_DECODE_ASTC) )
50015001
{
50025002
const bimg::ImageBlockInfo& astcBlockInfo = bimg::getBlockInfo(_srcFormat);
50035003

@@ -5070,7 +5070,7 @@ namespace bimg
50705070
}
50715071
else
50725072
{
5073-
BX_WARN(false, "ASTC decoder is disabled (BIMG_DECODE_ASTC).");
5073+
BX_WARN(false, "ASTC decoder is disabled (BIMG_CONFIG_DECODE_ASTC).");
50745074
imageCheckerboard(_dst, _width, _height, 16, UINT32_C(0xff000000), UINT32_C(0xff00ff00) );
50755075
}
50765076
break;

0 commit comments

Comments
 (0)