This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

ASTC Evaluation Codec

Mali has just published an evaluation codec for the new ARM Adaptive Scalable Texture Compression (ASTC) standard.

For more information on ASTC, take a look at the ARM Multimedia Blog posts "ASTC Texture Compression: ARM Pushes the Envelope in Graphics Technology" and "ARM Unveils Details of ASTC Texture Compression at HPG Conference".

I have started this thread for users of this evaluation tool to ask questions. Here's a very quick "getting started" guide:

Getting Started

First, accept the license, download the tarball and unpack. In the subdirectories Win32, Mac OS X and Linux32 are binaries for, you guessed it, Windows, Mac OS X, and Linux (x86 versions). If you are running on another system, you might like to try compiling from source - take a look at Source/buildinstructions.txt .

Open a terminal, change to the appropriate directory for your system, and run the astcenc encoder program, like this on Linux or Mac OS:

./astcenc

Or like this on Windows:

astcenc

Invoking the tool with no arguments gives a very extensive help message, including usage instructions, and details of all the possible options.

How do I run the tool?

First, find a 24-bit .png or .tga file you wish to use, say /images/example.png (or on windows C:\images\example.png).

You can compress it using the -c option, like this (use the first line for Linux or Mac OS, second line for Windows users):

./astcenc -c /images/example.png /images/example-compressed.astc 6x6 -medium
astcenc -c C:\images\example.png C:\images\example-compressed.astc 6x6 -medium

The -c indicates a compression operation, followed by the input and output filenames. The block footprint size follows, in this case 6x6 pixels, then the requested compression speed, medium.

To decompress the file again, you should use:

astcenc -d /images/example-compressed.astc /images/example-decompressed.tga
astcenc -d C:\images\example-compressed.astc C:\images\example-decompressed.tga

The -d indicates decompression, followed by the input and output filenames. The output file will be an uncompressed TGA image.

If you just want to test what compression and decompression are like, use the test mode:

astcenc -t /images/example.png /images/example-decompressed.tga 6x6 -medium
astcenc -c C:\images\example.png C:\images\example-compressed.tga 6x6 -medium

This is equivalent to compressing and then immediately decompressing again, and it also prints out statistics about the fidelity of the resulting image, using the peak signal-to-noise ratio.

Take a look at the input and output images.

Experimenting

The block footprints go from 4x4 (8 bits per pixel) all the way up to 12x12 (0.89 bits/pixel). Like any lossy codec, such as JPEG there will come a point where selecting too aggressive a compression results in inacceptable quality loss, and ASTC is no exception. Finding this optimum balance between size and quality is one place where ASTC excels since its compression ratio is adjustable in much finer steps than other texture codecs.

The compression speed runs from -veryfast, through -fast, -medium and -thorough, up to -exhaustive. In general, the more time the encoder has to spend looking for good encodings, the better the results.

So, download, run, have a play, and post any questions or results on this thread.

  • Hello again, seanellis, chrisvarns

    Some condition clauses in astc_compress_symbolic.cpp looks strange:

    393int color_quantization_level[4];
    394int color_quantization_level_mod[4];
    ...
    458if ((partition_count >= 2 && scb->color_formats[0] == scb->color_formats[1]
    459     && color_quantization_level != color_quantization_level_mod)

    Condition "color_quantization_level != color_quantization_level_mod" seems always be true, since color_quantization_level and color_quantization_level_mod are just pointers here and are always different.

    Maybe there should be 4 comparisons between each element pairs, but it makes little sence to me. Moreover, I've tested this and it's seems does not affect the compression results.

    The same are on the lines 760-761.

    Maybe this condition can be safely deleted? Am I wrong?

  • Hi Sean,

    I'd like to ask a question about ASTC evaluation codec for sRGB decode.

    According to ASTC spec1.0 3.13, for sRGB, 8-bit color endpoint extend to 16-bits use this equation C0 = (C0 <<8) | 0x80, which is different from linear RGB in C0 = (C0 <<8) | C0;

    But in astc_color_unquantize.cpp line 911, when decode mode is DECODE_LDR_SRGB, output0->x *= 257; which is the same with DECODE_LDR. It seems violate ASTC spec, right?!

    Did I have any misunderstanding?

    Thanks!

    pcchen

  • Hi,

    I am writing a wrapper over the ASTC Evaluation Code => meaning I have another executable that makes functions calls from the ASTC Evaluation Codec, which is being used as a static library.

    Now I am getting crashes when calling:

    static void four_partitions_find_best_combination_for_bitcount(float combined_best_error[21][13],

        int formats_of_choice[21][13][4],

        int bits_available, int *best_quantization_level, int *best_quantization_level_mod, int *best_formats, float *error_of_best_combination)

    @ best_formats[i] = formats_of_choice[ql][best_integer_count - 4][i];

    ql gets a value which is outside the array memory boundaries when best_integer_count = -4

    This happens because quantization_mode_table is not allocated in the BSS, so when using negative array indexes (underflow) you have no control over what values that are before the array allocation.

    Is this the intended behavior and people that want to write wrappers should look at ways of avoiding this?

  • Hello,

    I'm currently doing almost the same as cristinab : modifying the evaluation code so that it fits into a static library, with a simple fonction taking raw RGBA8/16F data in memory as input and outputing an ASTC buffer, with optionally all mipmap levels.
    I'm interested to know if someone already did it, or at least chnaged the executable's code so that it can generate an astc file with mip levels included. This is a real lack at this moment.
    Thanks a lot!

  • Hi Rhizom,

    thank you for sharing with us your plan, it's important to understand the needs of the community. As you have probably seen, ASTC codec is now on GitHub.

    I am not aware of anyone who has built a static library for ASTC, but now it's possible to fork the codec that we have published and start working on this functionality (as well as the mipmap levels one). We will be happy to review any patch or pull request, and support you in your activities.

    Thanks,

    Lorenzo