Log in

View Full Version : SubTract - bug or intention?


redfordxx
17th March 2005, 12:12
Hi
I don't know whether my question is suitable for "Avisynth Development" forum... then sorry.
When i make test script like thisSubtract(any_clip,any_clip) I receive BlankClip with color $7e8080 as a result. I would expect $808080. Then I have always to add 2 in Y. (Speaking about YV12)
Is that bug or has it some (for me) hidden purpose? Because when I enhance contrast maximally I receive black clip ($008080).

AVIL
17th March 2005, 12:29
Hello:

Subtract uses an offset of 126 (pixel difference is halved and added by 126).YV12Subtract uses 128 as offset, but in YV12 colorspace only.

Regards.

Wilbert
17th March 2005, 12:58
Subtract uses an offset of 126 (pixel difference is halved and added by 126).
We will change that in the next version.

IanB
20th March 2005, 05:30
Dear all,

Although it may seem strange to some the current behaviour is correct.

For YUV formats the valid Y range is from 16 to 235 inclusive and subtract takes this into account.

For YUV colorspaces (A - B) is implemented as
Min(219, Max(0, (A-B) + 219/2 + 0.5)) + 16

What is arguably wrong is the lack of divide by 2, however doing so would reduce the usefulness of being able to detecting single value errors in the comparison.

Wilbert, perhaps a note on the Subtract() page could clarify this.

For those that require a subtract function for PC range YUV data use Overlay() with mode="Subtract" and PC_Range=True

IanB