Skip to content

Commit 7643da6

Browse files
author
Argent77
committed
Merge remote-tracking branch 'origin/devel'
2 parents f3ba027 + 600b21d commit 7643da6

Some content is hidden

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

49 files changed

+3207
-1864
lines changed

README.md

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ The tool uses modern compression algorithms to achieve great compression ratios
88
- TBC files will be automatically decompressed into the TIS format.
99
- MOS files will be automatically compressed into the MBC format.
1010
- MBC files will be automatically decompressed into the MOS format.
11+
- MOZ files will be automatically decompressed into the MOS format.
12+
- TIZ files will be automatically decompressed into the TIS format.
1113

1214
A detailed description of the TBC and MBC formats can be found in FORMATS.
1315

@@ -29,7 +31,7 @@ Options:
2931
-u Do not apply tile compression.
3032
-o output Select output file or folder.
3133
(Note: Output file works only with single input file!)
32-
-z MOS only: Decompress MBC into compressed MOS (MOSC).
34+
-z Decode MBC/MOZ into compressed MOS (MOSC).
3335
-q Dec[Enc] Set quality levels for decoding and, optionally, encoding.
3436
Supported levels: 0..9 (Defaults: 4 for decoding, 9 for encoding)
3537
(0=fast and lower quality, 9=slow and higher quality)
@@ -54,31 +56,26 @@ Options:
5456
-I Show file information and exit.
5557
-V Print version number and exit.
5658
57-
Supported input file types: TIS, MOS, TBC, MBC
59+
Supported input file types: TIS, MOS, TBC, MBC, TIZ, MOZ
5860
Note: You can mix and match input files of each supported type.
5961
```
6062

6163

6264
### LICENSE
6365

64-
tileconv is distributed under the terms and conditions of the MIT license.
65-
This license is specified at the top of each source file and must be preserved
66-
in its entirety.
66+
tileconv is distributed under the terms and conditions of the MIT license. This license is specified at the top of each source file and must be preserved in its entirety.
6767

6868

6969
### BUILDING TILECONV
7070
**Dependencies:**
7171
- zlib (http://www.zlib.net/)
7272
- libsquish (https://code.google.com/p/libsquish/)
7373
- pngquant (https://github.com/pornel/pngquant/)
74+
- libjpeg-turbo (http://libjpeg-turbo.virtualgl.org/)
7475

75-
External libraries and include files are assumed to be located in the
76-
subfolders "zlib", "squish" and "pngquant". The libraries are providing their
77-
own instructions how to compile them. Afterwards call "make" to build tileconv.
78-
Note: You'll need a compiler that supports the C++11 standard.
76+
External libraries and include files are assumed to be located in the subfolders "zlib", "squish", "pngquant" and "jpeg-turbo". The libraries are providing their own instructions how to compile them. libjpeg-turbo has to be compiled with the v8 API/ABI. Afterwards call "make" to build tileconv. **Note:** You'll need a compiler that supports the C++11 standard.
7977

80-
If you want to change paths for the external libraries or include files,
81-
you can do so by modifying the file "config.mk" by hand.
78+
If you want to change paths for the external libraries or include files, you can do so by modifying the file "config.mk" by hand.
8279

8380

8481
### CONTACT

tileconv/COPYING

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,31 @@ copyright notice and this permission notice appear in supporting
116116
documentation. This software is provided "as is" without express or
117117
implied warranty.
118118

119+
120+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ libjpeg-turbo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
121+
122+
Copyright (C)2009-2012, 2014 D. R. Commander. All Rights Reserved.
123+
124+
Redistribution and use in source and binary forms, with or without
125+
modification, are permitted provided that the following conditions are met:
126+
127+
- Redistributions of source code must retain the above copyright notice,
128+
this list of conditions and the following disclaimer.
129+
- Redistributions in binary form must reproduce the above copyright notice,
130+
this list of conditions and the following disclaimer in the documentation
131+
and/or other materials provided with the distribution.
132+
- Neither the name of the libjpeg-turbo Project nor the names of its
133+
contributors may be used to endorse or promote products derived from this
134+
software without specific prior written permission.
135+
136+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS",
137+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
138+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
139+
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
140+
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
141+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
142+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
143+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
144+
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
145+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
146+
POSSIBILITY OF SUCH DAMAGE.

tileconv/FORMATS

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,46 @@
11
Description of the file formats TBC and MBC
22
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
33

4+
Note: Using little-endian byte order for data fields.
5+
46
Main Header (TBC):
57
Offset Size Description
68
0x0000 4 Signature ('TBC ')
79
0x0004 4 Version (currently supported: 'V1.0')
8-
0x0008 4 Compression type (see below)
10+
0x0008 4 Encoding type (see below)
911
0x000c 4 Tile count
1012
0x0010 var Compressed Tile(s)
1113

1214
Main Header (MBC):
1315
Offset Size Description
1416
0x0000 4 Signature ('MBC ')
1517
0x0004 4 Version (currently supported: 'V1.0')
16-
0x0008 4 Compression type (see below)
18+
0x0008 4 Encoding type (see below)
1719
0x000c 4 Width
1820
0x0010 4 Height
1921
0x0014 var Compressed Tile(s)
2022

21-
Encoded Tile:
22-
Offset Size Description
23-
0x0000 2 Tile width (internally padded to a multiple of 4
24-
for BCx pixel encodings)
25-
0x0002 2 Tile height (internally padded to a multiple of 4
26-
for BCx pixel encodings)
27-
0x0004 var either BCx encoded pixel data or palette & pixel data
28-
(depending on compression type)
29-
3023
Compressed Tile:
3124
Offset Size Description
32-
0x0000 4 Size of compressed data block
33-
0x0004 var zlib compressed Encoded Tile (if compression type < 0x0100)
34-
or unmodified Encoded Tile (if compression type >= 0x0100)
35-
25+
0x0000 4 Size of data block
26+
0x0004 var data block (content depends on encoding type)
3627

37-
Supported compression types in format version V1.0:
38-
0x0000 no pixel encoding, zlib compressed tiles
39-
0x0001 BC1 (DXT1) pixel encoding, zlib compressed tiles
40-
0x0002 BC2 (DXT3) pixel encoding, zlib compressed tiles
41-
0x0003 BC3 (DXT5) pixel encoding, zlib compressed tiles
42-
0x0100 no pixel encoding, no zlib compression
43-
0x0101 BC1 (DXT1) pixel encoding, no zlib compression
44-
0x0102 BC2 (DXT3) pixel encoding, no zlib compression
45-
0x0103 BC3 (DXT5) pixel encoding, no zlib compression
46-
47-
Note: Compression types 0x0000 and 0x0100 store palette and indexed pixel data
48-
as a contiguous block (1024+4096 bytes) for both formats TBC and MBC.
49-
50-
Note: Little-endian order is used for data fields.
28+
Encoded Tile:
29+
Offset Size Description
30+
0x0000 2 Tile width
31+
0x0002 2 Tile height
32+
0x0004 var encoded pixel data
33+
Note: Only used for fixed-rate data encoding types.
34+
35+
36+
Encoding types supported by format version V1.0
37+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
38+
39+
Fixed-rate data encoding types:
40+
0x0000 no pixel encoding (unmodified palette and pixel data as contiguous block)
41+
0x0001 BC1 (DXT1) pixel encoding
42+
0x0002 BC2 (DXT3) pixel encoding
43+
0x0003 BC3 (DXT5) pixel encoding
44+
Encoding type bit 8:
45+
- clear: Adding zlib compressed Encoded Tile to Compressed Tile structure
46+
- set: Adding uncompressed Encoded Tile to Compressed Tile structure

tileconv/Makefile

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
include config.mk
66

77
CXX ?= g++
8-
CXXFLAGS = -c -Wall -O2 -std=c++11 -msse -mfpmath=sse -I$(ZLIB_INCLUDE) -I$(PNGQUANT_INCLUDE) -I$(SQUISH_INCLUDE)
9-
LDFLAGS = -L$(ZLIB_LIB) -L$(PNGQUANT_LIB) -L$(SQUISH_LIB)
10-
LIBS = -lz -limagequant -lsquish
8+
CXXFLAGS = -c -Wall -O2 -std=c++11 -msse -mfpmath=sse -I$(ZLIB_INCLUDE) -I$(PNGQUANT_INCLUDE) -I$(SQUISH_INCLUDE) -I$(JPEG_INCLUDE)
9+
LDFLAGS = -L$(ZLIB_LIB) -L$(PNGQUANT_LIB) -L$(SQUISH_LIB) -L$(JPEG_LIB)
10+
LIBS = -lz -limagequant -lsquish -ljpeg
1111
EXECUTABLE = tileconv
1212

1313
ifeq ($(OS),Windows_NT)
@@ -24,28 +24,31 @@ else
2424
LIBS += -pthread
2525
ifeq ($(shell uname -s),Darwin)
2626
# A few hacks to enable proper threading support
27-
CXXFLAGS += -D_GLIBCXX_USE_NANOSLEEP -D_GLIBCXX_USE_SCHED_YIELD
27+
CXXFLAGS += -D_GLIBCXX_USE_NANOSLEEP
2828
else
2929
# Nothing to do for Linux (yet)
3030
endif
3131
endif
3232

3333
SOURCES = \
3434
tileconv.cpp \
35-
convert.cpp \
3635
version.cpp \
3736
graphics.cpp \
37+
converter.cpp \
38+
converter_raw.cpp \
39+
converter_dxt.cpp \
40+
converter_z.cpp \
41+
converterfactory.cpp \
3842
tilethreadpool_base.cpp \
3943
tilethreadpool_posix.cpp \
4044
tilethreadpool_win32.cpp \
4145
tiledata.cpp \
4246
compress.cpp \
47+
jpeg.cpp \
4348
colors.cpp \
4449
fileio.cpp \
4550
colorquant.cpp \
46-
options.cpp \
47-
dxtbase.cpp \
48-
dxtsquish.cpp
51+
options.cpp
4952

5053
OBJECTS = $(SOURCES:.cpp=.o)
5154

tileconv/README

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
TILECONV
22
~~~~~~~~
33

4-
Version: 0.4
4+
Version: 0.5
55
Author: Argent77
66

77
This tool allows you to compress or decompress TIS and MOS files provided by
@@ -14,6 +14,8 @@ Supported conversions:
1414
* TBC files will be automatically decompressed into the TIS format.
1515
* MOS files will be automatically compressed into the MBC format.
1616
* MBC files will be automatically decompressed into the MOS format.
17+
* MOZ files will be automatically decompressed into the MOS format.
18+
* TIZ files will be automatically decompressed into the TIS format.
1719

1820
A detailed description of the TBC and MBC formats can be found in FORMATS.
1921

@@ -36,7 +38,7 @@ Options:
3638
-u Do not apply tile compression.
3739
-o output Select output file or folder.
3840
(Note: Output file works only with single input file!)
39-
-z MOS only: Decompress MBC into compressed MOS (MOSC).
41+
-z Decode MBC/MOZ into compressed MOS (MOSC).
4042
-q Dec[Enc] Set quality levels for decoding and, optionally, encoding.
4143
Supported levels: 0..9 (Defaults: 4 for decoding, 9 for encoding)
4244
(0=fast and lower quality, 9=slow and higher quality)
@@ -61,7 +63,7 @@ Options:
6163
-I Show file information and exit.
6264
-V Print version number and exit.
6365

64-
Supported input file types: TIS, MOS, TBC, MBC
66+
Supported input file types: TIS, MOS, TBC, MBC, TIZ, MOZ
6567
Note: You can mix and match input files of each supported type.
6668

6769

@@ -80,10 +82,12 @@ Dependencies:
8082
- zlib (http://www.zlib.net/)
8183
- pngquant (https://github.com/pornel/pngquant/)
8284
- libsquish (https://code.google.com/p/libsquish/)
85+
- libjpeg-turbo (http://libjpeg-turbo.virtualgl.org/)
8386

8487
External libraries and include files are assumed to be located in the
85-
subfolders "zlib", "squish" and "pngquant". The libraries are providing their
86-
own instructions how to compile them. Afterwards call "make" to build tileconv.
88+
subfolders "zlib", "squish", "pngquant" and "jpeg-turbo". The libraries are
89+
providing their own instructions how to compile them. libjpeg-turbo has to be
90+
compiled with the v8 API/ABI. Afterwards call "make" to build tileconv.
8791
Note: You'll need a compiler that supports the C++11 standard.
8892

8993
If you want to change paths for the external libraries or include files,
@@ -119,3 +123,8 @@ v0.4 (2014-09-09)
119123
* Added output folder support
120124
* Added option "-T" to treat unrecognized files as headerless TIS
121125
* Added quality levels for encoding process
126+
127+
v0.5 (2014-09-18)
128+
* Added TIZ/MOZ decompression support
129+
* Option -T is recognized by option -I
130+
* Incomplete output files are deleted on error

tileconv/colorquant.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ THE SOFTWARE.
2323
#include <algorithm>
2424
#include "colorquant.h"
2525

26+
namespace tc {
27+
2628
ColorQuant::ColorQuant() noexcept
2729
: m_dithering(false)
2830
, m_lastTransparent(false)
@@ -135,15 +137,15 @@ bool ColorQuant::quantize() noexcept
135137
uint8_t *dstPal = (uint8_t*)m_palette;
136138
for (unsigned i = 0; i < numCols; i++, dstPal += 4) {
137139
liq_color px = pal->entries[i];
138-
if (px.a < 255) {
139-
dstPal[0] = dstPal[2] = dstPal[3] = 0;
140+
if (px.a < m_minOpacity) {
141+
dstPal[0] = dstPal[2] = 0;
140142
dstPal[1] = 255;
141143
} else {
142144
dstPal[0] = px.r;
143145
dstPal[1] = px.g;
144146
dstPal[2] = px.b;
145-
dstPal[3] = 0;
146147
}
148+
dstPal[3] = 0;
147149
}
148150

149151
return true;
@@ -211,3 +213,5 @@ void ColorQuant::freeMemory() noexcept
211213
m_liqResult = nullptr;
212214
}
213215
}
216+
217+
} // namespace tc

tileconv/colorquant.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ THE SOFTWARE.
2424

2525
#include <lib/libimagequant.h>
2626

27+
namespace tc {
28+
2729
class ColorQuant
2830
{
2931
public:
@@ -139,4 +141,6 @@ class ColorQuant
139141
liq_result *m_liqResult; // internally used, stores quantization data
140142
};
141143

144+
} // namespace tc
145+
142146
#endif // _COLORQUANT_H_

0 commit comments

Comments
 (0)