Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTon Roosendaal <ton@blender.org>2009-04-29 15:20:07 +0400
committerTon Roosendaal <ton@blender.org>2009-04-29 15:20:07 +0400
commit988fbb88dc621d8f41d1b07a729ae5afc24efdaa (patch)
treea557ac8417f396adf431869807fad784d34347d2 /source/blender/imbuf
parent32b70e333fde4351fd385dab1238ffd74b012663 (diff)
bugfix #18609
This fixes a commit from Peter, revision 12931, Dec 17 2007 He added quick image scaling code, derived from ppmqscale, http://libdv.sf.net This implementation gave ugly banding. especially visible on dark colors or byte images with very close colors. Solution is to add correct rounding, seems to me normal for such fixed point magic. Optimizing code and keeping quality is tricky dudes! Results for scaling down in sequencer were bad for over a year (2.47 and 2.48 both wrong).
Diffstat (limited to 'source/blender/imbuf')
-rw-r--r--source/blender/imbuf/intern/scaling.c33
1 files changed, 17 insertions, 16 deletions
diff --git a/source/blender/imbuf/intern/scaling.c b/source/blender/imbuf/intern/scaling.c
index 807b0c84e90..b308915cd62 100644
--- a/source/blender/imbuf/intern/scaling.c
+++ b/source/blender/imbuf/intern/scaling.c
@@ -609,34 +609,35 @@ static void shrink_picture_byte(
w = (weight1y * weight1x) >> 16;
- dst_line1[x].r += (line[0] * w) >> 16;
- dst_line1[x].g += (line[1] * w) >> 16;
- dst_line1[x].b += (line[2] * w) >> 16;
- dst_line1[x].a += (line[3] * w) >> 16;
+ /* ensure correct rounding, without this you get ugly banding (ton) */
+ dst_line1[x].r += (line[0] * w + 32767) >> 16;
+ dst_line1[x].g += (line[1] * w + 32767) >> 16;
+ dst_line1[x].b += (line[2] * w + 32767) >> 16;
+ dst_line1[x].a += (line[3] * w + 32767) >> 16;
dst_line1[x].weight += w;
w = (weight2y * weight1x) >> 16;
- dst_line2[x].r += (line[0] * w) >> 16;
- dst_line2[x].g += (line[1] * w) >> 16;
- dst_line2[x].b += (line[2] * w) >> 16;
- dst_line2[x].a += (line[3] * w) >> 16;
+ dst_line2[x].r += (line[0] * w + 32767) >> 16;
+ dst_line2[x].g += (line[1] * w + 32767) >> 16;
+ dst_line2[x].b += (line[2] * w + 32767) >> 16;
+ dst_line2[x].a += (line[3] * w + 32767) >> 16;
dst_line2[x].weight += w;
w = (weight1y * weight2x) >> 16;
- dst_line1[x+1].r += (line[0] * w) >> 16;
- dst_line1[x+1].g += (line[1] * w) >> 16;
- dst_line1[x+1].b += (line[2] * w) >> 16;
- dst_line1[x+1].a += (line[3] * w) >> 16;
+ dst_line1[x+1].r += (line[0] * w + 32767) >> 16;
+ dst_line1[x+1].g += (line[1] * w + 32767) >> 16;
+ dst_line1[x+1].b += (line[2] * w + 32767) >> 16;
+ dst_line1[x+1].a += (line[3] * w + 32767) >> 16;
dst_line1[x+1].weight += w;
w = (weight2y * weight2x) >> 16;
- dst_line2[x+1].r += (line[0] * w) >> 16;
- dst_line2[x+1].g += (line[1] * w) >> 16;
- dst_line2[x+1].b += (line[2] * w) >> 16;
- dst_line2[x+1].a += (line[3] * w) >> 16;
+ dst_line2[x+1].r += (line[0] * w + 32767) >> 16;
+ dst_line2[x+1].g += (line[1] * w + 32767) >> 16;
+ dst_line2[x+1].b += (line[2] * w + 32767) >> 16;
+ dst_line2[x+1].a += (line[3] * w + 32767) >> 16;
dst_line2[x+1].weight += w;
x_dst += dx_dst;