Git Product home page Git Product logo

baseline-jpeg-decoder's Introduction

Baseline JPEG Decoder

This repo contains the code for decoding a baseline encoded, YCrCb image using Python. The code is modified from Raul Aguaviva's MIT licensed micro-jpeg-visualizer repo. I made some stuff more explicit for better understanding. This is highly unoptimized code so don't use it in any production project. I have written an article that explains this code-base in a step-by-step fashion. You can read it on my blog.

baseline-jpeg-decoder's People

Contributors

yasoob avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

baseline-jpeg-decoder's Issues

IndexError: list index out of range

Hello,

I've tried using your code with your original picture and it worked, but with other picture such as the one below, I get the following error :

Traceback (most recent call last):
File "...", line 363, in
img.decode()
File "...", line 350, in decode
len_chunk = self.StartOfScan(data, len_chunk)
File "...", line 290, in StartOfScan
st, 0, self.quant[self.quantMapping[0]], oldlumdccoeff
File "...", line 253, in BuildMatrix
code = self.huffman_tables[0 + idx].GetCode(st)
File "...", line 201, in GetCode
res = self.Find(st)
File "...", line 196, in Find
r = r[st.GetBit()]
IndexError: list index out of range

I've looked into it and it seems that when the error occurs, r is a list of size 1, st.GetBit() is 0, but the code still fails. So I've tried to force Find to return r[0] when r is of size 1, but then another error occurs

Traceback (most recent call last):
File "...", line 363, in
img.decode()
File "...", line 350, in decode
len_chunk = self.StartOfScan(data, len_chunk)
File "...", line 290, in StartOfScan
st, 0, self.quant[self.quantMapping[0]], oldlumdccoeff
File "...", line 260, in BuildMatrix
code = self.huffman_tables[16 + idx].GetCode(st)
File "...", line 201, in GetCode
res = self.Find(st)
File "...", line 196, in Find
r = r[st.GetBit()]
File "...", line 218, in GetBit
b = self.data[self.pos >> 3]
IndexError: list index out of range

Any idea why this occurs ? Thanks in advance !

cat

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.