| 
									
										
										
										
											2011-02-23 10:52:22 +00:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  |  * This program is free software; you can redistribute it and/or | 
					
						
							|  |  |  |  * modify it under the terms of the GNU General Public License | 
					
						
							|  |  |  |  * as published by the Free Software Foundation; either version 2 | 
					
						
							| 
									
										
										
										
											2008-04-16 22:40:48 +00:00
										 |  |  |  * of the License, or (at your option) any later version. | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  |  * | 
					
						
							|  |  |  |  * This program is distributed in the hope that it will be useful, | 
					
						
							|  |  |  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
					
						
							|  |  |  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
					
						
							|  |  |  |  * GNU General Public License for more details. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * You should have received a copy of the GNU General Public License | 
					
						
							|  |  |  |  * along with this program; if not, write to the Free Software Foundation, | 
					
						
							| 
									
										
										
										
											2010-02-12 13:34:04 +00:00
										 |  |  |  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  |  * | 
					
						
							|  |  |  |  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. | 
					
						
							|  |  |  |  * All rights reserved. | 
					
						
							|  |  |  |  * util.c | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-18 08:08:12 +11:00
										 |  |  | /** \file
 | 
					
						
							|  |  |  |  * \ingroup imbuf | 
					
						
							| 
									
										
										
										
											2011-02-27 20:23:21 +00:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-11-04 23:46:01 +00:00
										 |  |  | #ifdef _WIN32
 | 
					
						
							| 
									
										
										
										
											2012-08-12 23:28:33 +00:00
										 |  |  | #  include <io.h>
 | 
					
						
							| 
									
										
										
										
											2008-11-04 23:46:01 +00:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-08-12 23:28:33 +00:00
										 |  |  | #include <stdlib.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-01 21:46:55 +00:00
										 |  |  | #include "BLI_fileops.h"
 | 
					
						
							| 
									
										
										
										
											2020-03-19 09:33:03 +01:00
										 |  |  | #include "BLI_path_util.h"
 | 
					
						
							|  |  |  | #include "BLI_utildefines.h"
 | 
					
						
							| 
									
										
										
										
											2020-03-18 13:26:38 -06:00
										 |  |  | #ifdef _WIN32
 | 
					
						
							|  |  |  | #  include "BLI_winstuff.h"
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												Merge image related changes from the render branch. This includes the image
tile cache code in imbuf, but it is not hooked up to the render engine.
Imbuf module: some small refactoring and removing a lot of unused or old code
(about 6.5k lines).
* Added a ImFileType struct with callbacks to make adding an file format type,
  or making changes to the API easier.
* Move imbuf init/exit code into IMB_init()/IMB_exit() functions.
* Increased mipmap levels from 10 to 20, you run into this limit already with
  a 2k image.
* Removed hamx, amiga, anim5 format support.
* Removed colormap saving, only simple colormap code now for reading tga.
* Removed gen_dynlibtiff.py, editing this is almost as much work as just
  editing the code directly.
* Functions removed that were only used for sequencer plugin API:
  IMB_anim_nextpic, IMB_clever_double, IMB_antialias, IMB_gamwarp,
  IMB_scalefieldImBuf, IMB_scalefastfieldImBuf, IMB_onethird, IMB_halflace,
  IMB_dit0, IMB_dit2, IMB_cspace
* Write metadata info into OpenEXR images. Can be viewed with the command
  line utility 'exrheader'
For the image tile cache code, see this page:
http://wiki.blender.org/index.php/Dev:2.5/Source/Imaging/ImageTileCache
											
										 
											2010-05-07 15:18:04 +00:00
										 |  |  | #include "IMB_filetype.h"
 | 
					
						
							| 
									
										
										
										
											2020-03-19 09:33:03 +01:00
										 |  |  | #include "IMB_imbuf.h"
 | 
					
						
							|  |  |  | #include "IMB_imbuf_types.h"
 | 
					
						
							|  |  |  | #include "imbuf.h"
 | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-04-28 02:15:46 +00:00
										 |  |  | #include "IMB_anim.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-02-05 19:23:34 +00:00
										 |  |  | #ifdef WITH_FFMPEG
 | 
					
						
							| 
									
										
										
										
											2019-01-26 20:41:52 +11:00
										 |  |  | #  include "BLI_string.h" /* BLI_vsnprintf */
 | 
					
						
							| 
									
										
										
										
											2011-05-27 07:47:42 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-26 20:41:52 +11:00
										 |  |  | #  include "BKE_global.h" /* G.debug */
 | 
					
						
							| 
									
										
										
										
											2011-05-27 07:47:42 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-26 20:41:52 +11:00
										 |  |  | #  include <libavcodec/avcodec.h>
 | 
					
						
							|  |  |  | #  include <libavdevice/avdevice.h>
 | 
					
						
							| 
									
										
										
										
											2020-03-19 09:33:03 +01:00
										 |  |  | #  include <libavformat/avformat.h>
 | 
					
						
							| 
									
										
										
										
											2019-01-26 20:41:52 +11:00
										 |  |  | #  include <libavutil/log.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #  include "ffmpeg_compat.h"
 | 
					
						
							| 
									
										
										
										
											2006-02-05 19:23:34 +00:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-04-28 02:15:46 +00:00
										 |  |  | #define UTIL_DEBUG 0
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-08-03 12:34:42 +00:00
										 |  |  | const char *imb_ext_image[] = { | 
					
						
							|  |  |  |     ".png", ".tga",  ".bmp", ".jpg", ".jpeg", ".sgi", ".rgb", ".rgba", | 
					
						
							|  |  |  | #ifdef WITH_TIFF
 | 
					
						
							|  |  |  |     ".tif", ".tiff", ".tx", | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2010-08-21 08:22:47 +00:00
										 |  |  | #ifdef WITH_OPENJPEG
 | 
					
						
							| 
									
										
										
										
											2012-08-27 11:59:26 +00:00
										 |  |  |     ".jp2", ".j2c", | 
					
						
							| 
									
										
										
										
											2010-08-03 12:34:42 +00:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | #ifdef WITH_HDR
 | 
					
						
							|  |  |  |     ".hdr", | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | #ifdef WITH_DDS
 | 
					
						
							|  |  |  |     ".dds", | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | #ifdef WITH_CINEON
 | 
					
						
							|  |  |  |     ".dpx", ".cin", | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2010-08-21 08:22:47 +00:00
										 |  |  | #ifdef WITH_OPENEXR
 | 
					
						
							| 
									
										
										
										
											2010-08-03 12:34:42 +00:00
										 |  |  |     ".exr", | 
					
						
							| 
									
										
										
										
											2013-10-08 21:17:24 +00:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2013-10-11 16:38:04 +00:00
										 |  |  | #ifdef WITH_OPENIMAGEIO
 | 
					
						
							| 
									
										
										
										
											2013-10-08 21:17:24 +00:00
										 |  |  |     ".psd", ".pdd",  ".psb", | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2019-01-19 13:21:18 +11:00
										 |  |  |     NULL, | 
					
						
							| 
									
										
										
										
											2013-10-08 21:17:24 +00:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const char *imb_ext_image_filepath_only[] = { | 
					
						
							| 
									
										
										
										
											2013-10-11 16:38:04 +00:00
										 |  |  | #ifdef WITH_OPENIMAGEIO
 | 
					
						
							| 
									
										
										
										
											2013-10-08 21:17:24 +00:00
										 |  |  |     ".psd", | 
					
						
							|  |  |  |     ".pdd", | 
					
						
							|  |  |  |     ".psb", | 
					
						
							| 
									
										
										
										
											2010-08-03 12:34:42 +00:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2019-01-19 13:21:18 +11:00
										 |  |  |     NULL, | 
					
						
							| 
									
										
										
										
											2012-05-16 07:38:23 +00:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2010-08-03 12:34:42 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | const char *imb_ext_movie[] = { | 
					
						
							|  |  |  |     ".avi",  ".flc", ".mov", ".movie", ".mp4",  ".m4v",  ".m2v", ".m2t",  ".m2ts", ".mts", | 
					
						
							|  |  |  |     ".ts",   ".mv",  ".avs", ".wmv",   ".ogv",  ".ogg",  ".r3d", ".dv",   ".mpeg", ".mpg", | 
					
						
							|  |  |  |     ".mpg2", ".vob", ".mkv", ".flv",   ".divx", ".xvid", ".mxf", ".webm", NULL, | 
					
						
							| 
									
										
										
										
											2012-05-16 07:38:23 +00:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2010-08-03 12:34:42 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* sort of wrong being here... */ | 
					
						
							|  |  |  | const char *imb_ext_audio[] = { | 
					
						
							|  |  |  |     ".wav", | 
					
						
							|  |  |  |     ".ogg", | 
					
						
							|  |  |  |     ".oga", | 
					
						
							|  |  |  |     ".mp3", | 
					
						
							|  |  |  |     ".mp2", | 
					
						
							|  |  |  |     ".ac3", | 
					
						
							|  |  |  |     ".aac", | 
					
						
							|  |  |  |     ".flac", | 
					
						
							|  |  |  |     ".wma", | 
					
						
							|  |  |  |     ".eac3", | 
					
						
							| 
									
										
										
										
											2011-06-17 08:50:47 +00:00
										 |  |  |     ".aif", | 
					
						
							|  |  |  |     ".aiff", | 
					
						
							|  |  |  |     ".m4a", | 
					
						
							| 
									
										
										
										
											2014-03-21 13:52:37 +06:00
										 |  |  |     ".mka", | 
					
						
							| 
									
										
										
										
											2019-01-19 13:21:18 +11:00
										 |  |  |     NULL, | 
					
						
							| 
									
										
										
										
											2012-05-16 07:38:23 +00:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2010-08-03 12:34:42 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-10 22:16:29 +11:00
										 |  |  | /* Increased from 32 to 64 because of the bitmaps header size. */ | 
					
						
							| 
									
										
										
										
											2013-07-13 12:58:00 +00:00
										 |  |  | #define HEADER_SIZE 64
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-12 12:19:12 +11:00
										 |  |  | static ssize_t imb_ispic_read_header_from_filepath(const char *filepath, | 
					
						
							|  |  |  |                                                    unsigned char buf[HEADER_SIZE]) | 
					
						
							| 
									
										
										
										
											2020-11-10 22:16:29 +11:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2014-05-28 22:50:40 +06:00
										 |  |  |   BLI_stat_t st; | 
					
						
							| 
									
										
										
										
											2013-07-13 12:58:00 +00:00
										 |  |  |   int fp; | 
					
						
							| 
									
										
										
										
											2003-04-28 02:15:46 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-17 15:53:35 +10:00
										 |  |  |   BLI_assert(!BLI_path_is_rel(filepath)); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-23 11:01:30 +10:00
										 |  |  |   if (UTIL_DEBUG) { | 
					
						
							| 
									
										
										
										
											2015-06-17 15:53:35 +10:00
										 |  |  |     printf("%s: loading %s\n", __func__, filepath); | 
					
						
							| 
									
										
										
										
											2019-04-23 11:01:30 +10:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2018-06-17 17:04:54 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-23 11:01:30 +10:00
										 |  |  |   if (BLI_stat(filepath, &st) == -1) { | 
					
						
							| 
									
										
										
										
											2020-11-12 12:19:12 +11:00
										 |  |  |     return -1; | 
					
						
							| 
									
										
										
										
											2019-04-23 11:01:30 +10:00
										 |  |  |   } | 
					
						
							|  |  |  |   if (((st.st_mode) & S_IFMT) != S_IFREG) { | 
					
						
							| 
									
										
										
										
											2020-11-12 12:19:12 +11:00
										 |  |  |     return -1; | 
					
						
							| 
									
										
										
										
											2019-04-23 11:01:30 +10:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2003-04-28 02:15:46 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-23 11:01:30 +10:00
										 |  |  |   if ((fp = BLI_open(filepath, O_BINARY | O_RDONLY, 0)) == -1) { | 
					
						
							| 
									
										
										
										
											2020-11-12 12:19:12 +11:00
										 |  |  |     return -1; | 
					
						
							| 
									
										
										
										
											2019-04-23 11:01:30 +10:00
										 |  |  |   } | 
					
						
							| 
									
										
											  
											
												Merge image related changes from the render branch. This includes the image
tile cache code in imbuf, but it is not hooked up to the render engine.
Imbuf module: some small refactoring and removing a lot of unused or old code
(about 6.5k lines).
* Added a ImFileType struct with callbacks to make adding an file format type,
  or making changes to the API easier.
* Move imbuf init/exit code into IMB_init()/IMB_exit() functions.
* Increased mipmap levels from 10 to 20, you run into this limit already with
  a 2k image.
* Removed hamx, amiga, anim5 format support.
* Removed colormap saving, only simple colormap code now for reading tga.
* Removed gen_dynlibtiff.py, editing this is almost as much work as just
  editing the code directly.
* Functions removed that were only used for sequencer plugin API:
  IMB_anim_nextpic, IMB_clever_double, IMB_antialias, IMB_gamwarp,
  IMB_scalefieldImBuf, IMB_scalefastfieldImBuf, IMB_onethird, IMB_halflace,
  IMB_dit0, IMB_dit2, IMB_cspace
* Write metadata info into OpenEXR images. Can be viewed with the command
  line utility 'exrheader'
For the image tile cache code, see this page:
http://wiki.blender.org/index.php/Dev:2.5/Source/Imaging/ImageTileCache
											
										 
											2010-05-07 15:18:04 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-12 12:19:12 +11:00
										 |  |  |   const ssize_t size = read(fp, buf, HEADER_SIZE); | 
					
						
							| 
									
										
										
										
											2003-04-28 02:15:46 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												Merge image related changes from the render branch. This includes the image
tile cache code in imbuf, but it is not hooked up to the render engine.
Imbuf module: some small refactoring and removing a lot of unused or old code
(about 6.5k lines).
* Added a ImFileType struct with callbacks to make adding an file format type,
  or making changes to the API easier.
* Move imbuf init/exit code into IMB_init()/IMB_exit() functions.
* Increased mipmap levels from 10 to 20, you run into this limit already with
  a 2k image.
* Removed hamx, amiga, anim5 format support.
* Removed colormap saving, only simple colormap code now for reading tga.
* Removed gen_dynlibtiff.py, editing this is almost as much work as just
  editing the code directly.
* Functions removed that were only used for sequencer plugin API:
  IMB_anim_nextpic, IMB_clever_double, IMB_antialias, IMB_gamwarp,
  IMB_scalefieldImBuf, IMB_scalefastfieldImBuf, IMB_onethird, IMB_halflace,
  IMB_dit0, IMB_dit2, IMB_cspace
* Write metadata info into OpenEXR images. Can be viewed with the command
  line utility 'exrheader'
For the image tile cache code, see this page:
http://wiki.blender.org/index.php/Dev:2.5/Source/Imaging/ImageTileCache
											
										 
											2010-05-07 15:18:04 +00:00
										 |  |  |   close(fp); | 
					
						
							| 
									
										
										
										
											2020-11-12 12:19:12 +11:00
										 |  |  |   return size; | 
					
						
							| 
									
										
										
										
											2020-11-10 22:16:29 +11:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-12 12:19:12 +11:00
										 |  |  | int IMB_ispic_type_from_memory(const unsigned char *buf, const size_t buf_size) | 
					
						
							| 
									
										
										
										
											2020-11-10 22:16:29 +11:00
										 |  |  | { | 
					
						
							|  |  |  |   for (const ImFileType *type = IMB_FILE_TYPES; type < IMB_FILE_TYPES_LAST; type++) { | 
					
						
							| 
									
										
										
										
											2020-11-11 16:14:05 +11:00
										 |  |  |     if (type->is_a != NULL) { | 
					
						
							| 
									
										
										
										
											2020-11-12 12:19:12 +11:00
										 |  |  |       if (type->is_a(buf, buf_size)) { | 
					
						
							| 
									
										
										
										
											2013-10-08 21:17:24 +00:00
										 |  |  |         return type->filetype; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2013-07-13 12:58:00 +00:00
										 |  |  |   } | 
					
						
							| 
									
										
											  
											
												Merge image related changes from the render branch. This includes the image
tile cache code in imbuf, but it is not hooked up to the render engine.
Imbuf module: some small refactoring and removing a lot of unused or old code
(about 6.5k lines).
* Added a ImFileType struct with callbacks to make adding an file format type,
  or making changes to the API easier.
* Move imbuf init/exit code into IMB_init()/IMB_exit() functions.
* Increased mipmap levels from 10 to 20, you run into this limit already with
  a 2k image.
* Removed hamx, amiga, anim5 format support.
* Removed colormap saving, only simple colormap code now for reading tga.
* Removed gen_dynlibtiff.py, editing this is almost as much work as just
  editing the code directly.
* Functions removed that were only used for sequencer plugin API:
  IMB_anim_nextpic, IMB_clever_double, IMB_antialias, IMB_gamwarp,
  IMB_scalefieldImBuf, IMB_scalefastfieldImBuf, IMB_onethird, IMB_halflace,
  IMB_dit0, IMB_dit2, IMB_cspace
* Write metadata info into OpenEXR images. Can be viewed with the command
  line utility 'exrheader'
For the image tile cache code, see this page:
http://wiki.blender.org/index.php/Dev:2.5/Source/Imaging/ImageTileCache
											
										 
											2010-05-07 15:18:04 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-13 20:25:21 +11:00
										 |  |  |   return IMB_FTYPE_NONE; | 
					
						
							| 
									
										
										
										
											2020-11-10 22:16:29 +11:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2013-07-13 12:58:00 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-10 22:16:29 +11:00
										 |  |  | int IMB_ispic_type(const char *filepath) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   unsigned char buf[HEADER_SIZE]; | 
					
						
							| 
									
										
										
										
											2020-11-12 12:19:12 +11:00
										 |  |  |   const ssize_t buf_size = imb_ispic_read_header_from_filepath(filepath, buf); | 
					
						
							|  |  |  |   if (buf_size <= 0) { | 
					
						
							| 
									
										
										
										
											2020-11-13 20:25:21 +11:00
										 |  |  |     return IMB_FTYPE_NONE; | 
					
						
							| 
									
										
										
										
											2020-11-10 22:16:29 +11:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2020-11-12 12:19:12 +11:00
										 |  |  |   return IMB_ispic_type_from_memory(buf, (size_t)buf_size); | 
					
						
							| 
									
										
										
										
											2020-11-10 22:16:29 +11:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool IMB_ispic_type_matches(const char *filepath, int filetype) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   unsigned char buf[HEADER_SIZE]; | 
					
						
							| 
									
										
										
										
											2020-11-12 12:19:12 +11:00
										 |  |  |   const ssize_t buf_size = imb_ispic_read_header_from_filepath(filepath, buf); | 
					
						
							|  |  |  |   if (buf_size <= 0) { | 
					
						
							|  |  |  |     return false; | 
					
						
							| 
									
										
										
										
											2020-11-10 22:16:29 +11:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-13 11:24:02 +11:00
										 |  |  |   const ImFileType *type = IMB_file_type_from_ftype(filetype); | 
					
						
							|  |  |  |   if (type != NULL) { | 
					
						
							|  |  |  |     /* Requesting to load a type that can't check it's own header doesn't make sense.
 | 
					
						
							|  |  |  |      * Keep the check for developers. */ | 
					
						
							|  |  |  |     BLI_assert(type->is_a != NULL); | 
					
						
							|  |  |  |     if (type->is_a != NULL) { | 
					
						
							|  |  |  |       return type->is_a(buf, (size_t)buf_size); | 
					
						
							| 
									
										
										
										
											2020-11-10 22:16:29 +11:00
										 |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2020-11-12 12:19:12 +11:00
										 |  |  |   return false; | 
					
						
							| 
									
										
											  
											
												Merge image related changes from the render branch. This includes the image
tile cache code in imbuf, but it is not hooked up to the render engine.
Imbuf module: some small refactoring and removing a lot of unused or old code
(about 6.5k lines).
* Added a ImFileType struct with callbacks to make adding an file format type,
  or making changes to the API easier.
* Move imbuf init/exit code into IMB_init()/IMB_exit() functions.
* Increased mipmap levels from 10 to 20, you run into this limit already with
  a 2k image.
* Removed hamx, amiga, anim5 format support.
* Removed colormap saving, only simple colormap code now for reading tga.
* Removed gen_dynlibtiff.py, editing this is almost as much work as just
  editing the code directly.
* Functions removed that were only used for sequencer plugin API:
  IMB_anim_nextpic, IMB_clever_double, IMB_antialias, IMB_gamwarp,
  IMB_scalefieldImBuf, IMB_scalefastfieldImBuf, IMB_onethird, IMB_halflace,
  IMB_dit0, IMB_dit2, IMB_cspace
* Write metadata info into OpenEXR images. Can be viewed with the command
  line utility 'exrheader'
For the image tile cache code, see this page:
http://wiki.blender.org/index.php/Dev:2.5/Source/Imaging/ImageTileCache
											
										 
											2010-05-07 15:18:04 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2003-04-28 02:15:46 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-10 22:16:29 +11:00
										 |  |  | #undef HEADER_SIZE
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-30 10:43:46 +10:00
										 |  |  | bool IMB_ispic(const char *filepath) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2020-11-13 20:25:21 +11:00
										 |  |  |   return (IMB_ispic_type(filepath) != IMB_FTYPE_NONE); | 
					
						
							| 
									
										
										
										
											2014-04-30 10:43:46 +10:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2003-04-28 02:15:46 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-11 16:14:05 +11:00
										 |  |  | static bool isavi(const char *filepath) | 
					
						
							| 
									
										
										
										
											2011-12-17 00:52:36 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-10-08 02:51:42 +00:00
										 |  |  | #ifdef WITH_AVI
 | 
					
						
							| 
									
										
										
										
											2012-05-16 07:38:23 +00:00
										 |  |  |   return AVI_is_avi(filepath); | 
					
						
							| 
									
										
										
										
											2012-10-08 02:51:42 +00:00
										 |  |  | #else
 | 
					
						
							|  |  |  |   (void)filepath; | 
					
						
							| 
									
										
										
										
											2014-04-01 11:34:00 +11:00
										 |  |  |   return false; | 
					
						
							| 
									
										
										
										
											2012-10-08 02:51:42 +00:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2003-04-28 02:15:46 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-02-05 19:23:34 +00:00
										 |  |  | #ifdef WITH_FFMPEG
 | 
					
						
							| 
									
										
										
										
											2008-11-03 13:33:11 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-08 01:05:37 +00:00
										 |  |  | /* BLI_vsnprintf in ffmpeg_log_callback() causes invalid warning */ | 
					
						
							| 
									
										
										
										
											2012-11-23 10:03:50 +00:00
										 |  |  | #  ifdef __GNUC__
 | 
					
						
							|  |  |  | #    pragma GCC diagnostic push
 | 
					
						
							|  |  |  | #    pragma GCC diagnostic ignored "-Wmissing-format-attribute"
 | 
					
						
							|  |  |  | #  endif
 | 
					
						
							| 
									
										
										
										
											2012-10-08 01:05:37 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-08-26 11:01:14 +00:00
										 |  |  | static char ffmpeg_last_error[1024]; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-09-15 01:52:28 +00:00
										 |  |  | static void ffmpeg_log_callback(void *ptr, int level, const char *format, va_list arg) | 
					
						
							| 
									
										
										
										
											2006-02-05 19:23:34 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-08-26 11:01:14 +00:00
										 |  |  |   if (ELEM(level, AV_LOG_FATAL, AV_LOG_ERROR)) { | 
					
						
							| 
									
										
										
										
											2012-11-19 17:22:40 +00:00
										 |  |  |     size_t n; | 
					
						
							| 
									
										
										
										
											2013-07-25 12:37:22 +00:00
										 |  |  |     va_list args_cpy; | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-07-25 12:37:22 +00:00
										 |  |  |     va_copy(args_cpy, arg); | 
					
						
							|  |  |  |     n = BLI_vsnprintf(ffmpeg_last_error, sizeof(ffmpeg_last_error), format, args_cpy); | 
					
						
							|  |  |  |     va_end(args_cpy); | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-08-26 11:01:14 +00:00
										 |  |  |     /* strip trailing \n */ | 
					
						
							|  |  |  |     ffmpeg_last_error[n - 1] = '\0'; | 
					
						
							| 
									
										
										
										
											2006-02-05 19:23:34 +00:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-09-03 12:01:00 +00:00
										 |  |  |   if (G.debug & G_DEBUG_FFMPEG) { | 
					
						
							|  |  |  |     /* call default logger to print all message to console */ | 
					
						
							|  |  |  |     av_log_default_callback(ptr, level, format, arg); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2012-08-26 11:01:14 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-11-23 10:03:50 +00:00
										 |  |  | #  ifdef __GNUC__
 | 
					
						
							|  |  |  | #    pragma GCC diagnostic pop
 | 
					
						
							|  |  |  | #  endif
 | 
					
						
							| 
									
										
										
										
											2012-10-08 01:05:37 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-08-26 11:01:14 +00:00
										 |  |  | void IMB_ffmpeg_init(void) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   av_register_all(); | 
					
						
							|  |  |  |   avdevice_register_all(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   ffmpeg_last_error[0] = '\0'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-23 11:01:30 +10:00
										 |  |  |   if (G.debug & G_DEBUG_FFMPEG) { | 
					
						
							| 
									
										
										
										
											2013-04-29 16:03:21 +00:00
										 |  |  |     av_log_set_level(AV_LOG_DEBUG); | 
					
						
							| 
									
										
										
										
											2019-04-23 11:01:30 +10:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2013-04-29 16:03:21 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-08-26 11:01:14 +00:00
										 |  |  |   /* set own callback which could store last error to report to UI */ | 
					
						
							|  |  |  |   av_log_set_callback(ffmpeg_log_callback); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const char *IMB_ffmpeg_last_error(void) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   return ffmpeg_last_error; | 
					
						
							| 
									
										
										
										
											2006-02-05 19:23:34 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-16 07:38:23 +00:00
										 |  |  | static int isffmpeg(const char *filepath) | 
					
						
							| 
									
										
										
										
											2011-12-17 00:52:36 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-06-18 10:29:11 +00:00
										 |  |  |   AVFormatContext *pFormatCtx = NULL; | 
					
						
							| 
									
										
										
										
											2008-11-04 23:46:01 +00:00
										 |  |  |   unsigned int i; | 
					
						
							|  |  |  |   int videoStream; | 
					
						
							| 
									
										
										
										
											2006-02-05 19:23:34 +00:00
										 |  |  |   AVCodec *pCodec; | 
					
						
							|  |  |  |   AVCodecContext *pCodecCtx; | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-17 16:13:24 +02:00
										 |  |  |   if (BLI_path_extension_check_n(filepath, | 
					
						
							| 
									
										
										
										
											2014-01-31 03:09:01 +11:00
										 |  |  |                                  ".swf", | 
					
						
							|  |  |  |                                  ".jpg", | 
					
						
							| 
									
										
										
										
											2019-09-27 11:09:38 +02:00
										 |  |  |                                  ".jp2", | 
					
						
							|  |  |  |                                  ".j2c", | 
					
						
							| 
									
										
										
										
											2014-01-31 03:09:01 +11:00
										 |  |  |                                  ".png", | 
					
						
							|  |  |  |                                  ".dds", | 
					
						
							|  |  |  |                                  ".tga", | 
					
						
							|  |  |  |                                  ".bmp", | 
					
						
							|  |  |  |                                  ".tif", | 
					
						
							|  |  |  |                                  ".exr", | 
					
						
							|  |  |  |                                  ".cin", | 
					
						
							|  |  |  |                                  ".wav", | 
					
						
							|  |  |  |                                  NULL)) { | 
					
						
							| 
									
										
										
										
											2012-04-28 06:31:57 +00:00
										 |  |  |     return 0; | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-18 10:29:11 +00:00
										 |  |  |   if (avformat_open_input(&pFormatCtx, filepath, NULL, NULL) != 0) { | 
					
						
							| 
									
										
										
										
											2019-04-23 11:01:30 +10:00
										 |  |  |     if (UTIL_DEBUG) { | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  |       fprintf(stderr, "isffmpeg: av_open_input_file failed\n"); | 
					
						
							| 
									
										
										
										
											2019-04-23 11:01:30 +10:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2006-02-05 19:23:34 +00:00
										 |  |  |     return 0; | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-01-12 12:51:10 +00:00
										 |  |  |   if (avformat_find_stream_info(pFormatCtx, NULL) < 0) { | 
					
						
							| 
									
										
										
										
											2019-04-23 11:01:30 +10:00
										 |  |  |     if (UTIL_DEBUG) { | 
					
						
							| 
									
										
										
										
											2013-01-12 12:51:10 +00:00
										 |  |  |       fprintf(stderr, "isffmpeg: avformat_find_stream_info failed\n"); | 
					
						
							| 
									
										
										
										
											2019-04-23 11:01:30 +10:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2014-01-16 15:40:37 +01:00
										 |  |  |     avformat_close_input(&pFormatCtx); | 
					
						
							| 
									
										
										
										
											2006-02-05 19:23:34 +00:00
										 |  |  |     return 0; | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-23 11:01:30 +10:00
										 |  |  |   if (UTIL_DEBUG) { | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  |     av_dump_format(pFormatCtx, 0, filepath, 0); | 
					
						
							| 
									
										
										
										
											2019-04-23 11:01:30 +10:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-16 07:38:23 +00:00
										 |  |  |   /* Find the first video stream */ | 
					
						
							|  |  |  |   videoStream = -1; | 
					
						
							| 
									
										
										
										
											2019-05-31 22:51:19 +10:00
										 |  |  |   for (i = 0; i < pFormatCtx->nb_streams; i++) { | 
					
						
							| 
									
										
										
										
											2012-05-16 07:38:23 +00:00
										 |  |  |     if (pFormatCtx->streams[i] && pFormatCtx->streams[i]->codec && | 
					
						
							|  |  |  |         (pFormatCtx->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO)) { | 
					
						
							|  |  |  |       videoStream = i; | 
					
						
							| 
									
										
										
										
											2006-02-05 19:23:34 +00:00
										 |  |  |       break; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-05-31 22:51:19 +10:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-16 07:38:23 +00:00
										 |  |  |   if (videoStream == -1) { | 
					
						
							| 
									
										
										
										
											2014-01-16 15:40:37 +01:00
										 |  |  |     avformat_close_input(&pFormatCtx); | 
					
						
							| 
									
										
										
										
											2006-02-05 19:23:34 +00:00
										 |  |  |     return 0; | 
					
						
							| 
									
										
										
										
											2007-05-25 17:11:24 +00:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-05-26 21:57:02 +00:00
										 |  |  |   pCodecCtx = pFormatCtx->streams[videoStream]->codec; | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-16 07:38:23 +00:00
										 |  |  |   /* Find the decoder for the video stream */ | 
					
						
							|  |  |  |   pCodec = avcodec_find_decoder(pCodecCtx->codec_id); | 
					
						
							|  |  |  |   if (pCodec == NULL) { | 
					
						
							| 
									
										
										
										
											2014-01-16 15:40:37 +01:00
										 |  |  |     avformat_close_input(&pFormatCtx); | 
					
						
							| 
									
										
										
										
											2006-02-05 19:23:34 +00:00
										 |  |  |     return 0; | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-01-12 12:51:10 +00:00
										 |  |  |   if (avcodec_open2(pCodecCtx, pCodec, NULL) < 0) { | 
					
						
							| 
									
										
										
										
											2014-01-16 15:40:37 +01:00
										 |  |  |     avformat_close_input(&pFormatCtx); | 
					
						
							| 
									
										
										
										
											2006-02-05 19:23:34 +00:00
										 |  |  |     return 0; | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-02-05 19:23:34 +00:00
										 |  |  |   avcodec_close(pCodecCtx); | 
					
						
							| 
									
										
										
										
											2014-01-16 15:40:37 +01:00
										 |  |  |   avformat_close_input(&pFormatCtx); | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-02-05 19:23:34 +00:00
										 |  |  |   return 1; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-16 07:38:23 +00:00
										 |  |  | int imb_get_anim_type(const char *filepath) | 
					
						
							| 
									
										
										
										
											2011-12-17 00:52:36 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2014-05-28 22:50:40 +06:00
										 |  |  |   BLI_stat_t st; | 
					
						
							| 
									
										
										
										
											2003-04-28 02:15:46 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-17 15:53:35 +10:00
										 |  |  |   BLI_assert(!BLI_path_is_rel(filepath)); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-23 11:01:30 +10:00
										 |  |  |   if (UTIL_DEBUG) { | 
					
						
							| 
									
										
										
										
											2015-06-17 15:53:35 +10:00
										 |  |  |     printf("%s: %s\n", __func__, filepath); | 
					
						
							| 
									
										
										
										
											2019-04-23 11:01:30 +10:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2003-04-28 02:15:46 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-05-30 06:11:25 +00:00
										 |  |  | #ifndef _WIN32
 | 
					
						
							| 
									
										
										
										
											2012-05-16 07:38:23 +00:00
										 |  |  | #  ifdef WITH_FFMPEG
 | 
					
						
							| 
									
										
										
										
											2006-02-05 19:23:34 +00:00
										 |  |  |   /* stat test below fails on large files > 4GB */ | 
					
						
							| 
									
										
										
										
											2019-04-23 11:01:30 +10:00
										 |  |  |   if (isffmpeg(filepath)) { | 
					
						
							| 
									
										
										
										
											2020-08-08 11:02:11 +10:00
										 |  |  |     return ANIM_FFMPEG; | 
					
						
							| 
									
										
										
										
											2019-04-23 11:01:30 +10:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2012-05-16 07:38:23 +00:00
										 |  |  | #  endif
 | 
					
						
							| 
									
										
										
										
											2019-04-23 11:01:30 +10:00
										 |  |  |   if (BLI_stat(filepath, &st) == -1) { | 
					
						
							| 
									
										
										
										
											2020-08-08 11:02:11 +10:00
										 |  |  |     return 0; | 
					
						
							| 
									
										
										
										
											2019-04-23 11:01:30 +10:00
										 |  |  |   } | 
					
						
							|  |  |  |   if (((st.st_mode) & S_IFMT) != S_IFREG) { | 
					
						
							| 
									
										
										
										
											2020-08-08 11:02:11 +10:00
										 |  |  |     return 0; | 
					
						
							| 
									
										
										
										
											2019-04-23 11:01:30 +10:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-23 11:01:30 +10:00
										 |  |  |   if (isavi(filepath)) { | 
					
						
							| 
									
										
										
										
											2020-08-08 11:02:11 +10:00
										 |  |  |     return ANIM_AVI; | 
					
						
							| 
									
										
										
										
											2019-04-23 11:01:30 +10:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-23 11:01:30 +10:00
										 |  |  |   if (ismovie(filepath)) { | 
					
						
							| 
									
										
										
										
											2020-08-08 11:02:11 +10:00
										 |  |  |     return ANIM_MOVIE; | 
					
						
							| 
									
										
										
										
											2019-04-23 11:01:30 +10:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2020-11-12 12:19:12 +11:00
										 |  |  | #else /* !_WIN32 */
 | 
					
						
							| 
									
										
										
										
											2019-04-23 11:01:30 +10:00
										 |  |  |   if (BLI_stat(filepath, &st) == -1) { | 
					
						
							| 
									
										
										
										
											2020-08-08 11:02:11 +10:00
										 |  |  |     return 0; | 
					
						
							| 
									
										
										
										
											2019-04-23 11:01:30 +10:00
										 |  |  |   } | 
					
						
							|  |  |  |   if (((st.st_mode) & S_IFMT) != S_IFREG) { | 
					
						
							| 
									
										
										
										
											2020-08-08 11:02:11 +10:00
										 |  |  |     return 0; | 
					
						
							| 
									
										
										
										
											2019-04-23 11:01:30 +10:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-23 11:01:30 +10:00
										 |  |  |   if (ismovie(filepath)) { | 
					
						
							| 
									
										
										
										
											2020-08-08 11:02:11 +10:00
										 |  |  |     return ANIM_MOVIE; | 
					
						
							| 
									
										
										
										
											2019-04-23 11:01:30 +10:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2012-05-16 07:38:23 +00:00
										 |  |  | #  ifdef WITH_FFMPEG
 | 
					
						
							| 
									
										
										
										
											2019-04-23 11:01:30 +10:00
										 |  |  |   if (isffmpeg(filepath)) { | 
					
						
							| 
									
										
										
										
											2020-08-08 11:02:11 +10:00
										 |  |  |     return ANIM_FFMPEG; | 
					
						
							| 
									
										
										
										
											2019-04-23 11:01:30 +10:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2012-05-16 07:38:23 +00:00
										 |  |  | #  endif
 | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-23 11:01:30 +10:00
										 |  |  |   if (isavi(filepath)) { | 
					
						
							| 
									
										
										
										
											2020-08-08 11:02:11 +10:00
										 |  |  |     return ANIM_AVI; | 
					
						
							| 
									
										
										
										
											2019-04-23 11:01:30 +10:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2020-11-12 12:19:12 +11:00
										 |  |  | #endif /* !_WIN32 */
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   /* Assume a single image is part of an image sequence. */ | 
					
						
							|  |  |  |   if (IMB_ispic(filepath)) { | 
					
						
							| 
									
										
										
										
											2012-04-23 08:05:02 +00:00
										 |  |  |     return ANIM_SEQUENCE; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return ANIM_NONE; | 
					
						
							| 
									
										
										
										
											2003-04-28 02:15:46 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2018-06-17 17:04:54 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-03 18:55:59 +11:00
										 |  |  | bool IMB_isanim(const char *filepath) | 
					
						
							| 
									
										
										
										
											2011-12-17 00:52:36 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2003-04-28 02:15:46 +00:00
										 |  |  |   int type; | 
					
						
							| 
									
										
										
										
											2015-06-17 15:53:35 +10:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-03 19:33:17 +11:00
										 |  |  |   type = imb_get_anim_type(filepath); | 
					
						
							| 
									
										
										
										
											2018-06-17 17:04:54 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-16 07:38:23 +00:00
										 |  |  |   return (type && type != ANIM_SEQUENCE); | 
					
						
							| 
									
										
										
										
											2003-04-28 02:15:46 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2015-04-06 10:40:12 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-25 17:11:00 +10:00
										 |  |  | bool IMB_isfloat(const ImBuf *ibuf) | 
					
						
							| 
									
										
										
										
											2015-04-06 10:40:12 -03:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2020-11-13 11:24:02 +11:00
										 |  |  |   const ImFileType *type = IMB_file_type_from_ibuf(ibuf); | 
					
						
							|  |  |  |   if (type != NULL) { | 
					
						
							|  |  |  |     if (type->flag & IM_FTYPE_FLOAT) { | 
					
						
							|  |  |  |       return true; | 
					
						
							| 
									
										
										
										
											2015-04-06 10:40:12 -03:00
										 |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   return false; | 
					
						
							|  |  |  | } |