Ok... I've fixed the problem... since i have caused it at the first
place when fixing already broken code when trying to do correct
drag'n'drop on timeline...

now it should work ok!

(we really miss unit tests... the real maschochist please stand up,
please stand up!)

bye
andraz


On tor, 2006-03-07 at 18:13 -0500, Dan Streetman wrote:
> Yep, I had (have...) the same problem.  I don't think it's tweaking while 
> playing back tho, as it's happened many times to me and I always stop 
> playback before tweaking.  I don't really know what's causing it.  
> It's certainly annoying as hell.  
> 
> What I did to fix the "broken" xml file was create a sed script-file 
> containing:
> s,<PLUGIN LENGTH="0" TYPE="0" TITLE=""><IN></IN><OUT></OUT><ON></ON><KEYFRAME 
> POSITION="[[:digit:]]*" DEFAULT="1"></KEYFRAME></PLUGIN>,,g
> 
> and run the xml file through it:
> cat file.xml | tr -d '\n' | sed -f sedscriptfile > fixed.xml
> 
> although using perl should work fine too.
> 
> 
> On Tue, 7 Mar 2006, Brendan Conoboy wrote:
> 
> >Hi everyone,
> >
> >As a novice cinelerra user, I've run into a heinous problem every now 
> >and again.  After doing some work on a video, I'll save, do some more, 
> >save.... for a day or two.  Normally when I start up again, the xml file 
> >is a few dozen to a few hundred k.  Every now and again, it's 5 
> >megabytes large, fails to load, and makes me weep in an unmanly way 
> >(tm).  The physical characteristic of the problem appears to be null 
> >keyframes being inserted into the xml file, like this:
> >
> ><PLUGIN LENGTH="0" TYPE="0" TITLE="">
> ><IN></IN><OUT></OUT><ON></ON>
> ><KEYFRAME POSITION="0" DEFAULT="1"></KEYFRAME>
> ></PLUGIN>
> >
> >Thousands of them.  Tens of thousands.  Hundreds of thousands of them.
> >
> >As to where they come from, it appears to be the result of tweaking 
> >plugin parameters *while* cinelerra is doing playback.  I've not 
> >investigated this problem, but I do have a bandaid of a solution, 
> >written in perl:
> >
> >#!/usr/bin/perl
> >while($_=<STDIN>)
> >   {
> >   if ( $_ =~ /PLUGIN LENGTH="0"/ )
> >     {
> >     $skipped=0;
> >     while($skipped==0)
> >       {
> >       $_=<STDIN>;
> >       if ( $_ =~ /\/PLUGIN/ )  { $skipped=1; }
> >     }
> >   }
> >   print $_;
> >}
> >
> >To use it, just save it as 'unexplode', make it executable and use 
> >"unexplode < bloated.xml > lean.xml" to strip out all plugins of length 
> >0.  Hopefully there aren't any desirable plugins of length 0!
> >
> >-Brendan
> >
> >_______________________________________________
> >Cinelerra mailing list
> >Cinelerra@skolelinux.no
> >https://init.linpro.no/mailman/skolelinux.no/listinfo/cinelerra
> >
> 
--- hvirtual-cvs/cinelerra/edits.C	2005-11-12 12:12:48.000000000 +0100
+++ hvirtual-2/cinelerra/edits.C	2006-04-06 19:48:56.000000000 +0200
@@ -176,16 +176,21 @@
 {
 	Edit *current = 0;
 //printf("Edits::insert_new_edit 1\n");
+	Edit *new_edit;
 	current = split_edit(position);
 	
-	// FIXME: This check can go out now... since split_edit always returns an edit!
-	if(current) current = PREVIOUS;
-
 //printf("Edits::insert_new_edit 1\n");
-	Edit *new_edit = create_edit();
+
+	if (current->length == 0) // when creating a split we got 0-length edit, just use it!
+		new_edit = current;
+	else      // we need to insert 
+	{
+		current = PREVIOUS;
+		new_edit = create_edit();
+		insert_after(current, new_edit);
+	}
 //printf("Edits::insert_new_edit 1\n");
-	insert_after(current, new_edit);
-	new_edit->startproject = position;
+ 	new_edit->startproject = position;
 //printf("Edits::insert_new_edit 2\n");
 	return new_edit;
 }
@@ -195,11 +200,15 @@
 {
 // Get edit containing position
 	Edit *edit = editof(position, PLAY_FORWARD, 0);
-
-// No edit found
-	if(!edit)
-		if (!last || last->startproject + last->length <= position)
+// No edit found, make one - except when we are at zero position!
+	if(!edit && position != 0)
+		if (last && last->startproject + last->length == position)
+		{
+			edit = last; // we do not need any edit to extend past the last one
+		} else
+		if (!last || last->startproject + last->length < position)
 		{
+
 			// Even when track is completely empty or split is beyond last edit, return correct edit
 			Edit *empty = create_edit();
 			if (last)
@@ -223,24 +232,29 @@
 
 	Edit *new_edit = create_edit();
 	insert_after(edit, new_edit);
-	new_edit->copy_from(edit);
-	new_edit->length = new_edit->startproject + new_edit->length - position;
-	edit->length = position - edit->startproject;
-	new_edit->startproject = edit->startproject + edit->length;
-	new_edit->startsource += edit->length;
+	new_edit->startproject = position;
+	if (edit)  // if we have actually split the edit, do the funky stuff!
+	{	
+		new_edit->copy_from(edit);
+		new_edit->length = new_edit->startproject + new_edit->length - position;
+		edit->length = position - edit->startproject;
+		new_edit->startsource += edit->length;
+// Decide what to do with the transition
+		if(edit->length && edit->transition)
+		{
+			delete new_edit->transition;
+			new_edit->transition = 0;
+		}
+
+		if(edit->transition && edit->transition->length > edit->length) 
+			edit->transition->length = edit->length;
+		if(new_edit->transition && new_edit->transition->length > new_edit->length)
+			new_edit->transition->length = new_edit->length;
+	} else
+		new_edit->length = 0;
 
 
-// Decide what to do with the transition
-	if(edit->length && edit->transition)
-	{
-		delete new_edit->transition;
-		new_edit->transition = 0;
-	}
 
-	if(edit->transition && edit->transition->length > edit->length) 
-		edit->transition->length = edit->length;
-	if(new_edit->transition && new_edit->transition->length > new_edit->length)
-		new_edit->transition->length = new_edit->length;
 	return new_edit;
 }
 

Reply via email to