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:
Diffstat (limited to 'source/blender/blenkernel/intern/sequencer.c')
-rw-r--r--source/blender/blenkernel/intern/sequencer.c92
1 files changed, 60 insertions, 32 deletions
diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c
index 4241f481c30..a4c1527c3c5 100644
--- a/source/blender/blenkernel/intern/sequencer.c
+++ b/source/blender/blenkernel/intern/sequencer.c
@@ -49,6 +49,7 @@
#include "RNA_access.h"
#include "RE_pipeline.h"
+#include "BLI_math.h"
#include "BLI_fileops.h"
#include "BLI_listbase.h"
#include "BLI_path_util.h"
@@ -213,6 +214,8 @@ void seq_free_strip(Strip *strip)
MEM_freeN(strip);
}
+static void seq_free_animdata(Scene *scene, Sequence *seq);
+
void seq_free_sequence(Scene *scene, Sequence *seq)
{
if(seq->strip) seq_free_strip(seq->strip);
@@ -236,6 +239,8 @@ void seq_free_sequence(Scene *scene, Sequence *seq)
sound_remove_scene_sound(scene, seq->scene_sound);
}
+ seq_free_animdata(scene, seq);
+
MEM_freeN(seq);
}
@@ -545,8 +550,8 @@ void calc_sequence(Scene *scene, Sequence *seq)
if(seq->type==SEQ_META) {
seqm= seq->seqbase.first;
if(seqm) {
- min= 1000000;
- max= -1000000;
+ min= MAXFRAME * 2;
+ max= -MAXFRAME * 2;
while(seqm) {
if(seqm->startdisp < min) min= seqm->startdisp;
if(seqm->enddisp > max) max= seqm->enddisp;
@@ -1488,15 +1493,16 @@ 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] = 2.0f - pow(cb.lift[c], 2);
+ }
+
+ if(cb.flag & SEQ_COLOR_BALANCE_INVERSE_LIFT) {
for (c = 0; c < 3; c++) {
- cb.lift[c] = -(1.0 - cb.lift[c]);
+ cb.lift[c] = 2.0f - cb.lift[c];
}
}
+
if (cb.flag & SEQ_COLOR_BALANCE_INVERSE_GAIN) {
for (c = 0; c < 3; c++) {
if (cb.gain[c] != 0.0) {
@@ -1520,25 +1526,22 @@ static StripColorBalance calc_cb(StripColorBalance * cb_)
return cb;
}
+/* pow(p[c] * cb.gain[c] + cb.lift[c], cb.gamma[c]) * mul;*/
+MINLINE float color_balance_fl(const float v, const float lift, const float gain, const float gamma, const float mul)
+{
+ return powf(powf(v * gain, lift), gamma) * mul;
+}
+
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 *= gain;
- v += lift;
- v = pow(v, gamma);
- v *= mul;
- if ( v > 1.0) {
- v = 1.0;
- } else if (v < 0.0) {
- v = 0.0;
- }
+ float v= color_balance_fl((float)y * (1.0 / 255.0f), lift, gain, gamma, mul);
+ CLAMP(v, 0.0f, 1.0f);
table[y] = v * 255;
}
-
}
static void make_cb_table_float(float lift, float gain, float gamma,
@@ -1547,11 +1550,7 @@ static void make_cb_table_float(float lift, float gain, float gamma,
int y;
for (y = 0; y < 256; y++) {
- float v = (float) y * 1.0 / 255.0;
- v *= gain;
- v += lift;
- v = pow(v, gamma);
- v *= mul;
+ float v= color_balance_fl((float)y * (1.0 / 255.0f), lift, gain, gamma, mul);
table[y] = v;
}
}
@@ -1622,8 +1621,7 @@ static void color_balance_float_float(Sequence * seq, TStripElem* se, float mul)
while (p < e) {
int c;
for (c = 0; c < 3; c++) {
- p[c] = pow(p[c] * cb.gain[c] + cb.lift[c],
- cb.gamma[c]) * mul;
+ p[c]= color_balance_fl(p[c], cb.lift[c], cb.gain[c], cb.gamma[c], mul);
}
p += 4;
}
@@ -3842,6 +3840,33 @@ void seq_offset_animdata(Scene *scene, Sequence *seq, int ofs)
}
}
+/* XXX - hackish function needed to remove all fcurves belonging to a sequencer strip */
+static void seq_free_animdata(Scene *scene, Sequence *seq)
+{
+ char str[32];
+ FCurve *fcu;
+
+ if(scene->adt==NULL || scene->adt->action==NULL)
+ return;
+
+ sprintf(str, "[\"%s\"]", seq->name+2);
+
+ fcu= scene->adt->action->curves.first;
+
+ while (fcu) {
+ if(strstr(fcu->rna_path, "sequence_editor.sequences_all[") && strstr(fcu->rna_path, str)) {
+ FCurve *next_fcu = fcu->next;
+
+ BLI_remlink(&scene->adt->action->curves, fcu);
+ free_fcurve(fcu);
+
+ fcu = next_fcu;
+ } else {
+ fcu = fcu->next;
+ }
+ }
+}
+
Sequence *get_seq_by_name(ListBase *seqbase, const char *name, int recursive)
{
@@ -3909,7 +3934,7 @@ int seq_active_pair_get(Scene *scene, Sequence **seq_act, Sequence **seq_other)
void seq_load_apply(Scene *scene, Sequence *seq, SeqLoadInfo *seq_load)
{
if(seq) {
- strcpy(seq->name, seq_load->name);
+ BLI_strncpy(seq->name+2, seq_load->name, sizeof(seq->name)-2);
seqbase_unique_name_recursive(&scene->ed->seqbase, seq);
if(seq_load->flag & SEQ_LOAD_FRAME_ADVANCE) {
@@ -3963,8 +3988,7 @@ Sequence *sequencer_add_image_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo
seq = alloc_sequence(seqbasep, seq_load->start_frame, seq_load->channel);
seq->type= SEQ_IMAGE;
- BLI_strncpy(seq->name+2, "Image", SEQ_NAME_MAXSTR-2);
- seqbase_unique_name_recursive(&scene->ed->seqbase, seq);
+ seq->blend_mode= SEQ_CROSS; /* so alpha adjustment fade to the strip below */
/* basic defaults */
seq->strip= strip= MEM_callocN(sizeof(Strip), "strip");
@@ -3972,8 +3996,8 @@ Sequence *sequencer_add_image_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo
strip->len = seq->len = seq_load->len ? seq_load->len : 1;
strip->us= 1;
strip->stripdata= se= MEM_callocN(seq->len*sizeof(StripElem), "stripelem");
- BLI_split_dirfile(seq_load->path, strip->dir, se->name);
-
+ BLI_strncpy(strip->dir, seq_load->path, sizeof(strip->dir));
+
seq_load_apply(scene, seq, seq_load);
return seq;
@@ -4056,8 +4080,9 @@ Sequence *sequencer_add_movie_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo
return NULL;
seq = alloc_sequence(seqbasep, seq_load->start_frame, seq_load->channel);
-
seq->type= SEQ_MOVIE;
+ seq->blend_mode= SEQ_CROSS; /* so alpha adjustment fade to the strip below */
+
seq->anim= an;
seq->anim_preseek = IMB_anim_get_preseek(an);
BLI_strncpy(seq->name+2, "Movie", SEQ_NAME_MAXSTR-2);
@@ -4085,6 +4110,9 @@ Sequence *sequencer_add_movie_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo
seq_load->channel--;
}
+ if(seq_load->name[0] == '\0')
+ BLI_strncpy(seq_load->name, se->name, sizeof(seq_load->name));
+
/* can be NULL */
seq_load_apply(scene, seq, seq_load);