diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-08-03 16:34:42 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-08-03 16:34:42 +0400 |
commit | 50c3da699db13a1b51311919063bb3ad92dd8b3d (patch) | |
tree | 570123d075671acb045e9ebd161d12802ed5f9e9 /source/blender | |
parent | 957976882d084d9951760b154f414724d6ddb8be (diff) |
minor cleanup, minimal functional change.
replace some long duplicated, ifdef'd if statements for image extension.
- new function: BLI_testextensie_array(), can take an array of extensions.
- define extension arrays: imb_ext_image, imb_ext_movie, imb_ext_sound - we could have more of these.
- removed amiga extensions iff and lbm
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenlib/BLI_path_util.h | 1 | ||||
-rw-r--r-- | source/blender/blenlib/intern/path_util.c | 13 | ||||
-rw-r--r-- | source/blender/editors/space_file/filelist.c | 152 | ||||
-rw-r--r-- | source/blender/imbuf/IMB_imbuf_types.h | 6 | ||||
-rw-r--r-- | source/blender/imbuf/intern/util.c | 164 |
5 files changed, 107 insertions, 229 deletions
diff --git a/source/blender/blenlib/BLI_path_util.h b/source/blender/blenlib/BLI_path_util.h index 07e0da5e461..b8c886d95a9 100644 --- a/source/blender/blenlib/BLI_path_util.h +++ b/source/blender/blenlib/BLI_path_util.h @@ -99,6 +99,7 @@ char *BLI_path_basename(char *path); int BKE_rebase_path(char *abs, int abs_size, char *rel, int rel_size, const char *base_dir, const char *src_dir, const char *dest_dir); void BLI_getlastdir(const char* dir, char *last, int maxlen); int BLI_testextensie(const char *str, const char *ext); +int BLI_testextensie_array(const char *str, const char **ext_array); int BLI_replace_extension(char *path, int maxlen, const char *ext); void BLI_uniquename(struct ListBase *list, void *vlink, const char defname[], char delim, short name_offs, short len); void BLI_newname(char * name, int add); diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c index d3e2b8f83e5..9a56722b5d9 100644 --- a/source/blender/blenlib/intern/path_util.c +++ b/source/blender/blenlib/intern/path_util.c @@ -1263,6 +1263,19 @@ int BLI_testextensie(const char *str, const char *ext) return (retval); } +int BLI_testextensie_array(const char *str, const char **ext_array) +{ + int i=0; + while(ext_array[i]) { + if(BLI_testextensie(str, ext_array[i])) { + return 1; + } + + i++; + } + return 0; +} + int BLI_replace_extension(char *path, int maxlen, const char *ext) { int a; diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index a6668d9a5fe..310e3d49bd9 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -828,153 +828,13 @@ void filelist_setfiletypes(struct FileList* filelist, short has_quicktime) file->flags |= BTXFILE; } else if(BLI_testextensie(file->relname, ".dae")) { file->flags |= COLLADAFILE; - } else if (has_quicktime){ - if( BLI_testextensie(file->relname, ".int") - || BLI_testextensie(file->relname, ".inta") - || BLI_testextensie(file->relname, ".jpg") -#ifdef WITH_OPENJPEG - || BLI_testextensie(file->relname, ".jp2") -#endif - || BLI_testextensie(file->relname, ".jpeg") - || BLI_testextensie(file->relname, ".tga") - || BLI_testextensie(file->relname, ".rgb") - || BLI_testextensie(file->relname, ".rgba") - || BLI_testextensie(file->relname, ".bmp") - || BLI_testextensie(file->relname, ".png") - || BLI_testextensie(file->relname, ".iff") - || BLI_testextensie(file->relname, ".lbm") - || BLI_testextensie(file->relname, ".gif") - || BLI_testextensie(file->relname, ".psd") - || BLI_testextensie(file->relname, ".tif") - || BLI_testextensie(file->relname, ".tiff") - || BLI_testextensie(file->relname, ".tx") - || BLI_testextensie(file->relname, ".pct") - || BLI_testextensie(file->relname, ".pict") - || BLI_testextensie(file->relname, ".pntg") //macpaint - || BLI_testextensie(file->relname, ".qtif") - || BLI_testextensie(file->relname, ".sgi") -#ifdef WITH_HDR - || BLI_testextensie(file->relname, ".hdr") -#endif -#ifdef WITH_CINEON - || BLI_testextensie(file->relname, ".cin") - || BLI_testextensie(file->relname, ".dpx") -#endif -#ifdef WITH_DDS - || BLI_testextensie(file->relname, ".dds") -#endif -#ifdef WITH_OPENEXR - || BLI_testextensie(file->relname, ".exr") -#endif - ) { + } else if(BLI_testextensie_array(file->relname, imb_ext_image) + || (has_quicktime && BLI_testextensie_array(file->relname, imb_ext_image_qt))) { file->flags |= IMAGEFILE; - } - else if(BLI_testextensie(file->relname, ".avi") - || BLI_testextensie(file->relname, ".flc") - || BLI_testextensie(file->relname, ".mov") - || BLI_testextensie(file->relname, ".movie") - || BLI_testextensie(file->relname, ".mp4") - || BLI_testextensie(file->relname, ".m4v") - || BLI_testextensie(file->relname, ".m2v") - || BLI_testextensie(file->relname, ".m2t") - || BLI_testextensie(file->relname, ".mts") - || BLI_testextensie(file->relname, ".mv") - || BLI_testextensie(file->relname, ".avs") - || BLI_testextensie(file->relname, ".wmv") - || BLI_testextensie(file->relname, ".ogv") - || BLI_testextensie(file->relname, ".dv") - || BLI_testextensie(file->relname, ".mpeg") - || BLI_testextensie(file->relname, ".mpg") - || BLI_testextensie(file->relname, ".mpg2") - || BLI_testextensie(file->relname, ".vob") - || BLI_testextensie(file->relname, ".mkv") - || BLI_testextensie(file->relname, ".flv") - || BLI_testextensie(file->relname, ".divx") - || BLI_testextensie(file->relname, ".xvid")) { - file->flags |= MOVIEFILE; - } - else if(BLI_testextensie(file->relname, ".wav") - || BLI_testextensie(file->relname, ".ogg") - || BLI_testextensie(file->relname, ".oga") - || BLI_testextensie(file->relname, ".mp3") - || BLI_testextensie(file->relname, ".mp2") - || BLI_testextensie(file->relname, ".ac3") - || BLI_testextensie(file->relname, ".aac") - || BLI_testextensie(file->relname, ".flac") - || BLI_testextensie(file->relname, ".wma") - || BLI_testextensie(file->relname, ".eac3")) { - file->flags |= SOUNDFILE; - } - } else { // no quicktime - if(BLI_testextensie(file->relname, ".int") - || BLI_testextensie(file->relname, ".inta") - || BLI_testextensie(file->relname, ".jpg") - || BLI_testextensie(file->relname, ".jpeg") -#ifdef WITH_OPENJPEG - || BLI_testextensie(file->relname, ".jp2") -#endif - || BLI_testextensie(file->relname, ".tga") - || BLI_testextensie(file->relname, ".rgb") - || BLI_testextensie(file->relname, ".rgba") - || BLI_testextensie(file->relname, ".bmp") - || BLI_testextensie(file->relname, ".png") - || BLI_testextensie(file->relname, ".iff") - || BLI_testextensie(file->relname, ".tif") - || BLI_testextensie(file->relname, ".tiff") - || BLI_testextensie(file->relname, ".tx") -#ifdef WITH_HDR - || BLI_testextensie(file->relname, ".hdr") -#endif -#ifdef WITH_CINEON - || BLI_testextensie(file->relname, ".cin") - || BLI_testextensie(file->relname, ".dpx") -#endif -#ifdef WITH_DDS - || BLI_testextensie(file->relname, ".dds") -#endif -#ifdef WITH_OPENEXR - || BLI_testextensie(file->relname, ".exr") -#endif - || BLI_testextensie(file->relname, ".lbm") - || BLI_testextensie(file->relname, ".sgi")) { - file->flags |= IMAGEFILE; - } - else if(BLI_testextensie(file->relname, ".avi") - || BLI_testextensie(file->relname, ".flc") - || BLI_testextensie(file->relname, ".mov") - || BLI_testextensie(file->relname, ".movie") - || BLI_testextensie(file->relname, ".mp4") - || BLI_testextensie(file->relname, ".m4v") - || BLI_testextensie(file->relname, ".m2v") - || BLI_testextensie(file->relname, ".m2t") - || BLI_testextensie(file->relname, ".mts") - || BLI_testextensie(file->relname, ".mv") - || BLI_testextensie(file->relname, ".avs") - || BLI_testextensie(file->relname, ".wmv") - || BLI_testextensie(file->relname, ".ogv") - || BLI_testextensie(file->relname, ".dv") - || BLI_testextensie(file->relname, ".mpeg") - || BLI_testextensie(file->relname, ".mpg") - || BLI_testextensie(file->relname, ".mpg2") - || BLI_testextensie(file->relname, ".vob") - || BLI_testextensie(file->relname, ".mkv") - || BLI_testextensie(file->relname, ".flv") - || BLI_testextensie(file->relname, ".divx") - || BLI_testextensie(file->relname, ".xvid")) { - file->flags |= MOVIEFILE; - } - else if(BLI_testextensie(file->relname, ".wav") - || BLI_testextensie(file->relname, ".ogg") - || BLI_testextensie(file->relname, ".oga") - || BLI_testextensie(file->relname, ".mp3") - || BLI_testextensie(file->relname, ".mp2") - || BLI_testextensie(file->relname, ".ac3") - || BLI_testextensie(file->relname, ".aac") - || BLI_testextensie(file->relname, ".flac") - || BLI_testextensie(file->relname, ".wma") - || BLI_testextensie(file->relname, ".eac3")) { - file->flags |= SOUNDFILE; - } + } else if(BLI_testextensie_array(file->relname, imb_ext_movie)) { + file->flags |= MOVIEFILE; + } else if(BLI_testextensie_array(file->relname, imb_ext_audio)) { + file->flags |= SOUNDFILE; } } } diff --git a/source/blender/imbuf/IMB_imbuf_types.h b/source/blender/imbuf/IMB_imbuf_types.h index 7408a43ee65..203a7268581 100644 --- a/source/blender/imbuf/IMB_imbuf_types.h +++ b/source/blender/imbuf/IMB_imbuf_types.h @@ -222,5 +222,9 @@ typedef struct ImBuf { #define IB_PROFILE_SRGB 2 #define IB_PROFILE_CUSTOM 3 -#endif +extern const char *imb_ext_image[]; +extern const char *imb_ext_image_qt[]; +extern const char *imb_ext_movie[]; +extern const char *imb_ext_audio[]; +#endif diff --git a/source/blender/imbuf/intern/util.c b/source/blender/imbuf/intern/util.c index 726a8fe2f36..13ffa504fec 100644 --- a/source/blender/imbuf/intern/util.c +++ b/source/blender/imbuf/intern/util.c @@ -68,6 +68,80 @@ #define UTIL_DEBUG 0 +const char *imb_ext_image[] = { + ".png" + ".tga", + ".bmp", + ".jpg", ".jpeg", + ".sgi", ".rgb", ".rgba", +#ifdef WITH_TIFF + ".tif", ".tiff", ".tx", +#endif +#ifdef WITH_BF_OPENJPEG + ".jp2", +#endif +#ifdef WITH_HDR + ".hdr", +#endif +#ifdef WITH_DDS + ".dds", +#endif +#ifdef WITH_CINEON + ".dpx", + ".cin", +#endif +#ifdef WITH_BF_OPENEXR + ".exr", +#endif + NULL}; + +const char *imb_ext_image_qt[] = { + ".gif", + ".psd", + ".pct", ".pict", + ".pntg", + ".qtif", + NULL}; + +const char *imb_ext_movie[] = { + ".avi", + ".flc", + ".mov", + ".movie", + ".mp4", + ".m4v", + ".m2v", + ".m2t", + ".mts", + ".mv", + ".avs", + ".wmv", + ".ogv", + ".dv", + ".mpeg", + ".mpg", + ".mpg2", + ".vob", + ".mkv", + ".flv", + ".divx", + ".xvid", + NULL}; + +/* sort of wrong being here... */ +const char *imb_ext_audio[] = { + ".wav", + ".ogg", + ".oga", + ".mp3", + ".mp2", + ".ac3", + ".aac", + ".flac", + ".wma", + ".eac3", + NULL}; + static int IMB_ispic_name(char *name) { ImFileType *type; @@ -105,90 +179,16 @@ static int IMB_ispic_name(char *name) int IMB_ispic(char *filename) { if(U.uiflag & USER_FILTERFILEEXTS) { - if (BLI_testextensie(filename, ".tif") - || BLI_testextensie(filename, ".tiff") - || BLI_testextensie(filename, ".tx")) { - return IMB_ispic_name(filename); + if( (BLI_testextensie_array(filename, imb_ext_image)) || + (G.have_quicktime && BLI_testextensie_array(filename, imb_ext_image_qt)) + ) { + return IMB_ispic_name(filename); } - if (G.have_quicktime){ - if( BLI_testextensie(filename, ".jpg") - || BLI_testextensie(filename, ".jpeg") -#ifdef WITH_TIFF - || BLI_testextensie(filename, ".tif") - || BLI_testextensie(filename, ".tiff") - || BLI_testextensie(filename, ".tx") -#endif -#ifdef WITH_HDR - || BLI_testextensie(filename, ".hdr") -#endif - || BLI_testextensie(filename, ".tga") - || BLI_testextensie(filename, ".rgb") - || BLI_testextensie(filename, ".bmp") - || BLI_testextensie(filename, ".png") -#ifdef WITH_DDS - || BLI_testextensie(filename, ".dds") -#endif - || BLI_testextensie(filename, ".iff") - || BLI_testextensie(filename, ".lbm") - || BLI_testextensie(filename, ".gif") - || BLI_testextensie(filename, ".psd") - || BLI_testextensie(filename, ".pct") - || BLI_testextensie(filename, ".pict") - || BLI_testextensie(filename, ".pntg") //macpaint - || BLI_testextensie(filename, ".qtif") -#ifdef WITH_CINEON - || BLI_testextensie(filename, ".dpx") - || BLI_testextensie(filename, ".cin") -#endif -#ifdef WITH_BF_OPENEXR - || BLI_testextensie(filename, ".exr") -#endif -#ifdef WITH_BF_OPENJPEG - || BLI_testextensie(filename, ".jp2") -#endif - || BLI_testextensie(filename, ".sgi")) { - return IMB_ispic_name(filename); - } else { - return(FALSE); - } - } else { /* no quicktime */ - if( BLI_testextensie(filename, ".jpg") - || BLI_testextensie(filename, ".jpeg") -#ifdef WITH_TIFF - || BLI_testextensie(filename, ".tif") - || BLI_testextensie(filename, ".tiff") - || BLI_testextensie(filename, ".tx") -#endif -#ifdef WITH_HDR - || BLI_testextensie(filename, ".hdr") -#endif - || BLI_testextensie(filename, ".tga") - || BLI_testextensie(filename, ".rgb") - || BLI_testextensie(filename, ".bmp") - || BLI_testextensie(filename, ".png") -#ifdef WITH_CINEON - || BLI_testextensie(filename, ".cin") - || BLI_testextensie(filename, ".dpx") -#endif -#ifdef WITH_DDS - || BLI_testextensie(filename, ".dds") -#endif -#ifdef WITH_BF_OPENEXR - || BLI_testextensie(filename, ".exr") -#endif -#ifdef WITH_BF_OPENJPEG - || BLI_testextensie(filename, ".jp2") -#endif - || BLI_testextensie(filename, ".iff") - || BLI_testextensie(filename, ".lbm") - || BLI_testextensie(filename, ".sgi")) { - return IMB_ispic_name(filename); - } - else { - return(FALSE); - } + else { + return FALSE; } - } else { /* no FILTERFILEEXTS */ + } + else { /* no FILTERFILEEXTS */ return IMB_ispic_name(filename); } } |