From 93e8da81f50c7c3d5c5d24fb997ec8ff067084dd Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Wed, 21 Dec 2011 21:23:21 +0100 Subject: Fix multithreaded initialization with API change thread count needs to be set before avcodec_open otherwise it will be stuck with a single thread at least for h264 (might also want to use avcodec_open2 instead?) --- src/combined/ffmpeg/ff_video_decoder.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/combined/ffmpeg/ff_video_decoder.c b/src/combined/ffmpeg/ff_video_decoder.c index 2ec18c55f..379732a82 100644 --- a/src/combined/ffmpeg/ff_video_decoder.c +++ b/src/combined/ffmpeg/ff_video_decoder.c @@ -329,6 +329,13 @@ static void init_video_codec (ff_video_decoder_t *this, unsigned int codec_type) if (this->class->choose_speed_over_accuracy) this->context->flags2 |= CODEC_FLAG2_FAST; +#ifdef DEPRECATED_AVCODEC_THREAD_INIT + if (this->class->thread_count > 1) { + if (this->codec->id != CODEC_ID_SVQ3) + this->context->thread_count = this->class->thread_count; + } +#endif + pthread_mutex_lock(&ffmpeg_lock); if (avcodec_open (this->context, this->codec) < 0) { pthread_mutex_unlock(&ffmpeg_lock); @@ -356,14 +363,13 @@ static void init_video_codec (ff_video_decoder_t *this, unsigned int codec_type) } } +#ifndef DEPRECATED_AVCODEC_THREAD_INIT if (this->class->thread_count > 1) { if (this->codec->id != CODEC_ID_SVQ3 -#ifndef DEPRECATED_AVCODEC_THREAD_INIT - && avcodec_thread_init(this->context, this->class->thread_count) != -1 -#endif - ) + && avcodec_thread_init(this->context, this->class->thread_count) != -1) this->context->thread_count = this->class->thread_count; } +#endif this->context->skip_loop_filter = skip_loop_filter_enum_values[this->class->skip_loop_filter_enum]; -- cgit v1.2.3