Log in

View Full Version : Can I call Invoke on my filter's output before returning?


wonkey_monkey
23rd December 2018, 16:07
I know how to call Invoke on a PClip within my filter, for example if I want to convert a passed clip to RGB before processing it further. But is it possible to call Invoke on my output?

For example, suppose the filter is given a YUV clip. I call Invoke to invoke ConverttoRGB32 so that I can process it in RGB, but then I want to invoke ConverttoYV12 (or whichever) to convert it back to YUV for the user.

Can that be done?

DJATOM
23rd December 2018, 16:16
I don't think so, invoking external filter in the getframe is probably bad idea.
But you still can implement your own routine (or copy codepath from core and change to your needs) and convert output back to YV12 with function/method call.

wonkey_monkey
23rd December 2018, 16:22
That's what I thought, thanks for the confirmation. It'd be nice if it was possible (though not by calling it in GetFrame).

StainlessS
24th December 2018, 04:17
I have seen this done before but cannot remember where.
In the create filter routine, instead of returning the new filter, you insert another one (filter) after it, and return result from that.
[above probably of limited help, sorry].

EDIT: I think I may be remembering seeing core code for inserting cache between each filter instance, maybe look to the core cache
source code [might be a bit tricky].

EDIT: Overlay has an 'output' arg for return colorspace, perhaps Overlay source code can give a clue on how to do it properly.
[I very much doubt that it will be done in GetFrame, probably in filter creator function]

EDIT: If you find a solution to this problem, would be a good idea to publish results, is prime candidate for a HowTo on wiki.

pinterf
24th December 2018, 11:23
You can do it in the filter constructor.
This is how I support old-syle formats in GeneralConvolution
https://github.com/pinterf/AviSynthPlus/blob/MT/avs_core/filters/convolution.cpp#L532

wonkey_monkey
24th December 2018, 12:51
Thanks (although I'd call that the creator function, not the constructor, which is GeneralConvolution::GeneralConvolution).

I actually solved my immediate problem in another way, but this is very useful to know.

pinterf
24th December 2018, 13:20
Yep. Creator of course, thanks.