diff options
-rw-r--r-- | source/blender/blenkernel/intern/movieclip.c | 28 | ||||
-rw-r--r-- | source/blender/imbuf/IMB_imbuf.h | 2 | ||||
-rw-r--r-- | source/blender/imbuf/intern/png.c | 3 | ||||
-rw-r--r-- | source/blender/imbuf/intern/readimage.c | 6 |
4 files changed, 27 insertions, 12 deletions
diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c index 4bd6676608e..6e8f2697ee1 100644 --- a/source/blender/blenkernel/intern/movieclip.c +++ b/source/blender/blenkernel/intern/movieclip.c @@ -520,6 +520,24 @@ static void movieclip_load_get_szie(MovieClip *clip) } } +static void detect_clip_source(MovieClip *clip) +{ + ImBuf *ibuf; + char name[FILE_MAX]; + + BLI_strncpy(name, clip->name, sizeof(name)); + BLI_path_abs(name, G.main->name); + + ibuf = IMB_testiffname(name, IB_rect | IB_multilayer); + if (ibuf) { + clip->source = MCLIP_SRC_SEQUENCE; + IMB_freeImBuf(ibuf); + } + else { + clip->source = MCLIP_SRC_MOVIE; + } +} + /* checks if image was already loaded, then returns same image * otherwise creates new. * does not load ibuf itself @@ -565,10 +583,7 @@ MovieClip *BKE_movieclip_file_add(const char *name) clip = movieclip_alloc(libname); BLI_strncpy(clip->name, name, sizeof(clip->name)); - if (BLI_testextensie_array(name, imb_ext_movie)) - clip->source = MCLIP_SRC_MOVIE; - else - clip->source = MCLIP_SRC_SEQUENCE; + detect_clip_source(clip); movieclip_load_get_szie(clip); if (clip->lastsize[0]) { @@ -1082,10 +1097,7 @@ void BKE_movieclip_reload(MovieClip *clip) clip->tracking.stabilization.ok = FALSE; /* update clip source */ - if (BLI_testextensie_array(clip->name, imb_ext_movie)) - clip->source = MCLIP_SRC_MOVIE; - else - clip->source = MCLIP_SRC_SEQUENCE; + detect_clip_source(clip); clip->lastsize[0] = clip->lastsize[1] = 0; movieclip_load_get_szie(clip); diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h index e297ebe3980..d0ac71a7131 100644 --- a/source/blender/imbuf/IMB_imbuf.h +++ b/source/blender/imbuf/IMB_imbuf.h @@ -103,7 +103,7 @@ struct ImBuf *IMB_ibImageFromMemory(unsigned char *mem, size_t size, int flags, * * \attention Defined in readimage.c */ -struct ImBuf *IMB_testiffname(const char *filepath, int flags, char colorspace[IM_MAX_SPACE]); +struct ImBuf *IMB_testiffname(const char *filepath, int flags); /** * diff --git a/source/blender/imbuf/intern/png.c b/source/blender/imbuf/intern/png.c index 6310d8e105f..dcfebb95b87 100644 --- a/source/blender/imbuf/intern/png.c +++ b/source/blender/imbuf/intern/png.c @@ -558,7 +558,8 @@ ImBuf *imb_loadpng(unsigned char *mem, size_t size, int flags, char colorspace[I MEM_freeN(pixels); if (pixels16) MEM_freeN(pixels16); - MEM_freeN(row_pointers); + if (row_pointers) + MEM_freeN(row_pointers); png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL); return(ibuf); diff --git a/source/blender/imbuf/intern/readimage.c b/source/blender/imbuf/intern/readimage.c index a1fa05d1098..5669a4cc45d 100644 --- a/source/blender/imbuf/intern/readimage.c +++ b/source/blender/imbuf/intern/readimage.c @@ -100,7 +100,8 @@ ImBuf *IMB_ibImageFromMemory(unsigned char *mem, size_t size, int flags, char co } } - fprintf(stderr, "%s: unknown fileformat (%s)\n", __func__, descr); + if ((flags & IB_test) == 0) + fprintf(stderr, "%s: unknown fileformat (%s)\n", __func__, descr); return NULL; } @@ -170,11 +171,12 @@ ImBuf *IMB_loadiffname(const char *filepath, int flags, char colorspace[IM_MAX_S return ibuf; } -ImBuf *IMB_testiffname(const char *filepath, int flags, char colorspace[IM_MAX_SPACE]) +ImBuf *IMB_testiffname(const char *filepath, int flags) { ImBuf *ibuf; int file; char filepath_tx[IB_FILENAME_SIZE]; + char colorspace[IM_MAX_SPACE]; imb_cache_filename(filepath_tx, filepath, flags); |