sh0dan // VoxPod

Thursday, February 12, 2009

Introducing RawSpeed

I have spent quite a lot of my spare time in the last two months creating a file loader for RAW files. My primary motivation, beside general interest was, that I was frustrated there wasn't any fast open source loaders out there.

So my main objectives were to make a very fast loader that worked for 75% of the cameras out there, and was able to decode a RAW file at close to the optimal speed. The last 25% of the cameras out there could be serviced by a more generic loader, or convert their images to DNG - which as a sidenote usually compresses better than your camera.

So far, I have support of the latest cameras from Canon, Nikon, Sony, Pentax and Olympus, besides DNG support. I plan to add Panasonic cameras to the mix, but that's about it. RawSpeed has been integrated into the upcoming version of Rawstudio, which is being maintained by my friend Anders Brander.

My natural choice of language was C++, and while I considered adding assembler, I haven't seem any obvious spots where it would help more than a few percent. That would also make it fairly easy to port, as a side-bonus. My C++ style is "object-oriented C", with carefully chosen STL use, inspired by AviSynth, so I knew it wouldn't hinder performance much.

Compared to other raw decoders out there, I decided from the start to completely forego file streams. The image must be fully loaded into memory before decoding can start. This would first of all avoid many system calls, non-serial IO, and futhermore makes it possible to have threaded IO and decoding, by having an IO thread.

I feel like I must mention the inspiration. Obviously the closest relative is libopenraw. It seems like a nice project. I considered contributing to the project, but since I had already made a TIFF parser, and making it "streamless" would make it almost a complete rewrite, I decided I might as well write my own. At least then I cannot blame bugs on other people.

The other wellknown project out there is Dave Coffin's dcraw. David has put an incredible amount of work into reverse-engineering the strangest formats out there and creating a solid application that works for jsut about any camera out there. While he has a radically different coding style than most of what you find out there, the amount of work and dedication put into this project is very admirably.

So far the only thing you can see it the Subversion repository, but I will make a formal release, when the time is right. If you want to follow the development, you can subscribe to the rawstudio commit mailing list, where my updates are also posted.

That's it for now. Next time I hope to be able to tell you a bit about what the library actually contains.