2011-02-23 10:52:22 +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
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
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"
|
2012-05-01 21:46:55 +00:00
|
|
|
#include "BLI_fileops.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
|
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>
|
2011-05-27 07:47:42 +00:00
|
|
|
|
2011-05-27 23:33:40 +00:00
|
|
|
#include "ffmpeg_compat.h"
|
2011-05-27 07:47:42 +00:00
|
|
|
|
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[] = {
|
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
|
2012-05-16 07:38:23 +00:00
|
|
|
NULL
|
|
|
|
};
|
2010-08-03 12:34:42 +00:00
|
|
|
|
|
|
|
const char *imb_ext_image_qt[] = {
|
|
|
|
".gif",
|
|
|
|
".psd",
|
|
|
|
".pct", ".pict",
|
|
|
|
".pntg",
|
|
|
|
".qtif",
|
2012-05-16 07:38:23 +00:00
|
|
|
NULL
|
|
|
|
};
|
2010-08-03 12:34:42 +00:00
|
|
|
|
|
|
|
const char *imb_ext_movie[] = {
|
|
|
|
".avi",
|
|
|
|
".flc",
|
|
|
|
".mov",
|
|
|
|
".movie",
|
|
|
|
".mp4",
|
|
|
|
".m4v",
|
|
|
|
".m2v",
|
|
|
|
".m2t",
|
2011-07-05 18:54:16 +00:00
|
|
|
".m2ts",
|
2010-08-03 12:34:42 +00:00
|
|
|
".mts",
|
|
|
|
".mv",
|
|
|
|
".avs",
|
|
|
|
".wmv",
|
|
|
|
".ogv",
|
|
|
|
".dv",
|
|
|
|
".mpeg",
|
|
|
|
".mpg",
|
|
|
|
".mpg2",
|
|
|
|
".vob",
|
|
|
|
".mkv",
|
|
|
|
".flv",
|
|
|
|
".divx",
|
|
|
|
".xvid",
|
2010-12-10 04:10:21 +00:00
|
|
|
".mxf",
|
2012-05-16 07:38:23 +00:00
|
|
|
NULL
|
|
|
|
};
|
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",
|
2012-05-16 07:38:23 +00:00
|
|
|
NULL
|
|
|
|
};
|
2010-08-03 12:34:42 +00:00
|
|
|
|
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
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (UTIL_DEBUG) printf("IMB_ispic_name: loading %s\n", name);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2012-04-29 15:47:02 +00:00
|
|
|
if (stat(name, &st) == -1)
|
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
|
|
|
return FALSE;
|
2012-03-24 06:38:07 +00:00
|
|
|
if (((st.st_mode) & S_IFMT) != S_IFREG)
|
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
|
|
|
return FALSE;
|
2003-04-28 02:15:46 +00:00
|
|
|
|
2012-05-16 07:38:23 +00:00
|
|
|
if ((fp = BLI_open(name, O_BINARY | O_RDONLY, 0)) < 0)
|
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
|
|
|
return FALSE;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (read(fp, buf, 32) != 32) {
|
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);
|
|
|
|
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 */
|
2012-03-24 06:38:07 +00:00
|
|
|
if ((BIG_LONG(buf[0]) & 0xfffffff0) == 0xffd8ffe0)
|
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
|
|
|
return JPG;
|
2003-04-28 02:15:46 +00:00
|
|
|
|
2012-05-16 07:38:23 +00:00
|
|
|
for (type = IMB_FILE_TYPES; type->is_a; type++)
|
|
|
|
if (type->is_a((uchar *)buf))
|
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
|
|
|
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
|
|
|
{
|
2012-03-24 06:38:07 +00:00
|
|
|
if (U.uiflag & USER_FILTERFILEEXTS) {
|
2012-05-20 19:49:27 +00:00
|
|
|
if ((BLI_testextensie_array(filename, imb_ext_image)) ||
|
|
|
|
(G.have_quicktime && BLI_testextensie_array(filename, imb_ext_image_qt)))
|
|
|
|
{
|
2010-08-03 12:34:42 +00:00
|
|
|
return IMB_ispic_name(filename);
|
2005-11-22 18:50:03 +00:00
|
|
|
}
|
2012-04-21 12:51:47 +00:00
|
|
|
else {
|
2010-08-03 12:34:42 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-05-16 07:38:23 +00:00
|
|
|
static int isavi(const char *name)
|
2011-12-17 00:52:36 +00:00
|
|
|
{
|
2012-05-16 07:38:23 +00:00
|
|
|
return AVI_is_avi(name);
|
2003-04-28 02:15:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef WITH_QUICKTIME
|
2012-05-16 07:38:23 +00:00
|
|
|
static int isqtime(const char *name)
|
2011-12-17 00:52:36 +00:00
|
|
|
{
|
2012-05-16 07:38:23 +00:00
|
|
|
return anim_is_quicktime(name);
|
2003-04-28 02:15:46 +00:00
|
|
|
}
|
|
|
|
#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)
|
|
|
|
{
|
2012-03-06 18:40:15 +00:00
|
|
|
if (quiet) {
|
2008-11-03 13:33:11 +00:00
|
|
|
av_log_set_level(AV_LOG_QUIET);
|
|
|
|
}
|
2012-03-06 18:40:15 +00:00
|
|
|
else {
|
== Sequencer ==
This patch adds:
* support for proxy building again (missing feature from Blender 2.49)
additionally to the way, Blender 2.49 worked, you can select several
strips at once and make Blender build proxies in the background (using
the job system)
Also a new thing: movie proxies are now build into AVI files, and
the proxy system is moved into ImBuf-library, so that other parts
of blender can also benefit from it.
* Timecode support: to fix seeking issues with files, that have
a) varying frame rates
b) very large GOP lengths
c) are broken inbetween
d) use different time code tracks
the proxy builder can now also build timecode indices, which are
used (optionally) for seeking.
For the first time, it is possible, to do frame exact seeking on
all file types.
* Support for different video-streams in one video file (can be
selected in sequencer, other parts of blender can also use it,
but UI has to be added accordingly)
* IMPORTANT: this patch *requires* ffmpeg 0.7 or newer, since
older versions don't support the pkt_pts field, that is essential
for building timecode indices.
Windows and Mac libs are already updated, Linux-users have to build
their own ffmpeg verions until distros keep up.
2011-08-28 14:46:03 +00:00
|
|
|
av_log_set_level(AV_LOG_DEBUG);
|
2008-11-03 13:33:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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();
|
2012-03-31 00:59:17 +00:00
|
|
|
if ((G.debug & G_DEBUG_FFMPEG) == 0) {
|
2008-11-02 16:28:34 +00:00
|
|
|
silence_log_ffmpeg(1);
|
2012-03-24 06:38:07 +00:00
|
|
|
}
|
|
|
|
else {
|
== Sequencer ==
This patch adds:
* support for proxy building again (missing feature from Blender 2.49)
additionally to the way, Blender 2.49 worked, you can select several
strips at once and make Blender build proxies in the background (using
the job system)
Also a new thing: movie proxies are now build into AVI files, and
the proxy system is moved into ImBuf-library, so that other parts
of blender can also benefit from it.
* Timecode support: to fix seeking issues with files, that have
a) varying frame rates
b) very large GOP lengths
c) are broken inbetween
d) use different time code tracks
the proxy builder can now also build timecode indices, which are
used (optionally) for seeking.
For the first time, it is possible, to do frame exact seeking on
all file types.
* Support for different video-streams in one video file (can be
selected in sequencer, other parts of blender can also use it,
but UI has to be added accordingly)
* IMPORTANT: this patch *requires* ffmpeg 0.7 or newer, since
older versions don't support the pkt_pts field, that is essential
for building timecode indices.
Windows and Mac libs are already updated, Linux-users have to build
their own ffmpeg verions until distros keep up.
2011-08-28 14:46:03 +00:00
|
|
|
silence_log_ffmpeg(0);
|
2008-11-02 16:28:34 +00:00
|
|
|
}
|
2006-02-05 19:23:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-16 07:38:23 +00:00
|
|
|
static int isffmpeg(const char *filename)
|
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;
|
|
|
|
|
|
|
|
do_init_ffmpeg();
|
|
|
|
|
2012-04-28 06:31:57 +00:00
|
|
|
if (BLI_testextensie(filename, ".swf") ||
|
2012-05-16 07:38:23 +00:00
|
|
|
BLI_testextensie(filename, ".jpg") ||
|
|
|
|
BLI_testextensie(filename, ".png") ||
|
|
|
|
BLI_testextensie(filename, ".dds") ||
|
|
|
|
BLI_testextensie(filename, ".tga") ||
|
|
|
|
BLI_testextensie(filename, ".bmp") ||
|
|
|
|
BLI_testextensie(filename, ".exr") ||
|
|
|
|
BLI_testextensie(filename, ".cin") ||
|
2012-04-28 06:31:57 +00:00
|
|
|
BLI_testextensie(filename, ".wav"))
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2007-05-25 17:11:24 +00:00
|
|
|
|
2012-06-18 10:29:11 +00:00
|
|
|
if (avformat_open_input(&pFormatCtx, filename, NULL, NULL) != 0) {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (UTIL_DEBUG) fprintf(stderr, "isffmpeg: av_open_input_file failed\n");
|
2006-02-05 19:23:34 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-05-16 07:38:23 +00:00
|
|
|
if (av_find_stream_info(pFormatCtx) < 0) {
|
2012-03-24 06:38:07 +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;
|
|
|
|
}
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (UTIL_DEBUG) av_dump_format(pFormatCtx, 0, filename, 0);
|
2006-02-05 19:23:34 +00:00
|
|
|
|
|
|
|
|
2012-05-16 07:38:23 +00:00
|
|
|
/* Find the first video stream */
|
|
|
|
videoStream = -1;
|
|
|
|
for (i = 0; i < pFormatCtx->nb_streams; i++)
|
2012-03-24 06:38:07 +00:00
|
|
|
if (pFormatCtx->streams[i] &&
|
2012-05-16 07:38:23 +00:00
|
|
|
pFormatCtx->streams[i]->codec &&
|
|
|
|
(pFormatCtx->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO))
|
2006-02-05 19:23:34 +00:00
|
|
|
{
|
2012-05-16 07:38:23 +00:00
|
|
|
videoStream = i;
|
2006-02-05 19:23:34 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2012-05-16 07:38:23 +00:00
|
|
|
if (videoStream == -1) {
|
2007-05-25 17:11:24 +00:00
|
|
|
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
|
|
|
|
2011-05-26 21:57:02 +00:00
|
|
|
pCodecCtx = pFormatCtx->streams[videoStream]->codec;
|
2006-02-05 19:23:34 +00: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) {
|
2006-02-05 19:23:34 +00:00
|
|
|
av_close_input_file(pFormatCtx);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-05-16 07:38:23 +00:00
|
|
|
if (avcodec_open(pCodecCtx, pCodec) < 0) {
|
2006-02-05 19:23:34 +00:00
|
|
|
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
|
2012-05-16 07:38:23 +00:00
|
|
|
static int isredcode(const char *filename)
|
2008-06-02 21:35:57 +00:00
|
|
|
{
|
2012-05-16 07:38:23 +00:00
|
|
|
struct redcode_handle *h = redcode_open(filename);
|
2008-06-02 21:35:57 +00:00
|
|
|
if (!h) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
redcode_close(h);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2012-05-16 07:38:23 +00:00
|
|
|
int imb_get_anim_type(const char *name)
|
2011-12-17 00:52:36 +00:00
|
|
|
{
|
2003-04-28 02:15:46 +00:00
|
|
|
int type;
|
|
|
|
struct stat st;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (UTIL_DEBUG) printf("in getanimtype: %s\n", name);
|
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_QUICKTIME
|
2009-11-18 09:49:42 +00:00
|
|
|
if (isqtime(name)) return (ANIM_QTIME);
|
2012-05-16 07:38:23 +00:00
|
|
|
# endif
|
|
|
|
# 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);
|
2012-05-16 07:38:23 +00:00
|
|
|
# endif
|
2012-05-01 21:46:55 +00:00
|
|
|
if (BLI_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
|
2012-05-01 21:46:55 +00:00
|
|
|
if (BLI_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);
|
2012-05-16 07:38:23 +00:00
|
|
|
# ifdef WITH_QUICKTIME
|
2003-04-28 02:15:46 +00:00
|
|
|
if (isqtime(name)) return (ANIM_QTIME);
|
2012-05-16 07:38:23 +00:00
|
|
|
# endif
|
|
|
|
# ifdef WITH_FFMPEG
|
2007-05-30 06:11:25 +00:00
|
|
|
if (isffmpeg(name)) return (ANIM_FFMPEG);
|
2012-05-16 07:38:23 +00:00
|
|
|
# endif
|
2012-05-01 21:46:55 +00:00
|
|
|
|
|
|
|
|
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);
|
2012-04-23 08:05:02 +00:00
|
|
|
if (type) {
|
|
|
|
return ANIM_SEQUENCE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ANIM_NONE;
|
2003-04-28 02:15:46 +00:00
|
|
|
}
|
|
|
|
|
2011-12-17 00:52:36 +00:00
|
|
|
int IMB_isanim(const char *filename)
|
|
|
|
{
|
2003-04-28 02:15:46 +00:00
|
|
|
int type;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (U.uiflag & USER_FILTERFILEEXTS) {
|
|
|
|
if (G.have_quicktime) {
|
2012-04-21 15:11:03 +00:00
|
|
|
if (BLI_testextensie(filename, ".avi") ||
|
|
|
|
BLI_testextensie(filename, ".flc") ||
|
|
|
|
BLI_testextensie(filename, ".dv") ||
|
|
|
|
BLI_testextensie(filename, ".r3d") ||
|
|
|
|
BLI_testextensie(filename, ".mov") ||
|
|
|
|
BLI_testextensie(filename, ".movie") ||
|
|
|
|
BLI_testextensie(filename, ".mv"))
|
|
|
|
{
|
2003-04-28 02:15:46 +00:00
|
|
|
type = imb_get_anim_type(filename);
|
2012-03-24 06:38:07 +00:00
|
|
|
}
|
|
|
|
else {
|
2003-04-28 02:15:46 +00:00
|
|
|
return(FALSE);
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
}
|
2012-04-21 15:11:03 +00:00
|
|
|
else { /* no quicktime */
|
|
|
|
if (BLI_testextensie(filename, ".avi") ||
|
|
|
|
BLI_testextensie(filename, ".dv") ||
|
|
|
|
BLI_testextensie(filename, ".r3d") ||
|
|
|
|
BLI_testextensie(filename, ".mv"))
|
|
|
|
{
|
2003-04-28 02:15:46 +00:00
|
|
|
type = imb_get_anim_type(filename);
|
|
|
|
}
|
2012-04-21 12:51:47 +00:00
|
|
|
else {
|
2003-04-28 02:15:46 +00:00
|
|
|
return(FALSE);
|
|
|
|
}
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
}
|
2012-04-21 15:11:03 +00:00
|
|
|
else { /* no FILTERFILEEXTS */
|
2003-04-28 02:15:46 +00:00
|
|
|
type = imb_get_anim_type(filename);
|
|
|
|
}
|
|
|
|
|
2012-05-16 07:38:23 +00:00
|
|
|
return (type && type != ANIM_SEQUENCE);
|
2003-04-28 02:15:46 +00:00
|
|
|
}
|