- hash characters in the path would confuse the output file name and not add numbers to it (when rendering animations).

- added an option to BLI_convertstringframe and BLI_convertstringframe_range to add digits if not found.
- removed BLI_convertstringframe where its obviously not needed - such as loading movies and sounds.
This commit is contained in:
Campbell Barton 2010-01-30 22:33:47 +00:00
parent 1943a73439
commit f749d0361f
11 changed files with 38 additions and 39 deletions

@ -392,7 +392,6 @@ Image *BKE_add_image_file(const char *name, int frame)
BLI_strncpy(str, name, sizeof(str));
BLI_convertstringcode(str, G.sce);
BLI_convertstringframe(str, frame);
/* exists? */
file= open(str, O_BINARY|O_RDONLY);
@ -404,7 +403,6 @@ Image *BKE_add_image_file(const char *name, int frame)
if(ima->source!=IMA_SRC_VIEWER && ima->source!=IMA_SRC_GENERATED) {
BLI_strncpy(strtest, ima->name, sizeof(ima->name));
BLI_convertstringcode(strtest, G.sce);
BLI_convertstringframe(strtest, frame);
if( strcmp(strtest, str)==0 ) {
if(ima->anim==NULL || ima->id.us==0) {
@ -1412,15 +1410,9 @@ int BKE_write_ibuf(Scene *scene, ImBuf *ibuf, char *name, int imtype, int subimt
void BKE_makepicstring(char *string, char *base, int frame, int imtype, int use_ext)
{
if (string==NULL) return;
BLI_strncpy(string, base, FILE_MAX - 10); /* weak assumption */
/* if we dont have any #'s to insert numbers into, use 4 numbers by default */
if (strchr(string, '#')==NULL)
strcat(string, "####"); /* 4 numbers */
BLI_convertstringcode(string, G.sce);
BLI_convertstringframe(string, frame);
BLI_convertstringframe(string, frame, 4);
if(use_ext)
BKE_add_image_extension(string, imtype);
@ -1675,8 +1667,6 @@ static ImBuf *image_load_sequence_file(Image *ima, ImageUser *iuser, int frame)
else
BLI_convertstringcode(name, G.sce);
BLI_convertstringframe(name, frame); /* TODO - should this be here? */
/* read ibuf */
ibuf = IMB_loadiffname(name, IB_rect|IB_multilayer);
if(G.f & G_DEBUG) printf("loaded %s\n", name);
@ -1838,7 +1828,7 @@ static ImBuf *image_load_image_file(Image *ima, ImageUser *iuser, int cfra)
else
BLI_convertstringcode(str, G.sce);
BLI_convertstringframe(str, cfra);
BLI_convertstringframe(str, cfra, 0);
/* read ibuf */
ibuf = IMB_loadiffname(str, IB_rect|IB_multilayer|IB_imginfo);

@ -583,8 +583,6 @@ void reload_sequence_new_file(Scene *scene, Sequence * seq)
seq->type != SEQ_IMAGE) {
BLI_join_dirfile(str, seq->strip->dir, seq->strip->stripdata->name);
BLI_convertstringcode(str, G.sce);
BLI_convertstringframe(str, scene->r.cfra);
}
if (seq->type == SEQ_IMAGE) {
@ -1190,7 +1188,6 @@ static int seq_proxy_get_fname(Scene *scene, Sequence * seq, int cfra, char * na
if (seq->flag & SEQ_USE_PROXY_CUSTOM_FILE) {
BLI_join_dirfile(name, dir, seq->strip->proxy->file);
BLI_convertstringcode(name, G.sce);
BLI_convertstringframe(name, cfra);
return TRUE;
}
@ -1220,8 +1217,8 @@ static int seq_proxy_get_fname(Scene *scene, Sequence * seq, int cfra, char * na
}
BLI_convertstringcode(name, G.sce);
BLI_convertstringframe(name, frameno);
BLI_convertstringframe(name, frameno, 0);
strcat(name, ".jpg");
@ -1988,7 +1985,6 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int
StripElem * s_elem = give_stripelem(seq, cfra);
BLI_join_dirfile(name, seq->strip->dir, s_elem->name);
BLI_convertstringcode(name, G.sce);
BLI_convertstringframe(name, scene->r.cfra);
if (!build_proxy_run) {
se->ibuf = seq_proxy_fetch(scene, seq, cfra, render_size);
}
@ -2023,7 +2019,6 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int
if(seq->anim==0) {
BLI_join_dirfile(name, seq->strip->dir, seq->strip->stripdata->name);
BLI_convertstringcode(name, G.sce);
BLI_convertstringframe(name, scene->r.cfra);
seq->anim = openanim(
name, IB_rect |

@ -129,11 +129,7 @@ static void filepath_avi (char *string, RenderData *rd)
BLI_make_existing_file(string);
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);
BLI_convertstringframe_range(string, rd->sfra, rd->efra, 4);
strcat(string, ".avi");
}
}

@ -781,7 +781,6 @@ void filepath_ffmpeg(char* string, RenderData* rd) {
strcpy(string, rd->pic);
BLI_convertstringcode(string, G.sce);
BLI_convertstringframe(string, rd->cfra);
BLI_make_existing_file(string);
@ -802,11 +801,7 @@ void filepath_ffmpeg(char* string, RenderData* rd) {
if (!*fe) {
strcat(string, autosplit);
/* 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);
BLI_convertstringframe_range(string, rd->sfra, rd->efra, 4);
strcat(string, *exts);
} else {
*(string + strlen(string) - strlen(*fe)) = 0;

@ -97,8 +97,8 @@ int BLI_has_parent(char *path);
* @retval Returns true if the path was relative (started with "//").
*/
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_convertstringframe(char *path, int frame, int digits);
int BLI_convertstringframe_range(char *path, int sta, int end, int digits);
int BLI_convertstringcwd(char *path);
void BLI_makestringcode(const char *relfile, char *file);

@ -557,9 +557,30 @@ static int stringframe_chars(char *path, int *char_start, int *char_end)
}
}
int BLI_convertstringframe(char *path, int frame)
static void ensure_digits(char *path, int digits)
{
char *file= BLI_last_slash(path);
if(file==NULL)
file= path;
if(strrchr(file, '#') == NULL) {
int len= strlen(file);
while(digits--) {
file[len++]= '#';
}
file[len]= '\0';
}
}
int BLI_convertstringframe(char *path, int frame, int digits)
{
int ch_sta, ch_end;
if(digits)
ensure_digits(path, digits);
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" */
@ -570,9 +591,13 @@ int BLI_convertstringframe(char *path, int frame)
return 0;
}
int BLI_convertstringframe_range(char *path, int sta, int end)
int BLI_convertstringframe_range(char *path, int sta, int end, int digits)
{
int ch_sta, ch_end;
if(digits)
ensure_digits(path, digits);
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" */

@ -9682,7 +9682,6 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
char str[FILE_MAX];
BLI_join_dirfile(str, seq->strip->dir, seq->strip->stripdata->name);
BLI_convertstringcode(str, G.sce);
BLI_convertstringframe(str, scene->r.cfra);
seq->sound = sound_new_file(main, str);
}
}

@ -106,7 +106,6 @@ static void save_rendered_image_cb_real(char *name, int confirm)
strcpy(str, name);
BLI_convertstringcode(str, G.sce);
BLI_convertstringframe(str, scene->r.cfra); /* TODO - is this even used? */
if (confirm)
overwrite = saveover(str);

@ -810,7 +810,7 @@ static void save_image_doit(bContext *C, SpaceImage *sima, Scene *scene, wmOpera
if (ibuf) {
BLI_convertstringcode(name, G.sce);
BLI_convertstringframe(name, scene->r.cfra);
BLI_convertstringframe(name, scene->r.cfra, 0);
if(scene->r.scemode & R_EXTENSION) {
BKE_add_image_extension(name, sima->imtypenr);

@ -98,7 +98,7 @@ char *rna_Image_get_abs_filename(Image *image, bContext *C)
BLI_strncpy(filename, image->name, FILE_MAXDIR + FILE_MAXFILE);
BLI_convertstringcode(filename, CTX_data_main(C)->name);
BLI_convertstringframe(filename, CTX_data_scene(C)->r.cfra);
BLI_convertstringframe(filename, CTX_data_scene(C)->r.cfra, 0);
return filename;
}

@ -2084,7 +2084,7 @@ static void load_backbuffer(Render *re)
strcpy(name, re->r.backbuf);
BLI_convertstringcode(name, G.sce);
BLI_convertstringframe(name, re->r.cfra);
BLI_convertstringframe(name, re->r.cfra, 0);
if(re->backbuf) {
re->backbuf->id.us--;