-// source channels are identical, assets are identical
- if( (current->silence() && next_edit->silence() && !current->is_plugin) ||
- (current->startsource + current->length == next_edit->startsource &&
- current->channel == next_edit->channel &&
- current->asset == next_edit->asset &&
- current->nested_edl == next_edit->nested_edl)) {
-//printf("Edits::optimize %d\n", __LINE__);
- current->length += next_edit->length;
- remove(next_edit);
- result = 1;
- break;
- }
-
- current = current->next;
+ if( !current->is_plugin && current->silence() &&
+ !next_edit->is_plugin && next_edit->silence() )
+ break;
+// source channels are identical & assets are identical
+ if( !result && current->channel == next_edit->channel &&
+ current->asset == next_edit->asset &&
+ current->nested_edl == next_edit->nested_edl ) {
+// and stop and start in the same frame
+ int64_t current_end = current->startsource + current->length;
+ int64_t next_start = next_edit->startsource;
+ if( current_end == next_start ||
+ EQUIV(edl->frame_align(track->from_units(current_end), 1),
+ edl->frame_align(track->from_units(next_start), 1)) )
+ break;
+ }
+ }
+ if( next_edit ) {
+ int64_t current_start = current->startproject;
+ int64_t next_end = next_edit->startproject + next_edit->length;
+ current->length = next_end - current_start;
+ remove(next_edit);
+ result = 1;
+ }