Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2014-01-29 13:01:30 +0400
committerCampbell Barton <ideasman42@gmail.com>2014-01-29 13:44:01 +0400
commit39eb314cb922b805e9126d5f0352f31c2f84f151 (patch)
tree9fc861802eeaab149539eb3692a975969cea03db /source/blender/blenkernel/intern/image.c
parentf70d9660474c2be5f56d65247df3be5af0479e08 (diff)
UI: Refactor timecode functions into BLI_timecode
- deduplicate timecode_simple_string from image.c - replace V2D_UNIT_SECONDSSEQ with V2D_UNIT_SECONDS - avoid possible buffer overflow bugs (sprintf -> BLI_snprintf) - remove option not to use timecode and split into 2 functions Patch D227 by Andrew Buttery with own refactoring.
Diffstat (limited to 'source/blender/blenkernel/intern/image.c')
-rw-r--r--source/blender/blenkernel/intern/image.c30
1 files changed, 4 insertions, 26 deletions
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index 336656eed19..3e93ab0cbcc 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -68,6 +68,7 @@
#include "BLI_blenlib.h"
#include "BLI_threads.h"
+#include "BLI_timecode.h" /* for stamp timecode format */
#include "BLI_utildefines.h"
#include "BKE_bmfont.h"
@@ -1520,30 +1521,6 @@ void BKE_imbuf_to_image_format(struct ImageFormatData *im_format, const ImBuf *i
}
-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);
- }
-}
#define STAMP_NAME_SIZE ((MAX_ID_NAME - 2) + 16)
/* could allow access externally - 512 is for long names,
@@ -1607,8 +1584,9 @@ static void stampdata(Scene *scene, Object *camera, StampData *stamp_data, int d
}
if (scene->r.stamp & R_STAMP_TIME) {
- 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);
+ const short timecode_style = USER_TIMECODE_SMPTE_FULL;
+ BLI_timecode_string_from_time(text, sizeof(text), 0, FRA2TIME(scene->r.cfra), FPS, timecode_style);
+ BLI_snprintf(stamp_data->time, sizeof(stamp_data->time), do_prefix ? "Timecode %s" : "%s", text);
}
else {
stamp_data->time[0] = '\0';