2009-05-23

Colorful Epiphany

I always thought that the RGB macro (Win32 GDI) which takes three arguments - red, green and blue - will create a 0xRRGGBB value.

I was wrong! Win32 GDI uses BGR colors! d'oh

Here is another assertion on the path of assertiveness (germ. Durchsetzungsvermögen)

#include <windows.h>
#include <assert.h>

int main()
{
     COLORREF color_rgb = 0xBBAADD;
    
     assert(color_rgb == RGB(0xBB, 0xAA, 0xDD));
}

Cheers!

2009-05-12

Visual Studio 2008 Donation

I would like to thank Opera Software for the retail package of Visual Studio 2008 Standard Edition I just received!


Thank you!

2009-05-10

Thusneldastr

2009-03-11

DirectShow oggenc v0.1

I have created a DirectShow oggenc clone, mainly due to Ticket #1517 (How to calculate the OGG encoding complete percent correctly?). It is a Visual C++ console application which renders an audio file, removes the audio renderer and inserts a Vorbis encoder and an Ogg muxer filter.

The example also illustrates how to use the IVorbisEncodeSettings and IOggMuxProgress COM interfaces.

During the development of the tool I have found out a few quirks of the COM interfaces, all of which I will address in future oggcodecs releases.

The supported audio source file formats are: WAV, MP3, WMA. FLAC and OGG are not supported because I have used IMediaDet DirectShow interface, which is not supported by oggcodecs at this moment.

One can use another methods of determining the length of the audio source file (seeking at the end of the file and getting the position), which would enable support for FLAC and OGG.

Testing the tool showed that encoding a 4m50s audio wave file on Windows Vista 64bit took an average of 18.1 seconds for the 32bit version, while the 64bit version took on average 13.1 seconds, a speed improvement of ~27%.

Source code can be found here, binaries can be found here (32 bit) and here (64 bit).

2009-02-23

Windows 7

Today while doing a bit of research regarding https://trac.xiph.org/ticket/1498
I found out another limitation of the default audio renderer in DirectShow.

The DirectSound audio renderer cannot play 192KHz, 24 bit audio samples. This behaviour was present on Windows XP SP3 and Windows Vista SP1.

To my surprise Windows 7 (build 7000) doesn't have this limitation, Windows Media Player 12 was able to play the 192Khz 24bit sample FLAC file from Linn Records

Windows Media Player 12 also knows about Ogg Vorbis metadata, which came as a surprise as well.

If somebody will ask me why he/she should upgrade to Windows 7 now I now what to answer :)

2009-01-21

Mono 2.2

Recently Mono 2.2 was released. It has a bunch of new stuff, one of them is: SIMD (Single Instruction, Multiple Data) support in Mono.

Miguel de Icaza has a blog entry where he describes the new SIMD support in Mono. He has ported to C# a C++ application, to illustrate the new SIMD stuff, and then he compares the results, the C++ program was rather slow. I had a look at the source code an I've seen that the C++ program was compiled in debug mode.

I've decided to make a few tests for myself. I've used MinGW 4.3.2 and Visual Studio 2005, the tests where run on my Intel Mobile Core 2 Duo T7500.

Here are the results (in seconds):



The parameters for the above results were:



Mono is not quite there yet (at least on Windows).

I had to change the timing code for the C++ code, glib::GTimer is not a very good option on Windows. I've used the high-resolution performance counter, the code is presented below:


#ifndef PERFTIMER_H
#define PERFTIMER_H

#include <windows.h>
#include <string>

#include <iostream>
#include <iomanip>
#include <sstream>

class PerfTimer
{
     LARGE_INTEGER start_;

     LARGE_INTEGER stop_;
     LARGE_INTEGER freq_;
   public:
    
     PerfTimer()
     {
       QueryPerformanceFrequency(&freq_);
     }

    
     void Start()
     {
       QueryPerformanceCounter(&start_);
     }
    
     void Stop()

     {
       QueryPerformanceCounter(&stop_);
     }
    
     std::string ToString()
     {
       const int precision = 10000000;

       unsigned long time = static_cast<unsigned long>(
     (stop_.QuadPart - start_.QuadPart) * precision /
     freq_.QuadPart);
      
       std::ostringstream os;

       os << std::setfill('0');
       os << std::setw(2) << time / precision / 3600 << ":";
       os << std::setw(2) << time / precision % 3600 / 60 << ":";

       os << std::setw(2) << time / precision % 60 << ".";
       os << std::setw(7) << time % precision;
       os << std::setfill(' ');

      
       return os.str();
     }
};

#if 0
int main()
{
   PerfTimer timer;
   timer.Start();

   Sleep(1250);
   timer.Stop();
  
   std::cout << "Time: " << timer.ToString() << std::endl;
  
   return 0;
}

#endif

#endif // PERFTIMER_H




There are a few things I would like to point out about the Mono 2.2 Windows installer.

1. The executable is not digitally signed by Novell.



2. The graphics are hideous, 16 colors dithering? why? Is anybody in their right mind running Windows in 16 colors?


2009-01-18

Windows CE

I've been busy with the port to Windows CE of libogg, libvorbis, libflac. This is only the beginning, there is still allot of work remaining.

Also I've done a bit of restructuring, I've reduced the number of binaries from 30 to 20, by changing from dynamic link libraries to static libraries. I've changed the usage of the CRT, from dynamic to static linking, this has increased the size of the binaries but overall the installer has the same size, thanks to LZMA solid compression :-)

The above changes will ease the usage of the libraries, for example only dsfOggDemux2.dll dsfVorbisDecoder.dll are needed for Vorbis decoding.

I have created my first Windows CE "Hello World" program. I've wanted for a long time to do that. I've learned that Windows CE has only Unicode support, no more multi byte nightmare.

Because you don't have a console attached the classical "Hello World" is a bit different, a bit WIN32 APIsh:


#include <windows.h>

int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nShowCmd )
{
    
wchar_t message[] = L"Goodbye cruel adventure world!";
    
wchar_t caption[] = L"Monkeys are listening";

    ::
MessageBox(0, message, caption, MB_OK | MB_ICONINFORMATION);
    
    
return 0;
}



If you try to run an executable which is not digitally signed, you are being prompted by the operating system telling you that it's dangerous to run "unknown" software.

Since I have a certificate from CERTUM I have signed the executable, but still the prompt was there. The problem was that my telephone doesn't have the root certificate from CERTUM installed. I've went to CERTUM's root certificate page and taken the "Public Key of Certum Level II", installed it and my program ran without any prompts from the operating system.

And now the mandatory "screen shot":