Current version

v1.10.4 (stable)

Navigation

Main page
Archived news
Downloads
Documentation
   Capture
   Compiling
   Processing
   Crashes
Features
Filters
Plugin SDK
Knowledge base
Donate
Contact info
Forum
 
Other projects
   Altirra

Search

Archives

01 Dec - 31 Dec 2013
01 Oct - 31 Oct 2013
01 Aug - 31 Aug 2013
01 May - 31 May 2013
01 Mar - 31 Mar 2013
01 Feb - 29 Feb 2013
01 Dec - 31 Dec 2012
01 Nov - 30 Nov 2012
01 Oct - 31 Oct 2012
01 Sep - 30 Sep 2012
01 Aug - 31 Aug 2012
01 June - 30 June 2012
01 May - 31 May 2012
01 Apr - 30 Apr 2012
01 Dec - 31 Dec 2011
01 Nov - 30 Nov 2011
01 Oct - 31 Oct 2011
01 Sep - 30 Sep 2011
01 Aug - 31 Aug 2011
01 Jul - 31 Jul 2011
01 June - 30 June 2011
01 May - 31 May 2011
01 Apr - 30 Apr 2011
01 Mar - 31 Mar 2011
01 Feb - 29 Feb 2011
01 Jan - 31 Jan 2011
01 Dec - 31 Dec 2010
01 Nov - 30 Nov 2010
01 Oct - 31 Oct 2010
01 Sep - 30 Sep 2010
01 Aug - 31 Aug 2010
01 Jul - 31 Jul 2010
01 June - 30 June 2010
01 May - 31 May 2010
01 Apr - 30 Apr 2010
01 Mar - 31 Mar 2010
01 Feb - 29 Feb 2010
01 Jan - 31 Jan 2010
01 Dec - 31 Dec 2009
01 Nov - 30 Nov 2009
01 Oct - 31 Oct 2009
01 Sep - 30 Sep 2009
01 Aug - 31 Aug 2009
01 Jul - 31 Jul 2009
01 June - 30 June 2009
01 May - 31 May 2009
01 Apr - 30 Apr 2009
01 Mar - 31 Mar 2009
01 Feb - 29 Feb 2009
01 Jan - 31 Jan 2009
01 Dec - 31 Dec 2008
01 Nov - 30 Nov 2008
01 Oct - 31 Oct 2008
01 Sep - 30 Sep 2008
01 Aug - 31 Aug 2008
01 Jul - 31 Jul 2008
01 June - 30 June 2008
01 May - 31 May 2008
01 Apr - 30 Apr 2008
01 Mar - 31 Mar 2008
01 Feb - 29 Feb 2008
01 Jan - 31 Jan 2008
01 Dec - 31 Dec 2007
01 Nov - 30 Nov 2007
01 Oct - 31 Oct 2007
01 Sep - 30 Sep 2007
01 Aug - 31 Aug 2007
01 Jul - 31 Jul 2007
01 June - 30 June 2007
01 May - 31 May 2007
01 Apr - 30 Apr 2007
01 Mar - 31 Mar 2007
01 Feb - 29 Feb 2007
01 Jan - 31 Jan 2007
01 Dec - 31 Dec 2006
01 Nov - 30 Nov 2006
01 Oct - 31 Oct 2006
01 Sep - 30 Sep 2006
01 Aug - 31 Aug 2006
01 Jul - 31 Jul 2006
01 June - 30 June 2006
01 May - 31 May 2006
01 Apr - 30 Apr 2006
01 Mar - 31 Mar 2006
01 Feb - 29 Feb 2006
01 Jan - 31 Jan 2006
01 Dec - 31 Dec 2005
01 Nov - 30 Nov 2005
01 Oct - 31 Oct 2005
01 Sep - 30 Sep 2005
01 Aug - 31 Aug 2005
01 Jul - 31 Jul 2005
01 June - 30 June 2005
01 May - 31 May 2005
01 Apr - 30 Apr 2005
01 Mar - 31 Mar 2005
01 Feb - 29 Feb 2005
01 Jan - 31 Jan 2005
01 Dec - 31 Dec 2004
01 Nov - 30 Nov 2004
01 Oct - 31 Oct 2004
01 Sep - 30 Sep 2004
01 Aug - 31 Aug 2004

Stuff

Powered by Pivot  
XML: RSS feed 
XML: Atom feed 

§ AMD64 and frustrations of an assembly language programmer

