2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
2008-04-16 22:40:48 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
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.
|
|
|
|
*
|
|
|
|
* The Original Code is: all of this file.
|
|
|
|
*
|
|
|
|
* Contributor(s): none yet.
|
|
|
|
*
|
2008-04-16 22:40:48 +00:00
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
2002-10-12 11:37:38 +00:00
|
|
|
* util.c
|
|
|
|
*
|
|
|
|
* $Id$
|
|
|
|
*/
|
|
|
|
|
2011-02-27 20:23:21 +00:00
|
|
|
/** \file blender/imbuf/intern/util.c
|
|
|
|
* \ingroup imbuf
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2008-11-04 23:46:01 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
#include <io.h>
|
|
|
|
#define open _open
|
|
|
|
#define read _read
|
|
|
|
#define close _close
|
|
|
|
#endif
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "BLI_blenlib.h"
|
|
|
|
|
2003-04-28 02:15:46 +00:00
|
|
|
#include "DNA_userdef_types.h"
|
|
|
|
#include "BKE_global.h"
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "imbuf.h"
|
|
|
|
#include "IMB_imbuf_types.h"
|
|
|
|
#include "IMB_imbuf.h"
|
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"
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2003-04-28 02:15:46 +00:00
|
|
|
#include "IMB_anim.h"
|
|
|
|
|
|
|
|
#ifdef WITH_QUICKTIME
|
|
|
|
#include "quicktime_import.h"
|
|
|
|
#endif
|
|
|
|
|
2006-02-05 19:23:34 +00:00
|
|
|
#ifdef WITH_FFMPEG
|
2009-03-22 19:19:21 +00:00
|
|
|
#include <libavcodec/avcodec.h>
|
|
|
|
#include <libavformat/avformat.h>
|
|
|
|
#include <libavdevice/avdevice.h>
|
|
|
|
#include <libavutil/log.h>
|
2006-02-05 19:23:34 +00:00
|
|
|
|
|
|
|
#if LIBAVFORMAT_VERSION_INT < (49 << 16)
|
|
|
|
#define FFMPEG_OLD_FRAME_RATE 1
|
|
|
|
#else
|
|
|
|
#define FFMPEG_CODEC_IS_POINTER 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#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[] = {
|
2010-08-03 19:03:51 +00:00
|
|
|
".png",
|
2010-08-03 12:34:42 +00:00
|
|
|
".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
|
2010-08-03 12:34:42 +00:00
|
|
|
".jp2",
|
|
|
|
#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",
|
|
|
|
#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",
|
2010-12-10 04:10:21 +00:00
|
|
|
".mxf",
|
2010-08-03 12:34:42 +00:00
|
|
|
NULL};
|
|
|
|
|
|
|
|
/* sort of wrong being here... */
|
|
|
|
const char *imb_ext_audio[] = {
|
|
|
|
".wav",
|
|
|
|
".ogg",
|
|
|
|
".oga",
|
|
|
|
".mp3",
|
|
|
|
".mp2",
|
|
|
|
".ac3",
|
|
|
|
".aac",
|
|
|
|
".flac",
|
|
|
|
".wma",
|
|
|
|
".eac3",
|
|
|
|
NULL};
|
|
|
|
|
2010-11-19 02:14:18 +00:00
|
|
|
static int IMB_ispic_name(const char *name)
|
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
|
|
|
ImFileType *type;
|
2002-10-12 11:37:38 +00:00
|
|
|
struct stat st;
|
2003-02-09 12:47:43 +00:00
|
|
|
int fp, buf[10];
|
2003-04-28 02:15:46 +00:00
|
|
|
|
|
|
|
if(UTIL_DEBUG) printf("IMB_ispic_name: loading %s\n", name);
|
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
|
|
|
if(stat(name,&st) == -1)
|
|
|
|
return FALSE;
|
|
|
|
if(((st.st_mode) & S_IFMT) != S_IFREG)
|
|
|
|
return FALSE;
|
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
|
|
|
if((fp = open(name,O_BINARY|O_RDONLY)) < 0)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if(read(fp, buf, 32) != 32) {
|
|
|
|
close(fp);
|
|
|
|
return FALSE;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
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);
|
|
|
|
|
|
|
|
/* XXX move this exception */
|
|
|
|
if((BIG_LONG(buf[0]) & 0xfffffff0) == 0xffd8ffe0)
|
|
|
|
return JPG;
|
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
|
|
|
for(type=IMB_FILE_TYPES; type->is_a; type++)
|
|
|
|
if(type->is_a((uchar*)buf))
|
|
|
|
return type->filetype;
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
2003-04-28 02:15:46 +00:00
|
|
|
|
2010-11-19 02:14:18 +00:00
|
|
|
int IMB_ispic(const char *filename)
|
2003-04-28 02:15:46 +00:00
|
|
|
{
|
2004-01-13 14:50:45 +00:00
|
|
|
if(U.uiflag & USER_FILTERFILEEXTS) {
|
2010-08-03 12:34:42 +00:00
|
|
|
if( (BLI_testextensie_array(filename, imb_ext_image)) ||
|
|
|
|
(G.have_quicktime && BLI_testextensie_array(filename, imb_ext_image_qt))
|
|
|
|
) {
|
|
|
|
return IMB_ispic_name(filename);
|
2005-11-22 18:50:03 +00:00
|
|
|
}
|
2010-08-03 12:34:42 +00:00
|
|
|
else {
|
|
|
|
return FALSE;
|
2003-04-28 02:15:46 +00:00
|
|
|
}
|
2010-08-03 12:34:42 +00:00
|
|
|
}
|
|
|
|
else { /* no FILTERFILEEXTS */
|
2003-04-28 02:15:46 +00:00
|
|
|
return IMB_ispic_name(filename);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-11-19 02:14:18 +00:00
|
|
|
static int isavi (const char *name) {
|
2005-01-03 19:53:04 +00:00
|
|
|
return AVI_is_avi (name);
|
2003-04-28 02:15:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef WITH_QUICKTIME
|
2010-11-19 02:14:18 +00:00
|
|
|
static int isqtime (const char *name) {
|
2003-04-28 02:15:46 +00:00
|
|
|
return anim_is_quicktime (name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2006-02-05 19:23:34 +00:00
|
|
|
#ifdef WITH_FFMPEG
|
2008-11-03 13:33:11 +00:00
|
|
|
|
|
|
|
void silence_log_ffmpeg(int quiet)
|
|
|
|
{
|
|
|
|
if (quiet)
|
|
|
|
{
|
|
|
|
av_log_set_level(AV_LOG_QUIET);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
av_log_set_level(AV_LOG_INFO);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-03 18:35:10 +00:00
|
|
|
extern void do_init_ffmpeg(void);
|
|
|
|
void do_init_ffmpeg(void)
|
2006-02-05 19:23:34 +00:00
|
|
|
{
|
|
|
|
static int ffmpeg_init = 0;
|
|
|
|
if (!ffmpeg_init) {
|
|
|
|
ffmpeg_init = 1;
|
|
|
|
av_register_all();
|
2008-12-17 20:52:39 +00:00
|
|
|
avdevice_register_all();
|
2008-11-02 16:28:34 +00:00
|
|
|
|
|
|
|
if ((G.f & G_DEBUG) == 0)
|
|
|
|
{
|
|
|
|
silence_log_ffmpeg(1);
|
|
|
|
}
|
2006-02-05 19:23:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-03-07 20:01:12 +00:00
|
|
|
#ifdef FFMPEG_CODEC_IS_POINTER
|
|
|
|
static AVCodecContext* get_codec_from_stream(AVStream* stream)
|
|
|
|
{
|
|
|
|
return stream->codec;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
static AVCodecContext* get_codec_from_stream(AVStream* stream)
|
|
|
|
{
|
|
|
|
return &stream->codec;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2006-02-05 19:23:34 +00:00
|
|
|
|
2010-11-19 02:14:18 +00:00
|
|
|
static int isffmpeg (const char *filename) {
|
2006-02-05 19:23:34 +00:00
|
|
|
AVFormatContext *pFormatCtx;
|
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;
|
|
|
|
|
|
|
|
do_init_ffmpeg();
|
|
|
|
|
2007-05-25 17:11:24 +00:00
|
|
|
if( BLI_testextensie(filename, ".swf") ||
|
|
|
|
BLI_testextensie(filename, ".jpg") ||
|
|
|
|
BLI_testextensie(filename, ".png") ||
|
2007-06-25 19:50:25 +00:00
|
|
|
BLI_testextensie(filename, ".dds") ||
|
2007-05-25 17:11:24 +00:00
|
|
|
BLI_testextensie(filename, ".tga") ||
|
|
|
|
BLI_testextensie(filename, ".bmp") ||
|
|
|
|
BLI_testextensie(filename, ".exr") ||
|
|
|
|
BLI_testextensie(filename, ".cin") ||
|
|
|
|
BLI_testextensie(filename, ".wav")) return 0;
|
|
|
|
|
2006-02-05 19:23:34 +00:00
|
|
|
if(av_open_input_file(&pFormatCtx, filename, NULL, 0, NULL)!=0) {
|
2007-05-30 06:11:25 +00:00
|
|
|
if(UTIL_DEBUG) fprintf(stderr, "isffmpeg: av_open_input_file failed\n");
|
2006-02-05 19:23:34 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(av_find_stream_info(pFormatCtx)<0) {
|
2007-05-30 06:11:25 +00:00
|
|
|
if(UTIL_DEBUG) fprintf(stderr, "isffmpeg: av_find_stream_info failed\n");
|
2006-02-05 19:23:34 +00:00
|
|
|
av_close_input_file(pFormatCtx);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-05-30 06:11:25 +00:00
|
|
|
if(UTIL_DEBUG) dump_format(pFormatCtx, 0, filename, 0);
|
2006-02-05 19:23:34 +00:00
|
|
|
|
|
|
|
|
2010-03-22 09:30:00 +00:00
|
|
|
/* Find the first video stream */
|
2006-02-05 19:23:34 +00:00
|
|
|
videoStream=-1;
|
|
|
|
for(i=0; i<pFormatCtx->nb_streams; i++)
|
2008-02-28 21:57:24 +00:00
|
|
|
if(pFormatCtx->streams[i] &&
|
|
|
|
get_codec_from_stream(pFormatCtx->streams[i]) &&
|
|
|
|
(get_codec_from_stream(pFormatCtx->streams[i])->codec_type==CODEC_TYPE_VIDEO))
|
2006-02-05 19:23:34 +00:00
|
|
|
{
|
|
|
|
videoStream=i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2007-05-25 17:11:24 +00:00
|
|
|
if(videoStream==-1) {
|
|
|
|
av_close_input_file(pFormatCtx);
|
2006-02-05 19:23:34 +00:00
|
|
|
return 0;
|
2007-05-25 17:11:24 +00:00
|
|
|
}
|
2006-02-05 19:23:34 +00:00
|
|
|
|
2006-03-30 21:51:59 +00:00
|
|
|
pCodecCtx = get_codec_from_stream(pFormatCtx->streams[videoStream]);
|
2006-02-05 19:23:34 +00:00
|
|
|
|
2010-03-22 09:30:00 +00:00
|
|
|
/* Find the decoder for the video stream */
|
2006-02-05 19:23:34 +00:00
|
|
|
pCodec=avcodec_find_decoder(pCodecCtx->codec_id);
|
|
|
|
if(pCodec==NULL) {
|
|
|
|
av_close_input_file(pFormatCtx);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(avcodec_open(pCodecCtx, pCodec)<0) {
|
|
|
|
av_close_input_file(pFormatCtx);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
avcodec_close(pCodecCtx);
|
|
|
|
av_close_input_file(pFormatCtx);
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2008-06-02 21:35:57 +00:00
|
|
|
#ifdef WITH_REDCODE
|
2010-11-30 18:52:39 +00:00
|
|
|
static int isredcode(const char * filename)
|
2008-06-02 21:35:57 +00:00
|
|
|
{
|
|
|
|
struct redcode_handle * h = redcode_open(filename);
|
|
|
|
if (!h) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
redcode_close(h);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2010-11-19 02:14:18 +00:00
|
|
|
int imb_get_anim_type(const char * name) {
|
2003-04-28 02:15:46 +00:00
|
|
|
int type;
|
|
|
|
struct stat st;
|
|
|
|
|
|
|
|
if(UTIL_DEBUG) printf("in getanimtype: %s\n", name);
|
|
|
|
|
2007-05-30 06:11:25 +00:00
|
|
|
#ifndef _WIN32
|
2009-11-18 09:49:42 +00:00
|
|
|
# ifdef WITH_QUICKTIME
|
|
|
|
if (isqtime(name)) return (ANIM_QTIME);
|
|
|
|
# endif
|
2007-05-30 06:11:25 +00:00
|
|
|
# ifdef WITH_FFMPEG
|
2006-02-05 19:23:34 +00:00
|
|
|
/* stat test below fails on large files > 4GB */
|
|
|
|
if (isffmpeg(name)) return (ANIM_FFMPEG);
|
2007-05-30 06:11:25 +00:00
|
|
|
# endif
|
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
|
|
|
if (stat(name,&st) == -1) return(0);
|
2007-05-30 06:11:25 +00:00
|
|
|
if (((st.st_mode) & S_IFMT) != S_IFREG) return(0);
|
|
|
|
|
|
|
|
if (isavi(name)) return (ANIM_AVI);
|
2006-02-05 19:23:34 +00:00
|
|
|
|
2007-05-30 06:11:25 +00:00
|
|
|
if (ismovie(name)) return (ANIM_MOVIE);
|
|
|
|
#else
|
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
|
|
|
if (stat(name,&st) == -1) return(0);
|
2005-01-03 19:53:04 +00:00
|
|
|
if (((st.st_mode) & S_IFMT) != S_IFREG) return(0);
|
2006-02-05 19:23:34 +00:00
|
|
|
|
2003-04-28 02:15:46 +00:00
|
|
|
if (ismovie(name)) return (ANIM_MOVIE);
|
2007-05-30 06:11:25 +00:00
|
|
|
# ifdef WITH_QUICKTIME
|
2003-04-28 02:15:46 +00:00
|
|
|
if (isqtime(name)) return (ANIM_QTIME);
|
2007-05-30 06:11:25 +00:00
|
|
|
# endif
|
|
|
|
# ifdef WITH_FFMPEG
|
|
|
|
if (isffmpeg(name)) return (ANIM_FFMPEG);
|
|
|
|
# endif
|
2009-06-21 12:02:40 +00:00
|
|
|
if (isavi(name)) return (ANIM_AVI);
|
2008-06-02 21:35:57 +00:00
|
|
|
#endif
|
|
|
|
#ifdef WITH_REDCODE
|
|
|
|
if (isredcode(name)) return (ANIM_REDCODE);
|
2003-04-28 02:15:46 +00:00
|
|
|
#endif
|
|
|
|
type = IMB_ispic(name);
|
|
|
|
if (type) return(ANIM_SEQUENCE);
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
2010-11-19 02:14:18 +00:00
|
|
|
int IMB_isanim(const char *filename) {
|
2003-04-28 02:15:46 +00:00
|
|
|
int type;
|
|
|
|
|
2004-01-13 14:50:45 +00:00
|
|
|
if(U.uiflag & USER_FILTERFILEEXTS) {
|
2003-04-28 02:15:46 +00:00
|
|
|
if (G.have_quicktime){
|
|
|
|
if( BLI_testextensie(filename, ".avi")
|
|
|
|
|| BLI_testextensie(filename, ".flc")
|
2006-02-05 19:23:34 +00:00
|
|
|
|| BLI_testextensie(filename, ".dv")
|
2008-06-02 21:35:57 +00:00
|
|
|
|| BLI_testextensie(filename, ".r3d")
|
2003-04-28 02:15:46 +00:00
|
|
|
|| BLI_testextensie(filename, ".mov")
|
|
|
|
|| BLI_testextensie(filename, ".movie")
|
|
|
|
|| BLI_testextensie(filename, ".mv")) {
|
|
|
|
type = imb_get_anim_type(filename);
|
|
|
|
} else {
|
|
|
|
return(FALSE);
|
|
|
|
}
|
|
|
|
} else { // no quicktime
|
|
|
|
if( BLI_testextensie(filename, ".avi")
|
2006-02-05 19:23:34 +00:00
|
|
|
|| BLI_testextensie(filename, ".dv")
|
2008-06-02 21:35:57 +00:00
|
|
|
|| BLI_testextensie(filename, ".r3d")
|
2003-04-28 02:15:46 +00:00
|
|
|
|| BLI_testextensie(filename, ".mv")) {
|
|
|
|
type = imb_get_anim_type(filename);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return(FALSE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else { // no FILTERFILEEXTS
|
|
|
|
type = imb_get_anim_type(filename);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (type && type!=ANIM_SEQUENCE);
|
|
|
|
}
|