digitalFAQ.com Forums [Archives]

digitalFAQ.com Forums [Archives] (http://www.digitalfaq.com/archives/)
-   Avisynth Scripting (http://www.digitalfaq.com/archives/avisynth/)
-   -   Delphi: Pascal conversion of avisynth_c.h (http://www.digitalfaq.com/archives/avisynth/13810-delphi-pascal-conversion.html)

GFR 09-15-2005 11:24 AM

Delphi: Pascal conversion of avisynth_c.h
 
http://forum.doom9.org/showthread.php?t=98327

Now we can code avisynth filters in Delphi :)

kwag 09-15-2005 07:24 PM

Re: Pascal conversion of avisynth_c.h
 
Quote:

Originally Posted by GFR
Now we can code avisynth filters in Delphi :)

What about speed :?:
Delphi (Pascal, yuck!) binaries are slower than MSC or even GCC :roll:
So filtering wll take a performance hit.

-kwag

incredible 09-16-2005 05:42 AM

Vhelp in that "Pascal avisynth headers" thread at Doom9 did insist on that delphi gots almost the speed of c++. Ok, this "could" be archived on some processes but ... I dont agree if seen as general.
Delphi, PureBasic, VB etc. are cool for a comfortable programming. But the c++ compilers AFAIK are much more developed to output a very good optimized asm code. Thats why much routines written natively in c++ are fast enough where such ones in other Languages have to be implementated as ASM included lines.
(Look at the post of SansGrip in the c++ Section related to Delphi.) :)

But anyhow .... its very useful and good work of the one who ported that avisynth header code.

OT/
@ Karl
Do look out for PureBasic Optimizer as its an executable which will be exchanged with the original one of puebasic. It catches the code when strating compiling, then it does optimize the asm code generation and serves it back to the next processes within the whole compiling process.

GFR 09-16-2005 06:37 AM

Well, you can always use inline assembly, register variables, obfuscated pointer arithmetic and the like if you want to speed up your Pascal code. It just won't look like Pascal anymore :) I mean, if you can speak English and think, you can look at Pascal code and understand what's happening.

Also, I have not measured it, but my impression as a user is that Delphi apps with VCL are not slower than Visual C with MFC by any means (not important for the avisynth filters, though).

Even if the speed is not optimized, being able to use other compilers instead of MS Visual C, that is not free, is a nightmarte to use, and makes a mess when installed in your PC, is a positive thing IMO. I think the avisynth_c.dll lets you use other languages that can call a dll, like "normal" C (not M$VC). Delphi has a free edition, there's FreePascal, and then there's the various free C compilers you can use (I like Dev-C++).

Besides, while professional programmers may like C++ better, that's not the case with scientists. I work in a research center and many people here code in fortran :!: or in Matlab. Making avisynth available in more friendly (and free) platforms may be a nice way to get new, state of the art, image processing algorithms as avisynth filters. If these prove nice and are open source (if you use the free edition of Delphi, they have to be) some C++ geek can port them later :)

And finally, Pascal is not slow. Java is. :lol:

GFR 09-16-2005 09:44 AM

Do not use avisynth_c.dll from avisynth_c-01x.zip - Delphi built plugins crash. Use the one from avisynth_c-stdcall.zip.

I tried the invert.dll that comes with avisynth_c-015.zip, and built a invert.dll in Delphi 7, and then compared to the internal filter Invert() using kassandros AVSTimer.

#LoadCPlugin("c:\downloads\plugins\invert.dll")
AviSource("c:\trailer.avi")
ConvertToYUY2()
AvsTimer(frames=100, name="load",quiet=true)
Invert()
AvsTimer(frames=100, name="invert",difference=1)

[2000] [97] invert = 1248 fps
[2000] [197] invert = 4993 fps
[2000] [297] invert = 1427 fps
[2000] [397] invert = 908 fps
[2000] [497] invert = 476 fps
[2000] [597] invert = 9986 fps
[2000] [697] invert = 4993 fps

LoadCPlugin("c:\downloads\plugins\invert.dll")
# C built dll
AviSource("c:\trailer.avi")
ConvertToYUY2()
AvsTimer(frames=100, name="load",quiet=true)
Invert()
AvsTimer(frames=100, name="invert",difference=1)


