Browse code

threads: allow thread count of zero

This moves setting the thread count to a minimum of 1 to
frame_thread_init(), allowing a value of zero to propagate
through to the codec if frame threading is not used. This
makes auto-threads work in libx264.

Signed-off-by: Mans Rullgard <mans@mansr.com>
(cherry picked from commit ff1efc524cb3c60f2f746e3b4550bb1a86c65316)

Mans Rullgard authored on 2011/03/02 22:08:15
Showing 1 changed files
... ...
@@ -683,6 +683,11 @@ static int frame_thread_init(AVCodecContext *avctx)
683 683
     FrameThreadContext *fctx;
684 684
     int i, err = 0;
685 685
 
686
+    if (thread_count <= 1) {
687
+        avctx->active_thread_type = 0;
688
+        return 0;
689
+    }
690
+
686 691
     avctx->thread_opaque = fctx = av_mallocz(sizeof(FrameThreadContext));
687 692
 
688 693
     fctx->threads = av_mallocz(sizeof(PerThreadContext) * thread_count);
... ...
@@ -882,8 +887,6 @@ int ff_thread_init(AVCodecContext *avctx, int thread_count)
882 882
         return -1;
883 883
     }
884 884
 
885
-    avctx->thread_count = FFMAX(1, thread_count);
886
-
887 885
     if (avctx->codec) {
888 886
         validate_thread_parameters(avctx);
889 887