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
path: root/source
diff options
context:
space:
mode:
authorPeter Schlaile <peter@schlaile.de>2009-06-17 01:16:22 +0400
committerPeter Schlaile <peter@schlaile.de>2009-06-17 01:16:22 +0400
commit74d3d136dbd98f59fb7ba2f9b908330caf15e411 (patch)
tree36a46c93717736f1e5a1b2b72a5528eed87203b3 /source
parent2faf20c4b3ae1ca6c82dd2a942d2f2a580685436 (diff)
== Sequencer ==
Fixed color balance tool. Problem was: we pretended to do Lift/Gamma/Gain, but in reality we did (1-Offset)/Power/Slope. (slightly modified ASC CDL). So now, the GUI is able to switch modes between ASC CDL-mode and real Lift/Gamma/Gain. It also adds a switch to enable Neutral Black/White flipping (very usefull for black point selection) This closes: [#18078] bugfix #18010 Sequencer lift
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenloader/intern/readfile.c3
-rw-r--r--source/blender/include/butspace.h2
-rw-r--r--source/blender/makesdna/DNA_sequence_types.h18
-rw-r--r--source/blender/src/buttons_scene.c277
-rw-r--r--source/blender/src/editseq.c4
-rw-r--r--source/blender/src/sequence.c11
6 files changed, 268 insertions, 47 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index b4efa5d1432..4e5789d87e8 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -3703,6 +3703,9 @@ static void direct_link_scene(FileData *fd, Scene *sce)
} else {
seq->strip->color_balance = 0;
}
+ if (seq->strip->color_balance) {
+ seq->strip->color_balance->gui = 0;
+ }
}
}
END_SEQ
diff --git a/source/blender/include/butspace.h b/source/blender/include/butspace.h
index 8aaf4a7c65b..998453ca69b 100644
--- a/source/blender/include/butspace.h
+++ b/source/blender/include/butspace.h
@@ -378,6 +378,8 @@ void curvemap_buttons(struct uiBlock *block, struct CurveMapping *cumap, char la
#define B_SEQ_BUT_REBUILD_PROXY 1697
#define B_SEQ_SEL_PROXY_DIR 1698
#define B_SEQ_SEL_PROXY_FILE 1699
+#define B_SEQ_BUT_COLOR_BALANCE 1700
+
/* *********************** */
#define B_ARMATUREBUTS 1800
#define B_POSE 1701
diff --git a/source/blender/makesdna/DNA_sequence_types.h b/source/blender/makesdna/DNA_sequence_types.h
index b6815df9fc5..707e06cf9cb 100644
--- a/source/blender/makesdna/DNA_sequence_types.h
+++ b/source/blender/makesdna/DNA_sequence_types.h
@@ -38,6 +38,7 @@
struct Ipo;
struct Scene;
+struct StripColorBalanceGUIHelper;
/* strlens; 80= FILE_MAXFILE, 160= FILE_MAXDIR */
@@ -71,9 +72,11 @@ typedef struct StripColorBalance {
float gamma[3];
float gain[3];
int flag;
- int pad;
+ int mode;
float exposure;
float saturation;
+ int pad;
+ struct StripColorBalanceGUIHelper * gui;
} StripColorBalance;
typedef struct StripProxy {
@@ -263,9 +266,16 @@ typedef struct SpeedControlVars {
#define SEQ_ACTIVE 1048576
#define SEQ_USE_PROXY_CUSTOM_FILE 2097152
-#define SEQ_COLOR_BALANCE_INVERSE_GAIN 1
-#define SEQ_COLOR_BALANCE_INVERSE_GAMMA 2
-#define SEQ_COLOR_BALANCE_INVERSE_LIFT 4
+#define SEQ_COLOR_BALANCE_INVERSE_GAIN 1
+#define SEQ_COLOR_BALANCE_INVERSE_GAMMA 2
+#define SEQ_COLOR_BALANCE_INVERSE_LIFT 4
+
+#define SEQ_COLOR_BALANCE_GUI_BW_FLIP_GAIN 8
+#define SEQ_COLOR_BALANCE_GUI_BW_FLIP_GAMMA 16
+#define SEQ_COLOR_BALANCE_GUI_BW_FLIP_LIFT 32
+
+#define SEQ_COLOR_BALANCE_GUI_MODE_LGG 0
+#define SEQ_COLOR_BALANCE_GUI_MODE_ASC_CDL 1
/* seq->type WATCH IT: SEQ_EFFECT BIT is used to determine if this is an effect strip!!! */
#define SEQ_IMAGE 0
diff --git a/source/blender/src/buttons_scene.c b/source/blender/src/buttons_scene.c
index dac093b6ba8..5e0d91cfae7 100644
--- a/source/blender/src/buttons_scene.c
+++ b/source/blender/src/buttons_scene.c
@@ -480,6 +480,13 @@ static void sound_panel_sound(bSound *sound)
/* ************************* Sequencer *********************** */
+typedef struct StripColorBalanceGUIHelper {
+ float lift[3];
+ float gamma[3];
+ float gain[3];
+ int flag;
+} StripColorBalanceGUIHelper;
+
#define SEQ_PANEL_EDITING 1
#define SEQ_PANEL_INPUT 2
#define SEQ_PANEL_FILTER 4
@@ -520,6 +527,108 @@ static char* seq_panel_blend_modes()
return string;
}
+static char* seq_panel_color_balance_modes()
+{
+ static char string[2048];
+
+ sprintf(string, "Color balance mode: %%t|%s %%x%d|%s %%x%d",
+ "LiftGamGain", SEQ_COLOR_BALANCE_GUI_MODE_LGG,
+ "ASC CDL", SEQ_COLOR_BALANCE_GUI_MODE_ASC_CDL);
+
+ return string;
+}
+
+static void copy_to_color_balance_gui(StripColorBalance * cb)
+{
+ int c;
+ StripColorBalanceGUIHelper * cg = cb->gui;
+
+ for (c = 0; c < 3; c++) {
+ /* well in ACL terms,
+
+ cb->lift is actually 1 - offset
+ cb->gamma is actually power
+ cb->gain is actually slope
+
+ sorry for the confusion, that is for
+ DNA backward compatibility...
+
+ might better be renamed to low, mid, high (neutral terms)
+
+ our lift / gamma / gain balancer sticks to neutral white
+ (by default, can be switched with BW_FLIP)
+ and therefore has:
+
+ lift is actually 1 - lift
+ gain is gain :)
+ gamma is actually power
+ */
+
+ cg->lift[c] = cb->lift[c];
+ cg->gamma[c] = cb->gamma[c];
+ cg->gain[c] = cb->gain[c];
+
+ if (cb->mode == SEQ_COLOR_BALANCE_GUI_MODE_LGG) {
+ float offset = cg->lift[c];
+ float slope = cg->gain[c];
+
+ offset = 1 - offset;
+
+ cg->gain[c] = offset + slope;
+ cg->lift[c] = offset/(offset + slope);
+
+ cg->lift[c] = 1 - cg->lift[c];
+
+ }
+
+ if (cb->flag & SEQ_COLOR_BALANCE_GUI_BW_FLIP_LIFT) {
+ cg->lift[c] = 1 - cg->lift[c];
+ }
+ if (cb->flag & SEQ_COLOR_BALANCE_GUI_BW_FLIP_GAMMA) {
+ cg->gamma[c] = 1 - cg->gamma[c];
+ }
+ if (cb->flag & SEQ_COLOR_BALANCE_GUI_BW_FLIP_GAIN) {
+ cg->gain[c] = 1 - cg->gain[c];
+ }
+ }
+}
+
+static void copy_from_color_balance_gui(StripColorBalance * cb)
+{
+ int c;
+ StripColorBalanceGUIHelper * cg = cb->gui;
+
+ for (c = 0; c < 3; c++) {
+ /* see note above regarding confusing variable names */
+
+ cb->lift[c] = cg->lift[c];
+ cb->gamma[c] = cg->gamma[c];
+ cb->gain[c] = cg->gain[c];
+
+ if (cb->flag & SEQ_COLOR_BALANCE_GUI_BW_FLIP_LIFT) {
+ cb->lift[c] = 1 - cb->lift[c];
+ }
+ if (cb->flag & SEQ_COLOR_BALANCE_GUI_BW_FLIP_GAMMA) {
+ cb->gamma[c] = 1 - cb->gamma[c];
+ }
+ if (cb->flag & SEQ_COLOR_BALANCE_GUI_BW_FLIP_GAIN) {
+ cb->gain[c] = 1 - cb->gain[c];
+ }
+
+ if (cb->mode == SEQ_COLOR_BALANCE_GUI_MODE_LGG) {
+ float lift = cb->lift[c];
+ float gain = cb->gain[c];
+
+ lift = 1 - lift;
+
+ cb->gain[c] = ( 1 - lift ) * gain;
+ cb->lift[c] = lift * gain;
+
+ cb->lift[c] = 1 - cb->lift[c];
+ }
+ }
+}
+
static char* seq_panel_scenes()
{
static char rstr[8192];
@@ -948,19 +1057,30 @@ static void seq_panel_filter_video()
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) {
+ uiDefButBitI(block, TOG, SEQ_USE_COLOR_BALANCE,
+ B_SEQ_BUT_RELOAD, "Use CB",
+ 10,50,120,19, &last_seq->flag,
+ 0.0, 21.0, 100, 0,
+ "Activate Color Balance "
+ "(3-Way color correction) on input");
+ } else {
+ 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) {
+ StripColorBalance * cb = last_seq->strip->color_balance;
+ StripColorBalanceGUIHelper * cg;
+ int xofs;
+
+ if (!cb) {
int c;
- StripColorBalance * cb
- = last_seq->strip->color_balance
+ cb = last_seq->strip->color_balance
= MEM_callocN(
sizeof(struct StripColorBalance),
"StripColorBalance");
@@ -971,43 +1091,111 @@ static void seq_panel_filter_video()
}
}
- 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)");
+ uiDefButI(block, MENU, B_SEQ_BUT_COLOR_BALANCE,
+ seq_panel_color_balance_modes(),
+ 130, 50, 120, 19, &cb->mode,
+ 0,0,0,0, "Color balance mode");
+
+ if (!cb->gui) {
+ cb->gui = MEM_callocN(
+ sizeof(struct StripColorBalanceGUIHelper),
+ "StripColorBalanceGUIHelper");
+ copy_to_color_balance_gui(cb);
+ cb->gui->flag = cb->flag;
+ }
- uiDefButF(block, COL, B_SEQ_BUT_RELOAD, "Gamma",
- 90,10,80,19, last_seq->strip->color_balance->gamma,
- 0, 0, 0, 0, "Gamma (midtones)");
+ cg = cb->gui;
+
+ if (cb->mode == SEQ_COLOR_BALANCE_GUI_MODE_ASC_CDL) {
+ uiDefBut(block, LABEL, 0, "Ofs (shad)",
+ 10,30,80,19, 0, 0, 0, 0, 0, "");
+ uiDefBut(block, LABEL, 0, "Pow (midt)",
+ 90,30,80,19, 0, 0, 0, 0, 0, "");
+ uiDefBut(block, LABEL, 0, "Slp (high)",
+ 170,30,80,19, 0, 0, 0, 0, 0, "");
+
+ uiDefButF(block, COL, B_SEQ_BUT_COLOR_BALANCE,
+ "1-Offset",
+ 10,10,80,19, cg->lift,
+ 0, 0, 0, 0, "1 - Offset (shadows)");
+
+ uiDefButF(block, COL, B_SEQ_BUT_COLOR_BALANCE,
+ "Gamma",
+ 90,10,80,19, cg->gamma,
+ 0, 0, 0, 0, "Power (midtones)");
+
+ uiDefButF(block, COL, B_SEQ_BUT_COLOR_BALANCE,
+ "Slope",
+ 170,10,80,19, cg->gain,
+ 0, 0, 0, 0, "Slope (highlights)");
+ } else {
+ uiDefBut(block, LABEL, 0, "Lift (shad)",
+ 10,30,80,19, 0, 0, 0, 0, 0, "");
+ uiDefBut(block, LABEL, 0, "Gamma (mi)",
+ 90,30,80,19, 0, 0, 0, 0, 0, "");
+ uiDefBut(block, LABEL, 0, "Gain (high)",
+ 170,30,80,19, 0, 0, 0, 0, 0, "");
+
+ uiDefButF(block, COL, B_SEQ_BUT_COLOR_BALANCE,
+ "1-Lift",
+ 10,10,80,19, cg->lift,
+ 0, 0, 0, 0, "1 - Lift (shadows)");
+
+ uiDefButF(block, COL, B_SEQ_BUT_COLOR_BALANCE,
+ "1/Gamma",
+ 90,10,80,19, cg->gamma,
+ 0, 0, 0, 0, "1 / Gamma (midtones)");
+
+ uiDefButF(block, COL, B_SEQ_BUT_COLOR_BALANCE,
+ "Gain",
+ 170,10,80,19, cg->gain,
+ 0, 0, 0, 0, "Gain (highlights)");
+ }
- uiDefButF(block, COL, B_SEQ_BUT_RELOAD, "Gain",
- 170,10,80,19, last_seq->strip->color_balance->gain,
- 0, 0, 0, 0, "Gain (highlights)");
+ xofs = 10;
uiDefButBitI(block, TOG, SEQ_COLOR_BALANCE_INVERSE_LIFT,
- B_SEQ_BUT_RELOAD, "Inv Lift",
- 10,-10,80,19,
- &last_seq->strip->color_balance->flag,
+ B_SEQ_BUT_COLOR_BALANCE, "Inverse",
+ xofs,-10,55,19,
+ &cb->flag,
0.0, 21.0, 100, 0,
- "Inverse Lift");
+ "Inverse");
+ xofs += 55;
+
+ uiDefButBitI(block, TOG, SEQ_COLOR_BALANCE_GUI_BW_FLIP_LIFT,
+ B_SEQ_BUT_COLOR_BALANCE, "NB",
+ xofs,-10,25,19,
+ &cb->flag,
+ 0.0, 21.0, 100, 0,
+ "Neutral Black");
+ xofs += 25;
uiDefButBitI(block, TOG, SEQ_COLOR_BALANCE_INVERSE_GAMMA,
- B_SEQ_BUT_RELOAD, "Inv Gamma",
- 90,-10,80,19,
- &last_seq->strip->color_balance->flag,
+ B_SEQ_BUT_COLOR_BALANCE, "Inverse",
+ xofs,-10,55,19,
+ &cb->flag,
0.0, 21.0, 100, 0,
- "Inverse Gamma");
+ "Inverse");
+ xofs += 55;
+ uiDefButBitI(block, TOG, SEQ_COLOR_BALANCE_GUI_BW_FLIP_GAMMA,
+ B_SEQ_BUT_COLOR_BALANCE, "NB",
+ xofs,-10,25,19,
+ &cb->flag,
+ 0.0, 21.0, 100, 0,
+ "Neutral Black");
+ xofs += 25;
uiDefButBitI(block, TOG, SEQ_COLOR_BALANCE_INVERSE_GAIN,
- B_SEQ_BUT_RELOAD, "Inv Gain",
- 170,-10,80,19,
- &last_seq->strip->color_balance->flag,
+ B_SEQ_BUT_COLOR_BALANCE, "Inverse",
+ xofs,-10,55,19,
+ &cb->flag,
+ 0.0, 21.0, 100, 0,
+ "Inverse");
+ xofs += 55;
+ uiDefButBitI(block, TOG, SEQ_COLOR_BALANCE_GUI_BW_FLIP_GAIN,
+ B_SEQ_BUT_COLOR_BALANCE, "NB",
+ xofs,-10,25,19,
+ &cb->flag,
0.0, 21.0, 100, 0,
- "Inverse Gain");
+ "Neutral Black");
}
@@ -1398,6 +1586,19 @@ void do_sequencer_panels(unsigned short event)
last_seq->strip->proxy->dir,
sel_proxy_file);
break;
+ case B_SEQ_BUT_COLOR_BALANCE: {
+ if (last_seq->strip && last_seq->strip->color_balance &&
+ last_seq->strip->color_balance->gui) {
+ StripColorBalance * cb=last_seq->strip->color_balance;
+ if (cb->gui->flag != cb->flag) {
+ copy_to_color_balance_gui(cb);
+ cb->gui->flag = cb->flag;
+ } else {
+ copy_from_color_balance_gui(cb);
+ }
+ }
+ /* fall through */
+ }
case B_SEQ_BUT_RELOAD:
case B_SEQ_BUT_RELOAD_ALL:
update_seq_ipo_rect(last_seq);
diff --git a/source/blender/src/editseq.c b/source/blender/src/editseq.c
index 48c301ab051..603a0e6b056 100644
--- a/source/blender/src/editseq.c
+++ b/source/blender/src/editseq.c
@@ -2290,6 +2290,10 @@ static Sequence *dupli_seq(Sequence *seq)
if (seq->strip->color_balance) {
seqn->strip->color_balance
= MEM_dupallocN(seq->strip->color_balance);
+ if (seq->strip->color_balance->gui) {
+ seqn->strip->color_balance->gui
+ =MEM_dupallocN(seq->strip->color_balance->gui);
+ }
}
if(seq->type==SEQ_META) {
diff --git a/source/blender/src/sequence.c b/source/blender/src/sequence.c
index 5a63e3ea995..482654de7ca 100644
--- a/source/blender/src/sequence.c
+++ b/source/blender/src/sequence.c
@@ -141,6 +141,9 @@ void free_strip(Strip *strip)
MEM_freeN(strip->transform);
}
if (strip->color_balance) {
+ if (strip->color_balance->gui) {
+ MEM_freeN(strip->color_balance->gui);
+ }
MEM_freeN(strip->color_balance);
}
@@ -1292,12 +1295,10 @@ 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++) {
+ for (c = 0; c < 3; c++) {
+ if (cb.flag & SEQ_COLOR_BALANCE_INVERSE_LIFT) {
cb.lift[c] = 1.0 - cb.lift[c];
- }
- } else {
- for (c = 0; c < 3; c++) {
+ } else {
cb.lift[c] = -(1.0 - cb.lift[c]);
}
}