Quantcast Delphi: Pascal Conversion of Avisynth_C.H - digitalFAQ.com Forums [Archives]
  #1  
09-15-2005, 11:24 AM
GFR GFR is offline
Free Member
 
Join Date: May 2002
Posts: 438
Thanks: 0
Thanked 0 Times in 0 Posts
http://forum.doom9.org/showthread.php?t=98327

Now we can code avisynth filters in Delphi
Reply With Quote
Someday, 12:01 PM
admin's Avatar
Site Staff / Ad Manager
 
Join Date: Dec 2002
Posts: 42
Thanks: ∞
Thanked 42 Times in 42 Posts
  #2  
09-15-2005, 07:24 PM
kwag kwag is offline
Free Member
 
Join Date: Apr 2002
Location: Puerto Rico, USA
Posts: 13,537
Thanks: 0
Thanked 0 Times in 0 Posts
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
So filtering wll take a performance hit.

-kwag
Reply With Quote
  #3  
09-16-2005, 05:42 AM
incredible incredible is offline
Free Member
 
Join Date: May 2003
Location: Germany
Posts: 3,189
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to incredible
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.
Reply With Quote
  #4  
09-16-2005, 06:37 AM
GFR GFR is offline
Free Member
 
Join Date: May 2002
Posts: 438
Thanks: 0
Thanked 0 Times in 0 Posts
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.
Reply With Quote
  #5  
09-16-2005, 09:44 AM
GFR GFR is offline
Free Member
 
Join Date: May 2002
Posts: 438
Thanks: 0
Thanked 0 Times in 0 Posts
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
Reply With Quote
  #6  
09-16-2005, 10:05 AM
incredible incredible is offline
Free Member
 
Join Date: May 2003
Location: Germany
Posts: 3,189
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to incredible
Nice tests! Thanx
Reply With Quote
  #7  
09-16-2005, 12:46 PM
kwag kwag is offline
Free Member
 
Join Date: Apr 2002
Location: Puerto Rico, USA
Posts: 13,537
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks GFR
I'll take a closer look at this
And BTW, I also agree about the C++ issue. C++ is really a developer's nightmare.
I'll always stick to C when I have to code low level stuff
Else, I use Python or PB
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
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
This is the correct link http://numeric.scipy.org/

-kwag
Reply With Quote
Reply




Similar Threads
Thread Thread Starter Forum Replies Last Post
Making a Delphi GUI need some help Zyphon Avisynth Scripting 8 07-06-2004 02:05 AM
Delphi command to control another application? GFR Avisynth Scripting 6 01-26-2004 07:14 AM
Delphi: PicSwitch v1.0.4 (beta) vhelp Avisynth Scripting 11 03-11-2003 10:41 PM
Automated file prediction written in Delphi black prince Avisynth Scripting 0 02-24-2003 11:52 PM
DLL - A Delphi Ex with vmath.dll (small steps) vhelp Avisynth Scripting 2 02-10-2003 12:54 AM

Thread Tools



 
All times are GMT -5. The time now is 12:28 PM  —  vBulletin © Jelsoft Enterprises Ltd