How estoiko/huffman-codec works
This repository implements huff, a command-line Huffman file archiver. The main workflow parses a mode and paths, opens binary streams, then dispatches to encoding or decoding. Encoding counts byte frequencies, builds codes, writes packed bits and a frequency header; decoding validates that header, rebuilds the tree, and restores symbols. The tree, code representation, bit-stream operators and queue are the main internal layer. Source excerpts show these core relationships; no README capabilities were available to verify.
Main entry points: Encoder.cpp Encode archive · Decoder.cpp Decode archive · HuffmanTree.cpp Huffman tree · main.cpp CLI and dispatch
Components 12
CLI and streams
- CLI and dispatch
src/main.cpp - Input/output files
Encoding
- Encode archive
src/Encoder.cpp - Frequency and header
src/Encoder.cpp
Decoding
- Decode archive
src/Decoder.cpp - Header validation
src/Decoder.cpp
Huffman internals
- Huffman tree
src/HuffmanTree.cpp - Code representation
src/HuffmanCode.h - Bit stream I/O
src/BitOperators.cpp - Priority queue
src/Queue.h - Error types
src/Exceptions.h
Other components
- User
Connections 16
- User → CLI and dispatch: invokes
src/main.cpp - CLI and dispatch → Input/output files: opens streams
src/main.cpp - CLI and dispatch → Encode archive: dispatches encode
src/main.cpp - CLI and dispatch → Decode archive: dispatches decode
src/main.cpp - Encode archive → Frequency and header: counts and writes
src/Encoder.cpp - Encode archive → Huffman tree: builds codes
src/Encoder.cpp - Encode archive → Bit stream I/O: writes bits
src/Encoder.cpp - Encode archive → Code representation: uses codes
src/Encoder.cpp - Decode archive → Header validation: extracts header
src/Decoder.cpp - Decode archive → Huffman tree: builds decode tree
src/Decoder.cpp - Decode archive → Bit stream I/O: reads bits
src/Decoder.cpp - Huffman tree → Priority queue: orders nodes
src/HuffmanTree.cpp - Huffman tree → Code representation: generates codes
src/HuffmanTree.cpp - Encode archive → Error types: throws errors
src/Encoder.cpp - Decode archive → Error types: throws errors
src/Decoder.cpp - Huffman tree → Error types: rejects empty input
src/HuffmanTree.cpp