Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/fytex/shafa-cd

File Compressor written in C using both Shannon Fano and RLE algorithms
https://github.com/fytex/shafa-cd

binary-code c clang compressor decompressor matrix rle rle-compression-algorithm shafa shannon-fano shannon-fano-algorithm shannonfano

Last synced: 8 days ago
JSON representation

File Compressor written in C using both Shannon Fano and RLE algorithms

Awesome Lists containing this project

README

        

![GitHub top language](https://img.shields.io/github/languages/top/fytex/Shafa-CD?style=for-the-badge)

# What is Shafa?

**Shafa** is a free and open-source program made for Lossless files' compression written in C (2020/21).
It is OS independent and some modules are multithread executed if running on Windows or POSIX-compliant (allowing pthreads).

Uses two algorithms for compression:
- **RLE**
- **Shannon Fano** with blocks of length 1 (K=1).

For RLE's decompression a .freq file is needed along with the .rle file.
For Shannon Fano's decompression a .cod file is needed along with .shaf.
(All these files are generated by the program)

## Modules:
- F ( RLE compression and Frequencies calculation )
- T ( Codes calculation using Shannon-Fano's algorithm )
- C ( Shannon-Fano compression )
- D ( RLE and Shannon-Fano decompression )

#### SETUP - \*NIX
```
gcc -o shafa $(find ./src -name '*.c' -or -name '*.h') -O3 -Wno-format -pthread
```

#### SETUP - WINDOWS
```
gcc -o shafa src/*.c src/*.h src/*/*.c src/*/*.h src/*/*/*.c src/*/*/*.h -O3 -Wno-format
```

### How to execute?
Open terminal where the created executable `shafa` is located and type the following:

**Windows**:
- shafa.exe \ \

**\*NIX**:
- ./shafa \ \

### CLI Options:
-m : Executes respective module (Can be executed more than one module if possible)
-b : Blocks size for compression (default: K)
-c : Forces execution (r -> RLE's compress | f -> Original file's frequencies)
-d : Only executes a specific decompression (s -> Shannon-Fano's algorithm | r -> RLE's algorithm)
--no-multithread : Disables multithread


### Blocks Size:
- K = 640 KiB
- m = 8 MiB
- M = 64 MiB

**Note:** Multithread was only implemented in modules C and D (the ones that cost the most)