[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [30081] trunk/blender/source/blender: fix for numeric problems for color balance in the sequencer ( same check as in compositor).

Campbell Barton ideasman42 at gmail.com
Wed Jul 7 17:06:57 CEST 2010


Revision: 30081
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=30081
Author:   campbellbarton
Date:     2010-07-07 17:06:57 +0200 (Wed, 07 Jul 2010)

Log Message:
-----------
fix for numeric problems for color balance in the sequencer (same check as in compositor).
for optimized builds this gave crazy colors.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/sequencer.c
    trunk/blender/source/blender/editors/space_sequencer/sequencer_draw.c

Modified: trunk/blender/source/blender/blenkernel/intern/sequencer.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/sequencer.c	2010-07-07 14:52:55 UTC (rev 30080)
+++ trunk/blender/source/blender/blenkernel/intern/sequencer.c	2010-07-07 15:06:57 UTC (rev 30081)
@@ -1536,9 +1536,14 @@
 }
 
 /* note: lift is actually 2-lift */
-MINLINE float color_balance_fl(float v, const float lift, const float gain, const float gamma, const float mul)
+MINLINE float color_balance_fl(float in, const float lift, const float gain, const float gamma, const float mul)
 {
-	return powf((((v - 1.0f) * lift) + 1.0f) * gain, gamma) * mul;
+	float x= (((in - 1.0f) * lift) + 1.0f) * gain;
+
+	/* prevent NaN */
+	if (x < 0.f) x = 0.f;
+
+	return powf(x, gamma) * mul;
 }
 
 static void make_cb_table_byte(float lift, float gain, float gamma,

Modified: trunk/blender/source/blender/editors/space_sequencer/sequencer_draw.c
===================================================================
--- trunk/blender/source/blender/editors/space_sequencer/sequencer_draw.c	2010-07-07 14:52:55 UTC (rev 30080)
+++ trunk/blender/source/blender/editors/space_sequencer/sequencer_draw.c	2010-07-07 15:06:57 UTC (rev 30081)
@@ -369,17 +369,17 @@
 {
 	float x1, x2, y1, y2, pixely, a;
 	char col[3], blendcol[3];
-	View2D *v2d;
+	View2D *v2d= &sseq->v2d;
 	
 	if(seq->type >= SEQ_EFFECT) return;
+	if(v2d->mask.ymax == v2d->mask.ymin) return; /* avoid divide by zero */
 
 	x1= seq->startdisp;
 	x2= seq->enddisp;
 	
 	y1= seq->machine+SEQ_STRIP_OFSBOTTOM;
 	y2= seq->machine+SEQ_STRIP_OFSTOP;
-	
-	v2d = &sseq->v2d;
+
 	pixely = (v2d->cur.ymax - v2d->cur.ymin)/(v2d->mask.ymax - v2d->mask.ymin);
 	
 	blendcol[0] = blendcol[1] = blendcol[2] = 120;





More information about the Bf-blender-cvs mailing list