[FFmpeg-cvslog] r21358 - in trunk: ffmpeg.c ffplay.c libavcodec/beosthread.c libavcodec/os2thread.c libavcodec/pthread.c libavcodec/w32thread.c

mru subversion
Wed Jan 20 23:55:51 CET 2010


Author: mru
Date: Wed Jan 20 23:55:50 2010
New Revision: 21358

Log:
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.

Modified:
   trunk/ffmpeg.c
   trunk/ffplay.c
   trunk/libavcodec/beosthread.c
   trunk/libavcodec/os2thread.c
   trunk/libavcodec/pthread.c
   trunk/libavcodec/w32thread.c

Modified: trunk/ffmpeg.c
==============================================================================
--- trunk/ffmpeg.c	Wed Jan 20 21:58:04 2010	(r21357)
+++ trunk/ffmpeg.c	Wed Jan 20 23:55:50 2010	(r21358)
@@ -2931,7 +2931,6 @@ static void opt_input_file(const char *f
     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(AVFormatCon
     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(AVFormatCon
     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;

Modified: trunk/ffplay.c
==============================================================================
--- trunk/ffplay.c	Wed Jan 20 21:58:04 2010	(r21357)
+++ trunk/ffplay.c	Wed Jan 20 23:55:50 2010	(r21358)
@@ -1722,7 +1722,6 @@ static int stream_component_open(VideoSt
     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);

Modified: trunk/libavcodec/beosthread.c
==============================================================================
--- trunk/libavcodec/beosthread.c	Wed Jan 20 21:58:04 2010	(r21357)
+++ trunk/libavcodec/beosthread.c	Wed Jan 20 23:55:50 2010	(r21358)
@@ -123,6 +123,9 @@ int avcodec_thread_init(AVCodecContext *
 
     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;

Modified: trunk/libavcodec/os2thread.c
==============================================================================
--- trunk/libavcodec/os2thread.c	Wed Jan 20 21:58:04 2010	(r21357)
+++ trunk/libavcodec/os2thread.c	Wed Jan 20 23:55:50 2010	(r21358)
@@ -116,6 +116,9 @@ int avcodec_thread_init(AVCodecContext *
 
     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;

Modified: trunk/libavcodec/pthread.c
==============================================================================
--- trunk/libavcodec/pthread.c	Wed Jan 20 21:58:04 2010	(r21357)
+++ trunk/libavcodec/pthread.c	Wed Jan 20 23:55:50 2010	(r21358)
@@ -145,6 +145,11 @@ int avcodec_thread_init(AVCodecContext *
     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->thread_opaque = c;
-    avctx->thread_count = thread_count;
     c->current_job = 0;
     c->job_count = 0;
     c->job_size = 0;

Modified: trunk/libavcodec/w32thread.c
==============================================================================
--- trunk/libavcodec/w32thread.c	Wed Jan 20 21:58:04 2010	(r21357)
+++ trunk/libavcodec/w32thread.c	Wed Jan 20 23:55:50 2010	(r21358)
@@ -131,6 +131,9 @@ int avcodec_thread_init(AVCodecContext *
 
     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;



More information about the ffmpeg-cvslog mailing list