views:

582

answers:

2

I have a sequence of jpg images that I am capturing and rendering to the screen to create a video.

I am decompressing the image from a MemoryStream using a JpegBitmapDecoder and rendering it by setting the Source on an Image control. This seems to work okay, but the processor overhead is pretty high. The images are 1280x720, running at 30fps and I can just barely keep up on my computer ( Dual Core 2.8Ghz). Running at higher resolutions cause me to throw away frames. I would like to try to get the cpu utilization down.

Most of the time spent spent seems to be in the decoding (simple benchmarks of the decoding alone on my machine put show that I can decode about 40fps). Does anyone know if there is a faster decoder available (DirectX? DirectShow? Something I can offload to the video card?)

As for the rendering, it doesn't seem like the Image control is designed for this type of use (I was actually surprised it worked at all, i just tried it because it was easy to do). Is there another way to render the individual frames that might be faster?

+1  A: 

It sounds like you are both decoding and resizing the jpeg at the same time. The resizing can be expensive too. Try separating decoding and resizing (using the cheapest algorithm available) the jpegs. Use something like FreeImage with "JPEG_FAST" to decompress and "FILTER_BOX" to resize.

For display, TinyPTC is simple and fast. (a wrapper around DirectDraw) It is C, but it is pretty easy to write a wrapper for and compile to a dll you can reference.

R Ubben
Resizing is nice, but not necessary, most of the time I will be using the native resolution. I'll have to look at FreeImage to see if it decodes any faster.
Dolphin
JPEG_FAST definitely is faster (almost 50% faster in my simple benchmark), I will need to look at the quality on monday to see if it is acceptable.
Dolphin