Baseline JPEG decoder written in C. The program parses JPEG metadata, extracts quantization and Huffman tables, decodes image data, applies inverse quantization and inverse DCT, and writes the decoded output as .pgm for grayscale images or .ppm for color images.
- JPEG header parsing.
- Quantization table extraction.
- Huffman table extraction and Huffman tree construction.
- MCU bitstream extraction and decoding.
- Inverse quantization.
- Inverse zig-zag ordering and inverse DCT.
- Chroma upsampling.
- YCbCr to RGB conversion for color images.
- PGM/PPM image generation.
This project was developed by a team of three students:
- DERGHAZI Ziyad
- SEGHYAR Moatassem
- EL HADARI Marouane
.
├── diagrams/ # Diagrams used to document internal structures
├── images/ # Sample JPEG files for testing
├── include/ # Header files
├── src/ # C source files
├── Makefile # Build automation
└── README.md
Generated files are ignored by Git:
jpeg2ppmobj/*.pgm*.ppmsrc/mcu_hex.txtsrc/mcu_bin.txt
make./jpeg2ppm images/zig-zag.jpgDepending on the input image, the decoder writes either:
images/<name>.pgmfor grayscale images.images/<name>.ppmfor color images.
make
./jpeg2ppm images/invader.jpeg
./jpeg2ppm images/zig-zag.jpgExpected generated outputs:
images/invader.pgmimages/zig-zag.ppm
- Parse JPEG markers and image metadata.
- Extract quantization tables.
- Extract Huffman tables and build decoding trees.
- Decode MCU blocks from the compressed bitstream.
- Apply inverse quantization.
- Reorder coefficients with inverse zig-zag.
- Apply inverse DCT.
- Upsample chroma components when needed.
- Convert YCbCr blocks to RGB for color images.
- Generate the final PGM or PPM image.
The diagrams/ directory contains diagrams documenting several internal data structures:





