MATH: Discrete Cosine Transform for JPEG in pasm
tonyp12
Posts: 1,951
Using just integer math,
the hardest part in JPEG encoding/decoding seems to be the DCT part.
Pdf file explaining how DCT is used in jpg
http://www.naic.edu/~phil/hardware/nvidia/doc/src/dct8x8/doc/dct8x8.pdf
Using 16bit integer Cuda source code should help to create a pasm version.
http://code.google.com/p/gpuocelot/source/browse/trunk/tests/cuda2.2/tests/dct8x8/dct8x8_kernel_short.cu?r=412
Any math person up to the challange to create 2D-DCT for the prop.
Taking picture with a cmos cam and saving to to SD card as jpg's using a prop!
the hardest part in JPEG encoding/decoding seems to be the DCT part.
Pdf file explaining how DCT is used in jpg
http://www.naic.edu/~phil/hardware/nvidia/doc/src/dct8x8/doc/dct8x8.pdf
Using 16bit integer Cuda source code should help to create a pasm version.
http://code.google.com/p/gpuocelot/source/browse/trunk/tests/cuda2.2/tests/dct8x8/dct8x8_kernel_short.cu?r=412
Any math person up to the challange to create 2D-DCT for the prop.
Taking picture with a cmos cam and saving to to SD card as jpg's using a prop!
Comments
Would be happy to see someone do it though.
Yes, it was slow, and written in Spin, but I don't see why it couldn't be converted to PASM / lmm without too much effort.
I've not done an encoder yet, though, as I never thought it would be of use on a prop, when we have PC's that can convert BMPs TGAs PNGs etc to JPG's a lot faster.
That's a neat trick Baggers. It would be cool to use that with my serial camera. I've been using uncompressed mode, but JPG mode would be a lot faster. There is a 160x128 preview mode...
Did you ever post that code?
But, I could do, I'll dig it out, and post.
A simple low-res JPEG decoder could be implemented for the Prop I just by decoding and displaying the DC component of the image. The JPEG algorithm works on smal 8x8 blocks of data at a time. The DC component is just the average value of an 8x8 block. A 1280x1024 consists of an array of 160x128 blocks. A 160x128 version of the image could be displayed just by decoding the DC coefficients. This would not require implementing the DCT.
Just noticed davehein1 said 8x8 blocks... even better...
There is also an unpublished 320x240 8-bit color per pixel driver with sprites, VGA timing
I also have an unfinished 400x300 8-bit color driver, SVGA timing
Using Floyd-Steinberg dithering to get more "effective" colors JPEG's should look decent
It can be done using a single prop, including having the display driver, albeit low res.
Jpeg goes through a couple of stages to get such good compression.
http://www.impulseadventure.com/photo/jpeg-compression.html
@Baggers, I'm looking forward to seeing your code. What algorithm did you use for the DCT? Was it a matrix multiply or a fast butterfly algorithm?
@Tony, the JPEG encoder could get by with as little as a single 8x8 memory. This would require random access of the image file to extract each 8x8 block. It would be better to have 3 8-line buffers, one for each color component. For an image with 1024 pixel across, that would be 24 Kbytes of line buffers. This assumes you use 4:4:4 or 4:2:2 sampling.
4:4:4 means that the chroma components are at the same resolution as lume. 4:2:2 would use half the resolution horizontally for chroma. Another common mode is 4:2:0, which uses half the resolution for chroma in both the verticle and horizontal directions. This would require a 16-line buffer for luma.
Why monochrome? The attached image is 192x160 standard Propeller colors.
The monochrome example was just for a point of reference. And I think the picture answers your own question. The dithering error is quite obvious in that picture.
I only mentioned sprites as that driver has them - I had no intention of using them for large images
Unfortunately the Prop is not up to 640x480x24bpp without a lot of extra hardware
About Prop 1 - the real problem is not enough bandwidth & pins to refresh a 640x480x24bpp display; adding enough memory is not a problem.
Prop 2 will have more than enough bandwidth & pins, and it will be possible to use nice cheap SDRAM's with it.
Can't wait
Ouch. I thought it looked OK, considering.
I may at some point be able to generate and excuse to do this at work but at the moment there is no chance.
Graham