Cracking 500

It looks like the 2008 edition of FOSS4G (going on next week!) in Cape Town, South Africa is going to crack 500 attendees. This is a great showing for an event which has had to overcome substantial distance from the FOSS4G centers of gravity in North America and Europe. And, supporting the theme of “An Option for Developing Countries”, a large proportion of registrants are South African. So lots of folks will be learning about open source geo-spatial next week, and taking it back to their communities.

As usual, I am suffering non-buyers-remorse as an exciting event that I won’t be attending approaches. However, with the family so wee (1.5 and 4), going away for well over a week just isn’t on right now.

The Spirit of 2010

Don’t let the Winter Olympics in Vancouver steal all the thunder for 2010, make your own mark, by organizing FOSS4G, the 2010 edition!

Organizing an international conference is more fun than a barrel of spit and will mark you permanently, leaving you a quivering shell of a man it’s a great learning experience, too!

Intel IJG and Image Artefacts

I wrote previously about how using the Intel “Integrated Performance Primitives” (IPP) and the Intel compiler (ICC) helped to improve performance in a Mapserver raster rendering system by about 40%.

I was feeling pretty proud, until the client pointed out that the outputs, while fast were, um, sort of wrong:

What was going on here?!

Well, the problem looked to be in the JPEG writing, and Mapserver writes its JPEG via libgd by default, so I looked at the JPEG code in libgd for clues. There was little to find. LibJPEG is provides a very simple interface to writing out images, and the code in GD (gd_jpeg.c) was identical to the sample image compression code in the Intel IJG code base (cjpeg.c).

I only had two clues to go on: first, the artefacts would go away, if we created the JPEGs in a “progressive” (interlaced) mode; second, the Intel cjpeg utility could create correct JPEGs in non-interlaced mode.

After taking a brain-break of a couple days, I found the problem while grepping the code and watching TV. Setting up a JPEG compressor requires that you provide the compressor with a buffer-fill function of your own design, so you can provide input from all kinds of sources. The implementation of the buffer-fill routine in the Intel example code had a switch in it, that checked if the mode was progressive or not!

In the case of non-progressive JPEG, the Intel function would allow the compressor to only partially read the buffer if it wanted. Then it would move the un-read bytes to the front of the buffer, and fill in the rest with new bytes. The standard JPEG library expects the compressor to always read the full buffer.

Patching GD to use this partial buffer logic, and JPEG compression worked, I was getting what looked like good ouputs! So, I put the patch in place and told the client and, um, there were still problems:

Gah! The artefacts were smaller, but they were still there. However, having my previous solution in hand, it was easy to find this bug. The artefacts were in a nice blocky patterns, just like the internal TIFF tile structure, which pointed to the JPEG decompressor having the same buffer behavior as the compressor.

So this time I opened up the GDAL library (that Mapserver uses to read the TIFFs) and found the JPEG reading code in the TIFF driver. Sure enough, the Intel decompressor only partially read the buffer, while the standard decompressor was expected to read the whole thing every time.

A small patch to the GDAL TIFF driver, and another patch to the GDAL JPEG driver (for completeness) and now we finally had IPP-accellerated JPEG input and output without artefacts.

Moral of the story: Although the Intel IJG is API-compatible with the standard libjpeg, the slightly different expected behavior of the empty_output_buffer and fill_input_buffer functions means that most existing code will require slight modifications before it can use the Intel libraries – they cannot just be dropped into place as a binary-only update.

Chrome: Tit for Tat

I haven’t seen anyone explicitly say this yet, so I will do so:

Google Chrome is not a web browser, it just happens to be shaped like one. Chrome is Google’s entry into the web application platform wars, currently being waged by Adobe (FLEX) and Microsoft (Silverlight). The horse Google is backing is the (oft maligned) one currently in the lead, DOM/Javascript, Chrome is an attempt to ensure that DOM/Javascript doesn’t lose that lead for reasons of speed or stability.

Chrome + Gears can deliver stand-alone and web-enabled apps. Next out of the gate from Google, I expect some debugging / IDE tools to support DOM/Javascript development in Chrome, ala Firebug+.

What I did on my Summer Holidays

I “just got back” (actually, last week) from a week at the Alders Beach Resort, a lovely place about 200km north up Vancouver Island. The Alders isn’t so much a “resort” in the conventional sense (well, in the conventional sense of 50 years ago), but rather a collection of mildly run-down cabins, full of families and kids, located on a tidal beach, tucked into the woods, comfortably far from pretty much anything stressful.

I had lots of time on my hands, and one can only watch children play with sand for so long, before the mood strikes, so what I did with my holiday was try to figure out how to build sand sculptures.

The Alders has been around for 50 years, and there were people at the resort last week who had been going to 15 years straight, whose kids grew up there. It is going to be a family holiday staple for us, for many years to come.