diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2013-03-28 12:21:29 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2013-03-28 12:21:29 +0400 |
commit | c5c34ca65f7d53abea3bead809dc282d231010ca (patch) | |
tree | 567833a875c1561fa0d6b3a131542b26be17f7fe /source/blender/blenlib/intern/math_interp.c | |
parent | ed99c94bef1dc896a645d5b361964afa7372365b (diff) |
Fix #34782: Video Editor - Substract after transform fails
Couple of precision issues here:
- Interpolation was rounding trunkcating colors, and because
of some precision issues value 254.999 became 254 leading
to troubles later.
Now color interpolaiton will do rounding to nearest int.
- Subtract was setting channels to something negative which
confused color management (especially negative alpha),
Now subtract effect will clamp channels to 0 from bottom
and also do some tricks to prevent small alpha which
could also confuse color management.
Diffstat (limited to 'source/blender/blenlib/intern/math_interp.c')
-rw-r--r-- | source/blender/blenlib/intern/math_interp.c | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/source/blender/blenlib/intern/math_interp.c b/source/blender/blenlib/intern/math_interp.c index 5a9e8244a46..de192d43699 100644 --- a/source/blender/blenlib/intern/math_interp.c +++ b/source/blender/blenlib/intern/math_interp.c @@ -215,18 +215,18 @@ BLI_INLINE void bicubic_interpolation(const unsigned char *byte_buffer, const fl } else { if (components == 1) { - byte_output[0] = out[0]; + byte_output[0] = out[0] + 0.5f; } else if (components == 3) { - byte_output[0] = out[0]; - byte_output[1] = out[1]; - byte_output[2] = out[2]; + byte_output[0] = out[0] + 0.5f; + byte_output[1] = out[1] + 0.5f; + byte_output[2] = out[2] + 0.5f; } else { - byte_output[0] = out[0]; - byte_output[1] = out[1]; - byte_output[2] = out[2]; - byte_output[3] = out[3]; + byte_output[0] = out[0] + 0.5f; + byte_output[1] = out[1] + 0.5f; + byte_output[2] = out[2] + 0.5f; + byte_output[3] = out[3] + 0.5f; } } } @@ -322,18 +322,18 @@ BLI_INLINE void bilinear_interpolation(const unsigned char *byte_buffer, const f a_b = a * b; ma_b = (1.0f - a) * b; a_mb = a * (1.0f - b); ma_mb = (1.0f - a) * (1.0f - b); if (components == 1) { - byte_output[0] = ma_mb * row1[0] + a_mb * row3[0] + ma_b * row2[0] + a_b * row4[0]; + byte_output[0] = ma_mb * row1[0] + a_mb * row3[0] + ma_b * row2[0] + a_b * row4[0] + 0.5f; } else if (components == 3) { - byte_output[0] = ma_mb * row1[0] + a_mb * row3[0] + ma_b * row2[0] + a_b * row4[0]; - byte_output[1] = ma_mb * row1[1] + a_mb * row3[1] + ma_b * row2[1] + a_b * row4[1]; - byte_output[2] = ma_mb * row1[2] + a_mb * row3[2] + ma_b * row2[2] + a_b * row4[2]; + byte_output[0] = ma_mb * row1[0] + a_mb * row3[0] + ma_b * row2[0] + a_b * row4[0] + 0.5f; + byte_output[1] = ma_mb * row1[1] + a_mb * row3[1] + ma_b * row2[1] + a_b * row4[1] + 0.5f; + byte_output[2] = ma_mb * row1[2] + a_mb * row3[2] + ma_b * row2[2] + a_b * row4[2] + 0.5f; } else { - byte_output[0] = ma_mb * row1[0] + a_mb * row3[0] + ma_b * row2[0] + a_b * row4[0]; - byte_output[1] = ma_mb * row1[1] + a_mb * row3[1] + ma_b * row2[1] + a_b * row4[1]; - byte_output[2] = ma_mb * row1[2] + a_mb * row3[2] + ma_b * row2[2] + a_b * row4[2]; - byte_output[3] = ma_mb * row1[3] + a_mb * row3[3] + ma_b * row2[3] + a_b * row4[3]; + byte_output[0] = ma_mb * row1[0] + a_mb * row3[0] + ma_b * row2[0] + a_b * row4[0] + 0.5f; + byte_output[1] = ma_mb * row1[1] + a_mb * row3[1] + ma_b * row2[1] + a_b * row4[1] + 0.5f; + byte_output[2] = ma_mb * row1[2] + a_mb * row3[2] + ma_b * row2[2] + a_b * row4[2] + 0.5f; + byte_output[3] = ma_mb * row1[3] + a_mb * row3[3] + ma_b * row2[3] + a_b * row4[3] + 0.5f; } } } |