[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [51284] trunk/blender/source/blender/ windowmanager/intern/wm_playanim.c: code cleanup: video playback move frame step into the PlayState struct.

Campbell Barton ideasman42 at gmail.com
Fri Oct 12 16:03:43 CEST 2012


Revision: 51284
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=51284
Author:   campbellbarton
Date:     2012-10-12 14:03:43 +0000 (Fri, 12 Oct 2012)
Log Message:
-----------
code cleanup: video playback move frame step into the PlayState struct.

Modified Paths:
--------------
    trunk/blender/source/blender/windowmanager/intern/wm_playanim.c

Modified: trunk/blender/source/blender/windowmanager/intern/wm_playanim.c
===================================================================
--- trunk/blender/source/blender/windowmanager/intern/wm_playanim.c	2012-10-12 09:50:22 UTC (rev 51283)
+++ trunk/blender/source/blender/windowmanager/intern/wm_playanim.c	2012-10-12 14:03:43 UTC (rev 51284)
@@ -89,6 +89,8 @@
 	short stopped;
 	short go;
 
+	int fstep;
+
 	/* current picture */
 	struct PlayAnimPict *picture;
 
@@ -213,7 +215,6 @@
 
 static struct ListBase picsbase = {NULL, NULL};
 static int fromdisk = FALSE;
-static int fstep = 1;
 static float zoomx = 1.0, zoomy = 1.0;
 static double ptottime = 0.0, swaptime = 0.04;
 
@@ -229,7 +230,7 @@
 	return (ptottime < 0);
 }
 
-static void playanim_toscreen(PlayAnimPict *picture, struct ImBuf *ibuf, int fontid)
+static void playanim_toscreen(PlayAnimPict *picture, struct ImBuf *ibuf, int fontid, int fstep)
 {
 
 	if (ibuf == NULL) {
@@ -287,7 +288,7 @@
 			int pic;
 			ibuf = IMB_anim_absolute(anim, 0, IMB_TC_NONE, IMB_PROXY_NONE);
 			if (ibuf) {
-				playanim_toscreen(NULL, ibuf, fontid);
+				playanim_toscreen(NULL, ibuf, fontid, fstep);
 				IMB_freeImBuf(ibuf);
 			}
 
@@ -390,7 +391,7 @@
 					ibuf = IMB_loadiffname(picture->name, picture->IB_flags, NULL);
 				}
 				if (ibuf) {
-					playanim_toscreen(picture, ibuf, fontid);
+					playanim_toscreen(picture, ibuf, fontid, fstep);
 					IMB_freeImBuf(ibuf);
 				}
 				pupdate_time();
@@ -446,34 +447,34 @@
 					if (val) ps->pingpong = !ps->pingpong;
 					break;
 				case GHOST_kKeyNumpad1:
-					if (val) swaptime = fstep / 60.0;
+					if (val) swaptime = ps->fstep / 60.0;
 					break;
 				case GHOST_kKeyNumpad2:
-					if (val) swaptime = fstep / 50.0;
+					if (val) swaptime = ps->fstep / 50.0;
 					break;
 				case GHOST_kKeyNumpad3:
-					if (val) swaptime = fstep / 30.0;
+					if (val) swaptime = ps->fstep / 30.0;
 					break;
 				case GHOST_kKeyNumpad4:
 					if (g_WS.qual & WS_QUAL_SHIFT)
-						swaptime = fstep / 24.0;
+						swaptime = ps->fstep / 24.0;
 					else
-						swaptime = fstep / 25.0;
+						swaptime = ps->fstep / 25.0;
 					break;
 				case GHOST_kKeyNumpad5:
-					if (val) swaptime = fstep / 20.0;
+					if (val) swaptime = ps->fstep / 20.0;
 					break;
 				case GHOST_kKeyNumpad6:
-					if (val) swaptime = fstep / 15.0;
+					if (val) swaptime = ps->fstep / 15.0;
 					break;
 				case GHOST_kKeyNumpad7:
-					if (val) swaptime = fstep / 12.0;
+					if (val) swaptime = ps->fstep / 12.0;
 					break;
 				case GHOST_kKeyNumpad8:
-					if (val) swaptime = fstep / 10.0;
+					if (val) swaptime = ps->fstep / 10.0;
 					break;
 				case GHOST_kKeyNumpad9:
-					if (val) swaptime = fstep / 6.0;
+					if (val) swaptime = ps->fstep / 6.0;
 					break;
 				case GHOST_kKeyLeftArrow:
 					if (val) {
@@ -531,10 +532,10 @@
 					if (val) {
 						if (g_WS.qual & WS_QUAL_SHIFT) {
 							if (ps->curframe_ibuf)
-								printf(" Name: %s | Speed: %.2f frames/s\n", ps->curframe_ibuf->name, fstep / swaptime);
+								printf(" Name: %s | Speed: %.2f frames/s\n", ps->curframe_ibuf->name, ps->fstep / swaptime);
 						}
 						else {
-							swaptime = fstep / 5.0;
+							swaptime = ps->fstep / 5.0;
 						}
 					}
 					break;
@@ -675,7 +676,7 @@
 			glPixelZoom(zoomx, zoomy);
 			glEnable(GL_DITHER);
 			ptottime = 0.0;
-			playanim_toscreen(ps->picture, ps->curframe_ibuf, ps->fontid);
+			playanim_toscreen(ps->picture, ps->curframe_ibuf, ps->fontid, ps->fstep);
 
 			break;
 		}
@@ -747,6 +748,8 @@
 	ps.picture   = NULL;
 	/* resetmap = FALSE */
 
+	ps.fstep     = 1;
+
 	ps.fontid = -1;
 
 	while (argc > 1) {
@@ -794,8 +797,8 @@
 					argv++;
 					break;
 				case 'j':
-					fstep = MIN2(MAXFRAME, MAX2(1, atoi(argv[2])));
-					swaptime *= fstep;
+					ps.fstep = MIN2(MAXFRAME, MAX2(1, atoi(argv[2])));
+					swaptime *= ps.fstep;
 					argc--;
 					argv++;
 					break;
@@ -894,11 +897,11 @@
 		efra = MAXFRAME;
 	}
 
-	build_pict_list(filepath, (efra - sfra) + 1, fstep, ps.fontid);
+	build_pict_list(filepath, (efra - sfra) + 1, ps.fstep, ps.fontid);
 
 	for (i = 2; i < argc; i++) {
 		BLI_strncpy(filepath, argv[i], sizeof(filepath));
-		build_pict_list(filepath, (efra - sfra) + 1, fstep, ps.fontid);
+		build_pict_list(filepath, (efra - sfra) + 1, ps.fstep, ps.fontid);
 	}
 
 	IMB_freeImBuf(ibuf);
@@ -970,7 +973,7 @@
 
 				while (pupdate_time()) PIL_sleep_ms(1);
 				ptottime -= swaptime;
-				playanim_toscreen(ps.picture, ibuf, ps.fontid);
+				playanim_toscreen(ps.picture, ibuf, ps.fontid, ps.fstep);
 			} /* else deleten */
 			else {
 				printf("error: can't play this image type\n");




More information about the Bf-blender-cvs mailing list