diff options
author | Anton Khirnov <anton@khirnov.net> | 2016-02-10 14:17:21 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2016-02-24 10:08:37 +0100 |
commit | 1138eb5509d3db7f6d565cb45f137a786d22beb9 (patch) | |
tree | a618bd529466156fb21bf1b99baa07d70f6543ab /libavfilter | |
parent | ac6d53589f3631ae08467c784fb371a15c957f01 (diff) | |
download | ffmpeg-1138eb5509d3db7f6d565cb45f137a786d22beb9.tar.gz |
vsrc_movie: convert to codecpar
Diffstat (limited to 'libavfilter')
-rw-r--r-- | libavfilter/vsrc_movie.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/libavfilter/vsrc_movie.c b/libavfilter/vsrc_movie.c index 850788c12b..95ef4f1e9c 100644 --- a/libavfilter/vsrc_movie.c +++ b/libavfilter/vsrc_movie.c @@ -86,6 +86,7 @@ static av_cold int movie_init(AVFilterContext *ctx) { MovieContext *movie = ctx->priv; AVInputFormat *iformat = NULL; + AVStream *st; AVCodec *codec; int ret; int64_t timestamp; @@ -132,18 +133,26 @@ static av_cold int movie_init(AVFilterContext *ctx) return ret; } movie->stream_index = ret; - movie->codec_ctx = movie->format_ctx->streams[movie->stream_index]->codec; + st = movie->format_ctx->streams[movie->stream_index]; /* * So now we've got a pointer to the so-called codec context for our video * stream, but we still have to find the actual codec and open it. */ - codec = avcodec_find_decoder(movie->codec_ctx->codec_id); + codec = avcodec_find_decoder(st->codecpar->codec_id); if (!codec) { av_log(ctx, AV_LOG_ERROR, "Failed to find any codec\n"); return AVERROR(EINVAL); } + movie->codec_ctx = avcodec_alloc_context3(codec); + if (!movie->codec_ctx) + return AVERROR(ENOMEM); + + ret = avcodec_parameters_to_context(movie->codec_ctx, st->codecpar); + if (ret < 0) + return ret; + movie->codec_ctx->refcounted_frames = 1; if ((ret = avcodec_open2(movie->codec_ctx, codec, NULL)) < 0) { @@ -174,8 +183,7 @@ static av_cold void uninit(AVFilterContext *ctx) { MovieContext *movie = ctx->priv; - if (movie->codec_ctx) - avcodec_close(movie->codec_ctx); + avcodec_free_context(&movie->codec_ctx); if (movie->format_ctx) avformat_close_input(&movie->format_ctx); av_frame_free(&movie->frame); |