ARM-software / astc-encoder

The Arm ASTC Encoder, a compressor for the Adaptive Scalable Texture Compression data format.
https://developer.arm.com/graphics
Apache License 2.0
1.05k stars 237 forks source link

cannot view the resulting image (OS X) #1

Closed nyotis closed 9 years ago

nyotis commented 9 years ago

I am using the test mode you describe in the wiki *./astcenc -t /images/example.png /images/example-decompressed.tga 6x6 -medium (to test what compression and decompression are like), but i cannot view the resulting image - compression/de-compression succeeds as i see from log. I am using the binary provided on OS X, tried tga/png as the resulting image

lordalcol commented 9 years ago

Hi, what happens when you try to display the png image? Can you try to attach the image?

nyotis commented 9 years ago

receive the non-helpful "Cannot load image"

lordalcol commented 9 years ago

Can you attach the initial image, the astc encoded image, and the final png output please?

nyotis commented 9 years ago

surprisingly the tool succeeded now, but only for *.tga - attached are two images and their compressed versions for the png format - tga and astec not supported- i got for the test mode you describe in the wiki. Encoding settings:

[1] ./astcenc -t /Downloads/temp/encoder/RedbrushAlpha-0.5.png /Downloads/temp/encoder/red-compressed.png 6x6 -medium

*2D Block size: 6x6 (3.56 bpp) 3D Block size: 6x6x1 (3.56 bpp) Radius for mean-and-stdev calculations: 0 texels RGB power: 1 RGB base-weight: 1 RGB local-mean weight: 0 RGB local-stdev weight: 0 RGB mean-and-stdev mixing across color channels: 0 Alpha power: 1 Alpha base-weight: 1 Alpha local-mean weight: 0 Alpha local-stdev weight: 0 RGB weights scale with alpha: disabled Color channel relative weighting: R=1 G=1 B=1 A=1 Block-artifact suppression parameter : 0 Number of distinct partitionings to test: 25 (preset) PSNR decibel limit: 2D: 40.529411 3D: 40.529411 (preset) 1->2 partition limit: 1.200000 Dual-plane color-correlation cutoff: 0.750000 (preset) Block Mode Percentile Cutoff: 75.000000 (preset) Max refinement iterations: 2 (preset) Thread count : 8 (autodetected)

/Downloads/temp/encoder/RedbrushAlpha-0.5.png: 2D LDR image, 512 x 480 x 1, 4 components

6880 blocks to process... 6875 Stored TGA image /Downloads/temp/encoder/red-compressed.tga with 4 color channels*

[2] ./astcenc -t /Downloads/temp/encoder/fight.png /Downloads/temp/encoder/fight-compressed.tga 6x6 -medium

2D Block size: 6x6 (3.56 bpp) 3D Block size: 6x6x1 (3.56 bpp) Radius for mean-and-stdev calculations: 0 texels RGB power: 1 RGB base-weight: 1 RGB local-mean weight: 0 RGB local-stdev weight: 0 RGB mean-and-stdev mixing across color channels: 0 Alpha power: 1 Alpha base-weight: 1 Alpha local-mean weight: 0 Alpha local-stdev weight: 0 RGB weights scale with alpha: disabled Color channel relative weighting: R=1 G=1 B=1 A=1 Block-artifact suppression parameter : 0 Number of distinct partitionings to test: 25 (preset) PSNR decibel limit: 2D: 40.529411 3D: 40.529411 (preset) 1->2 partition limit: 1.200000 Dual-plane color-correlation cutoff: 0.750000 (preset) Block Mode Percentile Cutoff: 75.000000 (preset) Max refinement iterations: 2 (preset) Thread count : 8 (autodetected)

/Downloads/temp/encoder/fight.png: 2D LDR image, 1467 x 916 x 1, 3 components

37485 blocks to process... 37479 Stored TGA image /Users/nik/Downloads/temp/encoder/fight-compressed.tga with 1 color channels

fight-compressed

fight red-compressed

redbrushalpha-0 5

nyotis commented 9 years ago

all files here https://drive.google.com/folderview?id=0B7IF7RBsCPxyfnItRUR1WXpJZUFBUFRNMnk1R2twaDhjNGhvYUUxcTlma3pUUzhKWnN6Rnc&usp=sharing

NikunjPatel-ARM commented 9 years ago

Managed to reproduce the error, I'll look into what's causing it.

NikunjPatel-ARM commented 9 years ago

Looks like astcenc is doing the correct thing here.

The ASTC encoder doesn't support writing out images as .png, or in any compressed format other than .astc. The list of supported output formats are shown when you execute astcenc without any args:

For decompression, the input file must be an ASTC compressed texture file; the following formats are supported for output:

  • Targa (*.tga)
  • KTX (*.ktx)
  • DDS (*.dds)
  • Half-Float-TGA (*.htga)
  • OpenEXR (*.exr; only if t'exr_to_htga' is present in the path)

Targa is suitable only for 2D LDR images; for HDR and/or 3D images, please use KTX or DDS.

So, when you pass something like the following...

.\astcenc.exe -t .\fight.png .\fight_compressed.png 6x6 -medium

...astcenc will default to outputting htga format instead.

nyotis commented 9 years ago

nice one -especially support for OpenEXR. Is it normal that the size of the image is way larger after encoding?

NikunjPatel-ARM commented 9 years ago

Yes. All output image formats (tga, ktx, dds, htga and exr) are uncompressed, so their size on disk is a function of the dimensions of the image and the number of bits the format uses per channel. This will almost always be larger than an input png file.

lordalcol commented 9 years ago

Yes, it is normal, if you compare to PNG. PNG is a highly optimized compression format. It works well in software, and when de-compression is done once for the whole file (think of it as a ZIP of a bitmap).

Unfortunately PNG is not good for on-the-fly decompression on GPU. A GPU rendering a graphics scene will need to access hundreds of textures, and usually only parts of them. This is why hardware decompression uses methods like ETC or ASTC, which allow on-the-fly decompression of single blocks of the image. This allows random access.

Coming to your example (the 'fight' image), as a raw RGB bitmap, its size is around 4MB (1467 × 916 x 24 bit). The ASTC file, on the other hand, is 2.6MB. This of course depends on the block size you choose.

More on this at http://mainroach.blogspot.co.uk/2014/03/the-png-vs-gpu-battle-on-android.html