OpenCores

Discrete Cosine Transform core

Issue List
Important details missing in docs #2
Closed galland opened this issue almost 16 years ago
galland commented almost 16 years ago

This core works very well, I've tested it thoroughly to implement it as part of a JPEG compressor. But there are some things which I consider very important but are missing in the documentation:

  1. The core does internally a level_shift (substract 128 from input). I don't think a DCT core should do level shift (i.e. MatLab's dct2 function doesn't). The code in DCT1D.vhd can be modified to avoid it by changing every "SIGNED('0' & dcti) - LEVEL_SHIFT" to "SIGNED(dcti(dcti'High) & dcti)"

  2. If you want output to be row-wise, input must be column-wise, that is, output is the transposed 2D-DCT of the input.

  3. I am going to try to see if the DCT is compliant with the JPEG standard in terms of calculation precision. To this moment, it looks fine (I've seen rounding errors of around abs(err)<3 in the 12 bit coefficients, not bad).

  4. This is said in the docs, but if you were wondering: yes, you can continuously feed data in to the core and get continuous output.

Great job and very readable code. Many thanks to the author!

mikel262 commented almost 16 years ago

Hi Victor, glad core works for you. Answers to your questions:

  1. (DC) level shift is necessary to have dynamic range symetrically distributed around zero. Otherwise, if you enter 8x8 block of unsigned data from 0-255 range, DC component output range could be few bits higher than accumulator can hold. For this purpose level shift is applied so that dynamic range stays within accumulator/output limits. A lot of technical papers on 2D DCT actually assume DCT level shifting is incorporated to calculation, but you are right - from purely mathematical point of view it is not. If I find some time it will be fixed, although at current time I am not sure if this could not create an overflow because of bit growth on DC component when unsigned pixels are feed through.

  2. Yes, that information is missing and will be added.

  3. Good, if you find it is not good enough let me know. Maybe I can do something about it.

  4. True. Core was designed with the intention to deliver maximum performance in terms that no wait-states shall be required ever.

Thank you for comments, Michal K

ocghost commented almost 16 years ago

Hi, I agree that a level shift is necessary before DCT, I just prefer to do it outside and I didn't know it was being done inside (it isn't said in the docs) until I browsed the source. The level shift I use takes advantage of another shift done during pixel conversion (from RGB to YCbCr), and the level shift becomes 112 instead of 128, so I do it before the DCT. :)

mikel262 closed this about 15 years ago
midoo commented about 7 years ago

please anyone fiix the link to download the project
https://opencores.org/project,mdct,overview and thnks


Assignee
No one
Labels
Idea