From c61244d24f43b13d75f73ff70c4421a14210ac13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reinhard=20Ni=C3=9Fl?= Date: Mon, 1 Oct 2007 23:28:27 +0200 Subject: 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. --- src/libffmpeg/ff_video_decoder.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) 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; } -- cgit v1.2.3