[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [48751] trunk/blender/source/blender: code cleanup: move sequencer timecode into its own func.

Campbell Barton ideasman42 at gmail.com
Mon Jul 9 12:55:41 CEST 2012


Revision: 48751
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=48751
Author:   campbellbarton
Date:     2012-07-09 10:55:41 +0000 (Mon, 09 Jul 2012)
Log Message:
-----------
code cleanup: move sequencer timecode into its own func.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/image.c
    trunk/blender/source/blender/python/bmesh/bmesh_py_types.c
    trunk/blender/source/blender/python/bmesh/bmesh_py_types_meshdata.c

Modified: trunk/blender/source/blender/blenkernel/intern/image.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/image.c	2012-07-09 10:33:09 UTC (rev 48750)
+++ trunk/blender/source/blender/blenkernel/intern/image.c	2012-07-09 10:55:41 UTC (rev 48751)
@@ -1312,6 +1312,31 @@
 
 }
 
+static void timecode_simple_string(char *text, size_t text_size, const int cfra, int const frs_sec)
+{
+	int f = (int)(cfra % frs_sec);
+	int s = (int)(cfra / frs_sec);
+	int h = 0;
+	int m = 0;
+
+	if (s) {
+		m = (int)(s / 60);
+		s %= 60;
+
+		if (m) {
+			h = (int)(m / 60);
+			m %= 60;
+		}
+	}
+
+	if (frs_sec < 100) {
+		BLI_snprintf(text, text_size, "%02d:%02d:%02d.%02d", h, m, s, f);
+	}
+	else {
+		BLI_snprintf(text, text_size, "%02d:%02d:%02d.%03d", h, m, s, f);
+	}
+}
+
 /* could allow access externally - 512 is for long names, 64 is for id names */
 typedef struct StampData {
 	char file[512];
@@ -1371,26 +1396,7 @@
 	}
 
 	if (scene->r.stamp & R_STAMP_TIME) {
-		int f = (int)(scene->r.cfra % scene->r.frs_sec);
-		int s = (int)(scene->r.cfra / scene->r.frs_sec);
-		int h = 0;
-		int m = 0;
-
-		if (s) {
-			m = (int)(s / 60);
-			s %= 60;
-
-			if (m) {
-				h = (int)(m / 60);
-				m %= 60;
-			}
-		}
-
-		if (scene->r.frs_sec < 100)
-			BLI_snprintf(text, sizeof(text), "%02d:%02d:%02d.%02d", h, m, s, f);
-		else
-			BLI_snprintf(text, sizeof(text), "%02d:%02d:%02d.%03d", h, m, s, f);
-
+		timecode_simple_string(text, sizeof(text), scene->r.cfra, scene->r.frs_sec);
 		BLI_snprintf(stamp_data->time, sizeof(stamp_data->time), do_prefix ? "Time %s" : "%s", text);
 	}
 	else {

Modified: trunk/blender/source/blender/python/bmesh/bmesh_py_types.c
===================================================================
--- trunk/blender/source/blender/python/bmesh/bmesh_py_types.c	2012-07-09 10:33:09 UTC (rev 48750)
+++ trunk/blender/source/blender/python/bmesh/bmesh_py_types.c	2012-07-09 10:55:41 UTC (rev 48751)
@@ -2438,21 +2438,21 @@
 }
 
 static PySequenceMethods bpy_bmelemseq_as_sequence = {
-    (lenfunc)bpy_bmelemseq_length,                  /* sq_length */
+    (lenfunc)bpy_bmelemseq_length,               /* sq_length */
     NULL,                                        /* sq_concat */
     NULL,                                        /* sq_repeat */
-    (ssizeargfunc)bpy_bmelemseq_subscript_int,      /* sq_item */ /* Only set this so PySequence_Check() returns True */
+    (ssizeargfunc)bpy_bmelemseq_subscript_int,   /* sq_item */ /* Only set this so PySequence_Check() returns True */
     NULL,                                        /* sq_slice */
     (ssizeobjargproc)NULL,                       /* sq_ass_item */
     NULL,                                        /* *was* sq_ass_slice */
-    (objobjproc)bpy_bmelemseq_contains,             /* sq_contains */
+    (objobjproc)bpy_bmelemseq_contains,          /* sq_contains */
     (binaryfunc) NULL,                           /* sq_inplace_concat */
     (ssizeargfunc) NULL,                         /* sq_inplace_repeat */
 };
 
 static PyMappingMethods bpy_bmelemseq_as_mapping = {
-    (lenfunc)bpy_bmelemseq_length,                  /* mp_length */
-    (binaryfunc)bpy_bmelemseq_subscript,            /* mp_subscript */
+    (lenfunc)bpy_bmelemseq_length,               /* mp_length */
+    (binaryfunc)bpy_bmelemseq_subscript,         /* mp_subscript */
     (objobjargproc)NULL,                         /* mp_ass_subscript */
 };
 
@@ -2859,7 +2859,7 @@
     PyModuleDef_HEAD_INIT,
     "bmesh.types",  /* m_name */
     NULL,  /* m_doc */
-    0,  /* m_size */
+    0,     /* m_size */
     NULL,  /* m_methods */
     NULL,  /* m_reload */
     NULL,  /* m_traverse */

Modified: trunk/blender/source/blender/python/bmesh/bmesh_py_types_meshdata.c
===================================================================
--- trunk/blender/source/blender/python/bmesh/bmesh_py_types_meshdata.c	2012-07-09 10:33:09 UTC (rev 48750)
+++ trunk/blender/source/blender/python/bmesh/bmesh_py_types_meshdata.c	2012-07-09 10:55:41 UTC (rev 48751)
@@ -432,7 +432,7 @@
 			/* dvert[group_index] = 0.5 */
 			if (i < 0) {
 				PyErr_SetString(PyExc_KeyError, "BMDeformVert[key] = x: "
-								"weight keys can't be negative");
+				                "weight keys can't be negative");
 				return -1;
 			}
 			else {
@@ -440,8 +440,8 @@
 				const float f = PyFloat_AsDouble(value);
 				if (f == -1 && PyErr_Occurred()) { // parsed key not a number
 					PyErr_SetString(PyExc_TypeError,
-									"BMDeformVert[key] = x: "
-									"argument not a number");
+					                "BMDeformVert[key] = x: "
+					                "argument not a number");
 					return -1;
 				}
 
@@ -496,7 +496,7 @@
     NULL,                                        /* sq_slice */
     NULL,                                        /* sq_ass_item */
     NULL,                                        /* *was* sq_ass_slice */
-    (objobjproc)bpy_bmdeformvert_contains,  /* sq_contains */
+    (objobjproc)bpy_bmdeformvert_contains,       /* sq_contains */
     (binaryfunc) NULL,                           /* sq_inplace_concat */
     (ssizeargfunc) NULL,                         /* sq_inplace_repeat */
 };




More information about the Bf-blender-cvs mailing list