summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReinhard Nißl <rnissl@gmx.de>2007-10-01 23:28:27 +0200
committerReinhard Nißl <rnissl@gmx.de>2007-10-01 23:28:27 +0200
commitc61244d24f43b13d75f73ff70c4421a14210ac13 (patch)
tree49f02293e1f8d9ba1cd7cd2703cb2a6e61926746
parent0c5696d523a43a5161134c354d6bfb21bb29bae6 (diff)
downloadxine-lib-c61244d24f43b13d75f73ff70c4421a14210ac13.tar.gz
xine-lib-c61244d24f43b13d75f73ff70c4421a14210ac13.tar.bz2
Add UI option to configure FFmpeg's video decoder thread count.
External FFmpeg has recently gained multithreaded H.264 decoding and to make use of this feature, it is necessary to inform FFmpeg about the maximum number of threads it may use for decoding.
-rw-r--r--src/libffmpeg/ff_video_decoder.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/libffmpeg/ff_video_decoder.c b/src/libffmpeg/ff_video_decoder.c
index 077ff2fad..9ab4f9daf 100644
--- a/src/libffmpeg/ff_video_decoder.c
+++ b/src/libffmpeg/ff_video_decoder.c
@@ -67,6 +67,7 @@ typedef struct ff_video_class_s {
video_decoder_class_t decoder_class;
int pp_quality;
+ int thread_count;
xine_t *xine;
} ff_video_class_t;
@@ -368,6 +369,12 @@ static void init_video_codec (ff_video_decoder_t *this, unsigned int codec_type)
_x_stream_info_set(this->stream, XINE_STREAM_INFO_VIDEO_HANDLED, 0);
return;
}
+
+ if (this->class->thread_count > 1) {
+ avcodec_thread_init(this->context, this->class->thread_count);
+ this->context->thread_count = this->class->thread_count;
+ }
+
pthread_mutex_unlock(&ffmpeg_lock);
lprintf("lavc decoder opened\n");
@@ -422,6 +429,12 @@ static void init_video_codec (ff_video_decoder_t *this, unsigned int codec_type)
}
+static void thread_count_cb(void *user_data, xine_cfg_entry_t *entry) {
+ ff_video_class_t *class = (ff_video_class_t *) user_data;
+
+ class->thread_count = entry->num_value;
+}
+
static void pp_quality_cb(void *user_data, xine_cfg_entry_t *entry) {
ff_video_class_t *class = (ff_video_class_t *) user_data;
@@ -1530,6 +1543,15 @@ void *init_video_plugin (xine_t *xine, void *data) {
"too much."),
10, pp_quality_cb, this);
+ this->thread_count = xine->config->register_num(config, "video.processing.ffmpeg_thread_count", 1,
+ _("FFmpeg video decoding thread count"),
+ _("You can adjust the number of video decoding threads which FFmpeg may use.\n"
+ "Higher values should speed up decoding but it depends on the codec used "
+ "whether parallel decoding is supported. A rule of thumb is to have one "
+ "decoding thread per logical CPU (typically 1 to 4). A change will take "
+ "effect with playing the next stream."),
+ 10, thread_count_cb, this);
+
return this;
}