1cc1dc7a3Sopenharmony_ci// SPDX-License-Identifier: Apache-2.0
2cc1dc7a3Sopenharmony_ci// ----------------------------------------------------------------------------
3cc1dc7a3Sopenharmony_ci// Copyright 2011-2023 Arm Limited
4cc1dc7a3Sopenharmony_ci//
5cc1dc7a3Sopenharmony_ci// Licensed under the Apache License, Version 2.0 (the "License"); you may not
6cc1dc7a3Sopenharmony_ci// use this file except in compliance with the License. You may obtain a copy
7cc1dc7a3Sopenharmony_ci// of the License at:
8cc1dc7a3Sopenharmony_ci//
9cc1dc7a3Sopenharmony_ci//     http://www.apache.org/licenses/LICENSE-2.0
10cc1dc7a3Sopenharmony_ci//
11cc1dc7a3Sopenharmony_ci// Unless required by applicable law or agreed to in writing, software
12cc1dc7a3Sopenharmony_ci// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13cc1dc7a3Sopenharmony_ci// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14cc1dc7a3Sopenharmony_ci// License for the specific language governing permissions and limitations
15cc1dc7a3Sopenharmony_ci// under the License.
16cc1dc7a3Sopenharmony_ci// ----------------------------------------------------------------------------
17cc1dc7a3Sopenharmony_ci
18cc1dc7a3Sopenharmony_ci/**
19cc1dc7a3Sopenharmony_ci * @brief Functions for printing build info and help messages.
20cc1dc7a3Sopenharmony_ci */
21cc1dc7a3Sopenharmony_ci
22cc1dc7a3Sopenharmony_ci#include "astcenccli_internal.h"
23cc1dc7a3Sopenharmony_ci#include "astcenccli_version.h"
24cc1dc7a3Sopenharmony_ci
25cc1dc7a3Sopenharmony_ci/** @brief The version header. */
26cc1dc7a3Sopenharmony_cistatic const char *astcenc_copyright_string =
27cc1dc7a3Sopenharmony_ciR"(astcenc v%s, %u-bit %s%s%s
28cc1dc7a3Sopenharmony_ciCopyright (c) 2011-%s Arm Limited. All rights reserved.
29cc1dc7a3Sopenharmony_ci)";
30cc1dc7a3Sopenharmony_ci
31cc1dc7a3Sopenharmony_ci/** @brief The short-form help text. */
32cc1dc7a3Sopenharmony_cistatic const char *astcenc_short_help =
33cc1dc7a3Sopenharmony_ciR"(
34cc1dc7a3Sopenharmony_ciBasic usage:
35cc1dc7a3Sopenharmony_ci
36cc1dc7a3Sopenharmony_ciTo compress an image use:
37cc1dc7a3Sopenharmony_ci    astcenc {-cl|-cs|-ch|-cH} <in> <out> <blockdim> <quality> [options]
38cc1dc7a3Sopenharmony_ci
39cc1dc7a3Sopenharmony_cie.g. using LDR profile, 8x6 blocks, and the thorough quality preset:
40cc1dc7a3Sopenharmony_ci    astcenc -cl kodim01.png kodim01.astc 8x6 -thorough
41cc1dc7a3Sopenharmony_ci
42cc1dc7a3Sopenharmony_ciTo decompress an image use:
43cc1dc7a3Sopenharmony_ci    astcenc {-dl|-ds|-dh|-dH} <in> <out>
44cc1dc7a3Sopenharmony_ci
45cc1dc7a3Sopenharmony_cie.g. using LDR profile:
46cc1dc7a3Sopenharmony_ci    astcenc -dl kodim01.astc kodim01.png
47cc1dc7a3Sopenharmony_ci
48cc1dc7a3Sopenharmony_ciTo perform a compression test, writing back the decompressed output, use:
49cc1dc7a3Sopenharmony_ci    astcenc {-tl|-ts|-th|-tH} <in> <out> <blockdim> <quality> [options]
50cc1dc7a3Sopenharmony_ci
51cc1dc7a3Sopenharmony_cie.g. using LDR profile, 8x6 blocks, and the thorough quality preset:
52cc1dc7a3Sopenharmony_ci    astcenc -tl kodim01.png kodim01-test.png 8x6 -thorough
53cc1dc7a3Sopenharmony_ci
54cc1dc7a3Sopenharmony_ciThe -*l options are used to configure the codec to support only the linear
55cc1dc7a3Sopenharmony_ciLDR profile, preventing use of the HDR encoding features.
56cc1dc7a3Sopenharmony_ci
57cc1dc7a3Sopenharmony_ciThe -*s options are used to configure the codec to support only
58cc1dc7a3Sopenharmony_cithe sRGB LDR profile, preventing use of the HDR encoding features. Input
59cc1dc7a3Sopenharmony_citexture data must be encoded in the sRGB colorspace for this option to
60cc1dc7a3Sopenharmony_ciprovide correct output results.
61cc1dc7a3Sopenharmony_ci
62cc1dc7a3Sopenharmony_ciThe -*h/-*H options are used to configure the codec to support the HDR ASTC
63cc1dc7a3Sopenharmony_cicolor profile. Textures compressed with this profile may fail to decompress
64cc1dc7a3Sopenharmony_cicorrectly on GPU hardware without HDR profile support. The -*h options
65cc1dc7a3Sopenharmony_ciconfigure the compressor for HDR RGB components and an LDR alpha component.
66cc1dc7a3Sopenharmony_ciThe -*H options configure the compressor for HDR across all 4 components.
67cc1dc7a3Sopenharmony_ci
68cc1dc7a3Sopenharmony_ciFor full help documentation run 'astcenc -help'.
69cc1dc7a3Sopenharmony_ci)";
70cc1dc7a3Sopenharmony_ci
71cc1dc7a3Sopenharmony_ci/** @brief The long-form help text. */
72cc1dc7a3Sopenharmony_cistatic const char *astcenc_long_help = R"(
73cc1dc7a3Sopenharmony_ciNAME
74cc1dc7a3Sopenharmony_ci       astcenc - compress or decompress images using the ASTC format
75cc1dc7a3Sopenharmony_ci
76cc1dc7a3Sopenharmony_ciSYNOPSIS
77cc1dc7a3Sopenharmony_ci       astcenc {-h|-help}
78cc1dc7a3Sopenharmony_ci       astcenc {-v|-version}
79cc1dc7a3Sopenharmony_ci       astcenc {-cl|-cs|-ch|-cH} <in> <out> <blocksize> <quality> [options]
80cc1dc7a3Sopenharmony_ci       astcenc {-dl|-ds|-dh|-dH} <in> <out> <blocksize> <quality> [options]
81cc1dc7a3Sopenharmony_ci       astcenc {-tl|-ts|-th|-tH} <in> <out> <blocksize> <quality> [options]
82cc1dc7a3Sopenharmony_ci
83cc1dc7a3Sopenharmony_ciDESCRIPTION
84cc1dc7a3Sopenharmony_ci       astcenc compresses image files into the Adaptive Scalable Texture
85cc1dc7a3Sopenharmony_ci       Compression (ASTC) image format, a lossy compression format design
86cc1dc7a3Sopenharmony_ci       for use in real-time graphics applications. It is a fully featured
87cc1dc7a3Sopenharmony_ci       compressor implementation, supporting all of the compression
88cc1dc7a3Sopenharmony_ci       profiles and block sizes specified by the ASTC format:
89cc1dc7a3Sopenharmony_ci
90cc1dc7a3Sopenharmony_ci           All color profiles (LDR linear, LDR sRGB, and HDR)
91cc1dc7a3Sopenharmony_ci           All 2D block sizes (4x4 though to 12x12)
92cc1dc7a3Sopenharmony_ci           All 3D block sizes (3x3x3 through to 6x6x6)
93cc1dc7a3Sopenharmony_ci
94cc1dc7a3Sopenharmony_ci       The compressor provides a flexible quality level, allowing users to
95cc1dc7a3Sopenharmony_ci       trade off compressed image quality against compression performance.
96cc1dc7a3Sopenharmony_ci       For ease of use, a number of quality presets are also provided. For
97cc1dc7a3Sopenharmony_ci       advanced users the compressor provides many additional control
98cc1dc7a3Sopenharmony_ci       options for fine tuning quality.
99cc1dc7a3Sopenharmony_ci
100cc1dc7a3Sopenharmony_ci       astcenc can also be used to decompress ASTC compressed images, and
101cc1dc7a3Sopenharmony_ci       perform compression image quality analysis.
102cc1dc7a3Sopenharmony_ci
103cc1dc7a3Sopenharmony_ciCOMPRESSION
104cc1dc7a3Sopenharmony_ci       To compress an image using the ASTC format you must specify the
105cc1dc7a3Sopenharmony_ci       color profile, the input file name, the output file name, the target
106cc1dc7a3Sopenharmony_ci       block size, and the quality preset.
107cc1dc7a3Sopenharmony_ci
108cc1dc7a3Sopenharmony_ci       The color profile is specified using the -cl (LDR linear), -cs (LDR
109cc1dc7a3Sopenharmony_ci       sRGB), -ch (HDR RGB, LDR A), or -cH (HDR RGBA) encoder options. Note
110cc1dc7a3Sopenharmony_ci       that not all GPUs implementing ASTC support the HDR profile.
111cc1dc7a3Sopenharmony_ci
112cc1dc7a3Sopenharmony_ci       The input file path must match a valid file format for compression,
113cc1dc7a3Sopenharmony_ci       and the output file format must be a valid output for compression.
114cc1dc7a3Sopenharmony_ci       See the FILE FORMATS section for the list of supported formats.
115cc1dc7a3Sopenharmony_ci
116cc1dc7a3Sopenharmony_ci       The block size must be a valid ASTC block size. Every block
117cc1dc7a3Sopenharmony_ci       compresses into 128 bits of compressed output, so the block size
118cc1dc7a3Sopenharmony_ci       determines the compressed data bitrate.
119cc1dc7a3Sopenharmony_ci
120cc1dc7a3Sopenharmony_ci       Supported 2D block sizes are:
121cc1dc7a3Sopenharmony_ci
122cc1dc7a3Sopenharmony_ci             4x4: 8.00 bpp        10x5: 2.56 bpp
123cc1dc7a3Sopenharmony_ci             5x4: 6.40 bpp        10x6: 2.13 bpp
124cc1dc7a3Sopenharmony_ci             5x5: 5.12 bpp         8x8: 2.00 bpp
125cc1dc7a3Sopenharmony_ci             6x5: 4.27 bpp        10x8: 1.60 bpp
126cc1dc7a3Sopenharmony_ci             6x6: 3.56 bpp       10x10: 1.28 bpp
127cc1dc7a3Sopenharmony_ci             8x5: 3.20 bpp       12x10: 1.07 bpp
128cc1dc7a3Sopenharmony_ci             8x6: 2.67 bpp       12x12: 0.89 bpp
129cc1dc7a3Sopenharmony_ci
130cc1dc7a3Sopenharmony_ci       Supported 3D block sizes are:
131cc1dc7a3Sopenharmony_ci
132cc1dc7a3Sopenharmony_ci           3x3x3: 4.74 bpp       5x5x4: 1.28 bpp
133cc1dc7a3Sopenharmony_ci           4x3x3: 3.56 bpp       5x5x5: 1.02 bpp
134cc1dc7a3Sopenharmony_ci           4x4x3: 2.67 bpp       6x5x5: 0.85 bpp
135cc1dc7a3Sopenharmony_ci           4x4x4: 2.00 bpp       6x6x5: 0.71 bpp
136cc1dc7a3Sopenharmony_ci           5x4x4: 1.60 bpp       6x6x6: 0.59 bpp
137cc1dc7a3Sopenharmony_ci
138cc1dc7a3Sopenharmony_ci       The quality level configures the quality-performance tradeoff for
139cc1dc7a3Sopenharmony_ci       the compressor; more complete searches of the search space improve
140cc1dc7a3Sopenharmony_ci       image quality at the expense of compression time. The quality level
141cc1dc7a3Sopenharmony_ci       can be set to any value between 0 (fastest) and 100 (exhaustive),
142cc1dc7a3Sopenharmony_ci       or to a fixed quality preset:
143cc1dc7a3Sopenharmony_ci
144cc1dc7a3Sopenharmony_ci           -fastest      (equivalent to quality =   0)
145cc1dc7a3Sopenharmony_ci           -fast         (equivalent to quality =  10)
146cc1dc7a3Sopenharmony_ci           -medium       (equivalent to quality =  60)
147cc1dc7a3Sopenharmony_ci           -thorough     (equivalent to quality =  98)
148cc1dc7a3Sopenharmony_ci           -verythorough (equivalent to quality =  99)
149cc1dc7a3Sopenharmony_ci           -exhaustive   (equivalent to quality = 100)
150cc1dc7a3Sopenharmony_ci
151cc1dc7a3Sopenharmony_ci       For compression of production content we recommend using a quality
152cc1dc7a3Sopenharmony_ci       level equivalent to -medium or higher.
153cc1dc7a3Sopenharmony_ci
154cc1dc7a3Sopenharmony_ci       Using quality levels higher than -thorough will significantly
155cc1dc7a3Sopenharmony_ci       increase compression time, but typically only gives minor quality
156cc1dc7a3Sopenharmony_ci       improvements.
157cc1dc7a3Sopenharmony_ci
158cc1dc7a3Sopenharmony_ci       There are a number of additional compressor options which are useful
159cc1dc7a3Sopenharmony_ci       to consider for common usage, based on the type of image data being
160cc1dc7a3Sopenharmony_ci       compressed.
161cc1dc7a3Sopenharmony_ci
162cc1dc7a3Sopenharmony_ci       -decode_unorm8
163cc1dc7a3Sopenharmony_ci           Indicate that an LDR compressed texture will be used with
164cc1dc7a3Sopenharmony_ci           the decode_unorm8 extension behavior, instead of the default
165cc1dc7a3Sopenharmony_ci           decode_unorm16 decompression.
166cc1dc7a3Sopenharmony_ci
167cc1dc7a3Sopenharmony_ci           Matching the decode mode used during compression to the mode
168cc1dc7a3Sopenharmony_ci           used at runtime will improve image quality as the compressor
169cc1dc7a3Sopenharmony_ci           can ensure that rounding goes the right way.
170cc1dc7a3Sopenharmony_ci
171cc1dc7a3Sopenharmony_ci           This mode is used automatically if you decompress to an 8-bit
172cc1dc7a3Sopenharmony_ci           per component output image format.
173cc1dc7a3Sopenharmony_ci
174cc1dc7a3Sopenharmony_ci       -normal
175cc1dc7a3Sopenharmony_ci           The input texture is a three component linear LDR normal map
176cc1dc7a3Sopenharmony_ci           storing unit length normals as (R=X, G=Y, B=Z). The output will
177cc1dc7a3Sopenharmony_ci           be a two component X+Y normal map stored as (RGB=X, A=Y). The Z
178cc1dc7a3Sopenharmony_ci           component can be recovered programmatically in shader code by
179cc1dc7a3Sopenharmony_ci           using the equation:
180cc1dc7a3Sopenharmony_ci
181cc1dc7a3Sopenharmony_ci               nml.xy = texture(...).ga;              // Load in [0,1]
182cc1dc7a3Sopenharmony_ci               nml.xy = nml.xy * 2.0 - 1.0;           // Unpack to [-1,1]
183cc1dc7a3Sopenharmony_ci               nml.z = sqrt(1 - dot(nml.xy, nml.xy)); // Compute Z
184cc1dc7a3Sopenharmony_ci
185cc1dc7a3Sopenharmony_ci           Alternative component swizzles can be set with -esw and -dsw
186cc1dc7a3Sopenharmony_ci           parameters.
187cc1dc7a3Sopenharmony_ci
188cc1dc7a3Sopenharmony_ci       -rgbm <max>
189cc1dc7a3Sopenharmony_ci           The input texture is an RGBM encoded texture, storing values HDR
190cc1dc7a3Sopenharmony_ci           values between 0 and <max> in an LDR container format with a
191cc1dc7a3Sopenharmony_ci           shared multiplier. Shaders reconstruct the HDR value as:
192cc1dc7a3Sopenharmony_ci
193cc1dc7a3Sopenharmony_ci               vec3 hdr_value = tex.rgb * tex.a * max;
194cc1dc7a3Sopenharmony_ci
195cc1dc7a3Sopenharmony_ci           The compression behavior of the ASTC format for RGBM data
196cc1dc7a3Sopenharmony_ci           requires that the user's RGBM encoding preprocess keeps values
197cc1dc7a3Sopenharmony_ci           of M above a lower threshold to avoid them quantizing to zero
198cc1dc7a3Sopenharmony_ci           during compression. We recommend trying 16/255 or 32/255.
199cc1dc7a3Sopenharmony_ci
200cc1dc7a3Sopenharmony_ci       -perceptual
201cc1dc7a3Sopenharmony_ci           The codec should optimize perceptual error, instead of direct
202cc1dc7a3Sopenharmony_ci           RMS error. This aims to improves perceived image quality, but
203cc1dc7a3Sopenharmony_ci           typically lowers the measured PSNR score. Perceptual methods are
204cc1dc7a3Sopenharmony_ci           currently only available for normal maps and RGB color data.
205cc1dc7a3Sopenharmony_ci
206cc1dc7a3Sopenharmony_ci       -zdim <zdim>
207cc1dc7a3Sopenharmony_ci           Load a sequence of <zdim> 2D image slices to use as a 3D image.
208cc1dc7a3Sopenharmony_ci           The input filename given is used is decorated with the postfix
209cc1dc7a3Sopenharmony_ci           "_<slice>" to find the file to load. For example, an input named
210cc1dc7a3Sopenharmony_ci           "input.png" would load as input_0.png, input_1.png, etc.
211cc1dc7a3Sopenharmony_ci
212cc1dc7a3Sopenharmony_ci       -pp-normalize
213cc1dc7a3Sopenharmony_ci            Run a preprocess over the image that forces normal vectors to
214cc1dc7a3Sopenharmony_ci            be unit length. Preprocessing applies before any codec encoding
215cc1dc7a3Sopenharmony_ci            swizzle, so normal data must be in the RGB components in the
216cc1dc7a3Sopenharmony_ci            source image.
217cc1dc7a3Sopenharmony_ci
218cc1dc7a3Sopenharmony_ci       -pp-premultiply
219cc1dc7a3Sopenharmony_ci            Run a preprocess over the image that scales RGB components in
220cc1dc7a3Sopenharmony_ci            the image by the alpha value. Preprocessing applies before any
221cc1dc7a3Sopenharmony_ci            codec encoding swizzle, so color data must be in the RGB
222cc1dc7a3Sopenharmony_ci            components in the source image.)"
223cc1dc7a3Sopenharmony_ci// This split in the literals is needed for Visual Studio; the compiler
224cc1dc7a3Sopenharmony_ci// will concatenate these two strings together ...
225cc1dc7a3Sopenharmony_ciR"(
226cc1dc7a3Sopenharmony_ci
227cc1dc7a3Sopenharmony_ciCOMPRESSION TIPS & TRICKS
228cc1dc7a3Sopenharmony_ci       ASTC is a block-based format that can be prone to block artifacts.
229cc1dc7a3Sopenharmony_ci       If block artifacts are a problem when compressing a given texture,
230cc1dc7a3Sopenharmony_ci       increasing the compressor quality preset can help to alleviate the
231cc1dc7a3Sopenharmony_ci       problem.
232cc1dc7a3Sopenharmony_ci
233cc1dc7a3Sopenharmony_ci       If a texture exhibits severe block artifacts in only some of the
234cc1dc7a3Sopenharmony_ci       color components, which is a common problem for mask textures, then
235cc1dc7a3Sopenharmony_ci       using the -cw option to raise the weighting of the affected color
236cc1dc7a3Sopenharmony_ci       component(s) may help. For example, if the green color component is
237cc1dc7a3Sopenharmony_ci       particularly badly encoded then try '-cw 1 6 1 1'.
238cc1dc7a3Sopenharmony_ci
239cc1dc7a3Sopenharmony_ciADVANCED COMPRESSION
240cc1dc7a3Sopenharmony_ci       Error weighting options
241cc1dc7a3Sopenharmony_ci       -----------------------
242cc1dc7a3Sopenharmony_ci
243cc1dc7a3Sopenharmony_ci       These options provide low-level control of the codec error metric
244cc1dc7a3Sopenharmony_ci       computation, used to determine what good compression looks like.
245cc1dc7a3Sopenharmony_ci
246cc1dc7a3Sopenharmony_ci       -a <radius>
247cc1dc7a3Sopenharmony_ci           For textures with alpha component, scale per-texel weights by
248cc1dc7a3Sopenharmony_ci           the alpha value. The alpha value chosen for scaling of any
249cc1dc7a3Sopenharmony_ci           particular texel is taken as an average across a neighborhood of
250cc1dc7a3Sopenharmony_ci           the texel defined by the <radius> argument. Setting <radius> to
251cc1dc7a3Sopenharmony_ci           0 causes only the texel's own alpha to be used.
252cc1dc7a3Sopenharmony_ci
253cc1dc7a3Sopenharmony_ci           ASTC blocks that are entirely zero weighted, after the radius is
254cc1dc7a3Sopenharmony_ci           taken into account, are replaced by constant color blocks. This
255cc1dc7a3Sopenharmony_ci           is an RDO-like technique to improve compression ratio in any
256cc1dc7a3Sopenharmony_ci           application packaging compression that is applied.
257cc1dc7a3Sopenharmony_ci
258cc1dc7a3Sopenharmony_ci       -cw <red> <green> <blue> <alpha>
259cc1dc7a3Sopenharmony_ci           Assign an additional weight scaling to each color component,
260cc1dc7a3Sopenharmony_ci           allowing the components to be treated differently in terms of
261cc1dc7a3Sopenharmony_ci           error significance. Set values above 1 to increase a component's
262cc1dc7a3Sopenharmony_ci           significance, and values below 1 to decrease it. Set to 0 to
263cc1dc7a3Sopenharmony_ci           exclude a component from error computation.
264cc1dc7a3Sopenharmony_ci
265cc1dc7a3Sopenharmony_ci       -mpsnr <low> <high>
266cc1dc7a3Sopenharmony_ci           Set the low and high f-stop values for the mPSNR error metric.
267cc1dc7a3Sopenharmony_ci           The mPSNR error metric only applies to HDR textures.
268cc1dc7a3Sopenharmony_ci
269cc1dc7a3Sopenharmony_ci       Performance-quality tradeoff options
270cc1dc7a3Sopenharmony_ci       ------------------------------------
271cc1dc7a3Sopenharmony_ci
272cc1dc7a3Sopenharmony_ci       These options provide low-level control of the codec heuristics that
273cc1dc7a3Sopenharmony_ci       drive the performance-quality trade off. The presets vary by block
274cc1dc7a3Sopenharmony_ci       bitrate; the recommended starting point for a 4x4 block is very
275cc1dc7a3Sopenharmony_ci       different to a 8x8 block. The presets documented here are for the
276cc1dc7a3Sopenharmony_ci	   high bitrate mode (fewer than 25 texels).
277cc1dc7a3Sopenharmony_ci
278cc1dc7a3Sopenharmony_ci       -partitioncountlimit <number>
279cc1dc7a3Sopenharmony_ci           Test up to and including <number> partitions for each block.
280cc1dc7a3Sopenharmony_ci           Higher numbers give better quality, as more complex blocks can
281cc1dc7a3Sopenharmony_ci           be encoded, but will increase search time. Preset defaults are:
282cc1dc7a3Sopenharmony_ci
283cc1dc7a3Sopenharmony_ci               -fastest      : 2
284cc1dc7a3Sopenharmony_ci               -fast         : 3
285cc1dc7a3Sopenharmony_ci               -medium       : 4
286cc1dc7a3Sopenharmony_ci               -thorough     : 4
287cc1dc7a3Sopenharmony_ci               -verythorough : 4
288cc1dc7a3Sopenharmony_ci               -exhaustive   : 4
289cc1dc7a3Sopenharmony_ci
290cc1dc7a3Sopenharmony_ci       -[2|3|4]partitionindexlimit <number>
291cc1dc7a3Sopenharmony_ci           Estimate errors for <number> block partition indices for this
292cc1dc7a3Sopenharmony_ci           partition count. Higher numbers give better quality, however
293cc1dc7a3Sopenharmony_ci           large values give diminishing returns especially for smaller
294cc1dc7a3Sopenharmony_ci           block sizes. Preset defaults are:
295cc1dc7a3Sopenharmony_ci
296cc1dc7a3Sopenharmony_ci               -fastest      :   10 |   6 |   4
297cc1dc7a3Sopenharmony_ci               -fast         :   18 |  10 |   8
298cc1dc7a3Sopenharmony_ci               -medium       :   34 |  28 |  16
299cc1dc7a3Sopenharmony_ci               -thorough     :   82 |  60 |  30
300cc1dc7a3Sopenharmony_ci               -verythorough :  256 | 128 |  64
301cc1dc7a3Sopenharmony_ci               -exhaustive   :  512 | 512 | 512
302cc1dc7a3Sopenharmony_ci
303cc1dc7a3Sopenharmony_ci       -[2|3|4]partitioncandidatelimit <number>
304cc1dc7a3Sopenharmony_ci           Calculate errors for <number> block partition indices for this
305cc1dc7a3Sopenharmony_ci           partition count. Higher numbers give better quality, however
306cc1dc7a3Sopenharmony_ci           large values give diminishing returns especially for smaller
307cc1dc7a3Sopenharmony_ci           block sizes. Preset defaults are:
308cc1dc7a3Sopenharmony_ci
309cc1dc7a3Sopenharmony_ci               -fastest      :   2 |  2 |  2
310cc1dc7a3Sopenharmony_ci               -fast         :   2 |  2 |  2
311cc1dc7a3Sopenharmony_ci               -medium       :   2 |  2 |  2
312cc1dc7a3Sopenharmony_ci               -thorough     :   3 |  2 |  2
313cc1dc7a3Sopenharmony_ci               -verythorough :  20 | 14 |  8
314cc1dc7a3Sopenharmony_ci               -exhaustive   :  32 | 32 | 32
315cc1dc7a3Sopenharmony_ci
316cc1dc7a3Sopenharmony_ci       -blockmodelimit <number>
317cc1dc7a3Sopenharmony_ci           Test block modes below <number> usage centile in an empirically
318cc1dc7a3Sopenharmony_ci           determined distribution of block mode frequency. This option is
319cc1dc7a3Sopenharmony_ci           ineffective for 3D textures. Preset defaults are:
320cc1dc7a3Sopenharmony_ci
321cc1dc7a3Sopenharmony_ci               -fastest      :  43
322cc1dc7a3Sopenharmony_ci               -fast         :  55
323cc1dc7a3Sopenharmony_ci               -medium       :  77
324cc1dc7a3Sopenharmony_ci               -thorough     :  94
325cc1dc7a3Sopenharmony_ci               -verythorough :  98
326cc1dc7a3Sopenharmony_ci               -exhaustive   : 100
327cc1dc7a3Sopenharmony_ci
328cc1dc7a3Sopenharmony_ci       -refinementlimit <number>
329cc1dc7a3Sopenharmony_ci           Iterate <number> refinement iterations on colors and
330cc1dc7a3Sopenharmony_ci           weights. Minimum value is 1. Preset defaults are:
331cc1dc7a3Sopenharmony_ci
332cc1dc7a3Sopenharmony_ci               -fastest      : 2
333cc1dc7a3Sopenharmony_ci               -fast         : 3
334cc1dc7a3Sopenharmony_ci               -medium       : 3
335cc1dc7a3Sopenharmony_ci               -thorough     : 4
336cc1dc7a3Sopenharmony_ci               -verythorough : 4
337cc1dc7a3Sopenharmony_ci               -exhaustive   : 4
338cc1dc7a3Sopenharmony_ci
339cc1dc7a3Sopenharmony_ci       -candidatelimit <number>
340cc1dc7a3Sopenharmony_ci           Trial <number> candidate encodings for each block mode:
341cc1dc7a3Sopenharmony_ci
342cc1dc7a3Sopenharmony_ci               -fastest      : 2
343cc1dc7a3Sopenharmony_ci               -fast         : 3
344cc1dc7a3Sopenharmony_ci               -medium       : 3
345cc1dc7a3Sopenharmony_ci               -thorough     : 4
346cc1dc7a3Sopenharmony_ci               -verythorough : 6
347cc1dc7a3Sopenharmony_ci               -exhaustive   : 8
348cc1dc7a3Sopenharmony_ci
349cc1dc7a3Sopenharmony_ci       -dblimit <number>
350cc1dc7a3Sopenharmony_ci           Stop compression work on a block as soon as the PSNR of the
351cc1dc7a3Sopenharmony_ci           block, measured in dB, exceeds <number>. This option is
352cc1dc7a3Sopenharmony_ci           ineffective for HDR textures. Preset defaults, where N is the
353cc1dc7a3Sopenharmony_ci           number of texels in a block, are:
354cc1dc7a3Sopenharmony_ci
355cc1dc7a3Sopenharmony_ci               -fastest      : MAX(63-19*log10(N),  85-35*log10(N))
356cc1dc7a3Sopenharmony_ci               -fast         : MAX(63-19*log10(N),  85-35*log10(N))
357cc1dc7a3Sopenharmony_ci               -medium       : MAX(70-19*log10(N),  95-35*log10(N))
358cc1dc7a3Sopenharmony_ci               -thorough     : MAX(77-19*log10(N), 105-35*log10(N))
359cc1dc7a3Sopenharmony_ci               -verythorough : 999
360cc1dc7a3Sopenharmony_ci               -exhaustive   : 999
361cc1dc7a3Sopenharmony_ci
362cc1dc7a3Sopenharmony_ci       -[2|3]partitionlimitfactor <factor>
363cc1dc7a3Sopenharmony_ci           Stop compression work on a block after only testing blocks with
364cc1dc7a3Sopenharmony_ci           up to 2/3 partitions and one plane of weights, unless the 2/3
365cc1dc7a3Sopenharmony_ci           partition error term is lower than the error term from encoding
366cc1dc7a3Sopenharmony_ci           with 1/2 partitions by more than the specified factor. Preset
367cc1dc7a3Sopenharmony_ci           defaults are:
368cc1dc7a3Sopenharmony_ci
369cc1dc7a3Sopenharmony_ci               -fastest       : 1.00 | 1.00
370cc1dc7a3Sopenharmony_ci               -fast          : 1.00 | 1.00
371cc1dc7a3Sopenharmony_ci               -medium        : 1.10 | 1.05
372cc1dc7a3Sopenharmony_ci               -thorough      : 1.35 | 1.15
373cc1dc7a3Sopenharmony_ci               -verythrorough : 1.60 | 1.40
374cc1dc7a3Sopenharmony_ci               -exhaustive    : 2.00 | 2.00
375cc1dc7a3Sopenharmony_ci
376cc1dc7a3Sopenharmony_ci       -2planelimitcorrelation <factor>
377cc1dc7a3Sopenharmony_ci           Stop compression after testing only one plane of weights, unless
378cc1dc7a3Sopenharmony_ci           the minimum color correlation factor between any pair of color
379cc1dc7a3Sopenharmony_ci           components is below this factor. This option is ineffective for
380cc1dc7a3Sopenharmony_ci           normal maps. Preset defaults are:
381cc1dc7a3Sopenharmony_ci
382cc1dc7a3Sopenharmony_ci               -fastest      : 0.50
383cc1dc7a3Sopenharmony_ci               -fast         : 0.65
384cc1dc7a3Sopenharmony_ci               -medium       : 0.85
385cc1dc7a3Sopenharmony_ci               -thorough     : 0.95
386cc1dc7a3Sopenharmony_ci               -verythorough : 0.98
387cc1dc7a3Sopenharmony_ci               -exhaustive   : 0.99
388cc1dc7a3Sopenharmony_ci)"
389cc1dc7a3Sopenharmony_ci// This split in the literals is needed for Visual Studio; the compiler
390cc1dc7a3Sopenharmony_ci// will concatenate these two strings together ...
391cc1dc7a3Sopenharmony_ciR"(
392cc1dc7a3Sopenharmony_ci       Other options
393cc1dc7a3Sopenharmony_ci       -------------
394cc1dc7a3Sopenharmony_ci
395cc1dc7a3Sopenharmony_ci       -esw <swizzle>
396cc1dc7a3Sopenharmony_ci           Specify an encoding swizzle to reorder the color components
397cc1dc7a3Sopenharmony_ci           before compression. The swizzle is specified using a four
398cc1dc7a3Sopenharmony_ci           character string, which defines the format ordering used by
399cc1dc7a3Sopenharmony_ci           the compressor.
400cc1dc7a3Sopenharmony_ci
401cc1dc7a3Sopenharmony_ci           The characters may be taken from the set [rgba01], selecting
402cc1dc7a3Sopenharmony_ci           either input color components or a literal zero or one. For
403cc1dc7a3Sopenharmony_ci           example to swap the RG components, and replace alpha with 1,
404cc1dc7a3Sopenharmony_ci           the swizzle 'grb1' should be used.
405cc1dc7a3Sopenharmony_ci
406cc1dc7a3Sopenharmony_ci           By default all 4 post-swizzle components are included in the
407cc1dc7a3Sopenharmony_ci           compression error metrics. When using -esw to map two
408cc1dc7a3Sopenharmony_ci           component data to the L+A endpoint (e.g. -esw rrrg) the
409cc1dc7a3Sopenharmony_ci           luminance data stored in the RGB components will be weighted 3
410cc1dc7a3Sopenharmony_ci           times more strongly than the alpha component. This can be
411cc1dc7a3Sopenharmony_ci           corrected using the -ssw option to specify which components
412cc1dc7a3Sopenharmony_ci           will be sampled at runtime e.g. -ssw ra.
413cc1dc7a3Sopenharmony_ci
414cc1dc7a3Sopenharmony_ci       -ssw <swizzle>
415cc1dc7a3Sopenharmony_ci           Specify a sampling swizzle to identify which color components
416cc1dc7a3Sopenharmony_ci           are actually read by the application shader program. For example,
417cc1dc7a3Sopenharmony_ci           using -ssw ra tells the compressor that the green and blue error
418cc1dc7a3Sopenharmony_ci           does not matter because the data is not actually read.
419cc1dc7a3Sopenharmony_ci
420cc1dc7a3Sopenharmony_ci           The sampling swizzle is based on the channel ordering after the
421cc1dc7a3Sopenharmony_ci           -esw transform has been applied. Note -ssw exposes the same
422cc1dc7a3Sopenharmony_ci           functionality as -cw, but in a more user-friendly form.
423cc1dc7a3Sopenharmony_ci
424cc1dc7a3Sopenharmony_ci       -dsw <swizzle>
425cc1dc7a3Sopenharmony_ci           Specify a decompression swizzle used to reorder the color
426cc1dc7a3Sopenharmony_ci           components after decompression. The swizzle is specified using
427cc1dc7a3Sopenharmony_ci           the same method as the -esw option, with support for an extra
428cc1dc7a3Sopenharmony_ci           "z" character. This is used to specify that the compressed data
429cc1dc7a3Sopenharmony_ci           stores an X+Y normal map, and that the Z output component
430cc1dc7a3Sopenharmony_ci           should be reconstructed from the two components stored in the
431cc1dc7a3Sopenharmony_ci           data. For the typical ASTC normal encoding, which uses an
432cc1dc7a3Sopenharmony_ci           'rrrg' compression swizzle, you should specify an 'raz1'
433cc1dc7a3Sopenharmony_ci           swizzle for decompression.
434cc1dc7a3Sopenharmony_ci
435cc1dc7a3Sopenharmony_ci       -yflip
436cc1dc7a3Sopenharmony_ci           Flip the image in the vertical axis prior to compression and
437cc1dc7a3Sopenharmony_ci           after decompression. Note that using this option in a test mode
438cc1dc7a3Sopenharmony_ci           (-t*) will have no effect as the image will be flipped twice.
439cc1dc7a3Sopenharmony_ci
440cc1dc7a3Sopenharmony_ci       -j <threads>
441cc1dc7a3Sopenharmony_ci           Explicitly specify the number of threads to use in the codec. If
442cc1dc7a3Sopenharmony_ci           not specified, the codec will use one thread per CPU detected in
443cc1dc7a3Sopenharmony_ci           the system.
444cc1dc7a3Sopenharmony_ci
445cc1dc7a3Sopenharmony_ci       -silent
446cc1dc7a3Sopenharmony_ci           Suppresses all non-essential diagnostic output from the codec.
447cc1dc7a3Sopenharmony_ci           Error messages will always be printed, as will mandatory outputs
448cc1dc7a3Sopenharmony_ci           for the selected operation mode. For example, the test mode will
449cc1dc7a3Sopenharmony_ci           always output image quality metrics and compression time but
450cc1dc7a3Sopenharmony_ci           will suppress all other output.)"
451cc1dc7a3Sopenharmony_ci// This split in the literals is needed for Visual Studio; the compiler
452cc1dc7a3Sopenharmony_ci// will concatenate these two strings together ...
453cc1dc7a3Sopenharmony_ciR"(
454cc1dc7a3Sopenharmony_ci
455cc1dc7a3Sopenharmony_ciDECOMPRESSION
456cc1dc7a3Sopenharmony_ci       To decompress an image stored in the ASTC format you must specify
457cc1dc7a3Sopenharmony_ci       the color profile, the input file name, and the output file name.
458cc1dc7a3Sopenharmony_ci
459cc1dc7a3Sopenharmony_ci       The color profile is specified using the -dl (LDR linear), -ds (LDR
460cc1dc7a3Sopenharmony_ci       sRGB), -dh (HDR RGB, LDR A), or -dH (HDR RGBA) decoder options.
461cc1dc7a3Sopenharmony_ci
462cc1dc7a3Sopenharmony_ci       The input file path must match a valid file format for
463cc1dc7a3Sopenharmony_ci       decompression, and the output file format must be a valid output for
464cc1dc7a3Sopenharmony_ci       a decompressed image. Note that not all output formats that the
465cc1dc7a3Sopenharmony_ci       compression path can produce are supported for decompression. See
466cc1dc7a3Sopenharmony_ci       the FILE FORMATS section for the list of supported formats.
467cc1dc7a3Sopenharmony_ci
468cc1dc7a3Sopenharmony_ci       The -dsw option documented in ADVANCED COMPRESSION option
469cc1dc7a3Sopenharmony_ci       documentation is also relevant to decompression.
470cc1dc7a3Sopenharmony_ci
471cc1dc7a3Sopenharmony_ciTEST
472cc1dc7a3Sopenharmony_ci       To perform a compression test which round-trips a single image
473cc1dc7a3Sopenharmony_ci       through compression and decompression and stores the decompressed
474cc1dc7a3Sopenharmony_ci       result back to file, you must specify same settings as COMPRESSION
475cc1dc7a3Sopenharmony_ci       other than swapping the color profile to select test mode. Note that
476cc1dc7a3Sopenharmony_ci       the compressed intermediate data is discarded in this mode.
477cc1dc7a3Sopenharmony_ci
478cc1dc7a3Sopenharmony_ci       The color profile is specified using the -tl (LDR linear), -ts (LDR
479cc1dc7a3Sopenharmony_ci       sRGB), -th (HDR RGB, LDR A), or -tH (HDR RGBA) encoder options.
480cc1dc7a3Sopenharmony_ci
481cc1dc7a3Sopenharmony_ci       This operation mode will print error metrics suitable for either LDR
482cc1dc7a3Sopenharmony_ci       and HDR images, allowing some assessment of the compression image
483cc1dc7a3Sopenharmony_ci       quality.
484cc1dc7a3Sopenharmony_ci
485cc1dc7a3Sopenharmony_ciCOMPRESSION FILE FORMATS
486cc1dc7a3Sopenharmony_ci       The following formats are supported as compression inputs:
487cc1dc7a3Sopenharmony_ci
488cc1dc7a3Sopenharmony_ci           LDR Formats:
489cc1dc7a3Sopenharmony_ci               BMP (*.bmp)
490cc1dc7a3Sopenharmony_ci               PNG (*.png)
491cc1dc7a3Sopenharmony_ci               Targa (*.tga)
492cc1dc7a3Sopenharmony_ci               JPEG (*.jpg)
493cc1dc7a3Sopenharmony_ci
494cc1dc7a3Sopenharmony_ci           HDR Formats:
495cc1dc7a3Sopenharmony_ci               OpenEXR (*.exr)
496cc1dc7a3Sopenharmony_ci               Radiance HDR (*.hdr)
497cc1dc7a3Sopenharmony_ci
498cc1dc7a3Sopenharmony_ci           Container Formats:
499cc1dc7a3Sopenharmony_ci               Khronos Texture KTX (*.ktx)
500cc1dc7a3Sopenharmony_ci               DirectDraw Surface DDS (*.dds)
501cc1dc7a3Sopenharmony_ci
502cc1dc7a3Sopenharmony_ci       For the KTX and DDS formats only a subset of the features of the
503cc1dc7a3Sopenharmony_ci       formats are supported:
504cc1dc7a3Sopenharmony_ci
505cc1dc7a3Sopenharmony_ci           Texture topology must be 2D, 2D-array, 3D, or cube-map. Note
506cc1dc7a3Sopenharmony_ci           that 2D-array textures are treated as 3D block input.
507cc1dc7a3Sopenharmony_ci
508cc1dc7a3Sopenharmony_ci           Texel format must be R, RG, RGB, BGR, RGBA, BGRA, L, or LA.
509cc1dc7a3Sopenharmony_ci
510cc1dc7a3Sopenharmony_ci           Only the first mipmap in the file will be read.
511cc1dc7a3Sopenharmony_ci
512cc1dc7a3Sopenharmony_ci       The following formats are supported as compression outputs:
513cc1dc7a3Sopenharmony_ci
514cc1dc7a3Sopenharmony_ci           ASTC (*.astc)
515cc1dc7a3Sopenharmony_ci           Khronos Texture KTX (*.ktx)
516cc1dc7a3Sopenharmony_ci
517cc1dc7a3Sopenharmony_ci
518cc1dc7a3Sopenharmony_ciDECOMPRESSION FILE FORMATS
519cc1dc7a3Sopenharmony_ci       The following formats are supported as decompression inputs:
520cc1dc7a3Sopenharmony_ci
521cc1dc7a3Sopenharmony_ci           ASTC (*.astc)
522cc1dc7a3Sopenharmony_ci           Khronos Texture KTX (*.ktx)
523cc1dc7a3Sopenharmony_ci
524cc1dc7a3Sopenharmony_ci       The following formats are supported as decompression outputs:
525cc1dc7a3Sopenharmony_ci
526cc1dc7a3Sopenharmony_ci           LDR Formats:
527cc1dc7a3Sopenharmony_ci               BMP (*.bmp)
528cc1dc7a3Sopenharmony_ci               PNG (*.png)
529cc1dc7a3Sopenharmony_ci               Targa (*.tga)
530cc1dc7a3Sopenharmony_ci
531cc1dc7a3Sopenharmony_ci           HDR Formats:
532cc1dc7a3Sopenharmony_ci               OpenEXR (*.exr)
533cc1dc7a3Sopenharmony_ci               Radiance HDR (*.hdr)
534cc1dc7a3Sopenharmony_ci
535cc1dc7a3Sopenharmony_ci           Container Formats:
536cc1dc7a3Sopenharmony_ci               Khronos Texture KTX (*.ktx)
537cc1dc7a3Sopenharmony_ci               DirectDraw Surface DDS (*.dds)
538cc1dc7a3Sopenharmony_ci
539cc1dc7a3Sopenharmony_ciQUICK REFERENCE
540cc1dc7a3Sopenharmony_ci
541cc1dc7a3Sopenharmony_ci       To compress an image use:
542cc1dc7a3Sopenharmony_ci           astcenc {-cl|-cs|-ch|-cH} <in> <out> <blockdim> <quality> [options]
543cc1dc7a3Sopenharmony_ci
544cc1dc7a3Sopenharmony_ci       To decompress an image use:
545cc1dc7a3Sopenharmony_ci           astcenc {-dl|-ds|-dh|-dH} <in> <out>
546cc1dc7a3Sopenharmony_ci
547cc1dc7a3Sopenharmony_ci       To perform a quality test use:
548cc1dc7a3Sopenharmony_ci           astcenc {-tl|-ts|-th|-tH} <in> <out> <blockdim> <quality> [options]
549cc1dc7a3Sopenharmony_ci
550cc1dc7a3Sopenharmony_ci       Mode -*l = linear LDR, -*s = sRGB LDR, -*h = HDR RGB/LDR A, -*H = HDR.
551cc1dc7a3Sopenharmony_ci       Quality = -fastest/-fast/-medium/-thorough/-verythorough/-exhaustive/a float [0-100].
552cc1dc7a3Sopenharmony_ci)";
553cc1dc7a3Sopenharmony_ci
554cc1dc7a3Sopenharmony_ci/* See header for documentation. */
555cc1dc7a3Sopenharmony_civoid astcenc_print_header()
556cc1dc7a3Sopenharmony_ci{
557cc1dc7a3Sopenharmony_ci#if (ASTCENC_AVX == 2)
558cc1dc7a3Sopenharmony_ci	const char* simdtype = "avx2";
559cc1dc7a3Sopenharmony_ci#elif (ASTCENC_SSE == 41)
560cc1dc7a3Sopenharmony_ci	const char* simdtype = "sse4.1";
561cc1dc7a3Sopenharmony_ci#elif (ASTCENC_SSE == 20)
562cc1dc7a3Sopenharmony_ci	const char* simdtype = "sse2";
563cc1dc7a3Sopenharmony_ci#elif (ASTCENC_NEON == 1)
564cc1dc7a3Sopenharmony_ci	const char* simdtype = "neon";
565cc1dc7a3Sopenharmony_ci#else
566cc1dc7a3Sopenharmony_ci	const char* simdtype = "none";
567cc1dc7a3Sopenharmony_ci#endif
568cc1dc7a3Sopenharmony_ci
569cc1dc7a3Sopenharmony_ci#if (ASTCENC_POPCNT == 1)
570cc1dc7a3Sopenharmony_ci	const char* pcnttype = "+popcnt";
571cc1dc7a3Sopenharmony_ci#else
572cc1dc7a3Sopenharmony_ci	const char* pcnttype = "";
573cc1dc7a3Sopenharmony_ci#endif
574cc1dc7a3Sopenharmony_ci
575cc1dc7a3Sopenharmony_ci#if (ASTCENC_F16C == 1)
576cc1dc7a3Sopenharmony_ci	const char* f16ctype = "+f16c";
577cc1dc7a3Sopenharmony_ci#else
578cc1dc7a3Sopenharmony_ci	const char* f16ctype = "";
579cc1dc7a3Sopenharmony_ci#endif
580cc1dc7a3Sopenharmony_ci
581cc1dc7a3Sopenharmony_ci	unsigned int bits = static_cast<unsigned int>(sizeof(void*) * 8);
582cc1dc7a3Sopenharmony_ci	printf(astcenc_copyright_string,
583cc1dc7a3Sopenharmony_ci	       VERSION_STRING, bits, simdtype, pcnttype, f16ctype, YEAR_STRING);
584cc1dc7a3Sopenharmony_ci}
585cc1dc7a3Sopenharmony_ci
586cc1dc7a3Sopenharmony_ci/* See header for documentation. */
587cc1dc7a3Sopenharmony_civoid astcenc_print_shorthelp()
588cc1dc7a3Sopenharmony_ci{
589cc1dc7a3Sopenharmony_ci	astcenc_print_header();
590cc1dc7a3Sopenharmony_ci	printf("%s", astcenc_short_help);
591cc1dc7a3Sopenharmony_ci}
592cc1dc7a3Sopenharmony_ci
593cc1dc7a3Sopenharmony_ci/* See header for documentation. */
594cc1dc7a3Sopenharmony_civoid astcenc_print_longhelp()
595cc1dc7a3Sopenharmony_ci{
596cc1dc7a3Sopenharmony_ci	astcenc_print_header();
597cc1dc7a3Sopenharmony_ci	printf("%s", astcenc_long_help);
598cc1dc7a3Sopenharmony_ci}
599