Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add C implementations of Kauai decompressors #31

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

beholdnec
Copy link

The original code includes C implementations of these functions, however, they are broken, and they are never used anyway since x86 assembly versions are used instead.

This PR adds new C implementations of the Kauai decompressors. After attempting to repair the original code, I decided to give up and adapt the kcdc_386 and kcd2_386 so they generate pure C code. I have verified these functions work correctly, but the x86 assembly versions are still used on Win32.

@beholdnec beholdnec force-pushed the kauai_codecs_flat branch from 067cfdc to d5ddf8e Compare June 21, 2022 01:08
@beholdnec beholdnec force-pushed the kauai_codecs_flat branch from d5ddf8e to 57cfad8 Compare June 21, 2022 01:43
@beholdnec
Copy link
Author

Checks fail on "// clang-format on". I need advice.

@LowLevelMahn
Copy link

strange - should work

maybe you can suppress the warning/error for this code-block: https://stackoverflow.com/questions/48426484/concise-way-to-disable-specific-warning-instances-in-clang

#if defined( __clang__)
  #pragma clang diagnostic push
  #pragma clang diagnostic ignored "-Wclang-format-violations"
  // your code for which the warning gets suppressed 
  #pragma clang diagnostic pop
  // not suppressed here
#endif

@beholdnec
Copy link
Author

The clang-format issue has been solved.

@nil-vr
Copy link

nil-vr commented Apr 8, 2023

I have working kauai decompressors in https://github.com/nil-vr/3dmm-dump/tree/main/src/kauai . I never figured out what was going wrong with the C++ code, but I got it working in Rust based on the C++ code and its documentation. It's pretty straightforward. It uses the bitvec crate to read the bytes as a series of bits. You just need to substitute in a different bitstream reader that yields the bits in the same order and it should be an easy port. If you can pass the tests from kcdc.rs that will prove your bitstream implementation and then kcd2 is very similar.

It might not be as fast as the custom generated version that has different implementations for each starting bit offset, but it's much easier to read and computers are a lot faster now so using Rust generics or C++ templates to achieve the same optimization seems like it'd be just for the challenge of doing it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants