CHDK: Canon PowerShot++

We were looking into supporting RAW images in our product, and purely by accident I bumped into CHDK (the name stands for Canon Hack Development Kit). It is a free firmware addon for Canon PowerShot cameras, enabling/adding many cool features, e.g. recording 10-bit/color RAW files (including experimental support for the open DNG standard), overriding camera parameters, bracketing for exposure, aperture, ISO, and focus, controlling video quality/bitrate, scripting, motion detection, live histogram, etc., etc., etc. Will definitely try it out as soon as will get some free time, but people are very excited about it. The risk is minimal, as it is not overriding the original firmware, but rather loading these extra goodies from the SD card.

Virtual PC Disk Resizer

VhdResize can resize Microsoft’s VHD files as well as convert between Fixed and Dynamic disks. It performs sector by sector copy operation, so the source file remains unaltered. It cannot resize partitions – for this task you will have to use Partition Magic or whatever other partitioning tools you are used to.

Windows: XP Embedded vs Embedded Standard

Just at this moment I am installing Windows Embedded Standard on Virtual PC 2007 SP1 with Windows XP Pro.

It was painful to start the installation! I have tried it a few times, but each and every time it failed complaining that it cannot register richtx32.ocx. Whatever I have tried brought me to the same result. Finally, after fair amount of googling, I found possible solution – to burn the ISO image to the DVD, and install it from this disk.

The only problem is, that it is installing more than 1 hour already, and I have no idea how much is still left – there is no total progress bar. On the other hand, when the ISO image was mounted, the installation process was going very fast (of course only till it was stucking at richtx32.ocx). I wonder, is it so difficult to make NORMAL installation these days? Is it difficult to make it so that your own products could install without problems on your own Virtual PC software (OMG, I still do not understand how the f#$k registration of the ocx can fail if disk is not burned, but rather mounted from ISO)? Why WES installer is trying to install IE7 and WMP11 if these applications are already installed? Rhetorical questions…

But the real question is – why did Microsoft “create” Windows Embedded Standard in the first place? It is obvious, that WES is based on XPE. Even more – it IS XPE! Tools have not changed much (not at all?). Components have references to XP in their descriptions and help. In fact, it seems that the only difference between XPE and WES is that there are some extra components (e.g. .NET 3.5) in WES that are not in XPE. Was it just for the sake of the “name unification”? Or to “separate” itself from XP? What was the real need to do this step? To confuse developers? I have no idea…

PS Now that I used real DVD disk, the installation completed without problems.

WPF Video Playback Problems

There is one severe problem with video playback in WPF/Silverlight that, for some reasons unknown to me, is getting very little (almost none) attention from both the community and Microsoft. Basically, it boils down to WPF being absolutely unable to properly play video content. Let me explain by using the following diagram:

WPF Video Playback Poblems

First line shows video frames as they are in the video content. Second line depicts variable frame rate of the WPF renderer – as you know, WPF is changing the frame rate dynamically, and CPU load will affect frame rate too. There are two possible outcomes:

  1. WPF is using vsync (version 1), i.e. it synchronizing rendering to the screen with the screen refresh frequency. This is what you will get on Vista, and sometimes on XP (normally XP video drivers are not using vsync). The resulting video shown on the screen will have variable duration of frames, and the viewer will be present with artifacts like skipped video frames, “jerky” playback, where motion is not “smooth”/uniform, etc.
  2. WPF is not using vsync (version 2). It is the case normally seen on XP. The resulting video is even worse, as there is the tearing effect present now – upper and lower parts of the displayed video frame are not matching. This problem is not present on some XP machines, e.g. I do not see it on my home PC, while it is present on 100% of other machines.

This is a bit oversimplified picture, but good enough for our purpose. In reality, the resulting on-screen picture will depend also on the screen refresh frequency, but artifacts will be more or less the same. In both cases the video playback it totally unacceptable though.

The issue is very serious, and, unfortunately, it is unsolvable in terms of today’s WPF. I think it will be not solved in the near future either, as solving it would require WPF to adopt constant-frame rate rendering paradigm, and synchronizing it with the display refresh rate. This is not likely to happen, as it is a drastic change to the fundamentals of WPF, and, at the same time, it will waste resources in non-video related applications (now WPF can decide what frame rate it will use, and can dynamically change it, e.g. dropping frame rate for “still” scenes and increasing it when animations start).

In our software we had to go through a lot of extra pain to “overcome” this issue – we render video using DirectShow by incorporating Win32 host into our WPF application and implement all kinds of “tricks” to allow WPF content to get into the video window airspace (to display OSD’s, menus, etc.) by using e.g. clipping regions (say Goodbye! to transparency though). There are a few third party projects out there (WPF MediaKit by Jeremiah Morrill is an excellent example) that allow one to mix DirectShow and WPF, but none of them will fix the above mentioned issues, as the resulting picture is rendered by WPF renderer and all the artifacts will be there still.

Probably, for majority of people this is not really an issue (at least until you point them to it; after that they can see it on their own and they become very annoyed), especially if you are playing some kind of home-made content from the YouTube (although YouTube has HD content nowadays too), but it is completely unacceptable for people at least somehow concerned about the video playback quality. DVD/DivX player costing $30 will not have these problems, so it is difficult to explain why $1000 machine (33 times more expensive!!!) cannot produce even remotely as good video playback on $2000 HD TV set.

In addition to these video playback problems, WPF on XP suffers from the tearing issue not only during video playback, but also during “normal” WPF animations. And this has even more profound effect, as it makes it impossible to implement animated WPF applications on XP.

Microsoft’s reaction to the tearing issue on XP is problematic. We have tried to approach them via all possible channels – Microsoft Connect program, Microsoft Metro program, newsgroups, personal contacts, everything. They either deny the issue, or say that it is unsolvable for XP in general case, so they are not going to solve it (but they could easily solve it for something like 95% of all XP installations by solving it at least for ATI and Nvidia cards), or they say that they will not solve it for XP anymore, as XP is not available so nobody cares. And this last reaction is problematic again, as the issue is present not only on Windows XP Home/Pro, but on Windows XP Embedded and Windows Embedded Standard as well. These OS’s will be around for some time still, and Windows 7 Embedded will not come before 2010 and, being Vista-based, will be a resource hog – something not necessarily good for embedded system.

Windows XP Embedded Resources

Microsoft Windows XP Embedded SP2 Resource Kit – quite useful collection of info about XPe. Despite it says SP2, it mentions Feature Pack 2007, so it is rather up to date. The only thing I wonder is why Microsoft did not release it earlier? :)