I recently discovered a bug in current versions of VirtualDub that manifests itself as occasionally massive audio sync errors when working with large frame start offsets, at least frame 60000 or so. It is caused by an overflow in the fraction scaling routines, which are used to compute the audio offset since AVI sample rates are 32:32 rational fractions. Whether or not you hit this bug depends on how reduced the fraction is in the AVI file; most files have small numbers here and thus the bug requires a very large frame offset, but it is rarely possible to encounter it in a 1hr+ file if you have a really large or unnormalized fraction. This is being fixed for the future 1.6.6 version by adding 96-bit intermediate arithmetic. What is annoying, however, is that the lack of both sufficient intrinsics and inline assembly support in the AMD64 compiler forces a rather silly assembly language function:

VDFractionScale64 proc public
    mov  rax, rcx
    mul  rdx
    div  r8
    mov  [r9], edx
    ret
VDFractionScale64 endp

For some reason, the VS2005 compiler for AMD64 has intrinsics to do 128-bit multiply and shift operations, but no add, subtract, or divide operations. Gee, thanks.

On the good side, the AMD64-compatible version of the Platform SDK is out for public download!

http://www.microsoft.com/downloads/details.aspx?FamilyID=d8eecd75-1fc4-49e5-bc66-9da2b03d9b92&DisplayLang=en

What's in the Platform SDK for AMD64

First of all, the Windows Server 2003 SP1 SDK does include the optimizing x64 compiler. It is version 14.00.40310.41, which is much newer than the DDK compiler; however, it appears to be older than the Visual Studio 2005 Beta 1 compiler, which is build 14.00.40607.16. The beta 1 compiler was rather stable and expect the PSDK compiler to be the same. 64-bit MASM (ML64) is also included (yay!), and of course, LINK. DUMPBIN is not included, but this is just an alias for LINK /DUMP anyway, and even if that weren't the case, surprisingly the VC7.1 DUMPBIN is capable of disassembling AMD64 object files. Sadly, NMAKE is not included. Can't give away everything, I suppose.

Far more interesting, though, is a little file in the Bin\win64\x86\AMD64 directory called "SWConventions.doc." This documents the Application Binary Interface (ABI) for x64 Windows, and is finally a real specification, not a handful of scattered pages stuck deep in MSDN Library. (Try reading the docs for Structured Exception Handling in the Core SDK sometime; they're a sad joke.) Among the interesting parts of this document, relative to the previously available kernel ABI docs:

It's too late to do so tonight, but I hope to compile 64-bit VirtualDub on the new PSDK tomorrow. The DDK includes and compiler are somewhat scrambled and it'd be nice to back out some of the hacks.

Comments

Comments posted:


Any chance scene change detection could make it into the new build?

Andrew Dunstan - 28 04 05 - 10:57


Yup, scene detection will work on AMD64 in 1.6.6. I wasn't planning on doing this, but after you asked I took a look and discovered that (1) the asm code was Pentium-optimized scalar, not MMX as I had thought; and 2) the 16-bit RGB case was completely and utterly busted on x86. So I'm fixing the 16-bit RGB x86 routine and adding C++ versions for AMD64.

Phaeron - 29 04 05 - 02:46


Thanks. I never realized how much I used those buttons until they stopped working.

Andrew Dunstan - 30 04 05 - 02:10


I'm just excited that this project has finally moved onto the x64 platform. Converting DV files to DivX with 2 passes just takes too dang long (25 minutes takes 2 hours), and this is just with Standard DivX speed. Don't talk to me about slow.

Yuusharo (link) - 11 05 05 - 07:35


"Tentatively, all functions must begin with an instruction that is at least two bytes, and have at least six bytes of unused space available before them. If the function is a nested function that begins with a PUSH, the instruction must be the two byte (modrm) form, and if it is a leaf function, a NOP must be used. The reason for this is so that the first instruction can safely be hot-patched by a short jump backwards to a long jump, which in turn jumps to a replacement function. This is really cool, as hotpatching in this manner is tougher and unsafe on x86, due to the possibility of a function starting with a one-byte instruction followed by another one-byte instruction that is a branch target."
That, BTW, have been ported back to x86 with Windows Server 2003 SP1. See the /hotpatch Visual C++ compiler option.

Yuhong Bao - 09 02 08 - 17:55

Comment form


Please keep comments on-topic for this entry. If you have unrelated comments about VirtualDub, the forum is a better place to post them.
Name:  
Remember personal info?

Email (Optional):
Your email address is only revealed to the blog owner and is not shown to the public.
URL (Optional):
Comment: /

An authentication dialog may appear when you click Post Comment. Simply type in "post" as the user and "now" as the password. I have had to do this to stop automated comment spam.



Small print: All html tags except <b> and <i> will be removed from your comment. You can make links by just typing the url or mail-address.