See tutorial: https://www.aspires.cc/jpeg/
JPEG encoding process (Image to blocks - DCT - quantization - zigzagging - entropy encoding - encapsulation)
JPEG decoding process (decapsulation - entropy decoding - inverse zigzagging - inverse quantization - iDCT - blocks to image)