33 # include <libavcodec/avcodec.h>
34 # include <libavdevice/avdevice.h>
35 # include <libavformat/avformat.h>
36 # include <libavutil/log.h>
44 ".png",
".tga",
".bmp",
".jpg",
".jpeg",
".sgi",
".rgb",
".rgba",
46 ".tif",
".tiff",
".tx",
63 #ifdef WITH_OPENIMAGEIO
64 ".psd",
".pdd",
".psb",
73 #ifdef WITH_OPENIMAGEIO
82 ".avi",
".flc",
".mov",
".movie",
".mp4",
".m4v",
".m2v",
".m2t",
".m2ts",
".mts",
83 ".ts",
".mv",
".avs",
".wmv",
".ogv",
".ogg",
".r3d",
".dv",
".mpeg",
".mpg",
84 ".mpg2",
".vob",
".mkv",
".flv",
".divx",
".xvid",
".mxf",
".webm",
NULL,
107 #define HEADER_SIZE 64
118 printf(
"%s: loading %s\n", __func__, filepath);
124 if (((
st.st_mode) & S_IFMT) != S_IFREG) {
142 if (
type->is_a(buf, buf_size)) {
143 return type->filetype;
175 return type->is_a(buf, (
size_t)buf_size);
188 static bool isavi(
const char *filepath)
202 # pragma GCC diagnostic push
203 # pragma GCC diagnostic ignored "-Wmissing-format-attribute"
206 static char ffmpeg_last_error[1024];
208 static void ffmpeg_log_callback(
void *
ptr,
int level,
const char *
format, va_list arg)
210 if (
ELEM(level, AV_LOG_FATAL, AV_LOG_ERROR)) {
219 ffmpeg_last_error[n - 1] =
'\0';
224 av_log_default_callback(
ptr, level,
format, arg);
229 # pragma GCC diagnostic pop
234 avdevice_register_all();
236 ffmpeg_last_error[0] =
'\0';
239 av_log_set_level(AV_LOG_DEBUG);
243 av_log_set_callback(ffmpeg_log_callback);
248 return ffmpeg_last_error;
251 static int isffmpeg(
const char *filepath)
253 AVFormatContext *pFormatCtx =
NULL;
256 const AVCodec *pCodec;
275 if (avformat_open_input(&pFormatCtx, filepath,
NULL,
NULL) != 0) {
277 fprintf(stderr,
"isffmpeg: av_open_input_file failed\n");
282 if (avformat_find_stream_info(pFormatCtx,
NULL) < 0) {
284 fprintf(stderr,
"isffmpeg: avformat_find_stream_info failed\n");
286 avformat_close_input(&pFormatCtx);
291 av_dump_format(pFormatCtx, 0, filepath, 0);
296 for (i = 0; i < pFormatCtx->nb_streams; i++) {
297 if (pFormatCtx->streams[i] && pFormatCtx->streams[i]->codecpar &&
298 (pFormatCtx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)) {
304 if (videoStream == -1) {
305 avformat_close_input(&pFormatCtx);
309 AVCodecParameters *codec_par = pFormatCtx->streams[videoStream]->codecpar;
312 pCodec = avcodec_find_decoder(codec_par->codec_id);
313 if (pCodec ==
NULL) {
314 avformat_close_input(&pFormatCtx);
318 avformat_close_input(&pFormatCtx);
331 printf(
"%s: %s\n", __func__, filepath);
337 if (isffmpeg(filepath)) {
344 if (((
st.st_mode) & S_IFMT) != S_IFREG) {
348 if (
isavi(filepath)) {
359 if (((
st.st_mode) & S_IFMT) != S_IFREG) {
367 if (isffmpeg(filepath)) {
372 if (
isavi(filepath)) {
bool AVI_is_avi(const char *name)
File and directory operations.
int BLI_stat(const char *path, BLI_stat_t *buffer) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
int BLI_open(const char *filepath, int oflag, int pmode) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
bool BLI_path_is_rel(const char *path) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT
bool BLI_path_extension_check_n(const char *str,...) ATTR_NONNULL(1) ATTR_SENTINEL(0)
size_t BLI_vsnprintf(char *__restrict buffer, size_t maxncpy, const char *__restrict format, va_list arg) ATTR_PRINTF_FORMAT(3
Compatibility-like things for windows.
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
void IMB_ffmpeg_init(void)
const char * IMB_ffmpeg_last_error(void)
int ismovie(const char *filepath)
Contains defines and structs used throughout the imbuf module.
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
SyclQueue void void size_t num_bytes void
const ImFileType * IMB_file_type_from_ftype(int ftype)
const ImFileType IMB_FILE_TYPES[]
const ImFileType * IMB_FILE_TYPES_LAST
static const pxr::TfToken st("st", pxr::TfToken::Immortal)
const char * imb_ext_image_filepath_only[]
static bool isavi(const char *filepath)
int IMB_ispic_type_from_memory(const unsigned char *buf, const size_t buf_size)
const char * imb_ext_movie[]
int IMB_ispic_type(const char *filepath)
const char * imb_ext_audio[]
bool IMB_isanim(const char *filepath)
static ssize_t imb_ispic_read_header_from_filepath(const char *filepath, unsigned char buf[HEADER_SIZE])
bool IMB_ispic_type_matches(const char *filepath, int filetype)
int imb_get_anim_type(const char *filepath)
bool IMB_ispic(const char *filepath)
const char * imb_ext_image[]