summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJanne Grunau <janne-libav@jannau.net>2012-01-01 14:21:50 +0100
committerJanne Grunau <janne-libav@jannau.net>2012-01-01 14:37:37 +0100
commitb4d44a45f9aa43bd2e5bddde33e3b37802607b0a (patch)
tree607eb03dedfb5ce9249e3094cd3a9d3f46524852
parentfebd022228660cb4b4d0e7b108bfec339b7dce92 (diff)
downloadffmpeg-streaming-b4d44a45f9aa43bd2e5bddde33e3b37802607b0a.zip
ffmpeg-streaming-b4d44a45f9aa43bd2e5bddde33e3b37802607b0a.tar.gz
threads: introduce CODEC_CAP_AUTO_THREADS and add it to libx264
Some external codecs have their own code to determine the best number of threads. This number is not necessary the number of cpu cores. Thread_count will be only 0 if the codec has CODEC_CAP_AUTO_THREADS.
-rw-r--r--libavcodec/avcodec.h4
-rw-r--r--libavcodec/libx264.c2
-rw-r--r--libavcodec/pthread.c3
-rw-r--r--libavcodec/version.h2
4 files changed, 9 insertions, 2 deletions
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 4f24f72..b139a8a 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -777,6 +777,10 @@ typedef struct RcOverride{
* Codec supports changed parameters at any point.
*/
#define CODEC_CAP_PARAM_CHANGE 0x4000
+/**
+ * Codec supports avctx->thread_count == 0 (auto).
+ */
+#define CODEC_CAP_AUTO_THREADS 0x8000
//The following defines may change, don't expect compatibility if you use them.
#define MB_TYPE_INTRA4x4 0x0001
diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index c525808..9b34795 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -592,7 +592,7 @@ AVCodec ff_libx264_encoder = {
.init = X264_init,
.encode = X264_frame,
.close = X264_close,
- .capabilities = CODEC_CAP_DELAY,
+ .capabilities = CODEC_CAP_DELAY | CODEC_CAP_AUTO_THREADS,
.long_name = NULL_IF_CONFIG_SMALL("libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10"),
.priv_class = &class,
.defaults = x264_defaults,
diff --git a/libavcodec/pthread.c b/libavcodec/pthread.c
index 400abf4..54a0eb3 100644
--- a/libavcodec/pthread.c
+++ b/libavcodec/pthread.c
@@ -982,6 +982,9 @@ static void validate_thread_parameters(AVCodecContext *avctx)
} else if (avctx->codec->capabilities & CODEC_CAP_SLICE_THREADS &&
avctx->thread_type & FF_THREAD_SLICE) {
avctx->active_thread_type = FF_THREAD_SLICE;
+ } else if (!(avctx->codec->capabilities & CODEC_CAP_AUTO_THREADS)) {
+ avctx->thread_count = 1;
+ avctx->active_thread_type = 0;
}
}
diff --git a/libavcodec/version.h b/libavcodec/version.h
index e6226cb..1317ef0 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -22,7 +22,7 @@
#define LIBAVCODEC_VERSION_MAJOR 53
#define LIBAVCODEC_VERSION_MINOR 32
-#define LIBAVCODEC_VERSION_MICRO 1
+#define LIBAVCODEC_VERSION_MICRO 2
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \
OpenPOWER on IntegriCloud