Options are consumed in avcodec_open2, so the option to enforce single
threaded decoding has to be set for every stream.
---
libavformat/utils.c | 14 +++++++++-----
1 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 163d602..54af0fc 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -2272,10 +2272,6 @@ int avformat_find_stream_info(AVFormatContext *ic,
AVDictionary **options)
int64_t old_offset = avio_tell(ic->pb);
int orig_nb_streams = ic->nb_streams; // new streams might appear,
no options for those
- /* 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 */
- av_dict_set(&one_thread_opt, "threads", "1", 0);
-
for(i=0;i<ic->nb_streams;i++) {
AVCodec *codec;
st = ic->streams[i];
@@ -2301,6 +2297,8 @@ int avformat_find_stream_info(AVFormatContext *ic,
AVDictionary **options)
* to 1 to fix behavior when thread count > number of frames in the
file */
if (options)
av_dict_set(&options[i], "threads", "1", 0);
+ else
+ av_dict_set(&one_thread_opt, "threads", "1", 0);
/* Ensure that subtitle_header is properly set. */
if (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE
@@ -2450,7 +2448,13 @@ int avformat_find_stream_info(AVFormatContext *ic,
AVDictionary **options)
least one frame of codec data, this makes sure the codec initializes
the channel configuration and does not only trust the values from
the container.
*/
- try_decode_frame(st, pkt, (options && i < orig_nb_streams )?
&options[i]
+
+ /* 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 && i < orig_nb_streams))
+ av_dict_set(&one_thread_opt, "threads", "1", 0);
+
+ try_decode_frame(st, pkt, (options && i < orig_nb_streams) ?
&options[i]
: &one_thread_opt);
st->codec_info_nb_frames++;
--
1.7.8.1
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel