OSDN Git Service

threads: make get_logical_cpus() available outside pthread.c
authorMichael Niedermayer <michaelni@gmx.at>
Thu, 14 Jun 2012 19:11:05 +0000 (21:11 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Fri, 22 Jun 2012 23:38:47 +0000 (01:38 +0200)
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavcodec/internal.h
libavcodec/pthread.c

index 8f00695..198483a 100644 (file)
@@ -167,4 +167,6 @@ static av_always_inline int64_t ff_samples_to_time_base(AVCodecContext *avctx,
 
 int ff_thread_can_start_frame(AVCodecContext *avctx);
 
+int ff_get_logical_cpus(AVCodecContext *avctx);
+
 #endif /* AVCODEC_INTERNAL_H */
index 4d84d4c..7f2ea09 100644 (file)
@@ -160,7 +160,7 @@ typedef struct FrameThreadContext {
  * limit the number of threads to 16 for automatic detection */
 #define MAX_AUTO_THREADS 16
 
-static int get_logical_cpus(AVCodecContext *avctx)
+int ff_get_logical_cpus(AVCodecContext *avctx)
 {
     int ret, nb_cpus = 1;
 #if HAVE_SCHED_GETAFFINITY && defined(CPU_COUNT)
@@ -303,7 +303,7 @@ static int thread_init(AVCodecContext *avctx)
     int thread_count = avctx->thread_count;
 
     if (!thread_count) {
-        int nb_cpus = get_logical_cpus(avctx);
+        int nb_cpus = ff_get_logical_cpus(avctx);
         // use number of cores + 1 as thread count if there is more than one
         if (nb_cpus > 1)
             thread_count = avctx->thread_count = FFMIN(nb_cpus + 1, MAX_AUTO_THREADS);
@@ -799,7 +799,7 @@ static int frame_thread_init(AVCodecContext *avctx)
     int i, err = 0;
 
     if (!thread_count) {
-        int nb_cpus = get_logical_cpus(avctx);
+        int nb_cpus = ff_get_logical_cpus(avctx);
         if ((avctx->debug & (FF_DEBUG_VIS_QP | FF_DEBUG_VIS_MB_TYPE)) || avctx->debug_mv)
             nb_cpus = 1;
         // use number of cores + 1 as thread count if there is more than one