Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JPEG Decoder in C

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.

Features

  • 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.

Project Context

This project was developed by a team of three students:

  • DERGHAZI Ziyad
  • SEGHYAR Moatassem
  • EL HADARI Marouane

Project Structure

.
├── 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:

  • jpeg2ppm
  • obj/
  • *.pgm
  • *.ppm
  • src/mcu_hex.txt
  • src/mcu_bin.txt

Build

make

Run

./jpeg2ppm images/zig-zag.jpg

Depending on the input image, the decoder writes either:

  • images/<name>.pgm for grayscale images.
  • images/<name>.ppm for color images.

Examples

make
./jpeg2ppm images/invader.jpeg
./jpeg2ppm images/zig-zag.jpg

Expected generated outputs:

  • images/invader.pgm
  • images/zig-zag.ppm

Internal Processing

  1. Parse JPEG markers and image metadata.
  2. Extract quantization tables.
  3. Extract Huffman tables and build decoding trees.
  4. Decode MCU blocks from the compressed bitstream.
  5. Apply inverse quantization.
  6. Reorder coefficients with inverse zig-zag.
  7. Apply inverse DCT.
  8. Upsample chroma components when needed.
  9. Convert YCbCr blocks to RGB for color images.
  10. Generate the final PGM or PPM image.

Diagrams

The diagrams/ directory contains diagrams documenting several internal data structures:

  • extract_image_info

  • extract_quant_tables

  • HuffmanTable and HuffmanCode

  • extract_huffman_info

  • build_huffman_tree

  • extract_huff_idx

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages