[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [39227] branches/soc-2011-tomato/source/ blender/blenkernel/intern/movieclip.c: Camera tracking integration

Sergey Sharybin g.ulairi at gmail.com
Tue Aug 9 20:26:21 CEST 2011


Revision: 39227
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=39227
Author:   nazgul
Date:     2011-08-09 18:26:21 +0000 (Tue, 09 Aug 2011)
Log Message:
-----------
Camera tracking integration
===========================

Fixing some problems caused by modifying imbuf from cache
when building proxy and preventing attempt to load image
duting saving it from cache builder.

Modified Paths:
--------------
    branches/soc-2011-tomato/source/blender/blenkernel/intern/movieclip.c

Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/movieclip.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/movieclip.c	2011-08-09 18:25:57 UTC (rev 39226)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/movieclip.c	2011-08-09 18:26:21 UTC (rev 39227)
@@ -764,7 +764,7 @@
 {
 	char name[FILE_MAXFILE+FILE_MAXDIR];
 	int quality, rectx, recty, size;
-	struct ImBuf * ibuf;
+	ImBuf *ibuf;
 	MovieClipUser user;
 
 	size= rendersize_to_number(proxy_render_size);
@@ -774,22 +774,33 @@
 
 	ibuf= BKE_movieclip_acquire_ibuf_flag(clip, &user, 0);
 
-	rectx= ibuf->x*size/100.f;
-	recty= ibuf->y*size/100.f;
+	if(ibuf) {
+		ImBuf *scaleibuf= ibuf;
 
-	if (ibuf->x != rectx || ibuf->y != recty) {
-		IMB_scalefastImBuf(ibuf, (short)rectx, (short)recty);
-	}
+		rectx= ibuf->x*size/100.f;
+		recty= ibuf->y*size/100.f;
 
-	quality= clip->proxy.quality;
-	ibuf->ftype= JPG | quality;
+		if (ibuf->x != rectx || ibuf->y != recty) {
+			if(ibuf->refcounter)	/* means buffer came from cache and shouldn't be modified */
+				scaleibuf= IMB_dupImBuf(ibuf);
 
-	BLI_make_existing_file(name);
+			IMB_scalefastImBuf(scaleibuf, (short)rectx, (short)recty);
+		}
 
-	if(IMB_saveiff(ibuf, name, IB_rect | IB_zbuf | IB_zbuffloat)==0)
-		perror(name);
+		quality= clip->proxy.quality;
+		scaleibuf->ftype= JPG | quality;
 
-	IMB_freeImBuf(ibuf);
+		BLI_lock_thread(LOCK_MOVIECLIP);
+
+		BLI_make_existing_file(name);
+		if(IMB_saveiff(scaleibuf, name, IB_rect | IB_zbuf | IB_zbuffloat)==0)
+			perror(name);
+
+		BLI_unlock_thread(LOCK_MOVIECLIP);
+
+		IMB_freeImBuf(ibuf);
+		if(scaleibuf!=ibuf) IMB_freeImBuf(scaleibuf);
+	}
 }
 
 void free_movieclip(MovieClip *clip)




More information about the Bf-blender-cvs mailing list