diff options
author | Clément Bœsch <cboesch@gopro.com> | 2017-03-28 11:29:19 +0200 |
---|---|---|
committer | Clément Bœsch <cboesch@gopro.com> | 2017-03-28 11:40:57 +0200 |
commit | c3706bc255741faab426093c64fe16c2c879b3a2 (patch) | |
tree | 414d1ec13584b6c1f1cdc29441e5c4eae03f8eb9 | |
parent | c0628919b8c5761d64b1169e8de7584544d15ebf (diff) | |
download | ffmpeg-c3706bc255741faab426093c64fe16c2c879b3a2.tar.gz |
doc/examples/filtering_*: switch to codecpar
-rw-r--r-- | doc/examples/filtering_audio.c | 9 | ||||
-rw-r--r-- | doc/examples/filtering_video.c | 9 |
2 files changed, 14 insertions, 4 deletions
diff --git a/doc/examples/filtering_audio.c b/doc/examples/filtering_audio.c index 6bb24a431d..c6a930ba8b 100644 --- a/doc/examples/filtering_audio.c +++ b/doc/examples/filtering_audio.c @@ -69,7 +69,12 @@ static int open_input_file(const char *filename) return ret; } audio_stream_index = ret; - dec_ctx = fmt_ctx->streams[audio_stream_index]->codec; + + /* create decoding context */ + dec_ctx = avcodec_alloc_context3(dec); + if (!dec_ctx) + return AVERROR(ENOMEM); + avcodec_parameters_to_context(dec_ctx, fmt_ctx->streams[audio_stream_index]->codecpar); av_opt_set_int(dec_ctx, "refcounted_frames", 1, 0); /* init the audio decoder */ @@ -281,7 +286,7 @@ int main(int argc, char **argv) } end: avfilter_graph_free(&filter_graph); - avcodec_close(dec_ctx); + avcodec_free_context(&dec_ctx); avformat_close_input(&fmt_ctx); av_frame_free(&frame); av_frame_free(&filt_frame); diff --git a/doc/examples/filtering_video.c b/doc/examples/filtering_video.c index 3dabf13b10..15116d3881 100644 --- a/doc/examples/filtering_video.c +++ b/doc/examples/filtering_video.c @@ -72,7 +72,12 @@ static int open_input_file(const char *filename) return ret; } video_stream_index = ret; - dec_ctx = fmt_ctx->streams[video_stream_index]->codec; + + /* create decoding context */ + dec_ctx = avcodec_alloc_context3(dec); + if (!dec_ctx) + return AVERROR(ENOMEM); + avcodec_parameters_to_context(dec_ctx, fmt_ctx->streams[video_stream_index]->codecpar); av_opt_set_int(dec_ctx, "refcounted_frames", 1, 0); /* init the video decoder */ @@ -266,7 +271,7 @@ int main(int argc, char **argv) } end: avfilter_graph_free(&filter_graph); - avcodec_close(dec_ctx); + avcodec_free_context(&dec_ctx); avformat_close_input(&fmt_ctx); av_frame_free(&frame); av_frame_free(&filt_frame); |