Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/seqmodifier.c
| Show First 20 Lines • Show All 539 Lines • ▼ Show 20 Lines | static void brightcontrast_apply_threaded(int width, | ||||
| int x, y; | int x, y; | ||||
| float i; | float i; | ||||
| int c; | int c; | ||||
| float a, b, v; | float a, b, v; | ||||
| float brightness = data->bright / 100.0f; | float brightness = data->bright / 100.0f; | ||||
| float contrast = data->contrast; | float contrast = data->contrast; | ||||
| float delta = contrast / 200.0f; | float delta = contrast / 200.0f; | ||||
| a = 1.0f - delta * 2.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 / a; | a = 1.0f - delta * 2.0f; | ||||
| a = 1.0f / max_ff(a, FLT_EPSILON); | |||||
brecht: Better would be to do this.
```
a = 1.0f / max_ff(a, FLT_EPSILON);
```
Otherwise contrast… | |||||
Not Done Inline Actions
Thats why I tweaked the valid range with RNA_def_property_range, but yeah, makes sense, will update... lichtwerk: > Otherwise contrast values > 100 would start reducing the contrast
Thats why I tweaked the… | |||||
| b = a * (brightness - delta); | b = a * (brightness - delta); | ||||
| } | } | ||||
| else { | else { | ||||
| delta *= -1; | delta *= -1; | ||||
| b = a * (brightness + delta); | a = max_ff(1.0f - delta * 2.0f, 0.0f); | ||||
| b = a * brightness + delta; | |||||
Not Done Inline ActionsIf we're changing code here anyway, this should be changed too since the formulas don't make sense for contrast < -100. a = max_ff(1.0f - delta * 2.0f, 0.0f); brecht: If we're changing code here anyway, this should be changed too since the formulas don't make… | |||||
Not Done Inline Actions
Thats why I tweaked the valid range with RNA_def_property_range, but yeah, still makes sense, will update... lichtwerk: > this should be changed too since the formulas don't make sense for contrast < -100
Thats why… | |||||
| } | } | ||||
| for (y = 0; y < height; y++) { | for (y = 0; y < height; y++) { | ||||
| for (x = 0; x < width; x++) { | for (x = 0; x < width; x++) { | ||||
| int pixel_index = (y * width + x) * 4; | int pixel_index = (y * width + x) * 4; | ||||
| if (rect) { | if (rect) { | ||||
| unsigned char *pixel = rect + pixel_index; | unsigned char *pixel = rect + pixel_index; | ||||
| ▲ Show 20 Lines • Show All 524 Lines • Show Last 20 Lines | |||||
Better would be to do this.
Otherwise contrast values > 100 would start reducing the contrast, and values of 0 < a < FLT_EPSILON would give more contrast then a == 0.