Git Product home page Git Product logo

astc-codec's Introduction

astc-codec

astc-codec is a software ASTC decoder implementation, which supports the ASTC LDR profile.

Example usage:

#include <astc-codec/astc-codec.h>

// ...

std::vector<uint8_t> astc = LoadMyASTCData();
const size_t width = 640;
const size_t height = 480;

std::vector<uint8_t> result;
result.resize(width * height * 4);

bool success = astc_codec::ASTCDecompressToRGBA(
    astc.data(), astc.size(), width, height, astc_codec::FootprintType::k4x4,
    result.data(), result.size(), /* stride */ width * 4);

Building

With bazel

Install Bazel, and then run:

bazel build :astc_codec -c opt

astc-codec has been tested on Mac and Linux.

Run Tests

bazel test //...

With CMake

Install CMake, and the run:

mkdir build && cd build && cmake .. && make

Or open the project in your favorite IDE and import CMakeLists.txt.

Run Tests

In the build directory, execute:

ctest

Contributing

See CONTRIBUTING.md for important contributing requirements.

License

astc-codec project is licensed under the Apache License Version 2.0. You can find a copy of it in LICENSE.

This is not an officially supported Google product.

astc-codec's People

Contributors

bbarenblat avatar fish2000 avatar jwmcglynn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

astc-codec's Issues

codec.cc size check incorrect?

if (kBytesPerPixelUNORM8 * width > out_buffer_stride ||
     out_buffer_stride * height < out_buffer_size) {
          // Output buffer too small.
          return false;
     }

If I pass in a buffer with exactly the right size, this would fail. If I passed in a buffer much larger than required, it would also fail? Seems like the logic is inverted on the second condition - unless I'm missing something?

Can not build as shared library

Hi!

I see no restriction described about building this project as shared library, however, I see a linkage error and building:

$ cd build && cmake .. -G "Unix Makefiles" -DCMAKE_BUILD_TYPE="Release" -DCMAKE_CXX_FLAGS="-m64" -DCMAKE_SHARED_LINKER_FLAGS="-m64" -DCMAKE_C_FLAGS="-m64" -DBUILD_SHARED_LIBS="ON" -DCMAKE_POSITION_INDEPENDENT_CODE="ON" -DOPTION_ASTC_TESTS="OFF"

-- The C compiler identification is GNU 10.1.0
-- The CXX compiler identification is GNU 10.1.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Conan: called by CMake conan helper
-- Conan: called inside local cache
-- Conan: Adjusting output directories
-- Conan: Using cmake global configuration
-- Conan: Adjusting default RPATHs Conan policies
-- Conan: Adjusting language standard
-- Conan: Adjusting fPIC flag (ON)
-- Conan: Compiler GCC>=5, checking major version 10
-- Conan: Checking correct version: 10
-- Conan: C++ stdlib: libstdc++11
-- Configuring done
-- Generating done

-- Build files have been written to: /home/uilian/data/astc-codec/build


$ cmake --build .

Scanning dependencies of target footprint
[  6%] Building CXX object src/decoder/CMakeFiles/footprint.dir/footprint.cc.o
[ 12%] Linking CXX shared library libfootprint.so
[ 12%] Built target footprint
Scanning dependencies of target astc_utils
[ 18%] Building CXX object src/decoder/CMakeFiles/astc_utils.dir/astc_file.cc.o
[ 25%] Building CXX object src/decoder/CMakeFiles/astc_utils.dir/endpoint_codec.cc.o
[ 31%] Building CXX object src/decoder/CMakeFiles/astc_utils.dir/integer_sequence_codec.cc.o
[ 37%] Building CXX object src/decoder/CMakeFiles/astc_utils.dir/intermediate_astc_block.cc.o
[ 43%] Building CXX object src/decoder/CMakeFiles/astc_utils.dir/logical_astc_block.cc.o
[ 50%] Building CXX object src/decoder/CMakeFiles/astc_utils.dir/partition.cc.o
[ 56%] Building CXX object src/decoder/CMakeFiles/astc_utils.dir/physical_astc_block.cc.o
[ 62%] Building CXX object src/decoder/CMakeFiles/astc_utils.dir/quantization.cc.o
[ 68%] Building CXX object src/decoder/CMakeFiles/astc_utils.dir/weight_infill.cc.o
[ 75%] Linking CXX shared library libastc_utils.so
[ 75%] Built target astc_utils
Scanning dependencies of target astc_inspector_cli
[ 81%] Building CXX object src/decoder/CMakeFiles/astc_inspector_cli.dir/tools/astc_inspector_cli.cc.o
[ 87%] Linking CXX executable astc_inspector_cli
/usr/bin/ld: CMakeFiles/astc_inspector_cli.dir/tools/astc_inspector_cli.cc.o: undefined reference to symbol '_ZN10astc_codec9Footprint5ParseEPKc'
/usr/bin/ld: /home/uilian/data/astc-codec/build/build/src/decoder/libfootprint.so: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[2]: *** [src/decoder/CMakeFiles/astc_inspector_cli.dir/build.make:104: src/decoder/astc_inspector_cli] Error 1
make[1]: *** [CMakeFiles/Makefile2:140: src/decoder/CMakeFiles/astc_inspector_cli.dir/all] Error 2
make: *** [Makefile:103: all] Error 2

