summaryrefslogtreecommitdiff
path: root/doc/examples
diff options
context:
space:
mode:
authorAndreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>2015-01-31 21:11:38 +0100
committerMichael Niedermayer <michaelni@gmx.at>2015-01-31 21:54:36 +0100
commit2a3b7a55b51116c968fc32d4b6a2f7cc35e677f2 (patch)
tree87b3ad8684d7360e91200f49f2c06e4e60599180 /doc/examples
parentb80106169ab16c31e27ea464ca62b805b205d61d (diff)
examples/demuxing_decoding: set stream_idx in open_codec_context only if no error occured
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'doc/examples')
-rw-r--r--doc/examples/demuxing_decoding.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/doc/examples/demuxing_decoding.c b/doc/examples/demuxing_decoding.c
index 2ce4018c79..30bee1dca5 100644
--- a/doc/examples/demuxing_decoding.c
+++ b/doc/examples/demuxing_decoding.c
@@ -138,7 +138,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;
@@ -150,8 +150,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;
@@ -170,6 +170,7 @@ static int open_codec_context(int *stream_idx,
av_get_media_type_string(type));
return ret;
}
+ *stream_idx = stream_index;
}
return 0;