WindowsForDevices.com – is a site dedicated to Windows Embedded and has a lot of interesting information about the subject.

HORM Manager Pro for XP Embedded “enables easy system development as well as smooth handling of EWF and HORM under rough field conditions”. Lite version is available too – see an article about it (in a few words, it is a GUI for EWF and HORM APIs).

JavaFX

It seems that Sun can say now, “rumors about my death were greatly exaggerated”. Recently they rather quietly released JavaFX – a rich client platform (what has happened to thin client dreams of Sun and alike? huh? ;) for creating and delivering rich Internet experiences across “all the screens of your life” (they are using this phrase all over the place, and it sucks, to be honest, but go figure).

From what they show in their videos, it looks rather like WPF/Silverlight for Java. In other words, it is the presentation layer for the Java platform. Performance-wise it looks rather good (OK, no idea what hardware was running those demos). For example, they were playing 9 (yes, nine!) video streams simultaneously, but then, who the f#$k needs 9 videos playing at the same time!? It is the same f#$*%ng old useless BS that Microsoft is showing all the time! Of course, it remains to be seen if it can play all this video content without framerate issues that plaque WPF/Silverlight. JavaFX Script is a declarative scripting language behind JavaFX.

Sun is promising to make JavaFX multiplatform, capable of running on desktop, mobile, TV and other Java-enabled consumer platforms, but so far they have desktop version only. Then, as far as I understand, development tools are not necessarily ready yet (judging from their sentence “JavaFX technology will provide a suite of tools and authoring solutions that enable unprecedented collaboration between designers and developers”). If they will deliver all these promises, Microsoft might get into deep trouble with WPF, as Java’s inability to provide good UIs were one of the main reasons why many were choosing .NET over Java on the client side (I am not discussing platforms – .NET 3.5 vs Java 6 – just presentation parts). What Sun has already made right, in my opinion, is their selection of Adobe PhotoShop and Illustrator as a designer tools, as these are light-years ahead of Microsoft Expression Designer.

Future will show, what will come out of all this, but the good point is that Microsoft will get some competition in this field, and might eventually do something to fix its platform’s shortcoming (though unlikely – so far they are taking extremely defensive and ignorant stance regarding WPF/Silverlight problems).

.NET/WPF Obfuscators

We have recently purchased PreEmptive Solutions Dotfuscator (which sounded like a good idea when we were making decision about it), but to be honest I am not very happy about it: it cannot properly handle WPF projects and you have to perform a lot of “voo-doo dances” to get at least some protection there (and all that while costing s|-|1t-load of money). This pushed me to do a new round of evaluations of competing products, and I have found few that are really interesting:

  • .NET Reactor (about 150€) is a really powerful tool with lots of features (code and resource protection, code encryption, support for .NET 1.1, 2.0, 3.0, 3.5, CF 1.0 and 2.0, ASP.NET, Mono, can merge assemblies, remove IL code, generate native executables, etc., etc., etc.). Additionaly there is a licensing system, but I have not tried it yet. Despite it claims supporting .NET 3.5 I did not manage to protect our WPF assemblies with it, but all other assemblies were protected like a charm.
  • DeepSea Obfuscator (about 200€). This obfuscator’s list of features is not much shorter, but few outstanding points are support for WPF assemblies, and declarative obfuscation, where the obfuscation process can be controlled by applying obfuscation-related attributes to your code. I managed to protect our WPF assembly with it, but resulting assembly is crashing when I’m entering one specific screen. I guess this crash can be eliminated by using attribute-based obfuscation and removing some properties/classes from the protection process (which is not that good, to be honest, as it means extra work, howewer small it is).
  • {smartassembly} (about 350€-650€, depending on version) looks really impressive as well. It was able to protect WPF assembly and, it seems that the abovementioned crash is not present here; well, it is with certain settings related to obfuscation, but it can be easily eliminated by tweaking settings. Control flow obfuscation seems to be much stronger than that of the DeepSea, and there are some additional protection settings that make lives of Reflector, ILDASM and others really miserable (e.g. invalid metadata streams).

It seems that to get decent level of protection we will have to use either {smartassembly}, or both .NET Reactor and {smartassembly} (in case {smartassembly} would be not able to provide the same protection level for “normal”=non-WPF assemblies as .NET Reactor does – remains to be seen).