PDA

View Full Version : Getting starting writing plugins


Si
17th August 2002, 09:36
Apologies for what could easily be a FAQ but ...

I'm starting off trying to convert my vast ;) range of VirtualDub filters to Avisynth plugins but I can't find the info on what the structure of the YUY2 Avisynth frame is.

i.e VirtualDub uses 4 bytes (x R G B) for each pixel -
Avisynth uses ? bytes (? ...)

I'm sure I had this info back in Ben's day but I can't find it anywhere :o

neuron2
17th August 2002, 14:41
Each line is like this:

Y1 U1+2 Y2 V1+2 Y3 U3+4 Y4 U3+4 ...

... where U1+2 means it applies to pixels 1 and 2. Thus, Y is fully sampled but U and V are subsampled.

RGB to YUV Conversion
Y = (0.257 * R) + (0.504 * G) + (0.098 * B) + 16
Cr = V = (0.439 * R) - (0.368 * G) - (0.071 * B) + 128
Cb = U = -(0.148 * R) - (0.291 * G) + (0.439 * B) + 128

YUV to RGB Conversion
B = 1.164(Y - 16) + 2.018(U - 128)
G = 1.164(Y - 16) - 0.813(V - 128) - 0.391(U - 128)
R = 1.164(Y - 16) + 1.596(V - 128)

Si
17th August 2002, 15:43
Thanks Don.
Suplementary if I may :D

If the previous filter prior to mine has done a convert to RGB would I get passed an RGB byte map and would it be the same format as VirtualDub's (i.e. x R G B)?

(or is my slim grasp of Avisynth plugins workings showing me up
:confused: )

regards
Simon
PS I've posted another problem on the avisynth-dev egroup as I'm not sure where the most appropriate place is - what do you think - put them here or there?

neuron2
17th August 2002, 16:29
If the previous filter prior to mine has done a convert to RGB would I get passed an RGB byte map and would it be the same format as VirtualDub's (i.e. x R G B)?Yes, but if you're thinking of leaving your VirtualDub filters as RGB when ported to Avisynth, I would advise against it.

I've posted another problem on the avisynth-dev egroup as I'm not sure where the most appropriate place is - what do you think - put them here or there?Here is good.

Si
17th August 2002, 16:58
Thanks for info - it was just for completeness sake. I understand that all filters should deal with YUY2 if they don't explicitly need to process in RGB space.

regards
Simon
If I only cold compile them now :mad:

neuron2
18th August 2002, 05:57
>If I only could compile them now

What's the hangup? Any way I can help?

Si
18th August 2002, 10:05
Copy of post to avisynth-dev egroup

I wonder if anyone can tell me what the simple stupid thing I've done
that is causing me to not be unable to load my own plugins

I was recompiling my ViewFields plugin when I noticed it gave me the
following error

Avisynth open failure:
Load Plugin: unable to open ...
... line 1)

in VirtualDub when using the following script

LoadPlugin("c:\av\avisynth\myplugins\ViewFields.dll")
AVISource("d:\vtest\Test1.avi")
last=ViewFields(last)
return last

if I copy Decomb.dll into c:\.. \myplugins and try the following

LoadPlugin("c:\av\avisynth\myplugins\Decomb.dll")
AVISource("d:\vtest\Test1.avi")
Telecide()
return last

No errors.

If I load in a decomb source (V3.1 was sitting om my machine) and compile it and use that Decomb.dll instead - no errors.

If I create a new dll from scratch - same unable to load plugin error.

If I unzip my prev version from my site and install it - same load plugin error.

Help!!!!

regards
Simon

neuron2
18th August 2002, 15:37
Strange.

If you rename the Decomb.dll to ViewFields.dll, what happens?

Si
18th August 2002, 17:34
delete viewfields.dll
Rename decomb.dll to viewfields.dll

LoadPlugin("c:\av\avisynth\myplugins\ViewFields.dll")
AVISource("d:\vtest\Test1.avi")
last=ViewFields(last)
return last

gives ... there is no function named "ViewFields" ... line 3.

My viewfields filter is at
http://www.geocities.com/siwalters_uk/viewfields.html

I thought it worked before I published it but maybe the QA dept was having a bad day :(

I'll keep the conversation here now unless you suggest otherwise.

Simon

neuron2
18th August 2002, 18:12
I downloaded it and it works fine. Hmm, let me think about this.

Give us the exact full error message you get.

Can you load from the current directory?

Si
18th August 2002, 19:03
Give us the exact full error message you get.
See attachment jpg.

Can you load from the current directory?
i.e LoadPlugin("ViewFields.dll")

No -same error (without the path info in the first part of msg).

For info my ViewFields.avs script is in the c:\av\avisynth\myplugins directory.
UPDATE UPDATE
This is using Decomb31 src (must have downloaded it a while ago)

I deleted all your .cpp files and added my ViewFields.cpp - I then output .dll file to be c:\av\avisynth\myplugins\ViewFields.dll and it works :)

