In V 1.2: We reviewed if kOfxImageEffectPropPreMultiplication should be deprecated - this was withdrawn
Bruno Nicoletti asked: "Is the kOfxImageEffectPropPreMultiplication flag used by anyone to do anything useful with? If not should we just kill it?" GaryO, PierreJ, and ShinK said NO, so we kept it. However all that was resolved is not deprecating.
The short form is GaryO thought kOfxImageOpaque was useful and PierreJ said we need to know that because some hosts are Straight (including historically the first host RE:Vision supported "Toxik").
In retrospect this should probably have been that Premult or UnPremult should have been a Project Property. And Opaque a Clip Property.
Historical Note: I believe it became a Clip Property because someone like 11 years ago mentioned that such host is possible (e.g. someone mentioned Cyborg - that would be life before Assimilate and SpeedSix for those that were not born yet).
Practical Issue: Let's say one passes you kOfxImageOpaque and you are a keyer, are you supposed to premult or not the output... More examples can be provided but that might do. Net effect is for tools including any spatial transform, warp that reveals the source frame edges we need to add a checkbox at the end [x] HostIsPremult which defaults to true for unknown hosts as it's the dominant state.
Pragmatic Issue: Although in theory we could fix this by splitting it, it might be easier to edit that property instead of breaking it in two.
Current options for this:
kOfxImageOpaque - the image is opaque and so has no premultiplication state
kOfxImagePreMultiplied - the image is premultiplied by it's alpha
kOfxImageUnPreMultiplied - the image is unpremultiplied
(revised feb 1, 2017): current proposal
-> Proposal: DescribeInContext property so plug-in can say what premult states is supports. kOfxPreMultiplicationSupported (multi-dimensional string, can return kOfxImagePreMultiplied and/or kOfxImageUnPreMultiplied). RGB-only plugins don’t need to set this.
-> Proposal: DescribeInContext integer property so plug-in can say whether it can generate alpha. kOfxCanGenerateAlpha, 0=No, 1=Yes.
-> For plug-ins that generate alpha and input clip is Opaque, they need a way to find out what host premult is desired. Proposal is a new string property set on a plug-in instance: kOfxImageEffectHostDesiredPremult (value can be kOfxImagePreMultiplied or kOfxImageUnPreMultiplied).
//
Revised: (jan 10, 2017)
Option 1: Define a Project Property (the word project is used but from the stand-point of effect it's no difference if the host defines this at a comp, sequence or whatever organisational structure they may use). This only inform plugin of host preference.
Option 2: Document that host sets Output clip to Premult or Unmult by default, and plugin who receives Opaque can always set that back to Opaque if they don't deal with alpha. To not set Opaque has very tiny performance effect and no effect on image down the line.
Option 2 has the advantage of not adding anything other than documenting expected behavior. And allowing an host to do more fine-grain management if they so desire.
Options not mutually exclusive, but one of them seems necessary as it's ambiguous right now.
(june 2017): Just a comment here. After playing supporting 2 more hosts here, I wished we had a distinction between Opaque and Transparent. Opaque is A = 1.0 and transparent is A = 0.0 (or undefined also). Currently there is at least 3 hosts that return zero alpha with Opaque flag...
Pierre Jasmin | 12:43 pm, 25 Jun 2017
This could qualify for 1.4.1 - I did not yet because I think we are missing to specify expected behavior for kOfxPreMultiplicationSupported - if an host is Straight/Unmult internally - i.e. is the host supposed to :
A. Not load you B. Report to user on first application about that? etc
Pierre Jasmin | 5:39 pm, 5 Feb 2017
Popup to problem statement:
Silhouette FX is a new host and is UnMult workflow. And Paul, I like the word Workflow here as this is about a Preference in this case not a Property (I know it's called Clip Preferences in doc, but at that level it's really a Property). Internally I don't know that host, right now if I have a tool that rotates the image 45 degrees I don't know if I have to return an edge UnMult or PreMult.
The only options I can think of are:
1) I create a parameter so user can turn [x] HostIsPremult on or off.
- Not a bad solution if host has a sort of Preset so user can set that once.
2) I do an on-disk config file per host a la GenArts
- Not going to happen here
3) I just output PreMult all the time for UnKnowns and user each time it applies effect has to add an UnMult node
- Terrible for users
4) I set the Output to PreMult and assume host internally will UnMult if necessary
- Not as great as it sounds for at least 8 bit images workflow as it creates banding / quantization in non-full alpha areas.
Well behaved plugin: Am I supposed to set the Output Clip Property to PreMult or UnMult when input is tagged Opaque? (Is anyone really tracking this? Most probably not much aside perhaps when input is a Read Node itself ) --
Possible Solution: Add a Project Preferences for Alpha Interpretation Workflow and leave the current clip property as is. Internally I could then from hosts supporting v1.5 or over hide the HostIsPremult boolean parameter and set it to Project Preferences reported by Host.
P.S.: We don't like people who provide Alpha all 0 when promoting to RGBA :) -
Pierre Jasmin | 2:31 pm, 14 Dec 2016
In Natron we set this property where needed (Readers, Premult/unpremult effects, etc...)
Then any effect can have a Unpremult boolean param that is checked automatically if the source clip premultiplication is premultiplied. User may always choose to uncheck it even if input is premultiplied.
Opaque is set only if pixel components is RGB, and I can't seem where you would need to care about alpha in this case.
If your are a keyer and input clip is RGB , then in the getClipPreferences action you may just request that in input you receive a RGBA clip instead. The host will most likely then tag the image premultiplied or unpremultiplied depending on its premultiplication policy and whether it is filling in alpha channel with 1s or 0s.
The code in the c++ library HostSupport on the Github repo already handles that (with a few fixes we brought on our fork).
On host side it may be useful to track the premultiplication state for various reasons
Alexandre | 10:46 am, 14 Dec 2016
FYI - Silhouette v6 is a new OFX host and has a straight alpha workflow, though it can mix and match straight and premul as it technically doesn't care what's in the alpha. If it knows an input is RGB only it'll fill the alpha and mark it as opaque, otherwise it doesn't know whether the image is straight or premul.
(june 2017): Just a comment here. After playing supporting 2 more hosts here, I wished we had a distinction between Opaque and Transparent. Opaque is A = 1.0 and transparent is A = 0.0 (or undefined also). Currently there is at least 3 hosts that return zero alpha with Opaque flag...