[FFmpeg-cvslog] avformat: Fix decoder search in find stream info

Michael Niedermayer git at videolan.org
Wed Apr 23 17:26:45 CEST 2014


ffmpeg | branch: release/2.2 | Michael Niedermayer <michaelni at gmx.at> | Mon Apr 21 03:38:07 2014 +0200| [0385c824f101151b6f0c4eda59249d70bd48fb53] | committer: Carl Eugen Hoyos

avformat: Fix decoder search in find stream info

Fixes Ticket3548

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
(cherry picked from commit f3743901d7df906342f99b179382b19d8a4d9716)

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

 libavformat/avformat.h |    6 ++++++
 libavformat/utils.c    |    8 +++++---
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index e0ec3da..7839c0a 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -844,6 +844,12 @@ typedef struct AVStream {
         double (*duration_error)[2][MAX_STD_TIMEBASES];
         int64_t codec_info_duration;
         int64_t codec_info_duration_fields;
+
+        /**
+         * 0  -> decoder has not been searched for yet.
+         * >0 -> decoder found
+         * <0 -> decoder with codec_id == -found_decoder has not been found
+         */
         int found_decoder;
 
         int64_t last_duration;
diff --git a/libavformat/utils.c b/libavformat/utils.c
index eac71dc..bff961a 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -2623,13 +2623,15 @@ static int try_decode_frame(AVFormatContext *s, AVStream *st, AVPacket *avpkt,
     if (!frame)
         return AVERROR(ENOMEM);
 
-    if (!avcodec_is_open(st->codec) && !st->info->found_decoder) {
+    if (!avcodec_is_open(st->codec) &&
+        st->info->found_decoder <= 0 &&
+        (st->codec->codec_id != -st->info->found_decoder || !st->codec->codec_id)) {
         AVDictionary *thread_opt = NULL;
 
         codec = find_decoder(s, st, st->codec->codec_id);
 
         if (!codec) {
-            st->info->found_decoder = -1;
+            st->info->found_decoder = -st->codec->codec_id;
             ret                     = -1;
             goto fail;
         }
@@ -2641,7 +2643,7 @@ static int try_decode_frame(AVFormatContext *s, AVStream *st, AVPacket *avpkt,
         if (!options)
             av_dict_free(&thread_opt);
         if (ret < 0) {
-            st->info->found_decoder = -1;
+            st->info->found_decoder = -st->codec->codec_id;
             goto fail;
         }
         st->info->found_decoder = 1;



More information about the ffmpeg-cvslog mailing list