Monthly Archives: October 2008

H.264 HRD simulator

It might be easier to read H.264 standard Annex C (Hypothetical Reference Decoder) compared to ISO/IEC 13818-2 Annex C (MPEG-2 VBV), but it’s quite difficult to understand why it’s defined in this way. What’s the purpose of initial_cpb_removal_delay_offset? I could … Continue reading

Posted in Video | 1 Comment

Windows Debugging with CDB / NTSD

I’m writing an article about Windows Debugging with CDB / NTSD. Here is the early draft version. Comments are welcome. Windows Debugging with CDB / NTSD

Posted in Advanced Debugging | Leave a comment

Win32 native monitor is much faster than boost

Windows Vista (finally!) introduced APIs to build a monitor object.http://msdn2.microsoft.com/en-us/library/ms683469.aspx So, how’s performance? Let’s benchmark it. I wrote two bounded FIFO classes. One was based on boost threading library (http://www.boost.org/doc/html/thread.html) and the other was based on the new Win32 APIs. … Continue reading

Posted in Optimization | 1 Comment

Non-alignment integer access performance

When you define a structure like this, the integer field is allocated not just after the byte field, but aligned to 4 byte boundary. struct foo{  unsigned char v1;  unsigned int v2;}; It’s because x86 architecture has a performance issue … Continue reading

Posted in Optimization | 2 Comments

Asynchronous Exception Handling

In Windows, you can catch an asynchronous exception (such as an access violation exception) with catch(…) clause. struct Foo {  ~Foo(){    // destructor  }}; try{   Foo foo;   *reinterpret_cast<char*>(0) = 0;}catch(…){    // handle access violation.} However, the behavior differs depends on … Continue reading

Posted in C++ | Leave a comment

std::string is not reference counted

After Visual C++ 6.0, Microsoft has changed the implementation of std::string to non-reference counted object due to threading issues. http://support.microsoft.com/kb/813810 If your in-loop functions take/return std::string object by value, it could be a cause of performance bottle neck. Here is … Continue reading

Posted in C++ | Leave a comment

Implicit null check in object instantiation

When an object with a vtable is instantiated, the vtable is constructed in the allocated buffer. So, what happens if the buffer allocation fails? In the case buffer allocation is done by default allocator, std::bad_alloc() is raised before vtable construction … Continue reading

Posted in C++ | Leave a comment

Why only integral const statics inside a class?

So, I wrote this and read D&E but still could not understand why. (Tell me where in D&E I can find the discussion.) Some google search, however,  unveiled the issue recently. http://groups.google.com/group/comp.std.c++/msg/0cbde331c9b8c28c?hl=en&amp; The cause seems to be a fact that … Continue reading

Posted in C++ | Leave a comment

Const static member is a compile time variable, somtimes

So, I said in-class static initializer is compile time constant. Except that it must be integral type. What surprised me recently is this is not valid C++. class Foo {  // ERROR: double is not an integral type  static const … Continue reading

Posted in C++ | Leave a comment

Tips for CreateProcess Win32 API function

The CreateProcess() Win32 API function is actually difficult to use. Don’t you think so? Read on. 1. Repeat an executable name in lpApplicationName and lpCommandLine.Otherwise OS may fail to separate an executable from the rest of command line when the … Continue reading

Posted in Tips | Leave a comment