diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-01-27 00:41:38 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-01-27 00:41:38 +0300 |
commit | 709b1a93e61e5c53f981819949641fb5db01d48e (patch) | |
tree | 7e2546594fa1ef5c5034d35b96efb69f301eb45a /source | |
parent | 586af8ca479ad22e59ef3a45694096f8a5e16405 (diff) |
support for #'s for output animation paths
This was supported...
image: /tmp/foo_###_bar --> /tmp/foo_001_bar.png
But not this...
anim: /tmp/foo_###_bar --> /tmp/foo_001_250_bar.avi
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/writeavi.c | 14 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/writeffmpeg.c | 19 | ||||
-rw-r--r-- | source/blender/blenlib/BLI_path_util.h | 1 | ||||
-rw-r--r-- | source/blender/blenlib/intern/path_util.c | 76 | ||||
-rw-r--r-- | source/blender/quicktime/apple/qtkit_export.m | 12 |
5 files changed, 57 insertions, 65 deletions
diff --git a/source/blender/blenkernel/intern/writeavi.c b/source/blender/blenkernel/intern/writeavi.c index 9ff5ee00bfb..0d057525f38 100644 --- a/source/blender/blenkernel/intern/writeavi.c +++ b/source/blender/blenkernel/intern/writeavi.c @@ -121,18 +121,20 @@ static int sframe; static void filepath_avi (char *string, RenderData *rd) { - char txt[64]; - - if (string==0) return; + if (string==NULL) return; strcpy(string, rd->pic); BLI_convertstringcode(string, G.sce); BLI_make_existing_file(string); - if (BLI_strcasecmp(string + strlen(string) - 4, ".avi")) { - sprintf(txt, "%04d_%04d.avi", (rd->sfra) , (rd->efra) ); - strcat(string, txt); + if (!BLI_testextensie(string, ".avi")) { + /* if we dont have any #'s to insert numbers into, use 4 numbers by default */ + if (strchr(string, '#')==NULL) + strcat(string, "####"); /* 4 numbers */ + + BLI_convertstringframe_range(string, rd->sfra, rd->efra); + strcat(string, ".avi"); } } diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index 920ff255bcc..56924cb0dfa 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -772,15 +772,6 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report /* Get the output filename-- similar to the other output formats */ void filepath_ffmpeg(char* string, RenderData* rd) { - - // XXX quick define, solve! -#define FILE_MAXDIR 256 -#define FILE_MAXFILE 126 - - char txt[FILE_MAXDIR+FILE_MAXFILE]; - // XXX -#undef FILE_MAXDIR -#undef FILE_MAXFILE char autosplit[20]; const char ** exts = get_file_extensions(rd->ffcodecdata.type); @@ -810,9 +801,13 @@ void filepath_ffmpeg(char* string, RenderData* rd) { if (!*fe) { strcat(string, autosplit); - sprintf(txt, "%04d_%04d%s", (rd->sfra), - (rd->efra), *exts); - strcat(string, txt); + + /* if we dont have any #'s to insert numbers into, use 4 numbers by default */ + if (strchr(string, '#')==NULL) + strcat(string, "####"); /* 4 numbers */ + + BLI_convertstringframe_range(string, rd->sfra, rd->efra); + strcat(string, *exts); } else { *(string + strlen(string) - strlen(*fe)) = 0; strcat(string, autosplit); diff --git a/source/blender/blenlib/BLI_path_util.h b/source/blender/blenlib/BLI_path_util.h index ca483903d46..f9ef3d8c828 100644 --- a/source/blender/blenlib/BLI_path_util.h +++ b/source/blender/blenlib/BLI_path_util.h @@ -98,6 +98,7 @@ int BLI_has_parent(char *path); */ int BLI_convertstringcode(char *path, const char *basepath); int BLI_convertstringframe(char *path, int frame); +int BLI_convertstringframe_range(char *path, int sta, int end); int BLI_convertstringcwd(char *path); void BLI_makestringcode(const char *relfile, char *file); diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c index 4f987fcd31e..895f2d1ee56 100644 --- a/source/blender/blenlib/intern/path_util.c +++ b/source/blender/blenlib/intern/path_util.c @@ -525,7 +525,7 @@ int BLI_parent_dir(char *path) } } -int BLI_convertstringframe(char *path, int frame) +static int stringframe_chars(char *path, int *char_start, int *char_end) { int ch_sta, ch_end, i; /* Insert current frame: file### -> file001 */ @@ -544,54 +544,44 @@ int BLI_convertstringframe(char *path, int frame) /* dont break, there may be a slash after this that invalidates the previous #'s */ } } - if (ch_end) { /* warning, ch_end is the last # +1 */ - /* Add the frame number? */ - short numlen, hashlen; - char tmp[FILE_MAX]; - - char format[16]; /* 6 is realistically the maxframe (300000), so 8 should be enough, but 16 to be safe. */ - if (((ch_end-1)-ch_sta) >= 16) { - ch_end = ch_sta+15; /* disallow values longer then 'format' can hold */ - } - - strcpy(tmp, path); - - numlen = 1 + (int)log10((double)frame); /* this is the number of chars in the number */ - hashlen = ch_end - ch_sta; - - sprintf(format, "%d", frame); - - if (numlen==hashlen) { /* simple case */ - memcpy(tmp+ch_sta, format, numlen); - } else if (numlen < hashlen) { - memcpy(tmp+ch_sta + (hashlen-numlen), format, numlen); /*dont copy the string terminator */ - memset(tmp+ch_sta, '0', hashlen-numlen); - } else { - /* number is longer then number of #'s */ - if (tmp[ch_end] == '\0') { /* hashes are last, no need to move any string*/ - /* bad juju - not testing string length here :/ */ - memcpy(tmp+ch_sta, format, numlen+1); /* add 1 to get the string terminator \0 */ - } else { - /* we need to move the end characters, reuse i */ - int j; - - i = strlen(tmp); /* +1 to copy the string terminator */ - j = i + (numlen-hashlen); /* from/to */ - - while (i >= ch_end) { - tmp[j] = tmp[i]; - i--; - j--; - } - memcpy(tmp + ch_sta, format, numlen); - } - } + + if(ch_end) { + *char_start= ch_sta; + *char_end= ch_end; + return 1; + } + else { + *char_start= -1; + *char_end= -1; + return 0; + } +} + +int BLI_convertstringframe(char *path, int frame) +{ + int ch_sta, ch_end; + if (stringframe_chars(path, &ch_sta, &ch_end)) { /* warning, ch_end is the last # +1 */ + char tmp[FILE_MAX], format[64]; + sprintf(format, "%%.%ds%%.%dd%%s", ch_sta, ch_end-ch_sta); /* example result: "%.12s%.5d%s" */ + sprintf(tmp, format, path, frame, path+ch_end); strcpy(path, tmp); return 1; } return 0; } +int BLI_convertstringframe_range(char *path, int sta, int end) +{ + int ch_sta, ch_end; + if (stringframe_chars(path, &ch_sta, &ch_end)) { /* warning, ch_end is the last # +1 */ + char tmp[FILE_MAX], format[64]; + sprintf(format, "%%.%ds%%.%dd_%%.%dd%%s", ch_sta, ch_end-ch_sta, ch_end-ch_sta); /* example result: "%.12s%.5d-%.5d%s" */ + sprintf(tmp, format, path, sta, end, path+ch_end); + strcpy(path, tmp); + return 1; + } + return 0; +} int BLI_convertstringcode(char *path, const char *basepath) { diff --git a/source/blender/quicktime/apple/qtkit_export.m b/source/blender/quicktime/apple/qtkit_export.m index 8a537617348..6e9e4885def 100644 --- a/source/blender/quicktime/apple/qtkit_export.m +++ b/source/blender/quicktime/apple/qtkit_export.m @@ -156,16 +156,20 @@ void makeqtstring (RenderData *rd, char *string) { void filepath_qt(char *string, RenderData *rd) { char txt[64]; - if (string==0) return; + if (string==NULL) return; strcpy(string, rd->pic); BLI_convertstringcode(string, G.sce); BLI_make_existing_file(string); - if (BLI_strcasecmp(string + strlen(string) - 4, ".mov")) { - sprintf(txt, "%04d_%04d.mov", (rd->sfra) , (rd->efra) ); - strcat(string, txt); + if (!BLI_testextensie(string, ".mov")) { + /* if we dont have any #'s to insert numbers into, use 4 numbers by default */ + if (strchr(string, '#')==NULL) + strcat(string, "####"); /* 4 numbers */ + + BLI_convertstringframe_range(string, rd->sfra, rd->efra); + strcat(string, ".mov"); } } |