From aab01c86cf56f5d21d2503f7e854bb19b07ca2c6 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sat, 12 Jan 2013 12:51:10 +0000 Subject: Patch #33837: ffmpeg1.1 and libav9.1 compatibility update Patch makes it possible to compile blender with recent ffmpeg and libav libraries, mainly by getting rid of deprecated API. Original patch by Campbell Barton with own modifications to support compilation with older ffmpeg versions. This patch could break compatibility of FFV1 videos playing back in older players, mainly because of alpha support changes. Preserving compatibility with such players became a headache and think it's high time to get rid of workarounds here. --- source/blender/imbuf/intern/anim_movie.c | 4 ++-- source/blender/imbuf/intern/indexer.c | 14 ++++++++------ source/blender/imbuf/intern/util.c | 6 +++--- 3 files changed, 13 insertions(+), 11 deletions(-) (limited to 'source/blender/imbuf') diff --git a/source/blender/imbuf/intern/anim_movie.c b/source/blender/imbuf/intern/anim_movie.c index 8dfdbd4fddc..8d79482ed18 100644 --- a/source/blender/imbuf/intern/anim_movie.c +++ b/source/blender/imbuf/intern/anim_movie.c @@ -486,7 +486,7 @@ static int startffmpeg(struct anim *anim) return -1; } - if (av_find_stream_info(pFormatCtx) < 0) { + if (avformat_find_stream_info(pFormatCtx, NULL) < 0) { av_close_input_file(pFormatCtx); return -1; } @@ -523,7 +523,7 @@ static int startffmpeg(struct anim *anim) pCodecCtx->workaround_bugs = 1; - if (avcodec_open(pCodecCtx, pCodec) < 0) { + if (avcodec_open2(pCodecCtx, pCodec, NULL) < 0) { av_close_input_file(pFormatCtx); return -1; } diff --git a/source/blender/imbuf/intern/indexer.c b/source/blender/imbuf/intern/indexer.c index 277f50bcdbc..86e451e7467 100644 --- a/source/blender/imbuf/intern/indexer.c +++ b/source/blender/imbuf/intern/indexer.c @@ -496,7 +496,9 @@ static struct proxy_output_ctx *alloc_proxy_output_ffmpeg( fprintf(stderr, "Starting work on proxy: %s\n", rv->of->filename); - rv->st = av_new_stream(rv->of, 0); + rv->st = avformat_new_stream(rv->of, NULL); + rv->st->id = 0; + rv->c = rv->st->codec; rv->c->codec_type = AVMEDIA_TYPE_VIDEO; rv->c->codec_id = CODEC_ID_MJPEG; @@ -531,8 +533,8 @@ static struct proxy_output_ctx *alloc_proxy_output_ffmpeg( /* there's no way to set JPEG quality in the same way as in AVI JPEG and image sequence, * but this seems to be giving expected quality result */ ffmpeg_quality = (int)(1.0f + 30.0f * (1.0f - (float)quality / 100.0f) + 0.5f); - av_set_int(rv->c, "qmin", ffmpeg_quality); - av_set_int(rv->c, "qmax", ffmpeg_quality); + av_opt_set_int(rv->c, "qmin", ffmpeg_quality, 0); + av_opt_set_int(rv->c, "qmax", ffmpeg_quality, 0); if (rv->of->flags & AVFMT_GLOBALHEADER) { rv->c->flags |= CODEC_FLAG_GLOBAL_HEADER; @@ -545,7 +547,7 @@ static struct proxy_output_ctx *alloc_proxy_output_ffmpeg( return 0; } - avcodec_open(rv->c, rv->codec); + avcodec_open2(rv->c, rv->codec, NULL); rv->video_buffersize = 2000000; rv->video_buffer = (uint8_t *)MEM_mallocN( @@ -758,7 +760,7 @@ static IndexBuildContext *index_ffmpeg_create_context(struct anim *anim, IMB_Tim return NULL; } - if (av_find_stream_info(context->iFormatCtx) < 0) { + if (avformat_find_stream_info(context->iFormatCtx, NULL) < 0) { av_close_input_file(context->iFormatCtx); MEM_freeN(context); return NULL; @@ -797,7 +799,7 @@ static IndexBuildContext *index_ffmpeg_create_context(struct anim *anim, IMB_Tim context->iCodecCtx->workaround_bugs = 1; - if (avcodec_open(context->iCodecCtx, context->iCodec) < 0) { + if (avcodec_open2(context->iCodecCtx, context->iCodec, NULL) < 0) { av_close_input_file(context->iFormatCtx); MEM_freeN(context); return NULL; diff --git a/source/blender/imbuf/intern/util.c b/source/blender/imbuf/intern/util.c index 42fb0c79b62..549a95e383d 100644 --- a/source/blender/imbuf/intern/util.c +++ b/source/blender/imbuf/intern/util.c @@ -306,8 +306,8 @@ static int isffmpeg(const char *filename) return 0; } - if (av_find_stream_info(pFormatCtx) < 0) { - if (UTIL_DEBUG) fprintf(stderr, "isffmpeg: av_find_stream_info failed\n"); + if (avformat_find_stream_info(pFormatCtx, NULL) < 0) { + if (UTIL_DEBUG) fprintf(stderr, "isffmpeg: avformat_find_stream_info failed\n"); av_close_input_file(pFormatCtx); return 0; } @@ -340,7 +340,7 @@ static int isffmpeg(const char *filename) return 0; } - if (avcodec_open(pCodecCtx, pCodec) < 0) { + if (avcodec_open2(pCodecCtx, pCodec, NULL) < 0) { av_close_input_file(pFormatCtx); return 0; } -- cgit v1.2.3