Log in

View Full Version : Help compiling avs2avi Wrapper Codec for x64


Malow
26th July 2016, 15:23
hi, I'm trying to compile this excellent wrapper for avisynth, (it create a fake AVI pointing to the script, and use a codec do serve to programs)

it was developed a while ago by Eugene Bujak, and looks like was abandoned.

it worked great in all my tests (better than any other) but there's no x64 codec for decoding the AVI file (video editing and encoders i have are now x64)

here are the files/sources:
https://hmage.net/files.html

the problem is, there an include "codecinst.h" that uses "__asm", and while trying to compile for x64, the compiler says __asm is not supported (using Microsoft Visual C++ Build Tools)

extern "C" {
LRESULT PASCAL DriverProc(DWORD dwDriverID, HDRVR hDriver, UINT uiMessage, LPARAM lParam1, LPARAM lParam2);

inline void mem2(void *dst, void *src, int nbytes)
{
#ifdef _MSC_VER
__asm {
mov esi, src
mov edi, dst
mov ecx, nbytes
shr ecx, 6 // 64 bytes per iteration

loop1:
movq mm1, 0[ESI] // Read in source data
movq mm2, 8[ESI]
movq mm3, 16[ESI]
movq mm4, 24[ESI]
movq mm5, 32[ESI]
movq mm6, 40[ESI]
movq mm7, 48[ESI]
movq mm0, 56[ESI]

movntq 0[EDI], mm1 // Non-temporal stores
movntq 8[EDI], mm2
movntq 16[EDI], mm3
movntq 24[EDI], mm4
movntq 32[EDI], mm5
movntq 40[EDI], mm6
movntq 48[EDI], mm7
movntq 56[EDI], mm0

add esi, 64
add edi, 64
dec ecx
jnz loop1

emms
}
#else
memcpy(dst,src,nbytes);
#endif
}
}

apparently, the codec is based on Huffyuv code.

as i am no programmer, any help appreciated. :o

LoRd_MuldeR
26th July 2016, 18:45
The Microsoft compiler does not support inline assembly in 64-Bit mode. You have to re-write the code to use intrinsics or use something like NASM/YASM (or disable the assembly).

See here:
https://msdn.microsoft.com/en-us/library/wbk4z78b.aspx

Malow
26th July 2016, 21:29
sheeet... well, that beyond my wildest capabilities..

will try to contact the original coder if he can help me... :(

thanks for the help LoRd_MuldeR! ;)

Groucho2004
26th July 2016, 22:12
sheeet... well, that beyond my wildest capabilities..

will try to contact the original coder if he can help me... :(

thanks for the help LoRd_MuldeR! ;)
All that inline asm block does is a fast memcpy. Nowadays with modern compilers this is not necessary, the simple memcpy is fast enough. This should work fine:
extern "C" {
LRESULT PASCAL DriverProc(DWORD dwDriverID, HDRVR hDriver, UINT uiMessage, LPARAM lParam1, LPARAM lParam2);

inline void mem2(void *dst, void *src, int nbytes)
{
memcpy(dst,src,nbytes);
}
}


There will probably be other caveats porting the code to 64 bit though, especially considering the time it was written.

Malow
27th July 2016, 03:08
yes, it fixed one problem, but there are a bunch of other errors now (even trying to compile in x86)

well, i guess I will stay with what i know. this was an "uncharted waters" attempt for me ;)

thanks again guys ;)