Changeset View
Changeset View
Standalone View
Standalone View
source/blender/imbuf/intern/util.c
| Show First 20 Lines • Show All 239 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| # ifdef __GNUC__ | # ifdef __GNUC__ | ||||
| # pragma GCC diagnostic pop | # pragma GCC diagnostic pop | ||||
| # endif | # endif | ||||
| void IMB_ffmpeg_init(void) | void IMB_ffmpeg_init(void) | ||||
| { | { | ||||
| av_register_all(); | |||||
| avdevice_register_all(); | avdevice_register_all(); | ||||
| ffmpeg_last_error[0] = '\0'; | ffmpeg_last_error[0] = '\0'; | ||||
| if (G.debug & G_DEBUG_FFMPEG) { | if (G.debug & G_DEBUG_FFMPEG) { | ||||
| av_log_set_level(AV_LOG_DEBUG); | av_log_set_level(AV_LOG_DEBUG); | ||||
| } | } | ||||
| /* set own callback which could store last error to report to UI */ | /* set own callback which could store last error to report to UI */ | ||||
| av_log_set_callback(ffmpeg_log_callback); | av_log_set_callback(ffmpeg_log_callback); | ||||
| } | } | ||||
| const char *IMB_ffmpeg_last_error(void) | const char *IMB_ffmpeg_last_error(void) | ||||
| { | { | ||||
| return ffmpeg_last_error; | return ffmpeg_last_error; | ||||
| } | } | ||||
| static int isffmpeg(const char *filepath) | static int isffmpeg(const char *filepath) | ||||
| { | { | ||||
| AVFormatContext *pFormatCtx = NULL; | AVFormatContext *pFormatCtx = NULL; | ||||
| unsigned int i; | unsigned int i; | ||||
| int videoStream; | int videoStream; | ||||
| AVCodec *pCodec; | AVCodec *pCodec; | ||||
| AVCodecContext *pCodecCtx; | |||||
| if (BLI_path_extension_check_n(filepath, | if (BLI_path_extension_check_n(filepath, | ||||
| ".swf", | ".swf", | ||||
| ".jpg", | ".jpg", | ||||
| ".jp2", | ".jp2", | ||||
| ".j2c", | ".j2c", | ||||
| ".png", | ".png", | ||||
| ".dds", | ".dds", | ||||
| Show All 24 Lines | static int isffmpeg(const char *filepath) | ||||
| if (UTIL_DEBUG) { | if (UTIL_DEBUG) { | ||||
| av_dump_format(pFormatCtx, 0, filepath, 0); | av_dump_format(pFormatCtx, 0, filepath, 0); | ||||
| } | } | ||||
| /* Find the first video stream */ | /* Find the first video stream */ | ||||
| videoStream = -1; | videoStream = -1; | ||||
| for (i = 0; i < pFormatCtx->nb_streams; i++) { | for (i = 0; i < pFormatCtx->nb_streams; i++) { | ||||
| if (pFormatCtx->streams[i] && pFormatCtx->streams[i]->codec && | if (pFormatCtx->streams[i] && pFormatCtx->streams[i]->codecpar && | ||||
| (pFormatCtx->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO)) { | (pFormatCtx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)) { | ||||
| videoStream = i; | videoStream = i; | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| if (videoStream == -1) { | if (videoStream == -1) { | ||||
| avformat_close_input(&pFormatCtx); | avformat_close_input(&pFormatCtx); | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| pCodecCtx = pFormatCtx->streams[videoStream]->codec; | AVCodecParameters *codec_par = pFormatCtx->streams[videoStream]->codecpar; | ||||
| /* Find the decoder for the video stream */ | /* Find the decoder for the video stream */ | ||||
| pCodec = avcodec_find_decoder(pCodecCtx->codec_id); | pCodec = avcodec_find_decoder(codec_par->codec_id); | ||||
| if (pCodec == NULL) { | if (pCodec == NULL) { | ||||
| avformat_close_input(&pFormatCtx); | avformat_close_input(&pFormatCtx); | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| if (avcodec_open2(pCodecCtx, pCodec, NULL) < 0) { | |||||
| avformat_close_input(&pFormatCtx); | |||||
| return 0; | |||||
| } | |||||
| avcodec_close(pCodecCtx); | |||||
| avformat_close_input(&pFormatCtx); | avformat_close_input(&pFormatCtx); | ||||
| return 1; | return 1; | ||||
| } | } | ||||
| #endif | #endif | ||||
| int imb_get_anim_type(const char *filepath) | int imb_get_anim_type(const char *filepath) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 78 Lines • Show Last 20 Lines | |||||