[FFmpeg-cvslog] av_cpu_count: factorize "detected %d logical cores" message

Michael Niedermayer git at videolan.org
Sun May 26 03:36:36 CEST 2013


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Sun May 26 02:18:38 2013 +0200| [4cf7b87551f2fd2d6f746acda15d33ded192624d] | committer: Michael Niedermayer

av_cpu_count: factorize "detected %d logical cores" message

Also print the message just once

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4cf7b87551f2fd2d6f746acda15d33ded192624d
---

 libavcodec/pthread.c  |    1 -
 libavfilter/pthread.c |    1 -
 libavutil/cpu.c       |    7 +++++++
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/libavcodec/pthread.c b/libavcodec/pthread.c
index 2433880..259dab0 100644
--- a/libavcodec/pthread.c
+++ b/libavcodec/pthread.c
@@ -790,7 +790,6 @@ static int frame_thread_init(AVCodecContext *avctx)
         int nb_cpus = av_cpu_count();
         if ((avctx->debug & (FF_DEBUG_VIS_QP | FF_DEBUG_VIS_MB_TYPE)) || avctx->debug_mv)
             nb_cpus = 1;
-        av_log(avctx, AV_LOG_DEBUG, "detected %d logical cores\n", nb_cpus);
         // 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);
diff --git a/libavfilter/pthread.c b/libavfilter/pthread.c
index 6ceb8e6..0630ad2 100644
--- a/libavfilter/pthread.c
+++ b/libavfilter/pthread.c
@@ -150,7 +150,6 @@ static int thread_init(ThreadContext *c, int nb_threads)
 
     if (!nb_threads) {
         int nb_cpus = av_cpu_count();
-        av_log(c->graph, AV_LOG_DEBUG, "Detected %d logical cores.\n", nb_cpus);
         // use number of cores + 1 as thread count if there is more than one
         if (nb_cpus > 1)
             nb_threads = nb_cpus + 1;
diff --git a/libavutil/cpu.c b/libavutil/cpu.c
index 73d5856..10e15ba 100644
--- a/libavutil/cpu.c
+++ b/libavutil/cpu.c
@@ -198,6 +198,8 @@ int av_parse_cpu_caps(unsigned *flags, const char *s)
 
 int av_cpu_count(void)
 {
+    static volatile int printed;
+
     int ret, nb_cpus = 1;
 #if HAVE_SCHED_GETAFFINITY && defined(CPU_COUNT)
     cpu_set_t cpuset;
@@ -226,6 +228,11 @@ int av_cpu_count(void)
     nb_cpus = sysconf(_SC_NPROCESSORS_ONLN);
 #endif
 
+    if (!printed) {
+        av_log(NULL, AV_LOG_DEBUG, "detected %d logical cores\n", nb_cpus);
+        printed = 1;
+    }
+
     return nb_cpus;
 }
 



More information about the ffmpeg-cvslog mailing list