PDA

View Full Version : beginners questions about filter programming


E-Male
29th September 2002, 19:22
i know this will sound dumb, so please donīt laugh :rolleyes: :
ok, i got the .cpp file of a filter and i got Microsoft Visual Studio .NET
so now, how do i compile the dll???
please, can somone give me a step by step explaination

thx a lot
cu
e-male

p.s. donīt worry about my programming skills, iīm a learning by doing guy :cool: :cool: :cool:
itīs just the compiler that doesnīt do like i want it to

Guest
29th September 2002, 19:43
Create a Windows empty DLL project. Then add the cpp file and avisynth.h to the project. Then build it.

I assume you're not asking for a tutorial on using the Microsoft compiler. :)

E-Male
29th September 2002, 20:05
thx, but still 2 problems
1. i canīt find "Windows empty DLL project" (i got the german version of visual studio)
2. i always get a "fatal error C1010" (somethign about unexpacted end of file whiel looking for directive for header [hard to tarnslate, but my luck that that error number is international])

CU
E-Male

Nic
29th September 2002, 20:09
Maybe you should have a licensed copy (preferably in your language) of VC hey? :)
VC7 (.net) is more complex/confusing when creating DLLs/different types of exes. Most of the time you can just create a empty non-MFC Windows App & add: /DLL in the linker parameters to create the dll.

-Nic

E-Male
30th September 2002, 12:45
canīt noone help me with this??

Guest
30th September 2002, 13:28
You're asking for help on using the Microsoft compiler in the Avisynth forum. That is off-topic.

I am moving you to the Development forum.

E-Male
30th September 2002, 13:58
ok, my mistake :(
thx for moving :rolleyes:
i hope someone can finally help with this problem, so i can start working on my filter(s) (and on my c++ skills)
thx&cu
e-male

Guest
1st October 2002, 03:44
OK, let's start at the beginning.

Are you able to create a Win32 dynamic link library (DLL) project, without MFC and without any files (empty project)?

If not, have you read the documentation that tells you how to do it?

(If your problem is that you have a foreign language version of the software that you cannot properly read, please admit it so we can stop wasting our time.)

E-Male
1st October 2002, 12:21
[i am german, so is my verison of VS, so that is not hte problem, except i have to translate everything said here in english to german, so i can find it in the program]


my latest progres is that i did this:

create a new project, choose win32, and teh assistent choose dll and empty
add the invert.cpp (from the filter guide) and the avisynth.h
and compiled

the result where a lot of error, mainly about avisynth.h
you can have a look at the BuildLog.htm (http://e-rels.dyndns.org/BuildLog.htm) if that helps


Iīm sorry if you think iīm wasting your time, but i think that as soon as iīm getting started i can get usefull things done


cu
e-male

Guest
1st October 2002, 13:02
@E-Male

You've misunderstood my comment. It would be a waste of our time if you were trying to struggle through using a tool whose language you did not speak.

Your avisynth file looks strange. Try the one I've attached. Where did you get the one you are using?

Guest
1st October 2002, 13:51
OK, you took the avisynth.h from a recent source of Avisynth. To use recent Avisynth source, you need to include internal.h instead of avisynth.h. Note that internal.h will pull in avisynth.h (and maybe others), so they also have to be in your project.

Or just use the header I attached. That is what I use.

E-Male
1st October 2002, 13:57
i thought about some kind version conflict myself
so, iīll try with both the internal.h and your avisynth.h

THX for your patience

E-Male
1st October 2002, 14:15
internal.h did it!!

THX

Guest
1st October 2002, 14:39
My pleasure. We're always happy to welcome new filter writers to the ranks!

E-Male
1st October 2002, 21:15
My logo detection filter is compiling fine now
but after some working on it i got a problem that virtualdub now displays me an error in itīs status bar:
"Avisynth read error: Avisynth: caught an access violation at 0x01153696, attempting to write to 0x011133000"
and a bit later crashes, without ever showing me a picture
this is the file: lode.cpp (http://e-rels.dyndns.org/lode.cpp)
CU
E-MAle

Guest
1st October 2002, 21:55
No fair asking us to do your debugging for you. :)

Doing all those GetFrame()'s in your inner loop is a very bad idea. Get all the previous frames you need once before entering your per-pixel loop.

E-Male
1st October 2002, 23:38
Originally posted by neuron2
No fair asking us to do your debugging for you. :)
I just need some help at the beginning,

Doing all those GetFrame()'s in your inner loop is a very bad idea. Get all the previous frames you need once before entering your per-pixel loop.
Iīd like to have a variable number of previouse frames used (controlled by a parameter or just taking all previosue to the current one) and i donīt see a way to do this without adding a 3rd "for"-loop and doing the getframe in it, but i gues i just donīt know enough to do this plugin (which seemed so simple when it was al theory)

cu
e-male

Guest
1st October 2002, 23:48
You can certainly get the frames you need, but you have to be smart about it. Putting a frame fetch loop inside your per-pixel loop is awful; you'd be re-fetching all the frames *for every pixel*. Even doing it once but doing it for "just taking all previous to the current one" is very dangerous; at the end of my last Sopranos encode, which is 105,000 frames long, you'd be fetching 105,000 frames on each new frame.

Suppose you limit your number of frames to some reasonable amount, say 20. Then you'd code something like this (pseudocode):

// first get the needed frames
get current_frame_number
for i=1 to 20
if current_frame_number-i >= 0
get current_frame_number-i
else
break (or just keeping getting 0)

// Now loop through your pixels
set up pointers to all frames as required
for all x
for all y
do what you want referencing the pointers as requiredHave a look at the Decimate() source code in Decomb. It always gets a cycle + 1 number of frames and stores their references in an array. Something like that will work for you.

Feel free to keep asking questions. Believe me, we've all made most of the horrible mistakes. :)

-h
2nd October 2002, 00:31
Feel free to keep asking questions. Believe me, we've all made most of the horrible mistakes.

Exactly. I'm just now writing my first filter, and look forward to its errors raining seven layers of hell on those who use it. 'Tis the way alphas should be.

Or maybe that's just me..

-h

E-Male
2nd October 2002, 00:44
Originally posted by neuron2
...at the end of my last Sopranos encode, which is 105,000 frames long, you'd be fetching 105,000 frames on each new frame...


the logo detection only creates a mask for another filter [one resulting frame of it turned to bmp used for the whole movie]
so it should be used on a trimemd clip (only one fade to black with the logo remaining could be enough)

After a day out tomorrow iīll be fresh to get further i hope
then iīll look into using arrays in c++

CU
E-Male

p.s.: this sentence:
Originally posted by neuron2
Feel free to keep asking questions...

was worst mistake of your life :)))))) *j/k*

