Skip to content

51ddhesh/RL_encoder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Run Length Encoder

Run-length encoding (RLE) is a form of lossless data compression in which runs of data (consecutive occurrences of the same data value) are stored as a single occurrence of that data value and a count of its consecutive occurrences, rather than as the original run.


Overview

This project provides a fast and simple implementation of Run-Length Encoding (RLE) in Rust, along with utilities for benchmarking and testing. It includes:

  • A Rust CLI tool for compressing and decompressing files using RLE.
  • Utility functions for efficient file I/O with progress bars.
  • A C++ utility to generate large input files for testing and benchmarking.

Project Structure

rl_encoding/
├── Cargo.toml            # Rust project manifest
├── generate_input.cpp    # C++ utility to generate large input files
└── src/
    ├── main.rs           # entry point
    ├── rle.rs            # RLE compression/decompression
    ├── utils.rs          # File I/O utilities with progress bars
    └── lib.rs            # (Optional) Rust library file

Usage

Generating Sample Input

Compile the generate_input.cpp with aggressive compilation flags as it generates large output file (~100MB)

g++ generate_input.cpp -o gen -O3 -std=c++20 -flto -march=native
./gen

This will generate a large_input.txt which can be used to test and benchmark this project.

Compress a File

cargo run -- compress <input_file> <output_file>

Decompress a File

cargo run -- decompress <input_file> <output_file>

Check Output

You can verify that decompression restores the original data:

diff <input> <output>
# No output means files are identical

Features

  • Efficient file reading and writing with progress bars (see src/utils.rs).
  • Simple and fast RLE compression/decompression (see src/rle.rs).
  • Example C++ generator for large test files.

License

This project is licensed under the MIT License.

About

A simple RL encoder and decoder.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors