Changeset View
Changeset View
Standalone View
Standalone View
source/blender/compositor/operations/COM_BrightnessOperation.cpp
| Show First 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | void BrightnessOperation::executePixelSampled(float output[4], | ||||
| brightness /= 100.0f; | brightness /= 100.0f; | ||||
| float delta = contrast / 200.0f; | float delta = contrast / 200.0f; | ||||
| /* | /* | ||||
| * The algorithm is by Werner D. Streidt | * The algorithm is by Werner D. Streidt | ||||
| * (http://visca.com/ffactory/archives/5-99/msg00021.html) | * (http://visca.com/ffactory/archives/5-99/msg00021.html) | ||||
| * Extracted of OpenCV demhist.c | * Extracted of OpenCV demhist.c | ||||
| */ | */ | ||||
| if (contrast > 0) { | if (contrast > 0) { | ||||
| a = 1.0f / (1.0f - delta * 2.0f); | a = 1.0f - delta * 2.0f; | ||||
| a = 1.0f / max_ff(a, FLT_EPSILON); | |||||
| b = a * (brightness - delta); | b = a * (brightness - delta); | ||||
| } | } | ||||
| else { | else { | ||||
| delta *= -1; | delta *= -1; | ||||
| a = 1.0f - delta * 2.0f; | a = max_ff(1.0f - delta * 2.0f, 0.0f); | ||||
| b = a * brightness + delta; | b = a * brightness + delta; | ||||
| } | } | ||||
| if (this->m_use_premultiply) { | if (this->m_use_premultiply) { | ||||
| premul_to_straight_v4(inputValue); | premul_to_straight_v4(inputValue); | ||||
| } | } | ||||
| output[0] = a * inputValue[0] + b; | output[0] = a * inputValue[0] + b; | ||||
| output[1] = a * inputValue[1] + b; | output[1] = a * inputValue[1] + b; | ||||
| output[2] = a * inputValue[2] + b; | output[2] = a * inputValue[2] + b; | ||||
| Show All 12 Lines | |||||