[FFmpeg-cvslog] examples/demuxing_decoding: set stream_idx in open_codec_context only if no error occured

Andreas Cadhalpun git at videolan.org
Sat Jan 31 22:05:38 CET 2015


ffmpeg | branch: master | Andreas Cadhalpun <Andreas.Cadhalpun at googlemail.com> | Sat Jan 31 21:11:38 2015 +0100| [2a3b7a55b51116c968fc32d4b6a2f7cc35e677f2] | committer: Michael Niedermayer

examples/demuxing_decoding: set stream_idx in open_codec_context only if no error occured

Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun at googlemail.com>
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2a3b7a55b51116c968fc32d4b6a2f7cc35e677f2
---

 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 2ce4018..30bee1d 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;



More information about the ffmpeg-cvslog mailing list