aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/utils.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-01-21 01:33:31 +0100
committerMichael Niedermayer <michaelni@gmx.at>2012-01-21 01:33:31 +0100
commit8f0768cc22788357f603695b86f5e9013652bba6 (patch)
treeaece6cab293d489b857d02d206d90e56ace4eade /libavformat/utils.c
parent01084336b7b969e29f163699a8414a84d00295da (diff)
parent23e57d167a87d3a671fe25efb2d5a1cf1719efc6 (diff)
downloadffmpeg-8f0768cc22788357f603695b86f5e9013652bba6.tar.gz
Merge remote-tracking branch 'qatar/master'
* qatar/master: Add a tool that uses avio to read and write, doing a plain copy of data ARM: fix build with FFT enabled and MDCT disabled lavf: force single-threaded decoding in avformat_find_stream_info avidec: migrate last of lavf from FF_ER_* to AV_EF_* avserver: fix build after the next bump. Conflicts: libavformat/Makefile libavformat/avidec.c libavformat/utils.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/utils.c')
-rw-r--r--libavformat/utils.c28
1 files changed, 18 insertions, 10 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 9409ebe671..9e3f775d43 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -2244,10 +2244,18 @@ static int try_decode_frame(AVStream *st, AVPacket *avpkt, AVDictionary **option
AVPacket pkt = *avpkt;
if(!st->codec->codec){
+ AVDictionary *thread_opt = NULL;
+
codec = avcodec_find_decoder(st->codec->codec_id);
if (!codec)
return -1;
- ret = avcodec_open2(st->codec, codec, options);
+
+ /* force thread count to 1 since the h264 decoder will not extract SPS
+ * and PPS to extradata during multi-threaded decoding */
+ av_dict_set(options ? options : &thread_opt, "threads", "1", 0);
+ ret = avcodec_open2(st->codec, codec, options ? options : &thread_opt);
+ if (!options)
+ av_dict_free(&thread_opt);
if (ret < 0)
return ret;
}
@@ -2384,15 +2392,13 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
int i, count, ret, read_size, j;
AVStream *st;
AVPacket pkt1, *pkt;
- AVDictionary *one_thread_opt = NULL;
int64_t old_offset = avio_tell(ic->pb);
int orig_nb_streams = ic->nb_streams; // new streams might appear, no options for those
int flush_codecs = 1;
- av_dict_set(&one_thread_opt, "threads", "1", 0);
-
for(i=0;i<ic->nb_streams;i++) {
AVCodec *codec;
+ AVDictionary *thread_opt = NULL;
st = ic->streams[i];
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO ||
@@ -2412,20 +2418,24 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
assert(!st->codec->codec);
codec = avcodec_find_decoder(st->codec->codec_id);
- if (options)
- av_dict_set(&options[i], "threads", "1", 0);
+ /* force thread count to 1 since the h264 decoder will not extract SPS
+ * and PPS to extradata during multi-threaded decoding */
+ av_dict_set(options ? &options[i] : &thread_opt, "threads", "1", 0);
/* Ensure that subtitle_header is properly set. */
if (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE
&& codec && !st->codec->codec)
- avcodec_open2(st->codec, codec, options ? &options[i] : &one_thread_opt);
+ avcodec_open2(st->codec, codec, options ? &options[i]
+ : &thread_opt);
//try to just open decoders, in case this is enough to get parameters
if(!has_codec_parameters(st->codec)){
if (codec && !st->codec->codec)
avcodec_open2(st->codec, codec, options ? &options[i]
- : &one_thread_opt);
+ : &thread_opt);
}
+ if (!options)
+ av_dict_free(&thread_opt);
}
for (i=0; i<ic->nb_streams; i++) {
@@ -2715,8 +2725,6 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
ic->streams[i]->codec->thread_count = 0;
av_freep(&ic->streams[i]->info);
}
-
- av_dict_free(&one_thread_opt);
return ret;
}