[Cin] oops apparently 'subtract' mode is broken!

Phyllis Smith phylsmith2017 at gmail.com
Sun Oct 2 03:27:02 CEST 2022


> more documentation, it seems Adobe products use shared code for this ....
>
>
> https://www.rippletraining.com/blog/final-cut-pro-x/understanding-blend-modes-final-cut-pro/
>
Using the above URL for comparison, I used it on current CinGG and HV 4.6.1
for subtract.  HV matches and GG does not.  So tomorrow I will look at the
code that Andrew quoted below to see if adding the specific guard corrects
the issue.  In the attached, top left is HV 4.6.1 and bottom left is GG
current with right side the URL.

>
>
> --quote---
>
> Subtract
>
> Subtract does what it advertises; the color values of one layer are
> subtracted from the other layer. This tends to have a net darkening effect.
> Pixel values can’t fall below zero, so negative numbers are rendered to
> black.
>
>
> ---end quote---
>
>
> in older cingg code (from 4.6.mod era - earliest public code on Google
> code) I see such construct :
>
>
> /data/data/com.termux/files/home/cingg-g~nelerra-4.6.mod/cinelerra/overlayframe.C
>      4762/69317  UTF-8        6%
>
>                         break; \
>
>                 case TRANSFER_SUBTRACT: \
>
>                         r = (temp_type)output[0] - (temp_type)input1; \
>
>                         g = ((temp_type)output[1] -
> (temp_type)chroma_offset) - \
>
>                                 ((temp_type)input2 -
> (temp_type)chroma_offset) + \
>
>                                 (temp_type)chroma_offset; \
>
>                         b = ((temp_type)output[2] -
> (temp_type)chroma_offset) - \
>
>                                 ((temp_type)input3 -
> (temp_type)chroma_offset) + \
>
>                                 (temp_type)chroma_offset; \
>
>                         if(r < 0) r = 0; \
>
>                         if(g < 0) g = 0; \
>
>                         if(b < 0) b = 0; \
>
>                         r = (r * opacity + output[0] * transparency) /
> max; \
>
>                         g = (g * opacity + output[1] * transparency) /
> max; \
>
>                         b = (b * opacity + output[2] * transparency) /
> max; \                                                              break; \
>
>
> ---
>
>
> so it basically had specific guard against going negative. Not sure if our
> implementation does the same just in different place?
>
>
> I see no specific handling of it in macros ...
>
>
>
> overlayframe.h     [----] 38 L:[ 53+ 0  53/615] *(1572/17155b) 001[*][X]
>
> // ADDITION<--->[(Sa + Da), (Sc + Dc)]
>
> #define ALPHA_ADDITION(mx, Sa, Da) (Sa + Da)
>
> #define COLOR_ADDITION(mx, Sc, Sa, Dc, Da) (Sc + Dc)
>
> #define CHROMA_ADDITION COLOR_ADDITION
>
>
> // SUBTRACT<--->[(Sa - Da), (Sc - Dc)]
>
> #define ALPHA_SUBTRACT(mx, Sa, Da) (Sa - Da)
>
> #define COLOR_SUBTRACT(mx, Sc, Sa, Dc, Da) (Sc - Dc)
>
> #define CHROMA_SUBTRACT COLOR_SUBTRACT
>
>
> but apparently you can add some comparing here ...just .. it went from
> two-stage process to single stage for untrained eye and I am not sure where
> to put those ifs?
>
>
>
>
>
>
>>
>> вс, 25 сент. 2022 г., 11:06 Andrew Randrianasulu <randrianasulu at gmail.com
>> >:
>>
>>> I found Graphics-softlight mode behaving visually close...but not sure
>>> how close to CinHV/CV subtract mode ...
>>>
>>>
>>>
>>> вс, 25 сент. 2022 г., 10:24 Andrew Randrianasulu <
>>> randrianasulu at gmail.com>:
>>>
>>>> I was trying to repeat tuto at
>>>>
>>>> https://linuxvideoediting.blogspot.com/2022/01/transparent-text-effect-in-Cinelerra-part1.html?m=1
>>>>
>>>>
>>>> so I loaded video, created empty new vid track, applied 'titles',
>>>> 'blur' and 'invert video' to _empty track_, then set track's mode to
>>>> subtract .... result was color inversion of original video on second vid
>>>> track (
>>>>
>>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.cinelerra-gg.org/pipermail/cin/attachments/20221001/3cf350e0/attachment.htm>


More information about the Cin mailing list