fix for numeric problems for color balance in the sequencer (same check as in compositor).

for optimized builds this gave crazy colors.
This commit is contained in:
Campbell Barton 2010-07-07 15:06:57 +00:00
parent 358738c1aa
commit be1846bcf6
2 changed files with 10 additions and 5 deletions

@ -1536,9 +1536,14 @@ static StripColorBalance calc_cb(StripColorBalance * cb_)
} }
/* note: lift is actually 2-lift */ /* 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, static void make_cb_table_byte(float lift, float gain, float gamma,

@ -369,17 +369,17 @@ static void draw_seq_extensions(Scene *scene, SpaceSeq *sseq, Sequence *seq)
{ {
float x1, x2, y1, y2, pixely, a; float x1, x2, y1, y2, pixely, a;
char col[3], blendcol[3]; char col[3], blendcol[3];
View2D *v2d; View2D *v2d= &sseq->v2d;
if(seq->type >= SEQ_EFFECT) return; if(seq->type >= SEQ_EFFECT) return;
if(v2d->mask.ymax == v2d->mask.ymin) return; /* avoid divide by zero */
x1= seq->startdisp; x1= seq->startdisp;
x2= seq->enddisp; x2= seq->enddisp;
y1= seq->machine+SEQ_STRIP_OFSBOTTOM; y1= seq->machine+SEQ_STRIP_OFSBOTTOM;
y2= seq->machine+SEQ_STRIP_OFSTOP; y2= seq->machine+SEQ_STRIP_OFSTOP;
v2d = &sseq->v2d;
pixely = (v2d->cur.ymax - v2d->cur.ymin)/(v2d->mask.ymax - v2d->mask.ymin); pixely = (v2d->cur.ymax - v2d->cur.ymin)/(v2d->mask.ymax - v2d->mask.ymin);
blendcol[0] = blendcol[1] = blendcol[2] = 120; blendcol[0] = blendcol[1] = blendcol[2] = 120;