[912] [97] invertc = 161 fps
[912] [197] invertc = 192 fps
[912] [297] invertc = 227 fps
[912] [397] invertc = 182 fps
[912] [497] invertc = 227 fps
[912] [597] invertc = 232 fps
[912] [697] invertc = 196 fps

LoadCPlugin("c:\downloads\plugins\invert.dll")
# C built dll
AviSource("c:\trailer.avi")
ConvertToYUY2()
AvsTimer(frames=100, name="load",quiet=true)
InvertInPlace()
AvsTimer(frames=100, name="invert",difference=1)


[912] [99] invertcinplace = 204 fps
[912] [199] invertcinplace = 182 fps
[912] [299] invertcinplace = 182 fps
[912] [399] invertcinplace = 238 fps
[912] [499] invertcinplace = 212 fps
[912] [599] invertcinplace = 200 fps
[912] [699] invertcinplace = 227 fps

LoadCPlugin("c:\downloads\plugins\invert.dll")
# Delphi built dll
AviSource("c:\trailer.avi")
ConvertToYUY2()
AvsTimer(frames=100, name="load",quiet=true)
Invert()
AvsTimer(frames=100, name="invert",difference=1)

[912] [98] invertdelphi = 154 fps
[912] [198] invertdelphi = 196 fps
[912] [298] invertdelphi = 250 fps
[912] [398] invertdelphi = 244 fps
[912] [498] invertdelphi = 227 fps
[912] [598] invertdelphi = 212 fps
[912] [698] invertdelphi = 208 fps

LoadCPlugin("c:\downloads\plugins\invert.dll")
# Delphi built dll
AviSource("c:\trailer.avi")
ConvertToYUY2()
AvsTimer(frames=100, name="load",quiet=true)
InvertInPlace()
AvsTimer(frames=100, name="invert",difference=1)

[912] [97] invertdelphiinplace = 169 fps
[912] [197] invertdelphiinplace = 188 fps
[912] [297] invertdelphiinplace = 204 fps
[912] [397] invertdelphiinplace = 212 fps
[912] [497] invertdelphiinplace = 185 fps
[912] [597] invertdelphiinplace = 256 fps
[912] [697] invertdelphiinplace = 244 fps

This is on a PIII-866Mhz, 256M, Win2K, Avisynth 2.55.

As you can see there's a huge difference between the internal filter and the external ones, but the Delphi build is not slower than the C build. I know this is not a real life test (a trivial filter on only a small clip with no other filters) but maybe it can give a rough idea.

I would like to test the invert filters built with M$VC as in

http://www.avisynth.org/AviSynthTwoFiveSDK

both the TwoFiveInvert and the TwoFiveFastInvert codes, to see how a properly built filter (that doesn't need avisynth_c.dll and LoadPluginC) would compare to the above.

But I couldn't find any binaries and if you have a look at:

http://www.avisynth.org/CompilingAviSynth

you'll know why I won't try to build them myself :)

incredible 09-16-2005 10:05 AM

Nice tests! Thanx :)

kwag 09-16-2005 12:46 PM

Thanks GFR :)
I'll take a closer look at this :!:
And BTW, I also agree about the C++ issue. C++ is really :arrow: a developer's nightmare.
I'll always stick to C when I have to code low level stuff ;)
Else, I use Python or PB :D
And also, Python looks like the future direction of AviSynth: http://www.avisynth.org/WhyPython
I'd love to see filters running in NumPY extensions, as they will blow away any C filter :lol:
These numeric extensions are built in C and assembly, and they are optimized for scientific work, so they would give us the best speed available :)
If anyone wants to read about NumPY, here's the link: http://www.python.org/workshops/1997...s/beazley.html

EDIT: Wrong link :oops:
This is the correct link http://numeric.scipy.org/

-kwag


All times are GMT -5. The time now is 11:14 AM  —  vBulletin © Jelsoft Enterprises Ltd

Site design, images and content © 2002-2024 The Digital FAQ, www.digitalFAQ.com
Forum Software by vBulletin · Copyright © 2024 Jelsoft Enterprises Ltd.