[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [45177] trunk/blender/source/blender: Fix for crash when adding image sequence movie clip into a sequencer

Sergey Sharybin sergey.vfx at gmail.com
Mon Mar 26 15:30:58 CEST 2012


Revision: 45177
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=45177
Author:   nazgul
Date:     2012-03-26 13:30:53 +0000 (Mon, 26 Mar 2012)
Log Message:
-----------
Fix for crash when adding image sequence movie clip into a sequencer

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/movieclip.c
    trunk/blender/source/blender/makesdna/DNA_movieclip_types.h

Modified: trunk/blender/source/blender/blenkernel/intern/movieclip.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/movieclip.c	2012-03-26 13:21:43 UTC (rev 45176)
+++ trunk/blender/source/blender/blenkernel/intern/movieclip.c	2012-03-26 13:30:53 UTC (rev 45177)
@@ -256,6 +256,28 @@
 	return ibuf;
 }
 
+static void movieclip_calc_length(MovieClip *clip)
+{
+	if (clip->anim) {
+		clip->len = IMB_anim_get_duration(clip->anim, clip->proxy.tc);
+	}
+	else if (clip->source == MCLIP_SRC_SEQUENCE) {
+		int framenr = 1;
+		char name[FILE_MAX];
+
+		for (;;) {
+			get_sequence_fname(clip, framenr, name);
+
+			if (!BLI_exists(name)) {
+				clip->len = framenr + 1;
+				break;
+			}
+
+			framenr++;
+		}
+	}
+}
+
 /*********************** image buffer cache *************************/
 
 typedef struct MovieClipCache {
@@ -452,9 +474,9 @@
 	BLI_strncpy(clip->name, name, sizeof(clip->name));
 
 	if (BLI_testextensie_array(name, imb_ext_movie))
-		clip->source= MCLIP_SRC_MOVIE;
+		clip->source = MCLIP_SRC_MOVIE;
 	else
-		clip->source= MCLIP_SRC_SEQUENCE;
+		clip->source = MCLIP_SRC_SEQUENCE;
 
 	user.framenr = 1;
 	BKE_movieclip_get_size(clip, &user, &width, &height);
@@ -465,6 +487,8 @@
 		clip->tracking.camera.focal = 24.0f * width / clip->tracking.camera.sensor_width;
 	}
 
+	movieclip_calc_length(clip);
+
 	return clip;
 }
 
@@ -891,9 +915,13 @@
 	}
 }
 
-int BKE_movieclip_get_duration(struct MovieClip *clip)
+int BKE_movieclip_get_duration(MovieClip *clip)
 {
-	return IMB_anim_get_duration(clip->anim, clip->proxy.tc);
+	if (!clip->len && clip->anim) {
+		return IMB_anim_get_duration(clip->anim, clip->proxy.tc);
+	}
+
+	return clip->len;
 }
 
 void BKE_movieclip_aspect(MovieClip *clip, float *aspx, float *aspy)
@@ -959,6 +987,8 @@
 		clip->source = MCLIP_SRC_MOVIE;
 	else
 		clip->source = MCLIP_SRC_SEQUENCE;
+
+	movieclip_calc_length(clip);
 }
 
 void BKE_movieclip_update_scopes(MovieClip *clip, MovieClipUser *user, MovieClipScopes *scopes)

Modified: trunk/blender/source/blender/makesdna/DNA_movieclip_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_movieclip_types.h	2012-03-26 13:21:43 UTC (rev 45176)
+++ trunk/blender/source/blender/makesdna/DNA_movieclip_types.h	2012-03-26 13:30:53 UTC (rev 45177)
@@ -82,7 +82,9 @@
 										 * in SpaceClip clip user */
 
 	struct MovieClipProxy proxy;		/* proxy to clip data */
-	int flag, pad;
+	int flag;
+
+	int len;	/* lenght of movie */
 } MovieClip;
 
 typedef struct MovieClipScopes {




More information about the Bf-blender-cvs mailing list