50 # include <libavcodec/avcodec.h>
51 # include <libavdevice/avdevice.h>
52 # include <libavformat/avformat.h>
53 # include <libavutil/log.h>
61 ".png",
".tga",
".bmp",
".jpg",
".jpeg",
".sgi",
".rgb",
".rgba",
63 ".tif",
".tiff",
".tx",
80 #ifdef WITH_OPENIMAGEIO
81 ".psd",
".pdd",
".psb",
87 #ifdef WITH_OPENIMAGEIO
96 ".avi",
".flc",
".mov",
".movie",
".mp4",
".m4v",
".m2v",
".m2t",
".m2ts",
".mts",
97 ".ts",
".mv",
".avs",
".wmv",
".ogv",
".ogg",
".r3d",
".dv",
".mpeg",
".mpg",
98 ".mpg2",
".vob",
".mkv",
".flv",
".divx",
".xvid",
".mxf",
".webm",
NULL,
121 #define HEADER_SIZE 64
132 printf(
"%s: loading %s\n", __func__, filepath);
135 if (
BLI_stat(filepath, &st) == -1) {
138 if (((st.st_mode) & S_IFMT) != S_IFREG) {
156 if (
type->is_a(buf, buf_size)) {
157 return type->filetype;
189 return type->is_a(buf, (
size_t)buf_size);
202 static bool isavi(
const char *filepath)
216 # pragma GCC diagnostic push
217 # pragma GCC diagnostic ignored "-Wmissing-format-attribute"
220 static char ffmpeg_last_error[1024];
222 static void ffmpeg_log_callback(
void *
ptr,
int level,
const char *
format, va_list arg)
224 if (
ELEM(level, AV_LOG_FATAL, AV_LOG_ERROR)) {
233 ffmpeg_last_error[n - 1] =
'\0';
238 av_log_default_callback(
ptr, level,
format, arg);
243 # pragma GCC diagnostic pop
248 avdevice_register_all();
250 ffmpeg_last_error[0] =
'\0';
253 av_log_set_level(AV_LOG_DEBUG);
257 av_log_set_callback(ffmpeg_log_callback);
262 return ffmpeg_last_error;
265 static int isffmpeg(
const char *filepath)
267 AVFormatContext *pFormatCtx =
NULL;
289 if (avformat_open_input(&pFormatCtx, filepath,
NULL,
NULL) != 0) {
291 fprintf(stderr,
"isffmpeg: av_open_input_file failed\n");
296 if (avformat_find_stream_info(pFormatCtx,
NULL) < 0) {
298 fprintf(stderr,
"isffmpeg: avformat_find_stream_info failed\n");
300 avformat_close_input(&pFormatCtx);
305 av_dump_format(pFormatCtx, 0, filepath, 0);
310 for (i = 0; i < pFormatCtx->nb_streams; i++) {
311 if (pFormatCtx->streams[i] && pFormatCtx->streams[i]->codecpar &&
312 (pFormatCtx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)) {
318 if (videoStream == -1) {
319 avformat_close_input(&pFormatCtx);
323 AVCodecParameters *codec_par = pFormatCtx->streams[videoStream]->codecpar;
326 pCodec = avcodec_find_decoder(codec_par->codec_id);
327 if (pCodec ==
NULL) {
328 avformat_close_input(&pFormatCtx);
332 avformat_close_input(&pFormatCtx);
345 printf(
"%s: %s\n", __func__, filepath);
351 if (isffmpeg(filepath)) {
355 if (
BLI_stat(filepath, &st) == -1) {
358 if (((st.st_mode) & S_IFMT) != S_IFREG) {
362 if (
isavi(filepath)) {
370 if (
BLI_stat(filepath, &st) == -1) {
373 if (((st.st_mode) & S_IFMT) != S_IFREG) {
381 if (isffmpeg(filepath)) {
386 if (
isavi(filepath)) {
bool AVI_is_avi(const char *name)
File and directory operations.
int BLI_open(const char *filename, int oflag, int pmode) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
int BLI_stat(const char *path, BLI_stat_t *buffer) 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)
const ImFileType * IMB_file_type_from_ftype(int ftype)
const ImFileType IMB_FILE_TYPES[]
const ImFileType * IMB_file_type_from_ibuf(const ImBuf *ibuf)
const ImFileType * IMB_FILE_TYPES_LAST
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[]
bool IMB_isfloat(const ImBuf *ibuf)