summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-03-05 12:55:36 +0100
committerDiogo Franco (Kovensky) <diogomfranco@gmail.com>2015-03-11 12:31:16 +0900
commitdc29a21b5c61ed7316766176476455309492b0c9 (patch)
tree93d5a86a05ef79ec173c7245c41b392c60cf49fa
parent4d87844508943aa18b58bd00971291f4eb65fee7 (diff)
downloadmpv-dc29a21b5c61ed7316766176476455309492b0c9.tar.bz2
mpv-dc29a21b5c61ed7316766176476455309492b0c9.tar.xz
vd_lavc: request 1 more threads than CPU cores
This duplicates the logic which FFmpeg's libavcodec uses. The effects are unknown, though it's somewhat clear that a single thread doesn't necessarily saturate a single CPU. (Eventually we should just let FFmpeg auto-init the thread count, but for now I prefer it this way, so e.g. verbose mode will print the thread count.) (cherry picked from commit 9657e5a2caef74de799fab0b9920284660865da9)
-rw-r--r--common/av_common.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/common/av_common.c b/common/av_common.c
index bc2845d4d4..05c694702d 100644
--- a/common/av_common.c
+++ b/common/av_common.c
@@ -135,6 +135,8 @@ void mp_set_avcodec_threads(struct mp_log *l, AVCodecContext *avctx, int threads
threads = 1;
} else {
mp_verbose(l, "Detected %d logical cores.\n", threads);
+ if (threads > 1)
+ threads += 1; // extra thread for better load balancing
}
// Apparently some libavcodec versions have or had trouble with more
// than 16 threads, and/or print a warning when using > 16.