== Sequencer ==
A lot of fixes for anim_startofs / anim_endofs: * crashed when striplen was 0 and startstill / endstill still in use * made it work for Audio (HD and RAM) * made it work for Image Sequences * added a new cutting tool, that uses anim_startofs / endofs instead of startofs / endofs. This is now the default and called "hard cut" * moved old cutting method to "Shift-K" and renamed it "soft cut"
This commit is contained in:
@@ -1528,7 +1528,7 @@ static void write_scenes(WriteData *wd, ListBase *scebase)
|
||||
writestruct(wd, DATA, "StripColorBalance", 1, strip->color_balance);
|
||||
}
|
||||
if(seq->type==SEQ_IMAGE)
|
||||
writestruct(wd, DATA, "StripElem", strip->len, strip->stripdata);
|
||||
writestruct(wd, DATA, "StripElem", MEM_allocN_len(strip->stripdata) / sizeof(struct StripElem), strip->stripdata);
|
||||
else if(seq->type==SEQ_MOVIE || seq->type==SEQ_RAM_SOUND || seq->type == SEQ_HD_SOUND)
|
||||
writestruct(wd, DATA, "StripElem", 1, strip->stripdata);
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ void seq_remap_paths(void);
|
||||
void transform_seq(int mode, int context);
|
||||
void transform_seq_nomarker(int mode, int context);
|
||||
void un_meta(void);
|
||||
void seq_cut(int cutframe);
|
||||
void seq_cut(int cutframe, int hard_cut);
|
||||
void seq_separate_images(void);
|
||||
void reassign_inputs_seq_effect(void);
|
||||
void select_surrounding_handles(struct Sequence *test);
|
||||
|
||||
@@ -614,7 +614,7 @@ static void seq_panel_editing()
|
||||
130, 80, 120, 20, &last_seq->machine,
|
||||
0.0, MAXSEQ, 0.0, 0.0, "Channel used (Y position)");
|
||||
|
||||
if (check_single_seq(last_seq)) {
|
||||
if (check_single_seq(last_seq) || last_seq->len == 0) {
|
||||
uiDefButI(block, NUM,
|
||||
B_SEQ_BUT_TRANSFORM, "End-Still",
|
||||
130, 60, 120, 19, &last_seq->endstill,
|
||||
@@ -858,12 +858,12 @@ static void seq_panel_input()
|
||||
B_SEQ_BUT_RELOAD_FILE, "A-Start",
|
||||
10, 0, 120, 20, &last_seq->anim_startofs,
|
||||
0.0, last_seq->len + last_seq->anim_startofs, 0.0, 0.0,
|
||||
"Animation start offset in file");
|
||||
"Animation start offset (trim start)");
|
||||
uiDefButI(block, NUM,
|
||||
B_SEQ_BUT_RELOAD_FILE, "A-End",
|
||||
130, 0, 120, 20, &last_seq->anim_endofs,
|
||||
0.0, last_seq->len + last_seq->anim_endofs, 0.0, 0.0,
|
||||
"Animation end offset in file");
|
||||
"Animation end offset (trim end)");
|
||||
|
||||
|
||||
if (last_seq->type == SEQ_MOVIE) {
|
||||
@@ -1235,8 +1235,8 @@ void sequencer_panels()
|
||||
panels |= SEQ_PANEL_INPUT | SEQ_PANEL_FILTER | SEQ_PANEL_PROXY;
|
||||
}
|
||||
|
||||
if (type == SEQ_RAM_SOUND) {
|
||||
panels |= SEQ_PANEL_FILTER;
|
||||
if (type == SEQ_RAM_SOUND || type == SEQ_HD_SOUND) {
|
||||
panels |= SEQ_PANEL_FILTER | SEQ_PANEL_INPUT;
|
||||
}
|
||||
|
||||
if (type == SEQ_PLUGIN || type >= SEQ_EFFECT) {
|
||||
|
||||
@@ -308,8 +308,8 @@ static void drawseqwave(Sequence *seq, float x1, float y1, float x2, float y2, i
|
||||
|
||||
if (seq->flag & SEQ_MUTE) glColor3ub(0x70, 0x80, 0x80); else glColor3ub(0x70, 0xc0, 0xc0);
|
||||
|
||||
sofs = ((int)( FRA2TIME(seq->startdisp-seq->start)*(float)G.scene->audio.mixrate*4.0 )) & (~3);
|
||||
eofs = ((int)( FRA2TIME(seq->enddisp-seq->start)*(float)G.scene->audio.mixrate*4.0 )) & (~3);
|
||||
sofs = ((int)( FRA2TIME(seq->startdisp-seq->start+seq->anim_startofs)*(float)G.scene->audio.mixrate*4.0 )) & (~3);
|
||||
eofs = ((int)( FRA2TIME(seq->enddisp-seq->start+seq->anim_startofs)*(float)G.scene->audio.mixrate*4.0 )) & (~3);
|
||||
|
||||
/* clip the drawing area to the screen bounds to save time */
|
||||
sample_step= (G.v2d->cur.xmax - G.v2d->cur.xmin)/winx;
|
||||
|
||||
@@ -2287,7 +2287,99 @@ static void recurs_dupli_seq(ListBase *old, ListBase *new)
|
||||
}
|
||||
}
|
||||
|
||||
static Sequence * cut_seq(Sequence * seq, int cutframe)
|
||||
static Sequence * cut_seq_hard(Sequence * seq, int cutframe)
|
||||
{
|
||||
TransSeq ts;
|
||||
Sequence *seqn = 0;
|
||||
int skip_dup = FALSE;
|
||||
|
||||
/* backup values */
|
||||
ts.start= seq->start;
|
||||
ts.machine= seq->machine;
|
||||
ts.startstill= seq->startstill;
|
||||
ts.endstill= seq->endstill;
|
||||
ts.startdisp= seq->startdisp;
|
||||
ts.enddisp= seq->enddisp;
|
||||
ts.startofs= seq->anim_startofs;
|
||||
ts.endofs= seq->anim_endofs;
|
||||
ts.len= seq->len;
|
||||
|
||||
/* First Strip! */
|
||||
/* strips with extended stillfames before */
|
||||
|
||||
if ((seq->startstill) && (cutframe <seq->start)) {
|
||||
/* don't do funny things with METAs ... */
|
||||
if (seq->type == SEQ_META) {
|
||||
skip_dup = TRUE;
|
||||
seq->startstill = seq->start - cutframe;
|
||||
} else {
|
||||
seq->start= cutframe -1;
|
||||
seq->startstill= cutframe -seq->startdisp -1;
|
||||
seq->anim_endofs += seq->len - 1;
|
||||
seq->endstill= 0;
|
||||
}
|
||||
}
|
||||
/* normal strip */
|
||||
else if ((cutframe >=seq->start)&&(cutframe <=(seq->start+seq->len))) {
|
||||
seq->endofs = 0;
|
||||
seq->endstill = 0;
|
||||
seq->anim_endofs += (seq->start+seq->len) - cutframe;
|
||||
}
|
||||
/* strips with extended stillframes after */
|
||||
else if (((seq->start+seq->len) < cutframe) && (seq->endstill)) {
|
||||
seq->endstill -= seq->enddisp - cutframe;
|
||||
/* don't do funny things with METAs ... */
|
||||
if (seq->type == SEQ_META) {
|
||||
skip_dup = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
reload_sequence_new_file(seq);
|
||||
calc_sequence(seq);
|
||||
|
||||
if (!skip_dup) {
|
||||
/* Duplicate AFTER the first change */
|
||||
seqn = deep_dupli_seq(seq);
|
||||
}
|
||||
|
||||
if (seqn) {
|
||||
seqn->flag |= SELECT;
|
||||
|
||||
/* Second Strip! */
|
||||
/* strips with extended stillframes before */
|
||||
if ((seqn->startstill) && (cutframe == seqn->start + 1)) {
|
||||
seqn->start = ts.start;
|
||||
seqn->startstill= ts.start- cutframe;
|
||||
seqn->anim_endofs = ts.endofs;
|
||||
seqn->endstill = ts.endstill;
|
||||
}
|
||||
|
||||
/* normal strip */
|
||||
else if ((cutframe>=seqn->start)&&(cutframe<=(seqn->start+seqn->len))) {
|
||||
seqn->start = cutframe;
|
||||
seqn->startstill = 0;
|
||||
seqn->startofs = 0;
|
||||
seqn->anim_startofs += cutframe - ts.start;
|
||||
seqn->anim_endofs = ts.endofs;
|
||||
seqn->endstill = ts.endstill;
|
||||
}
|
||||
|
||||
/* strips with extended stillframes after */
|
||||
else if (((seqn->start+seqn->len) < cutframe) && (seqn->endstill)) {
|
||||
seqn->start = cutframe;
|
||||
seqn->startofs = 0;
|
||||
seqn->anim_startofs += ts.len-1;
|
||||
seqn->endstill = ts.enddisp - cutframe -1;
|
||||
seqn->startstill = 0;
|
||||
}
|
||||
|
||||
reload_sequence_new_file(seqn);
|
||||
calc_sequence(seqn);
|
||||
}
|
||||
return seqn;
|
||||
}
|
||||
|
||||
static Sequence * cut_seq_soft(Sequence * seq, int cutframe)
|
||||
{
|
||||
TransSeq ts;
|
||||
Sequence *seqn = 0;
|
||||
@@ -2372,9 +2464,11 @@ static Sequence * cut_seq(Sequence * seq, int cutframe)
|
||||
return seqn;
|
||||
}
|
||||
|
||||
|
||||
/* like duplicate, but only duplicate and cut overlapping strips,
|
||||
* strips to the left of the cutframe are ignored and strips to the right are moved into the new list */
|
||||
static int cut_seq_list(ListBase *old, ListBase *new, int cutframe)
|
||||
static int cut_seq_list(ListBase *old, ListBase *new, int cutframe,
|
||||
Sequence * (*cut_seq)(Sequence *, int))
|
||||
{
|
||||
int did_something = FALSE;
|
||||
Sequence *seq, *seq_next;
|
||||
@@ -2406,7 +2500,7 @@ static int cut_seq_list(ListBase *old, ListBase *new, int cutframe)
|
||||
return did_something;
|
||||
}
|
||||
|
||||
void seq_cut(int cutframe)
|
||||
void seq_cut(int cutframe, int hard_cut)
|
||||
{
|
||||
Editing *ed;
|
||||
ListBase newlist;
|
||||
@@ -2418,7 +2512,13 @@ void seq_cut(int cutframe)
|
||||
|
||||
newlist.first= newlist.last= NULL;
|
||||
|
||||
did_something = cut_seq_list(ed->seqbasep, &newlist, cutframe);
|
||||
if (hard_cut) {
|
||||
did_something = cut_seq_list(
|
||||
ed->seqbasep, &newlist, cutframe, cut_seq_hard);
|
||||
} else {
|
||||
did_something = cut_seq_list(
|
||||
ed->seqbasep, &newlist, cutframe, cut_seq_soft);
|
||||
}
|
||||
|
||||
if (newlist.first) { /* got new strips ? */
|
||||
Sequence *seq;
|
||||
|
||||
@@ -420,7 +420,7 @@ static void do_seq_editmenu(void *arg, int event)
|
||||
seq_snap(event);
|
||||
break;
|
||||
case 13: /* Cut at Current Frame */
|
||||
seq_cut(CFRA);
|
||||
seq_cut(CFRA, 1);
|
||||
break;
|
||||
case 14:
|
||||
reassign_inputs_seq_effect();
|
||||
@@ -446,6 +446,9 @@ static void do_seq_editmenu(void *arg, int event)
|
||||
case 21:
|
||||
seq_mute_sel(0);
|
||||
break;
|
||||
case 22:
|
||||
seq_cut(CFRA, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -467,7 +470,8 @@ static uiBlock *seq_editmenu(void *arg_unused)
|
||||
|
||||
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
|
||||
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Cut at Current Frame|K", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 13, "");
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Cut (hard) at Current Frame|K", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 13, "");
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Cut (soft) at Current Frame|Shift-K", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 22, "");
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Separate Images to Strips|Y", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 16, "");
|
||||
|
||||
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
|
||||
|
||||
@@ -471,8 +471,11 @@ static int audiostream_play_seq(Sequence * seq, Uint32 startframe)
|
||||
}
|
||||
if ((seq->type == SEQ_RAM_SOUND) && (seq->sound)) {
|
||||
have_sound = 1;
|
||||
seq->curpos = (int)( (FRA2TIME((double) startframe -
|
||||
(double) seq->start)
|
||||
seq->curpos = (int)( (FRA2TIME(
|
||||
(double) startframe -
|
||||
(double) seq->start +
|
||||
(double)
|
||||
seq->anim_startofs)
|
||||
* ((float)G.scene->audio.mixrate)
|
||||
* 4 ));
|
||||
}
|
||||
@@ -486,7 +489,9 @@ static int audiostream_play_seq(Sequence * seq, Uint32 startframe)
|
||||
seq->hdaudio = sound_open_hdaudio(name);
|
||||
}
|
||||
seq->curpos = (int)( (FRA2TIME((double) startframe -
|
||||
(double) seq->start)
|
||||
(double) seq->start +
|
||||
(double)
|
||||
seq->anim_startofs)
|
||||
* ((float)G.scene->audio.mixrate)
|
||||
* 4 ));
|
||||
}
|
||||
|
||||
@@ -420,23 +420,33 @@ void reload_sequence_new_file(Sequence * seq)
|
||||
char str[FILE_MAXDIR+FILE_MAXFILE];
|
||||
|
||||
if (!(seq->type == SEQ_MOVIE || seq->type == SEQ_IMAGE ||
|
||||
seq->type == SEQ_HD_SOUND || seq->type == SEQ_SCENE ||
|
||||
seq->type == SEQ_META)) {
|
||||
seq->type == SEQ_HD_SOUND || seq->type == SEQ_RAM_SOUND ||
|
||||
seq->type == SEQ_SCENE || seq->type == SEQ_META)) {
|
||||
return;
|
||||
}
|
||||
|
||||
new_tstripdata(seq);
|
||||
|
||||
if (seq->type == SEQ_IMAGE) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (seq->type != SEQ_SCENE && seq->type != SEQ_META) {
|
||||
if (seq->type != SEQ_SCENE && seq->type != SEQ_META &&
|
||||
seq->type != SEQ_IMAGE) {
|
||||
strncpy(str, seq->strip->dir, FILE_MAXDIR-1);
|
||||
strncat(str, seq->strip->stripdata->name, FILE_MAXFILE-1);
|
||||
|
||||
BLI_convertstringcode(str, G.sce, G.scene->r.cfra);
|
||||
}
|
||||
|
||||
if (seq->type == SEQ_MOVIE) {
|
||||
if (seq->type == SEQ_IMAGE) {
|
||||
/* Hack? */
|
||||
int olen = MEM_allocN_len(seq->strip->stripdata)
|
||||
/ sizeof(struct StripElem);
|
||||
seq->len = olen;
|
||||
seq->len -= seq->anim_startofs;
|
||||
seq->len -= seq->anim_endofs;
|
||||
if (seq->len < 0) {
|
||||
seq->len = 0;
|
||||
}
|
||||
seq->strip->len = seq->len;
|
||||
} else if (seq->type == SEQ_MOVIE) {
|
||||
if(seq->anim) IMB_free_anim(seq->anim);
|
||||
seq->anim = openanim(str, IB_rect);
|
||||
|
||||
@@ -462,8 +472,22 @@ void reload_sequence_new_file(Sequence * seq)
|
||||
return;
|
||||
}
|
||||
|
||||
seq->strip->len = seq->len
|
||||
= sound_hdaudio_get_duration(seq->hdaudio, FPS);
|
||||
seq->len = sound_hdaudio_get_duration(seq->hdaudio, FPS)
|
||||
- seq->anim_startofs - seq->anim_endofs;
|
||||
if (seq->len < 0) {
|
||||
seq->len = 0;
|
||||
}
|
||||
seq->strip->len = seq->len;
|
||||
} else if (seq->type == SEQ_RAM_SOUND) {
|
||||
seq->len = (int) ( ((float)(seq->sound->streamlen-1)/
|
||||
((float)G.scene->audio.mixrate*4.0 ))
|
||||
* FPS);
|
||||
seq->len -= seq->anim_startofs;
|
||||
seq->len -= seq->anim_endofs;
|
||||
if (seq->len < 0) {
|
||||
seq->len = 0;
|
||||
}
|
||||
seq->strip->len = seq->len;
|
||||
} else if (seq->type == SEQ_SCENE) {
|
||||
Scene * sce = G.main->scene.first;
|
||||
int nr = 1;
|
||||
@@ -477,6 +501,8 @@ void reload_sequence_new_file(Sequence * seq)
|
||||
|
||||
if (sce) {
|
||||
seq->scene = sce;
|
||||
} else {
|
||||
sce = seq->scene;
|
||||
}
|
||||
|
||||
strncpy(seq->name + 2, sce->id.name + 2,
|
||||
@@ -794,7 +820,7 @@ static int give_stripelem_index(Sequence *seq, int cfra)
|
||||
int nr;
|
||||
|
||||
if(seq->startdisp >cfra || seq->enddisp <= cfra) return -1;
|
||||
|
||||
if(seq->len == 0) return -1;
|
||||
if(seq->flag&SEQ_REVERSE_FRAMES) {
|
||||
/*reverse frame in this sequence */
|
||||
if(cfra <= seq->start) nr= seq->len-1;
|
||||
@@ -1101,6 +1127,9 @@ static void seq_proxy_build_frame(Sequence * seq, int cfra)
|
||||
}
|
||||
|
||||
se = give_tstripelem(seq, cfra);
|
||||
if (!se) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(se->ibuf) {
|
||||
IMB_freeImBuf(se->ibuf);
|
||||
@@ -2045,6 +2074,10 @@ static TStripElem* do_build_seq_array_recursively(
|
||||
|
||||
se = give_tstripelem(seq_arr[count - 1], cfra);
|
||||
|
||||
if (!se) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
test_and_auto_discard_ibuf(se);
|
||||
|
||||
if (se->ibuf_comp != 0) {
|
||||
|
||||
@@ -4949,15 +4949,17 @@ static void winqreadseqspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
|
||||
transform_seq('g', 0);
|
||||
}
|
||||
break;
|
||||
case KKEY:
|
||||
if((G.qual==0)) { /* Cut at current frame */
|
||||
seq_cut(CFRA);
|
||||
case KKEY: /* Cut at current frame */
|
||||
if((G.qual == LR_SHIFTKEY)) {
|
||||
seq_cut(CFRA, FALSE); /* soft cut */
|
||||
} else if((G.qual==0)) {
|
||||
seq_cut(CFRA, TRUE); /* hard cut */
|
||||
}
|
||||
break;
|
||||
case LKEY:
|
||||
if((G.qual==0)) { /* Cut at current frame */
|
||||
if((G.qual==0)) {
|
||||
select_linked_seq( 0 );
|
||||
} else if((G.qual==LR_CTRLKEY)) { /* Cut at current frame */
|
||||
} else if((G.qual==LR_CTRLKEY)) {
|
||||
select_linked_seq( 2 );
|
||||
} else if (G.qual==LR_SHIFTKEY) {
|
||||
seq_lock_sel(1);
|
||||
|
||||
Reference in New Issue
Block a user