lavf: force threads to 1 in avformat_find_stream_info()
authorAnton Khirnov <anton@khirnov.net>
Tue, 6 Dec 2011 06:51:54 +0000 (07:51 +0100)
committerAnton Khirnov <anton@khirnov.net>
Sun, 18 Dec 2011 16:36:56 +0000 (17:36 +0100)
Fixes avformat_find_stream_info() on streams with number of frames <
thread count.

libavformat/utils.c

index f424285..bc5b7e0 100644 (file)
@@ -2291,6 +2291,11 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
         assert(!st->codec->codec);
         codec = avcodec_find_decoder(st->codec->codec_id);
 
         assert(!st->codec->codec);
         codec = avcodec_find_decoder(st->codec->codec_id);
 
+        /* this function doesn't flush the decoders, so force thread count
+         * to 1 to fix behavior when thread count > number of frames in the file */
+        if (options)
+            av_dict_set(&options[i], "threads", "1", 0);
+
         /* Ensure that subtitle_header is properly set. */
         if (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE
             && codec && !st->codec->codec)
         /* Ensure that subtitle_header is properly set. */
         if (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE
             && codec && !st->codec->codec)