Giter Club home page Giter Club logo

ptjd's Introduction

PTJD

An abstract test image used for PTJD

A single-file pure Tcl baseline JPEG decoder library. Works in Tcl 8.5, Tcl 8.6 and Jim Tcl 0.75 and later.

Q & A

What is supported?

  • JPEG/JFIF and JPEG/Exif
  • Huffman coding
  • YCbCy (standard three-channel color) and grayscale
  • 8-bit color channels
  • Chroma subsampling (horizontal and vertical 4:2:2 subsampling and 4:2:0 subsampling has been tested)
  • Restart markers

What isn't?

  • Progressive and lossless encoding
  • Arithmetic coding
  • CMYK color
  • 12-bit color channels

Why?

To learn how to write a JPEG decoder.

What is it good for?

The decoder is far too slow to replace C-based JPEG decoders for Tcl for anything but the smallest images. However, it can be used as a benchmark to compare different Tcl implementations and different versions of the same implementation. (See below.) The code may help you understand JPEG compression. It is small (circa 700 lines), written in a functional style (the decoder consists of pure functions insofar as those exist in Tcl) and stores data in easy-to-inspect immutable data structures.

(If you want to understand how a JPEG decoder works, based on my own experience I recommend reading the Wikipedia article on JPEG and following the JPEG Huffman Coding Tutorial before anything else. If you don't know Tcl, Learn Tcl in Y Minutes should teach you enough to start reading the decoder's code. Tcl is pretty much a collection of independent commands; once you know the syntax you can look them up as you go along.)

What is the performance like?

The script benchmark.tcl can be used to evaluate the performance of the decoder by timing how long it takes to decode several test images included in this repository. Here are the sample results obtained by running the benchmark on an AMD Phenom II CPU.

Running in Tcl 8.5.19 (64-bit) on x86_64 Linux
5 iterations per image
==========================
grayscale.jpg        10 ms
landscape.jpg     19548 ms
landscape-q.jpg   11159 ms
63.6 MB
Running in Tcl 8.6.5 (64-bit) on x86_64 Linux
5 iterations per image
==========================
grayscale.jpg        10 ms
landscape.jpg     18758 ms
landscape-q.jpg   10587 ms
75.3 MB
Running in Jim 0.75 (64-bit) on x86_64 linux
5 iterations per image
==========================
grayscale.jpg        19 ms
landscape.jpg     38508 ms
landscape-q.jpg   22832 ms
88.8 MB

License

MIT.

test-data/landscape* photo by Maciej Wrona, licensed under CC0.

ptjd's People

Contributors

dbohdan avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.