Log in

View Full Version : Question about filter development


jollye
4th December 2006, 11:24
Hi,

I want to get some advice about filter writing.
I want to write 2 different filters:

The first one will use one input clip and produce 2 output clips. (image_out and image_mask). The second one will use the 2 outputs of the previous one and have only one output.

I will then write a script pipelining the two filters.


First question: Is it possible to write such filters (1 input, 2 outputs) and (2 inputs, 1 output).



Second question: If it is possible can somebody point me to some existing code that I can use as a start for writing such filters.

I have alreasy used the simplesample to write my own source filter with success. But I couldn't adapt it to the 2 filters I need.

Thanks in advance for your support

Fizick
4th December 2006, 17:53
Welcome to the forum!

It is not possible to have 2 output. :( Result is one clip.
So, you must create 3 filters:
1) input to image_out
2) input to image_mask
3) image_out and image_mask to image_result

See SimpleSample latest version (1.7 ?) with two input clips.
Of course, you also can combine all 3 filters to one internally.

Please tell us what wonderful filter you want to create, and will you release it for public? :)

tritical
4th December 2006, 18:43
So, you must create 3 filters:
1) input to image_out
2) input to image_mask
3) image_out and image_mask to image_result

If you are generating image_out and image_mask at the same time, and they both have the same colorspace, width, height, number of frames, etc... then another possibility, as Didée has suggested before, is to simply stack the frames horizontally or vertically inside the filter (creating a clip that is 2x taller or wider) and then use crop afterwards to separate them.

jollye
5th December 2006, 10:01
Thanks for your answers. As I am generating image_out and image_mask at the same time I will try to use the solution proposed by tritical.

Please tell us what wonderful filter you want to create, and will you release it for public?
Actually it is not wonderful at all. In the company I am working, we are processing images for internal tests and I wanted to try avisynth to see if it can add some flexibility instead of using pure CLI programs written in C++. The algorithms are very basic.

Thanks again for your support. I will surely post new questions in this same thread.

IanB
7th December 2006, 02:49
Filters return the variant type AVSValue. Usually this contains a PClip.

An AVSValue can contain an array of AVSValues, each containing ....

A Cleaner implementation than stacking (which may lead to a conflict of ownership of the underlying VFB) might be to return an array with 2 PClips and export new functions to extract value[0] or value[1] for more normal processing of each PClip.

Fizick
7th December 2006, 06:30
jollye,
please consider to release your filters to public (with a sourceander GPL). you will get our full support.