But obviously somethings still not right somewhere:(

Simon

neuron2
18th August 2002, 19:17
Simon, a moderator has to approve your attachment. I'm supposed to know how to do it, but I'm a newbie moderator. Can't you just type it?

Si
18th August 2002, 19:25
You expect me to type it when I've got a 3.5GHz 400 TB machine ;)

Bloomin heck - I've had to move windows etc when it was so easy to do Alt-PrnScrn - load up Gimp -attempt paste - fail - load Pbrush - paste - save bmp -load gimp - open bmp - learn how to crop - save a jpg :devil:

Here goes
Aviynth open failure:
LoadPlugin: unable to load "c:\av\avisynth\myplugins\ViewFields.dll"
(C:\av\Avisynth\MyPlugins\ViewFields.avs, line 1)

Inconsistant capitalisation is as its displayed on screen.

Simon

neuron2
18th August 2002, 19:39
What version of avisynth are you using?

Marc FD
18th August 2002, 19:40
i've got the same error ...
... but only when i tried profiling

profiling seems impossible with avs plugins :(
(or i'm too domb to do it)

Si
18th August 2002, 20:25
@neuron2

I tried changing to earlier version before posting so I'm currently on the one dated 21/10/00 15:42 which makes it Bens 1.0b3.

Just trying 1.0b5 (25/10/01 15:53) ... same error.

Just trying 2.0.4 .. same error.

(Used a Version to check that I'm doing it right - its legal just to overwrite the avisynth.dll in c:\windows\system? (on Win98SE)

Could you compile the source attached and email me back the dll just so we can see what the results are

My src compiled on mine - run on my system - fail
My src compiled on mine - run on your system - OK.

mmm the above compilation was done a few days ago - I'll send you a recent run by email - try it out and see what happens

Your workspace setup - compiled on mine -run on mine - OK
My src - compiled on yours - run on mine ???


@Marc FD

Hello.

What's profiling?

regards
Simon

Si
18th August 2002, 22:45
@neuron2
from your emails
So my latest dll compiled on mine works on yours.

My source complied on yours and dll sent back to me did not work :confused:

I deleted all other ViewFields.dll -still the same

I renamed ViewFields.dll to View.dll - still the same (changed the avs to match of course :D )

The one thing I've just noticed is that all the versions are ~40K except for the one I compile by hacking your decomb31 src -its ~20K (which is the only one that works)

So it seems to me that for some reason (thats happened over the past week since I started writing plugins :mad: ), I am unable to use normal Avisynth plugin dlls on my system but if I use a modifed workspace enviroment (like your decomb31 workspace seems to be) I can get them to run.

I assume you just threw together a simple dll project to comiple my code?

regards
Simon

neuron2
18th August 2002, 23:19
OK I have a theory.

Go into project settings, C/C++ tab, category code generation.
Set use runtime library to "Multithreaded DLL". Rebuild.

Si
19th August 2002, 00:12
Your theory is good :D

My plugins now work if I recompile them using that setting.

So now I'm back in the plugin business - thanks once again.

Now - le deuxieme - why can't I run non-multihtreaded dlls when I could up until a few days ago :confused: :confused: :confused:

Simon

neuron2
19th August 2002, 00:45
>why can't I run non-multihtreaded dlls when I could up until a few days ago

Avery explained this once to me, but I forgot it. :(

Si
19th August 2002, 02:02
Eureka - we've got it :) :) :)

I found the info in the vdub-dev filter dev group(msg 257)

I read Avery's stuff - did't understand it of course - tried to code his program but (dare I say it) its got a few errors - since I can't understand it I didn't how to correct it!

Never mind - it got me thinking that I'd run out of the TLS indicies - so I thought what I have I installed to make this happen and then it came to me!!!!!

I had been making new versions of ViewFields and UnViewFields for both VirtualDub and Avisynth.

I hadn't removed the old versions from my VirtualDub plugin directory and adding one more non-multithreaded vdf put me over the limit. If I just remove one, then VirtualDub loads the ViewFields.avs script fine :D

Time to heed the masters words and get recompiling mulithread dll :o

Thanks for all your help and perseverence - I live and learn.

And I have to take my hat off to you with your own ability to deal with all the different threads (pun intended:) ) going on in this forum :)

Now its off to convert my vast :rolleyes: filter range

Thanks again

Simon

neuron2
19th August 2002, 02:27
Yeah, that was the explanation he gave at the time. I remember now that you've reminded me. I just remembered the bottom line; always use multithreaded DLL. What gave it away to me was when you pointed out the DLL size observations.

Thanks for tying up the loose ends.