[FFmpeg-devel] Regression: r20954-5 broke threads auto in libx264
Måns Rullgård
mans
Wed Jan 20 22:38:58 CET 2010
Jason Garrett-Glaser <darkshikari at gmail.com> writes:
> -threads 0 now no longer works to specify auto threads in libx264. We
> have received a ton of complaints from users already about ffmpeg
> performance going down massively in the past few weeks.
>
> This is a serious regression.
>
> If nobody can come up with a reasonable fix for this in the next day
> or two, I will disconnect the threads option in libx264.c, forcing it
> to auto in all cases.
Something like this perhaps?
diff --git a/ffmpeg.c b/ffmpeg.c
index 4b956ba..5ab7f7c 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -2931,7 +2931,6 @@ static void opt_input_file(const char *filename)
for(i=0;i<ic->nb_streams;i++) {
AVStream *st = ic->streams[i];
AVCodecContext *enc = st->codec;
- if(thread_count>1)
avcodec_thread_init(enc, thread_count);
switch(enc->codec_type) {
case CODEC_TYPE_AUDIO:
@@ -3066,7 +3065,6 @@ static void new_video_stream(AVFormatContext *oc)
bitstream_filters[nb_output_files][oc->nb_streams - 1]= video_bitstream_filters;
video_bitstream_filters= NULL;
- if(thread_count>1)
avcodec_thread_init(st->codec, thread_count);
video_enc = st->codec;
@@ -3212,7 +3210,6 @@ static void new_audio_stream(AVFormatContext *oc)
bitstream_filters[nb_output_files][oc->nb_streams - 1]= audio_bitstream_filters;
audio_bitstream_filters= NULL;
- if(thread_count>1)
avcodec_thread_init(st->codec, thread_count);
audio_enc = st->codec;
diff --git a/libavcodec/pthread.c b/libavcodec/pthread.c
index 556e546..60c82cd 100644
--- a/libavcodec/pthread.c
+++ b/libavcodec/pthread.c
@@ -145,6 +145,11 @@ int avcodec_thread_init(AVCodecContext *avctx, int thread_count)
int i;
ThreadContext *c;
+ avctx->thread_count = thread_count;
+
+ if (thread_count <= 1)
+ return 0;
+
c = av_mallocz(sizeof(ThreadContext));
if (!c)
return -1;
@@ -156,7 +161,6 @@ int avcodec_thread_init(AVCodecContext *avctx, int thread_count)
}
avctx->thread_opaque = c;
- avctx->thread_count = thread_count;
c->current_job = 0;
c->job_count = 0;
c->job_size = 0;
--
M?ns Rullg?rd
mans at mansr.com
More information about the ffmpeg-devel
mailing list