aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMåns Rullgård <mans@mansr.com>2010-01-20 22:55:50 +0000
committerMåns Rullgård <mans@mansr.com>2010-01-20 22:55:50 +0000
commit68cf92ee5e08331d6237a836adc74b4007fab4e9 (patch)
tree940d14641a23b82d9953953457338b1e9d2e11eb
parent5fcb865b7525f4ba6d601008bc6a2fb28be5af1e (diff)
downloadffmpeg-68cf92ee5e08331d6237a836adc74b4007fab4e9.tar.gz
Always call avcodec_thread_init()
The various avcodec_thread_init() functions are updated to return immediately after setting avctx->thread_count. This allows -threads 0 to pass through to codecs. It also simplifies the usage for apps using libavcodec. Originally committed as revision 21358 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r--ffmpeg.c3
-rw-r--r--ffplay.c1
-rw-r--r--libavcodec/beosthread.c3
-rw-r--r--libavcodec/os2thread.c3
-rw-r--r--libavcodec/pthread.c6
-rw-r--r--libavcodec/w32thread.c3
6 files changed, 14 insertions, 5 deletions
diff --git a/ffmpeg.c b/ffmpeg.c
index 4b956ba71d..5ab7f7c471 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/ffplay.c b/ffplay.c
index dc83031661..88b10e8c09 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -1722,7 +1722,6 @@ static int stream_component_open(VideoState *is, int stream_index)
enc->skip_loop_filter= skip_loop_filter;
enc->error_recognition= error_recognition;
enc->error_concealment= error_concealment;
- if (thread_count > 1)
avcodec_thread_init(enc, thread_count);
set_context_opts(enc, avcodec_opts[enc->codec_type], 0);
diff --git a/libavcodec/beosthread.c b/libavcodec/beosthread.c
index e2fd97777d..290e48c93f 100644
--- a/libavcodec/beosthread.c
+++ b/libavcodec/beosthread.c
@@ -123,6 +123,9 @@ int avcodec_thread_init(AVCodecContext *s, int thread_count){
s->thread_count= thread_count;
+ if (thread_count <= 1)
+ return 0;
+
assert(!s->thread_opaque);
c= av_mallocz(sizeof(ThreadContext)*thread_count);
s->thread_opaque= c;
diff --git a/libavcodec/os2thread.c b/libavcodec/os2thread.c
index edebc9a6c8..76dc0d56bc 100644
--- a/libavcodec/os2thread.c
+++ b/libavcodec/os2thread.c
@@ -116,6 +116,9 @@ int avcodec_thread_init(AVCodecContext *s, int thread_count){
s->thread_count= thread_count;
+ if (thread_count <= 1)
+ return 0;
+
assert(!s->thread_opaque);
c= av_mallocz(sizeof(ThreadContext)*thread_count);
s->thread_opaque= c;
diff --git a/libavcodec/pthread.c b/libavcodec/pthread.c
index 556e546188..60c82cd715 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;
diff --git a/libavcodec/w32thread.c b/libavcodec/w32thread.c
index bae09704a8..4b8145729e 100644
--- a/libavcodec/w32thread.c
+++ b/libavcodec/w32thread.c
@@ -131,6 +131,9 @@ int avcodec_thread_init(AVCodecContext *s, int thread_count){
s->thread_count= thread_count;
+ if (thread_count <= 1)
+ return 0;
+
assert(!s->thread_opaque);
c= av_mallocz(sizeof(ThreadContext)*thread_count);
s->thread_opaque= c;