Premultiplication and fxscripts

Posted by PieroF 
Premultiplication and fxscripts
October 15, 2008 12:14PM
I've been writing a few fxscript plugins and I'd like to clarify some issues I have with alpha premultiplication.
I think I understand the theory of it (lot of documents on internet and some discussion also in this forum), but my question is about how the FCP engine internally handles the alpha channel: straight, or premultiplied black or white ?

My question comes from the fact that most compositing functions in fxscript require an alpha type parameter for just one of the 2 or 3 input frame buffers; note that for each input clip fxscript runtime returns a predefined variable srcType containing its "Alpha" property.
Example: Matte (overImage, baseImage, destImage, amount, type) "Composites the image buffer specified as overImage onto the buffer specified as baseImage and places the result in the destination image buffer." From some examples it seems that the alpha type is supposed to be that of overImage, But what about baseImage or destImage ? their types in general might be different... from overImage.

Or, in other words my question might be: which of the 2 cases is correct ?
Case a. FCP internally handles all clips and sequences premultiplied black (just an example) and converts all imported clips from their native alpha type ("Alpha" property in the browser) into the internal standard - In the Matte case above: FCP will automatically convert overImage from its original type to the internal FCP representation, and the remaining 2 buffers are supposed to already conform to the internal FCP representation.
In this case the plugin code simply has to provide the input type for overImage and FCP will take care of the rest. The question remains though: which alpha type is native in FCP ?
OR
Case b. each fxscript function (including Matte) assumes that all its input buffers have the same alpha type given by the last parameter type in the function. Then it's up to the plugin code to convert possibly different buffer types to that one before applying these functions.

Can anybody help me here ?
Thanks in advance

Piero
Re: Premultiplication and fxscripts
October 15, 2008 03:51PM
>which alpha type is native in FCP ?

My guess- straight, as that's what it usually defaults to, but I'm no fxscript writer.



www.strypesinpost.com
Re: Premultiplication and fxscripts
October 15, 2008 05:34PM
Thanks Strypes.

Theory says that straight is less "efficient" than premultiplied black: it requires more multiply and divide operations per pixel during compositing; but it should also provide better quality, because it does not mix color and alpha information...
But practice might be very different, mostly with state of the art technologies: GPUs are fast enough and provide high precision math to make the first problem non-existent and reduce impact of the second to almost nothing.

So, Strypes, I tend to believe that you are right.
Still I'd like to hear the opinion of some fxscript or fxplug programmer... I'm sure there is some around in this forum.

Thanks

Piero
Re: Premultiplication and fxscripts
October 16, 2008 09:53AM
Piero, did you ask yet over on the pro apps dev list?
Re: Premultiplication and fxscripts
October 16, 2008 11:18AM
Hi Andy, thanks for your suggestion.

At the moment I didn't find any answer to my question, though, even in the FCP/FCE Developers Connections. Premultiplication is addressed in other documents in the Developer Connection (not FCP), but it's specific to contexts (e.g. Core Image) I'm not sure how related to FCP. In some cases its also contradicting: in Core Image guide it is stated that all images are premultiplied. In another context (here I don't recall exactly where) a statement discourages premultiplication...

But my problem is what FCP fxscripts expect in their parameters, and this might be different from the inner Leopard Core Image processing...

Well, eventually, I might schedule a long fxscript testing session using all possible cases and see what comes out... unless somebody else already has the answer.

Piero
Re: Premultiplication and fxscripts
October 16, 2008 10:04PM
but FxScript doesn't use Core Image ... AFAIK its just a wrapper to a lot of old carbon API's

this is where you need to be: [lists.apple.com]
its about the only place where you can field questions directly to the engineers and engineering managers from the pro apps group

admittedly FxScript questions don't come up too often, its more FxPlug oriented, but the questions are fielded as and when they do come up
Re: Premultiplication and fxscripts
October 17, 2008 12:56AM
Thanks again Andy, I'll try that.
Piero
Sorry, only registered users may post in this forum.

Click here to login

 


Google
  Web lafcpug.org

Web Hosting by HermosawaveHermosawave Internet


Recycle computers and electronics