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:
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)"
If you want output to be row-wise, input must be column-wise, that is, output is the transposed 2D-DCT of the input.
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).
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!
Hi Victor, glad core works for you. Answers to your questions:
(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.
Yes, that information is missing and will be added.
Good, if you find it is not good enough let me know. Maybe I can do something about it.
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
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. :)
please anyone fiix the link to download the project
https://opencores.org/project,mdct,overview
and thnks