The error seems be related to astc_inspector_cli and some missing symbol.

Environment:

arch=x86_64
build type=Release
compiler=gcc 10
libcxx=libstdc++11
os=Linux

I'm using the commit 9757bef: https://github.com/google/astc-codec/archive/9757befb64db6662aad45de09ca87cd6f599ac02.tar.gz

bug in DecodeEndpoints()

Hi,
I've been comparing the output of astc-codec vs. another ASTC decoder from Google. I found a decoding issue with void extent blocks, where the output differs from what is expected by the ASTC spec in LDR mode when sRGB enabled. Here's the relevant code:

static std::vector DecodeEndpoints(const VoidExtentData& block) {
EndpointPair eps;
// Original code:
//eps.first[0] = eps.second[0] = (block.r * 255) / 65535;
//eps.first[1] = eps.second[1] = (block.g * 255) / 65535;
//eps.first[2] = eps.second[2] = (block.b * 255) / 65535;
//eps.first[3] = eps.second[3] = (block.a * 255) / 65535;

// Corrected code that generates the expected result with void extent blocks:
eps.first[0] = eps.second[0] = (block.r >> 8);
eps.first[1] = eps.second[1] = (block.g >> 8);
eps.first[2] = eps.second[2] = (block.b >> 8);
eps.first[3] = eps.second[3] = (block.a >> 8);

iffy looking scaling code in LogicalASTCBlock::ColorAt()

Hi,
The code to compute 8-bit non-sRGB output doesn't seem to follow the method outlined in the ASTC spec:

const int c = (c0 * (64 - weight) + c1 * weight + 32) / 64;
// TODO(google): Handle conversion to sRGB or FP16 per C.2.19.
const int quantized = ((c * 255) + 32767) / 65536;
assert(quantized < 256);

The spec says "If sRGB conversion is not enabled and the decoding mode is decode_unorm8, then the top 8 bits of the interpolation result for the R, G, B and A channels are used as the final result.":

Section 23.19

The difference will be very slight, and I'm not sure if this actually causes any issues at all because the scale factors are so similar. I'm pointing it out here because there's a comment, and because I noticed that the implementation deviates from the spec in a way that could break bit-exact decoding.

Integrating with OSS-Fuzz

Greetings astc-codec developers and contributors,

We’re reaching out because your project is an important part of the open source ecosystem, and we’d like to invite you to integrate with our fuzzing service, OSS-Fuzz. OSS-Fuzz is a free fuzzing infrastructure you can use to identify security vulnerabilities and stability bugs in your project. OSS-Fuzz will:

  • Continuously run at scale all the fuzzers you write.
  • Alert you when it finds issues.
  • Automatically close issues after they’ve been fixed by a commit.

Many widely used open source projects like OpenSSL, FFmpeg, LibreOffice, and ImageMagick are fuzzing via OSS-Fuzz, which helps them find and remediate critical issues.

We see that you are fuzzing it already. We can help with the integration to OSS-Fuzz with the fuzzer you have.

If you're not interested in integrating with OSS-Fuzz, it would be helpful for us to understand why—lack of interest, lack of time, or something else—so we can better support projects like yours in the future.

If we’ve missed your question in our FAQ, feel free to reply or reach out to us at [email protected].

Thanks!

Tommy
OSS-Fuzz Team

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.