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,
|
|
|
|
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*
|
|
|
|
* 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$
|
|
|
|
*/
|
|
|
|
|
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 "imbuf_patch.h"
|
|
|
|
#include "IMB_imbuf_types.h"
|
|
|
|
#include "IMB_imbuf.h"
|
|
|
|
|
|
|
|
#include "IMB_targa.h"
|
|
|
|
#include "IMB_png.h"
|
2007-06-25 19:50:25 +00:00
|
|
|
|
|
|
|
#ifdef WITH_DDS
|
|
|
|
#include "dds/dds_api.h"
|
|
|
|
#endif
|
|
|
|
|
2003-01-29 12:18:25 +00:00
|
|
|
#include "IMB_bmp.h"
|
2005-11-22 18:50:03 +00:00
|
|
|
#include "IMB_tiff.h"
|
2005-11-20 14:32:07 +00:00
|
|
|
#include "IMB_radiance_hdr.h"
|
2006-03-12 14:11:23 +00:00
|
|
|
#include "IMB_dpxcineon.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2003-04-28 02:15:46 +00:00
|
|
|
#include "IMB_anim.h"
|
|
|
|
|
Orange branch: OpenEXR finally in Blender!
Credits go to Gernot Ziegler, who originally coded EXR support, and to
Austin Benesh for bringing it further. Kent Mein provided a lot of code
for integrating float buffers in Blender imbuf and ImBuf API cleanup,
and provided Make and Scons and static linking.
At this moment; the EXR libraries are a *dependency*, so you cannot get
the Orange branch compiled without having OpenEXR installed. Get the
(precompiled or sources) stuff from www.openexr.com. Current default is
that the headers and lib resides in /user/local/
Several changes/additions/fixes were added:
- EXR code only supported 'half' format (16 bits per channel). I've added
float writing, but for reading it I need tomorrow. :)
- Quite some clumsy copying of data happened in EXR code.
- cleaned up the api calls already a bit, preparing for more advanced
support
- Zbuffers were saved 16 bits, now 32 bits
- automatic adding of .exr extensions went wrong
Imbuf:
- added proper imbuf->flags and imbuf->mall support for float buffers, it
was created for *each* imbuf. :)
- found bugs for float buffers in scaling and flipping. Code there will
need more checks still
- imbuf also needs to be verified to behave properly when no 32 bits
rect exists (for saving for example)
TODO:
- support internal float images for textures, backbuf, AO probes, and
display in Image window
Hope this commit won't screwup syncing with bf-blender... :/
2006-01-09 00:40:35 +00:00
|
|
|
#ifdef WITH_OPENEXR
|
|
|
|
#include "openexr/openexr_api.h"
|
|
|
|
#endif
|
|
|
|
|
2003-04-28 02:15:46 +00:00
|
|
|
#ifdef WITH_QUICKTIME
|
|
|
|
#include "quicktime_import.h"
|
|
|
|
#endif
|
|
|
|
|
2009-01-23 21:08:01 +00:00
|
|
|
#ifdef WITH_OPENJPEG
|
|
|
|
#include "IMB_jp2.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
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
/* from misc_util: flip the bytes from x */
|
|
|
|
#define GS(x) (((unsigned char *)(x))[0] << 8 | ((unsigned char *)(x))[1])
|
|
|
|
|
|
|
|
/* this one is only def-ed once, strangely... */
|
|
|
|
#define GSS(x) (((uchar *)(x))[1] << 8 | ((uchar *)(x))[0])
|
|
|
|
|
2005-03-09 19:45:59 +00:00
|
|
|
static int IMB_ispic_name(char *name)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
struct stat st;
|
2003-02-09 12:47:43 +00:00
|
|
|
int fp, buf[10];
|
2002-10-12 11:37:38 +00:00
|
|
|
int ofs = 0;
|
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
|
|
|
|
|
|
|
if (ib_stat(name,&st) == -1) return(0);
|
|
|
|
if (((st.st_mode) & S_IFMT) == S_IFREG){
|
|
|
|
if ((fp = open(name,O_BINARY|O_RDONLY)) >= 0){
|
2003-02-09 12:47:43 +00:00
|
|
|
if (read(fp,buf,32)==32){
|
2002-10-12 11:37:38 +00:00
|
|
|
close(fp);
|
|
|
|
if (buf[ofs] == CAT) ofs += 3;
|
|
|
|
if (buf[ofs] == FORM){
|
|
|
|
if (buf[ofs + 2] == ILBM) return(AMI);
|
|
|
|
if (buf[ofs + 2] == ANIM){
|
|
|
|
if (buf[ofs + 3] == FORM){
|
|
|
|
return(ANIM);
|
|
|
|
}else{
|
|
|
|
return(Anim);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (GS(buf) == IMAGIC) return(IMAGIC);
|
|
|
|
if (GSS(buf) == IMAGIC) return(IMAGIC);
|
|
|
|
if ((BIG_LONG(buf[0]) & 0xfffffff0) == 0xffd8ffe0) return(JPG);
|
|
|
|
|
|
|
|
/* at windows there are ".ffl" files with the same magic numnber...
|
|
|
|
besides that, tim images are not really important anymore! */
|
|
|
|
/* if ((BIG_LONG(buf[0]) == 0x10000000) && ((BIG_LONG(buf[1]) & 0xf0ffffff) == 0)) return(TIM); */
|
|
|
|
|
|
|
|
}
|
2003-04-28 02:15:46 +00:00
|
|
|
if (imb_is_a_png(buf)) return(PNG);
|
2007-06-25 19:50:25 +00:00
|
|
|
#ifdef WITH_DDS
|
|
|
|
if (imb_is_a_dds((uchar *)buf)) return(DDS);
|
|
|
|
#endif
|
2003-04-28 02:15:46 +00:00
|
|
|
if (imb_is_a_targa(buf)) return(TGA);
|
Orange branch: OpenEXR finally in Blender!
Credits go to Gernot Ziegler, who originally coded EXR support, and to
Austin Benesh for bringing it further. Kent Mein provided a lot of code
for integrating float buffers in Blender imbuf and ImBuf API cleanup,
and provided Make and Scons and static linking.
At this moment; the EXR libraries are a *dependency*, so you cannot get
the Orange branch compiled without having OpenEXR installed. Get the
(precompiled or sources) stuff from www.openexr.com. Current default is
that the headers and lib resides in /user/local/
Several changes/additions/fixes were added:
- EXR code only supported 'half' format (16 bits per channel). I've added
float writing, but for reading it I need tomorrow. :)
- Quite some clumsy copying of data happened in EXR code.
- cleaned up the api calls already a bit, preparing for more advanced
support
- Zbuffers were saved 16 bits, now 32 bits
- automatic adding of .exr extensions went wrong
Imbuf:
- added proper imbuf->flags and imbuf->mall support for float buffers, it
was created for *each* imbuf. :)
- found bugs for float buffers in scaling and flipping. Code there will
need more checks still
- imbuf also needs to be verified to behave properly when no 32 bits
rect exists (for saving for example)
TODO:
- support internal float images for textures, backbuf, AO probes, and
display in Image window
Hope this commit won't screwup syncing with bf-blender... :/
2006-01-09 00:40:35 +00:00
|
|
|
#ifdef WITH_OPENEXR
|
|
|
|
if (imb_is_a_openexr((uchar *)buf)) return(OPENEXR);
|
|
|
|
#endif
|
2005-11-22 18:50:03 +00:00
|
|
|
if (imb_is_a_tiff(buf)) return(TIF);
|
2006-03-12 14:11:23 +00:00
|
|
|
if (imb_is_dpx(buf)) return (DPX);
|
|
|
|
if (imb_is_cineon(buf)) return(CINEON);
|
2005-11-20 14:32:07 +00:00
|
|
|
/* radhdr: check if hdr format */
|
|
|
|
if (imb_is_a_hdr(buf)) return(RADHDR);
|
|
|
|
|
2003-02-09 12:47:43 +00:00
|
|
|
/*
|
2003-04-28 02:15:46 +00:00
|
|
|
if (imb_is_a_bmp(buf)) return(BMP);
|
2003-02-09 12:47:43 +00:00
|
|
|
*/
|
2009-01-23 21:08:01 +00:00
|
|
|
|
|
|
|
#ifdef WITH_OPENJPEG
|
|
|
|
if (imb_is_a_jp2(buf)) return(JP2);
|
|
|
|
#endif
|
|
|
|
|
2003-04-28 02:15:46 +00:00
|
|
|
#ifdef WITH_QUICKTIME
|
|
|
|
#if defined(_WIN32) || defined(__APPLE__)
|
|
|
|
if(G.have_quicktime) {
|
|
|
|
if (imb_is_a_quicktime(name)) return(QUICKTIME);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
return(FALSE);
|
|
|
|
}
|
|
|
|
close(fp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return(FALSE);
|
|
|
|
}
|
2003-04-28 02:15:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int IMB_ispic(char *filename)
|
|
|
|
{
|
2004-01-13 14:50:45 +00:00
|
|
|
if(U.uiflag & USER_FILTERFILEEXTS) {
|
2005-11-22 18:50:03 +00:00
|
|
|
if (G.have_libtiff && (BLI_testextensie(filename, ".tif")
|
|
|
|
|| BLI_testextensie(filename, ".tiff"))) {
|
|
|
|
return IMB_ispic_name(filename);
|
|
|
|
}
|
2003-04-28 02:15:46 +00:00
|
|
|
if (G.have_quicktime){
|
|
|
|
if( BLI_testextensie(filename, ".jpg")
|
|
|
|
|| BLI_testextensie(filename, ".jpeg")
|
2005-11-22 18:50:03 +00:00
|
|
|
|| BLI_testextensie(filename, ".tif")
|
|
|
|
|| BLI_testextensie(filename, ".tiff")
|
2005-11-20 14:32:07 +00:00
|
|
|
|| BLI_testextensie(filename, ".hdr")
|
2003-04-28 02:15:46 +00:00
|
|
|
|| BLI_testextensie(filename, ".tga")
|
|
|
|
|| BLI_testextensie(filename, ".rgb")
|
|
|
|
|| BLI_testextensie(filename, ".bmp")
|
|
|
|
|| BLI_testextensie(filename, ".png")
|
2007-06-25 19:50:25 +00:00
|
|
|
#ifdef WITH_DDS
|
|
|
|
|| BLI_testextensie(filename, ".dds")
|
|
|
|
#endif
|
2003-04-28 02:15:46 +00:00
|
|
|
|| 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")
|
2007-05-25 17:32:41 +00:00
|
|
|
|| BLI_testextensie(filename, ".cin")
|
|
|
|
#ifdef WITH_BF_OPENEXR
|
|
|
|
|| BLI_testextensie(filename, ".exr")
|
2009-01-23 21:08:01 +00:00
|
|
|
#endif
|
|
|
|
#ifdef WITH_BF_OPENJPEG
|
|
|
|
|| BLI_testextensie(filename, ".jp2")
|
2007-05-25 17:32:41 +00:00
|
|
|
#endif
|
2003-04-28 02:15:46 +00:00
|
|
|
|| BLI_testextensie(filename, ".sgi")) {
|
|
|
|
return IMB_ispic_name(filename);
|
|
|
|
} else {
|
|
|
|
return(FALSE);
|
|
|
|
}
|
2005-11-22 18:50:03 +00:00
|
|
|
} else { /* no quicktime or libtiff */
|
2003-04-28 02:15:46 +00:00
|
|
|
if( BLI_testextensie(filename, ".jpg")
|
|
|
|
|| BLI_testextensie(filename, ".jpeg")
|
2005-11-20 14:32:07 +00:00
|
|
|
|| BLI_testextensie(filename, ".hdr")
|
2003-04-28 02:15:46 +00:00
|
|
|
|| BLI_testextensie(filename, ".tga")
|
|
|
|
|| BLI_testextensie(filename, ".rgb")
|
|
|
|
|| BLI_testextensie(filename, ".bmp")
|
|
|
|
|| BLI_testextensie(filename, ".png")
|
2007-05-25 17:32:41 +00:00
|
|
|
|| BLI_testextensie(filename, ".cin")
|
2007-06-25 19:50:25 +00:00
|
|
|
#ifdef WITH_DDS
|
|
|
|
|| BLI_testextensie(filename, ".dds")
|
|
|
|
#endif
|
2007-05-25 17:32:41 +00:00
|
|
|
#ifdef WITH_BF_OPENEXR
|
|
|
|
|| BLI_testextensie(filename, ".exr")
|
2009-01-23 21:08:01 +00:00
|
|
|
#endif
|
|
|
|
#ifdef WITH_BF_OPENJPEG
|
|
|
|
|| BLI_testextensie(filename, ".jp2")
|
2007-05-25 17:32:41 +00:00
|
|
|
#endif
|
2003-04-28 02:15:46 +00:00
|
|
|
|| BLI_testextensie(filename, ".iff")
|
|
|
|
|| BLI_testextensie(filename, ".lbm")
|
2005-03-23 21:10:03 +00:00
|
|
|
|| BLI_testextensie(filename, ".sgi")) {
|
2003-04-28 02:15:46 +00:00
|
|
|
return IMB_ispic_name(filename);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return(FALSE);
|
|
|
|
}
|
|
|
|
}
|
2005-11-22 18:50:03 +00:00
|
|
|
} else { /* no FILTERFILEEXTS */
|
2003-04-28 02:15:46 +00:00
|
|
|
return IMB_ispic_name(filename);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int isavi (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
|
|
|
|
static int isqtime (char *name) {
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-27 15:02:37 +00:00
|
|
|
extern void do_init_ffmpeg();
|
2006-02-05 19:23:34 +00:00
|
|
|
void do_init_ffmpeg()
|
|
|
|
{
|
|
|
|
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
|
|
|
|
|
|
|
static int isffmpeg (char *filename) {
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
/* Find the first video stream */
|
|
|
|
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
|
|
|
|
|
|
|
/* Find the decoder for the video stream */
|
|
|
|
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
|
|
|
|
static int isredcode(char * filename)
|
|
|
|
{
|
|
|
|
struct redcode_handle * h = redcode_open(filename);
|
|
|
|
if (!h) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
redcode_close(h);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2003-04-28 02:15:46 +00:00
|
|
|
int imb_get_anim_type(char * name) {
|
|
|
|
int type;
|
|
|
|
struct stat st;
|
|
|
|
|
|
|
|
if(UTIL_DEBUG) printf("in getanimtype: %s\n", name);
|
|
|
|
|
2007-05-30 06:11:25 +00:00
|
|
|
#ifndef _WIN32
|
|
|
|
# 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
|
|
|
|
if (ib_stat(name,&st) == -1) return(0);
|
|
|
|
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);
|
|
|
|
# ifdef WITH_QUICKTIME
|
|
|
|
if (isqtime(name)) return (ANIM_QTIME);
|
|
|
|
# endif
|
|
|
|
#else
|
2005-01-03 19:53:04 +00:00
|
|
|
if (ib_stat(name,&st) == -1) return(0);
|
|
|
|
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 (isavi(name)) return (ANIM_AVI);
|
|
|
|
|
|
|
|
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
|
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 == ANIM) return (ANIM_ANIM5);
|
|
|
|
if (type) return(ANIM_SEQUENCE);
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int IMB_isanim(char *filename) {
|
|
|
|
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);
|
|
|
|
}
|