[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [13527] trunk/blender/source/blender: == Sequencer ==
Peter Schlaile
peter at schlaile.de
Sun Feb 3 00:28:50 CET 2008
Revision: 13527
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=13527
Author: schlaile
Date: 2008-02-03 00:28:50 +0100 (Sun, 03 Feb 2008)
Log Message:
-----------
== Sequencer ==
New feature: color balance aka 3-way-color-correction aka lift/gamma/gain
on input (folded into byte -> float conversion, so _very_ fast in that case).
Interface is inspired from Rebel CC (but not as complete yet, you can't
choose white and black points right now).
Bugfix: clamp color seperated wave form display correctly.
Modified Paths:
--------------
trunk/blender/source/blender/blenloader/intern/readfile.c
trunk/blender/source/blender/blenloader/intern/writefile.c
trunk/blender/source/blender/makesdna/DNA_sequence_types.h
trunk/blender/source/blender/src/buttons_scene.c
trunk/blender/source/blender/src/editseq.c
trunk/blender/source/blender/src/seqscopes.c
trunk/blender/source/blender/src/sequence.c
Modified: trunk/blender/source/blender/blenloader/intern/readfile.c
===================================================================
--- trunk/blender/source/blender/blenloader/intern/readfile.c 2008-02-02 22:40:07 UTC (rev 13526)
+++ trunk/blender/source/blender/blenloader/intern/readfile.c 2008-02-02 23:28:50 UTC (rev 13527)
@@ -3468,6 +3468,12 @@
} else {
seq->strip->proxy = 0;
}
+ if (seq->flag & SEQ_USE_COLOR_BALANCE) {
+ seq->strip->color_balance = newdataadr(
+ fd, seq->strip->color_balance);
+ } else {
+ seq->strip->color_balance = 0;
+ }
}
}
END_SEQ
Modified: trunk/blender/source/blender/blenloader/intern/writefile.c
===================================================================
--- trunk/blender/source/blender/blenloader/intern/writefile.c 2008-02-02 22:40:07 UTC (rev 13526)
+++ trunk/blender/source/blender/blenloader/intern/writefile.c 2008-02-02 23:28:50 UTC (rev 13527)
@@ -1505,6 +1505,9 @@
if(seq->flag & SEQ_USE_PROXY && strip->proxy) {
writestruct(wd, DATA, "StripProxy", 1, strip->proxy);
}
+ if(seq->flag & SEQ_USE_COLOR_BALANCE && strip->color_balance) {
+ writestruct(wd, DATA, "StripColorBalance", 1, strip->color_balance);
+ }
if(seq->type==SEQ_IMAGE)
writestruct(wd, DATA, "StripElem", strip->len, strip->stripdata);
else if(seq->type==SEQ_MOVIE || seq->type==SEQ_RAM_SOUND || seq->type == SEQ_HD_SOUND)
Modified: trunk/blender/source/blender/makesdna/DNA_sequence_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_sequence_types.h 2008-02-02 22:40:07 UTC (rev 13526)
+++ trunk/blender/source/blender/makesdna/DNA_sequence_types.h 2008-02-02 23:28:50 UTC (rev 13527)
@@ -69,6 +69,15 @@
int yofs;
} StripTransform;
+typedef struct StripColorBalance {
+ float lift[3];
+ float gamma[3];
+ float gain[3];
+ int flag;
+ float exposure;
+ float saturation;
+} StripColorBalance;
+
typedef struct StripProxy {
char dir[160];
int format;
@@ -86,6 +95,7 @@
StripCrop *crop;
StripTransform *transform;
StripProxy *proxy;
+ StripColorBalance *color_balance;
TStripElem *tstripdata;
TStripElem *tstripdata_startstill;
TStripElem *tstripdata_endstill;
@@ -248,7 +258,11 @@
#define SEQ_USE_PROXY 32768
#define SEQ_USE_TRANSFORM 65536
#define SEQ_USE_CROP 131072
+#define SEQ_USE_COLOR_BALANCE 262144
+#define SEQ_COLOR_BALANCE_INVERSE_GAIN 1
+#define SEQ_COLOR_BALANCE_INVERSE_GAMMA 2
+#define SEQ_COLOR_BALANCE_INVERSE_LIFT 4
/* seq->type WATCH IT: SEQ_EFFECT BIT is used to determine if this is an effect strip!!! */
#define SEQ_IMAGE 0
Modified: trunk/blender/source/blender/src/buttons_scene.c
===================================================================
--- trunk/blender/source/blender/src/buttons_scene.c 2008-02-02 22:40:07 UTC (rev 13526)
+++ trunk/blender/source/blender/src/buttons_scene.c 2008-02-02 23:28:50 UTC (rev 13527)
@@ -889,50 +889,113 @@
uiDefButBitI(block, TOG, SEQ_MAKE_PREMUL,
- B_SEQ_BUT_RELOAD, "Convert to Premul",
- 10,110,150,19, &last_seq->flag,
+ B_SEQ_BUT_RELOAD, "Premul",
+ 10,110,80,19, &last_seq->flag,
0.0, 21.0, 100, 0,
"Converts RGB values to become premultiplied with Alpha");
+ uiDefButBitI(block, TOG, SEQ_MAKE_FLOAT,
+ B_SEQ_BUT_RELOAD, "Float",
+ 90,110,80,19, &last_seq->flag,
+ 0.0, 21.0, 100, 0,
+ "Convert input to float data");
+
uiDefButBitI(block, TOG, SEQ_FILTERY,
B_SEQ_BUT_RELOAD, "FilterY",
- 10,90,75,19, &last_seq->flag,
+ 170,110,80,19, &last_seq->flag,
0.0, 21.0, 100, 0,
"For video movies to remove fields");
- uiDefButBitI(block, TOG, SEQ_MAKE_FLOAT,
- B_SEQ_BUT_RELOAD, "Make Float",
- 85,90,75,19, &last_seq->flag,
- 0.0, 21.0, 100, 0,
- "Convert input to float data");
-
uiDefButBitI(block, TOG, SEQ_FLIPX,
B_SEQ_BUT_RELOAD, "FlipX",
- 10,70,75,19, &last_seq->flag,
+ 10,90,80,19, &last_seq->flag,
0.0, 21.0, 100, 0,
"Flip on the X axis");
uiDefButBitI(block, TOG, SEQ_FLIPY,
B_SEQ_BUT_RELOAD, "FlipY",
- 85,70,75,19, &last_seq->flag,
+ 90,90,80,19, &last_seq->flag,
0.0, 21.0, 100, 0,
"Flip on the Y axis");
-
- uiDefButF(block, NUM, B_SEQ_BUT_RELOAD, "Mul:",
- 10,50,150,19, &last_seq->mul,
- 0.001, 5.0, 100, 0,
- "Multiply colors");
uiDefButBitI(block, TOG, SEQ_REVERSE_FRAMES,
- B_SEQ_BUT_RELOAD, "Reverse Frames",
- 10,30,150,19, &last_seq->flag,
+ B_SEQ_BUT_RELOAD, "Flip Time",
+ 170,90,80,19, &last_seq->flag,
0.0, 21.0, 100, 0,
"Reverse frame order");
+
+ uiDefButF(block, NUM, B_SEQ_BUT_RELOAD, "Mul:",
+ 10,70,120,19, &last_seq->mul,
+ 0.001, 5.0, 0.1, 0,
+ "Multiply colors");
uiDefButF(block, NUM, B_SEQ_BUT_RELOAD, "Strobe:",
- 10,10,150,19, &last_seq->strobe,
+ 130,70,120,19, &last_seq->strobe,
1.0, 30.0, 100, 0,
"Only display every nth frame");
+ uiDefButBitI(block, TOG, SEQ_USE_COLOR_BALANCE,
+ B_SEQ_BUT_RELOAD, "Use Color Balance",
+ 10,50,240,19, &last_seq->flag,
+ 0.0, 21.0, 100, 0,
+ "Activate Color Balance "
+ "(3-Way color correction) on input");
+
+
+ if (last_seq->flag & SEQ_USE_COLOR_BALANCE) {
+ if (!last_seq->strip->color_balance) {
+ int c;
+ StripColorBalance * cb
+ = last_seq->strip->color_balance
+ = MEM_callocN(
+ sizeof(struct StripColorBalance),
+ "StripColorBalance");
+ for (c = 0; c < 3; c++) {
+ cb->lift[c] = 1.0;
+ cb->gamma[c] = 1.0;
+ cb->gain[c] = 1.0;
+ }
+ }
+
+ uiDefBut(block, LABEL, 0, "Lift",
+ 10,30,80,19, 0, 0, 0, 0, 0, "");
+ uiDefBut(block, LABEL, 0, "Gamma",
+ 90,30,80,19, 0, 0, 0, 0, 0, "");
+ uiDefBut(block, LABEL, 0, "Gain",
+ 170,30,80,19, 0, 0, 0, 0, 0, "");
+
+ uiDefButF(block, COL, B_SEQ_BUT_RELOAD, "Lift",
+ 10,10,80,19, last_seq->strip->color_balance->lift,
+ 0, 0, 0, 0, "Lift (shadows)");
+
+ uiDefButF(block, COL, B_SEQ_BUT_RELOAD, "Gamma",
+ 90,10,80,19, last_seq->strip->color_balance->gamma,
+ 0, 0, 0, 0, "Gamma (midtones)");
+
+ uiDefButF(block, COL, B_SEQ_BUT_RELOAD, "Gain",
+ 170,10,80,19, last_seq->strip->color_balance->gain,
+ 0, 0, 0, 0, "Gain (highlights)");
+
+ uiDefButBitI(block, TOG, SEQ_COLOR_BALANCE_INVERSE_LIFT,
+ B_SEQ_BUT_RELOAD, "Inv Lift",
+ 10,-10,80,19,
+ &last_seq->strip->color_balance->flag,
+ 0.0, 21.0, 100, 0,
+ "Inverse Lift");
+ uiDefButBitI(block, TOG, SEQ_COLOR_BALANCE_INVERSE_GAMMA,
+ B_SEQ_BUT_RELOAD, "Inv Gamma",
+ 90,-10,80,19,
+ &last_seq->strip->color_balance->flag,
+ 0.0, 21.0, 100, 0,
+ "Inverse Gamma");
+ uiDefButBitI(block, TOG, SEQ_COLOR_BALANCE_INVERSE_GAIN,
+ B_SEQ_BUT_RELOAD, "Inv Gain",
+ 170,-10,80,19,
+ &last_seq->strip->color_balance->flag,
+ 0.0, 21.0, 100, 0,
+ "Inverse Gain");
+ }
+
+
uiBlockEndAlign(block);
}
Modified: trunk/blender/source/blender/src/editseq.c
===================================================================
--- trunk/blender/source/blender/src/editseq.c 2008-02-02 22:40:07 UTC (rev 13526)
+++ trunk/blender/source/blender/src/editseq.c 2008-02-02 23:28:50 UTC (rev 13527)
@@ -2190,6 +2190,11 @@
if (seq->strip->proxy) {
seqn->strip->proxy = MEM_dupallocN(seq->strip->proxy);
}
+
+ if (seq->strip->color_balance) {
+ seqn->strip->color_balance
+ = MEM_dupallocN(seq->strip->color_balance);
+ }
if(seq->type==SEQ_META) {
seqn->strip->stripdata = 0;
Modified: trunk/blender/source/blender/src/seqscopes.c
===================================================================
--- trunk/blender/source/blender/src/seqscopes.c 2008-02-02 22:40:07 UTC (rev 13526)
+++ trunk/blender/source/blender/src/seqscopes.c 2008-02-02 23:28:50 UTC (rev 13527)
@@ -323,7 +323,11 @@
float * rgb = src + 4 * (ibuf->x * y + x);
for (c = 0; c < 3; c++) {
unsigned char * p = tgt;
- p += 4 * (w * ((int) (rgb[c] * (h - 3)) + 1)
+ float v = rgb[c];
+
+ CLAMP(v, 0.0, 1.0);
+
+ p += 4 * (w * ((int) (v * (h - 3)) + 1)
+ c * sw + x/3 + 1);
scope_put_pixel_single(wtable, p, c);
Modified: trunk/blender/source/blender/src/sequence.c
===================================================================
--- trunk/blender/source/blender/src/sequence.c 2008-02-02 22:40:07 UTC (rev 13526)
+++ trunk/blender/source/blender/src/sequence.c 2008-02-02 23:28:50 UTC (rev 13527)
@@ -127,6 +127,9 @@
if (strip->proxy) {
seq_proxy_free(strip->proxy);
}
+ if (strip->color_balance) {
+ MEM_freeN(strip->color_balance);
+ }
free_tstripdata(strip->len, strip->tstripdata);
free_tstripdata(strip->endstill, strip->tstripdata_endstill);
@@ -1010,6 +1013,164 @@
}
}
+static StripColorBalance calc_cb(StripColorBalance * cb_)
+{
+ StripColorBalance cb = *cb_;
+ int c;
+
+ if (cb.flag & SEQ_COLOR_BALANCE_INVERSE_LIFT) {
+ for (c = 0; c < 3; c++) {
+ cb.lift[c] = 1.0 - cb.lift[c];
+ }
+ } else {
+ for (c = 0; c < 3; c++) {
+ cb.lift[c] = -(1.0 - cb.lift[c]);
+ }
+ }
+ if (cb.flag & SEQ_COLOR_BALANCE_INVERSE_GAIN) {
+ for (c = 0; c < 3; c++) {
+ if (cb.gain[c] != 0.0) {
+ cb.gain[c] = 1.0/cb.gain[c];
+ } else {
+ cb.gain[c] = 1000000; /* should be enough :) */
+ }
+ }
+ }
+
+ if (!(cb.flag & SEQ_COLOR_BALANCE_INVERSE_GAMMA)) {
+ for (c = 0; c < 3; c++) {
+ if (cb.gain[c] != 0.0) {
+ cb.gamma[c] = 1.0/cb.gamma[c];
+ } else {
+ cb.gamma[c] = 1000000; /* should be enough :) */
+ }
+ }
+ }
+
+ return cb;
+}
+
+static void make_cb_table_byte(float lift, float gain, float gamma,
+ unsigned char * table, float mul)
+{
+ int y;
+
+ for (y = 0; y < 256; y++) {
+ float v = 1.0 * y / 255;
+ v += lift;
+ v *= gain;
+ v = pow(v, gamma);
+ v *= mul;
+ if ( v > 1.0) {
+ v = 1.0;
+ } else if (v < 0.0) {
+ v = 0.0;
+ }
+ table[y] = v * 255;
+ }
+
+}
+
+static void make_cb_table_float(float lift, float gain, float gamma,
+ float * table, float mul)
+{
+ int y;
+
+ for (y = 0; y < 256; y++) {
+ float v = (float) y * 1.0 / 255.0;
+ v += lift;
+ v *= gain;
+ v = pow(v, gamma);
+ v *= mul;
+ table[y] = v;
+ }
+}
+
+static void color_balance_byte_byte(Sequence * seq, TStripElem* se,
+ float mul)
+{
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list