Fixed DirectShow video capture issues

1. Several commits fixing DShow issues are ported from #3298 (already applied to 2.4 branch).
2. Code responsible for printing debug messages is refactored to reduce footprint in Release mode. Real printing functions are replaced with null-functions in this mode.