1cc1dc7a3Sopenharmony_ci# About
2cc1dc7a3Sopenharmony_ci
3cc1dc7a3Sopenharmony_ciThe Arm® Adaptive Scalable Texture Compression (ASTC) Encoder, `astcenc`, is
4cc1dc7a3Sopenharmony_cia command-line tool for compressing and decompressing images using the ASTC
5cc1dc7a3Sopenharmony_citexture compression standard.
6cc1dc7a3Sopenharmony_ci
7cc1dc7a3Sopenharmony_ci## The ASTC format
8cc1dc7a3Sopenharmony_ci
9cc1dc7a3Sopenharmony_ciThe ASTC compressed data format, developed by Arm® and AMD, has been adopted as
10cc1dc7a3Sopenharmony_cian official extension to the OpenGL®, OpenGL ES, and Vulkan® graphics APIs. It
11cc1dc7a3Sopenharmony_ciprovides a major step forward in terms of both the image quality at a given
12cc1dc7a3Sopenharmony_cibitrate, and the format and bitrate flexibility available to content creators.
13cc1dc7a3Sopenharmony_ciThis allows more assets to use compression, often at a reduced bitrate compared
14cc1dc7a3Sopenharmony_cito other formats, reducing memory storage and bandwidth requirements.
15cc1dc7a3Sopenharmony_ci
16cc1dc7a3Sopenharmony_ciRead the [ASTC Format Overview][1] for a quick introduction to the format, or
17cc1dc7a3Sopenharmony_ciread the full [Khronos Data Format Specification][2] for all the details.
18cc1dc7a3Sopenharmony_ci
19cc1dc7a3Sopenharmony_ci## License
20cc1dc7a3Sopenharmony_ci
21cc1dc7a3Sopenharmony_ciThis project is licensed under the Apache 2.0 license. By downloading any
22cc1dc7a3Sopenharmony_cicomponent from this repository you acknowledge that you accept terms specified
23cc1dc7a3Sopenharmony_ciin the [LICENSE.txt](LICENSE.txt) file.
24cc1dc7a3Sopenharmony_ci
25cc1dc7a3Sopenharmony_ci# Encoder feature support
26cc1dc7a3Sopenharmony_ci
27cc1dc7a3Sopenharmony_ciThe encoder supports compression of low dynamic range (BMP, JPEG, PNG, TGA) and
28cc1dc7a3Sopenharmony_cihigh dynamic range (EXR, HDR) images, as well as a subset of image data wrapped
29cc1dc7a3Sopenharmony_ciin the DDS and KTX container formats, into ASTC or KTX format output images.
30cc1dc7a3Sopenharmony_ci
31cc1dc7a3Sopenharmony_ciThe decoder supports decompression of ASTC or KTX format input images into low
32cc1dc7a3Sopenharmony_cidynamic range (BMP, PNG, TGA), high dynamic range (EXR, HDR), or DDS and KTX
33cc1dc7a3Sopenharmony_ciwrapped output images.
34cc1dc7a3Sopenharmony_ci
35cc1dc7a3Sopenharmony_ciThe encoder allows control over the compression time/quality tradeoff with
36cc1dc7a3Sopenharmony_ci`exhaustive`, `verythorough`, `thorough`, `medium`, `fast`, and `fastest`
37cc1dc7a3Sopenharmony_ciencoding quality presets.
38cc1dc7a3Sopenharmony_ci
39cc1dc7a3Sopenharmony_ciThe encoder allows compression time and quality analysis by reporting the
40cc1dc7a3Sopenharmony_cicompression time, and the Peak Signal-to-Noise Ratio (PSNR) between the input
41cc1dc7a3Sopenharmony_ciimage and the compressed output.
42cc1dc7a3Sopenharmony_ci
43cc1dc7a3Sopenharmony_ci## ASTC format support
44cc1dc7a3Sopenharmony_ci
45cc1dc7a3Sopenharmony_ciThe `astcenc` compressor supports generation of images for all three profiles
46cc1dc7a3Sopenharmony_ciallowed by the ASTC specification:
47cc1dc7a3Sopenharmony_ci
48cc1dc7a3Sopenharmony_ci* 2D Low Dynamic Range (LDR profile)
49cc1dc7a3Sopenharmony_ci* 2D LDR and High Dynamic Range (HDR profile)
50cc1dc7a3Sopenharmony_ci* 2D and 3D, LDR and HDR (Full profile)
51cc1dc7a3Sopenharmony_ci
52cc1dc7a3Sopenharmony_ciIt also supports all of the ASTC block sizes and compression modes, allowing
53cc1dc7a3Sopenharmony_cicontent creators to use the full spectrum of quality-to-bitrate options ranging
54cc1dc7a3Sopenharmony_cifrom 0.89 bits/pixel up to 8 bits/pixel.
55cc1dc7a3Sopenharmony_ci
56cc1dc7a3Sopenharmony_ci# Prebuilt binaries
57cc1dc7a3Sopenharmony_ci
58cc1dc7a3Sopenharmony_ciRelease build binaries for the `astcenc` stable releases are provided in the
59cc1dc7a3Sopenharmony_ci[GitHub Releases page][3].
60cc1dc7a3Sopenharmony_ci
61cc1dc7a3Sopenharmony_ci* Change log: [4.x series](./Docs/ChangeLog-4x.md)
62cc1dc7a3Sopenharmony_ci* Change log: [3.x series](./Docs/ChangeLog-3x.md)
63cc1dc7a3Sopenharmony_ci
64cc1dc7a3Sopenharmony_ciBinaries are provided for 64-bit builds on Windows, macOS, and Linux.
65cc1dc7a3Sopenharmony_ci
66cc1dc7a3Sopenharmony_ci## Windows and Linux
67cc1dc7a3Sopenharmony_ci
68cc1dc7a3Sopenharmony_ciFor Windows and Linux the builds of the astcenc are provided as multiple
69cc1dc7a3Sopenharmony_cibinaries, each tuned for a specific SIMD instruction set.
70cc1dc7a3Sopenharmony_ci
71cc1dc7a3Sopenharmony_ciFor x86-64 we provide, in order of increasing performance:
72cc1dc7a3Sopenharmony_ci
73cc1dc7a3Sopenharmony_ci* `astcenc-sse2` - uses SSE2
74cc1dc7a3Sopenharmony_ci* `astcenc-sse4.1` - uses SSE4.1 and POPCNT
75cc1dc7a3Sopenharmony_ci* `astcenc-avx2` - uses AVX2, SSE4.2, POPCNT, and F16C
76cc1dc7a3Sopenharmony_ci
77cc1dc7a3Sopenharmony_ciThe x86-64 SSE2 builds will work on all x86-64 machines, but it is the slowest
78cc1dc7a3Sopenharmony_ciof the three. The other two require extended CPU instruction set support which
79cc1dc7a3Sopenharmony_ciis not universally available, but each step gains ~15% more performance.
80cc1dc7a3Sopenharmony_ci
81cc1dc7a3Sopenharmony_ciFor Arm, if binaries are available, we provide:
82cc1dc7a3Sopenharmony_ci
83cc1dc7a3Sopenharmony_ci* `astcenc-neon` - uses NEON
84cc1dc7a3Sopenharmony_ci
85cc1dc7a3Sopenharmony_ci## macOS
86cc1dc7a3Sopenharmony_ci
87cc1dc7a3Sopenharmony_ciFor macOS devices we provide a single universal binary `astcenc`, which allows
88cc1dc7a3Sopenharmony_cithe OS to automatically use the correct binary variant for the current host
89cc1dc7a3Sopenharmony_cimachine. Support is provided for three architecture slices:
90cc1dc7a3Sopenharmony_ci
91cc1dc7a3Sopenharmony_ci* `x86_64` - uses the `astcenc-sse4.1` build defined above.
92cc1dc7a3Sopenharmony_ci* `x86_64h` - uses the `astcenc-avx2` build defined above.
93cc1dc7a3Sopenharmony_ci* `arm64` - uses the `astcenc-neon` build defined above.
94cc1dc7a3Sopenharmony_ci
95cc1dc7a3Sopenharmony_ci## Repository branches
96cc1dc7a3Sopenharmony_ci
97cc1dc7a3Sopenharmony_ciThe `main` branch is an active development branch for the compressor. It aims
98cc1dc7a3Sopenharmony_cito be a stable branch for the latest major release series, but as it is used
99cc1dc7a3Sopenharmony_cifor ongoing development expect it to have some volatility. We recommend using
100cc1dc7a3Sopenharmony_cithe latest stable release tag for production development.
101cc1dc7a3Sopenharmony_ci
102cc1dc7a3Sopenharmony_ciThe `3.x` branch is a stable branch for the 3.x release series. It is no longer
103cc1dc7a3Sopenharmony_ciunder active development, but is a supported branch that continues to get
104cc1dc7a3Sopenharmony_cibackported bug fixes.
105cc1dc7a3Sopenharmony_ci
106cc1dc7a3Sopenharmony_ciThe `1.x` and `2.x` branches are stable branches for older releases. They are
107cc1dc7a3Sopenharmony_cino longer under active development or getting bug fixes.
108cc1dc7a3Sopenharmony_ci
109cc1dc7a3Sopenharmony_ciAny other branches you might find are development branches for new features or
110cc1dc7a3Sopenharmony_cioptimizations, so might be interesting to play with but should be considered
111cc1dc7a3Sopenharmony_citransient and unstable.
112cc1dc7a3Sopenharmony_ci
113cc1dc7a3Sopenharmony_ci
114cc1dc7a3Sopenharmony_ci# Getting started
115cc1dc7a3Sopenharmony_ci
116cc1dc7a3Sopenharmony_ciOpen a terminal, change to the appropriate directory for your system, and run
117cc1dc7a3Sopenharmony_cithe astcenc encoder program, like this on Linux or macOS:
118cc1dc7a3Sopenharmony_ci
119cc1dc7a3Sopenharmony_ci    ./astcenc
120cc1dc7a3Sopenharmony_ci
121cc1dc7a3Sopenharmony_ci... or like this on Windows:
122cc1dc7a3Sopenharmony_ci
123cc1dc7a3Sopenharmony_ci    astcenc
124cc1dc7a3Sopenharmony_ci
125cc1dc7a3Sopenharmony_ciInvoking `astcenc -help` gives an extensive help message, including usage
126cc1dc7a3Sopenharmony_ciinstructions and details of all available command line options. A summary of
127cc1dc7a3Sopenharmony_cithe main encoder options are shown below.
128cc1dc7a3Sopenharmony_ci
129cc1dc7a3Sopenharmony_ci## Compressing an image
130cc1dc7a3Sopenharmony_ci
131cc1dc7a3Sopenharmony_ciCompress an image using the `-cl` \ `-cs` \ `-ch` \ `-cH` modes. For example:
132cc1dc7a3Sopenharmony_ci
133cc1dc7a3Sopenharmony_ci    astcenc -cl example.png example.astc 6x6 -medium
134cc1dc7a3Sopenharmony_ci
135cc1dc7a3Sopenharmony_ciThis compresses `example.png` using the LDR color profile and a 6x6 block
136cc1dc7a3Sopenharmony_cifootprint (3.56 bits/pixel). The `-medium` quality preset gives a reasonable
137cc1dc7a3Sopenharmony_ciimage quality for a relatively fast compression speed, so is a good starting
138cc1dc7a3Sopenharmony_cipoint for compression. The output is stored to a linear color space compressed
139cc1dc7a3Sopenharmony_ciimage, `example.astc`.
140cc1dc7a3Sopenharmony_ci
141cc1dc7a3Sopenharmony_ciThe modes available are:
142cc1dc7a3Sopenharmony_ci
143cc1dc7a3Sopenharmony_ci* `-cl` : use the linear LDR color profile.
144cc1dc7a3Sopenharmony_ci* `-cs` : use the sRGB LDR color profile.
145cc1dc7a3Sopenharmony_ci* `-ch` : use the HDR color profile, tuned for HDR RGB and LDR A.
146cc1dc7a3Sopenharmony_ci* `-cH` : use the HDR color profile, tuned for HDR RGBA.
147cc1dc7a3Sopenharmony_ci
148cc1dc7a3Sopenharmony_ciIf you intend to use the resulting image with the decode mode extensions to
149cc1dc7a3Sopenharmony_cilimit the decompressed precision to UNORM8, it is recommended that you also
150cc1dc7a3Sopenharmony_cispecify the `-decode_unorm8` flag. This will ensure that the compressor uses
151cc1dc7a3Sopenharmony_cithe correct rounding rules when choosing encodings.
152cc1dc7a3Sopenharmony_ci
153cc1dc7a3Sopenharmony_ci## Decompressing an image
154cc1dc7a3Sopenharmony_ci
155cc1dc7a3Sopenharmony_ciDecompress an image using the `-dl` \ `-ds` \ `-dh` \ `-dH` modes. For example:
156cc1dc7a3Sopenharmony_ci
157cc1dc7a3Sopenharmony_ci    astcenc -dh example.astc example.tga
158cc1dc7a3Sopenharmony_ci
159cc1dc7a3Sopenharmony_ciThis decompresses `example.astc` using the full HDR feature profile, storing
160cc1dc7a3Sopenharmony_cithe decompressed output to `example.tga`.
161cc1dc7a3Sopenharmony_ci
162cc1dc7a3Sopenharmony_ciThe modes available mirror the options used for compression, but use a `d`
163cc1dc7a3Sopenharmony_ciprefix. Note that for decompression there is no difference between the two HDR
164cc1dc7a3Sopenharmony_cimodes, they are both provided simply to maintain symmetry across operations.
165cc1dc7a3Sopenharmony_ci
166cc1dc7a3Sopenharmony_ci## Measuring image quality
167cc1dc7a3Sopenharmony_ci
168cc1dc7a3Sopenharmony_ciReview the compression quality using the `-tl` \ `-ts` \ `-th` \ `-tH` modes.
169cc1dc7a3Sopenharmony_ciFor example:
170cc1dc7a3Sopenharmony_ci
171cc1dc7a3Sopenharmony_ci    astcenc -tl example.png example.tga 5x5 -thorough
172cc1dc7a3Sopenharmony_ci
173cc1dc7a3Sopenharmony_ciThis is equivalent to using using the LDR color profile and a 5x5 block size
174cc1dc7a3Sopenharmony_cito compress the image, using the `-thorough` quality preset, and then
175cc1dc7a3Sopenharmony_ciimmediately decompressing the image and saving the result. This can be used
176cc1dc7a3Sopenharmony_cito enable a visual inspection of the compressed image quality. In addition
177cc1dc7a3Sopenharmony_cithis mode also prints out some image quality metrics to the console.
178cc1dc7a3Sopenharmony_ci
179cc1dc7a3Sopenharmony_ciThe modes available mirror the options used for compression, but use a `t`
180cc1dc7a3Sopenharmony_ciprefix.
181cc1dc7a3Sopenharmony_ci
182cc1dc7a3Sopenharmony_ci## Experimenting
183cc1dc7a3Sopenharmony_ci
184cc1dc7a3Sopenharmony_ciEfficient real-time graphics benefits from minimizing compressed texture size,
185cc1dc7a3Sopenharmony_cias it reduces memory footprint, reduces memory bandwidth, saves energy, and can
186cc1dc7a3Sopenharmony_ciimprove texture cache efficiency. However, like any lossy compression format
187cc1dc7a3Sopenharmony_cithere will come a point where the compressed image quality is unacceptable
188cc1dc7a3Sopenharmony_cibecause there are simply not enough bits to represent the output with the
189cc1dc7a3Sopenharmony_ciprecision needed. We recommend experimenting with the block footprint to find
190cc1dc7a3Sopenharmony_cithe optimum balance between size and quality, as the finely adjustable
191cc1dc7a3Sopenharmony_cicompression ratio is one of major strengths of the ASTC format.
192cc1dc7a3Sopenharmony_ci
193cc1dc7a3Sopenharmony_ciThe compression speed can be controlled from `-fastest`, through `-fast`,
194cc1dc7a3Sopenharmony_ci`-medium` and `-thorough`, up to `-exhaustive`. In general, the more time the
195cc1dc7a3Sopenharmony_ciencoder has to spend looking for good encodings the better the results, but it
196cc1dc7a3Sopenharmony_cidoes result in increasingly small improvements for the amount of time required.
197cc1dc7a3Sopenharmony_ci
198cc1dc7a3Sopenharmony_ciThere are many other command line options for tuning the encoder parameters
199cc1dc7a3Sopenharmony_ciwhich can be used to fine tune the compression algorithm. See the command line
200cc1dc7a3Sopenharmony_cihelp message for more details.
201cc1dc7a3Sopenharmony_ci
202cc1dc7a3Sopenharmony_ci# Documentation
203cc1dc7a3Sopenharmony_ci
204cc1dc7a3Sopenharmony_ciThe [ASTC Format Overview](./Docs/FormatOverview.md) page provides a high level
205cc1dc7a3Sopenharmony_ciintroduction to the ASTC texture format, how it encodes data, and why it is
206cc1dc7a3Sopenharmony_ciboth flexible and efficient.
207cc1dc7a3Sopenharmony_ci
208cc1dc7a3Sopenharmony_ciThe [Effective ASTC Encoding](./Docs/Encoding.md) page looks at some of the
209cc1dc7a3Sopenharmony_ciguidelines that should be followed when compressing data using `astcenc`.
210cc1dc7a3Sopenharmony_ciIt covers:
211cc1dc7a3Sopenharmony_ci
212cc1dc7a3Sopenharmony_ci* How to efficiently encode data with fewer than 4 channels.
213cc1dc7a3Sopenharmony_ci* How to efficiently encode normal maps, sRGB data, and HDR data.
214cc1dc7a3Sopenharmony_ci* Coding equivalents to other compression formats.
215cc1dc7a3Sopenharmony_ci
216cc1dc7a3Sopenharmony_ciThe [ASTC Developer Guide][5] document (external link) provides a more detailed
217cc1dc7a3Sopenharmony_ciguide for developers using the `astcenc` compressor.
218cc1dc7a3Sopenharmony_ci
219cc1dc7a3Sopenharmony_ciThe [.astc File Format](./Docs/FileFormat.md) page provides a light-weight
220cc1dc7a3Sopenharmony_cispecification for the `.astc` file format and how to read or write it.
221cc1dc7a3Sopenharmony_ci
222cc1dc7a3Sopenharmony_ciThe [Building ASTC Encoder](./Docs/Building.md) page provides instructions on
223cc1dc7a3Sopenharmony_cihow to build `astcenc` from the sources in this repository.
224cc1dc7a3Sopenharmony_ci
225cc1dc7a3Sopenharmony_ciThe [Testing ASTC Encoder](./Docs/Testing.md) page provides instructions on
226cc1dc7a3Sopenharmony_cihow to test any modifications to the source code in this repository.
227cc1dc7a3Sopenharmony_ci
228cc1dc7a3Sopenharmony_ci# Support
229cc1dc7a3Sopenharmony_ci
230cc1dc7a3Sopenharmony_ciIf you have issues with the `astcenc` encoder, or questions about the ASTC
231cc1dc7a3Sopenharmony_citexture format itself, please raise them in the GitHub issue tracker.
232cc1dc7a3Sopenharmony_ci
233cc1dc7a3Sopenharmony_ciIf you have any questions about Arm GPUs, application development for Arm GPUs,
234cc1dc7a3Sopenharmony_cior general mobile graphics development or technology please submit them on the
235cc1dc7a3Sopenharmony_ci[Arm Community graphics forums][4].
236cc1dc7a3Sopenharmony_ci
237cc1dc7a3Sopenharmony_ci- - -
238cc1dc7a3Sopenharmony_ci
239cc1dc7a3Sopenharmony_ci_Copyright © 2013-2024, Arm Limited and contributors. All rights reserved._
240cc1dc7a3Sopenharmony_ci
241cc1dc7a3Sopenharmony_ci[1]: ./Docs/FormatOverview.md
242cc1dc7a3Sopenharmony_ci[2]: https://www.khronos.org/registry/DataFormat/specs/1.3/dataformat.1.3.html#ASTC
243cc1dc7a3Sopenharmony_ci[3]: https://github.com/ARM-software/astc-encoder/releases
244cc1dc7a3Sopenharmony_ci[4]: https://community.arm.com/support-forums/f/graphics-gaming-and-vr-forum/
245cc1dc7a3Sopenharmony_ci[5]: https://developer.arm.com/documentation/102162/latest/?lang=en
246