E-Male
4th October 2002, 01:07
ok, most problems are solved, but i still got a quite strange one:

...
if (same)
dstp[x] = 100;
else
dstp[x] = 200;
...

should produce frames cotaining only 2 colors (those that belong to "100" and "200", which btw are just test colors)
but the resulting frames cotain multiple colors, and i canīt imagine any reason why
you can get the complete cpp-file here (http://e-rels.dyndns.org/lodecolorproblem.cpp) (no parameters in it so it compares n to all frames previouse to n and the threshold has to be changed in the code, itīs just the basic working filter)
cu
e-male

Guest
4th October 2002, 01:40
Yeah, when I saw that in the first version I knew you'd be asking about it. :)

You're stepping through all the bytes along x. But each byte doesn't correspond to a pixel's color. It's like this for each group of 4 bytes:

Y1 U Y2 V

...where Y1 is the luma of one pixel and Y2 of the next pixel to the right, and U and V are the chrominance components shared by both of them. That is why we say color is subsampled in YUV. So these two adjacent pixels can have different luminances but not different colors. You could set U and V to 128 for no color, and then use say 16 for Y1 to get black and 235 for Y2 to get white. Intermediate values will give you greys.

Now you see why we filter writers hate YUV.

Refer to other threads for formuale relating YUV to RGB.

E-Male
4th October 2002, 18:48
so one of these groups (= 4 x values) has the data for 2 pixels?
and if i want to check each pixel i have to go through the x values in pairs?

Guest
4th October 2002, 19:02
Each group of 4 x values has the data for two pixels, yes. But the chrominance (U and V) is the same for the two, while the luminance can differ. If you are interested only in luminance you have to examine one x value per pixel. It all depends on what you are trying to achieve.

E-Male
6th October 2002, 12:09
the filter is workign now, just needs to be optimized for the logo removing filter
i made it always compare a pair of x values, using 2 parameters, a luma and a chroma threshold, gives quite good results

cu
e-male

p.s. expect first beta next weekend :cool:

EDIT: rgb to yuv formula found here: http://forum.doom9.org/showthread.php?s=&threadid=31623
question removed