summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorAlfred E. Heggestad <alfred.heggestad@gmail.com>2016-12-08 10:27:37 +0100
committerAlfred E. Heggestad <alfred.heggestad@gmail.com>2016-12-08 10:27:37 +0100
commit7e5c0b7618bb368c4e45ac01a87bfdfe342120c6 (patch)
treea51e6fb9e201e0c467346bb79395d95efd2578fe /modules
parent1ddcc5cceab0441cf6161176cc81e3f6186c473d (diff)
avformat: use codecpar for newer versions (refs #178)
Diffstat (limited to 'modules')
-rw-r--r--modules/avformat/avformat.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/modules/avformat/avformat.c b/modules/avformat/avformat.c
index 909ac75..d05cde6 100644
--- a/modules/avformat/avformat.c
+++ b/modules/avformat/avformat.c
@@ -284,7 +284,26 @@ static int alloc(struct vidsrc_st **stp, const struct vidsrc *vs,
for (i=0; i<st->ic->nb_streams; i++) {
const struct AVStream *strm = st->ic->streams[i];
- AVCodecContext *ctx = strm->codec;
+ AVCodecContext *ctx;
+
+#if LIBAVFORMAT_VERSION_INT >= ((52<<16) + (110<<8) + 0)
+
+ ctx = avcodec_alloc_context3(NULL);
+ if (!ctx) {
+ err = ENOMEM;
+ goto out;
+ }
+
+ ret = avcodec_parameters_to_context(ctx, strm->codecpar);
+ if (ret < 0) {
+ warning("avformat: avcodec_parameters_to_context\n");
+ err = EPROTO;
+ goto out;
+ }
+
+#else
+ ctx = strm->codec;
+#endif
if (ctx->codec_type != AVMEDIA_TYPE_VIDEO)
continue;