Hi,
the demuxing_decoding example sets the stream_idx even if it fails find
a codec for that streams. This leads to a crash, when trying to decode
the stream.
Attached patch fixes this.
Best regards,
Andreas
>From 387b8eb9c1a45bd93b7dde68669426e9ca42525a Mon Sep 17 00:00:00 2001
From: Andreas Cadhalpun <andreas.cadhal...@googlemail.com>
Date: Sat, 31 Jan 2015 21:11:38 +0100
Subject: [PATCH 2/2] examples/demuxing_decoding: set stream_idx in
open_codec_context only if no error occured
Signed-off-by: Andreas Cadhalpun <andreas.cadhal...@googlemail.com>
---
doc/examples/demuxing_decoding.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/doc/examples/demuxing_decoding.c b/doc/examples/demuxing_decoding.c
index 905df01..196d481 100644
--- a/doc/examples/demuxing_decoding.c
+++ b/doc/examples/demuxing_decoding.c
@@ -150,7 +150,7 @@ static int decode_packet(int *got_frame, int cached)
static int open_codec_context(int *stream_idx,
AVFormatContext *fmt_ctx, enum AVMediaType type)
{
- int ret;
+ int ret, stream_index;
AVStream *st;
AVCodecContext *dec_ctx = NULL;
AVCodec *dec = NULL;
@@ -162,8 +162,8 @@ static int open_codec_context(int *stream_idx,
av_get_media_type_string(type), src_filename);
return ret;
} else {
- *stream_idx = ret;
- st = fmt_ctx->streams[*stream_idx];
+ stream_index = ret;
+ st = fmt_ctx->streams[stream_index];
/* find decoder for the stream */
dec_ctx = st->codec;
@@ -182,6 +182,7 @@ static int open_codec_context(int *stream_idx,
av_get_media_type_string(type));
return ret;
}
+ *stream_idx = stream_index;
}
return 0;
--
2.1.4
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel