{"id":19554618,"url":"https://github.com/m4tx/rans-rs","last_synced_at":"2025-04-26T21:32:15.067Z","repository":{"id":45841768,"uuid":"514706521","full_name":"m4tx/rans-rs","owner":"m4tx","description":"rANS encoder and decoder for Rust","archived":false,"fork":false,"pushed_at":"2024-02-11T15:46:18.000Z","size":51,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-31T11:57:16.823Z","etag":null,"topics":["asymmetric-numeral-systems","compression","entropy-coding","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/m4tx.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2022-07-16T23:36:58.000Z","updated_at":"2024-09-20T09:25:08.000Z","dependencies_parsed_at":"2024-02-03T18:28:31.814Z","dependency_job_id":"42deaab0-7951-4454-b214-aa16dd0e0983","html_url":"https://github.com/m4tx/rans-rs","commit_stats":{"total_commits":5,"total_committers":1,"mean_commits":5.0,"dds":0.0,"last_synced_commit":"f3612e011088c9bff80a85f5f8e2bc9eeeaee2e5"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m4tx%2Frans-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m4tx%2Frans-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m4tx%2Frans-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m4tx%2Frans-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/m4tx","download_url":"https://codeload.github.com/m4tx/rans-rs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224047831,"owners_count":17246909,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["asymmetric-numeral-systems","compression","entropy-coding","rust"],"created_at":"2024-11-11T04:28:20.780Z","updated_at":"2024-11-11T04:28:22.208Z","avatar_url":"https://github.com/m4tx.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"rans-rs\n=======\n\n[![Rust Build Status](https://github.com/m4tx/rans-rs/workflows/Rust%20CI/badge.svg)](https://github.com/m4tx/rans-rs/actions/workflows/rust.yml)\n[![crates.io](https://img.shields.io/crates/v/rans.svg)](https://crates.io/crates/rans)\n[![Documentation](https://docs.rs/rans/badge.svg)](https://docs.rs/rans)\n[![MIT licensed](https://img.shields.io/github/license/m4tx/rans-rs)](https://github.com/m4tx/rans-rs/blob/master/LICENSE)\n[![codecov](https://codecov.io/gh/m4tx/rans-rs/branch/master/graph/badge.svg)](https://codecov.io/gh/m4tx/rans-rs)\n\nRanged Asymmetric Numeral Systems (rANS) encoder and decoder. Under the hood,\nthis is a high-level wrapper over\n[ryg-rans-sys](https://github.com/m4tx/ryg-rans-sys/).\n\nANS is a family of modern entropy coding methods introduced by Jarek Duda from\nJagiellonian University. It serves as an alternative to arithmetic and Huffman\ncoding, combining the performance and compression ratio of both. Many recent\ncompression algorithms, such as Facebook’s Zstandard, Apple’s LZFSE, or JPEG XL,\nuse ANS under the hood.\n\nSee the [ryg_rans](https://github.com/rygorous/ryg_rans) repository for more\ndetails about the underlying implementation.\n\n## Usage\n\nAdd the following to your `Cargo.toml`:\n\n```toml\n[dependencies]\nrans = \"0.4.0\"\n```\n\n## Examples\n\n```rust\nuse rans::byte_decoder::{ByteRansDecSymbol, ByteRansDecoder};\nuse rans::byte_encoder::{ByteRansEncSymbol, ByteRansEncoder};\nuse rans::{RansDecSymbol, RansDecoder, RansEncSymbol, RansEncoder, RansEncoderMulti};\n\nconst SCALE_BITS: u32 = 2;\n\n// Encode two symbols\nlet mut encoder = ByteRansEncoder::new(1024);\nlet symbol1 = ByteRansEncSymbol::new(0, 2, SCALE_BITS);\nlet symbol2 = ByteRansEncSymbol::new(2, 2, SCALE_BITS);\n\nencoder.put(\u0026symbol1);\nencoder.put(\u0026symbol2);\nencoder.flush();\n\nlet mut data = encoder.data().to_owned();\n\n// Decode the encoded data\nlet mut decoder = ByteRansDecoder::new(data);\nlet symbol1 = ByteRansDecSymbol::new(0, 2);\nlet symbol2 = ByteRansDecSymbol::new(2, 2);\n\n// Please note that the data is being decoded in reverse\nassert_eq!(decoder.get(SCALE_BITS), 2); // Decoder returns cumulative frequency\ndecoder.advance(\u0026symbol2, SCALE_BITS);\nassert_eq!(decoder.get(SCALE_BITS), 0);\ndecoder.advance(\u0026symbol1, SCALE_BITS);\n```\n\n## License\n\nThe project is licensed under the [MIT license](LICENSE).\n\n## Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally submitted\nfor inclusion in the project by you shall be licensed as MIT, without any\nadditional terms or conditions.\n\n## Developing\n### `pre-commit`\nWe encourage contributors to use predefined [`pre-commit`](https://pre-commit.com/)\nhooks --- to install them in your local repo, make sure you have `pre-commit`\ninstalled and run\n```shell\npre-commit install\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fm4tx%2Frans-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fm4tx%2Frans-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fm4tx%2Frans-rs/lists"}